@scalemule/nextjs 0.1.58 → 0.1.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/dist/audio.css +0 -857
- package/dist/audio.d.mts +0 -334
- package/dist/audio.d.ts +0 -334
- package/dist/audio.js +0 -2178
- package/dist/audio.mjs +0 -2156
- package/dist/client.d.mts +0 -240
- package/dist/client.d.ts +0 -240
- package/dist/client.js +0 -938
- package/dist/client.mjs +0 -935
- package/dist/index-2PnO4RAF.d.mts +0 -975
- package/dist/index-2PnO4RAF.d.ts +0 -975
- package/dist/index.d.mts +0 -1234
- package/dist/index.d.ts +0 -1234
- package/dist/index.js +0 -5894
- package/dist/index.mjs +0 -5833
- package/dist/ledvery-CxPzZpxP.d.mts +0 -44
- package/dist/ledvery-CxPzZpxP.d.ts +0 -44
- package/dist/listening-hub.global.js +0 -1
- package/dist/server/auth.d.mts +0 -43
- package/dist/server/auth.d.ts +0 -43
- package/dist/server/auth.js +0 -1934
- package/dist/server/auth.mjs +0 -1928
- package/dist/server/index.d.mts +0 -1302
- package/dist/server/index.d.ts +0 -1302
- package/dist/server/index.js +0 -3579
- package/dist/server/index.mjs +0 -3500
- package/dist/server/ledvery.d.mts +0 -1
- package/dist/server/ledvery.d.ts +0 -1
- package/dist/server/ledvery.js +0 -336
- package/dist/server/ledvery.mjs +0 -333
- package/dist/server/webhook-handler.d.mts +0 -3
- package/dist/server/webhook-handler.d.ts +0 -3
- package/dist/server/webhook-handler.js +0 -59
- package/dist/server/webhook-handler.mjs +0 -57
- package/dist/testing.d.mts +0 -109
- package/dist/testing.d.ts +0 -109
- package/dist/testing.js +0 -144
- package/dist/testing.mjs +0 -138
- package/dist/webhook-handler-1nnrmWT0.d.ts +0 -826
- package/dist/webhook-handler-DNpCXDDA.d.mts +0 -826
package/dist/index.d.mts
DELETED
|
@@ -1,1234 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ApiError, RealtimeService, StorageService, PhotoService, VideoService, AudioService, TtsService, SocialService, SocialPolicyService, TtsJobStatus, TtsAudioInfo, FileStatus } from '@scalemule/sdk';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { ReactNode, ReactElement } from 'react';
|
|
5
|
-
import { MoneyClient } from '@scalemule/money';
|
|
6
|
-
export { MoneyClient, MoneyClientConfig, createMoneyClient } from '@scalemule/money';
|
|
7
|
-
import { ScaleMuleClient } from './client.mjs';
|
|
8
|
-
export { ClientConfig, RequestOptions, createClient } from './client.mjs';
|
|
9
|
-
import { S as ScaleMuleConfig, U as User, L as LoginResponse, A as ApiError$1, a as UseAuthReturn, b as UseBillingReturn, c as ListFilesParams, d as UseContentReturn, e as UseUserReturn, f as UseAnalyticsOptions, g as UseAnalyticsReturn } from './index-2PnO4RAF.mjs';
|
|
10
|
-
export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, k as AuthLoginResponse, B as BatchTrackRequest, l as BillingPayment, m as BillingPayout, n as BillingRefund, o as BillingTransaction, C as ChangeEmailRequest, p as ChangePasswordRequest, q as ClientContext, r as ConnectedAccount, s as CookieLoginResponse, t as CookieOAuthCallbackResponse, D as DeviceFingerprint, u as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, K as KnownAccountInfo, v as LinkedAccount, w as ListFilesResponse, x as LoginDeviceInfo, y as LoginRequest, z as LoginResponseWithMFA, G as LoginRiskInfo, M as MFAChallengeResponse, H as MFAMethod, I as MFASMSSetupResponse, J as MFASetupRequest, N as MFAStatus, O as MFATOTPSetupResponse, P as MFAVerifyRequest, Q as OAuthCallbackRequest, R as OAuthCallbackResponse, T as OAuthConfig, V as OAuthProvider, W as OAuthStartResponse, X as PageViewData, Y as PayoutSchedule, Z as PhoneLoginRequest, _ as PhoneSendCodeRequest, $ as PhoneVerifyRequest, a0 as Profile, a1 as ProxyBearerLoginResponse, a2 as RefreshResponse, a3 as RegisterRequest, a4 as ResetPasswordRequest, a5 as ScaleMuleApiError, a6 as ScaleMuleEnvironment, a7 as Session, a8 as SignedUploadCompleteRequest, a9 as SignedUploadRequest, aa as SignedUploadResponse, ab as SignedUploadUrl, ac as StorageAdapter, ad as StorageFile, ae as TrackEventResponse, af as TransactionSummary, ag as UTMParams, ah as UpdateProfileRequest, ai as UploadOptions, aj as UploadResponse, ak as VerifyEmailRequest } from './index-2PnO4RAF.mjs';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Tri-state file visibility — `'private' | 'app_public' | 'anonymous_visible'`.
|
|
14
|
-
*
|
|
15
|
-
* Locally redeclared here rather than imported from `@scalemule/sdk`
|
|
16
|
-
* so this package can ship before the sdk's `Visibility` export is
|
|
17
|
-
* published. Once `@scalemule/sdk` ≥ the version that exports
|
|
18
|
-
* `Visibility` is the minimum dep version, swap this for an `import
|
|
19
|
-
* type { Visibility } from '@scalemule/sdk'`.
|
|
20
|
-
*
|
|
21
|
-
* Keep the union members in lockstep with the storage migration's
|
|
22
|
-
* ENUM and the SDK's typed export.
|
|
23
|
-
*/
|
|
24
|
-
type Visibility = 'private' | 'app_public' | 'anonymous_visible';
|
|
25
|
-
/**
|
|
26
|
-
* Result of a single {@link useMedia} upload call.
|
|
27
|
-
*
|
|
28
|
-
* The shape is normalized regardless of MIME type — `optimized_url_promise`
|
|
29
|
-
* resolves on image uploads after the photo optimizer finishes; for non-image
|
|
30
|
-
* uploads it resolves to `null` immediately. (Video / audio branches will
|
|
31
|
-
* populate `hls_url_promise` in later phases — today they fall through to
|
|
32
|
-
* generic storage and that field stays `null`.)
|
|
33
|
-
*/
|
|
34
|
-
interface MediaUploadResult {
|
|
35
|
-
/** Storage file_id — store this in chat-attachment metadata. */
|
|
36
|
-
file_id: string;
|
|
37
|
-
/** Photo service id — null for non-image uploads or when register() failed. */
|
|
38
|
-
photo_id: string | null;
|
|
39
|
-
/** Short-lived signed URL to the original bytes (private uploads) or
|
|
40
|
-
* a public CDN URL (when caller passed `is_public: true`). */
|
|
41
|
-
original_view_url: string | null;
|
|
42
|
-
/** Resolves once the photo optimizer finishes. `null` for non-image
|
|
43
|
-
* MIME types or when register() failed. */
|
|
44
|
-
optimized_url_promise: Promise<string | null>;
|
|
45
|
-
/** Resolves once the video transcoder finishes (Phase 2 / S5b). `null` today. */
|
|
46
|
-
hls_url_promise: Promise<string | null>;
|
|
47
|
-
/** The file's MIME type — preserved from the input File / Blob. */
|
|
48
|
-
mime_type: string;
|
|
49
|
-
/** Whether the resulting storage object is public-readable.
|
|
50
|
-
* Derived from `visibility !== 'private'` for back-compat with
|
|
51
|
-
* callers that still branch on the boolean. */
|
|
52
|
-
is_public: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Resolved tri-state visibility from the storage service. Use this
|
|
55
|
-
* over `is_public` for new code — `is_public: true` covers both
|
|
56
|
-
* `'app_public'` (auth-gated CDN) and `'anonymous_visible'`
|
|
57
|
-
* (unsigned public CDN), which have different delivery contracts.
|
|
58
|
-
*/
|
|
59
|
-
visibility: Visibility;
|
|
60
|
-
/**
|
|
61
|
-
* Stable unsigned public-CDN URL — populated only when
|
|
62
|
-
* `visibility === 'anonymous_visible'`. Drop directly into
|
|
63
|
-
* `<img src>` on logged-out pages. For other visibilities use
|
|
64
|
-
* `original_view_url` (signed) or the photo transform URL.
|
|
65
|
-
*/
|
|
66
|
-
cdn_url: string | null;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Per-app media-pipeline policy. Drives release-gating + processing
|
|
70
|
-
* behavior. **Orthogonal to `is_public`.** See
|
|
71
|
-
* `docs/MEDIA-UPLOADS.md` and ADR-2026-04-26 for the full taxonomy.
|
|
72
|
-
*
|
|
73
|
-
* Today's behavior (Phase 4 v1):
|
|
74
|
-
* - `fast_trusted` / `safe_visible` (default): upload promise resolves
|
|
75
|
-
* as soon as the file is uploaded + registered. The post-processing
|
|
76
|
-
* (scan, optimize, transcode) runs async; callers can observe via
|
|
77
|
-
* `useFileStatus`.
|
|
78
|
-
* - `safe_public` / `moderated`: upload promise *waits* for the
|
|
79
|
-
* optimized image variant (image MIME) or HLS playlist (video MIME)
|
|
80
|
-
* to become ready before resolving. Acts as the release-gate for
|
|
81
|
-
* UGC-style apps that should not publish raw bytes.
|
|
82
|
-
* - `compliance`: today behaves as `safe_public`; Phase 4+ adds the
|
|
83
|
-
* audit-log + signed-with-purpose URL semantics.
|
|
84
|
-
*/
|
|
85
|
-
type MediaPolicy = 'fast_trusted' | 'safe_visible' | 'safe_public' | 'moderated' | 'compliance';
|
|
86
|
-
interface UseMediaUploadOptions {
|
|
87
|
-
/**
|
|
88
|
-
* Tri-state visibility (preferred — see {@link Visibility} in
|
|
89
|
-
* `@scalemule/sdk`). Three modes:
|
|
90
|
-
* - `'private'` — owner + app members only (DEFAULT)
|
|
91
|
-
* - `'app_public'` — readable by any authenticated end-user
|
|
92
|
-
* in the same application; same semantics
|
|
93
|
-
* the legacy `is_public: true` flag has
|
|
94
|
-
* always had
|
|
95
|
-
* - `'anonymous_visible'` — world-readable on the unsigned public
|
|
96
|
-
* CDN. Returned `cdn_url` is safe to drop
|
|
97
|
-
* into `<img src>` on a logged-out page.
|
|
98
|
-
*
|
|
99
|
-
* If both `visibility` and `is_public` are passed, `visibility`
|
|
100
|
-
* wins. `'anonymous_visible'` requires the operator to have
|
|
101
|
-
* provisioned the anonymous-delivery bucket — the storage service
|
|
102
|
-
* surfaces 503 `ANONYMOUS_DELIVERY_NOT_CONFIGURED` otherwise (the
|
|
103
|
-
* SDK never silently demotes).
|
|
104
|
-
*/
|
|
105
|
-
visibility?: Visibility;
|
|
106
|
-
/**
|
|
107
|
-
* Legacy two-state visibility flag. `true` → `app_public`; `false`
|
|
108
|
-
* → `private`. Prefer the typed `visibility` field for new code —
|
|
109
|
-
* `is_public: true` cannot express `anonymous_visible`.
|
|
110
|
-
*
|
|
111
|
-
* Default: `false` (private). Public is opt-in for surfaces that
|
|
112
|
-
* genuinely need it (avatars, public listings). Chat / DM uploads
|
|
113
|
-
* should always be private.
|
|
114
|
-
*/
|
|
115
|
-
is_public?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Per-call media-policy override. Defaults to `safe_visible` (visible
|
|
118
|
-
* immediately at original fidelity; optimized variants swap in async).
|
|
119
|
-
* Set to `safe_public` to make the upload promise *await* the optimized
|
|
120
|
-
* variant (image) or HLS playlist (video) before resolving — useful for
|
|
121
|
-
* broadcast / UGC apps that gate publication on processing complete.
|
|
122
|
-
*
|
|
123
|
-
* The per-app default lives in `application_storage_settings.media_policy`
|
|
124
|
-
* (Phase 4 / P3, live in prod 2026-04-26). Reading the per-app default
|
|
125
|
-
* into `useMedia` defaults lands in a follow-up; today the option is
|
|
126
|
-
* caller-provided per call.
|
|
127
|
-
*/
|
|
128
|
-
policy?: MediaPolicy;
|
|
129
|
-
/** Display filename (sanitized server-side). */
|
|
130
|
-
filename?: string;
|
|
131
|
-
/** Custom metadata attached to the file. */
|
|
132
|
-
metadata?: Record<string, unknown>;
|
|
133
|
-
/** Upload progress callback (0-100). */
|
|
134
|
-
onProgress?: (percent: number) => void;
|
|
135
|
-
/** AbortSignal for cancellation. */
|
|
136
|
-
signal?: AbortSignal;
|
|
137
|
-
/** Force a non-photo path even for image MIME types — useful for
|
|
138
|
-
* generic file uploads where you don't want the photo optimizer
|
|
139
|
-
* to register the file. Default: `false`. */
|
|
140
|
-
skipPhotoRegister?: boolean;
|
|
141
|
-
}
|
|
142
|
-
interface UseMediaReturn {
|
|
143
|
-
/** Upload a file. MIME-aware: images go through photo register +
|
|
144
|
-
* optimization; everything else goes through generic storage. */
|
|
145
|
-
upload: (file: File | Blob, options?: UseMediaUploadOptions) => Promise<MediaUploadResult>;
|
|
146
|
-
/** Cancel an upload by its `file_id`. Deletes the storage object so
|
|
147
|
-
* it doesn't orphan in S3 — useful when a chat composer accepts a
|
|
148
|
-
* file but the user removes it before sending. Idempotent. */
|
|
149
|
-
cancelUpload: (fileId: string) => Promise<void>;
|
|
150
|
-
/** Last error from `upload` or `cancelUpload`. */
|
|
151
|
-
error: ApiError | null;
|
|
152
|
-
/** True while an upload is in progress. */
|
|
153
|
-
uploading: boolean;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Opinionated, MIME-aware media upload hook.
|
|
157
|
-
*
|
|
158
|
-
* `useMedia()` is the canonical upload primitive for chat / progressive
|
|
159
|
-
* media use. It branches by MIME type:
|
|
160
|
-
* - `image/*` → `client.photo.uploadViaStorage()` — upload to storage,
|
|
161
|
-
* then register with the photo service so the on-demand transform
|
|
162
|
-
* endpoint resolves to optimized variants. The returned
|
|
163
|
-
* `optimized_url_promise` resolves once the optimizer finishes.
|
|
164
|
-
* - everything else → `client.storage.uploadPrivate()` — a private,
|
|
165
|
-
* uncompressed, fail-closed upload to generic storage.
|
|
166
|
-
*
|
|
167
|
-
* **Default visibility is `is_public: false`.** Public is opt-in per call.
|
|
168
|
-
* `useMedia()` does not expose `is_public` via app-level config — visibility
|
|
169
|
-
* is always an explicit per-call surface choice.
|
|
170
|
-
*
|
|
171
|
-
* Compared to `useContent()`:
|
|
172
|
-
* - `useContent()` is a thin wrapper over generic storage and does not
|
|
173
|
-
* register photos / videos with their typed services. Use it for plain
|
|
174
|
-
* file uploads where you don't need optimization or transcoding.
|
|
175
|
-
* - `useMedia()` defaults to private + no compression, integrates with the
|
|
176
|
-
* typed media services automatically, and is the right primitive for
|
|
177
|
-
* anything chat- or media-shaped.
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```tsx
|
|
181
|
-
* 'use client';
|
|
182
|
-
*
|
|
183
|
-
* import { useMedia, ScaleMuleMedia } from '@scalemule/nextjs';
|
|
184
|
-
*
|
|
185
|
-
* function ChatComposer({ onAttach }) {
|
|
186
|
-
* const { upload, uploading } = useMedia();
|
|
187
|
-
*
|
|
188
|
-
* async function handlePick(file: File) {
|
|
189
|
-
* const result = await upload(file);
|
|
190
|
-
* onAttach({
|
|
191
|
-
* file_id: result.file_id,
|
|
192
|
-
* mime_type: result.mime_type,
|
|
193
|
-
* optimized_url_promise: result.optimized_url_promise,
|
|
194
|
-
* });
|
|
195
|
-
* }
|
|
196
|
-
*
|
|
197
|
-
* return <input type="file" disabled={uploading}
|
|
198
|
-
* onChange={(e) => e.target.files?.[0] && handlePick(e.target.files[0])} />;
|
|
199
|
-
* }
|
|
200
|
-
* ```
|
|
201
|
-
*
|
|
202
|
-
* See `docs/MEDIA-UPLOADS.md` in the platform repo for the decision
|
|
203
|
-
* tree and the full anti-patterns list.
|
|
204
|
-
*/
|
|
205
|
-
declare function useMedia(): UseMediaReturn;
|
|
206
|
-
|
|
207
|
-
interface SecurityChallenge {
|
|
208
|
-
method: 'email' | 'totp' | 'sms';
|
|
209
|
-
error?: string;
|
|
210
|
-
}
|
|
211
|
-
type SecurityChallengePrompt = (challenge: SecurityChallenge) => Promise<string | null>;
|
|
212
|
-
|
|
213
|
-
interface ScaleMuleContextValue {
|
|
214
|
-
requestSecurityCode: SecurityChallengePrompt;
|
|
215
|
-
/** The API client instance */
|
|
216
|
-
client: ScaleMuleClient;
|
|
217
|
-
/** Money client instance sharing the same session token */
|
|
218
|
-
money: MoneyClient;
|
|
219
|
-
/** Base SDK realtime service — shared singleton for WebSocket connections */
|
|
220
|
-
realtime: RealtimeService;
|
|
221
|
-
/** Base SDK storage service — exposed for `useMedia()` and direct chat-attachment uploads */
|
|
222
|
-
storage: StorageService;
|
|
223
|
-
/** Base SDK photo service — exposed for `useMedia()` and `photo.uploadViaStorage()` */
|
|
224
|
-
photo: PhotoService;
|
|
225
|
-
/** Base SDK video service — exposed for `useMedia()` and `video.uploadViaStorage()` */
|
|
226
|
-
video: VideoService;
|
|
227
|
-
/** Base SDK audio service — exposed for `useMedia()` and `audio.uploadViaStorage()` */
|
|
228
|
-
audio: AudioService;
|
|
229
|
-
/** Base SDK media facade — shared upload/list/delete surface across apps and scripts. */
|
|
230
|
-
media: unknown;
|
|
231
|
-
/** Base SDK TTS service — exposed for `useTtsJob()` and direct narration requests */
|
|
232
|
-
tts: TtsService;
|
|
233
|
-
/** Base SDK social graph service — follow graph, posts, feed, likes, and activity */
|
|
234
|
-
social: SocialService;
|
|
235
|
-
/** Base SDK social policy service — privacy decisions, requests, blocks, reports */
|
|
236
|
-
socialPolicy: SocialPolicyService;
|
|
237
|
-
/**
|
|
238
|
-
* Default media policy for `useMedia()` calls. Set via
|
|
239
|
-
* `<ScaleMuleProvider mediaPolicy="…">`; per-call overrides win.
|
|
240
|
-
* Undefined falls back to `useMedia()`'s built-in `safe_visible` default.
|
|
241
|
-
*/
|
|
242
|
-
mediaPolicy?: MediaPolicy;
|
|
243
|
-
/** Current authenticated user */
|
|
244
|
-
user: User | null;
|
|
245
|
-
/** Set the current user */
|
|
246
|
-
setUser: (user: User | null) => void;
|
|
247
|
-
/** Whether the SDK is initializing */
|
|
248
|
-
initializing: boolean;
|
|
249
|
-
/** Last error */
|
|
250
|
-
error: ApiError$1 | null;
|
|
251
|
-
/** Set error */
|
|
252
|
-
setError: (error: ApiError$1 | null) => void;
|
|
253
|
-
/** Analytics proxy URL (when set, SDK sends events here instead of ScaleMule) */
|
|
254
|
-
analyticsProxyUrl?: string;
|
|
255
|
-
/** Auth proxy URL (when set, auth operations route through this proxy) */
|
|
256
|
-
authProxyUrl?: string;
|
|
257
|
-
/** Publishable key for browser-safe operations (analytics) */
|
|
258
|
-
publishableKey?: string;
|
|
259
|
-
/**
|
|
260
|
-
* The configured `apiKey` value. Exposed so hooks like `useAnalytics`
|
|
261
|
-
* can detect the proxy-mode sentinel (`'proxy-mode'`) and warn when
|
|
262
|
-
* the corresponding proxy route is missing — silently 401'ing on the
|
|
263
|
-
* fallback is the worst possible failure mode for an analytics path.
|
|
264
|
-
* Treat as read-only diagnostic; consumers should not pass it onward.
|
|
265
|
-
*/
|
|
266
|
-
apiKey?: string;
|
|
267
|
-
/** Gateway URL for direct API calls */
|
|
268
|
-
gatewayUrl?: string;
|
|
269
|
-
/** Configured environment ('dev' or 'prod') */
|
|
270
|
-
environment?: string;
|
|
271
|
-
/** Whether the account switcher is enabled */
|
|
272
|
-
enableAccountSwitcher?: boolean;
|
|
273
|
-
/** Privacy level for account switcher */
|
|
274
|
-
accountSwitcherPrivacy?: string;
|
|
275
|
-
/** Server-evaluated flag values to bootstrap the client (eliminates loading flash) */
|
|
276
|
-
bootstrapFlags?: Record<string, unknown>;
|
|
277
|
-
}
|
|
278
|
-
interface ScaleMuleProviderProps extends ScaleMuleConfig {
|
|
279
|
-
/** Recovery link in the built-in security challenge. */
|
|
280
|
-
passwordRecoveryUrl?: string;
|
|
281
|
-
/** Optional custom adaptive verification UI. */
|
|
282
|
-
onSecurityChallenge?: SecurityChallengePrompt;
|
|
283
|
-
children: ReactNode;
|
|
284
|
-
/** Called when user logs in */
|
|
285
|
-
onLogin?: (user: User, response: LoginResponse) => void;
|
|
286
|
-
/** Called when user logs out */
|
|
287
|
-
onLogout?: () => void;
|
|
288
|
-
/** Called on authentication error */
|
|
289
|
-
onAuthError?: (error: ApiError$1) => void;
|
|
290
|
-
/** Server-evaluated flag values to bootstrap the client (eliminates loading flash) */
|
|
291
|
-
bootstrapFlags?: Record<string, unknown>;
|
|
292
|
-
/**
|
|
293
|
-
* Default media-pipeline policy applied to `useMedia()` calls when no
|
|
294
|
-
* per-call `policy` override is given. Five modes — see
|
|
295
|
-
* `docs/MEDIA-UPLOADS.md` and the {@link import('./hooks/useMedia').MediaPolicy} type.
|
|
296
|
-
*
|
|
297
|
-
* The platform stores the per-app policy in
|
|
298
|
-
* `application_storage_settings.media_policy` (Phase 4 / P3, live in
|
|
299
|
-
* prod). On boot, the provider fetches `GET /v1/storage/policy` (a
|
|
300
|
-
* lightweight `MemberOrEndUser` endpoint added in `@scalemule/sdk@0.0.45`)
|
|
301
|
-
* and uses the returned policy as the effective default.
|
|
302
|
-
*
|
|
303
|
-
* Passing this prop overrides the auto-fetched value — useful for
|
|
304
|
-
* tests or when an app needs to force a specific mode regardless of
|
|
305
|
-
* platform config.
|
|
306
|
-
*/
|
|
307
|
-
mediaPolicy?: MediaPolicy;
|
|
308
|
-
/**
|
|
309
|
-
* Member-auth bridge. When set, the provider runs in **member mode**:
|
|
310
|
-
*
|
|
311
|
-
* - Skips the `/v1/auth/me` end-user lookup and the auth-proxy
|
|
312
|
-
* `/me` flow. Identity is owned upstream (e.g. `MemberAuthProvider`
|
|
313
|
-
* in `web/scalemule-app`).
|
|
314
|
-
* - Calls `getToken()` on mount and propagates the returned token
|
|
315
|
-
* to all three SDK clients (`client`, `baseClient`, `money`) as a
|
|
316
|
-
* `Bearer` Authorization header. Returning `null` clears the token.
|
|
317
|
-
* - Re-polls every {@link memberTokenPollMs} milliseconds (default
|
|
318
|
-
* 60s) so cookie rotation in the host platform is picked up
|
|
319
|
-
* without a full page reload.
|
|
320
|
-
*
|
|
321
|
-
* Use {@link userResolver} alongside this prop to populate `user` from
|
|
322
|
-
* a member-auth endpoint instead of `/v1/auth/me`.
|
|
323
|
-
*
|
|
324
|
-
* Mutually exclusive with `authProxyUrl`. If both are set, `getToken`
|
|
325
|
-
* wins and the auth-proxy path is skipped.
|
|
326
|
-
*/
|
|
327
|
-
getToken?: () => string | null | Promise<string | null>;
|
|
328
|
-
/**
|
|
329
|
-
* Resolves the `User` shown to the app in member-auth mode. The
|
|
330
|
-
* provider calls this once after the initial token is set; the host
|
|
331
|
-
* platform typically just returns its own `MemberProfile` mapped to
|
|
332
|
-
* the SDK's `User` shape. Optional — if omitted, `user` stays `null`
|
|
333
|
-
* and the host platform is responsible for surfacing identity.
|
|
334
|
-
*/
|
|
335
|
-
userResolver?: () => Promise<User | null>;
|
|
336
|
-
/**
|
|
337
|
-
* Member-mode token poll interval in milliseconds. Default 60_000
|
|
338
|
-
* (1 minute). Pass `null` to disable polling (only the mount-time
|
|
339
|
-
* read happens).
|
|
340
|
-
*/
|
|
341
|
-
memberTokenPollMs?: number | null;
|
|
342
|
-
}
|
|
343
|
-
declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, sessionMode, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, getToken, userResolver, memberTokenPollMs, passwordRecoveryUrl, onSecurityChallenge, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
|
|
344
|
-
declare function useScaleMule(): ScaleMuleContextValue;
|
|
345
|
-
declare function useScaleMuleClient(): ScaleMuleClient;
|
|
346
|
-
declare function useMoneyClient(): MoneyClient;
|
|
347
|
-
|
|
348
|
-
declare function useAuth(): UseAuthReturn;
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Billing hook for ScaleMule marketplace payments
|
|
352
|
-
*
|
|
353
|
-
* Provides connected accounts, payments, refunds, payouts, and ledger queries.
|
|
354
|
-
*
|
|
355
|
-
* @example
|
|
356
|
-
* ```tsx
|
|
357
|
-
* function CreatorDashboard() {
|
|
358
|
-
* const {
|
|
359
|
-
* getMyConnectedAccount,
|
|
360
|
-
* getAccountBalance,
|
|
361
|
-
* getTransactionSummary,
|
|
362
|
-
* loading,
|
|
363
|
-
* } = useBilling()
|
|
364
|
-
*
|
|
365
|
-
* useEffect(() => {
|
|
366
|
-
* async function load() {
|
|
367
|
-
* const account = await getMyConnectedAccount()
|
|
368
|
-
* if (account) {
|
|
369
|
-
* const balance = await getAccountBalance(account.id)
|
|
370
|
-
* const summary = await getTransactionSummary()
|
|
371
|
-
* }
|
|
372
|
-
* }
|
|
373
|
-
* load()
|
|
374
|
-
* }, [])
|
|
375
|
-
* }
|
|
376
|
-
* ```
|
|
377
|
-
*/
|
|
378
|
-
declare function useBilling(): UseBillingReturn;
|
|
379
|
-
|
|
380
|
-
interface UseContentOptions {
|
|
381
|
-
/** Auto-fetch files on mount */
|
|
382
|
-
autoFetch?: boolean;
|
|
383
|
-
/** Initial list params */
|
|
384
|
-
initialParams?: ListFilesParams;
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Content/Storage hook for ScaleMule
|
|
388
|
-
*
|
|
389
|
-
* Provides file upload, listing, and deletion functionality.
|
|
390
|
-
* Automatically includes user ID for proper multi-tenancy.
|
|
391
|
-
*
|
|
392
|
-
* **For chat / progressive media use, prefer {@link useMedia} instead.**
|
|
393
|
-
* `useContent()` is a thin wrapper over generic storage and does NOT register
|
|
394
|
-
* uploaded images with the photo service or videos with the video service —
|
|
395
|
-
* so optimized thumbnails and HLS streaming don't light up automatically.
|
|
396
|
-
* It also defaults to `is_public: true` and compresses images by default;
|
|
397
|
-
* `useMedia()` defaults to private + uncompressed (the right choice for chat).
|
|
398
|
-
*
|
|
399
|
-
* Use `useContent()` for plain file gallery / browser surfaces where you
|
|
400
|
-
* want flat storage and no media pipeline integration. See
|
|
401
|
-
* `docs/MEDIA-UPLOADS.md` in the platform repo for the decision tree.
|
|
402
|
-
*
|
|
403
|
-
* @example
|
|
404
|
-
* ```tsx
|
|
405
|
-
* function Gallery() {
|
|
406
|
-
* const { files, upload, uploadProgress, loading } = useContent({ autoFetch: true })
|
|
407
|
-
*
|
|
408
|
-
* const handleUpload = async (e) => {
|
|
409
|
-
* const file = e.target.files[0]
|
|
410
|
-
* await upload(file, {
|
|
411
|
-
* onProgress: (progress) => console.log(`${progress}%`)
|
|
412
|
-
* })
|
|
413
|
-
* // Files list is automatically refreshed
|
|
414
|
-
* }
|
|
415
|
-
*
|
|
416
|
-
* // For large files, use signed upload
|
|
417
|
-
* const handleLargeUpload = async (file) => {
|
|
418
|
-
* const signedUrl = await getSignedUploadUrl({
|
|
419
|
-
* filename: file.name,
|
|
420
|
-
* content_type: file.type,
|
|
421
|
-
* size_bytes: file.size,
|
|
422
|
-
* })
|
|
423
|
-
* await uploadToSignedUrl(signedUrl.upload_url, file, signedUrl.required_headers)
|
|
424
|
-
* const result = await completeSignedUpload(signedUrl.file_id)
|
|
425
|
-
* }
|
|
426
|
-
*
|
|
427
|
-
* return (
|
|
428
|
-
* <div>
|
|
429
|
-
* <input type="file" onChange={handleUpload} />
|
|
430
|
-
* {uploadProgress !== null && <progress value={uploadProgress} max={100} />}
|
|
431
|
-
* {files.map(file => (
|
|
432
|
-
* <img key={file.id} src={file.url} alt={file.filename} />
|
|
433
|
-
* ))}
|
|
434
|
-
* </div>
|
|
435
|
-
* )
|
|
436
|
-
* }
|
|
437
|
-
* ```
|
|
438
|
-
*/
|
|
439
|
-
declare function useContent(options?: UseContentOptions): UseContentReturn;
|
|
440
|
-
|
|
441
|
-
interface AudioFile {
|
|
442
|
-
audio_id: string;
|
|
443
|
-
file_id: string;
|
|
444
|
-
filename: string;
|
|
445
|
-
mime_type: string;
|
|
446
|
-
size_bytes: number;
|
|
447
|
-
status: string;
|
|
448
|
-
codec: string | null;
|
|
449
|
-
bit_rate_kbps: number | null;
|
|
450
|
-
duration_ms: number | null;
|
|
451
|
-
created_at: string;
|
|
452
|
-
original_view_url: string | null;
|
|
453
|
-
transcoded_url: string | null;
|
|
454
|
-
waveform_peaks?: unknown;
|
|
455
|
-
}
|
|
456
|
-
interface UseAudioUploadOptions {
|
|
457
|
-
filename?: string;
|
|
458
|
-
metadata?: Record<string, unknown>;
|
|
459
|
-
onProgress?: (progress: number) => void;
|
|
460
|
-
signal?: AbortSignal;
|
|
461
|
-
}
|
|
462
|
-
interface AudioUploadResult {
|
|
463
|
-
file_id: string;
|
|
464
|
-
audio_id: string | null;
|
|
465
|
-
original_view_url: string | null;
|
|
466
|
-
transcoded_url_promise: Promise<string | null>;
|
|
467
|
-
}
|
|
468
|
-
interface UseAudioReturn {
|
|
469
|
-
upload: (file: File | Blob, opts?: UseAudioUploadOptions) => Promise<AudioUploadResult>;
|
|
470
|
-
list: () => Promise<AudioFile[]>;
|
|
471
|
-
remove: (fileId: string) => Promise<void>;
|
|
472
|
-
error: ApiError | null;
|
|
473
|
-
loading: boolean;
|
|
474
|
-
}
|
|
475
|
-
declare function useAudio(): UseAudioReturn;
|
|
476
|
-
|
|
477
|
-
interface UseTtsJobOptions {
|
|
478
|
-
enabled?: boolean;
|
|
479
|
-
pollIntervalMs?: number;
|
|
480
|
-
}
|
|
481
|
-
interface UseTtsJobReturn {
|
|
482
|
-
job: TtsJobStatus | null;
|
|
483
|
-
loading: boolean;
|
|
484
|
-
error: ApiError | null;
|
|
485
|
-
refresh: () => Promise<TtsJobStatus | null>;
|
|
486
|
-
}
|
|
487
|
-
declare function useTtsJob(jobId: string | null | undefined, options?: UseTtsJobOptions): UseTtsJobReturn;
|
|
488
|
-
|
|
489
|
-
type NarrationPlayerAudio = TtsAudioInfo & {
|
|
490
|
-
waveform_peaks?: number[] | null;
|
|
491
|
-
ai_generated?: boolean;
|
|
492
|
-
};
|
|
493
|
-
interface NarrationPlayerProps {
|
|
494
|
-
audio: NarrationPlayerAudio;
|
|
495
|
-
className?: string;
|
|
496
|
-
providerLabel?: string;
|
|
497
|
-
narrationLabel?: string;
|
|
498
|
-
refreshing?: boolean;
|
|
499
|
-
onRefresh?: () => void | Promise<void>;
|
|
500
|
-
/** @deprecated No-op: no manual Refresh control is ever shown. */
|
|
501
|
-
showRefreshButton?: boolean;
|
|
502
|
-
onPlaybackError?: () => void;
|
|
503
|
-
}
|
|
504
|
-
declare function NarrationPlayer({ audio, className, providerLabel, narrationLabel, refreshing, onRefresh, onPlaybackError, }: NarrationPlayerProps): react_jsx_runtime.JSX.Element | null;
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Conversation kinds recognized by the chat realtime channel naming scheme.
|
|
508
|
-
* Matches `broadcast_to_conversation` in `ms/scalemule-chat/src/realtime.rs`.
|
|
509
|
-
*/
|
|
510
|
-
type ConversationKind = 'standard' | 'large_room' | 'broadcast' | 'support';
|
|
511
|
-
interface UseFileStatusOptions {
|
|
512
|
-
/** Storage file_id to read status for. */
|
|
513
|
-
fileId: string | null | undefined;
|
|
514
|
-
/**
|
|
515
|
-
* Optional poll interval in milliseconds. If set, the hook re-fetches
|
|
516
|
-
* status every `pollIntervalMs` until scan goes clean. Useful for
|
|
517
|
-
* non-chat surfaces or as a fallback alongside `conversationId` push.
|
|
518
|
-
*/
|
|
519
|
-
pollIntervalMs?: number | null;
|
|
520
|
-
/** Disable the hook (don't fetch). Useful when `fileId` is conditional. */
|
|
521
|
-
disabled?: boolean;
|
|
522
|
-
/**
|
|
523
|
-
* Chat-surface push variant: subscribe to the conversation's realtime
|
|
524
|
-
* channel and refresh when a `file_status_changed` event arrives for
|
|
525
|
-
* `fileId`. Auth rides the existing per-conversation channel ACL.
|
|
526
|
-
*/
|
|
527
|
-
conversationId?: string | null;
|
|
528
|
-
/**
|
|
529
|
-
* Conversation kind, controls the channel name prefix:
|
|
530
|
-
* - `standard` (default) → `conversation:{id}`
|
|
531
|
-
* - `large_room` → `conversation:lr:{id}`
|
|
532
|
-
* - `broadcast` → `conversation:bc:{id}`
|
|
533
|
-
* - `support` → `conversation:support:{id}`
|
|
534
|
-
*
|
|
535
|
-
* If you only have a `messageId`, look up the conversation first via
|
|
536
|
-
* `client.chat.getMessage(messageId)` and pass the result here.
|
|
537
|
-
*/
|
|
538
|
-
conversationKind?: ConversationKind;
|
|
539
|
-
}
|
|
540
|
-
interface UseFileStatusReturn {
|
|
541
|
-
/** The latest status response, or null on first render / disabled. */
|
|
542
|
-
status: FileStatus | null;
|
|
543
|
-
/** True while a fetch is in flight. */
|
|
544
|
-
loading: boolean;
|
|
545
|
-
/** Last error, or null. */
|
|
546
|
-
error: ApiError | null;
|
|
547
|
-
/**
|
|
548
|
-
* Convenience: scan is clean. For images/videos, this means the file
|
|
549
|
-
* is *safe to render*; the optimized / HLS variants may still be
|
|
550
|
-
* processing. The caller should attempt the constructed URLs and
|
|
551
|
-
* fall back to `urls.original` if the pipeline-specific URL 404s.
|
|
552
|
-
*/
|
|
553
|
-
isReady: boolean;
|
|
554
|
-
/** Force-refresh the status. Promise resolves when the new state is committed. */
|
|
555
|
-
refresh: () => Promise<void>;
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* Subscribes to {@link FileStatus} for a single file.
|
|
559
|
-
*
|
|
560
|
-
* Three call shapes:
|
|
561
|
-
*
|
|
562
|
-
* 1. **Pull-only** — `useFileStatus({ fileId })` plus optional `pollIntervalMs`.
|
|
563
|
-
* One-shot fetch; useful for non-chat surfaces or static reads.
|
|
564
|
-
*
|
|
565
|
-
* 2. **Chat-surface push** — `useFileStatus({ fileId, conversationId, conversationKind? })`.
|
|
566
|
-
* Subscribes to the conversation channel and refreshes when
|
|
567
|
-
* `file_status_changed` arrives for this `fileId`. The chat service's
|
|
568
|
-
* media-status bridge fans photo/video lifecycle events into the per-conversation
|
|
569
|
-
* channel; the hook drops events for other files and dedupes against polling.
|
|
570
|
-
*
|
|
571
|
-
* 3. **Push + slow poll fallback** — combine `conversationId` with `pollIntervalMs`
|
|
572
|
-
* if you want belt-and-suspenders for environments where the websocket may drop.
|
|
573
|
-
*
|
|
574
|
-
* The `surface: 'profile'` push variant (private-user channel) is deferred until
|
|
575
|
-
* the realtime SDK exposes private-channel subscription by user.
|
|
576
|
-
*
|
|
577
|
-
* @example Chat surface (push)
|
|
578
|
-
* ```tsx
|
|
579
|
-
* function ChatImage({ fileId, conversationId }: { fileId: string; conversationId: string }) {
|
|
580
|
-
* const { status, isReady } = useFileStatus({ fileId, conversationId });
|
|
581
|
-
* if (!isReady) return <div>Scanning…</div>;
|
|
582
|
-
* const src = status?.urls.optimized ?? status?.urls.original;
|
|
583
|
-
* return <img src={src} />;
|
|
584
|
-
* }
|
|
585
|
-
* ```
|
|
586
|
-
*
|
|
587
|
-
* @example Non-chat surface (pull + poll)
|
|
588
|
-
* ```tsx
|
|
589
|
-
* const { status, isReady } = useFileStatus({ fileId, pollIntervalMs: 2000 });
|
|
590
|
-
* ```
|
|
591
|
-
*/
|
|
592
|
-
declare function useFileStatus(options: UseFileStatusOptions): UseFileStatusReturn;
|
|
593
|
-
|
|
594
|
-
interface ScaleMuleMediaProps {
|
|
595
|
-
/** Storage `file_id` of the media to render. Required. */
|
|
596
|
-
fileId: string;
|
|
597
|
-
/** MIME type — drives which element to render. Required. */
|
|
598
|
-
mimeType: string;
|
|
599
|
-
/**
|
|
600
|
-
* Optional sender-side optimistic preview. While the upload is in
|
|
601
|
-
* progress (or the recipient hasn't yet observed the message), the
|
|
602
|
-
* component renders this Blob URL. Once `useFileStatus` resolves a
|
|
603
|
-
* scan-clean state and a server-side URL, the component swaps to it.
|
|
604
|
-
*/
|
|
605
|
-
blobPreview?: string;
|
|
606
|
-
/** Display width hint (CSS pixels). Used for image breakpoint selection. */
|
|
607
|
-
width?: number;
|
|
608
|
-
/** Display height hint (CSS pixels). */
|
|
609
|
-
height?: number;
|
|
610
|
-
/** Pass-through className for the rendered element. */
|
|
611
|
-
className?: string;
|
|
612
|
-
/** Pass-through style. */
|
|
613
|
-
style?: React.CSSProperties;
|
|
614
|
-
/** Alt text for `<img>`; aria-label for `<audio>` / `<video>`. */
|
|
615
|
-
alt?: string;
|
|
616
|
-
/**
|
|
617
|
-
* Polling interval while waiting for the media pipeline to complete.
|
|
618
|
-
*
|
|
619
|
-
* Default behaviour:
|
|
620
|
-
* - With `conversationId` set: polling **off** (the realtime
|
|
621
|
-
* conversation channel pushes `file_status_changed` events;
|
|
622
|
-
* a poll loop on top would just be wasted requests).
|
|
623
|
-
* - Without `conversationId`: 2000ms.
|
|
624
|
-
*
|
|
625
|
-
* Override either way by passing a number (belt-and-suspenders if you
|
|
626
|
-
* don't trust your websocket) or `null` (disable explicitly).
|
|
627
|
-
* Polling stops automatically once both scan and any expected
|
|
628
|
-
* pipeline (optimize / transcode) have settled.
|
|
629
|
-
*/
|
|
630
|
-
pollIntervalMs?: number | null;
|
|
631
|
-
/**
|
|
632
|
-
* Chat-surface push: when set, the underlying `useFileStatus` hook
|
|
633
|
-
* subscribes to the conversation's realtime channel and refreshes on
|
|
634
|
-
* `file_status_changed` events for this `fileId`. See `useFileStatus`
|
|
635
|
-
* docs for channel naming and bridge behaviour.
|
|
636
|
-
*/
|
|
637
|
-
conversationId?: string | null;
|
|
638
|
-
/**
|
|
639
|
-
* Conversation kind, controls the channel name prefix
|
|
640
|
-
* (`conversation:{id}` vs `conversation:lr|bc|support:{id}`).
|
|
641
|
-
* Default is `'standard'`.
|
|
642
|
-
*/
|
|
643
|
-
conversationKind?: ConversationKind;
|
|
644
|
-
/**
|
|
645
|
-
* Render a custom placeholder while waiting for scan / upload. Defaults
|
|
646
|
-
* to a tiny "Loading…" div. Receives the current FileStatus (or null).
|
|
647
|
-
*/
|
|
648
|
-
renderPlaceholder?: () => React.ReactNode;
|
|
649
|
-
/**
|
|
650
|
-
* Render the "blocked" UI when scan flips to `threat`. Defaults to a
|
|
651
|
-
* "This file was blocked" message. Customize for branding.
|
|
652
|
-
*/
|
|
653
|
-
renderBlocked?: () => React.ReactNode;
|
|
654
|
-
/**
|
|
655
|
-
* Custom render override. If provided, the component still calls
|
|
656
|
-
* `useFileStatus` but yields rendering to this function. Useful for
|
|
657
|
-
* highly custom presentation (e.g. lightbox triggers, hover overlays).
|
|
658
|
-
*/
|
|
659
|
-
renderOverride?: (args: {
|
|
660
|
-
src: string | null;
|
|
661
|
-
state: 'preview' | 'pending' | 'ready' | 'blocked' | 'error';
|
|
662
|
-
}) => React.ReactNode;
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* Progressive-enhancement media renderer.
|
|
666
|
-
*
|
|
667
|
-
* Renders the right element for the given MIME type and progressively
|
|
668
|
-
* upgrades the source URL as the media pipeline advances:
|
|
669
|
-
*
|
|
670
|
-
* blob preview (if set) → original view URL → optimized variant (image)
|
|
671
|
-
* → HLS playlist (video)
|
|
672
|
-
*
|
|
673
|
-
* Today this is pull-only — `useFileStatus` polls until scan is clean
|
|
674
|
-
* (and the caller can stop polling by passing `pollIntervalMs={null}`).
|
|
675
|
-
* The push variant rides on the chat translation bridge (Phase 3 / P5')
|
|
676
|
-
* and lights up automatically once that ships.
|
|
677
|
-
*
|
|
678
|
-
* For non-Safari browsers, HLS playback requires `hls.js` to be
|
|
679
|
-
* available. The component dynamic-imports it on first need; if the
|
|
680
|
-
* import fails (not installed), it falls back to the original-bytes URL.
|
|
681
|
-
*
|
|
682
|
-
* @example
|
|
683
|
-
* ```tsx
|
|
684
|
-
* <ScaleMuleMedia
|
|
685
|
-
* fileId={attachment.file_id}
|
|
686
|
-
* mimeType={attachment.mime_type}
|
|
687
|
-
* width={520}
|
|
688
|
-
* blobPreview={pendingPreviewUrl}
|
|
689
|
-
* alt={attachment.filename}
|
|
690
|
-
* />
|
|
691
|
-
* ```
|
|
692
|
-
*/
|
|
693
|
-
declare function ScaleMuleMedia(props: ScaleMuleMediaProps): React.ReactElement | null;
|
|
694
|
-
|
|
695
|
-
declare const useMoney: typeof useMoneyClient;
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* User profile hook for ScaleMule
|
|
699
|
-
*
|
|
700
|
-
* Provides profile management, password changes, and account operations.
|
|
701
|
-
*
|
|
702
|
-
* @example
|
|
703
|
-
* ```tsx
|
|
704
|
-
* function ProfilePage() {
|
|
705
|
-
* const { profile, update, changePassword } = useUser()
|
|
706
|
-
*
|
|
707
|
-
* const handleUpdate = async () => {
|
|
708
|
-
* await update({ full_name: 'New Name' })
|
|
709
|
-
* }
|
|
710
|
-
* }
|
|
711
|
-
* ```
|
|
712
|
-
*/
|
|
713
|
-
declare function useUser(): UseUserReturn;
|
|
714
|
-
|
|
715
|
-
type RealtimeEvent = 'user.updated' | 'user.deleted' | 'session.expired' | 'file.uploaded' | 'file.deleted' | 'file.scanned' | 'notification' | string;
|
|
716
|
-
interface RealtimeMessage<T = unknown> {
|
|
717
|
-
event: RealtimeEvent;
|
|
718
|
-
data: T;
|
|
719
|
-
timestamp: string;
|
|
720
|
-
}
|
|
721
|
-
type RealtimeStatus = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
722
|
-
interface UseRealtimeOptions {
|
|
723
|
-
/** Channels to subscribe to */
|
|
724
|
-
channels?: string[];
|
|
725
|
-
/** Called when a message arrives on any subscribed channel */
|
|
726
|
-
onMessage?: (channel: string, data: unknown) => void;
|
|
727
|
-
/** Auto-connect on mount (default: true) — subscribing auto-connects */
|
|
728
|
-
autoConnect?: boolean;
|
|
729
|
-
}
|
|
730
|
-
interface UseRealtimeReturn {
|
|
731
|
-
/** Current connection status */
|
|
732
|
-
status: RealtimeStatus;
|
|
733
|
-
/** Last received message */
|
|
734
|
-
lastMessage: {
|
|
735
|
-
channel: string;
|
|
736
|
-
data: unknown;
|
|
737
|
-
} | null;
|
|
738
|
-
/** Manually disconnect */
|
|
739
|
-
disconnect: () => void;
|
|
740
|
-
/** Subscribe to an additional channel (auto-connects) */
|
|
741
|
-
subscribe: (channel: string, callback?: (data: unknown) => void) => () => void;
|
|
742
|
-
/** Publish data to a channel */
|
|
743
|
-
publish: (channel: string, data: unknown) => void;
|
|
744
|
-
}
|
|
745
|
-
/**
|
|
746
|
-
* Real-time updates hook via WebSocket.
|
|
747
|
-
*
|
|
748
|
-
* Uses the base SDK's RealtimeService (shared singleton created in the provider)
|
|
749
|
-
* to ensure correct protocol handling and single WebSocket connection per page.
|
|
750
|
-
*
|
|
751
|
-
* @example
|
|
752
|
-
* ```tsx
|
|
753
|
-
* function ChatNotifications() {
|
|
754
|
-
* const { status, lastMessage } = useRealtime({
|
|
755
|
-
* channels: ['chat:room-1', 'notifications'],
|
|
756
|
-
* onMessage: (channel, data) => {
|
|
757
|
-
* console.log(`${channel}:`, data)
|
|
758
|
-
* },
|
|
759
|
-
* })
|
|
760
|
-
*
|
|
761
|
-
* return <div>Status: {status}</div>
|
|
762
|
-
* }
|
|
763
|
-
* ```
|
|
764
|
-
*/
|
|
765
|
-
declare function useRealtime(options?: UseRealtimeOptions): UseRealtimeReturn;
|
|
766
|
-
|
|
767
|
-
/**
|
|
768
|
-
* Analytics hook for ScaleMule
|
|
769
|
-
*
|
|
770
|
-
* Provides event tracking, page views, and user identification.
|
|
771
|
-
* Automatically handles session management, UTM capture, and device detection.
|
|
772
|
-
*
|
|
773
|
-
* @example
|
|
774
|
-
* ```tsx
|
|
775
|
-
* function App() {
|
|
776
|
-
* const { trackEvent, trackPageView } = useAnalytics()
|
|
777
|
-
*
|
|
778
|
-
* // Track page views automatically on mount
|
|
779
|
-
* useEffect(() => {
|
|
780
|
-
* trackPageView()
|
|
781
|
-
* }, [trackPageView])
|
|
782
|
-
*
|
|
783
|
-
* // Track custom events
|
|
784
|
-
* const handleClick = async () => {
|
|
785
|
-
* await trackEvent({
|
|
786
|
-
* event_name: 'button_clicked',
|
|
787
|
-
* event_category: 'engagement',
|
|
788
|
-
* properties: { button_id: 'cta_signup' }
|
|
789
|
-
* })
|
|
790
|
-
* }
|
|
791
|
-
*
|
|
792
|
-
* return <button onClick={handleClick}>Sign Up</button>
|
|
793
|
-
* }
|
|
794
|
-
* ```
|
|
795
|
-
*
|
|
796
|
-
* @example
|
|
797
|
-
* ```tsx
|
|
798
|
-
* // Full tracking with user identification
|
|
799
|
-
* function App() {
|
|
800
|
-
* const { trackEvent, identify, reset } = useAnalytics()
|
|
801
|
-
* const { user, login, logout } = useAuth()
|
|
802
|
-
*
|
|
803
|
-
* // Identify user after login
|
|
804
|
-
* const handleLogin = async (credentials) => {
|
|
805
|
-
* const result = await login(credentials)
|
|
806
|
-
* await identify(result.user.id, { email: result.user.email })
|
|
807
|
-
* }
|
|
808
|
-
*
|
|
809
|
-
* // Reset on logout
|
|
810
|
-
* const handleLogout = async () => {
|
|
811
|
-
* await logout()
|
|
812
|
-
* reset()
|
|
813
|
-
* }
|
|
814
|
-
* }
|
|
815
|
-
* ```
|
|
816
|
-
*/
|
|
817
|
-
declare function useAnalytics(options?: UseAnalyticsOptions): UseAnalyticsReturn;
|
|
818
|
-
|
|
819
|
-
interface FeatureFlagEvaluation<T = unknown> {
|
|
820
|
-
flag_id: string;
|
|
821
|
-
flag_key: string;
|
|
822
|
-
environment: string;
|
|
823
|
-
value: T;
|
|
824
|
-
reason: string;
|
|
825
|
-
matched_rule_id?: string | null;
|
|
826
|
-
variant_key?: string | null;
|
|
827
|
-
bucket?: number | null;
|
|
828
|
-
}
|
|
829
|
-
interface UseFeatureFlagsOptions {
|
|
830
|
-
environment?: string;
|
|
831
|
-
context?: Record<string, unknown>;
|
|
832
|
-
keys?: string[];
|
|
833
|
-
enabled?: boolean;
|
|
834
|
-
}
|
|
835
|
-
interface UseFeatureFlagsReturn {
|
|
836
|
-
flags: Record<string, FeatureFlagEvaluation>;
|
|
837
|
-
loading: boolean;
|
|
838
|
-
error: ApiError$1 | null;
|
|
839
|
-
refresh: () => Promise<void>;
|
|
840
|
-
isEnabled: (flagKey: string, fallback?: boolean) => boolean;
|
|
841
|
-
getFlag: <T = unknown>(flagKey: string, fallback?: T) => T;
|
|
842
|
-
}
|
|
843
|
-
declare function useFeatureFlags(options?: UseFeatureFlagsOptions): UseFeatureFlagsReturn;
|
|
844
|
-
|
|
845
|
-
interface UsePushNotificationsOptions {
|
|
846
|
-
/** Service worker URL (default: '/sw.js') */
|
|
847
|
-
serviceWorkerUrl?: string;
|
|
848
|
-
/** Push proxy URL (default: '/api/push') */
|
|
849
|
-
pushProxyUrl?: string;
|
|
850
|
-
/** Where the user subscribed (e.g., 'landing_prompt', 'post_signup', 'settings') */
|
|
851
|
-
registrationSource?: string;
|
|
852
|
-
/** Called when a push notification is received while app is in foreground */
|
|
853
|
-
onNotification?: (data: unknown) => void;
|
|
854
|
-
}
|
|
855
|
-
interface UsePushNotificationsReturn {
|
|
856
|
-
/** Whether the browser supports Web Push */
|
|
857
|
-
isSupported: boolean;
|
|
858
|
-
/** Current notification permission state */
|
|
859
|
-
permission: NotificationPermission | 'unsupported';
|
|
860
|
-
/** Whether push is currently subscribed */
|
|
861
|
-
isSubscribed: boolean;
|
|
862
|
-
/** Whether an operation is in progress */
|
|
863
|
-
isLoading: boolean;
|
|
864
|
-
/** Last error */
|
|
865
|
-
error: ApiError$1 | null;
|
|
866
|
-
/** Request permission and subscribe to push notifications */
|
|
867
|
-
subscribe: () => Promise<void>;
|
|
868
|
-
/** Unsubscribe from push notifications */
|
|
869
|
-
unsubscribe: () => Promise<void>;
|
|
870
|
-
/** Clear user association (call before logout) */
|
|
871
|
-
disassociateUser: () => Promise<void>;
|
|
872
|
-
/** The push token ID from backend registration */
|
|
873
|
-
tokenId: string | null;
|
|
874
|
-
}
|
|
875
|
-
declare function usePushNotifications(options?: UsePushNotificationsOptions): UsePushNotificationsReturn;
|
|
876
|
-
|
|
877
|
-
interface UseShareOptions {
|
|
878
|
-
/** The canonical URL to share. Defaults to current page URL.
|
|
879
|
-
* IMPORTANT: Pass the content's canonical URL, not window.location.href,
|
|
880
|
-
* to avoid re-sharing someone else's referral code. */
|
|
881
|
-
url?: string;
|
|
882
|
-
/** Manual referral code override (skips fetch) */
|
|
883
|
-
referralCode?: string;
|
|
884
|
-
/** Auto-fetch referral code from /v1/referrals/me when authenticated */
|
|
885
|
-
autoFetchReferral?: boolean;
|
|
886
|
-
}
|
|
887
|
-
interface UseShareReturn {
|
|
888
|
-
/** Share URL — absolute, with ?rc= appended if referral code available */
|
|
889
|
-
shareUrl: string;
|
|
890
|
-
/** User's referral code, or null if unauthenticated/not fetched */
|
|
891
|
-
referralCode: string | null;
|
|
892
|
-
/** Copy shareUrl to clipboard. Returns true on success. */
|
|
893
|
-
copyLink: () => Promise<boolean>;
|
|
894
|
-
/** Whether link was recently copied (auto-resets after 2s) */
|
|
895
|
-
copied: boolean;
|
|
896
|
-
/** Loading state for referral code fetch */
|
|
897
|
-
loading: boolean;
|
|
898
|
-
}
|
|
899
|
-
declare function useShare(options?: UseShareOptions): UseShareReturn;
|
|
900
|
-
|
|
901
|
-
/**
|
|
902
|
-
* Public types for the feedback hook + widget.
|
|
903
|
-
*
|
|
904
|
-
* Mirrors the JSON shape returned by `scalemule-feedback`'s public endpoints
|
|
905
|
-
* (`/v1/feedback/submit`, `/v1/feedback/items`). Dashboard/admin shapes live
|
|
906
|
-
* server-side and are not exported here — customer apps interact with the
|
|
907
|
-
* SDK only through the end-user surface.
|
|
908
|
-
*/
|
|
909
|
-
type FeedbackType = 'bug_report' | 'feature_request' | 'improvement' | 'other';
|
|
910
|
-
type FeedbackStatus = 'new' | 'reviewed' | 'planned' | 'in_progress' | 'completed' | 'declined';
|
|
911
|
-
type FeedbackPriority = 'low' | 'medium' | 'high' | 'urgent';
|
|
912
|
-
/**
|
|
913
|
-
* The end-user-visible shape of a feedback item. Excludes staff-only fields
|
|
914
|
-
* (assigned_to, internal_notes, email of OTHER users, etc.) that the service
|
|
915
|
-
* never returns through `/items`.
|
|
916
|
-
*/
|
|
917
|
-
interface FeedbackItem {
|
|
918
|
-
id: string;
|
|
919
|
-
type: FeedbackType;
|
|
920
|
-
title: string;
|
|
921
|
-
description: string;
|
|
922
|
-
status: FeedbackStatus;
|
|
923
|
-
priority: FeedbackPriority;
|
|
924
|
-
tags: string[] | null;
|
|
925
|
-
created_at: string;
|
|
926
|
-
updated_at: string;
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* Public widget configuration returned by `GET /v1/feedback/widget-config`.
|
|
930
|
-
* The SDK uses this to drive runtime widget behavior per application.
|
|
931
|
-
*/
|
|
932
|
-
interface FeedbackWidgetConfig {
|
|
933
|
-
enabled: boolean;
|
|
934
|
-
allow_anonymous: boolean;
|
|
935
|
-
widget_theme: 'light' | 'dark' | 'auto';
|
|
936
|
-
widget_position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
937
|
-
allowed_types: FeedbackType[] | null;
|
|
938
|
-
}
|
|
939
|
-
/**
|
|
940
|
-
* Body for `POST /v1/feedback/submit`.
|
|
941
|
-
*
|
|
942
|
-
* `email` is required when no end-user session is present — the gateway omits
|
|
943
|
-
* `x-user-id` in that case and the service rejects with 400 unless email is
|
|
944
|
-
* given. When a session exists, email is optional.
|
|
945
|
-
*/
|
|
946
|
-
interface FeedbackItemInput {
|
|
947
|
-
type: FeedbackType;
|
|
948
|
-
title: string;
|
|
949
|
-
description: string;
|
|
950
|
-
email?: string;
|
|
951
|
-
tags?: string[];
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
interface UseFeedbackOptions {
|
|
955
|
-
/** Optional status filter applied to the list call. */
|
|
956
|
-
status?: FeedbackStatus;
|
|
957
|
-
/** Optional type filter. */
|
|
958
|
-
type?: FeedbackType;
|
|
959
|
-
/** When false, suppress the initial list fetch (the widget submits without listing). */
|
|
960
|
-
enabled?: boolean;
|
|
961
|
-
}
|
|
962
|
-
interface UseFeedbackResult {
|
|
963
|
-
/** End-user's own feedback items for the current tenant. Empty when not signed in. */
|
|
964
|
-
items: FeedbackItem[];
|
|
965
|
-
loading: boolean;
|
|
966
|
-
error: ApiError$1 | null;
|
|
967
|
-
/** Submit a new feedback item. Returns the persisted item on success. */
|
|
968
|
-
submit: (input: FeedbackItemInput) => Promise<FeedbackItem>;
|
|
969
|
-
/** Re-fetch the list. */
|
|
970
|
-
refresh: () => Promise<void>;
|
|
971
|
-
}
|
|
972
|
-
/**
|
|
973
|
-
* Hook for end-user feedback submission and read-own.
|
|
974
|
-
*
|
|
975
|
-
* Calls go through `client` from `ScaleMuleProvider`, which attaches the
|
|
976
|
-
* configured API key and (when present) the user session token. Tenancy
|
|
977
|
-
* (`x-app-id`) is derived by the gateway from the API key — never set
|
|
978
|
-
* client-side.
|
|
979
|
-
*/
|
|
980
|
-
declare function useFeedback(options?: UseFeedbackOptions): UseFeedbackResult;
|
|
981
|
-
|
|
982
|
-
interface VoteState {
|
|
983
|
-
/** Caller's current vote: 1 = upvote, -1 = downvote, 0 = no vote. */
|
|
984
|
-
value: 1 | -1 | 0;
|
|
985
|
-
up_count: number;
|
|
986
|
-
down_count: number;
|
|
987
|
-
score: number;
|
|
988
|
-
}
|
|
989
|
-
interface UseVoteOptions {
|
|
990
|
-
/** Application-defined target type. e.g. "weekmob_post", "gistyo_gist". */
|
|
991
|
-
targetType: string;
|
|
992
|
-
targetId: string;
|
|
993
|
-
/** Optional seed (from SSR or list query). */
|
|
994
|
-
initialState?: VoteState | null;
|
|
995
|
-
/** Refetch even when initialState is provided. Default false. */
|
|
996
|
-
refetchOnMount?: boolean;
|
|
997
|
-
/** Skip the initial fetch entirely (anonymous viewers). Default true. */
|
|
998
|
-
enabled?: boolean;
|
|
999
|
-
}
|
|
1000
|
-
interface UseVoteReturn {
|
|
1001
|
-
state: VoteState;
|
|
1002
|
-
isLoading: boolean;
|
|
1003
|
-
error: Error | null;
|
|
1004
|
-
/** Cast (or change/clear) the caller's vote with optimistic update. */
|
|
1005
|
-
cast: (value: 1 | -1 | 0) => Promise<void>;
|
|
1006
|
-
/** Refetch the canonical state from the server. */
|
|
1007
|
-
refetch: () => Promise<void>;
|
|
1008
|
-
}
|
|
1009
|
-
declare function useVote({ targetType, targetId, initialState, refetchOnMount, enabled, }: UseVoteOptions): UseVoteReturn;
|
|
1010
|
-
|
|
1011
|
-
interface FeedbackWidgetProps {
|
|
1012
|
-
/** Floating-button corner. Default `bottom-right`. */
|
|
1013
|
-
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
1014
|
-
/** Default selected type when the modal opens. Default `feature_request`. */
|
|
1015
|
-
defaultType?: FeedbackType;
|
|
1016
|
-
/** Restrict the type select to this subset. Default: all four types. */
|
|
1017
|
-
allowedTypes?: FeedbackType[];
|
|
1018
|
-
/** Trigger button label. Default `Feedback`. */
|
|
1019
|
-
triggerLabel?: string;
|
|
1020
|
-
/** `light`/`dark`/`auto` (matches OS). Default `auto`. */
|
|
1021
|
-
theme?: 'light' | 'dark' | 'auto';
|
|
1022
|
-
/** Optional class for the trigger button (use to override styling). */
|
|
1023
|
-
className?: string;
|
|
1024
|
-
/** Show the 1–5 star rating row. Default `true`. Rating is stored as a
|
|
1025
|
-
* `rating:N` tag on the feedback item — staff can filter on it from the
|
|
1026
|
-
* dashboard inbox. Optional per submission; users who skip it just submit
|
|
1027
|
-
* without a rating. */
|
|
1028
|
-
enableRating?: boolean;
|
|
1029
|
-
/** Label for the rating row when enabled. Default `How would you rate
|
|
1030
|
-
* your experience?`. */
|
|
1031
|
-
ratingLabel?: string;
|
|
1032
|
-
/** Called after a successful submit. */
|
|
1033
|
-
onSubmitted?: (item: FeedbackItem) => void;
|
|
1034
|
-
}
|
|
1035
|
-
/**
|
|
1036
|
-
* Floating feedback widget. Renders nothing until the trigger is clicked,
|
|
1037
|
-
* then opens a small modal with type / title / description fields. Submits
|
|
1038
|
-
* via `useFeedback().submit()` — inherits identity from `ScaleMuleProvider`.
|
|
1039
|
-
*
|
|
1040
|
-
* If the end-user is not signed in, the widget shows an additional `email`
|
|
1041
|
-
* field (required by the service for anonymous submissions).
|
|
1042
|
-
*
|
|
1043
|
-
* Tenant must have `feedback_app_config.enabled = TRUE` for `/submit` to
|
|
1044
|
-
* accept submissions; otherwise the service responds with 404
|
|
1045
|
-
* `FEEDBACK_DISABLED` and the widget surfaces the error message.
|
|
1046
|
-
*/
|
|
1047
|
-
declare function FeedbackWidget(props: FeedbackWidgetProps): ReactElement | null;
|
|
1048
|
-
|
|
1049
|
-
interface VoteButtonClassNames {
|
|
1050
|
-
root?: string;
|
|
1051
|
-
upButton?: string;
|
|
1052
|
-
upButtonActive?: string;
|
|
1053
|
-
downButton?: string;
|
|
1054
|
-
downButtonActive?: string;
|
|
1055
|
-
score?: string;
|
|
1056
|
-
scorePositive?: string;
|
|
1057
|
-
scoreNegative?: string;
|
|
1058
|
-
}
|
|
1059
|
-
interface VoteButtonProps {
|
|
1060
|
-
targetType: string;
|
|
1061
|
-
targetId: string;
|
|
1062
|
-
/** Server-known initial state, e.g. seeded from a list query. */
|
|
1063
|
-
initialState?: VoteState | null;
|
|
1064
|
-
/** Visual layout. "horizontal" = up | score | down. "stacked" = column. */
|
|
1065
|
-
layout?: 'horizontal' | 'stacked';
|
|
1066
|
-
size?: 'compact' | 'regular';
|
|
1067
|
-
/** Called when an anonymous user clicks vote. */
|
|
1068
|
-
onSignInRequired?: () => void;
|
|
1069
|
-
onError?: (error: unknown) => void;
|
|
1070
|
-
classNames?: VoteButtonClassNames;
|
|
1071
|
-
upLabel?: string;
|
|
1072
|
-
downLabel?: string;
|
|
1073
|
-
}
|
|
1074
|
-
declare function VoteButton({ targetType, targetId, initialState, layout, size, onSignInRequired, onError, classNames, upLabel, downLabel, }: VoteButtonProps): react_jsx_runtime.JSX.Element;
|
|
1075
|
-
|
|
1076
|
-
/**
|
|
1077
|
-
* Client-side validation helpers
|
|
1078
|
-
*
|
|
1079
|
-
* These validators match ScaleMule backend validation rules exactly.
|
|
1080
|
-
* Use them for instant user feedback - the backend still validates all input.
|
|
1081
|
-
*
|
|
1082
|
-
* @example
|
|
1083
|
-
* ```tsx
|
|
1084
|
-
* import { validators } from '@scalemule/nextjs'
|
|
1085
|
-
*
|
|
1086
|
-
* function RegisterForm() {
|
|
1087
|
-
* const [email, setEmail] = useState('')
|
|
1088
|
-
* const [password, setPassword] = useState('')
|
|
1089
|
-
*
|
|
1090
|
-
* const emailValid = validators.email(email)
|
|
1091
|
-
* const passwordResult = validators.password(password)
|
|
1092
|
-
*
|
|
1093
|
-
* return (
|
|
1094
|
-
* <form>
|
|
1095
|
-
* <input
|
|
1096
|
-
* type="email"
|
|
1097
|
-
* value={email}
|
|
1098
|
-
* onChange={(e) => setEmail(e.target.value)}
|
|
1099
|
-
* className={emailValid ? 'valid' : 'invalid'}
|
|
1100
|
-
* />
|
|
1101
|
-
* <input
|
|
1102
|
-
* type="password"
|
|
1103
|
-
* value={password}
|
|
1104
|
-
* onChange={(e) => setPassword(e.target.value)}
|
|
1105
|
-
* />
|
|
1106
|
-
* {passwordResult.errors.map((err) => (
|
|
1107
|
-
* <span key={err} className="error">{err}</span>
|
|
1108
|
-
* ))}
|
|
1109
|
-
* </form>
|
|
1110
|
-
* )
|
|
1111
|
-
* }
|
|
1112
|
-
* ```
|
|
1113
|
-
*/
|
|
1114
|
-
interface PasswordValidationResult {
|
|
1115
|
-
valid: boolean;
|
|
1116
|
-
errors: string[];
|
|
1117
|
-
strength: 'weak' | 'fair' | 'good' | 'strong';
|
|
1118
|
-
}
|
|
1119
|
-
interface PhoneValidationResult {
|
|
1120
|
-
valid: boolean;
|
|
1121
|
-
formatted: string | null;
|
|
1122
|
-
error: string | null;
|
|
1123
|
-
}
|
|
1124
|
-
interface PhoneCountry {
|
|
1125
|
-
code: string;
|
|
1126
|
-
name: string;
|
|
1127
|
-
dialCode: string;
|
|
1128
|
-
}
|
|
1129
|
-
declare const phoneCountries: PhoneCountry[];
|
|
1130
|
-
interface UsernameValidationResult {
|
|
1131
|
-
valid: boolean;
|
|
1132
|
-
error: string | null;
|
|
1133
|
-
}
|
|
1134
|
-
declare function normalizePhone(input: string): string;
|
|
1135
|
-
declare function composePhone(countryDialCode: string, localNumber: string): string;
|
|
1136
|
-
/**
|
|
1137
|
-
* Validation helpers matching ScaleMule backend rules.
|
|
1138
|
-
* These provide instant feedback - backend is always the source of truth.
|
|
1139
|
-
*/
|
|
1140
|
-
declare const validators: {
|
|
1141
|
-
/**
|
|
1142
|
-
* Validate email address format.
|
|
1143
|
-
* Matches RFC 5322 simplified pattern used by ScaleMule backend.
|
|
1144
|
-
*/
|
|
1145
|
-
email: (email: string) => boolean;
|
|
1146
|
-
/**
|
|
1147
|
-
* Validate password strength.
|
|
1148
|
-
* Returns detailed result with errors and strength indicator.
|
|
1149
|
-
*/
|
|
1150
|
-
password: (password: string) => PasswordValidationResult;
|
|
1151
|
-
/**
|
|
1152
|
-
* Validate phone number in E.164 format.
|
|
1153
|
-
* ScaleMule requires E.164 format: +[country code][number]
|
|
1154
|
-
*/
|
|
1155
|
-
phone: (phone: string) => PhoneValidationResult;
|
|
1156
|
-
/**
|
|
1157
|
-
* Validate username format.
|
|
1158
|
-
* Alphanumeric with underscores, 3-30 characters.
|
|
1159
|
-
*/
|
|
1160
|
-
username: (username: string) => UsernameValidationResult;
|
|
1161
|
-
/**
|
|
1162
|
-
* Validate UUID format.
|
|
1163
|
-
* Accepts UUIDv1, v4, v7 formats.
|
|
1164
|
-
*/
|
|
1165
|
-
uuid: (uuid: string) => boolean;
|
|
1166
|
-
/**
|
|
1167
|
-
* Validate URL format.
|
|
1168
|
-
*/
|
|
1169
|
-
url: (url: string) => boolean;
|
|
1170
|
-
/**
|
|
1171
|
-
* Validate file size against ScaleMule limits.
|
|
1172
|
-
* Default max is 100MB, can be customized per application.
|
|
1173
|
-
*/
|
|
1174
|
-
fileSize: (bytes: number, maxMB?: number) => {
|
|
1175
|
-
valid: boolean;
|
|
1176
|
-
error: string | null;
|
|
1177
|
-
};
|
|
1178
|
-
/**
|
|
1179
|
-
* Validate file type against allowed MIME types.
|
|
1180
|
-
*/
|
|
1181
|
-
fileType: (mimeType: string, allowed?: string[]) => {
|
|
1182
|
-
valid: boolean;
|
|
1183
|
-
error: string | null;
|
|
1184
|
-
};
|
|
1185
|
-
/**
|
|
1186
|
-
* Sanitize and validate a display name.
|
|
1187
|
-
*/
|
|
1188
|
-
displayName: (name: string) => {
|
|
1189
|
-
valid: boolean;
|
|
1190
|
-
sanitized: string;
|
|
1191
|
-
error: string | null;
|
|
1192
|
-
};
|
|
1193
|
-
};
|
|
1194
|
-
/**
|
|
1195
|
-
* Validate multiple fields at once.
|
|
1196
|
-
* Returns a map of field names to error messages.
|
|
1197
|
-
*/
|
|
1198
|
-
declare function validateForm<T extends Record<string, unknown>>(data: T, rules: Partial<Record<keyof T, (value: unknown) => boolean | {
|
|
1199
|
-
valid: boolean;
|
|
1200
|
-
error?: string | null;
|
|
1201
|
-
}>>): {
|
|
1202
|
-
valid: boolean;
|
|
1203
|
-
errors: Partial<Record<keyof T, string>>;
|
|
1204
|
-
};
|
|
1205
|
-
/**
|
|
1206
|
-
* Sanitize an object for safe logging.
|
|
1207
|
-
* Redacts values of keys that may contain sensitive data.
|
|
1208
|
-
*
|
|
1209
|
-
* @example
|
|
1210
|
-
* ```typescript
|
|
1211
|
-
* const data = { email: 'user@example.com', password: 'secret123' }
|
|
1212
|
-
* console.log(sanitizeForLog(data))
|
|
1213
|
-
* // { email: 'user@example.com', password: '[REDACTED]' }
|
|
1214
|
-
* ```
|
|
1215
|
-
*/
|
|
1216
|
-
declare function sanitizeForLog(data: unknown): unknown;
|
|
1217
|
-
/**
|
|
1218
|
-
* Create a safe logger that automatically sanitizes data.
|
|
1219
|
-
*
|
|
1220
|
-
* @example
|
|
1221
|
-
* ```typescript
|
|
1222
|
-
* const log = createSafeLogger('[MyApp]')
|
|
1223
|
-
* log.info('User login', { email: 'user@example.com', password: 'secret' })
|
|
1224
|
-
* // [MyApp] User login { email: 'user@example.com', password: '[REDACTED]' }
|
|
1225
|
-
* ```
|
|
1226
|
-
*/
|
|
1227
|
-
declare function createSafeLogger(prefix: string): {
|
|
1228
|
-
log: (message: string, data?: unknown) => void;
|
|
1229
|
-
info: (message: string, data?: unknown) => void;
|
|
1230
|
-
warn: (message: string, data?: unknown) => void;
|
|
1231
|
-
error: (message: string, data?: unknown) => void;
|
|
1232
|
-
};
|
|
1233
|
-
|
|
1234
|
-
export { ApiError$1 as ApiError, type AudioFile, type AudioUploadResult, type ConversationKind, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetConfig, type FeedbackWidgetProps, ListFilesParams, LoginResponse, type MediaPolicy, type MediaUploadResult, NarrationPlayer, type NarrationPlayerAudio, type NarrationPlayerProps, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleMedia, type ScaleMuleMediaProps, ScaleMuleProvider, type ScaleMuleProviderProps, type SecurityChallenge, type SecurityChallengePrompt, UseAnalyticsOptions, UseAnalyticsReturn, type UseAudioReturn, type UseAudioUploadOptions, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFileStatusOptions, type UseFileStatusReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseMediaReturn, type UseMediaUploadOptions, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, type UseTtsJobOptions, type UseTtsJobReturn, UseUserReturn, type UseVoteOptions, type UseVoteReturn, User, type UsernameValidationResult, VoteButton, type VoteButtonClassNames, type VoteButtonProps, type VoteState, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAudio, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useTtsJob, useUser, useVote, validateForm, validators };
|