@sanity/client 7.26.2 → 8.0.0
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 +5 -377
- package/dist/browserUpload-CQgx9YYo.js +86 -0
- package/dist/browserUpload-CQgx9YYo.js.map +1 -0
- package/dist/browserUpload-icWlVP15.js +86 -0
- package/dist/browserUpload-icWlVP15.js.map +1 -0
- package/dist/config-a8VajuEY.js +126 -0
- package/dist/config-a8VajuEY.js.map +1 -0
- package/dist/csm.d.ts +122 -335
- package/dist/csm.js +79 -91
- package/dist/csm.js.map +1 -1
- package/dist/dist-C9ExSk2R.js +73 -0
- package/dist/dist-C9ExSk2R.js.map +1 -0
- package/dist/dist-Z8cIRxoB.js +69 -0
- package/dist/dist-Z8cIRxoB.js.map +1 -0
- package/dist/index.d.ts +107 -6723
- package/dist/index.js +2822 -2847
- package/dist/index.js.map +1 -1
- package/dist/{index.d.cts → index.node.d.ts} +4291 -5328
- package/dist/index.node.js +3131 -0
- package/dist/index.node.js.map +1 -0
- package/dist/isRecord-Kfmt-nk-.js +7 -0
- package/dist/isRecord-Kfmt-nk-.js.map +1 -0
- package/dist/media-library.d.ts +9 -100
- package/dist/media-library.js +36 -14
- package/dist/media-library.js.map +1 -1
- package/dist/request-CJxcN16k.js +372 -0
- package/dist/request-CJxcN16k.js.map +1 -0
- package/dist/request-k7VS_NnC.js +354 -0
- package/dist/request-k7VS_NnC.js.map +1 -0
- package/dist/resolveEditInfo-sq7yF78q.js +325 -0
- package/dist/resolveEditInfo-sq7yF78q.js.map +1 -0
- package/dist/rolldown-runtime-vyAXikos.js +9 -0
- package/dist/stega.d.ts +78 -7137
- package/dist/stega.js +27 -20
- package/dist/stega.js.map +1 -1
- package/dist/stegaClean-C18wLWau.js +21 -0
- package/dist/stegaClean-C18wLWau.js.map +1 -0
- package/dist/stegaEncodeSourceMap-B2fGArSf.js +163 -0
- package/dist/stegaEncodeSourceMap-B2fGArSf.js.map +1 -0
- package/dist/stegaEncodeSourceMap-DkoIlutY.js +367 -0
- package/dist/stegaEncodeSourceMap-DkoIlutY.js.map +1 -0
- package/dist/{index.browser.d.cts → types-CUxZSgB2.d.ts} +3956 -5256
- package/dist/types-CfGzbXrl.d.ts +108 -0
- package/package.json +64 -141
- package/src/SanityClient.ts +82 -117
- package/src/agent/actions/AgentActionsClient.ts +12 -12
- package/src/agent/actions/commonTypes.ts +2 -1
- package/src/agent/actions/generate.ts +26 -6
- package/src/agent/actions/patch.ts +27 -7
- package/src/agent/actions/prompt.ts +19 -5
- package/src/agent/actions/transform.ts +23 -5
- package/src/agent/actions/translate.ts +23 -5
- package/src/assets/AssetsClient.ts +71 -23
- package/src/csm/applySourceDocuments.ts +3 -1
- package/src/csm/createEditUrl.ts +1 -1
- package/src/csm/draftUtils.ts +0 -1
- package/src/csm/index.ts +2 -2
- package/src/csm/studioPath.ts +2 -1
- package/src/csm/types.ts +8 -2
- package/src/data/dataMethods.ts +801 -349
- package/src/data/eventsource.ts +13 -10
- package/src/data/listen.ts +18 -23
- package/src/data/live.ts +44 -27
- package/src/data/resolveEventSourceFetch.ts +96 -0
- package/src/datasets/DatasetsClient.ts +58 -41
- package/src/defineCreateClient.ts +35 -23
- package/src/http/browserMiddleware.ts +7 -1
- package/src/http/browserUpload.ts +162 -0
- package/src/http/errors.ts +60 -6
- package/src/http/nodeMiddleware.ts +94 -30
- package/src/http/request.ts +310 -87
- package/src/http/requestOptions.ts +131 -15
- package/src/{index.browser.ts → index.node.ts} +9 -4
- package/src/index.ts +4 -3
- package/src/mediaLibrary/MediaLibraryVideoClient.ts +26 -11
- package/src/projects/ProjectsClient.ts +18 -16
- package/src/releases/ReleasesClient.ts +38 -33
- package/src/stega/index.ts +1 -2
- package/src/stega/stegaEncodeSourceMap.ts +5 -0
- package/src/stega/types.ts +2 -2
- package/src/types.ts +148 -105
- package/src/users/UsersClient.ts +10 -14
- package/src/util/shareReplayLatest.ts +1 -1
- package/src/warnings.ts +6 -1
- package/dist/_chunks-cjs/config.cjs +0 -206
- package/dist/_chunks-cjs/config.cjs.map +0 -1
- package/dist/_chunks-cjs/isRecord.cjs +0 -6
- package/dist/_chunks-cjs/isRecord.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveEditInfo.cjs +0 -334
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +0 -1
- package/dist/_chunks-cjs/stegaClean.cjs +0 -46
- package/dist/_chunks-cjs/stegaClean.cjs.map +0 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +0 -388
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +0 -1
- package/dist/_chunks-es/config.js +0 -207
- package/dist/_chunks-es/config.js.map +0 -1
- package/dist/_chunks-es/isRecord.js +0 -7
- package/dist/_chunks-es/isRecord.js.map +0 -1
- package/dist/_chunks-es/resolveEditInfo.js +0 -335
- package/dist/_chunks-es/resolveEditInfo.js.map +0 -1
- package/dist/_chunks-es/stegaClean.js +0 -47
- package/dist/_chunks-es/stegaClean.js.map +0 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +0 -389
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +0 -1
- package/dist/csm.cjs +0 -99
- package/dist/csm.cjs.map +0 -1
- package/dist/csm.d.cts +0 -391
- package/dist/index.browser.cjs +0 -3106
- package/dist/index.browser.cjs.map +0 -1
- package/dist/index.browser.d.ts +0 -6802
- package/dist/index.browser.js +0 -3082
- package/dist/index.browser.js.map +0 -1
- package/dist/index.cjs +0 -2946
- package/dist/index.cjs.map +0 -1
- package/dist/media-library.cjs +0 -20
- package/dist/media-library.cjs.map +0 -1
- package/dist/media-library.d.cts +0 -117
- package/dist/stega.browser.cjs +0 -29
- package/dist/stega.browser.cjs.map +0 -1
- package/dist/stega.browser.d.cts +0 -7200
- package/dist/stega.browser.d.ts +0 -7200
- package/dist/stega.browser.js +0 -24
- package/dist/stega.browser.js.map +0 -1
- package/dist/stega.cjs +0 -29
- package/dist/stega.cjs.map +0 -1
- package/dist/stega.d.cts +0 -7200
- package/src/data/eventsourcePolyfill.ts +0 -7
- package/umd/.gitkeep +0 -1
- package/umd/sanityClient.js +0 -6543
- package/umd/sanityClient.min.js +0 -6
package/dist/csm.cjs
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var resolveEditInfo = require("./_chunks-cjs/resolveEditInfo.cjs"), config = require("./_chunks-cjs/config.cjs");
|
|
4
|
-
function resolvePerspectives(perspective) {
|
|
5
|
-
if (config.validateApiPerspective(perspective), Array.isArray(perspective))
|
|
6
|
-
return perspective.includes("published") ? perspective : [...perspective, "published"];
|
|
7
|
-
switch (perspective) {
|
|
8
|
-
case "previewDrafts":
|
|
9
|
-
case "drafts":
|
|
10
|
-
return ["drafts", "published"];
|
|
11
|
-
case "published":
|
|
12
|
-
default:
|
|
13
|
-
return ["published"];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function createSourceDocumentResolver(getCachedDocument, _perspective) {
|
|
17
|
-
const perspectives = resolvePerspectives(_perspective);
|
|
18
|
-
function findDocument(sourceDocument) {
|
|
19
|
-
for (const perspective of perspectives) {
|
|
20
|
-
let match = null;
|
|
21
|
-
if (perspective.startsWith("r") && (match = getCachedDocument({
|
|
22
|
-
...sourceDocument,
|
|
23
|
-
_id: resolveEditInfo.getVersionId(sourceDocument._id, perspective)
|
|
24
|
-
})), perspective === "drafts" && (match = getCachedDocument({
|
|
25
|
-
...sourceDocument,
|
|
26
|
-
_id: resolveEditInfo.getDraftId(sourceDocument._id)
|
|
27
|
-
})), perspective === "published" && (match = getCachedDocument({
|
|
28
|
-
...sourceDocument,
|
|
29
|
-
_id: resolveEditInfo.getPublishedId(sourceDocument._id)
|
|
30
|
-
})), match)
|
|
31
|
-
return { ...match, _id: resolveEditInfo.getPublishedId(match._id), _originalId: match._id };
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
return function(sourceDocument) {
|
|
36
|
-
return findDocument(sourceDocument);
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function applySourceDocuments(result, resultSourceMap, getCachedDocument, updateFn, perspective) {
|
|
40
|
-
if (!resultSourceMap) return result;
|
|
41
|
-
const resolveDocument = createSourceDocumentResolver(getCachedDocument, perspective), cachedDocuments = resultSourceMap.documents?.map?.(resolveDocument) || [];
|
|
42
|
-
return resolveEditInfo.walkMap(JSON.parse(JSON.stringify(result)), (value, path) => {
|
|
43
|
-
const resolveMappingResult = resolveEditInfo.resolveMapping(path, resultSourceMap);
|
|
44
|
-
if (!resolveMappingResult)
|
|
45
|
-
return value;
|
|
46
|
-
const { mapping, pathSuffix } = resolveMappingResult;
|
|
47
|
-
if (mapping.type !== "value" || mapping.source.type !== "documentValue")
|
|
48
|
-
return value;
|
|
49
|
-
const sourceDocument = resultSourceMap.documents[mapping.source.document], sourcePath = resultSourceMap.paths[mapping.source.path];
|
|
50
|
-
if (sourceDocument) {
|
|
51
|
-
const parsedPath = resolveEditInfo.parseJsonPath(sourcePath + pathSuffix), stringifiedPath = resolveEditInfo.toString(parsedPath), cachedDocument = cachedDocuments[mapping.source.document];
|
|
52
|
-
if (!cachedDocument)
|
|
53
|
-
return value;
|
|
54
|
-
const changedValue = cachedDocument ? resolveEditInfo.get(cachedDocument, stringifiedPath, value) : value;
|
|
55
|
-
return value === changedValue ? value : updateFn(changedValue, {
|
|
56
|
-
cachedDocument,
|
|
57
|
-
previousValue: value,
|
|
58
|
-
sourceDocument,
|
|
59
|
-
sourcePath: parsedPath
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return value;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
function resolvedKeyedSourcePath(options) {
|
|
66
|
-
const { keyedResultPath, pathSuffix, sourceBasePath } = options, inferredResultPath = pathSuffix === void 0 ? [] : resolveEditInfo.parseJsonPath(pathSuffix), inferredPath = keyedResultPath.slice(keyedResultPath.length - inferredResultPath.length), inferredPathSuffix = inferredPath.length ? resolveEditInfo.jsonPath(inferredPath).slice(1) : "";
|
|
67
|
-
return resolveEditInfo.parseJsonPath(sourceBasePath + inferredPathSuffix);
|
|
68
|
-
}
|
|
69
|
-
function resolveEditUrl(options) {
|
|
70
|
-
const { resultSourceMap, studioUrl } = options, resultPath = resolveEditInfo.studioPathToJsonPath(options.resultPath), editInfo = resolveEditInfo.resolveEditInfo({
|
|
71
|
-
resultPath,
|
|
72
|
-
resultSourceMap,
|
|
73
|
-
studioUrl
|
|
74
|
-
});
|
|
75
|
-
if (editInfo)
|
|
76
|
-
return resolveEditInfo.createEditUrl(editInfo);
|
|
77
|
-
}
|
|
78
|
-
exports.DRAFTS_FOLDER = resolveEditInfo.DRAFTS_FOLDER;
|
|
79
|
-
exports.VERSION_FOLDER = resolveEditInfo.VERSION_FOLDER;
|
|
80
|
-
exports.createEditUrl = resolveEditInfo.createEditUrl;
|
|
81
|
-
exports.getDraftId = resolveEditInfo.getDraftId;
|
|
82
|
-
exports.getPublishedId = resolveEditInfo.getPublishedId;
|
|
83
|
-
exports.getVersionFromId = resolveEditInfo.getVersionFromId;
|
|
84
|
-
exports.getVersionId = resolveEditInfo.getVersionId;
|
|
85
|
-
exports.isDraftId = resolveEditInfo.isDraftId;
|
|
86
|
-
exports.isPublishedId = resolveEditInfo.isPublishedId;
|
|
87
|
-
exports.isVersionId = resolveEditInfo.isVersionId;
|
|
88
|
-
exports.jsonPath = resolveEditInfo.jsonPath;
|
|
89
|
-
exports.jsonPathToStudioPath = resolveEditInfo.jsonPathToStudioPath;
|
|
90
|
-
exports.parseJsonPath = resolveEditInfo.parseJsonPath;
|
|
91
|
-
exports.resolveEditInfo = resolveEditInfo.resolveEditInfo;
|
|
92
|
-
exports.resolveMapping = resolveEditInfo.resolveMapping;
|
|
93
|
-
exports.studioPath = resolveEditInfo.studioPath;
|
|
94
|
-
exports.studioPathToJsonPath = resolveEditInfo.studioPathToJsonPath;
|
|
95
|
-
exports.walkMap = resolveEditInfo.walkMap;
|
|
96
|
-
exports.applySourceDocuments = applySourceDocuments;
|
|
97
|
-
exports.resolveEditUrl = resolveEditUrl;
|
|
98
|
-
exports.resolvedKeyedSourcePath = resolvedKeyedSourcePath;
|
|
99
|
-
//# sourceMappingURL=csm.cjs.map
|
package/dist/csm.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"csm.cjs","sources":["../src/csm/resolvePerspectives.ts","../src/csm/createSourceDocumentResolver.ts","../src/csm/applySourceDocuments.ts","../src/csm/resolvedKeyedSourcePath.ts","../src/csm/resolveEditUrl.ts"],"sourcesContent":["import {validateApiPerspective} from '../config'\nimport type {StackablePerspective} from '../types'\nimport type {ClientPerspective} from './types'\n\n/**\n * This resolves the perspectives to how documents should be resolved when applying optimistic updates,\n * like in `applySourceDocuments`.\n * @internal\n */\nexport function resolvePerspectives(\n perspective: Exclude<ClientPerspective, 'raw'>,\n): ('published' | 'drafts' | StackablePerspective)[] {\n validateApiPerspective(perspective)\n\n if (Array.isArray(perspective)) {\n if (!perspective.includes('published')) {\n return [...perspective, 'published']\n }\n return perspective\n }\n switch (perspective) {\n case 'previewDrafts':\n case 'drafts':\n return ['drafts', 'published']\n case 'published':\n default:\n return ['published']\n }\n}\n","import {getDraftId, getPublishedId, getVersionId} from './draftUtils'\nimport {resolvePerspectives} from './resolvePerspectives'\nimport type {ClientPerspective, ContentSourceMapDocuments, SanityDocument} from './types'\n\n/** @internal */\nexport type ResolvedDocument = Partial<SanityDocument> &\n Required<Pick<SanityDocument, '_id' | '_type'>>\n\n/** @internal */\nexport type MatchedDocument = Partial<SanityDocument> &\n Required<Pick<SanityDocument, '_id' | '_type' | '_originalId'>>\n\n/** @internal */\nexport function createSourceDocumentResolver(\n getCachedDocument: (\n sourceDocument: ContentSourceMapDocuments[number],\n ) => ResolvedDocument | null | undefined,\n _perspective: Exclude<ClientPerspective, 'raw'>,\n) {\n const perspectives = resolvePerspectives(_perspective)\n function findDocument(sourceDocument: ContentSourceMapDocuments[number]) {\n for (const perspective of perspectives) {\n let match: ReturnType<typeof getCachedDocument> = null\n if (perspective.startsWith('r')) {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getVersionId(sourceDocument._id, perspective),\n })\n }\n if (perspective === 'drafts') {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getDraftId(sourceDocument._id),\n })\n }\n if (perspective === 'published') {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getPublishedId(sourceDocument._id),\n })\n }\n if (match) {\n return {...match, _id: getPublishedId(match._id), _originalId: match._id}\n }\n }\n return null\n }\n // define resolver that loops over source documents and perspectives\n return function resolveSourceDocument(\n sourceDocument: ContentSourceMapDocuments[number],\n ): MatchedDocument | null {\n return findDocument(sourceDocument)\n }\n}\n","import {createSourceDocumentResolver} from './createSourceDocumentResolver'\nimport {parseJsonPath} from './jsonPath'\nimport {resolveMapping} from './resolveMapping'\nimport * as paths from './studioPath'\nimport type {\n Any,\n ApplySourceDocumentsUpdateFunction,\n ClientPerspective,\n ContentSourceMap,\n ContentSourceMapDocuments,\n Path,\n SanityDocument,\n} from './types'\nimport {walkMap} from './walkMap'\n\n/**\n * Optimistically applies source documents to a result, using the content source map to trace fields.\n * 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.\n * @alpha\n */\nexport function applySourceDocuments<Result = unknown>(\n result: Result,\n resultSourceMap: ContentSourceMap | undefined,\n getCachedDocument: (\n sourceDocument: ContentSourceMapDocuments[number],\n ) =>\n (Partial<SanityDocument> & Required<Pick<SanityDocument, '_id' | '_type'>>) | null | undefined,\n updateFn: ApplySourceDocumentsUpdateFunction,\n perspective: Exclude<ClientPerspective, 'raw'>,\n): Result {\n if (!resultSourceMap) return result\n\n const resolveDocument = createSourceDocumentResolver(getCachedDocument, perspective)\n const cachedDocuments = resultSourceMap.documents?.map?.(resolveDocument) || []\n\n return walkMap(JSON.parse(JSON.stringify(result)), (value, path) => {\n const resolveMappingResult = resolveMapping(path, resultSourceMap)\n if (!resolveMappingResult) {\n return value\n }\n\n const {mapping, pathSuffix} = resolveMappingResult\n if (mapping.type !== 'value') {\n return value\n }\n\n if (mapping.source.type !== 'documentValue') {\n return value\n }\n\n const sourceDocument = resultSourceMap.documents[mapping.source.document]\n const sourcePath = resultSourceMap.paths[mapping.source.path]\n\n if (sourceDocument) {\n const parsedPath = parseJsonPath(sourcePath + pathSuffix)\n const stringifiedPath = paths.toString(parsedPath as Path)\n const cachedDocument = cachedDocuments[mapping.source.document]\n\n if (!cachedDocument) {\n return value\n }\n\n const changedValue = cachedDocument\n ? paths.get<Result[keyof Result]>(cachedDocument, stringifiedPath, value)\n : value\n return value === changedValue\n ? value\n : updateFn<Result[keyof Result]>(changedValue as Any, {\n cachedDocument,\n previousValue: value as Result[keyof Result],\n sourceDocument,\n sourcePath: parsedPath,\n })\n }\n\n return value\n }) as Result\n}\n","import {jsonPath, parseJsonPath} from './jsonPath'\nimport type {ContentSourceMapParsedPath} from './types'\n\n/**\n * @internal\n */\nexport function resolvedKeyedSourcePath(options: {\n keyedResultPath: ContentSourceMapParsedPath\n pathSuffix?: string\n sourceBasePath: string\n}): ContentSourceMapParsedPath {\n const {keyedResultPath, pathSuffix, sourceBasePath} = options\n\n const inferredResultPath = pathSuffix === undefined ? [] : parseJsonPath(pathSuffix)\n\n const inferredPath = keyedResultPath.slice(keyedResultPath.length - inferredResultPath.length)\n\n const inferredPathSuffix = inferredPath.length ? jsonPath(inferredPath).slice(1) : ''\n\n return parseJsonPath(sourceBasePath + inferredPathSuffix)\n}\n","import {createEditUrl} from './createEditUrl'\nimport {studioPathToJsonPath} from './jsonPath'\nimport {resolveEditInfo} from './resolveEditInfo'\nimport type {ResolveEditUrlOptions} from './types'\n\n/** @alpha */\nexport function resolveEditUrl(\n options: ResolveEditUrlOptions,\n): ReturnType<typeof createEditUrl> | undefined {\n const {resultSourceMap, studioUrl} = options\n const resultPath = studioPathToJsonPath(options.resultPath)\n\n const editInfo = resolveEditInfo({\n resultPath,\n resultSourceMap,\n studioUrl,\n })\n if (!editInfo) {\n return undefined\n }\n\n return createEditUrl(editInfo)\n}\n"],"names":["validateApiPerspective","getVersionId","getDraftId","getPublishedId","walkMap","resolveMapping","parseJsonPath","paths.toString","paths.get","jsonPath","studioPathToJsonPath","resolveEditInfo","createEditUrl"],"mappings":"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"}
|
package/dist/csm.d.cts
DELETED
|
@@ -1,391 +0,0 @@
|
|
|
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
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Optimistically applies source documents to a result, using the content source map to trace fields.
|
|
9
|
-
* 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.
|
|
10
|
-
* @alpha
|
|
11
|
-
*/
|
|
12
|
-
export declare function applySourceDocuments<Result = unknown>(
|
|
13
|
-
result: Result,
|
|
14
|
-
resultSourceMap: ContentSourceMap | undefined,
|
|
15
|
-
getCachedDocument: (
|
|
16
|
-
sourceDocument: ContentSourceMapDocuments[number],
|
|
17
|
-
) =>
|
|
18
|
-
(Partial<SanityDocument> & Required<Pick<SanityDocument, '_id' | '_type'>>) | null | undefined,
|
|
19
|
-
updateFn: ApplySourceDocumentsUpdateFunction,
|
|
20
|
-
perspective: Exclude<ClientPerspective, 'raw'>,
|
|
21
|
-
): Result
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @alpha
|
|
25
|
-
*/
|
|
26
|
-
export declare type ApplySourceDocumentsUpdateFunction = <T = unknown>(
|
|
27
|
-
changedValue: T,
|
|
28
|
-
context: {
|
|
29
|
-
cachedDocument: Partial<SanityDocument>
|
|
30
|
-
previousValue: T
|
|
31
|
-
sourceDocument: ContentSourceMapDocuments[number]
|
|
32
|
-
sourcePath: ContentSourceMapParsedPath
|
|
33
|
-
},
|
|
34
|
-
) => T
|
|
35
|
-
|
|
36
|
-
/** @public */
|
|
37
|
-
export declare type ClientPerspective =
|
|
38
|
-
DeprecatedPreviewDrafts | 'published' | 'drafts' | 'raw' | StackablePerspective[]
|
|
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 | ContentSourceMapRemoteDocument
|
|
62
|
-
)[]
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* DocumentValueSource is a path to a value within a document
|
|
66
|
-
* @public
|
|
67
|
-
*/
|
|
68
|
-
export declare interface ContentSourceMapDocumentValueSource {
|
|
69
|
-
type: 'documentValue'
|
|
70
|
-
document: number
|
|
71
|
-
path: number
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* When a value is not from a source, its a literal
|
|
76
|
-
* @public
|
|
77
|
-
*/
|
|
78
|
-
export declare interface ContentSourceMapLiteralSource {
|
|
79
|
-
type: 'literal'
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** @public */
|
|
83
|
-
export declare type ContentSourceMapMapping = ContentSourceMapValueMapping
|
|
84
|
-
|
|
85
|
-
/** @public */
|
|
86
|
-
export declare type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>
|
|
87
|
-
|
|
88
|
-
/** @alpha */
|
|
89
|
-
export declare type ContentSourceMapParsedPath = (
|
|
90
|
-
string | number | ContentSourceMapParsedPathKeyedSegment
|
|
91
|
-
)[]
|
|
92
|
-
|
|
93
|
-
/** @alpha */
|
|
94
|
-
export declare type ContentSourceMapParsedPathKeyedSegment = {
|
|
95
|
-
_key: string
|
|
96
|
-
_index: number
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @alpha
|
|
101
|
-
* @deprecated use `ContentSourceMapParsedPath[number]` instead
|
|
102
|
-
*/
|
|
103
|
-
export declare type ContentSourceMapParsedPathSegment = ContentSourceMapParsedPath[number]
|
|
104
|
-
|
|
105
|
-
/** @public */
|
|
106
|
-
export declare type ContentSourceMapPaths = string[]
|
|
107
|
-
|
|
108
|
-
/** @public */
|
|
109
|
-
export declare interface ContentSourceMapRemoteDocument extends ContentSourceMapDocumentBase {
|
|
110
|
-
_projectId: string
|
|
111
|
-
_dataset: string
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** @public */
|
|
115
|
-
export declare type ContentSourceMapSource =
|
|
116
|
-
| ContentSourceMapDocumentValueSource
|
|
117
|
-
| ContentSourceMapLiteralSource
|
|
118
|
-
| ContentSourceMapUnknownSource
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* When a field source is unknown
|
|
122
|
-
* @public
|
|
123
|
-
*/
|
|
124
|
-
export declare interface ContentSourceMapUnknownSource {
|
|
125
|
-
type: 'unknown'
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* ValueMapping is a mapping when for value that is from a single source value
|
|
130
|
-
* It may refer to a field within a document or a literal value
|
|
131
|
-
* @public
|
|
132
|
-
*/
|
|
133
|
-
export declare interface ContentSourceMapValueMapping {
|
|
134
|
-
type: 'value'
|
|
135
|
-
source: ContentSourceMapSource
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/** @internal */
|
|
139
|
-
export declare function createEditUrl(
|
|
140
|
-
options: CreateEditUrlOptions,
|
|
141
|
-
): `${StudioBaseUrl}${EditIntentUrl}`
|
|
142
|
-
|
|
143
|
-
/** @internal */
|
|
144
|
-
export declare interface CreateEditUrlOptions {
|
|
145
|
-
baseUrl: string
|
|
146
|
-
workspace?: string
|
|
147
|
-
tool?: string
|
|
148
|
-
id: string
|
|
149
|
-
type: string
|
|
150
|
-
path: ContentSourceMapParsedPath | string
|
|
151
|
-
projectId?: string
|
|
152
|
-
dataset?: string
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @deprecated use 'drafts' instead
|
|
157
|
-
*/
|
|
158
|
-
declare type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
159
|
-
|
|
160
|
-
/** @internal */
|
|
161
|
-
export declare type DraftId = Opaque<string, 'draftId'>
|
|
162
|
-
|
|
163
|
-
/** @internal */
|
|
164
|
-
export declare const DRAFTS_FOLDER = 'drafts'
|
|
165
|
-
|
|
166
|
-
/** @alpha */
|
|
167
|
-
export declare type EditIntentUrl =
|
|
168
|
-
`/intent/edit/mode=presentation;id=${string};type=${string};path=${string}`
|
|
169
|
-
|
|
170
|
-
/** @alpha */
|
|
171
|
-
declare function fromString(path: string): Path
|
|
172
|
-
|
|
173
|
-
/** @internal */
|
|
174
|
-
declare function get<Result = unknown, Fallback = unknown>(
|
|
175
|
-
obj: unknown,
|
|
176
|
-
path: Path | string,
|
|
177
|
-
defaultVal?: Fallback,
|
|
178
|
-
): Result | typeof defaultVal
|
|
179
|
-
|
|
180
|
-
/** @internal */
|
|
181
|
-
export declare function getDraftId(id: string): DraftId
|
|
182
|
-
|
|
183
|
-
/** @internal */
|
|
184
|
-
export declare function getPublishedId(id: string): PublishedId
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* @internal
|
|
188
|
-
* Given an id, returns the versionId if it exists.
|
|
189
|
-
* e.g. `versions.summer-drop.foo` = `summer-drop`
|
|
190
|
-
* e.g. `drafts.foo` = `undefined`
|
|
191
|
-
* e.g. `foo` = `undefined`
|
|
192
|
-
*/
|
|
193
|
-
export declare function getVersionFromId(id: string): string | undefined
|
|
194
|
-
|
|
195
|
-
/** @internal */
|
|
196
|
-
export declare function getVersionId(id: string, version: string): string
|
|
197
|
-
|
|
198
|
-
/** @alpha */
|
|
199
|
-
export declare type IndexTuple = [number | '', number | '']
|
|
200
|
-
|
|
201
|
-
/** @internal */
|
|
202
|
-
export declare function isDraftId(id: string): id is DraftId
|
|
203
|
-
|
|
204
|
-
/** @internal */
|
|
205
|
-
declare function isIndexSegment(segment: PathSegment): segment is number
|
|
206
|
-
|
|
207
|
-
/** @internal */
|
|
208
|
-
declare function isIndexTuple(segment: PathSegment): segment is IndexTuple
|
|
209
|
-
|
|
210
|
-
/** @internal */
|
|
211
|
-
declare function isKeySegment(segment: PathSegment): segment is KeyedSegment
|
|
212
|
-
|
|
213
|
-
/** @internal */
|
|
214
|
-
export declare function isPublishedId(id: string): id is PublishedId
|
|
215
|
-
|
|
216
|
-
/** @internal */
|
|
217
|
-
export declare function isVersionId(id: string): boolean
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* @internal
|
|
221
|
-
*/
|
|
222
|
-
export declare function jsonPath(path: ContentSourceMapParsedPath): ContentSourceMapPaths[number]
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* @internal
|
|
226
|
-
*/
|
|
227
|
-
export declare function jsonPathToStudioPath(path: ContentSourceMapParsedPath): Path
|
|
228
|
-
|
|
229
|
-
/** @alpha */
|
|
230
|
-
export declare type KeyedSegment = {
|
|
231
|
-
_key: string
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
declare type Opaque<T, K> = T & {
|
|
235
|
-
__opaqueId__: K
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* @internal
|
|
240
|
-
*/
|
|
241
|
-
export declare function parseJsonPath(
|
|
242
|
-
path: ContentSourceMapPaths[number],
|
|
243
|
-
): ContentSourceMapParsedPath
|
|
244
|
-
|
|
245
|
-
/** @alpha */
|
|
246
|
-
export declare type Path = PathSegment[]
|
|
247
|
-
|
|
248
|
-
/** @alpha */
|
|
249
|
-
export declare type PathSegment = string | number | KeyedSegment | IndexTuple
|
|
250
|
-
|
|
251
|
-
/** @internal */
|
|
252
|
-
export declare type PublishedId = Opaque<string, 'publishedId'>
|
|
253
|
-
|
|
254
|
-
/** @internal */
|
|
255
|
-
declare const reKeySegment: RegExp
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* @internal
|
|
259
|
-
*/
|
|
260
|
-
export declare function resolvedKeyedSourcePath(options: {
|
|
261
|
-
keyedResultPath: ContentSourceMapParsedPath
|
|
262
|
-
pathSuffix?: string
|
|
263
|
-
sourceBasePath: string
|
|
264
|
-
}): ContentSourceMapParsedPath
|
|
265
|
-
|
|
266
|
-
/** @internal */
|
|
267
|
-
export declare function resolveEditInfo(
|
|
268
|
-
options: ResolveEditInfoOptions,
|
|
269
|
-
): CreateEditUrlOptions | undefined
|
|
270
|
-
|
|
271
|
-
/** @alpha */
|
|
272
|
-
export declare interface ResolveEditInfoOptions {
|
|
273
|
-
studioUrl: StudioUrl | ResolveStudioUrl
|
|
274
|
-
resultSourceMap: ContentSourceMap
|
|
275
|
-
resultPath: ContentSourceMapParsedPath
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/** @alpha */
|
|
279
|
-
export declare function resolveEditUrl(
|
|
280
|
-
options: ResolveEditUrlOptions,
|
|
281
|
-
): ReturnType<typeof createEditUrl> | undefined
|
|
282
|
-
|
|
283
|
-
/** @alpha */
|
|
284
|
-
export declare interface ResolveEditUrlOptions extends Omit<ResolveEditInfoOptions, 'resultPath'> {
|
|
285
|
-
resultPath: StudioPathLike
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @internal
|
|
290
|
-
*/
|
|
291
|
-
export declare function resolveMapping(
|
|
292
|
-
resultPath: ContentSourceMapParsedPath,
|
|
293
|
-
csm?: ContentSourceMap,
|
|
294
|
-
):
|
|
295
|
-
| {
|
|
296
|
-
mapping: ContentSourceMapMapping
|
|
297
|
-
matchedPath: string
|
|
298
|
-
pathSuffix: string
|
|
299
|
-
}
|
|
300
|
-
| undefined
|
|
301
|
-
|
|
302
|
-
/** @alpha */
|
|
303
|
-
export declare type ResolveStudioUrl = (
|
|
304
|
-
sourceDocument: ContentSourceMapDocuments[number],
|
|
305
|
-
) => StudioUrl
|
|
306
|
-
|
|
307
|
-
/** @internal */
|
|
308
|
-
export declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = {
|
|
309
|
-
[P in keyof T]: T[P]
|
|
310
|
-
} & {
|
|
311
|
-
_id: string
|
|
312
|
-
_rev: string
|
|
313
|
-
_type: string
|
|
314
|
-
_createdAt: string
|
|
315
|
-
_updatedAt: string
|
|
316
|
-
/**
|
|
317
|
-
* Present when `perspective` is set to `previewDrafts`
|
|
318
|
-
*/
|
|
319
|
-
_originalId?: string
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/** @public */
|
|
323
|
-
declare type StackablePerspective = ('published' | 'drafts' | string) & {}
|
|
324
|
-
|
|
325
|
-
/** @alpha */
|
|
326
|
-
export declare type StudioBaseRoute = {
|
|
327
|
-
baseUrl: StudioBaseUrl
|
|
328
|
-
workspace?: string
|
|
329
|
-
tool?: string
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/** @alpha */
|
|
333
|
-
export declare type StudioBaseUrl =
|
|
334
|
-
`/${string}` | `${string}.sanity.studio` | `https://${string}` | string
|
|
335
|
-
|
|
336
|
-
declare namespace studioPath {
|
|
337
|
-
export {
|
|
338
|
-
isIndexSegment,
|
|
339
|
-
isKeySegment,
|
|
340
|
-
isIndexTuple,
|
|
341
|
-
get,
|
|
342
|
-
toString_2 as toString,
|
|
343
|
-
fromString,
|
|
344
|
-
KeyedSegment,
|
|
345
|
-
IndexTuple,
|
|
346
|
-
PathSegment,
|
|
347
|
-
Path,
|
|
348
|
-
reKeySegment,
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
export {studioPath}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Path syntax as used by the `sanity` package, you can give it a string:
|
|
355
|
-
* `products[0].images[_key=="abc123"].asset._ref`
|
|
356
|
-
* or an array:
|
|
357
|
-
* `['products', 0, 'images', {_key: 'abc123'}, 'asset', '_ref']`
|
|
358
|
-
* @alpha
|
|
359
|
-
*/
|
|
360
|
-
export declare type StudioPathLike = Path | string
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* @internal
|
|
364
|
-
*/
|
|
365
|
-
export declare function studioPathToJsonPath(path: Path | string): ContentSourceMapParsedPath
|
|
366
|
-
|
|
367
|
-
/** @alpha */
|
|
368
|
-
export declare type StudioUrl = StudioBaseUrl | StudioBaseRoute
|
|
369
|
-
|
|
370
|
-
/** @alpha */
|
|
371
|
-
declare function toString_2(path: Path): string
|
|
372
|
-
|
|
373
|
-
/** @internal */
|
|
374
|
-
export declare const VERSION_FOLDER = 'versions'
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* generic way to walk a nested object or array and apply a mapping function to each value
|
|
378
|
-
* @internal
|
|
379
|
-
*/
|
|
380
|
-
export declare function walkMap(
|
|
381
|
-
value: unknown,
|
|
382
|
-
mappingFn: WalkMapFn,
|
|
383
|
-
path?: ContentSourceMapParsedPath,
|
|
384
|
-
): unknown
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* @internal
|
|
388
|
-
*/
|
|
389
|
-
export declare type WalkMapFn = (value: unknown, path: ContentSourceMapParsedPath) => unknown
|
|
390
|
-
|
|
391
|
-
export {}
|