@wp-typia/project-tools 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/dist/runtime/ai-feature-artifacts.js +4 -1
  2. package/dist/runtime/block-generator-service-spec.js +2 -1
  3. package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
  4. package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
  5. package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
  6. package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
  7. package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
  8. package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
  9. package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
  10. package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
  11. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
  12. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
  13. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
  14. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
  15. package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
  16. package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
  17. package/dist/runtime/cli-add-block-json.js +5 -1
  18. package/dist/runtime/cli-add-collision.js +8 -0
  19. package/dist/runtime/cli-add-help.js +14 -10
  20. package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
  21. package/dist/runtime/cli-add-kind-ids.js +1 -0
  22. package/dist/runtime/cli-add-types.d.ts +45 -6
  23. package/dist/runtime/cli-add-types.js +2 -0
  24. package/dist/runtime/cli-add-validation.d.ts +7 -0
  25. package/dist/runtime/cli-add-validation.js +9 -0
  26. package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
  27. package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
  28. package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
  29. package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
  30. package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
  31. package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -308
  32. package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +6 -2
  33. package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.d.ts +34 -0
  34. package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.js +483 -0
  35. package/dist/runtime/cli-add-workspace-admin-view-templates-default.d.ts +30 -0
  36. package/dist/runtime/cli-add-workspace-admin-view-templates-default.js +310 -0
  37. package/dist/runtime/cli-add-workspace-admin-view-templates-rest.d.ts +25 -0
  38. package/dist/runtime/cli-add-workspace-admin-view-templates-rest.js +124 -0
  39. package/dist/runtime/cli-add-workspace-admin-view-templates-settings.d.ts +34 -0
  40. package/dist/runtime/cli-add-workspace-admin-view-templates-settings.js +370 -0
  41. package/dist/runtime/cli-add-workspace-admin-view-templates-shared.d.ts +49 -0
  42. package/dist/runtime/cli-add-workspace-admin-view-templates-shared.js +259 -0
  43. package/dist/runtime/cli-add-workspace-admin-view-templates.d.ts +18 -27
  44. package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
  45. package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
  46. package/dist/runtime/cli-add-workspace-ai-anchors.js +8 -233
  47. package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
  48. package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
  49. package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -129
  50. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
  51. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
  52. package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
  53. package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
  54. package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
  55. package/dist/runtime/cli-add-workspace-assets.js +6 -950
  56. package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
  57. package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
  58. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
  59. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
  60. package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
  61. package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
  62. package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
  63. package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
  64. package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
  65. package/dist/runtime/cli-add-workspace-block-style.js +148 -0
  66. package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
  67. package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
  68. package/dist/runtime/cli-add-workspace-contract.js +1 -1
  69. package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
  70. package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
  71. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
  72. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
  73. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
  74. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
  75. package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
  76. package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
  77. package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
  78. package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
  79. package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
  80. package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
  81. package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
  82. package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
  83. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
  84. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
  85. package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
  86. package/dist/runtime/cli-add-workspace-integration-env.js +10 -313
  87. package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
  88. package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
  89. package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
  90. package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
  91. package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
  92. package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
  93. package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
  94. package/dist/runtime/cli-add-workspace-pattern.js +99 -0
  95. package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
  96. package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
  97. package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
  98. package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +9 -4
  99. package/dist/runtime/cli-add-workspace-rest-anchors.js +9 -428
  100. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
  101. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
  102. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
  103. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
  104. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
  105. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
  106. package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
  107. package/dist/runtime/cli-add-workspace-rest-generated.js +160 -0
  108. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
  109. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
  110. package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
  111. package/dist/runtime/cli-add-workspace-rest-manual.js +266 -0
  112. package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +18 -0
  113. package/dist/runtime/cli-add-workspace-rest-php-templates.js +359 -0
  114. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
  115. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
  116. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
  117. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
  118. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
  119. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
  120. package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -91
  121. package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -642
  122. package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
  123. package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
  124. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
  125. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
  126. package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
  127. package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
  128. package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
  129. package/dist/runtime/cli-add-workspace-rest.js +33 -788
  130. package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
  131. package/dist/runtime/cli-add-workspace-variation.js +162 -0
  132. package/dist/runtime/cli-add-workspace.d.ts +42 -107
  133. package/dist/runtime/cli-add-workspace.js +42 -674
  134. package/dist/runtime/cli-add.d.ts +3 -3
  135. package/dist/runtime/cli-add.js +2 -2
  136. package/dist/runtime/cli-core.d.ts +3 -2
  137. package/dist/runtime/cli-core.js +2 -2
  138. package/dist/runtime/cli-diagnostics.d.ts +3 -1
  139. package/dist/runtime/cli-diagnostics.js +17 -5
  140. package/dist/runtime/cli-doctor-workspace-bindings.js +63 -1
  141. package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
  142. package/dist/runtime/cli-doctor-workspace-block-addons.js +162 -0
  143. package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
  144. package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
  145. package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
  146. package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
  147. package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
  148. package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
  149. package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
  150. package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
  151. package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
  152. package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
  153. package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
  154. package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
  155. package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
  156. package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
  157. package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
  158. package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
  159. package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
  160. package/dist/runtime/cli-doctor-workspace-features.js +14 -487
  161. package/dist/runtime/cli-doctor.d.ts +54 -3
  162. package/dist/runtime/cli-doctor.js +92 -10
  163. package/dist/runtime/cli-help.js +12 -7
  164. package/dist/runtime/cli-init-package-json.js +4 -2
  165. package/dist/runtime/cli-prompt.d.ts +16 -2
  166. package/dist/runtime/cli-prompt.js +29 -12
  167. package/dist/runtime/cli-scaffold.d.ts +2 -1
  168. package/dist/runtime/cli-scaffold.js +19 -10
  169. package/dist/runtime/external-template-guards.js +4 -6
  170. package/dist/runtime/index.d.ts +6 -3
  171. package/dist/runtime/index.js +4 -2
  172. package/dist/runtime/json-utils.d.ts +62 -4
  173. package/dist/runtime/json-utils.js +78 -4
  174. package/dist/runtime/local-dev-presets.js +6 -2
  175. package/dist/runtime/migration-ui-capability.js +4 -1
  176. package/dist/runtime/migration-utils.js +4 -1
  177. package/dist/runtime/package-managers.js +6 -1
  178. package/dist/runtime/package-versions.d.ts +1 -0
  179. package/dist/runtime/package-versions.js +16 -3
  180. package/dist/runtime/pattern-catalog.d.ts +122 -0
  181. package/dist/runtime/pattern-catalog.js +471 -0
  182. package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
  183. package/dist/runtime/post-meta-binding-fields.js +135 -0
  184. package/dist/runtime/scaffold-bootstrap.js +7 -2
  185. package/dist/runtime/scaffold-package-manager-files.js +5 -1
  186. package/dist/runtime/scaffold-repository-reference.js +4 -2
  187. package/dist/runtime/scaffold-template-variables.js +2 -1
  188. package/dist/runtime/scaffold.d.ts +18 -1
  189. package/dist/runtime/scaffold.js +55 -2
  190. package/dist/runtime/temp-roots.js +4 -1
  191. package/dist/runtime/template-layers.js +4 -1
  192. package/dist/runtime/template-registry.js +9 -3
  193. package/dist/runtime/template-source-contracts.d.ts +2 -0
  194. package/dist/runtime/template-source-normalization.js +2 -1
  195. package/dist/runtime/template-source-remote.js +18 -5
  196. package/dist/runtime/template-source-seeds.js +10 -3
  197. package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
  198. package/dist/runtime/typia-llm-json-schema.js +33 -0
  199. package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
  200. package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
  201. package/dist/runtime/typia-llm-projection.d.ts +25 -0
  202. package/dist/runtime/typia-llm-projection.js +58 -0
  203. package/dist/runtime/typia-llm-render.d.ts +21 -0
  204. package/dist/runtime/typia-llm-render.js +252 -0
  205. package/dist/runtime/typia-llm-sync.d.ts +10 -0
  206. package/dist/runtime/typia-llm-sync.js +63 -0
  207. package/dist/runtime/typia-llm-types.d.ts +197 -0
  208. package/dist/runtime/typia-llm-types.js +1 -0
  209. package/dist/runtime/typia-llm.d.ts +9 -255
  210. package/dist/runtime/typia-llm.js +5 -634
  211. package/dist/runtime/workspace-inventory-mutations.js +15 -1
  212. package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
  213. package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
  214. package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
  215. package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
  216. package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
  217. package/dist/runtime/workspace-inventory-parser.js +3 -581
  218. package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
  219. package/dist/runtime/workspace-inventory-section-descriptors.js +443 -0
  220. package/dist/runtime/workspace-inventory-templates.d.ts +3 -3
  221. package/dist/runtime/workspace-inventory-templates.js +10 -1
  222. package/dist/runtime/workspace-inventory-types.d.ts +10 -1
  223. package/dist/runtime/workspace-project.js +4 -6
  224. package/package.json +8 -3
  225. package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
  226. package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
  227. package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
  228. package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
