@sanity/client 8.0.0 → 8.1.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/README.md +94 -0
- package/dist/{browserUpload-CQgx9YYo.js → browserUpload-2tz6Sdqp.js} +4 -3
- package/dist/browserUpload-2tz6Sdqp.js.map +1 -0
- package/dist/{browserUpload-icWlVP15.js → browserUpload-CwpNx7Vl.js} +4 -3
- package/dist/browserUpload-CwpNx7Vl.js.map +1 -0
- package/dist/{config-a8VajuEY.js → config-3wiPP-sZ.js} +2 -2
- package/dist/config-3wiPP-sZ.js.map +1 -0
- package/dist/csm.js +2 -2
- package/dist/csm.js.map +1 -1
- package/dist/index.d.ts +17 -11
- package/dist/index.js +247 -120
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +270 -26
- package/dist/index.node.js +183 -50
- package/dist/index.node.js.map +1 -1
- package/dist/media-library.d.ts +1 -1
- package/dist/{request-CJxcN16k.js → request-BhMuKj0D.js} +10 -9
- package/dist/request-BhMuKj0D.js.map +1 -0
- package/dist/{request-k7VS_NnC.js → request-SnMg7nUX.js} +10 -9
- package/dist/request-SnMg7nUX.js.map +1 -0
- package/dist/{resolveEditInfo-sq7yF78q.js → resolveEditInfo-Cz-smq3a.js} +17 -3
- package/dist/resolveEditInfo-Cz-smq3a.js.map +1 -0
- package/dist/stega.js +1 -1
- package/dist/{stegaEncodeSourceMap-DkoIlutY.js → stegaEncodeSourceMap-DbM2fTN4.js} +8 -2
- package/dist/stegaEncodeSourceMap-DbM2fTN4.js.map +1 -0
- package/dist/{stegaEncodeSourceMap-B2fGArSf.js → stegaEncodeSourceMap-YR3NQ3iz.js} +2 -2
- package/dist/{stegaEncodeSourceMap-B2fGArSf.js.map → stegaEncodeSourceMap-YR3NQ3iz.js.map} +1 -1
- package/dist/{types-CUxZSgB2.d.ts → types-BODIEY7F.d.ts} +262 -24
- package/package.json +26 -11
- package/src/SanityClient.ts +19 -20
- package/src/assets/AssetsClient.ts +54 -5
- package/src/csm/applySourceDocuments.ts +2 -4
- package/src/csm/draftUtils.ts +23 -4
- package/src/data/dataMethods.ts +2 -19
- package/src/data/eventsource.ts +71 -41
- package/src/data/live.ts +17 -9
- package/src/data/resolveEventSourceFetch.ts +9 -1
- package/src/defineCreateClient.ts +5 -1
- package/src/functions/FunctionsClient.ts +66 -0
- package/src/functions/invoke.ts +176 -0
- package/src/http/browserUpload.ts +1 -0
- package/src/http/errors.ts +2 -1
- package/src/http/request.ts +8 -14
- package/src/mediaLibrary/MediaLibraryVideoClient.ts +1 -1
- package/src/types.ts +186 -4
- package/src/validators.ts +1 -1
- package/src/warnings.ts +7 -1
- package/dist/browserUpload-CQgx9YYo.js.map +0 -1
- package/dist/browserUpload-icWlVP15.js.map +0 -1
- package/dist/config-a8VajuEY.js.map +0 -1
- package/dist/request-CJxcN16k.js.map +0 -1
- package/dist/request-k7VS_NnC.js.map +0 -1
- package/dist/resolveEditInfo-sq7yF78q.js.map +0 -1
- package/dist/stegaEncodeSourceMap-DkoIlutY.js.map +0 -1
package/dist/index.node.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FetchFunction } from "get-it";
|
|
1
|
+
import { FetchFunction, RequestOptions as RequestOptions$1, TimeoutErrorLike, isTimeoutError } from "get-it";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
3
|
import { ContentSourceMapDocuments as ContentSourceMapDocuments$1, ContentSourceMapParsedPath, ContentSourceMapParsedPath as ContentSourceMapParsedPath$1, ContentSourceMapParsedPathKeyedSegment, ResolveStudioUrl, StudioBaseRoute, StudioBaseUrl, StudioUrl, StudioUrl as StudioUrl$1 } from "@sanity/client/csm";
|
|
4
|
+
import { EventSourceConstructor } from "eventsource";
|
|
4
5
|
import { ClientPerspective as ClientPerspective$1 } from "@sanity/client";
|
|
5
6
|
/** @public */
|
|
6
7
|
interface StegaConfig {
|
|
@@ -1149,6 +1150,16 @@ declare class AssetsClient {
|
|
|
1149
1150
|
/**
|
|
1150
1151
|
* Uploads a file asset to the configured dataset
|
|
1151
1152
|
*
|
|
1153
|
+
* Note: when the client is configured against a Media Library
|
|
1154
|
+
* (`resource: {type: 'media-library', id}`), this resolves to a
|
|
1155
|
+
* {@link MediaLibraryAssetDocument} at runtime, not to a
|
|
1156
|
+
* {@link SanityAssetDocument}. The declared type cannot express that: the
|
|
1157
|
+
* shape depends on the client's configuration rather than on the arguments,
|
|
1158
|
+
* so an overload cannot discriminate it, and widening the return type into a
|
|
1159
|
+
* union would be a breaking change for every existing caller. Narrow the
|
|
1160
|
+
* result yourself (for example, check for `currentVersion`) if you upload to
|
|
1161
|
+
* a Media Library. Typing this honestly is deferred to the next major.
|
|
1162
|
+
*
|
|
1152
1163
|
* @param assetType - Asset type (file)
|
|
1153
1164
|
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1154
1165
|
* @param options - Options to use for the upload
|
|
@@ -1157,6 +1168,10 @@ declare class AssetsClient {
|
|
|
1157
1168
|
/**
|
|
1158
1169
|
* Uploads an image asset to the configured dataset
|
|
1159
1170
|
*
|
|
1171
|
+
* Note: against a Media Library this resolves to a
|
|
1172
|
+
* {@link MediaLibraryAssetDocument} at runtime. See the `'file'` overload
|
|
1173
|
+
* above for why the declared type cannot say so.
|
|
1174
|
+
*
|
|
1160
1175
|
* @param assetType - Asset type (image)
|
|
1161
1176
|
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1162
1177
|
* @param options - Options to use for the upload
|
|
@@ -1676,6 +1691,72 @@ declare class DatasetsClient {
|
|
|
1676
1691
|
*/
|
|
1677
1692
|
editEmbeddingsSettings(name: string, settings: EmbeddingsSettingsBody): Promise<void>;
|
|
1678
1693
|
}
|
|
1694
|
+
/** @public */
|
|
1695
|
+
interface InvokeFunctionEvent {
|
|
1696
|
+
/**
|
|
1697
|
+
* Payload handed to the function.
|
|
1698
|
+
* The function receives it as `event.data`.
|
|
1699
|
+
*/
|
|
1700
|
+
data?: unknown;
|
|
1701
|
+
}
|
|
1702
|
+
/** @public */
|
|
1703
|
+
interface InvokeFunctionRequest {
|
|
1704
|
+
event?: InvokeFunctionEvent;
|
|
1705
|
+
/**
|
|
1706
|
+
* Stack to resolve the function name against.
|
|
1707
|
+
* Overrides `stackId` from the client config.
|
|
1708
|
+
*/
|
|
1709
|
+
stackId?: string;
|
|
1710
|
+
/**
|
|
1711
|
+
* Organization owning the stack.
|
|
1712
|
+
*/
|
|
1713
|
+
organizationId?: string;
|
|
1714
|
+
/**
|
|
1715
|
+
* Milliseconds to wait for the function to return.
|
|
1716
|
+
*/
|
|
1717
|
+
timeout?: number;
|
|
1718
|
+
/** Abort the invocation. */
|
|
1719
|
+
signal?: AbortSignal;
|
|
1720
|
+
}
|
|
1721
|
+
/** @public */
|
|
1722
|
+
declare class ObservableFunctionsClient {
|
|
1723
|
+
#private;
|
|
1724
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest);
|
|
1725
|
+
/**
|
|
1726
|
+
* Invoke a deployed function by its blueprint name.
|
|
1727
|
+
*
|
|
1728
|
+
* The name is resolved within the stack given by `stackId` on the request or
|
|
1729
|
+
* the client config. Passes the function's return value once it finishes.
|
|
1730
|
+
*
|
|
1731
|
+
* @param functionName - name of the function, as declared in the blueprint
|
|
1732
|
+
* @param request - payload and request options
|
|
1733
|
+
*/
|
|
1734
|
+
invoke<R = unknown>(functionName: string, request?: InvokeFunctionRequest): Observable<R | undefined>;
|
|
1735
|
+
}
|
|
1736
|
+
/** @public */
|
|
1737
|
+
declare class FunctionsClient {
|
|
1738
|
+
#private;
|
|
1739
|
+
constructor(client: SanityClient, httpRequest: HttpRequest);
|
|
1740
|
+
/**
|
|
1741
|
+
* Invoke a deployed function by its blueprint name.
|
|
1742
|
+
*
|
|
1743
|
+
* The name is resolved within the stack given by `stackId` on the request or
|
|
1744
|
+
* the client config, which costs one extra request per call. Rejects if the
|
|
1745
|
+
* stack has no function by that name, or if the name resolves to anything
|
|
1746
|
+
* other than a `sanity.function.pubsub` function.
|
|
1747
|
+
*
|
|
1748
|
+
* The lookup is scoped to `projectId`, or to `organizationId` when one is set
|
|
1749
|
+
* for a stack deployed at organization scope.
|
|
1750
|
+
*
|
|
1751
|
+
* The request stays open until the function finishes, and resolves with its
|
|
1752
|
+
* return value, or `undefined` if it returns nothing. Long-running functions
|
|
1753
|
+
* may need an explicit `timeout`.
|
|
1754
|
+
*
|
|
1755
|
+
* @param functionName - name of the function, as declared in the blueprint
|
|
1756
|
+
* @param request - payload and request options
|
|
1757
|
+
*/
|
|
1758
|
+
invoke<R = unknown>(functionName: string, request?: InvokeFunctionRequest): Promise<R | undefined>;
|
|
1759
|
+
}
|
|
1679
1760
|
/** @internal */
|
|
1680
1761
|
declare class ObservableMediaLibraryVideoClient {
|
|
1681
1762
|
#private;
|
|
@@ -2270,6 +2351,7 @@ declare class ObservableSanityClient {
|
|
|
2270
2351
|
agent: {
|
|
2271
2352
|
action: ObservableAgentsActionClient;
|
|
2272
2353
|
};
|
|
2354
|
+
functions: ObservableFunctionsClient;
|
|
2273
2355
|
releases: ObservableReleasesClient;
|
|
2274
2356
|
/**
|
|
2275
2357
|
* Instance properties
|
|
@@ -2609,12 +2691,12 @@ declare class ObservableSanityClient {
|
|
|
2609
2691
|
delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>;
|
|
2610
2692
|
/**
|
|
2611
2693
|
* Deletes a document with the given document ID.
|
|
2612
|
-
* Returns an observable that resolves to the deleted document.
|
|
2694
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
2613
2695
|
*
|
|
2614
2696
|
* @param id - Document ID to delete
|
|
2615
2697
|
* @param options - Options for the mutation
|
|
2616
2698
|
*/
|
|
2617
|
-
delete
|
|
2699
|
+
delete(id: string, options?: BaseMutationOptions): Observable<MultipleMutationResult>;
|
|
2618
2700
|
/**
|
|
2619
2701
|
* Deletes one or more documents matching the given query or document ID.
|
|
2620
2702
|
* Returns an observable that resolves to first deleted document.
|
|
@@ -2649,12 +2731,12 @@ declare class ObservableSanityClient {
|
|
|
2649
2731
|
delete(selection: MutationSelection, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>;
|
|
2650
2732
|
/**
|
|
2651
2733
|
* Deletes one or more documents matching the given query or document ID.
|
|
2652
|
-
* Returns an observable that resolves to
|
|
2734
|
+
* Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
|
|
2653
2735
|
*
|
|
2654
2736
|
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2655
2737
|
* @param options - Options for the mutation
|
|
2656
2738
|
*/
|
|
2657
|
-
delete
|
|
2739
|
+
delete(selection: MutationSelection, options?: BaseMutationOptions): Observable<MultipleMutationResult>;
|
|
2658
2740
|
/**
|
|
2659
2741
|
* @public
|
|
2660
2742
|
*
|
|
@@ -2821,12 +2903,12 @@ declare class ObservableSanityClient {
|
|
|
2821
2903
|
mutate<R extends Record<string, Any> = Record<string, Any>>(operations: Mutation<R>[] | ObservablePatch | ObservableTransaction, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>;
|
|
2822
2904
|
/**
|
|
2823
2905
|
* Perform mutation operations against the configured dataset
|
|
2824
|
-
* Returns an observable that resolves to the
|
|
2906
|
+
* Returns an observable that resolves to a mutation result object containing the mutated document IDs.
|
|
2825
2907
|
*
|
|
2826
2908
|
* @param operations - Mutation operations to execute
|
|
2827
2909
|
* @param options - Mutation options
|
|
2828
2910
|
*/
|
|
2829
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(operations: Mutation<R>[] | ObservablePatch | ObservableTransaction, options?: BaseMutationOptions): Observable<
|
|
2911
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(operations: Mutation<R>[] | ObservablePatch | ObservableTransaction, options?: BaseMutationOptions): Observable<MultipleMutationResult>;
|
|
2830
2912
|
/**
|
|
2831
2913
|
* Create a new buildable patch of operations to perform
|
|
2832
2914
|
*
|
|
@@ -2899,6 +2981,7 @@ declare class SanityClient {
|
|
|
2899
2981
|
agent: {
|
|
2900
2982
|
action: AgentActionsClient;
|
|
2901
2983
|
};
|
|
2984
|
+
functions: FunctionsClient;
|
|
2902
2985
|
releases: ReleasesClient;
|
|
2903
2986
|
/**
|
|
2904
2987
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
@@ -3231,12 +3314,12 @@ declare class SanityClient {
|
|
|
3231
3314
|
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>;
|
|
3232
3315
|
/**
|
|
3233
3316
|
* Deletes a document with the given document ID.
|
|
3234
|
-
* Returns a promise that resolves to the deleted document.
|
|
3317
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
3235
3318
|
*
|
|
3236
3319
|
* @param id - Document ID to delete
|
|
3237
3320
|
* @param options - Options for the mutation
|
|
3238
3321
|
*/
|
|
3239
|
-
delete
|
|
3322
|
+
delete(id: string, options?: BaseMutationOptions): Promise<MultipleMutationResult>;
|
|
3240
3323
|
/**
|
|
3241
3324
|
* Deletes one or more documents matching the given query or document ID.
|
|
3242
3325
|
* Returns a promise that resolves to first deleted document.
|
|
@@ -3271,12 +3354,12 @@ declare class SanityClient {
|
|
|
3271
3354
|
delete(selection: MutationSelection, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>;
|
|
3272
3355
|
/**
|
|
3273
3356
|
* Deletes one or more documents matching the given query or document ID.
|
|
3274
|
-
* Returns a promise that resolves to
|
|
3357
|
+
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
3275
3358
|
*
|
|
3276
3359
|
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3277
3360
|
* @param options - Options for the mutation
|
|
3278
3361
|
*/
|
|
3279
|
-
delete
|
|
3362
|
+
delete(selection: MutationSelection, options?: BaseMutationOptions): Promise<MultipleMutationResult>;
|
|
3280
3363
|
/**
|
|
3281
3364
|
* @public
|
|
3282
3365
|
*
|
|
@@ -3443,12 +3526,12 @@ declare class SanityClient {
|
|
|
3443
3526
|
mutate<R extends Record<string, Any> = Record<string, Any>>(operations: Mutation<R>[] | Patch | Transaction, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>;
|
|
3444
3527
|
/**
|
|
3445
3528
|
* Perform mutation operations against the configured dataset
|
|
3446
|
-
* Returns a promise that resolves to the
|
|
3529
|
+
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
3447
3530
|
*
|
|
3448
3531
|
* @param operations - Mutation operations to execute
|
|
3449
3532
|
* @param options - Mutation options
|
|
3450
3533
|
*/
|
|
3451
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(operations: Mutation<R>[] | Patch | Transaction, options?: BaseMutationOptions): Promise<
|
|
3534
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(operations: Mutation<R>[] | Patch | Transaction, options?: BaseMutationOptions): Promise<MultipleMutationResult>;
|
|
3452
3535
|
/**
|
|
3453
3536
|
* Create a new buildable patch of operations to perform
|
|
3454
3537
|
*
|
|
@@ -3770,8 +3853,9 @@ type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any
|
|
|
3770
3853
|
/** @beta */
|
|
3771
3854
|
type GenerateInstruction<T extends Record<string, Any> = Record<string, Any>> = GenerateSyncInstruction<T> | GenerateAsyncInstruction<T>;
|
|
3772
3855
|
/**
|
|
3773
|
-
* Low-level requester returned by `
|
|
3774
|
-
* `client.config().requester` and as the named `requester`
|
|
3856
|
+
* Low-level requester returned by `defineRequester(...).observable`.
|
|
3857
|
+
* Surfaces as `client.config().requester` and as the named `requester`
|
|
3858
|
+
* export.
|
|
3775
3859
|
*
|
|
3776
3860
|
* Defined locally rather than imported from `http/request` so api-extractor
|
|
3777
3861
|
* inlines it into the bundled `.d.ts` instead of emitting a relative import
|
|
@@ -3803,6 +3887,25 @@ interface RequestOptions {
|
|
|
3803
3887
|
body?: Any;
|
|
3804
3888
|
signal?: AbortSignal;
|
|
3805
3889
|
}
|
|
3890
|
+
/**
|
|
3891
|
+
* The fully resolved request passed to a {@link RequestHandler}.
|
|
3892
|
+
*
|
|
3893
|
+
* @public
|
|
3894
|
+
*/
|
|
3895
|
+
type RequestHandlerOptions = RequestOptions$1;
|
|
3896
|
+
/**
|
|
3897
|
+
* Intercepts a client request around the normal HTTP pipeline.
|
|
3898
|
+
*
|
|
3899
|
+
* Call `next(request)` to execute the request. It resolves to the parsed
|
|
3900
|
+
* response body and rejects with the same errors the client normally exposes,
|
|
3901
|
+
* including {@link ClientError} and {@link ServerError}. A handler can modify
|
|
3902
|
+
* the request, retry it by calling `next` again, or return a synthetic body.
|
|
3903
|
+
*
|
|
3904
|
+
* Browser asset uploads and server-sent event connections do not use this handler.
|
|
3905
|
+
*
|
|
3906
|
+
* @public
|
|
3907
|
+
*/
|
|
3908
|
+
type RequestHandler = (request: RequestHandlerOptions, next: (request: RequestHandlerOptions) => Promise<unknown>) => Promise<unknown>;
|
|
3806
3909
|
/**
|
|
3807
3910
|
* @public
|
|
3808
3911
|
* @deprecated – The `r`-prefix is not required, use `string` instead
|
|
@@ -3895,6 +3998,19 @@ interface ClientConfig {
|
|
|
3895
3998
|
* Optional request tag prefix for all request tags
|
|
3896
3999
|
*/
|
|
3897
4000
|
requestTagPrefix?: string;
|
|
4001
|
+
/**
|
|
4002
|
+
* Intercepts requests after the client has resolved their URL, headers, and
|
|
4003
|
+
* transport options. The handler wraps the normal client pipeline, so errors
|
|
4004
|
+
* from `next` are already converted to {@link ClientError} or
|
|
4005
|
+
* {@link ServerError}.
|
|
4006
|
+
*
|
|
4007
|
+
* A handler supplied through `withConfig()` replaces the current handler.
|
|
4008
|
+
* To compose handlers, read the current handler from `client.config()` and
|
|
4009
|
+
* call it from the replacement.
|
|
4010
|
+
*
|
|
4011
|
+
* Browser asset uploads and server-sent event connections are not intercepted.
|
|
4012
|
+
*/
|
|
4013
|
+
requestHandler?: RequestHandler;
|
|
3898
4014
|
/**
|
|
3899
4015
|
* Optional default headers to include with all requests
|
|
3900
4016
|
*
|
|
@@ -3984,6 +4100,15 @@ interface ClientConfig {
|
|
|
3984
4100
|
* Lineage token for recursion control
|
|
3985
4101
|
*/
|
|
3986
4102
|
lineage?: string;
|
|
4103
|
+
/**
|
|
4104
|
+
* ID of the blueprints stack that `functions.invoke()` resolves function
|
|
4105
|
+
* names against. Function names are unique within a stack
|
|
4106
|
+
*/
|
|
4107
|
+
stackId?: string;
|
|
4108
|
+
/**
|
|
4109
|
+
* ID of the organization owning the blueprints stack
|
|
4110
|
+
*/
|
|
4111
|
+
organizationId?: string;
|
|
3987
4112
|
}
|
|
3988
4113
|
/** @public */
|
|
3989
4114
|
interface InitializedClientConfig extends ClientConfig {
|
|
@@ -4178,7 +4303,7 @@ interface ErrorProps {
|
|
|
4178
4303
|
* @internal
|
|
4179
4304
|
*/
|
|
4180
4305
|
type HttpRequest = {
|
|
4181
|
-
(options: Any): Promise<unknown>;
|
|
4306
|
+
(options: Any, requestHandler?: RequestHandler): Promise<unknown>;
|
|
4182
4307
|
};
|
|
4183
4308
|
/**
|
|
4184
4309
|
* Target URL for a request. Exactly one of `url` or the deprecated `uri` alias
|
|
@@ -4458,10 +4583,15 @@ type Mutation<R extends Record<string, Any> = Record<string, Any>> = {
|
|
|
4458
4583
|
};
|
|
4459
4584
|
/** @public */
|
|
4460
4585
|
type ReleaseAction = CreateReleaseAction | EditReleaseAction | PublishReleaseAction | ArchiveReleaseAction | UnarchiveReleaseAction | ScheduleReleaseAction | UnscheduleReleaseAction | DeleteReleaseAction | ImportReleaseAction;
|
|
4586
|
+
/**
|
|
4587
|
+
* @public
|
|
4588
|
+
* @beta
|
|
4589
|
+
*/
|
|
4590
|
+
type VariantDefinitionAction = CreateVariantDefinitionAction | EditVariantDefinitionAction | DeleteVariantDefinitionAction;
|
|
4461
4591
|
/** @public */
|
|
4462
4592
|
type VersionAction = CreateVersionAction | DiscardVersionAction | ReplaceVersionAction | UnpublishVersionAction;
|
|
4463
4593
|
/** @public */
|
|
4464
|
-
type Action = CreateAction | ReplaceDraftAction | EditAction | DeleteAction | DiscardAction | PublishAction | UnpublishAction | VersionAction | ReleaseAction;
|
|
4594
|
+
type Action = CreateAction | ReplaceDraftAction | EditAction | DeleteAction | DiscardAction | PublishAction | UnpublishAction | VersionAction | ReleaseAction | VariantDefinitionAction;
|
|
4465
4595
|
/** @public */
|
|
4466
4596
|
type ImportReleaseAction = {
|
|
4467
4597
|
actionType: 'sanity.action.release.import';
|
|
@@ -4600,6 +4730,76 @@ interface UnpublishVersionAction {
|
|
|
4600
4730
|
versionId: string;
|
|
4601
4731
|
publishedId: string;
|
|
4602
4732
|
}
|
|
4733
|
+
/**
|
|
4734
|
+
* Creates a new `system.variant` definition document.
|
|
4735
|
+
*
|
|
4736
|
+
* @public
|
|
4737
|
+
* @beta
|
|
4738
|
+
*/
|
|
4739
|
+
interface CreateVariantDefinitionAction {
|
|
4740
|
+
actionType: 'sanity.action.variant.definition.create';
|
|
4741
|
+
/**
|
|
4742
|
+
* Name of the variant definition to create, as in
|
|
4743
|
+
* `_.variants.{variantName}`. Must be a bare name, not a full document ID.
|
|
4744
|
+
*/
|
|
4745
|
+
variantId: string;
|
|
4746
|
+
/**
|
|
4747
|
+
* Conditions used to select this variant.
|
|
4748
|
+
*/
|
|
4749
|
+
conditions?: ClientVariantConditions;
|
|
4750
|
+
/**
|
|
4751
|
+
* Selection priority. Higher values are preferred when multiple variants
|
|
4752
|
+
* match.
|
|
4753
|
+
*
|
|
4754
|
+
* Defaults to `0`.
|
|
4755
|
+
*/
|
|
4756
|
+
priority?: number;
|
|
4757
|
+
metadata?: Record<string, Any>;
|
|
4758
|
+
}
|
|
4759
|
+
/**
|
|
4760
|
+
* Edits an existing variant definition.
|
|
4761
|
+
*
|
|
4762
|
+
* @public
|
|
4763
|
+
* @beta
|
|
4764
|
+
*/
|
|
4765
|
+
interface EditVariantDefinitionAction {
|
|
4766
|
+
actionType: 'sanity.action.variant.definition.edit';
|
|
4767
|
+
/**
|
|
4768
|
+
* Name of the variant definition to edit, as in `_.variants.{variantName}`.
|
|
4769
|
+
* Must be a bare name, not a full document ID.
|
|
4770
|
+
*/
|
|
4771
|
+
variantId: string;
|
|
4772
|
+
/**
|
|
4773
|
+
* Patch operations to apply.
|
|
4774
|
+
*/
|
|
4775
|
+
patch: PatchOperations;
|
|
4776
|
+
/**
|
|
4777
|
+
* When set, the action fails unless the current revision of the variant
|
|
4778
|
+
* definition matches this value.
|
|
4779
|
+
*/
|
|
4780
|
+
ifRevisionId?: string;
|
|
4781
|
+
}
|
|
4782
|
+
/**
|
|
4783
|
+
* Deletes a variant definition.
|
|
4784
|
+
*
|
|
4785
|
+
* Deletion fails if any document holds a strong reference to this variant.
|
|
4786
|
+
*
|
|
4787
|
+
* @public
|
|
4788
|
+
* @beta
|
|
4789
|
+
*/
|
|
4790
|
+
interface DeleteVariantDefinitionAction {
|
|
4791
|
+
actionType: 'sanity.action.variant.definition.delete';
|
|
4792
|
+
/**
|
|
4793
|
+
* Name of the variant definition to delete, as in
|
|
4794
|
+
* `_.variants.{variantName}`. Must be a bare name, not a full document ID.
|
|
4795
|
+
*/
|
|
4796
|
+
variantId: string;
|
|
4797
|
+
/**
|
|
4798
|
+
* When set, the action fails unless the current revision of the variant
|
|
4799
|
+
* definition matches this value.
|
|
4800
|
+
*/
|
|
4801
|
+
ifRevisionId?: string;
|
|
4802
|
+
}
|
|
4603
4803
|
/**
|
|
4604
4804
|
* Creates a new draft document. The published version of the document must not already exist.
|
|
4605
4805
|
* If the draft version of the document already exists the action will fail by default, but
|
|
@@ -5581,16 +5781,56 @@ interface VideoPlaybackTokens {
|
|
|
5581
5781
|
}
|
|
5582
5782
|
/** @public */
|
|
5583
5783
|
type MediaLibraryAssetInstanceIdentifier = string | SanityReference;
|
|
5784
|
+
/**
|
|
5785
|
+
* A single tracked version of a Media Library asset - one uploaded instance,
|
|
5786
|
+
* referencing the underlying (Content Lake shaped) asset document it wraps.
|
|
5787
|
+
*
|
|
5788
|
+
* @public
|
|
5789
|
+
*/
|
|
5790
|
+
interface MediaLibraryAssetVersion {
|
|
5791
|
+
_key: string;
|
|
5792
|
+
_type: 'sanity.asset.version';
|
|
5793
|
+
title?: string;
|
|
5794
|
+
instance: SanityReference;
|
|
5795
|
+
}
|
|
5796
|
+
/**
|
|
5797
|
+
* The document returned by the Media Library upload endpoint
|
|
5798
|
+
* (`POST /media-libraries/:id/upload`).
|
|
5799
|
+
*
|
|
5800
|
+
* This is _not_ the same shape as {@link SanityAssetDocument} /
|
|
5801
|
+
* {@link SanityImageAssetDocument}: a Media Library asset is a `sanity.asset`
|
|
5802
|
+
* document that tracks one or more uploaded versions, each pointing at its
|
|
5803
|
+
* own underlying Content Lake asset document via `currentVersion`/`versions`.
|
|
5804
|
+
*
|
|
5805
|
+
* Modelled directly on an observed API response. Fields whose full shape has
|
|
5806
|
+
* not been confirmed (`parent`, `rootDirectory`, `aspects`) are typed loosely
|
|
5807
|
+
* on purpose - widen them once their shape is confirmed.
|
|
5808
|
+
*
|
|
5809
|
+
* @public
|
|
5810
|
+
*/
|
|
5811
|
+
interface MediaLibraryAssetDocument {
|
|
5812
|
+
_id: string;
|
|
5813
|
+
_type: 'sanity.asset';
|
|
5814
|
+
assetType: string;
|
|
5815
|
+
title?: string;
|
|
5816
|
+
cdnAccessPolicy?: string;
|
|
5817
|
+
currentVersion: SanityReference;
|
|
5818
|
+
versions: MediaLibraryAssetVersion[];
|
|
5819
|
+
aspects?: Record<string, Any>;
|
|
5820
|
+
parent?: SanityReference | null;
|
|
5821
|
+
rootDirectory?: Any;
|
|
5822
|
+
}
|
|
5584
5823
|
/**
|
|
5585
5824
|
* @internal - it may have breaking changes in any release
|
|
5586
5825
|
*/
|
|
5587
5826
|
declare function validateApiPerspective(perspective: unknown): asserts perspective is ClientPerspective;
|
|
5588
5827
|
/**
|
|
5589
|
-
* @public
|
|
5590
5828
|
* Thrown when the EventSource connection could not be established, or was rejected by the server.
|
|
5591
5829
|
* Transient failures (network drops, 5xx, 408, 429) are reconnected internally and emitted as
|
|
5592
5830
|
* `reconnect` events; a permanent rejection (any other 4xx, eg an expired token) errors the
|
|
5593
5831
|
* stream with this class so consumers can react — check `status` for the rejection code.
|
|
5832
|
+
*
|
|
5833
|
+
* @public
|
|
5594
5834
|
*/
|
|
5595
5835
|
declare class ConnectionFailedError extends Error {
|
|
5596
5836
|
readonly name = "ConnectionFailedError";
|
|
@@ -5607,8 +5847,9 @@ declare class ConnectionFailedError extends Error {
|
|
|
5607
5847
|
}
|
|
5608
5848
|
/**
|
|
5609
5849
|
* The listener has been told to explicitly disconnect.
|
|
5610
|
-
*
|
|
5611
|
-
*
|
|
5850
|
+
* This is a rare situation, but may occur if the API knows reconnect attempts will fail,
|
|
5851
|
+
* eg in the case of a deleted dataset, a blocked project or similar events.
|
|
5852
|
+
*
|
|
5612
5853
|
* @public
|
|
5613
5854
|
*/
|
|
5614
5855
|
declare class DisconnectError extends Error {
|
|
@@ -5617,8 +5858,9 @@ declare class DisconnectError extends Error {
|
|
|
5617
5858
|
constructor(message: string, reason?: string, options?: ErrorOptions);
|
|
5618
5859
|
}
|
|
5619
5860
|
/**
|
|
5620
|
-
* @public
|
|
5621
5861
|
* The server sent a `channelError` message. Usually indicative of a bad or malformed request
|
|
5862
|
+
*
|
|
5863
|
+
* @public
|
|
5622
5864
|
*/
|
|
5623
5865
|
declare class ChannelError extends Error {
|
|
5624
5866
|
readonly name = "ChannelError";
|
|
@@ -5626,8 +5868,9 @@ declare class ChannelError extends Error {
|
|
|
5626
5868
|
constructor(message: string, data: unknown);
|
|
5627
5869
|
}
|
|
5628
5870
|
/**
|
|
5629
|
-
* @public
|
|
5630
5871
|
* The server sent an `error`-event to tell the client that an unexpected error has happened.
|
|
5872
|
+
*
|
|
5873
|
+
* @public
|
|
5631
5874
|
*/
|
|
5632
5875
|
declare class MessageError extends Error {
|
|
5633
5876
|
readonly name = "MessageError";
|
|
@@ -5635,8 +5878,9 @@ declare class MessageError extends Error {
|
|
|
5635
5878
|
constructor(message: string, data: unknown, options?: ErrorOptions);
|
|
5636
5879
|
}
|
|
5637
5880
|
/**
|
|
5638
|
-
* @public
|
|
5639
5881
|
* An error occurred while parsing the message sent by the server as JSON. Should normally not happen.
|
|
5882
|
+
*
|
|
5883
|
+
* @public
|
|
5640
5884
|
*/
|
|
5641
5885
|
declare class MessageParseError extends Error {
|
|
5642
5886
|
readonly name = "MessageParseError";
|
|
@@ -5656,7 +5900,7 @@ type EventSourceEvent<Name extends string> = ServerSentEvent<Name>;
|
|
|
5656
5900
|
/**
|
|
5657
5901
|
* @internal
|
|
5658
5902
|
*/
|
|
5659
|
-
type EventSourceInstance = InstanceType<
|
|
5903
|
+
type EventSourceInstance = InstanceType<EventSourceConstructor>;
|
|
5660
5904
|
/**
|
|
5661
5905
|
* Sanity API specific EventSource handler shared between the listen and live APIs
|
|
5662
5906
|
*
|
|
@@ -5676,7 +5920,7 @@ type EventSourceInstance = InstanceType<typeof globalThis.EventSource>;
|
|
|
5676
5920
|
*
|
|
5677
5921
|
* @internal
|
|
5678
5922
|
*/
|
|
5679
|
-
declare function connectEventSource<EventName extends string>(initEventSource: () => EventSourceInstance | Observable<EventSourceInstance>, events: EventName[]): Observable<
|
|
5923
|
+
declare function connectEventSource<EventName extends string>(initEventSource: () => EventSourceInstance | Observable<EventSourceInstance>, events: EventName[]): Observable<EventSourceEvent<EventName>>;
|
|
5680
5924
|
/**
|
|
5681
5925
|
* Shared properties for HTTP errors (eg both ClientError and ServerError)
|
|
5682
5926
|
* Use `isHttpError` for type narrowing and accessing response properties.
|
|
@@ -5754,5 +5998,5 @@ declare const createClient: (config: ClientConfig) => SanityClient;
|
|
|
5754
5998
|
* @deprecated Use the named export `createClient` instead of the `default` export
|
|
5755
5999
|
*/
|
|
5756
6000
|
declare const deprecatedCreateClient: (config: ClientConfig) => SanityClient;
|
|
5757
|
-
export { Action, ActionError, ActionErrorItem, type AgentActionParam, type AgentActionParams, type AgentActionPath, type AgentActionPathSegment, type AgentActionTarget, AllDocumentIdsMutationOptions, AllDocumentsMutationOptions, AnimatedImageFormat, AnimatedTransformOptions, Any, ApiError, ArchiveReleaseAction, AssetMetadataType, type AssetsClient, AttributeSet, AuthProvider, AuthProviderResponse, BaseActionOptions, BaseMutationOptions, BasePatch, BaseTransaction, ChannelError, ChannelErrorEvent, ClientConfig, ClientError, ClientPerspective, ClientReturn, ClientVariant, ClientVariantConditions, ConnectionFailedError, type ConstantAgentActionParam, ContentSourceMap, ContentSourceMapDocument, ContentSourceMapDocumentBase, ContentSourceMapDocumentValueSource, ContentSourceMapDocuments, ContentSourceMapLiteralSource, ContentSourceMapMapping, ContentSourceMapMappings, type ContentSourceMapParsedPath, type ContentSourceMapParsedPathKeyedSegment, ContentSourceMapPaths, ContentSourceMapRemoteDocument, ContentSourceMapSource, ContentSourceMapUnknownSource, ContentSourceMapValueMapping, CorsOriginError, CreateAction, CreateReleaseAction, CreateVersionAction, CurrentSanityUser, DatasetAclMode, DatasetCreateOptions, DatasetEditOptions, DatasetResponse, type DatasetsClient, DatasetsResponse, DeleteAction, DeleteReleaseAction, DiscardAction, DiscardVersionAction, DisconnectError, DisconnectEvent, type DocumentAgentActionParam, EXPERIMENTAL_API_WARNING, EditAction, EditReleaseAction, EditableReleaseDocument, EmbeddingsSettings, EmbeddingsSettingsBody, ErrorProps, type EventSourceEvent, type EventSourceInstance, type FieldAgentActionParam, type FilterDefault, FilteredResponseQueryOptions, FirstDocumentIdMutationOptions, FirstDocumentMutationOptions, FitMode, type GenerateInstruction, type GenerateOperation, type GenerateTarget, type GenerateTargetDocument, type GenerateTargetInclude, type GroqAgentActionParam, type HttpError, HttpRequest, IdentifiedSanityDocumentStub, type ImageDescriptionOperation, ImportReleaseAction, InitializedClientConfig, type InitializedStegaConfig, InsertPatch, ListenEvent, ListenEventName, ListenOptions, ListenParams, type LiveClient, LiveEvent, LiveEventGoAway, LiveEventMessage, LiveEventReconnect, LiveEventRestart, LiveEventWelcome, type Logger, MediaLibraryAssetInstanceIdentifier, MediaLibraryPlaybackInfoOptions, type MediaLibraryVideoClient, MediaLibraryVideoPlaybackTransformations, MessageError, MessageParseError, MultipleActionResult, MultipleMutationResult, Mutation, MutationError, MutationErrorItem, MutationEvent, MutationOperation, MutationSelection, MutationSelectionQueryParams, type ObservableAssetsClient, type ObservableDatasetsClient, type ObservableMediaLibraryVideoClient, ObservablePatch, ObservablePatchBuilder, type ObservableProjectsClient, ObservableSanityClient, ObservableTransaction, type ObservableUsersClient, OpenEvent, PartialExcept, Patch, PatchBuilder, type PatchDocument, PatchMutationOperation, type PatchOperation, PatchOperations, PatchSelection, type PatchTarget, type ProjectsClient, type PromptRequest, PublishAction, PublishReleaseAction, QueryOptions, QueryParams, QueryParseError, QueryWithoutParams, RawQueryResponse, RawQuerylessQueryResponse, RawRequestOptions, ReconnectEvent, ReleaseAction, ReleaseCardinality, ReleaseDocument, ReleaseId, ReleaseState, ReleaseType, ReplaceDraftAction, ReplaceVersionAction, RequestObservableOptions, RequestOptions, RequestUrlOptions, Requester, ResetEvent, type ResolveStudioUrl, ResponseQueryOptions, ResumableListenEventNames, ResumableListenOptions, SanityAssetDocument, SanityClient, SanityDocument, SanityDocumentStub, SanityImageAssetDocument, SanityImagePalette, SanityProject, SanityProjectMember, SanityQueries, SanityReference, SanityUser, ScheduleReleaseAction, ServerError, type ServerSentEvent, SingleActionResult, SingleMutationResult, StackablePerspective, type StegaConfig, type StegaConfigRequiredKeys, StillImageFormat, StoryboardTransformOptions, type StudioBaseRoute, type StudioBaseUrl, type StudioUrl, SyncTag, ThumbnailTransformOptions, Transaction, TransactionAllDocumentIdsMutationOptions, TransactionAllDocumentsMutationOptions, TransactionFirstDocumentIdMutationOptions, TransactionFirstDocumentMutationOptions, TransactionMutationOptions, type TransformDocument, type TransformOperation, type TransformTarget, type TransformTargetDocument, type TransformTargetInclude, type TranslateDocument, type TranslateTarget, type TranslateTargetInclude, UnarchiveReleaseAction, UnfilteredResponseQueryOptions, UnfilteredResponseWithoutQuery, UnpublishAction, UnpublishVersionAction, UnscheduleReleaseAction, UploadBody, UploadClientConfig, UploadEvent, UploadProgressEvent, UploadResponseEvent, type UsersClient, VersionAction, VideoPlaybackInfo, VideoPlaybackInfoItem, VideoPlaybackInfoItemPublic, VideoPlaybackInfoItemSigned, VideoPlaybackInfoPublic, VideoPlaybackInfoSigned, VideoPlaybackTokens, VideoRenditionInfo, VideoRenditionInfoPublic, VideoRenditionInfoSigned, VideoSubtitleInfo, VideoSubtitleInfoPublic, VideoSubtitleInfoSigned, WelcomeBackEvent, WelcomeEvent, type _listen, connectEventSource, createClient, deprecatedCreateClient as default, formatQueryParseError, isHttpError, isQueryParseError, requester, validateApiPerspective };
|
|
6001
|
+
export { Action, ActionError, ActionErrorItem, type AgentActionParam, type AgentActionParams, type AgentActionPath, type AgentActionPathSegment, type AgentActionTarget, AllDocumentIdsMutationOptions, AllDocumentsMutationOptions, AnimatedImageFormat, AnimatedTransformOptions, Any, ApiError, ArchiveReleaseAction, AssetMetadataType, type AssetsClient, AttributeSet, AuthProvider, AuthProviderResponse, BaseActionOptions, BaseMutationOptions, BasePatch, BaseTransaction, ChannelError, ChannelErrorEvent, ClientConfig, ClientError, ClientPerspective, ClientReturn, ClientVariant, ClientVariantConditions, ConnectionFailedError, type ConstantAgentActionParam, ContentSourceMap, ContentSourceMapDocument, ContentSourceMapDocumentBase, ContentSourceMapDocumentValueSource, ContentSourceMapDocuments, ContentSourceMapLiteralSource, ContentSourceMapMapping, ContentSourceMapMappings, type ContentSourceMapParsedPath, type ContentSourceMapParsedPathKeyedSegment, ContentSourceMapPaths, ContentSourceMapRemoteDocument, ContentSourceMapSource, ContentSourceMapUnknownSource, ContentSourceMapValueMapping, CorsOriginError, CreateAction, CreateReleaseAction, CreateVariantDefinitionAction, CreateVersionAction, CurrentSanityUser, DatasetAclMode, DatasetCreateOptions, DatasetEditOptions, DatasetResponse, type DatasetsClient, DatasetsResponse, DeleteAction, DeleteReleaseAction, DeleteVariantDefinitionAction, DiscardAction, DiscardVersionAction, DisconnectError, DisconnectEvent, type DocumentAgentActionParam, EXPERIMENTAL_API_WARNING, EditAction, EditReleaseAction, EditVariantDefinitionAction, EditableReleaseDocument, EmbeddingsSettings, EmbeddingsSettingsBody, ErrorProps, type EventSourceEvent, type EventSourceInstance, type FieldAgentActionParam, type FilterDefault, FilteredResponseQueryOptions, FirstDocumentIdMutationOptions, FirstDocumentMutationOptions, FitMode, type GenerateInstruction, type GenerateOperation, type GenerateTarget, type GenerateTargetDocument, type GenerateTargetInclude, type GroqAgentActionParam, type HttpError, HttpRequest, IdentifiedSanityDocumentStub, type ImageDescriptionOperation, ImportReleaseAction, InitializedClientConfig, type InitializedStegaConfig, InsertPatch, type InvokeFunctionEvent, type InvokeFunctionRequest, ListenEvent, ListenEventName, ListenOptions, ListenParams, type LiveClient, LiveEvent, LiveEventGoAway, LiveEventMessage, LiveEventReconnect, LiveEventRestart, LiveEventWelcome, type Logger, MediaLibraryAssetDocument, MediaLibraryAssetInstanceIdentifier, MediaLibraryAssetVersion, MediaLibraryPlaybackInfoOptions, type MediaLibraryVideoClient, MediaLibraryVideoPlaybackTransformations, MessageError, MessageParseError, MultipleActionResult, MultipleMutationResult, Mutation, MutationError, MutationErrorItem, MutationEvent, MutationOperation, MutationSelection, MutationSelectionQueryParams, type ObservableAssetsClient, type ObservableDatasetsClient, type ObservableMediaLibraryVideoClient, ObservablePatch, ObservablePatchBuilder, type ObservableProjectsClient, ObservableSanityClient, ObservableTransaction, type ObservableUsersClient, OpenEvent, PartialExcept, Patch, PatchBuilder, type PatchDocument, PatchMutationOperation, type PatchOperation, PatchOperations, PatchSelection, type PatchTarget, type ProjectsClient, type PromptRequest, PublishAction, PublishReleaseAction, QueryOptions, QueryParams, QueryParseError, QueryWithoutParams, RawQueryResponse, RawQuerylessQueryResponse, RawRequestOptions, ReconnectEvent, ReleaseAction, ReleaseCardinality, ReleaseDocument, ReleaseId, ReleaseState, ReleaseType, ReplaceDraftAction, ReplaceVersionAction, RequestHandler, RequestHandlerOptions, RequestObservableOptions, RequestOptions, RequestUrlOptions, Requester, ResetEvent, type ResolveStudioUrl, ResponseQueryOptions, ResumableListenEventNames, ResumableListenOptions, SanityAssetDocument, SanityClient, SanityDocument, SanityDocumentStub, SanityImageAssetDocument, SanityImagePalette, SanityProject, SanityProjectMember, SanityQueries, SanityReference, SanityUser, ScheduleReleaseAction, ServerError, type ServerSentEvent, SingleActionResult, SingleMutationResult, StackablePerspective, type StegaConfig, type StegaConfigRequiredKeys, StillImageFormat, StoryboardTransformOptions, type StudioBaseRoute, type StudioBaseUrl, type StudioUrl, SyncTag, ThumbnailTransformOptions, type TimeoutErrorLike, Transaction, TransactionAllDocumentIdsMutationOptions, TransactionAllDocumentsMutationOptions, TransactionFirstDocumentIdMutationOptions, TransactionFirstDocumentMutationOptions, TransactionMutationOptions, type TransformDocument, type TransformOperation, type TransformTarget, type TransformTargetDocument, type TransformTargetInclude, type TranslateDocument, type TranslateTarget, type TranslateTargetInclude, UnarchiveReleaseAction, UnfilteredResponseQueryOptions, UnfilteredResponseWithoutQuery, UnpublishAction, UnpublishVersionAction, UnscheduleReleaseAction, UploadBody, UploadClientConfig, UploadEvent, UploadProgressEvent, UploadResponseEvent, type UsersClient, VariantDefinitionAction, VersionAction, VideoPlaybackInfo, VideoPlaybackInfoItem, VideoPlaybackInfoItemPublic, VideoPlaybackInfoItemSigned, VideoPlaybackInfoPublic, VideoPlaybackInfoSigned, VideoPlaybackTokens, VideoRenditionInfo, VideoRenditionInfoPublic, VideoRenditionInfoSigned, VideoSubtitleInfo, VideoSubtitleInfoPublic, VideoSubtitleInfoSigned, WelcomeBackEvent, WelcomeEvent, type _listen, connectEventSource, createClient, deprecatedCreateClient as default, formatQueryParseError, isHttpError, isQueryParseError, isTimeoutError, requester, validateApiPerspective };
|
|
5758
6002
|
//# sourceMappingURL=index.node.d.ts.map
|