@sanity/sdk 3.0.0 → 3.2.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/_exports/_internal.d.ts +72 -19
- package/dist/_exports/_internal.d.ts.map +1 -1
- package/dist/_exports/_internal.js +130 -11
- package/dist/_exports/_internal.js.map +1 -1
- package/dist/_exports/agent.d.ts +7 -7
- package/dist/_exports/agent.d.ts.map +1 -1
- package/dist/_exports/agent.js +1 -1
- package/dist/_exports/comlink.d.ts +9 -9
- package/dist/_exports/comlink.d.ts.map +1 -1
- package/dist/_exports/comlink.js +2 -2
- package/dist/_exports/dashboard.d.ts +2 -0
- package/dist/_exports/dashboard.js +2 -0
- package/dist/{authStore-C0o1NOxW.d.ts → authStore-BO2vch3I.d.ts} +516 -63
- package/dist/authStore-BO2vch3I.d.ts.map +1 -0
- package/dist/{authStore-CtE9bLHW.js → clientStore-BI4D8HhJ.js} +390 -15
- package/dist/clientStore-BI4D8HhJ.js.map +1 -0
- package/dist/{createSanityInstance-DUI1bGIg.d.ts → createSanityInstance-BQIqyGLX.d.ts} +17 -2
- package/dist/createSanityInstance-BQIqyGLX.d.ts.map +1 -0
- package/dist/{createStateSourceAction-BOKtqFNm.js → createStateSourceAction-DdAhEfnZ.js} +7 -3
- package/dist/createStateSourceAction-DdAhEfnZ.js.map +1 -0
- package/dist/defineProperty-Bho9Ngsi.js +31 -0
- package/dist/{getNodeState-CR3__B2D.js → getNodeState-B4nG0sjm.js} +2 -2
- package/dist/{getNodeState-CR3__B2D.js.map → getNodeState-B4nG0sjm.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +370 -90
- package/dist/index.js.map +1 -1
- package/dist/topicStore-Ct7IFNtY.js +565 -0
- package/dist/topicStore-Ct7IFNtY.js.map +1 -0
- package/dist/topicStore-D0WqhQGF.d.ts +435 -0
- package/dist/topicStore-D0WqhQGF.d.ts.map +1 -0
- package/dist/{queryStore-C7yMHPUI.js → version-BcRmCiYi.js} +48 -16
- package/dist/version-BcRmCiYi.js.map +1 -0
- package/package.json +19 -18
- package/src/_exports/_internal.ts +13 -0
- package/src/_exports/dashboard.ts +36 -0
- package/src/_exports/index.ts +17 -1
- package/src/access/checkPermissions.test.ts +1 -1
- package/src/access/checkPermissions.ts +1 -1
- package/src/applications/applications.test-d.ts +28 -4
- package/src/applications/applications.test.ts +4 -4
- package/src/applications/applications.ts +43 -18
- package/src/auth/authMode.test.ts +24 -0
- package/src/auth/authMode.ts +8 -3
- package/src/auth/authStore.ts +12 -0
- package/src/auth/authStrategy.ts +2 -0
- package/src/auth/handleAuthCallback.test.ts +2 -2
- package/src/auth/handleAuthCallback.ts +1 -1
- package/src/auth/logout.test.ts +46 -1
- package/src/auth/logout.ts +2 -1
- package/src/auth/oauth/oauthActions.test.ts +457 -0
- package/src/auth/oauth/oauthActions.ts +389 -0
- package/src/auth/oauth/oauthAuth.test.ts +206 -0
- package/src/auth/oauth/oauthAuth.ts +168 -0
- package/src/auth/oauth/pkce.test.ts +44 -0
- package/src/auth/oauth/pkce.ts +60 -0
- package/src/auth/oauth/types.ts +12 -0
- package/src/auth/refreshStampedToken.ts +1 -1
- package/src/auth/studioModeAuth.test.ts +1 -1
- package/src/auth/studioModeAuth.ts +1 -1
- package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +2 -2
- package/src/auth/subscribeToStateAndFetchCurrentUser.ts +1 -1
- package/src/comments/addonDatasetStore.test.ts +2 -2
- package/src/comments/addonDatasetStore.ts +2 -2
- package/src/comments/commentActions.ts +6 -5
- package/src/comments/commentsStore.ts +4 -4
- package/src/config/authConfig.ts +18 -0
- package/src/dashboard/messageBus/__fixtures__/test-topics.ts +18 -0
- package/src/dashboard/messageBus/bus.test.ts +1033 -0
- package/src/dashboard/messageBus/bus.ts +1246 -0
- package/src/dashboard/messageBus/store.test.ts +142 -0
- package/src/dashboard/messageBus/store.ts +74 -0
- package/src/dashboard/messageBus/topicStore.test.ts +172 -0
- package/src/dashboard/messageBus/topicStore.ts +184 -0
- package/src/dashboard/messageBus/topics.test.ts +71 -0
- package/src/dashboard/messageBus/topics.ts +260 -0
- package/src/document/actions.ts +3 -3
- package/src/document/applyDocumentActions.ts +5 -9
- package/src/document/documentStore.concurrency.test.ts +2 -1
- package/src/document/documentStore.test.ts +19 -18
- package/src/document/documentStore.ts +17 -17
- package/src/document/permissions.ts +2 -1
- package/src/document/processActions.test.ts +2 -1
- package/src/document/processMutations.ts +61 -24
- package/src/document/reducers.ts +2 -2
- package/src/installations/installations.test-d.ts +3 -3
- package/src/installations/installations.test.ts +2 -2
- package/src/installations/installations.ts +4 -21
- package/src/organization/organization.test.ts +2 -2
- package/src/organization/organization.ts +1 -1
- package/src/organizations/organizations.test.ts +2 -2
- package/src/organizations/organizations.ts +1 -1
- package/src/presence/presenceStore.test.ts +15 -22
- package/src/presence/presenceStore.ts +3 -2
- package/src/project/project.test.ts +3 -3
- package/src/project/project.ts +1 -1
- package/src/projection/getProjectionState.test.ts +6 -4
- package/src/projection/getProjectionState.ts +4 -4
- package/src/projection/resolveProjection.ts +2 -2
- package/src/projects/projects.test.ts +2 -2
- package/src/projects/projects.ts +1 -1
- package/src/query/queryStore.ts +6 -6
- package/src/store/createSanityInstance.test.ts +1 -1
- package/src/store/createSanityInstance.ts +4 -4
- package/src/store/createStoreInstance.test.ts +0 -5
- package/src/telemetry/telemetryManager.test.ts +1 -1
- package/src/telemetry/telemetryManager.ts +2 -2
- package/src/typegen/defineProjection.test.ts +17 -0
- package/src/typegen/defineProjection.ts +19 -0
- package/src/typegen/groqCompat.ts +122 -0
- package/src/typegen/resolve.ts +37 -0
- package/src/users/usersStore.test.ts +1 -1
- package/src/users/usersStore.ts +5 -5
- package/src/utils/createGroqSearchFilter.test.ts +8 -0
- package/src/utils/createGroqSearchFilter.ts +6 -3
- package/src/utils/ids.test.ts +40 -15
- package/src/utils/ids.ts +47 -2
- package/dist/authStore-C0o1NOxW.d.ts.map +0 -1
- package/dist/authStore-CtE9bLHW.js.map +0 -1
- package/dist/clientStore-BtE2-q2i.js +0 -90
- package/dist/clientStore-BtE2-q2i.js.map +0 -1
- package/dist/createSanityInstance-DUI1bGIg.d.ts.map +0 -1
- package/dist/createStateSourceAction-BOKtqFNm.js.map +0 -1
- package/dist/getEnv-D5RGkQLu.js +0 -8
- package/dist/getEnv-D5RGkQLu.js.map +0 -1
- package/dist/logger-DAtJb5RQ.js +0 -173
- package/dist/logger-DAtJb5RQ.js.map +0 -1
- package/dist/queryStore-C7yMHPUI.js.map +0 -1
- package/dist/rolldown-runtime-vyAXikos.js +0 -9
- package/dist/telemetryManager-UIEiMtC0.js +0 -127
- package/dist/telemetryManager-UIEiMtC0.js.map +0 -1
- package/dist/version-D8RP_Q59.js +0 -9
- package/dist/version-D8RP_Q59.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as AuthConfig, c as DocumentTypeHandle, d as ProjectHandle, f as ReleaseHandle, i as DatasetHandle, o as DocumentHandle, s as DocumentResource, t as SanityInstance, u as PerspectiveHandle, x as AuthProvider } from "./createSanityInstance-
|
|
1
|
+
import { b as AuthConfig, c as DocumentTypeHandle, d as ProjectHandle, f as ReleaseHandle, i as DatasetHandle, o as DocumentHandle, s as DocumentResource, t as SanityInstance, u as PerspectiveHandle, x as AuthProvider } from "./createSanityInstance-BQIqyGLX.js";
|
|
2
2
|
import { ClientConfig, ClientPerspective, DatasetsResponse, ListenEvent, MultipleMutationResult, ReleaseDocument, ReleaseDocument as ReleaseDocument$1, ResponseQueryOptions, SanityClient, SanityDocument, SanityProject } from "@sanity/client";
|
|
3
3
|
import { Observable, Subject } from "rxjs";
|
|
4
|
-
import { CurrentUser, CurrentUser as CurrentUser$1, Mutation, PatchOperations, Path, PortableTextBlock, Role, SanityDocument as SanityDocument$1, SanityDocument as SanityDocument$3, SanityDocumentLike } from "@sanity/types";
|
|
4
|
+
import { CurrentUser, CurrentUser as CurrentUser$1, InsertPatch, Mutation, PatchOperations, Path, PortableTextBlock, Role, SanityDocument as SanityDocument$1, SanityDocument as SanityDocument$3, SanityDocumentLike } from "@sanity/types";
|
|
5
5
|
import "zustand/middleware";
|
|
6
6
|
import { getIndexForKey as getIndexForKey$1, getPathDepth, joinPaths, jsonMatch as jsonMatch$1, slicePath as slicePath$1, stringifyPath as stringifyPath$1 } from "@sanity/json-match";
|
|
7
7
|
import { PatchMutation } from "@sanity/mutate/_unstable_store";
|
|
@@ -420,25 +420,51 @@ type IncludesAny<Requested extends string, Set extends string> = [Requested & Se
|
|
|
420
420
|
* @public
|
|
421
421
|
*/
|
|
422
422
|
type ApplicationInclude = 'interfaces' | 'workspaces' | 'access' | 'config.studio' | 'config.mfManifest' | 'activeDeployment';
|
|
423
|
-
|
|
424
|
-
* An interface exposed by a deployment, embedded when `interfaces` is included.
|
|
425
|
-
*
|
|
426
|
-
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
427
|
-
* @public
|
|
428
|
-
*/
|
|
429
|
-
interface ApplicationInterface {
|
|
423
|
+
type ApplicationInterfaceBase = {
|
|
430
424
|
id: string;
|
|
431
|
-
type: 'app' | 'worker' | 'asset_source' | 'panel';
|
|
432
425
|
name: string;
|
|
433
426
|
title: string;
|
|
434
427
|
version: string;
|
|
435
428
|
/** Module federation module ID; resolved from the host mf-manifest at runtime */
|
|
436
429
|
moduleId: string;
|
|
437
|
-
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* Placement metadata for application and panel interfaces.
|
|
433
|
+
*
|
|
434
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
435
|
+
* @public
|
|
436
|
+
*/
|
|
437
|
+
type ApplicationInterfacePlacementMetadata = {
|
|
438
|
+
dock?: {
|
|
438
439
|
group?: string;
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
}
|
|
440
|
+
order?: number;
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* An interface exposed by a deployment, embedded when `interfaces` is included.
|
|
445
|
+
*
|
|
446
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
447
|
+
* @public
|
|
448
|
+
*/
|
|
449
|
+
type ApplicationInterface = ApplicationInterfaceBase & ({
|
|
450
|
+
type: 'app';
|
|
451
|
+
metadata: ApplicationInterfacePlacementMetadata | null;
|
|
452
|
+
} | {
|
|
453
|
+
type: 'panel';
|
|
454
|
+
metadata: ApplicationInterfacePlacementMetadata | null;
|
|
455
|
+
} | {
|
|
456
|
+
type: 'asset_source';
|
|
457
|
+
metadata: null;
|
|
458
|
+
} | {
|
|
459
|
+
type: 'worker';
|
|
460
|
+
metadata: null;
|
|
461
|
+
} | {
|
|
462
|
+
type: 'tile';
|
|
463
|
+
metadata: {
|
|
464
|
+
order?: number;
|
|
465
|
+
size: 'small' | 'large' | 'banner';
|
|
466
|
+
};
|
|
467
|
+
});
|
|
442
468
|
/**
|
|
443
469
|
* A studio workspace of a deployment, embedded when `workspaces` is included.
|
|
444
470
|
* Studio applications only.
|
|
@@ -531,15 +557,17 @@ interface ApplicationBase {
|
|
|
531
557
|
updatedAt: string;
|
|
532
558
|
}
|
|
533
559
|
type DeploymentToken = 'activeDeployment' | 'interfaces' | 'workspaces' | 'access';
|
|
534
|
-
type
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
};
|
|
560
|
+
type ConfigToken = 'config.studio' | 'config.mfManifest';
|
|
561
|
+
type ApplicationConfig<Include extends ApplicationInclude> = Included<ApplicationInclude, 'config.studio', Include, {
|
|
562
|
+
studio?: ApplicationStudioConfig;
|
|
538
563
|
}> & Included<ApplicationInclude, 'config.mfManifest', Include, {
|
|
539
|
-
|
|
540
|
-
mfManifest: unknown;
|
|
541
|
-
};
|
|
564
|
+
mfManifest?: unknown;
|
|
542
565
|
}>;
|
|
566
|
+
type ApplicationConfigShape<Include extends ApplicationInclude> = [ApplicationInclude] extends [Include] ? {
|
|
567
|
+
config?: ApplicationConfig<Include>;
|
|
568
|
+
} : IncludesAny<Include, ConfigToken> extends true ? {
|
|
569
|
+
config: ApplicationConfig<Include>;
|
|
570
|
+
} : unknown;
|
|
543
571
|
type ApplicationDeploymentShape<Include extends ApplicationInclude> = [ApplicationInclude] extends [Include] ? {
|
|
544
572
|
activeDeployment?: ApplicationDeployment<Include> | null;
|
|
545
573
|
} : IncludesAny<Include, DeploymentToken> extends true ? {
|
|
@@ -683,6 +711,62 @@ declare const handleAuthCallback: BoundStoreAction<AuthStoreState, [locationHref
|
|
|
683
711
|
* @public
|
|
684
712
|
*/
|
|
685
713
|
declare const logout: BoundStoreAction<AuthStoreState, [], Promise<void>>;
|
|
714
|
+
/**
|
|
715
|
+
* OAuth tokens issued by Sanity's OAuth token endpoint.
|
|
716
|
+
*
|
|
717
|
+
* @public
|
|
718
|
+
*/
|
|
719
|
+
interface OAuthTokens {
|
|
720
|
+
accessToken: string;
|
|
721
|
+
tokenType: 'bearer';
|
|
722
|
+
expiresIn: number;
|
|
723
|
+
expiresAt: Date;
|
|
724
|
+
refreshToken?: string;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Starts the OAuth authorization-code + PKCE flow: generates a `code_verifier`,
|
|
728
|
+
* `code_challenge` and `state`, persists the verifier and state to
|
|
729
|
+
* `sessionStorage`, then navigates the browser to the authorize endpoint.
|
|
730
|
+
*
|
|
731
|
+
* @public
|
|
732
|
+
*/
|
|
733
|
+
declare const startOAuthAuthorization: BoundStoreAction<AuthStoreState, [], Promise<void>>;
|
|
734
|
+
/**
|
|
735
|
+
* Handles the OAuth redirect callback: validates `state`, surfaces `error`
|
|
736
|
+
* responses, exchanges the authorization `code` for tokens, persists them, and
|
|
737
|
+
* transitions to `LOGGED_IN`.
|
|
738
|
+
*
|
|
739
|
+
* Returns the callback URL cleaned of OAuth params (for the caller to
|
|
740
|
+
* `history.replaceState`) when a callback was processed, or `false` when there
|
|
741
|
+
* was nothing to handle (no code, or an exchange already in progress).
|
|
742
|
+
*
|
|
743
|
+
* @public
|
|
744
|
+
*/
|
|
745
|
+
declare const handleOAuthCallback: BoundStoreAction<AuthStoreState, [locationHref?: string | undefined], Promise<string | false>>;
|
|
746
|
+
/**
|
|
747
|
+
* Refreshes the OAuth tokens using the `refresh_token` grant. Concurrent
|
|
748
|
+
* callers share a single in-flight request. An unrecoverable failure (a 4xx
|
|
749
|
+
* rejecting the refresh token) clears the tokens and transitions to
|
|
750
|
+
* `LOGGED_OUT`; transient failures (network, 5xx, rate limits) leave the
|
|
751
|
+
* session intact and rethrow so the caller can retry.
|
|
752
|
+
*
|
|
753
|
+
* @public
|
|
754
|
+
*/
|
|
755
|
+
declare const refreshOAuthTokens: BoundStoreAction<AuthStoreState, [], Promise<OAuthTokens | null>>;
|
|
756
|
+
/**
|
|
757
|
+
* Revokes the OAuth tokens then clears local storage and transitions to `LOGGED_OUT`.
|
|
758
|
+
* Local state is cleared even if the revoke request fails.
|
|
759
|
+
*
|
|
760
|
+
* @public
|
|
761
|
+
*/
|
|
762
|
+
declare const revokeOAuthTokens: BoundStoreAction<AuthStoreState, [], Promise<void>>;
|
|
763
|
+
/**
|
|
764
|
+
* A state source exposing the current OAuth tokens (including expiry), or
|
|
765
|
+
* `null` when not logged in via OAuth.
|
|
766
|
+
*
|
|
767
|
+
* @public
|
|
768
|
+
*/
|
|
769
|
+
declare const getOAuthTokensState: BoundStoreAction<AuthStoreState, [], StateSource<OAuthTokens | null>>;
|
|
686
770
|
type AllowedClientConfigKey = 'useCdn' | 'token' | 'perspective' | 'apiHost' | 'proxy' | 'withCredentials' | 'timeout' | 'maxRetries' | 'dataset' | 'projectId' | 'requestTagPrefix' | 'useProjectHostname';
|
|
687
771
|
/**
|
|
688
772
|
* States tracked by the client store
|
|
@@ -1260,6 +1344,17 @@ interface Logger {
|
|
|
1260
1344
|
/** Get the instance context if available */
|
|
1261
1345
|
getInstanceContext: () => InstanceContext | undefined;
|
|
1262
1346
|
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Create a logger for a specific namespace
|
|
1349
|
+
* @param namespace - A string identifier for the logging domain (e.g., 'auth', 'document')
|
|
1350
|
+
* @param baseContext - Optional base context to include in all log messages
|
|
1351
|
+
* @remarks
|
|
1352
|
+
* If baseContext includes an `instanceContext` property (with projectId, dataset, instanceId),
|
|
1353
|
+
* it will be automatically formatted into the log output for easier debugging of
|
|
1354
|
+
* multi-instance scenarios.
|
|
1355
|
+
* @public
|
|
1356
|
+
*/
|
|
1357
|
+
declare function createLogger(namespace: string, baseContext?: LogContext): Logger;
|
|
1263
1358
|
/**
|
|
1264
1359
|
* Configure logging for the Sanity SDK
|
|
1265
1360
|
*
|
|
@@ -1371,6 +1466,104 @@ declare function configureLogging(config: LoggerConfig): void;
|
|
|
1371
1466
|
* @internal
|
|
1372
1467
|
*/
|
|
1373
1468
|
declare const datasets: Fetcher<[options?: ProjectHandle<string> | undefined], DatasetsResponse>;
|
|
1469
|
+
/**
|
|
1470
|
+
* Augments `groq` with the type surface of `groq@3.88.1-typegen-experimental.0`, the fork
|
|
1471
|
+
* this package depended on before GA `groq`.
|
|
1472
|
+
*
|
|
1473
|
+
* A `sanity.types.ts` from the experimental Typegen flow imports these helpers from
|
|
1474
|
+
* `groq` and augments these interfaces. GA `groq` exports only `defineQuery` and the
|
|
1475
|
+
* template tag, so those files stop typechecking without this one.
|
|
1476
|
+
*
|
|
1477
|
+
* `defineProjection` is absent: it is a runtime function, and declaring it in a
|
|
1478
|
+
* type-only augmentation turns a compile error into `undefined is not a function`.
|
|
1479
|
+
* `@sanity/sdk` exports it instead.
|
|
1480
|
+
*
|
|
1481
|
+
* Keep these declarations while the SDK supports existing experimental generated files.
|
|
1482
|
+
*/
|
|
1483
|
+
declare module 'groq' {
|
|
1484
|
+
/**
|
|
1485
|
+
* Brands a type with the resource it came from so one flat interface can hold entries
|
|
1486
|
+
* from more than one schema; {@link PickSchema} narrows it back out.
|
|
1487
|
+
*/
|
|
1488
|
+
type SchemaOrigin<TBase, TSchemaId extends string> = TBase & {
|
|
1489
|
+
/**
|
|
1490
|
+
* @internal
|
|
1491
|
+
* @deprecated typescript helper only
|
|
1492
|
+
*/
|
|
1493
|
+
__schemaId?: TSchemaId;
|
|
1494
|
+
};
|
|
1495
|
+
/**
|
|
1496
|
+
* Brands a projection result with the document type it was evaluated against;
|
|
1497
|
+
* {@link PickProjectionResult} narrows it back out.
|
|
1498
|
+
*/
|
|
1499
|
+
type ProjectionBase<TBase, TProjectionBaseTypeName extends string> = TBase & {
|
|
1500
|
+
/**
|
|
1501
|
+
* @internal
|
|
1502
|
+
* @deprecated typescript helper only
|
|
1503
|
+
*/
|
|
1504
|
+
__schemaTypeName?: TProjectionBaseTypeName;
|
|
1505
|
+
};
|
|
1506
|
+
/** Extracts the members of `T` that came from the schema `TSchemaId`. */
|
|
1507
|
+
type PickSchema<T, TSchemaId extends string = string> = Extract<T, SchemaOrigin<T, TSchemaId>>;
|
|
1508
|
+
/** Extracts the members of `T` projected from the document type `TProjectionBaseTypeName`. */
|
|
1509
|
+
type PickProjectionResult<T, TProjectionBaseTypeName extends string = string> = Extract<T, ProjectionBase<T, TProjectionBaseTypeName>>;
|
|
1510
|
+
/** Augmented by generated files: resource key to the union of that schema's types. */
|
|
1511
|
+
interface SanitySchemas {}
|
|
1512
|
+
/** Augmented by generated files: query string to its result type. */
|
|
1513
|
+
interface SanityQueries {}
|
|
1514
|
+
/** Augmented by generated files: projection string to its result type. */
|
|
1515
|
+
interface SanityProjections {}
|
|
1516
|
+
/**
|
|
1517
|
+
* Indexes an augmented interface, falling back to the union of every registered value
|
|
1518
|
+
* when the key is absent. Code generated against the fork relies on that fallback, so
|
|
1519
|
+
* narrowing it to `never` changes what existing apps infer.
|
|
1520
|
+
*/
|
|
1521
|
+
type SafeAccess<T, K extends string> = K extends keyof T ? T[K] : T[keyof T];
|
|
1522
|
+
/** Fields Sanity adds to every document. */
|
|
1523
|
+
interface SanityDocumentShape {
|
|
1524
|
+
_id: string;
|
|
1525
|
+
_type: string;
|
|
1526
|
+
_createdAt: string;
|
|
1527
|
+
_updatedAt: string;
|
|
1528
|
+
_rev: string;
|
|
1529
|
+
[key: string]: unknown;
|
|
1530
|
+
}
|
|
1531
|
+
/** All types registered for one resource. */
|
|
1532
|
+
type SanitySchema<TSchemaId extends string = string> = PickSchema<SafeAccess<SanitySchemas, TSchemaId>, TSchemaId>;
|
|
1533
|
+
/** One schema type, selected by its `_type` and its resource. */
|
|
1534
|
+
type SanitySchemaType<TSchemaTypeName extends string = string, TSchemaId extends string = string> = Extract<SanitySchema<TSchemaId>, {
|
|
1535
|
+
_type: TSchemaTypeName;
|
|
1536
|
+
}>;
|
|
1537
|
+
/** One document type, selected by its `_type` and its resource. */
|
|
1538
|
+
type SanityDocument<TDocumentType extends string = string, TSchemaId extends string = string> = Extract<Extract<SanitySchema<TSchemaId>, SanityDocumentShape> | SanityDocumentShape, {
|
|
1539
|
+
_type: TDocumentType;
|
|
1540
|
+
}>;
|
|
1541
|
+
/** The result of a registered query, for one resource. */
|
|
1542
|
+
type SanityQueryResult<TQuery extends string = string, TSchemaId extends string = string> = Extract<SafeAccess<SanityQueries, TQuery>, SchemaOrigin<SafeAccess<SanityQueries, TQuery>, TSchemaId>>;
|
|
1543
|
+
/** The result of a registered projection, for one document type and one resource. */
|
|
1544
|
+
type SanityProjectionResult<TProjection extends string = string, TProjectionBaseTypeName extends string = string, TSchemaId extends string = string> = PickSchema<PickProjectionResult<SafeAccess<SanityProjections, TProjection>, TProjectionBaseTypeName>, TSchemaId>;
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* Resolves a document using declarations from experimental Typegen.
|
|
1548
|
+
* Preserves the legacy lookup behavior while the SDK uses released `groq`.
|
|
1549
|
+
*
|
|
1550
|
+
* @beta
|
|
1551
|
+
*/
|
|
1552
|
+
type ResolveDocument<TDocumentType extends string = string, TSchemaId extends string = string> = SanityDocument$2<TDocumentType, TSchemaId>;
|
|
1553
|
+
/**
|
|
1554
|
+
* Resolves a query using declarations from experimental Typegen.
|
|
1555
|
+
* For types generated by current Typegen, pass the result type to the hook explicitly.
|
|
1556
|
+
*
|
|
1557
|
+
* @beta
|
|
1558
|
+
*/
|
|
1559
|
+
type ResolveQueryResult<TQuery extends string = string, TSchemaId extends string = string> = SanityQueryResult<TQuery, TSchemaId>;
|
|
1560
|
+
/**
|
|
1561
|
+
* Resolves a projection using declarations from experimental Typegen.
|
|
1562
|
+
* Selects the result by projection string, document type, and schema ID.
|
|
1563
|
+
*
|
|
1564
|
+
* @beta
|
|
1565
|
+
*/
|
|
1566
|
+
type ResolveProjectionResult<TProjection extends string = string, TDocumentType extends string = string, TSchemaId extends string = string> = SanityProjectionResult<TProjection, TDocumentType, TSchemaId>;
|
|
1374
1567
|
/**
|
|
1375
1568
|
* Represents an action to create a new document.
|
|
1376
1569
|
* Specifies the document type and optionally a document ID (which will be treated as the published ID).
|
|
@@ -1383,7 +1576,7 @@ interface CreateDocumentAction<TDocumentType extends string = string, TDataset e
|
|
|
1383
1576
|
* These values will be set when the document is created.
|
|
1384
1577
|
* System fields (_id, _type, _rev, _createdAt, _updatedAt) are omitted as they are set automatically.
|
|
1385
1578
|
*/
|
|
1386
|
-
initialValue?: Partial<Omit<
|
|
1579
|
+
initialValue?: Partial<Omit<ResolveDocument<TDocumentType, `${TProjectId}.${TDataset}`>, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>;
|
|
1387
1580
|
}
|
|
1388
1581
|
/**
|
|
1389
1582
|
* Represents an action to delete an existing document.
|
|
@@ -1459,7 +1652,7 @@ type Action<TDocumentType extends string = string, TDataset extends string = str
|
|
|
1459
1652
|
* @returns A `CreateDocumentAction` object ready for dispatch.
|
|
1460
1653
|
* @beta
|
|
1461
1654
|
*/
|
|
1462
|
-
declare function createDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>, initialValue?: Partial<Omit<
|
|
1655
|
+
declare function createDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>, initialValue?: Partial<Omit<ResolveDocument<TDocumentType, `${TProjectId}.${TDataset}`>, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>): CreateDocumentAction<TDocumentType, TDataset, TProjectId>;
|
|
1463
1656
|
/**
|
|
1464
1657
|
* Creates a `DeleteDocumentAction` object.
|
|
1465
1658
|
* @param doc - A handle uniquely identifying the document to be deleted.
|
|
@@ -1639,12 +1832,275 @@ type DeepGet<TValue, TPath extends readonly (string | number)[]> = TPath extends
|
|
|
1639
1832
|
*/
|
|
1640
1833
|
type JsonMatch<TDocument, TPath extends string> = DeepGet<TDocument, PathParts<TPath>>;
|
|
1641
1834
|
/**
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1835
|
+
* Given an input object and a record of path expressions to values, this
|
|
1836
|
+
* function will set each match with the given value.
|
|
1837
|
+
*
|
|
1838
|
+
* ```js
|
|
1839
|
+
* const output = set(
|
|
1840
|
+
* {name: {first: 'initial', last: 'initial'}},
|
|
1841
|
+
* {'name.first': 'changed'}
|
|
1842
|
+
* );
|
|
1843
|
+
*
|
|
1844
|
+
* // { name: { first: 'changed', last: 'initial' } }
|
|
1845
|
+
* console.log(output);
|
|
1846
|
+
* ```
|
|
1847
|
+
*/
|
|
1848
|
+
declare function set<R>(input: unknown, pathExpressionValues: Record<string, unknown>): R;
|
|
1849
|
+
/**
|
|
1850
|
+
* Given an input object and a record of path expressions to values, this
|
|
1851
|
+
* function will set each match with the given value **if the value at the current
|
|
1852
|
+
* path is missing** (i.e. `null` or `undefined`).
|
|
1853
|
+
*
|
|
1854
|
+
* ```js
|
|
1855
|
+
* const output = setIfMissing(
|
|
1856
|
+
* {items: [null, 'initial']},
|
|
1857
|
+
* {'items[:]': 'changed'}
|
|
1858
|
+
* );
|
|
1859
|
+
*
|
|
1860
|
+
* // { items: ['changed', 'initial'] }
|
|
1861
|
+
* console.log(output);
|
|
1862
|
+
* ```
|
|
1863
|
+
*/
|
|
1864
|
+
declare function setIfMissing<R>(input: unknown, pathExpressionValues: Record<string, unknown>): R;
|
|
1865
|
+
/**
|
|
1866
|
+
* Given an input object and an array of path expressions, this function will
|
|
1867
|
+
* remove each match from the input object.
|
|
1868
|
+
*
|
|
1869
|
+
* ```js
|
|
1870
|
+
* const output = unset(
|
|
1871
|
+
* {name: {first: 'one', last: 'two'}},
|
|
1872
|
+
* ['name.last']
|
|
1873
|
+
* );
|
|
1874
|
+
*
|
|
1875
|
+
* // { name: { first: 'one' } }
|
|
1876
|
+
* console.log(output);
|
|
1877
|
+
* ```
|
|
1878
|
+
*/
|
|
1879
|
+
declare function unset<R>(input: unknown, pathExpressions: string[]): R;
|
|
1880
|
+
/**
|
|
1881
|
+
* Given an input object, a path expression (inside the insert patch object), and an array of items,
|
|
1882
|
+
* this function will insert or replace the matched items.
|
|
1883
|
+
*
|
|
1884
|
+
* **Insert before:**
|
|
1885
|
+
*
|
|
1886
|
+
* ```js
|
|
1887
|
+
* const input = {some: {array: ['a', 'b', 'c']}}
|
|
1888
|
+
* const output = insert(
|
|
1889
|
+
* input,
|
|
1890
|
+
* {
|
|
1891
|
+
* before: 'some.array[1]',
|
|
1892
|
+
* items: ['!']
|
|
1893
|
+
* }
|
|
1894
|
+
* );
|
|
1895
|
+
* // { some: { array: ['a', '!', 'b', 'c'] } }
|
|
1896
|
+
* console.log(output);
|
|
1897
|
+
* ```
|
|
1898
|
+
*
|
|
1899
|
+
* **Insert before with negative index (append):**
|
|
1900
|
+
*
|
|
1901
|
+
* ```js
|
|
1902
|
+
* const input = {some: {array: ['a', 'b', 'c']}}
|
|
1903
|
+
* const output = insert(
|
|
1904
|
+
* input,
|
|
1905
|
+
* {
|
|
1906
|
+
* before: 'some.array[-1]',
|
|
1907
|
+
* items: ['!']
|
|
1908
|
+
* }
|
|
1909
|
+
* );
|
|
1910
|
+
* // { some: { array: ['a', 'b', 'c', '!'] } }
|
|
1911
|
+
* console.log(output);
|
|
1912
|
+
* ```
|
|
1913
|
+
*
|
|
1914
|
+
* **Insert after:**
|
|
1915
|
+
*
|
|
1916
|
+
* ```js
|
|
1917
|
+
* const input = {some: {array: ['a', 'b', 'c']}}
|
|
1918
|
+
* const output = insert(
|
|
1919
|
+
* input,
|
|
1920
|
+
* {
|
|
1921
|
+
* after: 'some.array[1]',
|
|
1922
|
+
* items: ['!']
|
|
1923
|
+
* }
|
|
1924
|
+
* );
|
|
1925
|
+
* // { some: { array: ['a', 'b', '!', 'c'] } }
|
|
1926
|
+
* console.log(output);
|
|
1927
|
+
* ```
|
|
1928
|
+
*
|
|
1929
|
+
* **Replace:**
|
|
1930
|
+
*
|
|
1931
|
+
* ```js
|
|
1932
|
+
* const output = insert(
|
|
1933
|
+
* { some: { array: ['a', 'b', 'c'] } },
|
|
1934
|
+
* {
|
|
1935
|
+
* replace: 'some.array[1]',
|
|
1936
|
+
* items: ['!']
|
|
1937
|
+
* }
|
|
1938
|
+
* );
|
|
1939
|
+
* // { some: { array: ['a', '!', 'c'] } }
|
|
1940
|
+
* console.log(output);
|
|
1941
|
+
* ```
|
|
1942
|
+
*
|
|
1943
|
+
* **Replace many:**
|
|
1944
|
+
*
|
|
1945
|
+
* ```js
|
|
1946
|
+
* const input = {some: {array: ['a', 'b', 'c', 'd']}}
|
|
1947
|
+
* const output = insert(
|
|
1948
|
+
* input,
|
|
1949
|
+
* {
|
|
1950
|
+
* replace: 'some.array[1:3]',
|
|
1951
|
+
* items: ['!', '?']
|
|
1952
|
+
* }
|
|
1953
|
+
* );
|
|
1954
|
+
* // { some: { array: ['a', '!', '?', 'd'] } }
|
|
1955
|
+
* console.log(output);
|
|
1956
|
+
* ```
|
|
1957
|
+
*/
|
|
1958
|
+
declare function insert<R>(input: unknown, insertPatch: InsertPatch): R;
|
|
1959
|
+
/**
|
|
1960
|
+
* Given an input object and a record of path expressions to numeric values,
|
|
1961
|
+
* this function will increment each match with the given value.
|
|
1962
|
+
*
|
|
1963
|
+
* ```js
|
|
1964
|
+
* const output = inc(
|
|
1965
|
+
* {foo: {first: 3, second: 4.5}},
|
|
1966
|
+
* {'foo.first': 3, 'foo.second': 4}
|
|
1967
|
+
* );
|
|
1968
|
+
*
|
|
1969
|
+
* // { foo: { first: 6, second: 8.5 } }
|
|
1970
|
+
* console.log(output);
|
|
1971
|
+
* ```
|
|
1972
|
+
*/
|
|
1973
|
+
declare function inc<R>(input: unknown, pathExpressionValues: Record<string, number>): R;
|
|
1974
|
+
/**
|
|
1975
|
+
* Given an input object and a record of path expressions to numeric values,
|
|
1976
|
+
* this function will decrement each match with the given value.
|
|
1977
|
+
*
|
|
1978
|
+
* ```js
|
|
1979
|
+
* const output = dec(
|
|
1980
|
+
* {foo: {first: 3, second: 4.5}},
|
|
1981
|
+
* {'foo.first': 3, 'foo.second': 4}
|
|
1982
|
+
* );
|
|
1983
|
+
*
|
|
1984
|
+
* // { foo: { first: 0, second: 0.5 } }
|
|
1985
|
+
* console.log(output);
|
|
1986
|
+
* ```
|
|
1987
|
+
*/
|
|
1988
|
+
declare function dec<R>(input: unknown, pathExpressionValues: Record<string, number>): R;
|
|
1989
|
+
/**
|
|
1990
|
+
* Given an input object and a record of paths to [diff match patches][0], this
|
|
1991
|
+
* function will apply the diff match patch for the string at each match.
|
|
1992
|
+
*
|
|
1993
|
+
* [0]: https://www.sanity.io/docs/http-patches#aTbJhlAJ
|
|
1994
|
+
*
|
|
1995
|
+
* ```js
|
|
1996
|
+
* const output = diffMatchPatch(
|
|
1997
|
+
* {foo: 'the quick brown fox'},
|
|
1998
|
+
* {'foo': '@@ -13,7 +13,7 @@\n own \n-fox\n+cat\n'}
|
|
1999
|
+
* );
|
|
2000
|
+
*
|
|
2001
|
+
* // { foo: 'the quick brown cat' }
|
|
2002
|
+
* console.log(output);
|
|
2003
|
+
* ```
|
|
2004
|
+
*/
|
|
2005
|
+
declare function diffMatchPatch<R>(input: unknown, pathExpressionValues: Record<string, string>): R;
|
|
2006
|
+
/**
|
|
2007
|
+
* Simply checks if the given document input has a `_rev` that matches the given
|
|
2008
|
+
* `revisionId` and throws otherwise.
|
|
2009
|
+
*
|
|
2010
|
+
* (No code example provided.)
|
|
2011
|
+
*/
|
|
2012
|
+
declare function ifRevisionID<R>(input: unknown, revisionId: string): R;
|
|
2013
|
+
/**
|
|
2014
|
+
* Maps document IDs to documents, using `null` for documents that do not exist.
|
|
2015
|
+
*
|
|
2016
|
+
* @beta
|
|
1646
2017
|
*/
|
|
1647
2018
|
type DocumentSet<TDocument extends SanityDocument$1 = SanityDocument$1> = { [TDocumentId in string]?: TDocument | null; };
|
|
2019
|
+
/**
|
|
2020
|
+
* Exposes the patch operations used by {@link processMutations}.
|
|
2021
|
+
*
|
|
2022
|
+
* @remarks
|
|
2023
|
+
* Property order determines execution order in {@link processMutations}:
|
|
2024
|
+
* `ifRevisionID`, `set`, `setIfMissing`, `unset`, `inc`, `dec`, `insert`,
|
|
2025
|
+
* then `diffMatchPatch`. Reordering the properties changes mutation results.
|
|
2026
|
+
* Freezes the collection to prevent callers from replacing the functions
|
|
2027
|
+
* used by the SDK's mutation evaluator.
|
|
2028
|
+
*
|
|
2029
|
+
* @see https://www.sanity.io/docs/http-mutations#5b4db1396e56
|
|
2030
|
+
*
|
|
2031
|
+
* @example
|
|
2032
|
+
* ```ts
|
|
2033
|
+
* const document = {items: [{_key: 'a', title: 'Before'}]}
|
|
2034
|
+
* const updated = patchOperations.set<typeof document>(document, {
|
|
2035
|
+
* 'items[_key=="a"].title': 'After',
|
|
2036
|
+
* })
|
|
2037
|
+
* ```
|
|
2038
|
+
*
|
|
2039
|
+
* @internal
|
|
2040
|
+
*/
|
|
2041
|
+
declare const patchOperations: Readonly<{
|
|
2042
|
+
ifRevisionID: typeof ifRevisionID;
|
|
2043
|
+
set: typeof set;
|
|
2044
|
+
setIfMissing: typeof setIfMissing;
|
|
2045
|
+
unset: typeof unset;
|
|
2046
|
+
inc: typeof inc;
|
|
2047
|
+
dec: typeof dec;
|
|
2048
|
+
insert: typeof insert;
|
|
2049
|
+
diffMatchPatch: typeof diffMatchPatch;
|
|
2050
|
+
}>;
|
|
2051
|
+
/**
|
|
2052
|
+
* Configures {@link processMutations}.
|
|
2053
|
+
*
|
|
2054
|
+
* @internal
|
|
2055
|
+
*/
|
|
2056
|
+
interface ProcessMutationsOptions {
|
|
2057
|
+
/**
|
|
2058
|
+
* The transaction ID that will become the next `_rev` for documents mutated
|
|
2059
|
+
* by the given mutations.
|
|
2060
|
+
*/
|
|
2061
|
+
transactionId: string;
|
|
2062
|
+
/**
|
|
2063
|
+
* The input document set that the mutations will be applied to.
|
|
2064
|
+
*/
|
|
2065
|
+
documents: DocumentSet;
|
|
2066
|
+
/**
|
|
2067
|
+
* A list of mutations to apply to the given document set.
|
|
2068
|
+
*/
|
|
2069
|
+
mutations: Mutation[];
|
|
2070
|
+
/**
|
|
2071
|
+
* Supplies the default `_createdAt` and `_updatedAt` timestamps.
|
|
2072
|
+
* Uses the current time when omitted or empty.
|
|
2073
|
+
*/
|
|
2074
|
+
timestamp?: string;
|
|
2075
|
+
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Applies mutations to an in-memory set of Sanity documents.
|
|
2078
|
+
* Deleted documents remain in the returned set with a value of `null`.
|
|
2079
|
+
*
|
|
2080
|
+
* Include every document affected by `mutations` in `documents`, using `null`
|
|
2081
|
+
* for documents that do not exist.
|
|
2082
|
+
*
|
|
2083
|
+
* Returns `documents` itself when `mutations` is empty. Otherwise, returns a
|
|
2084
|
+
* shallow copy of that object. The result can reuse document objects and
|
|
2085
|
+
* nested objects from `documents`. Mutating a reused object through the
|
|
2086
|
+
* result also changes the input.
|
|
2087
|
+
*
|
|
2088
|
+
* Sets `_rev` to `transactionId` on created, replaced, and patched documents.
|
|
2089
|
+
* Uses `timestamp` for timestamps unless the mutation preserves them.
|
|
2090
|
+
* Ignores `merge` patches; `inc` and `dec` skip values that are not numbers.
|
|
2091
|
+
* Generates document IDs when omitted or ending in `.`.
|
|
2092
|
+
* Patch operations can generate missing array keys.
|
|
2093
|
+
*
|
|
2094
|
+
* Does not persist documents or run Content Lake's server validation.
|
|
2095
|
+
*
|
|
2096
|
+
* @throws If a selection uses a query, a `create` targets an existing document,
|
|
2097
|
+
* or a `patch` targets a document that does not exist.
|
|
2098
|
+
* @throws If a patch operation fails, including a revision check failure or
|
|
2099
|
+
* `diffMatchPatch` applied to a value other than a string or `undefined`.
|
|
2100
|
+
*
|
|
2101
|
+
* @internal
|
|
2102
|
+
*/
|
|
2103
|
+
declare function processMutations({ documents, mutations, transactionId, timestamp }: ProcessMutationsOptions): DocumentSet;
|
|
1648
2104
|
type Grant = 'read' | 'update' | 'create' | 'history';
|
|
1649
2105
|
/** @beta */
|
|
1650
2106
|
interface PermissionDeniedReason {
|
|
@@ -1678,7 +2134,7 @@ interface DocumentStoreState {
|
|
|
1678
2134
|
identity?: string;
|
|
1679
2135
|
error?: unknown;
|
|
1680
2136
|
sharedListener: SharedListener;
|
|
1681
|
-
fetchDocument: (documentId: string) => Observable<
|
|
2137
|
+
fetchDocument: (documentId: string) => Observable<ResolveDocument | null>;
|
|
1682
2138
|
events: Subject<DocumentEvent>;
|
|
1683
2139
|
}
|
|
1684
2140
|
interface DocumentState {
|
|
@@ -1687,12 +2143,12 @@ interface DocumentState {
|
|
|
1687
2143
|
* the "remote" local copy that matches the server. represents the last known
|
|
1688
2144
|
* server state. this gets updated every time we confirm remote patches
|
|
1689
2145
|
*/
|
|
1690
|
-
remote?:
|
|
2146
|
+
remote?: ResolveDocument | null;
|
|
1691
2147
|
/**
|
|
1692
2148
|
* the current ephemeral working copy that includes local optimistic changes
|
|
1693
2149
|
* that have not yet been confirmed by the server
|
|
1694
2150
|
*/
|
|
1695
|
-
local?:
|
|
2151
|
+
local?: ResolveDocument | null;
|
|
1696
2152
|
/**
|
|
1697
2153
|
* the revision that our remote document is at
|
|
1698
2154
|
*/
|
|
@@ -1731,15 +2187,15 @@ interface DocumentOptions<TPath extends string | undefined = undefined, TDocumen
|
|
|
1731
2187
|
path?: TPath;
|
|
1732
2188
|
}
|
|
1733
2189
|
/** @beta */
|
|
1734
|
-
declare function getDocumentState<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: DocumentOptions<undefined, TDocumentType, TDataset, TProjectId>): StateSource<
|
|
2190
|
+
declare function getDocumentState<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: DocumentOptions<undefined, TDocumentType, TDataset, TProjectId>): StateSource<ResolveDocument<TDocumentType, `${TProjectId}.${TDataset}`> | undefined | null>;
|
|
1735
2191
|
/** @beta */
|
|
1736
|
-
declare function getDocumentState<TPath extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: DocumentOptions<TPath, TDocumentType, TDataset, TProjectId>): StateSource<JsonMatch<
|
|
2192
|
+
declare function getDocumentState<TPath extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: DocumentOptions<TPath, TDocumentType, TDataset, TProjectId>): StateSource<JsonMatch<ResolveDocument<TDocumentType, `${TProjectId}.${TDataset}`>, TPath> | undefined>;
|
|
1737
2193
|
/** @beta */
|
|
1738
2194
|
declare function getDocumentState<TData>(instance: SanityInstance, options: DocumentOptions<string | undefined>): StateSource<TData | undefined | null>;
|
|
1739
2195
|
/** @beta */
|
|
1740
|
-
declare function resolveDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, docHandle: DocumentHandle<TDocumentType, TDataset, TProjectId>): Promise<
|
|
2196
|
+
declare function resolveDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, docHandle: DocumentHandle<TDocumentType, TDataset, TProjectId>): Promise<ResolveDocument<TDocumentType, `${TProjectId}.${TDataset}`> | null>;
|
|
1741
2197
|
/** @beta */
|
|
1742
|
-
declare function resolveDocument<TData extends
|
|
2198
|
+
declare function resolveDocument<TData extends ResolveDocument>(instance: SanityInstance, docHandle: DocumentHandle<string, string, string>): Promise<TData | null>;
|
|
1743
2199
|
/** @beta */
|
|
1744
2200
|
declare const getDocumentSyncStatus: BoundStoreAction<DocumentStoreState, [doc: DocumentHandle<string, string, string>], StateSource<boolean | undefined>>;
|
|
1745
2201
|
type PermissionsStateOptions = {
|
|
@@ -2053,7 +2509,7 @@ interface DocumentRemotePatchesEvent {
|
|
|
2053
2509
|
origin: 'local' | 'remote';
|
|
2054
2510
|
}
|
|
2055
2511
|
/** @beta */
|
|
2056
|
-
interface ActionsResult<TDocument extends
|
|
2512
|
+
interface ActionsResult<TDocument extends ResolveDocument = ResolveDocument> {
|
|
2057
2513
|
transactionId: string;
|
|
2058
2514
|
documents: DocumentSet<TDocument>;
|
|
2059
2515
|
previous: DocumentSet<TDocument>;
|
|
@@ -2086,7 +2542,7 @@ interface ApplyDocumentActionsOptions {
|
|
|
2086
2542
|
disableBatching?: boolean;
|
|
2087
2543
|
}
|
|
2088
2544
|
/** @beta */
|
|
2089
|
-
declare function applyDocumentActions<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult<
|
|
2545
|
+
declare function applyDocumentActions<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult<ResolveDocument<TDocumentType, `${TProjectId}.${TDataset}`>>>;
|
|
2090
2546
|
/** @beta */
|
|
2091
2547
|
declare function applyDocumentActions(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult>;
|
|
2092
2548
|
/**
|
|
@@ -2152,26 +2608,6 @@ interface InstallationAccess {
|
|
|
2152
2608
|
resourceType: 'datasets' | 'canvases' | 'dashboards' | 'media-libraries';
|
|
2153
2609
|
resourceId: string;
|
|
2154
2610
|
}
|
|
2155
|
-
/**
|
|
2156
|
-
* An interface exposed by an installation, embedded when `interfaces` is
|
|
2157
|
-
* included.
|
|
2158
|
-
*
|
|
2159
|
-
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2160
|
-
* @public
|
|
2161
|
-
*/
|
|
2162
|
-
interface InstallationInterface {
|
|
2163
|
-
id: string;
|
|
2164
|
-
type: 'app' | 'worker' | 'asset_source' | 'panel';
|
|
2165
|
-
name: string;
|
|
2166
|
-
title: string;
|
|
2167
|
-
version: string;
|
|
2168
|
-
/** Module federation module ID; resolved from the host mf-manifest at runtime */
|
|
2169
|
-
moduleId: string;
|
|
2170
|
-
metadata: {
|
|
2171
|
-
group?: string;
|
|
2172
|
-
priority?: number;
|
|
2173
|
-
} | null;
|
|
2174
|
-
}
|
|
2175
2611
|
/**
|
|
2176
2612
|
* The active config of an installation, embedded when `activeConfig` is
|
|
2177
2613
|
* included. `null` when nothing is deployed.
|
|
@@ -2224,7 +2660,7 @@ type Installation<Include extends InstallationInclude = never> = InstallationBas
|
|
|
2224
2660
|
}> & Included<InstallationInclude, 'access', Include, {
|
|
2225
2661
|
access: InstallationAccess[];
|
|
2226
2662
|
}> & Included<InstallationInclude, 'interfaces', Include, {
|
|
2227
|
-
interfaces:
|
|
2663
|
+
interfaces: ApplicationInterface[];
|
|
2228
2664
|
}>;
|
|
2229
2665
|
/**
|
|
2230
2666
|
* Options for listing an organization's installations.
|
|
@@ -2825,7 +3261,7 @@ interface ProjectionOptions<TProjection extends string = string, TDocumentType e
|
|
|
2825
3261
|
/**
|
|
2826
3262
|
* @beta
|
|
2827
3263
|
*/
|
|
2828
|
-
declare function getProjectionState<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>): StateSource<ProjectionValuePending<
|
|
3264
|
+
declare function getProjectionState<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>): StateSource<ProjectionValuePending<ResolveProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>> | undefined>;
|
|
2829
3265
|
/**
|
|
2830
3266
|
* @beta
|
|
2831
3267
|
*/
|
|
@@ -2835,7 +3271,7 @@ declare function getProjectionState<TData extends object>(instance: SanityInstan
|
|
|
2835
3271
|
*/
|
|
2836
3272
|
declare function getProjectionState(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<Record<string, unknown>> | undefined>;
|
|
2837
3273
|
/** @beta */
|
|
2838
|
-
declare function resolveProjection<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>): Promise<ProjectionValuePending<
|
|
3274
|
+
declare function resolveProjection<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>): Promise<ProjectionValuePending<ResolveProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>>>;
|
|
2839
3275
|
/** @beta */
|
|
2840
3276
|
declare function resolveProjection<TData extends object>(instance: SanityInstance, options: ProjectionOptions): Promise<ProjectionValuePending<TData>>;
|
|
2841
3277
|
/** @public */
|
|
@@ -2885,7 +3321,7 @@ declare const parseQueryKey: (key: string) => QueryOptions;
|
|
|
2885
3321
|
*
|
|
2886
3322
|
* @beta
|
|
2887
3323
|
*/
|
|
2888
|
-
declare function getQueryState<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, queryOptions: QueryOptions<TQuery, TDataset, TProjectId>): StateSource<
|
|
3324
|
+
declare function getQueryState<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, queryOptions: QueryOptions<TQuery, TDataset, TProjectId>): StateSource<ResolveQueryResult<TQuery, `${TProjectId}.${TDataset}`> | undefined>;
|
|
2889
3325
|
/** @beta */
|
|
2890
3326
|
declare function getQueryState<TData>(instance: SanityInstance, queryOptions: QueryOptions): StateSource<TData | undefined>;
|
|
2891
3327
|
/** @beta */
|
|
@@ -2905,7 +3341,7 @@ declare function getQueryState(instance: SanityInstance, queryOptions: QueryOpti
|
|
|
2905
3341
|
*
|
|
2906
3342
|
* @beta
|
|
2907
3343
|
*/
|
|
2908
|
-
declare function resolveQuery<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, queryOptions: ResolveQueryOptions<TQuery, TDataset, TProjectId>): Promise<
|
|
3344
|
+
declare function resolveQuery<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, queryOptions: ResolveQueryOptions<TQuery, TDataset, TProjectId>): Promise<ResolveQueryResult<TQuery, `${TProjectId}.${TDataset}`>>;
|
|
2909
3345
|
/** @beta */
|
|
2910
3346
|
declare function resolveQuery<TData>(instance: SanityInstance, queryOptions: ResolveQueryOptions): Promise<TData>;
|
|
2911
3347
|
/**
|
|
@@ -2954,6 +3390,21 @@ type BoundGetPerspectiveState = BoundStoreAction<ReleasesStoreState, SelectorPar
|
|
|
2954
3390
|
* @public
|
|
2955
3391
|
*/
|
|
2956
3392
|
declare const getPerspectiveState: BoundGetPerspectiveState;
|
|
3393
|
+
/**
|
|
3394
|
+
* Preserves a projection string's literal type and returns the string unchanged.
|
|
3395
|
+
* Use this import when migrating an app with existing experimental Typegen output.
|
|
3396
|
+
*
|
|
3397
|
+
* Current Typegen does not scan this helper. New or changed projections need an
|
|
3398
|
+
* explicit result type until projection generation is supported.
|
|
3399
|
+
*
|
|
3400
|
+
* @example
|
|
3401
|
+
* ```ts
|
|
3402
|
+
* const preview = defineProjection('{title, "author": author->name}')
|
|
3403
|
+
* ```
|
|
3404
|
+
*
|
|
3405
|
+
* @beta
|
|
3406
|
+
*/
|
|
3407
|
+
declare function defineProjection<const TProjection extends string>(projection: TProjection): TProjection;
|
|
2957
3408
|
/**
|
|
2958
3409
|
* Returns the state source for users associated with a specific resource.
|
|
2959
3410
|
*
|
|
@@ -3127,8 +3578,10 @@ interface AuthStoreState {
|
|
|
3127
3578
|
callbackUrl: string | undefined;
|
|
3128
3579
|
providedToken: string | undefined;
|
|
3129
3580
|
authMethod: AuthMethodOptions;
|
|
3581
|
+
oauth: AuthConfig['oauth'];
|
|
3130
3582
|
};
|
|
3131
3583
|
dashboardContext?: DashboardContext;
|
|
3584
|
+
oauthTokens?: OAuthTokens;
|
|
3132
3585
|
}
|
|
3133
3586
|
/**
|
|
3134
3587
|
* @public
|
|
@@ -3161,5 +3614,5 @@ declare const getIsInDashboardState: BoundStoreAction<AuthStoreState, [], StateS
|
|
|
3161
3614
|
* @internal
|
|
3162
3615
|
*/
|
|
3163
3616
|
declare const setAuthToken: BoundStoreAction<AuthStoreState, [token: string | null], void>;
|
|
3164
|
-
export {
|
|
3165
|
-
//# sourceMappingURL=authStore-
|
|
3617
|
+
export { project as $, publishDocument as $n, refreshOAuthTokens as $r, ApplyDocumentActionsOptions as $t, loadMoreUsers as A, CacheWriter as Ai, CreateReleaseAction as An, RemoveCommentOptions as Ar, OrganizationsOptions as At, getQueryState as B, BoundStoreAction as Bi, ReleaseAction as Bn, CommentLocalState as Br, InstallationBase as Bt, slicePath$1 as C, application as Ci, ProcessMutationsOptions as Cn, getCommentThreadsState as Cr, ResolveUsersOptions as Ct, getCorsErrorProjectId as D, AccessResourceType as Di, Action as Dn, resolveCommentThreads as Dr, UsersGroupState as Dt, isImportError as E, updateApplication as Ei, JsonMatch as En, parseCommentsOptionsKey as Er, UserProfile as Et, ReleaseState as F, MutationResult as Fi, EditDocumentAction as Fn, removeComment as Fr, OrganizationOptions as Ft, resolveProjection as G, archiveRelease as Gn, CommentTextSelectionItem as Gr, installations as Gt, resolveQuery as H, UnarchiveReleaseAction as Hn, CommentReaction as Hr, InstallationsOptions as Ht, getActiveReleasesState as I, defineFetcher as Ii, EditDocumentOptions as In, replyToComment as Ir, organization as It, ProjectBase as J, deleteDocument as Jn, ClientStoreState as Jr, SetFavoriteInput as Jt, getProjectionState as K, createDocument as Kn, CommentThread as Kr, FavoriteDocumentContext as Kt, getAllReleasesState as L, defineMutation as Li, EditReleaseAction as Ln, setCommentStatus as Lr, Installation as Lt, resolveUsers as M, FetcherDefinition as Mi, DeleteReleaseAction as Mn, SetCommentStatusOptions as Mr, Organization as Mt, defineProjection as N, FetcherSnapshot as Ni, DiscardDocumentAction as Nn, UpdateCommentOptions as Nr, OrganizationBase as Nt, getUserState as O, checkPermissions as Oi, ArchiveReleaseAction as On, resolveComments as Or, UsersStoreState as Ot, getPerspectiveState as P, MutationDefinition as Pi, DocumentAction as Pn, createComment as Pr, OrganizationMember as Pt, ProjectOptions as Q, editRelease as Qn, handleOAuthCallback as Qr, ActionsResult as Qt, QueryOptions as R, Selector as Ri, PublishDocumentAction as Rn, updateComment as Rr, InstallationAccess as Rt, jsonMatch$1 as S, UpdateApplicationInput as Si, DocumentSet as Sn, ResolveCommentsOptions as Sr, ResolveUserOptions as St, CORE_SDK_VERSION as T, deleteApplication as Ti, processMutations as Tn, getCommentsState as Tr, SanityUserResponse as Tt, ProjectsOptions as U, UnpublishDocumentAction as Un, CommentStatus as Ur, InstallationsResponse as Ut, parseQueryKey as V, ScheduleReleaseAction as Vn, CommentMessage as Vr, InstallationInclude as Vt, projects as W, UnscheduleReleaseAction as Wn, CommentTextSelection as Wr, installation as Wt, ProjectMemberRole as X, discardDocument as Xn, getClientState as Xr, setFavorite as Xt, ProjectMember as Y, deleteRelease as Yn, getClient as Yr, favorites as Yt, ProjectMetadata as Z, editDocument as Zn, getOAuthTokensState as Zr, getReleaseDocumentId as Zt, SanityDocument$3 as _, ApplicationWorkspace as _i, resolveDocument as _n, createDatasetHandle as _r, TransportEvent as _t, LoggedOutAuthState as a, observeOrganizationVerificationState as ai, DocumentEditedEvent as an, ResolveDocument as ar, getPresence as at, getPathDepth as b, DeleteApplicationInput as bi, DocumentPermissionsResult as bn, createProjectHandle as br, GetUsersOptions as bt, getCurrentUserState as c, Application as ci, DocumentRemotePatchesEvent as cn, datasets as cr, DocumentPresence as ct, getLoginUrlState as d, ApplicationDeployment as di, TransactionAcceptedEvent as dn, LogContext as dr, PresencePerspectiveOptions as dt, revokeOAuthTokens as ei, applyDocumentActions as en, publishRelease as er, PreviewMedia as et, getTokenState as f, ApplicationInclude as fi, TransactionRevertedEvent as fn, LogLevel as fr, PresenceSelection as ft, Role as g, ApplicationVisibility as gi, getPermissionsState as gn, createLogger as gr, StateEvent as gt, ReleaseDocument$1 as h, ApplicationStudioConfig as hi, getDocumentSyncStatus as hn, LoggerConfig as hr, RollCallEvent as ht, LoggedInAuthState as i, handleAuthCallback as ii, DocumentDiscardedEvent as in, unscheduleRelease as ir, getDocumentPresence as it, resolveUser as j, Fetcher as ji, DeleteDocumentAction as jn, ReplyToCommentOptions as jr, organizations as jt, getUsersState as k, CacheTag as ki, CreateDocumentAction as kn, CreateCommentOptions as kr, Organizations as kt, getDashboardOrganizationId as l, ApplicationAccess as li, DocumentTransactionSubmissionResult as ln, configureLogging as lr, DocumentPresenceOptions as lt, CurrentUser$1 as m, ApplicationInterfacePlacementMetadata as mi, getDocumentState as mn, Logger as mr, ReportPresenceOptions as mt, AuthStoreState as n, OAuthTokens as ni, DocumentCreatedEvent as nn, unarchiveRelease as nr, PreviewValue as nt, LoggingInAuthState as o, OrgVerificationResult as oi, DocumentEvent as on, ResolveProjectionResult as or, reportPresence as ot, setAuthToken as p, ApplicationInterface as pi, DocumentOptions as pn, LogNamespace as pr, PresenceSelectionPoint as pt, Project as q, createRelease as qn, ClientOptions as qr, FavoriteStatusResponse as qt, ErrorAuthState as r, logout as ri, DocumentDeletedEvent as rn, unpublishDocument as rr, ProjectionValuePending as rt, getAuthState as s, AuthStateType as si, DocumentPublishedEvent as sn, ResolveQueryResult as sr, DisconnectEvent as st, AuthState as t, startOAuthAuthorization as ti, ActionErrorEvent as tn, scheduleRelease as tr, PreviewQueryResult as tt, getIsInDashboardState as u, ApplicationBase as ui, DocumentUnpublishedEvent as un, InstanceContext as ur, PresenceLocation as ut, SanityProject$1 as v, ApplicationsOptions as vi, resolvePermissions as vn, createDocumentHandle as vr, UserPresence as vt, stringifyPath$1 as w, applications as wi, patchOperations as wn, getCommentsOptionsKey as wr, SanityUser as wt, joinPaths as x, DeletedResult as xi, PermissionDeniedReason as xn, CommentsOptions as xr, Membership as xt, getIndexForKey$1 as y, ApplicationsResponse as yi, subscribeDocumentEvents as yn, createDocumentTypeHandle as yr, GetUserOptions as yt, getQueryKey as z, StateSource as zi, PublishReleaseAction as zn, Comment as zr, InstallationActiveConfig as zt };
|
|
3618
|
+
//# sourceMappingURL=authStore-BO2vch3I.d.ts.map
|