@scalemule/sdk 0.0.1

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.
@@ -0,0 +1,4014 @@
1
+ export { PHONE_COUNTRIES, PhoneCountry, PhoneNormalizationResult, composePhoneNumber, countryFlag, detectCountryFromE164, findPhoneCountryByCode, findPhoneCountryByDialCode, isValidE164Phone, normalizeAndValidatePhone, normalizePhoneNumber } from '@scalemule/ui/phone';
2
+
3
+ /**
4
+ * ScaleMule SDK Types
5
+ *
6
+ * Core type definitions for the { data, error } response contract,
7
+ * standardized error codes, and pagination.
8
+ */
9
+ /**
10
+ * Universal response type for all SDK methods.
11
+ *
12
+ * On success: { data: T, error: null }
13
+ * On failure: { data: null, error: ApiError }
14
+ *
15
+ * Error is always present in the type (null when success).
16
+ * Data is always present in the type (null when failure).
17
+ * No exceptions thrown for expected API errors (4xx).
18
+ */
19
+ type ApiResponse<T> = {
20
+ data: T | null;
21
+ error: ApiError | null;
22
+ };
23
+ /**
24
+ * Standardized API error with machine-readable code.
25
+ *
26
+ * Codes are lowercase, underscore-separated identifiers.
27
+ * The `details` field carries context-specific data like
28
+ * field-level validation errors or rate limit reset times.
29
+ */
30
+ type ApiError = {
31
+ /** Machine-readable error code (e.g., 'not_found', 'rate_limited') */
32
+ code: string;
33
+ /** Human-readable error message */
34
+ message: string;
35
+ /** HTTP status code */
36
+ status: number;
37
+ /** Additional context (field errors, retryAfter, etc.) */
38
+ details?: Record<string, unknown>;
39
+ };
40
+ /**
41
+ * Paginated response envelope.
42
+ * Used by all methods that return lists.
43
+ */
44
+ type PaginatedResponse<T> = {
45
+ data: T[];
46
+ metadata: PaginationMetadata;
47
+ error: ApiError | null;
48
+ };
49
+ /**
50
+ * Pagination metadata returned with every list response.
51
+ */
52
+ type PaginationMetadata = {
53
+ total: number;
54
+ totalPages: number;
55
+ page: number;
56
+ perPage: number;
57
+ /** Reserved for future cursor-based pagination */
58
+ nextCursor?: string;
59
+ };
60
+ /**
61
+ * Pagination request parameters.
62
+ * Accepted by any paginated method.
63
+ */
64
+ type PaginationParams = {
65
+ page?: number;
66
+ perPage?: number;
67
+ };
68
+ /**
69
+ * Standardized error codes used across all services.
70
+ *
71
+ * These are the machine-readable `code` values on ApiError.
72
+ * Services may also return service-specific codes beyond these.
73
+ */
74
+ declare const ErrorCodes: {
75
+ readonly UNAUTHORIZED: "unauthorized";
76
+ readonly FORBIDDEN: "forbidden";
77
+ readonly NOT_FOUND: "not_found";
78
+ readonly CONFLICT: "conflict";
79
+ readonly VALIDATION_ERROR: "validation_error";
80
+ readonly RATE_LIMITED: "rate_limited";
81
+ readonly QUOTA_EXCEEDED: "quota_exceeded";
82
+ readonly INTERNAL_ERROR: "internal_error";
83
+ readonly NETWORK_ERROR: "network_error";
84
+ readonly TIMEOUT: "timeout";
85
+ readonly ABORTED: "aborted";
86
+ readonly FILE_SCANNING: "file_scanning";
87
+ readonly FILE_THREAT: "file_threat";
88
+ readonly FILE_QUARANTINED: "file_quarantined";
89
+ readonly UPLOAD_ERROR: "upload_error";
90
+ };
91
+ type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
92
+ /**
93
+ * Storage adapter interface for session persistence.
94
+ * Supports both sync (localStorage) and async (AsyncStorage) implementations.
95
+ */
96
+ interface StorageAdapter {
97
+ getItem(key: string): string | null | Promise<string | null>;
98
+ setItem(key: string, value: string): void | Promise<void>;
99
+ removeItem(key: string): void | Promise<void>;
100
+ }
101
+ /**
102
+ * Configuration for the ScaleMule client.
103
+ */
104
+ interface ScaleMuleConfig {
105
+ /** API key (publishable key for browser, secret key for server) */
106
+ apiKey: string;
107
+ /** Base URL for API requests. Overrides environment preset. */
108
+ baseUrl?: string;
109
+ /** Environment preset ('dev' or 'prod'). Defaults to 'prod'. */
110
+ environment?: 'dev' | 'prod';
111
+ /** Retry configuration for transient failures */
112
+ retry?: {
113
+ /** Max retry attempts (default: 2) */
114
+ maxRetries?: number;
115
+ /** Base delay between retries in ms (default: 300) */
116
+ backoffMs?: number;
117
+ };
118
+ /** Request timeout in ms (default: 30000) */
119
+ timeout?: number;
120
+ /** Enable debug logging to console */
121
+ debug?: boolean;
122
+ /** Custom storage adapter for session persistence */
123
+ storage?: StorageAdapter;
124
+ /** Enable rate limit queue — auto-queues requests when rate limited */
125
+ enableRateLimitQueue?: boolean;
126
+ /** Enable offline queue — queues requests when offline, syncs on reconnect */
127
+ enableOfflineQueue?: boolean;
128
+ }
129
+ /**
130
+ * Per-request options that override client defaults.
131
+ */
132
+ interface RequestOptions {
133
+ /** Skip adding auth headers (for public endpoints) */
134
+ skipAuth?: boolean;
135
+ /** Custom timeout in ms for this request */
136
+ timeout?: number;
137
+ /** Number of retry attempts for this request */
138
+ retries?: number;
139
+ /** Skip retries entirely for this request */
140
+ skipRetry?: boolean;
141
+ /** User-provided AbortSignal for cancellation */
142
+ signal?: AbortSignal;
143
+ /** Additional headers for this request */
144
+ headers?: Record<string, string>;
145
+ /** Client context to forward end-user info (IP, UA, etc.) in server-to-server calls */
146
+ clientContext?: ClientContext;
147
+ }
148
+ /**
149
+ * End-user context for server-to-server calls.
150
+ *
151
+ * When your server proxies requests to ScaleMule (e.g., from a Next.js API route),
152
+ * pass this so ScaleMule records the real end-user's information instead of your
153
+ * server's IP and user agent.
154
+ *
155
+ * Use `extractClientContext()` to build this from an incoming request.
156
+ */
157
+ interface ClientContext {
158
+ /** End-user IP address */
159
+ ip?: string;
160
+ /** End-user browser User-Agent */
161
+ userAgent?: string;
162
+ /** End-user device fingerprint */
163
+ deviceFingerprint?: string;
164
+ /** HTTP Referer header from the end-user's request */
165
+ referrer?: string;
166
+ }
167
+
168
+ /**
169
+ * Client Context Utilities (Framework-Agnostic)
170
+ *
171
+ * Extract end-user context from incoming HTTP requests and convert it
172
+ * to X-Client-* headers for forwarding to ScaleMule.
173
+ *
174
+ * Works with any server framework: Express, Fastify, Hono, raw Node.js
175
+ * http.IncomingMessage, Next.js, etc.
176
+ *
177
+ * For Next.js-specific helpers (App Router `NextRequest`, Pages Router
178
+ * `NextApiRequest`), see `@scalemule/nextjs/server` which re-exports
179
+ * these utilities plus Next.js-typed wrappers.
180
+ */
181
+
182
+ /**
183
+ * Minimal interface for an incoming HTTP request.
184
+ *
185
+ * Covers Node.js `http.IncomingMessage`, Express `Request`, Fastify
186
+ * `FastifyRequest`, and similar. Headers are a plain object where values
187
+ * can be `string`, `string[]`, or `undefined` (Node.js convention).
188
+ */
189
+ interface IncomingRequestLike {
190
+ headers: Record<string, string | string[] | undefined>;
191
+ socket?: {
192
+ remoteAddress?: string;
193
+ };
194
+ }
195
+ /**
196
+ * Validate an IPv4 or IPv6 address.
197
+ * Returns the trimmed IP if valid, `undefined` otherwise.
198
+ */
199
+ declare function validateIP(ip: string | undefined | null): string | undefined;
200
+ /**
201
+ * Extract end-user context from an incoming HTTP request.
202
+ *
203
+ * IP extraction priority (same chain as `@scalemule/nextjs`):
204
+ * 1. CF-Connecting-IP (Cloudflare)
205
+ * 2. DO-Connecting-IP (DigitalOcean)
206
+ * 3. X-Real-IP (nginx / DO K8s ingress)
207
+ * 4. X-Forwarded-For (first IP — standard proxy header)
208
+ * 5. X-Vercel-Forwarded-For (Vercel)
209
+ * 6. True-Client-IP (Akamai / Cloudflare Enterprise)
210
+ * 7. socket.remoteAddress (direct connection fallback)
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * // Express
215
+ * import { extractClientContext } from '@scalemule/sdk'
216
+ * app.post('/upload', async (req, res) => {
217
+ * const ctx = extractClientContext(req)
218
+ * const result = await sm.storage.upload(file, { clientContext: ctx })
219
+ * })
220
+ * ```
221
+ */
222
+ declare function extractClientContext(request: IncomingRequestLike): ClientContext;
223
+ /**
224
+ * Convert a `ClientContext` into request headers for ScaleMule.
225
+ *
226
+ * `x-sm-forwarded-client-ip` is the authenticated server-side forwarding header
227
+ * consumed by the gateway to derive trusted downstream IP context.
228
+ *
229
+ * We also keep the legacy `X-Client-*` headers during rollout for backward
230
+ * compatibility with older gateway/service deployments.
231
+ *
232
+ * Used internally by `ServiceModule.resolveOptions()`. You normally don't
233
+ * need to call this directly — just pass `clientContext` in `RequestOptions`.
234
+ */
235
+ declare function buildClientContextHeaders(context: ClientContext | undefined): Record<string, string>;
236
+
237
+ /**
238
+ * ScaleMule Core HTTP Client
239
+ *
240
+ * Fetch-based client with:
241
+ * - { data, error } response contract
242
+ * - Exponential backoff with jitter on retries
243
+ * - x-idempotency-key on POST retries (prevents duplicate side effects)
244
+ * - Rate limit queue (auto-queues on 429)
245
+ * - Offline queue with persistence
246
+ * - AbortController / AbortSignal support
247
+ * - Works in browser, Node.js 18+, and edge runtimes
248
+ *
249
+ * Promoted from sdks/scalemule-nextjs and adapted for the base SDK.
250
+ */
251
+
252
+ declare class ScaleMuleClient {
253
+ private apiKey;
254
+ private baseUrl;
255
+ private debug;
256
+ private storage;
257
+ private defaultTimeout;
258
+ private maxRetries;
259
+ private backoffMs;
260
+ private sessionToken;
261
+ private userId;
262
+ private rateLimitQueue;
263
+ private offlineQueue;
264
+ constructor(config: ScaleMuleConfig);
265
+ initialize(): Promise<void>;
266
+ setSession(token: string, userId: string): Promise<void>;
267
+ clearSession(): Promise<void>;
268
+ setAccessToken(token: string): void;
269
+ clearAccessToken(): void;
270
+ getSessionToken(): string | null;
271
+ getUserId(): string | null;
272
+ isAuthenticated(): boolean;
273
+ getBaseUrl(): string;
274
+ getApiKey(): string;
275
+ isOnline(): boolean;
276
+ getOfflineQueueLength(): number;
277
+ getRateLimitQueueLength(): number;
278
+ isRateLimited(): boolean;
279
+ request<T>(path: string, init?: {
280
+ method?: string;
281
+ body?: unknown;
282
+ headers?: Record<string, string>;
283
+ skipAuth?: boolean;
284
+ timeout?: number;
285
+ retries?: number;
286
+ skipRetry?: boolean;
287
+ signal?: AbortSignal;
288
+ }): Promise<ApiResponse<T>>;
289
+ get<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
290
+ post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
291
+ put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
292
+ patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
293
+ del<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
294
+ /**
295
+ * Upload a file using multipart/form-data.
296
+ *
297
+ * Supports progress tracking via XMLHttpRequest (browser only).
298
+ * Supports cancellation via AbortController signal.
299
+ * Retries with exponential backoff on transient failures.
300
+ */
301
+ upload<T>(path: string, file: File | Blob, additionalFields?: Record<string, string>, options?: RequestOptions & {
302
+ onProgress?: (progress: number) => void;
303
+ }): Promise<ApiResponse<T>>;
304
+ /**
305
+ * Single upload with XMLHttpRequest for progress tracking.
306
+ * Supports abort via AbortSignal.
307
+ */
308
+ private uploadWithXHR;
309
+ private syncOfflineQueue;
310
+ }
311
+
312
+ /**
313
+ * ServiceModule Base Class
314
+ *
315
+ * Abstract base that all service modules (auth, storage, etc.) extend.
316
+ * Provides typed HTTP methods that delegate to ScaleMuleClient and
317
+ * auto-normalize responses into the { data, error } contract.
318
+ *
319
+ * Pagination: The `list()` method normalizes backend pagination responses
320
+ * into the standard PaginatedResponse<T> envelope.
321
+ */
322
+
323
+ declare abstract class ServiceModule {
324
+ protected client: ScaleMuleClient;
325
+ protected abstract basePath: string;
326
+ constructor(client: ScaleMuleClient);
327
+ /**
328
+ * Merge `clientContext` from RequestOptions into `headers`.
329
+ * Explicit headers take precedence over context-derived ones.
330
+ */
331
+ private resolveOptions;
332
+ protected _get<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
333
+ protected post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
334
+ protected put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
335
+ protected patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
336
+ protected del<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
337
+ /**
338
+ * Fetch a paginated list from the backend.
339
+ *
340
+ * Normalizes varying backend pagination shapes into the standard
341
+ * PaginatedResponse<T> envelope. Supports backends that return:
342
+ * - { data: T[], metadata: { total, ... } } (preferred)
343
+ * - { items: T[], total, page, per_page } (legacy)
344
+ * - T[] (bare array)
345
+ *
346
+ * Extra params beyond page/perPage are forwarded as query string parameters.
347
+ */
348
+ protected _list<T>(path: string, params?: Record<string, unknown>, options?: RequestOptions): Promise<PaginatedResponse<T>>;
349
+ protected _upload<T>(path: string, file: File | Blob, additionalFields?: Record<string, string>, options?: RequestOptions & {
350
+ onProgress?: (progress: number) => void;
351
+ }): Promise<ApiResponse<T>>;
352
+ /**
353
+ * Append query parameters to a relative path.
354
+ * Use with verb methods: `this.get(this.withQuery('/items', { status: 'active' }))`
355
+ * Does NOT add basePath — the verb methods handle that.
356
+ */
357
+ protected withQuery(path: string, params?: Record<string, unknown>): string;
358
+ }
359
+
360
+ /**
361
+ * Auth Service Module
362
+ *
363
+ * Full auth service with nested sub-APIs:
364
+ * auth.mfa.* — Multi-factor authentication
365
+ * auth.sessions.* — Session management
366
+ * auth.devices.* — Device trust/block
367
+ * auth.loginHistory.* — Login history & activity
368
+ */
369
+
370
+ interface AuthUser {
371
+ id: string;
372
+ email: string;
373
+ email_verified: boolean;
374
+ phone?: string;
375
+ phone_verified: boolean;
376
+ full_name?: string;
377
+ username?: string;
378
+ avatar_url?: string;
379
+ status: string;
380
+ created_at: string;
381
+ }
382
+ interface LoginDeviceInfo {
383
+ id: string;
384
+ name: string;
385
+ trust_level: string;
386
+ is_new: boolean;
387
+ }
388
+ interface LoginRiskInfo {
389
+ score: number;
390
+ action: string;
391
+ factors: string[];
392
+ action_required?: boolean;
393
+ }
394
+ interface AuthSession {
395
+ session_token: string;
396
+ user: AuthUser;
397
+ expires_at: string;
398
+ absolute_expires_at: string;
399
+ access_token?: string;
400
+ refresh_token?: string;
401
+ access_token_expires_in?: number;
402
+ device?: LoginDeviceInfo;
403
+ risk?: LoginRiskInfo;
404
+ }
405
+ interface SessionInfo {
406
+ id: string;
407
+ ip_address?: string;
408
+ user_agent?: string;
409
+ device: string;
410
+ created_at: string;
411
+ last_active_at: string;
412
+ is_current: boolean;
413
+ }
414
+ interface DeviceInfo {
415
+ id: string;
416
+ device_name?: string;
417
+ trust_level: string;
418
+ successful_logins: number;
419
+ last_successful_login?: string;
420
+ last_ip?: string;
421
+ last_country?: string;
422
+ last_city?: string;
423
+ is_blocked: boolean;
424
+ is_current: boolean;
425
+ created_at: string;
426
+ }
427
+ interface MfaStatus {
428
+ mfa_enabled: boolean;
429
+ mfa_method?: string;
430
+ totp_configured: boolean;
431
+ sms_configured: boolean;
432
+ email_configured: boolean;
433
+ backup_codes_remaining: number;
434
+ allowed_methods: string[];
435
+ mfa_required: boolean;
436
+ requirement_source: string;
437
+ }
438
+ interface TotpSetup {
439
+ secret: string;
440
+ qr_code_uri: string;
441
+ issuer: string;
442
+ account_name: string;
443
+ }
444
+ interface BackupCodes {
445
+ backup_codes: string[];
446
+ message: string;
447
+ }
448
+ interface LoginHistoryEntry {
449
+ id: string;
450
+ login_method: string;
451
+ success: boolean;
452
+ failure_reason?: string;
453
+ risk_score: number;
454
+ risk_action: string;
455
+ device?: {
456
+ id?: string;
457
+ name: string;
458
+ user_agent?: string;
459
+ };
460
+ location?: {
461
+ ip_address: string;
462
+ country?: string;
463
+ city?: string;
464
+ };
465
+ created_at: string;
466
+ }
467
+ interface LoginActivitySummary {
468
+ total_logins_30d: number;
469
+ successful_logins_30d: number;
470
+ failed_logins_30d: number;
471
+ unique_devices: number;
472
+ unique_locations: number;
473
+ high_risk_logins_30d: number;
474
+ last_login?: string;
475
+ last_failed_login?: string;
476
+ }
477
+ interface OAuthUrl {
478
+ url: string;
479
+ state?: string;
480
+ }
481
+ interface OAuthProvider {
482
+ provider: string;
483
+ provider_email?: string;
484
+ linked_at: string;
485
+ }
486
+ interface DataExport {
487
+ user: {
488
+ id: string;
489
+ email: string;
490
+ email_verified: boolean;
491
+ phone?: string;
492
+ phone_verified: boolean;
493
+ full_name?: string;
494
+ username?: string;
495
+ avatar_url?: string;
496
+ status: string;
497
+ created_at: string;
498
+ };
499
+ sessions: Array<{
500
+ id: string;
501
+ ip_address?: string;
502
+ user_agent?: string;
503
+ created_at: string;
504
+ expires_at: string;
505
+ }>;
506
+ oauth_providers: Array<{
507
+ provider: string;
508
+ provider_email?: string;
509
+ linked_at: string;
510
+ }>;
511
+ exported_at: string;
512
+ }
513
+ declare class AuthMfaApi extends ServiceModule {
514
+ protected basePath: string;
515
+ getStatus(): Promise<ApiResponse<MfaStatus>>;
516
+ setupTotp(): Promise<ApiResponse<TotpSetup>>;
517
+ verifySetup(data: {
518
+ code: string;
519
+ }): Promise<ApiResponse<{
520
+ success: boolean;
521
+ backup_codes: string[];
522
+ message: string;
523
+ }>>;
524
+ enableSms(): Promise<ApiResponse<{
525
+ success: boolean;
526
+ message: string;
527
+ phone_last_digits: string;
528
+ }>>;
529
+ enableEmail(): Promise<ApiResponse<{
530
+ success: boolean;
531
+ message: string;
532
+ email_masked: string;
533
+ }>>;
534
+ disable(data: {
535
+ password: string;
536
+ code?: string;
537
+ }): Promise<ApiResponse<{
538
+ success: boolean;
539
+ message: string;
540
+ }>>;
541
+ regenerateBackupCodes(): Promise<ApiResponse<BackupCodes>>;
542
+ sendCode(data: {
543
+ pending_token: string;
544
+ method: 'sms' | 'email';
545
+ }): Promise<ApiResponse<{
546
+ success: boolean;
547
+ message: string;
548
+ expires_in_seconds: number;
549
+ }>>;
550
+ verify(data: {
551
+ pending_token: string;
552
+ code: string;
553
+ method?: 'totp' | 'sms' | 'email' | 'backup_code';
554
+ }): Promise<ApiResponse<AuthSession>>;
555
+ }
556
+ declare class AuthSessionsApi extends ServiceModule {
557
+ protected basePath: string;
558
+ list(): Promise<ApiResponse<SessionInfo[]>>;
559
+ revoke(sessionId: string): Promise<ApiResponse<{
560
+ revoked: boolean;
561
+ }>>;
562
+ revokeAll(): Promise<ApiResponse<{
563
+ revoked_count: number;
564
+ }>>;
565
+ }
566
+ declare class AuthDevicesApi extends ServiceModule {
567
+ protected basePath: string;
568
+ list(): Promise<ApiResponse<DeviceInfo[]>>;
569
+ trust(deviceId: string): Promise<ApiResponse<DeviceInfo>>;
570
+ block(deviceId: string): Promise<ApiResponse<DeviceInfo>>;
571
+ delete(deviceId: string): Promise<ApiResponse<{
572
+ deleted: boolean;
573
+ }>>;
574
+ }
575
+ declare class AuthLoginHistoryApi extends ServiceModule {
576
+ protected basePath: string;
577
+ list(params?: PaginationParams & {
578
+ success?: boolean;
579
+ }): Promise<ApiResponse<LoginHistoryEntry[]>>;
580
+ getSummary(): Promise<ApiResponse<LoginActivitySummary>>;
581
+ }
582
+ declare class AuthService extends ServiceModule {
583
+ protected basePath: string;
584
+ /** MFA sub-API: sm.auth.mfa.getStatus(), .setupTotp(), .verify(), etc. */
585
+ readonly mfa: AuthMfaApi;
586
+ /** Session sub-API: sm.auth.sessions.list(), .revoke(), .revokeAll() */
587
+ readonly sessions: AuthSessionsApi;
588
+ /** Device sub-API: sm.auth.devices.list(), .trust(), .block(), .delete() */
589
+ readonly devices: AuthDevicesApi;
590
+ /** Login history sub-API: sm.auth.loginHistory.list(), .getSummary() */
591
+ readonly loginHistory: AuthLoginHistoryApi;
592
+ constructor(client: ScaleMuleClient);
593
+ private sanitizePhoneField;
594
+ register(data: {
595
+ email: string;
596
+ password: string;
597
+ name?: string;
598
+ full_name?: string;
599
+ username?: string;
600
+ phone?: string;
601
+ session_id?: string;
602
+ }, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
603
+ login(data: {
604
+ email: string;
605
+ password: string;
606
+ remember_me?: boolean;
607
+ }, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
608
+ logout(options?: RequestOptions): Promise<ApiResponse<{
609
+ logged_out: boolean;
610
+ }>>;
611
+ me(options?: RequestOptions): Promise<ApiResponse<AuthUser>>;
612
+ /** Refresh the session. Alias: refreshToken() */
613
+ refreshSession(data?: {
614
+ refresh_token?: string;
615
+ session_token?: string;
616
+ }, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
617
+ /** @deprecated Use refreshSession() */
618
+ refreshToken(data?: {
619
+ refresh_token?: string;
620
+ session_token?: string;
621
+ }): Promise<ApiResponse<AuthSession>>;
622
+ /**
623
+ * Send a one-time password for passwordless sign-in.
624
+ * @experimental Endpoint availability depends on backend deployment.
625
+ */
626
+ signInWithOtp(data: {
627
+ email?: string;
628
+ phone?: string;
629
+ channel?: 'email' | 'sms';
630
+ }, options?: RequestOptions): Promise<ApiResponse<{
631
+ sent: boolean;
632
+ }>>;
633
+ /**
634
+ * Verify OTP code and create a session.
635
+ * @experimental Endpoint availability depends on backend deployment.
636
+ */
637
+ verifyOtp(data: {
638
+ email?: string;
639
+ phone?: string;
640
+ code: string;
641
+ }, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
642
+ /**
643
+ * Send a magic link for passwordless sign-in.
644
+ * @experimental Endpoint availability depends on backend deployment.
645
+ */
646
+ signInWithMagicLink(data: {
647
+ email: string;
648
+ }, options?: RequestOptions): Promise<ApiResponse<{
649
+ sent: boolean;
650
+ }>>;
651
+ /**
652
+ * Verify a magic link token and create a session.
653
+ * @experimental Endpoint availability depends on backend deployment.
654
+ */
655
+ verifyMagicLink(data: {
656
+ token: string;
657
+ }, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
658
+ sendPhoneOtp(data: {
659
+ phone: string;
660
+ purpose?: 'verify_phone' | 'login' | 'password_reset' | 'change_phone';
661
+ }, options?: RequestOptions): Promise<ApiResponse<{
662
+ sent: boolean;
663
+ }>>;
664
+ verifyPhoneOtp(data: {
665
+ phone: string;
666
+ code: string;
667
+ }, options?: RequestOptions): Promise<ApiResponse<{
668
+ verified: boolean;
669
+ }>>;
670
+ resendPhoneOtp(data: {
671
+ phone: string;
672
+ }, options?: RequestOptions): Promise<ApiResponse<{
673
+ sent: boolean;
674
+ }>>;
675
+ /** Login with phone OTP (sends + verifies in one flow) */
676
+ loginWithPhone(data: {
677
+ phone: string;
678
+ code: string;
679
+ }, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
680
+ forgotPassword(data: {
681
+ email: string;
682
+ }, options?: RequestOptions): Promise<ApiResponse<{
683
+ sent: boolean;
684
+ }>>;
685
+ resetPassword(data: {
686
+ token: string;
687
+ password?: string;
688
+ new_password?: string;
689
+ }, options?: RequestOptions): Promise<ApiResponse<{
690
+ reset: boolean;
691
+ }>>;
692
+ changePassword(data: {
693
+ current_password: string;
694
+ new_password: string;
695
+ }, options?: RequestOptions): Promise<ApiResponse<{
696
+ changed: boolean;
697
+ }>>;
698
+ verifyEmail(data: {
699
+ token: string;
700
+ }, options?: RequestOptions): Promise<ApiResponse<{
701
+ verified: boolean;
702
+ }>>;
703
+ /** Resend email verification. Alias: resendEmailVerification() */
704
+ resendVerification(data?: {
705
+ email?: string;
706
+ }, options?: RequestOptions): Promise<ApiResponse<{
707
+ sent: boolean;
708
+ }>>;
709
+ /** @deprecated Use resendVerification() */
710
+ resendEmailVerification(data?: {
711
+ email?: string;
712
+ }): Promise<ApiResponse<{
713
+ sent: boolean;
714
+ }>>;
715
+ changeEmail(data: {
716
+ new_email: string;
717
+ password: string;
718
+ }, options?: RequestOptions): Promise<ApiResponse<{
719
+ changed: boolean;
720
+ }>>;
721
+ changePhone(data: {
722
+ new_phone: string;
723
+ }, options?: RequestOptions): Promise<ApiResponse<{
724
+ changed: boolean;
725
+ }>>;
726
+ deleteAccount(options?: RequestOptions): Promise<ApiResponse<{
727
+ deleted: boolean;
728
+ }>>;
729
+ exportData(options?: RequestOptions): Promise<ApiResponse<DataExport>>;
730
+ getOAuthUrl(provider: string, redirectUri: string, options?: RequestOptions): Promise<ApiResponse<OAuthUrl>>;
731
+ handleOAuthCallback(data: {
732
+ provider: string;
733
+ code: string;
734
+ state?: string;
735
+ }, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
736
+ listOAuthProviders(options?: RequestOptions): Promise<ApiResponse<OAuthProvider[]>>;
737
+ unlinkOAuthProvider(provider: string, options?: RequestOptions): Promise<ApiResponse<{
738
+ unlinked: boolean;
739
+ }>>;
740
+ refreshAccessToken(data?: {
741
+ refresh_token?: string;
742
+ }, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
743
+ revokeRefreshToken(data: {
744
+ refresh_token: string;
745
+ }, options?: RequestOptions): Promise<ApiResponse<{
746
+ revoked: boolean;
747
+ }>>;
748
+ /** @deprecated Use auth.sessions.list() */
749
+ listSessions(): Promise<ApiResponse<SessionInfo[]>>;
750
+ /** @deprecated Use auth.sessions.revoke() */
751
+ revokeSession(sessionId: string): Promise<ApiResponse<{
752
+ revoked: boolean;
753
+ }>>;
754
+ /** @deprecated Use auth.sessions.revokeAll() */
755
+ revokeOtherSessions(): Promise<ApiResponse<{
756
+ revoked_count: number;
757
+ }>>;
758
+ /** @deprecated Use auth.devices.list() */
759
+ listDevices(): Promise<ApiResponse<DeviceInfo[]>>;
760
+ /** @deprecated Use auth.devices.trust() */
761
+ trustDevice(deviceId: string): Promise<ApiResponse<DeviceInfo>>;
762
+ /** @deprecated Use auth.devices.block() */
763
+ blockDevice(deviceId: string): Promise<ApiResponse<DeviceInfo>>;
764
+ /** @deprecated Use auth.devices.delete() */
765
+ deleteDevice(deviceId: string): Promise<ApiResponse<{
766
+ deleted: boolean;
767
+ }>>;
768
+ /** @deprecated Use auth.loginHistory.list() */
769
+ getLoginHistory(params?: {
770
+ success?: boolean;
771
+ page?: number;
772
+ per_page?: number;
773
+ }): Promise<ApiResponse<LoginHistoryEntry[]>>;
774
+ /** @deprecated Use auth.loginHistory.getSummary() */
775
+ getLoginActivitySummary(): Promise<ApiResponse<LoginActivitySummary>>;
776
+ /** @deprecated Use auth.mfa.getStatus() */
777
+ getMfaStatus(): Promise<ApiResponse<MfaStatus>>;
778
+ /** @deprecated Use auth.mfa.setupTotp() */
779
+ setupTotp(): Promise<ApiResponse<TotpSetup>>;
780
+ /** @deprecated Use auth.mfa.verifySetup() */
781
+ verifyTotpSetup(data: {
782
+ code: string;
783
+ }): Promise<ApiResponse<{
784
+ success: boolean;
785
+ backup_codes: string[];
786
+ message: string;
787
+ }>>;
788
+ /** @deprecated Use auth.mfa.enableSms() */
789
+ enableSmsMfa(): Promise<ApiResponse<{
790
+ success: boolean;
791
+ message: string;
792
+ phone_last_digits: string;
793
+ }>>;
794
+ /** @deprecated Use auth.mfa.enableEmail() */
795
+ enableEmailMfa(): Promise<ApiResponse<{
796
+ success: boolean;
797
+ message: string;
798
+ email_masked: string;
799
+ }>>;
800
+ /** @deprecated Use auth.mfa.disable() */
801
+ disableMfa(data: {
802
+ password: string;
803
+ code?: string;
804
+ }): Promise<ApiResponse<{
805
+ success: boolean;
806
+ message: string;
807
+ }>>;
808
+ /** @deprecated Use auth.mfa.regenerateBackupCodes() */
809
+ regenerateBackupCodes(): Promise<ApiResponse<BackupCodes>>;
810
+ /** @deprecated Use auth.mfa.sendCode() */
811
+ sendMfaCode(data: {
812
+ pending_token: string;
813
+ method: 'sms' | 'email';
814
+ }): Promise<ApiResponse<{
815
+ success: boolean;
816
+ message: string;
817
+ expires_in_seconds: number;
818
+ }>>;
819
+ /** @deprecated Use auth.mfa.verify() */
820
+ verifyMfa(data: {
821
+ pending_token: string;
822
+ code: string;
823
+ method?: 'totp' | 'sms' | 'email' | 'backup_code';
824
+ }): Promise<ApiResponse<AuthSession>>;
825
+ }
826
+
827
+ interface UploadOptions {
828
+ /** Display filename (sanitized automatically) */
829
+ filename?: string;
830
+ /** Make file publicly accessible */
831
+ isPublic?: boolean;
832
+ /** Custom metadata attached to the file */
833
+ metadata?: Record<string, unknown>;
834
+ /** Upload progress callback (0-100) */
835
+ onProgress?: (percent: number) => void;
836
+ /** AbortSignal for cancellation */
837
+ signal?: AbortSignal;
838
+ /** Client context to forward end-user info (IP, UA, etc.) in server-to-server calls */
839
+ clientContext?: ClientContext;
840
+ /** Skip client-side image compression (default: false) */
841
+ skipCompression?: boolean;
842
+ /** Compression configuration */
843
+ compression?: Partial<CompressionConfig>;
844
+ /** Force multipart upload regardless of file size */
845
+ forceMultipart?: boolean;
846
+ /** Resume behavior: 'auto' resumes from IndexedDB, 'off' disables (default: 'auto' in browser) */
847
+ resume?: 'auto' | 'off';
848
+ /** Chunk size in bytes for multipart upload */
849
+ chunkSize?: number;
850
+ /** Max concurrent part uploads */
851
+ maxConcurrency?: number;
852
+ /** Enable upload telemetry (default: true) */
853
+ telemetry?: boolean;
854
+ }
855
+ interface CompressionConfig {
856
+ /** Max width in pixels */
857
+ maxWidth: number;
858
+ /** Max height in pixels */
859
+ maxHeight: number;
860
+ /** JPEG/WebP quality 0-1 (default: 0.8) */
861
+ quality: number;
862
+ /** Max file size in MB to target */
863
+ maxSizeMB: number;
864
+ }
865
+ interface PresignedUploadResponse {
866
+ file_id: string;
867
+ upload_url: string;
868
+ completion_token: string;
869
+ expires_at: string;
870
+ method: string;
871
+ }
872
+ interface UploadCompleteResponse {
873
+ file_id: string;
874
+ filename: string;
875
+ size_bytes: number;
876
+ content_type: string;
877
+ url: string;
878
+ already_completed: boolean;
879
+ scan_queued: boolean;
880
+ }
881
+ interface MultipartStartResponse {
882
+ upload_session_id: string;
883
+ file_id: string;
884
+ completion_token: string;
885
+ part_size_bytes: number;
886
+ total_parts: number;
887
+ part_urls: PartUrl[];
888
+ expires_at: string;
889
+ }
890
+ interface PartUrl {
891
+ part_number: number;
892
+ url: string;
893
+ expires_at: string;
894
+ }
895
+ interface MultipartPartUrlsResponse {
896
+ part_urls: PartUrl[];
897
+ }
898
+ interface MultipartCompleteResponse {
899
+ file_id: string;
900
+ filename: string;
901
+ size_bytes: number;
902
+ content_type: string;
903
+ url: string;
904
+ scan_queued: boolean;
905
+ }
906
+ interface FileInfo {
907
+ id: string;
908
+ filename: string;
909
+ content_type: string;
910
+ size_bytes: number;
911
+ is_public?: boolean;
912
+ url?: string;
913
+ scan_status?: string;
914
+ scanned_at?: string;
915
+ checksum?: string;
916
+ created_at: string;
917
+ }
918
+ interface SignedUrlResponse {
919
+ url: string;
920
+ expires_at: string;
921
+ }
922
+ declare class StorageService extends ServiceModule {
923
+ protected basePath: string;
924
+ private telemetry;
925
+ /**
926
+ * Upload a file using the optimal strategy.
927
+ *
928
+ * Small files (< 8MB): 3-step presigned URL flow with retry + stall guard.
929
+ * Large files (>= 8MB): Multipart with windowed presigns, resumable.
930
+ *
931
+ * @returns The completed file record with id, url, etc.
932
+ */
933
+ upload(file: File | Blob, options?: UploadOptions): Promise<ApiResponse<FileInfo>>;
934
+ private uploadDirect;
935
+ private uploadMultipart;
936
+ private abortMultipart;
937
+ /**
938
+ * Get a presigned URL for direct upload to S3.
939
+ * Use this when the browser uploads directly (with progress tracking)
940
+ * and the server only brokers the URLs.
941
+ *
942
+ * Flow: server calls getUploadUrl() → returns URL to client → client PUTs to S3 → server calls completeUpload()
943
+ */
944
+ getUploadUrl(filename: string, contentType: string, options?: {
945
+ isPublic?: boolean;
946
+ expiresIn?: number;
947
+ metadata?: Record<string, unknown>;
948
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<PresignedUploadResponse>>;
949
+ /**
950
+ * Complete a presigned upload after the file has been uploaded to S3.
951
+ * Triggers scan and makes the file available.
952
+ */
953
+ completeUpload(fileId: string, completionToken: string, options?: {
954
+ sizeBytes?: number;
955
+ checksum?: string;
956
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<UploadCompleteResponse>>;
957
+ /** Start a multipart upload session. */
958
+ startMultipartUpload(params: {
959
+ filename: string;
960
+ content_type: string;
961
+ size_bytes: number;
962
+ is_public?: boolean;
963
+ metadata?: Record<string, unknown>;
964
+ chunk_size?: number;
965
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<MultipartStartResponse>>;
966
+ /** Get presigned URLs for specific part numbers. */
967
+ getMultipartPartUrls(uploadSessionId: string, partNumbers: number[], completionToken?: string, requestOptions?: RequestOptions): Promise<ApiResponse<MultipartPartUrlsResponse>>;
968
+ /** Complete a multipart upload. */
969
+ completeMultipartUpload(params: {
970
+ upload_session_id: string;
971
+ file_id: string;
972
+ completion_token: string;
973
+ parts: Array<{
974
+ part_number: number;
975
+ etag: string;
976
+ }>;
977
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<MultipartCompleteResponse>>;
978
+ /** Abort a multipart upload. */
979
+ abortMultipartUpload(uploadSessionId: string, completionToken?: string, requestOptions?: RequestOptions): Promise<ApiResponse<{
980
+ aborted: boolean;
981
+ }>>;
982
+ /** Get file metadata (no signed URL). */
983
+ getInfo(fileId: string, options?: RequestOptions): Promise<ApiResponse<FileInfo>>;
984
+ /**
985
+ * Get a signed view URL for inline display (img src, thumbnails).
986
+ * Returns CloudFront signed URL (fast, ~1us) or S3 presigned fallback.
987
+ */
988
+ getViewUrl(fileId: string, options?: RequestOptions): Promise<ApiResponse<SignedUrlResponse>>;
989
+ /**
990
+ * Get signed view URLs for multiple files (batch, up to 100).
991
+ * Single network call, returns all URLs.
992
+ * The shared `expires_at` is a conservative lower bound — reflects the shortest-lived
993
+ * URL in the batch. Individual URLs may remain valid longer if their files are public.
994
+ */
995
+ getViewUrls(fileIds: string[], options?: RequestOptions): Promise<ApiResponse<Record<string, SignedUrlResponse>>>;
996
+ /**
997
+ * Get a signed download URL (Content-Disposition: attachment).
998
+ */
999
+ getDownloadUrl(fileId: string, options?: RequestOptions): Promise<ApiResponse<SignedUrlResponse>>;
1000
+ /** Delete a file (soft delete). */
1001
+ delete(fileId: string, options?: RequestOptions): Promise<ApiResponse<{
1002
+ deleted: boolean;
1003
+ }>>;
1004
+ /** List the current user's files (paginated). */
1005
+ list(params?: PaginationParams, options?: RequestOptions): Promise<PaginatedResponse<FileInfo>>;
1006
+ /** Check file view/access status. */
1007
+ getViewStatus(fileId: string, options?: RequestOptions): Promise<ApiResponse<{
1008
+ status: string;
1009
+ url?: string;
1010
+ }>>;
1011
+ /**
1012
+ * Update a file's visibility (public/private).
1013
+ * Only the file owner can toggle this. Changes URL TTL — does not move the S3 object.
1014
+ * Public files get 7-day signed URLs; private files get 1-hour signed URLs.
1015
+ */
1016
+ updateVisibility(fileId: string, isPublic: boolean, options?: RequestOptions): Promise<ApiResponse<{
1017
+ file_id: string;
1018
+ is_public: boolean;
1019
+ }>>;
1020
+ /** @deprecated Use upload() instead */
1021
+ uploadFile(file: File | Blob, options?: {
1022
+ is_public?: boolean;
1023
+ metadata?: Record<string, unknown>;
1024
+ onProgress?: (progress: number) => void;
1025
+ signal?: AbortSignal;
1026
+ }): Promise<ApiResponse<FileInfo>>;
1027
+ /** @deprecated Use getInfo() instead */
1028
+ getFile(id: string): Promise<ApiResponse<FileInfo>>;
1029
+ /** @deprecated Use delete() instead */
1030
+ deleteFile(id: string): Promise<ApiResponse<{
1031
+ deleted: boolean;
1032
+ }>>;
1033
+ /** @deprecated Use list() instead */
1034
+ listFiles(params?: PaginationParams & {
1035
+ folder?: string;
1036
+ }): Promise<PaginatedResponse<FileInfo>>;
1037
+ private uploadToPresignedUrlWithRetry;
1038
+ /**
1039
+ * Upload file directly to S3 presigned URL.
1040
+ * Uses XHR for progress tracking in browser, fetch otherwise.
1041
+ * Includes stall detection.
1042
+ */
1043
+ private uploadToPresignedUrl;
1044
+ private uploadWithXHR;
1045
+ private uploadPartWithRetry;
1046
+ private shouldUseMultipart;
1047
+ private defaultChunkSize;
1048
+ private defaultConcurrency;
1049
+ private maybeCompress;
1050
+ private getOrCreateTelemetry;
1051
+ /** Build RequestOptions with X-Upload-Session-Id header for cross-boundary correlation */
1052
+ private withSessionHeader;
1053
+ /**
1054
+ * Use ServiceModule's list method but with a cleaner name internally
1055
+ * (can't call protected `list` from public method with same name).
1056
+ */
1057
+ private listMethod;
1058
+ }
1059
+
1060
+ /**
1061
+ * Upload Telemetry Module
1062
+ *
1063
+ * Best-effort upload lifecycle telemetry that never blocks upload success.
1064
+ * Events are buffered and flushed every 2s via analytics batch.
1065
+ * Error/warn/info events are also sent immediately via LoggerService.
1066
+ * Debug events are buffered and sent via logBatch on flush.
1067
+ *
1068
+ * Payload excludes filename/body/PII; only operational metadata is emitted.
1069
+ */
1070
+
1071
+ type UploadTelemetryEvent = 'upload.started' | 'upload.progress' | 'upload.completed' | 'upload.failed' | 'upload.aborted' | 'upload.retried' | 'upload.resumed' | 'upload.stalled' | 'upload.compression.started' | 'upload.compression.completed' | 'upload.compression.skipped' | 'upload.multipart.started' | 'upload.multipart.part_completed' | 'upload.multipart.part_failed' | 'upload.multipart.url_refreshed' | 'upload.multipart.completed' | 'upload.multipart.aborted';
1072
+ interface TelemetryPayload {
1073
+ /** Upload session correlation ID */
1074
+ upload_session_id: string;
1075
+ /** Event name */
1076
+ event: UploadTelemetryEvent;
1077
+ /** Timestamp in ISO 8601 */
1078
+ timestamp: string;
1079
+ /** Operational metadata (no PII) */
1080
+ metadata: Record<string, unknown>;
1081
+ }
1082
+ interface UploadTelemetryConfig {
1083
+ /** Enable/disable telemetry (default: true) */
1084
+ enabled: boolean;
1085
+ /** Flush interval in ms (default: 2000) */
1086
+ flushIntervalMs: number;
1087
+ /** Max buffer size before forced flush (default: 50) */
1088
+ maxBufferSize: number;
1089
+ }
1090
+ declare class UploadTelemetry {
1091
+ private buffer;
1092
+ private debugLogBuffer;
1093
+ private flushTimer;
1094
+ private client;
1095
+ private logger;
1096
+ private config;
1097
+ private flushing;
1098
+ constructor(client: ScaleMuleClient, config?: Partial<UploadTelemetryConfig>);
1099
+ /** Emit a telemetry event. Never throws. */
1100
+ emit(sessionId: string, event: UploadTelemetryEvent, metadata?: Record<string, unknown>): void;
1101
+ /** Flush buffered events immediately. Never throws. */
1102
+ flush(): Promise<void>;
1103
+ /** Stop the flush timer and drain remaining events. */
1104
+ destroy(): Promise<void>;
1105
+ private startFlushTimer;
1106
+ /** Send a log entry to the logger service (fire-and-forget) */
1107
+ private sendToLogger;
1108
+ }
1109
+ /** Generate a unique upload session ID */
1110
+ declare function generateUploadSessionId(): string;
1111
+
1112
+ /**
1113
+ * Upload Resume Module
1114
+ *
1115
+ * Provides cross-reload resume for multipart uploads using IndexedDB.
1116
+ * Browser-only; gracefully no-ops in non-browser runtimes.
1117
+ *
1118
+ * Store: sm_upload_sessions_v1 (IndexedDB)
1119
+ * Key: hash of app_id + user_id + filename + size + lastModified
1120
+ */
1121
+ interface CompletedPart {
1122
+ part_number: number;
1123
+ etag: string;
1124
+ }
1125
+ interface ResumeSession {
1126
+ upload_session_id: string;
1127
+ file_id: string;
1128
+ completion_token: string;
1129
+ total_parts: number;
1130
+ part_size_bytes: number;
1131
+ completed_parts: CompletedPart[];
1132
+ created_at: number;
1133
+ }
1134
+ declare class UploadResumeStore {
1135
+ private db;
1136
+ /** Generate a deterministic resume key from upload identity */
1137
+ static generateResumeKey(appId: string, userId: string, filename: string, size: number, lastModified?: number): Promise<string>;
1138
+ /** Open the IndexedDB store. No-ops if IndexedDB is unavailable. */
1139
+ open(): Promise<void>;
1140
+ /** Get a resume session by key. Returns null if not found or stale. */
1141
+ get(key: string): Promise<ResumeSession | null>;
1142
+ /** Save a new resume session. */
1143
+ save(key: string, session: ResumeSession): Promise<void>;
1144
+ /** Update a single completed part in an existing session. */
1145
+ updatePart(key: string, partNumber: number, etag: string): Promise<void>;
1146
+ /** Remove a resume session (e.g., after successful completion). */
1147
+ remove(key: string): Promise<void>;
1148
+ /** Purge all stale entries (older than MAX_AGE_MS). */
1149
+ purgeStale(): Promise<number>;
1150
+ /** Close the database connection. */
1151
+ close(): void;
1152
+ }
1153
+
1154
+ /**
1155
+ * Upload Strategy Module
1156
+ *
1157
+ * Determines the optimal upload strategy (direct PUT vs. multipart)
1158
+ * based on file size, network conditions, and user preferences.
1159
+ *
1160
+ * Also provides adaptive chunk size and concurrency defaults.
1161
+ */
1162
+ type UploadStrategy = 'direct' | 'multipart';
1163
+ type NetworkClass = 'slow-2g' | '2g' | '3g' | '4g' | 'unknown';
1164
+ interface StrategyResult {
1165
+ strategy: UploadStrategy;
1166
+ chunkSize: number;
1167
+ concurrency: number;
1168
+ stallTimeoutMs: number;
1169
+ }
1170
+ /**
1171
+ * Determine the optimal upload strategy for a file.
1172
+ */
1173
+ declare function resolveStrategy(fileSize: number, overrides?: {
1174
+ forceMultipart?: boolean;
1175
+ chunkSize?: number;
1176
+ concurrency?: number;
1177
+ }): StrategyResult;
1178
+ /** Detect the current network class from the Network Information API. */
1179
+ declare function detectNetworkClass(): NetworkClass;
1180
+ /** Estimate measured bandwidth (Mbps) from the Network Information API. */
1181
+ declare function getMeasuredBandwidthMbps(): number | null;
1182
+
1183
+ /**
1184
+ * Upload Engine Module
1185
+ *
1186
+ * Orchestrates the complete upload lifecycle:
1187
+ * - Strategy selection (direct vs multipart)
1188
+ * - Compression (browser images)
1189
+ * - Retry with backoff
1190
+ * - Stall detection
1191
+ * - Multipart with windowed presigns
1192
+ * - Cross-reload resume (IndexedDB)
1193
+ * - Telemetry (best-effort)
1194
+ * - Feature flag gating
1195
+ *
1196
+ * This module is the orchestrator consumed by StorageService.upload().
1197
+ * It delegates to upload-strategy, upload-compression, upload-resume,
1198
+ * and upload-telemetry for their respective concerns.
1199
+ */
1200
+
1201
+ interface UploadEngineConfig {
1202
+ /** Feature flag: enable multipart upload path (default: true) */
1203
+ multipartEnabled: boolean;
1204
+ /** Application allowlist for multipart (empty = all allowed) */
1205
+ multipartAllowlist: string[];
1206
+ /** Telemetry configuration */
1207
+ telemetry: Partial<UploadTelemetryConfig>;
1208
+ }
1209
+ interface UploadPlan {
1210
+ /** Selected strategy */
1211
+ strategy: UploadStrategy;
1212
+ /** Chunk size in bytes (for multipart) */
1213
+ chunkSize: number;
1214
+ /** Max concurrent part uploads */
1215
+ concurrency: number;
1216
+ /** Stall timeout in ms */
1217
+ stallTimeoutMs: number;
1218
+ /** Whether compression should be attempted */
1219
+ shouldCompress: boolean;
1220
+ /** Whether resume should be attempted */
1221
+ shouldResume: boolean;
1222
+ /** Total number of parts (multipart only) */
1223
+ totalParts: number;
1224
+ }
1225
+ /**
1226
+ * Create an upload plan based on file characteristics, user options, and runtime context.
1227
+ *
1228
+ * The plan determines strategy, chunk sizing, concurrency, compression,
1229
+ * and resume eligibility. The caller (StorageService) executes the plan.
1230
+ */
1231
+ declare function createUploadPlan(fileSize: number, contentType: string, options?: {
1232
+ forceMultipart?: boolean;
1233
+ skipCompression?: boolean;
1234
+ resume?: 'auto' | 'off';
1235
+ chunkSize?: number;
1236
+ maxConcurrency?: number;
1237
+ appId?: string;
1238
+ }, engineConfig?: Partial<UploadEngineConfig>): UploadPlan;
1239
+ /**
1240
+ * Calculate the total number of parts needed for a multipart upload.
1241
+ */
1242
+ declare function calculateTotalParts(fileSize: number, chunkSize: number): number;
1243
+ /**
1244
+ * Get the byte range for a specific part number (1-indexed).
1245
+ */
1246
+ declare function getPartRange(partNumber: number, chunkSize: number, totalSize: number): {
1247
+ start: number;
1248
+ end: number;
1249
+ size: number;
1250
+ };
1251
+
1252
+ /**
1253
+ * Realtime Service Module
1254
+ *
1255
+ * WebSocket client with:
1256
+ * - Lazy connection (connects on first subscribe)
1257
+ * - Auto-reconnect with exponential backoff + jitter
1258
+ * - Auto re-subscribe on reconnect
1259
+ * - Re-auth on reconnect (sends fresh session token)
1260
+ * - Heartbeat detection
1261
+ * - Presence support (join/leave/state)
1262
+ *
1263
+ * WebSocket protocol (JSON messages with `type` discriminator):
1264
+ * Client → Server: auth, subscribe, unsubscribe, publish, presence_join, presence_leave
1265
+ * Server → Client: auth_success, subscribed, message, error, presence_*
1266
+ *
1267
+ * HTTP endpoints for server-side broadcast:
1268
+ * POST /broadcast → all connections
1269
+ * POST /broadcast/channel/{c} → channel subscribers
1270
+ * POST /broadcast/user/{uid} → specific user
1271
+ */
1272
+
1273
+ type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
1274
+ type MessageCallback = (data: unknown, channel: string) => void;
1275
+ type StatusCallback = (status: ConnectionStatus) => void;
1276
+ type PresenceCallback = (event: PresenceEvent) => void;
1277
+ interface PresenceEvent {
1278
+ type: 'join' | 'leave' | 'state';
1279
+ channel: string;
1280
+ user_id?: string;
1281
+ user?: {
1282
+ user_id: string;
1283
+ user_data?: unknown;
1284
+ joined_at?: string;
1285
+ };
1286
+ members?: Array<{
1287
+ user_id: string;
1288
+ user_data?: unknown;
1289
+ joined_at?: string;
1290
+ }>;
1291
+ }
1292
+ declare class RealtimeService extends ServiceModule {
1293
+ protected basePath: string;
1294
+ private ws;
1295
+ private subscriptions;
1296
+ private presenceCallbacks;
1297
+ private statusCallbacks;
1298
+ private _status;
1299
+ private reconnectAttempt;
1300
+ private reconnectTimer;
1301
+ private heartbeatTimer;
1302
+ private authenticated;
1303
+ /** Current connection status */
1304
+ get status(): ConnectionStatus;
1305
+ /**
1306
+ * Subscribe to a channel. Connects WebSocket on first call.
1307
+ * Returns an unsubscribe function.
1308
+ */
1309
+ subscribe(channel: string, callback: MessageCallback): () => void;
1310
+ /** Publish data to a channel via WebSocket. */
1311
+ publish(channel: string, data: unknown): void;
1312
+ /** Join a presence channel with optional user data. */
1313
+ joinPresence(channel: string, userData?: unknown): void;
1314
+ /** Leave a presence channel. */
1315
+ leavePresence(channel: string): void;
1316
+ /** Listen for presence events on a channel. Returns unsubscribe function. */
1317
+ onPresence(channel: string, callback: PresenceCallback): () => void;
1318
+ /** Broadcast to all connections for this application. */
1319
+ broadcast(event: string, data: unknown, options?: RequestOptions): Promise<ApiResponse<{
1320
+ sent: boolean;
1321
+ }>>;
1322
+ /** Broadcast to a specific channel. */
1323
+ broadcastToChannel(channel: string, event: string, data: unknown, options?: RequestOptions): Promise<ApiResponse<{
1324
+ sent: boolean;
1325
+ }>>;
1326
+ /** Send to a specific user's connections. */
1327
+ sendToUser(userId: string, event: string, data: unknown, options?: RequestOptions): Promise<ApiResponse<{
1328
+ sent: boolean;
1329
+ }>>;
1330
+ /** Listen for connection status changes. */
1331
+ onStatusChange(callback: StatusCallback): () => void;
1332
+ /** Disconnect and clean up all subscriptions. */
1333
+ disconnect(): void;
1334
+ private connect;
1335
+ private authenticate;
1336
+ private handleMessage;
1337
+ private dispatchMessage;
1338
+ private dispatchPresence;
1339
+ private sendWs;
1340
+ private scheduleReconnect;
1341
+ private getReconnectDelay;
1342
+ private startHeartbeat;
1343
+ private clearHeartbeat;
1344
+ private clearTimers;
1345
+ private setStatus;
1346
+ }
1347
+
1348
+ /**
1349
+ * Video Service Module
1350
+ *
1351
+ * 3-step chunked upload flow (hidden from developer):
1352
+ * 1. POST /upload-start → get video_id, upload_id, s3_key
1353
+ * 2. POST /{id}/upload-part (×N) → upload chunks, get etags
1354
+ * 3. POST /{id}/upload-complete → finalize, trigger transcode
1355
+ *
1356
+ * Streaming:
1357
+ * GET /{id}/playlist.m3u8 → HLS master playlist
1358
+ * GET /{id}/stream/{q}/index.m3u8 → quality-specific playlist
1359
+ *
1360
+ * Analytics:
1361
+ * POST /{id}/track → playback events
1362
+ * GET /{id}/analytics → video metrics
1363
+ */
1364
+
1365
+ interface VideoUploadOptions {
1366
+ /** Custom filename */
1367
+ filename?: string;
1368
+ /** Video title */
1369
+ title?: string;
1370
+ /** Video description */
1371
+ description?: string;
1372
+ /** Custom metadata */
1373
+ metadata?: Record<string, unknown>;
1374
+ /** Upload progress callback (0-100) */
1375
+ onProgress?: (percent: number) => void;
1376
+ /** AbortSignal for cancellation */
1377
+ signal?: AbortSignal;
1378
+ /** Chunk size in bytes (default: 5MB) */
1379
+ chunkSize?: number;
1380
+ }
1381
+ interface VideoInfo {
1382
+ id: string;
1383
+ title?: string;
1384
+ description?: string;
1385
+ status: string;
1386
+ duration_seconds?: number;
1387
+ width?: number;
1388
+ height?: number;
1389
+ content_type: string;
1390
+ size_bytes: number;
1391
+ qualities?: string[];
1392
+ thumbnail_url?: string;
1393
+ created_at: string;
1394
+ updated_at: string;
1395
+ }
1396
+ declare class VideoService extends ServiceModule {
1397
+ protected basePath: string;
1398
+ /**
1399
+ * Upload a video file using chunked multipart upload.
1400
+ *
1401
+ * Internally:
1402
+ * 1. Starts a multipart upload session
1403
+ * 2. Uploads chunks sequentially with progress tracking
1404
+ * 3. Completes the upload, triggering transcoding
1405
+ *
1406
+ * @returns The video record with id, status, etc.
1407
+ */
1408
+ upload(file: File | Blob, options?: VideoUploadOptions, requestOptions?: RequestOptions): Promise<ApiResponse<VideoInfo>>;
1409
+ /** Get video metadata and status. */
1410
+ get(videoId: string, options?: RequestOptions): Promise<ApiResponse<VideoInfo>>;
1411
+ /**
1412
+ * Get the HLS master playlist URL for streaming.
1413
+ * Returns the playlist URL that can be passed to a video player.
1414
+ */
1415
+ getStreamUrl(videoId: string): Promise<ApiResponse<{
1416
+ url: string;
1417
+ }>>;
1418
+ /**
1419
+ * Track a playback event (view, play, pause, seek, complete, etc.).
1420
+ */
1421
+ trackPlayback(videoId: string, event: {
1422
+ event_type: string;
1423
+ position_seconds?: number;
1424
+ quality?: string;
1425
+ duration_seconds?: number;
1426
+ }, options?: RequestOptions): Promise<ApiResponse<{
1427
+ tracked: boolean;
1428
+ }>>;
1429
+ /** Get video analytics (views, watch time, etc.). */
1430
+ getAnalytics(videoId: string, options?: RequestOptions): Promise<ApiResponse<{
1431
+ views: number;
1432
+ watch_time_seconds: number;
1433
+ completions?: number;
1434
+ }>>;
1435
+ /**
1436
+ * Update a video's access mode (public/private).
1437
+ * Public videos get 7-day signed URLs; private get 1-hour signed URLs.
1438
+ */
1439
+ updateAccessMode(videoId: string, accessMode: 'public' | 'private', options?: RequestOptions): Promise<ApiResponse<{
1440
+ video_id: string;
1441
+ access_mode: string;
1442
+ }>>;
1443
+ /** @deprecated Use upload() instead */
1444
+ uploadVideo(file: File | Blob, options?: {
1445
+ metadata?: Record<string, unknown>;
1446
+ onProgress?: (progress: number) => void;
1447
+ signal?: AbortSignal;
1448
+ }): Promise<ApiResponse<VideoInfo>>;
1449
+ /** @deprecated Use get() instead */
1450
+ getVideo(id: string): Promise<ApiResponse<VideoInfo>>;
1451
+ private uploadPart;
1452
+ }
1453
+
1454
+ /**
1455
+ * Data Service Module
1456
+ *
1457
+ * Document-oriented data storage with collections, CRUD, query, and aggregation.
1458
+ *
1459
+ * Routes:
1460
+ * POST /collections → create collection
1461
+ * GET /collections → list collections
1462
+ * DELETE /collections/{name} → delete collection
1463
+ * POST /{collection}/documents → create document
1464
+ * GET /{collection}/documents/{id} → get document
1465
+ * PATCH /{collection}/documents/{id} → update document
1466
+ * DELETE /{collection}/documents/{id} → delete document
1467
+ * POST /{collection}/query → query documents
1468
+ * POST /{collection}/aggregate → aggregate
1469
+ * GET /{collection}/my-documents → user's documents
1470
+ */
1471
+
1472
+ interface Collection {
1473
+ id: string;
1474
+ collection_name: string;
1475
+ schema_definition?: unknown;
1476
+ indexes?: unknown;
1477
+ created_at: string;
1478
+ }
1479
+ interface Document {
1480
+ id: string;
1481
+ collection_id: string;
1482
+ sm_user_id?: string;
1483
+ data: Record<string, unknown>;
1484
+ created_at: string;
1485
+ updated_at: string;
1486
+ }
1487
+ interface QueryFilter {
1488
+ operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'contains';
1489
+ field: string;
1490
+ value: unknown;
1491
+ /** For 'in' operator */
1492
+ values?: unknown[];
1493
+ }
1494
+ interface QuerySort {
1495
+ field: string;
1496
+ direction?: 'asc' | 'desc';
1497
+ }
1498
+ interface QueryOptions extends PaginationParams {
1499
+ filters?: QueryFilter[];
1500
+ sort?: QuerySort[];
1501
+ }
1502
+ interface AggregateOptions {
1503
+ pipeline: Array<Record<string, unknown>>;
1504
+ }
1505
+ interface AggregateResult {
1506
+ results: Array<Record<string, unknown>>;
1507
+ }
1508
+ declare class DataService extends ServiceModule {
1509
+ protected basePath: string;
1510
+ createCollection(name: string, schema?: unknown, options?: RequestOptions): Promise<ApiResponse<Collection>>;
1511
+ listCollections(options?: RequestOptions): Promise<ApiResponse<Collection[]>>;
1512
+ deleteCollection(name: string, options?: RequestOptions): Promise<ApiResponse<{
1513
+ deleted: boolean;
1514
+ }>>;
1515
+ create(collection: string, data: unknown, options?: RequestOptions): Promise<ApiResponse<Document>>;
1516
+ get(collection: string, docId: string, options?: RequestOptions): Promise<ApiResponse<Document>>;
1517
+ update(collection: string, docId: string, data: unknown, options?: RequestOptions): Promise<ApiResponse<Document>>;
1518
+ delete(collection: string, docId: string, options?: RequestOptions): Promise<ApiResponse<{
1519
+ deleted: boolean;
1520
+ }>>;
1521
+ query(collection: string, options?: QueryOptions, requestOptions?: RequestOptions): Promise<PaginatedResponse<Document>>;
1522
+ aggregate(collection: string, options: AggregateOptions, requestOptions?: RequestOptions): Promise<ApiResponse<AggregateResult>>;
1523
+ myDocuments(collection: string, options?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Document>>;
1524
+ /** @deprecated Use create() instead */
1525
+ createDocument(collection: string, data: unknown): Promise<ApiResponse<Document>>;
1526
+ /** @deprecated Use get() instead */
1527
+ getDocument(collection: string, id: string): Promise<ApiResponse<Document>>;
1528
+ /** @deprecated Use update() instead */
1529
+ updateDocument(collection: string, id: string, data: unknown): Promise<ApiResponse<Document>>;
1530
+ /** @deprecated Use delete() instead */
1531
+ deleteDocument(collection: string, id: string): Promise<ApiResponse<{
1532
+ deleted: boolean;
1533
+ }>>;
1534
+ /** @deprecated Use query() instead */
1535
+ queryDocuments(collection: string, options?: QueryOptions): Promise<PaginatedResponse<Document>>;
1536
+ }
1537
+
1538
+ /**
1539
+ * Chat Service Module
1540
+ *
1541
+ * Conversations, messages, typing indicators, read receipts, reactions.
1542
+ *
1543
+ * Routes:
1544
+ * POST /conversations → create conversation
1545
+ * GET /conversations → list conversations
1546
+ * GET /conversations/{id} → get conversation
1547
+ * POST /conversations/{id}/participants → add participant
1548
+ * DELETE /conversations/{id}/participants/{userId} → remove participant
1549
+ * POST /conversations/{id}/messages → send message
1550
+ * GET /conversations/{id}/messages → get messages
1551
+ * PATCH /messages/{id} → edit message
1552
+ * DELETE /messages/{id} → delete message
1553
+ * POST /messages/{id}/reactions → add reaction
1554
+ * POST /conversations/{id}/typing → send typing indicator
1555
+ * POST /conversations/{id}/read → mark as read
1556
+ * GET /conversations/{id}/read-status → get read status
1557
+ */
1558
+
1559
+ interface Participant {
1560
+ user_id: string;
1561
+ role: string;
1562
+ joined_at: string;
1563
+ }
1564
+ interface Conversation {
1565
+ id: string;
1566
+ conversation_type: 'direct' | 'group';
1567
+ name?: string;
1568
+ created_by?: string;
1569
+ participant_count: number;
1570
+ last_message_at?: string;
1571
+ unread_count?: number;
1572
+ created_at: string;
1573
+ updated_at?: string;
1574
+ participants?: Participant[];
1575
+ }
1576
+ interface Attachment {
1577
+ file_id: string;
1578
+ file_name: string;
1579
+ file_size: number;
1580
+ mime_type: string;
1581
+ }
1582
+ interface ChatMessage {
1583
+ id: string;
1584
+ content: string;
1585
+ message_type: 'text' | 'image' | 'file' | 'system';
1586
+ sender_id: string;
1587
+ sender_type: string;
1588
+ sender_agent_model?: string;
1589
+ attachments?: Attachment[];
1590
+ is_edited: boolean;
1591
+ created_at: string;
1592
+ }
1593
+ interface ReadStatus {
1594
+ user_id: string;
1595
+ last_read_at?: string;
1596
+ }
1597
+ interface ChatReaction {
1598
+ emoji: string;
1599
+ user_id: string;
1600
+ message_id: string;
1601
+ created_at: string;
1602
+ }
1603
+ declare class ChatService extends ServiceModule {
1604
+ protected basePath: string;
1605
+ createConversation(data: {
1606
+ name?: string;
1607
+ participant_ids: string[];
1608
+ }, options?: RequestOptions): Promise<ApiResponse<Conversation>>;
1609
+ listConversations(params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Conversation>>;
1610
+ getConversation(id: string, options?: RequestOptions): Promise<ApiResponse<Conversation>>;
1611
+ addParticipant(conversationId: string, userId: string, options?: RequestOptions): Promise<ApiResponse<{
1612
+ added: boolean;
1613
+ }>>;
1614
+ removeParticipant(conversationId: string, userId: string, options?: RequestOptions): Promise<ApiResponse<{
1615
+ removed: boolean;
1616
+ }>>;
1617
+ sendMessage(conversationId: string, data: {
1618
+ content: string;
1619
+ type?: string;
1620
+ }, options?: RequestOptions): Promise<ApiResponse<ChatMessage>>;
1621
+ getMessages(conversationId: string, options?: {
1622
+ limit?: number;
1623
+ before?: string;
1624
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<ChatMessage[]>>;
1625
+ editMessage(messageId: string, data: {
1626
+ content: string;
1627
+ }, options?: RequestOptions): Promise<ApiResponse<ChatMessage>>;
1628
+ deleteMessage(messageId: string, options?: RequestOptions): Promise<ApiResponse<{
1629
+ deleted: boolean;
1630
+ }>>;
1631
+ addReaction(messageId: string, data: {
1632
+ emoji: string;
1633
+ }, options?: RequestOptions): Promise<ApiResponse<ChatReaction>>;
1634
+ sendTyping(conversationId: string, options?: RequestOptions): Promise<ApiResponse<{
1635
+ sent: boolean;
1636
+ }>>;
1637
+ markRead(conversationId: string, options?: RequestOptions): Promise<ApiResponse<{
1638
+ marked: boolean;
1639
+ }>>;
1640
+ getReadStatus(conversationId: string, options?: RequestOptions): Promise<ApiResponse<ReadStatus[]>>;
1641
+ /** @deprecated Use createConversation() instead */
1642
+ createChat(data: {
1643
+ participant_ids: string[];
1644
+ name?: string;
1645
+ }): Promise<ApiResponse<Conversation>>;
1646
+ }
1647
+
1648
+ /**
1649
+ * Social Service Module
1650
+ *
1651
+ * Follow/unfollow, posts, feed, likes, comments, activity feed.
1652
+ *
1653
+ * Routes:
1654
+ * POST /users/{id}/follow → follow user
1655
+ * DELETE /users/{id}/follow → unfollow user
1656
+ * GET /users/{id}/followers → get followers
1657
+ * GET /users/{id}/following → get following
1658
+ * GET /users/{id}/follow-status → check follow status
1659
+ * POST /posts → create post
1660
+ * GET /posts/{id} → get post
1661
+ * DELETE /posts/{id} → delete post
1662
+ * GET /users/{id}/posts → user's posts
1663
+ * GET /feed → user's feed
1664
+ * POST /{type}/{id}/like → like content
1665
+ * DELETE /{type}/{id}/like → unlike content
1666
+ * GET /{type}/{id}/likes → get likes
1667
+ * POST /posts/{id}/comments → comment on post
1668
+ * GET /posts/{id}/comments → get comments
1669
+ * GET /activity → activity feed
1670
+ * PATCH /activity/{id}/read → mark activity read
1671
+ * PATCH /activity/read-all → mark all read
1672
+ */
1673
+
1674
+ interface SocialPost {
1675
+ id: string;
1676
+ user_id: string;
1677
+ content: string;
1678
+ media_urls?: string[];
1679
+ visibility: 'public' | 'followers' | 'private';
1680
+ likes_count: number;
1681
+ comments_count: number;
1682
+ shares_count: number;
1683
+ created_at: string;
1684
+ }
1685
+ interface Comment {
1686
+ id: string;
1687
+ post_id: string;
1688
+ user_id: string;
1689
+ parent_comment_id?: string;
1690
+ content: string;
1691
+ likes_count: number;
1692
+ created_at: string;
1693
+ }
1694
+ interface FollowStatus {
1695
+ is_following: boolean;
1696
+ is_followed_by: boolean;
1697
+ }
1698
+ interface ActivityItem {
1699
+ id: string;
1700
+ activity_type: string;
1701
+ actor_user_id: string;
1702
+ target_type?: string;
1703
+ target_id?: string;
1704
+ metadata?: string;
1705
+ is_read: boolean;
1706
+ created_at: string;
1707
+ }
1708
+ /** Follower/following entry */
1709
+ interface SocialUser {
1710
+ user_id: string;
1711
+ followed_at: string;
1712
+ }
1713
+ interface Like {
1714
+ user_id: string;
1715
+ created_at: string;
1716
+ }
1717
+ declare class SocialService extends ServiceModule {
1718
+ protected basePath: string;
1719
+ follow(userId: string, options?: RequestOptions): Promise<ApiResponse<{
1720
+ followed: boolean;
1721
+ }>>;
1722
+ unfollow(userId: string, options?: RequestOptions): Promise<ApiResponse<{
1723
+ unfollowed: boolean;
1724
+ }>>;
1725
+ getFollowers(userId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<SocialUser>>;
1726
+ getFollowing(userId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<SocialUser>>;
1727
+ getFollowStatus(userId: string, options?: RequestOptions): Promise<ApiResponse<FollowStatus>>;
1728
+ createPost(data: {
1729
+ content: string;
1730
+ visibility?: string;
1731
+ }, options?: RequestOptions): Promise<ApiResponse<SocialPost>>;
1732
+ getPost(postId: string, options?: RequestOptions): Promise<ApiResponse<SocialPost>>;
1733
+ deletePost(postId: string, options?: RequestOptions): Promise<ApiResponse<{
1734
+ deleted: boolean;
1735
+ }>>;
1736
+ getUserPosts(userId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<SocialPost>>;
1737
+ getFeed(options?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<SocialPost>>;
1738
+ like(targetType: string, targetId: string, options?: RequestOptions): Promise<ApiResponse<{
1739
+ liked: boolean;
1740
+ }>>;
1741
+ unlike(targetType: string, targetId: string, options?: RequestOptions): Promise<ApiResponse<{
1742
+ unliked: boolean;
1743
+ }>>;
1744
+ getLikes(targetType: string, targetId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Like>>;
1745
+ comment(postId: string, data: {
1746
+ content: string;
1747
+ }, options?: RequestOptions): Promise<ApiResponse<Comment>>;
1748
+ getComments(postId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Comment>>;
1749
+ getActivity(params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<ActivityItem>>;
1750
+ markActivityRead(activityId: string, options?: RequestOptions): Promise<ApiResponse<ActivityItem>>;
1751
+ markAllRead(options?: RequestOptions): Promise<ApiResponse<{
1752
+ marked_count: number;
1753
+ }>>;
1754
+ /** @deprecated Use comment() instead */
1755
+ addComment(postId: string, data: {
1756
+ content: string;
1757
+ }): Promise<ApiResponse<Comment>>;
1758
+ }
1759
+
1760
+ /**
1761
+ * Billing Service Module
1762
+ *
1763
+ * Customers, subscriptions, usage, invoices, marketplace payments, payouts.
1764
+ *
1765
+ * Routes:
1766
+ * POST /customers → create customer
1767
+ * POST /payment-methods → add payment method
1768
+ * POST /subscriptions → create subscription
1769
+ * GET /subscriptions → list subscriptions
1770
+ * POST /subscriptions/{id}/cancel → cancel subscription
1771
+ * POST /subscriptions/{id}/resume → resume subscription
1772
+ * PATCH /subscriptions/{id}/upgrade → upgrade plan
1773
+ * POST /usage → report usage
1774
+ * GET /usage/summary → usage summary
1775
+ * GET /invoices → list invoices
1776
+ * GET /invoices/{id} → get invoice
1777
+ * POST /invoices/{id}/pay → pay invoice
1778
+ * GET /invoices/{id}/pdf → invoice PDF
1779
+ * POST /connected-accounts → create connected account
1780
+ * GET /connected-accounts/me → get own connected account
1781
+ * GET /connected-accounts/{id} → get connected account
1782
+ * POST /connected-accounts/{id}/onboarding-link → create onboarding link
1783
+ * GET /connected-accounts/{id}/balance → get account balance
1784
+ * POST /connected-accounts/{id}/account-session → create account session (embedded onboarding)
1785
+ * POST /payments → create payment
1786
+ * GET /payments → list payments
1787
+ * GET /payments/{id} → get payment
1788
+ * POST /payments/{id}/refund → refund payment
1789
+ * GET /connected-accounts/{id}/payouts → payout history
1790
+ * GET /connected-accounts/{id}/payout-schedule → get payout schedule
1791
+ * PUT /connected-accounts/{id}/payout-schedule → set payout schedule
1792
+ * GET /transactions → ledger transactions
1793
+ * GET /transactions/summary → transaction summary
1794
+ * POST /setup-sessions → create setup session
1795
+ */
1796
+
1797
+ interface Customer {
1798
+ id: string;
1799
+ stripe_customer_id?: string;
1800
+ email: string;
1801
+ metadata?: Record<string, unknown>;
1802
+ created_at: string;
1803
+ }
1804
+ interface Subscription {
1805
+ id: string;
1806
+ customer_id: string;
1807
+ stripe_subscription_id?: string;
1808
+ plan_id: string;
1809
+ status: string;
1810
+ current_period_start: string;
1811
+ current_period_end: string;
1812
+ cancel_at?: string;
1813
+ metadata?: Record<string, unknown>;
1814
+ created_at: string;
1815
+ }
1816
+ interface Invoice {
1817
+ id: string;
1818
+ customer_id: string;
1819
+ stripe_invoice_id?: string;
1820
+ amount_due: number;
1821
+ amount_paid: number;
1822
+ currency: string;
1823
+ status: string;
1824
+ due_date?: string;
1825
+ paid_at?: string;
1826
+ created_at: string;
1827
+ }
1828
+ interface UsageSummary {
1829
+ customer_id: string;
1830
+ event_type: string;
1831
+ total_quantity: number;
1832
+ total_cost: number;
1833
+ event_count: number;
1834
+ }
1835
+ interface PaymentMethod {
1836
+ id: string;
1837
+ customer_id: string;
1838
+ stripe_payment_method_id?: string;
1839
+ type: string;
1840
+ last4?: string;
1841
+ brand?: string;
1842
+ exp_month?: number;
1843
+ exp_year?: number;
1844
+ is_default: boolean;
1845
+ created_at: string;
1846
+ }
1847
+ interface ConnectedAccount {
1848
+ id: string;
1849
+ email: string;
1850
+ country: string;
1851
+ status: 'pending' | 'onboarding' | 'active' | 'restricted' | 'disabled';
1852
+ charges_enabled: boolean;
1853
+ payouts_enabled: boolean;
1854
+ onboarding_complete: boolean;
1855
+ details_submitted: boolean;
1856
+ metadata?: Record<string, unknown>;
1857
+ created_at: string;
1858
+ updated_at: string;
1859
+ }
1860
+ interface AccountBalance {
1861
+ currency: string;
1862
+ available_cents: number;
1863
+ pending_cents: number;
1864
+ reserved_cents: number;
1865
+ }
1866
+ interface Payment {
1867
+ id: string;
1868
+ customer_id: string;
1869
+ connected_account_id?: string;
1870
+ amount_cents: number;
1871
+ currency: string;
1872
+ platform_fee_cents: number;
1873
+ provider_fee_cents: number;
1874
+ creator_net_cents: number;
1875
+ status: string;
1876
+ payment_type?: string;
1877
+ client_secret?: string;
1878
+ metadata?: Record<string, unknown>;
1879
+ created_at: string;
1880
+ }
1881
+ interface Refund {
1882
+ id: string;
1883
+ payment_id: string;
1884
+ amount_cents: number;
1885
+ platform_fee_reversal_cents: number;
1886
+ reason?: string;
1887
+ status: string;
1888
+ created_at: string;
1889
+ }
1890
+ interface Payout {
1891
+ id: string;
1892
+ amount_cents: number;
1893
+ currency: string;
1894
+ status: string;
1895
+ arrival_date?: string;
1896
+ created_at: string;
1897
+ }
1898
+ interface PayoutSchedule {
1899
+ schedule_interval: string;
1900
+ minimum_amount_cents: number;
1901
+ day_of_week?: number;
1902
+ day_of_month?: number;
1903
+ }
1904
+ interface Transaction {
1905
+ id: string;
1906
+ entry_type: string;
1907
+ account_type: string;
1908
+ amount_cents: number;
1909
+ currency: string;
1910
+ category: string;
1911
+ reference_type: string;
1912
+ description?: string;
1913
+ created_at: string;
1914
+ }
1915
+ interface TransactionSummary {
1916
+ gross_cents: number;
1917
+ platform_fee_cents: number;
1918
+ net_cents: number;
1919
+ payout_cents: number;
1920
+ refund_cents: number;
1921
+ }
1922
+ interface PaymentListParams extends PaginationParams {
1923
+ status?: string;
1924
+ connected_account_id?: string;
1925
+ payment_type?: string;
1926
+ }
1927
+ interface TransactionListParams extends PaginationParams {
1928
+ account_id?: string;
1929
+ category?: string;
1930
+ date_from?: string;
1931
+ date_to?: string;
1932
+ }
1933
+ interface TransactionSummaryParams {
1934
+ account_id?: string;
1935
+ date_from?: string;
1936
+ date_to?: string;
1937
+ }
1938
+ interface Product {
1939
+ id: string;
1940
+ connected_account_id: string;
1941
+ external_product_id: string;
1942
+ name: string;
1943
+ description?: string;
1944
+ active: boolean;
1945
+ created_at: string;
1946
+ }
1947
+ interface Price {
1948
+ id: string;
1949
+ connected_account_id: string;
1950
+ product_id: string;
1951
+ external_price_id: string;
1952
+ unit_amount_cents: number;
1953
+ currency: string;
1954
+ recurring_interval?: string;
1955
+ active: boolean;
1956
+ created_at: string;
1957
+ }
1958
+ interface ConnectedAccountSubscription {
1959
+ id: string;
1960
+ connected_account_id: string;
1961
+ price_id: string;
1962
+ external_subscription_id: string;
1963
+ external_account_id: string;
1964
+ status: string;
1965
+ current_period_start?: string;
1966
+ current_period_end?: string;
1967
+ cancel_at_period_end: boolean;
1968
+ created_at: string;
1969
+ }
1970
+ interface Transfer {
1971
+ id: string;
1972
+ connected_account_id: string;
1973
+ payment_id?: string;
1974
+ amount_cents: number;
1975
+ currency: string;
1976
+ status: 'created' | 'processing' | 'succeeded' | 'failed' | 'needs_reconciliation';
1977
+ external_transfer_id?: string;
1978
+ idempotency_key: string;
1979
+ created_at: string;
1980
+ }
1981
+ interface ConnectedSetupIntentResponse {
1982
+ client_secret: string;
1983
+ external_account_id: string;
1984
+ }
1985
+ interface PaymentStatusResponse extends Payment {
1986
+ updated_at: string;
1987
+ }
1988
+ interface ConnectedSubscriptionListParams extends PaginationParams {
1989
+ connected_account_id?: string;
1990
+ }
1991
+ declare class BillingService extends ServiceModule {
1992
+ protected basePath: string;
1993
+ createCustomer(data: {
1994
+ email: string;
1995
+ name?: string;
1996
+ }, options?: RequestOptions): Promise<ApiResponse<Customer>>;
1997
+ addPaymentMethod(data: {
1998
+ type: string;
1999
+ token: string;
2000
+ }, options?: RequestOptions): Promise<ApiResponse<PaymentMethod>>;
2001
+ subscribe(data: {
2002
+ customer_id: string;
2003
+ plan_id: string;
2004
+ }, options?: RequestOptions): Promise<ApiResponse<Subscription>>;
2005
+ listSubscriptions(params?: PaginationParams, options?: RequestOptions): Promise<PaginatedResponse<Subscription>>;
2006
+ cancelSubscription(id: string, options?: RequestOptions): Promise<ApiResponse<Subscription>>;
2007
+ resumeSubscription(id: string, options?: RequestOptions): Promise<ApiResponse<Subscription>>;
2008
+ upgradeSubscription(id: string, data: {
2009
+ plan_id: string;
2010
+ }, options?: RequestOptions): Promise<ApiResponse<Subscription>>;
2011
+ reportUsage(data: {
2012
+ metric: string;
2013
+ quantity: number;
2014
+ }, options?: RequestOptions): Promise<ApiResponse<{
2015
+ recorded: boolean;
2016
+ }>>;
2017
+ getUsageSummary(options?: RequestOptions): Promise<ApiResponse<UsageSummary[]>>;
2018
+ listInvoices(params?: PaginationParams, options?: RequestOptions): Promise<PaginatedResponse<Invoice>>;
2019
+ getInvoice(id: string, options?: RequestOptions): Promise<ApiResponse<Invoice>>;
2020
+ payInvoice(id: string, options?: RequestOptions): Promise<ApiResponse<Invoice>>;
2021
+ getInvoicePdf(id: string, options?: RequestOptions): Promise<ApiResponse<{
2022
+ url: string;
2023
+ }>>;
2024
+ createConnectedAccount(data: {
2025
+ email: string;
2026
+ country?: string;
2027
+ }, options?: RequestOptions): Promise<ApiResponse<ConnectedAccount>>;
2028
+ getConnectedAccount(id: string, options?: RequestOptions): Promise<ApiResponse<ConnectedAccount>>;
2029
+ getMyConnectedAccount(options?: RequestOptions): Promise<ApiResponse<ConnectedAccount>>;
2030
+ createOnboardingLink(id: string, data: {
2031
+ return_url: string;
2032
+ refresh_url: string;
2033
+ }, options?: RequestOptions): Promise<ApiResponse<{
2034
+ url: string;
2035
+ }>>;
2036
+ getAccountBalance(id: string, options?: RequestOptions): Promise<ApiResponse<AccountBalance>>;
2037
+ createAccountSession(id: string, options?: RequestOptions): Promise<ApiResponse<{
2038
+ client_secret: string;
2039
+ }>>;
2040
+ getPublishableKey(options?: RequestOptions): Promise<ApiResponse<{
2041
+ publishable_key: string;
2042
+ }>>;
2043
+ createPayment(data: {
2044
+ amount_cents: number;
2045
+ currency?: string;
2046
+ connected_account_id?: string;
2047
+ platform_fee_percent?: number;
2048
+ platform_fee_cents?: number;
2049
+ payment_type?: string;
2050
+ metadata?: Record<string, unknown>;
2051
+ }, options?: RequestOptions): Promise<ApiResponse<Payment>>;
2052
+ getPayment(id: string, options?: RequestOptions): Promise<ApiResponse<Payment>>;
2053
+ listPayments(params?: PaymentListParams, options?: RequestOptions): Promise<PaginatedResponse<Payment>>;
2054
+ refundPayment(id: string, data?: {
2055
+ amount_cents?: number;
2056
+ reason?: string;
2057
+ }, options?: RequestOptions): Promise<ApiResponse<Refund>>;
2058
+ getPayoutHistory(accountId: string, params?: PaginationParams, options?: RequestOptions): Promise<PaginatedResponse<Payout>>;
2059
+ getPayoutSchedule(accountId: string, options?: RequestOptions): Promise<ApiResponse<PayoutSchedule>>;
2060
+ setPayoutSchedule(accountId: string, data: {
2061
+ schedule_interval: string;
2062
+ minimum_amount_cents?: number;
2063
+ day_of_week?: number;
2064
+ day_of_month?: number;
2065
+ }, options?: RequestOptions): Promise<ApiResponse<PayoutSchedule>>;
2066
+ getTransactions(params?: TransactionListParams, options?: RequestOptions): Promise<PaginatedResponse<Transaction>>;
2067
+ getTransactionSummary(params?: TransactionSummaryParams, options?: RequestOptions): Promise<ApiResponse<TransactionSummary>>;
2068
+ createSetupSession(data: {
2069
+ return_url: string;
2070
+ cancel_url: string;
2071
+ }, options?: RequestOptions): Promise<ApiResponse<{
2072
+ client_secret: string;
2073
+ }>>;
2074
+ createProduct(data: {
2075
+ connected_account_id: string;
2076
+ name: string;
2077
+ description?: string;
2078
+ metadata?: Record<string, unknown>;
2079
+ }, options?: RequestOptions): Promise<ApiResponse<Product>>;
2080
+ createPrice(data: {
2081
+ connected_account_id: string;
2082
+ product_id: string;
2083
+ unit_amount_cents: number;
2084
+ currency?: string;
2085
+ recurring_interval?: string;
2086
+ }, options?: RequestOptions): Promise<ApiResponse<Price>>;
2087
+ deactivatePrice(id: string, options?: RequestOptions): Promise<ApiResponse<Price>>;
2088
+ createConnectedSubscription(data: {
2089
+ connected_account_id: string;
2090
+ price_id: string;
2091
+ email: string;
2092
+ payment_method_id?: string;
2093
+ setup_intent_id?: string;
2094
+ }, options?: RequestOptions): Promise<ApiResponse<ConnectedAccountSubscription>>;
2095
+ cancelConnectedSubscription(id: string, data?: {
2096
+ at_period_end?: boolean;
2097
+ }, options?: RequestOptions): Promise<ApiResponse<ConnectedAccountSubscription>>;
2098
+ listConnectedSubscriptions(params?: ConnectedSubscriptionListParams, options?: RequestOptions): Promise<PaginatedResponse<ConnectedAccountSubscription>>;
2099
+ createConnectedSetupIntent(data: {
2100
+ connected_account_id: string;
2101
+ return_url: string;
2102
+ }, options?: RequestOptions): Promise<ApiResponse<ConnectedSetupIntentResponse>>;
2103
+ createTransfer(data: {
2104
+ connected_account_id: string;
2105
+ amount_cents: number;
2106
+ currency?: string;
2107
+ payment_id?: string;
2108
+ idempotency_key: string;
2109
+ metadata?: Record<string, unknown>;
2110
+ }, options?: RequestOptions): Promise<ApiResponse<Transfer>>;
2111
+ syncPaymentStatus(id: string, options?: RequestOptions): Promise<ApiResponse<PaymentStatusResponse>>;
2112
+ /** @deprecated Use subscribe() instead */
2113
+ createSubscription(data: {
2114
+ customer_id: string;
2115
+ plan_id: string;
2116
+ }): Promise<ApiResponse<Subscription>>;
2117
+ /** @deprecated Use listInvoices() instead */
2118
+ getInvoices(params?: PaginationParams): Promise<PaginatedResponse<Invoice>>;
2119
+ }
2120
+
2121
+ /**
2122
+ * Analytics Service Module
2123
+ *
2124
+ * Event tracking (v2 JetStream-buffered), page views, funnels, metrics.
2125
+ *
2126
+ * Routes:
2127
+ * POST /v2/events → track event (JetStream buffered)
2128
+ * POST /v2/events/batch → batch track events
2129
+ * POST /page-view → track page view
2130
+ * POST /identify → identify user
2131
+ * POST /alias → alias anonymous to user
2132
+ * GET /events → query events
2133
+ * GET /aggregations → get aggregations
2134
+ * GET /top-events → top events
2135
+ * GET /users/active → active users
2136
+ * POST /funnels → create funnel
2137
+ * GET /funnels → list funnels
2138
+ * GET /funnels/{id}/conversions → funnel conversions
2139
+ * POST /metrics → track metric
2140
+ * GET /metrics/query → query metrics
2141
+ */
2142
+
2143
+ interface AnalyticsEvent {
2144
+ id: string;
2145
+ event_name: string;
2146
+ user_id?: string;
2147
+ anonymous_id?: string;
2148
+ properties?: Record<string, unknown>;
2149
+ created_at: string;
2150
+ }
2151
+ interface Funnel {
2152
+ id: string;
2153
+ funnel_name: string;
2154
+ steps: string;
2155
+ created_at: string;
2156
+ }
2157
+ interface FunnelConversion {
2158
+ date_bucket: string;
2159
+ step_index: number;
2160
+ step_name: string;
2161
+ users_entered: number;
2162
+ users_completed: number;
2163
+ conversion_rate?: number;
2164
+ }
2165
+ interface ActiveUsers {
2166
+ active_users: number;
2167
+ period: string;
2168
+ }
2169
+ interface EventAggregation {
2170
+ time_bucket: string;
2171
+ event_name: string;
2172
+ count: number;
2173
+ }
2174
+ interface TopEvent {
2175
+ event_name: string;
2176
+ count: number;
2177
+ }
2178
+ interface MetricDataPoint {
2179
+ timestamp: string;
2180
+ value: number;
2181
+ dimensions?: Record<string, unknown>;
2182
+ }
2183
+ declare class AnalyticsService extends ServiceModule {
2184
+ protected basePath: string;
2185
+ track(event: string, properties?: Record<string, unknown>, userId?: string, options?: RequestOptions): Promise<ApiResponse<{
2186
+ tracked: boolean;
2187
+ }>>;
2188
+ trackBatch(events: Array<{
2189
+ event: string;
2190
+ properties?: Record<string, unknown>;
2191
+ user_id?: string;
2192
+ timestamp?: string;
2193
+ }>, options?: RequestOptions): Promise<ApiResponse<{
2194
+ count: number;
2195
+ }>>;
2196
+ trackPageView(data?: {
2197
+ path?: string;
2198
+ title?: string;
2199
+ referrer?: string;
2200
+ }, options?: RequestOptions): Promise<ApiResponse<{
2201
+ tracked: boolean;
2202
+ }>>;
2203
+ identify(userId: string, traits?: Record<string, unknown>, anonymousId?: string, options?: RequestOptions): Promise<ApiResponse<{
2204
+ identified: boolean;
2205
+ }>>;
2206
+ alias(userId: string, anonymousId: string, options?: RequestOptions): Promise<ApiResponse<{
2207
+ aliased: boolean;
2208
+ }>>;
2209
+ queryEvents(filters?: PaginationParams & Record<string, unknown>): Promise<PaginatedResponse<AnalyticsEvent>>;
2210
+ getAggregations(filters?: Record<string, unknown>): Promise<ApiResponse<EventAggregation[]>>;
2211
+ getTopEvents(filters?: Record<string, unknown>): Promise<ApiResponse<TopEvent[]>>;
2212
+ getActiveUsers(): Promise<ApiResponse<ActiveUsers>>;
2213
+ createFunnel(data: {
2214
+ name: string;
2215
+ steps: string[];
2216
+ }): Promise<ApiResponse<Funnel>>;
2217
+ listFunnels(): Promise<ApiResponse<Funnel[]>>;
2218
+ getFunnelConversions(id: string): Promise<ApiResponse<FunnelConversion[]>>;
2219
+ trackMetric(data: {
2220
+ name: string;
2221
+ value: number;
2222
+ tags?: Record<string, string>;
2223
+ }, options?: RequestOptions): Promise<ApiResponse<{
2224
+ tracked: boolean;
2225
+ }>>;
2226
+ queryMetrics(filters?: Record<string, unknown>): Promise<ApiResponse<MetricDataPoint[]>>;
2227
+ /** @deprecated Use queryEvents() instead */
2228
+ query(filters?: Record<string, unknown>): Promise<ApiResponse<AnalyticsEvent[]>>;
2229
+ }
2230
+
2231
+ /**
2232
+ * Communication Service Module
2233
+ *
2234
+ * Email, SMS, push notifications with template support.
2235
+ *
2236
+ * Routes:
2237
+ * POST /email/send → send email
2238
+ * POST /email/templates/{name}/send → send templated email
2239
+ * POST /sms/send → send SMS
2240
+ * POST /sms/templates/{name}/send → send templated SMS
2241
+ * POST /push/send → send push notification
2242
+ * POST /push/register → register push token
2243
+ * DELETE /push/tokens/{token} → unregister push token
2244
+ * GET /messages/{id} → get message status
2245
+ */
2246
+
2247
+ interface MessageStatus {
2248
+ id: string;
2249
+ channel: string;
2250
+ recipient: string;
2251
+ status: string;
2252
+ provider: string;
2253
+ provider_message_id?: string;
2254
+ sent_at?: string;
2255
+ delivered_at?: string;
2256
+ opened_at?: string;
2257
+ clicked_at?: string;
2258
+ failed_at?: string;
2259
+ error_message?: string;
2260
+ }
2261
+ interface PushToken {
2262
+ token: string;
2263
+ platform: string;
2264
+ created_at: string;
2265
+ }
2266
+ declare class CommunicationService extends ServiceModule {
2267
+ protected basePath: string;
2268
+ sendEmail(data: {
2269
+ to: string;
2270
+ subject: string;
2271
+ body: string;
2272
+ template_id?: string;
2273
+ }, options?: RequestOptions): Promise<ApiResponse<MessageStatus>>;
2274
+ sendEmailTemplate(template: string, data: {
2275
+ to: string;
2276
+ variables?: Record<string, unknown>;
2277
+ }, options?: RequestOptions): Promise<ApiResponse<MessageStatus>>;
2278
+ sendSms(data: {
2279
+ to: string;
2280
+ message: string;
2281
+ }, options?: RequestOptions): Promise<ApiResponse<MessageStatus>>;
2282
+ sendSmsTemplate(template: string, data: {
2283
+ to: string;
2284
+ variables?: Record<string, unknown>;
2285
+ }, options?: RequestOptions): Promise<ApiResponse<MessageStatus>>;
2286
+ sendPush(data: {
2287
+ user_id: string;
2288
+ title: string;
2289
+ body: string;
2290
+ data?: Record<string, unknown>;
2291
+ }, options?: RequestOptions): Promise<ApiResponse<MessageStatus>>;
2292
+ registerPushToken(data: {
2293
+ token: string;
2294
+ platform: string;
2295
+ }, options?: RequestOptions): Promise<ApiResponse<PushToken>>;
2296
+ unregisterPushToken(token: string, options?: RequestOptions): Promise<ApiResponse<{
2297
+ unregistered: boolean;
2298
+ }>>;
2299
+ getMessageStatus(id: string, options?: RequestOptions): Promise<ApiResponse<MessageStatus>>;
2300
+ /** @deprecated Use sendSms() instead */
2301
+ sendSMS(data: {
2302
+ to: string;
2303
+ message: string;
2304
+ }): Promise<ApiResponse<MessageStatus>>;
2305
+ /** @deprecated Use sendPush() instead */
2306
+ sendPushNotification(data: {
2307
+ user_id: string;
2308
+ title: string;
2309
+ body: string;
2310
+ data?: Record<string, unknown>;
2311
+ }): Promise<ApiResponse<MessageStatus>>;
2312
+ }
2313
+
2314
+ /**
2315
+ * Scheduler Service Module
2316
+ *
2317
+ * Cron jobs with pause/resume, execution history, and on-demand runs.
2318
+ *
2319
+ * Routes:
2320
+ * POST /jobs → create job
2321
+ * GET /jobs → list jobs
2322
+ * GET /jobs/{id} → get job
2323
+ * PATCH /jobs/{id} → update job
2324
+ * DELETE /jobs/{id} → delete job
2325
+ * POST /jobs/{id}/pause → pause job
2326
+ * POST /jobs/{id}/resume → resume job
2327
+ * POST /jobs/{id}/run-now → trigger immediate run
2328
+ * GET /jobs/{id}/executions → execution history
2329
+ * GET /jobs/{id}/stats → job statistics
2330
+ */
2331
+
2332
+ interface SchedulerJob {
2333
+ id: string;
2334
+ name: string;
2335
+ job_name?: string;
2336
+ schedule_type: string;
2337
+ cron_expression?: string;
2338
+ interval_seconds?: number;
2339
+ scheduled_at?: string;
2340
+ timezone: string;
2341
+ target_type: string;
2342
+ target_config: unknown;
2343
+ is_enabled: boolean;
2344
+ status: string;
2345
+ next_run_at?: string;
2346
+ last_run_at?: string;
2347
+ run_count: number;
2348
+ created_at: string;
2349
+ updated_at: string;
2350
+ }
2351
+ interface JobExecution {
2352
+ id: string;
2353
+ scheduled_job_id: string;
2354
+ started_at: string;
2355
+ completed_at?: string;
2356
+ status: string;
2357
+ result?: string;
2358
+ error?: string;
2359
+ execution_time_ms?: number;
2360
+ }
2361
+ interface JobStats {
2362
+ id: string;
2363
+ scheduled_job_id: string;
2364
+ total_executions: number;
2365
+ successful_executions: number;
2366
+ failed_executions: number;
2367
+ avg_execution_time_ms?: number;
2368
+ last_success_at?: string;
2369
+ last_failure_at?: string;
2370
+ updated_at: string;
2371
+ }
2372
+ declare class SchedulerService extends ServiceModule {
2373
+ protected basePath: string;
2374
+ createJob(data: {
2375
+ name: string;
2376
+ cron: string;
2377
+ type: string;
2378
+ config: unknown;
2379
+ }, options?: RequestOptions): Promise<ApiResponse<SchedulerJob>>;
2380
+ listJobs(params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<SchedulerJob>>;
2381
+ getJob(id: string, options?: RequestOptions): Promise<ApiResponse<SchedulerJob>>;
2382
+ updateJob(id: string, data: Partial<{
2383
+ name: string;
2384
+ cron: string;
2385
+ config: unknown;
2386
+ }>, options?: RequestOptions): Promise<ApiResponse<SchedulerJob>>;
2387
+ deleteJob(id: string, options?: RequestOptions): Promise<ApiResponse<{
2388
+ deleted: boolean;
2389
+ }>>;
2390
+ pauseJob(id: string, options?: RequestOptions): Promise<ApiResponse<SchedulerJob>>;
2391
+ resumeJob(id: string, options?: RequestOptions): Promise<ApiResponse<SchedulerJob>>;
2392
+ runNow(id: string, options?: RequestOptions): Promise<ApiResponse<JobExecution>>;
2393
+ getExecutions(jobId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<JobExecution>>;
2394
+ getStats(jobId: string, options?: RequestOptions): Promise<ApiResponse<JobStats>>;
2395
+ }
2396
+
2397
+ /**
2398
+ * Permissions Service Module
2399
+ *
2400
+ * RBAC: roles, permissions, policies, checks.
2401
+ *
2402
+ * Routes:
2403
+ * POST /roles → create role
2404
+ * GET /roles → list roles
2405
+ * POST /roles/{id}/permissions → assign permissions to role
2406
+ * POST /users/{id}/roles → assign role to user
2407
+ * POST /check → check single permission
2408
+ * POST /batch-check → check multiple permissions
2409
+ * GET /users/{id}/permissions → get user's permissions
2410
+ * POST /policies → create policy
2411
+ * GET /policies → list policies
2412
+ * POST /evaluate → evaluate policy
2413
+ */
2414
+
2415
+ type IdentityType = 'member' | 'user';
2416
+ interface Role {
2417
+ id: string;
2418
+ role_name: string;
2419
+ description?: string;
2420
+ role_level?: number;
2421
+ created_at: string;
2422
+ }
2423
+ interface PermissionCheck {
2424
+ granted: boolean;
2425
+ permission: string;
2426
+ resource_type?: string;
2427
+ resource_id?: string;
2428
+ reason: string;
2429
+ }
2430
+ interface Policy {
2431
+ id: string;
2432
+ policy_name: string;
2433
+ description?: string;
2434
+ effect: string;
2435
+ resource_pattern: string;
2436
+ action_pattern: string;
2437
+ conditions?: Record<string, unknown>;
2438
+ priority: number;
2439
+ is_active: boolean;
2440
+ principals: Array<{
2441
+ principal_type: string;
2442
+ principal_id: string;
2443
+ }>;
2444
+ created_at: string;
2445
+ }
2446
+ /** Full permission matrix for an identity — single request, no N+1 */
2447
+ interface PermissionMatrix {
2448
+ identityId: string;
2449
+ identityType: IdentityType;
2450
+ role?: string;
2451
+ roleLevel?: number;
2452
+ policyVersion: number;
2453
+ permissions: Record<string, Record<string, 'allow' | 'deny'>>;
2454
+ }
2455
+ /** Check if a specific resource:action is allowed in the matrix */
2456
+ declare function canPerform(matrix: PermissionMatrix | null, resource: string, action: string): boolean;
2457
+ /** Check if the matrix identity has at least the given role level */
2458
+ declare function hasMinRoleLevel(matrix: PermissionMatrix | null, minLevel: number): boolean;
2459
+ declare class PermissionsService extends ServiceModule {
2460
+ protected basePath: string;
2461
+ createRole(data: {
2462
+ name: string;
2463
+ description?: string;
2464
+ }, options?: RequestOptions): Promise<ApiResponse<Role>>;
2465
+ listRoles(options?: RequestOptions): Promise<ApiResponse<Role[]>>;
2466
+ assignPermissions(roleId: string, permissions: string[], options?: RequestOptions): Promise<ApiResponse<Role>>;
2467
+ assignRole(userId: string, roleId: string, options?: RequestOptions): Promise<ApiResponse<{
2468
+ assigned: boolean;
2469
+ }>>;
2470
+ /** Check a single permission. Supports identity_type for unified model. */
2471
+ check(identityId: string, permission: string, options?: RequestOptions & {
2472
+ identityType?: IdentityType;
2473
+ resourceType?: string;
2474
+ resourceId?: string;
2475
+ }): Promise<ApiResponse<PermissionCheck>>;
2476
+ /** Batch check multiple permissions for an identity. */
2477
+ batchCheck(identityId: string, permissions: string[], options?: RequestOptions & {
2478
+ identityType?: IdentityType;
2479
+ }): Promise<ApiResponse<PermissionCheck[]>>;
2480
+ /** Fetch the full permission matrix for an identity (single request, no N+1). */
2481
+ getMatrix(identityId: string, identityType?: IdentityType, options?: RequestOptions): Promise<ApiResponse<PermissionMatrix>>;
2482
+ getUserPermissions(userId: string, options?: RequestOptions): Promise<ApiResponse<string[]>>;
2483
+ createPolicy(data: {
2484
+ name: string;
2485
+ effect: 'allow' | 'deny';
2486
+ actions: string[];
2487
+ resources: string[];
2488
+ conditions?: Record<string, unknown>;
2489
+ }, options?: RequestOptions): Promise<ApiResponse<Policy>>;
2490
+ listPolicies(options?: RequestOptions): Promise<ApiResponse<Policy[]>>;
2491
+ evaluate(data: {
2492
+ user_id: string;
2493
+ action: string;
2494
+ resource: string;
2495
+ context?: Record<string, unknown>;
2496
+ }, options?: RequestOptions): Promise<ApiResponse<{
2497
+ allowed: boolean;
2498
+ reason?: string;
2499
+ }>>;
2500
+ /** @deprecated Use assignPermissions() instead */
2501
+ assignPermission(roleId: string, permission: string): Promise<ApiResponse<Role>>;
2502
+ /** @deprecated Use check() instead */
2503
+ checkPermission(userId: string, permission: string): Promise<ApiResponse<PermissionCheck>>;
2504
+ }
2505
+
2506
+ /**
2507
+ * Teams Service Module
2508
+ *
2509
+ * Team CRUD, members, invitations, SSO.
2510
+ *
2511
+ * Routes:
2512
+ * POST / → create team
2513
+ * GET / → list teams
2514
+ * GET /{id} → get team
2515
+ * PATCH /{id} → update team
2516
+ * DELETE /{id} → delete team
2517
+ * GET /{id}/members → list members
2518
+ * POST /{id}/members → add member
2519
+ * PATCH /{id}/members/{userId} → update member role
2520
+ * DELETE /{id}/members/{userId} → remove member
2521
+ * POST /{id}/invitations → invite
2522
+ * GET /{id}/invitations → list invitations
2523
+ * POST /invitations/{token}/accept → accept invitation
2524
+ * DELETE /invitations/{id} → cancel invitation
2525
+ * POST /{id}/sso/configure → configure SSO
2526
+ * GET /{id}/sso → get SSO config
2527
+ */
2528
+
2529
+ interface Team {
2530
+ id: string;
2531
+ team_name: string;
2532
+ description?: string;
2533
+ owner_user_id: string;
2534
+ plan_type?: string;
2535
+ member_limit?: number;
2536
+ created_at: string;
2537
+ }
2538
+ interface TeamMember {
2539
+ id: string;
2540
+ team_id: string;
2541
+ sm_user_id: string;
2542
+ role: string;
2543
+ joined_at: string;
2544
+ }
2545
+ interface TeamInvitation {
2546
+ id: string;
2547
+ team_id: string;
2548
+ email: string;
2549
+ invited_by: string;
2550
+ role: string;
2551
+ token: string;
2552
+ status: string;
2553
+ expires_at: string;
2554
+ created_at: string;
2555
+ }
2556
+ interface SsoConfig {
2557
+ id: string;
2558
+ team_id: string;
2559
+ provider_type: string;
2560
+ provider_name?: string;
2561
+ saml_idp_entity_id?: string;
2562
+ saml_idp_sso_url?: string;
2563
+ oauth_client_id?: string;
2564
+ oauth_authorize_url?: string;
2565
+ oauth_token_url?: string;
2566
+ oauth_userinfo_url?: string;
2567
+ allowed_domains?: string[];
2568
+ attribute_mapping?: Record<string, unknown>;
2569
+ is_enabled: boolean;
2570
+ is_enforced: boolean;
2571
+ jit_provisioning_enabled: boolean;
2572
+ default_role: string;
2573
+ metadata?: Record<string, unknown>;
2574
+ created_at: string;
2575
+ updated_at: string;
2576
+ }
2577
+ declare class TeamsService extends ServiceModule {
2578
+ protected basePath: string;
2579
+ create(data: {
2580
+ name: string;
2581
+ description?: string;
2582
+ }, options?: RequestOptions): Promise<ApiResponse<Team>>;
2583
+ list(params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Team>>;
2584
+ get(id: string, options?: RequestOptions): Promise<ApiResponse<Team>>;
2585
+ update(id: string, data: Partial<{
2586
+ name: string;
2587
+ description: string;
2588
+ }>, options?: RequestOptions): Promise<ApiResponse<Team>>;
2589
+ delete(id: string, options?: RequestOptions): Promise<ApiResponse<{
2590
+ deleted: boolean;
2591
+ }>>;
2592
+ listMembers(teamId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<TeamMember>>;
2593
+ addMember(teamId: string, data: {
2594
+ user_id: string;
2595
+ role: string;
2596
+ }, options?: RequestOptions): Promise<ApiResponse<TeamMember>>;
2597
+ updateMember(teamId: string, userId: string, data: {
2598
+ role: string;
2599
+ }, options?: RequestOptions): Promise<ApiResponse<TeamMember>>;
2600
+ removeMember(teamId: string, userId: string, options?: RequestOptions): Promise<ApiResponse<{
2601
+ removed: boolean;
2602
+ }>>;
2603
+ invite(teamId: string, data: {
2604
+ email: string;
2605
+ role: string;
2606
+ }, options?: RequestOptions): Promise<ApiResponse<TeamInvitation>>;
2607
+ listInvitations(teamId: string, options?: RequestOptions): Promise<ApiResponse<TeamInvitation[]>>;
2608
+ acceptInvitation(token: string, options?: RequestOptions): Promise<ApiResponse<TeamMember>>;
2609
+ cancelInvitation(id: string, options?: RequestOptions): Promise<ApiResponse<{
2610
+ cancelled: boolean;
2611
+ }>>;
2612
+ configureSso(teamId: string, data: {
2613
+ provider: string;
2614
+ domain: string;
2615
+ metadata_url?: string;
2616
+ }, options?: RequestOptions): Promise<ApiResponse<SsoConfig>>;
2617
+ getSso(teamId: string, options?: RequestOptions): Promise<ApiResponse<SsoConfig>>;
2618
+ /** @deprecated Use create() instead */
2619
+ createTeam(data: {
2620
+ name: string;
2621
+ description?: string;
2622
+ }): Promise<ApiResponse<Team>>;
2623
+ /** @deprecated Use invite() instead */
2624
+ inviteMember(teamId: string, email: string, role: string): Promise<ApiResponse<TeamInvitation>>;
2625
+ }
2626
+
2627
+ /**
2628
+ * Graph Service Module
2629
+ *
2630
+ * Graph database: nodes, edges, traversal, algorithms.
2631
+ *
2632
+ * Routes:
2633
+ * POST /nodes → create node
2634
+ * PATCH /nodes/{id} → update node
2635
+ * POST /edges → create edge
2636
+ * GET /nodes/{id}/edges → get edges for node
2637
+ * GET /nodes/{id}/traverse → traverse graph
2638
+ * POST /shortest-path → shortest path
2639
+ * GET /nodes/{id}/neighbors → neighbors
2640
+ * POST /algorithms/pagerank → PageRank
2641
+ * POST /algorithms/centrality → centrality
2642
+ * POST /algorithms/connected-components → connected components
2643
+ */
2644
+
2645
+ interface GraphNode {
2646
+ node_id: string;
2647
+ node_type: string;
2648
+ properties: Record<string, unknown>;
2649
+ created_at: string;
2650
+ }
2651
+ interface GraphEdge {
2652
+ edge_id: string;
2653
+ from_node_id: string;
2654
+ to_node_id: string;
2655
+ edge_type: string;
2656
+ properties?: Record<string, unknown>;
2657
+ weight: number;
2658
+ created_at: string;
2659
+ }
2660
+ interface TraversalResult {
2661
+ nodes: GraphNode[];
2662
+ edges: GraphEdge[];
2663
+ depth: number;
2664
+ }
2665
+ interface ShortestPathResult {
2666
+ path: string[];
2667
+ distance: number;
2668
+ edges: GraphEdge[];
2669
+ }
2670
+ declare class GraphService extends ServiceModule {
2671
+ protected basePath: string;
2672
+ createNode(data: {
2673
+ label: string;
2674
+ properties?: Record<string, unknown>;
2675
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<GraphNode>>;
2676
+ updateNode(nodeId: string, data: {
2677
+ properties: Record<string, unknown>;
2678
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<GraphNode>>;
2679
+ createEdge(data: {
2680
+ from_id: string;
2681
+ to_id: string;
2682
+ type: string;
2683
+ properties?: Record<string, unknown>;
2684
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<GraphEdge>>;
2685
+ getEdges(nodeId: string, options?: {
2686
+ type?: string;
2687
+ direction?: 'in' | 'out' | 'both';
2688
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<GraphEdge[]>>;
2689
+ traverse(nodeId: string, options?: {
2690
+ depth?: number;
2691
+ direction?: string;
2692
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<TraversalResult>>;
2693
+ shortestPath(options: {
2694
+ from: string;
2695
+ to: string;
2696
+ max_depth?: number;
2697
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<ShortestPathResult>>;
2698
+ neighbors(nodeId: string, options?: {
2699
+ depth?: number;
2700
+ type?: string;
2701
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<GraphNode[]>>;
2702
+ pageRank(options?: {
2703
+ iterations?: number;
2704
+ damping?: number;
2705
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<Record<string, number>>>;
2706
+ centrality(options?: {
2707
+ algorithm?: string;
2708
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<Record<string, number>>>;
2709
+ connectedComponents(options?: RequestOptions): Promise<ApiResponse<string[][]>>;
2710
+ }
2711
+
2712
+ /**
2713
+ * Functions Service Module
2714
+ *
2715
+ * Serverless functions: deploy, invoke, logs, executions, metrics.
2716
+ *
2717
+ * Routes:
2718
+ * POST / → deploy function
2719
+ * GET / → list functions
2720
+ * GET /{name} → get function
2721
+ * PATCH /{name} → update function
2722
+ * DELETE /{name} → delete function
2723
+ * POST /{name}/invoke → invoke synchronously
2724
+ * POST /{name}/invoke-async → invoke asynchronously
2725
+ * GET /{name}/logs → function logs
2726
+ * GET /{name}/executions → execution history
2727
+ * GET /{name}/metrics → function metrics
2728
+ */
2729
+
2730
+ interface ServerlessFunction {
2731
+ name: string;
2732
+ runtime: string;
2733
+ status: string;
2734
+ memory_mb?: number;
2735
+ timeout_seconds?: number;
2736
+ environment?: Record<string, string>;
2737
+ created_at: string;
2738
+ updated_at: string;
2739
+ }
2740
+ interface FunctionExecution {
2741
+ id: string;
2742
+ function_name: string;
2743
+ status: string;
2744
+ started_at: string;
2745
+ completed_at?: string;
2746
+ duration_ms?: number;
2747
+ result?: unknown;
2748
+ error?: string;
2749
+ }
2750
+ interface FunctionMetrics {
2751
+ invocations: number;
2752
+ errors: number;
2753
+ avg_duration_ms: number;
2754
+ p99_duration_ms: number;
2755
+ }
2756
+ declare class FunctionsService extends ServiceModule {
2757
+ protected basePath: string;
2758
+ deploy(data: {
2759
+ name: string;
2760
+ runtime: string;
2761
+ code: string;
2762
+ }, options?: RequestOptions): Promise<ApiResponse<ServerlessFunction>>;
2763
+ list(options?: RequestOptions): Promise<ApiResponse<ServerlessFunction[]>>;
2764
+ get(name: string, options?: RequestOptions): Promise<ApiResponse<ServerlessFunction>>;
2765
+ update(name: string, data: {
2766
+ code?: string;
2767
+ config?: Record<string, unknown>;
2768
+ }, options?: RequestOptions): Promise<ApiResponse<ServerlessFunction>>;
2769
+ delete(name: string, options?: RequestOptions): Promise<ApiResponse<{
2770
+ deleted: boolean;
2771
+ }>>;
2772
+ invoke(name: string, payload?: unknown, options?: RequestOptions): Promise<ApiResponse<unknown>>;
2773
+ invokeAsync(name: string, payload?: unknown, options?: RequestOptions): Promise<ApiResponse<{
2774
+ execution_id: string;
2775
+ }>>;
2776
+ getLogs(name: string, options?: RequestOptions): Promise<ApiResponse<unknown[]>>;
2777
+ getExecutions(name: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<FunctionExecution>>;
2778
+ getMetrics(name: string, options?: RequestOptions): Promise<ApiResponse<FunctionMetrics>>;
2779
+ /** @deprecated Use deploy() instead */
2780
+ deployFunction(data: {
2781
+ name: string;
2782
+ runtime: string;
2783
+ code: string;
2784
+ }): Promise<ApiResponse<ServerlessFunction>>;
2785
+ /** @deprecated Use invoke() instead */
2786
+ invokeFunction(name: string, payload?: unknown): Promise<ApiResponse<unknown>>;
2787
+ }
2788
+
2789
+ /**
2790
+ * Listings Service Module
2791
+ *
2792
+ * Marketplace listings: CRUD, search, nearby, favorites.
2793
+ *
2794
+ * Routes:
2795
+ * POST / → create listing
2796
+ * GET /{id} → get listing
2797
+ * PATCH /{id} → update listing
2798
+ * DELETE /{id} → delete listing
2799
+ * GET /search → search listings
2800
+ * GET /nearby → nearby listings
2801
+ * GET /categories/{category} → by category
2802
+ * POST /{id}/favorite → favorite
2803
+ * DELETE /{id}/favorite → unfavorite
2804
+ * GET /favorites → user's favorites
2805
+ * POST /{id}/view → track view
2806
+ */
2807
+
2808
+ interface Listing {
2809
+ id: string;
2810
+ title: string;
2811
+ description: string;
2812
+ price?: number;
2813
+ category?: string;
2814
+ location?: {
2815
+ lat: number;
2816
+ lng: number;
2817
+ };
2818
+ images?: string[];
2819
+ status: string;
2820
+ view_count?: number;
2821
+ favorite_count?: number;
2822
+ created_at: string;
2823
+ updated_at: string;
2824
+ }
2825
+ declare class ListingsService extends ServiceModule {
2826
+ protected basePath: string;
2827
+ create(data: {
2828
+ title: string;
2829
+ description: string;
2830
+ price?: number;
2831
+ category?: string;
2832
+ }, options?: RequestOptions): Promise<ApiResponse<Listing>>;
2833
+ get(id: string, options?: RequestOptions): Promise<ApiResponse<Listing>>;
2834
+ update(id: string, data: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<Listing>>;
2835
+ delete(id: string, options?: RequestOptions): Promise<ApiResponse<{
2836
+ deleted: boolean;
2837
+ }>>;
2838
+ search(query: string, filters?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<Listing[]>>;
2839
+ nearby(nearbyOptions: {
2840
+ lat: number;
2841
+ lng: number;
2842
+ radius: number;
2843
+ category?: string;
2844
+ }, options?: RequestOptions): Promise<ApiResponse<Listing[]>>;
2845
+ getByCategory(category: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Listing>>;
2846
+ favorite(listingId: string, options?: RequestOptions): Promise<ApiResponse<{
2847
+ favorited: boolean;
2848
+ }>>;
2849
+ unfavorite(listingId: string, options?: RequestOptions): Promise<ApiResponse<{
2850
+ unfavorited: boolean;
2851
+ }>>;
2852
+ getFavorites(params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Listing>>;
2853
+ trackView(listingId: string, options?: RequestOptions): Promise<ApiResponse<{
2854
+ tracked: boolean;
2855
+ }>>;
2856
+ /** @deprecated Use create() instead */
2857
+ createListing(data: {
2858
+ title: string;
2859
+ description: string;
2860
+ price?: number;
2861
+ category?: string;
2862
+ }): Promise<ApiResponse<Listing>>;
2863
+ /** @deprecated Use search() instead */
2864
+ searchListings(query: string, filters?: Record<string, unknown>): Promise<ApiResponse<Listing[]>>;
2865
+ /** @deprecated Use get() instead */
2866
+ getListing(id: string): Promise<ApiResponse<Listing>>;
2867
+ }
2868
+
2869
+ /**
2870
+ * Events Service Module
2871
+ *
2872
+ * Event management: CRUD, registration, attendees, check-in.
2873
+ *
2874
+ * Routes:
2875
+ * POST / → create event
2876
+ * GET /{id} → get event
2877
+ * PATCH /{id} → update event
2878
+ * DELETE /{id} → delete event
2879
+ * GET / → list events
2880
+ * POST /{id}/register → register for event
2881
+ * DELETE /{id}/register → unregister
2882
+ * GET /{id}/attendees → list attendees
2883
+ * POST /{id}/check-in → check in
2884
+ */
2885
+
2886
+ interface CalendarEvent {
2887
+ id: string;
2888
+ title: string;
2889
+ description: string;
2890
+ start_date: string;
2891
+ end_date?: string;
2892
+ location?: string;
2893
+ capacity?: number;
2894
+ attendee_count?: number;
2895
+ status: string;
2896
+ created_at: string;
2897
+ updated_at: string;
2898
+ }
2899
+ interface Attendee {
2900
+ user_id: string;
2901
+ event_id: string;
2902
+ status: string;
2903
+ checked_in_at?: string;
2904
+ registered_at: string;
2905
+ }
2906
+ declare class EventsService extends ServiceModule {
2907
+ protected basePath: string;
2908
+ create(data: {
2909
+ title: string;
2910
+ description: string;
2911
+ start_date: string;
2912
+ end_date?: string;
2913
+ }, options?: RequestOptions): Promise<ApiResponse<CalendarEvent>>;
2914
+ get(eventId: string, options?: RequestOptions): Promise<ApiResponse<CalendarEvent>>;
2915
+ update(eventId: string, data: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<CalendarEvent>>;
2916
+ delete(eventId: string, options?: RequestOptions): Promise<ApiResponse<{
2917
+ deleted: boolean;
2918
+ }>>;
2919
+ list(filters?: PaginationParams & Record<string, unknown>, requestOptions?: RequestOptions): Promise<PaginatedResponse<CalendarEvent>>;
2920
+ register(eventId: string, options?: RequestOptions): Promise<ApiResponse<Attendee>>;
2921
+ unregister(eventId: string, options?: RequestOptions): Promise<ApiResponse<{
2922
+ unregistered: boolean;
2923
+ }>>;
2924
+ getAttendees(eventId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Attendee>>;
2925
+ checkIn(eventId: string, options?: RequestOptions): Promise<ApiResponse<Attendee>>;
2926
+ /** @deprecated Use create() instead */
2927
+ createEvent(data: {
2928
+ title: string;
2929
+ description: string;
2930
+ start_date: string;
2931
+ end_date: string;
2932
+ }): Promise<ApiResponse<CalendarEvent>>;
2933
+ /** @deprecated Use list() instead */
2934
+ listEvents(filters?: PaginationParams & Record<string, unknown>): Promise<PaginatedResponse<CalendarEvent>>;
2935
+ }
2936
+
2937
+ /**
2938
+ * Leaderboard Service Module
2939
+ *
2940
+ * Leaderboards: create, scores, rankings, history.
2941
+ *
2942
+ * Routes:
2943
+ * POST / → create leaderboard
2944
+ * POST /{boardId}/scores → submit score
2945
+ * GET /{boardId}/rankings → get rankings
2946
+ * GET /{boardId}/users/{userId}/rank → user rank
2947
+ * GET /{boardId}/users/{userId}/history → user history
2948
+ * PATCH /{boardId}/users/{userId}/score → update score
2949
+ * DELETE /{boardId}/users/{userId}/score → delete score
2950
+ */
2951
+
2952
+ interface Leaderboard {
2953
+ id: string;
2954
+ name: string;
2955
+ sort_order: 'asc' | 'desc';
2956
+ entry_count?: number;
2957
+ created_at: string;
2958
+ }
2959
+ interface LeaderboardEntry {
2960
+ user_id: string;
2961
+ score: number;
2962
+ rank: number;
2963
+ updated_at: string;
2964
+ }
2965
+ interface UserRank {
2966
+ rank: number;
2967
+ score: number;
2968
+ total_entries: number;
2969
+ }
2970
+ declare class LeaderboardService extends ServiceModule {
2971
+ protected basePath: string;
2972
+ create(data: {
2973
+ name: string;
2974
+ sort_order?: 'asc' | 'desc';
2975
+ }, options?: RequestOptions): Promise<ApiResponse<Leaderboard>>;
2976
+ submitScore(boardId: string, data: {
2977
+ user_id: string;
2978
+ score: number;
2979
+ }, options?: RequestOptions): Promise<ApiResponse<LeaderboardEntry>>;
2980
+ getRankings(boardId: string, rankingOptions?: {
2981
+ limit?: number;
2982
+ offset?: number;
2983
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<LeaderboardEntry[]>>;
2984
+ getUserRank(boardId: string, userId: string, options?: RequestOptions): Promise<ApiResponse<UserRank>>;
2985
+ getUserHistory(boardId: string, userId: string, options?: RequestOptions): Promise<ApiResponse<LeaderboardEntry[]>>;
2986
+ updateScore(boardId: string, userId: string, data: {
2987
+ score: number;
2988
+ }, options?: RequestOptions): Promise<ApiResponse<LeaderboardEntry>>;
2989
+ deleteScore(boardId: string, userId: string, options?: RequestOptions): Promise<ApiResponse<{
2990
+ deleted: boolean;
2991
+ }>>;
2992
+ }
2993
+
2994
+ /**
2995
+ * Webhooks Service Module
2996
+ *
2997
+ * Webhook management: CRUD, event types.
2998
+ *
2999
+ * Routes:
3000
+ * POST / → create webhook
3001
+ * GET / → list webhooks
3002
+ * GET /{id} → get webhook
3003
+ * PATCH /{id} → update webhook
3004
+ * DELETE /{id} → delete webhook
3005
+ * GET /events → list available event types
3006
+ */
3007
+
3008
+ interface Webhook {
3009
+ id: string;
3010
+ url: string;
3011
+ events: string[];
3012
+ secret?: string;
3013
+ is_active: boolean;
3014
+ created_at: string;
3015
+ updated_at: string;
3016
+ }
3017
+ declare class WebhooksService extends ServiceModule {
3018
+ protected basePath: string;
3019
+ create(data: {
3020
+ url: string;
3021
+ events: string[];
3022
+ secret?: string;
3023
+ }, options?: RequestOptions): Promise<ApiResponse<Webhook>>;
3024
+ list(options?: RequestOptions): Promise<ApiResponse<Webhook[]>>;
3025
+ get(id: string, options?: RequestOptions): Promise<ApiResponse<Webhook>>;
3026
+ update(id: string, data: {
3027
+ url?: string;
3028
+ events?: string[];
3029
+ is_active?: boolean;
3030
+ }, options?: RequestOptions): Promise<ApiResponse<Webhook>>;
3031
+ delete(id: string, options?: RequestOptions): Promise<ApiResponse<{
3032
+ deleted: boolean;
3033
+ }>>;
3034
+ listEvents(options?: RequestOptions): Promise<ApiResponse<string[]>>;
3035
+ /** @deprecated Use create() instead */
3036
+ createWebhook(data: {
3037
+ url: string;
3038
+ events: string[];
3039
+ secret?: string;
3040
+ }): Promise<ApiResponse<Webhook>>;
3041
+ /** @deprecated Use list() instead */
3042
+ listWebhooks(): Promise<ApiResponse<Webhook[]>>;
3043
+ /** @deprecated Use delete() instead */
3044
+ deleteWebhook(id: string): Promise<ApiResponse<{
3045
+ deleted: boolean;
3046
+ }>>;
3047
+ }
3048
+
3049
+ /**
3050
+ * Search Service Module
3051
+ *
3052
+ * Full-text search: index, query, remove.
3053
+ *
3054
+ * Routes:
3055
+ * POST / → search/query
3056
+ * POST /documents → index document
3057
+ * DELETE /documents/{index}/{docId} → remove document
3058
+ */
3059
+
3060
+ interface SearchResult {
3061
+ id: string;
3062
+ index: string;
3063
+ score: number;
3064
+ document: Record<string, unknown>;
3065
+ highlights?: Record<string, string[]>;
3066
+ }
3067
+ declare class SearchService extends ServiceModule {
3068
+ protected basePath: string;
3069
+ query(queryStr: string, queryOptions?: {
3070
+ index?: string;
3071
+ limit?: number;
3072
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<SearchResult[]>>;
3073
+ index(indexName: string, document: {
3074
+ id: string;
3075
+ [key: string]: unknown;
3076
+ }, options?: RequestOptions): Promise<ApiResponse<{
3077
+ indexed: boolean;
3078
+ }>>;
3079
+ removeDocument(indexName: string, docId: string, options?: RequestOptions): Promise<ApiResponse<{
3080
+ deleted: boolean;
3081
+ }>>;
3082
+ /** @deprecated Use query() instead */
3083
+ search(queryStr: string, options?: {
3084
+ index?: string;
3085
+ limit?: number;
3086
+ }): Promise<ApiResponse<SearchResult[]>>;
3087
+ /** @deprecated Use index() instead */
3088
+ indexDocument(data: {
3089
+ index: string;
3090
+ id: string;
3091
+ document: unknown;
3092
+ }): Promise<ApiResponse<{
3093
+ indexed: boolean;
3094
+ }>>;
3095
+ }
3096
+
3097
+ /**
3098
+ * Photo Service Module
3099
+ *
3100
+ * Photo upload, transformation, management.
3101
+ *
3102
+ * Routes:
3103
+ * POST / → upload photo
3104
+ * POST /{id}/transform → transform photo
3105
+ * GET /{id} → get photo info
3106
+ * DELETE /{id} → delete photo
3107
+ */
3108
+
3109
+ interface PhotoInfo {
3110
+ id: string;
3111
+ filename: string;
3112
+ content_type: string;
3113
+ width?: number;
3114
+ height?: number;
3115
+ size_bytes: number;
3116
+ url?: string;
3117
+ thumbnails?: Array<{
3118
+ url: string;
3119
+ width: number;
3120
+ height: number;
3121
+ }>;
3122
+ metadata?: Record<string, unknown>;
3123
+ created_at: string;
3124
+ }
3125
+ interface TransformResult {
3126
+ id: string;
3127
+ url: string;
3128
+ width: number;
3129
+ height: number;
3130
+ format: string;
3131
+ }
3132
+ /** Options for building a transform URL or requesting a transform */
3133
+ interface TransformOptions {
3134
+ width?: number;
3135
+ height?: number;
3136
+ fit?: 'cover' | 'contain' | 'fill' | 'scaledown';
3137
+ /** Output format. Omit to let the server negotiate from the Accept header (AVIF > WebP > JPEG). */
3138
+ format?: 'jpeg' | 'jpg' | 'png' | 'webp' | 'gif' | 'avif';
3139
+ /** Quality 1-100 (default: 85) */
3140
+ quality?: number;
3141
+ }
3142
+ /**
3143
+ * Pre-generated square crop sizes (px).
3144
+ * URLs built with these sizes + fit=cover get instant cache hits (no server-side transform).
3145
+ */
3146
+ declare const PHOTO_BREAKPOINTS: readonly [150, 320, 640, 1080];
3147
+ declare class PhotoService extends ServiceModule {
3148
+ protected basePath: string;
3149
+ upload(file: File | Blob, uploadOptions?: {
3150
+ metadata?: Record<string, unknown>;
3151
+ onProgress?: (progress: number) => void;
3152
+ signal?: AbortSignal;
3153
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<PhotoInfo>>;
3154
+ transform(photoId: string, transformations: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<TransformResult>>;
3155
+ get(id: string, options?: RequestOptions): Promise<ApiResponse<PhotoInfo>>;
3156
+ delete(id: string, options?: RequestOptions): Promise<ApiResponse<{
3157
+ deleted: boolean;
3158
+ }>>;
3159
+ /**
3160
+ * Build an absolute URL for the on-demand transform endpoint.
3161
+ *
3162
+ * Use in `<img src>` or `srcset` — the server negotiates the best format
3163
+ * (AVIF > WebP > JPEG) from the browser's Accept header automatically.
3164
+ * Transformed images are cached server-side on first request.
3165
+ */
3166
+ getTransformUrl(photoId: string, options?: TransformOptions): string;
3167
+ /**
3168
+ * Get a transform URL optimized for the given display area.
3169
+ *
3170
+ * Snaps UP to the nearest pre-generated square breakpoint (150, 320, 640, 1080)
3171
+ * so the response is served instantly from cache. Format is auto-negotiated
3172
+ * by the browser's Accept header (WebP in modern browsers, JPEG fallback).
3173
+ *
3174
+ * @param photoId Photo ID
3175
+ * @param displayWidth CSS pixel width of the display area
3176
+ * @param options.dpr Device pixel ratio (default: 1). Pass `window.devicePixelRatio` in browsers.
3177
+ *
3178
+ * @example
3179
+ * ```typescript
3180
+ * // 280px card on 2x Retina -> snaps to 640px (280×2=560, next breakpoint up)
3181
+ * const url = sm.photo.getOptimalUrl(photoId, 280, { dpr: 2 })
3182
+ *
3183
+ * // Profile avatar at 48px -> snaps to 150px
3184
+ * const url = sm.photo.getOptimalUrl(photoId, 48)
3185
+ * ```
3186
+ */
3187
+ getOptimalUrl(photoId: string, displayWidth: number, options?: {
3188
+ dpr?: number;
3189
+ }): string;
3190
+ /**
3191
+ * Generate an HTML srcset string for responsive square photo display.
3192
+ *
3193
+ * Returns all pre-generated breakpoints as width descriptors. Pair with
3194
+ * the `sizes` attribute so the browser picks the optimal variant automatically.
3195
+ *
3196
+ * @example
3197
+ * ```tsx
3198
+ * const srcset = sm.photo.getSrcSet(photoId)
3199
+ * // -> ".../transform?width=150&height=150&fit=cover 150w, .../transform?width=320..."
3200
+ *
3201
+ * <img
3202
+ * src={sm.photo.getOptimalUrl(photoId, 320)}
3203
+ * srcSet={srcset}
3204
+ * sizes="(max-width: 640px) 100vw, 640px"
3205
+ * alt="Photo"
3206
+ * />
3207
+ * ```
3208
+ */
3209
+ getSrcSet(photoId: string): string;
3210
+ /**
3211
+ * Register a photo from an already-uploaded storage file.
3212
+ *
3213
+ * Creates a photo record so the optimization pipeline can process it.
3214
+ * Use this when files are uploaded via the storage service (presigned URL)
3215
+ * instead of the photo service's upload endpoint.
3216
+ *
3217
+ * Returns the photo record with `id` that can be used with `getTransformUrl()`.
3218
+ */
3219
+ register(registerOptions: {
3220
+ fileId: string;
3221
+ userId?: string;
3222
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<PhotoInfo>>;
3223
+ /** @deprecated Use upload() instead */
3224
+ uploadPhoto(file: File | Blob, options?: {
3225
+ metadata?: Record<string, unknown>;
3226
+ onProgress?: (progress: number) => void;
3227
+ signal?: AbortSignal;
3228
+ }): Promise<ApiResponse<PhotoInfo>>;
3229
+ /** @deprecated Use transform() instead */
3230
+ transformPhoto(photoId: string, transformations: Record<string, unknown>): Promise<ApiResponse<TransformResult>>;
3231
+ /** @deprecated Use get() instead */
3232
+ getPhoto(id: string): Promise<ApiResponse<PhotoInfo>>;
3233
+ }
3234
+
3235
+ /**
3236
+ * Queue Service Module
3237
+ *
3238
+ * Job queue with dead letter sub-API.
3239
+ *
3240
+ * Routes:
3241
+ * POST /jobs → enqueue job
3242
+ * GET /jobs/{id} → get job status
3243
+ * GET /dead-letter → list dead letter jobs
3244
+ * GET /dead-letter/{id} → get dead letter job
3245
+ * POST /dead-letter/{id}/retry → retry dead letter job
3246
+ * DELETE /dead-letter/{id} → delete dead letter job
3247
+ */
3248
+
3249
+ interface QueueJob {
3250
+ id: string;
3251
+ job_type: string;
3252
+ status: string;
3253
+ queue?: string;
3254
+ priority?: string;
3255
+ payload: unknown;
3256
+ attempts: number;
3257
+ max_attempts: number;
3258
+ created_at: string;
3259
+ completed_at?: string;
3260
+ error?: string;
3261
+ }
3262
+ interface DeadLetterJob {
3263
+ id: string;
3264
+ original_job_id: string;
3265
+ job_type: string;
3266
+ payload: unknown;
3267
+ error: string;
3268
+ failed_at: string;
3269
+ }
3270
+ declare class DeadLetterApi extends ServiceModule {
3271
+ protected basePath: string;
3272
+ list(options?: RequestOptions): Promise<ApiResponse<DeadLetterJob[]>>;
3273
+ get(id: string, options?: RequestOptions): Promise<ApiResponse<DeadLetterJob>>;
3274
+ retry(id: string, options?: RequestOptions): Promise<ApiResponse<QueueJob>>;
3275
+ delete(id: string, options?: RequestOptions): Promise<ApiResponse<{
3276
+ deleted: boolean;
3277
+ }>>;
3278
+ }
3279
+ declare class QueueService extends ServiceModule {
3280
+ protected basePath: string;
3281
+ readonly deadLetter: DeadLetterApi;
3282
+ constructor(client: ScaleMuleClient);
3283
+ enqueue(data: {
3284
+ job_type: string;
3285
+ payload: unknown;
3286
+ queue?: string;
3287
+ priority?: 'low' | 'normal' | 'high' | 'critical';
3288
+ run_at?: string;
3289
+ max_attempts?: number;
3290
+ }, options?: RequestOptions): Promise<ApiResponse<QueueJob>>;
3291
+ getJob(id: string, options?: RequestOptions): Promise<ApiResponse<QueueJob>>;
3292
+ }
3293
+
3294
+ /**
3295
+ * Cache Service Module
3296
+ *
3297
+ * Key-value cache: get, set, delete, flush.
3298
+ *
3299
+ * Routes:
3300
+ * GET /{key} → get cached value
3301
+ * POST / → set value
3302
+ * DELETE /{key} → delete key
3303
+ * DELETE / → flush all
3304
+ */
3305
+
3306
+ interface CacheEntry {
3307
+ key: string;
3308
+ value: unknown;
3309
+ ttl?: number;
3310
+ expires_at?: string;
3311
+ }
3312
+ declare class CacheService extends ServiceModule {
3313
+ protected basePath: string;
3314
+ get(key: string, options?: RequestOptions): Promise<ApiResponse<CacheEntry>>;
3315
+ set(key: string, value: unknown, ttl?: number, options?: RequestOptions): Promise<ApiResponse<CacheEntry>>;
3316
+ delete(key: string, options?: RequestOptions): Promise<ApiResponse<{
3317
+ deleted: boolean;
3318
+ }>>;
3319
+ flush(options?: RequestOptions): Promise<ApiResponse<{
3320
+ flushed: boolean;
3321
+ }>>;
3322
+ }
3323
+
3324
+ /**
3325
+ * Compliance Service Module
3326
+ *
3327
+ * GDPR/CCPA data subject requests, consent management, breach tracking,
3328
+ * data retention policies, processing activities, and audit logging.
3329
+ *
3330
+ * Routes:
3331
+ * POST /audit-logs → create audit log
3332
+ * GET /audit-logs → query audit logs
3333
+ *
3334
+ * Legacy GDPR (deprecated — use DSR endpoints):
3335
+ * POST /gdpr/access-request → request data export
3336
+ * POST /gdpr/deletion-request → request data deletion
3337
+ *
3338
+ * Consent Purposes:
3339
+ * POST /consent-purposes → create consent purpose
3340
+ * GET /consent-purposes → list consent purposes
3341
+ *
3342
+ * Consent v2:
3343
+ * POST /consent/v2 → record consent
3344
+ * GET /consent/v2/:userId → get user consents
3345
+ * PUT /consent/v2/:id/withdraw → withdraw consent
3346
+ *
3347
+ * Data Subject Requests (DSR):
3348
+ * POST /dsr → create DSR
3349
+ * GET /dsr → list DSRs
3350
+ * GET /dsr/:id → get DSR
3351
+ * PUT /dsr/:id/status → update DSR status
3352
+ * POST /dsr/:id/actions → create DSR action
3353
+ * GET /dsr/:id/actions → list DSR actions
3354
+ *
3355
+ * Breaches:
3356
+ * POST /breaches → report breach
3357
+ * GET /breaches → list breaches
3358
+ * GET /breaches/:id → get breach
3359
+ * PUT /breaches/:id → update breach
3360
+ *
3361
+ * Retention Policies:
3362
+ * GET /retention/policies → list retention policies
3363
+ * POST /retention/policies → create retention policy
3364
+ *
3365
+ * Processing Activities:
3366
+ * POST /processing-activities → create processing activity
3367
+ * GET /processing-activities → list processing activities
3368
+ * GET /processing-activities/:id → get processing activity
3369
+ * PUT /processing-activities/:id → update processing activity
3370
+ */
3371
+
3372
+ interface AuditLog {
3373
+ id: string;
3374
+ action: string;
3375
+ resource_type: string;
3376
+ resource_id: string;
3377
+ actor_id?: string;
3378
+ metadata?: Record<string, unknown>;
3379
+ created_at: string;
3380
+ }
3381
+ /** @deprecated Use DataSubjectRequest instead */
3382
+ interface GdprRequest {
3383
+ id: string;
3384
+ type: 'access' | 'deletion';
3385
+ user_id: string;
3386
+ status: string;
3387
+ created_at: string;
3388
+ completed_at?: string;
3389
+ }
3390
+ interface ConsentPurpose {
3391
+ id: string;
3392
+ name: string;
3393
+ description?: string;
3394
+ legal_basis: string;
3395
+ category: string;
3396
+ is_active: boolean;
3397
+ created_at: string;
3398
+ updated_at: string;
3399
+ }
3400
+ interface ConsentRecord {
3401
+ id: string;
3402
+ user_id: string;
3403
+ purpose_id: string;
3404
+ purpose_name: string;
3405
+ consent_given: boolean;
3406
+ consent_method?: string;
3407
+ double_opt_in_verified: boolean;
3408
+ granted_at: string;
3409
+ withdrawn_at?: string;
3410
+ }
3411
+ interface DataSubjectRequest {
3412
+ id: string;
3413
+ request_type: string;
3414
+ status: string;
3415
+ priority: string;
3416
+ reference_number: string;
3417
+ requester_email: string;
3418
+ requester_name?: string;
3419
+ description?: string;
3420
+ deadline: string;
3421
+ completed_at?: string;
3422
+ created_at: string;
3423
+ updated_at: string;
3424
+ }
3425
+ interface DsrAction {
3426
+ id: string;
3427
+ dsr_id: string;
3428
+ service_name: string;
3429
+ action_type: string;
3430
+ status: string;
3431
+ details?: string;
3432
+ completed_at?: string;
3433
+ created_at: string;
3434
+ }
3435
+ interface DataBreach {
3436
+ id: string;
3437
+ reference_number: string;
3438
+ title: string;
3439
+ description?: string;
3440
+ incident_type: string;
3441
+ severity: string;
3442
+ status: string;
3443
+ discovered_at: string;
3444
+ reported_to_authority: boolean;
3445
+ individuals_affected?: number;
3446
+ created_at: string;
3447
+ updated_at: string;
3448
+ }
3449
+ interface RetentionPolicy {
3450
+ id: string;
3451
+ data_type: string;
3452
+ table_name?: string;
3453
+ retention_days: number;
3454
+ name?: string;
3455
+ description?: string;
3456
+ is_active: boolean;
3457
+ last_execution_at?: string;
3458
+ last_execution_result?: string;
3459
+ records_deleted_last_run?: number;
3460
+ }
3461
+ interface ProcessingActivity {
3462
+ id: string;
3463
+ name: string;
3464
+ description?: string;
3465
+ purpose: string;
3466
+ legal_basis: string;
3467
+ data_categories?: string;
3468
+ data_subjects?: string;
3469
+ recipients?: string;
3470
+ international_transfers?: string;
3471
+ retention_period?: string;
3472
+ technical_measures?: string;
3473
+ dpia_required: boolean;
3474
+ dpia_conducted: boolean;
3475
+ status: string;
3476
+ created_at: string;
3477
+ updated_at: string;
3478
+ }
3479
+ interface CreateConsentPurposeRequest {
3480
+ name: string;
3481
+ description?: string;
3482
+ legal_basis: string;
3483
+ category: string;
3484
+ }
3485
+ interface RecordConsentRequest {
3486
+ user_id: string;
3487
+ purpose_id: string;
3488
+ consent_given: boolean;
3489
+ consent_method?: string;
3490
+ }
3491
+ interface CreateDsrRequest {
3492
+ request_type: 'access' | 'deletion' | 'rectification' | 'portability' | 'restriction' | 'objection';
3493
+ requester_email: string;
3494
+ requester_name?: string;
3495
+ description?: string;
3496
+ priority?: 'low' | 'medium' | 'high' | 'urgent';
3497
+ }
3498
+ interface UpdateDsrStatusRequest {
3499
+ status: string;
3500
+ reason?: string;
3501
+ actor?: string;
3502
+ }
3503
+ interface CreateDsrActionRequest {
3504
+ service_name: string;
3505
+ action_type: string;
3506
+ details?: string;
3507
+ }
3508
+ interface ReportBreachRequest {
3509
+ title: string;
3510
+ description?: string;
3511
+ incident_type: string;
3512
+ severity: string;
3513
+ discovered_at: string;
3514
+ individuals_affected?: number;
3515
+ }
3516
+ interface UpdateBreachRequest {
3517
+ title?: string;
3518
+ description?: string;
3519
+ status?: string;
3520
+ severity?: string;
3521
+ reported_to_authority?: boolean;
3522
+ authority_reference?: string;
3523
+ individuals_affected?: number;
3524
+ }
3525
+ interface CreateRetentionPolicyRequest {
3526
+ data_type: string;
3527
+ table_name?: string;
3528
+ retention_days: number;
3529
+ name?: string;
3530
+ description?: string;
3531
+ }
3532
+ interface CreateProcessingActivityRequest {
3533
+ name: string;
3534
+ description?: string;
3535
+ purpose: string;
3536
+ legal_basis: string;
3537
+ data_categories?: string;
3538
+ data_subjects?: string;
3539
+ recipients?: string;
3540
+ international_transfers?: string;
3541
+ retention_period?: string;
3542
+ technical_measures?: string;
3543
+ dpia_required?: boolean;
3544
+ }
3545
+ declare class ComplianceService extends ServiceModule {
3546
+ protected basePath: string;
3547
+ /** Build query string from params object */
3548
+ private qs;
3549
+ log(data: {
3550
+ action: string;
3551
+ resource_type: string;
3552
+ resource_id: string;
3553
+ metadata?: Record<string, unknown>;
3554
+ }, options?: RequestOptions): Promise<ApiResponse<AuditLog>>;
3555
+ queryAuditLogs(params?: {
3556
+ page?: number;
3557
+ per_page?: number;
3558
+ action?: string;
3559
+ resource_type?: string;
3560
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<AuditLog[]>>;
3561
+ /** @deprecated Use createDataSubjectRequest({ request_type: 'access', ... }) instead */
3562
+ requestDataExport(userId: string): Promise<ApiResponse<GdprRequest>>;
3563
+ /** @deprecated Use createDataSubjectRequest({ request_type: 'deletion', ... }) instead */
3564
+ requestDataDeletion(userId: string): Promise<ApiResponse<GdprRequest>>;
3565
+ /** @deprecated Use log() instead */
3566
+ createAuditLog(data: {
3567
+ action: string;
3568
+ resource_type: string;
3569
+ resource_id: string;
3570
+ }): Promise<ApiResponse<AuditLog>>;
3571
+ listConsentPurposes(options?: RequestOptions): Promise<ApiResponse<ConsentPurpose[]>>;
3572
+ createConsentPurpose(data: CreateConsentPurposeRequest, options?: RequestOptions): Promise<ApiResponse<ConsentPurpose>>;
3573
+ recordConsent(data: RecordConsentRequest, options?: RequestOptions): Promise<ApiResponse<ConsentRecord>>;
3574
+ getUserConsents(userId: string, options?: RequestOptions): Promise<ApiResponse<ConsentRecord[]>>;
3575
+ withdrawConsent(consentId: string, data?: {
3576
+ reason?: string;
3577
+ actor?: string;
3578
+ }, options?: RequestOptions): Promise<ApiResponse<ConsentRecord>>;
3579
+ createDataSubjectRequest(data: CreateDsrRequest, options?: RequestOptions): Promise<ApiResponse<DataSubjectRequest>>;
3580
+ listDataSubjectRequests(params?: {
3581
+ page?: number;
3582
+ per_page?: number;
3583
+ status?: string;
3584
+ request_type?: string;
3585
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<DataSubjectRequest[]>>;
3586
+ getDataSubjectRequest(id: string, options?: RequestOptions): Promise<ApiResponse<DataSubjectRequest>>;
3587
+ updateDsrStatus(id: string, data: UpdateDsrStatusRequest, options?: RequestOptions): Promise<ApiResponse<DataSubjectRequest>>;
3588
+ createDsrAction(dsrId: string, data: CreateDsrActionRequest, options?: RequestOptions): Promise<ApiResponse<DsrAction>>;
3589
+ listDsrActions(dsrId: string, options?: RequestOptions): Promise<ApiResponse<DsrAction[]>>;
3590
+ reportBreach(data: ReportBreachRequest, options?: RequestOptions): Promise<ApiResponse<DataBreach>>;
3591
+ listBreaches(params?: {
3592
+ page?: number;
3593
+ per_page?: number;
3594
+ status?: string;
3595
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<DataBreach[]>>;
3596
+ getBreach(id: string, options?: RequestOptions): Promise<ApiResponse<DataBreach>>;
3597
+ updateBreach(id: string, data: UpdateBreachRequest, options?: RequestOptions): Promise<ApiResponse<DataBreach>>;
3598
+ listRetentionPolicies(options?: RequestOptions): Promise<ApiResponse<RetentionPolicy[]>>;
3599
+ createRetentionPolicy(data: CreateRetentionPolicyRequest, options?: RequestOptions): Promise<ApiResponse<RetentionPolicy>>;
3600
+ createProcessingActivity(data: CreateProcessingActivityRequest, options?: RequestOptions): Promise<ApiResponse<ProcessingActivity>>;
3601
+ listProcessingActivities(params?: {
3602
+ page?: number;
3603
+ per_page?: number;
3604
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<ProcessingActivity[]>>;
3605
+ getProcessingActivity(id: string, options?: RequestOptions): Promise<ApiResponse<ProcessingActivity>>;
3606
+ updateProcessingActivity(id: string, data: Partial<CreateProcessingActivityRequest>, options?: RequestOptions): Promise<ApiResponse<ProcessingActivity>>;
3607
+ }
3608
+
3609
+ /**
3610
+ * Orchestrator Service Module
3611
+ *
3612
+ * Workflow orchestration: create, execute, track.
3613
+ *
3614
+ * Routes:
3615
+ * POST /workflows → create workflow
3616
+ * POST /workflows/{id}/execute → execute workflow
3617
+ * GET /executions/{id} → get execution status
3618
+ */
3619
+
3620
+ interface Workflow {
3621
+ id: string;
3622
+ name: string;
3623
+ steps: unknown[];
3624
+ created_at: string;
3625
+ updated_at: string;
3626
+ }
3627
+ interface WorkflowExecution {
3628
+ id: string;
3629
+ workflow_id: string;
3630
+ status: string;
3631
+ input?: unknown;
3632
+ output?: unknown;
3633
+ started_at: string;
3634
+ completed_at?: string;
3635
+ error?: string;
3636
+ }
3637
+ declare class OrchestratorService extends ServiceModule {
3638
+ protected basePath: string;
3639
+ createWorkflow(data: {
3640
+ name: string;
3641
+ steps: unknown[];
3642
+ }, options?: RequestOptions): Promise<ApiResponse<Workflow>>;
3643
+ execute(workflowId: string, input?: unknown, options?: RequestOptions): Promise<ApiResponse<WorkflowExecution>>;
3644
+ getExecution(executionId: string, options?: RequestOptions): Promise<ApiResponse<WorkflowExecution>>;
3645
+ /** @deprecated Use execute() instead */
3646
+ executeWorkflow(workflowId: string, input?: unknown): Promise<ApiResponse<WorkflowExecution>>;
3647
+ }
3648
+
3649
+ /**
3650
+ * Accounts Service Module
3651
+ *
3652
+ * Client and application management.
3653
+ *
3654
+ * Routes:
3655
+ * POST /clients → create client
3656
+ * GET /clients → list clients
3657
+ * POST /applications → create application
3658
+ * GET /applications → list applications
3659
+ */
3660
+
3661
+ interface Client {
3662
+ id: string;
3663
+ name: string;
3664
+ email: string;
3665
+ created_at: string;
3666
+ }
3667
+ interface Application {
3668
+ id: string;
3669
+ name: string;
3670
+ description?: string;
3671
+ api_key?: string;
3672
+ created_at: string;
3673
+ }
3674
+ declare class AccountsService extends ServiceModule {
3675
+ protected basePath: string;
3676
+ createClient(data: {
3677
+ name: string;
3678
+ email: string;
3679
+ }, options?: RequestOptions): Promise<ApiResponse<Client>>;
3680
+ getClients(options?: RequestOptions): Promise<ApiResponse<Client[]>>;
3681
+ createApplication(data: {
3682
+ name: string;
3683
+ description?: string;
3684
+ }, options?: RequestOptions): Promise<ApiResponse<Application>>;
3685
+ getApplications(options?: RequestOptions): Promise<ApiResponse<Application[]>>;
3686
+ }
3687
+
3688
+ /**
3689
+ * Identity Service Module
3690
+ *
3691
+ * API key management.
3692
+ *
3693
+ * Routes:
3694
+ * POST /api-keys → create API key
3695
+ * GET /api-keys → list API keys
3696
+ * DELETE /api-keys/{id} → revoke API key
3697
+ */
3698
+
3699
+ interface ApiKey {
3700
+ id: string;
3701
+ name: string;
3702
+ key?: string;
3703
+ prefix: string;
3704
+ expires_at?: string;
3705
+ last_used_at?: string;
3706
+ created_at: string;
3707
+ }
3708
+ declare class IdentityService extends ServiceModule {
3709
+ protected basePath: string;
3710
+ createApiKey(data: {
3711
+ name: string;
3712
+ expires_at?: string;
3713
+ }, options?: RequestOptions): Promise<ApiResponse<ApiKey>>;
3714
+ listApiKeys(options?: RequestOptions): Promise<ApiResponse<ApiKey[]>>;
3715
+ revokeApiKey(id: string, options?: RequestOptions): Promise<ApiResponse<{
3716
+ revoked: boolean;
3717
+ }>>;
3718
+ }
3719
+
3720
+ /**
3721
+ * Catalog Service Module
3722
+ *
3723
+ * Service catalog and health checks.
3724
+ *
3725
+ * Routes:
3726
+ * GET /services → list services
3727
+ * GET /services/{name}/health → service health check
3728
+ */
3729
+
3730
+ interface CatalogEntry {
3731
+ name: string;
3732
+ version: string;
3733
+ status: string;
3734
+ port: number;
3735
+ description?: string;
3736
+ }
3737
+ interface ServiceHealth {
3738
+ status: string;
3739
+ uptime_seconds?: number;
3740
+ checks?: Record<string, {
3741
+ status: string;
3742
+ message?: string;
3743
+ }>;
3744
+ }
3745
+ declare class CatalogService extends ServiceModule {
3746
+ protected basePath: string;
3747
+ listServices(options?: RequestOptions): Promise<ApiResponse<CatalogEntry[]>>;
3748
+ getServiceHealth(name: string, options?: RequestOptions): Promise<ApiResponse<ServiceHealth>>;
3749
+ }
3750
+
3751
+ /**
3752
+ * Logger Service Module
3753
+ *
3754
+ * Centralized logging: write and query logs.
3755
+ *
3756
+ * Routes:
3757
+ * POST /logs → write log entry
3758
+ * POST /logs/batch → write log entries in batch (max 100 per call, auto-chunked)
3759
+ * GET /logs → query logs (paginated)
3760
+ */
3761
+
3762
+ type Severity = 'debug' | 'info' | 'warn' | 'error' | 'fatal';
3763
+ /** Input for creating a log entry. Matches backend schema. */
3764
+ interface LogInput {
3765
+ /** Service name (required — maps to backend service_name) */
3766
+ service: string;
3767
+ /** Log severity (required) */
3768
+ severity: Severity;
3769
+ /** Log message (required) */
3770
+ message: string;
3771
+ /** Arbitrary JSON metadata */
3772
+ metadata?: Record<string, unknown>;
3773
+ /** Distributed tracing / correlation ID */
3774
+ trace_id?: string;
3775
+ span_id?: string;
3776
+ parent_span_id?: string;
3777
+ /** ISO 8601 timestamp, defaults to now on backend */
3778
+ timestamp?: string;
3779
+ }
3780
+ /** Legacy input shape for backward compatibility */
3781
+ interface LegacyLogInput {
3782
+ level: string;
3783
+ message: string;
3784
+ metadata?: Record<string, unknown>;
3785
+ }
3786
+ /** Log record as returned by the backend query endpoint */
3787
+ interface LogRecord {
3788
+ id: string;
3789
+ service_name: string;
3790
+ severity: string;
3791
+ message: string;
3792
+ metadata?: Record<string, unknown>;
3793
+ trace_id?: string;
3794
+ span_id?: string;
3795
+ parent_span_id?: string;
3796
+ timestamp: string;
3797
+ }
3798
+ /** Paginated query response from GET /logs */
3799
+ interface LogQueryResponse {
3800
+ logs: LogRecord[];
3801
+ total: number;
3802
+ page: number;
3803
+ limit: number;
3804
+ }
3805
+ /** Query parameters for filtering logs */
3806
+ interface LogQueryParams {
3807
+ service?: string;
3808
+ severity?: Severity;
3809
+ search?: string;
3810
+ trace_id?: string;
3811
+ start_time?: string;
3812
+ end_time?: string;
3813
+ page?: number;
3814
+ limit?: number;
3815
+ }
3816
+ /** @deprecated Use LogRecord instead */
3817
+ interface LogEntry {
3818
+ id: string;
3819
+ level: string;
3820
+ message: string;
3821
+ service?: string;
3822
+ metadata?: Record<string, unknown>;
3823
+ timestamp: string;
3824
+ }
3825
+ declare class LoggerService extends ServiceModule {
3826
+ protected basePath: string;
3827
+ /**
3828
+ * Write a single log entry.
3829
+ * Accepts both new schema (LogInput) and legacy shape ({ level, message }) for backward compatibility.
3830
+ */
3831
+ log(data: LogInput | LegacyLogInput, options?: RequestOptions): Promise<ApiResponse<void>>;
3832
+ /**
3833
+ * Write log entries in batch.
3834
+ * Auto-chunks into groups of 100 (backend hard limit) and sends sequentially.
3835
+ * Returns total ingested count across all chunks.
3836
+ */
3837
+ logBatch(logs: LogInput[], options?: RequestOptions): Promise<ApiResponse<{
3838
+ ingested: number;
3839
+ }>>;
3840
+ /**
3841
+ * Query logs with filters. Returns paginated response.
3842
+ */
3843
+ queryLogs(filters?: LogQueryParams, requestOptions?: RequestOptions): Promise<ApiResponse<LogQueryResponse>>;
3844
+ debug(service: string, message: string, meta?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<void>>;
3845
+ info(service: string, message: string, meta?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<void>>;
3846
+ warn(service: string, message: string, meta?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<void>>;
3847
+ error(service: string, message: string, meta?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<void>>;
3848
+ /** Normalize legacy { level, message } to { severity, service, message } */
3849
+ private normalizeLogInput;
3850
+ }
3851
+
3852
+ /**
3853
+ * FlagContent Service Module (Content Moderation)
3854
+ *
3855
+ * Content flagging, checking, and appeals.
3856
+ *
3857
+ * Routes:
3858
+ * POST /flags → create flag
3859
+ * GET /flags/check → check if content is flagged
3860
+ * GET /flags/{id} → get flag details
3861
+ * POST /appeals → submit appeal
3862
+ * GET /appeals/{id} → get appeal status
3863
+ */
3864
+
3865
+ interface ContentFlag {
3866
+ id: string;
3867
+ content_type: string;
3868
+ content_id: string;
3869
+ category: string;
3870
+ subcategory?: string;
3871
+ status: string;
3872
+ description?: string;
3873
+ created_at: string;
3874
+ }
3875
+ interface FlagCheck {
3876
+ flagged: boolean;
3877
+ flags?: ContentFlag[];
3878
+ }
3879
+ interface Appeal {
3880
+ id: string;
3881
+ flag_id: string;
3882
+ reason: string;
3883
+ status: string;
3884
+ created_at: string;
3885
+ resolved_at?: string;
3886
+ }
3887
+ declare class FlagContentService extends ServiceModule {
3888
+ protected basePath: string;
3889
+ createFlag(data: {
3890
+ content_type: string;
3891
+ content_id: string;
3892
+ content_url?: string;
3893
+ category: string;
3894
+ subcategory?: string;
3895
+ description?: string;
3896
+ reporter_id?: string;
3897
+ reporter_email?: string;
3898
+ is_anonymous?: boolean;
3899
+ }, options?: RequestOptions): Promise<ApiResponse<ContentFlag>>;
3900
+ checkFlag(params: {
3901
+ content_type: string;
3902
+ content_id: string;
3903
+ }, requestOptions?: RequestOptions): Promise<ApiResponse<FlagCheck>>;
3904
+ getFlag(id: string, options?: RequestOptions): Promise<ApiResponse<ContentFlag>>;
3905
+ submitAppeal(data: {
3906
+ flag_id: string;
3907
+ reason: string;
3908
+ }, options?: RequestOptions): Promise<ApiResponse<Appeal>>;
3909
+ getAppeal(id: string, options?: RequestOptions): Promise<ApiResponse<Appeal>>;
3910
+ }
3911
+
3912
+ /**
3913
+ * ScaleMule SDK for TypeScript/JavaScript
3914
+ *
3915
+ * Official SDK for ScaleMule Backend-as-a-Service (v2)
3916
+ *
3917
+ * All methods return { data, error } — never throws on API errors.
3918
+ * List methods return { data[], metadata, error } with standardized pagination.
3919
+ *
3920
+ * @packageDocumentation
3921
+ */
3922
+
3923
+ /**
3924
+ * Main entry point for the ScaleMule SDK.
3925
+ *
3926
+ * @example
3927
+ * ```typescript
3928
+ * import { ScaleMule } from '@scalemule/sdk'
3929
+ *
3930
+ * const sm = new ScaleMule({ apiKey: 'pk_live_...' })
3931
+ * await sm.initialize()
3932
+ *
3933
+ * // Auth
3934
+ * const { data, error } = await sm.auth.signInWithOtp({ email: 'user@example.com' })
3935
+ *
3936
+ * // Data
3937
+ * const { data: doc } = await sm.data.create('todos', { title: 'Ship SDK', done: false })
3938
+ * const { data: todos } = await sm.data.query('todos', {
3939
+ * filters: [{ operator: 'eq', field: 'done', value: false }],
3940
+ * })
3941
+ *
3942
+ * // Storage
3943
+ * const { data: file } = await sm.storage.upload(blob, { onProgress: (p) => {} })
3944
+ * const { data: url } = await sm.storage.getViewUrl(file.id)
3945
+ *
3946
+ * // Realtime
3947
+ * const unsub = sm.realtime.subscribe('chat:room-1', (msg) => console.log(msg))
3948
+ *
3949
+ * // All methods return { data, error } — never throws
3950
+ * if (error) console.error(error.code, error.message)
3951
+ * ```
3952
+ */
3953
+ declare class ScaleMule {
3954
+ private readonly _client;
3955
+ readonly auth: AuthService;
3956
+ readonly storage: StorageService;
3957
+ readonly realtime: RealtimeService;
3958
+ readonly video: VideoService;
3959
+ readonly data: DataService;
3960
+ readonly chat: ChatService;
3961
+ readonly social: SocialService;
3962
+ readonly billing: BillingService;
3963
+ readonly analytics: AnalyticsService;
3964
+ readonly communication: CommunicationService;
3965
+ readonly scheduler: SchedulerService;
3966
+ readonly permissions: PermissionsService;
3967
+ readonly teams: TeamsService;
3968
+ readonly accounts: AccountsService;
3969
+ readonly identity: IdentityService;
3970
+ readonly catalog: CatalogService;
3971
+ readonly cache: CacheService;
3972
+ readonly queue: QueueService;
3973
+ readonly search: SearchService;
3974
+ readonly logger: LoggerService;
3975
+ readonly webhooks: WebhooksService;
3976
+ readonly leaderboard: LeaderboardService;
3977
+ readonly listings: ListingsService;
3978
+ readonly events: EventsService;
3979
+ readonly graph: GraphService;
3980
+ readonly functions: FunctionsService;
3981
+ readonly photo: PhotoService;
3982
+ readonly flagContent: FlagContentService;
3983
+ readonly compliance: ComplianceService;
3984
+ readonly orchestrator: OrchestratorService;
3985
+ constructor(config: ScaleMuleConfig);
3986
+ /**
3987
+ * Initialize the client — loads persisted session from storage.
3988
+ * Call this once after construction, before making authenticated requests.
3989
+ */
3990
+ initialize(): Promise<void>;
3991
+ /**
3992
+ * Set authentication session (token + userId).
3993
+ * Persisted to storage for cross-session continuity.
3994
+ */
3995
+ setSession(token: string, userId: string): Promise<void>;
3996
+ /** Clear the current session and remove from storage. */
3997
+ clearSession(): Promise<void>;
3998
+ /** Set access token (in-memory only, not persisted). */
3999
+ setAccessToken(token: string): void;
4000
+ /** Clear access token. */
4001
+ clearAccessToken(): void;
4002
+ /** Current session token, or null. */
4003
+ getSessionToken(): string | null;
4004
+ /** Current user ID, or null. */
4005
+ getUserId(): string | null;
4006
+ /** Whether a session token is set. */
4007
+ isAuthenticated(): boolean;
4008
+ /** The base URL being used for API requests. */
4009
+ getBaseUrl(): string;
4010
+ /** Access the underlying ScaleMuleClient for advanced usage. */
4011
+ getClient(): ScaleMuleClient;
4012
+ }
4013
+
4014
+ export { type AccountBalance, AccountsService, type ActiveUsers, type ActivityItem, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type Attachment, type Attendee, type AuditLog, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, 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 Customer, type DataExport, DataService, type DeadLetterJob, type DeviceInfo, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, type FlagCheck, FlagContentService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, 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 MultipartCompleteResponse, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, 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 Policy, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type PushToken, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type Refund, type RequestOptions, type ResumeSession, type Role, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type ServerlessFunction, type ServiceHealth, ServiceModule, type SessionInfo, type Severity, type ShortestPathResult, type SignedUrlResponse, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StrategyResult, type Subscription, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type UploadCompleteResponse, type UploadEngineConfig, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, type Webhook, WebhooksService, type Workflow, type WorkflowExecution, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, extractClientContext, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, resolveStrategy, validateIP };