@scalemule/sdk 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +99 -1
- package/dist/index.d.ts +99 -1
- package/dist/index.js +228 -13
- package/dist/index.mjs +217 -13
- package/package.json +3 -6
package/dist/index.d.mts
CHANGED
|
@@ -104,6 +104,8 @@ interface StorageAdapter {
|
|
|
104
104
|
interface ScaleMuleConfig {
|
|
105
105
|
/** API key (publishable key for browser, secret key for server) */
|
|
106
106
|
apiKey: string;
|
|
107
|
+
/** Application ID — required for realtime features (WebSocket auth, notifications) */
|
|
108
|
+
applicationId?: string;
|
|
107
109
|
/** Base URL for API requests. Overrides environment preset. */
|
|
108
110
|
baseUrl?: string;
|
|
109
111
|
/** Environment preset ('dev' or 'prod'). Defaults to 'prod'. */
|
|
@@ -250,6 +252,7 @@ declare function buildClientContextHeaders(context: ClientContext | undefined):
|
|
|
250
252
|
|
|
251
253
|
declare class ScaleMuleClient {
|
|
252
254
|
private apiKey;
|
|
255
|
+
private applicationId;
|
|
253
256
|
private baseUrl;
|
|
254
257
|
private debug;
|
|
255
258
|
private storage;
|
|
@@ -271,6 +274,7 @@ declare class ScaleMuleClient {
|
|
|
271
274
|
setAccessToken(token: string): void;
|
|
272
275
|
clearAccessToken(): void;
|
|
273
276
|
getSessionToken(): string | null;
|
|
277
|
+
getApplicationId(): string | null;
|
|
274
278
|
getUserId(): string | null;
|
|
275
279
|
isAuthenticated(): boolean;
|
|
276
280
|
getAnonymousId(): string | null;
|
|
@@ -2771,6 +2775,88 @@ declare class CommunicationService extends ServiceModule {
|
|
|
2771
2775
|
}): Promise<ApiResponse<MessageStatus>>;
|
|
2772
2776
|
}
|
|
2773
2777
|
|
|
2778
|
+
/**
|
|
2779
|
+
* Notifications Service
|
|
2780
|
+
*
|
|
2781
|
+
* In-app notification management — list, read, dismiss.
|
|
2782
|
+
* Notifications are created server-side by the notification pipeline
|
|
2783
|
+
* and delivered in real-time via WebSocket or fetched via these endpoints.
|
|
2784
|
+
*/
|
|
2785
|
+
|
|
2786
|
+
interface Notification {
|
|
2787
|
+
id: string;
|
|
2788
|
+
kind: string;
|
|
2789
|
+
title: string;
|
|
2790
|
+
body: string;
|
|
2791
|
+
icon_url?: string;
|
|
2792
|
+
action_url?: string;
|
|
2793
|
+
data: unknown;
|
|
2794
|
+
priority: 'high' | 'normal' | 'low';
|
|
2795
|
+
is_read: boolean;
|
|
2796
|
+
read_at?: string;
|
|
2797
|
+
created_at: string;
|
|
2798
|
+
}
|
|
2799
|
+
interface NotificationListResponse {
|
|
2800
|
+
notifications: Notification[];
|
|
2801
|
+
has_more: boolean;
|
|
2802
|
+
}
|
|
2803
|
+
interface UnreadCountResponse {
|
|
2804
|
+
count: number;
|
|
2805
|
+
}
|
|
2806
|
+
interface ListNotificationsParams {
|
|
2807
|
+
/** Only return unread notifications */
|
|
2808
|
+
unread_only?: boolean;
|
|
2809
|
+
/** Filter by notification kind (e.g., 'video.ready') */
|
|
2810
|
+
kind?: string;
|
|
2811
|
+
/** ISO 8601 timestamp — return notifications created after this time */
|
|
2812
|
+
since?: string;
|
|
2813
|
+
/** Max results per page (default: 20, max: 100) */
|
|
2814
|
+
limit?: number;
|
|
2815
|
+
/** Cursor for pagination (created_at of last item) */
|
|
2816
|
+
cursor?: string;
|
|
2817
|
+
}
|
|
2818
|
+
declare class NotificationsService extends ServiceModule {
|
|
2819
|
+
protected basePath: string;
|
|
2820
|
+
/**
|
|
2821
|
+
* List notifications for the authenticated user.
|
|
2822
|
+
*
|
|
2823
|
+
* @example
|
|
2824
|
+
* ```ts
|
|
2825
|
+
* // All unread
|
|
2826
|
+
* const { data } = await sm.notifications.list({ unread_only: true })
|
|
2827
|
+
*
|
|
2828
|
+
* // With pagination
|
|
2829
|
+
* const { data } = await sm.notifications.list({ limit: 10, cursor: lastCreatedAt })
|
|
2830
|
+
*
|
|
2831
|
+
* // Since last seen (reconnect catch-up)
|
|
2832
|
+
* const { data } = await sm.notifications.list({ unread_only: true, since: '2026-03-25T00:00:00Z' })
|
|
2833
|
+
* ```
|
|
2834
|
+
*/
|
|
2835
|
+
list(params?: ListNotificationsParams, options?: RequestOptions): Promise<ApiResponse<NotificationListResponse>>;
|
|
2836
|
+
/**
|
|
2837
|
+
* Get the count of unread notifications.
|
|
2838
|
+
*
|
|
2839
|
+
* @example
|
|
2840
|
+
* ```ts
|
|
2841
|
+
* const { data } = await sm.notifications.unreadCount()
|
|
2842
|
+
* console.log(`${data.count} unread`)
|
|
2843
|
+
* ```
|
|
2844
|
+
*/
|
|
2845
|
+
unreadCount(options?: RequestOptions): Promise<ApiResponse<UnreadCountResponse>>;
|
|
2846
|
+
/**
|
|
2847
|
+
* Mark a single notification as read.
|
|
2848
|
+
*/
|
|
2849
|
+
markRead(id: string, options?: RequestOptions): Promise<ApiResponse<void>>;
|
|
2850
|
+
/**
|
|
2851
|
+
* Mark all notifications as read.
|
|
2852
|
+
*/
|
|
2853
|
+
markAllRead(options?: RequestOptions): Promise<ApiResponse<void>>;
|
|
2854
|
+
/**
|
|
2855
|
+
* Dismiss a notification (soft delete).
|
|
2856
|
+
*/
|
|
2857
|
+
dismiss(id: string, options?: RequestOptions): Promise<ApiResponse<void>>;
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2774
2860
|
/**
|
|
2775
2861
|
* WebPushManager — Browser push notification subscription manager
|
|
2776
2862
|
*
|
|
@@ -4866,6 +4952,10 @@ interface Task {
|
|
|
4866
4952
|
metadata?: Record<string, unknown>;
|
|
4867
4953
|
created_at: string;
|
|
4868
4954
|
updated_at: string;
|
|
4955
|
+
pipeline_id?: string;
|
|
4956
|
+
pipeline_version?: number;
|
|
4957
|
+
current_phase?: string;
|
|
4958
|
+
phase_entered_at?: string;
|
|
4869
4959
|
}
|
|
4870
4960
|
interface ClaimResult {
|
|
4871
4961
|
task_id: string;
|
|
@@ -4989,6 +5079,7 @@ declare class AgentProjectsService extends ServiceModule {
|
|
|
4989
5079
|
priority?: string;
|
|
4990
5080
|
due_date?: string;
|
|
4991
5081
|
metadata?: Record<string, unknown>;
|
|
5082
|
+
pipeline_id?: string;
|
|
4992
5083
|
}, applicationId?: string, options?: RequestOptions): Promise<ApiResponse<Task>>;
|
|
4993
5084
|
listTasks(projectId: string, params?: PaginationParams & {
|
|
4994
5085
|
application_id?: string;
|
|
@@ -5012,6 +5103,10 @@ declare class AgentProjectsService extends ServiceModule {
|
|
|
5012
5103
|
heartbeat(taskId: string, agentId: string, applicationId?: string, options?: RequestOptions): Promise<ApiResponse<{
|
|
5013
5104
|
lease_expires_at: string;
|
|
5014
5105
|
}>>;
|
|
5106
|
+
startTask(taskId: string, agentId: string, applicationId?: string, options?: RequestOptions): Promise<ApiResponse<{
|
|
5107
|
+
task_id: string;
|
|
5108
|
+
status: string;
|
|
5109
|
+
}>>;
|
|
5015
5110
|
submit(taskId: string, data: {
|
|
5016
5111
|
agent_id: string;
|
|
5017
5112
|
idempotency_key: string;
|
|
@@ -5455,6 +5550,7 @@ declare class ScaleMule {
|
|
|
5455
5550
|
readonly analytics: AnalyticsService;
|
|
5456
5551
|
readonly flags: FlagsService;
|
|
5457
5552
|
readonly communication: CommunicationService;
|
|
5553
|
+
readonly notifications: NotificationsService;
|
|
5458
5554
|
readonly scheduler: SchedulerService;
|
|
5459
5555
|
readonly permissions: PermissionsService;
|
|
5460
5556
|
readonly workspaces: WorkspacesService;
|
|
@@ -5520,6 +5616,8 @@ declare class ScaleMule {
|
|
|
5520
5616
|
clearAllAccounts(): Promise<void>;
|
|
5521
5617
|
/** The base URL being used for API requests. */
|
|
5522
5618
|
getBaseUrl(): string;
|
|
5619
|
+
/** The application ID, or null if not configured. */
|
|
5620
|
+
getApplicationId(): string | null;
|
|
5523
5621
|
/** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
|
|
5524
5622
|
setWorkspaceContext(id: string | null): void;
|
|
5525
5623
|
/** Get the current workspace ID, or null. */
|
|
@@ -5528,4 +5626,4 @@ declare class ScaleMule {
|
|
|
5528
5626
|
getClient(): ScaleMuleClient;
|
|
5529
5627
|
}
|
|
5530
5628
|
|
|
5531
|
-
export { type AccountBalance, AccountsService, type ActiveUsers, type ActivityItem, AgentAuthService, AgentModelsService, type AgentProfile, AgentProjectsService, type AgentResponse, type AgentSecurityPolicy, AgentSessionsService, type AgentSigningKey, type AgentToken, type AgentToolEntitlement, AgentToolsService, type Workspace as AgentWorkspace, AgentsService, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type Attachment, type Attendee, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateFlagRequest, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, type FlagAuditEntry, type FlagCheck, type FlagCondition, FlagContentService, type FlagDefinition, type FlagDetail, type FlagEnvironment, type FlagEvaluation, type FlagSegment, type FlagVariant, FlagsService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type Leaderboard, type LeaderboardEntry, LeaderboardService, type Like, type Listing, ListingsService, type LogEntry, type LogInput, type LogQueryParams, type LogQueryResponse, type LogRecord, LoggerService, type LoginActivitySummary, type LoginDeviceInfo, type LoginHistoryEntry, type LoginRiskInfo, type MessageCallback, type MessageStatus, type MetricDataPoint, type MfaStatus, type Model, type ModelEntitlement, type ModelPricing, type ModelProvider, type UsageSummary as ModelUsageSummary, type MultipartCompleteResponse, type MultipartConfig, type MultipartPartUrl, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, type PartResult, type PartUrl, type Participant, type Payment, type PaymentListParams, type PaymentMethod, type PaymentStatusResponse, type Payout, type PayoutSchedule, type PermissionCheck, type PermissionMatrix, PermissionsService, type PhotoInfo, PhotoService, type Pipeline, type PipelineVersion, type Policy, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type Project, type ProjectDocument, type ProjectGrant, type ProjectMember, type PushApiFetcher, type PushPreferences, type PushSettings, type PushSubscriptionInfo, type PushToken, type PushTokenAssociationResult, type PushTopic, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type RedeemResult, type ReferralAnalytics, type ReferralCampaign, type ReferralProfile, type ReferralStats, ReferralsService, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterPushTokenData, type RequestOptions, type ResolvedReferral, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, type S3MultipartOptions, type S3MultipartResult, type S3SingleUploadOptions, type S3SingleUploadResult, type S3UploadProgress, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type SecurityLayers, type ServerlessFunction, type ServiceHealth, ServiceModule, type Session, type SessionArtifact, type SessionInfo, type SessionLog, type SessionPoolEntry, type Severity, type ShareLink, type ShortestPathResult, type SignedUrlResponse, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, type SubmitResult, type Subscription, type TargetingRule, type Task, type TaskAttempt, type TaskTransition, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type Tool, type ToolCapability, type ToolIntegration, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type UpdateFlagRequest, type UpdateRuleRequest, type UpdateSegmentRequest, type UpdateVariantRequest, type UploadCompleteResponse, type UploadEngineConfig, type UploadFailureReport, type UploadFailureReportResponse, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UpsertEnvironmentRequest, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
|
|
5629
|
+
export { type AccountBalance, AccountsService, type ActiveUsers, type ActivityItem, AgentAuthService, AgentModelsService, type AgentProfile, AgentProjectsService, type AgentResponse, type AgentSecurityPolicy, AgentSessionsService, type AgentSigningKey, type AgentToken, type AgentToolEntitlement, AgentToolsService, type Workspace as AgentWorkspace, AgentsService, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type Attachment, type Attendee, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateFlagRequest, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, type FlagAuditEntry, type FlagCheck, type FlagCondition, FlagContentService, type FlagDefinition, type FlagDetail, type FlagEnvironment, type FlagEvaluation, type FlagSegment, type FlagVariant, FlagsService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type Leaderboard, type LeaderboardEntry, LeaderboardService, type Like, type ListNotificationsParams, type Listing, ListingsService, type LogEntry, type LogInput, type LogQueryParams, type LogQueryResponse, type LogRecord, LoggerService, type LoginActivitySummary, type LoginDeviceInfo, type LoginHistoryEntry, type LoginRiskInfo, type MessageCallback, type MessageStatus, type MetricDataPoint, type MfaStatus, type Model, type ModelEntitlement, type ModelPricing, type ModelProvider, type UsageSummary as ModelUsageSummary, type MultipartCompleteResponse, type MultipartConfig, type MultipartPartUrl, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type Notification, type NotificationListResponse, NotificationsService, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, type PartResult, type PartUrl, type Participant, type Payment, type PaymentListParams, type PaymentMethod, type PaymentStatusResponse, type Payout, type PayoutSchedule, type PermissionCheck, type PermissionMatrix, PermissionsService, type PhotoInfo, PhotoService, type Pipeline, type PipelineVersion, type Policy, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type Project, type ProjectDocument, type ProjectGrant, type ProjectMember, type PushApiFetcher, type PushPreferences, type PushSettings, type PushSubscriptionInfo, type PushToken, type PushTokenAssociationResult, type PushTopic, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type RedeemResult, type ReferralAnalytics, type ReferralCampaign, type ReferralProfile, type ReferralStats, ReferralsService, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterPushTokenData, type RequestOptions, type ResolvedReferral, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, type S3MultipartOptions, type S3MultipartResult, type S3SingleUploadOptions, type S3SingleUploadResult, type S3UploadProgress, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type SecurityLayers, type ServerlessFunction, type ServiceHealth, ServiceModule, type Session, type SessionArtifact, type SessionInfo, type SessionLog, type SessionPoolEntry, type Severity, type ShareLink, type ShortestPathResult, type SignedUrlResponse, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, type SubmitResult, type Subscription, type TargetingRule, type Task, type TaskAttempt, type TaskTransition, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type Tool, type ToolCapability, type ToolIntegration, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type UnreadCountResponse, type UpdateFlagRequest, type UpdateRuleRequest, type UpdateSegmentRequest, type UpdateVariantRequest, type UploadCompleteResponse, type UploadEngineConfig, type UploadFailureReport, type UploadFailureReportResponse, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UpsertEnvironmentRequest, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
|
package/dist/index.d.ts
CHANGED
|
@@ -104,6 +104,8 @@ interface StorageAdapter {
|
|
|
104
104
|
interface ScaleMuleConfig {
|
|
105
105
|
/** API key (publishable key for browser, secret key for server) */
|
|
106
106
|
apiKey: string;
|
|
107
|
+
/** Application ID — required for realtime features (WebSocket auth, notifications) */
|
|
108
|
+
applicationId?: string;
|
|
107
109
|
/** Base URL for API requests. Overrides environment preset. */
|
|
108
110
|
baseUrl?: string;
|
|
109
111
|
/** Environment preset ('dev' or 'prod'). Defaults to 'prod'. */
|
|
@@ -250,6 +252,7 @@ declare function buildClientContextHeaders(context: ClientContext | undefined):
|
|
|
250
252
|
|
|
251
253
|
declare class ScaleMuleClient {
|
|
252
254
|
private apiKey;
|
|
255
|
+
private applicationId;
|
|
253
256
|
private baseUrl;
|
|
254
257
|
private debug;
|
|
255
258
|
private storage;
|
|
@@ -271,6 +274,7 @@ declare class ScaleMuleClient {
|
|
|
271
274
|
setAccessToken(token: string): void;
|
|
272
275
|
clearAccessToken(): void;
|
|
273
276
|
getSessionToken(): string | null;
|
|
277
|
+
getApplicationId(): string | null;
|
|
274
278
|
getUserId(): string | null;
|
|
275
279
|
isAuthenticated(): boolean;
|
|
276
280
|
getAnonymousId(): string | null;
|
|
@@ -2771,6 +2775,88 @@ declare class CommunicationService extends ServiceModule {
|
|
|
2771
2775
|
}): Promise<ApiResponse<MessageStatus>>;
|
|
2772
2776
|
}
|
|
2773
2777
|
|
|
2778
|
+
/**
|
|
2779
|
+
* Notifications Service
|
|
2780
|
+
*
|
|
2781
|
+
* In-app notification management — list, read, dismiss.
|
|
2782
|
+
* Notifications are created server-side by the notification pipeline
|
|
2783
|
+
* and delivered in real-time via WebSocket or fetched via these endpoints.
|
|
2784
|
+
*/
|
|
2785
|
+
|
|
2786
|
+
interface Notification {
|
|
2787
|
+
id: string;
|
|
2788
|
+
kind: string;
|
|
2789
|
+
title: string;
|
|
2790
|
+
body: string;
|
|
2791
|
+
icon_url?: string;
|
|
2792
|
+
action_url?: string;
|
|
2793
|
+
data: unknown;
|
|
2794
|
+
priority: 'high' | 'normal' | 'low';
|
|
2795
|
+
is_read: boolean;
|
|
2796
|
+
read_at?: string;
|
|
2797
|
+
created_at: string;
|
|
2798
|
+
}
|
|
2799
|
+
interface NotificationListResponse {
|
|
2800
|
+
notifications: Notification[];
|
|
2801
|
+
has_more: boolean;
|
|
2802
|
+
}
|
|
2803
|
+
interface UnreadCountResponse {
|
|
2804
|
+
count: number;
|
|
2805
|
+
}
|
|
2806
|
+
interface ListNotificationsParams {
|
|
2807
|
+
/** Only return unread notifications */
|
|
2808
|
+
unread_only?: boolean;
|
|
2809
|
+
/** Filter by notification kind (e.g., 'video.ready') */
|
|
2810
|
+
kind?: string;
|
|
2811
|
+
/** ISO 8601 timestamp — return notifications created after this time */
|
|
2812
|
+
since?: string;
|
|
2813
|
+
/** Max results per page (default: 20, max: 100) */
|
|
2814
|
+
limit?: number;
|
|
2815
|
+
/** Cursor for pagination (created_at of last item) */
|
|
2816
|
+
cursor?: string;
|
|
2817
|
+
}
|
|
2818
|
+
declare class NotificationsService extends ServiceModule {
|
|
2819
|
+
protected basePath: string;
|
|
2820
|
+
/**
|
|
2821
|
+
* List notifications for the authenticated user.
|
|
2822
|
+
*
|
|
2823
|
+
* @example
|
|
2824
|
+
* ```ts
|
|
2825
|
+
* // All unread
|
|
2826
|
+
* const { data } = await sm.notifications.list({ unread_only: true })
|
|
2827
|
+
*
|
|
2828
|
+
* // With pagination
|
|
2829
|
+
* const { data } = await sm.notifications.list({ limit: 10, cursor: lastCreatedAt })
|
|
2830
|
+
*
|
|
2831
|
+
* // Since last seen (reconnect catch-up)
|
|
2832
|
+
* const { data } = await sm.notifications.list({ unread_only: true, since: '2026-03-25T00:00:00Z' })
|
|
2833
|
+
* ```
|
|
2834
|
+
*/
|
|
2835
|
+
list(params?: ListNotificationsParams, options?: RequestOptions): Promise<ApiResponse<NotificationListResponse>>;
|
|
2836
|
+
/**
|
|
2837
|
+
* Get the count of unread notifications.
|
|
2838
|
+
*
|
|
2839
|
+
* @example
|
|
2840
|
+
* ```ts
|
|
2841
|
+
* const { data } = await sm.notifications.unreadCount()
|
|
2842
|
+
* console.log(`${data.count} unread`)
|
|
2843
|
+
* ```
|
|
2844
|
+
*/
|
|
2845
|
+
unreadCount(options?: RequestOptions): Promise<ApiResponse<UnreadCountResponse>>;
|
|
2846
|
+
/**
|
|
2847
|
+
* Mark a single notification as read.
|
|
2848
|
+
*/
|
|
2849
|
+
markRead(id: string, options?: RequestOptions): Promise<ApiResponse<void>>;
|
|
2850
|
+
/**
|
|
2851
|
+
* Mark all notifications as read.
|
|
2852
|
+
*/
|
|
2853
|
+
markAllRead(options?: RequestOptions): Promise<ApiResponse<void>>;
|
|
2854
|
+
/**
|
|
2855
|
+
* Dismiss a notification (soft delete).
|
|
2856
|
+
*/
|
|
2857
|
+
dismiss(id: string, options?: RequestOptions): Promise<ApiResponse<void>>;
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2774
2860
|
/**
|
|
2775
2861
|
* WebPushManager — Browser push notification subscription manager
|
|
2776
2862
|
*
|
|
@@ -4866,6 +4952,10 @@ interface Task {
|
|
|
4866
4952
|
metadata?: Record<string, unknown>;
|
|
4867
4953
|
created_at: string;
|
|
4868
4954
|
updated_at: string;
|
|
4955
|
+
pipeline_id?: string;
|
|
4956
|
+
pipeline_version?: number;
|
|
4957
|
+
current_phase?: string;
|
|
4958
|
+
phase_entered_at?: string;
|
|
4869
4959
|
}
|
|
4870
4960
|
interface ClaimResult {
|
|
4871
4961
|
task_id: string;
|
|
@@ -4989,6 +5079,7 @@ declare class AgentProjectsService extends ServiceModule {
|
|
|
4989
5079
|
priority?: string;
|
|
4990
5080
|
due_date?: string;
|
|
4991
5081
|
metadata?: Record<string, unknown>;
|
|
5082
|
+
pipeline_id?: string;
|
|
4992
5083
|
}, applicationId?: string, options?: RequestOptions): Promise<ApiResponse<Task>>;
|
|
4993
5084
|
listTasks(projectId: string, params?: PaginationParams & {
|
|
4994
5085
|
application_id?: string;
|
|
@@ -5012,6 +5103,10 @@ declare class AgentProjectsService extends ServiceModule {
|
|
|
5012
5103
|
heartbeat(taskId: string, agentId: string, applicationId?: string, options?: RequestOptions): Promise<ApiResponse<{
|
|
5013
5104
|
lease_expires_at: string;
|
|
5014
5105
|
}>>;
|
|
5106
|
+
startTask(taskId: string, agentId: string, applicationId?: string, options?: RequestOptions): Promise<ApiResponse<{
|
|
5107
|
+
task_id: string;
|
|
5108
|
+
status: string;
|
|
5109
|
+
}>>;
|
|
5015
5110
|
submit(taskId: string, data: {
|
|
5016
5111
|
agent_id: string;
|
|
5017
5112
|
idempotency_key: string;
|
|
@@ -5455,6 +5550,7 @@ declare class ScaleMule {
|
|
|
5455
5550
|
readonly analytics: AnalyticsService;
|
|
5456
5551
|
readonly flags: FlagsService;
|
|
5457
5552
|
readonly communication: CommunicationService;
|
|
5553
|
+
readonly notifications: NotificationsService;
|
|
5458
5554
|
readonly scheduler: SchedulerService;
|
|
5459
5555
|
readonly permissions: PermissionsService;
|
|
5460
5556
|
readonly workspaces: WorkspacesService;
|
|
@@ -5520,6 +5616,8 @@ declare class ScaleMule {
|
|
|
5520
5616
|
clearAllAccounts(): Promise<void>;
|
|
5521
5617
|
/** The base URL being used for API requests. */
|
|
5522
5618
|
getBaseUrl(): string;
|
|
5619
|
+
/** The application ID, or null if not configured. */
|
|
5620
|
+
getApplicationId(): string | null;
|
|
5523
5621
|
/** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
|
|
5524
5622
|
setWorkspaceContext(id: string | null): void;
|
|
5525
5623
|
/** Get the current workspace ID, or null. */
|
|
@@ -5528,4 +5626,4 @@ declare class ScaleMule {
|
|
|
5528
5626
|
getClient(): ScaleMuleClient;
|
|
5529
5627
|
}
|
|
5530
5628
|
|
|
5531
|
-
export { type AccountBalance, AccountsService, type ActiveUsers, type ActivityItem, AgentAuthService, AgentModelsService, type AgentProfile, AgentProjectsService, type AgentResponse, type AgentSecurityPolicy, AgentSessionsService, type AgentSigningKey, type AgentToken, type AgentToolEntitlement, AgentToolsService, type Workspace as AgentWorkspace, AgentsService, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type Attachment, type Attendee, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateFlagRequest, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, type FlagAuditEntry, type FlagCheck, type FlagCondition, FlagContentService, type FlagDefinition, type FlagDetail, type FlagEnvironment, type FlagEvaluation, type FlagSegment, type FlagVariant, FlagsService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type Leaderboard, type LeaderboardEntry, LeaderboardService, type Like, type Listing, ListingsService, type LogEntry, type LogInput, type LogQueryParams, type LogQueryResponse, type LogRecord, LoggerService, type LoginActivitySummary, type LoginDeviceInfo, type LoginHistoryEntry, type LoginRiskInfo, type MessageCallback, type MessageStatus, type MetricDataPoint, type MfaStatus, type Model, type ModelEntitlement, type ModelPricing, type ModelProvider, type UsageSummary as ModelUsageSummary, type MultipartCompleteResponse, type MultipartConfig, type MultipartPartUrl, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, type PartResult, type PartUrl, type Participant, type Payment, type PaymentListParams, type PaymentMethod, type PaymentStatusResponse, type Payout, type PayoutSchedule, type PermissionCheck, type PermissionMatrix, PermissionsService, type PhotoInfo, PhotoService, type Pipeline, type PipelineVersion, type Policy, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type Project, type ProjectDocument, type ProjectGrant, type ProjectMember, type PushApiFetcher, type PushPreferences, type PushSettings, type PushSubscriptionInfo, type PushToken, type PushTokenAssociationResult, type PushTopic, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type RedeemResult, type ReferralAnalytics, type ReferralCampaign, type ReferralProfile, type ReferralStats, ReferralsService, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterPushTokenData, type RequestOptions, type ResolvedReferral, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, type S3MultipartOptions, type S3MultipartResult, type S3SingleUploadOptions, type S3SingleUploadResult, type S3UploadProgress, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type SecurityLayers, type ServerlessFunction, type ServiceHealth, ServiceModule, type Session, type SessionArtifact, type SessionInfo, type SessionLog, type SessionPoolEntry, type Severity, type ShareLink, type ShortestPathResult, type SignedUrlResponse, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, type SubmitResult, type Subscription, type TargetingRule, type Task, type TaskAttempt, type TaskTransition, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type Tool, type ToolCapability, type ToolIntegration, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type UpdateFlagRequest, type UpdateRuleRequest, type UpdateSegmentRequest, type UpdateVariantRequest, type UploadCompleteResponse, type UploadEngineConfig, type UploadFailureReport, type UploadFailureReportResponse, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UpsertEnvironmentRequest, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
|
|
5629
|
+
export { type AccountBalance, AccountsService, type ActiveUsers, type ActivityItem, AgentAuthService, AgentModelsService, type AgentProfile, AgentProjectsService, type AgentResponse, type AgentSecurityPolicy, AgentSessionsService, type AgentSigningKey, type AgentToken, type AgentToolEntitlement, AgentToolsService, type Workspace as AgentWorkspace, AgentsService, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type Attachment, type Attendee, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateFlagRequest, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, type FlagAuditEntry, type FlagCheck, type FlagCondition, FlagContentService, type FlagDefinition, type FlagDetail, type FlagEnvironment, type FlagEvaluation, type FlagSegment, type FlagVariant, FlagsService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type Leaderboard, type LeaderboardEntry, LeaderboardService, type Like, type ListNotificationsParams, type Listing, ListingsService, type LogEntry, type LogInput, type LogQueryParams, type LogQueryResponse, type LogRecord, LoggerService, type LoginActivitySummary, type LoginDeviceInfo, type LoginHistoryEntry, type LoginRiskInfo, type MessageCallback, type MessageStatus, type MetricDataPoint, type MfaStatus, type Model, type ModelEntitlement, type ModelPricing, type ModelProvider, type UsageSummary as ModelUsageSummary, type MultipartCompleteResponse, type MultipartConfig, type MultipartPartUrl, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type Notification, type NotificationListResponse, NotificationsService, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, type PartResult, type PartUrl, type Participant, type Payment, type PaymentListParams, type PaymentMethod, type PaymentStatusResponse, type Payout, type PayoutSchedule, type PermissionCheck, type PermissionMatrix, PermissionsService, type PhotoInfo, PhotoService, type Pipeline, type PipelineVersion, type Policy, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type Project, type ProjectDocument, type ProjectGrant, type ProjectMember, type PushApiFetcher, type PushPreferences, type PushSettings, type PushSubscriptionInfo, type PushToken, type PushTokenAssociationResult, type PushTopic, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type RedeemResult, type ReferralAnalytics, type ReferralCampaign, type ReferralProfile, type ReferralStats, ReferralsService, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterPushTokenData, type RequestOptions, type ResolvedReferral, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, type S3MultipartOptions, type S3MultipartResult, type S3SingleUploadOptions, type S3SingleUploadResult, type S3UploadProgress, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type SecurityLayers, type ServerlessFunction, type ServiceHealth, ServiceModule, type Session, type SessionArtifact, type SessionInfo, type SessionLog, type SessionPoolEntry, type Severity, type ShareLink, type ShortestPathResult, type SignedUrlResponse, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, type SubmitResult, type Subscription, type TargetingRule, type Task, type TaskAttempt, type TaskTransition, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type Tool, type ToolCapability, type ToolIntegration, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type UnreadCountResponse, type UpdateFlagRequest, type UpdateRuleRequest, type UpdateSegmentRequest, type UpdateVariantRequest, type UploadCompleteResponse, type UploadEngineConfig, type UploadFailureReport, type UploadFailureReportResponse, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UpsertEnvironmentRequest, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
|
package/dist/index.js
CHANGED
|
@@ -319,8 +319,9 @@ __export(index_exports, {
|
|
|
319
319
|
LeaderboardService: () => LeaderboardService,
|
|
320
320
|
ListingsService: () => ListingsService,
|
|
321
321
|
LoggerService: () => LoggerService,
|
|
322
|
+
NotificationsService: () => NotificationsService,
|
|
322
323
|
OrchestratorService: () => OrchestratorService,
|
|
323
|
-
PHONE_COUNTRIES: () =>
|
|
324
|
+
PHONE_COUNTRIES: () => PHONE_COUNTRIES,
|
|
324
325
|
PHOTO_BREAKPOINTS: () => PHOTO_BREAKPOINTS,
|
|
325
326
|
PermissionsService: () => PermissionsService,
|
|
326
327
|
PhotoService: () => PhotoService,
|
|
@@ -345,22 +346,22 @@ __export(index_exports, {
|
|
|
345
346
|
buildClientContextHeaders: () => buildClientContextHeaders,
|
|
346
347
|
calculateTotalParts: () => calculateTotalParts,
|
|
347
348
|
canPerform: () => canPerform,
|
|
348
|
-
composePhoneNumber: () =>
|
|
349
|
-
countryFlag: () =>
|
|
349
|
+
composePhoneNumber: () => composePhoneNumber,
|
|
350
|
+
countryFlag: () => countryFlag,
|
|
350
351
|
createUploadPlan: () => createUploadPlan,
|
|
351
352
|
default: () => index_default,
|
|
352
|
-
detectCountryFromE164: () =>
|
|
353
|
+
detectCountryFromE164: () => detectCountryFromE164,
|
|
353
354
|
detectNetworkClass: () => detectNetworkClass,
|
|
354
355
|
extractClientContext: () => extractClientContext,
|
|
355
|
-
findPhoneCountryByCode: () =>
|
|
356
|
-
findPhoneCountryByDialCode: () =>
|
|
356
|
+
findPhoneCountryByCode: () => findPhoneCountryByCode,
|
|
357
|
+
findPhoneCountryByDialCode: () => findPhoneCountryByDialCode,
|
|
357
358
|
generateUploadSessionId: () => generateUploadSessionId,
|
|
358
359
|
getMeasuredBandwidthMbps: () => getMeasuredBandwidthMbps,
|
|
359
360
|
getPartRange: () => getPartRange,
|
|
360
361
|
hasMinRoleLevel: () => hasMinRoleLevel,
|
|
361
|
-
isValidE164Phone: () =>
|
|
362
|
-
normalizeAndValidatePhone: () =>
|
|
363
|
-
normalizePhoneNumber: () =>
|
|
362
|
+
isValidE164Phone: () => isValidE164Phone,
|
|
363
|
+
normalizeAndValidatePhone: () => normalizeAndValidatePhone,
|
|
364
|
+
normalizePhoneNumber: () => normalizePhoneNumber,
|
|
364
365
|
resolveStrategy: () => resolveStrategy,
|
|
365
366
|
uploadMultipartToS3: () => uploadMultipartToS3,
|
|
366
367
|
uploadSingleToS3: () => uploadSingleToS3,
|
|
@@ -660,6 +661,7 @@ var OfflineQueue = class {
|
|
|
660
661
|
};
|
|
661
662
|
var ScaleMuleClient = class {
|
|
662
663
|
constructor(config) {
|
|
664
|
+
this.applicationId = null;
|
|
663
665
|
this.sessionToken = null;
|
|
664
666
|
this.userId = null;
|
|
665
667
|
this.rateLimitQueue = null;
|
|
@@ -668,6 +670,7 @@ var ScaleMuleClient = class {
|
|
|
668
670
|
this.anonymousId = null;
|
|
669
671
|
this.sessionPool = /* @__PURE__ */ new Map();
|
|
670
672
|
this.apiKey = config.apiKey;
|
|
673
|
+
this.applicationId = config.applicationId || null;
|
|
671
674
|
this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
|
|
672
675
|
this.debug = config.debug || false;
|
|
673
676
|
this.storage = config.storage || createDefaultStorage();
|
|
@@ -772,6 +775,9 @@ var ScaleMuleClient = class {
|
|
|
772
775
|
getSessionToken() {
|
|
773
776
|
return this.sessionToken;
|
|
774
777
|
}
|
|
778
|
+
getApplicationId() {
|
|
779
|
+
return this.applicationId;
|
|
780
|
+
}
|
|
775
781
|
getUserId() {
|
|
776
782
|
return this.userId;
|
|
777
783
|
}
|
|
@@ -1346,8 +1352,138 @@ function asString(parent, key) {
|
|
|
1346
1352
|
return typeof value === "string" ? value : void 0;
|
|
1347
1353
|
}
|
|
1348
1354
|
|
|
1349
|
-
//
|
|
1350
|
-
var
|
|
1355
|
+
// node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1356
|
+
var PHONE_COUNTRIES = [
|
|
1357
|
+
{ code: "US", name: "United States", dialCode: "+1" },
|
|
1358
|
+
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
1359
|
+
{ code: "GB", name: "United Kingdom", dialCode: "+44" },
|
|
1360
|
+
{ code: "AU", name: "Australia", dialCode: "+61" },
|
|
1361
|
+
{ code: "DE", name: "Germany", dialCode: "+49" },
|
|
1362
|
+
{ code: "FR", name: "France", dialCode: "+33" },
|
|
1363
|
+
{ code: "IT", name: "Italy", dialCode: "+39" },
|
|
1364
|
+
{ code: "ES", name: "Spain", dialCode: "+34" },
|
|
1365
|
+
{ code: "NL", name: "Netherlands", dialCode: "+31" },
|
|
1366
|
+
{ code: "BE", name: "Belgium", dialCode: "+32" },
|
|
1367
|
+
{ code: "CH", name: "Switzerland", dialCode: "+41" },
|
|
1368
|
+
{ code: "AT", name: "Austria", dialCode: "+43" },
|
|
1369
|
+
{ code: "SE", name: "Sweden", dialCode: "+46" },
|
|
1370
|
+
{ code: "NO", name: "Norway", dialCode: "+47" },
|
|
1371
|
+
{ code: "DK", name: "Denmark", dialCode: "+45" },
|
|
1372
|
+
{ code: "FI", name: "Finland", dialCode: "+358" },
|
|
1373
|
+
{ code: "IE", name: "Ireland", dialCode: "+353" },
|
|
1374
|
+
{ code: "PT", name: "Portugal", dialCode: "+351" },
|
|
1375
|
+
{ code: "PL", name: "Poland", dialCode: "+48" },
|
|
1376
|
+
{ code: "CZ", name: "Czech Republic", dialCode: "+420" },
|
|
1377
|
+
{ code: "GR", name: "Greece", dialCode: "+30" },
|
|
1378
|
+
{ code: "RU", name: "Russia", dialCode: "+7" },
|
|
1379
|
+
{ code: "JP", name: "Japan", dialCode: "+81" },
|
|
1380
|
+
{ code: "KR", name: "South Korea", dialCode: "+82" },
|
|
1381
|
+
{ code: "CN", name: "China", dialCode: "+86" },
|
|
1382
|
+
{ code: "HK", name: "Hong Kong", dialCode: "+852" },
|
|
1383
|
+
{ code: "TW", name: "Taiwan", dialCode: "+886" },
|
|
1384
|
+
{ code: "SG", name: "Singapore", dialCode: "+65" },
|
|
1385
|
+
{ code: "MY", name: "Malaysia", dialCode: "+60" },
|
|
1386
|
+
{ code: "TH", name: "Thailand", dialCode: "+66" },
|
|
1387
|
+
{ code: "VN", name: "Vietnam", dialCode: "+84" },
|
|
1388
|
+
{ code: "PH", name: "Philippines", dialCode: "+63" },
|
|
1389
|
+
{ code: "ID", name: "Indonesia", dialCode: "+62" },
|
|
1390
|
+
{ code: "IN", name: "India", dialCode: "+91" },
|
|
1391
|
+
{ code: "PK", name: "Pakistan", dialCode: "+92" },
|
|
1392
|
+
{ code: "BD", name: "Bangladesh", dialCode: "+880" },
|
|
1393
|
+
{ code: "AE", name: "UAE", dialCode: "+971" },
|
|
1394
|
+
{ code: "SA", name: "Saudi Arabia", dialCode: "+966" },
|
|
1395
|
+
{ code: "IL", name: "Israel", dialCode: "+972" },
|
|
1396
|
+
{ code: "TR", name: "Turkey", dialCode: "+90" },
|
|
1397
|
+
{ code: "EG", name: "Egypt", dialCode: "+20" },
|
|
1398
|
+
{ code: "ZA", name: "South Africa", dialCode: "+27" },
|
|
1399
|
+
{ code: "NG", name: "Nigeria", dialCode: "+234" },
|
|
1400
|
+
{ code: "KE", name: "Kenya", dialCode: "+254" },
|
|
1401
|
+
{ code: "BR", name: "Brazil", dialCode: "+55" },
|
|
1402
|
+
{ code: "MX", name: "Mexico", dialCode: "+52" },
|
|
1403
|
+
{ code: "AR", name: "Argentina", dialCode: "+54" },
|
|
1404
|
+
{ code: "CL", name: "Chile", dialCode: "+56" },
|
|
1405
|
+
{ code: "CO", name: "Colombia", dialCode: "+57" },
|
|
1406
|
+
{ code: "PE", name: "Peru", dialCode: "+51" },
|
|
1407
|
+
{ code: "NZ", name: "New Zealand", dialCode: "+64" }
|
|
1408
|
+
];
|
|
1409
|
+
var E164_REGEX = /^\+[1-9]\d{6,14}$/;
|
|
1410
|
+
function isValidE164Phone(input) {
|
|
1411
|
+
return E164_REGEX.test(input);
|
|
1412
|
+
}
|
|
1413
|
+
function normalizePhoneNumber(input) {
|
|
1414
|
+
if (typeof input !== "string") return "";
|
|
1415
|
+
const trimmed = input.trim();
|
|
1416
|
+
if (!trimmed) return "";
|
|
1417
|
+
const digitsOnly = trimmed.replace(/\D/g, "");
|
|
1418
|
+
if (!digitsOnly) return "";
|
|
1419
|
+
if (trimmed.startsWith("+")) {
|
|
1420
|
+
return `+${digitsOnly}`;
|
|
1421
|
+
}
|
|
1422
|
+
if (trimmed.startsWith("00") && digitsOnly.length > 2) {
|
|
1423
|
+
return `+${digitsOnly.slice(2)}`;
|
|
1424
|
+
}
|
|
1425
|
+
return `+${digitsOnly}`;
|
|
1426
|
+
}
|
|
1427
|
+
function normalizeAndValidatePhone(input) {
|
|
1428
|
+
const normalized = normalizePhoneNumber(input);
|
|
1429
|
+
if (!normalized) {
|
|
1430
|
+
return {
|
|
1431
|
+
input,
|
|
1432
|
+
normalized: null,
|
|
1433
|
+
valid: false,
|
|
1434
|
+
error: "Phone number is required"
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
if (!E164_REGEX.test(normalized)) {
|
|
1438
|
+
return {
|
|
1439
|
+
input,
|
|
1440
|
+
normalized,
|
|
1441
|
+
valid: false,
|
|
1442
|
+
error: "Phone number must be in E.164 format (+[country code][number])"
|
|
1443
|
+
};
|
|
1444
|
+
}
|
|
1445
|
+
return {
|
|
1446
|
+
input,
|
|
1447
|
+
normalized,
|
|
1448
|
+
valid: true,
|
|
1449
|
+
error: null
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
function composePhoneNumber(countryDialCode, localNumber) {
|
|
1453
|
+
const normalizedDial = normalizePhoneNumber(countryDialCode);
|
|
1454
|
+
if (!normalizedDial) return "";
|
|
1455
|
+
const localDigits = typeof localNumber === "string" ? localNumber.replace(/\D/g, "") : "";
|
|
1456
|
+
if (!localDigits) return "";
|
|
1457
|
+
return `${normalizedDial}${localDigits}`;
|
|
1458
|
+
}
|
|
1459
|
+
function findPhoneCountryByCode(code) {
|
|
1460
|
+
if (!code) return void 0;
|
|
1461
|
+
const upperCode = code.toUpperCase();
|
|
1462
|
+
return PHONE_COUNTRIES.find((country) => country.code === upperCode);
|
|
1463
|
+
}
|
|
1464
|
+
function findPhoneCountryByDialCode(dialCode) {
|
|
1465
|
+
if (!dialCode) return void 0;
|
|
1466
|
+
const normalized = dialCode.startsWith("+") ? dialCode : `+${dialCode}`;
|
|
1467
|
+
return PHONE_COUNTRIES.find((country) => country.dialCode === normalized);
|
|
1468
|
+
}
|
|
1469
|
+
var DIAL_CODES_DESC = [...PHONE_COUNTRIES].sort((a, b) => b.dialCode.length - a.dialCode.length);
|
|
1470
|
+
function detectCountryFromE164(e164) {
|
|
1471
|
+
if (!e164 || !e164.startsWith("+")) return null;
|
|
1472
|
+
const normalized = "+" + e164.slice(1).replace(/\D/g, "");
|
|
1473
|
+
for (const country of DIAL_CODES_DESC) {
|
|
1474
|
+
const prefix = country.dialCode;
|
|
1475
|
+
if (normalized.startsWith(prefix)) {
|
|
1476
|
+
const local = normalized.slice(prefix.length);
|
|
1477
|
+
if (local.length > 0) {
|
|
1478
|
+
return { country, local };
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
return null;
|
|
1483
|
+
}
|
|
1484
|
+
function countryFlag(code) {
|
|
1485
|
+
return [...code.toUpperCase()].map((c) => String.fromCodePoint(127462 + c.charCodeAt(0) - 65)).join("");
|
|
1486
|
+
}
|
|
1351
1487
|
|
|
1352
1488
|
// src/services/auth.ts
|
|
1353
1489
|
function collectDeviceFingerprint() {
|
|
@@ -1454,7 +1590,7 @@ var AuthService = class extends ServiceModule {
|
|
|
1454
1590
|
}
|
|
1455
1591
|
sanitizePhoneField(value) {
|
|
1456
1592
|
if (typeof value !== "string") return value;
|
|
1457
|
-
const normalized =
|
|
1593
|
+
const normalized = normalizePhoneNumber(value);
|
|
1458
1594
|
return normalized || void 0;
|
|
1459
1595
|
}
|
|
1460
1596
|
// --------------------------------------------------------------------------
|
|
@@ -3512,9 +3648,11 @@ var RealtimeService = class extends ServiceModule {
|
|
|
3512
3648
|
}
|
|
3513
3649
|
authenticate() {
|
|
3514
3650
|
const token = this.client.getSessionToken();
|
|
3651
|
+
const appId = this.client.getApplicationId();
|
|
3515
3652
|
this.sendWs({
|
|
3516
3653
|
type: "auth",
|
|
3517
|
-
token: token || void 0
|
|
3654
|
+
token: token || void 0,
|
|
3655
|
+
app_id: appId || void 0
|
|
3518
3656
|
});
|
|
3519
3657
|
}
|
|
3520
3658
|
handleMessage(msg) {
|
|
@@ -4572,6 +4710,70 @@ var CommunicationService = class extends ServiceModule {
|
|
|
4572
4710
|
}
|
|
4573
4711
|
};
|
|
4574
4712
|
|
|
4713
|
+
// src/services/notifications.ts
|
|
4714
|
+
var NotificationsService = class extends ServiceModule {
|
|
4715
|
+
constructor() {
|
|
4716
|
+
super(...arguments);
|
|
4717
|
+
this.basePath = "/notifications";
|
|
4718
|
+
}
|
|
4719
|
+
/**
|
|
4720
|
+
* List notifications for the authenticated user.
|
|
4721
|
+
*
|
|
4722
|
+
* @example
|
|
4723
|
+
* ```ts
|
|
4724
|
+
* // All unread
|
|
4725
|
+
* const { data } = await sm.notifications.list({ unread_only: true })
|
|
4726
|
+
*
|
|
4727
|
+
* // With pagination
|
|
4728
|
+
* const { data } = await sm.notifications.list({ limit: 10, cursor: lastCreatedAt })
|
|
4729
|
+
*
|
|
4730
|
+
* // Since last seen (reconnect catch-up)
|
|
4731
|
+
* const { data } = await sm.notifications.list({ unread_only: true, since: '2026-03-25T00:00:00Z' })
|
|
4732
|
+
* ```
|
|
4733
|
+
*/
|
|
4734
|
+
async list(params, options) {
|
|
4735
|
+
const qs = new URLSearchParams();
|
|
4736
|
+
if (params?.unread_only) qs.set("unread_only", "true");
|
|
4737
|
+
if (params?.kind) qs.set("kind", params.kind);
|
|
4738
|
+
if (params?.since) qs.set("since", params.since);
|
|
4739
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
4740
|
+
if (params?.cursor) qs.set("cursor", params.cursor);
|
|
4741
|
+
const query = qs.toString();
|
|
4742
|
+
const path = query ? `?${query}` : "";
|
|
4743
|
+
return this._get(path, options);
|
|
4744
|
+
}
|
|
4745
|
+
/**
|
|
4746
|
+
* Get the count of unread notifications.
|
|
4747
|
+
*
|
|
4748
|
+
* @example
|
|
4749
|
+
* ```ts
|
|
4750
|
+
* const { data } = await sm.notifications.unreadCount()
|
|
4751
|
+
* console.log(`${data.count} unread`)
|
|
4752
|
+
* ```
|
|
4753
|
+
*/
|
|
4754
|
+
async unreadCount(options) {
|
|
4755
|
+
return this._get("/unread-count", options);
|
|
4756
|
+
}
|
|
4757
|
+
/**
|
|
4758
|
+
* Mark a single notification as read.
|
|
4759
|
+
*/
|
|
4760
|
+
async markRead(id, options) {
|
|
4761
|
+
return this.patch(`/${id}/read`, void 0, options);
|
|
4762
|
+
}
|
|
4763
|
+
/**
|
|
4764
|
+
* Mark all notifications as read.
|
|
4765
|
+
*/
|
|
4766
|
+
async markAllRead(options) {
|
|
4767
|
+
return this.patch("/read-all", void 0, options);
|
|
4768
|
+
}
|
|
4769
|
+
/**
|
|
4770
|
+
* Dismiss a notification (soft delete).
|
|
4771
|
+
*/
|
|
4772
|
+
async dismiss(id, options) {
|
|
4773
|
+
return this.del(`/${id}`, options);
|
|
4774
|
+
}
|
|
4775
|
+
};
|
|
4776
|
+
|
|
4575
4777
|
// src/web-push.ts
|
|
4576
4778
|
var STORAGE_KEY = "scalemule_push_state";
|
|
4577
4779
|
var WebPushManager = class {
|
|
@@ -6022,6 +6224,13 @@ var AgentProjectsService = class extends ServiceModule {
|
|
|
6022
6224
|
options
|
|
6023
6225
|
);
|
|
6024
6226
|
}
|
|
6227
|
+
async startTask(taskId, agentId, applicationId, options) {
|
|
6228
|
+
return this.post(
|
|
6229
|
+
this.withAppId(`/tasks/${taskId}/start`, applicationId),
|
|
6230
|
+
{ agent_id: agentId },
|
|
6231
|
+
options
|
|
6232
|
+
);
|
|
6233
|
+
}
|
|
6025
6234
|
async submit(taskId, data, applicationId, options) {
|
|
6026
6235
|
return this.post(this.withAppId(`/tasks/${taskId}/submit`, applicationId), data, options);
|
|
6027
6236
|
}
|
|
@@ -6309,6 +6518,7 @@ var ScaleMule = class {
|
|
|
6309
6518
|
this.analytics = new AnalyticsService(this._client);
|
|
6310
6519
|
this.flags = new FlagsService(this._client);
|
|
6311
6520
|
this.communication = new CommunicationService(this._client);
|
|
6521
|
+
this.notifications = new NotificationsService(this._client);
|
|
6312
6522
|
this.scheduler = new SchedulerService(this._client);
|
|
6313
6523
|
this.permissions = new PermissionsService(this._client);
|
|
6314
6524
|
this.workspaces = new WorkspacesService(this._client);
|
|
@@ -6410,6 +6620,10 @@ var ScaleMule = class {
|
|
|
6410
6620
|
getBaseUrl() {
|
|
6411
6621
|
return this._client.getBaseUrl();
|
|
6412
6622
|
}
|
|
6623
|
+
/** The application ID, or null if not configured. */
|
|
6624
|
+
getApplicationId() {
|
|
6625
|
+
return this._client.getApplicationId();
|
|
6626
|
+
}
|
|
6413
6627
|
/** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
|
|
6414
6628
|
setWorkspaceContext(id) {
|
|
6415
6629
|
this._client.setWorkspaceContext(id);
|
|
@@ -6452,6 +6666,7 @@ var index_default = ScaleMule;
|
|
|
6452
6666
|
LeaderboardService,
|
|
6453
6667
|
ListingsService,
|
|
6454
6668
|
LoggerService,
|
|
6669
|
+
NotificationsService,
|
|
6455
6670
|
OrchestratorService,
|
|
6456
6671
|
PHONE_COUNTRIES,
|
|
6457
6672
|
PHOTO_BREAKPOINTS,
|
package/dist/index.mjs
CHANGED
|
@@ -294,6 +294,7 @@ var OfflineQueue = class {
|
|
|
294
294
|
};
|
|
295
295
|
var ScaleMuleClient = class {
|
|
296
296
|
constructor(config) {
|
|
297
|
+
this.applicationId = null;
|
|
297
298
|
this.sessionToken = null;
|
|
298
299
|
this.userId = null;
|
|
299
300
|
this.rateLimitQueue = null;
|
|
@@ -302,6 +303,7 @@ var ScaleMuleClient = class {
|
|
|
302
303
|
this.anonymousId = null;
|
|
303
304
|
this.sessionPool = /* @__PURE__ */ new Map();
|
|
304
305
|
this.apiKey = config.apiKey;
|
|
306
|
+
this.applicationId = config.applicationId || null;
|
|
305
307
|
this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
|
|
306
308
|
this.debug = config.debug || false;
|
|
307
309
|
this.storage = config.storage || createDefaultStorage();
|
|
@@ -406,6 +408,9 @@ var ScaleMuleClient = class {
|
|
|
406
408
|
getSessionToken() {
|
|
407
409
|
return this.sessionToken;
|
|
408
410
|
}
|
|
411
|
+
getApplicationId() {
|
|
412
|
+
return this.applicationId;
|
|
413
|
+
}
|
|
409
414
|
getUserId() {
|
|
410
415
|
return this.userId;
|
|
411
416
|
}
|
|
@@ -980,18 +985,138 @@ function asString(parent, key) {
|
|
|
980
985
|
return typeof value === "string" ? value : void 0;
|
|
981
986
|
}
|
|
982
987
|
|
|
983
|
-
//
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
988
|
+
// node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
989
|
+
var PHONE_COUNTRIES = [
|
|
990
|
+
{ code: "US", name: "United States", dialCode: "+1" },
|
|
991
|
+
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
992
|
+
{ code: "GB", name: "United Kingdom", dialCode: "+44" },
|
|
993
|
+
{ code: "AU", name: "Australia", dialCode: "+61" },
|
|
994
|
+
{ code: "DE", name: "Germany", dialCode: "+49" },
|
|
995
|
+
{ code: "FR", name: "France", dialCode: "+33" },
|
|
996
|
+
{ code: "IT", name: "Italy", dialCode: "+39" },
|
|
997
|
+
{ code: "ES", name: "Spain", dialCode: "+34" },
|
|
998
|
+
{ code: "NL", name: "Netherlands", dialCode: "+31" },
|
|
999
|
+
{ code: "BE", name: "Belgium", dialCode: "+32" },
|
|
1000
|
+
{ code: "CH", name: "Switzerland", dialCode: "+41" },
|
|
1001
|
+
{ code: "AT", name: "Austria", dialCode: "+43" },
|
|
1002
|
+
{ code: "SE", name: "Sweden", dialCode: "+46" },
|
|
1003
|
+
{ code: "NO", name: "Norway", dialCode: "+47" },
|
|
1004
|
+
{ code: "DK", name: "Denmark", dialCode: "+45" },
|
|
1005
|
+
{ code: "FI", name: "Finland", dialCode: "+358" },
|
|
1006
|
+
{ code: "IE", name: "Ireland", dialCode: "+353" },
|
|
1007
|
+
{ code: "PT", name: "Portugal", dialCode: "+351" },
|
|
1008
|
+
{ code: "PL", name: "Poland", dialCode: "+48" },
|
|
1009
|
+
{ code: "CZ", name: "Czech Republic", dialCode: "+420" },
|
|
1010
|
+
{ code: "GR", name: "Greece", dialCode: "+30" },
|
|
1011
|
+
{ code: "RU", name: "Russia", dialCode: "+7" },
|
|
1012
|
+
{ code: "JP", name: "Japan", dialCode: "+81" },
|
|
1013
|
+
{ code: "KR", name: "South Korea", dialCode: "+82" },
|
|
1014
|
+
{ code: "CN", name: "China", dialCode: "+86" },
|
|
1015
|
+
{ code: "HK", name: "Hong Kong", dialCode: "+852" },
|
|
1016
|
+
{ code: "TW", name: "Taiwan", dialCode: "+886" },
|
|
1017
|
+
{ code: "SG", name: "Singapore", dialCode: "+65" },
|
|
1018
|
+
{ code: "MY", name: "Malaysia", dialCode: "+60" },
|
|
1019
|
+
{ code: "TH", name: "Thailand", dialCode: "+66" },
|
|
1020
|
+
{ code: "VN", name: "Vietnam", dialCode: "+84" },
|
|
1021
|
+
{ code: "PH", name: "Philippines", dialCode: "+63" },
|
|
1022
|
+
{ code: "ID", name: "Indonesia", dialCode: "+62" },
|
|
1023
|
+
{ code: "IN", name: "India", dialCode: "+91" },
|
|
1024
|
+
{ code: "PK", name: "Pakistan", dialCode: "+92" },
|
|
1025
|
+
{ code: "BD", name: "Bangladesh", dialCode: "+880" },
|
|
1026
|
+
{ code: "AE", name: "UAE", dialCode: "+971" },
|
|
1027
|
+
{ code: "SA", name: "Saudi Arabia", dialCode: "+966" },
|
|
1028
|
+
{ code: "IL", name: "Israel", dialCode: "+972" },
|
|
1029
|
+
{ code: "TR", name: "Turkey", dialCode: "+90" },
|
|
1030
|
+
{ code: "EG", name: "Egypt", dialCode: "+20" },
|
|
1031
|
+
{ code: "ZA", name: "South Africa", dialCode: "+27" },
|
|
1032
|
+
{ code: "NG", name: "Nigeria", dialCode: "+234" },
|
|
1033
|
+
{ code: "KE", name: "Kenya", dialCode: "+254" },
|
|
1034
|
+
{ code: "BR", name: "Brazil", dialCode: "+55" },
|
|
1035
|
+
{ code: "MX", name: "Mexico", dialCode: "+52" },
|
|
1036
|
+
{ code: "AR", name: "Argentina", dialCode: "+54" },
|
|
1037
|
+
{ code: "CL", name: "Chile", dialCode: "+56" },
|
|
1038
|
+
{ code: "CO", name: "Colombia", dialCode: "+57" },
|
|
1039
|
+
{ code: "PE", name: "Peru", dialCode: "+51" },
|
|
1040
|
+
{ code: "NZ", name: "New Zealand", dialCode: "+64" }
|
|
1041
|
+
];
|
|
1042
|
+
var E164_REGEX = /^\+[1-9]\d{6,14}$/;
|
|
1043
|
+
function isValidE164Phone(input) {
|
|
1044
|
+
return E164_REGEX.test(input);
|
|
1045
|
+
}
|
|
1046
|
+
function normalizePhoneNumber(input) {
|
|
1047
|
+
if (typeof input !== "string") return "";
|
|
1048
|
+
const trimmed = input.trim();
|
|
1049
|
+
if (!trimmed) return "";
|
|
1050
|
+
const digitsOnly = trimmed.replace(/\D/g, "");
|
|
1051
|
+
if (!digitsOnly) return "";
|
|
1052
|
+
if (trimmed.startsWith("+")) {
|
|
1053
|
+
return `+${digitsOnly}`;
|
|
1054
|
+
}
|
|
1055
|
+
if (trimmed.startsWith("00") && digitsOnly.length > 2) {
|
|
1056
|
+
return `+${digitsOnly.slice(2)}`;
|
|
1057
|
+
}
|
|
1058
|
+
return `+${digitsOnly}`;
|
|
1059
|
+
}
|
|
1060
|
+
function normalizeAndValidatePhone(input) {
|
|
1061
|
+
const normalized = normalizePhoneNumber(input);
|
|
1062
|
+
if (!normalized) {
|
|
1063
|
+
return {
|
|
1064
|
+
input,
|
|
1065
|
+
normalized: null,
|
|
1066
|
+
valid: false,
|
|
1067
|
+
error: "Phone number is required"
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
if (!E164_REGEX.test(normalized)) {
|
|
1071
|
+
return {
|
|
1072
|
+
input,
|
|
1073
|
+
normalized,
|
|
1074
|
+
valid: false,
|
|
1075
|
+
error: "Phone number must be in E.164 format (+[country code][number])"
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
return {
|
|
1079
|
+
input,
|
|
1080
|
+
normalized,
|
|
1081
|
+
valid: true,
|
|
1082
|
+
error: null
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
function composePhoneNumber(countryDialCode, localNumber) {
|
|
1086
|
+
const normalizedDial = normalizePhoneNumber(countryDialCode);
|
|
1087
|
+
if (!normalizedDial) return "";
|
|
1088
|
+
const localDigits = typeof localNumber === "string" ? localNumber.replace(/\D/g, "") : "";
|
|
1089
|
+
if (!localDigits) return "";
|
|
1090
|
+
return `${normalizedDial}${localDigits}`;
|
|
1091
|
+
}
|
|
1092
|
+
function findPhoneCountryByCode(code) {
|
|
1093
|
+
if (!code) return void 0;
|
|
1094
|
+
const upperCode = code.toUpperCase();
|
|
1095
|
+
return PHONE_COUNTRIES.find((country) => country.code === upperCode);
|
|
1096
|
+
}
|
|
1097
|
+
function findPhoneCountryByDialCode(dialCode) {
|
|
1098
|
+
if (!dialCode) return void 0;
|
|
1099
|
+
const normalized = dialCode.startsWith("+") ? dialCode : `+${dialCode}`;
|
|
1100
|
+
return PHONE_COUNTRIES.find((country) => country.dialCode === normalized);
|
|
1101
|
+
}
|
|
1102
|
+
var DIAL_CODES_DESC = [...PHONE_COUNTRIES].sort((a, b) => b.dialCode.length - a.dialCode.length);
|
|
1103
|
+
function detectCountryFromE164(e164) {
|
|
1104
|
+
if (!e164 || !e164.startsWith("+")) return null;
|
|
1105
|
+
const normalized = "+" + e164.slice(1).replace(/\D/g, "");
|
|
1106
|
+
for (const country of DIAL_CODES_DESC) {
|
|
1107
|
+
const prefix = country.dialCode;
|
|
1108
|
+
if (normalized.startsWith(prefix)) {
|
|
1109
|
+
const local = normalized.slice(prefix.length);
|
|
1110
|
+
if (local.length > 0) {
|
|
1111
|
+
return { country, local };
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
return null;
|
|
1116
|
+
}
|
|
1117
|
+
function countryFlag(code) {
|
|
1118
|
+
return [...code.toUpperCase()].map((c) => String.fromCodePoint(127462 + c.charCodeAt(0) - 65)).join("");
|
|
1119
|
+
}
|
|
995
1120
|
|
|
996
1121
|
// src/services/auth.ts
|
|
997
1122
|
function collectDeviceFingerprint() {
|
|
@@ -3153,9 +3278,11 @@ var RealtimeService = class extends ServiceModule {
|
|
|
3153
3278
|
}
|
|
3154
3279
|
authenticate() {
|
|
3155
3280
|
const token = this.client.getSessionToken();
|
|
3281
|
+
const appId = this.client.getApplicationId();
|
|
3156
3282
|
this.sendWs({
|
|
3157
3283
|
type: "auth",
|
|
3158
|
-
token: token || void 0
|
|
3284
|
+
token: token || void 0,
|
|
3285
|
+
app_id: appId || void 0
|
|
3159
3286
|
});
|
|
3160
3287
|
}
|
|
3161
3288
|
handleMessage(msg) {
|
|
@@ -4213,6 +4340,70 @@ var CommunicationService = class extends ServiceModule {
|
|
|
4213
4340
|
}
|
|
4214
4341
|
};
|
|
4215
4342
|
|
|
4343
|
+
// src/services/notifications.ts
|
|
4344
|
+
var NotificationsService = class extends ServiceModule {
|
|
4345
|
+
constructor() {
|
|
4346
|
+
super(...arguments);
|
|
4347
|
+
this.basePath = "/notifications";
|
|
4348
|
+
}
|
|
4349
|
+
/**
|
|
4350
|
+
* List notifications for the authenticated user.
|
|
4351
|
+
*
|
|
4352
|
+
* @example
|
|
4353
|
+
* ```ts
|
|
4354
|
+
* // All unread
|
|
4355
|
+
* const { data } = await sm.notifications.list({ unread_only: true })
|
|
4356
|
+
*
|
|
4357
|
+
* // With pagination
|
|
4358
|
+
* const { data } = await sm.notifications.list({ limit: 10, cursor: lastCreatedAt })
|
|
4359
|
+
*
|
|
4360
|
+
* // Since last seen (reconnect catch-up)
|
|
4361
|
+
* const { data } = await sm.notifications.list({ unread_only: true, since: '2026-03-25T00:00:00Z' })
|
|
4362
|
+
* ```
|
|
4363
|
+
*/
|
|
4364
|
+
async list(params, options) {
|
|
4365
|
+
const qs = new URLSearchParams();
|
|
4366
|
+
if (params?.unread_only) qs.set("unread_only", "true");
|
|
4367
|
+
if (params?.kind) qs.set("kind", params.kind);
|
|
4368
|
+
if (params?.since) qs.set("since", params.since);
|
|
4369
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
4370
|
+
if (params?.cursor) qs.set("cursor", params.cursor);
|
|
4371
|
+
const query = qs.toString();
|
|
4372
|
+
const path = query ? `?${query}` : "";
|
|
4373
|
+
return this._get(path, options);
|
|
4374
|
+
}
|
|
4375
|
+
/**
|
|
4376
|
+
* Get the count of unread notifications.
|
|
4377
|
+
*
|
|
4378
|
+
* @example
|
|
4379
|
+
* ```ts
|
|
4380
|
+
* const { data } = await sm.notifications.unreadCount()
|
|
4381
|
+
* console.log(`${data.count} unread`)
|
|
4382
|
+
* ```
|
|
4383
|
+
*/
|
|
4384
|
+
async unreadCount(options) {
|
|
4385
|
+
return this._get("/unread-count", options);
|
|
4386
|
+
}
|
|
4387
|
+
/**
|
|
4388
|
+
* Mark a single notification as read.
|
|
4389
|
+
*/
|
|
4390
|
+
async markRead(id, options) {
|
|
4391
|
+
return this.patch(`/${id}/read`, void 0, options);
|
|
4392
|
+
}
|
|
4393
|
+
/**
|
|
4394
|
+
* Mark all notifications as read.
|
|
4395
|
+
*/
|
|
4396
|
+
async markAllRead(options) {
|
|
4397
|
+
return this.patch("/read-all", void 0, options);
|
|
4398
|
+
}
|
|
4399
|
+
/**
|
|
4400
|
+
* Dismiss a notification (soft delete).
|
|
4401
|
+
*/
|
|
4402
|
+
async dismiss(id, options) {
|
|
4403
|
+
return this.del(`/${id}`, options);
|
|
4404
|
+
}
|
|
4405
|
+
};
|
|
4406
|
+
|
|
4216
4407
|
// src/web-push.ts
|
|
4217
4408
|
var STORAGE_KEY = "scalemule_push_state";
|
|
4218
4409
|
var WebPushManager = class {
|
|
@@ -5663,6 +5854,13 @@ var AgentProjectsService = class extends ServiceModule {
|
|
|
5663
5854
|
options
|
|
5664
5855
|
);
|
|
5665
5856
|
}
|
|
5857
|
+
async startTask(taskId, agentId, applicationId, options) {
|
|
5858
|
+
return this.post(
|
|
5859
|
+
this.withAppId(`/tasks/${taskId}/start`, applicationId),
|
|
5860
|
+
{ agent_id: agentId },
|
|
5861
|
+
options
|
|
5862
|
+
);
|
|
5863
|
+
}
|
|
5666
5864
|
async submit(taskId, data, applicationId, options) {
|
|
5667
5865
|
return this.post(this.withAppId(`/tasks/${taskId}/submit`, applicationId), data, options);
|
|
5668
5866
|
}
|
|
@@ -5950,6 +6148,7 @@ var ScaleMule = class {
|
|
|
5950
6148
|
this.analytics = new AnalyticsService(this._client);
|
|
5951
6149
|
this.flags = new FlagsService(this._client);
|
|
5952
6150
|
this.communication = new CommunicationService(this._client);
|
|
6151
|
+
this.notifications = new NotificationsService(this._client);
|
|
5953
6152
|
this.scheduler = new SchedulerService(this._client);
|
|
5954
6153
|
this.permissions = new PermissionsService(this._client);
|
|
5955
6154
|
this.workspaces = new WorkspacesService(this._client);
|
|
@@ -6051,6 +6250,10 @@ var ScaleMule = class {
|
|
|
6051
6250
|
getBaseUrl() {
|
|
6052
6251
|
return this._client.getBaseUrl();
|
|
6053
6252
|
}
|
|
6253
|
+
/** The application ID, or null if not configured. */
|
|
6254
|
+
getApplicationId() {
|
|
6255
|
+
return this._client.getApplicationId();
|
|
6256
|
+
}
|
|
6054
6257
|
/** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
|
|
6055
6258
|
setWorkspaceContext(id) {
|
|
6056
6259
|
this._client.setWorkspaceContext(id);
|
|
@@ -6092,6 +6295,7 @@ export {
|
|
|
6092
6295
|
LeaderboardService,
|
|
6093
6296
|
ListingsService,
|
|
6094
6297
|
LoggerService,
|
|
6298
|
+
NotificationsService,
|
|
6095
6299
|
OrchestratorService,
|
|
6096
6300
|
PHONE_COUNTRIES,
|
|
6097
6301
|
PHOTO_BREAKPOINTS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalemule/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "Official TypeScript/JavaScript SDK for ScaleMule Backend-as-a-Service",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"LICENSE"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "tsup
|
|
26
|
+
"build": "tsup",
|
|
27
27
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
28
28
|
"test": "vitest run",
|
|
29
29
|
"test:watch": "vitest",
|
|
@@ -62,16 +62,13 @@
|
|
|
62
62
|
"node": ">=18.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
+
"@scalemule/ui": ">=0.0.1",
|
|
65
66
|
"semver": "^7.7.4"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
|
-
"@scalemule/ui": ">=0.0.1",
|
|
69
69
|
"browser-image-compression": ">=2.0.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependenciesMeta": {
|
|
72
|
-
"@scalemule/ui": {
|
|
73
|
-
"optional": false
|
|
74
|
-
},
|
|
75
72
|
"browser-image-compression": {
|
|
76
73
|
"optional": true
|
|
77
74
|
}
|