@sanity/client 7.26.1 → 8.0.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.
Files changed (128) hide show
  1. package/README.md +5 -377
  2. package/dist/browserUpload-CQgx9YYo.js +86 -0
  3. package/dist/browserUpload-CQgx9YYo.js.map +1 -0
  4. package/dist/browserUpload-icWlVP15.js +86 -0
  5. package/dist/browserUpload-icWlVP15.js.map +1 -0
  6. package/dist/config-a8VajuEY.js +126 -0
  7. package/dist/config-a8VajuEY.js.map +1 -0
  8. package/dist/csm.d.ts +122 -347
  9. package/dist/csm.js +79 -91
  10. package/dist/csm.js.map +1 -1
  11. package/dist/dist-C9ExSk2R.js +73 -0
  12. package/dist/dist-C9ExSk2R.js.map +1 -0
  13. package/dist/dist-Z8cIRxoB.js +69 -0
  14. package/dist/dist-Z8cIRxoB.js.map +1 -0
  15. package/dist/index.d.ts +107 -6758
  16. package/dist/index.js +2822 -2848
  17. package/dist/index.js.map +1 -1
  18. package/dist/{index.d.cts → index.node.d.ts} +4291 -5363
  19. package/dist/index.node.js +3131 -0
  20. package/dist/index.node.js.map +1 -0
  21. package/dist/isRecord-Kfmt-nk-.js +7 -0
  22. package/dist/isRecord-Kfmt-nk-.js.map +1 -0
  23. package/dist/media-library.d.ts +9 -100
  24. package/dist/media-library.js +36 -14
  25. package/dist/media-library.js.map +1 -1
  26. package/dist/request-CJxcN16k.js +372 -0
  27. package/dist/request-CJxcN16k.js.map +1 -0
  28. package/dist/request-k7VS_NnC.js +354 -0
  29. package/dist/request-k7VS_NnC.js.map +1 -0
  30. package/dist/resolveEditInfo-sq7yF78q.js +325 -0
  31. package/dist/resolveEditInfo-sq7yF78q.js.map +1 -0
  32. package/dist/rolldown-runtime-vyAXikos.js +9 -0
  33. package/dist/stega.d.ts +78 -7179
  34. package/dist/stega.js +27 -20
  35. package/dist/stega.js.map +1 -1
  36. package/dist/stegaClean-C18wLWau.js +21 -0
  37. package/dist/stegaClean-C18wLWau.js.map +1 -0
  38. package/dist/stegaEncodeSourceMap-B2fGArSf.js +163 -0
  39. package/dist/stegaEncodeSourceMap-B2fGArSf.js.map +1 -0
  40. package/dist/stegaEncodeSourceMap-DkoIlutY.js +367 -0
  41. package/dist/stegaEncodeSourceMap-DkoIlutY.js.map +1 -0
  42. package/dist/{index.browser.d.cts → types-CUxZSgB2.d.ts} +3956 -5295
  43. package/dist/types-CfGzbXrl.d.ts +108 -0
  44. package/package.json +69 -146
  45. package/src/SanityClient.ts +82 -117
  46. package/src/agent/actions/AgentActionsClient.ts +12 -12
  47. package/src/agent/actions/generate.ts +20 -3
  48. package/src/agent/actions/patch.ts +21 -4
  49. package/src/agent/actions/prompt.ts +17 -4
  50. package/src/agent/actions/transform.ts +21 -4
  51. package/src/agent/actions/translate.ts +21 -4
  52. package/src/assets/AssetsClient.ts +71 -23
  53. package/src/csm/createEditUrl.ts +1 -1
  54. package/src/csm/draftUtils.ts +0 -1
  55. package/src/csm/index.ts +2 -2
  56. package/src/csm/studioPath.ts +2 -1
  57. package/src/csm/types.ts +5 -1
  58. package/src/data/dataMethods.ts +801 -349
  59. package/src/data/eventsource.ts +13 -10
  60. package/src/data/listen.ts +16 -22
  61. package/src/data/live.ts +44 -27
  62. package/src/data/resolveEventSourceFetch.ts +96 -0
  63. package/src/datasets/DatasetsClient.ts +58 -41
  64. package/src/defineCreateClient.ts +35 -23
  65. package/src/http/browserMiddleware.ts +7 -1
  66. package/src/http/browserUpload.ts +162 -0
  67. package/src/http/errors.ts +60 -6
  68. package/src/http/nodeMiddleware.ts +94 -30
  69. package/src/http/request.ts +310 -87
  70. package/src/http/requestOptions.ts +131 -15
  71. package/src/{index.browser.ts → index.node.ts} +9 -4
  72. package/src/index.ts +4 -3
  73. package/src/mediaLibrary/MediaLibraryVideoClient.ts +26 -11
  74. package/src/projects/ProjectsClient.ts +18 -16
  75. package/src/releases/ReleasesClient.ts +34 -31
  76. package/src/stega/index.ts +1 -2
  77. package/src/stega/stegaEncodeSourceMap.ts +5 -0
  78. package/src/stega/types.ts +0 -1
  79. package/src/types.ts +110 -96
  80. package/src/users/UsersClient.ts +10 -14
  81. package/src/util/shareReplayLatest.ts +1 -1
  82. package/src/warnings.ts +6 -1
  83. package/dist/_chunks-cjs/config.cjs +0 -206
  84. package/dist/_chunks-cjs/config.cjs.map +0 -1
  85. package/dist/_chunks-cjs/isRecord.cjs +0 -6
  86. package/dist/_chunks-cjs/isRecord.cjs.map +0 -1
  87. package/dist/_chunks-cjs/resolveEditInfo.cjs +0 -334
  88. package/dist/_chunks-cjs/resolveEditInfo.cjs.map +0 -1
  89. package/dist/_chunks-cjs/stegaClean.cjs +0 -46
  90. package/dist/_chunks-cjs/stegaClean.cjs.map +0 -1
  91. package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +0 -388
  92. package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +0 -1
  93. package/dist/_chunks-es/config.js +0 -207
  94. package/dist/_chunks-es/config.js.map +0 -1
  95. package/dist/_chunks-es/isRecord.js +0 -7
  96. package/dist/_chunks-es/isRecord.js.map +0 -1
  97. package/dist/_chunks-es/resolveEditInfo.js +0 -335
  98. package/dist/_chunks-es/resolveEditInfo.js.map +0 -1
  99. package/dist/_chunks-es/stegaClean.js +0 -47
  100. package/dist/_chunks-es/stegaClean.js.map +0 -1
  101. package/dist/_chunks-es/stegaEncodeSourceMap.js +0 -389
  102. package/dist/_chunks-es/stegaEncodeSourceMap.js.map +0 -1
  103. package/dist/csm.cjs +0 -99
  104. package/dist/csm.cjs.map +0 -1
  105. package/dist/csm.d.cts +0 -403
  106. package/dist/index.browser.cjs +0 -3106
  107. package/dist/index.browser.cjs.map +0 -1
  108. package/dist/index.browser.d.ts +0 -6841
  109. package/dist/index.browser.js +0 -3082
  110. package/dist/index.browser.js.map +0 -1
  111. package/dist/index.cjs +0 -2947
  112. package/dist/index.cjs.map +0 -1
  113. package/dist/media-library.cjs +0 -20
  114. package/dist/media-library.cjs.map +0 -1
  115. package/dist/media-library.d.cts +0 -117
  116. package/dist/stega.browser.cjs +0 -29
  117. package/dist/stega.browser.cjs.map +0 -1
  118. package/dist/stega.browser.d.cts +0 -7242
  119. package/dist/stega.browser.d.ts +0 -7242
  120. package/dist/stega.browser.js +0 -24
  121. package/dist/stega.browser.js.map +0 -1
  122. package/dist/stega.cjs +0 -29
  123. package/dist/stega.cjs.map +0 -1
  124. package/dist/stega.d.cts +0 -7242
  125. package/src/data/eventsourcePolyfill.ts +0 -7
  126. package/umd/.gitkeep +0 -1
  127. package/umd/sanityClient.js +0 -6536
  128. package/umd/sanityClient.min.js +0 -6
