@sanity/sdk-react 0.0.0-alpha.24 → 0.0.0-alpha.26
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-es/index.js +5817 -0
- package/dist/_chunks-es/index.js.map +1 -0
- package/dist/_chunks-es/node.js +256 -0
- package/dist/_chunks-es/node.js.map +1 -0
- package/dist/_chunks-es/stegaEncodeSourceMap.js +340 -0
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -0
- package/dist/index.d.ts +45 -28
- package/dist/index.js +1 -970
- package/dist/index.js.map +1 -1
- package/package.json +10 -8
- package/src/_exports/index.ts +1 -64
- package/src/_exports/sdk-react.ts +70 -0
- package/src/components/SanityApp.tsx +4 -0
- package/src/components/auth/AuthBoundary.tsx +4 -3
- package/src/components/auth/LoginError.tsx +25 -5
- package/src/hooks/auth/useDashboardOrganizationId.tsx +3 -2
- package/src/hooks/auth/useLoginUrl.tsx +1 -1
- package/src/hooks/comlink/useManageFavorite.ts +9 -4
- package/src/hooks/comlink/useRecordDocumentHistoryEvent.ts +10 -3
- package/src/hooks/context/useSanityInstance.ts +1 -0
- package/src/hooks/dashboard/useNavigateToStudioDocument.ts +20 -36
- package/src/hooks/documents/useDocuments.ts +9 -5
- package/src/hooks/paginatedDocuments/usePaginatedDocuments.ts +8 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stegaEncodeSourceMap.js","sources":["../../../../node_modules/.pnpm/@sanity+client@6.29.0/node_modules/@sanity/client/dist/_chunks-es/stegaEncodeSourceMap.js"],"sourcesContent":["import { C } from \"./stegaClean.js\";\nconst reKeySegment = /_key\\s*==\\s*['\"](.*)['\"]/;\nfunction isKeySegment(segment) {\n return typeof segment == \"string\" ? reKeySegment.test(segment.trim()) : typeof segment == \"object\" && \"_key\" in segment;\n}\nfunction toString(path) {\n if (!Array.isArray(path))\n throw new Error(\"Path is not an array\");\n return path.reduce((target, segment, i) => {\n const segmentType = typeof segment;\n if (segmentType === \"number\")\n return `${target}[${segment}]`;\n if (segmentType === \"string\")\n return `${target}${i === 0 ? \"\" : \".\"}${segment}`;\n if (isKeySegment(segment) && segment._key)\n return `${target}[_key==\"${segment._key}\"]`;\n if (Array.isArray(segment)) {\n const [from, to] = segment;\n return `${target}[${from}:${to}]`;\n }\n throw new Error(`Unsupported path segment \\`${JSON.stringify(segment)}\\``);\n }, \"\");\n}\nconst ESCAPE = {\n \"\\f\": \"\\\\f\",\n \"\\n\": \"\\\\n\",\n \"\\r\": \"\\\\r\",\n \"\t\": \"\\\\t\",\n \"'\": \"\\\\'\",\n \"\\\\\": \"\\\\\\\\\"\n}, UNESCAPE = {\n \"\\\\f\": \"\\f\",\n \"\\\\n\": `\n`,\n \"\\\\r\": \"\\r\",\n \"\\\\t\": \"\t\",\n \"\\\\'\": \"'\",\n \"\\\\\\\\\": \"\\\\\"\n};\nfunction jsonPath(path) {\n return `$${path.map((segment) => typeof segment == \"string\" ? `['${segment.replace(/[\\f\\n\\r\\t'\\\\]/g, (match) => ESCAPE[match])}']` : typeof segment == \"number\" ? `[${segment}]` : segment._key !== \"\" ? `[?(@._key=='${segment._key.replace(/['\\\\]/g, (match) => ESCAPE[match])}')]` : `[${segment._index}]`).join(\"\")}`;\n}\nfunction parseJsonPath(path) {\n const parsed = [], parseRe = /\\['(.*?)'\\]|\\[(\\d+)\\]|\\[\\?\\(@\\._key=='(.*?)'\\)\\]/g;\n let match;\n for (; (match = parseRe.exec(path)) !== null; ) {\n if (match[1] !== void 0) {\n const key = match[1].replace(/\\\\(\\\\|f|n|r|t|')/g, (m) => UNESCAPE[m]);\n parsed.push(key);\n continue;\n }\n if (match[2] !== void 0) {\n parsed.push(parseInt(match[2], 10));\n continue;\n }\n if (match[3] !== void 0) {\n const _key = match[3].replace(/\\\\(\\\\')/g, (m) => UNESCAPE[m]);\n parsed.push({\n _key,\n _index: -1\n });\n continue;\n }\n }\n return parsed;\n}\nfunction jsonPathToStudioPath(path) {\n return path.map((segment) => {\n if (typeof segment == \"string\" || typeof segment == \"number\")\n return segment;\n if (segment._key !== \"\")\n return { _key: segment._key };\n if (segment._index !== -1)\n return segment._index;\n throw new Error(`invalid segment:${JSON.stringify(segment)}`);\n });\n}\nfunction jsonPathToMappingPath(path) {\n return path.map((segment) => {\n if (typeof segment == \"string\" || typeof segment == \"number\")\n return segment;\n if (segment._index !== -1)\n return segment._index;\n throw new Error(`invalid segment:${JSON.stringify(segment)}`);\n });\n}\nfunction resolveMapping(resultPath, csm) {\n if (!csm?.mappings)\n return;\n const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));\n if (csm.mappings[resultMappingPath] !== void 0)\n return {\n mapping: csm.mappings[resultMappingPath],\n matchedPath: resultMappingPath,\n pathSuffix: \"\"\n };\n const mappings = Object.entries(csm.mappings).filter(([key]) => resultMappingPath.startsWith(key)).sort(([key1], [key2]) => key2.length - key1.length);\n if (mappings.length == 0)\n return;\n const [matchedPath, mapping] = mappings[0], pathSuffix = resultMappingPath.substring(matchedPath.length);\n return { mapping, matchedPath, pathSuffix };\n}\nfunction isArray(value) {\n return value !== null && Array.isArray(value);\n}\nfunction isRecord(value) {\n return typeof value == \"object\" && value !== null;\n}\nfunction walkMap(value, mappingFn, path = []) {\n if (isArray(value))\n return value.map((v, idx) => {\n if (isRecord(v)) {\n const _key = v._key;\n if (typeof _key == \"string\")\n return walkMap(v, mappingFn, path.concat({ _key, _index: idx }));\n }\n return walkMap(v, mappingFn, path.concat(idx));\n });\n if (isRecord(value)) {\n if (value._type === \"block\" || value._type === \"span\") {\n const result = { ...value };\n return value._type === \"block\" ? result.children = walkMap(value.children, mappingFn, path.concat(\"children\")) : value._type === \"span\" && (result.text = walkMap(value.text, mappingFn, path.concat(\"text\"))), result;\n }\n return Object.fromEntries(\n Object.entries(value).map(([k, v]) => [k, walkMap(v, mappingFn, path.concat(k))])\n );\n }\n return mappingFn(value, path);\n}\nfunction encodeIntoResult(result, csm, encoder) {\n return walkMap(result, (value, path) => {\n if (typeof value != \"string\")\n return value;\n const resolveMappingResult = resolveMapping(path, csm);\n if (!resolveMappingResult)\n return value;\n const { mapping, matchedPath } = resolveMappingResult;\n if (mapping.type !== \"value\" || mapping.source.type !== \"documentValue\")\n return value;\n const sourceDocument = csm.documents[mapping.source.document], sourcePath = csm.paths[mapping.source.path], matchPathSegments = parseJsonPath(matchedPath), fullSourceSegments = parseJsonPath(sourcePath).concat(path.slice(matchPathSegments.length));\n return encoder({\n sourcePath: fullSourceSegments,\n sourceDocument,\n resultPath: path,\n value\n });\n });\n}\nconst DRAFTS_FOLDER = \"drafts\", VERSION_FOLDER = \"versions\", PATH_SEPARATOR = \".\", DRAFTS_PREFIX = `${DRAFTS_FOLDER}${PATH_SEPARATOR}`, VERSION_PREFIX = `${VERSION_FOLDER}${PATH_SEPARATOR}`;\nfunction isDraftId(id) {\n return id.startsWith(DRAFTS_PREFIX);\n}\nfunction isVersionId(id) {\n return id.startsWith(VERSION_PREFIX);\n}\nfunction isPublishedId(id) {\n return !isDraftId(id) && !isVersionId(id);\n}\nfunction getVersionFromId(id) {\n if (!isVersionId(id)) return;\n const [_versionPrefix, versionId, ..._publishedId] = id.split(PATH_SEPARATOR);\n return versionId;\n}\nfunction getPublishedId(id) {\n return isVersionId(id) ? id.split(PATH_SEPARATOR).slice(2).join(PATH_SEPARATOR) : isDraftId(id) ? id.slice(DRAFTS_PREFIX.length) : id;\n}\nfunction createEditUrl(options) {\n const {\n baseUrl,\n workspace: _workspace = \"default\",\n tool: _tool = \"default\",\n id: _id,\n type,\n path,\n projectId,\n dataset\n } = options;\n if (!baseUrl)\n throw new Error(\"baseUrl is required\");\n if (!path)\n throw new Error(\"path is required\");\n if (!_id)\n throw new Error(\"id is required\");\n if (baseUrl !== \"/\" && baseUrl.endsWith(\"/\"))\n throw new Error(\"baseUrl must not end with a slash\");\n const workspace = _workspace === \"default\" ? void 0 : _workspace, tool = _tool === \"default\" ? void 0 : _tool, id = getPublishedId(_id), stringifiedPath = Array.isArray(path) ? toString(jsonPathToStudioPath(path)) : path, searchParams = new URLSearchParams({\n baseUrl,\n id,\n type,\n path: stringifiedPath\n });\n if (workspace && searchParams.set(\"workspace\", workspace), tool && searchParams.set(\"tool\", tool), projectId && searchParams.set(\"projectId\", projectId), dataset && searchParams.set(\"dataset\", dataset), isPublishedId(_id))\n searchParams.set(\"perspective\", \"published\");\n else if (isVersionId(_id)) {\n const versionId = getVersionFromId(_id);\n searchParams.set(\"perspective\", versionId);\n }\n const segments = [baseUrl === \"/\" ? \"\" : baseUrl];\n workspace && segments.push(workspace);\n const routerParams = [\n \"mode=presentation\",\n `id=${id}`,\n `type=${type}`,\n `path=${encodeURIComponent(stringifiedPath)}`\n ];\n return tool && routerParams.push(`tool=${tool}`), segments.push(\"intent\", \"edit\", `${routerParams.join(\";\")}?${searchParams}`), segments.join(\"/\");\n}\nfunction resolveStudioBaseRoute(studioUrl) {\n let baseUrl = typeof studioUrl == \"string\" ? studioUrl : studioUrl.baseUrl;\n return baseUrl !== \"/\" && (baseUrl = baseUrl.replace(/\\/$/, \"\")), typeof studioUrl == \"string\" ? { baseUrl } : { ...studioUrl, baseUrl };\n}\nconst filterDefault = ({ sourcePath, resultPath, value }) => {\n if (isValidDate(value) || isValidURL(value))\n return !1;\n const endPath = sourcePath.at(-1);\n return !(sourcePath.at(-2) === \"slug\" && endPath === \"current\" || typeof endPath == \"string\" && (endPath.startsWith(\"_\") || endPath.endsWith(\"Id\")) || sourcePath.some(\n (path) => path === \"meta\" || path === \"metadata\" || path === \"openGraph\" || path === \"seo\"\n ) || hasTypeLike(sourcePath) || hasTypeLike(resultPath) || typeof endPath == \"string\" && denylist.has(endPath));\n}, denylist = /* @__PURE__ */ new Set([\n \"color\",\n \"colour\",\n \"currency\",\n \"email\",\n \"format\",\n \"gid\",\n \"hex\",\n \"href\",\n \"hsl\",\n \"hsla\",\n \"icon\",\n \"id\",\n \"index\",\n \"key\",\n \"language\",\n \"layout\",\n \"link\",\n \"linkAction\",\n \"locale\",\n \"lqip\",\n \"page\",\n \"path\",\n \"ref\",\n \"rgb\",\n \"rgba\",\n \"route\",\n \"secret\",\n \"slug\",\n \"status\",\n \"tag\",\n \"template\",\n \"theme\",\n \"type\",\n \"textTheme\",\n \"unit\",\n \"url\",\n \"username\",\n \"variant\",\n \"website\"\n]);\nfunction isValidDate(dateString) {\n return /^\\d{4}-\\d{2}-\\d{2}/.test(dateString) ? !!Date.parse(dateString) : !1;\n}\nfunction isValidURL(url) {\n try {\n new URL(url, url.startsWith(\"/\") ? \"https://acme.com\" : void 0);\n } catch {\n return !1;\n }\n return !0;\n}\nfunction hasTypeLike(path) {\n return path.some((segment) => typeof segment == \"string\" && segment.match(/type/i) !== null);\n}\nconst TRUNCATE_LENGTH = 20;\nfunction stegaEncodeSourceMap(result, resultSourceMap, config) {\n const { filter, logger, enabled } = config;\n if (!enabled) {\n const msg = \"config.enabled must be true, don't call this function otherwise\";\n throw logger?.error?.(`[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);\n }\n if (!resultSourceMap)\n return logger?.error?.(\"[@sanity/client]: Missing Content Source Map from response body\", {\n result,\n resultSourceMap,\n config\n }), result;\n if (!config.studioUrl) {\n const msg = \"config.studioUrl must be defined\";\n throw logger?.error?.(`[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);\n }\n const report = {\n encoded: [],\n skipped: []\n }, resultWithStega = encodeIntoResult(\n result,\n resultSourceMap,\n ({ sourcePath, sourceDocument, resultPath, value }) => {\n if ((typeof filter == \"function\" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, value })) === !1)\n return logger && report.skipped.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? \"...\" : \"\"}`,\n length: value.length\n }), value;\n logger && report.encoded.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? \"...\" : \"\"}`,\n length: value.length\n });\n const { baseUrl, workspace, tool } = resolveStudioBaseRoute(\n typeof config.studioUrl == \"function\" ? config.studioUrl(sourceDocument) : config.studioUrl\n );\n if (!baseUrl) return value;\n const { _id: id, _type: type, _projectId: projectId, _dataset: dataset } = sourceDocument;\n return C(\n value,\n {\n origin: \"sanity.io\",\n href: createEditUrl({\n baseUrl,\n workspace,\n tool,\n id,\n type,\n path: sourcePath,\n ...!config.omitCrossDatasetReferenceData && { dataset, projectId }\n })\n },\n // We use custom logic to determine if we should skip encoding\n !1\n );\n }\n );\n if (logger) {\n const isSkipping = report.skipped.length, isEncoding = report.encoded.length;\n if ((isSkipping || isEncoding) && ((logger?.groupCollapsed || logger.log)?.(\"[@sanity/client]: Encoding source map into result\"), logger.log?.(\n `[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`\n )), report.encoded.length > 0 && (logger?.log?.(\"[@sanity/client]: Table of encoded paths\"), (logger?.table || logger.log)?.(report.encoded)), report.skipped.length > 0) {\n const skipped = /* @__PURE__ */ new Set();\n for (const { path } of report.skipped)\n skipped.add(path.replace(reKeySegment, \"0\").replace(/\\[\\d+\\]/g, \"[]\"));\n logger?.log?.(\"[@sanity/client]: List of skipped paths\", [...skipped.values()]);\n }\n (isSkipping || isEncoding) && logger?.groupEnd?.();\n }\n return resultWithStega;\n}\nfunction prettyPathForLogging(path) {\n return toString(jsonPathToStudioPath(path));\n}\nvar stegaEncodeSourceMap$1 = /* @__PURE__ */ Object.freeze({\n __proto__: null,\n stegaEncodeSourceMap\n});\nexport {\n encodeIntoResult,\n stegaEncodeSourceMap,\n stegaEncodeSourceMap$1\n};\n//# sourceMappingURL=stegaEncodeSourceMap.js.map\n"],"names":["reKeySegment","isKeySegment","segment","test","trim","toString","path","Array","isArray","Error","reduce","target","i","segmentType","_key","from","to","JSON","stringify"],"mappings":";AAeO,MAAMA,eAAe;AASrB,SAASC,aAAaC,SAA+C;AAC1E,SAAI,OAAOA,WAAY,WACdF,aAAaG,KAAKD,QAAQE,KAAA,CAAM,IAGlC,OAAOF,WAAY,YAAY,UAAUA;AAClD;AA8DO,SAASG,SAASC,MAAoB;AACvC,MAACC,CAAAA,MAAMC,QAAQF,IAAI,EACf,OAAA,IAAIG,MAAM,sBAAsB;AAGxC,SAAOH,KAAKI,OAAe,CAACC,QAAQT,SAASU,MAAM;AACjD,UAAMC,cAAc,OAAOX;AAC3B,QAAIW,gBAAgB,SACX,QAAGF,GAAAA,MAAM,IAAIT,OAAO;AAG7B,QAAIW,gBAAgB,SAEX,QAAA,GAAGF,MAAM,GADEC,MAAM,IAAI,KAAK,GACL,GAAGV,OAAO;AAGpC,QAAAD,aAAaC,OAAO,KAAKA,QAAQY,KACnC,QAAO,GAAGH,MAAM,WAAWT,QAAQY,IAAI;AAGrC,QAAAP,MAAMC,QAAQN,OAAO,GAAG;AACpB,YAAA,CAACa,MAAMC,EAAE,IAAId;AACnB,aAAO,GAAGS,MAAM,IAAII,IAAI,IAAIC,EAAE;AAAA,IAAA;AAGhC,UAAM,IAAIP,MAAM,8BAA8BQ,KAAKC,UAAUhB,OAAO,CAAC,IAAI;AAAA,EAAA,GACxE,EAAE;AACP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0]}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ import {SanityClient} from '@sanity/client'
|
|
|
24
24
|
import {SanityConfig} from '@sanity/sdk'
|
|
25
25
|
import {SanityDocument} from '@sanity/types'
|
|
26
26
|
import {SanityInstance} from '@sanity/sdk'
|
|
27
|
-
import {SanityProject
|
|
27
|
+
import {SanityProject} from '@sanity/sdk'
|
|
28
28
|
import {SanityUser} from '@sanity/sdk'
|
|
29
29
|
import {SortOrderingItem} from '@sanity/types'
|
|
30
30
|
import {StudioResource} from '@sanity/message-protocol'
|
|
@@ -219,7 +219,11 @@ export declare type MessageHandler<TWindowMessage extends WindowMessage> = (
|
|
|
219
219
|
event: TWindowMessage['data'],
|
|
220
220
|
) => TWindowMessage['response'] | Promise<TWindowMessage['response']>
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
/**
|
|
223
|
+
* @public
|
|
224
|
+
* @category Types
|
|
225
|
+
*/
|
|
226
|
+
export declare interface NavigateToStudioResult {
|
|
223
227
|
navigateToStudioDocument: () => void
|
|
224
228
|
isConnected: boolean
|
|
225
229
|
}
|
|
@@ -332,7 +336,7 @@ export declare interface PaginatedDocumentsResponse {
|
|
|
332
336
|
* @category Types
|
|
333
337
|
* @interface
|
|
334
338
|
*/
|
|
335
|
-
export declare type ProjectWithoutMembers = Omit<
|
|
339
|
+
export declare type ProjectWithoutMembers = Omit<SanityProject_2, 'members'>
|
|
336
340
|
|
|
337
341
|
/**
|
|
338
342
|
* This version is provided by pkg-utils at build time
|
|
@@ -414,6 +418,7 @@ export declare interface ResourceProviderProps extends SanityConfig {
|
|
|
414
418
|
* SanityApp creates a hierarchy of ResourceProviders, each providing a SanityInstance that can be
|
|
415
419
|
* accessed by hooks. The first configuration in the array becomes the default instance.
|
|
416
420
|
*
|
|
421
|
+
* @category Components
|
|
417
422
|
* @param props - Your Sanity configuration and the React children to render
|
|
418
423
|
* @returns Your Sanity application, integrated with your Sanity configuration and application context
|
|
419
424
|
*
|
|
@@ -467,6 +472,7 @@ export declare function SanityApp({
|
|
|
467
472
|
|
|
468
473
|
/**
|
|
469
474
|
* @public
|
|
475
|
+
* @category Types
|
|
470
476
|
*/
|
|
471
477
|
export declare interface SanityAppProps {
|
|
472
478
|
config: SanityConfig | SanityConfig[]
|
|
@@ -479,7 +485,7 @@ export declare interface SanityAppProps {
|
|
|
479
485
|
export {SanityDocument}
|
|
480
486
|
|
|
481
487
|
/** @public */
|
|
482
|
-
|
|
488
|
+
declare interface SanityProject_2 {
|
|
483
489
|
id: string
|
|
484
490
|
displayName: string
|
|
485
491
|
/**
|
|
@@ -688,7 +694,8 @@ declare type UseCurrentUser = {
|
|
|
688
694
|
export declare const useCurrentUser: UseCurrentUser
|
|
689
695
|
|
|
690
696
|
/**
|
|
691
|
-
* @
|
|
697
|
+
* @public
|
|
698
|
+
*
|
|
692
699
|
* A React hook that retrieves the dashboard organization ID that is currently selected in the Sanity Dashboard.
|
|
693
700
|
*
|
|
694
701
|
* @example
|
|
@@ -702,8 +709,8 @@ export declare const useCurrentUser: UseCurrentUser
|
|
|
702
709
|
* }
|
|
703
710
|
* ```
|
|
704
711
|
*
|
|
712
|
+
* @category Dashboard
|
|
705
713
|
* @returns The dashboard organization ID (string | undefined)
|
|
706
|
-
* @public
|
|
707
714
|
*/
|
|
708
715
|
export declare function useDashboardOrganizationId(): string | undefined
|
|
709
716
|
|
|
@@ -1189,7 +1196,7 @@ export declare const useHandleAuthCallback: () => (
|
|
|
1189
1196
|
) => Promise<string | false>
|
|
1190
1197
|
|
|
1191
1198
|
/**
|
|
1192
|
-
* @
|
|
1199
|
+
* @internal
|
|
1193
1200
|
*/
|
|
1194
1201
|
export declare function useLoginUrl(): string
|
|
1195
1202
|
|
|
@@ -1201,12 +1208,10 @@ export declare function useLoginUrl(): string
|
|
|
1201
1208
|
export declare const useLogOut: () => () => Promise<void>
|
|
1202
1209
|
|
|
1203
1210
|
/**
|
|
1204
|
-
* @
|
|
1211
|
+
* @internal
|
|
1205
1212
|
*
|
|
1206
|
-
* ## useManageFavorite
|
|
1207
1213
|
* This hook provides functionality to add and remove documents from favorites,
|
|
1208
1214
|
* and tracks the current favorite status of the document.
|
|
1209
|
-
* @category Dashboard Communication
|
|
1210
1215
|
* @param documentHandle - The document handle containing document ID and type, like `{_id: '123', _type: 'book'}`
|
|
1211
1216
|
* @returns An object containing:
|
|
1212
1217
|
* - `favorite` - Function to add document to favorites
|
|
@@ -1240,34 +1245,39 @@ export declare function useManageFavorite({
|
|
|
1240
1245
|
dataset: paramDataset,
|
|
1241
1246
|
resourceId: paramResourceId,
|
|
1242
1247
|
resourceType,
|
|
1248
|
+
schemaName,
|
|
1243
1249
|
}: UseManageFavoriteProps): ManageFavorite
|
|
1244
1250
|
|
|
1245
1251
|
declare interface UseManageFavoriteProps extends DocumentHandle {
|
|
1246
1252
|
resourceId?: string
|
|
1247
1253
|
resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']
|
|
1254
|
+
/**
|
|
1255
|
+
* The name of the schema collection this document belongs to.
|
|
1256
|
+
* Typically is the name of the workspace when used in the context of a studio.
|
|
1257
|
+
*/
|
|
1258
|
+
schemaName?: string
|
|
1248
1259
|
}
|
|
1249
1260
|
|
|
1250
1261
|
/**
|
|
1251
1262
|
* @public
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1255
|
-
*
|
|
1256
|
-
*
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
1259
|
-
*
|
|
1260
|
-
*
|
|
1261
|
-
*
|
|
1262
|
-
*
|
|
1263
|
-
* @param documentHandle - The document handle containing document ID, type, and resource ID
|
|
1263
|
+
*
|
|
1264
|
+
* Hook that provides a function to navigate to a given document in its parent Studio.
|
|
1265
|
+
*
|
|
1266
|
+
* Uses the `projectId` and `dataset` properties of the {@link DocumentHandle} you provide to resolve the correct Studio.
|
|
1267
|
+
* This will only work if you have deployed a studio with a workspace with this `projectId` / `dataset` combination.
|
|
1268
|
+
*
|
|
1269
|
+
* @remarks If you write your own Document Handle to pass to this hook (as opposed to a Document Handle generated by another hook),
|
|
1270
|
+
* it must include values for `documentId`, `documentType`, `projectId`, and `dataset`.
|
|
1271
|
+
*
|
|
1272
|
+
* @category Documents
|
|
1273
|
+
* @param documentHandle - The document handle for the document to navigate to
|
|
1264
1274
|
* @returns An object containing:
|
|
1265
|
-
* - navigateToStudioDocument - Function that when called will navigate to the studio document
|
|
1266
|
-
* - isConnected - Boolean indicating if connection to Dashboard is established
|
|
1275
|
+
* - `navigateToStudioDocument` - Function that when called will navigate to the studio document
|
|
1276
|
+
* - `isConnected` - Boolean indicating if connection to Dashboard is established
|
|
1267
1277
|
*
|
|
1268
1278
|
* @example
|
|
1269
1279
|
* ```ts
|
|
1270
|
-
* import {
|
|
1280
|
+
* import {useNavigateToStudioDocument, type DocumentHandle} from '@sanity/sdk-react'
|
|
1271
1281
|
*
|
|
1272
1282
|
* function MyComponent({documentHandle}: {documentHandle: DocumentHandle}) {
|
|
1273
1283
|
* const {navigateToStudioDocument, isConnected} = useNavigateToStudioDocument(documentHandle)
|
|
@@ -1431,7 +1441,7 @@ declare type UseProject = {
|
|
|
1431
1441
|
* }
|
|
1432
1442
|
* ```
|
|
1433
1443
|
*/
|
|
1434
|
-
(projectHandle?: ProjectHandle):
|
|
1444
|
+
(projectHandle?: ProjectHandle): SanityProject
|
|
1435
1445
|
}
|
|
1436
1446
|
|
|
1437
1447
|
/**
|
|
@@ -1614,7 +1624,7 @@ export declare function useQuery<T>(
|
|
|
1614
1624
|
}
|
|
1615
1625
|
|
|
1616
1626
|
/**
|
|
1617
|
-
* @
|
|
1627
|
+
* @internal
|
|
1618
1628
|
* Hook for managing document interaction history in Sanity Studio.
|
|
1619
1629
|
* This hook provides functionality to record document interactions.
|
|
1620
1630
|
* @category History
|
|
@@ -1649,14 +1659,20 @@ export declare function useRecordDocumentHistoryEvent({
|
|
|
1649
1659
|
documentType,
|
|
1650
1660
|
resourceType,
|
|
1651
1661
|
resourceId,
|
|
1662
|
+
schemaName,
|
|
1652
1663
|
}: UseRecordDocumentHistoryEventProps): DocumentInteractionHistory
|
|
1653
1664
|
|
|
1654
1665
|
/**
|
|
1655
|
-
* @
|
|
1666
|
+
* @internal
|
|
1656
1667
|
*/
|
|
1657
1668
|
declare interface UseRecordDocumentHistoryEventProps extends DocumentHandle {
|
|
1658
1669
|
resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']
|
|
1659
1670
|
resourceId?: string
|
|
1671
|
+
/**
|
|
1672
|
+
* The name of the schema collection this document belongs to.
|
|
1673
|
+
* Typically is the name of the workspace when used in the context of a studio.
|
|
1674
|
+
*/
|
|
1675
|
+
schemaName?: string
|
|
1660
1676
|
}
|
|
1661
1677
|
|
|
1662
1678
|
/**
|
|
@@ -1687,6 +1703,7 @@ export declare interface UsersResult {
|
|
|
1687
1703
|
*
|
|
1688
1704
|
* @public
|
|
1689
1705
|
*
|
|
1706
|
+
* @category Platform
|
|
1690
1707
|
* @param config - Optional configuration to match against when finding an instance
|
|
1691
1708
|
* @returns The current or matching Sanity instance
|
|
1692
1709
|
*
|