@phtngyn/cms 0.1.0-beta.0 → 0.1.0-beta.1

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.
Files changed (123) hide show
  1. package/README.md +72 -1
  2. package/package.json +5 -5
  3. package/src/Authoring.d.ts +13 -1
  4. package/src/{AuthoringSchema-BQ5kbhVB.js → Configuration-DyKo0sLS.js} +595 -367
  5. package/src/Configuration-DyKo0sLS.js.map +1 -0
  6. package/src/{DocumentEngine-Da0kWotL.js → DocumentEngine-DYObwMDY.js} +44 -66
  7. package/src/DocumentEngine-DYObwMDY.js.map +1 -0
  8. package/src/DocumentModel.d.ts +4 -0
  9. package/src/DocumentModel.js.map +1 -1
  10. package/src/{HttpPaths-86qLGB90.js → HttpPaths-BbS21Jy8.js} +4 -2
  11. package/src/{HttpPaths-86qLGB90.js.map → HttpPaths-BbS21Jy8.js.map} +1 -1
  12. package/src/Module.js +27 -76
  13. package/src/Module.js.map +1 -1
  14. package/src/{StudioHttp-BTLLooh0.js → StudioHttp-jR2-bc01.js} +44 -242
  15. package/src/StudioHttp-jR2-bc01.js.map +1 -0
  16. package/src/{connection-ZGtL54qY.js → connection-CBTY-TzB.js} +3 -3
  17. package/src/{connection-ZGtL54qY.js.map → connection-CBTY-TzB.js.map} +1 -1
  18. package/src/{installation-BNKaVjni.js → installation-DeuBiFRE.js} +488 -236
  19. package/src/installation-DeuBiFRE.js.map +1 -0
  20. package/src/internal/authoring-catalog.js +147 -0
  21. package/src/internal/authoring-catalog.js.map +1 -0
  22. package/src/internal/authoring-compiler.js +2 -1
  23. package/src/internal/authoring-compiler.js.map +1 -1
  24. package/src/internal/authoring-metadata.js +67 -48
  25. package/src/internal/authoring-metadata.js.map +1 -1
  26. package/src/internal/configuration.js +5 -6
  27. package/src/internal/configuration.js.map +1 -1
  28. package/src/internal/document-model.js +3 -2
  29. package/src/internal/document-model.js.map +1 -1
  30. package/src/internal/studio-app.js +66 -0
  31. package/src/internal/studio-app.js.map +1 -0
  32. package/src/location-DtYv2aes.js +36 -0
  33. package/src/location-DtYv2aes.js.map +1 -0
  34. package/src/{metadata-Czvi3E4K.js → metadata-DE1Mc2td.js} +2 -2
  35. package/src/{metadata-Czvi3E4K.js.map → metadata-DE1Mc2td.js.map} +1 -1
  36. package/src/{models-Citx8jBi.js → models-BkMgeaOL.js} +252 -3
  37. package/src/models-BkMgeaOL.js.map +1 -0
  38. package/src/{models-DS5ClMsH.js → models-C3witQBK.js} +8 -31
  39. package/src/models-C3witQBK.js.map +1 -0
  40. package/src/runtime/blocks.js +17 -0
  41. package/src/runtime/blocks.js.map +1 -0
  42. package/src/runtime/collaboration.js +9 -4
  43. package/src/runtime/collaboration.js.map +1 -1
  44. package/src/runtime/delivery/DocumentRenderer.js +6 -3
  45. package/src/runtime/delivery/DocumentRenderer.js.map +1 -1
  46. package/src/runtime/delivery/blocks.js +6 -0
  47. package/src/runtime/delivery/blocks.js.map +1 -0
  48. package/src/runtime/delivery/context.js +12 -0
  49. package/src/runtime/delivery/context.js.map +1 -0
  50. package/src/runtime/delivery/document-page.js +5 -3
  51. package/src/runtime/delivery/document-page.js.map +1 -1
  52. package/src/runtime/delivery/document.js +18 -2
  53. package/src/runtime/delivery/document.js.map +1 -1
  54. package/src/runtime/delivery/error.js +11 -0
  55. package/src/runtime/delivery/error.js.map +1 -0
  56. package/src/runtime/delivery/plugin.js +21 -0
  57. package/src/runtime/delivery/plugin.js.map +1 -0
  58. package/src/runtime/delivery/useDocument.js +6 -3
  59. package/src/runtime/delivery/useDocument.js.map +1 -1
  60. package/src/runtime/delivery/useDocumentQuery.js +6 -3
  61. package/src/runtime/delivery/useDocumentQuery.js.map +1 -1
  62. package/src/runtime/installation.js +1 -1
  63. package/src/runtime/plugin.js +3 -3
  64. package/src/runtime/plugin.js.map +1 -1
  65. package/src/runtime/preview/connection.js +1 -1
  66. package/src/runtime/preview/controller.js +29 -10
  67. package/src/runtime/preview/controller.js.map +1 -1
  68. package/src/runtime/preview/overlay.js +65 -0
  69. package/src/runtime/preview/overlay.js.map +1 -0
  70. package/src/runtime/preview/plugin.client.js +21 -34
  71. package/src/runtime/preview/plugin.client.js.map +1 -1
  72. package/src/runtime/preview/preview.css +72 -4
  73. package/src/runtime/preview/store.js +1 -1
  74. package/src/runtime/studio-app.js +5 -1
  75. package/src/runtime/studio-app.js.map +1 -1
  76. package/src/runtime/studio-entry.js +36 -0
  77. package/src/runtime/studio-entry.js.map +1 -0
  78. package/src/runtime/studio-navigation.js +11 -0
  79. package/src/runtime/studio-navigation.js.map +1 -0
  80. package/src/{store-Nl4uxEXx.js → store-CfFFx9Ua.js} +3 -3
  81. package/src/{store-Nl4uxEXx.js.map → store-CfFFx9Ua.js.map} +1 -1
  82. package/studio/CreateDocumentDialog--L9lTfx6.js +256 -0
  83. package/studio/collaboration-DUuu678R.js +4565 -0
  84. package/studio/documentPlanning-BXX04Woe.js +28989 -0
  85. package/studio/dom-to-image-more.min-D6jGGdrW.js +877 -0
  86. package/studio/editor-PexnXkJY.js +30817 -0
  87. package/studio/host.css +3 -0
  88. package/studio/host.js +44179 -0
  89. package/studio/rolldown-runtime-B0aSnxlc.js +20 -0
  90. package/dist/studio/assets/ActivityEntryRow-D--fRvWI.js +0 -1
  91. package/dist/studio/assets/ActivityView-D-XBBUHb.js +0 -1
  92. package/dist/studio/assets/CreateDocumentDialog-CH8UH1QM.js +0 -1
  93. package/dist/studio/assets/DocumentsView-CxRpmAxt.js +0 -34
  94. package/dist/studio/assets/DropdownMenu-BSb1l7fr.js +0 -1
  95. package/dist/studio/assets/Input-DVao38h7.js +0 -3
  96. package/dist/studio/assets/MediaView-BHrPIjxB.js +0 -1
  97. package/dist/studio/assets/Modal-VNrXGa5C.js +0 -1
  98. package/dist/studio/assets/OverviewView-DfP6-mLZ.js +0 -1
  99. package/dist/studio/assets/Select-BJZIs9sY.js +0 -1
  100. package/dist/studio/assets/SettingsView-CerHe-ua.js +0 -1
  101. package/dist/studio/assets/Skeleton-CWJNi3nS.js +0 -1
  102. package/dist/studio/assets/StudioPageHeader-DP9HDAF2.js +0 -1
  103. package/dist/studio/assets/UsersView-cP3REkH2.js +0 -1
  104. package/dist/studio/assets/collaboration-BLnCzfvV.js +0 -4
  105. package/dist/studio/assets/context-dY4fNbn3.js +0 -1
  106. package/dist/studio/assets/editor-CE07wW83.js +0 -137
  107. package/dist/studio/assets/gateway-BAyQgCse.js +0 -10
  108. package/dist/studio/assets/index-CjoaPLhZ.js +0 -28
  109. package/dist/studio/assets/index-s2rPqCmP.css +0 -2
  110. package/dist/studio/assets/render-BkxbK2St.js +0 -83
  111. package/dist/studio/assets/rolldown-runtime-DK3Fl9T5.js +0 -1
  112. package/dist/studio/assets/useMediaLibrary-D7qR7aBf.js +0 -1
  113. package/dist/studio/index.html +0 -76
  114. package/src/AuthoringSchema-BQ5kbhVB.js.map +0 -1
  115. package/src/Configuration-BGYFD2N1.js +0 -150
  116. package/src/Configuration-BGYFD2N1.js.map +0 -1
  117. package/src/DocumentEngine-Da0kWotL.js.map +0 -1
  118. package/src/StudioHttp-BTLLooh0.js.map +0 -1
  119. package/src/installation-BNKaVjni.js.map +0 -1
  120. package/src/internal/component-metadata.js +0 -37
  121. package/src/internal/component-metadata.js.map +0 -1
  122. package/src/models-Citx8jBi.js.map +0 -1
  123. package/src/models-DS5ClMsH.js.map +0 -1
