@sanity/client 6.11.3 → 6.11.4-canary.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.
- package/README.md +4 -4
- package/dist/_chunks/{browserMiddleware-1MULg59S.cjs → browserMiddleware-EnEpy_gt.cjs} +247 -299
- package/dist/_chunks/browserMiddleware-EnEpy_gt.cjs.map +1 -0
- package/dist/_chunks/{browserMiddleware-heyg-fDk.js → browserMiddleware-nSeu_Rmf.js} +246 -299
- package/dist/_chunks/browserMiddleware-nSeu_Rmf.js.map +1 -0
- package/dist/_chunks/{nodeMiddleware-CHxg1-zH.cjs → nodeMiddleware-_hIIS1d7.cjs} +248 -300
- package/dist/_chunks/nodeMiddleware-_hIIS1d7.cjs.map +1 -0
- package/dist/_chunks/{nodeMiddleware-u_fUUnxa.js → nodeMiddleware-hZIb_1T_.js} +247 -300
- package/dist/_chunks/nodeMiddleware-hZIb_1T_.js.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-4w5UCEGT.cjs +479 -0
- package/dist/_chunks/stegaEncodeSourceMap-4w5UCEGT.cjs.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-SOgem38i.js +475 -0
- package/dist/_chunks/stegaEncodeSourceMap-SOgem38i.js.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-Tuf6zjiN.cjs +230 -0
- package/dist/_chunks/stegaEncodeSourceMap-Tuf6zjiN.cjs.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-zvyGxB_C.js +226 -0
- package/dist/_chunks/stegaEncodeSourceMap-zvyGxB_C.js.map +1 -0
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +319 -49
- package/dist/index.js +2 -2
- package/dist/stega.browser.cjs +12 -695
- package/dist/stega.browser.cjs.map +1 -1
- package/dist/stega.browser.js +7 -690
- package/dist/stega.browser.js.map +1 -1
- package/dist/stega.cjs +12 -446
- package/dist/stega.cjs.js +3 -3
- package/dist/stega.cjs.map +1 -1
- package/dist/stega.d.ts +1418 -1422
- package/dist/stega.js +7 -441
- package/dist/stega.js.map +1 -1
- package/package.json +11 -9
- package/src/SanityClient.ts +152 -75
- package/src/assets/AssetsClient.ts +19 -10
- package/src/config.ts +34 -12
- package/src/data/dataMethods.ts +40 -14
- package/src/data/patch.ts +12 -10
- package/src/data/transaction.ts +13 -12
- package/src/datasets/DatasetsClient.ts +36 -16
- package/src/projects/ProjectsClient.ts +21 -12
- package/src/stega/index.browser.ts +3 -7
- package/src/stega/index.ts +3 -7
- package/src/stega/shared.ts +7 -5
- package/src/stega/types.ts +11 -18
- package/src/types.ts +107 -5
- package/src/users/UsersClient.ts +20 -13
- package/umd/sanityClient.js +3148 -2235
- package/umd/sanityClient.min.js +4 -3
- package/dist/_chunks/browserMiddleware-1MULg59S.cjs.map +0 -1
- package/dist/_chunks/browserMiddleware-heyg-fDk.js.map +0 -1
- package/dist/_chunks/nodeMiddleware-CHxg1-zH.cjs.map +0 -1
- package/dist/_chunks/nodeMiddleware-u_fUUnxa.js.map +0 -1
- package/src/stega/SanityStegaClient.ts +0 -298
- package/src/stega/config.ts +0 -76
package/src/data/dataMethods.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {type MonoTypeOperatorFunction, Observable} from 'rxjs'
|
|
2
|
-
import {filter, map} from 'rxjs/operators'
|
|
1
|
+
import {from, type MonoTypeOperatorFunction, Observable} from 'rxjs'
|
|
2
|
+
import {combineLatestWith, filter, map} from 'rxjs/operators'
|
|
3
3
|
|
|
4
4
|
import {validateApiPerspective} from '../config'
|
|
5
5
|
import {requestOptions} from '../http/requestOptions'
|
|
6
6
|
import type {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
7
|
+
import {vercelStegaCleanAll} from '../stega/vercelStegaCleanAll'
|
|
7
8
|
import type {
|
|
8
9
|
AllDocumentIdsMutationOptions,
|
|
9
10
|
AllDocumentsMutationOptions,
|
|
10
11
|
Any,
|
|
11
12
|
BaseMutationOptions,
|
|
12
|
-
FilteredResponseQueryOptions,
|
|
13
13
|
FirstDocumentIdMutationOptions,
|
|
14
14
|
FirstDocumentMutationOptions,
|
|
15
15
|
HttpRequest,
|
|
16
16
|
HttpRequestEvent,
|
|
17
17
|
IdentifiedSanityDocumentStub,
|
|
18
|
+
InitializedStegaConfig,
|
|
18
19
|
MultipleMutationResult,
|
|
19
20
|
Mutation,
|
|
20
21
|
MutationSelection,
|
|
21
|
-
|
|
22
|
+
QueryOptions,
|
|
22
23
|
RawQueryResponse,
|
|
23
24
|
RequestObservableOptions,
|
|
24
25
|
RequestOptions,
|
|
25
26
|
SanityDocument,
|
|
26
27
|
SingleMutationResult,
|
|
27
|
-
UnfilteredResponseQueryOptions,
|
|
28
28
|
} from '../types'
|
|
29
29
|
import {getSelection} from '../util/getSelection'
|
|
30
30
|
import * as validate from '../validators'
|
|
@@ -62,24 +62,30 @@ const indexBy = (docs: Any[], attr: Any) =>
|
|
|
62
62
|
const getQuerySizeLimit = 11264
|
|
63
63
|
|
|
64
64
|
/** @internal */
|
|
65
|
-
export function _fetch<R, Q
|
|
65
|
+
export function _fetch<R, Q>(
|
|
66
66
|
client: ObservableSanityClient | SanityClient,
|
|
67
67
|
httpRequest: HttpRequest,
|
|
68
|
+
_stega: InitializedStegaConfig,
|
|
68
69
|
query: string,
|
|
69
|
-
|
|
70
|
-
options:
|
|
70
|
+
_params: Q = {} as Q,
|
|
71
|
+
options: QueryOptions = {},
|
|
71
72
|
): Observable<RawQueryResponse<R> | R> {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
const stega =
|
|
74
|
+
'stega' in options
|
|
75
|
+
? {
|
|
76
|
+
...(_stega || {}),
|
|
77
|
+
...(typeof options.stega === 'boolean' ? {enabled: options.stega} : options.stega || {}),
|
|
78
|
+
}
|
|
79
|
+
: _stega
|
|
80
|
+
const params = stega.enabled ? vercelStegaCleanAll(_params) : _params
|
|
77
81
|
const mapResponse =
|
|
78
82
|
options.filterResponse === false ? (res: Any) => res : (res: Any) => res.result
|
|
79
83
|
const {cache, next, ...opts} = {
|
|
80
84
|
// Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
|
|
81
85
|
// This is necessary in React Server Components to avoid opting out of Request Memoization.
|
|
82
86
|
useAbortSignal: typeof options.signal !== 'undefined',
|
|
87
|
+
// Set `resultSourceMap' when stega is enabled, as it's required for encoding.
|
|
88
|
+
resultSourceMap: stega.enabled ? 'withKeyArraySelector' : options.resultSourceMap,
|
|
83
89
|
...options,
|
|
84
90
|
}
|
|
85
91
|
const reqOpts =
|
|
@@ -87,7 +93,27 @@ export function _fetch<R, Q extends QueryParams>(
|
|
|
87
93
|
? {...opts, fetch: {cache, next}}
|
|
88
94
|
: opts
|
|
89
95
|
|
|
90
|
-
|
|
96
|
+
const $request = _dataRequest(client, httpRequest, 'query', {query, params}, reqOpts)
|
|
97
|
+
return stega.enabled
|
|
98
|
+
? $request.pipe(
|
|
99
|
+
combineLatestWith(
|
|
100
|
+
from(
|
|
101
|
+
import('../stega/stegaEncodeSourceMap').then(
|
|
102
|
+
({stegaEncodeSourceMap}) => stegaEncodeSourceMap,
|
|
103
|
+
),
|
|
104
|
+
),
|
|
105
|
+
),
|
|
106
|
+
map(
|
|
107
|
+
([res, stegaEncodeSourceMap]: [
|
|
108
|
+
Any,
|
|
109
|
+
(typeof import('../stega/stegaEncodeSourceMap'))['stegaEncodeSourceMap'],
|
|
110
|
+
]) => {
|
|
111
|
+
const result = stegaEncodeSourceMap(res.result, res.resultSourceMap, stega)
|
|
112
|
+
return mapResponse({...res, result})
|
|
113
|
+
},
|
|
114
|
+
),
|
|
115
|
+
)
|
|
116
|
+
: $request.pipe(map(mapResponse))
|
|
91
117
|
}
|
|
92
118
|
|
|
93
119
|
/** @internal */
|
package/src/data/patch.ts
CHANGED
|
@@ -19,6 +19,8 @@ import type {
|
|
|
19
19
|
import {getSelection} from '../util/getSelection'
|
|
20
20
|
import {validateInsert, validateObject} from '../validators'
|
|
21
21
|
|
|
22
|
+
const clientSymbol = Symbol('#client')
|
|
23
|
+
|
|
22
24
|
/** @internal */
|
|
23
25
|
export class BasePatch {
|
|
24
26
|
protected selection: PatchSelection
|
|
@@ -193,7 +195,7 @@ export class BasePatch {
|
|
|
193
195
|
|
|
194
196
|
/** @public */
|
|
195
197
|
export class ObservablePatch extends BasePatch {
|
|
196
|
-
|
|
198
|
+
private [clientSymbol]?: ObservableSanityClient
|
|
197
199
|
|
|
198
200
|
constructor(
|
|
199
201
|
selection: PatchSelection,
|
|
@@ -201,14 +203,14 @@ export class ObservablePatch extends BasePatch {
|
|
|
201
203
|
client?: ObservableSanityClient,
|
|
202
204
|
) {
|
|
203
205
|
super(selection, operations)
|
|
204
|
-
this
|
|
206
|
+
this[clientSymbol] = client
|
|
205
207
|
}
|
|
206
208
|
|
|
207
209
|
/**
|
|
208
210
|
* Clones the patch
|
|
209
211
|
*/
|
|
210
212
|
clone(): ObservablePatch {
|
|
211
|
-
return new ObservablePatch(this.selection, {...this.operations}, this
|
|
213
|
+
return new ObservablePatch(this.selection, {...this.operations}, this[clientSymbol])
|
|
212
214
|
}
|
|
213
215
|
|
|
214
216
|
/**
|
|
@@ -257,7 +259,7 @@ export class ObservablePatch extends BasePatch {
|
|
|
257
259
|
): Observable<
|
|
258
260
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
259
261
|
> {
|
|
260
|
-
if (!this
|
|
262
|
+
if (!this[clientSymbol]) {
|
|
261
263
|
throw new Error(
|
|
262
264
|
'No `client` passed to patch, either provide one or pass the ' +
|
|
263
265
|
'patch to a clients `mutate()` method',
|
|
@@ -266,23 +268,23 @@ export class ObservablePatch extends BasePatch {
|
|
|
266
268
|
|
|
267
269
|
const returnFirst = typeof this.selection === 'string'
|
|
268
270
|
const opts = Object.assign({returnFirst, returnDocuments: true}, options)
|
|
269
|
-
return this
|
|
271
|
+
return this[clientSymbol].mutate<R>({patch: this.serialize()} as Any, opts)
|
|
270
272
|
}
|
|
271
273
|
}
|
|
272
274
|
|
|
273
275
|
/** @public */
|
|
274
276
|
export class Patch extends BasePatch {
|
|
275
|
-
|
|
277
|
+
private [clientSymbol]?: SanityClient
|
|
276
278
|
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient) {
|
|
277
279
|
super(selection, operations)
|
|
278
|
-
this
|
|
280
|
+
this[clientSymbol] = client
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
/**
|
|
282
284
|
* Clones the patch
|
|
283
285
|
*/
|
|
284
286
|
clone(): Patch {
|
|
285
|
-
return new Patch(this.selection, {...this.operations}, this
|
|
287
|
+
return new Patch(this.selection, {...this.operations}, this[clientSymbol])
|
|
286
288
|
}
|
|
287
289
|
|
|
288
290
|
/**
|
|
@@ -331,7 +333,7 @@ export class Patch extends BasePatch {
|
|
|
331
333
|
): Promise<
|
|
332
334
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
333
335
|
> {
|
|
334
|
-
if (!this
|
|
336
|
+
if (!this[clientSymbol]) {
|
|
335
337
|
throw new Error(
|
|
336
338
|
'No `client` passed to patch, either provide one or pass the ' +
|
|
337
339
|
'patch to a clients `mutate()` method',
|
|
@@ -340,6 +342,6 @@ export class Patch extends BasePatch {
|
|
|
340
342
|
|
|
341
343
|
const returnFirst = typeof this.selection === 'string'
|
|
342
344
|
const opts = Object.assign({returnFirst, returnDocuments: true}, options)
|
|
343
|
-
return this
|
|
345
|
+
return this[clientSymbol].mutate<R>({patch: this.serialize()} as Any, opts)
|
|
344
346
|
}
|
|
345
347
|
}
|
package/src/data/transaction.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type PatchBuilder = (patch: Patch) => Patch
|
|
|
25
25
|
export type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch
|
|
26
26
|
|
|
27
27
|
const defaultMutateOptions = {returnDocuments: false}
|
|
28
|
+
const clientSymbol = Symbol('#client')
|
|
28
29
|
|
|
29
30
|
/** @internal */
|
|
30
31
|
export class BaseTransaction {
|
|
@@ -135,17 +136,17 @@ export class BaseTransaction {
|
|
|
135
136
|
|
|
136
137
|
/** @public */
|
|
137
138
|
export class Transaction extends BaseTransaction {
|
|
138
|
-
|
|
139
|
+
private [clientSymbol]?: SanityClient
|
|
139
140
|
constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string) {
|
|
140
141
|
super(operations, transactionId)
|
|
141
|
-
this
|
|
142
|
+
this[clientSymbol] = client
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
/**
|
|
145
146
|
* Clones the transaction
|
|
146
147
|
*/
|
|
147
148
|
clone(): Transaction {
|
|
148
|
-
return new Transaction([...this.operations], this
|
|
149
|
+
return new Transaction([...this.operations], this[clientSymbol], this.trxId)
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
/**
|
|
@@ -192,14 +193,14 @@ export class Transaction extends BaseTransaction {
|
|
|
192
193
|
): Promise<
|
|
193
194
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
194
195
|
> {
|
|
195
|
-
if (!this
|
|
196
|
+
if (!this[clientSymbol]) {
|
|
196
197
|
throw new Error(
|
|
197
198
|
'No `client` passed to transaction, either provide one or pass the ' +
|
|
198
199
|
'transaction to a clients `mutate()` method',
|
|
199
200
|
)
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
return this
|
|
203
|
+
return this[clientSymbol].mutate<R>(
|
|
203
204
|
this.serialize() as Any,
|
|
204
205
|
Object.assign({transactionId: this.trxId}, defaultMutateOptions, options || {}),
|
|
205
206
|
)
|
|
@@ -231,7 +232,7 @@ export class Transaction extends BaseTransaction {
|
|
|
231
232
|
|
|
232
233
|
// patch => patch.inc({visits: 1}).set({foo: 'bar'})
|
|
233
234
|
if (isBuilder) {
|
|
234
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, this
|
|
235
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, this[clientSymbol]))
|
|
235
236
|
if (!(patch instanceof Patch)) {
|
|
236
237
|
throw new Error('function passed to `patch()` must return the patch')
|
|
237
238
|
}
|
|
@@ -245,17 +246,17 @@ export class Transaction extends BaseTransaction {
|
|
|
245
246
|
|
|
246
247
|
/** @public */
|
|
247
248
|
export class ObservableTransaction extends BaseTransaction {
|
|
248
|
-
|
|
249
|
+
private [clientSymbol]?: ObservableSanityClient
|
|
249
250
|
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string) {
|
|
250
251
|
super(operations, transactionId)
|
|
251
|
-
this
|
|
252
|
+
this[clientSymbol] = client
|
|
252
253
|
}
|
|
253
254
|
|
|
254
255
|
/**
|
|
255
256
|
* Clones the transaction
|
|
256
257
|
*/
|
|
257
258
|
clone(): ObservableTransaction {
|
|
258
|
-
return new ObservableTransaction([...this.operations], this
|
|
259
|
+
return new ObservableTransaction([...this.operations], this[clientSymbol], this.trxId)
|
|
259
260
|
}
|
|
260
261
|
|
|
261
262
|
/**
|
|
@@ -302,14 +303,14 @@ export class ObservableTransaction extends BaseTransaction {
|
|
|
302
303
|
): Observable<
|
|
303
304
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
304
305
|
> {
|
|
305
|
-
if (!this
|
|
306
|
+
if (!this[clientSymbol]) {
|
|
306
307
|
throw new Error(
|
|
307
308
|
'No `client` passed to transaction, either provide one or pass the ' +
|
|
308
309
|
'transaction to a clients `mutate()` method',
|
|
309
310
|
)
|
|
310
311
|
}
|
|
311
312
|
|
|
312
|
-
return this
|
|
313
|
+
return this[clientSymbol].mutate<R>(
|
|
313
314
|
this.serialize() as Any,
|
|
314
315
|
Object.assign({transactionId: this.trxId}, defaultMutateOptions, options || {}),
|
|
315
316
|
)
|
|
@@ -345,7 +346,7 @@ export class ObservableTransaction extends BaseTransaction {
|
|
|
345
346
|
|
|
346
347
|
// patch => patch.inc({visits: 1}).set({foo: 'bar'})
|
|
347
348
|
if (isBuilder) {
|
|
348
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this
|
|
349
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this[clientSymbol]))
|
|
349
350
|
if (!(patch instanceof ObservablePatch)) {
|
|
350
351
|
throw new Error('function passed to `patch()` must return the patch')
|
|
351
352
|
}
|
|
@@ -5,13 +5,16 @@ import type {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
|
5
5
|
import type {DatasetAclMode, DatasetResponse, DatasetsResponse, HttpRequest} from '../types'
|
|
6
6
|
import * as validate from '../validators'
|
|
7
7
|
|
|
8
|
+
const clientSymbol = Symbol('#client')
|
|
9
|
+
const httpRequestSymbol = Symbol('#httpRequest')
|
|
10
|
+
|
|
8
11
|
/** @internal */
|
|
9
12
|
export class ObservableDatasetsClient {
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
private [clientSymbol]: ObservableSanityClient
|
|
14
|
+
private [httpRequestSymbol]: HttpRequest
|
|
12
15
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest) {
|
|
13
|
-
this
|
|
14
|
-
this
|
|
16
|
+
this[clientSymbol] = client
|
|
17
|
+
this[httpRequestSymbol] = httpRequest
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
/**
|
|
@@ -21,7 +24,13 @@ export class ObservableDatasetsClient {
|
|
|
21
24
|
* @param options - Options for the dataset
|
|
22
25
|
*/
|
|
23
26
|
create(name: string, options?: {aclMode?: DatasetAclMode}): Observable<DatasetResponse> {
|
|
24
|
-
return _modify<DatasetResponse>(
|
|
27
|
+
return _modify<DatasetResponse>(
|
|
28
|
+
this[clientSymbol],
|
|
29
|
+
this[httpRequestSymbol],
|
|
30
|
+
'PUT',
|
|
31
|
+
name,
|
|
32
|
+
options,
|
|
33
|
+
)
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
/**
|
|
@@ -31,7 +40,13 @@ export class ObservableDatasetsClient {
|
|
|
31
40
|
* @param options - New options for the dataset
|
|
32
41
|
*/
|
|
33
42
|
edit(name: string, options?: {aclMode?: DatasetAclMode}): Observable<DatasetResponse> {
|
|
34
|
-
return _modify<DatasetResponse>(
|
|
43
|
+
return _modify<DatasetResponse>(
|
|
44
|
+
this[clientSymbol],
|
|
45
|
+
this[httpRequestSymbol],
|
|
46
|
+
'PATCH',
|
|
47
|
+
name,
|
|
48
|
+
options,
|
|
49
|
+
)
|
|
35
50
|
}
|
|
36
51
|
|
|
37
52
|
/**
|
|
@@ -40,14 +55,14 @@ export class ObservableDatasetsClient {
|
|
|
40
55
|
* @param name - Name of the dataset to delete
|
|
41
56
|
*/
|
|
42
57
|
delete(name: string): Observable<{deleted: true}> {
|
|
43
|
-
return _modify<{deleted: true}>(this
|
|
58
|
+
return _modify<{deleted: true}>(this[clientSymbol], this[httpRequestSymbol], 'DELETE', name)
|
|
44
59
|
}
|
|
45
60
|
|
|
46
61
|
/**
|
|
47
62
|
* Fetch a list of datasets for the configured project
|
|
48
63
|
*/
|
|
49
64
|
list(): Observable<DatasetsResponse> {
|
|
50
|
-
return _request<DatasetsResponse>(this
|
|
65
|
+
return _request<DatasetsResponse>(this[clientSymbol], this[httpRequestSymbol], {
|
|
51
66
|
uri: '/datasets',
|
|
52
67
|
tag: null,
|
|
53
68
|
})
|
|
@@ -56,11 +71,11 @@ export class ObservableDatasetsClient {
|
|
|
56
71
|
|
|
57
72
|
/** @internal */
|
|
58
73
|
export class DatasetsClient {
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
private [clientSymbol]: SanityClient
|
|
75
|
+
private [httpRequestSymbol]: HttpRequest
|
|
61
76
|
constructor(client: SanityClient, httpRequest: HttpRequest) {
|
|
62
|
-
this
|
|
63
|
-
this
|
|
77
|
+
this[clientSymbol] = client
|
|
78
|
+
this[httpRequestSymbol] = httpRequest
|
|
64
79
|
}
|
|
65
80
|
|
|
66
81
|
/**
|
|
@@ -71,7 +86,7 @@ export class DatasetsClient {
|
|
|
71
86
|
*/
|
|
72
87
|
create(name: string, options?: {aclMode?: DatasetAclMode}): Promise<DatasetResponse> {
|
|
73
88
|
return lastValueFrom(
|
|
74
|
-
_modify<DatasetResponse>(this
|
|
89
|
+
_modify<DatasetResponse>(this[clientSymbol], this[httpRequestSymbol], 'PUT', name, options),
|
|
75
90
|
)
|
|
76
91
|
}
|
|
77
92
|
|
|
@@ -83,7 +98,7 @@ export class DatasetsClient {
|
|
|
83
98
|
*/
|
|
84
99
|
edit(name: string, options?: {aclMode?: DatasetAclMode}): Promise<DatasetResponse> {
|
|
85
100
|
return lastValueFrom(
|
|
86
|
-
_modify<DatasetResponse>(this
|
|
101
|
+
_modify<DatasetResponse>(this[clientSymbol], this[httpRequestSymbol], 'PATCH', name, options),
|
|
87
102
|
)
|
|
88
103
|
}
|
|
89
104
|
|
|
@@ -93,7 +108,9 @@ export class DatasetsClient {
|
|
|
93
108
|
* @param name - Name of the dataset to delete
|
|
94
109
|
*/
|
|
95
110
|
delete(name: string): Promise<{deleted: true}> {
|
|
96
|
-
return lastValueFrom(
|
|
111
|
+
return lastValueFrom(
|
|
112
|
+
_modify<{deleted: true}>(this[clientSymbol], this[httpRequestSymbol], 'DELETE', name),
|
|
113
|
+
)
|
|
97
114
|
}
|
|
98
115
|
|
|
99
116
|
/**
|
|
@@ -101,7 +118,10 @@ export class DatasetsClient {
|
|
|
101
118
|
*/
|
|
102
119
|
list(): Promise<DatasetsResponse> {
|
|
103
120
|
return lastValueFrom(
|
|
104
|
-
_request<DatasetsResponse>(this
|
|
121
|
+
_request<DatasetsResponse>(this[clientSymbol], this[httpRequestSymbol], {
|
|
122
|
+
uri: '/datasets',
|
|
123
|
+
tag: null,
|
|
124
|
+
}),
|
|
105
125
|
)
|
|
106
126
|
}
|
|
107
127
|
}
|
|
@@ -4,13 +4,16 @@ import {_request} from '../data/dataMethods'
|
|
|
4
4
|
import type {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
5
5
|
import type {HttpRequest, SanityProject} from '../types'
|
|
6
6
|
|
|
7
|
+
const clientSymbol = Symbol('#client')
|
|
8
|
+
const httpRequestSymbol = Symbol('#httpRequest')
|
|
9
|
+
|
|
7
10
|
/** @internal */
|
|
8
11
|
export class ObservableProjectsClient {
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
private [clientSymbol]: ObservableSanityClient
|
|
13
|
+
private [httpRequestSymbol]: HttpRequest
|
|
11
14
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest) {
|
|
12
|
-
this
|
|
13
|
-
this
|
|
15
|
+
this[clientSymbol] = client
|
|
16
|
+
this[httpRequestSymbol] = httpRequest
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -25,7 +28,7 @@ export class ObservableProjectsClient {
|
|
|
25
28
|
includeMembers?: boolean
|
|
26
29
|
}): Observable<SanityProject[] | Omit<SanityProject, 'members'>[]> {
|
|
27
30
|
const uri = options?.includeMembers === false ? '/projects?includeMembers=false' : '/projects'
|
|
28
|
-
return _request<SanityProject[]>(this
|
|
31
|
+
return _request<SanityProject[]>(this[clientSymbol], this[httpRequestSymbol], {uri})
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
/**
|
|
@@ -34,17 +37,19 @@ export class ObservableProjectsClient {
|
|
|
34
37
|
* @param projectId - ID of the project to fetch
|
|
35
38
|
*/
|
|
36
39
|
getById(projectId: string): Observable<SanityProject> {
|
|
37
|
-
return _request<SanityProject>(this
|
|
40
|
+
return _request<SanityProject>(this[clientSymbol], this[httpRequestSymbol], {
|
|
41
|
+
uri: `/projects/${projectId}`,
|
|
42
|
+
})
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
/** @internal */
|
|
42
47
|
export class ProjectsClient {
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
private [clientSymbol]: SanityClient
|
|
49
|
+
private [httpRequestSymbol]: HttpRequest
|
|
45
50
|
constructor(client: SanityClient, httpRequest: HttpRequest) {
|
|
46
|
-
this
|
|
47
|
-
this
|
|
51
|
+
this[clientSymbol] = client
|
|
52
|
+
this[httpRequestSymbol] = httpRequest
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
/**
|
|
@@ -57,7 +62,9 @@ export class ProjectsClient {
|
|
|
57
62
|
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
58
63
|
list(options?: {includeMembers?: boolean}): Promise<SanityProject[]> {
|
|
59
64
|
const uri = options?.includeMembers === false ? '/projects?includeMembers=false' : '/projects'
|
|
60
|
-
return lastValueFrom(
|
|
65
|
+
return lastValueFrom(
|
|
66
|
+
_request<SanityProject[]>(this[clientSymbol], this[httpRequestSymbol], {uri}),
|
|
67
|
+
)
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
/**
|
|
@@ -67,7 +74,9 @@ export class ProjectsClient {
|
|
|
67
74
|
*/
|
|
68
75
|
getById(projectId: string): Promise<SanityProject> {
|
|
69
76
|
return lastValueFrom(
|
|
70
|
-
_request<SanityProject>(this
|
|
77
|
+
_request<SanityProject>(this[clientSymbol], this[httpRequestSymbol], {
|
|
78
|
+
uri: `/projects/${projectId}`,
|
|
79
|
+
}),
|
|
71
80
|
)
|
|
72
81
|
}
|
|
73
82
|
}
|
|
@@ -2,15 +2,11 @@ export * from '../defineCreateClient'
|
|
|
2
2
|
|
|
3
3
|
import defineCreateClientExports from '../defineCreateClient'
|
|
4
4
|
import envMiddleware from '../http/browserMiddleware'
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
5
|
+
import {SanityClient} from '../SanityClient'
|
|
6
|
+
import type {ClientConfig} from './types'
|
|
7
7
|
|
|
8
|
-
const exp = defineCreateClientExports<
|
|
9
|
-
envMiddleware,
|
|
10
|
-
SanityStegaClient,
|
|
11
|
-
)
|
|
8
|
+
const exp = defineCreateClientExports<SanityClient, ClientConfig>(envMiddleware, SanityClient)
|
|
12
9
|
|
|
13
|
-
export type {ObservableSanityClient, SanityClient} from './shared'
|
|
14
10
|
export * from './shared'
|
|
15
11
|
|
|
16
12
|
/** @public */
|
package/src/stega/index.ts
CHANGED
|
@@ -2,15 +2,11 @@ export * from '../defineCreateClient'
|
|
|
2
2
|
|
|
3
3
|
import defineCreateClientExports from '../defineCreateClient'
|
|
4
4
|
import envMiddleware from '../http/nodeMiddleware'
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
5
|
+
import {SanityClient} from '../SanityClient'
|
|
6
|
+
import type {ClientConfig} from './types'
|
|
7
7
|
|
|
8
|
-
const exp = defineCreateClientExports<
|
|
9
|
-
envMiddleware,
|
|
10
|
-
SanityStegaClient,
|
|
11
|
-
)
|
|
8
|
+
const exp = defineCreateClientExports<SanityClient, ClientConfig>(envMiddleware, SanityClient)
|
|
12
9
|
|
|
13
|
-
export type {ObservableSanityClient, SanityClient} from './shared'
|
|
14
10
|
export * from './shared'
|
|
15
11
|
|
|
16
12
|
/** @public */
|
package/src/stega/shared.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
2
|
+
|
|
3
|
+
export * from '../SanityClient'
|
|
1
4
|
export {encodeIntoResult} from './encodeIntoResult'
|
|
2
|
-
export * from './SanityStegaClient'
|
|
3
5
|
export {stegaEncodeSourceMap} from './stegaEncodeSourceMap'
|
|
4
6
|
export * from './types'
|
|
5
7
|
export {vercelStegaCleanAll} from './vercelStegaCleanAll'
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
|
-
* @deprecated -- Use `import
|
|
10
|
+
* @deprecated -- Use `import {SanityClient} from '@sanity/client'` instead
|
|
9
11
|
* @public
|
|
10
12
|
*/
|
|
11
|
-
export
|
|
13
|
+
export class SanityStegaClient extends SanityClient {}
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
|
-
* @deprecated -- Use `import
|
|
16
|
+
* @deprecated -- Use `import {ObservableSanityClient} from '@sanity/client'` instead
|
|
15
17
|
* @public
|
|
16
18
|
*/
|
|
17
|
-
export
|
|
19
|
+
export class ObservableSanityStegaClient extends ObservableSanityClient {}
|
package/src/stega/types.ts
CHANGED
|
@@ -53,21 +53,23 @@ export interface StegaConfig {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/** @public */
|
|
56
|
-
export type StegaConfigRequiredKeys = Extract<keyof StegaConfig, 'enabled'
|
|
56
|
+
export type StegaConfigRequiredKeys = Extract<keyof StegaConfig, 'enabled'>
|
|
57
57
|
|
|
58
58
|
/** @public */
|
|
59
59
|
export type InitializedStegaConfig = Omit<StegaConfig, StegaConfigRequiredKeys> &
|
|
60
60
|
Required<Pick<StegaConfig, StegaConfigRequiredKeys>>
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
/**
|
|
63
|
+
* @public
|
|
64
|
+
* @deprecated -- use `ClientConfig` instead
|
|
65
|
+
*/
|
|
66
|
+
export interface ClientStegaConfig extends ClientConfig {}
|
|
66
67
|
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
/**
|
|
69
|
+
* @public
|
|
70
|
+
* @deprecated -- use `InitializedClientConfig` instead
|
|
71
|
+
*/
|
|
72
|
+
export interface InitializedClientStegaConfig extends InitializedClientConfig {}
|
|
71
73
|
|
|
72
74
|
/** @public */
|
|
73
75
|
export type FilterDefault = (props: {
|
|
@@ -134,12 +136,3 @@ export type Encoder = (context: {
|
|
|
134
136
|
resultPath: ContentSourceMapParsedPath
|
|
135
137
|
value: string
|
|
136
138
|
}) => string
|
|
137
|
-
|
|
138
|
-
// Extends the `client.fetch` call with a `stega` option
|
|
139
|
-
declare module '../types' {
|
|
140
|
-
/** @public */
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
142
|
-
export interface ResponseQueryOptions<T = 'next'> extends RequestOptions {
|
|
143
|
-
stega?: boolean | StegaConfig
|
|
144
|
-
}
|
|
145
|
-
}
|