@sanity/client 7.26.1 → 7.26.2

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.
Files changed (43) hide show
  1. package/dist/_chunks-cjs/resolveEditInfo.cjs +4 -4
  2. package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
  3. package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +3 -3
  4. package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
  5. package/dist/_chunks-es/resolveEditInfo.js +4 -4
  6. package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
  7. package/dist/_chunks-es/stegaEncodeSourceMap.js +3 -3
  8. package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
  9. package/dist/csm.cjs.map +1 -1
  10. package/dist/csm.d.cts +5 -17
  11. package/dist/csm.d.ts +5 -17
  12. package/dist/csm.js.map +1 -1
  13. package/dist/index.browser.cjs +1 -1
  14. package/dist/index.browser.cjs.map +1 -1
  15. package/dist/index.browser.d.cts +23 -62
  16. package/dist/index.browser.d.ts +23 -62
  17. package/dist/index.browser.js +1 -1
  18. package/dist/index.browser.js.map +1 -1
  19. package/dist/index.cjs +3 -4
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +22 -57
  22. package/dist/index.d.ts +22 -57
  23. package/dist/index.js +3 -4
  24. package/dist/index.js.map +1 -1
  25. package/dist/stega.browser.d.cts +26 -68
  26. package/dist/stega.browser.d.ts +26 -68
  27. package/dist/stega.d.cts +26 -68
  28. package/dist/stega.d.ts +26 -68
  29. package/package.json +31 -31
  30. package/src/agent/actions/commonTypes.ts +1 -2
  31. package/src/agent/actions/generate.ts +3 -6
  32. package/src/agent/actions/patch.ts +3 -6
  33. package/src/agent/actions/prompt.ts +1 -2
  34. package/src/agent/actions/transform.ts +1 -2
  35. package/src/agent/actions/translate.ts +1 -2
  36. package/src/csm/applySourceDocuments.ts +1 -3
  37. package/src/csm/types.ts +1 -3
  38. package/src/data/listen.ts +1 -2
  39. package/src/releases/ReleasesClient.ts +2 -4
  40. package/src/stega/types.ts +1 -2
  41. package/src/types.ts +9 -38
  42. package/umd/sanityClient.js +21 -14
  43. package/umd/sanityClient.min.js +2 -2
