@sanity/client 6.15.6 → 6.15.7
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/_chunks-cjs/nodeMiddleware.cjs +1 -1
- package/dist/_chunks-es/nodeMiddleware.js +1 -1
- package/dist/csm.d.cts +349 -0
- package/dist/index.browser.d.cts +2813 -0
- package/dist/index.browser.d.ts +2813 -0
- package/dist/index.d.cts +2813 -0
- package/dist/stega.browser.d.cts +2873 -0
- package/dist/stega.browser.d.ts +2873 -0
- package/dist/stega.d.cts +2873 -0
- package/package.json +7 -10
|
@@ -1474,7 +1474,7 @@ function defineCreateClientExports(envMiddleware, ClassConstructor) {
|
|
|
1474
1474
|
config
|
|
1475
1475
|
) };
|
|
1476
1476
|
}
|
|
1477
|
-
var name = "@sanity/client", version = "6.15.
|
|
1477
|
+
var name = "@sanity/client", version = "6.15.7";
|
|
1478
1478
|
const middleware = [
|
|
1479
1479
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1480
1480
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|
|
@@ -1455,7 +1455,7 @@ function defineCreateClientExports(envMiddleware, ClassConstructor) {
|
|
|
1455
1455
|
config
|
|
1456
1456
|
) };
|
|
1457
1457
|
}
|
|
1458
|
-
var name = "@sanity/client", version = "6.15.
|
|
1458
|
+
var name = "@sanity/client", version = "6.15.7";
|
|
1459
1459
|
const middleware = [
|
|
1460
1460
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1461
1461
|
headers({ "User-Agent": `${name} ${version}` }),
|
package/dist/csm.d.cts
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare type Any = any
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Optimistically applies source documents to a result, using the content source map to trace fields.
|
|
11
|
+
* Can be used to apply mutations to documents being edited in a Studio, or any mutation on Content Lake, to a result with extremely low latency.
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
14
|
+
export declare function applySourceDocuments<Result = unknown>(
|
|
15
|
+
result: Result,
|
|
16
|
+
resultSourceMap: ContentSourceMap | undefined,
|
|
17
|
+
getCachedDocument: (
|
|
18
|
+
sourceDocument: ContentSourceMapDocuments[number],
|
|
19
|
+
) => Partial<SanityDocument> | null | undefined,
|
|
20
|
+
updateFn?: ApplySourceDocumentsUpdateFunction,
|
|
21
|
+
perspective?: ClientPerspective,
|
|
22
|
+
): Result
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @alpha
|
|
26
|
+
*/
|
|
27
|
+
export declare type ApplySourceDocumentsUpdateFunction = <T = unknown>(
|
|
28
|
+
changedValue: T,
|
|
29
|
+
context: {
|
|
30
|
+
cachedDocument: Partial<SanityDocument>
|
|
31
|
+
previousValue: T
|
|
32
|
+
sourceDocument: ContentSourceMapDocuments[number]
|
|
33
|
+
sourcePath: ContentSourceMapParsedPath
|
|
34
|
+
},
|
|
35
|
+
) => T
|
|
36
|
+
|
|
37
|
+
/** @public */
|
|
38
|
+
export declare type ClientPerspective = 'previewDrafts' | 'published' | 'raw'
|
|
39
|
+
|
|
40
|
+
/** @public */
|
|
41
|
+
export declare interface ContentSourceMap {
|
|
42
|
+
mappings: ContentSourceMapMappings
|
|
43
|
+
documents: ContentSourceMapDocuments
|
|
44
|
+
paths: ContentSourceMapPaths
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** @public */
|
|
48
|
+
export declare interface ContentSourceMapDocument extends ContentSourceMapDocumentBase {
|
|
49
|
+
_projectId?: undefined
|
|
50
|
+
_dataset?: undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** @public */
|
|
54
|
+
export declare interface ContentSourceMapDocumentBase {
|
|
55
|
+
_id: string
|
|
56
|
+
_type: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** @public */
|
|
60
|
+
export declare type ContentSourceMapDocuments = (
|
|
61
|
+
| ContentSourceMapDocument
|
|
62
|
+
| ContentSourceMapRemoteDocument
|
|
63
|
+
)[]
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* DocumentValueSource is a path to a value within a document
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export declare interface ContentSourceMapDocumentValueSource {
|
|
70
|
+
type: 'documentValue'
|
|
71
|
+
document: number
|
|
72
|
+
path: number
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* When a value is not from a source, its a literal
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare interface ContentSourceMapLiteralSource {
|
|
80
|
+
type: 'literal'
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** @public */
|
|
84
|
+
export declare type ContentSourceMapMapping = ContentSourceMapValueMapping
|
|
85
|
+
|
|
86
|
+
/** @public */
|
|
87
|
+
export declare type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>
|
|
88
|
+
|
|
89
|
+
/** @alpha */
|
|
90
|
+
export declare type ContentSourceMapParsedPath = (
|
|
91
|
+
| string
|
|
92
|
+
| number
|
|
93
|
+
| ContentSourceMapParsedPathKeyedSegment
|
|
94
|
+
)[]
|
|
95
|
+
|
|
96
|
+
/** @alpha */
|
|
97
|
+
export declare type ContentSourceMapParsedPathKeyedSegment = {
|
|
98
|
+
_key: string
|
|
99
|
+
_index: number
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @alpha
|
|
104
|
+
* @deprecated use `ContentSourceMapParsedPath[number]` instead
|
|
105
|
+
*/
|
|
106
|
+
export declare type ContentSourceMapParsedPathSegment = ContentSourceMapParsedPath[number]
|
|
107
|
+
|
|
108
|
+
/** @public */
|
|
109
|
+
export declare type ContentSourceMapPaths = string[]
|
|
110
|
+
|
|
111
|
+
/** @public */
|
|
112
|
+
export declare interface ContentSourceMapRemoteDocument extends ContentSourceMapDocumentBase {
|
|
113
|
+
_projectId: string
|
|
114
|
+
_dataset: string
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** @public */
|
|
118
|
+
export declare type ContentSourceMapSource =
|
|
119
|
+
| ContentSourceMapDocumentValueSource
|
|
120
|
+
| ContentSourceMapLiteralSource
|
|
121
|
+
| ContentSourceMapUnknownSource
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* When a field source is unknown
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
export declare interface ContentSourceMapUnknownSource {
|
|
128
|
+
type: 'unknown'
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* ValueMapping is a mapping when for value that is from a single source value
|
|
133
|
+
* It may refer to a field within a document or a literal value
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
export declare interface ContentSourceMapValueMapping {
|
|
137
|
+
type: 'value'
|
|
138
|
+
source: ContentSourceMapSource
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** @internal */
|
|
142
|
+
export declare function createEditUrl(
|
|
143
|
+
options: CreateEditUrlOptions,
|
|
144
|
+
): `${StudioBaseUrl}${EditIntentUrl}`
|
|
145
|
+
|
|
146
|
+
/** @internal */
|
|
147
|
+
export declare interface CreateEditUrlOptions {
|
|
148
|
+
baseUrl: string
|
|
149
|
+
workspace?: string
|
|
150
|
+
tool?: string
|
|
151
|
+
id: string
|
|
152
|
+
type: string
|
|
153
|
+
path: ContentSourceMapParsedPath | string
|
|
154
|
+
projectId?: string
|
|
155
|
+
dataset?: string
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** @alpha */
|
|
159
|
+
export declare type EditIntentUrl =
|
|
160
|
+
`/intent/edit/mode=presentation;id=${string};type=${string};path=${string}`
|
|
161
|
+
|
|
162
|
+
/** @alpha */
|
|
163
|
+
declare function fromString(path: string): Path
|
|
164
|
+
|
|
165
|
+
/** @internal */
|
|
166
|
+
declare function get<Result = unknown, Fallback = unknown>(
|
|
167
|
+
obj: unknown,
|
|
168
|
+
path: Path | string,
|
|
169
|
+
defaultVal?: Fallback,
|
|
170
|
+
): Result | typeof defaultVal
|
|
171
|
+
|
|
172
|
+
/** @internal */
|
|
173
|
+
export declare function getPublishedId(id: string): string
|
|
174
|
+
|
|
175
|
+
/** @alpha */
|
|
176
|
+
export declare type IndexTuple = [number | '', number | '']
|
|
177
|
+
|
|
178
|
+
/** @internal */
|
|
179
|
+
declare function isIndexSegment(segment: PathSegment): segment is number
|
|
180
|
+
|
|
181
|
+
/** @internal */
|
|
182
|
+
declare function isIndexTuple(segment: PathSegment): segment is IndexTuple
|
|
183
|
+
|
|
184
|
+
/** @internal */
|
|
185
|
+
declare function isKeySegment(segment: PathSegment): segment is KeyedSegment
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @internal
|
|
189
|
+
*/
|
|
190
|
+
export declare function jsonPath(path: ContentSourceMapParsedPath): ContentSourceMapPaths[number]
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @internal
|
|
194
|
+
*/
|
|
195
|
+
export declare function jsonPathToStudioPath(path: ContentSourceMapParsedPath): Path
|
|
196
|
+
|
|
197
|
+
/** @alpha */
|
|
198
|
+
export declare type KeyedSegment = {
|
|
199
|
+
_key: string
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
export declare function parseJsonPath(
|
|
206
|
+
path: ContentSourceMapPaths[number],
|
|
207
|
+
): ContentSourceMapParsedPath
|
|
208
|
+
|
|
209
|
+
/** @alpha */
|
|
210
|
+
export declare type Path = PathSegment[]
|
|
211
|
+
|
|
212
|
+
/** @alpha */
|
|
213
|
+
export declare type PathSegment = string | number | KeyedSegment | IndexTuple
|
|
214
|
+
|
|
215
|
+
/** @internal */
|
|
216
|
+
declare const reKeySegment: RegExp
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
export declare function resolvedKeyedSourcePath(options: {
|
|
222
|
+
keyedResultPath: ContentSourceMapParsedPath
|
|
223
|
+
pathSuffix?: string
|
|
224
|
+
sourceBasePath: string
|
|
225
|
+
}): ContentSourceMapParsedPath
|
|
226
|
+
|
|
227
|
+
/** @internal */
|
|
228
|
+
export declare function resolveEditInfo(
|
|
229
|
+
options: ResolveEditInfoOptions,
|
|
230
|
+
): CreateEditUrlOptions | undefined
|
|
231
|
+
|
|
232
|
+
/** @alpha */
|
|
233
|
+
export declare interface ResolveEditInfoOptions {
|
|
234
|
+
studioUrl: StudioUrl | ResolveStudioUrl
|
|
235
|
+
resultSourceMap: ContentSourceMap
|
|
236
|
+
resultPath: ContentSourceMapParsedPath
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** @alpha */
|
|
240
|
+
export declare function resolveEditUrl(
|
|
241
|
+
options: ResolveEditUrlOptions,
|
|
242
|
+
): ReturnType<typeof createEditUrl> | undefined
|
|
243
|
+
|
|
244
|
+
/** @alpha */
|
|
245
|
+
export declare interface ResolveEditUrlOptions extends Omit<ResolveEditInfoOptions, 'resultPath'> {
|
|
246
|
+
resultPath: StudioPathLike
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* @internal
|
|
251
|
+
*/
|
|
252
|
+
export declare function resolveMapping(
|
|
253
|
+
resultPath: ContentSourceMapParsedPath,
|
|
254
|
+
csm?: ContentSourceMap,
|
|
255
|
+
):
|
|
256
|
+
| {
|
|
257
|
+
mapping: ContentSourceMapMapping
|
|
258
|
+
matchedPath: string
|
|
259
|
+
pathSuffix: string
|
|
260
|
+
}
|
|
261
|
+
| undefined
|
|
262
|
+
|
|
263
|
+
/** @alpha */
|
|
264
|
+
export declare type ResolveStudioUrl = (
|
|
265
|
+
sourceDocument: ContentSourceMapDocuments[number],
|
|
266
|
+
) => StudioUrl
|
|
267
|
+
|
|
268
|
+
/** @internal */
|
|
269
|
+
export declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = {
|
|
270
|
+
[P in keyof T]: T[P]
|
|
271
|
+
} & {
|
|
272
|
+
_id: string
|
|
273
|
+
_rev: string
|
|
274
|
+
_type: string
|
|
275
|
+
_createdAt: string
|
|
276
|
+
_updatedAt: string
|
|
277
|
+
/**
|
|
278
|
+
* Present when `perspective` is set to `previewDrafts`
|
|
279
|
+
*/
|
|
280
|
+
_originalId?: string
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** @alpha */
|
|
284
|
+
export declare type StudioBaseRoute = {
|
|
285
|
+
baseUrl: StudioBaseUrl
|
|
286
|
+
workspace?: string
|
|
287
|
+
tool?: string
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** @alpha */
|
|
291
|
+
export declare type StudioBaseUrl =
|
|
292
|
+
| `/${string}`
|
|
293
|
+
| `${string}.sanity.studio`
|
|
294
|
+
| `https://${string}`
|
|
295
|
+
| string
|
|
296
|
+
|
|
297
|
+
declare namespace studioPath {
|
|
298
|
+
export {
|
|
299
|
+
isIndexSegment,
|
|
300
|
+
isKeySegment,
|
|
301
|
+
isIndexTuple,
|
|
302
|
+
get,
|
|
303
|
+
toString_2 as toString,
|
|
304
|
+
fromString,
|
|
305
|
+
KeyedSegment,
|
|
306
|
+
IndexTuple,
|
|
307
|
+
PathSegment,
|
|
308
|
+
Path,
|
|
309
|
+
reKeySegment,
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
export {studioPath}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Path syntax as used by the `sanity` package, you can give it a string:
|
|
316
|
+
* `products[0].images[_key=="abc123"].asset._ref`
|
|
317
|
+
* or an array:
|
|
318
|
+
* `['products', 0, 'images', {_key: 'abc123'}, 'asset', '_ref']`
|
|
319
|
+
* @alpha
|
|
320
|
+
*/
|
|
321
|
+
export declare type StudioPathLike = Path | string
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* @internal
|
|
325
|
+
*/
|
|
326
|
+
export declare function studioPathToJsonPath(path: Path | string): ContentSourceMapParsedPath
|
|
327
|
+
|
|
328
|
+
/** @alpha */
|
|
329
|
+
export declare type StudioUrl = StudioBaseUrl | StudioBaseRoute
|
|
330
|
+
|
|
331
|
+
/** @alpha */
|
|
332
|
+
declare function toString_2(path: Path): string
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* generic way to walk a nested object or array and apply a mapping function to each value
|
|
336
|
+
* @internal
|
|
337
|
+
*/
|
|
338
|
+
export declare function walkMap(
|
|
339
|
+
value: unknown,
|
|
340
|
+
mappingFn: WalkMapFn,
|
|
341
|
+
path?: ContentSourceMapParsedPath,
|
|
342
|
+
): unknown
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* @internal
|
|
346
|
+
*/
|
|
347
|
+
export declare type WalkMapFn = (value: unknown, path: ContentSourceMapParsedPath) => unknown
|
|
348
|
+
|
|
349
|
+
export {}
|