@sanity/client 6.21.1 → 6.21.3-bundle-perspective

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "6.21.1",
3
+ "version": "6.21.3-bundle-perspective",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -118,39 +118,39 @@
118
118
  },
119
119
  "dependencies": {
120
120
  "@sanity/eventsource": "^5.0.2",
121
- "get-it": "^8.6.3",
121
+ "get-it": "^8.6.4",
122
122
  "rxjs": "^7.0.0"
123
123
  },
124
124
  "devDependencies": {
125
- "@edge-runtime/types": "^3.0.0",
126
- "@edge-runtime/vm": "^4.0.0",
125
+ "@edge-runtime/types": "^3.0.1",
126
+ "@edge-runtime/vm": "^4.0.1",
127
127
  "@rollup/plugin-commonjs": "^26.0.1",
128
128
  "@rollup/plugin-node-resolve": "^15.2.3",
129
- "@sanity/pkg-utils": "^6.9.3",
129
+ "@sanity/pkg-utils": "^6.10.9",
130
130
  "@types/json-diff": "^1.0.3",
131
131
  "@types/node": "^20.8.8",
132
- "@typescript-eslint/eslint-plugin": "^7.13.1",
133
- "@typescript-eslint/parser": "^7.13.1",
132
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
133
+ "@typescript-eslint/parser": "^7.18.0",
134
134
  "@vercel/stega": "0.1.2",
135
- "@vitest/coverage-v8": "2.0.2",
135
+ "@vitest/coverage-v8": "2.0.5",
136
136
  "eslint": "^8.57.0",
137
137
  "eslint-config-prettier": "^9.1.0",
138
- "eslint-plugin-prettier": "^5.1.3",
139
- "eslint-plugin-simple-import-sort": "^12.1.0",
138
+ "eslint-plugin-prettier": "^5.2.1",
139
+ "eslint-plugin-simple-import-sort": "^12.1.1",
140
140
  "faucet": "^0.0.4",
141
141
  "happy-dom": "^12.10.3",
142
142
  "json-diff": "^1.0.6",
143
- "ls-engines": "^0.9.2",
144
- "next": "^14.2.4",
143
+ "ls-engines": "^0.9.3",
144
+ "next": "^14.2.5",
145
145
  "nock": "^13.5.4",
146
- "prettier": "^3.3.2",
147
- "prettier-plugin-packagejson": "^2.5.0",
146
+ "prettier": "^3.3.3",
147
+ "prettier-plugin-packagejson": "^2.5.1",
148
148
  "rimraf": "^5.0.7",
149
- "rollup": "^4.18.0",
149
+ "rollup": "^4.20.0",
150
150
  "sse-channel": "^4.0.0",
151
- "terser": "^5.31.1",
152
- "typescript": "5.4.5",
153
- "vitest": "2.0.2",
151
+ "terser": "^5.31.5",
152
+ "typescript": "5.5.3",
153
+ "vitest": "2.0.5",
154
154
  "vitest-github-actions-reporter": "0.11.1"
155
155
  },
