@scalemule/nextjs 0.1.24 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,27 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ApiError, RealtimeService, StorageService, PhotoService, VideoService, AudioService, TtsService, TtsJobStatus, FileStatus, TtsAudioInfo } from '@scalemule/sdk';
2
+ import { ApiError, RealtimeService, StorageService, PhotoService, VideoService, AudioService, TtsService, TtsJobStatus, FileStatus } from '@scalemule/sdk';
3
3
  import * as React from 'react';
4
4
  import { ReactNode, ReactElement } from 'react';
5
5
  import { MoneyClient } from '@scalemule/money';
6
6
  export { MoneyClient, MoneyClientConfig, createMoneyClient } from '@scalemule/money';
7
7
  import { ScaleMuleClient } from './client.js';
8
8
  export { ClientConfig, RequestOptions, createClient } from './client.js';
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-DTWyUcyd.js';
10
- export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, B as BatchTrackRequest, k as BillingPayment, l as BillingPayout, m as BillingRefund, n as BillingTransaction, C as ChangeEmailRequest, o as ChangePasswordRequest, p as ClientContext, q as ConnectedAccount, D as DeviceFingerprint, r as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, K as KnownAccountInfo, s as LinkedAccount, t as ListFilesResponse, u as LoginDeviceInfo, v as LoginRequest, w as LoginResponseWithMFA, x as LoginRiskInfo, M as MFAChallengeResponse, y as MFAMethod, z as MFASMSSetupResponse, G as MFASetupRequest, H as MFAStatus, I as MFATOTPSetupResponse, J as MFAVerifyRequest, O as OAuthCallbackRequest, N as OAuthCallbackResponse, P as OAuthConfig, Q as OAuthProvider, R as OAuthStartResponse, T as PageViewData, V as PayoutSchedule, W as PhoneLoginRequest, X as PhoneSendCodeRequest, Y as PhoneVerifyRequest, Z as Profile, _ as RefreshResponse, $ as RegisterRequest, a0 as ResetPasswordRequest, a1 as ScaleMuleApiError, a2 as ScaleMuleEnvironment, a3 as Session, a4 as SignedUploadCompleteRequest, a5 as SignedUploadRequest, a6 as SignedUploadResponse, a7 as SignedUploadUrl, a8 as StorageAdapter, a9 as StorageFile, aa as TrackEventResponse, ab as TransactionSummary, ac as UTMParams, ad as UpdateProfileRequest, ae as UploadOptions, af as UploadResponse, ag as VerifyEmailRequest } from './index-DTWyUcyd.js';
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-zQloSkpW.js';
10
+ export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, B as BatchTrackRequest, k as BillingPayment, l as BillingPayout, m as BillingRefund, n as BillingTransaction, C as ChangeEmailRequest, o as ChangePasswordRequest, p as ClientContext, q as ConnectedAccount, D as DeviceFingerprint, r as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, K as KnownAccountInfo, s as LinkedAccount, t as ListFilesResponse, u as LoginDeviceInfo, v as LoginRequest, w as LoginResponseWithMFA, x as LoginRiskInfo, M as MFAChallengeResponse, y as MFAMethod, z as MFASMSSetupResponse, G as MFASetupRequest, H as MFAStatus, I as MFATOTPSetupResponse, J as MFAVerifyRequest, O as OAuthCallbackRequest, N as OAuthCallbackResponse, P as OAuthConfig, Q as OAuthProvider, R as OAuthStartResponse, T as PageViewData, V as PayoutSchedule, W as PhoneLoginRequest, X as PhoneSendCodeRequest, Y as PhoneVerifyRequest, Z as Profile, _ as RefreshResponse, $ as RegisterRequest, a0 as ResetPasswordRequest, a1 as ScaleMuleApiError, a2 as ScaleMuleEnvironment, a3 as Session, a4 as SignedUploadCompleteRequest, a5 as SignedUploadRequest, a6 as SignedUploadResponse, a7 as SignedUploadUrl, a8 as StorageAdapter, a9 as StorageFile, aa as TrackEventResponse, ab as TransactionSummary, ac as UTMParams, ad as UpdateProfileRequest, ae as UploadOptions, af as UploadResponse, ag as VerifyEmailRequest } from './index-zQloSkpW.js';
11
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';
12
25
  /**
13
26
  * Result of a single {@link useMedia} upload call.
14
27
  *
@@ -33,8 +46,24 @@ interface MediaUploadResult {
33
46
  hls_url_promise: Promise<string | null>;
34
47
  /** The file's MIME type — preserved from the input File / Blob. */