@@ -1,24 +0,0 @@
1
- import { createClient as createClient$1, requester as requester$1, ObservableSanityClient, SanityClient } from "@sanity/client";
2
- export * from "@sanity/client";
3
- import { encodeIntoResult, stegaEncodeSourceMap } from "./_chunks-es/stegaEncodeSourceMap.js";
4
- import { stegaClean, vercelStegaCleanAll } from "./_chunks-es/stegaClean.js";
5
- function stegaBrand(result) {
6
- return result;
7
- }
8
- class SanityStegaClient extends SanityClient {
9
- }
10
- class ObservableSanityStegaClient extends ObservableSanityClient {
11
- }
12
- const requester = requester$1, createClient = createClient$1;
13
- export {
14
- ObservableSanityStegaClient,
15
- SanityStegaClient,
16
- createClient,
17
- encodeIntoResult,
18
- requester,
19
- stegaBrand,
20
- stegaClean,
21
- stegaEncodeSourceMap,
22
- vercelStegaCleanAll
23
- };
24
- //# sourceMappingURL=stega.browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stega.browser.js","sources":["../src/stega/stegaBrand.ts","../src/stega/index.ts"],"sourcesContent":["import type {Any, ClientReturn} from '@sanity/client'\n\n/**\n * A string that might contain stega-encoded data, and is unsafe to compare against string literals\n * until it's been cleaned with `stegaClean()`.\n *\n * The type intersects a template literal that has a human readable suffix, with a brand property\n * that holds the original string type:\n * - The suffix makes TypeScript report \"This comparison appears to be unintentional\" (TS2367) when\n * the string is compared to a literal (`===`, `switch` cases), and makes it unassignable to\n * literal unions like `'left' | 'right'`, while keeping it assignable to `string` so rendering,\n * interpolation and string methods keep working. The suffix is a type-level fiction, the runtime\n * value never ends with that text.\n * - The brand property preserves the original type so `stegaClean()` can recover it exactly. It's\n * a string-keyed property rather than a `unique symbol` so that branded types stay structurally\n * compatible across duplicated copies of `@sanity/client` in `node_modules`. It only exists in\n * the type system and is never present at runtime.\n *\n * @beta\n */\nexport type StegaString<T extends string = string> =\n `${T} (may contain hidden stega characters)` & {\n readonly ' stegaBrand': T\n }\n\n/**\n * Deeply brands the string properties of a query result as `StegaString`, marking them as\n * potentially containing stega-encoded data.\n *\n * String properties that the stega encoder is guaranteed to never encode keep their plain type:\n * - keys starting with `_` (`_id`, `_type`, `_createdAt`, `_updatedAt`, `_key`, `_ref`, `_rev` and\n * so on), which also preserves discriminated union narrowing on `_type`\n * - `slug.current` patterns: a `current` key directly under a `slug` key, as well as string valued\n * `slug` keys (covering `\"slug\": slug.current` projections)\n * - Portable Text internals: the encoder only visits `children` of `_type: 'block'` objects and\n * `text` of `_type: 'span'` objects, so properties like `style`, `listItem` and `marks` stay\n * plain\n * - symbol-keyed properties (like TypeGen's `internalGroqTypeReferenceTo` reference marker): JSON\n * can't contain symbol keys, so they only exist in the type system and are never encoded\n *\n * Every other string is assumed to be \"poisoned\", even if the runtime `filter` happens to skip it\n * (URLs, dates, keys ending in `Id`, denylisted keys). Being conservative is safe: the worst case\n * is a redundant `stegaClean()` call, whereas under-branding would hide real bugs.\n *\n * The `Key` and `ParentKey` type parameters track the key the current value is found under, and\n * the key of the object containing it, they're only used internally during recursion.\n *\n * @beta\n */\nexport type StegaBranded<\n T,\n Key extends PropertyKey = number,\n ParentKey extends PropertyKey = number,\n> = 0 extends 1 & T\n ? T\n : T extends string\n ? T extends {readonly ' stegaBrand': string}\n ? T\n : Key extends `_${string}` | 'slug' | symbol\n ? T\n : Key extends 'current'\n ? ParentKey extends 'slug'\n ? T\n : StegaString<T>\n : StegaString<T>\n : T extends number | bigint | boolean | null | undefined\n ? T\n : T extends Date | RegExp | ((...args: never[]) => unknown)\n ? T\n : T extends readonly unknown[]\n ? {[Index in keyof T]: StegaBranded<T[Index], number, number>}\n : T extends {_type: 'block'}\n ? {[K in keyof T]: K extends 'children' ? StegaBranded<T[K], K, Key> : T[K]}\n : T extends {_type: 'span'}\n ? {[K in keyof T]: K extends 'text' ? StegaBranded<T[K], K, Key> : T[K]}\n : T extends object\n ? {[K in keyof T]: StegaBranded<T[K], K, Key>}\n : T\n\n/**\n * Drop-in replacement for `ClientReturn` that brands the result strings as `StegaString`, for use\n * as the first generic of `client.fetch` when stega is enabled:\n * ```ts\n * import {createClient} from '@sanity/client'\n * import type {ClientReturnStega} from '@sanity/client/stega'\n *\n * const query = '*[_type == \"post\"][0]'\n * const post = await client.fetch<ClientReturnStega<typeof query>>(query)\n * ```\n * When the query is registered in the `SanityQueries` interface (for example by `sanity typegen`),\n * the result type is looked up and deeply branded with `StegaBranded`. Otherwise it falls back to\n * `Fallback`, which defaults to `any`, just like `ClientReturn`.\n *\n * @beta\n */\nexport type ClientReturnStega<GroqString extends string, Fallback = Any> = StegaBranded<\n ClientReturn<GroqString, Fallback>\n>\n\n/**\n * Marks strings in an already fetched query result as potentially containing stega-encoded data,\n * by re-typing them as `StegaString`. Comparing branded strings to string literals is a type error\n * until they're cleaned with `stegaClean()`, which recovers the original type.\n *\n * This is an identity function, it only changes the type of the input, not its value.\n * Prefer passing `ClientReturnStega` as the first generic to `client.fetch` when possible, and use\n * this function for data that has already been fetched.\n *\n * @beta\n */\nexport function stegaBrand<Result>(result: Result): StegaBranded<Result> {\n return result as StegaBranded<Result>\n}\n","export * from '@sanity/client'\nimport {\n createClient as originalCreateClient,\n ObservableSanityClient,\n requester as originalRequester,\n SanityClient,\n} from '@sanity/client'\n\nexport {encodeIntoResult} from './encodeIntoResult'\nexport {type ClientReturnStega, stegaBrand, type StegaBranded, type StegaString} from './stegaBrand'\nexport {stegaClean, type StegaCleaned, vercelStegaCleanAll} from './stegaClean'\nexport {stegaEncodeSourceMap} from './stegaEncodeSourceMap'\nexport * from './types'\n\n/**\n * @deprecated -- Use `import {SanityClient} from '@sanity/client'` instead\n * @public\n */\nexport class SanityStegaClient extends SanityClient {}\n\n/**\n * @deprecated -- Use `import {ObservableSanityClient} from '@sanity/client'` instead\n * @public\n */\nexport class ObservableSanityStegaClient extends ObservableSanityClient {}\n\n/**\n * @deprecated -- Use `import {requester} from '@sanity/client'` instead\n * @public\n */\nexport const requester = originalRequester\n\n/**\n * @deprecated -- Use `import {createClient} from '@sanity/client'` instead\n * @public\n */\nexport const createClient = originalCreateClient\n"],"names":["originalRequester","originalCreateClient"],"mappings":";;;;AA8GO,SAAS,WAAmB,QAAsC;AACvE,SAAO;AACT;AC9FO,MAAM,0BAA0B,aAAa;AAAC;AAM9C,MAAM,oCAAoC,uBAAuB;AAAC;AAMlE,MAAM,YAAYA,aAMZ,eAAeC;"}
package/dist/stega.cjs DELETED
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var client = require("@sanity/client"), stegaEncodeSourceMap = require("./_chunks-cjs/stegaEncodeSourceMap.cjs"), stegaClean = require("./_chunks-cjs/stegaClean.cjs");
4
- function stegaBrand(result) {
5
- return result;
6
- }
7
- class SanityStegaClient extends client.SanityClient {
8
- }
9
- class ObservableSanityStegaClient extends client.ObservableSanityClient {
10
- }
11
- const requester = client.requester, createClient = client.createClient;
12
- exports.encodeIntoResult = stegaEncodeSourceMap.encodeIntoResult;
13
- exports.stegaEncodeSourceMap = stegaEncodeSourceMap.stegaEncodeSourceMap;
14
- exports.stegaClean = stegaClean.stegaClean;
15
- exports.vercelStegaCleanAll = stegaClean.vercelStegaCleanAll;
16
- exports.ObservableSanityStegaClient = ObservableSanityStegaClient;
17
- exports.SanityStegaClient = SanityStegaClient;
18
- exports.createClient = createClient;
19
- exports.requester = requester;
20
- exports.stegaBrand = stegaBrand;
21
- Object.keys(client).forEach(function(k) {
22
- k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k) && Object.defineProperty(exports, k, {
23
- enumerable: !0,
24
- get: function() {
25
- return client[k];
26
- }
27
- });
28
- });
29
- //# sourceMappingURL=stega.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stega.cjs","sources":["../src/stega/stegaBrand.ts","../src/stega/index.ts"],"sourcesContent":["import type {Any, ClientReturn} from '@sanity/client'\n\n/**\n * A string that might contain stega-encoded data, and is unsafe to compare against string literals\n * until it's been cleaned with `stegaClean()`.\n *\n * The type intersects a template literal that has a human readable suffix, with a brand property\n * that holds the original string type:\n * - The suffix makes TypeScript report \"This comparison appears to be unintentional\" (TS2367) when\n * the string is compared to a literal (`===`, `switch` cases), and makes it unassignable to\n * literal unions like `'left' | 'right'`, while keeping it assignable to `string` so rendering,\n * interpolation and string methods keep working. The suffix is a type-level fiction, the runtime\n * value never ends with that text.\n * - The brand property preserves the original type so `stegaClean()` can recover it exactly. It's\n * a string-keyed property rather than a `unique symbol` so that branded types stay structurally\n * compatible across duplicated copies of `@sanity/client` in `node_modules`. It only exists in\n * the type system and is never present at runtime.\n *\n * @beta\n */\nexport type StegaString<T extends string = string> =\n `${T} (may contain hidden stega characters)` & {\n readonly ' stegaBrand': T\n }\n\n/**\n * Deeply brands the string properties of a query result as `StegaString`, marking them as\n * potentially containing stega-encoded data.\n *\n * String properties that the stega encoder is guaranteed to never encode keep their plain type:\n * - keys starting with `_` (`_id`, `_type`, `_createdAt`, `_updatedAt`, `_key`, `_ref`, `_rev` and\n * so on), which also preserves discriminated union narrowing on `_type`\n * - `slug.current` patterns: a `current` key directly under a `slug` key, as well as string valued\n * `slug` keys (covering `\"slug\": slug.current` projections)\n * - Portable Text internals: the encoder only visits `children` of `_type: 'block'` objects and\n * `text` of `_type: 'span'` objects, so properties like `style`, `listItem` and `marks` stay\n * plain\n * - symbol-keyed properties (like TypeGen's `internalGroqTypeReferenceTo` reference marker): JSON\n * can't contain symbol keys, so they only exist in the type system and are never encoded\n *\n * Every other string is assumed to be \"poisoned\", even if the runtime `filter` happens to skip it\n * (URLs, dates, keys ending in `Id`, denylisted keys). Being conservative is safe: the worst case\n * is a redundant `stegaClean()` call, whereas under-branding would hide real bugs.\n *\n * The `Key` and `ParentKey` type parameters track the key the current value is found under, and\n * the key of the object containing it, they're only used internally during recursion.\n *\n * @beta\n */\nexport type StegaBranded<\n T,\n Key extends PropertyKey = number,\n ParentKey extends PropertyKey = number,\n> = 0 extends 1 & T\n ? T\n : T extends string\n ? T extends {readonly ' stegaBrand': string}\n ? T\n : Key extends `_${string}` | 'slug' | symbol\n ? T\n : Key extends 'current'\n ? ParentKey extends 'slug'\n ? T\n : StegaString<T>\n : StegaString<T>\n : T extends number | bigint | boolean | null | undefined\n ? T\n : T extends Date | RegExp | ((...args: never[]) => unknown)\n ? T\n : T extends readonly unknown[]\n ? {[Index in keyof T]: StegaBranded<T[Index], number, number>}\n : T extends {_type: 'block'}\n ? {[K in keyof T]: K extends 'children' ? StegaBranded<T[K], K, Key> : T[K]}\n : T extends {_type: 'span'}\n ? {[K in keyof T]: K extends 'text' ? StegaBranded<T[K], K, Key> : T[K]}\n : T extends object\n ? {[K in keyof T]: StegaBranded<T[K], K, Key>}\n : T\n\n/**\n * Drop-in replacement for `ClientReturn` that brands the result strings as `StegaString`, for use\n * as the first generic of `client.fetch` when stega is enabled:\n * ```ts\n * import {createClient} from '@sanity/client'\n * import type {ClientReturnStega} from '@sanity/client/stega'\n *\n * const query = '*[_type == \"post\"][0]'\n * const post = await client.fetch<ClientReturnStega<typeof query>>(query)\n * ```\n * When the query is registered in the `SanityQueries` interface (for example by `sanity typegen`),\n * the result type is looked up and deeply branded with `StegaBranded`. Otherwise it falls back to\n * `Fallback`, which defaults to `any`, just like `ClientReturn`.\n *\n * @beta\n */\nexport type ClientReturnStega<GroqString extends string, Fallback = Any> = StegaBranded<\n ClientReturn<GroqString, Fallback>\n>\n\n/**\n * Marks strings in an already fetched query result as potentially containing stega-encoded data,\n * by re-typing them as `StegaString`. Comparing branded strings to string literals is a type error\n * until they're cleaned with `stegaClean()`, which recovers the original type.\n *\n * This is an identity function, it only changes the type of the input, not its value.\n * Prefer passing `ClientReturnStega` as the first generic to `client.fetch` when possible, and use\n * this function for data that has already been fetched.\n *\n * @beta\n */\nexport function stegaBrand<Result>(result: Result): StegaBranded<Result> {\n return result as StegaBranded<Result>\n}\n","export * from '@sanity/client'\nimport {\n createClient as originalCreateClient,\n ObservableSanityClient,\n requester as originalRequester,\n SanityClient,\n} from '@sanity/client'\n\nexport {encodeIntoResult} from './encodeIntoResult'\nexport {type ClientReturnStega, stegaBrand, type StegaBranded, type StegaString} from './stegaBrand'\nexport {stegaClean, type StegaCleaned, vercelStegaCleanAll} from './stegaClean'\nexport {stegaEncodeSourceMap} from './stegaEncodeSourceMap'\nexport * from './types'\n\n/**\n * @deprecated -- Use `import {SanityClient} from '@sanity/client'` instead\n * @public\n */\nexport class SanityStegaClient extends SanityClient {}\n\n/**\n * @deprecated -- Use `import {ObservableSanityClient} from '@sanity/client'` instead\n * @public\n */\nexport class ObservableSanityStegaClient extends ObservableSanityClient {}\n\n/**\n * @deprecated -- Use `import {requester} from '@sanity/client'` instead\n * @public\n */\nexport const requester = originalRequester\n\n/**\n * @deprecated -- Use `import {createClient} from '@sanity/client'` instead\n * @public\n */\nexport const createClient = originalCreateClient\n"],"names":["SanityClient","ObservableSanityClient","originalRequester","originalCreateClient"],"mappings":";;;AA8GO,SAAS,WAAmB,QAAsC;AACvE,SAAO;AACT;AC9FO,MAAM,0BAA0BA,OAAAA,aAAa;AAAC;AAM9C,MAAM,oCAAoCC,OAAAA,uBAAuB;AAAC;AAMlE,MAAM,YAAYC,OAAAA,WAMZ,eAAeC,OAAAA;;;;;;;;;;;;;;;;;;"}