@sanity/client 6.24.2 → 6.24.4
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/dist/csm.d.cts +99 -34
- package/dist/csm.d.ts +99 -34
- package/dist/index.browser.cjs +188 -128
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +112 -4
- package/dist/index.browser.d.ts +112 -4
- package/dist/index.browser.js +189 -129
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +189 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +112 -4
- package/dist/index.d.ts +112 -4
- package/dist/index.js +190 -130
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +3419 -96
- package/dist/stega.browser.d.ts +3419 -96
- package/dist/stega.d.cts +3419 -96
- package/dist/stega.d.ts +3419 -96
- package/package.json +4 -4
- package/src/data/eventsource.ts +255 -0
- package/src/data/eventsourcePolyfill.ts +7 -0
- package/src/data/listen.ts +31 -142
- package/src/data/live.ts +60 -120
- package/src/data/reconnectOnConnectionFailure.ts +30 -0
- package/src/data/transaction.ts +26 -1
- package/src/defineCreateClient.ts +11 -0
- package/src/types.ts +10 -0
- package/umd/sanityClient.js +988 -144
- package/umd/sanityClient.min.js +2 -2
package/dist/csm.d.cts
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {ContentSourceMapDocuments} from '@sanity/client'
|
|
7
|
-
import {ContentSourceMapDocumentValueSource} from '@sanity/client'
|
|
8
|
-
import {ContentSourceMapLiteralSource} from '@sanity/client'
|
|
9
|
-
import {ContentSourceMapMapping} from '@sanity/client'
|
|
10
|
-
import {ContentSourceMapMappings} from '@sanity/client'
|
|
11
|
-
import {ContentSourceMapPaths} from '@sanity/client'
|
|
12
|
-
import {ContentSourceMapRemoteDocument} from '@sanity/client'
|
|
13
|
-
import {ContentSourceMapSource} from '@sanity/client'
|
|
14
|
-
import {ContentSourceMapUnknownSource} from '@sanity/client'
|
|
15
|
-
import {ContentSourceMapValueMapping} from '@sanity/client'
|
|
16
|
-
import {SanityDocument} from '@sanity/client'
|
|
17
|
-
|
|
18
|
-
export {Any}
|
|
1
|
+
/**
|
|
2
|
+
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare type Any = any
|
|
19
6
|
|
|
20
7
|
/**
|
|
21
8
|
* Optimistically applies source documents to a result, using the content source map to trace fields.
|
|
@@ -45,23 +32,62 @@ export declare type ApplySourceDocumentsUpdateFunction = <T = unknown>(
|
|
|
45
32
|
},
|
|
46
33
|
) => T
|
|
47
34
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
/** @public */
|
|
36
|
+
export declare type ClientPerspective =
|
|
37
|
+
| 'previewDrafts'
|
|
38
|
+
| 'published'
|
|
39
|
+
| 'drafts'
|
|
40
|
+
| 'raw'
|
|
41
|
+
| ('published' | 'drafts' | ReleaseId)[]
|
|
42
|
+
|
|
43
|
+
/** @public */
|
|
44
|
+
export declare interface ContentSourceMap {
|
|
45
|
+
mappings: ContentSourceMapMappings
|
|
46
|
+
documents: ContentSourceMapDocuments
|
|
47
|
+
paths: ContentSourceMapPaths
|
|
48
|
+
}
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
/** @public */
|
|
51
|
+
export declare interface ContentSourceMapDocument extends ContentSourceMapDocumentBase {
|
|
52
|
+
_projectId?: undefined
|
|
53
|
+
_dataset?: undefined
|
|
54
|
+
}
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
/** @public */
|
|
57
|
+
export declare interface ContentSourceMapDocumentBase {
|
|
58
|
+
_id: string
|
|
59
|
+
_type: string
|
|
60
|
+
}
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
/** @public */
|
|
63
|
+
export declare type ContentSourceMapDocuments = (
|
|
64
|
+
| ContentSourceMapDocument
|
|
65
|
+
| ContentSourceMapRemoteDocument
|
|
66
|
+
)[]
|
|
57
67
|
|
|
58
|
-
|
|
68
|
+
/**
|
|
69
|
+
* DocumentValueSource is a path to a value within a document
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export declare interface ContentSourceMapDocumentValueSource {
|
|
73
|
+
type: 'documentValue'
|
|
74
|
+
document: number
|
|
75
|
+
path: number
|
|
76
|
+
}
|
|
59
77
|
|
|
60
|
-
|
|
78
|
+
/**
|
|
79
|
+
* When a value is not from a source, its a literal
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export declare interface ContentSourceMapLiteralSource {
|
|
83
|
+
type: 'literal'
|
|
84
|
+
}
|
|
61
85
|
|
|
62
|
-
|
|
86
|
+
/** @public */
|
|
87
|
+
export declare type ContentSourceMapMapping = ContentSourceMapValueMapping
|
|
63
88
|
|
|
64
|
-
|
|
89
|
+
/** @public */
|
|
90
|
+
export declare type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>
|
|
65
91
|
|
|
66
92
|
/** @alpha */
|
|
67
93
|
export declare type ContentSourceMapParsedPath = (
|
|
@@ -82,15 +108,38 @@ export declare type ContentSourceMapParsedPathKeyedSegment = {
|
|
|
82
108
|
*/
|
|
83
109
|
export declare type ContentSourceMapParsedPathSegment = ContentSourceMapParsedPath[number]
|
|
84
110
|
|
|
85
|
-
|
|
111
|
+
/** @public */
|
|
112
|
+
export declare type ContentSourceMapPaths = string[]
|
|
86
113
|
|
|
87
|
-
|
|
114
|
+
/** @public */
|
|
115
|
+
export declare interface ContentSourceMapRemoteDocument extends ContentSourceMapDocumentBase {
|
|
116
|
+
_projectId: string
|
|
117
|
+
_dataset: string
|
|
118
|
+
}
|
|
88
119
|
|
|
89
|
-
|
|
120
|
+
/** @public */
|
|
121
|
+
export declare type ContentSourceMapSource =
|
|
122
|
+
| ContentSourceMapDocumentValueSource
|
|
123
|
+
| ContentSourceMapLiteralSource
|
|
124
|
+
| ContentSourceMapUnknownSource
|
|
90
125
|
|
|
91
|
-
|
|
126
|
+
/**
|
|
127
|
+
* When a field source is unknown
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
export declare interface ContentSourceMapUnknownSource {
|
|
131
|
+
type: 'unknown'
|
|
132
|
+
}
|
|
92
133
|
|
|
93
|
-
|
|
134
|
+
/**
|
|
135
|
+
* ValueMapping is a mapping when for value that is from a single source value
|
|
136
|
+
* It may refer to a field within a document or a literal value
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
export declare interface ContentSourceMapValueMapping {
|
|
140
|
+
type: 'value'
|
|
141
|
+
source: ContentSourceMapSource
|
|
142
|
+
}
|
|
94
143
|
|
|
95
144
|
/** @internal */
|
|
96
145
|
export declare function createEditUrl(
|
|
@@ -169,6 +218,9 @@ export declare type PathSegment = string | number | KeyedSegment | IndexTuple
|
|
|
169
218
|
/** @internal */
|
|
170
219
|
declare const reKeySegment: RegExp
|
|
171
220
|
|
|
221
|
+
/** @public */
|
|
222
|
+
declare type ReleaseId = `r${string}`
|
|
223
|
+
|
|
172
224
|
/**
|
|
173
225
|
* @internal
|
|
174
226
|
*/
|
|
@@ -219,7 +271,20 @@ export declare type ResolveStudioUrl = (
|
|
|
219
271
|
sourceDocument: ContentSourceMapDocuments[number],
|
|
220
272
|
) => StudioUrl
|
|
221
273
|
|
|
222
|
-
|
|
274
|
+
/** @internal */
|
|
275
|
+
export declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = {
|
|
276
|
+
[P in keyof T]: T[P]
|
|
277
|
+
} & {
|
|
278
|
+
_id: string
|
|
279
|
+
_rev: string
|
|
280
|
+
_type: string
|
|
281
|
+
_createdAt: string
|
|
282
|
+
_updatedAt: string
|
|
283
|
+
/**
|
|
284
|
+
* Present when `perspective` is set to `previewDrafts`
|
|
285
|
+
*/
|
|
286
|
+
_originalId?: string
|
|
287
|
+
}
|
|
223
288
|
|
|
224
289
|
/** @alpha */
|
|
225
290
|
export declare type StudioBaseRoute = {
|
package/dist/csm.d.ts
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {ContentSourceMapDocuments} from '@sanity/client'
|
|
7
|
-
import {ContentSourceMapDocumentValueSource} from '@sanity/client'
|
|
8
|
-
import {ContentSourceMapLiteralSource} from '@sanity/client'
|
|
9
|
-
import {ContentSourceMapMapping} from '@sanity/client'
|
|
10
|
-
import {ContentSourceMapMappings} from '@sanity/client'
|
|
11
|
-
import {ContentSourceMapPaths} from '@sanity/client'
|
|
12
|
-
import {ContentSourceMapRemoteDocument} from '@sanity/client'
|
|
13
|
-
import {ContentSourceMapSource} from '@sanity/client'
|
|
14
|
-
import {ContentSourceMapUnknownSource} from '@sanity/client'
|
|
15
|
-
import {ContentSourceMapValueMapping} from '@sanity/client'
|
|
16
|
-
import {SanityDocument} from '@sanity/client'
|
|
17
|
-
|
|
18
|
-
export {Any}
|
|
1
|
+
/**
|
|
2
|
+
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare type Any = any
|
|
19
6
|
|
|
20
7
|
/**
|
|
21
8
|
* Optimistically applies source documents to a result, using the content source map to trace fields.
|
|
@@ -45,23 +32,62 @@ export declare type ApplySourceDocumentsUpdateFunction = <T = unknown>(
|
|
|
45
32
|
},
|
|
46
33
|
) => T
|
|
47
34
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
/** @public */
|
|
36
|
+
export declare type ClientPerspective =
|
|
37
|
+
| 'previewDrafts'
|
|
38
|
+
| 'published'
|
|
39
|
+
| 'drafts'
|
|
40
|
+
| 'raw'
|
|
41
|
+
| ('published' | 'drafts' | ReleaseId)[]
|
|
42
|
+
|
|
43
|
+
/** @public */
|
|
44
|
+
export declare interface ContentSourceMap {
|
|
45
|
+
mappings: ContentSourceMapMappings
|
|
46
|
+
documents: ContentSourceMapDocuments
|
|
47
|
+
paths: ContentSourceMapPaths
|
|
48
|
+
}
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
/** @public */
|
|
51
|
+
export declare interface ContentSourceMapDocument extends ContentSourceMapDocumentBase {
|
|
52
|
+
_projectId?: undefined
|
|
53
|
+
_dataset?: undefined
|
|
54
|
+
}
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
/** @public */
|
|
57
|
+
export declare interface ContentSourceMapDocumentBase {
|
|
58
|
+
_id: string
|
|
59
|
+
_type: string
|
|
60
|
+
}
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
/** @public */
|
|
63
|
+
export declare type ContentSourceMapDocuments = (
|
|
64
|
+
| ContentSourceMapDocument
|
|
65
|
+
| ContentSourceMapRemoteDocument
|
|
66
|
+
)[]
|
|
57
67
|
|
|
58
|
-
|
|
68
|
+
/**
|
|
69
|
+
* DocumentValueSource is a path to a value within a document
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export declare interface ContentSourceMapDocumentValueSource {
|
|
73
|
+
type: 'documentValue'
|
|
74
|
+
document: number
|
|
75
|
+
path: number
|
|
76
|
+
}
|
|
59
77
|
|
|
60
|
-
|
|
78
|
+
/**
|
|
79
|
+
* When a value is not from a source, its a literal
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export declare interface ContentSourceMapLiteralSource {
|
|
83
|
+
type: 'literal'
|
|
84
|
+
}
|
|
61
85
|
|
|
62
|
-
|
|
86
|
+
/** @public */
|
|
87
|
+
export declare type ContentSourceMapMapping = ContentSourceMapValueMapping
|
|
63
88
|
|
|
64
|
-
|
|
89
|
+
/** @public */
|
|
90
|
+
export declare type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>
|
|
65
91
|
|
|
66
92
|
/** @alpha */
|
|
67
93
|
export declare type ContentSourceMapParsedPath = (
|
|
@@ -82,15 +108,38 @@ export declare type ContentSourceMapParsedPathKeyedSegment = {
|
|
|
82
108
|
*/
|
|
83
109
|
export declare type ContentSourceMapParsedPathSegment = ContentSourceMapParsedPath[number]
|
|
84
110
|
|
|
85
|
-
|
|
111
|
+
/** @public */
|
|
112
|
+
export declare type ContentSourceMapPaths = string[]
|
|
86
113
|
|
|
87
|
-
|
|
114
|
+
/** @public */
|
|
115
|
+
export declare interface ContentSourceMapRemoteDocument extends ContentSourceMapDocumentBase {
|
|
116
|
+
_projectId: string
|
|
117
|
+
_dataset: string
|
|
118
|
+
}
|
|
88
119
|
|
|
89
|
-
|
|
120
|
+
/** @public */
|
|
121
|
+
export declare type ContentSourceMapSource =
|
|
122
|
+
| ContentSourceMapDocumentValueSource
|
|
123
|
+
| ContentSourceMapLiteralSource
|
|
124
|
+
| ContentSourceMapUnknownSource
|
|
90
125
|
|
|
91
|
-
|
|
126
|
+
/**
|
|
127
|
+
* When a field source is unknown
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
export declare interface ContentSourceMapUnknownSource {
|
|
131
|
+
type: 'unknown'
|
|
132
|
+
}
|
|
92
133
|
|
|
93
|
-
|
|
134
|
+
/**
|
|
135
|
+
* ValueMapping is a mapping when for value that is from a single source value
|
|
136
|
+
* It may refer to a field within a document or a literal value
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
export declare interface ContentSourceMapValueMapping {
|
|
140
|
+
type: 'value'
|
|
141
|
+
source: ContentSourceMapSource
|
|
142
|
+
}
|
|
94
143
|
|
|
95
144
|
/** @internal */
|
|
96
145
|
export declare function createEditUrl(
|
|
@@ -169,6 +218,9 @@ export declare type PathSegment = string | number | KeyedSegment | IndexTuple
|
|
|
169
218
|
/** @internal */
|
|
170
219
|
declare const reKeySegment: RegExp
|
|
171
220
|
|
|
221
|
+
/** @public */
|
|
222
|
+
declare type ReleaseId = `r${string}`
|
|
223
|
+
|
|
172
224
|
/**
|
|
173
225
|
* @internal
|
|
174
226
|
*/
|
|
@@ -219,7 +271,20 @@ export declare type ResolveStudioUrl = (
|
|
|
219
271
|
sourceDocument: ContentSourceMapDocuments[number],
|
|
220
272
|
) => StudioUrl
|
|
221
273
|
|
|
222
|
-
|
|
274
|
+
/** @internal */
|
|
275
|
+
export declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = {
|
|
276
|
+
[P in keyof T]: T[P]
|
|
277
|
+
} & {
|
|
278
|
+
_id: string
|
|
279
|
+
_rev: string
|
|
280
|
+
_type: string
|
|
281
|
+
_createdAt: string
|
|
282
|
+
_updatedAt: string
|
|
283
|
+
/**
|
|
284
|
+
* Present when `perspective` is set to `previewDrafts`
|
|
285
|
+
*/
|
|
286
|
+
_originalId?: string
|
|
287
|
+
}
|
|
223
288
|
|
|
224
289
|
/** @alpha */
|
|
225
290
|
export declare type StudioBaseRoute = {
|