@scalemule/sdk 0.0.36 → 0.0.38
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 +153 -1
- package/dist/index.d.ts +153 -1
- package/dist/index.js +202 -4
- package/dist/index.mjs +202 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1134,6 +1134,23 @@ declare class StorageService extends ServiceModule {
|
|
|
1134
1134
|
* @returns The completed file record with id, url, etc.
|
|
1135
1135
|
*/
|
|
1136
1136
|
upload(file: File | Blob, options?: UploadOptions): Promise<ApiResponse<FileInfo>>;
|
|
1137
|
+
/**
|
|
1138
|
+
* Upload a file as a private attachment (e.g. chat / DM attachment).
|
|
1139
|
+
*
|
|
1140
|
+
* Same browser→S3 pipeline as {@link upload}, but enforces:
|
|
1141
|
+
* - `is_public: false` — caller cannot opt out
|
|
1142
|
+
* - no client-side compression — preserve the original bytes
|
|
1143
|
+
* - fail-closed if storage returns `is_public: true` for any reason
|
|
1144
|
+
*
|
|
1145
|
+
* The shared primitive used by `@scalemule/chat`'s chat-attachment uploader
|
|
1146
|
+
* and by `@scalemule/nextjs`'s `useMedia()` when an app's media policy is
|
|
1147
|
+
* `fast_trusted`. Both packages call this method via `@scalemule/sdk` —
|
|
1148
|
+
* `@scalemule/nextjs` does not depend on `@scalemule/chat`.
|
|
1149
|
+
*
|
|
1150
|
+
* See ADR-2026-04-26 (realtime-chat media pipeline) and
|
|
1151
|
+
* docs/MEDIA-UPLOADS.md for the full pattern.
|
|
1152
|
+
*/
|
|
1153
|
+
uploadPrivate(file: File | Blob, options?: Omit<UploadOptions, 'isPublic' | 'skipCompression'>): Promise<ApiResponse<FileInfo>>;
|
|
1137
1154
|
private uploadDirect;
|
|
1138
1155
|
private uploadMultipart;
|
|
1139
1156
|
private abortMultipart;
|
|
@@ -1832,6 +1849,9 @@ declare class DataService extends ServiceModule {
|
|
|
1832
1849
|
* PATCH /messages/{id} → edit message
|
|
1833
1850
|
* DELETE /messages/{id} → delete message
|
|
1834
1851
|
* POST /messages/{id}/reactions → add reaction
|
|
1852
|
+
* POST /messages/{id}/pin → pin message
|
|
1853
|
+
* DELETE /messages/{id}/pin → unpin message
|
|
1854
|
+
* GET /conversations/{id}/pins → list pinned messages
|
|
1835
1855
|
* POST /conversations/{id}/typing → send typing indicator
|
|
1836
1856
|
* POST /conversations/{id}/read → mark as read
|
|
1837
1857
|
* GET /conversations/{id}/read-status → get read status
|
|
@@ -1875,6 +1895,8 @@ interface ChatMessage {
|
|
|
1875
1895
|
latest_reply_at?: string;
|
|
1876
1896
|
reply_user_ids?: string[];
|
|
1877
1897
|
is_thread_broadcast?: boolean;
|
|
1898
|
+
is_pinned?: boolean;
|
|
1899
|
+
pinned_at?: string;
|
|
1878
1900
|
}
|
|
1879
1901
|
interface ReadStatus {
|
|
1880
1902
|
user_id: string;
|
|
@@ -1886,6 +1908,15 @@ interface ChatReaction {
|
|
|
1886
1908
|
message_id: string;
|
|
1887
1909
|
created_at: string;
|
|
1888
1910
|
}
|
|
1911
|
+
interface MessagePin {
|
|
1912
|
+
message_id: string;
|
|
1913
|
+
conversation_id: string;
|
|
1914
|
+
pinned_by_user_id: string;
|
|
1915
|
+
pinned_at: string;
|
|
1916
|
+
}
|
|
1917
|
+
interface PinnedMessagesResponse {
|
|
1918
|
+
pins: MessagePin[];
|
|
1919
|
+
}
|
|
1889
1920
|
declare class ChatService extends ServiceModule {
|
|
1890
1921
|
protected basePath: string;
|
|
1891
1922
|
createConversation(data: {
|
|
@@ -1924,6 +1955,11 @@ declare class ChatService extends ServiceModule {
|
|
|
1924
1955
|
addReaction(messageId: string, data: {
|
|
1925
1956
|
emoji: string;
|
|
1926
1957
|
}, options?: RequestOptions): Promise<ApiResponse<ChatReaction>>;
|
|
1958
|
+
pinMessage(messageId: string, options?: RequestOptions): Promise<ApiResponse<MessagePin>>;
|
|
1959
|
+
unpinMessage(messageId: string, options?: RequestOptions): Promise<ApiResponse<{
|
|
1960
|
+
unpinned: boolean;
|
|
1961
|
+
}>>;
|
|
1962
|
+
getPinnedMessages(conversationId: string, options?: RequestOptions): Promise<ApiResponse<PinnedMessagesResponse>>;
|
|
1927
1963
|
sendTyping(conversationId: string, options?: RequestOptions): Promise<ApiResponse<{
|
|
1928
1964
|
sent: boolean;
|
|
1929
1965
|
}>>;
|
|
@@ -2271,7 +2307,12 @@ declare class ReferralsService extends ServiceModule {
|
|
|
2271
2307
|
|
|
2272
2308
|
interface Customer {
|
|
2273
2309
|
id: string;
|
|
2310
|
+
sm_application_id?: string;
|
|
2311
|
+
account_id?: string;
|
|
2312
|
+
sm_user_id?: string;
|
|
2313
|
+
billing_mode?: 'test' | 'live';
|
|
2274
2314
|
stripe_customer_id?: string;
|
|
2315
|
+
stripe_account_id?: string | null;
|
|
2275
2316
|
email: string;
|
|
2276
2317
|
metadata?: Record<string, unknown>;
|
|
2277
2318
|
created_at: string;
|
|
@@ -2291,6 +2332,10 @@ interface Subscription {
|
|
|
2291
2332
|
interface Invoice {
|
|
2292
2333
|
id: string;
|
|
2293
2334
|
customer_id: string;
|
|
2335
|
+
sm_application_id?: string;
|
|
2336
|
+
account_id?: string;
|
|
2337
|
+
billing_mode?: 'test' | 'live';
|
|
2338
|
+
stripe_account_id?: string | null;
|
|
2294
2339
|
stripe_invoice_id?: string;
|
|
2295
2340
|
amount_due: number;
|
|
2296
2341
|
amount_paid: number;
|
|
@@ -2310,6 +2355,10 @@ interface UsageSummary$1 {
|
|
|
2310
2355
|
interface PaymentMethod {
|
|
2311
2356
|
id: string;
|
|
2312
2357
|
customer_id: string;
|
|
2358
|
+
sm_application_id?: string;
|
|
2359
|
+
account_id?: string;
|
|
2360
|
+
billing_mode?: 'test' | 'live';
|
|
2361
|
+
stripe_account_id?: string | null;
|
|
2313
2362
|
stripe_payment_method_id?: string;
|
|
2314
2363
|
type: string;
|
|
2315
2364
|
last4?: string;
|
|
@@ -2319,6 +2368,30 @@ interface PaymentMethod {
|
|
|
2319
2368
|
is_default: boolean;
|
|
2320
2369
|
created_at: string;
|
|
2321
2370
|
}
|
|
2371
|
+
/**
|
|
2372
|
+
* Identifies the target account for an account-scoped billing call.
|
|
2373
|
+
* `billing_mode` defaults to the application's configured mode if omitted.
|
|
2374
|
+
*/
|
|
2375
|
+
interface AccountScopedBillingRequest {
|
|
2376
|
+
account_id: string;
|
|
2377
|
+
billing_mode?: 'test' | 'live';
|
|
2378
|
+
}
|
|
2379
|
+
interface PortalSession {
|
|
2380
|
+
url: string;
|
|
2381
|
+
expires_at: string;
|
|
2382
|
+
}
|
|
2383
|
+
interface AttachPaymentMethodRequest {
|
|
2384
|
+
stripe_payment_method_id: string;
|
|
2385
|
+
set_default?: boolean;
|
|
2386
|
+
}
|
|
2387
|
+
interface InvoiceListParams {
|
|
2388
|
+
limit?: number;
|
|
2389
|
+
cursor?: string;
|
|
2390
|
+
}
|
|
2391
|
+
interface InvoiceListResponse {
|
|
2392
|
+
data: Invoice[];
|
|
2393
|
+
next_cursor?: string | null;
|
|
2394
|
+
}
|
|
2322
2395
|
interface ConnectedAccount {
|
|
2323
2396
|
id: string;
|
|
2324
2397
|
email: string;
|
|
@@ -2466,14 +2539,27 @@ interface ConnectedSubscriptionListParams extends PaginationParams {
|
|
|
2466
2539
|
declare class BillingService extends ServiceModule {
|
|
2467
2540
|
protected basePath: string;
|
|
2468
2541
|
private retiredSurface;
|
|
2542
|
+
/** @deprecated Use `getAccountCustomer({ account_id })`. Targets the user-scoped legacy endpoint. */
|
|
2469
2543
|
createCustomer(data: {
|
|
2470
2544
|
email: string;
|
|
2471
2545
|
name?: string;
|
|
2472
2546
|
}, options?: RequestOptions): Promise<ApiResponse<Customer>>;
|
|
2547
|
+
/** @deprecated Use `attachAccountPaymentMethod({ account_id }, ...)`. Targets the user-scoped legacy endpoint. */
|
|
2473
2548
|
addPaymentMethod(data: {
|
|
2474
2549
|
type: string;
|
|
2475
2550
|
token: string;
|
|
2476
2551
|
}, options?: RequestOptions): Promise<ApiResponse<PaymentMethod>>;
|
|
2552
|
+
private accountBase;
|
|
2553
|
+
getAccountCustomer(req: AccountScopedBillingRequest, options?: RequestOptions): Promise<ApiResponse<Customer>>;
|
|
2554
|
+
listAccountPaymentMethods(req: AccountScopedBillingRequest, options?: RequestOptions): Promise<ApiResponse<PaymentMethod[]>>;
|
|
2555
|
+
attachAccountPaymentMethod(req: AccountScopedBillingRequest, body: AttachPaymentMethodRequest, options?: RequestOptions): Promise<ApiResponse<PaymentMethod>>;
|
|
2556
|
+
detachAccountPaymentMethod(req: AccountScopedBillingRequest, paymentMethodId: string, options?: RequestOptions): Promise<ApiResponse<void>>;
|
|
2557
|
+
setDefaultAccountPaymentMethod(req: AccountScopedBillingRequest, paymentMethodId: string, options?: RequestOptions): Promise<ApiResponse<PaymentMethod>>;
|
|
2558
|
+
listAccountInvoices(req: AccountScopedBillingRequest, params?: InvoiceListParams, options?: RequestOptions): Promise<ApiResponse<InvoiceListResponse>>;
|
|
2559
|
+
getAccountInvoice(req: AccountScopedBillingRequest, invoiceId: string, options?: RequestOptions): Promise<ApiResponse<Invoice>>;
|
|
2560
|
+
createAccountPortalSession(req: AccountScopedBillingRequest, body?: {
|
|
2561
|
+
return_url?: string;
|
|
2562
|
+
}, options?: RequestOptions): Promise<ApiResponse<PortalSession>>;
|
|
2477
2563
|
subscribe(data: {
|
|
2478
2564
|
customer_id: string;
|
|
2479
2565
|
plan_id: string;
|
|
@@ -4153,8 +4239,39 @@ interface TransformOptions {
|
|
|
4153
4239
|
* URLs built with these sizes + fit=cover get instant cache hits (no server-side transform).
|
|
4154
4240
|
*/
|
|
4155
4241
|
declare const PHOTO_BREAKPOINTS: readonly [36, 150, 320, 640, 1080];
|
|
4242
|
+
/** Result of {@link PhotoService.uploadViaStorage}. */
|
|
4243
|
+
interface UploadViaStorageResult {
|
|
4244
|
+
/** Storage file_id — pass this to chat-message attachment metadata. */
|
|
4245
|
+
file_id: string;
|
|
4246
|
+
/**
|
|
4247
|
+
* Photo service's photo_id. Use with `getTransformUrl()` /
|
|
4248
|
+
* `getOptimalUrl()` to fetch responsive variants. `null` when register
|
|
4249
|
+
* failed after a successful storage upload (the file_id is still usable
|
|
4250
|
+
* as a generic storage file).
|
|
4251
|
+
*/
|
|
4252
|
+
photo_id: string | null;
|
|
4253
|
+
/**
|
|
4254
|
+
* Short-lived signed URL to the original bytes — usable immediately on the
|
|
4255
|
+
* recipient side, before optimization completes.
|
|
4256
|
+
*/
|
|
4257
|
+
original_view_url: string | null;
|
|
4258
|
+
/**
|
|
4259
|
+
* Resolves once the optimization worker finishes (or times out at 10s).
|
|
4260
|
+
* On resolution: a transform URL pointing at the largest pre-cached
|
|
4261
|
+
* breakpoint. On timeout: `null` — caller should fall back to
|
|
4262
|
+
* `getTransformUrl()` which uses the on-demand transform path.
|
|
4263
|
+
*/
|
|
4264
|
+
optimized_url_promise: Promise<string | null>;
|
|
4265
|
+
}
|
|
4156
4266
|
declare class PhotoService extends ServiceModule {
|
|
4267
|
+
private readonly storage;
|
|
4157
4268
|
protected basePath: string;
|
|
4269
|
+
/**
|
|
4270
|
+
* @param storage Required for {@link uploadViaStorage}. Wired up by the
|
|
4271
|
+
* top-level {@link ScaleMule} constructor — most call sites should not
|
|
4272
|
+
* instantiate `PhotoService` directly.
|
|
4273
|
+
*/
|
|
4274
|
+
constructor(client: ScaleMuleClient, storage: StorageService);
|
|
4158
4275
|
upload(file: File | Blob, uploadOptions?: {
|
|
4159
4276
|
metadata?: Record<string, unknown>;
|
|
4160
4277
|
onProgress?: (progress: number) => void;
|
|
@@ -4242,6 +4359,41 @@ declare class PhotoService extends ServiceModule {
|
|
|
4242
4359
|
fileId: string;
|
|
4243
4360
|
userId?: string;
|
|
4244
4361
|
}, requestOptions?: RequestOptions): Promise<ApiResponse<PhotoInfo>>;
|
|
4362
|
+
/**
|
|
4363
|
+
* Upload a file to storage (browser → S3 direct, private, uncompressed) and
|
|
4364
|
+
* register it with the photo service so optimization + transform URLs work.
|
|
4365
|
+
*
|
|
4366
|
+
* The canonical chat-attachment / progressive-image upload primitive. Same
|
|
4367
|
+
* presigned-direct-to-S3 path as `storage.uploadPrivate()`, plus a follow-up
|
|
4368
|
+
* `photo.register()` call so `getTransformUrl()` / `getOptimalUrl()` return
|
|
4369
|
+
* usable URLs.
|
|
4370
|
+
*
|
|
4371
|
+
* The returned `optimized_url_promise` resolves once the photo's
|
|
4372
|
+
* `optimization_status` flips to `completed` (or once a 10s timeout fires;
|
|
4373
|
+
* the caller can still use `getTransformUrl()` directly — the on-demand
|
|
4374
|
+
* transform path produces a variant even before pre-rendered breakpoints
|
|
4375
|
+
* are cached). Phase 3 of ADR-2026-04-26 replaces the poll with a realtime
|
|
4376
|
+
* subscription.
|
|
4377
|
+
*
|
|
4378
|
+
* If `register()` fails after a successful storage upload (e.g. scan times
|
|
4379
|
+
* out), the file is *not* lost: the returned `file_id` is still valid as a
|
|
4380
|
+
* generic storage file. The SDK logs a warning and resolves
|
|
4381
|
+
* `optimized_url_promise` to `null`.
|
|
4382
|
+
*/
|
|
4383
|
+
uploadViaStorage(file: File | Blob, uploadOptions?: {
|
|
4384
|
+
userId?: string;
|
|
4385
|
+
filename?: string;
|
|
4386
|
+
metadata?: Record<string, unknown>;
|
|
4387
|
+
onProgress?: (progress: number) => void;
|
|
4388
|
+
signal?: AbortSignal;
|
|
4389
|
+
}, requestOptions?: RequestOptions): Promise<ApiResponse<UploadViaStorageResult>>;
|
|
4390
|
+
/**
|
|
4391
|
+
* Poll {@link get} until the photo's `optimization_status` is `completed`
|
|
4392
|
+
* or the 10s timeout fires. Resolves to a usable transform URL on success;
|
|
4393
|
+
* `null` on timeout (caller should fall back to {@link getTransformUrl}
|
|
4394
|
+
* which uses the on-demand transform path).
|
|
4395
|
+
*/
|
|
4396
|
+
private pollOptimizationComplete;
|
|
4245
4397
|
/** @deprecated Use upload() instead */
|
|
4246
4398
|
uploadPhoto(file: File | Blob, options?: {
|
|
4247
4399
|
metadata?: Record<string, unknown>;
|
|
@@ -6052,4 +6204,4 @@ declare class ScaleMule {
|
|
|
6052
6204
|
getClient(): ScaleMuleClient;
|
|
6053
6205
|
}
|
|
6054
6206
|
|
|
6055
|
-
export { type AccountBalance, type AccountSwitcherPrivacy, 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 CallParticipant, type CallSession, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, ConferenceService, type ConferenceSettings, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type GenerationJob as CreatorJob, CreatorMakerService, type GenerationOutput as CreatorOutput, type CreatorProject, type CreatorUsage, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type DirectoryUser, type DirectoryUserDetail, type DirectoryUsersListResponse, 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 GenerateInput, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type JoinCallResponse, type KnownAccount, type KnownAccountDisplay, 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 SearchUsersParams, 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 StylePreset, 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 WebrtcStats, 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 };
|
|
6207
|
+
export { type AccountBalance, type AccountSwitcherPrivacy, 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 CallParticipant, type CallSession, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, ConferenceService, type ConferenceSettings, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type GenerationJob as CreatorJob, CreatorMakerService, type GenerationOutput as CreatorOutput, type CreatorProject, type CreatorUsage, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type DirectoryUser, type DirectoryUserDetail, type DirectoryUsersListResponse, 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 GenerateInput, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type JoinCallResponse, type KnownAccount, type KnownAccountDisplay, 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 MessagePin, 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 PinnedMessagesResponse, 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 SearchUsersParams, 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 StylePreset, 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 WebrtcStats, 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
|
@@ -1134,6 +1134,23 @@ declare class StorageService extends ServiceModule {
|
|
|
1134
1134
|
* @returns The completed file record with id, url, etc.
|
|
1135
1135
|
*/
|
|
1136
1136
|
upload(file: File | Blob, options?: UploadOptions): Promise<ApiResponse<FileInfo>>;
|
|
1137
|
+
/**
|
|
1138
|
+
* Upload a file as a private attachment (e.g. chat / DM attachment).
|
|
1139
|
+
*
|
|
1140
|
+
* Same browser→S3 pipeline as {@link upload}, but enforces:
|
|
1141
|
+
* - `is_public: false` — caller cannot opt out
|
|
1142
|
+
* - no client-side compression — preserve the original bytes
|
|
1143
|
+
* - fail-closed if storage returns `is_public: true` for any reason
|
|
1144
|
+
*
|
|
1145
|
+
* The shared primitive used by `@scalemule/chat`'s chat-attachment uploader
|
|
1146
|
+
* and by `@scalemule/nextjs`'s `useMedia()` when an app's media policy is
|
|
1147
|
+
* `fast_trusted`. Both packages call this method via `@scalemule/sdk` —
|
|
1148
|
+
* `@scalemule/nextjs` does not depend on `@scalemule/chat`.
|
|
1149
|
+
*
|
|
1150
|
+
* See ADR-2026-04-26 (realtime-chat media pipeline) and
|
|
1151
|
+
* docs/MEDIA-UPLOADS.md for the full pattern.
|
|
1152
|
+
*/
|
|
1153
|
+
uploadPrivate(file: File | Blob, options?: Omit<UploadOptions, 'isPublic' | 'skipCompression'>): Promise<ApiResponse<FileInfo>>;
|
|
1137
1154
|
private uploadDirect;
|
|
1138
1155
|
private uploadMultipart;
|
|
1139
1156
|
private abortMultipart;
|
|
@@ -1832,6 +1849,9 @@ declare class DataService extends ServiceModule {
|
|
|
1832
1849
|
* PATCH /messages/{id} → edit message
|
|
1833
1850
|
* DELETE /messages/{id} → delete message
|
|
1834
1851
|
* POST /messages/{id}/reactions → add reaction
|
|
1852
|
+
* POST /messages/{id}/pin → pin message
|
|
1853
|
+
* DELETE /messages/{id}/pin → unpin message
|
|
1854
|
+
* GET /conversations/{id}/pins → list pinned messages
|
|
1835
1855
|
* POST /conversations/{id}/typing → send typing indicator
|
|
1836
1856
|
* POST /conversations/{id}/read → mark as read
|
|
1837
1857
|
* GET /conversations/{id}/read-status → get read status
|
|
@@ -1875,6 +1895,8 @@ interface ChatMessage {
|
|
|
1875
1895
|
latest_reply_at?: string;
|
|
1876
1896
|
reply_user_ids?: string[];
|
|
1877
1897
|
is_thread_broadcast?: boolean;
|
|
1898
|
+
is_pinned?: boolean;
|
|
1899
|
+
pinned_at?: string;
|
|
1878
1900
|
}
|
|
1879
1901
|
interface ReadStatus {
|
|
1880
1902
|
user_id: string;
|
|
@@ -1886,6 +1908,15 @@ interface ChatReaction {
|
|
|
1886
1908
|
message_id: string;
|
|
1887
1909
|
created_at: string;
|
|
1888
1910
|
}
|
|
1911
|
+
interface MessagePin {
|
|
1912
|
+
message_id: string;
|
|
1913
|
+
conversation_id: string;
|
|
1914
|
+
pinned_by_user_id: string;
|
|
1915
|
+
pinned_at: string;
|
|
1916
|
+
}
|
|
1917
|
+
interface PinnedMessagesResponse {
|
|
1918
|
+
pins: MessagePin[];
|
|
1919
|
+
}
|
|
1889
1920
|
declare class ChatService extends ServiceModule {
|
|
1890
1921
|
protected basePath: string;
|
|
1891
1922
|
createConversation(data: {
|
|
@@ -1924,6 +1955,11 @@ declare class ChatService extends ServiceModule {
|
|
|
1924
1955
|
addReaction(messageId: string, data: {
|
|
1925
1956
|
emoji: string;
|
|
1926
1957
|
}, options?: RequestOptions): Promise<ApiResponse<ChatReaction>>;
|
|
1958
|
+
pinMessage(messageId: string, options?: RequestOptions): Promise<ApiResponse<MessagePin>>;
|
|
1959
|
+
unpinMessage(messageId: string, options?: RequestOptions): Promise<ApiResponse<{
|
|
1960
|
+
unpinned: boolean;
|
|
1961
|
+
}>>;
|
|
1962
|
+
getPinnedMessages(conversationId: string, options?: RequestOptions): Promise<ApiResponse<PinnedMessagesResponse>>;
|
|
1927
1963
|
sendTyping(conversationId: string, options?: RequestOptions): Promise<ApiResponse<{
|
|
1928
1964
|
sent: boolean;
|
|
1929
1965
|
}>>;
|
|
@@ -2271,7 +2307,12 @@ declare class ReferralsService extends ServiceModule {
|
|
|
2271
2307
|
|
|
2272
2308
|
interface Customer {
|
|
2273
2309
|
id: string;
|
|
2310
|
+
sm_application_id?: string;
|
|
2311
|
+
account_id?: string;
|
|
2312
|
+
sm_user_id?: string;
|
|
2313
|
+
billing_mode?: 'test' | 'live';
|
|
2274
2314
|
stripe_customer_id?: string;
|
|
2315
|
+
stripe_account_id?: string | null;
|
|
2275
2316
|
email: string;
|
|
2276
2317
|
metadata?: Record<string, unknown>;
|
|
2277
2318
|
created_at: string;
|
|
@@ -2291,6 +2332,10 @@ interface Subscription {
|
|
|
2291
2332
|
interface Invoice {
|
|
2292
2333
|
id: string;
|
|
2293
2334
|
customer_id: string;
|
|
2335
|
+
sm_application_id?: string;
|
|
2336
|
+
account_id?: string;
|
|
2337
|
+
billing_mode?: 'test' | 'live';
|
|
2338
|
+
stripe_account_id?: string | null;
|
|
2294
2339
|
stripe_invoice_id?: string;
|
|
2295
2340
|
amount_due: number;
|
|
2296
2341
|
amount_paid: number;
|
|
@@ -2310,6 +2355,10 @@ interface UsageSummary$1 {
|
|
|
2310
2355
|
interface PaymentMethod {
|
|
2311
2356
|
id: string;
|
|
2312
2357
|
customer_id: string;
|
|
2358
|
+
sm_application_id?: string;
|
|
2359
|
+
account_id?: string;
|
|
2360
|
+
billing_mode?: 'test' | 'live';
|
|
2361
|
+
stripe_account_id?: string | null;
|
|
2313
2362
|
stripe_payment_method_id?: string;
|
|
2314
2363
|
type: string;
|
|
2315
2364
|
last4?: string;
|
|
@@ -2319,6 +2368,30 @@ interface PaymentMethod {
|
|
|
2319
2368
|
is_default: boolean;
|
|
2320
2369
|
created_at: string;
|
|
2321
2370
|
}
|
|
2371
|
+
/**
|
|
2372
|
+
* Identifies the target account for an account-scoped billing call.
|
|
2373
|
+
* `billing_mode` defaults to the application's configured mode if omitted.
|
|
2374
|
+
*/
|
|
2375
|
+
interface AccountScopedBillingRequest {
|
|
2376
|
+
account_id: string;
|
|
2377
|
+
billing_mode?: 'test' | 'live';
|
|
2378
|
+
}
|
|
2379
|
+
interface PortalSession {
|
|
2380
|
+
url: string;
|
|
2381
|
+
expires_at: string;
|
|
2382
|
+
}
|
|
2383
|
+
interface AttachPaymentMethodRequest {
|
|
2384
|
+
stripe_payment_method_id: string;
|
|
2385
|
+
set_default?: boolean;
|
|
2386
|
+
}
|
|
2387
|
+
interface InvoiceListParams {
|
|
2388
|
+
limit?: number;
|
|
2389
|
+
cursor?: string;
|
|
2390
|
+
}
|
|
2391
|
+
interface InvoiceListResponse {
|
|
2392
|
+
data: Invoice[];
|
|
2393
|
+
next_cursor?: string | null;
|
|
2394
|
+
}
|
|
2322
2395
|
interface ConnectedAccount {
|
|
2323
2396
|
id: string;
|
|
2324
2397
|
email: string;
|
|
@@ -2466,14 +2539,27 @@ interface ConnectedSubscriptionListParams extends PaginationParams {
|
|
|
2466
2539
|
declare class BillingService extends ServiceModule {
|
|
2467
2540
|
protected basePath: string;
|
|
2468
2541
|
private retiredSurface;
|
|
2542
|
+
/** @deprecated Use `getAccountCustomer({ account_id })`. Targets the user-scoped legacy endpoint. */
|
|
2469
2543
|
createCustomer(data: {
|
|
2470
2544
|
email: string;
|
|
2471
2545
|
name?: string;
|
|
2472
2546
|
}, options?: RequestOptions): Promise<ApiResponse<Customer>>;
|
|
2547
|
+
/** @deprecated Use `attachAccountPaymentMethod({ account_id }, ...)`. Targets the user-scoped legacy endpoint. */
|
|
2473
2548
|
addPaymentMethod(data: {
|
|
2474
2549
|
type: string;
|
|
2475
2550
|
token: string;
|
|
2476
2551
|
}, options?: RequestOptions): Promise<ApiResponse<PaymentMethod>>;
|
|
2552
|
+
private accountBase;
|
|
2553
|
+
getAccountCustomer(req: AccountScopedBillingRequest, options?: RequestOptions): Promise<ApiResponse<Customer>>;
|
|
2554
|
+
listAccountPaymentMethods(req: AccountScopedBillingRequest, options?: RequestOptions): Promise<ApiResponse<PaymentMethod[]>>;
|
|
2555
|
+
attachAccountPaymentMethod(req: AccountScopedBillingRequest, body: AttachPaymentMethodRequest, options?: RequestOptions): Promise<ApiResponse<PaymentMethod>>;
|
|
2556
|
+
detachAccountPaymentMethod(req: AccountScopedBillingRequest, paymentMethodId: string, options?: RequestOptions): Promise<ApiResponse<void>>;
|
|
2557
|
+
setDefaultAccountPaymentMethod(req: AccountScopedBillingRequest, paymentMethodId: string, options?: RequestOptions): Promise<ApiResponse<PaymentMethod>>;
|
|
2558
|
+
listAccountInvoices(req: AccountScopedBillingRequest, params?: InvoiceListParams, options?: RequestOptions): Promise<ApiResponse<InvoiceListResponse>>;
|
|
2559
|
+
getAccountInvoice(req: AccountScopedBillingRequest, invoiceId: string, options?: RequestOptions): Promise<ApiResponse<Invoice>>;
|
|
2560
|
+
createAccountPortalSession(req: AccountScopedBillingRequest, body?: {
|
|
2561
|
+
return_url?: string;
|
|
2562
|
+
}, options?: RequestOptions): Promise<ApiResponse<PortalSession>>;
|
|
2477
2563
|
subscribe(data: {
|
|
2478
2564
|
customer_id: string;
|
|
2479
2565
|
plan_id: string;
|
|
@@ -4153,8 +4239,39 @@ interface TransformOptions {
|
|
|
4153
4239
|
* URLs built with these sizes + fit=cover get instant cache hits (no server-side transform).
|
|
4154
4240
|
*/
|
|
4155
4241
|
declare const PHOTO_BREAKPOINTS: readonly [36, 150, 320, 640, 1080];
|
|
4242
|
+
/** Result of {@link PhotoService.uploadViaStorage}. */
|
|
4243
|
+
interface UploadViaStorageResult {
|
|
4244
|
+
/** Storage file_id — pass this to chat-message attachment metadata. */
|
|
4245
|
+
file_id: string;
|
|
4246
|
+
/**
|
|
4247
|
+
* Photo service's photo_id. Use with `getTransformUrl()` /
|
|
4248
|
+
* `getOptimalUrl()` to fetch responsive variants. `null` when register
|
|
4249
|
+
* failed after a successful storage upload (the file_id is still usable
|
|
4250
|
+
* as a generic storage file).
|
|
4251
|
+
*/
|
|
4252
|
+
photo_id: string | null;
|
|
4253
|
+
/**
|
|
4254
|
+
* Short-lived signed URL to the original bytes — usable immediately on the
|
|
4255
|
+
* recipient side, before optimization completes.
|
|
4256
|
+
*/
|
|
4257
|
+
original_view_url: string | null;
|
|
4258
|
+
/**
|
|
4259
|
+
* Resolves once the optimization worker finishes (or times out at 10s).
|
|
4260
|
+
* On resolution: a transform URL pointing at the largest pre-cached
|
|
4261
|
+
* breakpoint. On timeout: `null` — caller should fall back to
|
|
4262
|
+
* `getTransformUrl()` which uses the on-demand transform path.
|
|
4263
|
+
*/
|
|
4264
|
+
optimized_url_promise: Promise<string | null>;
|
|
4265
|
+
}
|
|
4156
4266
|
declare class PhotoService extends ServiceModule {
|
|
4267
|
+
private readonly storage;
|
|
4157
4268
|
protected basePath: string;
|
|
4269
|
+
/**
|
|
4270
|
+
* @param storage Required for {@link uploadViaStorage}. Wired up by the
|
|
4271
|
+
* top-level {@link ScaleMule} constructor — most call sites should not
|
|
4272
|
+
* instantiate `PhotoService` directly.
|
|
4273
|
+
*/
|
|
4274
|
+
constructor(client: ScaleMuleClient, storage: StorageService);
|
|
4158
4275
|
upload(file: File | Blob, uploadOptions?: {
|
|
4159
4276
|
metadata?: Record<string, unknown>;
|
|
4160
4277
|
onProgress?: (progress: number) => void;
|
|
@@ -4242,6 +4359,41 @@ declare class PhotoService extends ServiceModule {
|
|
|
4242
4359
|
fileId: string;
|
|
4243
4360
|
userId?: string;
|
|
4244
4361
|
}, requestOptions?: RequestOptions): Promise<ApiResponse<PhotoInfo>>;
|
|
4362
|
+
/**
|
|
4363
|
+
* Upload a file to storage (browser → S3 direct, private, uncompressed) and
|
|
4364
|
+
* register it with the photo service so optimization + transform URLs work.
|
|
4365
|
+
*
|
|
4366
|
+
* The canonical chat-attachment / progressive-image upload primitive. Same
|
|
4367
|
+
* presigned-direct-to-S3 path as `storage.uploadPrivate()`, plus a follow-up
|
|
4368
|
+
* `photo.register()` call so `getTransformUrl()` / `getOptimalUrl()` return
|
|
4369
|
+
* usable URLs.
|
|
4370
|
+
*
|
|
4371
|
+
* The returned `optimized_url_promise` resolves once the photo's
|
|
4372
|
+
* `optimization_status` flips to `completed` (or once a 10s timeout fires;
|
|
4373
|
+
* the caller can still use `getTransformUrl()` directly — the on-demand
|
|
4374
|
+
* transform path produces a variant even before pre-rendered breakpoints
|
|
4375
|
+
* are cached). Phase 3 of ADR-2026-04-26 replaces the poll with a realtime
|
|
4376
|
+
* subscription.
|
|
4377
|
+
*
|
|
4378
|
+
* If `register()` fails after a successful storage upload (e.g. scan times
|
|
4379
|
+
* out), the file is *not* lost: the returned `file_id` is still valid as a
|
|
4380
|
+
* generic storage file. The SDK logs a warning and resolves
|
|
4381
|
+
* `optimized_url_promise` to `null`.
|
|
4382
|
+
*/
|
|
4383
|
+
uploadViaStorage(file: File | Blob, uploadOptions?: {
|
|
4384
|
+
userId?: string;
|
|
4385
|
+
filename?: string;
|
|
4386
|
+
metadata?: Record<string, unknown>;
|
|
4387
|
+
onProgress?: (progress: number) => void;
|
|
4388
|
+
signal?: AbortSignal;
|
|
4389
|
+
}, requestOptions?: RequestOptions): Promise<ApiResponse<UploadViaStorageResult>>;
|
|
4390
|
+
/**
|
|
4391
|
+
* Poll {@link get} until the photo's `optimization_status` is `completed`
|
|
4392
|
+
* or the 10s timeout fires. Resolves to a usable transform URL on success;
|
|
4393
|
+
* `null` on timeout (caller should fall back to {@link getTransformUrl}
|
|
4394
|
+
* which uses the on-demand transform path).
|
|
4395
|
+
*/
|
|
4396
|
+
private pollOptimizationComplete;
|
|
4245
4397
|
/** @deprecated Use upload() instead */
|
|
4246
4398
|
uploadPhoto(file: File | Blob, options?: {
|
|
4247
4399
|
metadata?: Record<string, unknown>;
|
|
@@ -6052,4 +6204,4 @@ declare class ScaleMule {
|
|
|
6052
6204
|
getClient(): ScaleMuleClient;
|
|
6053
6205
|
}
|
|
6054
6206
|
|
|
6055
|
-
export { type AccountBalance, type AccountSwitcherPrivacy, 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 CallParticipant, type CallSession, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, ConferenceService, type ConferenceSettings, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type GenerationJob as CreatorJob, CreatorMakerService, type GenerationOutput as CreatorOutput, type CreatorProject, type CreatorUsage, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type DirectoryUser, type DirectoryUserDetail, type DirectoryUsersListResponse, 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 GenerateInput, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type JoinCallResponse, type KnownAccount, type KnownAccountDisplay, 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 SearchUsersParams, 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 StylePreset, 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 WebrtcStats, 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 };
|
|
6207
|
+
export { type AccountBalance, type AccountSwitcherPrivacy, 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 CallParticipant, type CallSession, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, ConferenceService, type ConferenceSettings, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type GenerationJob as CreatorJob, CreatorMakerService, type GenerationOutput as CreatorOutput, type CreatorProject, type CreatorUsage, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type DirectoryUser, type DirectoryUserDetail, type DirectoryUsersListResponse, 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 GenerateInput, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type JoinCallResponse, type KnownAccount, type KnownAccountDisplay, 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 MessagePin, 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 PinnedMessagesResponse, 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 SearchUsersParams, 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 StylePreset, 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 WebrtcStats, 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
|
@@ -2335,6 +2335,40 @@ var StorageService = class extends ServiceModule {
|
|
|
2335
2335
|
return { data: null, error: { code: "upload_error", message, status: 0 } };
|
|
2336
2336
|
}
|
|
2337
2337
|
}
|
|
2338
|
+
/**
|
|
2339
|
+
* Upload a file as a private attachment (e.g. chat / DM attachment).
|
|
2340
|
+
*
|
|
2341
|
+
* Same browser→S3 pipeline as {@link upload}, but enforces:
|
|
2342
|
+
* - `is_public: false` — caller cannot opt out
|
|
2343
|
+
* - no client-side compression — preserve the original bytes
|
|
2344
|
+
* - fail-closed if storage returns `is_public: true` for any reason
|
|
2345
|
+
*
|
|
2346
|
+
* The shared primitive used by `@scalemule/chat`'s chat-attachment uploader
|
|
2347
|
+
* and by `@scalemule/nextjs`'s `useMedia()` when an app's media policy is
|
|
2348
|
+
* `fast_trusted`. Both packages call this method via `@scalemule/sdk` —
|
|
2349
|
+
* `@scalemule/nextjs` does not depend on `@scalemule/chat`.
|
|
2350
|
+
*
|
|
2351
|
+
* See ADR-2026-04-26 (realtime-chat media pipeline) and
|
|
2352
|
+
* docs/MEDIA-UPLOADS.md for the full pattern.
|
|
2353
|
+
*/
|
|
2354
|
+
async uploadPrivate(file, options) {
|
|
2355
|
+
const result = await this.upload(file, {
|
|
2356
|
+
...options,
|
|
2357
|
+
isPublic: false,
|
|
2358
|
+
skipCompression: true
|
|
2359
|
+
});
|
|
2360
|
+
if (result.data && result.data.is_public === true) {
|
|
2361
|
+
return {
|
|
2362
|
+
data: null,
|
|
2363
|
+
error: {
|
|
2364
|
+
code: "visibility_violation",
|
|
2365
|
+
message: "Storage returned is_public=true for an uploadPrivate() call. This usually indicates a server-side bug or an admin override; the caller asked for a private upload.",
|
|
2366
|
+
status: 0
|
|
2367
|
+
}
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
return result;
|
|
2371
|
+
}
|
|
2338
2372
|
// --------------------------------------------------------------------------
|
|
2339
2373
|
// Direct Upload (3-step with retry + stall)
|
|
2340
2374
|
// --------------------------------------------------------------------------
|
|
@@ -4352,6 +4386,18 @@ var ChatService = class extends ServiceModule {
|
|
|
4352
4386
|
return this.post(`/messages/${messageId}/reactions`, data, options);
|
|
4353
4387
|
}
|
|
4354
4388
|
// --------------------------------------------------------------------------
|
|
4389
|
+
// Pins
|
|
4390
|
+
// --------------------------------------------------------------------------
|
|
4391
|
+
async pinMessage(messageId, options) {
|
|
4392
|
+
return this.post(`/messages/${messageId}/pin`, void 0, options);
|
|
4393
|
+
}
|
|
4394
|
+
async unpinMessage(messageId, options) {
|
|
4395
|
+
return this.del(`/messages/${messageId}/pin`, options);
|
|
4396
|
+
}
|
|
4397
|
+
async getPinnedMessages(conversationId, options) {
|
|
4398
|
+
return this._get(`/conversations/${conversationId}/pins`, options);
|
|
4399
|
+
}
|
|
4400
|
+
// --------------------------------------------------------------------------
|
|
4355
4401
|
// Typing & Read Receipts
|
|
4356
4402
|
// --------------------------------------------------------------------------
|
|
4357
4403
|
async sendTyping(conversationId, options) {
|
|
@@ -4570,15 +4616,80 @@ var BillingService = class extends ServiceModule {
|
|
|
4570
4616
|
);
|
|
4571
4617
|
}
|
|
4572
4618
|
// --------------------------------------------------------------------------
|
|
4573
|
-
// Customers
|
|
4619
|
+
// Customers (legacy user-scoped — deprecated in favor of account-scoped)
|
|
4574
4620
|
// --------------------------------------------------------------------------
|
|
4621
|
+
/** @deprecated Use `getAccountCustomer({ account_id })`. Targets the user-scoped legacy endpoint. */
|
|
4575
4622
|
async createCustomer(data, options) {
|
|
4576
4623
|
return this.post("/customers", data, options);
|
|
4577
4624
|
}
|
|
4625
|
+
/** @deprecated Use `attachAccountPaymentMethod({ account_id }, ...)`. Targets the user-scoped legacy endpoint. */
|
|
4578
4626
|
async addPaymentMethod(data, options) {
|
|
4579
4627
|
return this.post("/payment-methods", data, options);
|
|
4580
4628
|
}
|
|
4581
4629
|
// --------------------------------------------------------------------------
|
|
4630
|
+
// Account-Scoped Billing (v2 — ADR-2026-04-25)
|
|
4631
|
+
//
|
|
4632
|
+
// The customer/payment-method/invoice record set belongs to an `app_account`
|
|
4633
|
+
// (typically a `customer_org`), not to a single user. These methods target
|
|
4634
|
+
// the `/v1/billing/accounts/{account_id}/*` endpoints described in
|
|
4635
|
+
// openapi/scalemule-money-billing-v1.yaml.
|
|
4636
|
+
// --------------------------------------------------------------------------
|
|
4637
|
+
accountBase(accountId) {
|
|
4638
|
+
return `/v1/billing/accounts/${encodeURIComponent(accountId)}`;
|
|
4639
|
+
}
|
|
4640
|
+
async getAccountCustomer(req, options) {
|
|
4641
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/customer`, {
|
|
4642
|
+
billing_mode: req.billing_mode
|
|
4643
|
+
});
|
|
4644
|
+
return this.client.get(path, options);
|
|
4645
|
+
}
|
|
4646
|
+
async listAccountPaymentMethods(req, options) {
|
|
4647
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/payment-methods`, {
|
|
4648
|
+
billing_mode: req.billing_mode
|
|
4649
|
+
});
|
|
4650
|
+
return this.client.get(path, options);
|
|
4651
|
+
}
|
|
4652
|
+
async attachAccountPaymentMethod(req, body, options) {
|
|
4653
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/payment-methods`, {
|
|
4654
|
+
billing_mode: req.billing_mode
|
|
4655
|
+
});
|
|
4656
|
+
return this.client.post(path, body, options);
|
|
4657
|
+
}
|
|
4658
|
+
async detachAccountPaymentMethod(req, paymentMethodId, options) {
|
|
4659
|
+
const path = this.withQuery(
|
|
4660
|
+
`${this.accountBase(req.account_id)}/payment-methods/${encodeURIComponent(paymentMethodId)}`,
|
|
4661
|
+
{ billing_mode: req.billing_mode }
|
|
4662
|
+
);
|
|
4663
|
+
return this.client.del(path, options);
|
|
4664
|
+
}
|
|
4665
|
+
async setDefaultAccountPaymentMethod(req, paymentMethodId, options) {
|
|
4666
|
+
const path = this.withQuery(
|
|
4667
|
+
`${this.accountBase(req.account_id)}/payment-methods/${encodeURIComponent(paymentMethodId)}/default`,
|
|
4668
|
+
{ billing_mode: req.billing_mode }
|
|
4669
|
+
);
|
|
4670
|
+
return this.client.put(path, void 0, options);
|
|
4671
|
+
}
|
|
4672
|
+
async listAccountInvoices(req, params, options) {
|
|
4673
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/invoices`, {
|
|
4674
|
+
billing_mode: req.billing_mode,
|
|
4675
|
+
limit: params?.limit,
|
|
4676
|
+
cursor: params?.cursor
|
|
4677
|
+
});
|
|
4678
|
+
return this.client.get(path, options);
|
|
4679
|
+
}
|
|
4680
|
+
async getAccountInvoice(req, invoiceId, options) {
|
|
4681
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/invoices/${encodeURIComponent(invoiceId)}`, {
|
|
4682
|
+
billing_mode: req.billing_mode
|
|
4683
|
+
});
|
|
4684
|
+
return this.client.get(path, options);
|
|
4685
|
+
}
|
|
4686
|
+
async createAccountPortalSession(req, body, options) {
|
|
4687
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/portal-session`, {
|
|
4688
|
+
billing_mode: req.billing_mode
|
|
4689
|
+
});
|
|
4690
|
+
return this.client.post(path, body ?? {}, options);
|
|
4691
|
+
}
|
|
4692
|
+
// --------------------------------------------------------------------------
|
|
4582
4693
|
// Subscriptions
|
|
4583
4694
|
// --------------------------------------------------------------------------
|
|
4584
4695
|
async subscribe(data, options) {
|
|
@@ -5965,8 +6076,14 @@ var SearchService = class extends ServiceModule {
|
|
|
5965
6076
|
// src/services/photo.ts
|
|
5966
6077
|
var PHOTO_BREAKPOINTS = [36, 150, 320, 640, 1080];
|
|
5967
6078
|
var PhotoService = class extends ServiceModule {
|
|
5968
|
-
|
|
5969
|
-
|
|
6079
|
+
/**
|
|
6080
|
+
* @param storage Required for {@link uploadViaStorage}. Wired up by the
|
|
6081
|
+
* top-level {@link ScaleMule} constructor — most call sites should not
|
|
6082
|
+
* instantiate `PhotoService` directly.
|
|
6083
|
+
*/
|
|
6084
|
+
constructor(client, storage) {
|
|
6085
|
+
super(client);
|
|
6086
|
+
this.storage = storage;
|
|
5970
6087
|
this.basePath = "/v1/photos";
|
|
5971
6088
|
}
|
|
5972
6089
|
async upload(file, uploadOptions, requestOptions) {
|
|
@@ -6106,6 +6223,87 @@ var PhotoService = class extends ServiceModule {
|
|
|
6106
6223
|
}
|
|
6107
6224
|
};
|
|
6108
6225
|
}
|
|
6226
|
+
/**
|
|
6227
|
+
* Upload a file to storage (browser → S3 direct, private, uncompressed) and
|
|
6228
|
+
* register it with the photo service so optimization + transform URLs work.
|
|
6229
|
+
*
|
|
6230
|
+
* The canonical chat-attachment / progressive-image upload primitive. Same
|
|
6231
|
+
* presigned-direct-to-S3 path as `storage.uploadPrivate()`, plus a follow-up
|
|
6232
|
+
* `photo.register()` call so `getTransformUrl()` / `getOptimalUrl()` return
|
|
6233
|
+
* usable URLs.
|
|
6234
|
+
*
|
|
6235
|
+
* The returned `optimized_url_promise` resolves once the photo's
|
|
6236
|
+
* `optimization_status` flips to `completed` (or once a 10s timeout fires;
|
|
6237
|
+
* the caller can still use `getTransformUrl()` directly — the on-demand
|
|
6238
|
+
* transform path produces a variant even before pre-rendered breakpoints
|
|
6239
|
+
* are cached). Phase 3 of ADR-2026-04-26 replaces the poll with a realtime
|
|
6240
|
+
* subscription.
|
|
6241
|
+
*
|
|
6242
|
+
* If `register()` fails after a successful storage upload (e.g. scan times
|
|
6243
|
+
* out), the file is *not* lost: the returned `file_id` is still valid as a
|
|
6244
|
+
* generic storage file. The SDK logs a warning and resolves
|
|
6245
|
+
* `optimized_url_promise` to `null`.
|
|
6246
|
+
*/
|
|
6247
|
+
async uploadViaStorage(file, uploadOptions, requestOptions) {
|
|
6248
|
+
const uploadResult = await this.storage.uploadPrivate(file, {
|
|
6249
|
+
filename: uploadOptions?.filename,
|
|
6250
|
+
metadata: uploadOptions?.metadata,
|
|
6251
|
+
onProgress: uploadOptions?.onProgress,
|
|
6252
|
+
signal: uploadOptions?.signal
|
|
6253
|
+
});
|
|
6254
|
+
if (uploadResult.error || !uploadResult.data) {
|
|
6255
|
+
return { data: null, error: uploadResult.error };
|
|
6256
|
+
}
|
|
6257
|
+
const fileInfo = uploadResult.data;
|
|
6258
|
+
const fileId = fileInfo.id;
|
|
6259
|
+
const originalViewUrl = fileInfo.url ?? null;
|
|
6260
|
+
const registerResult = await this.register({ fileId, userId: uploadOptions?.userId }, requestOptions);
|
|
6261
|
+
if (registerResult.error || !registerResult.data) {
|
|
6262
|
+
console.warn(
|
|
6263
|
+
"[scalemule-sdk] photo.register() failed after storage upload; optimized variants unavailable.",
|
|
6264
|
+
registerResult.error
|
|
6265
|
+
);
|
|
6266
|
+
return {
|
|
6267
|
+
data: {
|
|
6268
|
+
file_id: fileId,
|
|
6269
|
+
photo_id: null,
|
|
6270
|
+
original_view_url: originalViewUrl,
|
|
6271
|
+
optimized_url_promise: Promise.resolve(null)
|
|
6272
|
+
},
|
|
6273
|
+
error: null
|
|
6274
|
+
};
|
|
6275
|
+
}
|
|
6276
|
+
const photoId = registerResult.data.id;
|
|
6277
|
+
const optimizedUrlPromise = this.pollOptimizationComplete(photoId, requestOptions);
|
|
6278
|
+
return {
|
|
6279
|
+
data: {
|
|
6280
|
+
file_id: fileId,
|
|
6281
|
+
photo_id: photoId,
|
|
6282
|
+
original_view_url: originalViewUrl,
|
|
6283
|
+
optimized_url_promise: optimizedUrlPromise
|
|
6284
|
+
},
|
|
6285
|
+
error: null
|
|
6286
|
+
};
|
|
6287
|
+
}
|
|
6288
|
+
/**
|
|
6289
|
+
* Poll {@link get} until the photo's `optimization_status` is `completed`
|
|
6290
|
+
* or the 10s timeout fires. Resolves to a usable transform URL on success;
|
|
6291
|
+
* `null` on timeout (caller should fall back to {@link getTransformUrl}
|
|
6292
|
+
* which uses the on-demand transform path).
|
|
6293
|
+
*/
|
|
6294
|
+
async pollOptimizationComplete(photoId, requestOptions) {
|
|
6295
|
+
const intervalMs = 250;
|
|
6296
|
+
const maxAttempts = 40;
|
|
6297
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
6298
|
+
const result = await this.get(photoId, requestOptions);
|
|
6299
|
+
const status = result.data?.optimization_status;
|
|
6300
|
+
if (status === "completed") {
|
|
6301
|
+
return this.getOptimalUrl(photoId, 1080);
|
|
6302
|
+
}
|
|
6303
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
6304
|
+
}
|
|
6305
|
+
return null;
|
|
6306
|
+
}
|
|
6109
6307
|
/** @deprecated Use upload() instead */
|
|
6110
6308
|
async uploadPhoto(file, options) {
|
|
6111
6309
|
return this.upload(file, options);
|
|
@@ -6969,7 +7167,7 @@ var ScaleMule = class {
|
|
|
6969
7167
|
this.events = new EventsService(this._client);
|
|
6970
7168
|
this.graph = new GraphService(this._client);
|
|
6971
7169
|
this.functions = new FunctionsService(this._client);
|
|
6972
|
-
this.photo = new PhotoService(this._client);
|
|
7170
|
+
this.photo = new PhotoService(this._client, this.storage);
|
|
6973
7171
|
this.flagContent = new FlagContentService(this._client);
|
|
6974
7172
|
this.creatorMaker = new CreatorMakerService(this._client);
|
|
6975
7173
|
this.compliance = new ComplianceService(this._client);
|
package/dist/index.mjs
CHANGED
|
@@ -1966,6 +1966,40 @@ var StorageService = class extends ServiceModule {
|
|
|
1966
1966
|
return { data: null, error: { code: "upload_error", message, status: 0 } };
|
|
1967
1967
|
}
|
|
1968
1968
|
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Upload a file as a private attachment (e.g. chat / DM attachment).
|
|
1971
|
+
*
|
|
1972
|
+
* Same browser→S3 pipeline as {@link upload}, but enforces:
|
|
1973
|
+
* - `is_public: false` — caller cannot opt out
|
|
1974
|
+
* - no client-side compression — preserve the original bytes
|
|
1975
|
+
* - fail-closed if storage returns `is_public: true` for any reason
|
|
1976
|
+
*
|
|
1977
|
+
* The shared primitive used by `@scalemule/chat`'s chat-attachment uploader
|
|
1978
|
+
* and by `@scalemule/nextjs`'s `useMedia()` when an app's media policy is
|
|
1979
|
+
* `fast_trusted`. Both packages call this method via `@scalemule/sdk` —
|
|
1980
|
+
* `@scalemule/nextjs` does not depend on `@scalemule/chat`.
|
|
1981
|
+
*
|
|
1982
|
+
* See ADR-2026-04-26 (realtime-chat media pipeline) and
|
|
1983
|
+
* docs/MEDIA-UPLOADS.md for the full pattern.
|
|
1984
|
+
*/
|
|
1985
|
+
async uploadPrivate(file, options) {
|
|
1986
|
+
const result = await this.upload(file, {
|
|
1987
|
+
...options,
|
|
1988
|
+
isPublic: false,
|
|
1989
|
+
skipCompression: true
|
|
1990
|
+
});
|
|
1991
|
+
if (result.data && result.data.is_public === true) {
|
|
1992
|
+
return {
|
|
1993
|
+
data: null,
|
|
1994
|
+
error: {
|
|
1995
|
+
code: "visibility_violation",
|
|
1996
|
+
message: "Storage returned is_public=true for an uploadPrivate() call. This usually indicates a server-side bug or an admin override; the caller asked for a private upload.",
|
|
1997
|
+
status: 0
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
2001
|
+
return result;
|
|
2002
|
+
}
|
|
1969
2003
|
// --------------------------------------------------------------------------
|
|
1970
2004
|
// Direct Upload (3-step with retry + stall)
|
|
1971
2005
|
// --------------------------------------------------------------------------
|
|
@@ -3980,6 +4014,18 @@ var ChatService = class extends ServiceModule {
|
|
|
3980
4014
|
return this.post(`/messages/${messageId}/reactions`, data, options);
|
|
3981
4015
|
}
|
|
3982
4016
|
// --------------------------------------------------------------------------
|
|
4017
|
+
// Pins
|
|
4018
|
+
// --------------------------------------------------------------------------
|
|
4019
|
+
async pinMessage(messageId, options) {
|
|
4020
|
+
return this.post(`/messages/${messageId}/pin`, void 0, options);
|
|
4021
|
+
}
|
|
4022
|
+
async unpinMessage(messageId, options) {
|
|
4023
|
+
return this.del(`/messages/${messageId}/pin`, options);
|
|
4024
|
+
}
|
|
4025
|
+
async getPinnedMessages(conversationId, options) {
|
|
4026
|
+
return this._get(`/conversations/${conversationId}/pins`, options);
|
|
4027
|
+
}
|
|
4028
|
+
// --------------------------------------------------------------------------
|
|
3983
4029
|
// Typing & Read Receipts
|
|
3984
4030
|
// --------------------------------------------------------------------------
|
|
3985
4031
|
async sendTyping(conversationId, options) {
|
|
@@ -4198,15 +4244,80 @@ var BillingService = class extends ServiceModule {
|
|
|
4198
4244
|
);
|
|
4199
4245
|
}
|
|
4200
4246
|
// --------------------------------------------------------------------------
|
|
4201
|
-
// Customers
|
|
4247
|
+
// Customers (legacy user-scoped — deprecated in favor of account-scoped)
|
|
4202
4248
|
// --------------------------------------------------------------------------
|
|
4249
|
+
/** @deprecated Use `getAccountCustomer({ account_id })`. Targets the user-scoped legacy endpoint. */
|
|
4203
4250
|
async createCustomer(data, options) {
|
|
4204
4251
|
return this.post("/customers", data, options);
|
|
4205
4252
|
}
|
|
4253
|
+
/** @deprecated Use `attachAccountPaymentMethod({ account_id }, ...)`. Targets the user-scoped legacy endpoint. */
|
|
4206
4254
|
async addPaymentMethod(data, options) {
|
|
4207
4255
|
return this.post("/payment-methods", data, options);
|
|
4208
4256
|
}
|
|
4209
4257
|
// --------------------------------------------------------------------------
|
|
4258
|
+
// Account-Scoped Billing (v2 — ADR-2026-04-25)
|
|
4259
|
+
//
|
|
4260
|
+
// The customer/payment-method/invoice record set belongs to an `app_account`
|
|
4261
|
+
// (typically a `customer_org`), not to a single user. These methods target
|
|
4262
|
+
// the `/v1/billing/accounts/{account_id}/*` endpoints described in
|
|
4263
|
+
// openapi/scalemule-money-billing-v1.yaml.
|
|
4264
|
+
// --------------------------------------------------------------------------
|
|
4265
|
+
accountBase(accountId) {
|
|
4266
|
+
return `/v1/billing/accounts/${encodeURIComponent(accountId)}`;
|
|
4267
|
+
}
|
|
4268
|
+
async getAccountCustomer(req, options) {
|
|
4269
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/customer`, {
|
|
4270
|
+
billing_mode: req.billing_mode
|
|
4271
|
+
});
|
|
4272
|
+
return this.client.get(path, options);
|
|
4273
|
+
}
|
|
4274
|
+
async listAccountPaymentMethods(req, options) {
|
|
4275
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/payment-methods`, {
|
|
4276
|
+
billing_mode: req.billing_mode
|
|
4277
|
+
});
|
|
4278
|
+
return this.client.get(path, options);
|
|
4279
|
+
}
|
|
4280
|
+
async attachAccountPaymentMethod(req, body, options) {
|
|
4281
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/payment-methods`, {
|
|
4282
|
+
billing_mode: req.billing_mode
|
|
4283
|
+
});
|
|
4284
|
+
return this.client.post(path, body, options);
|
|
4285
|
+
}
|
|
4286
|
+
async detachAccountPaymentMethod(req, paymentMethodId, options) {
|
|
4287
|
+
const path = this.withQuery(
|
|
4288
|
+
`${this.accountBase(req.account_id)}/payment-methods/${encodeURIComponent(paymentMethodId)}`,
|
|
4289
|
+
{ billing_mode: req.billing_mode }
|
|
4290
|
+
);
|
|
4291
|
+
return this.client.del(path, options);
|
|
4292
|
+
}
|
|
4293
|
+
async setDefaultAccountPaymentMethod(req, paymentMethodId, options) {
|
|
4294
|
+
const path = this.withQuery(
|
|
4295
|
+
`${this.accountBase(req.account_id)}/payment-methods/${encodeURIComponent(paymentMethodId)}/default`,
|
|
4296
|
+
{ billing_mode: req.billing_mode }
|
|
4297
|
+
);
|
|
4298
|
+
return this.client.put(path, void 0, options);
|
|
4299
|
+
}
|
|
4300
|
+
async listAccountInvoices(req, params, options) {
|
|
4301
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/invoices`, {
|
|
4302
|
+
billing_mode: req.billing_mode,
|
|
4303
|
+
limit: params?.limit,
|
|
4304
|
+
cursor: params?.cursor
|
|
4305
|
+
});
|
|
4306
|
+
return this.client.get(path, options);
|
|
4307
|
+
}
|
|
4308
|
+
async getAccountInvoice(req, invoiceId, options) {
|
|
4309
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/invoices/${encodeURIComponent(invoiceId)}`, {
|
|
4310
|
+
billing_mode: req.billing_mode
|
|
4311
|
+
});
|
|
4312
|
+
return this.client.get(path, options);
|
|
4313
|
+
}
|
|
4314
|
+
async createAccountPortalSession(req, body, options) {
|
|
4315
|
+
const path = this.withQuery(`${this.accountBase(req.account_id)}/portal-session`, {
|
|
4316
|
+
billing_mode: req.billing_mode
|
|
4317
|
+
});
|
|
4318
|
+
return this.client.post(path, body ?? {}, options);
|
|
4319
|
+
}
|
|
4320
|
+
// --------------------------------------------------------------------------
|
|
4210
4321
|
// Subscriptions
|
|
4211
4322
|
// --------------------------------------------------------------------------
|
|
4212
4323
|
async subscribe(data, options) {
|
|
@@ -5593,8 +5704,14 @@ var SearchService = class extends ServiceModule {
|
|
|
5593
5704
|
// src/services/photo.ts
|
|
5594
5705
|
var PHOTO_BREAKPOINTS = [36, 150, 320, 640, 1080];
|
|
5595
5706
|
var PhotoService = class extends ServiceModule {
|
|
5596
|
-
|
|
5597
|
-
|
|
5707
|
+
/**
|
|
5708
|
+
* @param storage Required for {@link uploadViaStorage}. Wired up by the
|
|
5709
|
+
* top-level {@link ScaleMule} constructor — most call sites should not
|
|
5710
|
+
* instantiate `PhotoService` directly.
|
|
5711
|
+
*/
|
|
5712
|
+
constructor(client, storage) {
|
|
5713
|
+
super(client);
|
|
5714
|
+
this.storage = storage;
|
|
5598
5715
|
this.basePath = "/v1/photos";
|
|
5599
5716
|
}
|
|
5600
5717
|
async upload(file, uploadOptions, requestOptions) {
|
|
@@ -5734,6 +5851,87 @@ var PhotoService = class extends ServiceModule {
|
|
|
5734
5851
|
}
|
|
5735
5852
|
};
|
|
5736
5853
|
}
|
|
5854
|
+
/**
|
|
5855
|
+
* Upload a file to storage (browser → S3 direct, private, uncompressed) and
|
|
5856
|
+
* register it with the photo service so optimization + transform URLs work.
|
|
5857
|
+
*
|
|
5858
|
+
* The canonical chat-attachment / progressive-image upload primitive. Same
|
|
5859
|
+
* presigned-direct-to-S3 path as `storage.uploadPrivate()`, plus a follow-up
|
|
5860
|
+
* `photo.register()` call so `getTransformUrl()` / `getOptimalUrl()` return
|
|
5861
|
+
* usable URLs.
|
|
5862
|
+
*
|
|
5863
|
+
* The returned `optimized_url_promise` resolves once the photo's
|
|
5864
|
+
* `optimization_status` flips to `completed` (or once a 10s timeout fires;
|
|
5865
|
+
* the caller can still use `getTransformUrl()` directly — the on-demand
|
|
5866
|
+
* transform path produces a variant even before pre-rendered breakpoints
|
|
5867
|
+
* are cached). Phase 3 of ADR-2026-04-26 replaces the poll with a realtime
|
|
5868
|
+
* subscription.
|
|
5869
|
+
*
|
|
5870
|
+
* If `register()` fails after a successful storage upload (e.g. scan times
|
|
5871
|
+
* out), the file is *not* lost: the returned `file_id` is still valid as a
|
|
5872
|
+
* generic storage file. The SDK logs a warning and resolves
|
|
5873
|
+
* `optimized_url_promise` to `null`.
|
|
5874
|
+
*/
|
|
5875
|
+
async uploadViaStorage(file, uploadOptions, requestOptions) {
|
|
5876
|
+
const uploadResult = await this.storage.uploadPrivate(file, {
|
|
5877
|
+
filename: uploadOptions?.filename,
|
|
5878
|
+
metadata: uploadOptions?.metadata,
|
|
5879
|
+
onProgress: uploadOptions?.onProgress,
|
|
5880
|
+
signal: uploadOptions?.signal
|
|
5881
|
+
});
|
|
5882
|
+
if (uploadResult.error || !uploadResult.data) {
|
|
5883
|
+
return { data: null, error: uploadResult.error };
|
|
5884
|
+
}
|
|
5885
|
+
const fileInfo = uploadResult.data;
|
|
5886
|
+
const fileId = fileInfo.id;
|
|
5887
|
+
const originalViewUrl = fileInfo.url ?? null;
|
|
5888
|
+
const registerResult = await this.register({ fileId, userId: uploadOptions?.userId }, requestOptions);
|
|
5889
|
+
if (registerResult.error || !registerResult.data) {
|
|
5890
|
+
console.warn(
|
|
5891
|
+
"[scalemule-sdk] photo.register() failed after storage upload; optimized variants unavailable.",
|
|
5892
|
+
registerResult.error
|
|
5893
|
+
);
|
|
5894
|
+
return {
|
|
5895
|
+
data: {
|
|
5896
|
+
file_id: fileId,
|
|
5897
|
+
photo_id: null,
|
|
5898
|
+
original_view_url: originalViewUrl,
|
|
5899
|
+
optimized_url_promise: Promise.resolve(null)
|
|
5900
|
+
},
|
|
5901
|
+
error: null
|
|
5902
|
+
};
|
|
5903
|
+
}
|
|
5904
|
+
const photoId = registerResult.data.id;
|
|
5905
|
+
const optimizedUrlPromise = this.pollOptimizationComplete(photoId, requestOptions);
|
|
5906
|
+
return {
|
|
5907
|
+
data: {
|
|
5908
|
+
file_id: fileId,
|
|
5909
|
+
photo_id: photoId,
|
|
5910
|
+
original_view_url: originalViewUrl,
|
|
5911
|
+
optimized_url_promise: optimizedUrlPromise
|
|
5912
|
+
},
|
|
5913
|
+
error: null
|
|
5914
|
+
};
|
|
5915
|
+
}
|
|
5916
|
+
/**
|
|
5917
|
+
* Poll {@link get} until the photo's `optimization_status` is `completed`
|
|
5918
|
+
* or the 10s timeout fires. Resolves to a usable transform URL on success;
|
|
5919
|
+
* `null` on timeout (caller should fall back to {@link getTransformUrl}
|
|
5920
|
+
* which uses the on-demand transform path).
|
|
5921
|
+
*/
|
|
5922
|
+
async pollOptimizationComplete(photoId, requestOptions) {
|
|
5923
|
+
const intervalMs = 250;
|
|
5924
|
+
const maxAttempts = 40;
|
|
5925
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
5926
|
+
const result = await this.get(photoId, requestOptions);
|
|
5927
|
+
const status = result.data?.optimization_status;
|
|
5928
|
+
if (status === "completed") {
|
|
5929
|
+
return this.getOptimalUrl(photoId, 1080);
|
|
5930
|
+
}
|
|
5931
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
5932
|
+
}
|
|
5933
|
+
return null;
|
|
5934
|
+
}
|
|
5737
5935
|
/** @deprecated Use upload() instead */
|
|
5738
5936
|
async uploadPhoto(file, options) {
|
|
5739
5937
|
return this.upload(file, options);
|
|
@@ -6597,7 +6795,7 @@ var ScaleMule = class {
|
|
|
6597
6795
|
this.events = new EventsService(this._client);
|
|
6598
6796
|
this.graph = new GraphService(this._client);
|
|
6599
6797
|
this.functions = new FunctionsService(this._client);
|
|
6600
|
-
this.photo = new PhotoService(this._client);
|
|
6798
|
+
this.photo = new PhotoService(this._client, this.storage);
|
|
6601
6799
|
this.flagContent = new FlagContentService(this._client);
|
|
6602
6800
|
this.creatorMaker = new CreatorMakerService(this._client);
|
|
6603
6801
|
this.compliance = new ComplianceService(this._client);
|