35
48
  mime_type: string;
36
- /** Whether the resulting storage object is public-readable. */
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. */
37
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;
38
67
  }
39
68
  /**
40
69
  * Per-app media-pipeline policy. Drives release-gating + processing
@@ -55,10 +84,34 @@ interface MediaUploadResult {
55
84
  */
56
85
  type MediaPolicy = 'fast_trusted' | 'safe_visible' | 'safe_public' | 'moderated' | 'compliance';
57
86
  interface UseMediaUploadOptions {
58
- /** Whether the resulting storage object should be public-readable.
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
+ *
59
111
  * Default: `false` (private). Public is opt-in for surfaces that
60
112
  * genuinely need it (avatars, public listings). Chat / DM uploads
61
- * should always be private. */
113
+ * should always be private.
114
+ */
62
115
  is_public?: boolean;
63
116
  /**
64
117
  * Per-call media-policy override. Defaults to `safe_visible` (visible
@@ -219,7 +272,7 @@ interface ScaleMuleProviderProps extends ScaleMuleConfig {
219
272
  * The platform stores the per-app policy in
220
273
  * `application_storage_settings.media_policy` (Phase 4 / P3, live in
221
274
  * prod). On boot, the provider fetches `GET /v1/storage/policy` (a
222
- * lightweight `EndUserOnly` endpoint added in `@scalemule/sdk@0.0.45`)
275
+ * lightweight `MemberOrEndUser` endpoint added in `@scalemule/sdk@0.0.45`)
223
276
  * and uses the returned policy as the effective default.
224
277
  *
225
278
  * Passing this prop overrides the auto-fetched value — useful for
@@ -227,8 +280,42 @@ interface ScaleMuleProviderProps extends ScaleMuleConfig {
227
280
  * platform config.
228
281
  */
229
282
  mediaPolicy?: MediaPolicy;
283
+ /**
284
+ * Member-auth bridge. When set, the provider runs in **member mode**:
285
+ *
286
+ * - Skips the `/v1/auth/me` end-user lookup and the auth-proxy
287
+ * `/me` flow. Identity is owned upstream (e.g. `MemberAuthProvider`
288
+ * in `web/scalemule-app`).
289
+ * - Calls `getToken()` on mount and propagates the returned token
290
+ * to all three SDK clients (`client`, `baseClient`, `money`) as a
291
+ * `Bearer` Authorization header. Returning `null` clears the token.
292
+ * - Re-polls every {@link memberTokenPollMs} milliseconds (default
293
+ * 60s) so cookie rotation in the host platform is picked up
294
+ * without a full page reload.
295
+ *
296
+ * Use {@link userResolver} alongside this prop to populate `user` from
297
+ * a member-auth endpoint instead of `/v1/auth/me`.
298
+ *
299
+ * Mutually exclusive with `authProxyUrl`. If both are set, `getToken`
300
+ * wins and the auth-proxy path is skipped.
301
+ */
302
+ getToken?: () => string | null | Promise<string | null>;
303
+ /**
304
+ * Resolves the `User` shown to the app in member-auth mode. The
305
+ * provider calls this once after the initial token is set; the host
306
+ * platform typically just returns its own `MemberProfile` mapped to
307
+ * the SDK's `User` shape. Optional — if omitted, `user` stays `null`
308
+ * and the host platform is responsible for surfacing identity.
309
+ */
310
+ userResolver?: () => Promise<User | null>;
311
+ /**
312
+ * Member-mode token poll interval in milliseconds. Default 60_000
313
+ * (1 minute). Pass `null` to disable polling (only the mount-time
314
+ * read happens).
315
+ */
316
+ memberTokenPollMs?: number | null;
230
317
  }
231
- declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
318
+ declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, getToken, userResolver, memberTokenPollMs, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
232
319
  declare function useScaleMule(): ScaleMuleContextValue;
233
320
  declare function useScaleMuleClient(): ScaleMuleClient;
234
321
  declare function useMoneyClient(): MoneyClient;
