@sanity/sdk 2.8.0 → 2.9.0
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/_chunks-dts/utils.d.ts +2396 -0
- package/dist/_chunks-es/_internal.js +129 -0
- package/dist/_chunks-es/_internal.js.map +1 -0
- package/dist/_chunks-es/createGroqSearchFilter.js +1460 -0
- package/dist/_chunks-es/createGroqSearchFilter.js.map +1 -0
- package/dist/_chunks-es/telemetryManager.js +87 -0
- package/dist/_chunks-es/telemetryManager.js.map +1 -0
- package/dist/_chunks-es/version.js +7 -0
- package/dist/_chunks-es/version.js.map +1 -0
- package/dist/_exports/_internal.d.ts +64 -0
- package/dist/_exports/_internal.js +20 -0
- package/dist/_exports/_internal.js.map +1 -0
- package/dist/index.d.ts +2 -2343
- package/dist/index.js +383 -1777
- package/dist/index.js.map +1 -1
- package/package.json +11 -4
- package/src/_exports/_internal.ts +14 -0
- package/src/_exports/index.ts +10 -1
- package/src/auth/authStore.test.ts +150 -1
- package/src/auth/authStore.ts +11 -11
- package/src/auth/dashboardAuth.ts +2 -2
- package/src/auth/handleAuthCallback.ts +9 -3
- package/src/auth/logout.test.ts +1 -1
- package/src/auth/logout.ts +1 -1
- package/src/auth/refreshStampedToken.test.ts +118 -1
- package/src/auth/refreshStampedToken.ts +3 -2
- package/src/auth/standaloneAuth.ts +9 -3
- package/src/auth/studioAuth.ts +34 -7
- package/src/auth/studioModeAuth.ts +2 -1
- package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +10 -2
- package/src/auth/subscribeToStateAndFetchCurrentUser.ts +5 -1
- package/src/auth/subscribeToStorageEventsAndSetToken.ts +2 -2
- package/src/auth/utils.ts +33 -0
- package/src/client/clientStore.test.ts +14 -0
- package/src/client/clientStore.ts +2 -1
- package/src/comlink/node/getNodeState.ts +2 -1
- package/src/config/sanityConfig.ts +6 -0
- package/src/document/actions.ts +18 -11
- package/src/document/applyDocumentActions.test.ts +7 -6
- package/src/document/applyDocumentActions.ts +10 -4
- package/src/document/documentStore.test.ts +536 -188
- package/src/document/documentStore.ts +142 -76
- package/src/document/events.ts +7 -2
- package/src/document/permissions.test.ts +18 -16
- package/src/document/permissions.ts +35 -11
- package/src/document/processActions.test.ts +359 -32
- package/src/document/processActions.ts +104 -76
- package/src/document/reducers.test.ts +117 -29
- package/src/document/reducers.ts +43 -36
- package/src/document/sharedListener.ts +16 -6
- package/src/document/util.ts +14 -0
- package/src/favorites/favorites.test.ts +9 -2
- package/src/presence/bifurTransport.ts +6 -1
- package/src/preview/getPreviewState.test.ts +115 -98
- package/src/preview/getPreviewState.ts +38 -60
- package/src/preview/previewProjectionUtils.test.ts +179 -0
- package/src/preview/previewProjectionUtils.ts +93 -0
- package/src/preview/resolvePreview.test.ts +42 -25
- package/src/preview/resolvePreview.ts +29 -10
- package/src/preview/{previewStore.ts → types.ts} +8 -17
- package/src/projection/getProjectionState.test.ts +16 -16
- package/src/projection/getProjectionState.ts +2 -1
- package/src/projection/projectionQuery.ts +2 -3
- package/src/projection/types.ts +1 -1
- package/src/query/queryStore.ts +2 -1
- package/src/releases/getPerspectiveState.ts +7 -6
- package/src/releases/releasesStore.test.ts +20 -5
- package/src/releases/releasesStore.ts +20 -8
- package/src/store/createStateSourceAction.test.ts +62 -0
- package/src/store/createStateSourceAction.ts +34 -39
- package/src/telemetry/__telemetry__/sdk.telemetry.ts +42 -0
- package/src/telemetry/devMode.test.ts +52 -0
- package/src/telemetry/devMode.ts +40 -0
- package/src/telemetry/initTelemetry.test.ts +225 -0
- package/src/telemetry/initTelemetry.ts +205 -0
- package/src/telemetry/telemetryManager.test.ts +263 -0
- package/src/telemetry/telemetryManager.ts +187 -0
- package/src/users/usersStore.test.ts +1 -0
- package/src/users/usersStore.ts +5 -1
- package/src/utils/createFetcherStore.test.ts +6 -4
- package/src/utils/createFetcherStore.ts +2 -1
- package/src/utils/getStagingApiHost.test.ts +21 -0
- package/src/utils/getStagingApiHost.ts +14 -0
- package/src/utils/ids.test.ts +1 -29
- package/src/utils/ids.ts +0 -10
- package/src/utils/setCleanupTimeout.ts +24 -0
- package/src/preview/previewQuery.test.ts +0 -236
- package/src/preview/previewQuery.ts +0 -153
- package/src/preview/previewStore.test.ts +0 -36
- package/src/preview/subscribeToStateAndFetchBatches.test.ts +0 -221
- package/src/preview/subscribeToStateAndFetchBatches.ts +0 -112
- package/src/preview/util.ts +0 -13
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { H as getUsersKey, J as getQueryKey, P as createGroqSearchFilter, U as parseUsersKey, X as parseQueryKey, a as isProjectUserNotFoundClientError, i as getClientErrorApiType, n as getClientErrorApiBody, ot as transformProjectionToPreview, r as getClientErrorApiDescription, st as PREVIEW_PROJECTION, t as ApiErrorBody, xr as isStudioConfig, yr as SanityInstance } from "../_chunks-dts/utils.js";
|
|
2
|
+
import { SanityClient } from "@sanity/client";
|
|
3
|
+
/**
|
|
4
|
+
* Manages dev-mode telemetry for a single SDK instance.
|
|
5
|
+
*
|
|
6
|
+
* Wraps `@sanity/telemetry`'s batched store with SDK-specific concerns:
|
|
7
|
+
* consent caching, session lifecycle events, and hook usage tracking.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
interface TelemetryManager {
|
|
12
|
+
/**
|
|
13
|
+
* Eagerly resolve and cache the user's consent status.
|
|
14
|
+
* Returns true only when the user has explicitly opted in (`granted`).
|
|
15
|
+
* Call this before logging any events to avoid buffering events that
|
|
16
|
+
* will be dropped on the first flush.
|
|
17
|
+
*/
|
|
18
|
+
checkConsent(): Promise<boolean>;
|
|
19
|
+
/** Log a "SDK Dev Session Started" event */
|
|
20
|
+
logSessionStarted(data: {
|
|
21
|
+
projectId: string;
|
|
22
|
+
perspective: string;
|
|
23
|
+
authMethod: string;
|
|
24
|
+
}): void;
|
|
25
|
+
/** Log a "SDK Hook First Used" event (deduplicated per hook name) */
|
|
26
|
+
logHookFirstUsed(hookName: string): void;
|
|
27
|
+
/** Log a "SDK Dev Error" event */
|
|
28
|
+
logDevError(errorType: string, hookName: string): void;
|
|
29
|
+
/** Log a "SDK Dev Session Ended" event and tear down the store */
|
|
30
|
+
endSession(): void;
|
|
31
|
+
/** Tear down the store without logging a session-end event */
|
|
32
|
+
dispose(): void;
|
|
33
|
+
/** The set of hook names used during this session */
|
|
34
|
+
readonly hooksUsed: ReadonlySet<string>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Initializes dev-mode telemetry for a SDK instance if the environment
|
|
38
|
+
* qualifies. Both `telemetryManager` and `clientStore` are dynamically
|
|
39
|
+
* imported to avoid circular dependencies and to keep telemetry code
|
|
40
|
+
* out of production bundles via code splitting.
|
|
41
|
+
*
|
|
42
|
+
* The `projectId` must be passed explicitly because the resource
|
|
43
|
+
* configuration is typically set by the React layer after the
|
|
44
|
+
* instance has already been created.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
declare function initTelemetry(instance: SanityInstance, projectId: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves the telemetry manager for an instance, if one exists.
|
|
51
|
+
* Returns undefined when telemetry is disabled or not yet initialized.
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
declare function getTelemetryManager(instance: SanityInstance): TelemetryManager | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Record a hook name for an instance. If the telemetry manager is
|
|
58
|
+
* already initialized the event is logged immediately. Otherwise
|
|
59
|
+
* the name is buffered and flushed when init completes.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
declare function trackHookMounted(instance: SanityInstance, hookName: string): void;
|
|
64
|
+
export { type ApiErrorBody, PREVIEW_PROJECTION, createGroqSearchFilter, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getQueryKey, getTelemetryManager, getUsersKey, initTelemetry, isProjectUserNotFoundClientError, isStudioConfig, parseQueryKey, parseUsersKey, trackHookMounted, transformProjectionToPreview };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PREVIEW_PROJECTION, createGroqSearchFilter, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getQueryKey, getUsersKey, isProjectUserNotFoundClientError, isStudioConfig, parseQueryKey, parseUsersKey, transformProjectionToPreview } from "../_chunks-es/createGroqSearchFilter.js";
|
|
2
|
+
import { getTelemetryManager, initTelemetry, trackHookMounted } from "../_chunks-es/_internal.js";
|
|
3
|
+
export {
|
|
4
|
+
PREVIEW_PROJECTION,
|
|
5
|
+
createGroqSearchFilter,
|
|
6
|
+
getClientErrorApiBody,
|
|
7
|
+
getClientErrorApiDescription,
|
|
8
|
+
getClientErrorApiType,
|
|
9
|
+
getQueryKey,
|
|
10
|
+
getTelemetryManager,
|
|
11
|
+
getUsersKey,
|
|
12
|
+
initTelemetry,
|
|
13
|
+
isProjectUserNotFoundClientError,
|
|
14
|
+
isStudioConfig,
|
|
15
|
+
parseQueryKey,
|
|
16
|
+
parseUsersKey,
|
|
17
|
+
trackHookMounted,
|
|
18
|
+
transformProjectionToPreview
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=_internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_internal.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|