@@ -0,0 +1,157 @@
1
+ import ts from "typescript";
2
+ import { getPropertyNameText } from "./ts-property-names.js";
3
+ import { assertParsedInventoryEntry, } from "./workspace-inventory-parser-validation.js";
4
+ function findExportedArrayLiteral(sourceFile, exportName) {
5
+ for (const statement of sourceFile.statements) {
6
+ if (!ts.isVariableStatement(statement)) {
7
+ continue;
8
+ }
9
+ if (!statement.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)) {
10
+ continue;
11
+ }
12
+ for (const declaration of statement.declarationList.declarations) {
13
+ if (!ts.isIdentifier(declaration.name) ||
14
+ declaration.name.text !== exportName) {
15
+ continue;
16
+ }
17
+ if (declaration.initializer &&
18
+ ts.isArrayLiteralExpression(declaration.initializer)) {
19
+ return {
20
+ array: declaration.initializer,
21
+ found: true,
22
+ };
23
+ }
24
+ return {
25
+ array: null,
26
+ found: true,
27
+ };
28
+ }
29
+ }
30
+ return {
31
+ array: null,
32
+ found: false,
33
+ };
34
+ }
35
+ function getOptionalStringProperty(entryName, elementIndex, objectLiteral, key) {
36
+ for (const property of objectLiteral.properties) {
37
+ if (!ts.isPropertyAssignment(property)) {
38
+ continue;
39
+ }
40
+ const propertyName = getPropertyNameText(property.name);
41
+ if (propertyName !== key) {
42
+ continue;
43
+ }
44
+ if (ts.isStringLiteralLike(property.initializer)) {
45
+ return property.initializer.text;
46
+ }
47
+ throw new Error(`${entryName}[${elementIndex}] must use a string literal for "${key}" in scripts/block-config.ts.`);
48
+ }
49
+ return undefined;
50
+ }
51
+ function getOptionalStringArrayProperty(entryName, elementIndex, objectLiteral, key) {
52
+ for (const property of objectLiteral.properties) {
53
+ if (!ts.isPropertyAssignment(property)) {
54
+ continue;
55
+ }
56
+ const propertyName = getPropertyNameText(property.name);
57
+ if (propertyName !== key) {
58
+ continue;
59
+ }
60
+ if (!ts.isArrayLiteralExpression(property.initializer)) {
61
+ throw new Error(`${entryName}[${elementIndex}] must use an array literal for "${key}" in scripts/block-config.ts.`);
62
+ }
63
+ return property.initializer.elements.map((element, itemIndex) => {
64
+ if (!ts.isStringLiteralLike(element)) {
65
+ throw new Error(`${entryName}[${elementIndex}].${key}[${itemIndex}] must use a string literal in scripts/block-config.ts.`);
66
+ }
67
+ return element.text;
68
+ });
69
+ }
70
+ return undefined;
71
+ }
72
+ function getOptionalBooleanProperty(entryName, elementIndex, objectLiteral, key) {
73
+ for (const property of objectLiteral.properties) {
74
+ if (!ts.isPropertyAssignment(property)) {
75
+ continue;
76
+ }
77
+ const propertyName = getPropertyNameText(property.name);
78
+ if (propertyName !== key) {
79
+ continue;
80
+ }
81
+ if (property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
82
+ return true;
83
+ }
84
+ if (property.initializer.kind === ts.SyntaxKind.FalseKeyword) {
85
+ return false;
86
+ }
87
+ throw new Error(`${entryName}[${elementIndex}] must use a boolean literal for "${key}" in scripts/block-config.ts.`);
88
+ }
89
+ return undefined;
90
+ }
91
+ function parseInventoryEntries(arrayLiteral, descriptor) {
92
+ return arrayLiteral.elements.map((element, elementIndex) => {
93
+ if (!ts.isObjectLiteralExpression(element)) {
94
+ throw new Error(`${descriptor.entryName}[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
95
+ }
96
+ const entry = {};
97
+ for (const field of descriptor.fields) {
98
+ const kind = field.kind ?? "string";
99
+ const value = kind === "stringArray"
100
+ ? getOptionalStringArrayProperty(descriptor.entryName, elementIndex, element, field.key)
101
+ : kind === "boolean"
102
+ ? getOptionalBooleanProperty(descriptor.entryName, elementIndex, element, field.key)
103
+ : getOptionalStringProperty(descriptor.entryName, elementIndex, element, field.key);
104
+ field.validate?.(value, {
105
+ elementIndex,
106
+ entryName: descriptor.entryName,
107
+ key: field.key,
108
+ });
109
+ entry[field.key] = value;
110
+ }
111
+ assertParsedInventoryEntry(entry, descriptor, elementIndex);
112
+ return entry;
113
+ });
114
+ }
115
+ /**
116
+ * Parse one descriptor-backed inventory section from a TypeScript source file.
117
+ *
118
+ * The generic `T` is the typed entry shape returned in `entries`. The
119
+ * `descriptor` supplies the exported array name, parser field metadata, and
120
+ * whether the section is required; this helper uses `findExportedArrayLiteral`
121
+ * and `parseInventoryEntries` to guarantee object-literal entries and literal
122
+ * field values. It returns parsed entries plus a `found` flag, and throws when
123
+ * required exports are missing, descriptors cannot resolve an export name, or
124
+ * exported values are not array literals.
125
+ */
126
+ export function parseInventorySection(sourceFile, descriptor) {
127
+ if (!descriptor.parse) {
128
+ return {
129
+ entries: [],
130
+ found: false,
131
+ };
132
+ }
133
+ const exportName = descriptor.parse.exportName ?? descriptor.value?.name;
134
+ if (!exportName) {
135
+ throw new Error("Inventory parser descriptor is missing an export name.");
136
+ }
137
+ const exportedArray = findExportedArrayLiteral(sourceFile, exportName);
138
+ if (!exportedArray.found) {
139
+ if (descriptor.parse.required) {
140
+ throw new Error(`scripts/block-config.ts must export a ${exportName} array.`);
141
+ }
142
+ return {
143
+ entries: [],
144
+ found: false,
145
+ };
146
+ }
147
+ if (!exportedArray.array) {
148
+ if (descriptor.parse.required) {
149
+ throw new Error(`scripts/block-config.ts must export a ${exportName} array.`);
150
+ }
151
+ throw new Error(`scripts/block-config.ts must export ${exportName} as an array literal.`);
152
+ }
153
+ return {
154
+ entries: parseInventoryEntries(exportedArray.array, descriptor.parse.entry),
155
+ found: true,
156
+ };
157
+ }
@@ -0,0 +1,104 @@
1
+ import type { WorkspaceInventoryAppendOptionKey, WorkspaceInventoryEntriesKey, WorkspaceInventorySectionFlagKey } from "./workspace-inventory-types.js";
2
+ /**
3
+ * Literal value shape accepted by descriptor-driven inventory entry fields.
4
+ */
5
+ export type InventoryEntryFieldValue = string | string[] | boolean | undefined;
6
+ /**
7
+ * Context passed to custom field validators while parsing one inventory entry.
8
+ */
9
+ export type InventoryEntryFieldValidationContext = {
10
+ elementIndex: number;
11
+ entryName: string;
12
+ key: string;
13
+ };
14
+ type InventoryEntryFieldDescriptor = {
15
+ key: string;
16
+ kind?: "boolean" | "string" | "stringArray";
17
+ required?: boolean;
18
+ validate?: (value: InventoryEntryFieldValue, context: InventoryEntryFieldValidationContext) => void;
19
+ };
20
+ /**
21
+ * Runtime parser contract for one exported inventory array.
22
+ *
23
+ * `entryName` is used in diagnostics and `fields` defines the literal values,
24
+ * required flags, and custom validators accepted for each object entry.
25
+ */
26
+ export type InventoryEntryParserDescriptor = {
27
+ entryName: string;
28
+ fields: readonly InventoryEntryFieldDescriptor[];
29
+ };
30
+ type RequiredInventoryEntryKey<T extends object> = Extract<{
31
+ [Key in keyof T]-?: undefined extends T[Key] ? never : Key;
32
+ }[keyof T], string>;
33
+ type TypedInventoryEntryFieldDescriptor<T extends object, TKey extends Extract<keyof T, string> = Extract<keyof T, string>> = TKey extends Extract<keyof T, string> ? Omit<InventoryEntryFieldDescriptor, "key" | "required"> & {
34
+ key: TKey;
35
+ } & (TKey extends RequiredInventoryEntryKey<T> ? {
36
+ required: true;
37
+ } : {
38
+ required?: boolean;
39
+ }) : never;
40
+ type RequiredInventoryEntryFieldDescriptor<T extends object> = Omit<InventoryEntryFieldDescriptor, "key" | "required"> & {
41
+ key: RequiredInventoryEntryKey<T>;
42
+ required: true;
43
+ };
44
+ type MissingRequiredInventoryEntryKeys<T extends object, TFields extends readonly TypedInventoryEntryFieldDescriptor<T>[]> = Exclude<RequiredInventoryEntryKey<T>, TFields[number]["key"]>;
45
+ type RequiredInventoryEntryFieldsPresent<T extends object, TFields extends readonly TypedInventoryEntryFieldDescriptor<T>[]> = MissingRequiredInventoryEntryKeys<T, TFields> extends never ? unknown : {
46
+ missingRequiredInventoryEntryFields: MissingRequiredInventoryEntryKeys<T, TFields>;
47
+ };
48
+ type RequiredInventoryEntryFieldsMarkedRequired<T extends object, TFields extends readonly TypedInventoryEntryFieldDescriptor<T>[]> = Extract<TFields[number], {
49
+ key: RequiredInventoryEntryKey<T>;
50
+ }> extends RequiredInventoryEntryFieldDescriptor<T> ? unknown : {
51
+ requiredInventoryEntryFieldsMustSetRequiredTrue: RequiredInventoryEntryKey<T>;
52
+ };
53
+ /**
54
+ * Shared descriptor contract for generated workspace inventory sections.
55
+ *
56
+ * Callers rely on `append` markers when inserting generated entries, `parse`
57
+ * metadata when reading exported arrays, and `interface`/`value` sections when
58
+ * repairing older `scripts/block-config.ts` files.
59
+ */
60
+ export type InventorySectionDescriptor = {
61
+ /** Optional marker metadata used when appending generated entries. */
62
+ append?: {
63
+ marker: string;
64
+ optionKey: WorkspaceInventoryAppendOptionKey;
65
+ };
66
+ /** Optional exported interface that backs the inventory section entries. */
67
+ interface?: {
68
+ name: string;
69
+ section: string;
70
+ };
71
+ /** Optional parser metadata for descriptor-driven inventory reads. */
72
+ parse?: {
73
+ entriesKey: WorkspaceInventoryEntriesKey;
74
+ entry: InventoryEntryParserDescriptor;
75
+ exportName?: string;
76
+ hasSectionKey?: WorkspaceInventorySectionFlagKey;
77
+ required?: boolean;
78
+ };
79
+ /** Optional exported const array that stores the inventory section entries. */
80
+ value?: {
81
+ name: string;
82
+ section: string;
83
+ };
84
+ };
85
+ /**
86
+ * Define a typed inventory entry parser while enforcing required fields at
87
+ * compile time.
88
+ *
89
+ * The returned descriptor is consumed by `parseInventorySection` to extract
90
+ * literal field values and run runtime validators.
91
+ */
92
+ export declare function defineInventoryEntryParser<T extends object>(): <const TFields extends readonly TypedInventoryEntryFieldDescriptor<T>[]>(descriptor: {
93
+ entryName: string;
94
+ fields: TFields;
95
+ } & RequiredInventoryEntryFieldsPresent<T, TFields> & RequiredInventoryEntryFieldsMarkedRequired<T, TFields>) => InventoryEntryParserDescriptor;
96
+ /**
97
+ * Assert that a parsed inventory entry contains every required descriptor
98
+ * field.
99
+ *
100
+ * Missing `undefined` values and empty strings throw with diagnostics tied to
101
+ * the original exported inventory array name and element index.
102
+ */
103
+ export declare function assertParsedInventoryEntry<T extends object>(entry: Record<string, InventoryEntryFieldValue>, descriptor: InventoryEntryParserDescriptor, elementIndex: number): asserts entry is Record<string, InventoryEntryFieldValue> & T;
104
+ export {};
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Define a typed inventory entry parser while enforcing required fields at
3
+ * compile time.
4
+ *
5
+ * The returned descriptor is consumed by `parseInventorySection` to extract
6
+ * literal field values and run runtime validators.
7
+ */
8
+ export function defineInventoryEntryParser() {
9
+ return (descriptor) => descriptor;
10
+ }
11
+ function isMissingRequiredInventoryValue(value) {
12
+ return (value === undefined || (typeof value === "string" && value.length === 0));
13
+ }
14
+ function formatMissingRequiredInventoryFields(keys) {
15
+ return keys.length === 1
16
+ ? `required "${keys[0]}"`
17
+ : `required fields ${keys.map((key) => `"${key}"`).join(", ")}`;
18
+ }
19
+ /**
20
+ * Assert that a parsed inventory entry contains every required descriptor
21
+ * field.
22
+ *
23
+ * Missing `undefined` values and empty strings throw with diagnostics tied to
24
+ * the original exported inventory array name and element index.
25
+ */
26
+ export function assertParsedInventoryEntry(entry, descriptor, elementIndex) {
27
+ const missingRequiredKeys = descriptor.fields
28
+ .filter((field) => field.required === true &&
29
+ isMissingRequiredInventoryValue(entry[field.key]))
30
+ .map((field) => field.key);
31
+ if (missingRequiredKeys.length > 0) {
32
+ throw new Error(`${descriptor.entryName}[${elementIndex}] is missing ${formatMissingRequiredInventoryFields(missingRequiredKeys)} in scripts/block-config.ts.`);
33
+ }
34
+ }
@@ -1,47 +1,6 @@
1
- import type { WorkspaceInventory, WorkspaceInventoryAppendOptionKey, WorkspaceInventoryEntriesKey, WorkspaceInventorySectionFlagKey } from "./workspace-inventory-types.js";
2
- type InventoryEntryFieldValue = string | string[] | boolean | undefined;
3
- type InventoryEntryFieldValidationContext = {
4
- elementIndex: number;
5
- entryName: string;
6
- key: string;
7
- };
8
- type InventoryEntryFieldDescriptor = {
9
- key: string;
10
- kind?: "boolean" | "string" | "stringArray";
11
- required?: boolean;
12
- validate?: (value: InventoryEntryFieldValue, context: InventoryEntryFieldValidationContext) => void;
13
- };
14
- type InventoryEntryParserDescriptor = {
15
- entryName: string;
16
- fields: readonly InventoryEntryFieldDescriptor[];
17
- };
18
- export type InventorySectionDescriptor = {
19
- /** Optional marker metadata used when appending generated entries. */
20
- append?: {
21
- marker: string;
22
- optionKey: WorkspaceInventoryAppendOptionKey;
23
- };
24
- /** Optional exported interface that backs the inventory section entries. */
25
- interface?: {
26
- name: string;
27
- section: string;
28
- };
29
- /** Optional parser metadata for descriptor-driven inventory reads. */
30
- parse?: {
31
- entriesKey: WorkspaceInventoryEntriesKey;
32
- entry: InventoryEntryParserDescriptor;
33
- exportName?: string;
34
- hasSectionKey?: WorkspaceInventorySectionFlagKey;
35
- required?: boolean;
36
- };
37
- /** Optional exported const array that stores the inventory section entries. */
38
- value?: {
39
- name: string;
40
- section: string;
41
- };
42
- };
43
- export declare const BLOCK_INVENTORY_SECTION: InventorySectionDescriptor;
44
- export declare const INVENTORY_SECTIONS: readonly InventorySectionDescriptor[];
1
+ import type { WorkspaceInventory } from "./workspace-inventory-types.js";
2
+ export { BLOCK_INVENTORY_SECTION, INVENTORY_SECTIONS, } from "./workspace-inventory-section-descriptors.js";
3
+ export type { InventorySectionDescriptor } from "./workspace-inventory-parser-validation.js";
45
4
  /**
46
5
  * Parse workspace inventory entries from the source of `scripts/block-config.ts`.
47
6
  *
@@ -50,4 +9,3 @@ export declare const INVENTORY_SECTIONS: readonly InventorySectionDescriptor[];
50
9
  * @throws {Error} When `BLOCKS` is missing or any inventory entry is malformed.
51
10
  */
52
11
  export declare function parseWorkspaceInventorySource(source: string): Omit<WorkspaceInventory, "blockConfigPath">;
53
- export {};