@@ -0,0 +1,147 @@
1
+ import { l as validateCollectionBody, n as ComponentDefinition, t as AuthoringCatalog } from "../Configuration-DyKo0sLS.js";
2
+ import { resolveBlockAuthoring } from "./authoring-metadata.js";
3
+ import { addTemplate, addVitePlugin, updateTemplates } from "@nuxt/kit";
4
+ import { Crypto, Effect, Encoding, FileSystem, Path, Schema } from "effect";
5
+ import { createCheckerByJson } from "vue-component-meta";
6
+
7
+ //#region src/internal/authoring-catalog.ts
8
+ /** A complete, validated snapshot shared by Vite and Nitro through ordinary imports. */
9
+ const registerAuthoringCatalog = Effect.fn("CmsAuthoring.register")(function* (nuxt, documents) {
10
+ const fs = yield* FileSystem.FileSystem;
11
+ const path = yield* Path.Path;
12
+ const crypto = yield* Crypto.Crypto;
13
+ const run = Effect.runPromiseWith(yield* Effect.context());
14
+ let contents = "export default { revision: \"empty\", components: [] }\n";
15
+ let blockContents = "export default {}\n";
16
+ let discovered = [];
17
+ let dependencies = /* @__PURE__ */ new Set();
18
+ let queue = Promise.resolve();
19
+ const servers = /* @__PURE__ */ new Set();
20
+ let initialized = false;
21
+ let rejected = false;
22
+ const template = addTemplate({
23
+ filename: "cms/authoring.mjs",
24
+ write: true,
25
+ getContents: () => contents
26
+ });
27
+ const blocks = addTemplate({
28
+ filename: "cms/blocks.mjs",
29
+ write: true,
30
+ getContents: () => blockContents
31
+ });
32
+ nuxt.options.alias["#cms/blocks"] = blocks.dst;
33
+ nuxt.options.alias["#cms/authoring"] = template.dst;
34
+ nuxt.hook("nitro:config", (config) => {
35
+ config.externals ||= {};
36
+ config.externals.inline ||= [];
37
+ config.externals.inline.push(template.dst);
38
+ });
39
+ const compile = Effect.fn("CmsAuthoring.compile")(function* () {
40
+ const checker = createCheckerByJson(nuxt.options.rootDir, {
41
+ compilerOptions: {
42
+ strict: true,
43
+ target: "ESNext",
44
+ module: "ESNext",
45
+ moduleResolution: "Bundler",
46
+ baseUrl: nuxt.options.rootDir,
47
+ paths: Object.fromEntries(Object.entries(nuxt.options.alias).map(([key, value]) => [`${key}/*`, [`${value}/*`]]))
48
+ },
49
+ files: []
50
+ }, { schema: true });
51
+ const definitions = [];
52
+ const registrations = [];
53
+ try {
54
+ for (const component of discovered) {
55
+ if (!component.filePath.endsWith(".vue") || component.filePath.includes("/node_modules/")) continue;
56
+ if (!(yield* fs.exists(component.filePath))) continue;
57
+ const source = yield* fs.readFileString(component.filePath);
58
+ const definition = yield* resolveBlockAuthoring(checker, component.filePath, component.kebabName, source);
59
+ if (!definition) continue;
60
+ if (definitions.some((existing) => existing.name === definition.name)) throw new Error(`Duplicate authoring block ${definition.name}.`);
61
+ definitions.push(definition);
62
+ component.global = false;
63
+ registrations.push({
64
+ name: definition.name,
65
+ filePath: component.filePath
66
+ });
67
+ }
68
+ const components = definitions.sort((left, right) => left.name.localeCompare(right.name));
69
+ for (const collection of documents.types) {
70
+ const issues = validateCollectionBody(components, collection.body);
71
+ if (issues.length) throw new Error(`${collection.label}: ${issues.join(" ")}`);
72
+ }
73
+ const encoded = yield* Schema.encodeEffect(Schema.fromJsonString(Schema.Array(ComponentDefinition)))(components);
74
+ const revision = Encoding.encodeHex(yield* crypto.digest("SHA-256", new TextEncoder().encode(encoded)));
75
+ const next = `export default ${yield* Schema.encodeEffect(Schema.fromJsonString(AuthoringCatalog))({
76
+ revision,
77
+ components
78
+ })}\n`;
79
+ registrations.sort((left, right) => left.name.localeCompare(right.name));
80
+ const nextBlocks = [...registrations.map((component, index) => `import Block${index} from ${JSON.stringify(component.filePath)}`), `export default { ${registrations.map((component, index) => `${JSON.stringify(component.name)}: Block${index}`).join(", ")} }`].join("\n");
81
+ const changed = next !== contents || nextBlocks !== blockContents;
82
+ blockContents = nextBlocks;
83
+ if (rejected) {
84
+ rejected = false;
85
+ for (const server of servers) server.ws.send({
86
+ type: "update",
87
+ updates: []
88
+ });
89
+ }
90
+ if (!changed) return false;
91
+ contents = next;
92
+ return true;
93
+ } finally {
94
+ const discoveredDependencies = new Set(checker.getProgram()?.getSourceFiles().map((file) => path.resolve(file.fileName)).filter((file) => !file.includes("/node_modules/")));
95
+ dependencies = /* @__PURE__ */ new Set([...dependencies, ...discoveredDependencies]);
96
+ for (const server of servers) server.watcher.add([...dependencies]);
97
+ }
98
+ });
99
+ function rebuild() {
100
+ const current = queue.then(() => run(compile()));
101
+ queue = current.then(() => void 0, () => void 0);
102
+ return current;
103
+ }
104
+ function report(error) {
105
+ rejected = true;
106
+ for (const server of servers) server.ws.send({
107
+ type: "error",
108
+ err: {
109
+ message: error.message,
110
+ stack: error.stack ?? "",
111
+ plugin: "cms-authoring"
112
+ }
113
+ });
114
+ return run(Effect.logError("Authoring update rejected; keeping the last valid catalog.", error));
115
+ }
116
+ function update() {
117
+ return rebuild().then((changed) => changed ? updateTemplates({ filter: (candidate) => [template.dst, blocks.dst].includes(candidate.dst) }) : void 0).catch((error) => report(error instanceof Error ? error : new Error(String(error))));
118
+ }
119
+ nuxt.hook("components:extend", (components) => {
120
+ discovered = components;
121
+ const candidate = rebuild().then(() => void 0);
122
+ if (initialized) return candidate.catch((error) => report(error instanceof Error ? error : new Error(String(error))));
123
+ initialized = true;
124
+ return candidate;
125
+ });
126
+ addVitePlugin({
127
+ name: "cms-authoring-catalog",
128
+ configureServer(server) {
129
+ servers.add(server);
130
+ server.watcher.add([...dependencies]);
131
+ const changed = (filename) => {
132
+ const absolute = path.resolve(filename);
133
+ if (dependencies.has(absolute) || discovered.some((component) => component.filePath === absolute)) update();
134
+ };
135
+ server.watcher.on("change", changed);
136
+ server.httpServer?.once("close", () => {
137
+ servers.delete(server);
138
+ server.watcher.off("change", changed);
139
+ });
140
+ }
141
+ });
142
+ return template;
143
+ });
144
+
145
+ //#endregion
146
+ export { registerAuthoringCatalog };
147
+ //# sourceMappingURL=authoring-catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring-catalog.js","names":[],"sources":["../../../../src/internal/authoring-catalog.ts"],"sourcesContent":["import { validateCollectionBody } from '@internal/document/AuthoringSchema'\nimport type { DocumentConfiguration } from '@internal/protocol/Configuration'\nimport type { ViteDevServer } from 'vite'\nimport type { Nuxt } from '@nuxt/schema'\nimport type { Component } from '@nuxt/schema'\nimport { AuthoringCatalog, ComponentDefinition } from '@internal/protocol/Configuration'\nimport { addTemplate, addVitePlugin, updateTemplates } from '@nuxt/kit'\nimport { Crypto, Effect, Encoding, FileSystem, Path, Schema } from 'effect'\nimport { createCheckerByJson } from 'vue-component-meta'\nimport { resolveBlockAuthoring } from './authoring-metadata'\n\n/** A complete, validated snapshot shared by Vite and Nitro through ordinary imports. */\nexport const registerAuthoringCatalog = Effect.fn('CmsAuthoring.register')(function* (\n nuxt: Nuxt,\n documents: DocumentConfiguration,\n) {\n const fs = yield* FileSystem.FileSystem\n const path = yield* Path.Path\n const crypto = yield* Crypto.Crypto\n const run = Effect.runPromiseWith(yield* Effect.context<never>())\n let contents = 'export default { revision: \"empty\", components: [] }\\n'\n let blockContents = 'export default {}\\n'\n let discovered: Component[] = []\n let dependencies = new Set<string>()\n let queue = Promise.resolve()\n const servers = new Set<ViteDevServer>()\n let initialized = false\n let rejected = false\n const template = addTemplate({\n filename: 'cms/authoring.mjs',\n write: true,\n getContents: () => contents,\n })\n const blocks = addTemplate({ filename: 'cms/blocks.mjs', write: true, getContents: () => blockContents })\n nuxt.options.alias['#cms/blocks'] = blocks.dst\n nuxt.options.alias['#cms/authoring'] = template.dst\n nuxt.hook('nitro:config', (config) => {\n config.externals ||= {}\n config.externals.inline ||= []\n config.externals.inline.push(template.dst)\n })\n\n const compile = Effect.fn('CmsAuthoring.compile')(function* () {\n const checker = createCheckerByJson(\n nuxt.options.rootDir,\n {\n compilerOptions: {\n strict: true,\n target: 'ESNext',\n module: 'ESNext',\n moduleResolution: 'Bundler',\n baseUrl: nuxt.options.rootDir,\n paths: Object.fromEntries(\n Object.entries(nuxt.options.alias).map(([key, value]) => [`${key}/*`, [`${value}/*`]]),\n ),\n },\n files: [],\n },\n { schema: true },\n )\n const definitions: ComponentDefinition[] = []\n const registrations: { name: string; filePath: string }[] = []\n try {\n for (const component of discovered) {\n if (!component.filePath.endsWith('.vue') || component.filePath.includes('/node_modules/')) continue\n if (!(yield* fs.exists(component.filePath))) continue\n const source = yield* fs.readFileString(component.filePath)\n const definition = yield* resolveBlockAuthoring(checker, component.filePath, component.kebabName, source)\n if (!definition) continue\n if (definitions.some((existing) => existing.name === definition.name))\n throw new Error(`Duplicate authoring block ${definition.name}.`)\n definitions.push(definition)\n component.global = false\n registrations.push({ name: definition.name, filePath: component.filePath })\n }\n const components = definitions.sort((left, right) => left.name.localeCompare(right.name))\n for (const collection of documents.types) {\n const issues = validateCollectionBody(components, collection.body)\n if (issues.length) throw new Error(`${collection.label}: ${issues.join(' ')}`)\n }\n const encoded = yield* Schema.encodeEffect(Schema.fromJsonString(Schema.Array(ComponentDefinition)))(components)\n const revision = Encoding.encodeHex(yield* crypto.digest('SHA-256', new TextEncoder().encode(encoded)))\n const catalog = yield* Schema.encodeEffect(Schema.fromJsonString(AuthoringCatalog))({ revision, components })\n const next = `export default ${catalog}\\n`\n registrations.sort((left, right) => left.name.localeCompare(right.name))\n const nextBlocks = [\n ...registrations.map((component, index) => `import Block${index} from ${JSON.stringify(component.filePath)}`),\n `export default { ${registrations.map((component, index) => `${JSON.stringify(component.name)}: Block${index}`).join(', ')} }`,\n ].join('\\n')\n const changed = next !== contents || nextBlocks !== blockContents\n blockContents = nextBlocks\n if (rejected) {\n rejected = false\n for (const server of servers) server.ws.send({ type: 'update', updates: [] })\n }\n if (!changed) return false\n contents = next\n return true\n } finally {\n const discoveredDependencies = new Set(\n checker\n .getProgram()\n ?.getSourceFiles()\n .map((file) => path.resolve(file.fileName))\n .filter((file) => !file.includes('/node_modules/')),\n )\n // Keep failed candidate dependencies too, so fixing an imported type can recover the catalog.\n dependencies = new Set([...dependencies, ...discoveredDependencies])\n for (const server of servers) server.watcher.add([...dependencies])\n }\n })\n function rebuild() {\n const current = queue.then(() => run(compile()))\n queue = current.then(\n () => undefined,\n () => undefined,\n )\n return current\n }\n function report(error: Error) {\n rejected = true\n for (const server of servers)\n server.ws.send({\n type: 'error',\n err: { message: error.message, stack: error.stack ?? '', plugin: 'cms-authoring' },\n })\n return run(Effect.logError('Authoring update rejected; keeping the last valid catalog.', error))\n }\n function update() {\n return rebuild()\n .then((changed) =>\n changed\n ? updateTemplates({ filter: (candidate) => [template.dst, blocks.dst].includes(candidate.dst) })\n : undefined,\n )\n .catch((error) => report(error instanceof Error ? error : new Error(String(error))))\n }\n nuxt.hook('components:extend', (components) => {\n discovered = components\n // This hook runs inside template generation. Its caller writes the new snapshot.\n const candidate = rebuild().then(() => undefined)\n if (initialized)\n return candidate.catch((error) => report(error instanceof Error ? error : new Error(String(error))))\n initialized = true\n return candidate\n })\n addVitePlugin({\n name: 'cms-authoring-catalog',\n configureServer(server) {\n servers.add(server)\n server.watcher.add([...dependencies])\n const changed = (filename: string) => {\n const absolute = path.resolve(filename)\n if (dependencies.has(absolute) || discovered.some((component) => component.filePath === absolute)) void update()\n }\n server.watcher.on('change', changed)\n server.httpServer?.once('close', () => {\n servers.delete(server)\n server.watcher.off('change', changed)\n })\n },\n })\n return template\n})\n"],"mappings":";;;;;;;;AAYA,MAAa,2BAA2B,OAAO,GAAG,uBAAuB,CAAC,CAAC,WACzE,MACA,WACA;CACA,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,OAAO,OAAO;CAC7B,MAAM,MAAM,OAAO,eAAe,OAAO,OAAO,QAAe,CAAC;CAChE,IAAI,WAAW;CACf,IAAI,gBAAgB;CACpB,IAAI,aAA0B,CAAC;CAC/B,IAAI,+BAAe,IAAI,IAAY;CACnC,IAAI,QAAQ,QAAQ,QAAQ;CAC5B,MAAM,0BAAU,IAAI,IAAmB;CACvC,IAAI,cAAc;CAClB,IAAI,WAAW;CACf,MAAM,WAAW,YAAY;EAC3B,UAAU;EACV,OAAO;EACP,mBAAmB;CACrB,CAAC;CACD,MAAM,SAAS,YAAY;EAAE,UAAU;EAAkB,OAAO;EAAM,mBAAmB;CAAc,CAAC;CACxG,KAAK,QAAQ,MAAM,iBAAiB,OAAO;CAC3C,KAAK,QAAQ,MAAM,oBAAoB,SAAS;CAChD,KAAK,KAAK,iBAAiB,WAAW;EACpC,OAAO,cAAc,CAAC;EACtB,OAAO,UAAU,WAAW,CAAC;EAC7B,OAAO,UAAU,OAAO,KAAK,SAAS,GAAG;CAC3C,CAAC;CAED,MAAM,UAAU,OAAO,GAAG,sBAAsB,CAAC,CAAC,aAAa;EAC7D,MAAM,UAAU,oBACd,KAAK,QAAQ,SACb;GACE,iB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 +98,8 @@ function readAuthoringDefault(source, filename) {
98
98
  plugins: ["typescript"]
