@wp-typia/project-tools 0.23.0 → 0.23.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.
- package/dist/runtime/ai-feature-artifacts.js +4 -1
- package/dist/runtime/block-generator-service-spec.js +2 -1
- package/dist/runtime/cli-add-block-json.js +5 -1
- package/dist/runtime/cli-add-help.js +4 -3
- package/dist/runtime/cli-add-types.d.ts +18 -6
- package/dist/runtime/cli-add-validation.d.ts +7 -0
- package/dist/runtime/cli-add-validation.js +9 -0
- package/dist/runtime/cli-add-workspace-ability-scaffold.js +4 -1
- package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +5 -1
- package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.js +483 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-default.d.ts +30 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-default.js +310 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-rest.d.ts +25 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-rest.js +124 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-settings.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-settings.js +370 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-shared.d.ts +49 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-shared.js +259 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates.d.ts +18 -27
- package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
- package/dist/runtime/cli-add-workspace-ai-anchors.js +4 -1
- package/dist/runtime/cli-add-workspace-ai-source-emitters.js +17 -1
- package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
- package/dist/runtime/cli-add-workspace-integration-env.js +42 -5
- package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.js +41 -0
- package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-generated.js +158 -0
- package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-rest-manual.js +279 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +24 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.js +678 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +25 -4
- package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
- package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
- package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
- package/dist/runtime/cli-add-workspace-rest.js +33 -788
- package/dist/runtime/cli-core.d.ts +1 -1
- package/dist/runtime/cli-core.js +1 -1
- package/dist/runtime/cli-diagnostics.d.ts +3 -1
- package/dist/runtime/cli-diagnostics.js +17 -5
- package/dist/runtime/cli-doctor-workspace-bindings.js +4 -1
- package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
- package/dist/runtime/cli-doctor-workspace-block-addons.js +134 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
- package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
- package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
- package/dist/runtime/cli-doctor-workspace-features.js +14 -487
- package/dist/runtime/cli-doctor.d.ts +52 -3
- package/dist/runtime/cli-doctor.js +79 -8
- package/dist/runtime/cli-help.js +6 -3
- package/dist/runtime/cli-init-package-json.js +4 -2
- package/dist/runtime/cli-prompt.d.ts +16 -2
- package/dist/runtime/cli-prompt.js +29 -12
- package/dist/runtime/cli-scaffold.d.ts +2 -1
- package/dist/runtime/cli-scaffold.js +19 -10
- package/dist/runtime/external-template-guards.js +4 -6
- package/dist/runtime/index.d.ts +2 -2
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/json-utils.d.ts +62 -4
- package/dist/runtime/json-utils.js +78 -4
- package/dist/runtime/local-dev-presets.js +4 -1
- package/dist/runtime/migration-ui-capability.js +4 -1
- package/dist/runtime/migration-utils.js +4 -1
- package/dist/runtime/package-managers.js +6 -1
- package/dist/runtime/package-versions.js +6 -1
- package/dist/runtime/scaffold-bootstrap.js +7 -2
- package/dist/runtime/scaffold-package-manager-files.js +5 -1
- package/dist/runtime/scaffold-repository-reference.js +4 -2
- package/dist/runtime/scaffold-template-variables.js +2 -1
- package/dist/runtime/scaffold.d.ts +18 -1
- package/dist/runtime/scaffold.js +55 -2
- package/dist/runtime/temp-roots.js +4 -1
- package/dist/runtime/template-layers.js +4 -1
- package/dist/runtime/template-registry.js +9 -3
- package/dist/runtime/template-source-contracts.d.ts +2 -0
- package/dist/runtime/template-source-normalization.js +2 -1
- package/dist/runtime/template-source-remote.js +18 -5
- package/dist/runtime/template-source-seeds.js +10 -3
- package/dist/runtime/workspace-inventory-mutations.js +2 -1
- package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
- package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
- package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
- package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
- package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
- package/dist/runtime/workspace-inventory-parser.js +3 -581
- package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
- package/dist/runtime/workspace-inventory-section-descriptors.js +435 -0
- package/dist/runtime/workspace-inventory-templates.d.ts +1 -1
- package/dist/runtime/workspace-inventory-templates.js +1 -0
- package/dist/runtime/workspace-inventory-types.d.ts +1 -0
- package/dist/runtime/workspace-project.js +4 -6
- package/package.json +2 -2
|
@@ -1,585 +1,7 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
function defineInventoryEntryParser() {
|
|
6
|
-
return (descriptor) => descriptor;
|
|
7
|
-
}
|
|
8
|
-
export const BLOCK_INVENTORY_SECTION = {
|
|
9
|
-
append: {
|
|
10
|
-
marker: BLOCK_CONFIG_ENTRY_MARKER,
|
|
11
|
-
optionKey: "blockEntries",
|
|
12
|
-
},
|
|
13
|
-
parse: {
|
|
14
|
-
entriesKey: "blocks",
|
|
15
|
-
entry: defineInventoryEntryParser()({
|
|
16
|
-
entryName: "BLOCKS",
|
|
17
|
-
fields: [
|
|
18
|
-
{ key: "apiTypesFile" },
|
|
19
|
-
{ key: "attributeTypeName" },
|
|
20
|
-
{ key: "openApiFile" },
|
|
21
|
-
{ key: "slug", required: true },
|
|
22
|
-
{ key: "typesFile", required: true },
|
|
23
|
-
],
|
|
24
|
-
}),
|
|
25
|
-
exportName: "BLOCKS",
|
|
26
|
-
required: true,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
export const INVENTORY_SECTIONS = [
|
|
30
|
-
{
|
|
31
|
-
append: {
|
|
32
|
-
marker: VARIATION_CONFIG_ENTRY_MARKER,
|
|
33
|
-
optionKey: "variationEntries",
|
|
34
|
-
},
|
|
35
|
-
interface: {
|
|
36
|
-
name: "WorkspaceVariationConfig",
|
|
37
|
-
section: VARIATIONS_INTERFACE_SECTION,
|
|
38
|
-
},
|
|
39
|
-
parse: {
|
|
40
|
-
entriesKey: "variations",
|
|
41
|
-
entry: defineInventoryEntryParser()({
|
|
42
|
-
entryName: "VARIATIONS",
|
|
43
|
-
fields: [
|
|
44
|
-
{ key: "block", required: true },
|
|
45
|
-
{ key: "file", required: true },
|
|
46
|
-
{ key: "slug", required: true },
|
|
47
|
-
],
|
|
48
|
-
}),
|
|
49
|
-
hasSectionKey: "hasVariationsSection",
|
|
50
|
-
},
|
|
51
|
-
value: {
|
|
52
|
-
name: "VARIATIONS",
|
|
53
|
-
section: VARIATIONS_CONST_SECTION,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
append: {
|
|
58
|
-
marker: BLOCK_STYLE_CONFIG_ENTRY_MARKER,
|
|
59
|
-
optionKey: "blockStyleEntries",
|
|
60
|
-
},
|
|
61
|
-
interface: {
|
|
62
|
-
name: "WorkspaceBlockStyleConfig",
|
|
63
|
-
section: BLOCK_STYLES_INTERFACE_SECTION,
|
|
64
|
-
},
|
|
65
|
-
parse: {
|
|
66
|
-
entriesKey: "blockStyles",
|
|
67
|
-
entry: defineInventoryEntryParser()({
|
|
68
|
-
entryName: "BLOCK_STYLES",
|
|
69
|
-
fields: [
|
|
70
|
-
{ key: "block", required: true },
|
|
71
|
-
{ key: "file", required: true },
|
|
72
|
-
{ key: "slug", required: true },
|
|
73
|
-
],
|
|
74
|
-
}),
|
|
75
|
-
hasSectionKey: "hasBlockStylesSection",
|
|
76
|
-
},
|
|
77
|
-
value: {
|
|
78
|
-
name: "BLOCK_STYLES",
|
|
79
|
-
section: BLOCK_STYLES_CONST_SECTION,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
append: {
|
|
84
|
-
marker: BLOCK_TRANSFORM_CONFIG_ENTRY_MARKER,
|
|
85
|
-
optionKey: "blockTransformEntries",
|
|
86
|
-
},
|
|
87
|
-
interface: {
|
|
88
|
-
name: "WorkspaceBlockTransformConfig",
|
|
89
|
-
section: BLOCK_TRANSFORMS_INTERFACE_SECTION,
|
|
90
|
-
},
|
|
91
|
-
parse: {
|
|
92
|
-
entriesKey: "blockTransforms",
|
|
93
|
-
entry: defineInventoryEntryParser()({
|
|
94
|
-
entryName: "BLOCK_TRANSFORMS",
|
|
95
|
-
fields: [
|
|
96
|
-
{ key: "block", required: true },
|
|
97
|
-
{ key: "file", required: true },
|
|
98
|
-
{ key: "from", required: true },
|
|
99
|
-
{ key: "slug", required: true },
|
|
100
|
-
{ key: "to", required: true },
|
|
101
|
-
],
|
|
102
|
-
}),
|
|
103
|
-
hasSectionKey: "hasBlockTransformsSection",
|
|
104
|
-
},
|
|
105
|
-
value: {
|
|
106
|
-
name: "BLOCK_TRANSFORMS",
|
|
107
|
-
section: BLOCK_TRANSFORMS_CONST_SECTION,
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
append: {
|
|
112
|
-
marker: PATTERN_CONFIG_ENTRY_MARKER,
|
|
113
|
-
optionKey: "patternEntries",
|
|
114
|
-
},
|
|
115
|
-
interface: {
|
|
116
|
-
name: "WorkspacePatternConfig",
|
|
117
|
-
section: PATTERNS_INTERFACE_SECTION,
|
|
118
|
-
},
|
|
119
|
-
parse: {
|
|
120
|
-
entriesKey: "patterns",
|
|
121
|
-
entry: defineInventoryEntryParser()({
|
|
122
|
-
entryName: "PATTERNS",
|
|
123
|
-
fields: [
|
|
124
|
-
{ key: "file", required: true },
|
|
125
|
-
{ key: "slug", required: true },
|
|
126
|
-
],
|
|
127
|
-
}),
|
|
128
|
-
hasSectionKey: "hasPatternsSection",
|
|
129
|
-
},
|
|
130
|
-
value: {
|
|
131
|
-
name: "PATTERNS",
|
|
132
|
-
section: PATTERNS_CONST_SECTION,
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
append: {
|
|
137
|
-
marker: BINDING_SOURCE_CONFIG_ENTRY_MARKER,
|
|
138
|
-
optionKey: "bindingSourceEntries",
|
|
139
|
-
},
|
|
140
|
-
interface: {
|
|
141
|
-
name: "WorkspaceBindingSourceConfig",
|
|
142
|
-
section: BINDING_SOURCES_INTERFACE_SECTION,
|
|
143
|
-
},
|
|
144
|
-
parse: {
|
|
145
|
-
entriesKey: "bindingSources",
|
|
146
|
-
entry: defineInventoryEntryParser()({
|
|
147
|
-
entryName: "BINDING_SOURCES",
|
|
148
|
-
fields: [
|
|
149
|
-
{ key: "attribute" },
|
|
150
|
-
{ key: "block" },
|
|
151
|
-
{ key: "editorFile", required: true },
|
|
152
|
-
{ key: "serverFile", required: true },
|
|
153
|
-
{ key: "slug", required: true },
|
|
154
|
-
],
|
|
155
|
-
}),
|
|
156
|
-
hasSectionKey: "hasBindingSourcesSection",
|
|
157
|
-
},
|
|
158
|
-
value: {
|
|
159
|
-
name: "BINDING_SOURCES",
|
|
160
|
-
section: BINDING_SOURCES_CONST_SECTION,
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
append: {
|
|
165
|
-
marker: CONTRACT_CONFIG_ENTRY_MARKER,
|
|
166
|
-
optionKey: "contractEntries",
|
|
167
|
-
},
|
|
168
|
-
interface: {
|
|
169
|
-
name: "WorkspaceContractConfig",
|
|
170
|
-
section: CONTRACTS_INTERFACE_SECTION,
|
|
171
|
-
},
|
|
172
|
-
parse: {
|
|
173
|
-
entriesKey: "contracts",
|
|
174
|
-
entry: defineInventoryEntryParser()({
|
|
175
|
-
entryName: "CONTRACTS",
|
|
176
|
-
fields: [
|
|
177
|
-
{ key: "schemaFile", required: true },
|
|
178
|
-
{ key: "slug", required: true },
|
|
179
|
-
{ key: "sourceTypeName", required: true },
|
|
180
|
-
{ key: "typesFile", required: true },
|
|
181
|
-
],
|
|
182
|
-
}),
|
|
183
|
-
hasSectionKey: "hasContractsSection",
|
|
184
|
-
},
|
|
185
|
-
value: {
|
|
186
|
-
name: "CONTRACTS",
|
|
187
|
-
section: CONTRACTS_CONST_SECTION,
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
append: {
|
|
192
|
-
marker: REST_RESOURCE_CONFIG_ENTRY_MARKER,
|
|
193
|
-
optionKey: "restResourceEntries",
|
|
194
|
-
},
|
|
195
|
-
interface: {
|
|
196
|
-
name: "WorkspaceRestResourceConfig",
|
|
197
|
-
section: REST_RESOURCES_INTERFACE_SECTION,
|
|
198
|
-
},
|
|
199
|
-
parse: {
|
|
200
|
-
entriesKey: "restResources",
|
|
201
|
-
entry: defineInventoryEntryParser()({
|
|
202
|
-
entryName: "REST_RESOURCES",
|
|
203
|
-
fields: [
|
|
204
|
-
{ key: "apiFile", required: true },
|
|
205
|
-
{
|
|
206
|
-
key: "auth",
|
|
207
|
-
validate: (value, context) => {
|
|
208
|
-
if (typeof value === "string" &&
|
|
209
|
-
!MANUAL_REST_CONTRACT_AUTH_IDS.includes(value)) {
|
|
210
|
-
throw new Error(`${context.entryName}[${context.elementIndex}].${context.key} must be one of: ${MANUAL_REST_CONTRACT_AUTH_IDS.join(", ")}.`);
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
{ key: "bodyTypeName" },
|
|
215
|
-
{ key: "clientFile", required: true },
|
|
216
|
-
{ key: "controllerClass" },
|
|
217
|
-
{ key: "controllerExtends" },
|
|
218
|
-
{ key: "dataFile" },
|
|
219
|
-
{
|
|
220
|
-
key: "method",
|
|
221
|
-
validate: (value, context) => {
|
|
222
|
-
if (typeof value === "string" &&
|
|
223
|
-
!MANUAL_REST_CONTRACT_HTTP_METHOD_IDS.includes(value)) {
|
|
224
|
-
throw new Error(`${context.entryName}[${context.elementIndex}].${context.key} must be one of: ${MANUAL_REST_CONTRACT_HTTP_METHOD_IDS.join(", ")}.`);
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
key: "methods",
|
|
230
|
-
kind: "stringArray",
|
|
231
|
-
required: true,
|
|
232
|
-
validate: (value, context) => {
|
|
233
|
-
const methods = Array.isArray(value) ? value : [];
|
|
234
|
-
const invalidMethods = methods.filter((method) => !REST_RESOURCE_METHOD_IDS.includes(method));
|
|
235
|
-
if (invalidMethods.length > 0) {
|
|
236
|
-
throw new Error(`${context.entryName}[${context.elementIndex}].${context.key} includes unsupported values: ${invalidMethods.join(", ")}.`);
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
key: "mode",
|
|
242
|
-
validate: (value, context) => {
|
|
243
|
-
if (typeof value === "string" &&
|
|
244
|
-
value !== "generated" &&
|
|
245
|
-
value !== "manual") {
|
|
246
|
-
throw new Error(`${context.entryName}[${context.elementIndex}].${context.key} must be generated or manual.`);
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
{ key: "namespace", required: true },
|
|
251
|
-
{ key: "openApiFile", required: true },
|
|
252
|
-
{ key: "pathPattern" },
|
|
253
|
-
{ key: "permissionCallback" },
|
|
254
|
-
{ key: "phpFile" },
|
|
255
|
-
{ key: "queryTypeName" },
|
|
256
|
-
{ key: "responseTypeName" },
|
|
257
|
-
{ key: "routePattern" },
|
|
258
|
-
{ key: "secretFieldName" },
|
|
259
|
-
{ key: "secretStateFieldName" },
|
|
260
|
-
{ key: "slug", required: true },
|
|
261
|
-
{ key: "typesFile", required: true },
|
|
262
|
-
{ key: "validatorsFile", required: true },
|
|
263
|
-
],
|
|
264
|
-
}),
|
|
265
|
-
hasSectionKey: "hasRestResourcesSection",
|
|
266
|
-
},
|
|
267
|
-
value: {
|
|
268
|
-
name: "REST_RESOURCES",
|
|
269
|
-
section: REST_RESOURCES_CONST_SECTION,
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
append: {
|
|
274
|
-
marker: POST_META_CONFIG_ENTRY_MARKER,
|
|
275
|
-
optionKey: "postMetaEntries",
|
|
276
|
-
},
|
|
277
|
-
interface: {
|
|
278
|
-
name: "WorkspacePostMetaConfig",
|
|
279
|
-
section: POST_META_INTERFACE_SECTION,
|
|
280
|
-
},
|
|
281
|
-
parse: {
|
|
282
|
-
entriesKey: "postMeta",
|
|
283
|
-
entry: defineInventoryEntryParser()({
|
|
284
|
-
entryName: "POST_META",
|
|
285
|
-
fields: [
|
|
286
|
-
{ key: "metaKey", required: true },
|
|
287
|
-
{ key: "phpFile", required: true },
|
|
288
|
-
{ key: "postType", required: true },
|
|
289
|
-
{ key: "schemaFile", required: true },
|
|
290
|
-
{ key: "showInRest", kind: "boolean", required: true },
|
|
291
|
-
{ key: "slug", required: true },
|
|
292
|
-
{ key: "sourceTypeName", required: true },
|
|
293
|
-
{ key: "typesFile", required: true },
|
|
294
|
-
],
|
|
295
|
-
}),
|
|
296
|
-
hasSectionKey: "hasPostMetaSection",
|
|
297
|
-
},
|
|
298
|
-
value: {
|
|
299
|
-
name: "POST_META",
|
|
300
|
-
section: POST_META_CONST_SECTION,
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
append: {
|
|
305
|
-
marker: ABILITY_CONFIG_ENTRY_MARKER,
|
|
306
|
-
optionKey: "abilityEntries",
|
|
307
|
-
},
|
|
308
|
-
interface: {
|
|
309
|
-
name: "WorkspaceAbilityConfig",
|
|
310
|
-
section: ABILITIES_INTERFACE_SECTION,
|
|
311
|
-
},
|
|
312
|
-
parse: {
|
|
313
|
-
entriesKey: "abilities",
|
|
314
|
-
entry: defineInventoryEntryParser()({
|
|
315
|
-
entryName: "ABILITIES",
|
|
316
|
-
fields: [
|
|
317
|
-
{ key: "clientFile", required: true },
|
|
318
|
-
{ key: "configFile", required: true },
|
|
319
|
-
{ key: "dataFile", required: true },
|
|
320
|
-
{ key: "inputSchemaFile", required: true },
|
|
321
|
-
{ key: "inputTypeName", required: true },
|
|
322
|
-
{ key: "outputSchemaFile", required: true },
|
|
323
|
-
{ key: "outputTypeName", required: true },
|
|
324
|
-
{ key: "phpFile", required: true },
|
|
325
|
-
{ key: "slug", required: true },
|
|
326
|
-
{ key: "typesFile", required: true },
|
|
327
|
-
],
|
|
328
|
-
}),
|
|
329
|
-
hasSectionKey: "hasAbilitiesSection",
|
|
330
|
-
},
|
|
331
|
-
value: {
|
|
332
|
-
name: "ABILITIES",
|
|
333
|
-
section: ABILITIES_CONST_SECTION,
|
|
334
|
-
},
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
append: {
|
|
338
|
-
marker: AI_FEATURE_CONFIG_ENTRY_MARKER,
|
|
339
|
-
optionKey: "aiFeatureEntries",
|
|
340
|
-
},
|
|
341
|
-
interface: {
|
|
342
|
-
name: "WorkspaceAiFeatureConfig",
|
|
343
|
-
section: AI_FEATURES_INTERFACE_SECTION,
|
|
344
|
-
},
|
|
345
|
-
parse: {
|
|
346
|
-
entriesKey: "aiFeatures",
|
|
347
|
-
entry: defineInventoryEntryParser()({
|
|
348
|
-
entryName: "AI_FEATURES",
|
|
349
|
-
fields: [
|
|
350
|
-
{ key: "aiSchemaFile", required: true },
|
|
351
|
-
{ key: "apiFile", required: true },
|
|
352
|
-
{ key: "clientFile", required: true },
|
|
353
|
-
{ key: "dataFile", required: true },
|
|
354
|
-
{ key: "namespace", required: true },
|
|
355
|
-
{ key: "openApiFile", required: true },
|
|
356
|
-
{ key: "phpFile", required: true },
|
|
357
|
-
{ key: "slug", required: true },
|
|
358
|
-
{ key: "typesFile", required: true },
|
|
359
|
-
{ key: "validatorsFile", required: true },
|
|
360
|
-
],
|
|
361
|
-
}),
|
|
362
|
-
hasSectionKey: "hasAiFeaturesSection",
|
|
363
|
-
},
|
|
364
|
-
value: {
|
|
365
|
-
name: "AI_FEATURES",
|
|
366
|
-
section: AI_FEATURES_CONST_SECTION,
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
append: {
|
|
371
|
-
marker: ADMIN_VIEW_CONFIG_ENTRY_MARKER,
|
|
372
|
-
optionKey: "adminViewEntries",
|
|
373
|
-
},
|
|
374
|
-
interface: {
|
|
375
|
-
name: "WorkspaceAdminViewConfig",
|
|
376
|
-
section: ADMIN_VIEWS_INTERFACE_SECTION,
|
|
377
|
-
},
|
|
378
|
-
parse: {
|
|
379
|
-
entriesKey: "adminViews",
|
|
380
|
-
entry: defineInventoryEntryParser()({
|
|
381
|
-
entryName: "ADMIN_VIEWS",
|
|
382
|
-
fields: [
|
|
383
|
-
{ key: "file", required: true },
|
|
384
|
-
{ key: "phpFile", required: true },
|
|
385
|
-
{ key: "slug", required: true },
|
|
386
|
-
{ key: "source" },
|
|
387
|
-
],
|
|
388
|
-
}),
|
|
389
|
-
hasSectionKey: "hasAdminViewsSection",
|
|
390
|
-
},
|
|
391
|
-
value: {
|
|
392
|
-
name: "ADMIN_VIEWS",
|
|
393
|
-
section: ADMIN_VIEWS_CONST_SECTION,
|
|
394
|
-
},
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
append: {
|
|
398
|
-
marker: EDITOR_PLUGIN_CONFIG_ENTRY_MARKER,
|
|
399
|
-
optionKey: "editorPluginEntries",
|
|
400
|
-
},
|
|
401
|
-
interface: {
|
|
402
|
-
name: "WorkspaceEditorPluginConfig",
|
|
403
|
-
section: EDITOR_PLUGINS_INTERFACE_SECTION,
|
|
404
|
-
},
|
|
405
|
-
parse: {
|
|
406
|
-
entriesKey: "editorPlugins",
|
|
407
|
-
entry: defineInventoryEntryParser()({
|
|
408
|
-
entryName: "EDITOR_PLUGINS",
|
|
409
|
-
fields: [
|
|
410
|
-
{ key: "file", required: true },
|
|
411
|
-
{ key: "slug", required: true },
|
|
412
|
-
{ key: "slot", required: true },
|
|
413
|
-
],
|
|
414
|
-
}),
|
|
415
|
-
hasSectionKey: "hasEditorPluginsSection",
|
|
416
|
-
},
|
|
417
|
-
value: {
|
|
418
|
-
name: "EDITOR_PLUGINS",
|
|
419
|
-
section: EDITOR_PLUGINS_CONST_SECTION,
|
|
420
|
-
},
|
|
421
|
-
},
|
|
422
|
-
];
|
|
423
|
-
function findExportedArrayLiteral(sourceFile, exportName) {
|
|
424
|
-
for (const statement of sourceFile.statements) {
|
|
425
|
-
if (!ts.isVariableStatement(statement)) {
|
|
426
|
-
continue;
|
|
427
|
-
}
|
|
428
|
-
if (!statement.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)) {
|
|
429
|
-
continue;
|
|
430
|
-
}
|
|
431
|
-
for (const declaration of statement.declarationList.declarations) {
|
|
432
|
-
if (!ts.isIdentifier(declaration.name) ||
|
|
433
|
-
declaration.name.text !== exportName) {
|
|
434
|
-
continue;
|
|
435
|
-
}
|
|
436
|
-
if (declaration.initializer &&
|
|
437
|
-
ts.isArrayLiteralExpression(declaration.initializer)) {
|
|
438
|
-
return {
|
|
439
|
-
array: declaration.initializer,
|
|
440
|
-
found: true,
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
return {
|
|
444
|
-
array: null,
|
|
445
|
-
found: true,
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
return {
|
|
450
|
-
array: null,
|
|
451
|
-
found: false,
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
function getOptionalStringProperty(entryName, elementIndex, objectLiteral, key) {
|
|
455
|
-
for (const property of objectLiteral.properties) {
|
|
456
|
-
if (!ts.isPropertyAssignment(property)) {
|
|
457
|
-
continue;
|
|
458
|
-
}
|
|
459
|
-
const propertyName = getPropertyNameText(property.name);
|
|
460
|
-
if (propertyName !== key) {
|
|
461
|
-
continue;
|
|
462
|
-
}
|
|
463
|
-
if (ts.isStringLiteralLike(property.initializer)) {
|
|
464
|
-
return property.initializer.text;
|
|
465
|
-
}
|
|
466
|
-
throw new Error(`${entryName}[${elementIndex}] must use a string literal for "${key}" in scripts/block-config.ts.`);
|
|
467
|
-
}
|
|
468
|
-
return undefined;
|
|
469
|
-
}
|
|
470
|
-
function getOptionalStringArrayProperty(entryName, elementIndex, objectLiteral, key) {
|
|
471
|
-
for (const property of objectLiteral.properties) {
|
|
472
|
-
if (!ts.isPropertyAssignment(property)) {
|
|
473
|
-
continue;
|
|
474
|
-
}
|
|
475
|
-
const propertyName = getPropertyNameText(property.name);
|
|
476
|
-
if (propertyName !== key) {
|
|
477
|
-
continue;
|
|
478
|
-
}
|
|
479
|
-
if (!ts.isArrayLiteralExpression(property.initializer)) {
|
|
480
|
-
throw new Error(`${entryName}[${elementIndex}] must use an array literal for "${key}" in scripts/block-config.ts.`);
|
|
481
|
-
}
|
|
482
|
-
return property.initializer.elements.map((element, itemIndex) => {
|
|
483
|
-
if (!ts.isStringLiteralLike(element)) {
|
|
484
|
-
throw new Error(`${entryName}[${elementIndex}].${key}[${itemIndex}] must use a string literal in scripts/block-config.ts.`);
|
|
485
|
-
}
|
|
486
|
-
return element.text;
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
return undefined;
|
|
490
|
-
}
|
|
491
|
-
function getOptionalBooleanProperty(entryName, elementIndex, objectLiteral, key) {
|
|
492
|
-
for (const property of objectLiteral.properties) {
|
|
493
|
-
if (!ts.isPropertyAssignment(property)) {
|
|
494
|
-
continue;
|
|
495
|
-
}
|
|
496
|
-
const propertyName = getPropertyNameText(property.name);
|
|
497
|
-
if (propertyName !== key) {
|
|
498
|
-
continue;
|
|
499
|
-
}
|
|
500
|
-
if (property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
|
|
501
|
-
return true;
|
|
502
|
-
}
|
|
503
|
-
if (property.initializer.kind === ts.SyntaxKind.FalseKeyword) {
|
|
504
|
-
return false;
|
|
505
|
-
}
|
|
506
|
-
throw new Error(`${entryName}[${elementIndex}] must use a boolean literal for "${key}" in scripts/block-config.ts.`);
|
|
507
|
-
}
|
|
508
|
-
return undefined;
|
|
509
|
-
}
|
|
510
|
-
function isMissingRequiredInventoryValue(value) {
|
|
511
|
-
return (value === undefined || (typeof value === "string" && value.length === 0));
|
|
512
|
-
}
|
|
513
|
-
function formatMissingRequiredInventoryFields(keys) {
|
|
514
|
-
return keys.length === 1
|
|
515
|
-
? `required "${keys[0]}"`
|
|
516
|
-
: `required fields ${keys.map((key) => `"${key}"`).join(", ")}`;
|
|
517
|
-
}
|
|
518
|
-
function assertParsedInventoryEntry(entry, descriptor, elementIndex) {
|
|
519
|
-
const missingRequiredKeys = descriptor.fields
|
|
520
|
-
.filter((field) => field.required === true &&
|
|
521
|
-
isMissingRequiredInventoryValue(entry[field.key]))
|
|
522
|
-
.map((field) => field.key);
|
|
523
|
-
if (missingRequiredKeys.length > 0) {
|
|
524
|
-
throw new Error(`${descriptor.entryName}[${elementIndex}] is missing ${formatMissingRequiredInventoryFields(missingRequiredKeys)} in scripts/block-config.ts.`);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
function parseInventoryEntries(arrayLiteral, descriptor) {
|
|
528
|
-
return arrayLiteral.elements.map((element, elementIndex) => {
|
|
529
|
-
if (!ts.isObjectLiteralExpression(element)) {
|
|
530
|
-
throw new Error(`${descriptor.entryName}[${elementIndex}] must be an object literal in scripts/block-config.ts.`);
|
|
531
|
-
}
|
|
532
|
-
const entry = {};
|
|
533
|
-
for (const field of descriptor.fields) {
|
|
534
|
-
const kind = field.kind ?? "string";
|
|
535
|
-
const value = kind === "stringArray"
|
|
536
|
-
? getOptionalStringArrayProperty(descriptor.entryName, elementIndex, element, field.key)
|
|
537
|
-
: kind === "boolean"
|
|
538
|
-
? getOptionalBooleanProperty(descriptor.entryName, elementIndex, element, field.key)
|
|
539
|
-
: getOptionalStringProperty(descriptor.entryName, elementIndex, element, field.key);
|
|
540
|
-
field.validate?.(value, {
|
|
541
|
-
elementIndex,
|
|
542
|
-
entryName: descriptor.entryName,
|
|
543
|
-
key: field.key,
|
|
544
|
-
});
|
|
545
|
-
entry[field.key] = value;
|
|
546
|
-
}
|
|
547
|
-
assertParsedInventoryEntry(entry, descriptor, elementIndex);
|
|
548
|
-
return entry;
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
function parseInventorySection(sourceFile, descriptor) {
|
|
552
|
-
if (!descriptor.parse) {
|
|
553
|
-
return {
|
|
554
|
-
entries: [],
|
|
555
|
-
found: false,
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
const exportName = descriptor.parse.exportName ?? descriptor.value?.name;
|
|
559
|
-
if (!exportName) {
|
|
560
|
-
throw new Error("Inventory parser descriptor is missing an export name.");
|
|
561
|
-
}
|
|
562
|
-
const exportedArray = findExportedArrayLiteral(sourceFile, exportName);
|
|
563
|
-
if (!exportedArray.found) {
|
|
564
|
-
if (descriptor.parse.required) {
|
|
565
|
-
throw new Error(`scripts/block-config.ts must export a ${exportName} array.`);
|
|
566
|
-
}
|
|
567
|
-
return {
|
|
568
|
-
entries: [],
|
|
569
|
-
found: false,
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
if (!exportedArray.array) {
|
|
573
|
-
if (descriptor.parse.required) {
|
|
574
|
-
throw new Error(`scripts/block-config.ts must export a ${exportName} array.`);
|
|
575
|
-
}
|
|
576
|
-
throw new Error(`scripts/block-config.ts must export ${exportName} as an array literal.`);
|
|
577
|
-
}
|
|
578
|
-
return {
|
|
579
|
-
entries: parseInventoryEntries(exportedArray.array, descriptor.parse.entry),
|
|
580
|
-
found: true,
|
|
581
|
-
};
|
|
582
|
-
}
|
|
2
|
+
import { parseInventorySection } from "./workspace-inventory-parser-entries.js";
|
|
3
|
+
import { BLOCK_INVENTORY_SECTION, INVENTORY_SECTIONS, } from "./workspace-inventory-section-descriptors.js";
|
|
4
|
+
export { BLOCK_INVENTORY_SECTION, INVENTORY_SECTIONS, } from "./workspace-inventory-section-descriptors.js";
|
|
583
5
|
/**
|
|
584
6
|
* Parse workspace inventory entries from the source of `scripts/block-config.ts`.
|
|
585
7
|
*
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type InventorySectionDescriptor } from "./workspace-inventory-parser-validation.js";
|
|
2
|
+
/**
|
|
3
|
+
* Descriptor for the required `BLOCKS` inventory section.
|
|
4
|
+
*
|
|
5
|
+
* Runtime readers use its `parse` contract to require the exported `BLOCKS`
|
|
6
|
+
* array and validate required block entry fields; mutation helpers use its
|
|
7
|
+
* `append` marker to insert generated block entries without duplicating section
|
|
8
|
+
* knowledge.
|
|
9
|
+
*/
|
|
10
|
+
export declare const BLOCK_INVENTORY_SECTION: InventorySectionDescriptor;
|
|
11
|
+
/**
|
|
12
|
+
* Descriptors for optional workspace inventory sections beyond `BLOCKS`.
|
|
13
|
+
*
|
|
14
|
+
* Each descriptor centralizes append markers, exported interface/value repair
|
|
15
|
+
* sections, parser entry metadata such as `entriesKey` and `entryName`, and
|
|
16
|
+
* optional section flags so add, doctor, read, and mutation flows share one
|
|
17
|
+
* runtime contract when adding new inventory domains.
|
|
18
|
+
*/
|
|
19
|
+
export declare const INVENTORY_SECTIONS: readonly InventorySectionDescriptor[];
|