@scalemule/sdk 0.0.25 → 0.0.27
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 +97 -1
- package/dist/index.d.ts +97 -1
- package/dist/index.js +118 -2
- package/dist/index.mjs +117 -2
- package/package.json +1 -1
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;
|
|
@@ -2707,6 +2711,10 @@ interface RegisterPushTokenData {
|
|
|
2707
2711
|
app_version?: string;
|
|
2708
2712
|
os_version?: string;
|
|
2709
2713
|
device_model?: string;
|
|
2714
|
+
timezone?: string;
|
|
2715
|
+
language?: string;
|
|
2716
|
+
browser?: string;
|
|
2717
|
+
registration_source?: string;
|
|
2710
2718
|
}
|
|
2711
2719
|
declare class CommunicationService extends ServiceModule {
|
|
2712
2720
|
protected basePath: string;
|
|
@@ -2767,6 +2775,88 @@ declare class CommunicationService extends ServiceModule {
|
|
|
2767
2775
|
}): Promise<ApiResponse<MessageStatus>>;
|
|
2768
2776
|
}
|
|
2769
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
|
+
|
|
2770
2860
|
/**
|
|
2771
2861
|
* WebPushManager — Browser push notification subscription manager
|
|
2772
2862
|
*
|
|
@@ -2792,10 +2882,13 @@ interface WebPushManagerOptions {
|
|
|
2792
2882
|
serviceWorkerUrl?: string;
|
|
2793
2883
|
/** Required: HTTP transport abstraction */
|
|
2794
2884
|
fetcher: PushApiFetcher;
|
|
2885
|
+
/** Where the user subscribed (e.g., 'landing_prompt', 'post_signup', 'settings') */
|
|
2886
|
+
registrationSource?: string;
|
|
2795
2887
|
}
|
|
2796
2888
|
declare class WebPushManager {
|
|
2797
2889
|
private fetcher;
|
|
2798
2890
|
private swUrl;
|
|
2891
|
+
private registrationSource?;
|
|
2799
2892
|
private state;
|
|
2800
2893
|
private registration;
|
|
2801
2894
|
constructor(options: WebPushManagerOptions);
|
|
@@ -5448,6 +5541,7 @@ declare class ScaleMule {
|
|
|
5448
5541
|
readonly analytics: AnalyticsService;
|
|
5449
5542
|
readonly flags: FlagsService;
|
|
5450
5543
|
readonly communication: CommunicationService;
|
|
5544
|
+
readonly notifications: NotificationsService;
|
|
5451
5545
|
readonly scheduler: SchedulerService;
|
|
5452
5546
|
readonly permissions: PermissionsService;
|
|
5453
5547
|
readonly workspaces: WorkspacesService;
|
|
@@ -5513,6 +5607,8 @@ declare class ScaleMule {
|
|
|
5513
5607
|
clearAllAccounts(): Promise<void>;
|
|
5514
5608
|
/** The base URL being used for API requests. */
|
|
5515
5609
|
getBaseUrl(): string;
|
|
5610
|
+
/** The application ID, or null if not configured. */
|
|
5611
|
+
getApplicationId(): string | null;
|
|
5516
5612
|
/** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
|
|
5517
5613
|
setWorkspaceContext(id: string | null): void;
|
|
5518
5614
|
/** Get the current workspace ID, or null. */
|
|
@@ -5521,4 +5617,4 @@ declare class ScaleMule {
|
|
|
5521
5617
|
getClient(): ScaleMuleClient;
|
|
5522
5618
|
}
|
|
5523
5619
|
|
|
5524
|
-
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 };
|
|
5620
|
+
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;
|
|
@@ -2707,6 +2711,10 @@ interface RegisterPushTokenData {
|
|
|
2707
2711
|
app_version?: string;
|
|
2708
2712
|
os_version?: string;
|
|
2709
2713
|
device_model?: string;
|
|
2714
|
+
timezone?: string;
|
|
2715
|
+
language?: string;
|
|
2716
|
+
browser?: string;
|
|
2717
|
+
registration_source?: string;
|
|
2710
2718
|
}
|
|
2711
2719
|
declare class CommunicationService extends ServiceModule {
|
|
2712
2720
|
protected basePath: string;
|
|
@@ -2767,6 +2775,88 @@ declare class CommunicationService extends ServiceModule {
|
|
|
2767
2775
|
}): Promise<ApiResponse<MessageStatus>>;
|
|
2768
2776
|
}
|
|
2769
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
|
+
|
|
2770
2860
|
/**
|
|
2771
2861
|
* WebPushManager — Browser push notification subscription manager
|
|
2772
2862
|
*
|
|
@@ -2792,10 +2882,13 @@ interface WebPushManagerOptions {
|
|
|
2792
2882
|
serviceWorkerUrl?: string;
|
|
2793
2883
|
/** Required: HTTP transport abstraction */
|
|
2794
2884
|
fetcher: PushApiFetcher;
|
|
2885
|
+
/** Where the user subscribed (e.g., 'landing_prompt', 'post_signup', 'settings') */
|
|
2886
|
+
registrationSource?: string;
|
|
2795
2887
|
}
|
|
2796
2888
|
declare class WebPushManager {
|
|
2797
2889
|
private fetcher;
|
|
2798
2890
|
private swUrl;
|
|
2891
|
+
private registrationSource?;
|
|
2799
2892
|
private state;
|
|
2800
2893
|
private registration;
|
|
2801
2894
|
constructor(options: WebPushManagerOptions);
|
|
@@ -5448,6 +5541,7 @@ declare class ScaleMule {
|
|
|
5448
5541
|
readonly analytics: AnalyticsService;
|
|
5449
5542
|
readonly flags: FlagsService;
|
|
5450
5543
|
readonly communication: CommunicationService;
|
|
5544
|
+
readonly notifications: NotificationsService;
|
|
5451
5545
|
readonly scheduler: SchedulerService;
|
|
5452
5546
|
readonly permissions: PermissionsService;
|
|
5453
5547
|
readonly workspaces: WorkspacesService;
|
|
@@ -5513,6 +5607,8 @@ declare class ScaleMule {
|
|
|
5513
5607
|
clearAllAccounts(): Promise<void>;
|
|
5514
5608
|
/** The base URL being used for API requests. */
|
|
5515
5609
|
getBaseUrl(): string;
|
|
5610
|
+
/** The application ID, or null if not configured. */
|
|
5611
|
+
getApplicationId(): string | null;
|
|
5516
5612
|
/** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
|
|
5517
5613
|
setWorkspaceContext(id: string | null): void;
|
|
5518
5614
|
/** Get the current workspace ID, or null. */
|
|
@@ -5521,4 +5617,4 @@ declare class ScaleMule {
|
|
|
5521
5617
|
getClient(): ScaleMuleClient;
|
|
5522
5618
|
}
|
|
5523
5619
|
|
|
5524
|
-
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 };
|
|
5620
|
+
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,6 +319,7 @@ __export(index_exports, {
|
|
|
319
319
|
LeaderboardService: () => LeaderboardService,
|
|
320
320
|
ListingsService: () => ListingsService,
|
|
321
321
|
LoggerService: () => LoggerService,
|
|
322
|
+
NotificationsService: () => NotificationsService,
|
|
322
323
|
OrchestratorService: () => OrchestratorService,
|
|
323
324
|
PHONE_COUNTRIES: () => import_phone.PHONE_COUNTRIES,
|
|
324
325
|
PHOTO_BREAKPOINTS: () => PHOTO_BREAKPOINTS,
|
|
@@ -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
|
}
|
|
@@ -3512,9 +3518,11 @@ var RealtimeService = class extends ServiceModule {
|
|
|
3512
3518
|
}
|
|
3513
3519
|
authenticate() {
|
|
3514
3520
|
const token = this.client.getSessionToken();
|
|
3521
|
+
const appId = this.client.getApplicationId();
|
|
3515
3522
|
this.sendWs({
|
|
3516
3523
|
type: "auth",
|
|
3517
|
-
token: token || void 0
|
|
3524
|
+
token: token || void 0,
|
|
3525
|
+
app_id: appId || void 0
|
|
3518
3526
|
});
|
|
3519
3527
|
}
|
|
3520
3528
|
handleMessage(msg) {
|
|
@@ -4572,6 +4580,70 @@ var CommunicationService = class extends ServiceModule {
|
|
|
4572
4580
|
}
|
|
4573
4581
|
};
|
|
4574
4582
|
|
|
4583
|
+
// src/services/notifications.ts
|
|
4584
|
+
var NotificationsService = class extends ServiceModule {
|
|
4585
|
+
constructor() {
|
|
4586
|
+
super(...arguments);
|
|
4587
|
+
this.basePath = "/notifications";
|
|
4588
|
+
}
|
|
4589
|
+
/**
|
|
4590
|
+
* List notifications for the authenticated user.
|
|
4591
|
+
*
|
|
4592
|
+
* @example
|
|
4593
|
+
* ```ts
|
|
4594
|
+
* // All unread
|
|
4595
|
+
* const { data } = await sm.notifications.list({ unread_only: true })
|
|
4596
|
+
*
|
|
4597
|
+
* // With pagination
|
|
4598
|
+
* const { data } = await sm.notifications.list({ limit: 10, cursor: lastCreatedAt })
|
|
4599
|
+
*
|
|
4600
|
+
* // Since last seen (reconnect catch-up)
|
|
4601
|
+
* const { data } = await sm.notifications.list({ unread_only: true, since: '2026-03-25T00:00:00Z' })
|
|
4602
|
+
* ```
|
|
4603
|
+
*/
|
|
4604
|
+
async list(params, options) {
|
|
4605
|
+
const qs = new URLSearchParams();
|
|
4606
|
+
if (params?.unread_only) qs.set("unread_only", "true");
|
|
4607
|
+
if (params?.kind) qs.set("kind", params.kind);
|
|
4608
|
+
if (params?.since) qs.set("since", params.since);
|
|
4609
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
4610
|
+
if (params?.cursor) qs.set("cursor", params.cursor);
|
|
4611
|
+
const query = qs.toString();
|
|
4612
|
+
const path = query ? `?${query}` : "";
|
|
4613
|
+
return this._get(path, options);
|
|
4614
|
+
}
|
|
4615
|
+
/**
|
|
4616
|
+
* Get the count of unread notifications.
|
|
4617
|
+
*
|
|
4618
|
+
* @example
|
|
4619
|
+
* ```ts
|
|
4620
|
+
* const { data } = await sm.notifications.unreadCount()
|
|
4621
|
+
* console.log(`${data.count} unread`)
|
|
4622
|
+
* ```
|
|
4623
|
+
*/
|
|
4624
|
+
async unreadCount(options) {
|
|
4625
|
+
return this._get("/unread-count", options);
|
|
4626
|
+
}
|
|
4627
|
+
/**
|
|
4628
|
+
* Mark a single notification as read.
|
|
4629
|
+
*/
|
|
4630
|
+
async markRead(id, options) {
|
|
4631
|
+
return this.patch(`/${id}/read`, void 0, options);
|
|
4632
|
+
}
|
|
4633
|
+
/**
|
|
4634
|
+
* Mark all notifications as read.
|
|
4635
|
+
*/
|
|
4636
|
+
async markAllRead(options) {
|
|
4637
|
+
return this.patch("/read-all", void 0, options);
|
|
4638
|
+
}
|
|
4639
|
+
/**
|
|
4640
|
+
* Dismiss a notification (soft delete).
|
|
4641
|
+
*/
|
|
4642
|
+
async dismiss(id, options) {
|
|
4643
|
+
return this.del(`/${id}`, options);
|
|
4644
|
+
}
|
|
4645
|
+
};
|
|
4646
|
+
|
|
4575
4647
|
// src/web-push.ts
|
|
4576
4648
|
var STORAGE_KEY = "scalemule_push_state";
|
|
4577
4649
|
var WebPushManager = class {
|
|
@@ -4583,6 +4655,7 @@ var WebPushManager = class {
|
|
|
4583
4655
|
}
|
|
4584
4656
|
this.fetcher = options.fetcher;
|
|
4585
4657
|
this.swUrl = options.serviceWorkerUrl || "/sw.js";
|
|
4658
|
+
this.registrationSource = options.registrationSource;
|
|
4586
4659
|
try {
|
|
4587
4660
|
const stored = localStorage.getItem(STORAGE_KEY);
|
|
4588
4661
|
if (stored) {
|
|
@@ -4644,7 +4717,13 @@ var WebPushManager = class {
|
|
|
4644
4717
|
token: endpoint,
|
|
4645
4718
|
platform: "web",
|
|
4646
4719
|
device_id: resolvedDeviceId,
|
|
4647
|
-
subscription
|
|
4720
|
+
subscription,
|
|
4721
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
4722
|
+
language: navigator.language,
|
|
4723
|
+
browser: detectBrowser(),
|
|
4724
|
+
os_version: detectOS(),
|
|
4725
|
+
device_model: detectDeviceType(),
|
|
4726
|
+
registration_source: this.registrationSource
|
|
4648
4727
|
});
|
|
4649
4728
|
this.state = {
|
|
4650
4729
|
endpoint,
|
|
@@ -4740,6 +4819,37 @@ function generateDeviceId() {
|
|
|
4740
4819
|
return v.toString(16);
|
|
4741
4820
|
});
|
|
4742
4821
|
}
|
|
4822
|
+
function detectBrowser() {
|
|
4823
|
+
if (typeof navigator === "undefined") return "Unknown";
|
|
4824
|
+
const ua = navigator.userAgent;
|
|
4825
|
+
if (ua.includes("Firefox/")) return "Firefox/" + (ua.split("Firefox/")[1] || "").split(" ")[0];
|
|
4826
|
+
if (ua.includes("Edg/")) return "Edge/" + (ua.split("Edg/")[1] || "").split(" ")[0];
|
|
4827
|
+
if (ua.includes("Chrome/")) return "Chrome/" + (ua.split("Chrome/")[1] || "").split(" ")[0];
|
|
4828
|
+
if (ua.includes("Safari/") && !ua.includes("Chrome")) {
|
|
4829
|
+
const ver = (ua.split("Version/")[1] || "").split(" ")[0];
|
|
4830
|
+
return "Safari/" + ver;
|
|
4831
|
+
}
|
|
4832
|
+
return "Unknown";
|
|
4833
|
+
}
|
|
4834
|
+
function detectOS() {
|
|
4835
|
+
if (typeof navigator === "undefined") return "Unknown";
|
|
4836
|
+
const ua = navigator.userAgent;
|
|
4837
|
+
if (ua.includes("Windows NT")) return "Windows/" + ((ua.split("Windows NT ")[1] || "").split(/[;)]/)[0] || "");
|
|
4838
|
+
if (ua.includes("Mac OS X"))
|
|
4839
|
+
return "macOS/" + ((ua.split("Mac OS X ")[1] || "").split(/[;)]/)[0] || "").replace(/_/g, ".");
|
|
4840
|
+
if (ua.includes("Android")) return "Android/" + ((ua.split("Android ")[1] || "").split(/[;)]/)[0] || "");
|
|
4841
|
+
if (ua.includes("iPhone OS"))
|
|
4842
|
+
return "iOS/" + ((ua.split("iPhone OS ")[1] || "").split(" ")[0] || "").replace(/_/g, ".");
|
|
4843
|
+
if (ua.includes("Linux")) return "Linux";
|
|
4844
|
+
return "Unknown";
|
|
4845
|
+
}
|
|
4846
|
+
function detectDeviceType() {
|
|
4847
|
+
if (typeof navigator === "undefined") return "unknown";
|
|
4848
|
+
const ua = navigator.userAgent;
|
|
4849
|
+
if (/Mobi|Android.*Mobile|iPhone/i.test(ua)) return "mobile";
|
|
4850
|
+
if (/iPad|Android(?!.*Mobile)|Tablet/i.test(ua)) return "tablet";
|
|
4851
|
+
return "desktop";
|
|
4852
|
+
}
|
|
4743
4853
|
|
|
4744
4854
|
// src/web-push-sw.ts
|
|
4745
4855
|
var WEB_PUSH_SERVICE_WORKER = `
|
|
@@ -6271,6 +6381,7 @@ var ScaleMule = class {
|
|
|
6271
6381
|
this.analytics = new AnalyticsService(this._client);
|
|
6272
6382
|
this.flags = new FlagsService(this._client);
|
|
6273
6383
|
this.communication = new CommunicationService(this._client);
|
|
6384
|
+
this.notifications = new NotificationsService(this._client);
|
|
6274
6385
|
this.scheduler = new SchedulerService(this._client);
|
|
6275
6386
|
this.permissions = new PermissionsService(this._client);
|
|
6276
6387
|
this.workspaces = new WorkspacesService(this._client);
|
|
@@ -6372,6 +6483,10 @@ var ScaleMule = class {
|
|
|
6372
6483
|
getBaseUrl() {
|
|
6373
6484
|
return this._client.getBaseUrl();
|
|
6374
6485
|
}
|
|
6486
|
+
/** The application ID, or null if not configured. */
|
|
6487
|
+
getApplicationId() {
|
|
6488
|
+
return this._client.getApplicationId();
|
|
6489
|
+
}
|
|
6375
6490
|
/** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
|
|
6376
6491
|
setWorkspaceContext(id) {
|
|
6377
6492
|
this._client.setWorkspaceContext(id);
|
|
@@ -6414,6 +6529,7 @@ var index_default = ScaleMule;
|
|
|
6414
6529
|
LeaderboardService,
|
|
6415
6530
|
ListingsService,
|
|
6416
6531
|
LoggerService,
|
|
6532
|
+
NotificationsService,
|
|
6417
6533
|
OrchestratorService,
|
|
6418
6534
|
PHONE_COUNTRIES,
|
|
6419
6535
|
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
|
}
|
|
@@ -3153,9 +3158,11 @@ var RealtimeService = class extends ServiceModule {
|
|
|
3153
3158
|
}
|
|
3154
3159
|
authenticate() {
|
|
3155
3160
|
const token = this.client.getSessionToken();
|
|
3161
|
+
const appId = this.client.getApplicationId();
|
|
3156
3162
|
this.sendWs({
|
|
3157
3163
|
type: "auth",
|
|
3158
|
-
token: token || void 0
|
|
3164
|
+
token: token || void 0,
|
|
3165
|
+
app_id: appId || void 0
|
|
3159
3166
|
});
|
|
3160
3167
|
}
|
|
3161
3168
|
handleMessage(msg) {
|
|
@@ -4213,6 +4220,70 @@ var CommunicationService = class extends ServiceModule {
|
|
|
4213
4220
|
}
|
|
4214
4221
|
};
|
|
4215
4222
|
|
|
4223
|
+
// src/services/notifications.ts
|
|
4224
|
+
var NotificationsService = class extends ServiceModule {
|
|
4225
|
+
constructor() {
|
|
4226
|
+
super(...arguments);
|
|
4227
|
+
this.basePath = "/notifications";
|
|
4228
|
+
}
|
|
4229
|
+
/**
|
|
4230
|
+
* List notifications for the authenticated user.
|
|
4231
|
+
*
|
|
4232
|
+
* @example
|
|
4233
|
+
* ```ts
|
|
4234
|
+
* // All unread
|
|
4235
|
+
* const { data } = await sm.notifications.list({ unread_only: true })
|
|
4236
|
+
*
|
|
4237
|
+
* // With pagination
|
|
4238
|
+
* const { data } = await sm.notifications.list({ limit: 10, cursor: lastCreatedAt })
|
|
4239
|
+
*
|
|
4240
|
+
* // Since last seen (reconnect catch-up)
|
|
4241
|
+
* const { data } = await sm.notifications.list({ unread_only: true, since: '2026-03-25T00:00:00Z' })
|
|
4242
|
+
* ```
|
|
4243
|
+
*/
|
|
4244
|
+
async list(params, options) {
|
|
4245
|
+
const qs = new URLSearchParams();
|
|
4246
|
+
if (params?.unread_only) qs.set("unread_only", "true");
|
|
4247
|
+
if (params?.kind) qs.set("kind", params.kind);
|
|
4248
|
+
if (params?.since) qs.set("since", params.since);
|
|
4249
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
4250
|
+
if (params?.cursor) qs.set("cursor", params.cursor);
|
|
4251
|
+
const query = qs.toString();
|
|
4252
|
+
const path = query ? `?${query}` : "";
|
|
4253
|
+
return this._get(path, options);
|
|
4254
|
+
}
|
|
4255
|
+
/**
|
|
4256
|
+
* Get the count of unread notifications.
|
|
4257
|
+
*
|
|
4258
|
+
* @example
|
|
4259
|
+
* ```ts
|
|
4260
|
+
* const { data } = await sm.notifications.unreadCount()
|
|
4261
|
+
* console.log(`${data.count} unread`)
|
|
4262
|
+
* ```
|
|
4263
|
+
*/
|
|
4264
|
+
async unreadCount(options) {
|
|
4265
|
+
return this._get("/unread-count", options);
|
|
4266
|
+
}
|
|
4267
|
+
/**
|
|
4268
|
+
* Mark a single notification as read.
|
|
4269
|
+
*/
|
|
4270
|
+
async markRead(id, options) {
|
|
4271
|
+
return this.patch(`/${id}/read`, void 0, options);
|
|
4272
|
+
}
|
|
4273
|
+
/**
|
|
4274
|
+
* Mark all notifications as read.
|
|
4275
|
+
*/
|
|
4276
|
+
async markAllRead(options) {
|
|
4277
|
+
return this.patch("/read-all", void 0, options);
|
|
4278
|
+
}
|
|
4279
|
+
/**
|
|
4280
|
+
* Dismiss a notification (soft delete).
|
|
4281
|
+
*/
|
|
4282
|
+
async dismiss(id, options) {
|
|
4283
|
+
return this.del(`/${id}`, options);
|
|
4284
|
+
}
|
|
4285
|
+
};
|
|
4286
|
+
|
|
4216
4287
|
// src/web-push.ts
|
|
4217
4288
|
var STORAGE_KEY = "scalemule_push_state";
|
|
4218
4289
|
var WebPushManager = class {
|
|
@@ -4224,6 +4295,7 @@ var WebPushManager = class {
|
|
|
4224
4295
|
}
|
|
4225
4296
|
this.fetcher = options.fetcher;
|
|
4226
4297
|
this.swUrl = options.serviceWorkerUrl || "/sw.js";
|
|
4298
|
+
this.registrationSource = options.registrationSource;
|
|
4227
4299
|
try {
|
|
4228
4300
|
const stored = localStorage.getItem(STORAGE_KEY);
|
|
4229
4301
|
if (stored) {
|
|
@@ -4285,7 +4357,13 @@ var WebPushManager = class {
|
|
|
4285
4357
|
token: endpoint,
|
|
4286
4358
|
platform: "web",
|
|
4287
4359
|
device_id: resolvedDeviceId,
|
|
4288
|
-
subscription
|
|
4360
|
+
subscription,
|
|
4361
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
4362
|
+
language: navigator.language,
|
|
4363
|
+
browser: detectBrowser(),
|
|
4364
|
+
os_version: detectOS(),
|
|
4365
|
+
device_model: detectDeviceType(),
|
|
4366
|
+
registration_source: this.registrationSource
|
|
4289
4367
|
});
|
|
4290
4368
|
this.state = {
|
|
4291
4369
|
endpoint,
|
|
@@ -4381,6 +4459,37 @@ function generateDeviceId() {
|
|
|
4381
4459
|
return v.toString(16);
|
|
4382
4460
|
});
|
|
4383
4461
|
}
|
|
4462
|
+
function detectBrowser() {
|
|
4463
|
+
if (typeof navigator === "undefined") return "Unknown";
|
|
4464
|
+
const ua = navigator.userAgent;
|
|
4465
|
+
if (ua.includes("Firefox/")) return "Firefox/" + (ua.split("Firefox/")[1] || "").split(" ")[0];
|
|
4466
|
+
if (ua.includes("Edg/")) return "Edge/" + (ua.split("Edg/")[1] || "").split(" ")[0];
|
|
4467
|
+
if (ua.includes("Chrome/")) return "Chrome/" + (ua.split("Chrome/")[1] || "").split(" ")[0];
|
|
4468
|
+
if (ua.includes("Safari/") && !ua.includes("Chrome")) {
|
|
4469
|
+
const ver = (ua.split("Version/")[1] || "").split(" ")[0];
|
|
4470
|
+
return "Safari/" + ver;
|
|
4471
|
+
}
|
|
4472
|
+
return "Unknown";
|
|
4473
|
+
}
|
|
4474
|
+
function detectOS() {
|
|
4475
|
+
if (typeof navigator === "undefined") return "Unknown";
|
|
4476
|
+
const ua = navigator.userAgent;
|
|
4477
|
+
if (ua.includes("Windows NT")) return "Windows/" + ((ua.split("Windows NT ")[1] || "").split(/[;)]/)[0] || "");
|
|
4478
|
+
if (ua.includes("Mac OS X"))
|
|
4479
|
+
return "macOS/" + ((ua.split("Mac OS X ")[1] || "").split(/[;)]/)[0] || "").replace(/_/g, ".");
|
|
4480
|
+
if (ua.includes("Android")) return "Android/" + ((ua.split("Android ")[1] || "").split(/[;)]/)[0] || "");
|
|
4481
|
+
if (ua.includes("iPhone OS"))
|
|
4482
|
+
return "iOS/" + ((ua.split("iPhone OS ")[1] || "").split(" ")[0] || "").replace(/_/g, ".");
|
|
4483
|
+
if (ua.includes("Linux")) return "Linux";
|
|
4484
|
+
return "Unknown";
|
|
4485
|
+
}
|
|
4486
|
+
function detectDeviceType() {
|
|
4487
|
+
if (typeof navigator === "undefined") return "unknown";
|
|
4488
|
+
const ua = navigator.userAgent;
|
|
4489
|
+
if (/Mobi|Android.*Mobile|iPhone/i.test(ua)) return "mobile";
|
|
4490
|
+
if (/iPad|Android(?!.*Mobile)|Tablet/i.test(ua)) return "tablet";
|
|
4491
|
+
return "desktop";
|
|
4492
|
+
}
|
|
4384
4493
|
|
|
4385
4494
|
// src/web-push-sw.ts
|
|
4386
4495
|
var WEB_PUSH_SERVICE_WORKER = `
|
|
@@ -5912,6 +6021,7 @@ var ScaleMule = class {
|
|
|
5912
6021
|
this.analytics = new AnalyticsService(this._client);
|
|
5913
6022
|
this.flags = new FlagsService(this._client);
|
|
5914
6023
|
this.communication = new CommunicationService(this._client);
|
|
6024
|
+
this.notifications = new NotificationsService(this._client);
|
|
5915
6025
|
this.scheduler = new SchedulerService(this._client);
|
|
5916
6026
|
this.permissions = new PermissionsService(this._client);
|
|
5917
6027
|
this.workspaces = new WorkspacesService(this._client);
|
|
@@ -6013,6 +6123,10 @@ var ScaleMule = class {
|
|
|
6013
6123
|
getBaseUrl() {
|
|
6014
6124
|
return this._client.getBaseUrl();
|
|
6015
6125
|
}
|
|
6126
|
+
/** The application ID, or null if not configured. */
|
|
6127
|
+
getApplicationId() {
|
|
6128
|
+
return this._client.getApplicationId();
|
|
6129
|
+
}
|
|
6016
6130
|
/** Set the active workspace context. All subsequent requests include this as x-sm-workspace-id. */
|
|
6017
6131
|
setWorkspaceContext(id) {
|
|
6018
6132
|
this._client.setWorkspaceContext(id);
|
|
@@ -6054,6 +6168,7 @@ export {
|
|
|
6054
6168
|
LeaderboardService,
|
|
6055
6169
|
ListingsService,
|
|
6056
6170
|
LoggerService,
|
|
6171
|
+
NotificationsService,
|
|
6057
6172
|
OrchestratorService,
|
|
6058
6173
|
PHONE_COUNTRIES,
|
|
6059
6174
|
PHOTO_BREAKPOINTS,
|