99
99
  }).program.body[0];
100
100
  if (expression?.type !== "ExpressionStatement") throw new Error(`${filename}: expected a literal Vue default.`);
101
- return staticValue(expression.expression, filename);
101
+ const value = expression.expression;
102
+ return staticValue(value.type === "ArrowFunctionExpression" && value.body.type !== "BlockStatement" ? value.body : value, filename);
102
103
  }
103
104
  function cmsAuthoringPlugin() {
104
105
  return {
@@ -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'\ntype Statement = ReturnType<typeof babelParse>['program']['body'][number]\ntype Expression = Extract<Statement, { type: 'ExpressionStatement' }>['expression']\ntype Call = Extract<Expression, { type: 'CallExpression' }>\n\n/** Reads static authoring data and erases the macro before Vue compiles the SFC. */\nexport function compileCmsBlock(source: string, filename: string) {\n if (!source.includes(authoringImport)) return undefined\n const { descriptor, errors } = parse(source, { filename })\n if (errors.length) throw new Error(`${filename}: ${errors.join('\\n')}`)\n if (descriptor.script?.content.includes(authoringImport)) {\n const script = babelParse(descriptor.script.content, { sourceType: 'module', plugins: ['typescript'] })\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 const setup = descriptor.scriptSetup\n if (!setup) return undefined\n const ast = babelParse(setup.content, { sourceType: 'module', plugins: ['typescript'] })\n const imports = ast.program.body.filter(\n (statement) =>\n statement.type === 'ImportDeclaration' &&\n statement.source.value === authoringImport &&\n statement.importKind !== 'type',\n )\n if (!imports.length) return undefined\n const imported = imports[0]\n if (imported?.type !== 'ImportDeclaration') return undefined\n const specifier = imported.specifiers[0]\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 if (setup.lang !== 'ts' || setup.attrs.generic) {\n throw new Error(`${filename}: defineCmsBlock requires a non-generic <script setup lang=\"ts\">.`)\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 const statement = calls[0]\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 const call = statement.expression\n const argument = call.arguments[0]\n if (call.arguments.length !== 1 || argument?.type !== 'ObjectExpression') {\n throw new Error(`${filename}: defineCmsBlock requires one object literal.`)\n }\n const types = call.typeParameters?.type === 'TSTypeParameterInstantiation' ? call.typeParameters.params : []\n if (types.length !== 2)\n throw new Error(`${filename}: share named Props and Slots types with defineProps and defineSlots.`)\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 return type.typeName.name\n })\n const vueCalls = new Map<string, Call>()\n walkIdentifiers(ast.program, (identifier, parent, _stack, isReference) => {\n if (!isReference) return\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 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 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 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 const declaration = staticValue(argument, filename)\n const code = new MagicString(source)\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 code.remove(setup.loc.start.offset + node.start, setup.loc.start.offset + node.end)\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 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 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 return [\n property.key.type === 'Identifier' ? property.key.name : property.key.value,\n staticValue(property.value, filename),\n ]\n })\n if (new Set(entries.map(([key]) => key)).size !== entries.length)\n throw new Error(`${filename}: duplicate authoring property.`)\n return Object.fromEntries(entries)\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 if (expression?.type !== 'ExpressionStatement') throw new Error(`${filename}: expected a literal Vue default.`)\n return staticValue(expression.expression, filename)\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 return compiled ? { code: compiled.code, map: compiled.map } : undefined\n },\n }\n}\n"],"mappings":";;;AAGA,MAAM,kBAAkB;;AAMxB,SAAgB,gBAAgB,QAAgB,UAAkB;CAChE,IAAI,CAAC,OAAO,SAAS,eAAe,GAAG,OAAO;CAC9C,MAAM,EAAE,YAAY,WAAW,MAAM,QAAQ,EAAE,SAAS,CAAC;CACzD,IAAI,OAAO,QAAQ,MAAM,IAAI,MAAM,GAAG,SAAS,IAAI,OAAO,KAAK,IAAI,GAAG;CACtE,IAAI,WAAW,QAAQ,QAAQ,SAAS,eAAe,GAErD;MADe,WAAW,WAAW,OAAO,SAAS;GAAE,YAAY;GAAU,SAAS,CAAC,YAAY;EAAE,CAE9F,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;;CAEpF,MAAM,QAAQ,WAAW;CACzB,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,MAAM,WAAW,MAAM,SAAS;EAAE,Y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,CAAC,YAAY;CAAE,CAAC,CAAC,CAAC,QAAQ,KAAK;CAC7G,IAAI,YAAY,SAAS,uBAAuB,MAAM,IAAI,MAAM,GAAG,SAAS,kCAAkC;CAC9G,OAAO,YAAY,WAAW,YAAY,QAAQ;AACpD;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;GAC3C,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 type { Schema } from 'effect'\n\nconst authoringImport = '@phtngyn/cms/Authoring'\ntype Statement = ReturnType<typeof babelParse>['program']['body'][number]\ntype Expression = Extract<Statement, { type: 'ExpressionStatement' }>['expression']\ntype Call = Extract<Expression, { type: 'CallExpression' }>\n\n/** Reads static authoring data and erases the macro before Vue compiles the SFC. */\nexport function compileCmsBlock(source: string, filename: string) {\n if (!source.includes(authoringImport)) return undefined\n const { descriptor, errors } = parse(source, { filename })\n if (errors.length) throw new Error(`${filename}: ${errors.join('\\n')}`)\n if (descriptor.script?.content.includes(authoringImport)) {\n const script = babelParse(descriptor.script.content, { sourceType: 'module', plugins: ['typescript'] })\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 const setup = descriptor.scriptSetup\n if (!setup) return undefined\n const ast = babelParse(setup.content, { sourceType: 'module', plugins: ['typescript'] })\n const imports = ast.program.body.filter(\n (statement) =>\n statement.type === 'ImportDeclaration' &&\n statement.source.value === authoringImport &&\n statement.importKind !== 'type',\n )\n if (!imports.length) return undefined\n const imported = imports[0]\n if (imported?.type !== 'ImportDeclaration') return undefined\n const specifier = imported.specifiers[0]\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 if (setup.lang !== 'ts' || setup.attrs.generic) {\n throw new Error(`${filename}: defineCmsBlock requires a non-generic <script setup lang=\"ts\">.`)\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 const statement = calls[0]\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 const call = statement.expression\n const argument = call.arguments[0]\n if (call.arguments.length !== 1 || argument?.type !== 'ObjectExpression') {\n throw new Error(`${filename}: defineCmsBlock requires one object literal.`)\n }\n const types = call.typeParameters?.type === 'TSTypeParameterInstantiation' ? call.typeParameters.params : []\n if (types.length !== 2)\n throw new Error(`${filename}: share named Props and Slots types with defineProps and defineSlots.`)\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 return type.typeName.name\n })\n const vueCalls = new Map<string, Call>()\n walkIdentifiers(ast.program, (identifier, parent, _stack, isReference) => {\n if (!isReference) return\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 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 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 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 const declaration = staticValue(argument, filename)\n const code = new MagicString(source)\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 code.remove(setup.loc.start.offset + node.start, setup.loc.start.offset + node.end)\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 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 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 return [\n property.key.type === 'Identifier' ? property.key.name : property.key.value,\n staticValue(property.value, filename),\n ]\n })\n if (new Set(entries.map(([key]) => key)).size !== entries.length)\n throw new Error(`${filename}: duplicate authoring property.`)\n return Object.fromEntries(entries)\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 if (expression?.type !== 'ExpressionStatement') throw new Error(`${filename}: expected a literal Vue default.`)\n const value = expression.expression\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 return compiled ? { code: compiled.code, map: compiled.map } : undefined\n },\n }\n}\n"],"mappings":";;;AAGA,MAAM,kBAAkB;;AAMxB,SAAgB,gBAAgB,QAAgB,UAAkB;CAChE,IAAI,CAAC,OAAO,SAAS,eAAe,GAAG,OAAO;CAC9C,MAAM,EAAE,YAAY,WAAW,MAAM,QAAQ,EAAE,SAAS,CAAC;CACzD,IAAI,OAAO,QAAQ,MAAM,IAAI,MAAM,GAAG,SAAS,IAAI,OAAO,KAAK,IAAI,GAAG;CACtE,IAAI,WAAW,QAAQ,QAAQ,SAAS,eAAe,GAErD;MADe,WAAW,WAAW,OAAO,SAAS;GAAE,YAAY;GAAU,SAAS,CAAC,YAAY;EAAE,CAE9F,CAAC,CAAC,QAAQ,KAAK,MACjB,cACC,UAAU,SAAS,uBACnB,UAAU,OAAO,UAAU,mBAC3B,UAAU,eAAe,UACzB,UAAU,WAAW,MAClB,cA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AAY,OAAO;EACnC;CACF;CACA,MAAM,IAAI,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;CAC7G,IAAI,YAAY,SAAS,uBAAuB,MAAM,IAAI,MAAM,GAAG,SAAS,kCAAkC;CAC9G,MAAM,QAAQ,WAAW;CACzB,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;GAC3C,OAAO,WAAW;IAAE,MAAM,SAAS;IAAM,KAAK,SAAS;GAAI,IAAI;EACjE;CACF;AACF"}
@@ -1,11 +1,13 @@
1
- import { i as BlockAuthoring, t as ComponentDefinition } from "../Configuration-BGYFD2N1.js";
2
- import { n as parseAuthoringContent, t as createAuthoringSchema } from "../AuthoringSchema-BQ5kbhVB.js";
1
+ import { a as BlockAuthoring, n as ComponentDefinition, o as createAuthoringSchema, s as parseAuthoringContent } from "../Configuration-DyKo0sLS.js";
3
2
  import { compileCmsBlock, readAuthoringDefault } from "./authoring-compiler.js";
4
3
  import { Effect, Schema } from "effect";
5
4
  import ts from "typescript";
6
5
 
7
6
  //#region src/internal/authoring-metadata.ts
8
7
  const Presentation = Schema.Struct({
8
+ fields: Schema.optionalKey(Schema.Record(Schema.String, Schema.suspend(() => Presentation))),
9
+ blocks: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),
10
+ groups: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),
9
11
  label: Schema.NonEmptyString,
10
12
  help: Schema.optionalKey(Schema.String),
11
13
  input: Schema.String,
@@ -40,28 +42,9 @@ const resolveBlockAuthoring = Effect.fn("NuxtAuthoring.resolve")(function* (chec
40
42
  const props = Object.entries(declared.props).map(([key, presentation]) => {
41
43
  const prop = metadata.props.find((candidate) => candidate.name === key && !candidate.global);
42
44
  if (!prop) throw new Error(`${filename}: unknown Vue prop ${key}.`);
43
- const resolved = scalarProp(prop, filename);
44
- const input = presentation.input;
45
- if (resolved.type === "string" && ![
46
- "text",
47
- "textarea",
48
- "select"
49
- ].includes(input) || resolved.type === "number" && input !== "number" || resolved.type === "boolean" && input !== "toggle" || input === "select" && !resolved.choices.length) throw new Error(`${filename}: ${key} has an incompatible authoring input ${input}.`);
50
- for (const key of Object.keys(presentation.optionLabels ?? {})) if (!resolved.choices.includes(key)) throw new Error(`${filename}: ${key} is not a Vue union choice.`);
51
- return Schema.decodeUnknownSync(BlockAuthoring.fields.props.value)({
52
- name: key,
53
- label: presentation.label,
54
- ...presentation.help === void 0 ? void 0 : { help: presentation.help },
55
- type: resolved.type,
56
- input,
57
- required: prop.required,
58
- nullable: resolved.nullable,
59
- ...prop.default === void 0 ? void 0 : { defaultValue: readAuthoringDefault(prop.default, `${filename} prop ${key}`) },
60
- options: resolved.choices.map((value) => ({
61
- value,
62
- label: presentation.optionLabels?.[value] ?? value
63
- }))
64
- });
45
+ const typeChecker = checker.getProgram()?.getTypeChecker();
46
+ if (!typeChecker) throw new Error(`${filename}: Vue type information is unavailable.`);
47
+ return resolveProp(prop.getTypeObject(), key, prop.required, presentation, typeChecker, filename, prop.default);
65
48
  });
66
49
  for (const prop of metadata.props) if (!prop.global && prop.required && prop.default === void 0 && !Object.hasOwn(declared.props, prop.name)) throw new Error(`${filename}: required prop ${prop.name} needs an authoring declaration and initial value.`);
67
50
  const slotTypes = vueSlots(checker, filename);
@@ -83,6 +66,8 @@ const resolveBlockAuthoring = Effect.fn("NuxtAuthoring.resolve")(function* (chec
83
66
  input: presentation.input,
84
67
  required: slot.required,
85
68
  features: presentation.features ?? [],
69
+ ...presentation.blocks === void 0 ? void 0 : { blocks: presentation.blocks },
70
+ ...presentation.groups === void 0 ? void 0 : { groups: presentation.groups },
86
71
  ...initial === void 0 ? void 0 : { initial }
87
72
  }));
88
73
  if (slot.required && !seed) throw new Error(`${filename}: required slot ${key} needs initial content.`);
@@ -102,37 +87,71 @@ const resolveBlockAuthoring = Effect.fn("NuxtAuthoring.resolve")(function* (chec
102
87
  createAuthoringSchema(name, authoring);
103
88
  return ComponentDefinition.make({
104
89
  name,
105
- authoring,
106
- props: props.map(({ name, required, type }) => ({
107
- name,
108
- required,
109
- type
110
- })),
111
- slots: slots.map(({ name }) => ({ name }))
90
+ authoring
112
91
  });
113
92
  });
114
- function scalarProp(prop, filename) {
115
- const raw = prop.getTypeObject();
93
+ function resolveProp(raw, name, required, presentation, checker, filename, defaultSource, depth = 0) {
94
+ if (depth > 12) throw new Error(`${filename}: ${name} exceeds the supported property nesting depth.`);
116
95
  const union = raw.isUnion() ? raw.types : [raw];
117
96
  const members = union.filter((type) => !(type.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Null)));
118
97
  const nullable = union.some((type) => Boolean(type.flags & ts.TypeFlags.Null));
119
98
  const choices = members.flatMap((type) => type.isStringLiteral() ? [type.value] : []).sort();
120
- if (members.length && members.every((type) => Boolean(type.flags & ts.TypeFlags.StringLike))) return {
121
- type: "string",
122
- nullable,
123
- choices
124
- };
125
- if (members.length === 1 && members[0]?.flags === ts.TypeFlags.Number) return {
126
- type: "number",
127
- nullable,
128
- choices
129
- };
130
- if (members.length === 2 && members.every((type) => Boolean(type.flags & ts.TypeFlags.BooleanLiteral))) return {
131
- type: "boolean",
99
+ const valueType = checker.getNonNullableType(raw);
100
+ let type;
101
+ let fields;
102
+ if (members.length && members.every((type) => Boolean(type.flags & ts.TypeFlags.StringLike))) type = "string";
103
+ else if (members.length === 1 && members[0]?.flags === ts.TypeFlags.Number) type = "number";
104
+ else if (members.length && members.every((type) => Boolean(type.flags & ts.TypeFlags.BooleanLike))) type = "boolean";
105
+ else if (presentation.input === "object" || presentation.input === "list") {
106
+ type = presentation.input === "list" ? "array" : "object";
107
+ const item = type === "array" ? checker.getIndexTypeOfType(valueType, ts.IndexKind.Number) : valueType;
108
+ if (!item || !(item.flags & ts.TypeFlags.Object) || item.getCallSignatures().length) throw new Error(`${filename}: ${name} needs an object${type === "array" ? " list" : ""} type.`);
109
+ if (type === "array") {
110
+ const id = item.getProperty("id");
111
+ const declaration = id?.valueDeclaration ?? id?.declarations?.[0];
112
+ if (!id || !declaration || id.flags & ts.SymbolFlags.Optional || checker.getTypeOfSymbolAtLocation(id, declaration).flags !== ts.TypeFlags.String) throw new Error(`${filename}: ${name} list items need a required string id for stable editing.`);
113
+ }
114
+ fields = Object.entries(presentation.fields ?? {}).map(([key, field]) => {
115
+ if (type === "array" && key === "id") throw new Error(`${filename}: list item ids are managed by Studio.`);
116
+ const property = item.getProperty(key);
117
+ const declaration = property?.valueDeclaration ?? property?.declarations?.[0];
118
+ if (!property || !declaration) throw new Error(`${filename}: unknown field ${name}.${key}.`);
119
+ return resolveProp(checker.getTypeOfSymbolAtLocation(property, declaration), key, !(property.flags & ts.SymbolFlags.Optional), field, checker, filename, void 0, depth + 1);
120
+ });
121
+ for (const property of item.getProperties()) {
122
+ if (type === "array" && property.name === "id") continue;
123
+ if (!(property.flags & ts.SymbolFlags.Optional) && !fields.some((field) => field.name === property.name)) throw new Error(`${filename}: required field ${name}.${property.name} needs an authoring declaration.`);
124
+ }
125
+ } else throw new Error(`${filename}: unsupported editable prop ${name}.`);
126
+ if (!{
127
+ string: [
128
+ "text",
129
+ "textarea",
130
+ "select",
131
+ "image",
132
+ "link"
133
+ ],
134
+ number: ["number"],
135
+ boolean: ["toggle"],
136
+ object: ["object"],
137
+ array: ["list"]
138
+ }[type].includes(presentation.input) || presentation.input === "select" && !choices.length) throw new Error(`${filename}: ${name} has an incompatible authoring input ${presentation.input}.`);
139
+ for (const key of Object.keys(presentation.optionLabels ?? {})) if (!choices.includes(key)) throw new Error(`${filename}: ${key} is not a Vue union choice.`);
140
+ return Schema.decodeUnknownSync(BlockAuthoring.fields.props.value)({
141
+ name,
142
+ label: presentation.label,
143
+ type,
144
+ input: presentation.input,
145
+ required,
132
146
  nullable,
133
- choices
134
- };
135
- throw new Error(`${filename}: editable prop ${prop.name} must be a string, literal string union, number, or boolean.`);
147
+ ...presentation.help === void 0 ? void 0 : { help: presentation.help },
148
+ ...fields === void 0 ? void 0 : { fields },
149
+ ...defaultSource === void 0 ? void 0 : { defaultValue: readAuthoringDefault(defaultSource, `${filename} prop ${name}`) },
150
+ options: choices.map((value) => ({
151
+ value,
152
+ label: presentation.optionLabels?.[value] ?? value
153
+ }))
154
+ });
136
155
  }
137
156
  function vueSlots(checker, filename) {
138
157
  const program = checker.getProgram();
@@ -1 +1 @@
1
- {"version":3,"file":"authoring-metadata.js","names":[],"sources":["../../../../src/internal/authoring-metadata.ts"],"sourcesContent":["import type { ComponentMetaChecker, PropertyMeta } 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 { Effect, Schema } from 'effect'\nimport ts from 'typescript'\nimport { compileCmsBlock, readAuthoringDefault } from './authoring-compiler'\n\nconst Presentation = Schema.Struct({\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})\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 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 const props = Object.entries(declared.props).map(([key, presentation]): BlockProp => {\n const prop = metadata.props.find((candidate) => candidate.name === key && !candidate.global)\n if (!prop) throw new Error(`${filename}: unknown Vue prop ${key}.`)\n const resolved = scalarProp(prop, filename)\n const input = presentation.input\n if (\n (resolved.type === 'string' && !['text', 'textarea', 'select'].includes(input)) ||\n (resolved.type === 'number' && input !== 'number') ||\n (resolved.type === 'boolean' && input !== 'toggle') ||\n (input === 'select' && !resolved.choices.length)\n )\n throw new Error(`${filename}: ${key} has an incompatible authoring input ${input}.`)\n for (const key of Object.keys(presentation.optionLabels ?? {}))\n if (!resolved.choices.includes(key)) throw new Error(`${filename}: ${key} is not a Vue union choice.`)\n return Schema.decodeUnknownSync(BlockAuthoring.fields.props.value)({\n name: key,\n label: presentation.label,\n ...(presentation.help === undefined ? undefined : { help: presentation.help }),\n type: resolved.type,\n input,\n required: prop.required,\n nullable: resolved.nullable,\n ...(prop.default === undefined\n ? undefined\n : { defaultValue: readAuthoringDefault(prop.default, `${filename} prop ${key}`) }),\n options: resolved.choices.map((value) => ({ value, label: presentation.optionLabels?.[value] ?? value })),\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 const slotTypes = vueSlots(checker, filename)\n const slots: BlockSlot[] = []\n for (const [key, presentation] of Object.entries(declared.slots)) {\n const slot = slotTypes.get(key)\n if (!slot) throw new Error(`${filename}: unknown Vue slot ${key}.`)\n if (slot.scoped) throw new Error(`${filename}: scoped slot ${key} cannot be authored.`)\n const seed = declared.initial?.slots?.[key]\n const initial = seed\n ? 'text' in seed\n ? [['p', {}, seed.text]]\n : yield* parseAuthoringContent(seed.markdown)\n : undefined\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 ...(initial === undefined ? undefined : { initial }),\n }),\n )\n if (slot.required && !seed) throw new Error(`${filename}: required slot ${key} needs initial content.`)\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 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 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 createAuthoringSchema(name, authoring)\n return ComponentDefinition.make({\n name,\n authoring,\n props: props.map(({ name, required, type }) => ({ name, required, type })),\n slots: slots.map(({ name }) => ({ name })),\n })\n})\n\nfunction scalarProp(prop: PropertyMeta, filename: string) {\n const raw = prop.getTypeObject()\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 if (members.length && members.every((type) => Boolean(type.flags & ts.TypeFlags.StringLike)))\n return { type: 'string' as const, nullable, choices }\n if (members.length === 1 && members[0]?.flags === ts.TypeFlags.Number)\n return { type: 'number' as const, nullable, choices }\n if (members.length === 2 && members.every((type) => Boolean(type.flags & ts.TypeFlags.BooleanLiteral)))\n return { type: 'boolean' as const, nullable, choices }\n throw new Error(`${filename}: editable prop ${prop.name} must be a string, literal string union, number, or boolean.`)\n}\n\nfunction vueSlots(checker: ComponentMetaChecker, filename: string) {\n const program = checker.getProgram()\n const file = program?.getSourceFile(filename)\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 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 if (type)\n for (const property of typeChecker.getTypeAtLocation(type).getProperties()) {\n const declaration = property.valueDeclaration ?? property.declarations?.[0]\n const signature = declaration\n ? typeChecker\n .getNonNullableType(typeChecker.getTypeOfSymbolAtLocation(property, declaration))\n .getCallSignatures()\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 ts.forEachChild(node, visit)\n }\n visit(file)\n return result\n}\n"],"mappings":";;;;;;;AASA,MAAM,eAAe,OAAO,OAAO;CACjC,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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M,OAAO,SAAS,cAAc,QAAQ;CAC5C,IAAI,CAAC,WAAW,CAAC,MAAM,MAAM,IAAI,MAAM,GAAG,SAAS,uCAAuC;CAC1F,MAAM,cAAc,QAAQ,eAAe;CAC3C,MAAM,yBAAS,IAAI,IAAoD;CACvE,SAAS,MAAM,MAAqB;EAClC,IAAI,GAAG,iBAAiB,IAAI,KAAK,GAAG,aAAa,KAAK,UAAU,KAAK,KAAK,WAAW,SAAS,eAAe;GAC3G,MAAM,OAAO,KAAK,gBAAgB;GAClC,IAAI,MACF,KAAK,MAAM,YAAY,YAAY,kBAAkB,IAAI,CAAC,CAAC,cAAc,GAAG;IAC1E,MAAM,cAAc,SAAS,oBAAoB,SAAS,eAAe;IACzE,MAAM,YAAY,cACd,YACG,mBAAmB,YAAY,0BAA0B,UAAU,WAAW,CAAC,CAAC,CAChF,kBAAkB,IACrB,CAAC;IACL,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;EACA,GAAG,aAAa,MAAM,KAAK;CAC7B;CACA,MAAM,IAAI;CACV,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 { 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 { 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}\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})\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 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 const props = Object.entries(declared.props).map(([key, presentation]): BlockProp => {\n const prop = metadata.props.find((candidate) => candidate.name === key && !candidate.global)\n if (!prop) throw new Error(`${filename}: unknown Vue prop ${key}.`)\n const typeChecker = checker.getProgram()?.getTypeChecker()\n if (!typeChecker) throw new Error(`${filename}: Vue type information is unavailable.`)\n return resolveProp(prop.getTypeObject(), key, prop.required, presentation, typeChecker, filename, prop.default)\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 const slotTypes = vueSlots(checker, filename)\n const slots: BlockSlot[] = []\n for (const [key, presentation] of Object.entries(declared.slots)) {\n const slot = slotTypes.get(key)\n if (!slot) throw new Error(`${filename}: unknown Vue slot ${key}.`)\n if (slot.scoped) throw new Error(`${filename}: scoped slot ${key} cannot be authored.`)\n const seed = declared.initial?.slots?.[key]\n const initial = seed\n ? 'text' in seed\n ? [['p', {}, seed.text]]\n : yield* parseAuthoringContent(seed.markdown)\n : undefined\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 if (slot.required && !seed) throw new Error(`${filename}: required slot ${key} needs initial content.`)\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 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 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 createAuthoringSchema(name, authoring)\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 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 if (!item || !(item.flags & ts.TypeFlags.Object) || item.getCallSignatures().length)\n throw new Error(`${filename}: ${name} needs an object${type === 'array' ? ' list' : ''} type.`)\n if (type === 'array') {\n const id = item.getProperty('id')\n const declaration = id?.valueDeclaration ?? id?.declarations?.[0]\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 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 if (!property || !declaration) throw new Error(`${filename}: unknown field ${name}.${key}.`)\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 for (const property of item.getProperties()) {\n if (type === 'array' && property.name === 'id') continue\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 const inputs = {\n string: ['text', 'textarea', 'select', 'image', 'link'],\n number: ['number'],\n boolean: ['toggle'],\n object: ['object'],\n array: ['list'],\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 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 return Schema.decodeUnknownSync(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\nfunction vueSlots(checker: ComponentMetaChecker, filename: string) {\n const program = checker.getProgram()\n const file = program?.getSourceFile(filename)\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 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 if (type)\n for (const property of typeChecker.getTypeAtLocation(type).getProperties()) {\n const declaration = property.valueDeclaration ?? property.declarations?.[0]\n const signature = declaration\n ? typeChecker\n .getNonNullableType(typeChecker.getTypeOfSymbolAtLocation(property, declaration))\n .getCallSignatures()\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 ts.forEachChild(node, visit)\n }\n visit(file)\n return result\n}\n"],"mappings":";;;;;;AAmBA,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;AACD,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,CAA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,MAAqB;EAClC,IAAI,GAAG,iBAAiB,IAAI,KAAK,GAAG,aAAa,KAAK,UAAU,KAAK,KAAK,WAAW,SAAS,eAAe;GAC3G,MAAM,OAAO,KAAK,gBAAgB;GAClC,IAAI,MACF,KAAK,MAAM,YAAY,YAAY,kBAAkB,IAAI,CAAC,CAAC,cAAc,GAAG;IAC1E,MAAM,cAAc,SAAS,oBAAoB,SAAS,eAAe;IACzE,MAAM,YAAY,cACd,YACG,mBAAmB,YAAY,0BAA0B,UAAU,WAAW,CAAC,CAAC,CAChF,kBAAkB,IACrB,CAAC;IACL,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;EACA,GAAG,aAAa,MAAM,KAAK;CAC7B;CACA,MAAM,IAAI;CACV,OAAO;AACT"}
@@ -1,7 +1,6 @@
1
- import { u as DocumentImportSource } from "../models-Citx8jBi.js";
2
- import { a as StudioBootstrap } from "../StudioHttp-BTLLooh0.js";
3
- import { s as PreviewOrigin } from "../models-DS5ClMsH.js";
4
- import { cmsComponentDefinitions } from "./component-metadata.js";
1
+ import { u as DocumentImportSource } from "../models-BkMgeaOL.js";
2
+ import { a as StudioBootstrap } from "../StudioHttp-jR2-bc01.js";
3
+ import { i as PreviewOrigin } from "../models-C3witQBK.js";
5
4
  import { compileCmsDocumentModel } from "./document-model.js";
6
5
  import { Result, Schema } from "effect";
7
6
 
@@ -51,14 +50,13 @@ function compileCmsConfiguration(configuration, initialSources = []) {
51
50
  };
52
51
  }
53
52
  /** Produces the single input consumed by the Node installation from the authored CMS configuration. */
54
- function resolveCmsInstallation(authored, componentMetadata, initialSources = [], authoring = []) {
53
+ function resolveCmsInstallation(authored, authoring, initialSources = []) {
55
54
  const compiled = compileCmsConfiguration(authored, initialSources);
56
55
  const configuration = compiled.installation;
57
56
  const cleanup = configuration.cleanup === false ? void 0 : configuration.cleanup;
58
57
  const media = configuration.media === false ? void 0 : configuration.media;
59
58
  const bootstrap = Schema.decodeSync(StudioBootstrap)({
60
59
  basePath: "/",
61
- components: [...cmsComponentDefinitions(Object.fromEntries(Object.entries(componentMetadata).filter(([, component]) => !authoring.some((definition) => definition.name === component.kebabName)))), ...authoring].sort((left, right) => left.name.localeCompare(right.name)),
62
60
  documents: compiled.documents,
63
61
  media: {
64
62
  enabled: media !== void 0,
@@ -67,6 +65,7 @@ function resolveCmsInstallation(authored, componentMetadata, initialSources = []
67
65
  version: "1"
68
66
  });
69
67
  return {
68
+ authoring,
70
69
  baseUrl: configuration.baseUrl,
71
70
  bootstrap,
72
71
  cleanup: {
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","names":["PreviewOriginSchema","DocumentImportSourceSchema","compileComponentDefinitions"],"sources":["../../../../src/internal/configuration.ts"],"sourcesContent":["import type { ExecutableDocumentModel } from '@internal/document/DocumentEngine'\nimport type { ComponentDefinition, DocumentConfiguration } from '@internal/protocol/Configuration'\nimport type { DocumentImportSource } from '@internal/protocol/Documents'\nimport type { CmsConfiguration, CmsInitialDocument } from '../Configuration'\nimport type { cmsComponentDefinitions } from './component-metadata'\nimport type { NuxtCmsInstallationOptions } from '../runtime/installation'\nimport { DocumentImportSource as DocumentImportSourceSchema } from '@internal/protocol/Documents'\nimport { PreviewOrigin as PreviewOriginSchema } from '@internal/protocol/Preview'\nimport { StudioBootstrap } from '@internal/protocol/StudioHttp'\nimport { Result, Schema } from 'effect'\nimport { cmsComponentDefinitions as compileComponentDefinitions } from './component-metadata'\nimport { compileCmsDocumentModel } from './document-model'\n\nconst DEFAULT_CLEANUP_INTERVAL_MILLIS = 24 * 60 * 60_000\nconst DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS = 60_000\nconst DEFAULT_MEDIA_MAX_UPLOAD_BYTES = 10_000_000\n\nconst optionalString = Schema.optionalKey(Schema.NonEmptyString)\nconst InstallationConfiguration = Schema.Struct({\n baseUrl: PreviewOriginSchema,\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 databaseUrl: Schema.NonEmptyString,\n initializationToken: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n media: Schema.optionalKey(\n Schema.Union([\n Schema.Literals([false]),\n Schema.Struct({\n maxUploadBytes: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),\n publicBaseUrl: Schema.NonEmptyString,\n storage: Schema.Struct({\n bucket: Schema.NonEmptyString,\n credentials: Schema.optionalKey(\n Schema.Struct({\n accessKeyId: Schema.NonEmptyString,\n secretAccessKey: Schema.NonEmptyString,\n sessionToken: optionalString,\n }),\n ),\n endpoint: optionalString,\n forcePathStyle: Schema.optionalKey(Schema.Boolean),\n provisionBucket: Schema.optionalKey(Schema.Boolean),\n region: Schema.NonEmptyString,\n }),\n }),\n ]),\n ),\n secret: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n})\ntype CmsInstallationConfiguration = Schema.Schema.Type<typeof InstallationConfiguration>\n\nexport interface CompiledCmsConfiguration {\n readonly documents: DocumentConfiguration\n readonly documentModel: ExecutableDocumentModel\n readonly initialSources: ReadonlyArray<DocumentImportSource>\n readonly installation: CmsInstallationConfiguration\n}\n\n/** Compiles every authored, executable concern once through the owning document interface. */\nexport function compileCmsConfiguration(\n configuration: CmsConfiguration,\n initialSources: ReadonlyArray<CmsInitialDocument> = [],\n): CompiledCmsConfiguration {\n const decodedConfiguration = Schema.decodeResult(InstallationConfiguration)(configuration)\n if (Result.isFailure(decodedConfiguration)) {\n throw new Error(`Invalid CMS configuration: ${String(decodedConfiguration.failure)}`)\n }\n const documents = compileCmsDocumentModel(configuration.documents)\n const decodedSources = Schema.decodeResult(Schema.Array(DocumentImportSourceSchema))(initialSources)\n if (Result.isFailure(decodedSources)) {\n throw new Error(`Invalid CMS initial sources: ${String(decodedSources.failure)}`)\n }\n return {\n documentModel: documents.executable,\n documents: documents.authoring,\n initialSources: decodedSources.success,\n installation: decodedConfiguration.success,\n }\n}\n\n/** Produces the single input consumed by the Node installation from the authored CMS configuration. */\nexport function resolveCmsInstallation(\n authored: CmsConfiguration,\n componentMetadata: Parameters<typeof cmsComponentDefinitions>[0],\n initialSources: ReadonlyArray<CmsInitialDocument> = [],\n authoring: ReadonlyArray<ComponentDefinition> = [],\n): NuxtCmsInstallationOptions {\n const compiled = compileCmsConfiguration(authored, initialSources)\n const configuration = compiled.installation\n const cleanup = configuration.cleanup === false ? undefined : configuration.cleanup\n const media = configuration.media === false ? undefined : configuration.media\n const bootstrap = Schema.decodeSync(StudioBootstrap)({\n basePath: '/',\n components: [\n ...compileComponentDefinitions(\n Object.fromEntries(\n Object.entries(componentMetadata).filter(\n ([, component]) => !authoring.some((definition) => definition.name === component.kebabName),\n ),\n ),\n ),\n ...authoring,\n ].sort((left, right) => left.name.localeCompare(right.name)),\n documents: compiled.documents,\n media: {\n enabled: media !== undefined,\n maxUploadBytes: media?.maxUploadBytes ?? DEFAULT_MEDIA_MAX_UPLOAD_BYTES,\n },\n version: '1',\n })\n\n return {\n baseUrl: configuration.baseUrl,\n bootstrap,\n cleanup: {\n enabled: configuration.cleanup !== false,\n initialDelayMillis: cleanup?.initialDelayMillis ?? DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS,\n intervalMillis: cleanup?.intervalMillis ?? DEFAULT_CLEANUP_INTERVAL_MILLIS,\n },\n databaseUrl: configuration.databaseUrl,\n documentModel: compiled.documentModel,\n initialSources: compiled.initialSources,\n initializationToken: configuration.initializationToken,\n ...(media === undefined\n ? undefined\n : {\n media: {\n publicBaseUrl: media.publicBaseUrl,\n ...media.storage,\n forcePathStyle: media.storage.forcePathStyle ?? false,\n provisionBucket: media.storage.provisionBucket ?? false,\n },\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A,EACE,OAAO;GACL,eAAe,MAAM;GACrB,GAAG,MAAM;GACT,gBAAgB,MAAM,QAAQ,kBAAkB;GAChD,iBAAiB,MAAM,QAAQ,mBAAmB;EACpD,EACF;EACJ,QAAQ,cAAc;CACxB;AACF"}
1
+ {"version":3,"file":"configuration.js","names":["PreviewOriginSchema","DocumentImportSourceSchema"],"sources":["../../../../src/internal/configuration.ts"],"sourcesContent":["import type { ExecutableDocumentModel } from '@internal/document/DocumentEngine'\nimport type { AuthoringCatalog, DocumentConfiguration } from '@internal/protocol/Configuration'\nimport type { DocumentImportSource } from '@internal/protocol/Documents'\nimport type { CmsConfiguration, CmsInitialDocument } from '../Configuration'\nimport type { NuxtCmsInstallationOptions } from '../runtime/installation'\nimport { DocumentImportSource as DocumentImportSourceSchema } from '@internal/protocol/Documents'\nimport { PreviewOrigin as PreviewOriginSchema } from '@internal/protocol/Preview'\nimport { StudioBootstrap } from '@internal/protocol/StudioHttp'\nimport { Result, Schema } from 'effect'\nimport { compileCmsDocumentModel } from './document-model'\n\nconst DEFAULT_CLEANUP_INTERVAL_MILLIS = 24 * 60 * 60_000\nconst DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS = 60_000\nconst DEFAULT_MEDIA_MAX_UPLOAD_BYTES = 10_000_000\n\nconst optionalString = Schema.optionalKey(Schema.NonEmptyString)\nconst InstallationConfiguration = Schema.Struct({\n baseUrl: PreviewOriginSchema,\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 databaseUrl: Schema.NonEmptyString,\n initializationToken: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n media: Schema.optionalKey(\n Schema.Union([\n Schema.Literals([false]),\n Schema.Struct({\n maxUploadBytes: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),\n publicBaseUrl: Schema.NonEmptyString,\n storage: Schema.Struct({\n bucket: Schema.NonEmptyString,\n credentials: Schema.optionalKey(\n Schema.Struct({\n accessKeyId: Schema.NonEmptyString,\n secretAccessKey: Schema.NonEmptyString,\n sessionToken: optionalString,\n }),\n ),\n endpoint: optionalString,\n forcePathStyle: Schema.optionalKey(Schema.Boolean),\n provisionBucket: Schema.optionalKey(Schema.Boolean),\n region: Schema.NonEmptyString,\n }),\n }),\n ]),\n ),\n secret: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n})\ntype CmsInstallationConfiguration = Schema.Schema.Type<typeof InstallationConfiguration>\n\nexport interface CompiledCmsConfiguration {\n readonly documents: DocumentConfiguration\n readonly documentModel: ExecutableDocumentModel\n readonly initialSources: ReadonlyArray<DocumentImportSource>\n readonly installation: CmsInstallationConfiguration\n}\n\n/** Compiles every authored, executable concern once through the owning document interface. */\nexport function compileCmsConfiguration(\n configuration: CmsConfiguration,\n initialSources: ReadonlyArray<CmsInitialDocument> = [],\n): CompiledCmsConfiguration {\n const decodedConfiguration = Schema.decodeResult(InstallationConfiguration)(configuration)\n if (Result.isFailure(decodedConfiguration)) {\n throw new Error(`Invalid CMS configuration: ${String(decodedConfiguration.failure)}`)\n }\n const documents = compileCmsDocumentModel(configuration.documents)\n const decodedSources = Schema.decodeResult(Schema.Array(DocumentImportSourceSchema))(initialSources)\n if (Result.isFailure(decodedSources)) {\n throw new Error(`Invalid CMS initial sources: ${String(decodedSources.failure)}`)\n }\n return {\n documentModel: documents.executable,\n documents: documents.authoring,\n initialSources: decodedSources.success,\n installation: decodedConfiguration.success,\n }\n}\n\n/** Produces the single input consumed by the Node installation from the authored CMS configuration. */\nexport function resolveCmsInstallation(\n authored: CmsConfiguration,\n authoring: AuthoringCatalog,\n initialSources: ReadonlyArray<CmsInitialDocument> = [],\n): NuxtCmsInstallationOptions {\n const compiled = compileCmsConfiguration(authored, initialSources)\n const configuration = compiled.installation\n const cleanup = configuration.cleanup === false ? undefined : configuration.cleanup\n const media = configuration.media === false ? undefined : configuration.media\n const bootstrap = Schema.decodeSync(StudioBootstrap)({\n basePath: '/',\n documents: compiled.documents,\n media: {\n enabled: media !== undefined,\n maxUploadBytes: media?.maxUploadBytes ?? DEFAULT_MEDIA_MAX_UPLOAD_BYTES,\n },\n version: '1',\n })\n\n return {\n authoring,\n baseUrl: configuration.baseUrl,\n bootstrap,\n cleanup: {\n enabled: configuration.cleanup !== false,\n initialDelayMillis: cleanup?.initialDelayMillis ?? DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS,\n intervalMillis: cleanup?.intervalMillis ?? DEFAULT_CLEANUP_INTERVAL_MILLIS,\n },\n databaseUrl: configuration.databaseUrl,\n documentModel: compiled.documentModel,\n initialSources: compiled.initialSources,\n initializationToken: configuration.initializationToken,\n ...(media === undefined\n ? undefined\n : {\n media: {\n publicBaseUrl: media.publicBaseUrl,\n ...media.storage,\n forcePathStyle: media.storage.forcePathStyle ?? false,\n provisionBucket: media.storage.provisionBucket ?? false,\n },\n }),\n secret: configuration.secret,\n }\n}\n"],"mappings":";;;;;;;AAWA,MAAM,kCAAkC;AACxC,MAAM,uCAAuC;AAC7C,MAAM,iCAAiC;AAEvC,MAAM,iBAAiB,OAAO,YAAY,OAAO,cAAc;AAC/D,MAAM,4BAA4B,OAAO,OAAO;CAC9C,SAASA;CACT,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,aAAa,OAAO;CACpB,qBAAqB,OAAO,eAAe,MAAM,OAAO,YAAY,EAAE,CAAC;CACvE,OAAO,OAAO,YACZ,OAAO,MAAM,CACX,OAAO,SAA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AO,WAAW,eAAe,CAAC,CAAC;EACnD,UAAU;EACV,WAAW,SAAS;EACpB,OAAO;GACL,SAAS,UAAU;GACnB,gBAAgB,OAAO,kBAAkB;EAC3C;EACA,SAAS;CACX,CAAC;CAED,OAAO;EACL;EACA,SAAS,cAAc;EACvB;EACA,SAAS;GACP,SAAS,cAAc,YAAY;GACnC,oBAAoB,SAAS,sBAAsB;GACnD,gBAAgB,SAAS,kBAAkB;EAC7C;EACA,aAAa,cAAc;EAC3B,eAAe,SAAS;EACxB,gBAAgB,SAAS;EACzB,qBAAqB,cAAc;EACnC,GAAI,UAAU,SACV,SACA,EACE,OAAO;GACL,eAAe,MAAM;GACrB,GAAG,MAAM;GACT,gBAAgB,MAAM,QAAQ,kBAAkB;GAChD,iBAAiB,MAAM,QAAQ,mBAAmB;EACpD,EACF;EACJ,QAAQ,cAAc;CACxB;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { FIELD_INPUT_METADATA } from "./field-metadata.js";
2
- import { t as createDocumentEngine } from "../DocumentEngine-Da0kWotL.js";
3
- import { n as DocumentConfiguration } from "../Configuration-BGYFD2N1.js";
2
+ import { t as createDocumentEngine } from "../DocumentEngine-DYObwMDY.js";
3
+ import { r as DocumentConfiguration } from "../Configuration-DyKo0sLS.js";
4
4
  import { Effect, Result, Schema } from "effect";
5
5
  import { z } from "zod";
6
6
 
@@ -58,6 +58,7 @@ function compileCollection(collection, options) {
58
58
  return {
59
59
  authoring: {
60
60
  addressPattern: options.route,
61
+ ...options.body === void 0 ? void 0 : { body: options.body },
61
62
  authoringFields: compileAuthoringFields(input, `${path}.schema`),
62
63
  canCreate: options.canCreate ?? true,
63
64
  collection,