@sanity/client 8.2.0 → 8.3.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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -40
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +91 -15
- package/dist/index.node.js +31 -41
- package/dist/index.node.js.map +1 -1
- package/dist/media-library.d.ts +1 -1
- package/dist/{types-nJhm5Nyq.d.ts → types-0x2hPfhJ.d.ts} +92 -16
- package/package.json +1 -2
- package/src/collaboration/types.ts +59 -8
- package/src/functions/FunctionsClient.ts +52 -9
- package/src/functions/invoke.ts +47 -6
- package/src/types.ts +6 -1
- package/src/util/createVersionId.ts +15 -5
package/dist/index.node.d.ts
CHANGED
|
@@ -1369,6 +1369,17 @@ interface CollaborationCommentRange {
|
|
|
1369
1369
|
offset: number;
|
|
1370
1370
|
};
|
|
1371
1371
|
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Portable Text covering a comment `range`. Callers can send just the blocks
|
|
1374
|
+
* from the `range` start `_key` through end `_key`, or the full field.
|
|
1375
|
+
*
|
|
1376
|
+
* @alpha
|
|
1377
|
+
*/
|
|
1378
|
+
type CollaborationCommentFieldValue = Array<{
|
|
1379
|
+
_type: string;
|
|
1380
|
+
_key: string;
|
|
1381
|
+
[key: string]: Any;
|
|
1382
|
+
}>;
|
|
1372
1383
|
/**
|
|
1373
1384
|
* Target for a top-level comment. Inline selections require both `path` and
|
|
1374
1385
|
* `range`; field-level comments may set `path` alone.
|
|
@@ -1377,6 +1388,9 @@ interface CollaborationCommentRange {
|
|
|
1377
1388
|
* `target.path.field`, and `range` is resolved against the document into
|
|
1378
1389
|
* `target.path.selection` and `contentSnapshot` rather than being stored.
|
|
1379
1390
|
*
|
|
1391
|
+
* An optional `fieldValue` is Portable Text covering the `range`. When set,
|
|
1392
|
+
* the `range` is resolved from those blocks instead of from the live document.
|
|
1393
|
+
*
|
|
1380
1394
|
* @alpha
|
|
1381
1395
|
*/
|
|
1382
1396
|
type CollaborationCommentTarget = {
|
|
@@ -1387,10 +1401,16 @@ type CollaborationCommentTarget = {
|
|
|
1387
1401
|
/** Path to the field containing the inline comment selection */
|
|
1388
1402
|
path: string;
|
|
1389
1403
|
range: CollaborationCommentRange;
|
|
1404
|
+
/**
|
|
1405
|
+
* Portable Text covering the `range`. When set, the `range` is resolved
|
|
1406
|
+
* from these blocks instead of from the live document.
|
|
1407
|
+
*/
|
|
1408
|
+
fieldValue?: CollaborationCommentFieldValue;
|
|
1390
1409
|
} | {
|
|
1391
1410
|
/** Path to the commented field */
|
|
1392
1411
|
path?: string;
|
|
1393
1412
|
range?: never;
|
|
1413
|
+
fieldValue?: never;
|
|
1394
1414
|
});
|
|
1395
1415
|
/**
|
|
1396
1416
|
* Comment to create with `collaboration.comments.create`.
|
|
@@ -1409,6 +1429,19 @@ type CollaborationCommentTarget = {
|
|
|
1409
1429
|
* })
|
|
1410
1430
|
* ```
|
|
1411
1431
|
*
|
|
1432
|
+
* #### Inline comment
|
|
1433
|
+
* ```ts
|
|
1434
|
+
* await client.collaboration.comments.create({
|
|
1435
|
+
* message,
|
|
1436
|
+
* target: {
|
|
1437
|
+
* documentId: 'doc-1',
|
|
1438
|
+
* documentType: 'article',
|
|
1439
|
+
* path: 'body',
|
|
1440
|
+
* range: {start: {_key: 'block-1', offset: 0}, end: {_key: 'block-1', offset: 5}},
|
|
1441
|
+
* },
|
|
1442
|
+
* })
|
|
1443
|
+
* ```
|
|
1444
|
+
*
|
|
1412
1445
|
* #### Reply
|
|
1413
1446
|
* ```ts
|
|
1414
1447
|
* await client.collaboration.comments.create({
|
|
@@ -1436,20 +1469,33 @@ type CollaborationCommentCreate = {
|
|
|
1436
1469
|
/**
|
|
1437
1470
|
* Fields that can be updated on an existing comment.
|
|
1438
1471
|
*
|
|
1472
|
+
* A `range` re-anchors the comment within the field it already targets.
|
|
1473
|
+
* Pass `null` to remove the selection and leave a field-level comment.
|
|
1474
|
+
* An optional `fieldValue` is Portable Text covering that `range`; when set,
|
|
1475
|
+
* the `range` is resolved from those blocks instead of from the live document.
|
|
1476
|
+
* `fieldValue` cannot be sent alone or together with `range: null`.
|
|
1477
|
+
*
|
|
1439
1478
|
* @alpha
|
|
1440
1479
|
*/
|
|
1441
|
-
|
|
1480
|
+
type CollaborationCommentUpdate = {
|
|
1442
1481
|
/** Replaces the current message */
|
|
1443
1482
|
message?: CollaborationCommentMessage;
|
|
1444
1483
|
/** Cascades to the comment's replies */
|
|
1445
1484
|
status?: CollaborationCommentStatus;
|
|
1485
|
+
} & ({
|
|
1486
|
+
range: CollaborationCommentRange;
|
|
1446
1487
|
/**
|
|
1447
|
-
*
|
|
1448
|
-
*
|
|
1449
|
-
* comment.
|
|
1488
|
+
* Portable Text covering the `range`. When set, the `range` is resolved
|
|
1489
|
+
* from these blocks instead of from the live document.
|
|
1450
1490
|
*/
|
|
1451
|
-
|
|
1452
|
-
}
|
|
1491
|
+
fieldValue?: CollaborationCommentFieldValue;
|
|
1492
|
+
} | {
|
|
1493
|
+
range: null;
|
|
1494
|
+
fieldValue?: never;
|
|
1495
|
+
} | {
|
|
1496
|
+
range?: undefined;
|
|
1497
|
+
fieldValue?: never;
|
|
1498
|
+
});
|
|
1453
1499
|
/**
|
|
1454
1500
|
* Comments on the configured organization resource.
|
|
1455
1501
|
*
|
|
@@ -2175,6 +2221,17 @@ interface InvokeFunctionRequest {
|
|
|
2175
2221
|
signal?: AbortSignal;
|
|
2176
2222
|
}
|
|
2177
2223
|
/** @public */
|
|
2224
|
+
interface InvokeFunctionOptions {
|
|
2225
|
+
/**
|
|
2226
|
+
* Wait for the function to finish and resolve with its return value.
|
|
2227
|
+
*
|
|
2228
|
+
* Defaults to `false`: the invocation is started, the request resolves as soon
|
|
2229
|
+
* as it is accepted, and the value is always `undefined`. Only function types
|
|
2230
|
+
* that support running inline can be invoked synchronously.
|
|
2231
|
+
*/
|
|
2232
|
+
sync?: boolean;
|
|
2233
|
+
}
|
|
2234
|
+
/** @public */
|
|
2178
2235
|
declare class ObservableFunctionsClient {
|
|
2179
2236
|
#private;
|
|
2180
2237
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest);
|
|
@@ -2182,12 +2239,21 @@ declare class ObservableFunctionsClient {
|
|
|
2182
2239
|
* Invoke a deployed function by its blueprint name.
|
|
2183
2240
|
*
|
|
2184
2241
|
* The name is resolved within the stack given by `stackId` on the request or
|
|
2185
|
-
* the client config.
|
|
2242
|
+
* the client config. Starts the invocation and emits `undefined` as soon as
|
|
2243
|
+
* it is accepted; pass `{sync: true}` to wait for the function's return value
|
|
2244
|
+
* instead.
|
|
2186
2245
|
*
|
|
2187
2246
|
* @param functionName - name of the function, as declared in the blueprint
|
|
2188
2247
|
* @param request - payload and request options
|
|
2248
|
+
* @param options - invocation options
|
|
2189
2249
|
*/
|
|
2190
|
-
invoke
|
|
2250
|
+
invoke(functionName: string, request?: InvokeFunctionRequest, options?: InvokeFunctionOptions & {
|
|
2251
|
+
sync?: false;
|
|
2252
|
+
}): Observable<undefined>;
|
|
2253
|
+
invoke<R = unknown>(functionName: string, request: InvokeFunctionRequest | undefined, options: InvokeFunctionOptions & {
|
|
2254
|
+
sync: true;
|
|
2255
|
+
}): Observable<R>;
|
|
2256
|
+
invoke<R = unknown>(functionName: string, request?: InvokeFunctionRequest, options?: InvokeFunctionOptions): Observable<R | undefined>;
|
|
2191
2257
|
}
|
|
2192
2258
|
/** @public */
|
|
2193
2259
|
declare class FunctionsClient {
|
|
@@ -2198,20 +2264,30 @@ declare class FunctionsClient {
|
|
|
2198
2264
|
*
|
|
2199
2265
|
* The name is resolved within the stack given by `stackId` on the request or
|
|
2200
2266
|
* the client config, which costs one extra request per call. Rejects if the
|
|
2201
|
-
* stack has no function by that name, or if the name resolves to
|
|
2202
|
-
*
|
|
2267
|
+
* stack has no function by that name, or if the name resolves to a function
|
|
2268
|
+
* type that cannot be invoked the way it was asked for.
|
|
2203
2269
|
*
|
|
2204
2270
|
* The lookup is scoped to `projectId`, or to `organizationId` when one is set
|
|
2205
2271
|
* for a stack deployed at organization scope.
|
|
2206
2272
|
*
|
|
2207
|
-
* The
|
|
2208
|
-
*
|
|
2209
|
-
*
|
|
2273
|
+
* The invocation is started by default: the promise resolves with `undefined`
|
|
2274
|
+
* as soon as the call is accepted, without waiting for the function to run.
|
|
2275
|
+
* Pass `{sync: true}` to keep the request open until the function finishes
|
|
2276
|
+
* and resolve with its return value — long-running functions may then need an
|
|
2277
|
+
* explicit `timeout`. Only `sanity.function.pubsub` functions can be invoked
|
|
2278
|
+
* synchronously.
|
|
2210
2279
|
*
|
|
2211
2280
|
* @param functionName - name of the function, as declared in the blueprint
|
|
2212
2281
|
* @param request - payload and request options
|
|
2282
|
+
* @param options - invocation options
|
|
2213
2283
|
*/
|
|
2214
|
-
invoke
|
|
2284
|
+
invoke(functionName: string, request?: InvokeFunctionRequest, options?: InvokeFunctionOptions & {
|
|
2285
|
+
sync?: false;
|
|
2286
|
+
}): Promise<undefined>;
|
|
2287
|
+
invoke<R = unknown>(functionName: string, request: InvokeFunctionRequest | undefined, options: InvokeFunctionOptions & {
|
|
2288
|
+
sync: true;
|
|
2289
|
+
}): Promise<R>;
|
|
2290
|
+
invoke<R = unknown>(functionName: string, request?: InvokeFunctionRequest, options?: InvokeFunctionOptions): Promise<R | undefined>;
|
|
2215
2291
|
}
|
|
2216
2292
|
/** @internal */
|
|
2217
2293
|
declare class ObservableMediaLibraryVideoClient {
|
|
@@ -6646,5 +6722,5 @@ declare const createClient: (config: ClientConfig) => SanityClient;
|
|
|
6646
6722
|
* @deprecated Use the named export `createClient` instead of the `default` export
|
|
6647
6723
|
*/
|
|
6648
6724
|
declare const deprecatedCreateClient: (config: ClientConfig) => SanityClient;
|
|
6649
|
-
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, type CollaborationCommentCreate, type CollaborationCommentDocument, type CollaborationCommentMessage, type CollaborationCommentPortableTextBlock, type CollaborationCommentRange, type CollaborationCommentReactionShortName, type CollaborationCommentSelection, type CollaborationCommentStatus, type CollaborationCommentTarget, type CollaborationCommentUpdate, type CollaborationCommentsClient, type CollaborationCommentsListenOptions, type CollaborationCommentsRequestOptions, type CollaborationCommentsWriteOptions, ConnectionFailedError, type ConstantAgentActionParam, ContentSourceMap, ContentSourceMapDocument, ContentSourceMapDocumentBase, ContentSourceMapDocumentValueSource, ContentSourceMapDocuments, ContentSourceMapLiteralSource, ContentSourceMapMapping, ContentSourceMapMappings, type ContentSourceMapParsedPath, type ContentSourceMapParsedPathKeyedSegment, ContentSourceMapPaths, ContentSourceMapRemoteDocument, ContentSourceMapSource, ContentSourceMapUnknownSource, ContentSourceMapValueMapping, CorsOriginError, CreateAction, CreateReleaseAction, CreateVariantAction, CreateVariantDefinitionAction, CreateVersionAction, CurrentSanityUser, DatasetAclMode, DatasetCreateOptions, DatasetEditOptions, DatasetResponse, type DatasetsClient, DatasetsResponse, DeleteAction, DeleteReleaseAction, DeleteVariantAction, DeleteVariantDefinitionAction, DiscardAction, DiscardVersionAction, DisconnectError, DisconnectEvent, type DocumentAgentActionParam, EXPERIMENTAL_API_WARNING, EditAction, EditReleaseAction, EditVariantAction, 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 ObservableCollaborationCommentsClient, 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, PublishVariantAction, 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, UnpublishVariantAction, UnpublishVersionAction, UnscheduleReleaseAction, UploadBody, UploadClientConfig, UploadEvent, UploadProgressEvent, UploadResponseEvent, type UsersClient, VariantAction, 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 };
|
|
6725
|
+
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, type CollaborationCommentCreate, type CollaborationCommentDocument, type CollaborationCommentFieldValue, type CollaborationCommentMessage, type CollaborationCommentPortableTextBlock, type CollaborationCommentRange, type CollaborationCommentReactionShortName, type CollaborationCommentSelection, type CollaborationCommentStatus, type CollaborationCommentTarget, type CollaborationCommentUpdate, type CollaborationCommentsClient, type CollaborationCommentsListenOptions, type CollaborationCommentsRequestOptions, type CollaborationCommentsWriteOptions, ConnectionFailedError, type ConstantAgentActionParam, ContentSourceMap, ContentSourceMapDocument, ContentSourceMapDocumentBase, ContentSourceMapDocumentValueSource, ContentSourceMapDocuments, ContentSourceMapLiteralSource, ContentSourceMapMapping, ContentSourceMapMappings, type ContentSourceMapParsedPath, type ContentSourceMapParsedPathKeyedSegment, ContentSourceMapPaths, ContentSourceMapRemoteDocument, ContentSourceMapSource, ContentSourceMapUnknownSource, ContentSourceMapValueMapping, CorsOriginError, CreateAction, CreateReleaseAction, CreateVariantAction, CreateVariantDefinitionAction, CreateVersionAction, CurrentSanityUser, DatasetAclMode, DatasetCreateOptions, DatasetEditOptions, DatasetResponse, type DatasetsClient, DatasetsResponse, DeleteAction, DeleteReleaseAction, DeleteVariantAction, DeleteVariantDefinitionAction, DiscardAction, DiscardVersionAction, DisconnectError, DisconnectEvent, type DocumentAgentActionParam, EXPERIMENTAL_API_WARNING, EditAction, EditReleaseAction, EditVariantAction, 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 InvokeFunctionOptions, 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 ObservableCollaborationCommentsClient, 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, PublishVariantAction, 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, UnpublishVariantAction, UnpublishVersionAction, UnscheduleReleaseAction, UploadBody, UploadClientConfig, UploadEvent, UploadProgressEvent, UploadResponseEvent, type UsersClient, VariantAction, 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 };
|
|
6650
6726
|
//# sourceMappingURL=index.node.d.ts.map
|
package/dist/index.node.js
CHANGED
|
@@ -7,7 +7,6 @@ import { Observable, catchError, concat, defer, finalize, isObservable, lastValu
|
|
|
7
7
|
import { getDraftId, getPublishedId, getVersionFromId, getVersionId, isDraftId, isVersionId } from "@sanity/client/csm";
|
|
8
8
|
import { filter, finalize as finalize$1, map as map$1, mergeAll } from "rxjs/operators";
|
|
9
9
|
import { EventSource } from "eventsource";
|
|
10
|
-
import { customAlphabet } from "nanoid";
|
|
11
10
|
import { Readable } from "node:stream";
|
|
12
11
|
import { createNodeFetch } from "get-it/node";
|
|
13
12
|
import { createDebug } from "obug";
|
|
@@ -2293,7 +2292,11 @@ function _modify(client, httpRequest, method, name, options) {
|
|
|
2293
2292
|
});
|
|
2294
2293
|
}
|
|
2295
2294
|
/** Function resource types in a blueprint are namespaced under this prefix. */
|
|
2296
|
-
const
|
|
2295
|
+
const SYNC_INVOCABLE_FUNCTION_TYPES = ["sanity.function.pubsub"], ASYNC_INVOCABLE_FUNCTION_TYPES = [
|
|
2296
|
+
"sanity.function.durable",
|
|
2297
|
+
"sanity.function.pubsub",
|
|
2298
|
+
"sanity.function.queue"
|
|
2299
|
+
], INVOCABLE_FUNCTION_TYPES = [.../* @__PURE__ */ new Set([...SYNC_INVOCABLE_FUNCTION_TYPES, ...ASYNC_INVOCABLE_FUNCTION_TYPES])], scopeHeaders = (config, request) => {
|
|
2297
2300
|
let organizationId = request?.organizationId || config.organizationId;
|
|
2298
2301
|
if (organizationId) return {
|
|
2299
2302
|
"X-Sanity-Scope-Type": "organization",
|
|
@@ -2317,7 +2320,7 @@ const scopeHeaders = (config, request) => {
|
|
|
2317
2320
|
*
|
|
2318
2321
|
* @internal
|
|
2319
2322
|
*/
|
|
2320
|
-
function _resolveFunctionId(client, httpRequest, functionName, stackId, headers, request) {
|
|
2323
|
+
function _resolveFunctionId(client, httpRequest, functionName, stackId, headers, request, sync) {
|
|
2321
2324
|
return _requestObservable(client, httpRequest, {
|
|
2322
2325
|
method: "GET",
|
|
2323
2326
|
url: `/blueprints/stacks/${stackId}`,
|
|
@@ -2327,17 +2330,19 @@ function _resolveFunctionId(client, httpRequest, functionName, stackId, headers,
|
|
|
2327
2330
|
let match = (stack?.resources || []).find((resource) => resource.type?.startsWith("sanity.function.") && resource.name === functionName);
|
|
2328
2331
|
if (!match) throw Error(`Function "${functionName}" not found in stack "${stackId}"`);
|
|
2329
2332
|
if (!match.externalId) throw Error(`Function "${functionName}" is declared in stack "${stackId}" but is not deployed`);
|
|
2330
|
-
if (match.type
|
|
2333
|
+
if (!INVOCABLE_FUNCTION_TYPES.includes(match.type)) throw Error(`Function invocation is not supported for ${match.type}`);
|
|
2334
|
+
if (sync && !SYNC_INVOCABLE_FUNCTION_TYPES.includes(match.type)) throw Error(`Synchronous function invocation is not supported for ${match.type}`);
|
|
2335
|
+
if (!sync && !ASYNC_INVOCABLE_FUNCTION_TYPES.includes(match.type)) throw Error(`Asynchronous function invocation is not supported for ${match.type}`);
|
|
2331
2336
|
return match.externalId;
|
|
2332
2337
|
}));
|
|
2333
2338
|
}
|
|
2334
2339
|
/** @internal */
|
|
2335
|
-
function _invoke(client, httpRequest, functionName, request) {
|
|
2340
|
+
function _invoke(client, httpRequest, functionName, request, options) {
|
|
2336
2341
|
return defer(() => {
|
|
2337
|
-
let config = client.config(), headers = scopeHeaders(config, request);
|
|
2338
|
-
return _resolveFunctionId(client, httpRequest, functionName,
|
|
2342
|
+
let config = client.config(), headers = scopeHeaders(config, request), stackId = resolveStackId(config, request), sync = options?.sync ?? !1;
|
|
2343
|
+
return _resolveFunctionId(client, httpRequest, functionName, stackId, headers, request, sync).pipe(mergeMap((functionId) => _requestObservable(client, httpRequest, {
|
|
2339
2344
|
method: "POST",
|
|
2340
|
-
url: `/functions/${functionId}/invoke`,
|
|
2345
|
+
url: `/functions/${functionId}/invoke${sync ? "?sync=true" : ""}`,
|
|
2341
2346
|
headers,
|
|
2342
2347
|
body: { event: { data: request?.event?.data ?? {} } },
|
|
2343
2348
|
timeout: request?.timeout,
|
|
@@ -2352,17 +2357,8 @@ var ObservableFunctionsClient = class {
|
|
|
2352
2357
|
constructor(client, httpRequest) {
|
|
2353
2358
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
2354
2359
|
}
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
*
|
|
2358
|
-
* The name is resolved within the stack given by `stackId` on the request or
|
|
2359
|
-
* the client config. Passes the function's return value once it finishes.
|
|
2360
|
-
*
|
|
2361
|
-
* @param functionName - name of the function, as declared in the blueprint
|
|
2362
|
-
* @param request - payload and request options
|
|
2363
|
-
*/
|
|
2364
|
-
invoke(functionName, request) {
|
|
2365
|
-
return _invoke(this.#client, this.#httpRequest, functionName, request);
|
|
2360
|
+
invoke(functionName, request, options) {
|
|
2361
|
+
return _invoke(this.#client, this.#httpRequest, functionName, request, options);
|
|
2366
2362
|
}
|
|
2367
2363
|
}, FunctionsClient = class {
|
|
2368
2364
|
#client;
|
|
@@ -2370,26 +2366,8 @@ var ObservableFunctionsClient = class {
|
|
|
2370
2366
|
constructor(client, httpRequest) {
|
|
2371
2367
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
2372
2368
|
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
*
|
|
2376
|
-
* The name is resolved within the stack given by `stackId` on the request or
|
|
2377
|
-
* the client config, which costs one extra request per call. Rejects if the
|
|
2378
|
-
* stack has no function by that name, or if the name resolves to anything
|
|
2379
|
-
* other than a `sanity.function.pubsub` function.
|
|
2380
|
-
*
|
|
2381
|
-
* The lookup is scoped to `projectId`, or to `organizationId` when one is set
|
|
2382
|
-
* for a stack deployed at organization scope.
|
|
2383
|
-
*
|
|
2384
|
-
* The request stays open until the function finishes, and resolves with its
|
|
2385
|
-
* return value, or `undefined` if it returns nothing. Long-running functions
|
|
2386
|
-
* may need an explicit `timeout`.
|
|
2387
|
-
*
|
|
2388
|
-
* @param functionName - name of the function, as declared in the blueprint
|
|
2389
|
-
* @param request - payload and request options
|
|
2390
|
-
*/
|
|
2391
|
-
invoke(functionName, request) {
|
|
2392
|
-
return lastValueFrom(_invoke(this.#client, this.#httpRequest, functionName, request));
|
|
2369
|
+
invoke(functionName, request, options) {
|
|
2370
|
+
return lastValueFrom(_invoke(this.#client, this.#httpRequest, functionName, request, options));
|
|
2393
2371
|
}
|
|
2394
2372
|
}, ObservableMediaLibraryVideoClient = class {
|
|
2395
2373
|
#client;
|
|
@@ -2537,7 +2515,19 @@ var ObservableProjectsClient = class {
|
|
|
2537
2515
|
*
|
|
2538
2516
|
* ~24 years (or 7.54e+8 seconds) needed, in order to have a 1% probability of at least one collision if 10 ID's are generated every hour.
|
|
2539
2517
|
*/
|
|
2540
|
-
|
|
2518
|
+
function generateReleaseId() {
|
|
2519
|
+
let id = "";
|
|
2520
|
+
for (; id.length < 8;) {
|
|
2521
|
+
let bytes = crypto.getRandomValues(new Uint8Array(8 - id.length));
|
|
2522
|
+
for (let byte of bytes) {
|
|
2523
|
+
let index = byte & 63;
|
|
2524
|
+
index < 62 && (id += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[index]);
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
return id;
|
|
2528
|
+
}
|
|
2529
|
+
/** @internal */
|
|
2530
|
+
const getDocumentVersionId = (publishedId, releaseId) => releaseId ? getVersionId(publishedId, releaseId) : getDraftId(publishedId);
|
|
2541
2531
|
/** @internal */
|
|
2542
2532
|
function deriveDocumentVersionId(op, { releaseId, publishedId, document }) {
|
|
2543
2533
|
if (publishedId && document._id) {
|
|
@@ -3562,7 +3552,7 @@ function defineDeprecatedCreateClient(createClient) {
|
|
|
3562
3552
|
return printNoDefaultExport(), createClient(config);
|
|
3563
3553
|
};
|
|
3564
3554
|
}
|
|
3565
|
-
var name = "@sanity/client", version = "8.
|
|
3555
|
+
var name = "@sanity/client", version = "8.3.0";
|
|
3566
3556
|
const log = createDebug("sanity:client");
|
|
3567
3557
|
function isNodeReadableStream(value) {
|
|
3568
3558
|
return typeof value != "object" || !value || !("pipe" in value) ? !1 : typeof value.pipe == "function";
|