@phtngyn/cms 0.2.0-beta.3 → 0.2.0-beta.5
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 +31 -13
- package/package.json +7 -7
- package/src/ApplicationTypes.d.ts +3 -3
- package/src/Authoring.d.ts +11 -3
- package/src/{Configuration-BU-UyGoH.js → Configuration-JQ1qyaU0.js} +347 -189
- package/src/Configuration-JQ1qyaU0.js.map +1 -0
- package/src/Configuration.d.ts +1 -1
- package/src/Content.d.ts +7 -6
- package/src/Content.js +106 -47
- package/src/Content.js.map +1 -1
- package/src/ContentTransfer-BxwswWn3.js +86 -0
- package/src/ContentTransfer-BxwswWn3.js.map +1 -0
- package/src/{ContentTransfer-CRQet3QJ.d.ts → ContentTransfer-Z9FHyLez.d.ts} +33 -9
- package/src/{DocumentEngine-ClhFXW9M.js → DocumentEngine-j6Vi7nQo.js} +279 -178
- package/src/DocumentEngine-j6Vi7nQo.js.map +1 -0
- package/src/DocumentModel.d.ts +9 -2
- package/src/DocumentModel.js +17 -4
- package/src/DocumentModel.js.map +1 -1
- package/src/{Forms-DoB56hfe.js → Forms-CX-hwmJF.js} +18 -11
- package/src/Forms-CX-hwmJF.js.map +1 -0
- package/src/{Forms-BbkE7QfC.js → Forms-CfNPTiCr.js} +2 -2
- package/src/{Forms-BbkE7QfC.js.map → Forms-CfNPTiCr.js.map} +1 -1
- package/src/Media-j1bTritO.js +112 -0
- package/src/Media-j1bTritO.js.map +1 -0
- package/src/Module.js +0 -4
- package/src/Module.js.map +1 -1
- package/src/References-CCPDAPve.js +45 -0
- package/src/References-CCPDAPve.js.map +1 -0
- package/src/{S3MediaObjects-CR3p1WTg.js → S3MediaObjects-BRuPQbxl.js} +454 -516
- package/src/S3MediaObjects-BRuPQbxl.js.map +1 -0
- package/src/cli/content.js +6 -5
- package/src/cli/content.js.map +1 -1
- package/src/cli.js +16 -3
- package/src/cli.js.map +1 -1
- package/src/{connection-D5S9Iph-.js → connection-BP80q4d-.js} +2 -2
- package/src/{connection-D5S9Iph-.js.map → connection-BP80q4d-.js.map} +1 -1
- package/src/{dev-lifecycle-D3f9-upa.js → dev-lifecycle-DdBluSiR.js} +26 -6
- package/src/dev-lifecycle-DdBluSiR.js.map +1 -0
- package/src/{installation-fZtNxtoW.js → installation-BoG8E3nJ.js} +7982 -7155
- package/src/installation-BoG8E3nJ.js.map +1 -0
- package/src/internal/authoring-catalog.js +2 -2
- package/src/internal/authoring-compiler.js +35 -9
- package/src/internal/authoring-compiler.js.map +1 -1
- package/src/internal/authoring-metadata.js +14 -5
- package/src/internal/authoring-metadata.js.map +1 -1
- package/src/internal/configuration.js +27 -3
- package/src/internal/configuration.js.map +1 -1
- package/src/internal/dev-lifecycle.js +2 -2
- package/src/internal/document-model.js +134 -43
- package/src/internal/document-model.js.map +1 -1
- package/src/internal/field-metadata.js +2 -1
- package/src/internal/field-metadata.js.map +1 -1
- package/src/internal/form-capabilities.js +1 -1
- package/src/{location-CPX7oj0o.js → location-CMNGO3lU.js} +2 -2
- package/src/{location-CPX7oj0o.js.map → location-CMNGO3lU.js.map} +1 -1
- package/src/{metadata-BEZPWh-3.js → metadata-UzZmjwxM.js} +2 -2
- package/src/{metadata-BEZPWh-3.js.map → metadata-UzZmjwxM.js.map} +1 -1
- package/src/{models-C9kF9JlQ.js → models-5j67LMqW.js} +4 -4
- package/src/{models-C9kF9JlQ.js.map → models-5j67LMqW.js.map} +1 -1
- package/src/{models-ChRxBChy.js → models-VmGmG19-.js} +42 -130
- package/src/models-VmGmG19-.js.map +1 -0
- package/src/runtime/delivery/DocumentRenderer.js +5 -1
- package/src/runtime/delivery/DocumentRenderer.js.map +1 -1
- package/src/runtime/delivery/context.js +1 -1
- package/src/runtime/delivery/document-page.js +1 -5
- package/src/runtime/delivery/document-page.js.map +1 -1
- package/src/runtime/delivery/plugin.js +34 -5
- package/src/runtime/delivery/plugin.js.map +1 -1
- package/src/runtime/delivery/preview.d.ts +1 -1
- package/src/runtime/delivery/types.d.ts +1 -1
- package/src/runtime/delivery/useCmsDocumentSeo.d.ts +2 -1
- package/src/runtime/delivery/useCmsDocumentSeo.js +5 -4
- package/src/runtime/delivery/useCmsDocumentSeo.js.map +1 -1
- package/src/runtime/forms/document.js +2 -2
- package/src/runtime/forms/useCmsForm.js +2 -2
- package/src/runtime/installation.js +1 -1
- package/src/runtime/plugin.js +1 -1
- package/src/runtime/preview/CmsStudioPreviewMarker.js +18 -4
- package/src/runtime/preview/CmsStudioPreviewMarker.js.map +1 -1
- package/src/runtime/preview/connection.js +1 -1
- package/src/runtime/preview/controller.js +65 -74
- package/src/runtime/preview/controller.js.map +1 -1
- package/src/runtime/preview/overlay.js +85 -28
- package/src/runtime/preview/overlay.js.map +1 -1
- package/src/runtime/preview/plugin.client.js +4 -4
- package/src/runtime/preview/preview.css +50 -36
- package/src/runtime/preview/protocol.d.ts +11 -5
- package/src/runtime/preview/protocol.js +17 -5
- package/src/runtime/preview/protocol.js.map +1 -1
- package/src/runtime/preview/regions.js +142 -0
- package/src/runtime/preview/regions.js.map +1 -0
- package/src/runtime/preview/store.js +1 -1
- package/src/runtime/sitemap.js +9 -10
- package/src/runtime/sitemap.js.map +1 -1
- package/src/{scalars-B2lgGUnj.js → scalars-CVZqT3L0.js} +2 -6
- package/src/scalars-CVZqT3L0.js.map +1 -0
- package/src/{store-CCsjHaZm.js → store-PKKB8xa2.js} +49 -66
- package/src/store-PKKB8xa2.js.map +1 -0
- package/src/{types-DutFRtaG.d.ts → types-DZ0IV-Ow.d.ts} +14 -3
- package/studio/CreateDocumentDialog-vQ8hDs2C.js +253 -0
- package/studio/{documentPlanning-CDb31mnl.js → documentPlanning-Bx3W9KkD.js} +12054 -12085
- package/studio/{editor-Bzlh3zXt.js → editor-P2rB7Csp.js} +11228 -11927
- package/studio/host.css +1 -1
- package/studio/host.js +23595 -24903
- package/studio/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/src/Configuration-BU-UyGoH.js.map +0 -1
- package/src/ContentTransfer-BhF9G56s.js +0 -57
- package/src/ContentTransfer-BhF9G56s.js.map +0 -1
- package/src/DocumentEngine-ClhFXW9M.js.map +0 -1
- package/src/Forms-DoB56hfe.js.map +0 -1
- package/src/S3MediaObjects-CR3p1WTg.js.map +0 -1
- package/src/dev-lifecycle-D3f9-upa.js.map +0 -1
- package/src/installation-fZtNxtoW.js.map +0 -1
- package/src/models-ChRxBChy.js.map +0 -1
- package/src/runtime/preview/targets.js +0 -101
- package/src/runtime/preview/targets.js.map +0 -1
- package/src/scalars-B2lgGUnj.js.map +0 -1
- package/src/store-CCsjHaZm.js.map +0 -1
- package/studio/CreateDocumentDialog-DJ8c0WZb.js +0 -256
- package/studio/dom-to-image-more.min-D6jGGdrW.js +0 -877
- package/studio/rolldown-runtime-B0aSnxlc.js +0 -20
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as formAuthoring } from "../Forms-
|
|
2
|
-
import { l as validateCollectionBody, n as ComponentDefinition, t as AuthoringCatalog } from "../Configuration-
|
|
1
|
+
import { n as formAuthoring } from "../Forms-CX-hwmJF.js";
|
|
2
|
+
import { l as validateCollectionBody, n as ComponentDefinition, t as AuthoringCatalog } from "../Configuration-JQ1qyaU0.js";
|
|
3
3
|
import { resolveBlockAuthoring } from "./authoring-metadata.js";
|
|
4
4
|
import { Crypto, Effect, Encoding, FileSystem, Path, Schema } from "effect";
|
|
5
5
|
import { addTemplate, addVitePlugin, updateTemplates } from "@nuxt/kit";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
1
2
|
import { MagicString, babelParse, parse, walkIdentifiers } from "@vue/compiler-sfc";
|
|
2
3
|
|
|
3
4
|
//#region src/internal/authoring-compiler.ts
|
|
4
5
|
const authoringImport = "@phtngyn/cms/Authoring";
|
|
6
|
+
const isJsonObject = Schema.is(Schema.JsonObject);
|
|
5
7
|
function compileCmsBlock(source, filename) {
|
|
6
8
|
if (!source.includes(authoringImport)) return void 0;
|
|
7
9
|
const { descriptor, errors } = parse(source, { filename });
|
|
@@ -48,7 +50,8 @@ function compileCmsBlock(source, filename) {
|
|
|
48
50
|
const type = parameters?.type === "TSTypeParameterInstantiation" ? parameters.params[0] : void 0;
|
|
49
51
|
if (type?.type !== "TSTypeReference" || type.typeName.type !== "Identifier" || type.typeParameters !== void 0 || type.typeName.name !== names[index]) throw new Error(`${filename}: ${macro} must use the same ${names[index]} type as defineCmsBlock.`);
|
|
50
52
|
}
|
|
51
|
-
const declaration =
|
|
53
|
+
const declaration = staticObjectValue(argument, filename);
|
|
54
|
+
validateSlotOutlets(descriptor.template?.ast, declaration, filename);
|
|
52
55
|
const code = new MagicString(source);
|
|
53
56
|
for (const node of [imported, statement]) {
|
|
54
57
|
if (node.start === null || node.start === void 0 || node.end === null || node.end === void 0) throw new Error(`${filename}: missing authoring declaration source location.`);
|
|
@@ -64,6 +67,36 @@ function compileCmsBlock(source, filename) {
|
|
|
64
67
|
})
|
|
65
68
|
};
|
|
66
69
|
}
|
|
70
|
+
function validateSlotOutlets(template, declaration, filename) {
|
|
71
|
+
if (!isJsonObject(declaration.slots)) return;
|
|
72
|
+
const declared = new Set(Object.keys(declaration.slots));
|
|
73
|
+
const rendered = /* @__PURE__ */ new Set();
|
|
74
|
+
function visit(node) {
|
|
75
|
+
const element = node.type === 1 ? node : void 0;
|
|
76
|
+
if (element?.tag === "slot") {
|
|
77
|
+
const slot = staticSlotName(element, filename);
|
|
78
|
+
if (declared.has(slot)) rendered.add(slot);
|
|
79
|
+
}
|
|
80
|
+
if (node.type === 0 || node.type === 1) for (const child of node.children) visit(child);
|
|
81
|
+
}
|
|
82
|
+
if (template) visit(template);
|
|
83
|
+
for (const slot of declared) if (!rendered.has(slot)) throw new Error(`${filename}: authored slot "${slot}" requires a matching <slot> outlet.`);
|
|
84
|
+
}
|
|
85
|
+
function staticSlotName(node, filename) {
|
|
86
|
+
if (node.props.some((property) => property.type === 7 && property.name === "bind" && property.arg?.type === 4 && property.arg.isStatic && property.arg.content === "name")) throw new Error(`${filename}: authored slot outlets require a static name.`);
|
|
87
|
+
return staticAttribute(node, "name") ?? "default";
|
|
88
|
+
}
|
|
89
|
+
function staticAttribute(node, name) {
|
|
90
|
+
return node.props.find((property) => property.type === 6 && property.name === name)?.value?.content;
|
|
91
|
+
}
|
|
92
|
+
function staticObjectValue(expression, filename) {
|
|
93
|
+
const entries = expression.properties.map((property) => {
|
|
94
|
+
if (property.type !== "ObjectProperty" || property.computed || property.shorthand || property.key.type !== "Identifier" && property.key.type !== "StringLiteral") throw new Error(`${filename}: authoring objects require literal named properties; spreads and methods are unsupported.`);
|
|
95
|
+
return [property.key.type === "Identifier" ? property.key.name : property.key.value, staticValue(property.value, filename)];
|
|
96
|
+
});
|
|
97
|
+
if (new Set(entries.map(([key]) => key)).size !== entries.length) throw new Error(`${filename}: duplicate authoring property.`);
|
|
98
|
+
return Object.fromEntries(entries);
|
|
99
|
+
}
|
|
67
100
|
function staticValue(expression, filename) {
|
|
68
101
|
switch (expression.type) {
|
|
69
102
|
case "StringLiteral":
|
|
@@ -79,14 +112,7 @@ function staticValue(expression, filename) {
|
|
|
79
112
|
if (!element || element.type === "SpreadElement") throw new Error(`${filename}: authoring arrays require literal entries.`);
|
|
80
113
|
return staticValue(element, filename);
|
|
81
114
|
});
|
|
82
|
-
case "ObjectExpression":
|
|
83
|
-
const entries = expression.properties.map((property) => {
|
|
84
|
-
if (property.type !== "ObjectProperty" || property.computed || property.shorthand || property.key.type !== "Identifier" && property.key.type !== "StringLiteral") throw new Error(`${filename}: authoring objects require literal named properties; spreads and methods are unsupported.`);
|
|
85
|
-
return [property.key.type === "Identifier" ? property.key.name : property.key.value, staticValue(property.value, filename)];
|
|
86
|
-
});
|
|
87
|
-
if (new Set(entries.map(([key]) => key)).size !== entries.length) throw new Error(`${filename}: duplicate authoring property.`);
|
|
88
|
-
return Object.fromEntries(entries);
|
|
89
|
-
}
|
|
115
|
+
case "ObjectExpression": return staticObjectValue(expression, filename);
|
|
90
116
|
}
|
|
91
117
|
throw new Error(`${filename}: authoring metadata must contain only JSON literals; ${expression.type} is unsupported.`);
|
|
92
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-compiler.js","names":[],"sources":["../../../../src/internal/authoring-compiler.ts"],"sourcesContent":["import { babelParse, MagicString, parse, walkIdentifiers } from '@vue/compiler-sfc'\nimport type { Schema } from 'effect'\n\nconst authoringImport = '@phtngyn/cms/Authoring'\n\ntype Statement = ReturnType<typeof babelParse>['program']['body'][number]\n\ntype Expression = Extract<Statement, { type: 'ExpressionStatement' }>['expression']\n\ntype Call = Extract<Expression, { type: 'CallExpression' }>\n\nexport function compileCmsBlock(source: string, filename: string) {\n if (!source.includes(authoringImport)) return undefined\n const { descriptor, errors } = parse(source, { filename })\n\n if (errors.length) throw new Error(`${filename}: ${errors.join('\\n')}`)\n\n if (descriptor.script?.content.includes(authoringImport)) {\n const script = babelParse(descriptor.script.content, { sourceType: 'module', plugins: ['typescript'] })\n\n if (\n script.program.body.some(\n (statement) =>\n statement.type === 'ImportDeclaration' &&\n statement.source.value === authoringImport &&\n statement.importKind !== 'type' &&\n statement.specifiers.some(\n (specifier) => specifier.type !== 'ImportSpecifier' || specifier.importKind !== 'type',\n ),\n )\n )\n throw new Error(`${filename}: defineCmsBlock requires <script setup lang=\"ts\">.`)\n }\n\n const setup = descriptor.scriptSetup\n\n if (!setup) return undefined\n const ast = babelParse(setup.content, { sourceType: 'module', plugins: ['typescript'] })\n\n const imports = ast.program.body.filter(\n (statement) =>\n statement.type === 'ImportDeclaration' &&\n statement.source.value === authoringImport &&\n statement.importKind !== 'type',\n )\n\n if (!imports.length) return undefined\n const imported = imports[0]\n\n if (imported?.type !== 'ImportDeclaration') return undefined\n const specifier = imported.specifiers[0]\n\n if (\n imports.length !== 1 ||\n imported.specifiers.length !== 1 ||\n specifier?.type !== 'ImportSpecifier' ||\n specifier.importKind === 'type' ||\n specifier.imported.type !== 'Identifier' ||\n specifier.imported.name !== 'defineCmsBlock'\n ) {\n throw new Error(`${filename}: use a dedicated named import for defineCmsBlock.`)\n }\n\n if (setup.lang !== 'ts' || setup.attrs.generic) {\n throw new Error(`${filename}: defineCmsBlock requires a non-generic <script setup lang=\"ts\">.`)\n }\n\n const calls = ast.program.body.filter(\n (statement) =>\n statement.type === 'ExpressionStatement' &&\n statement.expression.type === 'CallExpression' &&\n statement.expression.callee.type === 'Identifier' &&\n statement.expression.callee.name === specifier.local.name,\n )\n\n const statement = calls[0]\n\n if (\n calls.length !== 1 ||\n statement?.type !== 'ExpressionStatement' ||\n statement.expression.type !== 'CallExpression'\n ) {\n throw new Error(`${filename}: defineCmsBlock must be called exactly once as a top-level statement.`)\n }\n\n const call = statement.expression\n const argument = call.arguments[0]\n\n if (call.arguments.length !== 1 || argument?.type !== 'ObjectExpression') {\n throw new Error(`${filename}: defineCmsBlock requires one object literal.`)\n }\n\n const types = call.typeParameters?.type === 'TSTypeParameterInstantiation' ? call.typeParameters.params : []\n\n if (types.length !== 2)\n throw new Error(`${filename}: share named Props and Slots types with defineProps and defineSlots.`)\n\n const names = types.map((type) => {\n if (type.type !== 'TSTypeReference' || type.typeName.type !== 'Identifier' || type.typeParameters) {\n throw new Error(`${filename}: defineCmsBlock type arguments must be named, non-generic types.`)\n }\n\n return type.typeName.name\n })\n\n const vueCalls = new Map<string, Call>()\n walkIdentifiers(ast.program, (identifier, parent, _stack, isReference) => {\n if (!isReference) return\n\n if (identifier.name === specifier.local.name && identifier !== call.callee) {\n throw new Error(`${filename}: defineCmsBlock may only be used in its top-level declaration.`)\n }\n\n if (\n (identifier.name === 'defineProps' || identifier.name === 'defineSlots') &&\n parent?.type === 'CallExpression' &&\n parent.callee === identifier\n ) {\n vueCalls.set(identifier.name, parent)\n }\n })\n\n for (const [index, macro] of ['defineProps', 'defineSlots'].entries()) {\n const vueCall = vueCalls.get(macro)\n const parameters = vueCall?.typeParameters\n const type = parameters?.type === 'TSTypeParameterInstantiation' ? parameters.params[0] : undefined\n\n if (\n type?.type !== 'TSTypeReference' ||\n type.typeName.type !== 'Identifier' ||\n type.typeParameters !== undefined ||\n type.typeName.name !== names[index]\n ) {\n throw new Error(`${filename}: ${macro} must use the same ${names[index]} type as defineCmsBlock.`)\n }\n }\n\n const declaration = staticValue(argument, filename)\n const code = new MagicString(source)\n\n for (const node of [imported, statement]) {\n if (node.start === null || node.start === undefined || node.end === null || node.end === undefined) {\n throw new Error(`${filename}: missing authoring declaration source location.`)\n }\n\n code.remove(setup.loc.start.offset + node.start, setup.loc.start.offset + node.end)\n }\n\n return {\n declaration,\n code: code.toString(),\n map: code.generateMap({ source: filename, includeContent: true, hires: true }),\n }\n}\n\nfunction staticValue(expression: Parameters<typeof walkIdentifiers>[0], filename: string): Schema.Json {\n switch (expression.type) {\n case 'StringLiteral':\n case 'BooleanLiteral':\n return expression.value\n case 'NumericLiteral':\n if (Number.isFinite(expression.value)) return expression.value\n break\n case 'NullLiteral':\n return null\n case 'UnaryExpression':\n if (\n expression.operator === '-' &&\n expression.argument.type === 'NumericLiteral' &&\n Number.isFinite(expression.argument.value)\n ) {\n return -expression.argument.value\n }\n\n break\n case 'ArrayExpression':\n return expression.elements.map((element) => {\n if (!element || element.type === 'SpreadElement')\n throw new Error(`${filename}: authoring arrays require literal entries.`)\n\n return staticValue(element, filename)\n })\n case 'ObjectExpression': {\n const entries = expression.properties.map((property): [string, Schema.Json] => {\n if (\n property.type !== 'ObjectProperty' ||\n property.computed ||\n property.shorthand ||\n (property.key.type !== 'Identifier' && property.key.type !== 'StringLiteral')\n ) {\n throw new Error(\n `${filename}: authoring objects require literal named properties; spreads and methods are unsupported.`,\n )\n }\n\n return [\n property.key.type === 'Identifier' ? property.key.name : property.key.value,\n staticValue(property.value, filename),\n ]\n })\n\n if (new Set(entries.map(([key]) => key)).size !== entries.length)\n throw new Error(`${filename}: duplicate authoring property.`)\n\n return Object.fromEntries(entries)\n }\n }\n\n throw new Error(`${filename}: authoring metadata must contain only JSON literals; ${expression.type} is unsupported.`)\n}\n\n/** Reads Vue's printed default expression without evaluating application code. */\nexport function readAuthoringDefault(source: string, filename: string): Schema.Json {\n const expression = babelParse(`(${source})`, { sourceType: 'module', plugins: ['typescript'] }).program.body[0]\n\n if (expression?.type !== 'ExpressionStatement') throw new Error(`${filename}: expected a literal Vue default.`)\n const value = expression.expression\n\n return staticValue(\n value.type === 'ArrowFunctionExpression' && value.body.type !== 'BlockStatement' ? value.body : value,\n filename,\n )\n}\n\nexport function cmsAuthoringPlugin() {\n return {\n name: 'cms:authoring',\n enforce: 'pre' as const,\n transform(source: string, id: string) {\n if (!id.endsWith('.vue')) return undefined\n const compiled = compileCmsBlock(source, id)\n\n return compiled ? { code: compiled.code, map: compiled.map } : undefined\n },\n }\n}\n"],"mappings":";;;AAGA,MAAM,kBAAkB;AAQxB,SAAgB,gBAAgB,QAAgB,UAAkB;CAChE,IAAI,CAAC,OAAO,SAAS,eAAe,GAAG,OAAO;CAC9C,MAAM,EAAE,YAAY,WAAW,MAAM,QAAQ,EAAE,SAAS,CAAC;CAEzD,IAAI,OAAO,QAAQ,MAAM,IAAI,MAAM,GAAG,SAAS,IAAI,OAAO,KAAK,IAAI,GAAG;CAEtE,IAAI,WAAW,QAAQ,QAAQ,SAAS,eAAe,GAGrD;MAFe,WAAW,WAAW,OAAO,SAAS;GAAE,YAAY;GAAU,SAAS,CAAC,YAAY;EAAE,CAG9F,CAAC,CAAC,QAAQ,KAAK,MACjB,cACC,UAAU,SAAS,uBACnB,UAAU,OAAO,UAAU,mBAC3B,UAAU,eAAe,UACzB,UAAU,WAAW,MAClB,cAAc,UAAU,SAAS,qBAAqB,UAAU,eAAe,MAClF,CACJ,GAEA,MAAM,IAAI,MAAM,GAAG,SAAS,oDAAoD;;CAGpF,MAAM,QAAQ,WAAW;CAEzB,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,MAAM,WAAW,MAAM,SAAS;EAAE,YAAY;EAAU,SAAS,CAAC,YAAY;CAAE,CAAC;CA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C,CAAC,QAAQ,KAAK;CAE7G,IAAI,YAAY,SAAS,uBAAuB,MAAM,IAAI,MAAM,GAAG,SAAS,kCAAkC;CAC9G,MAAM,QAAQ,WAAW;CAEzB,OAAO,YACL,MAAM,SAAS,6BAA6B,MAAM,KAAK,SAAS,mBAAmB,MAAM,OAAO,OAChG,QACF;AACF;AAEA,SAAgB,qBAAqB;CACnC,OAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,QAAgB,IAAY;GACpC,IAAI,CAAC,GAAG,SAAS,MAAM,GAAG,OAAO;GACjC,MAAM,WAAW,gBAAgB,QAAQ,EAAE;GAE3C,OAAO,WAAW;IAAE,MAAM,SAAS;IAAM,KAAK,SAAS;GAAI,IAAI;EACjE;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"authoring-compiler.js","names":[],"sources":["../../../../src/internal/authoring-compiler.ts"],"sourcesContent":["import { babelParse, MagicString, parse, walkIdentifiers } from '@vue/compiler-sfc'\nimport { Schema } from 'effect'\n\nconst authoringImport = '@phtngyn/cms/Authoring'\n\ntype Statement = ReturnType<typeof babelParse>['program']['body'][number]\n\ntype Expression = Extract<Statement, { type: 'ExpressionStatement' }>['expression']\n\ntype Call = Extract<Expression, { type: 'CallExpression' }>\n\ntype TemplateRoot = NonNullable<NonNullable<ReturnType<typeof parse>['descriptor']['template']>['ast']>\n\ntype TemplateNode = TemplateRoot | TemplateRoot['children'][number]\n\ntype TemplateElement = Extract<TemplateNode, { type: 1 }>\n\ntype TemplateAttribute = Extract<TemplateElement['props'][number], { type: 6 }>\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\nexport function compileCmsBlock(source: string, filename: string) {\n if (!source.includes(authoringImport)) return undefined\n const { descriptor, errors } = parse(source, { filename })\n\n if (errors.length) throw new Error(`${filename}: ${errors.join('\\n')}`)\n\n if (descriptor.script?.content.includes(authoringImport)) {\n const script = babelParse(descriptor.script.content, { sourceType: 'module', plugins: ['typescript'] })\n\n if (\n script.program.body.some(\n (statement) =>\n statement.type === 'ImportDeclaration' &&\n statement.source.value === authoringImport &&\n statement.importKind !== 'type' &&\n statement.specifiers.some(\n (specifier) => specifier.type !== 'ImportSpecifier' || specifier.importKind !== 'type',\n ),\n )\n )\n throw new Error(`${filename}: defineCmsBlock requires <script setup lang=\"ts\">.`)\n }\n\n const setup = descriptor.scriptSetup\n\n if (!setup) return undefined\n const ast = babelParse(setup.content, { sourceType: 'module', plugins: ['typescript'] })\n\n const imports = ast.program.body.filter(\n (statement) =>\n statement.type === 'ImportDeclaration' &&\n statement.source.value === authoringImport &&\n statement.importKind !== 'type',\n )\n\n if (!imports.length) return undefined\n const imported = imports[0]\n\n if (imported?.type !== 'ImportDeclaration') return undefined\n const specifier = imported.specifiers[0]\n\n if (\n imports.length !== 1 ||\n imported.specifiers.length !== 1 ||\n specifier?.type !== 'ImportSpecifier' ||\n specifier.importKind === 'type' ||\n specifier.imported.type !== 'Identifier' ||\n specifier.imported.name !== 'defineCmsBlock'\n ) {\n throw new Error(`${filename}: use a dedicated named import for defineCmsBlock.`)\n }\n\n if (setup.lang !== 'ts' || setup.attrs.generic) {\n throw new Error(`${filename}: defineCmsBlock requires a non-generic <script setup lang=\"ts\">.`)\n }\n\n const calls = ast.program.body.filter(\n (statement) =>\n statement.type === 'ExpressionStatement' &&\n statement.expression.type === 'CallExpression' &&\n statement.expression.callee.type === 'Identifier' &&\n statement.expression.callee.name === specifier.local.name,\n )\n\n const statement = calls[0]\n\n if (\n calls.length !== 1 ||\n statement?.type !== 'ExpressionStatement' ||\n statement.expression.type !== 'CallExpression'\n ) {\n throw new Error(`${filename}: defineCmsBlock must be called exactly once as a top-level statement.`)\n }\n\n const call = statement.expression\n const argument = call.arguments[0]\n\n if (call.arguments.length !== 1 || argument?.type !== 'ObjectExpression') {\n throw new Error(`${filename}: defineCmsBlock requires one object literal.`)\n }\n\n const types = call.typeParameters?.type === 'TSTypeParameterInstantiation' ? call.typeParameters.params : []\n\n if (types.length !== 2)\n throw new Error(`${filename}: share named Props and Slots types with defineProps and defineSlots.`)\n\n const names = types.map((type) => {\n if (type.type !== 'TSTypeReference' || type.typeName.type !== 'Identifier' || type.typeParameters) {\n throw new Error(`${filename}: defineCmsBlock type arguments must be named, non-generic types.`)\n }\n\n return type.typeName.name\n })\n\n const vueCalls = new Map<string, Call>()\n walkIdentifiers(ast.program, (identifier, parent, _stack, isReference) => {\n if (!isReference) return\n\n if (identifier.name === specifier.local.name && identifier !== call.callee) {\n throw new Error(`${filename}: defineCmsBlock may only be used in its top-level declaration.`)\n }\n\n if (\n (identifier.name === 'defineProps' || identifier.name === 'defineSlots') &&\n parent?.type === 'CallExpression' &&\n parent.callee === identifier\n ) {\n vueCalls.set(identifier.name, parent)\n }\n })\n\n for (const [index, macro] of ['defineProps', 'defineSlots'].entries()) {\n const vueCall = vueCalls.get(macro)\n const parameters = vueCall?.typeParameters\n const type = parameters?.type === 'TSTypeParameterInstantiation' ? parameters.params[0] : undefined\n\n if (\n type?.type !== 'TSTypeReference' ||\n type.typeName.type !== 'Identifier' ||\n type.typeParameters !== undefined ||\n type.typeName.name !== names[index]\n ) {\n throw new Error(`${filename}: ${macro} must use the same ${names[index]} type as defineCmsBlock.`)\n }\n }\n\n const declaration = staticObjectValue(argument, filename)\n validateSlotOutlets(descriptor.template?.ast, declaration, filename)\n const code = new MagicString(source)\n\n for (const node of [imported, statement]) {\n if (node.start === null || node.start === undefined || node.end === null || node.end === undefined) {\n throw new Error(`${filename}: missing authoring declaration source location.`)\n }\n\n code.remove(setup.loc.start.offset + node.start, setup.loc.start.offset + node.end)\n }\n\n return {\n declaration,\n code: code.toString(),\n map: code.generateMap({ source: filename, includeContent: true, hires: true }),\n }\n}\n\nfunction validateSlotOutlets(\n template: TemplateRoot | undefined,\n declaration: Schema.JsonObject,\n filename: string,\n): void {\n if (!isJsonObject(declaration.slots)) return\n\n const declared = new Set(Object.keys(declaration.slots))\n const rendered = new Set<string>()\n\n function visit(node: TemplateNode): void {\n const element = node.type === 1 ? node : undefined\n\n if (element?.tag === 'slot') {\n const slot = staticSlotName(element, filename)\n\n if (declared.has(slot)) rendered.add(slot)\n }\n\n if (node.type === 0 || node.type === 1) {\n for (const child of node.children) visit(child)\n }\n }\n\n if (template) visit(template)\n\n for (const slot of declared) {\n if (!rendered.has(slot)) throw new Error(`${filename}: authored slot \"${slot}\" requires a matching <slot> outlet.`)\n }\n}\n\nfunction staticSlotName(node: TemplateElement, filename: string): string {\n const dynamicName = node.props.some(\n (property) =>\n property.type === 7 &&\n property.name === 'bind' &&\n property.arg?.type === 4 &&\n property.arg.isStatic &&\n property.arg.content === 'name',\n )\n\n if (dynamicName) throw new Error(`${filename}: authored slot outlets require a static name.`)\n\n return staticAttribute(node, 'name') ?? 'default'\n}\n\nfunction staticAttribute(node: TemplateElement, name: string): string | undefined {\n return node.props.find((property): property is TemplateAttribute => property.type === 6 && property.name === name)\n ?.value?.content\n}\n\nfunction staticObjectValue(\n expression: Extract<Parameters<typeof walkIdentifiers>[0], { type: 'ObjectExpression' }>,\n filename: string,\n): Schema.JsonObject {\n const entries = expression.properties.map((property): [string, Schema.Json] => {\n if (\n property.type !== 'ObjectProperty' ||\n property.computed ||\n property.shorthand ||\n (property.key.type !== 'Identifier' && property.key.type !== 'StringLiteral')\n ) {\n throw new Error(\n `${filename}: authoring objects require literal named properties; spreads and methods are unsupported.`,\n )\n }\n\n return [\n property.key.type === 'Identifier' ? property.key.name : property.key.value,\n staticValue(property.value, filename),\n ]\n })\n\n if (new Set(entries.map(([key]) => key)).size !== entries.length)\n throw new Error(`${filename}: duplicate authoring property.`)\n\n return Object.fromEntries(entries)\n}\n\nfunction staticValue(expression: Parameters<typeof walkIdentifiers>[0], filename: string): Schema.Json {\n switch (expression.type) {\n case 'StringLiteral':\n case 'BooleanLiteral':\n return expression.value\n case 'NumericLiteral':\n if (Number.isFinite(expression.value)) return expression.value\n break\n case 'NullLiteral':\n return null\n case 'UnaryExpression':\n if (\n expression.operator === '-' &&\n expression.argument.type === 'NumericLiteral' &&\n Number.isFinite(expression.argument.value)\n ) {\n return -expression.argument.value\n }\n\n break\n case 'ArrayExpression':\n return expression.elements.map((element) => {\n if (!element || element.type === 'SpreadElement')\n throw new Error(`${filename}: authoring arrays require literal entries.`)\n\n return staticValue(element, filename)\n })\n case 'ObjectExpression':\n return staticObjectValue(expression, filename)\n }\n\n throw new Error(`${filename}: authoring metadata must contain only JSON literals; ${expression.type} is unsupported.`)\n}\n\n/** Reads Vue's printed default expression without evaluating application code. */\nexport function readAuthoringDefault(source: string, filename: string): Schema.Json {\n const expression = babelParse(`(${source})`, { sourceType: 'module', plugins: ['typescript'] }).program.body[0]\n\n if (expression?.type !== 'ExpressionStatement') throw new Error(`${filename}: expected a literal Vue default.`)\n const value = expression.expression\n\n return staticValue(\n value.type === 'ArrowFunctionExpression' && value.body.type !== 'BlockStatement' ? value.body : value,\n filename,\n )\n}\n\nexport function cmsAuthoringPlugin() {\n return {\n name: 'cms:authoring',\n enforce: 'pre' as const,\n transform(source: string, id: string) {\n if (!id.endsWith('.vue')) return undefined\n const compiled = compileCmsBlock(source, id)\n\n return compiled ? { code: compiled.code, map: compiled.map } : undefined\n },\n }\n}\n"],"mappings":";;;;AAGA,MAAM,kBAAkB;AAgBxB,MAAM,eAAe,OAAO,GAAG,OAAO,UAAU;AAEhD,SAAgB,gBAAgB,QAAgB,UAAkB;CAChE,IAAI,CAAC,OAAO,SAAS,eAAe,GAAG,OAAO;CAC9C,MAAM,EAAE,YAAY,WAAW,MAAM,QAAQ,EAAE,SAAS,CAAC;CAEzD,IAAI,OAAO,QAAQ,MAAM,IAAI,MAAM,GAAG,SAAS,IAAI,OAAO,KAAK,IAAI,GAAG;CAEtE,IAAI,WAAW,QAAQ,QAAQ,SAAS,eAAe,GAGrD;MAFe,WAAW,WAAW,OAAO,SAAS;GAAE,YAAY;GAAU,SAAS,CAAC,YAAY;EAAE,CAG9F,CAAC,CAAC,QAAQ,KAAK,MACjB,cACC,UAAU,SAAS,uBACnB,UAAU,OAAO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MAAM,GAAG,SAAS,wDAAwD,WAAW,KAAK,iBAAiB;AACvH;;AAGA,SAAgB,qBAAqB,QAAgB,UAA+B;CAClF,MAAM,aAAa,WAAW,IAAI,OAAO,IAAI;EAAE,YAAY;EAAU,SAAS,CAAC,YAAY;CAAE,CAAC,CAAC,CAAC,QAAQ,KAAK;CAE7G,IAAI,YAAY,SAAS,uBAAuB,MAAM,IAAI,MAAM,GAAG,SAAS,kCAAkC;CAC9G,MAAM,QAAQ,WAAW;CAEzB,OAAO,YACL,MAAM,SAAS,6BAA6B,MAAM,KAAK,SAAS,mBAAmB,MAAM,OAAO,OAChG,QACF;AACF;AAEA,SAAgB,qBAAqB;CACnC,OAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,QAAgB,IAAY;GACpC,IAAI,CAAC,GAAG,SAAS,MAAM,GAAG,OAAO;GACjC,MAAM,WAAW,gBAAgB,QAAQ,EAAE;GAE3C,OAAO,WAAW;IAAE,MAAM,SAAS;IAAM,KAAK,SAAS;GAAI,IAAI;EACjE;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as BlockAuthoring, c as parseAuthoringContent, n as ComponentDefinition, s as createAuthoringSchema } from "../Configuration-
|
|
1
|
+
import { a as BlockAuthoring, c as parseAuthoringContent, n as ComponentDefinition, s as createAuthoringSchema } from "../Configuration-JQ1qyaU0.js";
|
|
2
2
|
import { compileCmsBlock, readAuthoringDefault } from "./authoring-compiler.js";
|
|
3
3
|
import { Effect, Result, Schema } from "effect";
|
|
4
4
|
import ts from "typescript";
|
|
@@ -99,7 +99,13 @@ function resolveProp(raw, name, required, presentation, checker, filename, defau
|
|
|
99
99
|
const valueType = checker.getNonNullableType(raw);
|
|
100
100
|
let type;
|
|
101
101
|
let fields;
|
|
102
|
-
if (
|
|
102
|
+
if (presentation.input === "multiselect") {
|
|
103
|
+
const item = checker.getIndexTypeOfType(valueType, ts.IndexKind.Number);
|
|
104
|
+
const itemMembers = item?.isUnion() ? item.types : item ? [item] : [];
|
|
105
|
+
if (!itemMembers.length || !itemMembers.every((member) => Boolean(member.flags & ts.TypeFlags.StringLike))) throw new Error(`${filename}: ${name} needs a string list type.`);
|
|
106
|
+
type = "string[]";
|
|
107
|
+
choices.push(...itemMembers.flatMap((member) => member.isStringLiteral() ? [member.value] : []).sort());
|
|
108
|
+
} else if (members.length && members.every((type) => Boolean(type.flags & ts.TypeFlags.StringLike))) type = "string";
|
|
103
109
|
else if (members.length === 1 && members[0]?.flags === ts.TypeFlags.Number) type = "number";
|
|
104
110
|
else if (members.length && members.every((type) => Boolean(type.flags & ts.TypeFlags.BooleanLike))) type = "boolean";
|
|
105
111
|
else if (presentation.input === "object" || presentation.input === "list") {
|
|
@@ -129,13 +135,16 @@ function resolveProp(raw, name, required, presentation, checker, filename, defau
|
|
|
129
135
|
"textarea",
|
|
130
136
|
"select",
|
|
131
137
|
"image",
|
|
132
|
-
"link"
|
|
138
|
+
"link",
|
|
139
|
+
"document",
|
|
140
|
+
"media"
|
|
133
141
|
],
|
|
134
142
|
number: ["number"],
|
|
135
143
|
boolean: ["toggle"],
|
|
144
|
+
"string[]": ["multiselect"],
|
|
136
145
|
object: ["object"],
|
|
137
146
|
array: ["list"]
|
|
138
|
-
}[type].includes(presentation.input) || presentation.input === "select" && !choices.length) throw new Error(`${filename}: ${name} has an incompatible authoring input ${presentation.input}.`);
|
|
147
|
+
}[type].includes(presentation.input) || (presentation.input === "select" || presentation.input === "multiselect") && presentation.optionLabels !== void 0 && !choices.length) throw new Error(`${filename}: ${name} has an incompatible authoring input ${presentation.input}.`);
|
|
139
148
|
for (const key of Object.keys(presentation.optionLabels ?? {})) if (!choices.includes(key)) throw new Error(`${filename}: ${key} is not a Vue union choice.`);
|
|
140
149
|
return Result.getOrThrow(Schema.decodeUnknownResult(BlockAuthoring.fields.props.value)({
|
|
141
150
|
name,
|
|
@@ -144,7 +153,7 @@ function resolveProp(raw, name, required, presentation, checker, filename, defau
|
|
|
144
153
|
input: presentation.input,
|
|
145
154
|
required,
|
|
146
155
|
nullable,
|
|
147
|
-
...presentation.help === void 0 ? void 0 : {
|
|
156
|
+
...presentation.help === void 0 ? void 0 : { description: presentation.help },
|
|
148
157
|
...fields === void 0 ? void 0 : { fields },
|
|
149
158
|
...defaultSource === void 0 ? void 0 : { defaultValue: readAuthoringDefault(defaultSource, `${filename} prop ${name}`) },
|
|
150
159
|
options: choices.map((value) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-metadata.js","names":[],"sources":["../../../../src/internal/authoring-metadata.ts"],"sourcesContent":["import type { ComponentMetaChecker } from 'vue-component-meta'\nimport type { BlockProp, BlockSlot } from '@internal/protocol/Authoring'\nimport { createAuthoringSchema, parseAuthoringContent } from '@internal/document/AuthoringSchema'\nimport { BlockAuthoring } from '@internal/protocol/Authoring'\nimport { ComponentDefinition } from '@internal/protocol/Configuration'\nimport { Result, Effect, Schema } from 'effect'\nimport ts from 'typescript'\nimport { compileCmsBlock, readAuthoringDefault } from './authoring-compiler'\n\ninterface Presentation {\n readonly label: string\n readonly help?: string\n readonly input: string\n readonly optionLabels?: Readonly<Record<string, string>>\n readonly features?: ReadonlyArray<'bold' | 'italic' | 'link' | 'bullet-list' | 'code'>\n readonly blocks?: ReadonlyArray<string>\n readonly groups?: ReadonlyArray<string>\n readonly fields?: Readonly<Record<string, Presentation>>\n}\n\nconst Presentation: Schema.Codec<Presentation> = Schema.Struct({\n fields: Schema.optionalKey(\n Schema.Record(\n Schema.String,\n Schema.suspend(() => Presentation),\n ),\n ),\n blocks: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n groups: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n label: Schema.NonEmptyString,\n help: Schema.optionalKey(Schema.String),\n input: Schema.String,\n optionLabels: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n features: Schema.optionalKey(Schema.Array(Schema.Literals(['bold', 'italic', 'link', 'bullet-list', 'code']))),\n})\n\nconst Declaration = Schema.Struct({\n label: Schema.NonEmptyString,\n description: Schema.optionalKey(Schema.String),\n group: Schema.optionalKey(Schema.String),\n icon: Schema.optionalKey(Schema.String),\n props: Schema.Record(Schema.String, Presentation),\n slots: Schema.Record(Schema.String, Presentation),\n initial: Schema.optionalKey(\n Schema.Struct({\n props: Schema.optionalKey(Schema.JsonObject),\n slots: Schema.optionalKey(\n Schema.Record(\n Schema.String,\n Schema.Union([Schema.Struct({ text: Schema.String }), Schema.Struct({ markdown: Schema.String })]),\n ),\n ),\n }),\n ),\n})\n\n/** Resolves one opted-in SFC. No framework metadata or executable defaults cross this seam. */\nexport const resolveBlockAuthoring = Effect.fn('NuxtAuthoring.resolve')(function* (\n checker: ComponentMetaChecker,\n filename: string,\n name: string,\n source: string,\n) {\n const compiled = compileCmsBlock(source, filename)\n\n if (!compiled) return undefined\n const declared = yield* Schema.decodeUnknownEffect(Declaration)(compiled.declaration, { onExcessProperty: 'error' })\n checker.updateFile(filename, source)\n const metadata = checker.getComponentMeta(filename)\n\n const props = Object.entries(declared.props).map(([key, presentation]): BlockProp => {\n const prop = metadata.props.find((candidate) => candidate.name === key && !candidate.global)\n\n if (!prop) throw new Error(`${filename}: unknown Vue prop ${key}.`)\n const typeChecker = checker.getProgram()?.getTypeChecker()\n\n if (!typeChecker) throw new Error(`${filename}: Vue type information is unavailable.`)\n\n return resolveProp(prop.getTypeObject(), key, prop.required, presentation, typeChecker, filename, prop.default)\n })\n\n for (const prop of metadata.props) {\n if (!prop.global && prop.required && prop.default === undefined && !Object.hasOwn(declared.props, prop.name))\n throw new Error(`${filename}: required prop ${prop.name} needs an authoring declaration and initial value.`)\n }\n\n const slotTypes = vueSlots(checker, filename)\n const slots: BlockSlot[] = []\n\n for (const [key, presentation] of Object.entries(declared.slots)) {\n const slot = slotTypes.get(key)\n\n if (!slot) throw new Error(`${filename}: unknown Vue slot ${key}.`)\n\n if (slot.scoped) throw new Error(`${filename}: scoped slot ${key} cannot be authored.`)\n const seed = declared.initial?.slots?.[key]\n\n const initial = seed\n ? 'text' in seed\n ? [['p', {}, seed.text]]\n : yield* parseAuthoringContent(seed.markdown)\n : undefined\n\n slots.push(\n yield* Schema.decodeUnknownEffect(BlockAuthoring.fields.slots.value)({\n name: key,\n label: presentation.label,\n ...(presentation.help === undefined ? undefined : { help: presentation.help }),\n input: presentation.input,\n required: slot.required,\n features: presentation.features ?? [],\n ...(presentation.blocks === undefined ? undefined : { blocks: presentation.blocks }),\n ...(presentation.groups === undefined ? undefined : { groups: presentation.groups }),\n ...(initial === undefined ? undefined : { initial }),\n }),\n )\n\n if (slot.required && !seed) throw new Error(`${filename}: required slot ${key} needs initial content.`)\n }\n\n for (const [key, slot] of slotTypes)\n if (slot.required && !Object.hasOwn(declared.slots, key))\n throw new Error(`${filename}: required slot ${key} must be declared.`)\n\n for (const key of Object.keys(declared.initial?.slots ?? {}))\n if (!slotTypes.has(key) || !Object.hasOwn(declared.slots, key))\n throw new Error(`${filename}: initial content refers to undeclared slot ${key}.`)\n\n const authoring = BlockAuthoring.make({\n version: 1,\n label: declared.label,\n props,\n slots,\n initialProps: declared.initial?.props ?? {},\n ...(declared.description === undefined ? undefined : { description: declared.description }),\n ...(declared.group === undefined ? undefined : { group: declared.group }),\n ...(declared.icon === undefined ? undefined : { icon: declared.icon }),\n })\n\n createAuthoringSchema(name, authoring)\n\n return ComponentDefinition.make({\n name,\n authoring,\n })\n})\n\nfunction resolveProp(\n raw: ts.Type,\n name: string,\n required: boolean,\n presentation: Presentation,\n checker: ts.TypeChecker,\n filename: string,\n defaultSource?: string,\n depth = 0,\n): BlockProp {\n if (depth > 12) throw new Error(`${filename}: ${name} exceeds the supported property nesting depth.`)\n const union = raw.isUnion() ? raw.types : [raw]\n const members = union.filter((type) => !(type.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Null)))\n const nullable = union.some((type) => Boolean(type.flags & ts.TypeFlags.Null))\n const choices = members.flatMap((type) => (type.isStringLiteral() ? [type.value] : [])).sort()\n const valueType = checker.getNonNullableType(raw)\n let type: BlockProp['type']\n let fields: BlockProp[] | undefined\n\n if (members.length && members.every((type) => Boolean(type.flags & ts.TypeFlags.StringLike))) type = 'string'\n else if (members.length === 1 && members[0]?.flags === ts.TypeFlags.Number) type = 'number'\n else if (members.length && members.every((type) => Boolean(type.flags & ts.TypeFlags.BooleanLike))) type = 'boolean'\n else if (presentation.input === 'object' || presentation.input === 'list') {\n type = presentation.input === 'list' ? 'array' : 'object'\n const item = type === 'array' ? checker.getIndexTypeOfType(valueType, ts.IndexKind.Number) : valueType\n\n if (!item || !(item.flags & ts.TypeFlags.Object) || item.getCallSignatures().length)\n throw new Error(`${filename}: ${name} needs an object${type === 'array' ? ' list' : ''} type.`)\n\n if (type === 'array') {\n const id = item.getProperty('id')\n const declaration = id?.valueDeclaration ?? id?.declarations?.[0]\n\n if (\n !id ||\n !declaration ||\n id.flags & ts.SymbolFlags.Optional ||\n checker.getTypeOfSymbolAtLocation(id, declaration).flags !== ts.TypeFlags.String\n )\n throw new Error(`${filename}: ${name} list items need a required string id for stable editing.`)\n }\n\n fields = Object.entries(presentation.fields ?? {}).map(([key, field]) => {\n if (type === 'array' && key === 'id') throw new Error(`${filename}: list item ids are managed by Studio.`)\n const property = item.getProperty(key)\n const declaration = property?.valueDeclaration ?? property?.declarations?.[0]\n\n if (!property || !declaration) throw new Error(`${filename}: unknown field ${name}.${key}.`)\n\n return resolveProp(\n checker.getTypeOfSymbolAtLocation(property, declaration),\n key,\n !(property.flags & ts.SymbolFlags.Optional),\n field,\n checker,\n filename,\n undefined,\n depth + 1,\n )\n })\n\n for (const property of item.getProperties()) {\n if (type === 'array' && property.name === 'id') continue\n\n if (!(property.flags & ts.SymbolFlags.Optional) && !fields.some((field) => field.name === property.name))\n throw new Error(`${filename}: required field ${name}.${property.name} needs an authoring declaration.`)\n }\n } else throw new Error(`${filename}: unsupported editable prop ${name}.`)\n\n const inputs = {\n string: ['text', 'textarea', 'select', 'image', 'link'],\n number: ['number'],\n boolean: ['toggle'],\n object: ['object'],\n array: ['list'],\n }\n\n if (!inputs[type].includes(presentation.input) || (presentation.input === 'select' && !choices.length))\n throw new Error(`${filename}: ${name} has an incompatible authoring input ${presentation.input}.`)\n\n for (const key of Object.keys(presentation.optionLabels ?? {}))\n if (!choices.includes(key)) throw new Error(`${filename}: ${key} is not a Vue union choice.`)\n\n return Result.getOrThrow(\n Schema.decodeUnknownResult(BlockAuthoring.fields.props.value)({\n name,\n label: presentation.label,\n type,\n input: presentation.input,\n required,\n nullable,\n ...(presentation.help === undefined ? undefined : { help: presentation.help }),\n ...(fields === undefined ? undefined : { fields }),\n ...(defaultSource === undefined\n ? undefined\n : { defaultValue: readAuthoringDefault(defaultSource, `${filename} prop ${name}`) }),\n options: choices.map((value) => ({ value, label: presentation.optionLabels?.[value] ?? value })),\n }),\n )\n}\n\nfunction vueSlots(checker: ComponentMetaChecker, filename: string) {\n const program = checker.getProgram()\n const file = program?.getSourceFile(filename)\n\n if (!program || !file) throw new Error(`${filename}: Vue type information is unavailable.`)\n const typeChecker = program.getTypeChecker()\n const result = new Map<string, { required: boolean; scoped: boolean }>()\n\n function visit(node: ts.Node): void {\n if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'defineSlots') {\n const type = node.typeArguments?.[0]\n\n if (type)\n for (const property of typeChecker.getTypeAtLocation(type).getProperties()) {\n const declaration = property.valueDeclaration ?? property.declarations?.[0]\n\n const signature = declaration\n ? typeChecker\n .getNonNullableType(typeChecker.getTypeOfSymbolAtLocation(property, declaration))\n .getCallSignatures()\n : []\n\n result.set(property.name, {\n required: !(property.flags & ts.SymbolFlags.Optional),\n scoped: signature.length !== 1 || signature.some((signature) => signature.parameters.length > 0),\n })\n }\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(file)\n\n return result\n}\n"],"mappings":";;;;;;AAoBA,MAAM,eAA2C,OAAO,OAAO;CAC7D,QAAQ,OAAO,YACb,OAAO,OACL,OAAO,QACP,OAAO,cAAc,YAAY,CAC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kBAAkB,IACrB,CAAC;IAEL,OAAO,IAAI,SAAS,MAAM;KACxB,UAAU,EAAE,SAAS,QAAQ,GAAG,YAAY;KAC5C,QAAQ,UAAU,WAAW,KAAK,UAAU,MAAM,cAAc,UAAU,WAAW,SAAS,CAAC;IACjG,CAAC;GACH;EACJ;EAEA,GAAG,aAAa,MAAM,KAAK;CAC7B;CAEA,MAAM,IAAI;CAEV,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"authoring-metadata.js","names":[],"sources":["../../../../src/internal/authoring-metadata.ts"],"sourcesContent":["import type { ComponentMetaChecker } from 'vue-component-meta'\nimport type { BlockSlot } from '@internal/protocol/Authoring'\nimport type { StructuredField } from '@internal/protocol/StructuredFields'\nimport { createAuthoringSchema, parseAuthoringContent } from '@internal/document/AuthoringSchema'\nimport { BlockAuthoring } from '@internal/protocol/Authoring'\nimport { ComponentDefinition } from '@internal/protocol/Configuration'\nimport { Result, Effect, Schema } from 'effect'\nimport ts from 'typescript'\nimport { compileCmsBlock, readAuthoringDefault } from './authoring-compiler'\n\ninterface Presentation {\n readonly label: string\n readonly help?: string\n readonly input: string\n readonly optionLabels?: Readonly<Record<string, string>>\n readonly features?: ReadonlyArray<'bold' | 'italic' | 'link' | 'bullet-list' | 'code'>\n readonly blocks?: ReadonlyArray<string>\n readonly groups?: ReadonlyArray<string>\n readonly fields?: Readonly<Record<string, Presentation>>\n}\n\nconst Presentation: Schema.Codec<Presentation> = Schema.Struct({\n fields: Schema.optionalKey(\n Schema.Record(\n Schema.String,\n Schema.suspend(() => Presentation),\n ),\n ),\n blocks: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n groups: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n label: Schema.NonEmptyString,\n help: Schema.optionalKey(Schema.String),\n input: Schema.String,\n optionLabels: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n features: Schema.optionalKey(Schema.Array(Schema.Literals(['bold', 'italic', 'link', 'bullet-list', 'code']))),\n})\n\nconst Declaration = Schema.Struct({\n label: Schema.NonEmptyString,\n description: Schema.optionalKey(Schema.String),\n group: Schema.optionalKey(Schema.String),\n icon: Schema.optionalKey(Schema.String),\n props: Schema.Record(Schema.String, Presentation),\n slots: Schema.Record(Schema.String, Presentation),\n initial: Schema.optionalKey(\n Schema.Struct({\n props: Schema.optionalKey(Schema.JsonObject),\n slots: Schema.optionalKey(\n Schema.Record(\n Schema.String,\n Schema.Union([Schema.Struct({ text: Schema.String }), Schema.Struct({ markdown: Schema.String })]),\n ),\n ),\n }),\n ),\n})\n\n/** Resolves one opted-in SFC. No framework metadata or executable defaults cross this seam. */\nexport const resolveBlockAuthoring = Effect.fn('NuxtAuthoring.resolve')(function* (\n checker: ComponentMetaChecker,\n filename: string,\n name: string,\n source: string,\n) {\n const compiled = compileCmsBlock(source, filename)\n\n if (!compiled) return undefined\n const declared = yield* Schema.decodeUnknownEffect(Declaration)(compiled.declaration, { onExcessProperty: 'error' })\n checker.updateFile(filename, source)\n const metadata = checker.getComponentMeta(filename)\n\n const props = Object.entries(declared.props).map(([key, presentation]): StructuredField => {\n const prop = metadata.props.find((candidate) => candidate.name === key && !candidate.global)\n\n if (!prop) throw new Error(`${filename}: unknown Vue prop ${key}.`)\n const typeChecker = checker.getProgram()?.getTypeChecker()\n\n if (!typeChecker) throw new Error(`${filename}: Vue type information is unavailable.`)\n\n return resolveProp(prop.getTypeObject(), key, prop.required, presentation, typeChecker, filename, prop.default)\n })\n\n for (const prop of metadata.props) {\n if (!prop.global && prop.required && prop.default === undefined && !Object.hasOwn(declared.props, prop.name))\n throw new Error(`${filename}: required prop ${prop.name} needs an authoring declaration and initial value.`)\n }\n\n const slotTypes = vueSlots(checker, filename)\n const slots: BlockSlot[] = []\n\n for (const [key, presentation] of Object.entries(declared.slots)) {\n const slot = slotTypes.get(key)\n\n if (!slot) throw new Error(`${filename}: unknown Vue slot ${key}.`)\n\n if (slot.scoped) throw new Error(`${filename}: scoped slot ${key} cannot be authored.`)\n const seed = declared.initial?.slots?.[key]\n\n const initial = seed\n ? 'text' in seed\n ? [['p', {}, seed.text]]\n : yield* parseAuthoringContent(seed.markdown)\n : undefined\n\n slots.push(\n yield* Schema.decodeUnknownEffect(BlockAuthoring.fields.slots.value)({\n name: key,\n label: presentation.label,\n ...(presentation.help === undefined ? undefined : { help: presentation.help }),\n input: presentation.input,\n required: slot.required,\n features: presentation.features ?? [],\n ...(presentation.blocks === undefined ? undefined : { blocks: presentation.blocks }),\n ...(presentation.groups === undefined ? undefined : { groups: presentation.groups }),\n ...(initial === undefined ? undefined : { initial }),\n }),\n )\n\n if (slot.required && !seed) throw new Error(`${filename}: required slot ${key} needs initial content.`)\n }\n\n for (const [key, slot] of slotTypes)\n if (slot.required && !Object.hasOwn(declared.slots, key))\n throw new Error(`${filename}: required slot ${key} must be declared.`)\n\n for (const key of Object.keys(declared.initial?.slots ?? {}))\n if (!slotTypes.has(key) || !Object.hasOwn(declared.slots, key))\n throw new Error(`${filename}: initial content refers to undeclared slot ${key}.`)\n\n const authoring = BlockAuthoring.make({\n version: 1,\n label: declared.label,\n props,\n slots,\n initialProps: declared.initial?.props ?? {},\n ...(declared.description === undefined ? undefined : { description: declared.description }),\n ...(declared.group === undefined ? undefined : { group: declared.group }),\n ...(declared.icon === undefined ? undefined : { icon: declared.icon }),\n })\n\n createAuthoringSchema(name, authoring)\n\n return ComponentDefinition.make({\n name,\n authoring,\n })\n})\n\nfunction resolveProp(\n raw: ts.Type,\n name: string,\n required: boolean,\n presentation: Presentation,\n checker: ts.TypeChecker,\n filename: string,\n defaultSource?: string,\n depth = 0,\n): StructuredField {\n if (depth > 12) throw new Error(`${filename}: ${name} exceeds the supported property nesting depth.`)\n const union = raw.isUnion() ? raw.types : [raw]\n const members = union.filter((type) => !(type.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Null)))\n const nullable = union.some((type) => Boolean(type.flags & ts.TypeFlags.Null))\n const choices = members.flatMap((type) => (type.isStringLiteral() ? [type.value] : [])).sort()\n const valueType = checker.getNonNullableType(raw)\n let type: StructuredField['type']\n let fields: StructuredField[] | undefined\n\n if (presentation.input === 'multiselect') {\n const item = checker.getIndexTypeOfType(valueType, ts.IndexKind.Number)\n const itemMembers = item?.isUnion() ? item.types : item ? [item] : []\n\n if (!itemMembers.length || !itemMembers.every((member) => Boolean(member.flags & ts.TypeFlags.StringLike)))\n throw new Error(`${filename}: ${name} needs a string list type.`)\n\n type = 'string[]'\n choices.push(...itemMembers.flatMap((member) => (member.isStringLiteral() ? [member.value] : [])).sort())\n } else if (members.length && members.every((type) => Boolean(type.flags & ts.TypeFlags.StringLike))) type = 'string'\n else if (members.length === 1 && members[0]?.flags === ts.TypeFlags.Number) type = 'number'\n else if (members.length && members.every((type) => Boolean(type.flags & ts.TypeFlags.BooleanLike))) type = 'boolean'\n else if (presentation.input === 'object' || presentation.input === 'list') {\n type = presentation.input === 'list' ? 'array' : 'object'\n const item = type === 'array' ? checker.getIndexTypeOfType(valueType, ts.IndexKind.Number) : valueType\n\n if (!item || !(item.flags & ts.TypeFlags.Object) || item.getCallSignatures().length)\n throw new Error(`${filename}: ${name} needs an object${type === 'array' ? ' list' : ''} type.`)\n\n if (type === 'array') {\n const id = item.getProperty('id')\n const declaration = id?.valueDeclaration ?? id?.declarations?.[0]\n\n if (\n !id ||\n !declaration ||\n id.flags & ts.SymbolFlags.Optional ||\n checker.getTypeOfSymbolAtLocation(id, declaration).flags !== ts.TypeFlags.String\n )\n throw new Error(`${filename}: ${name} list items need a required string id for stable editing.`)\n }\n\n fields = Object.entries(presentation.fields ?? {}).map(([key, field]) => {\n if (type === 'array' && key === 'id') throw new Error(`${filename}: list item ids are managed by Studio.`)\n const property = item.getProperty(key)\n const declaration = property?.valueDeclaration ?? property?.declarations?.[0]\n\n if (!property || !declaration) throw new Error(`${filename}: unknown field ${name}.${key}.`)\n\n return resolveProp(\n checker.getTypeOfSymbolAtLocation(property, declaration),\n key,\n !(property.flags & ts.SymbolFlags.Optional),\n field,\n checker,\n filename,\n undefined,\n depth + 1,\n )\n })\n\n for (const property of item.getProperties()) {\n if (type === 'array' && property.name === 'id') continue\n\n if (!(property.flags & ts.SymbolFlags.Optional) && !fields.some((field) => field.name === property.name))\n throw new Error(`${filename}: required field ${name}.${property.name} needs an authoring declaration.`)\n }\n } else throw new Error(`${filename}: unsupported editable prop ${name}.`)\n\n const inputs = {\n string: ['text', 'textarea', 'select', 'image', 'link', 'document', 'media'],\n number: ['number'],\n boolean: ['toggle'],\n 'string[]': ['multiselect'],\n object: ['object'],\n array: ['list'],\n }\n\n if (\n !inputs[type].includes(presentation.input) ||\n ((presentation.input === 'select' || presentation.input === 'multiselect') &&\n presentation.optionLabels !== undefined &&\n !choices.length)\n )\n throw new Error(`${filename}: ${name} has an incompatible authoring input ${presentation.input}.`)\n\n for (const key of Object.keys(presentation.optionLabels ?? {}))\n if (!choices.includes(key)) throw new Error(`${filename}: ${key} is not a Vue union choice.`)\n\n return Result.getOrThrow(\n Schema.decodeUnknownResult(BlockAuthoring.fields.props.value)({\n name,\n label: presentation.label,\n type,\n input: presentation.input,\n required,\n nullable,\n ...(presentation.help === undefined ? undefined : { description: presentation.help }),\n ...(fields === undefined ? undefined : { fields }),\n ...(defaultSource === undefined\n ? undefined\n : { defaultValue: readAuthoringDefault(defaultSource, `${filename} prop ${name}`) }),\n options: choices.map((value) => ({ value, label: presentation.optionLabels?.[value] ?? value })),\n }),\n )\n}\n\nfunction vueSlots(checker: ComponentMetaChecker, filename: string) {\n const program = checker.getProgram()\n const file = program?.getSourceFile(filename)\n\n if (!program || !file) throw new Error(`${filename}: Vue type information is unavailable.`)\n const typeChecker = program.getTypeChecker()\n const result = new Map<string, { required: boolean; scoped: boolean }>()\n\n function visit(node: ts.Node): void {\n if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'defineSlots') {\n const type = node.typeArguments?.[0]\n\n if (type)\n for (const property of typeChecker.getTypeAtLocation(type).getProperties()) {\n const declaration = property.valueDeclaration ?? property.declarations?.[0]\n\n const signature = declaration\n ? typeChecker\n .getNonNullableType(typeChecker.getTypeOfSymbolAtLocation(property, declaration))\n .getCallSignatures()\n : []\n\n result.set(property.name, {\n required: !(property.flags & ts.SymbolFlags.Optional),\n scoped: signature.length !== 1 || signature.some((signature) => signature.parameters.length > 0),\n })\n }\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(file)\n\n return result\n}\n"],"mappings":";;;;;;AAqBA,MAAM,eAA2C,OAAO,OAAO;CAC7D,QAAQ,OAAO,YACb,OAAO,OACL,OAAO,QACP,OAAO,cAAc,YAAY,CACnC,CACF;CACA,QAAQ,OAAO,YAAY,OAAO,MAAM,OAAO,cAAc,CAAC;CAC9D,QAAQ,OAAO,YAAY,OAAO,MAAM,OAAO,cAAc,CAAC;CAC9D,OAAO,OAAO;CACd,MAAM,OAAO,YAAY,OAAO,MAAM;CACtC,OAAO,OAAO;CACd,cAAc,OAAO,YAAY,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM,CAAC;CAC5E,UAAU,OAAO,YAAY,OAAO,MAAM,OAAO,SAAS;EAAC;EAAQ;EAAU;EAAQ;EAAe;CAAM,CAAC,CAAC,CAAC;AAC/G,CAAC;AAED,MAAM,cAAc,OAAO,OAAO;CAChC,OAAO,OAAO;CACd,aAAa,OAAO,YAAY,OAAO,MAAM;CAC7C,OAAO,OAAO,YAAY,OAAO,MAAM;CACvC,MAAM,OAAO,YAAY,OAAO,MAAM;CACtC,OAAO,OAAO,OAAO,OAAO,QAAQ,YAAY;CAChD,OAAO,OAAO,OAAO,OAAO,QAAQ,YAAY;CAChD,SAAS,OAAO,YACd,OAAO,OAAO;EACZ,OAAO,OAAO,YAAY,OAAO,UAAU;EAC3C,OAAO,OAAO,YACZ,OAAO,OACL,OAAO,QACP,OAAO,MAAM,CAAC,OAAO,OAAO,EAAE,MAAM,OAAO,OAAO,CAAC,GAAG,OAAO,OAAO,EAAE,UAAU,OAAO,OAAO,CAAC,CAAC,CAAC,CACnG,CACF;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
|
|
1
|
+
import { B as SeoConfiguration } from "../models-VmGmG19-.js";
|
|
2
|
+
import { M as StudioBootstrap, t as maxS3SingleCopyBytes, u as makeDefaultSeoOptions } from "../S3MediaObjects-BRuPQbxl.js";
|
|
3
3
|
import { validateFormCapabilities } from "./form-capabilities.js";
|
|
4
4
|
import { compileCmsI18n } from "./i18n.js";
|
|
5
|
-
import { i as PreviewOrigin } from "../models-
|
|
5
|
+
import { i as PreviewOrigin } from "../models-5j67LMqW.js";
|
|
6
6
|
import { compileCmsDocumentModel } from "./document-model.js";
|
|
7
7
|
import { Config, Effect, Predicate, Redacted, Result, Schema } from "effect";
|
|
8
8
|
|
|
@@ -134,9 +134,11 @@ function resolveCmsInstallation(authored, runtimeInput, authoring) {
|
|
|
134
134
|
seo: compiled.seo ?? makeDefaultSeoOptions(runtime.baseUrl),
|
|
135
135
|
version: "1"
|
|
136
136
|
}));
|
|
137
|
+
const catalog = configurationCatalog(compiled.documents, authoring);
|
|
137
138
|
return {
|
|
138
139
|
formHandlers: Object.fromEntries(Object.entries(authored.forms ?? {}).map(([name, form]) => [name, form.onSubmit])),
|
|
139
140
|
authoring,
|
|
141
|
+
configuration: catalog,
|
|
140
142
|
baseUrl: runtime.baseUrl,
|
|
141
143
|
bootstrap,
|
|
142
144
|
cleanup: {
|
|
@@ -165,6 +167,28 @@ function resolveCmsInstallation(authored, runtimeInput, authoring) {
|
|
|
165
167
|
secret: runtime.secret
|
|
166
168
|
};
|
|
167
169
|
}
|
|
170
|
+
function configurationCatalog(documents, authoring) {
|
|
171
|
+
const value = {
|
|
172
|
+
version: 1,
|
|
173
|
+
documents,
|
|
174
|
+
components: authoring.components
|
|
175
|
+
};
|
|
176
|
+
const revision = `${authoring.revision}:${fingerprint(JSON.stringify(documents))}`;
|
|
177
|
+
return {
|
|
178
|
+
...value,
|
|
179
|
+
revision
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function fingerprint(value) {
|
|
183
|
+
let first = 2166136261;
|
|
184
|
+
let second = 2654435769;
|
|
185
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
186
|
+
const code = value.charCodeAt(index);
|
|
187
|
+
first = Math.imul(first ^ code, 16777619);
|
|
188
|
+
second = Math.imul(second ^ code, 2246822507);
|
|
189
|
+
}
|
|
190
|
+
return `${(first >>> 0).toString(16).padStart(8, "0")}${(second >>> 0).toString(16).padStart(8, "0")}`;
|
|
191
|
+
}
|
|
168
192
|
function decodeRuntimeMedia(input) {
|
|
169
193
|
const raw = Predicate.isObject(input) ? input : {};
|
|
170
194
|
requireRuntimeValue(raw.bucket, "cms.media.bucket", "NUXT_CMS_MEDIA_BUCKET");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","names":["PreviewOriginSchema"],"sources":["../../../../src/internal/configuration.ts"],"sourcesContent":["import { compileCmsI18n, type CompiledCmsI18n } from './i18n'\nimport type { ExecutableDocumentModel } from '@internal/document/DocumentEngine'\nimport type { AuthoringCatalog, DocumentConfiguration } from '@internal/protocol/Configuration'\nimport type { CmsConfiguration, CmsRuntimeConfiguration } from '../Configuration'\nimport type { NuxtCmsInstallationOptions } from '../runtime/installation'\nimport { PreviewOrigin as PreviewOriginSchema } from '@internal/protocol/Preview'\nimport { StudioBootstrap } from '@internal/protocol/StudioHttp'\nimport { SeoConfiguration } from '@internal/protocol/Seo'\nimport { makeDefaultSeoOptions } from '@internal/server/Seo'\nimport { maxS3SingleCopyBytes } from '@internal/s3/S3MediaObjects'\nimport { Config, Effect, Predicate, Redacted, Result, Schema } from 'effect'\nimport { compileCmsDocumentModel } from './document-model'\nimport { validateFormCapabilities } from './form-capabilities'\n\nconst DEFAULT_CLEANUP_INTERVAL_MILLIS = 24 * 60 * 60_000\n\nconst DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS = 60_000\n\nconst DEFAULT_MEDIA_MAX_UPLOAD_BYTES = 10_000_000\n\nconst AuthoredInstallationConfiguration = Schema.Struct({\n cleanup: Schema.optionalKey(\n Schema.Union([\n Schema.Literals([false]),\n Schema.Struct({\n initialDelayMillis: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n intervalMillis: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),\n }),\n ]),\n ),\n database: Schema.Struct({\n schema: Schema.NonEmptyString.check(\n Schema.makeFilter((value) => /^[a-z_][a-z0-9_]{0,62}$/u.test(value), {\n expected: 'a lowercase PostgreSQL identifier',\n }),\n ),\n }),\n media: Schema.optionalKey(\n Schema.Union([\n Schema.Literals([false]),\n Schema.Struct({\n maxUploadBytes: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: maxS3SingleCopyBytes })),\n ),\n prefix: Schema.NonEmptyString.check(\n Schema.makeFilter((value) => !value.startsWith('/') && value.endsWith('/') && !value.includes('..'), {\n expected: 'a relative object prefix ending in /',\n }),\n ),\n }),\n ]),\n ),\n})\n\nconst RuntimeConfiguration = Schema.Struct({\n baseUrl: PreviewOriginSchema,\n databaseUrl: Schema.NonEmptyString,\n initializationToken: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n secret: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n})\n\nconst RuntimeMediaConfiguration = Schema.Struct({\n accessKeyId: Schema.optionalKey(Schema.NonEmptyString),\n bucket: Schema.NonEmptyString,\n endpoint: Schema.optionalKey(Schema.NonEmptyString),\n forcePathStyle: Schema.optionalKey(Schema.Boolean),\n provisionBucket: Schema.optionalKey(Schema.Boolean),\n publicBaseUrl: Schema.NonEmptyString,\n region: Schema.NonEmptyString,\n secretAccessKey: Schema.optionalKey(Schema.NonEmptyString),\n sessionToken: Schema.optionalKey(Schema.NonEmptyString),\n})\n\nclass CmsRuntimeConfigurationMissing extends Schema.TaggedError<CmsRuntimeConfigurationMissing>()(\n 'CmsRuntimeConfigurationMissing',\n {\n environmentVariable: Schema.String,\n message: Schema.String,\n path: Schema.String,\n },\n) {}\n\ntype CmsAuthoredInstallationConfiguration = Schema.Schema.Type<typeof AuthoredInstallationConfiguration>\n\nexport interface CompiledCmsConfiguration {\n readonly i18n: CompiledCmsI18n\n readonly documents: DocumentConfiguration\n readonly documentModel: ExecutableDocumentModel\n readonly installation: CmsAuthoredInstallationConfiguration\n readonly seo?: Schema.Schema.Type<typeof SeoConfiguration>\n}\n\nexport function compileCmsConfiguration(configuration: CmsConfiguration): CompiledCmsConfiguration {\n const installation = decodeOrThrow(\n AuthoredInstallationConfiguration,\n configuration.installation,\n 'authored installation',\n )\n\n for (const [name, form] of Object.entries(configuration.forms ?? {})) {\n if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(name))\n throw new Error(`Form ${name} needs a kebab-case Vue component name.`)\n validateFormCapabilities(form.definition)\n\n if (!Predicate.isFunction(form.onSubmit)) throw new Error(`Form ${name} needs a server submission handler.`)\n }\n\n const i18n = compileCmsI18n(configuration.i18n)\n const documents = compileCmsDocumentModel(configuration.documents, configuration.i18n)\n const seo = configuration.seo === undefined ? undefined : decodeOrThrow(SeoConfiguration, configuration.seo, 'SEO')\n\n return {\n i18n,\n documentModel: documents.executable,\n documents: documents.authoring,\n installation,\n ...(seo === undefined ? undefined : { seo }),\n }\n}\n\n/** Adds the keys Nitro needs in order to apply NUXT_CMS_* runtime environment overrides. */\nexport function cmsRuntimeConfigurationDefaults(\n authored: CmsConfiguration,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Nuxt runtime config is an external input parsed field by field here.\n input?: unknown,\n): CmsRuntimeConfiguration {\n const configured = Predicate.isObject(input) ? input : {}\n const mediaEnabled = authored.installation.media !== false && authored.installation.media !== undefined\n const configuredMedia = Predicate.isObject(configured.media) ? configured.media : undefined\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Each external field is narrowed immediately.\n const string = (value: unknown) => (Schema.is(Schema.String)(value) ? value : '')\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Each external field is narrowed immediately.\n const boolean = (value: unknown) => (Schema.is(Schema.Boolean)(value) ? value : false)\n\n return {\n baseUrl: string(configured.baseUrl),\n databaseUrl: string(configured.databaseUrl),\n initializationToken: string(configured.initializationToken),\n media: mediaEnabled\n ? configured.media === false\n ? false\n : {\n accessKeyId: string(configuredMedia?.accessKeyId),\n bucket: string(configuredMedia?.bucket),\n endpoint: string(configuredMedia?.endpoint),\n forcePathStyle: boolean(configuredMedia?.forcePathStyle),\n provisionBucket: boolean(configuredMedia?.provisionBucket),\n publicBaseUrl: string(configuredMedia?.publicBaseUrl),\n region: string(configuredMedia?.region),\n secretAccessKey: string(configuredMedia?.secretAccessKey),\n sessionToken: string(configuredMedia?.sessionToken),\n }\n : false,\n secret: string(configured.secret),\n }\n}\n\n/** Reads the same NUXT_CMS_* values that Nitro applies to runtimeConfig at process startup. */\nexport const cmsRuntimeConfigurationFromEnvironment = Effect.fn('CmsConfiguration.runtimeFromEnvironment')(function* (\n defaults: CmsRuntimeConfiguration,\n) {\n const string = (name: string, fallback: string) => Config.String(name).pipe(Config.withDefault(fallback))\n\n const secret = (name: string, fallback: string) =>\n Config.Redacted(name).pipe(Config.withDefault(Redacted.make(fallback)), Effect.map(Redacted.value))\n\n return {\n baseUrl: yield* string('NUXT_CMS_BASE_URL', defaults.baseUrl),\n databaseUrl: yield* string('NUXT_CMS_DATABASE_URL', defaults.databaseUrl),\n initializationToken: yield* secret('NUXT_CMS_INITIALIZATION_TOKEN', defaults.initializationToken),\n media:\n defaults.media === false || defaults.media === undefined\n ? false\n : {\n accessKeyId: yield* string('NUXT_CMS_MEDIA_ACCESS_KEY_ID', defaults.media.accessKeyId ?? ''),\n bucket: yield* string('NUXT_CMS_MEDIA_BUCKET', defaults.media.bucket),\n endpoint: yield* string('NUXT_CMS_MEDIA_ENDPOINT', defaults.media.endpoint ?? ''),\n forcePathStyle: yield* Config.Boolean('NUXT_CMS_MEDIA_FORCE_PATH_STYLE').pipe(\n Config.withDefault(defaults.media.forcePathStyle ?? false),\n ),\n provisionBucket: yield* Config.Boolean('NUXT_CMS_MEDIA_PROVISION_BUCKET').pipe(\n Config.withDefault(defaults.media.provisionBucket ?? false),\n ),\n publicBaseUrl: yield* string('NUXT_CMS_MEDIA_PUBLIC_BASE_URL', defaults.media.publicBaseUrl),\n region: yield* string('NUXT_CMS_MEDIA_REGION', defaults.media.region),\n secretAccessKey: yield* secret('NUXT_CMS_MEDIA_SECRET_ACCESS_KEY', defaults.media.secretAccessKey ?? ''),\n sessionToken: yield* secret('NUXT_CMS_MEDIA_SESSION_TOKEN', defaults.media.sessionToken ?? ''),\n },\n secret: yield* secret('NUXT_CMS_SECRET', defaults.secret),\n } satisfies CmsRuntimeConfiguration\n})\n\nexport function resolveCmsInstallation(\n authored: CmsConfiguration,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Shared Nitro/CLI boundary validates this value before resource acquisition.\n runtimeInput: unknown,\n authoring: AuthoringCatalog,\n): NuxtCmsInstallationOptions {\n const compiled = compileCmsConfiguration(authored)\n const runtimeObject = Predicate.isObject(runtimeInput) ? runtimeInput : {}\n requireRuntimeValue(runtimeObject.baseUrl, 'cms.baseUrl', 'NUXT_CMS_BASE_URL')\n requireRuntimeValue(runtimeObject.databaseUrl, 'cms.databaseUrl', 'NUXT_CMS_DATABASE_URL')\n requireRuntimeValue(runtimeObject.initializationToken, 'cms.initializationToken', 'NUXT_CMS_INITIALIZATION_TOKEN')\n requireRuntimeValue(runtimeObject.secret, 'cms.secret', 'NUXT_CMS_SECRET')\n const runtimeResult = Schema.decodeUnknownResult(RuntimeConfiguration)(runtimeInput)\n\n if (Result.isFailure(runtimeResult))\n throw new Error(`Invalid CMS runtime installation configuration: ${String(runtimeResult.failure)}`)\n const runtime = runtimeResult.success\n const cleanup = compiled.installation.cleanup === false ? undefined : compiled.installation.cleanup\n const authoredMedia = compiled.installation.media === false ? undefined : compiled.installation.media\n const runtimeMedia = authoredMedia ? decodeRuntimeMedia(runtimeObject.media) : undefined\n\n const bootstrap = Result.getOrThrow(\n Schema.decodeResult(StudioBootstrap)({\n basePath: '/',\n documents: compiled.documents,\n media: {\n enabled: runtimeMedia !== undefined,\n maxUploadBytes: authoredMedia?.maxUploadBytes ?? DEFAULT_MEDIA_MAX_UPLOAD_BYTES,\n },\n seo: compiled.seo ?? makeDefaultSeoOptions(runtime.baseUrl),\n version: '1',\n }),\n )\n\n return {\n formHandlers: Object.fromEntries(Object.entries(authored.forms ?? {}).map(([name, form]) => [name, form.onSubmit])),\n authoring,\n baseUrl: runtime.baseUrl,\n bootstrap,\n cleanup: {\n enabled: compiled.installation.cleanup !== false,\n initialDelayMillis: cleanup?.initialDelayMillis ?? DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS,\n intervalMillis: cleanup?.intervalMillis ?? DEFAULT_CLEANUP_INTERVAL_MILLIS,\n },\n database: { schema: compiled.installation.database.schema, url: runtime.databaseUrl },\n documentModel: compiled.documentModel,\n initializationToken: runtime.initializationToken,\n ...(runtimeMedia && authoredMedia\n ? {\n media: {\n ...runtimeMedia,\n credentials:\n runtimeMedia.accessKeyId && runtimeMedia.secretAccessKey\n ? {\n accessKeyId: runtimeMedia.accessKeyId,\n secretAccessKey: runtimeMedia.secretAccessKey,\n ...(runtimeMedia.sessionToken ? { sessionToken: runtimeMedia.sessionToken } : undefined),\n }\n : undefined,\n forcePathStyle: runtimeMedia.forcePathStyle ?? false,\n prefix: authoredMedia.prefix,\n provisionBucket: runtimeMedia.provisionBucket ?? false,\n publicBaseUrl: `${runtimeMedia.publicBaseUrl.replace(/\\/+$/gu, '')}/${authoredMedia.prefix.replace(/\\/+$/gu, '')}`,\n },\n }\n : undefined),\n secret: runtime.secret,\n }\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Runtime media is validated before use.\nfunction decodeRuntimeMedia(input: unknown) {\n const raw = Predicate.isObject(input) ? input : {}\n requireRuntimeValue(raw.bucket, 'cms.media.bucket', 'NUXT_CMS_MEDIA_BUCKET')\n requireRuntimeValue(raw.publicBaseUrl, 'cms.media.publicBaseUrl', 'NUXT_CMS_MEDIA_PUBLIC_BASE_URL')\n requireRuntimeValue(raw.region, 'cms.media.region', 'NUXT_CMS_MEDIA_REGION')\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Each external field is narrowed immediately.\n const optionalString = (value: unknown) => (Schema.is(Schema.NonEmptyString)(value) ? value : undefined)\n const accessKeyId = optionalString(raw.accessKeyId)\n const endpoint = optionalString(raw.endpoint)\n const secretAccessKey = optionalString(raw.secretAccessKey)\n const sessionToken = optionalString(raw.sessionToken)\n\n const normalized = Object.assign(\n { bucket: raw.bucket, publicBaseUrl: raw.publicBaseUrl, region: raw.region },\n accessKeyId ? { accessKeyId } : undefined,\n endpoint ? { endpoint } : undefined,\n Schema.is(Schema.Boolean)(raw.forcePathStyle) ? { forcePathStyle: raw.forcePathStyle } : undefined,\n Schema.is(Schema.Boolean)(raw.provisionBucket) ? { provisionBucket: raw.provisionBucket } : undefined,\n secretAccessKey ? { secretAccessKey } : undefined,\n sessionToken ? { sessionToken } : undefined,\n )\n\n const result = Schema.decodeUnknownResult(RuntimeMediaConfiguration)(normalized)\n\n if (Result.isFailure(result)) throw new Error(`Invalid CMS runtime media configuration: ${String(result.failure)}`)\n const decoded = result.success\n\n if ((decoded.accessKeyId === undefined) !== (decoded.secretAccessKey === undefined))\n throw new Error(\n 'Invalid CMS runtime media configuration: accessKeyId and secretAccessKey must be provided together.',\n )\n\n return decoded\n}\n\nfunction requireRuntimeValue(\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- This external field is narrowed immediately to a non-empty string.\n value: unknown,\n path: string,\n environmentVariable: string,\n): void {\n if (!Schema.is(Schema.NonEmptyString)(value))\n throw new CmsRuntimeConfigurationMissing({\n environmentVariable,\n message: `Missing ${environmentVariable} for ${path}.`,\n path,\n })\n}\n\nfunction decodeOrThrow<Decoded, Encoded>(\n schema: Schema.Codec<Decoded, Encoded>,\n input: Encoded,\n label: string,\n): Decoded {\n const decoded = Schema.decodeUnknownResult(schema)(input)\n\n if (Result.isFailure(decoded))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AAM,CAAC,CAAC,KAAK;CAExD,IAAI,OAAO,UAAU,OAAO,GAAG,MAAM,IAAI,MAAM,eAAe,MAAM,kBAAkB,OAAO,QAAQ,OAAO,GAAG;CAE/G,OAAO,QAAQ;AACjB"}
|
|
1
|
+
{"version":3,"file":"configuration.js","names":["PreviewOriginSchema"],"sources":["../../../../src/internal/configuration.ts"],"sourcesContent":["import { compileCmsI18n, type CompiledCmsI18n } from './i18n'\nimport type { ExecutableDocumentModel } from '@internal/document/DocumentEngine'\nimport type { AuthoringCatalog, DocumentConfiguration } from '@internal/protocol/Configuration'\nimport type { ConfigurationCatalog } from '@internal/protocol/ConfigurationChanges'\nimport type { CmsConfiguration, CmsRuntimeConfiguration } from '../Configuration'\nimport type { NuxtCmsInstallationOptions } from '../runtime/installation'\nimport { PreviewOrigin as PreviewOriginSchema } from '@internal/protocol/Preview'\nimport { StudioBootstrap } from '@internal/protocol/StudioHttp'\nimport { SeoConfiguration } from '@internal/protocol/Seo'\nimport { makeDefaultSeoOptions } from '@internal/server/Seo'\nimport { maxS3SingleCopyBytes } from '@internal/s3/S3MediaObjects'\nimport { Config, Effect, Predicate, Redacted, Result, Schema } from 'effect'\nimport { compileCmsDocumentModel } from './document-model'\nimport { validateFormCapabilities } from './form-capabilities'\n\nconst DEFAULT_CLEANUP_INTERVAL_MILLIS = 24 * 60 * 60_000\n\nconst DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS = 60_000\n\nconst DEFAULT_MEDIA_MAX_UPLOAD_BYTES = 10_000_000\n\nconst AuthoredInstallationConfiguration = Schema.Struct({\n cleanup: Schema.optionalKey(\n Schema.Union([\n Schema.Literals([false]),\n Schema.Struct({\n initialDelayMillis: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n intervalMillis: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),\n }),\n ]),\n ),\n database: Schema.Struct({\n schema: Schema.NonEmptyString.check(\n Schema.makeFilter((value) => /^[a-z_][a-z0-9_]{0,62}$/u.test(value), {\n expected: 'a lowercase PostgreSQL identifier',\n }),\n ),\n }),\n media: Schema.optionalKey(\n Schema.Union([\n Schema.Literals([false]),\n Schema.Struct({\n maxUploadBytes: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: maxS3SingleCopyBytes })),\n ),\n prefix: Schema.NonEmptyString.check(\n Schema.makeFilter((value) => !value.startsWith('/') && value.endsWith('/') && !value.includes('..'), {\n expected: 'a relative object prefix ending in /',\n }),\n ),\n }),\n ]),\n ),\n})\n\nconst RuntimeConfiguration = Schema.Struct({\n baseUrl: PreviewOriginSchema,\n databaseUrl: Schema.NonEmptyString,\n initializationToken: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n secret: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n})\n\nconst RuntimeMediaConfiguration = Schema.Struct({\n accessKeyId: Schema.optionalKey(Schema.NonEmptyString),\n bucket: Schema.NonEmptyString,\n endpoint: Schema.optionalKey(Schema.NonEmptyString),\n forcePathStyle: Schema.optionalKey(Schema.Boolean),\n provisionBucket: Schema.optionalKey(Schema.Boolean),\n publicBaseUrl: Schema.NonEmptyString,\n region: Schema.NonEmptyString,\n secretAccessKey: Schema.optionalKey(Schema.NonEmptyString),\n sessionToken: Schema.optionalKey(Schema.NonEmptyString),\n})\n\nclass CmsRuntimeConfigurationMissing extends Schema.TaggedError<CmsRuntimeConfigurationMissing>()(\n 'CmsRuntimeConfigurationMissing',\n {\n environmentVariable: Schema.String,\n message: Schema.String,\n path: Schema.String,\n },\n) {}\n\ntype CmsAuthoredInstallationConfiguration = Schema.Schema.Type<typeof AuthoredInstallationConfiguration>\n\nexport interface CompiledCmsConfiguration {\n readonly i18n: CompiledCmsI18n\n readonly documents: DocumentConfiguration\n readonly documentModel: ExecutableDocumentModel\n readonly installation: CmsAuthoredInstallationConfiguration\n readonly seo?: Schema.Schema.Type<typeof SeoConfiguration>\n}\n\nexport function compileCmsConfiguration(configuration: CmsConfiguration): CompiledCmsConfiguration {\n const installation = decodeOrThrow(\n AuthoredInstallationConfiguration,\n configuration.installation,\n 'authored installation',\n )\n\n for (const [name, form] of Object.entries(configuration.forms ?? {})) {\n if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(name))\n throw new Error(`Form ${name} needs a kebab-case Vue component name.`)\n validateFormCapabilities(form.definition)\n\n if (!Predicate.isFunction(form.onSubmit)) throw new Error(`Form ${name} needs a server submission handler.`)\n }\n\n const i18n = compileCmsI18n(configuration.i18n)\n const documents = compileCmsDocumentModel(configuration.documents, configuration.i18n)\n const seo = configuration.seo === undefined ? undefined : decodeOrThrow(SeoConfiguration, configuration.seo, 'SEO')\n\n return {\n i18n,\n documentModel: documents.executable,\n documents: documents.authoring,\n installation,\n ...(seo === undefined ? undefined : { seo }),\n }\n}\n\n/** Adds the keys Nitro needs in order to apply NUXT_CMS_* runtime environment overrides. */\nexport function cmsRuntimeConfigurationDefaults(\n authored: CmsConfiguration,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Nuxt runtime config is an external input parsed field by field here.\n input?: unknown,\n): CmsRuntimeConfiguration {\n const configured = Predicate.isObject(input) ? input : {}\n const mediaEnabled = authored.installation.media !== false && authored.installation.media !== undefined\n const configuredMedia = Predicate.isObject(configured.media) ? configured.media : undefined\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Each external field is narrowed immediately.\n const string = (value: unknown) => (Schema.is(Schema.String)(value) ? value : '')\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Each external field is narrowed immediately.\n const boolean = (value: unknown) => (Schema.is(Schema.Boolean)(value) ? value : false)\n\n return {\n baseUrl: string(configured.baseUrl),\n databaseUrl: string(configured.databaseUrl),\n initializationToken: string(configured.initializationToken),\n media: mediaEnabled\n ? configured.media === false\n ? false\n : {\n accessKeyId: string(configuredMedia?.accessKeyId),\n bucket: string(configuredMedia?.bucket),\n endpoint: string(configuredMedia?.endpoint),\n forcePathStyle: boolean(configuredMedia?.forcePathStyle),\n provisionBucket: boolean(configuredMedia?.provisionBucket),\n publicBaseUrl: string(configuredMedia?.publicBaseUrl),\n region: string(configuredMedia?.region),\n secretAccessKey: string(configuredMedia?.secretAccessKey),\n sessionToken: string(configuredMedia?.sessionToken),\n }\n : false,\n secret: string(configured.secret),\n }\n}\n\n/** Reads the same NUXT_CMS_* values that Nitro applies to runtimeConfig at process startup. */\nexport const cmsRuntimeConfigurationFromEnvironment = Effect.fn('CmsConfiguration.runtimeFromEnvironment')(function* (\n defaults: CmsRuntimeConfiguration,\n) {\n const string = (name: string, fallback: string) => Config.String(name).pipe(Config.withDefault(fallback))\n\n const secret = (name: string, fallback: string) =>\n Config.Redacted(name).pipe(Config.withDefault(Redacted.make(fallback)), Effect.map(Redacted.value))\n\n return {\n baseUrl: yield* string('NUXT_CMS_BASE_URL', defaults.baseUrl),\n databaseUrl: yield* string('NUXT_CMS_DATABASE_URL', defaults.databaseUrl),\n initializationToken: yield* secret('NUXT_CMS_INITIALIZATION_TOKEN', defaults.initializationToken),\n media:\n defaults.media === false || defaults.media === undefined\n ? false\n : {\n accessKeyId: yield* string('NUXT_CMS_MEDIA_ACCESS_KEY_ID', defaults.media.accessKeyId ?? ''),\n bucket: yield* string('NUXT_CMS_MEDIA_BUCKET', defaults.media.bucket),\n endpoint: yield* string('NUXT_CMS_MEDIA_ENDPOINT', defaults.media.endpoint ?? ''),\n forcePathStyle: yield* Config.Boolean('NUXT_CMS_MEDIA_FORCE_PATH_STYLE').pipe(\n Config.withDefault(defaults.media.forcePathStyle ?? false),\n ),\n provisionBucket: yield* Config.Boolean('NUXT_CMS_MEDIA_PROVISION_BUCKET').pipe(\n Config.withDefault(defaults.media.provisionBucket ?? false),\n ),\n publicBaseUrl: yield* string('NUXT_CMS_MEDIA_PUBLIC_BASE_URL', defaults.media.publicBaseUrl),\n region: yield* string('NUXT_CMS_MEDIA_REGION', defaults.media.region),\n secretAccessKey: yield* secret('NUXT_CMS_MEDIA_SECRET_ACCESS_KEY', defaults.media.secretAccessKey ?? ''),\n sessionToken: yield* secret('NUXT_CMS_MEDIA_SESSION_TOKEN', defaults.media.sessionToken ?? ''),\n },\n secret: yield* secret('NUXT_CMS_SECRET', defaults.secret),\n } satisfies CmsRuntimeConfiguration\n})\n\nexport function resolveCmsInstallation(\n authored: CmsConfiguration,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Shared Nitro/CLI boundary validates this value before resource acquisition.\n runtimeInput: unknown,\n authoring: AuthoringCatalog,\n): NuxtCmsInstallationOptions {\n const compiled = compileCmsConfiguration(authored)\n const runtimeObject = Predicate.isObject(runtimeInput) ? runtimeInput : {}\n requireRuntimeValue(runtimeObject.baseUrl, 'cms.baseUrl', 'NUXT_CMS_BASE_URL')\n requireRuntimeValue(runtimeObject.databaseUrl, 'cms.databaseUrl', 'NUXT_CMS_DATABASE_URL')\n requireRuntimeValue(runtimeObject.initializationToken, 'cms.initializationToken', 'NUXT_CMS_INITIALIZATION_TOKEN')\n requireRuntimeValue(runtimeObject.secret, 'cms.secret', 'NUXT_CMS_SECRET')\n const runtimeResult = Schema.decodeUnknownResult(RuntimeConfiguration)(runtimeInput)\n\n if (Result.isFailure(runtimeResult))\n throw new Error(`Invalid CMS runtime installation configuration: ${String(runtimeResult.failure)}`)\n const runtime = runtimeResult.success\n const cleanup = compiled.installation.cleanup === false ? undefined : compiled.installation.cleanup\n const authoredMedia = compiled.installation.media === false ? undefined : compiled.installation.media\n const runtimeMedia = authoredMedia ? decodeRuntimeMedia(runtimeObject.media) : undefined\n\n const bootstrap = Result.getOrThrow(\n Schema.decodeResult(StudioBootstrap)({\n basePath: '/',\n documents: compiled.documents,\n media: {\n enabled: runtimeMedia !== undefined,\n maxUploadBytes: authoredMedia?.maxUploadBytes ?? DEFAULT_MEDIA_MAX_UPLOAD_BYTES,\n },\n seo: compiled.seo ?? makeDefaultSeoOptions(runtime.baseUrl),\n version: '1',\n }),\n )\n\n const catalog = configurationCatalog(compiled.documents, authoring)\n\n return {\n formHandlers: Object.fromEntries(Object.entries(authored.forms ?? {}).map(([name, form]) => [name, form.onSubmit])),\n authoring,\n configuration: catalog,\n baseUrl: runtime.baseUrl,\n bootstrap,\n cleanup: {\n enabled: compiled.installation.cleanup !== false,\n initialDelayMillis: cleanup?.initialDelayMillis ?? DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS,\n intervalMillis: cleanup?.intervalMillis ?? DEFAULT_CLEANUP_INTERVAL_MILLIS,\n },\n database: { schema: compiled.installation.database.schema, url: runtime.databaseUrl },\n documentModel: compiled.documentModel,\n initializationToken: runtime.initializationToken,\n ...(runtimeMedia && authoredMedia\n ? {\n media: {\n ...runtimeMedia,\n credentials:\n runtimeMedia.accessKeyId && runtimeMedia.secretAccessKey\n ? {\n accessKeyId: runtimeMedia.accessKeyId,\n secretAccessKey: runtimeMedia.secretAccessKey,\n ...(runtimeMedia.sessionToken ? { sessionToken: runtimeMedia.sessionToken } : undefined),\n }\n : undefined,\n forcePathStyle: runtimeMedia.forcePathStyle ?? false,\n prefix: authoredMedia.prefix,\n provisionBucket: runtimeMedia.provisionBucket ?? false,\n publicBaseUrl: `${runtimeMedia.publicBaseUrl.replace(/\\/+$/gu, '')}/${authoredMedia.prefix.replace(/\\/+$/gu, '')}`,\n },\n }\n : undefined),\n secret: runtime.secret,\n }\n}\n\nfunction configurationCatalog(documents: DocumentConfiguration, authoring: AuthoringCatalog): ConfigurationCatalog {\n const value = { version: 1 as const, documents, components: authoring.components }\n const revision = `${authoring.revision}:${fingerprint(JSON.stringify(documents))}`\n\n return { ...value, revision }\n}\n\nfunction fingerprint(value: string): string {\n let first = 0x811c9dc5\n let second = 0x9e3779b9\n\n for (let index = 0; index < value.length; index += 1) {\n const code = value.charCodeAt(index)\n first = Math.imul(first ^ code, 0x01000193)\n second = Math.imul(second ^ code, 0x85ebca6b)\n }\n\n return `${(first >>> 0).toString(16).padStart(8, '0')}${(second >>> 0).toString(16).padStart(8, '0')}`\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Runtime media is validated before use.\nfunction decodeRuntimeMedia(input: unknown) {\n const raw = Predicate.isObject(input) ? input : {}\n requireRuntimeValue(raw.bucket, 'cms.media.bucket', 'NUXT_CMS_MEDIA_BUCKET')\n requireRuntimeValue(raw.publicBaseUrl, 'cms.media.publicBaseUrl', 'NUXT_CMS_MEDIA_PUBLIC_BASE_URL')\n requireRuntimeValue(raw.region, 'cms.media.region', 'NUXT_CMS_MEDIA_REGION')\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Each external field is narrowed immediately.\n const optionalString = (value: unknown) => (Schema.is(Schema.NonEmptyString)(value) ? value : undefined)\n const accessKeyId = optionalString(raw.accessKeyId)\n const endpoint = optionalString(raw.endpoint)\n const secretAccessKey = optionalString(raw.secretAccessKey)\n const sessionToken = optionalString(raw.sessionToken)\n\n const normalized = Object.assign(\n { bucket: raw.bucket, publicBaseUrl: raw.publicBaseUrl, region: raw.region },\n accessKeyId ? { accessKeyId } : undefined,\n endpoint ? { endpoint } : undefined,\n Schema.is(Schema.Boolean)(raw.forcePathStyle) ? { forcePathStyle: raw.forcePathStyle } : undefined,\n Schema.is(Schema.Boolean)(raw.provisionBucket) ? { provisionBucket: raw.provisionBucket } : undefined,\n secretAccessKey ? { secretAccessKey } : undefined,\n sessionToken ? { sessionToken } : undefined,\n )\n\n const result = Schema.decodeUnknownResult(RuntimeMediaConfiguration)(normalized)\n\n if (Result.isFailure(result)) throw new Error(`Invalid CMS runtime media configuration: ${String(result.failure)}`)\n const decoded = result.success\n\n if ((decoded.accessKeyId === undefined) !== (decoded.secretAccessKey === undefined))\n throw new Error(\n 'Invalid CMS runtime media configuration: accessKeyId and secretAccessKey must be provided together.',\n )\n\n return decoded\n}\n\nfunction requireRuntimeValue(\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- This external field is narrowed immediately to a non-empty string.\n value: unknown,\n path: string,\n environmentVariable: string,\n): void {\n if (!Schema.is(Schema.NonEmptyString)(value))\n throw new CmsRuntimeConfigurationMissing({\n environmentVariable,\n message: `Missing ${environmentVariable} for ${path}.`,\n path,\n })\n}\n\nfunction decodeOrThrow<Decoded, Encoded>(\n schema: Schema.Codec<Decoded, Encoded>,\n input: Encoded,\n label: string,\n): Decoded {\n const decoded = Schema.decodeUnknownResult(schema)(input)\n\n if (Result.isFailure(decoded)) throw new Error(`Invalid CMS ${label} configuration: ${String(decoded.failure)}`)\n\n return decoded.success\n}\n"],"mappings":";;;;;;;;;AAeA,MAAM,kCAAkC;AAExC,MAAM,uCAAuC;AAE7C,MAAM,iCAAiC;AAEvC,MAAM,oCAAoC,OAAO,OAAO;CACtD,SAAS,OAAO,YACd,OAAO,MAAM,CACX,OAAO,SAAS,CAAC,KAAK,CAAC,GACvB,OAAO,OAAO;EACZ,oBAAoB,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC,CAAC;EACzF,gBAAgB,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC,CAAC;CAC9E,CAAC,CACH,CAAC,CACH;CACA,UAAU,OAAO,OAAO,EACtB,QAAQ,OAAO,eAAe,MAC5B,OAAO,YAAY,UAAU,2BAA2B,KAAK,KAAK,GAAG,EACnE,UAAU,oCACZ,CAAC,CACH,EACF,CAAC;CACD,OAAO,OAAO,YACZ,OAAO,MAAM,CACX,OAAO,SAAS,CAAC,KAAK,CAAC,GACvB,OAAO,OAAO;EACZ,gBAAgB,OAAO,YACrB,OAAO,IAAI,MAAM,OAAO,UAAU;GAAE,SAAS;GAAG,SAAS;EAAqB,CAAC,CAAC,CAClF;EACA,QAAQ,OAAO,eAAe,MAC5B,OAAO,YAAY,UAAU,CAAC,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,SAAS,IAAI,GAAG,EACnG,UAAU,uCACZ,CAAC,CACH;CACF,CAAC,CACH,CAAC,CACH;AACF,CAAC;AAED,MAAM,uBAAuB,OAAO,OAAO;CACzC,SAASA;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;EAAQ,eAAe,IAAI;EAAe,QAAQ,IAAI;CAAO,GAC3E,cAAc,EAAE,YAAY,IAAI,QAChC,WAAW,EAAE,SAAS,IAAI,QAC1B,OAAO,GAAG,OAAO,OAAO,CAAC,CAAC,IAAI,cAAc,IAAI,EAAE,gBAAgB,IAAI,eAAe,IAAI,QACzF,OAAO,GAAG,OAAO,OAAO,CAAC,CAAC,IAAI,eAAe,IAAI,EAAE,iBAAiB,IAAI,gBAAgB,IAAI,QAC5F,kBAAkB,EAAE,gBAAgB,IAAI,QACxC,eAAe,EAAE,aAAa,IAAI,MACpC;CAEA,MAAM,SAAS,OAAO,oBAAoB,yBAAyB,CAAC,CAAC,UAAU;CAE/E,IAAI,OAAO,UAAU,MAAM,GAAG,MAAM,IAAI,MAAM,4CAA4C,OAAO,OAAO,OAAO,GAAG;CAClH,MAAM,UAAU,OAAO;CAEvB,IAAK,QAAQ,gBAAgB,YAAgB,QAAQ,oBAAoB,SACvE,MAAM,IAAI,MACR,qGACF;CAEF,OAAO;AACT;AAEA,SAAS,oBAEP,OACA,MACA,qBACM;CACN,IAAI,CAAC,OAAO,GAAG,OAAO,cAAc,CAAC,CAAC,KAAK,GACzC,MAAM,IAAI,+BAA+B;EACvC;EACA,SAAS,WAAW,oBAAoB,OAAO,KAAK;EACpD;CACF,CAAC;AACL;AAEA,SAAS,cACP,QACA,OACA,OACS;CACT,MAAM,UAAU,OAAO,oBAAoB,MAAM,CAAC,CAAC,KAAK;CAExD,IAAI,OAAO,UAAU,OAAO,GAAG,MAAM,IAAI,MAAM,eAAe,MAAM,kBAAkB,OAAO,QAAQ,OAAO,GAAG;CAE/G,OAAO,QAAQ;AACjB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as resetCmsDevelopment, i as loadCmsProjectEnvironment, n as checkCmsConfiguration, r as doctorCmsDevelopment, t as bootstrapCmsDevelopment } from "../dev-lifecycle-DdBluSiR.js";
|
|
2
2
|
|
|
3
|
-
export { bootstrapCmsDevelopment, doctorCmsDevelopment, loadCmsProjectEnvironment, resetCmsDevelopment };
|
|
3
|
+
export { bootstrapCmsDevelopment, checkCmsConfiguration, doctorCmsDevelopment, loadCmsProjectEnvironment, resetCmsDevelopment };
|