@phtngyn/cms 0.1.0-beta.0 → 0.1.0-beta.2
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 +260 -6
- package/package.json +31 -16
- package/src/Authoring.d.ts +13 -1
- package/src/Configuration-Br7tE9Qt.d.ts +68 -0
- package/src/{AuthoringSchema-BQ5kbhVB.js → Configuration-CA_jvQKG.js} +599 -492
- package/src/Configuration-CA_jvQKG.js.map +1 -0
- package/src/Configuration.d.ts +2 -44
- package/src/Configuration.js +0 -1
- package/src/Configuration.js.map +1 -1
- package/src/{DocumentEngine-Da0kWotL.js → DocumentEngine-CgiBQU4g.js} +110 -84
- package/src/DocumentEngine-CgiBQU4g.js.map +1 -0
- package/src/DocumentModel-BB9igGC7.d.ts +34 -0
- package/src/DocumentModel.d.ts +2 -30
- package/src/DocumentModel.js +13 -3
- package/src/DocumentModel.js.map +1 -1
- package/src/Forms-BsJMev5_.d.ts +74 -0
- package/src/Forms-CfcI3tPU.js +79 -0
- package/src/Forms-CfcI3tPU.js.map +1 -0
- package/src/Forms-DxbkU3_5.js +367 -0
- package/src/Forms-DxbkU3_5.js.map +1 -0
- package/src/Forms.d.ts +35 -0
- package/src/Forms.js +13 -0
- package/src/Forms.js.map +1 -0
- package/src/HttpPaths-c9nLZ9H2.js +21 -0
- package/src/HttpPaths-c9nLZ9H2.js.map +1 -0
- package/src/I18n-DZK4CkJF.d.ts +21 -0
- package/src/I18n.d.ts +2 -0
- package/src/I18n.js +1 -0
- package/src/Module.js +78 -81
- package/src/Module.js.map +1 -1
- package/src/S3MediaObjects-JKMAWyVB.js +2664 -0
- package/src/S3MediaObjects-JKMAWyVB.js.map +1 -0
- package/src/Seed.d.ts +6 -0
- package/src/Seed.js +34 -0
- package/src/Seed.js.map +1 -0
- package/src/Seo-402YumpT.d.ts +198 -0
- package/src/{connection-ZGtL54qY.js → connection-B-iz0Y9Y.js} +5 -7
- package/src/connection-B-iz0Y9Y.js.map +1 -0
- package/src/{installation-BNKaVjni.js → installation-DgF2M1gL.js} +1162 -2147
- package/src/installation-DgF2M1gL.js.map +1 -0
- package/src/internal/authoring-catalog.js +153 -0
- package/src/internal/authoring-catalog.js.map +1 -0
- package/src/internal/authoring-compiler.js +2 -2
- package/src/internal/authoring-compiler.js.map +1 -1
- package/src/internal/authoring-metadata.js +68 -49
- package/src/internal/authoring-metadata.js.map +1 -1
- package/src/internal/cms-config.js +0 -1
- package/src/internal/cms-config.js.map +1 -1
- package/src/internal/configuration.js +25 -13
- package/src/internal/configuration.js.map +1 -1
- package/src/internal/document-model.js +66 -20
- package/src/internal/document-model.js.map +1 -1
- package/src/internal/form-capabilities.js +12 -0
- package/src/internal/form-capabilities.js.map +1 -0
- package/src/internal/i18n.js +47 -0
- package/src/internal/i18n.js.map +1 -0
- package/src/internal/studio-app.js +66 -0
- package/src/internal/studio-app.js.map +1 -0
- package/src/location-CFKTeK1K.js +35 -0
- package/src/location-CFKTeK1K.js.map +1 -0
- package/src/{metadata-Czvi3E4K.js → metadata-BEZPWh-3.js} +3 -72
- package/src/metadata-BEZPWh-3.js.map +1 -0
- package/src/{models-DS5ClMsH.js → models-BWm1pTAf.js} +9 -31
- package/src/models-BWm1pTAf.js.map +1 -0
- package/src/models-DwYioyNV.js +726 -0
- package/src/models-DwYioyNV.js.map +1 -0
- package/src/runtime/blocks.js +30 -0
- package/src/runtime/blocks.js.map +1 -0
- package/src/runtime/collaboration.js +9 -4
- package/src/runtime/collaboration.js.map +1 -1
- package/src/runtime/delivery/DocumentRenderer.js +10 -4
- package/src/runtime/delivery/DocumentRenderer.js.map +1 -1
- package/src/runtime/delivery/blocks.js +8 -0
- package/src/runtime/delivery/blocks.js.map +1 -0
- package/src/runtime/delivery/context.js +12 -0
- package/src/runtime/delivery/context.js.map +1 -0
- package/src/runtime/delivery/document-page.js +14 -12
- package/src/runtime/delivery/document-page.js.map +1 -1
- package/src/runtime/delivery/document.js +21 -3
- package/src/runtime/delivery/document.js.map +1 -1
- package/src/runtime/delivery/error.js +11 -0
- package/src/runtime/delivery/error.js.map +1 -0
- package/src/runtime/delivery/plugin.js +41 -0
- package/src/runtime/delivery/plugin.js.map +1 -0
- package/src/runtime/delivery/types.d.ts +5 -0
- package/src/runtime/delivery/useCmsDocumentSeo.d.ts +56 -0
- package/src/runtime/delivery/useCmsDocumentSeo.js +99 -0
- package/src/runtime/delivery/useCmsDocumentSeo.js.map +1 -0
- package/src/runtime/delivery/useDocument.js +5 -2
- package/src/runtime/delivery/useDocument.js.map +1 -1
- package/src/runtime/delivery/useDocumentQuery.js +5 -2
- package/src/runtime/delivery/useDocumentQuery.js.map +1 -1
- package/src/runtime/forms/document.js +38 -0
- package/src/runtime/forms/document.js.map +1 -0
- package/src/runtime/forms/useCmsForm.js +149 -0
- package/src/runtime/forms/useCmsForm.js.map +1 -0
- package/src/runtime/i18n/translator.js +22 -0
- package/src/runtime/i18n/translator.js.map +1 -0
- package/src/runtime/i18n/useCmsI18n.d.ts +9 -0
- package/src/runtime/i18n/useCmsI18n.js +29 -0
- package/src/runtime/i18n/useCmsI18n.js.map +1 -0
- package/src/runtime/installation.js +1 -1
- package/src/runtime/plugin.js +3 -3
- package/src/runtime/plugin.js.map +1 -1
- package/src/runtime/preview/comark-document.js +0 -1
- package/src/runtime/preview/comark-document.js.map +1 -1
- package/src/runtime/preview/connection.js +1 -1
- package/src/runtime/preview/controller.js +37 -11
- package/src/runtime/preview/controller.js.map +1 -1
- package/src/runtime/preview/overlay.js +65 -0
- package/src/runtime/preview/overlay.js.map +1 -0
- package/src/runtime/preview/plugin.client.js +59 -61
- package/src/runtime/preview/plugin.client.js.map +1 -1
- package/src/runtime/preview/preview.css +72 -4
- package/src/runtime/preview/protocol.js.map +1 -1
- package/src/runtime/preview/store.js +1 -1
- package/src/runtime/preview/targets.js +0 -1
- package/src/runtime/preview/targets.js.map +1 -1
- package/src/runtime/sitemap-entries.js +17 -0
- package/src/runtime/sitemap-entries.js.map +1 -0
- package/src/runtime/sitemap.js +24 -0
- package/src/runtime/sitemap.js.map +1 -0
- package/src/runtime/studio-app.js +5 -1
- package/src/runtime/studio-app.js.map +1 -1
- package/src/runtime/studio-entry.js +36 -0
- package/src/runtime/studio-entry.js.map +1 -0
- package/src/runtime/studio-navigation.js +11 -0
- package/src/runtime/studio-navigation.js.map +1 -0
- package/src/scalars-B2lgGUnj.js +26 -0
- package/src/scalars-B2lgGUnj.js.map +1 -0
- package/src/{store-Nl4uxEXx.js → store-DjJs3I7k.js} +12 -7
- package/src/store-DjJs3I7k.js.map +1 -0
- package/studio/CreateDocumentDialog-CTeIFlPb.js +256 -0
- package/studio/collaboration-DcK2F6v9.js +4566 -0
- package/studio/documentPlanning-Bfv-d7OU.js +29820 -0
- package/studio/dom-to-image-more.min-D6jGGdrW.js +877 -0
- package/studio/editor-Bzlh3zXt.js +30827 -0
- package/studio/host.css +3 -0
- package/studio/host.js +46614 -0
- package/studio/rolldown-runtime-B0aSnxlc.js +20 -0
- package/dist/studio/assets/ActivityEntryRow-D--fRvWI.js +0 -1
- package/dist/studio/assets/ActivityView-D-XBBUHb.js +0 -1
- package/dist/studio/assets/CreateDocumentDialog-CH8UH1QM.js +0 -1
- package/dist/studio/assets/DocumentsView-CxRpmAxt.js +0 -34
- package/dist/studio/assets/DropdownMenu-BSb1l7fr.js +0 -1
- package/dist/studio/assets/Input-DVao38h7.js +0 -3
- package/dist/studio/assets/MediaView-BHrPIjxB.js +0 -1
- package/dist/studio/assets/Modal-VNrXGa5C.js +0 -1
- package/dist/studio/assets/OverviewView-DfP6-mLZ.js +0 -1
- package/dist/studio/assets/Select-BJZIs9sY.js +0 -1
- package/dist/studio/assets/SettingsView-CerHe-ua.js +0 -1
- package/dist/studio/assets/Skeleton-CWJNi3nS.js +0 -1
- package/dist/studio/assets/StudioPageHeader-DP9HDAF2.js +0 -1
- package/dist/studio/assets/UsersView-cP3REkH2.js +0 -1
- package/dist/studio/assets/collaboration-BLnCzfvV.js +0 -4
- package/dist/studio/assets/context-dY4fNbn3.js +0 -1
- package/dist/studio/assets/editor-CE07wW83.js +0 -137
- package/dist/studio/assets/gateway-BAyQgCse.js +0 -10
- package/dist/studio/assets/index-CjoaPLhZ.js +0 -28
- package/dist/studio/assets/index-s2rPqCmP.css +0 -2
- package/dist/studio/assets/render-BkxbK2St.js +0 -83
- package/dist/studio/assets/rolldown-runtime-DK3Fl9T5.js +0 -1
- package/dist/studio/assets/useMediaLibrary-D7qR7aBf.js +0 -1
- package/dist/studio/index.html +0 -76
- package/src/AuthoringSchema-BQ5kbhVB.js.map +0 -1
- package/src/Configuration-BGYFD2N1.js +0 -150
- package/src/Configuration-BGYFD2N1.js.map +0 -1
- package/src/DocumentEngine-Da0kWotL.js.map +0 -1
- package/src/HttpPaths-86qLGB90.js +0 -15
- package/src/HttpPaths-86qLGB90.js.map +0 -1
- package/src/StudioHttp-BTLLooh0.js +0 -916
- package/src/StudioHttp-BTLLooh0.js.map +0 -1
- package/src/connection-ZGtL54qY.js.map +0 -1
- package/src/installation-BNKaVjni.js.map +0 -1
- package/src/internal/component-metadata.js +0 -37
- package/src/internal/component-metadata.js.map +0 -1
- package/src/metadata-Czvi3E4K.js.map +0 -1
- package/src/models-Citx8jBi.js +0 -306
- package/src/models-Citx8jBi.js.map +0 -1
- package/src/models-DS5ClMsH.js.map +0 -1
- package/src/store-Nl4uxEXx.js.map +0 -1
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { t as ComponentDefinition } from "../Configuration-BGYFD2N1.js";
|
|
2
|
-
|
|
3
|
-
//#region src/internal/component-metadata.ts
|
|
4
|
-
function cmsComponentDefinitions(metadata) {
|
|
5
|
-
const definitions = Object.values(metadata).filter((component) => component.global !== false).map((component) => ComponentDefinition.make({
|
|
6
|
-
name: component.kebabName,
|
|
7
|
-
props: component.meta.props.filter((prop) => !prop.global).map((prop) => ({
|
|
8
|
-
name: prop.name,
|
|
9
|
-
required: prop.required,
|
|
10
|
-
type: componentPropType(component.pascalName, prop.name, prop.type)
|
|
11
|
-
})),
|
|
12
|
-
slots: component.meta.slots.map((slot) => ({ name: slot.name }))
|
|
13
|
-
})).sort((left, right) => left.name.localeCompare(right.name));
|
|
14
|
-
const names = /* @__PURE__ */ new Set();
|
|
15
|
-
for (const definition of definitions) {
|
|
16
|
-
if (names.has(definition.name)) throw new Error(`Global document component "${definition.name}" is defined more than once.`);
|
|
17
|
-
names.add(definition.name);
|
|
18
|
-
}
|
|
19
|
-
return definitions;
|
|
20
|
-
}
|
|
21
|
-
function componentPropType(componentName, propName, declaredType) {
|
|
22
|
-
const classified = declaredType.split("|").map((member) => member.trim()).filter((member) => member !== "null" && member !== "undefined").map(classifyPropType);
|
|
23
|
-
const types = new Set(classified);
|
|
24
|
-
if (!classified.includes(void 0) && types.size === 1) return [...types][0];
|
|
25
|
-
throw new Error(`Global document component "${componentName}" prop "${propName}" has unsupported type "${declaredType}". Use one JSON-compatible string, number, boolean, array, or object type.`);
|
|
26
|
-
}
|
|
27
|
-
function classifyPropType(type) {
|
|
28
|
-
if (type === "string" || /^(['"]).*\1$/u.test(type)) return "string";
|
|
29
|
-
if (type === "number" || /^-?\d+(?:\.\d+)?$/u.test(type)) return "number";
|
|
30
|
-
if (type === "boolean" || type === "true" || type === "false") return "boolean";
|
|
31
|
-
if (/^(?:readonly\s+)?(?:Array|ReadonlyArray)</u.test(type) || type.endsWith("[]") || type.startsWith("[")) return "array";
|
|
32
|
-
if (type === "object" || type.startsWith("{") || /^(?:Readonly|Record)</u.test(type)) return "object";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { cmsComponentDefinitions };
|
|
37
|
-
//# sourceMappingURL=component-metadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-metadata.js","names":["ComponentDefinitionSchema"],"sources":["../../../../src/internal/component-metadata.ts"],"sourcesContent":["import type { ComponentDefinition, ComponentPropDefinition } from '@internal/protocol/Configuration'\nimport { ComponentDefinition as ComponentDefinitionSchema } from '@internal/protocol/Configuration'\n\ninterface NuxtComponentMetadata {\n readonly global?: boolean | 'sync'\n readonly kebabName: string\n readonly meta: {\n readonly props: ReadonlyArray<{\n readonly global: boolean\n readonly name: string\n readonly required: boolean\n readonly type: string\n }>\n readonly slots: ReadonlyArray<{ readonly name: string }>\n }\n readonly pascalName: string\n}\n\nexport function cmsComponentDefinitions(\n metadata: Readonly<Record<string, NuxtComponentMetadata>>,\n): ReadonlyArray<ComponentDefinition> {\n const definitions = Object.values(metadata)\n // nuxt-component-meta is configured with globalsOnly; undefined means a\n // globally available component whose registration mode was not annotated.\n .filter((component) => component.global !== false)\n .map((component) =>\n ComponentDefinitionSchema.make({\n name: component.kebabName,\n props: component.meta.props\n .filter((prop) => !prop.global)\n .map((prop) => ({\n name: prop.name,\n required: prop.required,\n type: componentPropType(component.pascalName, prop.name, prop.type),\n })),\n slots: component.meta.slots.map((slot) => ({ name: slot.name })),\n }),\n )\n .sort((left, right) => left.name.localeCompare(right.name))\n\n const names = new Set<string>()\n for (const definition of definitions) {\n if (names.has(definition.name))\n throw new Error(`Global document component \"${definition.name}\" is defined more than once.`)\n names.add(definition.name)\n }\n return definitions\n}\n\nfunction componentPropType(\n componentName: string,\n propName: string,\n declaredType: string,\n): ComponentPropDefinition['type'] {\n const members = declaredType\n .split('|')\n .map((member) => member.trim())\n .filter((member) => member !== 'null' && member !== 'undefined')\n const classified = members.map(classifyPropType)\n const types = new Set(classified)\n if (!classified.includes(undefined) && types.size === 1) return [...types][0]!\n throw new Error(\n `Global document component \"${componentName}\" prop \"${propName}\" has unsupported type \"${declaredType}\". ` +\n 'Use one JSON-compatible string, number, boolean, array, or object type.',\n )\n}\n\nfunction classifyPropType(type: string): ComponentPropDefinition['type'] | undefined {\n if (type === 'string' || /^(['\"]).*\\1$/u.test(type)) return 'string'\n if (type === 'number' || /^-?\\d+(?:\\.\\d+)?$/u.test(type)) return 'number'\n if (type === 'boolean' || type === 'true' || type === 'false') return 'boolean'\n if (/^(?:readonly\\s+)?(?:Array|ReadonlyArray)</u.test(type) || type.endsWith('[]') || type.startsWith('['))\n return 'array'\n if (type === 'object' || type.startsWith('{') || /^(?:Readonly|Record)</u.test(type)) return 'object'\n return undefined\n}\n"],"mappings":";;;AAkBA,SAAgB,wBACd,UACoC;CACpC,MAAM,cAAc,OAAO,OAAO,QAAQ,CAAC,CAGxC,QAAQ,cAAc,UAAU,WAAW,KAAK,CAAC,CACjD,KAAK,cACJA,oBAA0B,KAAK;EAC7B,MAAM,UAAU;EAChB,OAAO,UAAU,KAAK,MACnB,QAAQ,SAAS,CAAC,KAAK,MAAM,CAAC,CAC9B,KAAK,UAAU;GACd,MAAM,KAAK;GACX,UAAU,KAAK;GACf,MAAM,kBAAkB,UAAU,YAAY,KAAK,MAAM,KAAK,IAAI;EACpE,EAAE;EACJ,OAAO,UAAU,KAAK,MAAM,KAAK,UAAU,EAAE,MAAM,KAAK,KAAK,EAAE;CACjE,CAAC,CACH,CAAC,CACA,MAAM,MAAM,UAAU,KAAK,KAAK,cAAc,MAAM,IAAI,CAAC;CAE5D,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,cAAc,aAAa;EACpC,IAAI,MAAM,IAAI,WAAW,IAAI,GAC3B,MAAM,IAAI,MAAM,8BAA8B,WAAW,KAAK,6BAA6B;EAC7F,MAAM,IAAI,WAAW,IAAI;CAC3B;CACA,OAAO;AACT;AAEA,SAAS,kBACP,eACA,UACA,cACiC;CAKjC,MAAM,aAJU,aACb,MAAM,GAAG,CAAC,CACV,KAAK,WAAW,OAAO,KAAK,CAAC,CAAC,CAC9B,QAAQ,WAAW,WAAW,UAAU,WAAW,WAC7B,CAAC,CAAC,IAAI,gBAAgB;CAC/C,MAAM,QAAQ,IAAI,IAAI,UAAU;CAChC,IAAI,CAAC,WAAW,SAAS,MAAS,KAAK,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;CAC3E,MAAM,IAAI,MACR,8BAA8B,cAAc,UAAU,SAAS,0BAA0B,aAAa,2EAExG;AACF;AAEA,SAAS,iBAAiB,MAA2D;CACnF,IAAI,SAAS,YAAY,gBAAgB,KAAK,IAAI,GAAG,OAAO;CAC5D,IAAI,SAAS,YAAY,qBAAqB,KAAK,IAAI,GAAG,OAAO;CACjE,IAAI,SAAS,aAAa,SAAS,UAAU,SAAS,SAAS,OAAO;CACtE,IAAI,6CAA6C,KAAK,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,WAAW,GAAG,GACvG,OAAO;CACT,IAAI,SAAS,YAAY,KAAK,WAAW,GAAG,KAAK,yBAAyB,KAAK,IAAI,GAAG,OAAO;AAE/F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-Czvi3E4K.js","names":["isJsonObject","jsonObject","EditorNodeIdSchema"],"sources":["../../../../document/src/internal/comark/document-adapter.ts","../../../../document/src/internal/editor/identity.ts","../../../../document/src/internal/editor/metadata.ts"],"sourcesContent":["import type { CmsMarkdownDocument, MarkdownNode } from '@internal/protocol/Documents'\nimport type {\n ElementNodeAttributes,\n MarkdownDocument as ComarkMarkdownDocument,\n Node as ComarkNode,\n NodeRenderData,\n} from 'comark'\nimport { textContent } from 'comark/utils'\nimport { Predicate, Schema } from 'effect'\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\n/** The only adapter from the validated wire document to Comark's mutable document model. */\nexport function toComarkDocument(document: CmsMarkdownDocument): ComarkMarkdownDocument {\n return {\n frontmatter: mutableJsonObject(document.frontmatter),\n meta: mutableJsonObject(document.meta),\n nodes: document.nodes.map(toComarkNode),\n }\n}\n\nexport function createCmsComarkRenderData(document: CmsMarkdownDocument): NodeRenderData {\n return {\n data: {},\n frontmatter: mutableJsonObject(document.frontmatter),\n meta: mutableJsonObject(document.meta),\n props: {},\n }\n}\n\n/** Extracts inline text with Comark semantics, preserving punctuation between nested inline nodes. */\nexport function cmsComarkTextContent(node: MarkdownNode): string {\n return textContent(toComarkNode(node), { decodeUnicodeEntities: true })\n}\n\nexport function toMutableComarkAttributes(attributes: Schema.JsonObject): ElementNodeAttributes {\n const result: ElementNodeAttributes = {}\n for (const [name, value] of Object.entries(attributes)) {\n if (name !== '$') result[name] = mutableJson(value)\n }\n const internal = jsonObject(attributes.$)\n const line = internal.line\n const html = binaryFlag(internal.html)\n const block = binaryFlag(internal.block)\n if (Predicate.isNumber(line) || html !== undefined || block !== undefined) {\n const metadata: Record<string, number> = {}\n if (Predicate.isNumber(line)) metadata.line = line\n if (html !== undefined) metadata.html = html\n if (block !== undefined) metadata.block = block\n result.$ = metadata\n }\n return result\n}\n\nexport function mutableJson(value: Schema.Json): Schema.Json {\n if (Array.isArray(value)) return value.map(mutableJson)\n if (isJsonObject(value)) return mutableJsonObject(value)\n return value\n}\n\nfunction toComarkNode(node: MarkdownNode): ComarkNode {\n if (Predicate.isString(node)) return node\n if (node[0] === null) return [null, toMutableComarkAttributes(node[1]), node[2]]\n const [tag, attributes, ...children] = node\n return [tag, toMutableComarkAttributes(attributes), ...children.map(toComarkNode)]\n}\n\nexport function mutableJsonObject(value: Schema.JsonObject): Record<string, Schema.Json> {\n return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, mutableJson(child)]))\n}\n\nfunction binaryFlag(value: Schema.Json | undefined): 0 | 1 | undefined {\n return value === 0 || value === 1 ? value : undefined\n}\n\nfunction jsonObject(value: Schema.Json | undefined): Schema.JsonObject {\n return isJsonObject(value) ? value : {}\n}\n","import type { EditorNodeId } from '@internal/protocol/Documents'\nimport { EditorNodeId as EditorNodeIdSchema } from '@internal/protocol/Documents'\nimport { Schema } from 'effect'\n\nconst isEditorNodeId = Schema.is(EditorNodeIdSchema)\n\nexport const IDENTIFIED_EDITOR_TYPES = new Set([\n 'blockquote',\n 'bulletList',\n 'cmsBlock',\n 'cmsOpaque',\n 'cmsSlot',\n 'codeBlock',\n 'heading',\n 'horizontalRule',\n 'image',\n 'listItem',\n 'orderedList',\n 'paragraph',\n])\n\nexport function createEditorNodeId(): EditorNodeId {\n const bytes = globalThis.crypto.getRandomValues(new Uint8Array(16))\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80\n const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('')\n return EditorNodeIdSchema.make(\n `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`,\n )\n}\n\nexport function editorNodeId(value: Schema.Json | undefined): EditorNodeId | undefined {\n return isEditorNodeId(value) ? value : undefined\n}\n\nexport function isIdentifiedEditorType(type: string | undefined): boolean {\n return type !== undefined && IDENTIFIED_EDITOR_TYPES.has(type)\n}\n","import type { CmsMarkdownDocument, MarkdownNode } from '@internal/protocol/Documents'\nimport type { EditorNodeId } from '@internal/protocol/Documents'\nimport type { JSONContent } from '@tiptap/core'\nimport { Predicate, Schema } from 'effect'\nimport { editorNodeId, isIdentifiedEditorType } from './identity'\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\ninterface EditorMetadata {\n readonly implicitSlotId?: EditorNodeId\n readonly nodeId: EditorNodeId\n}\n\nexport function assertCanonicalEditorContent(content: JSONContent): void {\n const seen = new Set<EditorNodeId>()\n const visit = (node: JSONContent, path: ReadonlyArray<number>) => {\n if (isIdentifiedEditorNode(node)) {\n const id = editorNodeId(node.attrs?.cmsNodeId)\n if (id === undefined) {\n throw new Error(`Authorable ${node.type} at ${diagnosticPath(path)} has no valid node identity.`)\n }\n if (seen.has(id)) {\n throw new Error(`Authorable ${node.type} at ${diagnosticPath(path)} duplicates node identity \"${id}\".`)\n }\n seen.add(id)\n }\n node.content?.forEach((child, index) => visit(child, [...path, index]))\n }\n visit(content, [])\n}\n\nexport function identifiedAttributes(\n attributes: Schema.JsonObject,\n nodeIdValue: Schema.Json | undefined,\n implicitSlotIdValue?: Schema.Json,\n): Schema.JsonObject {\n const nodeId = editorNodeId(nodeIdValue)\n const implicitSlotId = implicitSlotIdValue === undefined ? undefined : editorNodeId(implicitSlotIdValue)\n if (nodeId === undefined) throw new Error('Cannot project an authorable node without a valid identity.')\n if (implicitSlotIdValue !== undefined && implicitSlotId === undefined)\n throw new Error('Cannot project an implicit slot without a valid identity.')\n\n const internal: Record<string, Schema.Json> = structuredClone(jsonObject(attributes.$))\n if (implicitSlotId === undefined) internal.editor = { nodeId }\n else internal.editor = { implicitSlotId, nodeId }\n const result: Record<string, Schema.Json> = structuredClone(attributes)\n result.$ = internal\n return result\n}\n\nexport function editorMetadata(attributes: Schema.JsonObject): EditorMetadata | undefined {\n const metadata = jsonObject(jsonObject(attributes.$).editor)\n const nodeId = editorNodeId(metadata.nodeId)\n const implicitSlotId = metadata.implicitSlotId === undefined ? undefined : editorNodeId(metadata.implicitSlotId)\n if (nodeId === undefined) return undefined\n if (metadata.implicitSlotId !== undefined && implicitSlotId === undefined) return undefined\n return implicitSlotId === undefined ? { nodeId } : { implicitSlotId, nodeId }\n}\n\nexport function withoutEditorMetadata(body: CmsMarkdownDocument): CmsMarkdownDocument {\n return {\n frontmatter: structuredClone(body.frontmatter),\n meta: structuredClone(body.meta),\n nodes: body.nodes.map(cleanNode),\n }\n}\n\nfunction cleanNode(node: MarkdownNode): MarkdownNode {\n if (Predicate.isString(node)) return node\n if (node[0] === null) {\n const cleanAttributes = cleanNodeAttributes(node[1])\n return [null, cleanAttributes, node[2]]\n }\n const [tag, attributes, ...children] = node\n return [tag, cleanNodeAttributes(attributes), ...children.map(cleanNode)]\n}\n\nfunction cleanNodeAttributes(attributes: Schema.JsonObject): Record<string, Schema.Json> {\n const cleanAttributes: Record<string, Schema.Json> = structuredClone(attributes)\n const internal = jsonObject(cleanAttributes.$)\n if (internal.editor !== undefined) {\n const { editor: _editor, ...remaining } = internal\n if (Object.keys(remaining).length) cleanAttributes.$ = remaining\n else delete cleanAttributes.$\n }\n return cleanAttributes\n}\n\nfunction isIdentifiedEditorNode(node: JSONContent): boolean {\n if (!isIdentifiedEditorType(node.type)) return false\n if (node.attrs?.cmsSynthetic === true || node.attrs?.cmsTransient === true) return false\n return node.type !== 'paragraph' || Boolean(node.content?.length)\n}\n\nfunction diagnosticPath(path: ReadonlyArray<number>): string {\n return path.length ? path.join('.') : 'document root'\n}\n\nfunction jsonObject(value: Schema.Json | undefined): Schema.JsonObject {\n return isJsonObject(value) ? value : {}\n}\n"],"mappings":";;;;;AAUA,MAAMA,iBAAe,OAAO,GAAG,OAAO,UAAU;;AAGhD,SAAgB,iBAAiB,UAAuD;CACtF,OAAO;EACL,aAAa,kBAAkB,SAAS,WAAW;EACnD,MAAM,kBAAkB,SAAS,IAAI;EACrC,OAAO,SAAS,MAAM,IAAI,YAAY;CACxC;AACF;AAEA,SAAgB,0BAA0B,UAA+C;CACvF,OAAO;EACL,MAAM,CAAC;EACP,aAAa,kBAAkB,SAAS,WAAW;EACnD,MAAM,kBAAkB,SAAS,IAAI;EACrC,OAAO,CAAC;CACV;AACF;;AAGA,SAAgB,qBAAqB,MAA4B;CAC/D,OAAO,YAAY,aAAa,IAAI,GAAG,EAAE,uBAAuB,KAAK,CAAC;AACxE;AAEA,SAAgB,0BAA0B,YAAsD;CAC9F,MAAM,SAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,UAAU,GACnD,IAAI,SAAS,KAAK,OAAO,QAAQ,YAAY,KAAK;CAEpD,MAAM,WAAWC,aAAW,WAAW,CAAC;CACxC,MAAM,OAAO,SAAS;CACtB,MAAM,OAAO,WAAW,SAAS,IAAI;CACrC,MAAM,QAAQ,WAAW,SAAS,KAAK;CACvC,IAAI,UAAU,SAAS,IAAI,KAAK,SAAS,UAAa,UAAU,QAAW;EACzE,MAAM,WAAmC,CAAC;EAC1C,IAAI,UAAU,SAAS,IAAI,GAAG,SAAS,OAAO;EAC9C,IAAI,SAAS,QAAW,SAAS,OAAO;EACxC,IAAI,UAAU,QAAW,SAAS,QAAQ;EAC1C,OAAO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I,CAAC,uBAAuB,KAAK,IAAI,GAAG,OAAO;CAC/C,IAAI,KAAK,OAAO,iBAAiB,QAAQ,KAAK,OAAO,iBAAiB,MAAM,OAAO;CACnF,OAAO,KAAK,SAAS,eAAe,QAAQ,KAAK,SAAS,MAAM;AAClE;AAEA,SAAS,eAAe,MAAqC;CAC3D,OAAO,KAAK,SAAS,KAAK,KAAK,GAAG,IAAI;AACxC;AAEA,SAAS,WAAW,OAAmD;CACrE,OAAO,aAAa,KAAK,IAAI,QAAQ,CAAC;AACxC"}
|
package/src/models-Citx8jBi.js
DELETED
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
|
|
3
|
-
//#region ../protocol/src/internal/scalars.ts
|
|
4
|
-
const nonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
5
|
-
const publicPathPattern = /^\/(?!(?:[^/]+\/)*\.\.?(?:\/|$))(?:[^/?#\\]+(?:\/[^/?#\\]+)*)?$/u;
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region ../protocol/src/internal/documents/scalars.ts
|
|
9
|
-
const relativeDocumentPathPattern = /^(?!(?:[^/]+\/)*\.\.?(?:\/|$))[^/?#\\]+(?:\/[^/?#\\]+)*$/u;
|
|
10
|
-
const slugPattern = /^[\p{Letter}\p{Number}][\p{Letter}\p{Number}_-]*$/u;
|
|
11
|
-
const sourcePathPattern = /^(?!\.)[^/?#\\]+(?:\/(?!\.)[^/?#\\]+)*\.(?:md|mdc)$/u;
|
|
12
|
-
const DocumentGeneration = Schema.String.check(Schema.isPattern(/^(?:0|[1-9]\d*)$/u)).pipe(Schema.brand("DocumentGeneration"));
|
|
13
|
-
const DocumentVersion = Schema.NonEmptyString.pipe(Schema.brand("DocumentVersion"));
|
|
14
|
-
const DocumentHistoryCursor = Schema.NonEmptyString.pipe(Schema.brand("DocumentHistoryCursor"));
|
|
15
|
-
const DocumentId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand("DocumentId"));
|
|
16
|
-
const EditorNodeId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand("EditorNodeId"));
|
|
17
|
-
const PublicPath = Schema.String.check(Schema.isPattern(publicPathPattern)).pipe(Schema.brand("PublicPath"));
|
|
18
|
-
const RelativeDocumentPath = Schema.String.check(Schema.isPattern(relativeDocumentPathPattern)).pipe(Schema.brand("RelativeDocumentPath"));
|
|
19
|
-
const RevisionId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand("RevisionId"));
|
|
20
|
-
const RevisionNumber = nonNegativeInt.pipe(Schema.brand("RevisionNumber"));
|
|
21
|
-
const Slug = Schema.String.check(Schema.isPattern(slugPattern)).pipe(Schema.brand("Slug"));
|
|
22
|
-
const SourcePath = Schema.String.check(Schema.isPattern(sourcePathPattern)).pipe(Schema.brand("SourcePath"));
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region ../protocol/src/internal/configuration/scalars.ts
|
|
26
|
-
const collectionNamePattern = /^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$/u;
|
|
27
|
-
const localePattern = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u;
|
|
28
|
-
const sourceDirectoryPattern = /^(?:\.|(?!\.)[^/?#\\]+(?:\/(?!\.)[^/?#\\]+)*)$/u;
|
|
29
|
-
const AddressPattern = Schema.String.check(Schema.isPattern(publicPathPattern)).pipe(Schema.brand("AddressPattern"));
|
|
30
|
-
const CollectionName = Schema.String.check(Schema.isPattern(collectionNamePattern)).pipe(Schema.brand("CollectionName"));
|
|
31
|
-
const Locale = Schema.String.check(Schema.isPattern(localePattern)).pipe(Schema.brand("Locale"));
|
|
32
|
-
const SourceDirectory = Schema.String.check(Schema.isPattern(sourceDirectoryPattern)).pipe(Schema.brand("SourceDirectory"));
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region ../protocol/src/internal/documents/models.ts
|
|
36
|
-
const DocumentIssueCode = Schema.Literals([
|
|
37
|
-
"document.collision",
|
|
38
|
-
"document.id",
|
|
39
|
-
"document.invalid",
|
|
40
|
-
"i18n.missing-translation",
|
|
41
|
-
"markdown.parse",
|
|
42
|
-
"reference.document",
|
|
43
|
-
"reference.component",
|
|
44
|
-
"schema.option",
|
|
45
|
-
"schema.constraint",
|
|
46
|
-
"schema.required",
|
|
47
|
-
"schema.type",
|
|
48
|
-
"schema.unknown"
|
|
49
|
-
]);
|
|
50
|
-
const DocumentIssue = Schema.Struct({
|
|
51
|
-
code: DocumentIssueCode,
|
|
52
|
-
severity: Schema.Literals(["error", "warning"]),
|
|
53
|
-
message: Schema.NonEmptyString,
|
|
54
|
-
sourcePath: Schema.optionalKey(SourcePath),
|
|
55
|
-
collection: Schema.optionalKey(CollectionName),
|
|
56
|
-
field: Schema.optionalKey(Schema.NonEmptyString),
|
|
57
|
-
key: Schema.optionalKey(PublicPath),
|
|
58
|
-
locale: Schema.optionalKey(Locale)
|
|
59
|
-
}).annotate({ identifier: "DocumentIssue" });
|
|
60
|
-
const DocumentSourcePoint = Schema.Struct({
|
|
61
|
-
offset: nonNegativeInt,
|
|
62
|
-
line: nonNegativeInt,
|
|
63
|
-
column: nonNegativeInt
|
|
64
|
-
});
|
|
65
|
-
const DocumentSourceRange = Schema.Struct({
|
|
66
|
-
start: DocumentSourcePoint,
|
|
67
|
-
end: DocumentSourcePoint
|
|
68
|
-
});
|
|
69
|
-
const DocumentSourceMapping = Schema.Struct({
|
|
70
|
-
nodePath: Schema.Array(nonNegativeInt),
|
|
71
|
-
range: DocumentSourceRange
|
|
72
|
-
});
|
|
73
|
-
const MarkdownNode = Schema.suspend(() => Schema.Union([
|
|
74
|
-
Schema.String,
|
|
75
|
-
Schema.Tuple([
|
|
76
|
-
Schema.Null,
|
|
77
|
-
Schema.JsonObject,
|
|
78
|
-
Schema.String
|
|
79
|
-
]),
|
|
80
|
-
Schema.TupleWithRest(Schema.Tuple([Schema.NonEmptyString, Schema.JsonObject]), [MarkdownNode])
|
|
81
|
-
]));
|
|
82
|
-
const CmsMarkdownDocument = Schema.Struct({
|
|
83
|
-
nodes: Schema.Array(MarkdownNode),
|
|
84
|
-
frontmatter: Schema.JsonObject,
|
|
85
|
-
meta: Schema.JsonObject
|
|
86
|
-
}).annotate({ identifier: "CmsMarkdownDocument" });
|
|
87
|
-
const CmsDocumentHeading = Schema.Struct({
|
|
88
|
-
depth: Schema.Int.check(Schema.isBetween({
|
|
89
|
-
minimum: 1,
|
|
90
|
-
maximum: 6
|
|
91
|
-
})),
|
|
92
|
-
id: Schema.String,
|
|
93
|
-
text: Schema.String
|
|
94
|
-
});
|
|
95
|
-
/** Stable, JSON-safe analysis derived from the same document used for delivery. */
|
|
96
|
-
const CmsDocumentAnalysis = Schema.Struct({
|
|
97
|
-
components: Schema.Array(Schema.NonEmptyString),
|
|
98
|
-
headings: Schema.Array(CmsDocumentHeading),
|
|
99
|
-
searchText: Schema.String,
|
|
100
|
-
summary: Schema.String
|
|
101
|
-
});
|
|
102
|
-
const CompiledDocumentSource = Schema.Struct({
|
|
103
|
-
path: SourcePath,
|
|
104
|
-
mappings: Schema.Array(DocumentSourceMapping)
|
|
105
|
-
});
|
|
106
|
-
const CompiledDocument = Schema.Struct({
|
|
107
|
-
id: DocumentId,
|
|
108
|
-
key: PublicPath,
|
|
109
|
-
path: PublicPath,
|
|
110
|
-
locale: Schema.optionalKey(Locale),
|
|
111
|
-
collection: CollectionName,
|
|
112
|
-
draft: Schema.Boolean,
|
|
113
|
-
title: Schema.NonEmptyString,
|
|
114
|
-
description: Schema.optionalKey(Schema.String),
|
|
115
|
-
data: Schema.JsonObject,
|
|
116
|
-
issues: Schema.Array(DocumentIssue),
|
|
117
|
-
analysis: CmsDocumentAnalysis,
|
|
118
|
-
body: CmsMarkdownDocument,
|
|
119
|
-
engineFingerprint: Schema.NonEmptyString,
|
|
120
|
-
source: CompiledDocumentSource
|
|
121
|
-
}).annotate({ identifier: "CompiledDocument" });
|
|
122
|
-
const DocumentSource = Schema.Struct({
|
|
123
|
-
documentId: DocumentId,
|
|
124
|
-
sourcePath: SourcePath,
|
|
125
|
-
markdown: Schema.String,
|
|
126
|
-
revisionId: RevisionId,
|
|
127
|
-
version: DocumentVersion,
|
|
128
|
-
publishedVersion: Schema.optionalKey(DocumentVersion)
|
|
129
|
-
}).annotate({ identifier: "DocumentSource" });
|
|
130
|
-
const DocumentImportSource = Schema.Struct({
|
|
131
|
-
sourcePath: SourcePath,
|
|
132
|
-
markdown: Schema.String,
|
|
133
|
-
published: Schema.Boolean
|
|
134
|
-
}).annotate({ identifier: "DocumentImportSource" });
|
|
135
|
-
const DocumentImportMode = Schema.Literals(["preserve", "overwrite"]);
|
|
136
|
-
const DocumentImportInput = Schema.Struct({
|
|
137
|
-
sources: Schema.Array(DocumentImportSource),
|
|
138
|
-
mode: DocumentImportMode,
|
|
139
|
-
reason: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(1e3)))
|
|
140
|
-
}).annotate({ identifier: "DocumentImportInput" });
|
|
141
|
-
const DocumentImportReport = Schema.Struct({
|
|
142
|
-
created: nonNegativeInt,
|
|
143
|
-
preserved: nonNegativeInt,
|
|
144
|
-
published: nonNegativeInt,
|
|
145
|
-
unchanged: nonNegativeInt,
|
|
146
|
-
updated: nonNegativeInt
|
|
147
|
-
}).annotate({ identifier: "DocumentImportReport" });
|
|
148
|
-
const DocumentSummary = Schema.Struct({
|
|
149
|
-
sourcePath: SourcePath,
|
|
150
|
-
version: DocumentVersion,
|
|
151
|
-
document: CompiledDocument
|
|
152
|
-
}).annotate({ identifier: "DocumentSummary" });
|
|
153
|
-
const DeletedDocument = Schema.Struct({
|
|
154
|
-
documentId: DocumentId,
|
|
155
|
-
deletedAt: Schema.DateTimeUtcFromString,
|
|
156
|
-
sourcePath: SourcePath,
|
|
157
|
-
version: DocumentVersion
|
|
158
|
-
}).annotate({ identifier: "DeletedDocument" });
|
|
159
|
-
const DocumentBrowseQuery = Schema.Struct({
|
|
160
|
-
collection: Schema.optionalKey(CollectionName),
|
|
161
|
-
locale: Schema.optionalKey(Locale)
|
|
162
|
-
}).annotate({ identifier: "DocumentBrowseQuery" });
|
|
163
|
-
const PublishedDocumentLookup = Schema.Union([
|
|
164
|
-
Schema.Struct({
|
|
165
|
-
kind: Schema.tag("id"),
|
|
166
|
-
documentId: DocumentId
|
|
167
|
-
}),
|
|
168
|
-
Schema.Struct({
|
|
169
|
-
kind: Schema.tag("path"),
|
|
170
|
-
path: PublicPath
|
|
171
|
-
}),
|
|
172
|
-
Schema.Struct({
|
|
173
|
-
kind: Schema.tag("key"),
|
|
174
|
-
key: PublicPath,
|
|
175
|
-
collection: Schema.optionalKey(CollectionName),
|
|
176
|
-
locale: Schema.optionalKey(Locale)
|
|
177
|
-
})
|
|
178
|
-
]).pipe(Schema.toTaggedUnion("kind"));
|
|
179
|
-
const DocumentQueryScalar = Schema.Union([
|
|
180
|
-
Schema.String,
|
|
181
|
-
Schema.Finite,
|
|
182
|
-
Schema.Boolean,
|
|
183
|
-
Schema.Null
|
|
184
|
-
]);
|
|
185
|
-
const validDocumentQueryField = Schema.makeFilter((field) => {
|
|
186
|
-
const segments = field.split(".");
|
|
187
|
-
return field.length <= 200 && segments.length <= 8 && segments.every((segment) => segment.length > 0);
|
|
188
|
-
}, { expected: "a non-empty field path of at most 200 characters and eight non-empty segments" });
|
|
189
|
-
const DocumentQueryField = Schema.NonEmptyString.check(validDocumentQueryField);
|
|
190
|
-
const DocumentQueryValue = Schema.Union([DocumentQueryScalar, Schema.Array(DocumentQueryScalar).check(Schema.isMaxLength(20))]);
|
|
191
|
-
const DocumentQuerySort = Schema.Struct({
|
|
192
|
-
field: DocumentQueryField,
|
|
193
|
-
direction: Schema.optionalKey(Schema.Literals(["asc", "desc"]))
|
|
194
|
-
});
|
|
195
|
-
const DocumentQueryWhere = Schema.Record(Schema.String, DocumentQueryValue).check(Schema.makeFilter((where) => Object.keys(where).every((field) => Schema.is(DocumentQueryField)(field)), { expected: "document query keys with valid bounded field paths" }), Schema.makeFilter((where) => Object.keys(where).length <= 12, { expected: "at most 12 document query filters" }));
|
|
196
|
-
const PublishedDocumentSelection = Schema.Struct({
|
|
197
|
-
collection: Schema.optionalKey(CollectionName),
|
|
198
|
-
locale: Schema.optionalKey(Locale),
|
|
199
|
-
where: Schema.optionalKey(DocumentQueryWhere),
|
|
200
|
-
sort: Schema.optionalKey(Schema.Array(DocumentQuerySort).check(Schema.isMaxLength(4)))
|
|
201
|
-
}).annotate({ identifier: "PublishedDocumentSelection" });
|
|
202
|
-
const PublishedDocumentQuery = Schema.Struct({
|
|
203
|
-
...PublishedDocumentSelection.fields,
|
|
204
|
-
offset: Schema.optionalKey(nonNegativeInt),
|
|
205
|
-
limit: Schema.Int.check(Schema.isBetween({
|
|
206
|
-
minimum: 1,
|
|
207
|
-
maximum: 100
|
|
208
|
-
}))
|
|
209
|
-
}).annotate({ identifier: "PublishedDocumentQuery" });
|
|
210
|
-
const PublishedDocumentSurroundQuery = Schema.Struct({ ...PublishedDocumentSelection.fields }).annotate({ identifier: "PublishedDocumentSurroundQuery" });
|
|
211
|
-
const PublishedDocumentPage = Schema.Struct({
|
|
212
|
-
items: Schema.Array(CompiledDocument),
|
|
213
|
-
total: nonNegativeInt
|
|
214
|
-
}).annotate({ identifier: "PublishedDocumentPage" });
|
|
215
|
-
const DocumentNavigationQuery = Schema.Struct({
|
|
216
|
-
collection: Schema.optionalKey(CollectionName),
|
|
217
|
-
locale: Schema.optionalKey(Locale)
|
|
218
|
-
}).annotate({ identifier: "DocumentNavigationQuery" });
|
|
219
|
-
const documentMutationMetadata = { reason: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(1e3))) };
|
|
220
|
-
const DocumentNavigationItem = Schema.suspend(() => Schema.Struct({
|
|
221
|
-
key: PublicPath,
|
|
222
|
-
title: Schema.NonEmptyString,
|
|
223
|
-
path: Schema.optionalKey(PublicPath),
|
|
224
|
-
locale: Schema.optionalKey(Locale),
|
|
225
|
-
documentId: Schema.optionalKey(DocumentId),
|
|
226
|
-
children: Schema.Array(DocumentNavigationItem)
|
|
227
|
-
}));
|
|
228
|
-
const DocumentSurround = Schema.Struct({
|
|
229
|
-
previous: Schema.NullOr(CompiledDocument),
|
|
230
|
-
next: Schema.NullOr(CompiledDocument)
|
|
231
|
-
}).annotate({ identifier: "DocumentSurround" });
|
|
232
|
-
const HomeDocumentLocation = Schema.Struct({ kind: Schema.tag("home") });
|
|
233
|
-
const NestedDocumentLocation = Schema.Struct({
|
|
234
|
-
kind: Schema.tag("entry"),
|
|
235
|
-
parent: Schema.optionalKey(RelativeDocumentPath),
|
|
236
|
-
slug: Slug
|
|
237
|
-
});
|
|
238
|
-
const DocumentLocation = Schema.Union([HomeDocumentLocation, NestedDocumentLocation]).pipe(Schema.toTaggedUnion("kind"));
|
|
239
|
-
const CreateDocumentInput = Schema.Struct({
|
|
240
|
-
collection: CollectionName,
|
|
241
|
-
locale: Schema.optionalKey(Locale),
|
|
242
|
-
location: DocumentLocation,
|
|
243
|
-
title: Schema.NonEmptyString,
|
|
244
|
-
...documentMutationMetadata
|
|
245
|
-
}).annotate({ identifier: "CreateDocumentInput" });
|
|
246
|
-
const UpdateDocumentInput = Schema.Struct({
|
|
247
|
-
documentId: DocumentId,
|
|
248
|
-
expectedVersion: DocumentVersion,
|
|
249
|
-
markdown: Schema.String,
|
|
250
|
-
...documentMutationMetadata
|
|
251
|
-
}).annotate({ identifier: "UpdateDocumentInput" });
|
|
252
|
-
const MoveDocumentInput = Schema.Struct({
|
|
253
|
-
documentId: DocumentId,
|
|
254
|
-
expectedVersion: DocumentVersion,
|
|
255
|
-
location: DocumentLocation,
|
|
256
|
-
...documentMutationMetadata
|
|
257
|
-
}).annotate({ identifier: "MoveDocumentInput" });
|
|
258
|
-
const RemoveDocumentInput = Schema.Struct({
|
|
259
|
-
documentId: DocumentId,
|
|
260
|
-
expectedVersion: DocumentVersion,
|
|
261
|
-
...documentMutationMetadata
|
|
262
|
-
}).annotate({ identifier: "RemoveDocumentInput" });
|
|
263
|
-
const PublishDocumentInput = Schema.Struct({
|
|
264
|
-
documentId: DocumentId,
|
|
265
|
-
expectedVersion: DocumentVersion,
|
|
266
|
-
...documentMutationMetadata
|
|
267
|
-
}).annotate({ identifier: "PublishDocumentInput" });
|
|
268
|
-
const RestoreDocumentInput = Schema.Struct({
|
|
269
|
-
documentId: DocumentId,
|
|
270
|
-
revisionId: RevisionId,
|
|
271
|
-
expectedVersion: DocumentVersion,
|
|
272
|
-
...documentMutationMetadata
|
|
273
|
-
}).annotate({ identifier: "RestoreDocumentInput" });
|
|
274
|
-
const UndeleteDocumentInput = Schema.Struct({
|
|
275
|
-
documentId: DocumentId,
|
|
276
|
-
expectedVersion: DocumentVersion,
|
|
277
|
-
...documentMutationMetadata
|
|
278
|
-
}).annotate({ identifier: "UndeleteDocumentInput" });
|
|
279
|
-
const DOCUMENT_REVISION_ACTIONS = [
|
|
280
|
-
"document.create",
|
|
281
|
-
"document.move",
|
|
282
|
-
"document.remove",
|
|
283
|
-
"document.restore",
|
|
284
|
-
"document.undelete",
|
|
285
|
-
"document.update"
|
|
286
|
-
];
|
|
287
|
-
const DocumentRevisionAction = Schema.Literals(DOCUMENT_REVISION_ACTIONS);
|
|
288
|
-
const DocumentMutationAction = Schema.Literals([...DOCUMENT_REVISION_ACTIONS, "document.publish"]);
|
|
289
|
-
const DocumentMutationResult = Schema.Struct({
|
|
290
|
-
action: DocumentMutationAction,
|
|
291
|
-
documentId: DocumentId,
|
|
292
|
-
generation: DocumentGeneration,
|
|
293
|
-
revisionId: RevisionId,
|
|
294
|
-
sourcePath: SourcePath,
|
|
295
|
-
version: DocumentVersion,
|
|
296
|
-
entry: Schema.optionalKey(DocumentSummary)
|
|
297
|
-
}).annotate({ identifier: "DocumentMutationResult" });
|
|
298
|
-
const DocumentValidationResult = Schema.Struct({
|
|
299
|
-
valid: Schema.Boolean,
|
|
300
|
-
document: Schema.optionalKey(CompiledDocument),
|
|
301
|
-
issues: Schema.Array(DocumentIssue)
|
|
302
|
-
}).annotate({ identifier: "DocumentValidationResult" });
|
|
303
|
-
|
|
304
|
-
//#endregion
|
|
305
|
-
export { RestoreDocumentInput as A, DocumentVersion as B, MoveDocumentInput as C, PublishedDocumentQuery as D, PublishedDocumentPage as E, Locale as F, SourcePath as G, PublicPath as H, SourceDirectory as I, nonNegativeInt as K, DocumentGeneration as L, UpdateDocumentInput as M, AddressPattern as N, PublishedDocumentSurroundQuery as O, CollectionName as P, DocumentHistoryCursor as R, MarkdownNode as S, PublishedDocumentLookup as T, RevisionId as U, EditorNodeId as V, RevisionNumber as W, DocumentSource as _, DOCUMENT_REVISION_ACTIONS as a, DocumentSurround as b, DocumentImportInput as c, DocumentIssue as d, DocumentMutationResult as f, DocumentRevisionAction as g, DocumentQueryScalar as h, CreateDocumentInput as i, UndeleteDocumentInput as j, RemoveDocumentInput as k, DocumentImportReport as l, DocumentNavigationQuery as m, CmsMarkdownDocument as n, DeletedDocument as o, DocumentNavigationItem as p, CompiledDocument as r, DocumentBrowseQuery as s, CmsDocumentAnalysis as t, DocumentImportSource as u, DocumentSourceMapping as v, PublishDocumentInput as w, DocumentValidationResult as x, DocumentSummary as y, DocumentId as z };
|
|
306
|
-
//# sourceMappingURL=models-Citx8jBi.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models-Citx8jBi.js","names":[],"sources":["../../../../protocol/src/internal/scalars.ts","../../../../protocol/src/internal/documents/scalars.ts","../../../../protocol/src/internal/configuration/scalars.ts","../../../../protocol/src/internal/documents/models.ts"],"sourcesContent":["import { Schema } from 'effect'\n\nexport const nonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))\n\nexport const publicPathPattern = /^\\/(?!(?:[^/]+\\/)*\\.\\.?(?:\\/|$))(?:[^/?#\\\\]+(?:\\/[^/?#\\\\]+)*)?$/u\n","import { Schema } from 'effect'\nimport { nonNegativeInt, publicPathPattern } from '../scalars'\n\nconst relativeDocumentPathPattern = /^(?!(?:[^/]+\\/)*\\.\\.?(?:\\/|$))[^/?#\\\\]+(?:\\/[^/?#\\\\]+)*$/u\nconst slugPattern = /^[\\p{Letter}\\p{Number}][\\p{Letter}\\p{Number}_-]*$/u\nconst sourcePathPattern = /^(?!\\.)[^/?#\\\\]+(?:\\/(?!\\.)[^/?#\\\\]+)*\\.(?:md|mdc)$/u\n\nexport const DocumentGeneration = Schema.String.check(Schema.isPattern(/^(?:0|[1-9]\\d*)$/u)).pipe(\n Schema.brand('DocumentGeneration'),\n)\nexport type DocumentGeneration = typeof DocumentGeneration.Type\n\nexport const DocumentVersion = Schema.NonEmptyString.pipe(Schema.brand('DocumentVersion'))\nexport type DocumentVersion = typeof DocumentVersion.Type\n\nexport const DocumentHistoryCursor = Schema.NonEmptyString.pipe(Schema.brand('DocumentHistoryCursor'))\nexport type DocumentHistoryCursor = typeof DocumentHistoryCursor.Type\n\nexport const DocumentId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('DocumentId'))\nexport type DocumentId = typeof DocumentId.Type\n\nexport const EditorNodeId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('EditorNodeId'))\nexport type EditorNodeId = typeof EditorNodeId.Type\n\nexport const PublicPath = Schema.String.check(Schema.isPattern(publicPathPattern)).pipe(Schema.brand('PublicPath'))\nexport type PublicPath = typeof PublicPath.Type\n\nexport const RelativeDocumentPath = Schema.String.check(Schema.isPattern(relativeDocumentPathPattern)).pipe(\n Schema.brand('RelativeDocumentPath'),\n)\nexport type RelativeDocumentPath = typeof RelativeDocumentPath.Type\n\nexport const RevisionId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('RevisionId'))\nexport type RevisionId = typeof RevisionId.Type\n\nexport const RevisionNumber = nonNegativeInt.pipe(Schema.brand('RevisionNumber'))\nexport type RevisionNumber = typeof RevisionNumber.Type\n\nexport const Slug = Schema.String.check(Schema.isPattern(slugPattern)).pipe(Schema.brand('Slug'))\nexport type Slug = typeof Slug.Type\n\nexport const SourcePath = Schema.String.check(Schema.isPattern(sourcePathPattern)).pipe(Schema.brand('SourcePath'))\nexport type SourcePath = typeof SourcePath.Type\n","import { Schema } from 'effect'\nimport { publicPathPattern } from '../scalars'\n\nconst collectionNamePattern = /^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$/u\nconst localePattern = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u\nconst sourceDirectoryPattern = /^(?:\\.|(?!\\.)[^/?#\\\\]+(?:\\/(?!\\.)[^/?#\\\\]+)*)$/u\n\nexport const AddressPattern = Schema.String.check(Schema.isPattern(publicPathPattern)).pipe(\n Schema.brand('AddressPattern'),\n)\nexport type AddressPattern = typeof AddressPattern.Type\n\nexport const CollectionName = Schema.String.check(Schema.isPattern(collectionNamePattern)).pipe(\n Schema.brand('CollectionName'),\n)\nexport type CollectionName = typeof CollectionName.Type\n\nexport const Locale = Schema.String.check(Schema.isPattern(localePattern)).pipe(Schema.brand('Locale'))\nexport type Locale = typeof Locale.Type\n\nexport const SourceDirectory = Schema.String.check(Schema.isPattern(sourceDirectoryPattern)).pipe(\n Schema.brand('SourceDirectory'),\n)\nexport type SourceDirectory = typeof SourceDirectory.Type\n","import { Schema } from 'effect'\nimport { CollectionName, Locale } from '../configuration/scalars'\nimport { nonNegativeInt } from '../scalars'\nimport {\n DocumentGeneration,\n DocumentVersion,\n DocumentId,\n PublicPath,\n RelativeDocumentPath,\n RevisionId,\n Slug,\n SourcePath,\n} from './scalars'\n\nexport const DocumentIssueCode = Schema.Literals([\n 'document.collision',\n 'document.id',\n 'document.invalid',\n 'i18n.missing-translation',\n 'markdown.parse',\n 'reference.document',\n 'reference.component',\n 'schema.option',\n 'schema.constraint',\n 'schema.required',\n 'schema.type',\n 'schema.unknown',\n])\nexport type DocumentIssueCode = typeof DocumentIssueCode.Type\n\nexport const DocumentIssue = Schema.Struct({\n code: DocumentIssueCode,\n severity: Schema.Literals(['error', 'warning']),\n message: Schema.NonEmptyString,\n sourcePath: Schema.optionalKey(SourcePath),\n collection: Schema.optionalKey(CollectionName),\n field: Schema.optionalKey(Schema.NonEmptyString),\n key: Schema.optionalKey(PublicPath),\n locale: Schema.optionalKey(Locale),\n}).annotate({ identifier: 'DocumentIssue' })\nexport interface DocumentIssue extends Schema.Schema.Type<typeof DocumentIssue> {}\n\nexport const DocumentSourcePoint = Schema.Struct({\n offset: nonNegativeInt,\n line: nonNegativeInt,\n column: nonNegativeInt,\n})\nexport interface DocumentSourcePoint extends Schema.Schema.Type<typeof DocumentSourcePoint> {}\n\nexport const DocumentSourceRange = Schema.Struct({\n start: DocumentSourcePoint,\n end: DocumentSourcePoint,\n})\nexport interface DocumentSourceRange extends Schema.Schema.Type<typeof DocumentSourceRange> {}\n\nexport const DocumentSourceMapping = Schema.Struct({\n nodePath: Schema.Array(nonNegativeInt),\n range: DocumentSourceRange,\n})\nexport interface DocumentSourceMapping extends Schema.Schema.Type<typeof DocumentSourceMapping> {}\n\nexport type MarkdownNode =\n | string\n | readonly [null, Schema.JsonObject, string]\n | readonly [string, Schema.JsonObject, ...MarkdownNode[]]\n\nexport const MarkdownNode: Schema.Codec<MarkdownNode> = Schema.suspend(() =>\n Schema.Union([\n Schema.String,\n Schema.Tuple([Schema.Null, Schema.JsonObject, Schema.String]),\n Schema.TupleWithRest(Schema.Tuple([Schema.NonEmptyString, Schema.JsonObject]), [MarkdownNode]),\n ]),\n)\n\nexport const CmsMarkdownDocument = Schema.Struct({\n nodes: Schema.Array(MarkdownNode),\n frontmatter: Schema.JsonObject,\n meta: Schema.JsonObject,\n}).annotate({ identifier: 'CmsMarkdownDocument' })\nexport interface CmsMarkdownDocument extends Schema.Schema.Type<typeof CmsMarkdownDocument> {}\n\nexport const CmsDocumentHeading = Schema.Struct({\n depth: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 6 })),\n id: Schema.String,\n text: Schema.String,\n})\nexport interface CmsDocumentHeading extends Schema.Schema.Type<typeof CmsDocumentHeading> {}\n\n/** Stable, JSON-safe analysis derived from the same document used for delivery. */\nexport const CmsDocumentAnalysis = Schema.Struct({\n components: Schema.Array(Schema.NonEmptyString),\n headings: Schema.Array(CmsDocumentHeading),\n searchText: Schema.String,\n summary: Schema.String,\n})\nexport interface CmsDocumentAnalysis extends Schema.Schema.Type<typeof CmsDocumentAnalysis> {}\n\nexport const CompiledDocumentSource = Schema.Struct({\n path: SourcePath,\n mappings: Schema.Array(DocumentSourceMapping),\n})\nexport interface CompiledDocumentSource extends Schema.Schema.Type<typeof CompiledDocumentSource> {}\n\nexport const CompiledDocument = Schema.Struct({\n id: DocumentId,\n key: PublicPath,\n path: PublicPath,\n locale: Schema.optionalKey(Locale),\n collection: CollectionName,\n draft: Schema.Boolean,\n title: Schema.NonEmptyString,\n description: Schema.optionalKey(Schema.String),\n data: Schema.JsonObject,\n issues: Schema.Array(DocumentIssue),\n analysis: CmsDocumentAnalysis,\n body: CmsMarkdownDocument,\n engineFingerprint: Schema.NonEmptyString,\n source: CompiledDocumentSource,\n}).annotate({ identifier: 'CompiledDocument' })\nexport interface CompiledDocument extends Schema.Schema.Type<typeof CompiledDocument> {}\n\nexport const DocumentSource = Schema.Struct({\n documentId: DocumentId,\n sourcePath: SourcePath,\n markdown: Schema.String,\n revisionId: RevisionId,\n version: DocumentVersion,\n publishedVersion: Schema.optionalKey(DocumentVersion),\n}).annotate({ identifier: 'DocumentSource' })\nexport interface DocumentSource extends Schema.Schema.Type<typeof DocumentSource> {}\n\nexport const DocumentImportSource = Schema.Struct({\n sourcePath: SourcePath,\n markdown: Schema.String,\n published: Schema.Boolean,\n}).annotate({ identifier: 'DocumentImportSource' })\nexport interface DocumentImportSource extends Schema.Schema.Type<typeof DocumentImportSource> {}\n\nexport const DocumentImportMode = Schema.Literals(['preserve', 'overwrite'])\nexport type DocumentImportMode = typeof DocumentImportMode.Type\n\nexport const DocumentImportInput = Schema.Struct({\n sources: Schema.Array(DocumentImportSource),\n mode: DocumentImportMode,\n reason: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(1_000))),\n}).annotate({ identifier: 'DocumentImportInput' })\nexport interface DocumentImportInput extends Schema.Schema.Type<typeof DocumentImportInput> {}\n\nexport const DocumentImportReport = Schema.Struct({\n created: nonNegativeInt,\n preserved: nonNegativeInt,\n published: nonNegativeInt,\n unchanged: nonNegativeInt,\n updated: nonNegativeInt,\n}).annotate({ identifier: 'DocumentImportReport' })\nexport interface DocumentImportReport extends Schema.Schema.Type<typeof DocumentImportReport> {}\n\nexport const DocumentSummary = Schema.Struct({\n sourcePath: SourcePath,\n version: DocumentVersion,\n document: CompiledDocument,\n}).annotate({ identifier: 'DocumentSummary' })\nexport interface DocumentSummary extends Schema.Schema.Type<typeof DocumentSummary> {}\n\nexport const DeletedDocument = Schema.Struct({\n documentId: DocumentId,\n deletedAt: Schema.DateTimeUtcFromString,\n sourcePath: SourcePath,\n version: DocumentVersion,\n}).annotate({ identifier: 'DeletedDocument' })\nexport interface DeletedDocument extends Schema.Schema.Type<typeof DeletedDocument> {}\n\nexport const DocumentBrowseQuery = Schema.Struct({\n collection: Schema.optionalKey(CollectionName),\n locale: Schema.optionalKey(Locale),\n}).annotate({ identifier: 'DocumentBrowseQuery' })\nexport interface DocumentBrowseQuery extends Schema.Schema.Type<typeof DocumentBrowseQuery> {}\n\nexport const PublishedDocumentLookup = Schema.Union([\n Schema.Struct({\n kind: Schema.tag('id'),\n documentId: DocumentId,\n }),\n Schema.Struct({\n kind: Schema.tag('path'),\n path: PublicPath,\n }),\n Schema.Struct({\n kind: Schema.tag('key'),\n key: PublicPath,\n collection: Schema.optionalKey(CollectionName),\n locale: Schema.optionalKey(Locale),\n }),\n]).pipe(Schema.toTaggedUnion('kind'))\nexport type PublishedDocumentLookup = typeof PublishedDocumentLookup.Type\n\nexport const DocumentQueryScalar = Schema.Union([Schema.String, Schema.Finite, Schema.Boolean, Schema.Null])\nexport type DocumentQueryScalar = typeof DocumentQueryScalar.Type\n\nconst validDocumentQueryField = Schema.makeFilter<string>(\n (field) => {\n const segments = field.split('.')\n return field.length <= 200 && segments.length <= 8 && segments.every((segment) => segment.length > 0)\n },\n { expected: 'a non-empty field path of at most 200 characters and eight non-empty segments' },\n)\n\nexport const DocumentQueryField = Schema.NonEmptyString.check(validDocumentQueryField)\nexport type DocumentQueryField = typeof DocumentQueryField.Type\n\nexport const DocumentQueryValue = Schema.Union([\n DocumentQueryScalar,\n Schema.Array(DocumentQueryScalar).check(Schema.isMaxLength(20)),\n])\nexport type DocumentQueryValue = typeof DocumentQueryValue.Type\n\nexport const DocumentQuerySort = Schema.Struct({\n field: DocumentQueryField,\n direction: Schema.optionalKey(Schema.Literals(['asc', 'desc'])),\n})\nexport interface DocumentQuerySort extends Schema.Schema.Type<typeof DocumentQuerySort> {}\n\nconst DocumentQueryWhere = Schema.Record(Schema.String, DocumentQueryValue).check(\n Schema.makeFilter((where) => Object.keys(where).every((field) => Schema.is(DocumentQueryField)(field)), {\n expected: 'document query keys with valid bounded field paths',\n }),\n Schema.makeFilter((where) => Object.keys(where).length <= 12, {\n expected: 'at most 12 document query filters',\n }),\n)\n\nexport const PublishedDocumentSelection = Schema.Struct({\n collection: Schema.optionalKey(CollectionName),\n locale: Schema.optionalKey(Locale),\n where: Schema.optionalKey(DocumentQueryWhere),\n sort: Schema.optionalKey(Schema.Array(DocumentQuerySort).check(Schema.isMaxLength(4))),\n}).annotate({ identifier: 'PublishedDocumentSelection' })\nexport interface PublishedDocumentSelection extends Schema.Schema.Type<typeof PublishedDocumentSelection> {}\n\nexport const PublishedDocumentQuery = Schema.Struct({\n ...PublishedDocumentSelection.fields,\n offset: Schema.optionalKey(nonNegativeInt),\n limit: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 })),\n}).annotate({ identifier: 'PublishedDocumentQuery' })\nexport interface PublishedDocumentQuery extends Schema.Schema.Type<typeof PublishedDocumentQuery> {}\n\nexport const PublishedDocumentSurroundQuery = Schema.Struct({\n ...PublishedDocumentSelection.fields,\n}).annotate({ identifier: 'PublishedDocumentSurroundQuery' })\nexport interface PublishedDocumentSurroundQuery extends Schema.Schema.Type<typeof PublishedDocumentSurroundQuery> {}\n\nexport const PublishedDocumentPage = Schema.Struct({\n items: Schema.Array(CompiledDocument),\n total: nonNegativeInt,\n}).annotate({ identifier: 'PublishedDocumentPage' })\nexport interface PublishedDocumentPage extends Schema.Schema.Type<typeof PublishedDocumentPage> {}\n\nexport const DocumentNavigationQuery = Schema.Struct({\n collection: Schema.optionalKey(CollectionName),\n locale: Schema.optionalKey(Locale),\n}).annotate({ identifier: 'DocumentNavigationQuery' })\nexport interface DocumentNavigationQuery extends Schema.Schema.Type<typeof DocumentNavigationQuery> {}\n\nconst documentMutationMetadata = {\n reason: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(1_000))),\n}\n\nexport interface DocumentNavigationItem {\n readonly key: PublicPath\n readonly title: string\n readonly path?: PublicPath\n readonly locale?: Locale\n readonly documentId?: DocumentId\n readonly children: ReadonlyArray<DocumentNavigationItem>\n}\n\ninterface DocumentNavigationItemEncoded {\n readonly key: string\n readonly title: string\n readonly path?: string\n readonly locale?: string\n readonly documentId?: string\n readonly children: ReadonlyArray<DocumentNavigationItemEncoded>\n}\n\nexport const DocumentNavigationItem: Schema.Codec<DocumentNavigationItem, DocumentNavigationItemEncoded> =\n Schema.suspend(() =>\n Schema.Struct({\n key: PublicPath,\n title: Schema.NonEmptyString,\n path: Schema.optionalKey(PublicPath),\n locale: Schema.optionalKey(Locale),\n documentId: Schema.optionalKey(DocumentId),\n children: Schema.Array(DocumentNavigationItem),\n }),\n )\n\nexport const DocumentSurround = Schema.Struct({\n previous: Schema.NullOr(CompiledDocument),\n next: Schema.NullOr(CompiledDocument),\n}).annotate({ identifier: 'DocumentSurround' })\nexport interface DocumentSurround extends Schema.Schema.Type<typeof DocumentSurround> {}\n\nexport const HomeDocumentLocation = Schema.Struct({\n kind: Schema.tag('home'),\n})\nexport interface HomeDocumentLocation extends Schema.Schema.Type<typeof HomeDocumentLocation> {}\n\nexport const NestedDocumentLocation = Schema.Struct({\n kind: Schema.tag('entry'),\n parent: Schema.optionalKey(RelativeDocumentPath),\n slug: Slug,\n})\nexport interface NestedDocumentLocation extends Schema.Schema.Type<typeof NestedDocumentLocation> {}\n\nexport const DocumentLocation = Schema.Union([HomeDocumentLocation, NestedDocumentLocation]).pipe(\n Schema.toTaggedUnion('kind'),\n)\nexport type DocumentLocation = typeof DocumentLocation.Type\n\nexport const CreateDocumentInput = Schema.Struct({\n collection: CollectionName,\n locale: Schema.optionalKey(Locale),\n location: DocumentLocation,\n title: Schema.NonEmptyString,\n ...documentMutationMetadata,\n}).annotate({ identifier: 'CreateDocumentInput' })\nexport interface CreateDocumentInput extends Schema.Schema.Type<typeof CreateDocumentInput> {}\n\nexport const UpdateDocumentInput = Schema.Struct({\n documentId: DocumentId,\n expectedVersion: DocumentVersion,\n markdown: Schema.String,\n ...documentMutationMetadata,\n}).annotate({ identifier: 'UpdateDocumentInput' })\nexport interface UpdateDocumentInput extends Schema.Schema.Type<typeof UpdateDocumentInput> {}\n\nexport const MoveDocumentInput = Schema.Struct({\n documentId: DocumentId,\n expectedVersion: DocumentVersion,\n location: DocumentLocation,\n ...documentMutationMetadata,\n}).annotate({ identifier: 'MoveDocumentInput' })\nexport interface MoveDocumentInput extends Schema.Schema.Type<typeof MoveDocumentInput> {}\n\nexport const RemoveDocumentInput = Schema.Struct({\n documentId: DocumentId,\n expectedVersion: DocumentVersion,\n ...documentMutationMetadata,\n}).annotate({ identifier: 'RemoveDocumentInput' })\nexport interface RemoveDocumentInput extends Schema.Schema.Type<typeof RemoveDocumentInput> {}\n\nexport const PublishDocumentInput = Schema.Struct({\n documentId: DocumentId,\n expectedVersion: DocumentVersion,\n ...documentMutationMetadata,\n}).annotate({ identifier: 'PublishDocumentInput' })\nexport interface PublishDocumentInput extends Schema.Schema.Type<typeof PublishDocumentInput> {}\n\nexport const RestoreDocumentInput = Schema.Struct({\n documentId: DocumentId,\n revisionId: RevisionId,\n expectedVersion: DocumentVersion,\n ...documentMutationMetadata,\n}).annotate({ identifier: 'RestoreDocumentInput' })\nexport interface RestoreDocumentInput extends Schema.Schema.Type<typeof RestoreDocumentInput> {}\n\nexport const UndeleteDocumentInput = Schema.Struct({\n documentId: DocumentId,\n expectedVersion: DocumentVersion,\n ...documentMutationMetadata,\n}).annotate({ identifier: 'UndeleteDocumentInput' })\nexport interface UndeleteDocumentInput extends Schema.Schema.Type<typeof UndeleteDocumentInput> {}\n\nexport const DOCUMENT_REVISION_ACTIONS = [\n 'document.create',\n 'document.move',\n 'document.remove',\n 'document.restore',\n 'document.undelete',\n 'document.update',\n] as const\n\nexport const DocumentRevisionAction = Schema.Literals(DOCUMENT_REVISION_ACTIONS)\nexport type DocumentRevisionAction = typeof DocumentRevisionAction.Type\n\nexport const DocumentMutationAction = Schema.Literals([...DOCUMENT_REVISION_ACTIONS, 'document.publish'])\nexport type DocumentMutationAction = typeof DocumentMutationAction.Type\n\nexport const DocumentMutationResult = Schema.Struct({\n action: DocumentMutationAction,\n documentId: DocumentId,\n generation: DocumentGeneration,\n revisionId: RevisionId,\n sourcePath: SourcePath,\n version: DocumentVersion,\n entry: Schema.optionalKey(DocumentSummary),\n}).annotate({ identifier: 'DocumentMutationResult' })\nexport interface DocumentMutationResult extends Schema.Schema.Type<typeof DocumentMutationResult> {}\n\nexport const DocumentValidationResult = Schema.Struct({\n valid: Schema.Boolean,\n document: Schema.optionalKey(CompiledDocument),\n issues: Schema.Array(DocumentIssue),\n}).annotate({ identifier: 'DocumentValidationResult' })\nexport interface DocumentValidationResult extends Schema.Schema.Type<typeof DocumentValidationResult> {}\n"],"mappings":";;;AAEA,MAAa,iBAAiB,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAE/E,MAAa,oBAAoB;;;;ACDjC,MAAM,8BAA8B;AACpC,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAE1B,MAAa,qBAAqB,OAAO,OAAO,MAAM,OAAO,UAAU,mBAAmB,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AAO,YAAY,eAAe;AAC3C,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,yBAAyB,CAAC;AAGpD,MAAa,2BAA2B,OAAO,OAAO;CACpD,OAAO,OAAO;CACd,UAAU,OAAO,YAAY,gBAAgB;CAC7C,QAAQ,OAAO,MAAM,aAAa;AACpC,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,2BAA2B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models-DS5ClMsH.js","names":[],"sources":["../../../../protocol/src/Identity.ts","../../../../protocol/src/internal/preview/models.ts"],"sourcesContent":["/** Cross-domain request correlation; decode unknown strings before crossing a seam. */\nimport { Schema } from 'effect'\n\nexport const RequestId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('RequestId'))\nexport type RequestId = typeof RequestId.Type\n","import { CompiledDocument, PublishedDocumentLookup } from '../../Documents'\nimport { RequestId } from '../../Identity'\nimport { CollectionName } from '../configuration/scalars'\nimport { DocumentGeneration, DocumentId, EditorNodeId, PublicPath, RevisionNumber } from '../documents/scalars'\nimport { Schema } from 'effect'\n\nexport const DOCUMENT_PREVIEW_CHANNEL = 'cms:document-preview'\n\nexport const PreviewSessionId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('PreviewSessionId'))\nexport type PreviewSessionId = typeof PreviewSessionId.Type\n\nexport const PreviewIntentId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('PreviewIntentId'))\nexport type PreviewIntentId = typeof PreviewIntentId.Type\n\nconst exactOrigin = Schema.makeFilter<string>(\n (value) => {\n try {\n const url = new URL(value)\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.origin === value\n } catch {\n return false\n }\n },\n { expected: 'an exact HTTP or HTTPS origin without a path' },\n)\n\nexport const PreviewOrigin = Schema.NonEmptyString.check(exactOrigin).pipe(Schema.brand('PreviewOrigin'))\nexport type PreviewOrigin = typeof PreviewOrigin.Type\n\nexport const PreviewSessionRequest = Schema.Struct({\n previewOrigin: PreviewOrigin,\n}).annotate({ identifier: 'PreviewSessionRequest' })\nexport interface PreviewSessionRequest extends Schema.Schema.Type<typeof PreviewSessionRequest> {}\n\nexport const PreviewSession = Schema.Struct({\n editorOrigin: PreviewOrigin,\n expiresAt: Schema.DateTimeUtcFromString,\n previewOrigin: PreviewOrigin,\n sessionId: PreviewSessionId,\n token: Schema.NonEmptyString,\n}).annotate({ identifier: 'PreviewSession' })\nexport interface PreviewSession extends Schema.Schema.Type<typeof PreviewSession> {}\n\nexport const PreviewSessionAccess = Schema.Struct({ token: PreviewSession.fields.token }).annotate({\n identifier: 'PreviewSessionAccess',\n})\nexport interface PreviewSessionAccess extends Schema.Schema.Type<typeof PreviewSessionAccess> {}\n\nexport const PreviewDraftRequest = Schema.Struct({\n lookup: PublishedDocumentLookup,\n token: PreviewSession.fields.token,\n}).annotate({ identifier: 'PreviewDraftRequest' })\nexport interface PreviewDraftRequest extends Schema.Schema.Type<typeof PreviewDraftRequest> {}\n\nexport const PreviewInvalidation = Schema.Struct({\n generation: DocumentGeneration,\n type: Schema.tag('document-invalidated'),\n}).annotate({ identifier: 'PreviewInvalidation' })\nexport interface PreviewInvalidation extends Schema.Schema.Type<typeof PreviewInvalidation> {}\n\nexport class PreviewSessionInvalid extends Schema.TaggedError<PreviewSessionInvalid>()('Preview.SessionInvalid', {\n reason: Schema.Literals(['expired', 'invalid', 'origin']),\n}) {}\n\nexport class PreviewDraftNotFound extends Schema.TaggedError<PreviewDraftNotFound>()('Preview.DraftNotFound', {\n lookup: PublishedDocumentLookup,\n}) {}\n\nexport const DocumentPreviewFocusIntent = Schema.Struct({\n id: PreviewIntentId,\n documentId: DocumentId,\n nodeId: Schema.optionalKey(EditorNodeId),\n origin: Schema.Literals(['editor', 'preview']),\n reveal: Schema.Boolean,\n revision: RevisionNumber,\n})\nexport interface DocumentPreviewFocusIntent extends Schema.Schema.Type<typeof DocumentPreviewFocusIntent> {}\n\nexport const RenderedCompiledDocument = Schema.Struct({\n collection: CollectionName,\n documentId: DocumentId,\n path: PublicPath,\n role: Schema.Literals(['embedded', 'primary', 'related', 'summary']),\n title: Schema.NonEmptyString,\n})\nexport interface RenderedCompiledDocument extends Schema.Schema.Type<typeof RenderedCompiledDocument> {}\n\nexport const RenderedDocumentManifest = Schema.Struct({\n documents: Schema.Array(RenderedCompiledDocument),\n route: PublicPath,\n})\nexport interface RenderedDocumentManifest extends Schema.Schema.Type<typeof RenderedDocumentManifest> {}\n\nconst previewEnvelope = {\n channel: Schema.Literal(DOCUMENT_PREVIEW_CHANNEL),\n sessionId: PreviewSessionId,\n}\n\nconst StudioConnectMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:connect'),\n})\n\nconst StudioModeMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:mode'),\n mode: Schema.Literals(['browse', 'edit']),\n})\n\nconst StudioNavigateMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:navigate'),\n path: PublicPath,\n})\n\nconst StudioPatchMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:patch'),\n document: CompiledDocument,\n fallbacks: Schema.Record(Schema.String, Schema.String),\n focus: Schema.optionalKey(DocumentPreviewFocusIntent),\n revision: RevisionNumber,\n})\n\nconst StudioFocusMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:focus'),\n focus: DocumentPreviewFocusIntent,\n})\n\nconst PreviewReadyMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:ready'),\n path: PublicPath,\n})\n\nconst PreviewManifestMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:manifest'),\n manifest: RenderedDocumentManifest,\n revision: RevisionNumber,\n})\n\nconst PreviewActivateMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:activate'),\n documentId: DocumentId,\n field: Schema.optionalKey(Schema.NonEmptyString),\n nodeId: Schema.optionalKey(EditorNodeId),\n requestId: RequestId,\n revision: RevisionNumber,\n})\n\nconst PreviewAppliedMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:applied'),\n intentId: PreviewIntentId,\n nodeId: Schema.optionalKey(EditorNodeId),\n result: Schema.Literals(['exact', 'fallback', 'missing']),\n revision: RevisionNumber,\n})\n\nconst PreviewRenderedMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:rendered'),\n revision: RevisionNumber,\n})\n\nexport const DocumentPreviewMessage = Schema.Union([\n StudioConnectMessage,\n StudioModeMessage,\n StudioNavigateMessage,\n StudioPatchMessage,\n StudioFocusMessage,\n PreviewReadyMessage,\n PreviewManifestMessage,\n PreviewActivateMessage,\n PreviewAppliedMessage,\n PreviewRenderedMessage,\n]).pipe(Schema.toTaggedUnion('type'))\nexport type DocumentPreviewMessage = typeof DocumentPreviewMessage.Type\n\nexport const isDocumentPreviewMessage = Schema.is(DocumentPreviewMessage)\n\ntype PreviewPayload<Message extends DocumentPreviewMessage> = Message extends DocumentPreviewMessage\n ? Omit<Message, 'channel' | 'sessionId'>\n : never\n\nexport type StudioPreviewPayload = PreviewPayload<\n Extract<DocumentPreviewMessage, { readonly type: `studio:${string}` }>\n>\n\nexport type PreviewSitePayload = PreviewPayload<Extract<DocumentPreviewMessage, { readonly type: `preview:${string}` }>>\n"],"mappings":";;;;;AAGA,MAAa,YAAY,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,WAAW,CAAC;;;;ACG5F,MAAa,2BAA2B;AAExC,MAAa,mBAAmB,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG1G,MAAa,kBAAkB,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAGxG,MAAM,cAAc,OAAO,YACxB,UAAU;CACT,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,KAAK;EACzB,QAAQ,IA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,IAAI,kBAAkB;CACnC,YAAY;CACZ,OAAO,OAAO,YAAY,OAAO,cAAc;CAC/C,QAAQ,OAAO,YAAY,YAAY;CACvC,WAAW;CACX,UAAU;AACZ,CAAC;AAED,MAAM,wBAAwB,OAAO,OAAO;CAC1C,GAAG;CACH,MAAM,OAAO,IAAI,iBAAiB;CAClC,UAAU;CACV,QAAQ,OAAO,YAAY,YAAY;CACvC,QAAQ,OAAO,SAAS;EAAC;EAAS;EAAY;CAAS,CAAC;CACxD,UAAU;AACZ,CAAC;AAED,MAAM,yBAAyB,OAAO,OAAO;CAC3C,GAAG;CACH,MAAM,OAAO,IAAI,kBAAkB;CACnC,UAAU;AACZ,CAAC;AAED,MAAa,yBAAyB,OAAO,MAAM;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,CAAC,KAAK,OAAO,cAAc,MAAM,CAAC;AAGpC,MAAa,2BAA2B,OAAO,GAAG,sBAAsB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store-Nl4uxEXx.js","names":["CmsMarkdownDocumentSchema"],"sources":["../../../../document/src/PreviewProjection.ts","../../../src/runtime/preview/store.ts"],"sourcesContent":["import type { CmsMarkdownDocument, MarkdownNode } from '@internal/protocol/Documents'\nimport type { EditorNodeId } from '@internal/protocol/Documents'\nimport { CmsMarkdownDocument as CmsMarkdownDocumentSchema } from '@internal/protocol/Documents'\nimport { Predicate, Result, Schema } from 'effect'\nimport { mutableJson, mutableJsonObject } from './internal/comark/document-adapter'\nimport { editorMetadata } from './internal/editor/metadata'\n\nexport interface PreviewProjectionMarkers {\n readonly inlineHostAttribute: string\n readonly markerTag: string\n readonly nodeAttribute: string\n readonly targetAttribute: string\n readonly wrapperAttribute: string\n}\n\nexport interface PreviewProjection {\n readonly body: CmsMarkdownDocument\n readonly fallbacks: Readonly<Record<string, string>>\n}\n\nexport class PreviewProjectionInvalid extends Schema.TaggedError<PreviewProjectionInvalid>()(\n 'PreviewProjection.Invalid',\n {\n message: Schema.NonEmptyString,\n cause: Schema.Defect(),\n },\n) {}\n\nconst NATIVE_BLOCK_TAGS = new Set([\n 'blockquote',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'img',\n 'li',\n 'math',\n 'ol',\n 'p',\n 'pre',\n 'table',\n 'tbody',\n 'td',\n 'th',\n 'thead',\n 'tr',\n 'ul',\n])\nconst INLINE_TAGS = new Set(['a', 'br', 'code', 'del', 'em', 'img', 'strong', 'u'])\n\n/** Projects private authoring identities into an ephemeral preview without mutating the canonical body. */\nexport function projectPreviewDocument(\n body: CmsMarkdownDocument,\n markers: PreviewProjectionMarkers,\n): Result.Result<PreviewProjection, PreviewProjectionInvalid> {\n return Result.try({\n try: () => projectPreviewDocumentUnsafe(body, markers),\n catch: (cause) =>\n new PreviewProjectionInvalid({\n cause,\n message: cause instanceof Error && cause.message ? cause.message : 'The preview projection is invalid.',\n }),\n })\n}\n\nfunction projectPreviewDocumentUnsafe(body: CmsMarkdownDocument, markers: PreviewProjectionMarkers): PreviewProjection {\n const fallbacks: Record<string, string> = {}\n let identifiedTargets = 0\n\n const cloneNodes = (nodes: ReadonlyArray<MarkdownNode>, componentId?: EditorNodeId): ReadonlyArray<Schema.Json> =>\n nodes.map((node) => {\n if (Predicate.isString(node) || node[0] === null) return mutableJson(node)\n const [tag, originalAttributes, ...originalChildren] = node\n const isSlot = tag === 'template'\n const isNative = NATIVE_BLOCK_TAGS.has(tag)\n const attributes = mutableJsonObject(originalAttributes)\n const metadata = editorMetadata(attributes)\n const id = metadata?.nodeId\n if (id) {\n identifiedTargets++\n if (componentId) fallbacks[id] = componentId\n if (!isSlot && !isNative) {\n attributes[markers.nodeAttribute] = id\n attributes[markers.targetAttribute] = 'component'\n }\n }\n\n const nextComponentId = !isNative && !isSlot && id ? id : componentId\n const children = [...cloneNodes(originalChildren, nextComponentId)]\n if (id && metadata?.implicitSlotId && !isNative && !isSlot && hasImplicitDefaultContent(originalChildren)) {\n const slotId = metadata.implicitSlotId\n fallbacks[slotId] = id\n const markerChildren = hasInlineImplicitDefaultContent(originalChildren) ? children.splice(0) : []\n const markerAttributes = {\n [markers.nodeAttribute]: slotId,\n [markers.targetAttribute]: 'slot',\n [markers.wrapperAttribute]: '',\n }\n if (markerChildren.length) markerAttributes[markers.inlineHostAttribute] = ''\n children.unshift([markers.markerTag, markerAttributes, ...markerChildren])\n }\n if (isSlot && id) {\n children.unshift([\n markers.markerTag,\n {\n [markers.nodeAttribute]: id,\n [markers.targetAttribute]: 'slot',\n [markers.wrapperAttribute]: '',\n },\n ])\n }\n const cloned: Schema.Json = [tag, attributes, ...children]\n if (id && isNative) return previewWrapper(id, 'native', cloned, markers)\n if (id && !isNative && !isSlot) return previewWrapper(id, 'component', cloned, markers)\n return cloned\n })\n\n const nodes = cloneNodes(body.nodes)\n if (body.nodes.length && !identifiedTargets)\n throw new Error('Studio preview requires an identified authoring document.')\n return {\n body: CmsMarkdownDocumentSchema.make({\n frontmatter: mutableJsonObject(body.frontmatter),\n meta: mutableJsonObject(body.meta),\n nodes,\n }),\n fallbacks,\n }\n}\n\nfunction previewWrapper(\n nodeId: EditorNodeId,\n kind: 'component' | 'native' | 'slot',\n child: Schema.Json,\n markers: PreviewProjectionMarkers,\n): Schema.Json {\n return [\n markers.markerTag,\n {\n [markers.nodeAttribute]: nodeId,\n [markers.targetAttribute]: kind,\n [markers.wrapperAttribute]: '',\n },\n child,\n ]\n}\n\nfunction hasImplicitDefaultContent(nodes: ReadonlyArray<MarkdownNode>): boolean {\n const hasExplicitDefault = nodes.some(\n (node) => Array.isArray(node) && node[0] === 'template' && node[1].name === 'default',\n )\n return (\n !hasExplicitDefault && nodes.some((node) => (Predicate.isString(node) ? Boolean(node) : node[0] !== 'template'))\n )\n}\n\nfunction hasInlineImplicitDefaultContent(nodes: ReadonlyArray<MarkdownNode>): boolean {\n return (\n nodes.length > 0 &&\n nodes.every(\n (node) => Predicate.isString(node) || (Array.isArray(node) && node[0] !== null && INLINE_TAGS.has(node[0])),\n )\n )\n}\n","import type { RenderedCompiledDocument, RenderedDocumentManifest } from '@internal/protocol/Preview'\nimport { projectPreviewDocument } from '@internal/document/PreviewProjection'\nimport { CollectionName } from '@internal/protocol/Configuration'\nimport { DocumentId, PublicPath } from '@internal/protocol/Documents'\nimport { Result } from 'effect'\nimport { createComarkContext } from 'comark'\nimport { shallowReactive } from 'vue'\nimport type { DeliveryDocument as PreviewCompiledDocument } from '../delivery/types'\nimport type { DocumentPreviewStore, PreviewDocumentRole } from '../delivery/preview'\nimport { toPreviewRenderDocument } from './comark-document'\nimport {\n CMS_PREVIEW_INLINE_HOST_ATTRIBUTE,\n CMS_PREVIEW_MARKER_TAG,\n CMS_PREVIEW_NODE_ATTRIBUTE,\n CMS_PREVIEW_TARGET_ATTRIBUTE,\n CMS_PREVIEW_WRAPPER_ATTRIBUTE,\n} from './protocol'\n\nexport { documentPreviewStoreKey, type DocumentPreviewStore, type PreviewDocumentRole } from '../delivery/preview'\nexport type { DeliveryDocument as PreviewCompiledDocument } from '../delivery/types'\n\nexport interface StudioPreviewStore extends DocumentPreviewStore {\n readonly manifest: () => RenderedDocumentManifest\n readonly patch: (document: PreviewCompiledDocument) => Promise<Readonly<Record<string, string>>>\n readonly routeChanged: () => void\n readonly subscribe: (listener: (manifest: RenderedDocumentManifest) => void) => () => void\n}\n\nexport function createStudioPreviewStore(route: () => RenderedDocumentManifest['route']): StudioPreviewStore {\n const context = createComarkContext()\n const patches = shallowReactive(new Map<string, PreviewCompiledDocument>())\n const registrations = new Map<\n symbol,\n { readonly document: PreviewCompiledDocument; readonly role: PreviewDocumentRole }\n >()\n const listeners = new Set<(manifest: RenderedDocumentManifest) => void>()\n const manifest = (): RenderedDocumentManifest => ({\n documents: renderedDocuments(registrations.values(), patches),\n route: route(),\n })\n const notify = (): void => {\n const value = manifest()\n for (const listener of listeners) listener(value)\n }\n\n return {\n manifest,\n async patch(document) {\n const preview = createPreviewDocument(document.body)\n const patched = Object.assign({}, document, { body: preview.body })\n patches.set(document.id, patched)\n const renderBody = toPreviewRenderDocument(preview.body)\n context.get(document.id, renderBody).set(renderBody)\n notify()\n return preview.fallbacks\n },\n register(document, role) {\n const registration = Symbol(document.id)\n registrations.set(registration, { document, role })\n notify()\n return () => {\n registrations.delete(registration)\n notify()\n }\n },\n resolve(document) {\n return patches.get(document.id) ?? document\n },\n routeChanged: notify,\n subscribe(listener) {\n listeners.add(listener)\n listener(manifest())\n return () => listeners.delete(listener)\n },\n }\n}\n\nfunction renderedDocuments(\n registrations: Iterable<{ readonly document: PreviewCompiledDocument; readonly role: PreviewDocumentRole }>,\n patches: ReadonlyMap<string, PreviewCompiledDocument>,\n): ReadonlyArray<RenderedCompiledDocument> {\n const priority = { embedded: 1, primary: 4, related: 2, summary: 3 } satisfies Record<PreviewDocumentRole, number>\n const documents = new Map<string, RenderedCompiledDocument>()\n for (const registration of registrations) {\n const document = patches.get(registration.document.id) ?? registration.document\n const current = documents.get(document.id)\n if (current && priority[current.role] >= priority[registration.role]) continue\n documents.set(document.id, {\n collection: CollectionName.make(document.collection),\n documentId: DocumentId.make(document.id),\n path: PublicPath.make(document.path),\n role: registration.role,\n title: document.title,\n })\n }\n return [...documents.values()].sort(\n (left, right) => priority[right.role] - priority[left.role] || left.title.localeCompare(right.title),\n )\n}\n\nfunction createPreviewDocument(body: PreviewCompiledDocument['body']) {\n const projection = projectPreviewDocument(body, {\n inlineHostAttribute: CMS_PREVIEW_INLINE_HOST_ATTRIBUTE,\n markerTag: CMS_PREVIEW_MARKER_TAG,\n nodeAttribute: CMS_PREVIEW_NODE_ATTRIBUTE,\n targetAttribute: CMS_PREVIEW_TARGET_ATTRIBUTE,\n wrapperAttribute: CMS_PREVIEW_WRAPPER_ATTRIBUTE,\n })\n if (Result.isFailure(projection)) throw projection.failure\n return projection.success\n}\n"],"mappings":";;;;;;;;;AAoBA,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,C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