156
156
  "engines": {
@@ -900,7 +900,7 @@ export class SanityClient {
900
900
  */
901
901
  getDocument<R extends Record<string, Any> = Record<string, Any>>(
902
902
  id: string,
903
- options?: {tag?: string},
903
+ options?: {signal?: AbortSignal; tag?: string},
904
904
  ): Promise<SanityDocument<R> | undefined> {
905
905
  return lastValueFrom(dataMethods._getDocument<R>(this, this.#httpRequest, id, options))
906
906
  }
@@ -916,7 +916,7 @@ export class SanityClient {
916
916
  */
917
917
  getDocuments<R extends Record<string, Any> = Record<string, Any>>(
918
918
  ids: string[],
919
- options?: {tag?: string},
919
+ options?: {signal?: AbortSignal; tag?: string},
920
920
  ): Promise<(SanityDocument<R> | null)[]> {
921
921
  return lastValueFrom(dataMethods._getDocuments<R>(this, this.#httpRequest, ids, options))
922
922
  }
@@ -129,9 +129,14 @@ export function _getDocument<R extends Record<string, Any>>(
129
129
  client: ObservableSanityClient | SanityClient,
130
130
  httpRequest: HttpRequest,
131
131
  id: string,
132
- opts: {tag?: string} = {},
132
+ opts: {signal?: AbortSignal; tag?: string} = {},
133
133
  ): Observable<SanityDocument<R> | undefined> {
134
- const options = {uri: _getDataUrl(client, 'doc', id), json: true, tag: opts.tag}
134
+ const options = {
135
+ uri: _getDataUrl(client, 'doc', id),
136
+ json: true,
137
+ tag: opts.tag,
138
+ signal: opts.signal,
139
+ }
135
140
  return _requestObservable<SanityDocument<R> | undefined>(client, httpRequest, options).pipe(
136
141
  filter(isResponse),
137
142
  map((event) => event.body.documents && event.body.documents[0]),
@@ -143,9 +148,14 @@ export function _getDocuments<R extends Record<string, Any>>(
143
148
  client: ObservableSanityClient | SanityClient,
144
149
  httpRequest: HttpRequest,
145
150
  ids: string[],
146
- opts: {tag?: string} = {},
151
+ opts: {signal?: AbortSignal; tag?: string} = {},
147
152
  ): Observable<(SanityDocument<R> | null)[]> {
148
- const options = {uri: _getDataUrl(client, 'doc', ids.join(',')), json: true, tag: opts.tag}
153
+ const options = {
154
+ uri: _getDataUrl(client, 'doc', ids.join(',')),
155
+ json: true,
156
+ tag: opts.tag,
157
+ signal: opts.signal,
158
+ }
149
159
  return _requestObservable<(SanityDocument<R> | null)[]>(client, httpRequest, options).pipe(
150
160
  filter(isResponse),
151
161
  map((event: Any) => {
@@ -302,6 +312,7 @@ export function _dataRequest(
302
312
  tag,
303
313
  returnQuery,
304
314
  perspective: options.perspective,
315
+ bundlePerspective: options.bundlePerspective,
305
316
  resultSourceMap: options.resultSourceMap,
306
317
  lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
307
318
  canUseCdn: isQuery,
@@ -395,6 +406,7 @@ export function _requestObservable<R>(
395
406
  options.query = {resultSourceMap, ...options.query}
396
407
  }
397
408
  const perspective = options.perspective || config.perspective
409
+ const bundlePerspective = options.bundlePerspective || config.bundlePerspective
398
410
  if (typeof perspective === 'string' && perspective !== 'raw') {
399
411
  validateApiPerspective(perspective)
400
412
  options.query = {perspective, ...options.query}
@@ -405,6 +417,13 @@ export function _requestObservable<R>(
405
417
  }
406
418
  }
407
419
 
420
+ if (typeof bundlePerspective === 'string') {
421
+ if (perspective) {
422
+ // printWarning()
423
+ }
424
+ options.query = {perspective: undefined, bundlePerspective, ...options.query}
425
+ }
426
+
408
427
  if (options.lastLiveEventId) {
409
428
  options.query = {...options.query, lastLiveEventId: options.lastLiveEventId}
410
429
  }
package/src/types.ts CHANGED
@@ -42,6 +42,7 @@ export interface ClientConfig {
42
42
  token?: string
43
43
  /** @defaultValue 'raw' */
44
44
  perspective?: ClientPerspective
45
+ bundlePerspective?: string
45
46
  apiHost?: string
46
47
  apiVersion?: string
47
48
  proxy?: string
@@ -221,7 +222,7 @@ export type SanityDocument<T extends Record<string, Any> = Record<string, Any>>
221
222
  _createdAt: string
222
223
  _updatedAt: string
223
224
  /**
224
- * Present when `perspective` is set to `previewDrafts`
225
+ * Present when `perspective` is set to `previewDrafts` or `bundlePerspective` is specified
225
226
  */
226
227
  _originalId?: string
227
228
  }
@@ -306,6 +307,7 @@ export interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
306
307
  returnQuery?: boolean
307
308
  resultSourceMap?: boolean | 'withKeyArraySelector'
308
309
  perspective?: ClientPerspective
310
+ bundlePerspective?: string
309
311
  lastLiveEventId?: string
310
312
  }
311
313
 
@@ -372,6 +374,10 @@ export interface SanityProjectMember {
372
374
  export interface SanityProject {
373
375
  id: string
374
376
  displayName: string
377
+ /**
378
+ * @deprecated Use the `/user-applications` endpoint instead, which lists all deployed studios/applications
379
+ * @see https://www.sanity.io/help/studio-host-user-applications
380
+ */
375
381
  studioHost: string | null
376
382
  organizationId: string | null
377
383
  isBlocked: boolean
@@ -384,6 +390,10 @@ export interface SanityProject {
384
390
  metadata: {
385
391
  cliInitializedAt?: string
386
392
  color?: string
393
+ /**
394
+ * @deprecated Use the `/user-applications` endpoint instead, which lists all deployed studios/applications
395
+ * @see https://www.sanity.io/help/studio-host-user-applications
396
+ */
387
397
  externalStudioHost?: string
388
398
  }
389
399
  }
@@ -463,6 +473,8 @@ export interface QueryParams {
463
473
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
464
474
  perspective?: never
465
475
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
476
+ bundlePerspective?: never
477
+ /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
466
478
  query?: never
467
479
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
468
480
  resultSourceMap?: never
@@ -928,6 +940,7 @@ export interface ListenOptions {
928
940
  /** @public */
929
941
  export interface ResponseQueryOptions extends RequestOptions {
930
942
  perspective?: ClientPerspective
943
+ bundlePerspective?: string
931
944
  resultSourceMap?: boolean | 'withKeyArraySelector'
932
945
  returnQuery?: boolean
933
946
  useCdn?: boolean