@sanity/client 3.3.1 → 3.3.3
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 +11 -11
- package/sanityClient.d.ts +86 -4
- package/test/listen.test.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.3",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"main": "lib/sanityClient.js",
|
|
6
6
|
"umd": "umd/sanityClient.min.js",
|
|
@@ -28,28 +28,28 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@sanity/eventsource": "^4.0.0",
|
|
30
30
|
"@sanity/generate-help-url": "^3.0.0",
|
|
31
|
-
"get-it": "^6.
|
|
31
|
+
"get-it": "^6.1.1",
|
|
32
32
|
"make-error": "^1.3.0",
|
|
33
33
|
"object-assign": "^4.1.1",
|
|
34
34
|
"rxjs": "^6.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@babel/cli": "^7.
|
|
38
|
-
"@babel/core": "^7.
|
|
39
|
-
"@babel/preset-env": "^7.
|
|
37
|
+
"@babel/cli": "^7.18.10",
|
|
38
|
+
"@babel/core": "^7.18.10",
|
|
39
|
+
"@babel/preset-env": "^7.18.10",
|
|
40
40
|
"browserify": "^17.0.0",
|
|
41
41
|
"envify": "^4.0.0",
|
|
42
|
-
"eslint": "^8.
|
|
42
|
+
"eslint": "^8.21.0",
|
|
43
43
|
"eslint-config-prettier": "^8.5.0",
|
|
44
|
-
"eslint-config-sanity": "^
|
|
45
|
-
"nock": "^13.2.
|
|
44
|
+
"eslint-config-sanity": "^6.0.0",
|
|
45
|
+
"nock": "^13.2.9",
|
|
46
46
|
"nyc": "^15.1.0",
|
|
47
|
-
"prettier": "^2.
|
|
47
|
+
"prettier": "^2.7.1",
|
|
48
48
|
"rimraf": "^3.0.2",
|
|
49
49
|
"sse-channel": "^4.0.0",
|
|
50
|
-
"tape": "^5.5.
|
|
50
|
+
"tape": "^5.5.3",
|
|
51
51
|
"terser": "^5.12.1",
|
|
52
|
-
"uglifyify": "^5.0.
|
|
52
|
+
"uglifyify": "^5.0.0",
|
|
53
53
|
"xtend": "4.0.2"
|
|
54
54
|
},
|
|
55
55
|
"repository": {
|
package/sanityClient.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type AssetMetadataType =
|
|
|
12
12
|
export type DatasetAclMode = 'public' | 'private' | 'custom'
|
|
13
13
|
export type ListenVisibility = 'sync' | 'async' | 'query'
|
|
14
14
|
export type ListenEventName = 'mutation' | 'welcome' | 'reconnect'
|
|
15
|
+
export type MutationOperation = 'create' | 'delete' | 'update' | 'none'
|
|
15
16
|
|
|
16
17
|
export interface ResponseEvent<T = unknown> {
|
|
17
18
|
type: 'response'
|
|
@@ -214,13 +215,13 @@ export type Mutation<R = any> =
|
|
|
214
215
|
export interface SingleMutationResult {
|
|
215
216
|
transactionId: string
|
|
216
217
|
documentId: string
|
|
217
|
-
results: {id: string}[]
|
|
218
|
+
results: {id: string; operation: MutationOperation}[]
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
export interface MultipleMutationResult {
|
|
221
222
|
transactionId: string
|
|
222
223
|
documentIds: string[]
|
|
223
|
-
results: {id: string}[]
|
|
224
|
+
results: {id: string; operation: MutationOperation}[]
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
export class Patch {
|
|
@@ -379,6 +380,48 @@ export class Patch {
|
|
|
379
380
|
reset(): this
|
|
380
381
|
}
|
|
381
382
|
|
|
383
|
+
export class ObservablePatch extends Patch {
|
|
384
|
+
/**
|
|
385
|
+
* Clones the patch
|
|
386
|
+
*/
|
|
387
|
+
clone(): ObservablePatch
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Commit the patch, returning an observable that produces the first patched document
|
|
391
|
+
*
|
|
392
|
+
* @param options Options for the mutation operation
|
|
393
|
+
*/
|
|
394
|
+
commit<R = any>(options: FirstDocumentMutationOptions): Observable<SanityDocument<R>>
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Commit the patch, returning an observable that produces an array of the mutated documents
|
|
398
|
+
*
|
|
399
|
+
* @param options Options for the mutation operation
|
|
400
|
+
*/
|
|
401
|
+
commit<R = any>(options: AllDocumentsMutationOptions): Observable<SanityDocument<R>[]>
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Commit the patch, returning an observable that produces a mutation result object
|
|
405
|
+
*
|
|
406
|
+
* @param options Options for the mutation operation
|
|
407
|
+
*/
|
|
408
|
+
commit(options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Commit the patch, returning an observable that produces a mutation result object
|
|
412
|
+
*
|
|
413
|
+
* @param options Options for the mutation operation
|
|
414
|
+
*/
|
|
415
|
+
commit(options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Commit the patch, returning an observable that produces the first patched document
|
|
419
|
+
*
|
|
420
|
+
* @param options Options for the mutation operation
|
|
421
|
+
*/
|
|
422
|
+
commit<R = any>(options?: BaseMutationOptions): Observable<SanityDocument<R>>
|
|
423
|
+
}
|
|
424
|
+
|
|
382
425
|
export class Transaction {
|
|
383
426
|
constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string)
|
|
384
427
|
clone(): Transaction
|
|
@@ -492,6 +535,45 @@ export class Transaction {
|
|
|
492
535
|
reset(): this
|
|
493
536
|
}
|
|
494
537
|
|
|
538
|
+
export class ObservableTransaction extends Transaction {
|
|
539
|
+
clone(): ObservableTransaction
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Commit the transaction, returning an observable that produces the first mutated document
|
|
543
|
+
*
|
|
544
|
+
* @param options Options for the mutation operation
|
|
545
|
+
*/
|
|
546
|
+
commit<R>(options: TransactionFirstDocumentMutationOptions): Observable<SanityDocument<R>>
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Commit the transaction, returning an observable that produces an array of the mutated documents
|
|
550
|
+
*
|
|
551
|
+
* @param options Options for the mutation operation
|
|
552
|
+
*/
|
|
553
|
+
commit<R>(options: TransactionAllDocumentsMutationOptions): Observable<SanityDocument<R>[]>
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
557
|
+
*
|
|
558
|
+
* @param options Options for the mutation operation
|
|
559
|
+
*/
|
|
560
|
+
commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
564
|
+
*
|
|
565
|
+
* @param options Options for the mutation operation
|
|
566
|
+
*/
|
|
567
|
+
commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
571
|
+
*
|
|
572
|
+
* @param options Options for the mutation operation
|
|
573
|
+
*/
|
|
574
|
+
commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
|
|
575
|
+
}
|
|
576
|
+
|
|
495
577
|
export interface ClientConfig {
|
|
496
578
|
projectId?: string
|
|
497
579
|
dataset?: string
|
|
@@ -1384,14 +1466,14 @@ export class ObservableSanityClient {
|
|
|
1384
1466
|
* @param documentId Document ID to patch
|
|
1385
1467
|
* @param operations Optional object of patch operations to initialize the patch instance with
|
|
1386
1468
|
*/
|
|
1387
|
-
patch(documentId: string | MutationSelection, operations?: PatchOperations):
|
|
1469
|
+
patch(documentId: string | MutationSelection, operations?: PatchOperations): ObservablePatch
|
|
1388
1470
|
|
|
1389
1471
|
/**
|
|
1390
1472
|
* Create a new transaction of mutations
|
|
1391
1473
|
*
|
|
1392
1474
|
* @param operations Optional array of mutation operations to initialize the transaction instance with
|
|
1393
1475
|
*/
|
|
1394
|
-
transaction<R = any>(operations?: Mutation<R>[]):
|
|
1476
|
+
transaction<R = any>(operations?: Mutation<R>[]): ObservableTransaction
|
|
1395
1477
|
|
|
1396
1478
|
// "Internals", should generally not be used externally
|
|
1397
1479
|
/**
|
package/test/listen.test.js
CHANGED