@@ -24,9 +24,7 @@ export function applySourceDocuments<Result = unknown>(
24
24
  getCachedDocument: (
25
25
  sourceDocument: ContentSourceMapDocuments[number],
26
26
  ) =>
27
- | (Partial<SanityDocument> & Required<Pick<SanityDocument, '_id' | '_type'>>)
28
- | null
29
- | undefined,
27
+ (Partial<SanityDocument> & Required<Pick<SanityDocument, '_id' | '_type'>>) | null | undefined,
30
28
  updateFn: ApplySourceDocumentsUpdateFunction,
31
29
  perspective: Exclude<ClientPerspective, 'raw'>,
32
30
  ): Result {
package/src/csm/types.ts CHANGED
@@ -33,9 +33,7 @@ export type ContentSourceMapParsedPathKeyedSegment = {_key: string; _index: numb
33
33
 
34
34
  /** @alpha */
35
35
  export type ContentSourceMapParsedPath = (
36
- | string
37
- | number
38
- | ContentSourceMapParsedPathKeyedSegment
36
+ string | number | ContentSourceMapParsedPathKeyedSegment
39
37
  )[]
40
38
 
41
39
  /** @alpha */
@@ -57,8 +57,7 @@ const defaultOptions = {
57
57
  export type MapListenEventNamesToListenEvents<
58
58
  R extends Record<string, Any> = Record<string, Any>,
59
59
  Events extends (ResumableListenEventNames | ListenEventName)[] = (
60
- | ResumableListenEventNames
61
- | ListenEventName
60
+ ResumableListenEventNames | ListenEventName
62
61
  )[],
63
62
  > = Events extends (infer E)[]
64
63
  ? E extends 'welcome'
@@ -133,8 +133,7 @@ export class ObservableReleasesClient {
133
133
  ): Observable<SingleActionResult & {releaseId: string; metadata: ReleaseDocument['metadata']}>
134
134
  create(
135
135
  releaseOrOptions?:
136
- | {releaseId?: string; metadata?: Partial<ReleaseDocument['metadata']>}
137
- | BaseActionOptions,
136
+ {releaseId?: string; metadata?: Partial<ReleaseDocument['metadata']>} | BaseActionOptions,
138
137
  maybeOptions?: BaseActionOptions,
139
138
  ): Observable<SingleActionResult & {releaseId: string; metadata: ReleaseDocument['metadata']}> {
140
139
  const {action, options} = createRelease(releaseOrOptions, maybeOptions)
@@ -463,8 +462,7 @@ export class ReleasesClient {
463
462
  ): Promise<SingleActionResult & {releaseId: string; metadata: ReleaseDocument['metadata']}>
464
463
  async create(
465
464
  releaseOrOptions?:
466
- | {releaseId?: string; metadata?: Partial<ReleaseDocument['metadata']>}
467
- | BaseActionOptions,
465
+ {releaseId?: string; metadata?: Partial<ReleaseDocument['metadata']>} | BaseActionOptions,
468
466
  maybeOptions?: BaseActionOptions,
469
467
  ): Promise<SingleActionResult & {releaseId: string; metadata: ReleaseDocument['metadata']}> {
470
468
  const {action, options} = createRelease(releaseOrOptions, maybeOptions)
@@ -20,8 +20,7 @@ export type {ContentSourceMap, ResolveStudioUrl}
20
20
 
21
21
  /** @public */
22
22
  export type ContentSourceMapQueryResponse =
23
- | RawQueryResponse<unknown>
24
- | Pick<RawQueryResponse<unknown>, 'result' | 'resultSourceMap'>
23
+ RawQueryResponse<unknown> | Pick<RawQueryResponse<unknown>, 'result' | 'resultSourceMap'>
25
24
 
26
25
  /** @public */
27
26
  export interface StegaConfig {
package/src/types.ts CHANGED
@@ -49,11 +49,7 @@ export type StackablePerspective = ('published' | 'drafts' | string) & {}
49
49
 
50
50
  /** @public */
51
51
  export type ClientPerspective =
52
- | DeprecatedPreviewDrafts
53
- | 'published'
54
- | 'drafts'
55
- | 'raw'
56
- | StackablePerspective[]
52
+ DeprecatedPreviewDrafts | 'published' | 'drafts' | 'raw' | StackablePerspective[]
57
53
 
58
54
  /**
59
55
  * @public
@@ -284,14 +280,7 @@ export interface InitializedClientConfig extends ClientConfig {
284
280
 
285
281
  /** @public */
286
282
  export type AssetMetadataType =
287
- | 'location'
288
- | 'exif'
289
- | 'image'
290
- | 'palette'
291
- | 'lqip'
292
- | 'blurhash'
293
- | 'thumbhash'
294
- | 'none'
283
+ 'location' | 'exif' | 'image' | 'palette' | 'lqip' | 'blurhash' | 'thumbhash' | 'none'
295
284
 
296
285
  /** @public */
297
286
  export interface UploadClientConfig {
@@ -663,9 +652,7 @@ export type IdentifiedSanityDocumentStub<T extends Record<string, Any> = Record<
663
652
 
664
653
  /** @internal */
665
654
  export type InsertPatch =
666
- | {before: string; items: Any[]}
667
- | {after: string; items: Any[]}
668
- | {replace: string; items: Any[]}
655
+ {before: string; items: Any[]} | {after: string; items: Any[]} | {replace: string; items: Any[]}
669
656
 
670
657
  // Note: this is actually incorrect/invalid, but implemented as-is for backwards compatibility
671
658
  /** @internal */
@@ -735,8 +722,7 @@ export type QueryWithoutParams = Record<string, never> | undefined
735
722
  export type MutationSelectionQueryParams = {[key: string]: Any}
736
723
  /** @internal */
737
724
  export type MutationSelection =
738
- | {query: string; params?: MutationSelectionQueryParams}
739
- | {id: string | string[]}
725
+ {query: string; params?: MutationSelectionQueryParams} | {id: string | string[]}
740
726
  /** @internal */
741
727
  export type PatchSelection = string | string[] | MutationSelection
742
728
  /** @internal */
@@ -764,10 +750,7 @@ export type ReleaseAction =
764
750
 
765
751
  /** @public */
766
752
  export type VersionAction =
767
- | CreateVersionAction
768
- | DiscardVersionAction
769
- | ReplaceVersionAction
770
- | UnpublishVersionAction
753
+ CreateVersionAction | DiscardVersionAction | ReplaceVersionAction | UnpublishVersionAction
771
754
 
772
755
  /** @public */
773
756
  export type Action =
@@ -1313,12 +1296,7 @@ export type ResetEvent = {
1313
1296
 
1314
1297
  /** @public */
1315
1298
  export type ListenEvent<R extends Record<string, Any> = Record<string, Any>> =
1316
- | MutationEvent<R>
1317
- | ReconnectEvent
1318
- | WelcomeBackEvent
1319
- | ResetEvent
1320
- | WelcomeEvent
1321
- | OpenEvent
1299
+ MutationEvent<R> | ReconnectEvent | WelcomeBackEvent | ResetEvent | WelcomeEvent | OpenEvent
1322
1300
 
1323
1301
  /** @public */
1324
1302
  export type ListenEventName =
@@ -1498,9 +1476,7 @@ export interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {
1498
1476
 
1499
1477
  /** @public */
1500
1478
  export type QueryOptions =
1501
- | FilteredResponseQueryOptions
1502
- | UnfilteredResponseQueryOptions
1503
- | UnfilteredResponseWithoutQuery
1479
+ FilteredResponseQueryOptions | UnfilteredResponseQueryOptions | UnfilteredResponseWithoutQuery
1504
1480
 
1505
1481
  /** @public */
1506
1482
  export interface RawQueryResponse<R> {
@@ -1829,8 +1805,7 @@ export interface ContentSourceMapRemoteDocument extends ContentSourceMapDocument
1829
1805
 
1830
1806
  /** @public */
1831
1807
  export type ContentSourceMapDocuments = (
1832
- | ContentSourceMapDocument
1833
- | ContentSourceMapRemoteDocument
1808
+ ContentSourceMapDocument | ContentSourceMapRemoteDocument
1834
1809
  )[]
1835
1810
 
1836
1811
  /** @public */
@@ -1876,11 +1851,7 @@ export interface LiveEventGoAway {
1876
1851
  }
1877
1852
  /** @public */
1878
1853
  export type LiveEvent =
1879
- | LiveEventRestart
1880
- | LiveEventReconnect
1881
- | LiveEventMessage
1882
- | LiveEventWelcome
1883
- | LiveEventGoAway
1854
+ LiveEventRestart | LiveEventReconnect | LiveEventMessage | LiveEventWelcome | LiveEventGoAway
1884
1855
 
1885
1856
  /** @public */
1886
1857
  export interface SanityQueries {}
@@ -1945,7 +1945,7 @@
1945
1945
  return w(result);
1946
1946
  }
1947
1947
 
1948
- const DRAFTS_FOLDER$1 = "drafts", VERSION_FOLDER$1 = "versions", PATH_SEPARATOR$1 = ".", DRAFTS_PREFIX$1 = `${DRAFTS_FOLDER$1}${PATH_SEPARATOR$1}`, VERSION_PREFIX$1 = `${VERSION_FOLDER$1}${PATH_SEPARATOR$1}`;
1948
+ const DRAFTS_FOLDER$1 = "drafts", VERSION_FOLDER$1 = "versions", DRAFTS_PREFIX$1 = `${DRAFTS_FOLDER$1}.`, VERSION_PREFIX$1 = `${VERSION_FOLDER$1}.`;
1949
1949
  function isDraftId$1(id) {
1950
1950
  return id.startsWith(DRAFTS_PREFIX$1);
1951
1951
  }
@@ -1962,22 +1962,28 @@
1962
1962
  function getVersionId(id, version) {
1963
1963
  if (version === "drafts" || version === "published")
1964
1964
  throw new Error('Version can not be "published" or "drafts"');
1965
- return `${VERSION_PREFIX$1}${version}${PATH_SEPARATOR$1}${getPublishedId$1(id)}`;
1965
+ return `${VERSION_PREFIX$1}${version}.${getPublishedId$1(id)}`;
1966
1966
  }
1967
1967
  function getVersionFromId$1(id) {
1968
1968
  if (!isVersionId$1(id)) return;
1969
- const [_versionPrefix, versionId] = id.split(PATH_SEPARATOR$1);
1969
+ const [_versionPrefix, versionId] = id.split(".");
1970
1970
  return versionId;
1971
1971
  }
1972
1972
  function getPublishedId$1(id) {
1973
- return isVersionId$1(id) ? id.split(PATH_SEPARATOR$1).slice(2).join(PATH_SEPARATOR$1) : isDraftId$1(id) ? id.slice(DRAFTS_PREFIX$1.length) : id;
1973
+ return isVersionId$1(id) ? id.split(".").slice(2).join(".") : isDraftId$1(id) ? id.slice(DRAFTS_PREFIX$1.length) : id;
1974
1974
  }
1975
1975
 
1976
1976
  let random = bytes => crypto.getRandomValues(new Uint8Array(bytes));
1977
+
1977
1978
  let customRandom = (alphabet, defaultSize, getRandom) => {
1978
1979
  let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1;
1980
+
1981
+
1982
+
1979
1983
  let step = -~((1.6 * mask * defaultSize) / alphabet.length);
1984
+
1980
1985
  return (size = defaultSize) => {
1986
+ if (size <= 0) return ''
1981
1987
  let id = '';
1982
1988
  while (true) {
1983
1989
  let bytes = getRandom(step);
@@ -1989,6 +1995,7 @@
1989
1995
  }
1990
1996
  }
1991
1997
  };
1998
+
1992
1999
  let customAlphabet = (alphabet, size = 21) =>
1993
2000
  customRandom(alphabet, size, random);
1994
2001
 
@@ -2856,7 +2863,7 @@ ${selectionOpts}`);
2856
2863
  const withCredentials = !!(typeof overrides.withCredentials > "u" ? config.withCredentials : overrides.withCredentials), timeout = typeof overrides.timeout > "u" ? config.timeout : overrides.timeout;
2857
2864
  return Object.assign({}, overrides, {
2858
2865
  headers: Object.assign({}, headers, overrides.headers || {}),
2859
- timeout: typeof timeout > "u" ? 5 * 60 * 1e3 : timeout,
2866
+ timeout: typeof timeout > "u" ? 300 * 1e3 : timeout,
2860
2867
  proxy: overrides.proxy || config.proxy,
2861
2868
  json: true,
2862
2869
  withCredentials,
@@ -5187,7 +5194,7 @@ ${selectionOpts}`);
5187
5194
  });
5188
5195
  });
5189
5196
  }
5190
- const DRAFTS_FOLDER = "drafts", VERSION_FOLDER = "versions", PATH_SEPARATOR = ".", DRAFTS_PREFIX = `${DRAFTS_FOLDER}${PATH_SEPARATOR}`, VERSION_PREFIX = `${VERSION_FOLDER}${PATH_SEPARATOR}`;
5197
+ const DRAFTS_FOLDER = "drafts", VERSION_FOLDER = "versions", DRAFTS_PREFIX = `${DRAFTS_FOLDER}.`, VERSION_PREFIX = `${VERSION_FOLDER}.`;
5191
5198
  function isDraftId(id) {
5192
5199
  return id.startsWith(DRAFTS_PREFIX);
5193
5200
  }
@@ -5199,11 +5206,11 @@ ${selectionOpts}`);
5199
5206
  }
5200
5207
  function getVersionFromId(id) {
5201
5208
  if (!isVersionId(id)) return;
5202
- const [_versionPrefix, versionId] = id.split(PATH_SEPARATOR);
5209
+ const [_versionPrefix, versionId] = id.split(".");
5203
5210
  return versionId;
5204
5211
  }
5205
5212
  function getPublishedId(id) {
5206
- return isVersionId(id) ? id.split(PATH_SEPARATOR).slice(2).join(PATH_SEPARATOR) : isDraftId(id) ? id.slice(DRAFTS_PREFIX.length) : id;
5213
+ return isVersionId(id) ? id.split(".").slice(2).join(".") : isDraftId(id) ? id.slice(DRAFTS_PREFIX.length) : id;
5207
5214
  }
5208
5215
  function createEditUrl(options) {
5209
5216
  const {
@@ -5445,7 +5452,7 @@ ${selectionOpts}`);
5445
5452
  function requireEventsource () {
5446
5453
  if (hasRequiredEventsource) return eventsource$1.exports;
5447
5454
  hasRequiredEventsource = 1;
5448
- (function (module, exports$1) {
5455
+ (function (module, exports) {
5449
5456
  /*jslint indent: 2, vars: true, plusplus: true */
5450
5457
  /*global setTimeout, clearTimeout */
5451
5458
 
@@ -6472,13 +6479,13 @@ ${selectionOpts}`);
6472
6479
 
6473
6480
  (function (factory) {
6474
6481
  {
6475
- var v = factory(exports$1);
6482
+ var v = factory(exports);
6476
6483
  if (v !== undefined) module.exports = v;
6477
6484
  }
6478
- })(function (exports$1) {
6479
- exports$1.EventSourcePolyfill = EventSourcePolyfill;
6480
- exports$1.NativeEventSource = NativeEventSource;
6481
- exports$1.EventSource = R;
6485
+ })(function (exports) {
6486
+ exports.EventSourcePolyfill = EventSourcePolyfill;
6487
+ exports.NativeEventSource = NativeEventSource;
6488
+ exports.EventSource = R;
6482
6489
  });
6483
6490
  }(typeof globalThis === 'undefined' ? (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : eventsource) : globalThis));
6484
6491
  } (eventsource$1, eventsource$1.exports));