deepspace 0.22.1 → 0.23.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.
- package/CHANGELOG.md +29 -0
- package/dist/build.d.ts +116 -0
- package/dist/build.js +139 -0
- package/dist/build.js.map +1 -0
- package/dist/{chunk-XXOLIJB5.js → chunk-UUCAFDYW.js} +2 -2
- package/dist/{chunk-XXOLIJB5.js.map → chunk-UUCAFDYW.js.map} +1 -1
- package/dist/cli.js +978 -633
- package/dist/cli.js.map +1 -1
- package/dist/documentation-client-core.js +1 -1
- package/dist/documentation-default-renderer.cjs +1 -1
- package/dist/documentation-react.js +1 -1
- package/dist/documentation-runtime.js +1 -1
- package/dist/documentation-server-core.js +1 -1
- package/dist/documentation.js +1 -1
- package/dist/documentation.js.map +1 -1
- package/dist/index.d.ts +41 -7
- package/dist/index.js +29 -29
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +10 -0
- package/dist/schema.js +6 -0
- package/dist/schema.js.map +1 -1
- package/dist/server.d.ts +134 -25
- package/dist/server.js +450 -234
- package/dist/server.js.map +1 -1
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +21 -9
- package/dist/testing.js.map +1 -1
- package/dist/worker.d.ts +123 -14
- package/dist/worker.js +558 -342
- package/dist/worker.js.map +1 -1
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -100,6 +100,16 @@ interface CollectionSchema {
|
|
|
100
100
|
permissions: Record<string, RolePermissions>;
|
|
101
101
|
/** Default role assigned on the `users` collection. */
|
|
102
102
|
defaultRole?: string;
|
|
103
|
+
/**
|
|
104
|
+
* `users` collection only: what the `user.list` roster shows a non-admin
|
|
105
|
+
* whose `read` policy is row-scoped (`'own'`, `'team'`, …). Default
|
|
106
|
+
* `'public-identity'`: every registered user's id/name/imageUrl/role — the
|
|
107
|
+
* row policy keeps guarding full-row reads on the records/query path.
|
|
108
|
+
* `'read-policy'`: the roster contains only the rows the caller's read
|
|
109
|
+
* policy grants (still projected to public identity) — for apps that scope
|
|
110
|
+
* users to a tenant/team and must not show names across it.
|
|
111
|
+
*/
|
|
112
|
+
roster?: 'public-identity' | 'read-policy';
|
|
103
113
|
}
|
|
104
114
|
interface Query {
|
|
105
115
|
collection: string;
|
|
@@ -655,10 +665,26 @@ declare const MSG_YJS_SYNC = 22;
|
|
|
655
665
|
declare const MSG_YJS_AWARENESS = 23;
|
|
656
666
|
/** Role assigned to unauthenticated WebSocket connections */
|
|
657
667
|
declare const ROLE_ANONYMOUS = "viewer";
|
|
668
|
+
/** Prefix `base-room` mints anonymous socket ids with. */
|
|
669
|
+
declare const ANONYMOUS_USER_ID_PREFIX = "anon-";
|
|
670
|
+
/** The one test for an anonymous socket identity — `ROLE_ANONYMOUS` cannot be
|
|
671
|
+
* it, since authenticated users can legitimately hold the same role name. */
|
|
672
|
+
declare function isAnonymousUserId(userId: string): boolean;
|
|
658
673
|
/** Default role for newly registered authenticated users */
|
|
659
674
|
declare const ROLE_DEFAULT = "member";
|
|
660
675
|
/** Admin role */
|
|
661
676
|
declare const ROLE_ADMIN = "admin";
|
|
677
|
+
/**
|
|
678
|
+
* Reported when a record id resolves to nothing.
|
|
679
|
+
*
|
|
680
|
+
* This crosses the DO boundary as a response body and callers branch on it,
|
|
681
|
+
* so it is a contract rather than prose. `getChat` in particular treats it as
|
|
682
|
+
* "no such chat" and returns null — the same answer it gives for a chat owned
|
|
683
|
+
* by someone else, which is what stops chat ids being enumerable. If a room
|
|
684
|
+
* reworded this independently, a miss would start throwing while a cross-user
|
|
685
|
+
* hit kept returning null, and that difference is an existence oracle.
|
|
686
|
+
*/
|
|
687
|
+
declare const RECORD_NOT_FOUND = "Record not found";
|
|
662
688
|
|
|
663
689
|
/**
|
|
664
690
|
* Typed wire-protocol layer — discriminated unions, typed builders, and a
|
|
@@ -2820,10 +2846,14 @@ interface RoomUser {
|
|
|
2820
2846
|
lastSeenAt?: string;
|
|
2821
2847
|
}
|
|
2822
2848
|
type RoomConnectionState = 'connecting' | 'connected' | 'disconnected';
|
|
2823
|
-
/** A
|
|
2849
|
+
/** A rejected optimistic write. */
|
|
2824
2850
|
interface WriteError {
|
|
2825
|
-
/**
|
|
2826
|
-
|
|
2851
|
+
/**
|
|
2852
|
+
* `permission` — RBAC denial; `validation` — data validation/other server
|
|
2853
|
+
* rejection; `not_ready` — rejected client-side because the room could not
|
|
2854
|
+
* accept writes yet (gate the control on `ready` from `useMutations()`).
|
|
2855
|
+
*/
|
|
2856
|
+
kind: 'permission' | 'validation' | 'not_ready';
|
|
2827
2857
|
/** Short human-readable summary, safe to show end users. */
|
|
2828
2858
|
title: string;
|
|
2829
2859
|
/** Longer human-readable explanation; may be empty. */
|
|
@@ -2841,8 +2871,9 @@ interface RecordProviderProps {
|
|
|
2841
2871
|
/** Auth token provider for WS connections. */
|
|
2842
2872
|
getAuthToken?: () => Promise<string | null>;
|
|
2843
2873
|
/**
|
|
2844
|
-
* Receives
|
|
2845
|
-
*
|
|
2874
|
+
* Receives every rejected write — denied or invalid by the server, and
|
|
2875
|
+
* attempted before the room was ready. Wire this to app UI so users see
|
|
2876
|
+
* changes that didn't land. Defaults to a deduplicated console error.
|
|
2846
2877
|
*/
|
|
2847
2878
|
onWriteError?: (error: WriteError) => void;
|
|
2848
2879
|
}
|
|
@@ -3113,7 +3144,10 @@ declare function useQuery<T = unknown>(collection: string, options?: {
|
|
|
3113
3144
|
* ```
|
|
3114
3145
|
*/
|
|
3115
3146
|
declare function useMutations<T = unknown>(collection: string): {
|
|
3116
|
-
/** True once the collection's RecordRoom can accept writes.
|
|
3147
|
+
/** True once the collection's RecordRoom can accept writes. Disable the
|
|
3148
|
+
* control on it (`disabled={!ready}`) rather than early-returning from
|
|
3149
|
+
* the handler: an early return drops the user's write silently, while a
|
|
3150
|
+
* write attempted before `ready` at least raises a `not_ready` error. */
|
|
3117
3151
|
ready: boolean;
|
|
3118
3152
|
create: (data: T) => Promise<string>;
|
|
3119
3153
|
put: (recordId: string, data: Partial<T>) => Promise<void>;
|
|
@@ -5057,4 +5091,4 @@ declare const ACCOUNT_STORAGE_LIMIT_BYTES: {
|
|
|
5057
5091
|
declare function storageLimitForTier(tier: string | null | undefined): number;
|
|
5058
5092
|
declare function formatBytes(bytes: number): string;
|
|
5059
5093
|
|
|
5060
|
-
export { ACCOUNT_STORAGE_LIMIT_BYTES, APP_LOG_EVENT_KEYS, ASYNC_RESOURCE_DEFAULTS, type AdHocChargeOpts, type AiStreamAction, type AiStreamChunk, type ApiErrorIssue, type AppLogEvent, type AppLogEventKey, type AppLogsResponse, type AppMigrationIdsValidation, type AsyncResourceDefaults, type AsyncResourceState, type AsyncResourceStatus, AuthGate, type AuthGateProps, AuthOverlay, Awareness, type AwarenessState, type AwarenessStates, type BaseMessage, type CanvasShapeClient, type Channel, type ChannelInvitation, type ChannelMember, type ChargeOnceOpts, type ChargeOnceResult, type ClientErrorKind, type ClientErrorReport, type ClientErrorReporterOptions, type ClientMessage, type CollectionSchema, type ConnectionAttachment, type ConnectionStatus, type ContentSegment, type ConversationObject, type CronHistoryEntry, type CronMutationResult, type CronTaskState, DEEPSPACE_AGENT_PROFILES, DEEPSPACE_AI_DEFAULTS, DEEPSPACE_AI_MODELS, DEEPSPACE_MODEL_CATALOG_PROVENANCE, DEEPSPACE_THEME_PROPERTIES, DEFAULT_USER_COLORS, type DeepSpaceAIModel, type DeepSpaceAIModelId, type DeepSpaceAIProvider, type DeepSpaceAgentProfile, type DeepSpaceAgentProfileId, type DeepSpaceAgentSupport, DeepSpaceAuthProvider, type DeepSpaceThemeConfig, DeepSpaceThemeProvider, type DeepSpaceThemeProviderProps, type DeriveLoadStateInput, ENV, type Environment, type FileAttachment, type GroupedReaction, GuestBanner, type HandlerContext, type InboxEntry, type IntegrationResponse, type JobStatusView, type JobView, LOG_LEVELS, type LinkPreviewData, type LoadState, type LoadStateAuthInput, type LoadStateStatusInput, type LogLevel, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MemberRecord, type Message, type MessageHandlers, type MessageRecord, type MsgType, type NormalizedApiError, type PagedResourceFetchArgs, type PagedResourcePage, type PagedResourceState, type PagedResourceStatus, type PlanInfo, PlatformApiError, PlatformContext, type PlatformContextValue, PlatformProvider, type PlatformWSOptions, type PlatformWSResult, type PresencePeerClient, PricingTable, type PricingTablePlan, type PricingTablePrice, type ProductChargeOpts, type ProtocolMessage, type Purchase, type Query, type R2FileInfo, type R2FileListPage, type R2Scope, type R2UploadResult, ROLES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_CONFIG, ROLE_DEFAULT, type Reaction, type ReactionRecord, type ReadCursorRecord, type ReadReceipt, type RecordData, RecordProvider, type RecordProviderProps, RecordRoomNotReadyError, RecordScope, type RequestOptions, type ResolvedDeepSpaceAgentModel, type Role, type RoomUser, SECURE_ROOM_BOUNDARIES_MIGRATION_ID, type ScopeEntry, ScopeRegistryProvider, type ServerMessage, SignedIn, SignedOut, type SubscribeOpts, type SubscribeResult, type SubscriptionState, type SubscriptionStatus, type SyncResult, type UseAsyncResourceOptions, type UseAuthProfileReadyOptions, type UseAuthStatusOptions, type UseCanvasResult, type UseCheckoutOpts, type UseCronMonitorResult, type UseJobsResult, type UsePagedResourceOptions, type UsePresenceRoomResult, type UseR2FilesReturn, type UseVoiceAgentOptions, type UseVoiceAgentResult, type UseYjsFieldResult, type UseYjsRoomResult, type UseYjsTextResult, type User, type UserCredits, type UserInfo, type UserKarma, type UserProfile, type ViewportClient, type VoiceStatus, type VoiceTranscriptEntry, WORKER_OWNED_NOT_FOUND_MIGRATION_ID, type WriteError, applyDeepSpaceTheme, applyUIThemeTokens, authClient, canAutoLoadPagedResource, clampPagedResourceItems, clearAuthToken, clearDeepSpaceTheme, clientBuild, createDecoder, createEncoder, decodeAiStreamChunk, deriveLoadState, detectEnvironment, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, formatBytes, formatFileSize, formatFullTimestamp, formatMessageTime, getApiUrl, getAuthToken, getAuthUrl, getConversationDisplayName, getConversationParticipantIds, getDeepSpaceAIModel, getEnvironmentConfig, getMessageType, getPagedResourceCooldownMs, getPlatformWorkerUrl, getThreadCounts, getUserColor, groupReactionsForMessage, handleAwarenessMessage, handleSyncMessage, hasContent, installClientErrorReporter, integration, isAsyncResourceSlow, isDMConversation, isDarkColor, isImageFile, isLocalDev, isProduction, listDeepSpaceAgentModels, parseMessageMetadata, parseSseLine, readThemeFromDOM, readVarUint, readVarUint8Array, reportClientError, resetEnvironmentCache, resolveDeepSpaceAgentModel, serverBuild, shouldGroupMessages, signIn, signOut, storageLimitForTier, toConnectionStatus, toUint8Array, useAsyncResource, useAuth, useAuthProfileReady, useAuthStatus, useAuthUser, useCanvas, useChannelMembers, useChannels, useCheckout, useCommunities, useConversation, useConversations, useCronMonitor, useDisplayName, useInbox, useIsDarkTheme, useJobs, useMessages, useMutations, usePagedResource, usePlatform, usePlatformWS, usePosts, usePresence, usePresenceRoom, useQuery, useR2Files, useReactions, useReadReceipts, useRecordContext, useSession, useSubscription, useUser, useUserLookup, useUsers, useVoiceAgent, useYjsField, useYjsRoom, useYjsText, validateAppMigrationIds, writeVarUint, writeVarUint8Array };
|
|
5094
|
+
export { ACCOUNT_STORAGE_LIMIT_BYTES, ANONYMOUS_USER_ID_PREFIX, APP_LOG_EVENT_KEYS, ASYNC_RESOURCE_DEFAULTS, type AdHocChargeOpts, type AiStreamAction, type AiStreamChunk, type ApiErrorIssue, type AppLogEvent, type AppLogEventKey, type AppLogsResponse, type AppMigrationIdsValidation, type AsyncResourceDefaults, type AsyncResourceState, type AsyncResourceStatus, AuthGate, type AuthGateProps, AuthOverlay, Awareness, type AwarenessState, type AwarenessStates, type BaseMessage, type CanvasShapeClient, type Channel, type ChannelInvitation, type ChannelMember, type ChargeOnceOpts, type ChargeOnceResult, type ClientErrorKind, type ClientErrorReport, type ClientErrorReporterOptions, type ClientMessage, type CollectionSchema, type ConnectionAttachment, type ConnectionStatus, type ContentSegment, type ConversationObject, type CronHistoryEntry, type CronMutationResult, type CronTaskState, DEEPSPACE_AGENT_PROFILES, DEEPSPACE_AI_DEFAULTS, DEEPSPACE_AI_MODELS, DEEPSPACE_MODEL_CATALOG_PROVENANCE, DEEPSPACE_THEME_PROPERTIES, DEFAULT_USER_COLORS, type DeepSpaceAIModel, type DeepSpaceAIModelId, type DeepSpaceAIProvider, type DeepSpaceAgentProfile, type DeepSpaceAgentProfileId, type DeepSpaceAgentSupport, DeepSpaceAuthProvider, type DeepSpaceThemeConfig, DeepSpaceThemeProvider, type DeepSpaceThemeProviderProps, type DeriveLoadStateInput, ENV, type Environment, type FileAttachment, type GroupedReaction, GuestBanner, type HandlerContext, type InboxEntry, type IntegrationResponse, type JobStatusView, type JobView, LOG_LEVELS, type LinkPreviewData, type LoadState, type LoadStateAuthInput, type LoadStateStatusInput, type LogLevel, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MemberRecord, type Message, type MessageHandlers, type MessageRecord, type MsgType, type NormalizedApiError, type PagedResourceFetchArgs, type PagedResourcePage, type PagedResourceState, type PagedResourceStatus, type PlanInfo, PlatformApiError, PlatformContext, type PlatformContextValue, PlatformProvider, type PlatformWSOptions, type PlatformWSResult, type PresencePeerClient, PricingTable, type PricingTablePlan, type PricingTablePrice, type ProductChargeOpts, type ProtocolMessage, type Purchase, type Query, type R2FileInfo, type R2FileListPage, type R2Scope, type R2UploadResult, RECORD_NOT_FOUND, ROLES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_CONFIG, ROLE_DEFAULT, type Reaction, type ReactionRecord, type ReadCursorRecord, type ReadReceipt, type RecordData, RecordProvider, type RecordProviderProps, RecordRoomNotReadyError, RecordScope, type RequestOptions, type ResolvedDeepSpaceAgentModel, type Role, type RoomUser, SECURE_ROOM_BOUNDARIES_MIGRATION_ID, type ScopeEntry, ScopeRegistryProvider, type ServerMessage, SignedIn, SignedOut, type SubscribeOpts, type SubscribeResult, type SubscriptionState, type SubscriptionStatus, type SyncResult, type UseAsyncResourceOptions, type UseAuthProfileReadyOptions, type UseAuthStatusOptions, type UseCanvasResult, type UseCheckoutOpts, type UseCronMonitorResult, type UseJobsResult, type UsePagedResourceOptions, type UsePresenceRoomResult, type UseR2FilesReturn, type UseVoiceAgentOptions, type UseVoiceAgentResult, type UseYjsFieldResult, type UseYjsRoomResult, type UseYjsTextResult, type User, type UserCredits, type UserInfo, type UserKarma, type UserProfile, type ViewportClient, type VoiceStatus, type VoiceTranscriptEntry, WORKER_OWNED_NOT_FOUND_MIGRATION_ID, type WriteError, applyDeepSpaceTheme, applyUIThemeTokens, authClient, canAutoLoadPagedResource, clampPagedResourceItems, clearAuthToken, clearDeepSpaceTheme, clientBuild, createDecoder, createEncoder, decodeAiStreamChunk, deriveLoadState, detectEnvironment, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, formatBytes, formatFileSize, formatFullTimestamp, formatMessageTime, getApiUrl, getAuthToken, getAuthUrl, getConversationDisplayName, getConversationParticipantIds, getDeepSpaceAIModel, getEnvironmentConfig, getMessageType, getPagedResourceCooldownMs, getPlatformWorkerUrl, getThreadCounts, getUserColor, groupReactionsForMessage, handleAwarenessMessage, handleSyncMessage, hasContent, installClientErrorReporter, integration, isAnonymousUserId, isAsyncResourceSlow, isDMConversation, isDarkColor, isImageFile, isLocalDev, isProduction, listDeepSpaceAgentModels, parseMessageMetadata, parseSseLine, readThemeFromDOM, readVarUint, readVarUint8Array, reportClientError, resetEnvironmentCache, resolveDeepSpaceAgentModel, serverBuild, shouldGroupMessages, signIn, signOut, storageLimitForTier, toConnectionStatus, toUint8Array, useAsyncResource, useAuth, useAuthProfileReady, useAuthStatus, useAuthUser, useCanvas, useChannelMembers, useChannels, useCheckout, useCommunities, useConversation, useConversations, useCronMonitor, useDisplayName, useInbox, useIsDarkTheme, useJobs, useMessages, useMutations, usePagedResource, usePlatform, usePlatformWS, usePosts, usePresence, usePresenceRoom, useQuery, useR2Files, useReactions, useReadReceipts, useRecordContext, useSession, useSubscription, useUser, useUserLookup, useUsers, useVoiceAgent, useYjsField, useYjsRoom, useYjsText, validateAppMigrationIds, writeVarUint, writeVarUint8Array };
|
package/dist/index.js
CHANGED
|
@@ -613,8 +613,13 @@ var MSG = {
|
|
|
613
613
|
var MSG_YJS_SYNC = 22;
|
|
614
614
|
var MSG_YJS_AWARENESS = 23;
|
|
615
615
|
var ROLE_ANONYMOUS = "viewer";
|
|
616
|
+
var ANONYMOUS_USER_ID_PREFIX = "anon-";
|
|
617
|
+
function isAnonymousUserId(userId) {
|
|
618
|
+
return userId.startsWith(ANONYMOUS_USER_ID_PREFIX);
|
|
619
|
+
}
|
|
616
620
|
var ROLE_DEFAULT = "member";
|
|
617
621
|
var ROLE_ADMIN = "admin";
|
|
622
|
+
var RECORD_NOT_FOUND = "Record not found";
|
|
618
623
|
|
|
619
624
|
// src/shared/protocol/messages.ts
|
|
620
625
|
var EMPTY = Object.freeze({});
|
|
@@ -1376,20 +1381,14 @@ function RecordProviderState({
|
|
|
1376
1381
|
fetchUser,
|
|
1377
1382
|
allowAnonymous = false,
|
|
1378
1383
|
getAuthToken: getAuthTokenProp,
|
|
1379
|
-
|
|
1380
|
-
onValidationError: onValidationErrorProp
|
|
1384
|
+
onWriteError: onWriteErrorProp
|
|
1381
1385
|
}) {
|
|
1382
1386
|
const [userProfile, setUserProfile] = useState3(null);
|
|
1383
1387
|
const [userProfileLoading, setUserProfileLoading] = useState3(true);
|
|
1384
|
-
const
|
|
1385
|
-
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1388
|
-
const onPermissionError = useCallback2((title, detail) => {
|
|
1389
|
-
onPermissionErrorRef.current?.(title, detail);
|
|
1390
|
-
}, []);
|
|
1391
|
-
const onValidationError = useCallback2((title, detail) => {
|
|
1392
|
-
onValidationErrorRef.current?.(title, detail);
|
|
1388
|
+
const onWriteErrorRef = useRef4(onWriteErrorProp);
|
|
1389
|
+
onWriteErrorRef.current = onWriteErrorProp;
|
|
1390
|
+
const onWriteError = useCallback2((error) => {
|
|
1391
|
+
onWriteErrorRef.current(error);
|
|
1393
1392
|
}, []);
|
|
1394
1393
|
const refetchUserProfile = useCallback2(async () => {
|
|
1395
1394
|
try {
|
|
@@ -1427,8 +1426,7 @@ function RecordProviderState({
|
|
|
1427
1426
|
refetchUserProfile,
|
|
1428
1427
|
allowAnonymous,
|
|
1429
1428
|
getAuthToken: getAuthTokenProp,
|
|
1430
|
-
|
|
1431
|
-
onValidationError
|
|
1429
|
+
onWriteError
|
|
1432
1430
|
}),
|
|
1433
1431
|
[
|
|
1434
1432
|
userProfile,
|
|
@@ -1436,8 +1434,7 @@ function RecordProviderState({
|
|
|
1436
1434
|
refetchUserProfile,
|
|
1437
1435
|
allowAnonymous,
|
|
1438
1436
|
getAuthTokenProp,
|
|
1439
|
-
|
|
1440
|
-
onValidationError
|
|
1437
|
+
onWriteError
|
|
1441
1438
|
]
|
|
1442
1439
|
);
|
|
1443
1440
|
return /* @__PURE__ */ jsx6(RecordAuthContext.Provider, { value: authValue, children: /* @__PURE__ */ jsx6(ScopeRegistryProvider, { children }) });
|
|
@@ -1533,16 +1530,13 @@ function RecordProvider({
|
|
|
1533
1530
|
}
|
|
1534
1531
|
return /* @__PURE__ */ jsx6(Fragment5, { children: null });
|
|
1535
1532
|
}
|
|
1536
|
-
const onPermissionError = (title, detail) => onWriteError({ kind: "permission", title, detail });
|
|
1537
|
-
const onValidationError = (title, detail) => onWriteError({ kind: "validation", title, detail });
|
|
1538
1533
|
return /* @__PURE__ */ jsx6(
|
|
1539
1534
|
RecordProviderState,
|
|
1540
1535
|
{
|
|
1541
1536
|
fetchUser,
|
|
1542
1537
|
allowAnonymous,
|
|
1543
1538
|
getAuthToken: getAuthTokenFn,
|
|
1544
|
-
|
|
1545
|
-
onValidationError,
|
|
1539
|
+
onWriteError,
|
|
1546
1540
|
children
|
|
1547
1541
|
}
|
|
1548
1542
|
);
|
|
@@ -2205,12 +2199,8 @@ function ScopeConnection({
|
|
|
2205
2199
|
userProfileRef.current = auth?.userProfile ?? null;
|
|
2206
2200
|
const getAuthTokenRef = useRef5(auth?.getAuthToken ?? null);
|
|
2207
2201
|
getAuthTokenRef.current = auth?.getAuthToken ?? null;
|
|
2208
|
-
const
|
|
2209
|
-
|
|
2210
|
-
onValidationError: auth?.onValidationError
|
|
2211
|
-
});
|
|
2212
|
-
authCallbacksRef.current.onPermissionError = auth?.onPermissionError;
|
|
2213
|
-
authCallbacksRef.current.onValidationError = auth?.onValidationError;
|
|
2202
|
+
const onWriteErrorRef = useRef5(auth?.onWriteError);
|
|
2203
|
+
onWriteErrorRef.current = auth?.onWriteError;
|
|
2214
2204
|
const allowAnonymous = auth?.allowAnonymous ?? false;
|
|
2215
2205
|
const userProfileId = auth?.userProfile?.id ?? null;
|
|
2216
2206
|
const userProfileLoading = auth?.userProfileLoading ?? false;
|
|
@@ -2235,8 +2225,8 @@ function ScopeConnection({
|
|
|
2235
2225
|
setUsersLoaded(true);
|
|
2236
2226
|
},
|
|
2237
2227
|
onSchemas: setDiscoveredSchemas,
|
|
2238
|
-
onPermissionError: (title, detail) =>
|
|
2239
|
-
onValidationError: (title, detail) =>
|
|
2228
|
+
onPermissionError: (title, detail) => onWriteErrorRef.current?.({ kind: "permission", title, detail }),
|
|
2229
|
+
onValidationError: (title, detail) => onWriteErrorRef.current?.({ kind: "validation", title, detail })
|
|
2240
2230
|
}
|
|
2241
2231
|
});
|
|
2242
2232
|
socketRef.current = socket;
|
|
@@ -2519,6 +2509,7 @@ import { useCallback as useCallback5, useContext as useContext4, useMemo as useM
|
|
|
2519
2509
|
function useMutations(collection) {
|
|
2520
2510
|
const registry = useScopeRegistry();
|
|
2521
2511
|
const recordCtx = useContext4(RecordContext);
|
|
2512
|
+
const onWriteError = useRecordAuth()?.onWriteError;
|
|
2522
2513
|
const scopeEntry = registry?.resolve(collection) ?? null;
|
|
2523
2514
|
const preferLocal = recordCtx?.registeredCollections?.has(collection) ?? false;
|
|
2524
2515
|
const sendMessage = preferLocal ? recordCtx.sendMessage : scopeEntry?.sendMessage ?? recordCtx?.sendMessage;
|
|
@@ -2530,8 +2521,14 @@ function useMutations(collection) {
|
|
|
2530
2521
|
);
|
|
2531
2522
|
}
|
|
2532
2523
|
const assertReady = useCallback5(() => {
|
|
2533
|
-
if (
|
|
2534
|
-
|
|
2524
|
+
if (ready) return;
|
|
2525
|
+
onWriteError?.({
|
|
2526
|
+
kind: "not_ready",
|
|
2527
|
+
title: "Not saved \u2014 still connecting",
|
|
2528
|
+
detail: `The room backing "${collection}" was not ready to accept writes yet, so the change was dropped. Gate the action on the \`ready\` flag from useMutations('${collection}') (e.g. \`disabled={!ready}\`) and retry once it is true.`
|
|
2529
|
+
});
|
|
2530
|
+
throw new RecordRoomNotReadyError(collection);
|
|
2531
|
+
}, [ready, collection, onWriteError]);
|
|
2535
2532
|
const create = useCallback5(
|
|
2536
2533
|
async (data) => {
|
|
2537
2534
|
assertReady();
|
|
@@ -6476,6 +6473,7 @@ var APP_LOG_EVENT_KEYS = [
|
|
|
6476
6473
|
];
|
|
6477
6474
|
export {
|
|
6478
6475
|
ACCOUNT_STORAGE_LIMIT_BYTES,
|
|
6476
|
+
ANONYMOUS_USER_ID_PREFIX,
|
|
6479
6477
|
APP_LOG_EVENT_KEYS,
|
|
6480
6478
|
ASYNC_RESOURCE_DEFAULTS,
|
|
6481
6479
|
AuthGate,
|
|
@@ -6504,6 +6502,7 @@ export {
|
|
|
6504
6502
|
PlatformContext,
|
|
6505
6503
|
PlatformProvider,
|
|
6506
6504
|
PricingTable,
|
|
6505
|
+
RECORD_NOT_FOUND,
|
|
6507
6506
|
ROLES,
|
|
6508
6507
|
ROLE_ADMIN,
|
|
6509
6508
|
ROLE_ANONYMOUS,
|
|
@@ -6558,6 +6557,7 @@ export {
|
|
|
6558
6557
|
hasContent,
|
|
6559
6558
|
installClientErrorReporter,
|
|
6560
6559
|
integration,
|
|
6560
|
+
isAnonymousUserId,
|
|
6561
6561
|
isAsyncResourceSlow,
|
|
6562
6562
|
isDMConversation,
|
|
6563
6563
|
isDarkColor,
|