@sanity/sdk 3.1.0 → 3.3.0-rc.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 +52 -21
- package/dist/_exports/_internal.d.ts.map +1 -1
- package/dist/_exports/_internal.js +10 -9
- 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 +3 -2
- package/dist/_exports/comlink.js.map +1 -1
- package/dist/_exports/dashboard.d.ts +2 -0
- package/dist/_exports/dashboard.js +2 -0
- package/dist/{authStore-C-OEkGaM.d.ts → authStore-BGoEGxOq.d.ts} +531 -63
- package/dist/authStore-BGoEGxOq.d.ts.map +1 -0
- package/dist/{clientStore-gUALQ0qW.js → clientStore-QDrJNTM4.js} +128 -7
- package/dist/clientStore-QDrJNTM4.js.map +1 -0
- package/dist/{createSanityInstance-DCePpBYW.d.ts → createSanityInstance-BQIqyGLX.d.ts} +16 -1
- package/dist/createSanityInstance-BQIqyGLX.d.ts.map +1 -0
- package/dist/{object-BwynGPRZ.js → createStateSourceAction-DdAhEfnZ.js} +2 -82
- package/dist/createStateSourceAction-DdAhEfnZ.js.map +1 -0
- package/dist/defineProperty-Bho9Ngsi.js +31 -0
- package/dist/{getNodeState-E0hjqFOo.js → getNodeState-B4nG0sjm.js} +3 -2
- package/dist/{getNodeState-E0hjqFOo.js.map → getNodeState-B4nG0sjm.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +371 -54
- package/dist/index.js.map +1 -1
- package/dist/object-CxXlSVg7.js +83 -0
- package/dist/object-CxXlSVg7.js.map +1 -0
- package/dist/topicStore-Ct7IFNtY.js +565 -0
- package/dist/topicStore-Ct7IFNtY.js.map +1 -0
- package/dist/topicStore-DXvuH9h4.d.ts +435 -0
- package/dist/topicStore-DXvuH9h4.d.ts.map +1 -0
- package/dist/{version-C90rNWaX.js → version-CIhX5ppJ.js} +6 -6
- package/dist/{version-C90rNWaX.js.map → version-CIhX5ppJ.js.map} +1 -1
- package/package.json +20 -19
- package/src/_exports/_internal.ts +12 -0
- package/src/_exports/dashboard.ts +36 -0
- package/src/_exports/index.ts +17 -1
- package/src/applications/applications.test-d.ts +28 -4
- package/src/applications/applications.ts +39 -14
- package/src/auth/authMode.test.ts +24 -0
- package/src/auth/authMode.ts +8 -3
- package/src/auth/authStore.test.ts +18 -0
- package/src/auth/authStore.ts +15 -0
- package/src/auth/authStrategy.ts +2 -0
- package/src/auth/handleAuthCallback.test.ts +33 -0
- package/src/auth/handleAuthCallback.ts +11 -1
- package/src/auth/logout.test.ts +53 -0
- package/src/auth/logout.ts +19 -1
- package/src/auth/oauth/oauthActions.test.ts +593 -0
- package/src/auth/oauth/oauthActions.ts +438 -0
- package/src/auth/oauth/oauthAuth.test.ts +229 -0
- package/src/auth/oauth/oauthAuth.ts +178 -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/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 +3 -3
- package/src/document/documentStore.ts +12 -12
- package/src/document/processMutations.ts +58 -22
- package/src/installations/installations.test-d.ts +3 -3
- package/src/installations/installations.ts +2 -19
- package/src/projection/getProjectionState.ts +2 -2
- package/src/projection/resolveProjection.ts +2 -2
- package/src/query/queryStore.ts +3 -3
- 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/utils/createGroqSearchFilter.test.ts +8 -0
- package/src/utils/createGroqSearchFilter.ts +6 -3
- package/dist/authStore-C-OEkGaM.d.ts.map +0 -1
- package/dist/clientStore-gUALQ0qW.js.map +0 -1
- package/dist/createSanityInstance-DCePpBYW.d.ts.map +0 -1
- package/dist/object-BwynGPRZ.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 ? {
|
|
@@ -676,13 +704,84 @@ interface OrgVerificationResult {
|
|
|
676
704
|
*/
|
|
677
705
|
declare function observeOrganizationVerificationState(instance: SanityInstance, projectIds: string[]): Observable<OrgVerificationResult>;
|
|
678
706
|
/**
|
|
707
|
+
* Handles the auth redirect callback. In OAuth mode this delegates to
|
|
708
|
+
* {@link handleOAuthCallback}; otherwise it exchanges the legacy `sid` for a
|
|
709
|
+
* long-lived token.
|
|
710
|
+
*
|
|
679
711
|
* @public
|
|
680
712
|
*/
|
|
681
713
|
declare const handleAuthCallback: BoundStoreAction<AuthStoreState, [locationHref?: string | undefined], Promise<string | false>>;
|
|
682
714
|
/**
|
|
715
|
+
* Logs the current user out. In OAuth mode this revokes the OAuth tokens
|
|
716
|
+
* instead of calling the legacy `/auth/logout` endpoint; revocation is
|
|
717
|
+
* best-effort, so the OAuth path resolves even if the revoke request fails,
|
|
718
|
+
* whereas the legacy path rejects when `/auth/logout` fails. Local state and
|
|
719
|
+
* storage are cleared in both cases.
|
|
720
|
+
*
|
|
683
721
|
* @public
|
|
684
722
|
*/
|
|
685
723
|
declare const logout: BoundStoreAction<AuthStoreState, [], Promise<void>>;
|
|
724
|
+
/**
|
|
725
|
+
* OAuth tokens issued by Sanity's OAuth token endpoint.
|
|
726
|
+
*
|
|
727
|
+
* @public
|
|
728
|
+
*/
|
|
729
|
+
interface OAuthTokens {
|
|
730
|
+
accessToken: string;
|
|
731
|
+
tokenType: 'bearer';
|
|
732
|
+
expiresIn: number;
|
|
733
|
+
expiresAt: Date;
|
|
734
|
+
refreshToken?: string;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Starts the OAuth authorization-code + PKCE flow: generates a `code_verifier`,
|
|
738
|
+
* `code_challenge` and `state`, persists the verifier and state to
|
|
739
|
+
* `sessionStorage`, then navigates the browser to the authorize endpoint.
|
|
740
|
+
*
|
|
741
|
+
* @public
|
|
742
|
+
*/
|
|
743
|
+
declare const startOAuthAuthorization: BoundStoreAction<AuthStoreState, [], Promise<void>>;
|
|
744
|
+
/**
|
|
745
|
+
* Handles the OAuth redirect callback: validates `state`, surfaces `error`
|
|
746
|
+
* responses, exchanges the authorization `code` for tokens, persists them, and
|
|
747
|
+
* transitions to `LOGGED_IN`.
|
|
748
|
+
*
|
|
749
|
+
* Returns the URL for the caller to `history.replaceState` to when a callback
|
|
750
|
+
* was processed: on success, the same-origin location the user was on when
|
|
751
|
+
* the flow started (if any), otherwise the callback URL cleaned of OAuth
|
|
752
|
+
* params. Returns `false` when there was nothing to handle (no code, or an
|
|
753
|
+
* exchange already in progress). A callback that fails validation while a
|
|
754
|
+
* session is already `LOGGED_IN` (e.g. a remount before the params were
|
|
755
|
+
* stripped) is ignored with a warning and still returns the cleaned URL, so a
|
|
756
|
+
* string result does not imply an exchange ran.
|
|
757
|
+
*
|
|
758
|
+
* @public
|
|
759
|
+
*/
|
|
760
|
+
declare const handleOAuthCallback: BoundStoreAction<AuthStoreState, [locationHref?: string | undefined], Promise<string | false>>;
|
|
761
|
+
/**
|
|
762
|
+
* Refreshes the OAuth tokens using the `refresh_token` grant. Concurrent
|
|
763
|
+
* callers share a single in-flight request. An unrecoverable failure (a 4xx
|
|
764
|
+
* rejecting the refresh token) clears the tokens and transitions to
|
|
765
|
+
* `LOGGED_OUT`; transient failures (network, 5xx, rate limits) leave the
|
|
766
|
+
* session intact and rethrow so the caller can retry.
|
|
767
|
+
*
|
|
768
|
+
* @public
|
|
769
|
+
*/
|
|
770
|
+
declare const refreshOAuthTokens: BoundStoreAction<AuthStoreState, [], Promise<OAuthTokens | null>>;
|
|
771
|
+
/**
|
|
772
|
+
* Revokes the OAuth tokens then clears local storage and transitions to `LOGGED_OUT`.
|
|
773
|
+
* Local state is cleared even if the revoke request fails.
|
|
774
|
+
*
|
|
775
|
+
* @public
|
|
776
|
+
*/
|
|
777
|
+
declare const revokeOAuthTokens: BoundStoreAction<AuthStoreState, [], Promise<void>>;
|
|
778
|
+
/**
|
|
779
|
+
* A state source exposing the current OAuth tokens (including expiry), or
|
|
780
|
+
* `null` when not logged in via OAuth.
|
|
781
|
+
*
|
|
782
|
+
* @public
|
|
783
|
+
*/
|
|
784
|
+
declare const getOAuthTokensState: BoundStoreAction<AuthStoreState, [], StateSource<OAuthTokens | null>>;
|
|
686
785
|
type AllowedClientConfigKey = 'useCdn' | 'token' | 'perspective' | 'apiHost' | 'proxy' | 'withCredentials' | 'timeout' | 'maxRetries' | 'dataset' | 'projectId' | 'requestTagPrefix' | 'useProjectHostname';
|
|
687
786
|
/**
|
|
688
787
|
* States tracked by the client store
|
|
@@ -1260,6 +1359,17 @@ interface Logger {
|
|
|
1260
1359
|
/** Get the instance context if available */
|
|
1261
1360
|
getInstanceContext: () => InstanceContext | undefined;
|
|
1262
1361
|
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Create a logger for a specific namespace
|
|
1364
|
+
* @param namespace - A string identifier for the logging domain (e.g., 'auth', 'document')
|
|
1365
|
+
* @param baseContext - Optional base context to include in all log messages
|
|
1366
|
+
* @remarks
|
|
1367
|
+
* If baseContext includes an `instanceContext` property (with projectId, dataset, instanceId),
|
|
1368
|
+
* it will be automatically formatted into the log output for easier debugging of
|
|
1369
|
+
* multi-instance scenarios.
|
|
1370
|
+
* @public
|
|
1371
|
+
*/
|
|
1372
|
+
declare function createLogger(namespace: string, baseContext?: LogContext): Logger;
|
|
1263
1373
|
/**
|
|
1264
1374
|
* Configure logging for the Sanity SDK
|
|
1265
1375
|
*
|
|
@@ -1371,6 +1481,104 @@ declare function configureLogging(config: LoggerConfig): void;
|
|
|
1371
1481
|
* @internal
|
|
1372
1482
|
*/
|
|
1373
1483
|
declare const datasets: Fetcher<[options?: ProjectHandle<string> | undefined], DatasetsResponse>;
|
|
1484
|
+
/**
|
|
1485
|
+
* Augments `groq` with the type surface of `groq@3.88.1-typegen-experimental.0`, the fork
|
|
1486
|
+
* this package depended on before GA `groq`.
|
|
1487
|
+
*
|
|
1488
|
+
* A `sanity.types.ts` from the experimental Typegen flow imports these helpers from
|
|
1489
|
+
* `groq` and augments these interfaces. GA `groq` exports only `defineQuery` and the
|
|
1490
|
+
* template tag, so those files stop typechecking without this one.
|
|
1491
|
+
*
|
|
1492
|
+
* `defineProjection` is absent: it is a runtime function, and declaring it in a
|
|
1493
|
+
* type-only augmentation turns a compile error into `undefined is not a function`.
|
|
1494
|
+
* `@sanity/sdk` exports it instead.
|
|
1495
|
+
*
|
|
1496
|
+
* Keep these declarations while the SDK supports existing experimental generated files.
|
|
1497
|
+
*/
|
|
1498
|
+
declare module 'groq' {
|
|
1499
|
+
/**
|
|
1500
|
+
* Brands a type with the resource it came from so one flat interface can hold entries
|
|
1501
|
+
* from more than one schema; {@link PickSchema} narrows it back out.
|
|
1502
|
+
*/
|
|
1503
|
+
type SchemaOrigin<TBase, TSchemaId extends string> = TBase & {
|
|
1504
|
+
/**
|
|
1505
|
+
* @internal
|
|
1506
|
+
* @deprecated typescript helper only
|
|
1507
|
+
*/
|
|
1508
|
+
__schemaId?: TSchemaId;
|
|
1509
|
+
};
|
|
1510
|
+
/**
|
|
1511
|
+
* Brands a projection result with the document type it was evaluated against;
|
|
1512
|
+
* {@link PickProjectionResult} narrows it back out.
|
|
1513
|
+
*/
|
|
1514
|
+
type ProjectionBase<TBase, TProjectionBaseTypeName extends string> = TBase & {
|
|
1515
|
+
/**
|
|
1516
|
+
* @internal
|
|
1517
|
+
* @deprecated typescript helper only
|
|
1518
|
+
*/
|
|
1519
|
+
__schemaTypeName?: TProjectionBaseTypeName;
|
|
1520
|
+
};
|
|
1521
|
+
/** Extracts the members of `T` that came from the schema `TSchemaId`. */
|
|
1522
|
+
type PickSchema<T, TSchemaId extends string = string> = Extract<T, SchemaOrigin<T, TSchemaId>>;
|
|
1523
|
+
/** Extracts the members of `T` projected from the document type `TProjectionBaseTypeName`. */
|
|
1524
|
+
type PickProjectionResult<T, TProjectionBaseTypeName extends string = string> = Extract<T, ProjectionBase<T, TProjectionBaseTypeName>>;
|
|
1525
|
+
/** Augmented by generated files: resource key to the union of that schema's types. */
|
|
1526
|
+
interface SanitySchemas {}
|
|
1527
|
+
/** Augmented by generated files: query string to its result type. */
|
|
1528
|
+
interface SanityQueries {}
|
|
1529
|
+
/** Augmented by generated files: projection string to its result type. */
|
|
1530
|
+
interface SanityProjections {}
|
|
1531
|
+
/**
|
|
1532
|
+
* Indexes an augmented interface, falling back to the union of every registered value
|
|
1533
|
+
* when the key is absent. Code generated against the fork relies on that fallback, so
|
|
1534
|
+
* narrowing it to `never` changes what existing apps infer.
|
|
1535
|
+
*/
|
|
1536
|
+
type SafeAccess<T, K extends string> = K extends keyof T ? T[K] : T[keyof T];
|
|
1537
|
+
/** Fields Sanity adds to every document. */
|
|
1538
|
+
interface SanityDocumentShape {
|
|
1539
|
+
_id: string;
|
|
1540
|
+
_type: string;
|
|
1541
|
+
_createdAt: string;
|
|
1542
|
+
_updatedAt: string;
|
|
1543
|
+
_rev: string;
|
|
1544
|
+
[key: string]: unknown;
|
|
1545
|
+
}
|
|
1546
|
+
/** All types registered for one resource. */
|
|
1547
|
+
type SanitySchema<TSchemaId extends string = string> = PickSchema<SafeAccess<SanitySchemas, TSchemaId>, TSchemaId>;
|
|
1548
|
+
/** One schema type, selected by its `_type` and its resource. */
|
|
1549
|
+
type SanitySchemaType<TSchemaTypeName extends string = string, TSchemaId extends string = string> = Extract<SanitySchema<TSchemaId>, {
|
|
1550
|
+
_type: TSchemaTypeName;
|
|
1551
|
+
}>;
|
|
1552
|
+
/** One document type, selected by its `_type` and its resource. */
|
|
1553
|
+
type SanityDocument<TDocumentType extends string = string, TSchemaId extends string = string> = Extract<Extract<SanitySchema<TSchemaId>, SanityDocumentShape> | SanityDocumentShape, {
|
|
1554
|
+
_type: TDocumentType;
|
|
1555
|
+
}>;
|
|
1556
|
+
/** The result of a registered query, for one resource. */
|
|
1557
|
+
type SanityQueryResult<TQuery extends string = string, TSchemaId extends string = string> = Extract<SafeAccess<SanityQueries, TQuery>, SchemaOrigin<SafeAccess<SanityQueries, TQuery>, TSchemaId>>;
|
|
1558
|
+
/** The result of a registered projection, for one document type and one resource. */
|
|
1559
|
+
type SanityProjectionResult<TProjection extends string = string, TProjectionBaseTypeName extends string = string, TSchemaId extends string = string> = PickSchema<PickProjectionResult<SafeAccess<SanityProjections, TProjection>, TProjectionBaseTypeName>, TSchemaId>;
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Resolves a document using declarations from experimental Typegen.
|
|
1563
|
+
* Preserves the legacy lookup behavior while the SDK uses released `groq`.
|
|
1564
|
+
*
|
|
1565
|
+
* @beta
|
|
1566
|
+
*/
|
|
1567
|
+
type ResolveDocument<TDocumentType extends string = string, TSchemaId extends string = string> = SanityDocument$2<TDocumentType, TSchemaId>;
|
|
1568
|
+
/**
|
|
1569
|
+
* Resolves a query using declarations from experimental Typegen.
|
|
1570
|
+
* For types generated by current Typegen, pass the result type to the hook explicitly.
|
|
1571
|
+
*
|
|
1572
|
+
* @beta
|
|
1573
|
+
*/
|
|
1574
|
+
type ResolveQueryResult<TQuery extends string = string, TSchemaId extends string = string> = SanityQueryResult<TQuery, TSchemaId>;
|
|
1575
|
+
/**
|
|
1576
|
+
* Resolves a projection using declarations from experimental Typegen.
|
|
1577
|
+
* Selects the result by projection string, document type, and schema ID.
|
|
1578
|
+
*
|
|
1579
|
+
* @beta
|
|
1580
|
+
*/
|
|
1581
|
+
type ResolveProjectionResult<TProjection extends string = string, TDocumentType extends string = string, TSchemaId extends string = string> = SanityProjectionResult<TProjection, TDocumentType, TSchemaId>;
|
|
1374
1582
|
/**
|
|
1375
1583
|
* Represents an action to create a new document.
|
|
1376
1584
|
* Specifies the document type and optionally a document ID (which will be treated as the published ID).
|
|
@@ -1383,7 +1591,7 @@ interface CreateDocumentAction<TDocumentType extends string = string, TDataset e
|
|
|
1383
1591
|
* These values will be set when the document is created.
|
|
1384
1592
|
* System fields (_id, _type, _rev, _createdAt, _updatedAt) are omitted as they are set automatically.
|
|
1385
1593
|
*/
|
|
1386
|
-
initialValue?: Partial<Omit<
|
|
1594
|
+
initialValue?: Partial<Omit<ResolveDocument<TDocumentType, `${TProjectId}.${TDataset}`>, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>;
|
|
1387
1595
|
}
|
|
1388
1596
|
/**
|
|
1389
1597
|
* Represents an action to delete an existing document.
|
|
@@ -1459,7 +1667,7 @@ type Action<TDocumentType extends string = string, TDataset extends string = str
|
|
|
1459
1667
|
* @returns A `CreateDocumentAction` object ready for dispatch.
|
|
1460
1668
|
* @beta
|
|
1461
1669
|
*/
|
|
1462
|
-
declare function createDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>, initialValue?: Partial<Omit<
|
|
1670
|
+
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
1671
|
/**
|
|
1464
1672
|
* Creates a `DeleteDocumentAction` object.
|
|
1465
1673
|
* @param doc - A handle uniquely identifying the document to be deleted.
|
|
@@ -1639,12 +1847,275 @@ type DeepGet<TValue, TPath extends readonly (string | number)[]> = TPath extends
|
|
|
1639
1847
|
*/
|
|
1640
1848
|
type JsonMatch<TDocument, TPath extends string> = DeepGet<TDocument, PathParts<TPath>>;
|
|
1641
1849
|
/**
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1850
|
+
* Given an input object and a record of path expressions to values, this
|
|
1851
|
+
* function will set each match with the given value.
|
|
1852
|
+
*
|
|
1853
|
+
* ```js
|
|
1854
|
+
* const output = set(
|
|
1855
|
+
* {name: {first: 'initial', last: 'initial'}},
|
|
1856
|
+
* {'name.first': 'changed'}
|
|
1857
|
+
* );
|
|
1858
|
+
*
|
|
1859
|
+
* // { name: { first: 'changed', last: 'initial' } }
|
|
1860
|
+
* console.log(output);
|
|
1861
|
+
* ```
|
|
1862
|
+
*/
|
|
1863
|
+
declare function set<R>(input: unknown, pathExpressionValues: Record<string, unknown>): R;
|
|
1864
|
+
/**
|
|
1865
|
+
* Given an input object and a record of path expressions to values, this
|
|
1866
|
+
* function will set each match with the given value **if the value at the current
|
|
1867
|
+
* path is missing** (i.e. `null` or `undefined`).
|
|
1868
|
+
*
|
|
1869
|
+
* ```js
|
|
1870
|
+
* const output = setIfMissing(
|
|
1871
|
+
* {items: [null, 'initial']},
|
|
1872
|
+
* {'items[:]': 'changed'}
|
|
1873
|
+
* );
|
|
1874
|
+
*
|
|
1875
|
+
* // { items: ['changed', 'initial'] }
|
|
1876
|
+
* console.log(output);
|
|
1877
|
+
* ```
|
|
1878
|
+
*/
|
|
1879
|
+
declare function setIfMissing<R>(input: unknown, pathExpressionValues: Record<string, unknown>): R;
|
|
1880
|
+
/**
|
|
1881
|
+
* Given an input object and an array of path expressions, this function will
|
|
1882
|
+
* remove each match from the input object.
|
|
1883
|
+
*
|
|
1884
|
+
* ```js
|
|
1885
|
+
* const output = unset(
|
|
1886
|
+
* {name: {first: 'one', last: 'two'}},
|
|
1887
|
+
* ['name.last']
|
|
1888
|
+
* );
|
|
1889
|
+
*
|
|
1890
|
+
* // { name: { first: 'one' } }
|
|
1891
|
+
* console.log(output);
|
|
1892
|
+
* ```
|
|
1893
|
+
*/
|
|
1894
|
+
declare function unset<R>(input: unknown, pathExpressions: string[]): R;
|
|
1895
|
+
/**
|
|
1896
|
+
* Given an input object, a path expression (inside the insert patch object), and an array of items,
|
|
1897
|
+
* this function will insert or replace the matched items.
|
|
1898
|
+
*
|
|
1899
|
+
* **Insert before:**
|
|
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 before with negative index (append):**
|
|
1915
|
+
*
|
|
1916
|
+
* ```js
|
|
1917
|
+
* const input = {some: {array: ['a', 'b', 'c']}}
|
|
1918
|
+
* const output = insert(
|
|
1919
|
+
* input,
|
|
1920
|
+
* {
|
|
1921
|
+
* before: 'some.array[-1]',
|
|
1922
|
+
* items: ['!']
|
|
1923
|
+
* }
|
|
1924
|
+
* );
|
|
1925
|
+
* // { some: { array: ['a', 'b', 'c', '!'] } }
|
|
1926
|
+
* console.log(output);
|
|
1927
|
+
* ```
|
|
1928
|
+
*
|
|
1929
|
+
* **Insert after:**
|
|
1930
|
+
*
|
|
1931
|
+
* ```js
|
|
1932
|
+
* const input = {some: {array: ['a', 'b', 'c']}}
|
|
1933
|
+
* const output = insert(
|
|
1934
|
+
* input,
|
|
1935
|
+
* {
|
|
1936
|
+
* after: 'some.array[1]',
|
|
1937
|
+
* items: ['!']
|
|
1938
|
+
* }
|
|
1939
|
+
* );
|
|
1940
|
+
* // { some: { array: ['a', 'b', '!', 'c'] } }
|
|
1941
|
+
* console.log(output);
|
|
1942
|
+
* ```
|
|
1943
|
+
*
|
|
1944
|
+
* **Replace:**
|
|
1945
|
+
*
|
|
1946
|
+
* ```js
|
|
1947
|
+
* const output = insert(
|
|
1948
|
+
* { some: { array: ['a', 'b', 'c'] } },
|
|
1949
|
+
* {
|
|
1950
|
+
* replace: 'some.array[1]',
|
|
1951
|
+
* items: ['!']
|
|
1952
|
+
* }
|
|
1953
|
+
* );
|
|
1954
|
+
* // { some: { array: ['a', '!', 'c'] } }
|
|
1955
|
+
* console.log(output);
|
|
1956
|
+
* ```
|
|
1957
|
+
*
|
|
1958
|
+
* **Replace many:**
|
|
1959
|
+
*
|
|
1960
|
+
* ```js
|
|
1961
|
+
* const input = {some: {array: ['a', 'b', 'c', 'd']}}
|
|
1962
|
+
* const output = insert(
|
|
1963
|
+
* input,
|
|
1964
|
+
* {
|
|
1965
|
+
* replace: 'some.array[1:3]',
|
|
1966
|
+
* items: ['!', '?']
|
|
1967
|
+
* }
|
|
1968
|
+
* );
|
|
1969
|
+
* // { some: { array: ['a', '!', '?', 'd'] } }
|
|
1970
|
+
* console.log(output);
|
|
1971
|
+
* ```
|
|
1972
|
+
*/
|
|
1973
|
+
declare function insert<R>(input: unknown, insertPatch: InsertPatch): R;
|
|
1974
|
+
/**
|
|
1975
|
+
* Given an input object and a record of path expressions to numeric values,
|
|
1976
|
+
* this function will increment each match with the given value.
|
|
1977
|
+
*
|
|
1978
|
+
* ```js
|
|
1979
|
+
* const output = inc(
|
|
1980
|
+
* {foo: {first: 3, second: 4.5}},
|
|
1981
|
+
* {'foo.first': 3, 'foo.second': 4}
|
|
1982
|
+
* );
|
|
1983
|
+
*
|
|
1984
|
+
* // { foo: { first: 6, second: 8.5 } }
|
|
1985
|
+
* console.log(output);
|
|
1986
|
+
* ```
|
|
1987
|
+
*/
|
|
1988
|
+
declare function inc<R>(input: unknown, pathExpressionValues: Record<string, number>): R;
|
|
1989
|
+
/**
|
|
1990
|
+
* Given an input object and a record of path expressions to numeric values,
|
|
1991
|
+
* this function will decrement each match with the given value.
|
|
1992
|
+
*
|
|
1993
|
+
* ```js
|
|
1994
|
+
* const output = dec(
|
|
1995
|
+
* {foo: {first: 3, second: 4.5}},
|
|
1996
|
+
* {'foo.first': 3, 'foo.second': 4}
|
|
1997
|
+
* );
|
|
1998
|
+
*
|
|
1999
|
+
* // { foo: { first: 0, second: 0.5 } }
|
|
2000
|
+
* console.log(output);
|
|
2001
|
+
* ```
|
|
2002
|
+
*/
|
|
2003
|
+
declare function dec<R>(input: unknown, pathExpressionValues: Record<string, number>): R;
|
|
2004
|
+
/**
|
|
2005
|
+
* Given an input object and a record of paths to [diff match patches][0], this
|
|
2006
|
+
* function will apply the diff match patch for the string at each match.
|
|
2007
|
+
*
|
|
2008
|
+
* [0]: https://www.sanity.io/docs/http-patches#aTbJhlAJ
|
|
2009
|
+
*
|
|
2010
|
+
* ```js
|
|
2011
|
+
* const output = diffMatchPatch(
|
|
2012
|
+
* {foo: 'the quick brown fox'},
|
|
2013
|
+
* {'foo': '@@ -13,7 +13,7 @@\n own \n-fox\n+cat\n'}
|
|
2014
|
+
* );
|
|
2015
|
+
*
|
|
2016
|
+
* // { foo: 'the quick brown cat' }
|
|
2017
|
+
* console.log(output);
|
|
2018
|
+
* ```
|
|
2019
|
+
*/
|
|
2020
|
+
declare function diffMatchPatch<R>(input: unknown, pathExpressionValues: Record<string, string>): R;
|
|
2021
|
+
/**
|
|
2022
|
+
* Simply checks if the given document input has a `_rev` that matches the given
|
|
2023
|
+
* `revisionId` and throws otherwise.
|
|
2024
|
+
*
|
|
2025
|
+
* (No code example provided.)
|
|
2026
|
+
*/
|
|
2027
|
+
declare function ifRevisionID<R>(input: unknown, revisionId: string): R;
|
|
2028
|
+
/**
|
|
2029
|
+
* Maps document IDs to documents, using `null` for documents that do not exist.
|
|
2030
|
+
*
|
|
2031
|
+
* @beta
|
|
1646
2032
|
*/
|
|
1647
2033
|
type DocumentSet<TDocument extends SanityDocument$1 = SanityDocument$1> = { [TDocumentId in string]?: TDocument | null; };
|
|
2034
|
+
/**
|
|
2035
|
+
* Exposes the patch operations used by {@link processMutations}.
|
|
2036
|
+
*
|
|
2037
|
+
* @remarks
|
|
2038
|
+
* Property order determines execution order in {@link processMutations}:
|
|
2039
|
+
* `ifRevisionID`, `set`, `setIfMissing`, `unset`, `inc`, `dec`, `insert`,
|
|
2040
|
+
* then `diffMatchPatch`. Reordering the properties changes mutation results.
|
|
2041
|
+
* Freezes the collection to prevent callers from replacing the functions
|
|
2042
|
+
* used by the SDK's mutation evaluator.
|
|
2043
|
+
*
|
|
2044
|
+
* @see https://www.sanity.io/docs/http-mutations#5b4db1396e56
|
|
2045
|
+
*
|
|
2046
|
+
* @example
|
|
2047
|
+
* ```ts
|
|
2048
|
+
* const document = {items: [{_key: 'a', title: 'Before'}]}
|
|
2049
|
+
* const updated = patchOperations.set<typeof document>(document, {
|
|
2050
|
+
* 'items[_key=="a"].title': 'After',
|
|
2051
|
+
* })
|
|
2052
|
+
* ```
|
|
2053
|
+
*
|
|
2054
|
+
* @internal
|
|
2055
|
+
*/
|
|
2056
|
+
declare const patchOperations: Readonly<{
|
|
2057
|
+
ifRevisionID: typeof ifRevisionID;
|
|
2058
|
+
set: typeof set;
|
|
2059
|
+
setIfMissing: typeof setIfMissing;
|
|
2060
|
+
unset: typeof unset;
|
|
2061
|
+
inc: typeof inc;
|
|
2062
|
+
dec: typeof dec;
|
|
2063
|
+
insert: typeof insert;
|
|
2064
|
+
diffMatchPatch: typeof diffMatchPatch;
|
|
2065
|
+
}>;
|
|
2066
|
+
/**
|
|
2067
|
+
* Configures {@link processMutations}.
|
|
2068
|
+
*
|
|
2069
|
+
* @internal
|
|
2070
|
+
*/
|
|
2071
|
+
interface ProcessMutationsOptions {
|
|
2072
|
+
/**
|
|
2073
|
+
* The transaction ID that will become the next `_rev` for documents mutated
|
|
2074
|
+
* by the given mutations.
|
|
2075
|
+
*/
|
|
2076
|
+
transactionId: string;
|
|
2077
|
+
/**
|
|
2078
|
+
* The input document set that the mutations will be applied to.
|
|
2079
|
+
*/
|
|
2080
|
+
documents: DocumentSet;
|
|
2081
|
+
/**
|
|
2082
|
+
* A list of mutations to apply to the given document set.
|
|
2083
|
+
*/
|
|
2084
|
+
mutations: Mutation[];
|
|
2085
|
+
/**
|
|
2086
|
+
* Supplies the default `_createdAt` and `_updatedAt` timestamps.
|
|
2087
|
+
* Uses the current time when omitted or empty.
|
|
2088
|
+
*/
|
|
2089
|
+
timestamp?: string;
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Applies mutations to an in-memory set of Sanity documents.
|
|
2093
|
+
* Deleted documents remain in the returned set with a value of `null`.
|
|
2094
|
+
*
|
|
2095
|
+
* Include every document affected by `mutations` in `documents`, using `null`
|
|
2096
|
+
* for documents that do not exist.
|
|
2097
|
+
*
|
|
2098
|
+
* Returns `documents` itself when `mutations` is empty. Otherwise, returns a
|
|
2099
|
+
* shallow copy of that object. The result can reuse document objects and
|
|
2100
|
+
* nested objects from `documents`. Mutating a reused object through the
|
|
2101
|
+
* result also changes the input.
|
|
2102
|
+
*
|
|
2103
|
+
* Sets `_rev` to `transactionId` on created, replaced, and patched documents.
|
|
2104
|
+
* Uses `timestamp` for timestamps unless the mutation preserves them.
|
|
2105
|
+
* Ignores `merge` patches; `inc` and `dec` skip values that are not numbers.
|
|
2106
|
+
* Generates document IDs when omitted or ending in `.`.
|
|
2107
|
+
* Patch operations can generate missing array keys.
|
|
2108
|
+
*
|
|
2109
|
+
* Does not persist documents or run Content Lake's server validation.
|
|
2110
|
+
*
|
|
2111
|
+
* @throws If a selection uses a query, a `create` targets an existing document,
|
|
2112
|
+
* or a `patch` targets a document that does not exist.
|
|
2113
|
+
* @throws If a patch operation fails, including a revision check failure or
|
|
2114
|
+
* `diffMatchPatch` applied to a value other than a string or `undefined`.
|
|
2115
|
+
*
|
|
2116
|
+
* @internal
|
|
2117
|
+
*/
|
|
2118
|
+
declare function processMutations({ documents, mutations, transactionId, timestamp }: ProcessMutationsOptions): DocumentSet;
|
|
1648
2119
|
type Grant = 'read' | 'update' | 'create' | 'history';
|
|
1649
2120
|
/** @beta */
|
|
1650
2121
|
interface PermissionDeniedReason {
|
|
@@ -1678,7 +2149,7 @@ interface DocumentStoreState {
|
|
|
1678
2149
|
identity?: string;
|
|
1679
2150
|
error?: unknown;
|
|
1680
2151
|
sharedListener: SharedListener;
|
|
1681
|
-
fetchDocument: (documentId: string) => Observable<
|
|
2152
|
+
fetchDocument: (documentId: string) => Observable<ResolveDocument | null>;
|
|
1682
2153
|
events: Subject<DocumentEvent>;
|
|
1683
2154
|
}
|
|
1684
2155
|
interface DocumentState {
|
|
@@ -1687,12 +2158,12 @@ interface DocumentState {
|
|
|
1687
2158
|
* the "remote" local copy that matches the server. represents the last known
|
|
1688
2159
|
* server state. this gets updated every time we confirm remote patches
|
|
1689
2160
|
*/
|
|
1690
|
-
remote?:
|
|
2161
|
+
remote?: ResolveDocument | null;
|
|
1691
2162
|
/**
|
|
1692
2163
|
* the current ephemeral working copy that includes local optimistic changes
|
|
1693
2164
|
* that have not yet been confirmed by the server
|
|
1694
2165
|
*/
|
|
1695
|
-
local?:
|
|
2166
|
+
local?: ResolveDocument | null;
|
|
1696
2167
|
/**
|
|
1697
2168
|
* the revision that our remote document is at
|
|
1698
2169
|
*/
|
|
@@ -1731,15 +2202,15 @@ interface DocumentOptions<TPath extends string | undefined = undefined, TDocumen
|
|
|
1731
2202
|
path?: TPath;
|
|
1732
2203
|
}
|
|
1733
2204
|
/** @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<
|
|
2205
|
+
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
2206
|
/** @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<
|
|
2207
|
+
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
2208
|
/** @beta */
|
|
1738
2209
|
declare function getDocumentState<TData>(instance: SanityInstance, options: DocumentOptions<string | undefined>): StateSource<TData | undefined | null>;
|
|
1739
2210
|
/** @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<
|
|
2211
|
+
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
2212
|
/** @beta */
|
|
1742
|
-
declare function resolveDocument<TData extends
|
|
2213
|
+
declare function resolveDocument<TData extends ResolveDocument>(instance: SanityInstance, docHandle: DocumentHandle<string, string, string>): Promise<TData | null>;
|
|
1743
2214
|
/** @beta */
|
|
1744
2215
|
declare const getDocumentSyncStatus: BoundStoreAction<DocumentStoreState, [doc: DocumentHandle<string, string, string>], StateSource<boolean | undefined>>;
|
|
1745
2216
|
type PermissionsStateOptions = {
|
|
@@ -2053,7 +2524,7 @@ interface DocumentRemotePatchesEvent {
|
|
|
2053
2524
|
origin: 'local' | 'remote';
|
|
2054
2525
|
}
|
|
2055
2526
|
/** @beta */
|
|
2056
|
-
interface ActionsResult<TDocument extends
|
|
2527
|
+
interface ActionsResult<TDocument extends ResolveDocument = ResolveDocument> {
|
|
2057
2528
|
transactionId: string;
|
|
2058
2529
|
documents: DocumentSet<TDocument>;
|
|
2059
2530
|
previous: DocumentSet<TDocument>;
|
|
@@ -2086,7 +2557,7 @@ interface ApplyDocumentActionsOptions {
|
|
|
2086
2557
|
disableBatching?: boolean;
|
|
2087
2558
|
}
|
|
2088
2559
|
/** @beta */
|
|
2089
|
-
declare function applyDocumentActions<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult<
|
|
2560
|
+
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
2561
|
/** @beta */
|
|
2091
2562
|
declare function applyDocumentActions(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult>;
|
|
2092
2563
|
/**
|
|
@@ -2152,26 +2623,6 @@ interface InstallationAccess {
|
|
|
2152
2623
|
resourceType: 'datasets' | 'canvases' | 'dashboards' | 'media-libraries';
|
|
2153
2624
|
resourceId: string;
|
|
2154
2625
|
}
|
|
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
2626
|
/**
|
|
2176
2627
|
* The active config of an installation, embedded when `activeConfig` is
|
|
2177
2628
|
* included. `null` when nothing is deployed.
|
|
@@ -2224,7 +2675,7 @@ type Installation<Include extends InstallationInclude = never> = InstallationBas
|
|
|
2224
2675
|
}> & Included<InstallationInclude, 'access', Include, {
|
|
2225
2676
|
access: InstallationAccess[];
|
|
2226
2677
|
}> & Included<InstallationInclude, 'interfaces', Include, {
|
|
2227
|
-
interfaces:
|
|
2678
|
+
interfaces: ApplicationInterface[];
|
|
2228
2679
|
}>;
|
|
2229
2680
|
/**
|
|
2230
2681
|
* Options for listing an organization's installations.
|
|
@@ -2825,7 +3276,7 @@ interface ProjectionOptions<TProjection extends string = string, TDocumentType e
|
|
|
2825
3276
|
/**
|
|
2826
3277
|
* @beta
|
|
2827
3278
|
*/
|
|
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<
|
|
3279
|
+
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
3280
|
/**
|
|
2830
3281
|
* @beta
|
|
2831
3282
|
*/
|
|
@@ -2835,7 +3286,7 @@ declare function getProjectionState<TData extends object>(instance: SanityInstan
|
|
|
2835
3286
|
*/
|
|
2836
3287
|
declare function getProjectionState(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<Record<string, unknown>> | undefined>;
|
|
2837
3288
|
/** @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<
|
|
3289
|
+
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
3290
|
/** @beta */
|
|
2840
3291
|
declare function resolveProjection<TData extends object>(instance: SanityInstance, options: ProjectionOptions): Promise<ProjectionValuePending<TData>>;
|
|
2841
3292
|
/** @public */
|
|
@@ -2885,7 +3336,7 @@ declare const parseQueryKey: (key: string) => QueryOptions;
|
|
|
2885
3336
|
*
|
|
2886
3337
|
* @beta
|
|
2887
3338
|
*/
|
|
2888
|
-
declare function getQueryState<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, queryOptions: QueryOptions<TQuery, TDataset, TProjectId>): StateSource<
|
|
3339
|
+
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
3340
|
/** @beta */
|
|
2890
3341
|
declare function getQueryState<TData>(instance: SanityInstance, queryOptions: QueryOptions): StateSource<TData | undefined>;
|
|
2891
3342
|
/** @beta */
|
|
@@ -2905,7 +3356,7 @@ declare function getQueryState(instance: SanityInstance, queryOptions: QueryOpti
|
|
|
2905
3356
|
*
|
|
2906
3357
|
* @beta
|
|
2907
3358
|
*/
|
|
2908
|
-
declare function resolveQuery<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, queryOptions: ResolveQueryOptions<TQuery, TDataset, TProjectId>): Promise<
|
|
3359
|
+
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
3360
|
/** @beta */
|
|
2910
3361
|
declare function resolveQuery<TData>(instance: SanityInstance, queryOptions: ResolveQueryOptions): Promise<TData>;
|
|
2911
3362
|
/**
|
|
@@ -2954,6 +3405,21 @@ type BoundGetPerspectiveState = BoundStoreAction<ReleasesStoreState, SelectorPar
|
|
|
2954
3405
|
* @public
|
|
2955
3406
|
*/
|
|
2956
3407
|
declare const getPerspectiveState: BoundGetPerspectiveState;
|
|
3408
|
+
/**
|
|
3409
|
+
* Preserves a projection string's literal type and returns the string unchanged.
|
|
3410
|
+
* Use this import when migrating an app with existing experimental Typegen output.
|
|
3411
|
+
*
|
|
3412
|
+
* Current Typegen does not scan this helper. New or changed projections need an
|
|
3413
|
+
* explicit result type until projection generation is supported.
|
|
3414
|
+
*
|
|
3415
|
+
* @example
|
|
3416
|
+
* ```ts
|
|
3417
|
+
* const preview = defineProjection('{title, "author": author->name}')
|
|
3418
|
+
* ```
|
|
3419
|
+
*
|
|
3420
|
+
* @beta
|
|
3421
|
+
*/
|
|
3422
|
+
declare function defineProjection<const TProjection extends string>(projection: TProjection): TProjection;
|
|
2957
3423
|
/**
|
|
2958
3424
|
* Returns the state source for users associated with a specific resource.
|
|
2959
3425
|
*
|
|
@@ -3127,8 +3593,10 @@ interface AuthStoreState {
|
|
|
3127
3593
|
callbackUrl: string | undefined;
|
|
3128
3594
|
providedToken: string | undefined;
|
|
3129
3595
|
authMethod: AuthMethodOptions;
|
|
3596
|
+
oauth: AuthConfig['oauth'];
|
|
3130
3597
|
};
|
|
3131
3598
|
dashboardContext?: DashboardContext;
|
|
3599
|
+
oauthTokens?: OAuthTokens;
|
|
3132
3600
|
}
|
|
3133
3601
|
/**
|
|
3134
3602
|
* @public
|
|
@@ -3161,5 +3629,5 @@ declare const getIsInDashboardState: BoundStoreAction<AuthStoreState, [], StateS
|
|
|
3161
3629
|
* @internal
|
|
3162
3630
|
*/
|
|
3163
3631
|
declare const setAuthToken: BoundStoreAction<AuthStoreState, [token: string | null], void>;
|
|
3164
|
-
export {
|
|
3165
|
-
//# sourceMappingURL=authStore-
|
|
3632
|
+
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 };
|
|
3633
|
+
//# sourceMappingURL=authStore-BGoEGxOq.d.ts.map
|