@@ -850,6 +937,35 @@ interface UseFeedbackResult {
850
937
  */
851
938
  declare function useFeedback(options?: UseFeedbackOptions): UseFeedbackResult;
852
939
 
940
+ interface VoteState {
941
+ /** Caller's current vote: 1 = upvote, -1 = downvote, 0 = no vote. */
942
+ value: 1 | -1 | 0;
943
+ up_count: number;
944
+ down_count: number;
945
+ score: number;
946
+ }
947
+ interface UseVoteOptions {
948
+ /** Application-defined target type. e.g. "weekmob_post", "gistyo_gist". */
949
+ targetType: string;
950
+ targetId: string;
951
+ /** Optional seed (from SSR or list query). */
952
+ initialState?: VoteState | null;
953
+ /** Refetch even when initialState is provided. Default false. */
954
+ refetchOnMount?: boolean;
955
+ /** Skip the initial fetch entirely (anonymous viewers). Default true. */
956
+ enabled?: boolean;
957
+ }
958
+ interface UseVoteReturn {
959
+ state: VoteState;
960
+ isLoading: boolean;
961
+ error: Error | null;
962
+ /** Cast (or change/clear) the caller's vote with optimistic update. */
963
+ cast: (value: 1 | -1 | 0) => Promise<void>;
964
+ /** Refetch the canonical state from the server. */
965
+ refetch: () => Promise<void>;
966
+ }
967
+ declare function useVote({ targetType, targetId, initialState, refetchOnMount, enabled, }: UseVoteOptions): UseVoteReturn;
968
+
853
969
  interface FeedbackWidgetProps {
854
970
  /** Floating-button corner. Default `bottom-right`. */
855
971
  position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
@@ -888,21 +1004,32 @@ interface FeedbackWidgetProps {
888
1004
  */
889
1005
  declare function FeedbackWidget(props: FeedbackWidgetProps): ReactElement | null;
890
1006
 
891
- type NarrationPlayerAudio = TtsAudioInfo & {
892
- waveform_peaks?: number[] | null;
893
- ai_generated?: boolean;
894
- };
895
- interface NarrationPlayerProps {
896
- audio: NarrationPlayerAudio;
897
- className?: string;
898
- providerLabel?: string;
899
- narrationLabel?: string;
900
- refreshing?: boolean;
901
- onRefresh?: () => void | Promise<void>;
902
- showRefreshButton?: boolean;
903
- onPlaybackError?: () => void;
1007
+ interface VoteButtonClassNames {
1008
+ root?: string;
1009
+ upButton?: string;
1010
+ upButtonActive?: string;
1011
+ downButton?: string;
1012
+ downButtonActive?: string;
1013
+ score?: string;
1014
+ scorePositive?: string;
1015
+ scoreNegative?: string;
1016
+ }
1017
+ interface VoteButtonProps {
1018
+ targetType: string;
1019
+ targetId: string;
1020
+ /** Server-known initial state, e.g. seeded from a list query. */
1021
+ initialState?: VoteState | null;
1022
+ /** Visual layout. "horizontal" = up | score | down. "stacked" = column. */
1023
+ layout?: 'horizontal' | 'stacked';
1024
+ size?: 'compact' | 'regular';
1025
+ /** Called when an anonymous user clicks vote. */
1026
+ onSignInRequired?: () => void;
1027
+ onError?: (error: unknown) => void;
1028
+ classNames?: VoteButtonClassNames;
1029
+ upLabel?: string;
1030
+ downLabel?: string;
904
1031
  }
905
- declare function NarrationPlayer({ audio, className, providerLabel, narrationLabel, refreshing, onRefresh, showRefreshButton, onPlaybackError, }: NarrationPlayerProps): react_jsx_runtime.JSX.Element | null;
1032
+ declare function VoteButton({ targetType, targetId, initialState, layout, size, onSignInRequired, onError, classNames, upLabel, downLabel, }: VoteButtonProps): react_jsx_runtime.JSX.Element;
906
1033
 
907
1034
  /**
908
1035
  * Client-side validation helpers
@@ -1062,4 +1189,4 @@ declare function createSafeLogger(prefix: string): {
1062
1189
  error: (message: string, data?: unknown) => void;
1063
1190
  };
1064
1191
 
1065
- 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, 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, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAudio, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useTtsJob, useUser, validateForm, validators };
1192
+ 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, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleMedia, type ScaleMuleMediaProps, ScaleMuleProvider, type ScaleMuleProviderProps, 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 };