@sanity/client 7.11.2 → 7.12.1

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.
@@ -780,6 +780,10 @@ export declare interface ClientConfig {
780
780
  * Options for how, if enabled, Content Source Maps are encoded into query results using steganography
781
781
  */
782
782
  stega?: StegaConfig | boolean
783
+ /**
784
+ * Lineage token for recursion control
785
+ */
786
+ lineage?: string
783
787
  }
784
788
 
785
789
  declare type ClientConfigResource =
@@ -3449,7 +3453,7 @@ export declare class ObservableSanityClient {
3449
3453
  createVersion(
3450
3454
  args: {
3451
3455
  baseId: string
3452
- releaseId: string
3456
+ releaseId?: string
3453
3457
  publishedId: string
3454
3458
  ifBaseRevisionId?: string
3455
3459
  },
@@ -5274,7 +5278,7 @@ export declare class SanityClient {
5274
5278
  args: {
5275
5279
  publishedId: string
5276
5280
  baseId: string
5277
- releaseId: string
5281
+ releaseId?: string
5278
5282
  ifBaseRevisionId?: string
5279
5283
  },
5280
5284
  options?: BaseActionOptions,
@@ -780,6 +780,10 @@ export declare interface ClientConfig {
780
780
  * Options for how, if enabled, Content Source Maps are encoded into query results using steganography
781
781
  */
782
782
  stega?: StegaConfig | boolean
783
+ /**
784
+ * Lineage token for recursion control
785
+ */
786
+ lineage?: string
783
787
  }
784
788
 
785
789
  declare type ClientConfigResource =
@@ -3449,7 +3453,7 @@ export declare class ObservableSanityClient {
3449
3453
  createVersion(
3450
3454
  args: {
3451
3455
  baseId: string
3452
- releaseId: string
3456
+ releaseId?: string
3453
3457
  publishedId: string
3454
3458
  ifBaseRevisionId?: string
3455
3459
  },
@@ -5274,7 +5278,7 @@ export declare class SanityClient {
5274
5278
  args: {
5275
5279
  publishedId: string
5276
5280
  baseId: string
5277
- releaseId: string
5281
+ releaseId?: string
5278
5282
  ifBaseRevisionId?: string
5279
5283
  },
5280
5284
  options?: BaseActionOptions,
package/dist/stega.d.cts CHANGED
@@ -780,6 +780,10 @@ export declare interface ClientConfig {
780
780
  * Options for how, if enabled, Content Source Maps are encoded into query results using steganography
781
781
  */
782
782
  stega?: StegaConfig | boolean
783
+ /**
784
+ * Lineage token for recursion control
785
+ */
786
+ lineage?: string
783
787
  }
784
788
 
785
789
  declare type ClientConfigResource =
@@ -3449,7 +3453,7 @@ export declare class ObservableSanityClient {
3449
3453
  createVersion(
3450
3454
  args: {
3451
3455
  baseId: string
3452
- releaseId: string
3456
+ releaseId?: string
3453
3457
  publishedId: string
3454
3458
  ifBaseRevisionId?: string
3455
3459
  },
@@ -5274,7 +5278,7 @@ export declare class SanityClient {
5274
5278
  args: {
5275
5279
  publishedId: string
5276
5280
  baseId: string
5277
- releaseId: string
5281
+ releaseId?: string
5278
5282
  ifBaseRevisionId?: string
5279
5283
  },
5280
5284
  options?: BaseActionOptions,
package/dist/stega.d.ts CHANGED
@@ -780,6 +780,10 @@ export declare interface ClientConfig {
780
780
  * Options for how, if enabled, Content Source Maps are encoded into query results using steganography
781
781
  */
782
782
  stega?: StegaConfig | boolean
783
+ /**
784
+ * Lineage token for recursion control
785
+ */
786
+ lineage?: string
783
787
  }
784
788
 
785
789
  declare type ClientConfigResource =
@@ -3449,7 +3453,7 @@ export declare class ObservableSanityClient {
3449
3453
  createVersion(
3450
3454
  args: {
3451
3455
  baseId: string
3452
- releaseId: string
3456
+ releaseId?: string
3453
3457
  publishedId: string
3454
3458
  ifBaseRevisionId?: string
3455
3459
  },
@@ -5274,7 +5278,7 @@ export declare class SanityClient {
5274
5278
  args: {
5275
5279
  publishedId: string
5276
5280
  baseId: string
5277
- releaseId: string
5281
+ releaseId?: string
5278
5282
  ifBaseRevisionId?: string
5279
5283
  },
5280
5284
  options?: BaseActionOptions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "7.11.2",
3
+ "version": "7.12.1",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -116,7 +116,7 @@
116
116
  "test:deno:update_import_map": "deno run --allow-read --allow-write runtimes/deno/update_import_map.ts",
117
117
  "test:edge-runtime": "npm test -- --config vitest.edge.config.ts",
118
118
  "test:next": "npm test -- --config ./vitest.next.config.ts",
119
- "test:node-runtimes": "(cd runtimes/node && node --test | npx faucet)"
119
+ "test:node-runtimes": "(cd runtimes/node && node --test)"
120
120
  },
121
121
  "browserslist": "extends @sanity/browserslist-config",
122
122
  "prettier": {
@@ -156,7 +156,6 @@
156
156
  "eslint-plugin-simple-import-sort": "^12.1.1",
157
157
  "eslint-plugin-tsdoc": "^0.4.0",
158
158
  "eslint-plugin-unused-imports": "^4.1.4",
159
- "faucet": "^0.0.4",
160
159
  "globals": "^16.0.0",
161
160
  "happy-dom": "^12.10.3",
162
161
  "json-diff": "^1.0.6",
@@ -601,7 +601,7 @@ export class ObservableSanityClient {
601
601
  createVersion(
602
602
  args: {
603
603
  baseId: string
604
- releaseId: string
604
+ releaseId?: string
605
605
  publishedId: string
606
606
  ifBaseRevisionId?: string
607
607
  },
@@ -1647,7 +1647,7 @@ export class SanityClient {
1647
1647
  args: {
1648
1648
  publishedId: string
1649
1649
  baseId: string
1650
- releaseId: string
1650
+ releaseId?: string
1651
1651
  ifBaseRevisionId?: string
1652
1652
  },
1653
1653
  options?: BaseActionOptions,
@@ -56,6 +56,7 @@ export default function defineCreateClientExports<
56
56
  maxRedirects: 0,
57
57
  maxRetries: config.maxRetries,
58
58
  retryDelay: config.retryDelay,
59
+ lineage: config.lineage,
59
60
  ...options,
60
61
  } as Any),
61
62
  config,
@@ -1,11 +1,28 @@
1
+ import type {Middleware, RequestOptions} from 'get-it'
1
2
  import {agent, debug, headers} from 'get-it/middleware'
2
3
 
3
4
  import {name, version} from '../../package.json'
4
5
 
5
- const middleware = [
6
+ const middleware: Middleware[] = [
6
7
  debug({verbose: true, namespace: 'sanity:client'}),
7
8
  headers({'User-Agent': `${name} ${version}`}),
8
9
 
10
+ // Lineage is used for recursion control/tracing and can be passed either through
11
+ // client constructor or through environent variable.
12
+ // Not used in browser environments.
13
+ {
14
+ processOptions(opts: RequestOptions & {lineage?: string}) {
15
+ const lineage =
16
+ (typeof process !== 'undefined' && process.env.X_SANITY_LINEAGE) || opts.lineage
17
+
18
+ if (lineage) {
19
+ opts.headers = opts.headers || {}
20
+ opts.headers['x-sanity-lineage'] = lineage
21
+ }
22
+ return opts
23
+ },
24
+ },
25
+
9
26
  // Enable keep-alive, and in addition limit the number of sockets that can be opened.
10
27
  // This avoids opening too many connections to the server if someone tries to execute
11
28
  // a bunch of requests in parallel. It's recommended to have a concurrency limit
@@ -58,10 +58,14 @@ function printWarnings(config: {ignoreWarnings?: string | RegExp | Array<string
58
58
  }
59
59
  }
60
60
 
61
+ type HttpRequestConfig = {
62
+ ignoreWarnings?: string | RegExp | Array<string | RegExp>
63
+ }
64
+
61
65
  /** @internal */
62
66
  export function defineHttpRequest(
63
67
  envMiddleware: Middlewares,
64
- config: {ignoreWarnings?: string | RegExp | Array<string | RegExp>} = {},
68
+ config: HttpRequestConfig = {},
65
69
  ): Requester {
66
70
  return getIt([
67
71
  retry({shouldRetry}),
package/src/types.ts CHANGED
@@ -179,6 +179,10 @@ export interface ClientConfig {
179
179
  * Options for how, if enabled, Content Source Maps are encoded into query results using steganography
180
180
  */
181
181
  stega?: StegaConfig | boolean
182
+ /**
183
+ * Lineage token for recursion control
184
+ */
185
+ lineage?: string
182
186
  }
183
187
 
184
188
  /** @public */
@@ -4801,6 +4801,7 @@ ${selectionOpts}`);
4801
4801
  maxRedirects: 0,
4802
4802
  maxRetries: config.maxRetries,
4803
4803
  retryDelay: config.retryDelay,
4804
+ lineage: config.lineage,
4804
4805
  ...options
4805
4806
  }),
4806
4807
  config