@specverse/engines 4.1.5 → 4.1.6
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/libs/instance-factories/applications/templates/generic/backend-env-generator.js +22 -0
- package/dist/libs/instance-factories/applications/templates/generic/backend-package-json-generator.js +66 -0
- package/dist/libs/instance-factories/applications/templates/generic/backend-tsconfig-generator.js +54 -0
- package/dist/libs/instance-factories/applications/templates/generic/main-generator.js +290 -0
- package/dist/libs/instance-factories/applications/templates/react/_view-components-source.js +530 -0
- package/dist/libs/instance-factories/applications/templates/react/api-client-generator.js +437 -0
- package/dist/libs/instance-factories/applications/templates/react/api-types-generator.js +146 -0
- package/dist/libs/instance-factories/applications/templates/react/app-tsx-generator.js +73 -0
- package/dist/libs/instance-factories/applications/templates/react/env-example-generator.js +18 -0
- package/dist/libs/instance-factories/applications/templates/react/field-helpers-generator.js +99 -0
- package/dist/libs/instance-factories/applications/templates/react/gitignore-generator.js +35 -0
- package/dist/libs/instance-factories/applications/templates/react/index-css-generator.js +9 -0
- package/dist/libs/instance-factories/applications/templates/react/index-html-generator.js +23 -0
- package/dist/libs/instance-factories/applications/templates/react/main-tsx-generator.js +29 -0
- package/dist/libs/instance-factories/applications/templates/react/package-json-generator.js +49 -0
- package/dist/libs/instance-factories/applications/templates/react/pattern-adapter-generator.js +156 -0
- package/dist/libs/instance-factories/applications/templates/react/react-pattern-adapter.js +935 -0
- package/dist/libs/instance-factories/applications/templates/react/relationship-field-generator.js +143 -0
- package/dist/libs/instance-factories/applications/templates/react/runtime-app-tsx-generator.js +101 -0
- package/dist/libs/instance-factories/applications/templates/react/runtime-package-json-generator.js +50 -0
- package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.js +646 -0
- package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.js +65 -0
- package/dist/libs/instance-factories/applications/templates/react/tsconfig-generator.js +28 -0
- package/dist/libs/instance-factories/applications/templates/react/use-api-hooks-generator.js +132 -0
- package/dist/libs/instance-factories/applications/templates/react/view-dashboard-generator.js +143 -0
- package/dist/libs/instance-factories/applications/templates/react/view-detail-generator.js +143 -0
- package/dist/libs/instance-factories/applications/templates/react/view-form-generator.js +355 -0
- package/dist/libs/instance-factories/applications/templates/react/view-list-generator.js +91 -0
- package/dist/libs/instance-factories/applications/templates/react/view-router-generator.js +79 -0
- package/dist/libs/instance-factories/applications/templates/react/vite-config-generator.js +42 -0
- package/dist/libs/instance-factories/cli/templates/commander/cli-bin-wrapper-generator.js +11 -0
- package/dist/libs/instance-factories/cli/templates/commander/cli-entry-generator.js +111 -0
- package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +928 -0
- package/dist/libs/instance-factories/communication/templates/eventemitter/bus-generator.js +83 -0
- package/dist/libs/instance-factories/communication/templates/eventemitter/publisher-generator.js +91 -0
- package/dist/libs/instance-factories/communication/templates/eventemitter/subscriber-generator.js +86 -0
- package/dist/libs/instance-factories/controllers/templates/fastify/meta-routes-generator.js +93 -0
- package/dist/libs/instance-factories/controllers/templates/fastify/routes-generator.js +280 -0
- package/dist/libs/instance-factories/controllers/templates/fastify/server-generator.js +125 -0
- package/dist/libs/instance-factories/infrastructure/templates/docker-k8s/infrastructure-generator.js +25 -0
- package/dist/libs/instance-factories/orms/templates/prisma/schema-generator.js +371 -0
- package/dist/libs/instance-factories/orms/templates/prisma/services-generator.js +266 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/env-example-generator.js +51 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/env-generator.js +61 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/gitignore-generator.js +59 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/package-json-generator.js +126 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/readme-generator.js +159 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/tsconfig-generator.js +56 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/tsconfig-react-generator.js +37 -0
- package/dist/libs/instance-factories/sdks/templates/python/sdk-generator.js +29 -0
- package/dist/libs/instance-factories/sdks/templates/typescript/sdk-generator.js +28 -0
- package/dist/libs/instance-factories/services/templates/memory/generate-interpreter.js +14 -0
- package/dist/libs/instance-factories/services/templates/memory/step-conventions-memory.js +415 -0
- package/dist/libs/instance-factories/services/templates/prisma/behavior-generator.js +177 -0
- package/dist/libs/instance-factories/services/templates/prisma/controller-generator.js +413 -0
- package/dist/libs/instance-factories/services/templates/prisma/service-generator.js +243 -0
- package/dist/libs/instance-factories/services/templates/prisma/step-conventions.js +264 -0
- package/dist/libs/instance-factories/services/templates/shared-patterns.js +24 -0
- package/dist/libs/instance-factories/shared/path-resolver.js +59 -0
- package/dist/libs/instance-factories/storage/templates/mongodb/config-generator.js +13 -0
- package/dist/libs/instance-factories/storage/templates/mongodb/docker-generator.js +16 -0
- package/dist/libs/instance-factories/storage/templates/postgresql/config-generator.js +45 -0
- package/dist/libs/instance-factories/storage/templates/postgresql/docker-generator.js +46 -0
- package/dist/libs/instance-factories/storage/templates/redis/config-generator.js +14 -0
- package/dist/libs/instance-factories/storage/templates/redis/docker-generator.js +16 -0
- package/dist/libs/instance-factories/test-generation.js +145 -0
- package/dist/libs/instance-factories/testing/templates/vitest/tests-generator.js +30 -0
- package/dist/libs/instance-factories/tools/templates/mcp/mcp-server-generator.js +149 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/controllers/MCPServerController.js +232 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/events/EventEmitter.js +49 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/index.js +18 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/interfaces/ResourceProvider.js +0 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/models/LibrarySuggestion.js +97 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/models/SpecVerseResource.js +64 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/server/mcp-server.js +182 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/CLIProxyService.js +1210 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/EmbeddedResourcesAdapter.js +172 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/EntityModuleService.js +240 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/HybridResourcesProvider.js +147 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/LibraryToolsService.js +281 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/OrchestratorBridge.js +409 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/OrchestratorToolsService.js +414 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/PromptToolsService.js +467 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/ResourcesProviderService.js +135 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/types/index.js +0 -0
- package/dist/libs/instance-factories/tools/templates/vscode/static/extension.js +965 -0
- package/dist/libs/instance-factories/tools/templates/vscode/vscode-extension-generator.js +238 -0
- package/dist/libs/instance-factories/validation/templates/zod/validation-generator.js +25 -0
- package/dist/libs/instance-factories/views/index.js +48 -0
- package/dist/libs/instance-factories/views/templates/react/adapters/antd-adapter.js +742 -0
- package/dist/libs/instance-factories/views/templates/react/adapters/mui-adapter.js +824 -0
- package/dist/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.js +719 -0
- package/dist/libs/instance-factories/views/templates/react/app-generator.js +45 -0
- package/dist/libs/instance-factories/views/templates/react/components-generator.js +779 -0
- package/dist/libs/instance-factories/views/templates/react/forms-generator.js +285 -0
- package/dist/libs/instance-factories/views/templates/react/frontend-package-json-generator.js +46 -0
- package/dist/libs/instance-factories/views/templates/react/hooks-generator.js +111 -0
- package/dist/libs/instance-factories/views/templates/react/index-css-generator.js +9 -0
- package/dist/libs/instance-factories/views/templates/react/index-html-generator.js +23 -0
- package/dist/libs/instance-factories/views/templates/react/main-tsx-generator.js +21 -0
- package/dist/libs/instance-factories/views/templates/react/react-component-generator.js +299 -0
- package/dist/libs/instance-factories/views/templates/react/router-generator.js +136 -0
- package/dist/libs/instance-factories/views/templates/react/router-generic-generator.js +107 -0
- package/dist/libs/instance-factories/views/templates/react/shared-utils-generator.js +179 -0
- package/dist/libs/instance-factories/views/templates/react/spec-json-generator.js +7 -0
- package/dist/libs/instance-factories/views/templates/react/types-generator.js +56 -0
- package/dist/libs/instance-factories/views/templates/react/views-metadata-generator.js +27 -0
- package/dist/libs/instance-factories/views/templates/react/vite-config-generator.js +29 -0
- package/dist/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js +261 -0
- package/dist/libs/instance-factories/views/templates/shared/adapter-types.js +34 -0
- package/dist/libs/instance-factories/views/templates/shared/atomic-components-registry.js +800 -0
- package/dist/libs/instance-factories/views/templates/shared/base-generator.js +305 -0
- package/dist/libs/instance-factories/views/templates/shared/component-metadata.js +517 -0
- package/dist/libs/instance-factories/views/templates/shared/composite-pattern-types.js +0 -0
- package/dist/libs/instance-factories/views/templates/shared/composite-patterns.js +445 -0
- package/dist/libs/instance-factories/views/templates/shared/index.js +80 -0
- package/dist/libs/instance-factories/views/templates/shared/pattern-validator.js +210 -0
- package/dist/libs/instance-factories/views/templates/shared/property-mapper.js +492 -0
- package/dist/libs/instance-factories/views/templates/shared/syntax-mapper.js +321 -0
- package/package.json +3 -2
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { mapProperties } from "./property-mapper.js";
|
|
2
|
+
import { getSyntaxPattern } from "./syntax-mapper.js";
|
|
3
|
+
import { ATOMIC_COMPONENTS_REGISTRY } from "./atomic-components-registry.js";
|
|
4
|
+
class BaseComponentGenerator {
|
|
5
|
+
// Configuration
|
|
6
|
+
config;
|
|
7
|
+
adapter;
|
|
8
|
+
// Architectural constraints
|
|
9
|
+
MAX_DEPTH;
|
|
10
|
+
ENABLE_WARNINGS;
|
|
11
|
+
// Tracking
|
|
12
|
+
warnings = [];
|
|
13
|
+
imports = /* @__PURE__ */ new Set();
|
|
14
|
+
constructor(adapter, config) {
|
|
15
|
+
this.adapter = adapter;
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.MAX_DEPTH = config.maxDepth ?? 3;
|
|
18
|
+
this.ENABLE_WARNINGS = config.enableWarnings ?? true;
|
|
19
|
+
}
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Public API
|
|
22
|
+
// ============================================================================
|
|
23
|
+
/**
|
|
24
|
+
* Generate code for a complete view specification
|
|
25
|
+
*
|
|
26
|
+
* @param viewSpec - View specification from SpecVerse
|
|
27
|
+
* @returns Generation result with code, imports, and warnings
|
|
28
|
+
*/
|
|
29
|
+
generate(viewSpec) {
|
|
30
|
+
this.reset();
|
|
31
|
+
const importStatements = this.generateImports(viewSpec);
|
|
32
|
+
const stateCode = viewSpec.state ? this.generateState(viewSpec.state) : "";
|
|
33
|
+
const eventsCode = viewSpec.events ? this.generateEvents(viewSpec.events) : "";
|
|
34
|
+
const componentsCode = this.generateComponentTree(viewSpec.components);
|
|
35
|
+
const code = this.generateComponent({
|
|
36
|
+
name: viewSpec.name,
|
|
37
|
+
imports: importStatements,
|
|
38
|
+
state: stateCode,
|
|
39
|
+
events: eventsCode,
|
|
40
|
+
components: componentsCode
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
code,
|
|
44
|
+
imports: Array.from(this.imports),
|
|
45
|
+
warnings: this.warnings
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// Shared Component Rendering (Framework-Agnostic)
|
|
50
|
+
// ============================================================================
|
|
51
|
+
/**
|
|
52
|
+
* Render all components in the view
|
|
53
|
+
*/
|
|
54
|
+
generateComponentTree(components) {
|
|
55
|
+
const rendered = Object.entries(components).map(([name, component]) => {
|
|
56
|
+
return this.renderComponent(component, {
|
|
57
|
+
depth: 0,
|
|
58
|
+
path: [name],
|
|
59
|
+
dataContext: void 0
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return rendered.join("\n\n");
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Render a single component with depth tracking and nesting enforcement
|
|
66
|
+
*
|
|
67
|
+
* This is the core shared logic - applies to ALL frameworks
|
|
68
|
+
*/
|
|
69
|
+
renderComponent(component, context) {
|
|
70
|
+
if (context.depth > this.MAX_DEPTH) {
|
|
71
|
+
this.addWarning(
|
|
72
|
+
`Component at path ${context.path.join(".")} exceeds max depth (${this.MAX_DEPTH}). Flattening to maintain readability.`
|
|
73
|
+
);
|
|
74
|
+
return this.renderFlattened(component, context);
|
|
75
|
+
}
|
|
76
|
+
const componentDef = ATOMIC_COMPONENTS_REGISTRY[component.type];
|
|
77
|
+
if (!componentDef) {
|
|
78
|
+
this.addWarning(`Unknown component type: ${component.type}`);
|
|
79
|
+
return `<!-- Unknown component: ${component.type} -->`;
|
|
80
|
+
}
|
|
81
|
+
const mappedProps = this.mapComponentProperties(component, componentDef);
|
|
82
|
+
if (component.condition) {
|
|
83
|
+
return this.renderConditional(component, mappedProps, context);
|
|
84
|
+
}
|
|
85
|
+
if (component.dataSource) {
|
|
86
|
+
return this.renderList(component, mappedProps, context);
|
|
87
|
+
}
|
|
88
|
+
const children = component.children ? this.renderChildren(component.children, context) : void 0;
|
|
89
|
+
return this.renderAdapterComponent(
|
|
90
|
+
component.type,
|
|
91
|
+
mappedProps,
|
|
92
|
+
children,
|
|
93
|
+
context
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Map component properties using property-mapper
|
|
98
|
+
*/
|
|
99
|
+
mapComponentProperties(component, componentDef) {
|
|
100
|
+
if (!component.properties) {
|
|
101
|
+
return {};
|
|
102
|
+
}
|
|
103
|
+
return mapProperties(
|
|
104
|
+
component.type,
|
|
105
|
+
component.properties,
|
|
106
|
+
this.config.target
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Render child components with incremented depth
|
|
111
|
+
*/
|
|
112
|
+
renderChildren(children, parentContext) {
|
|
113
|
+
const childContext = {
|
|
114
|
+
...parentContext,
|
|
115
|
+
depth: parentContext.depth + 1
|
|
116
|
+
};
|
|
117
|
+
return children.map((child, index) => {
|
|
118
|
+
const childPath = [...parentContext.path, `child_${index}`];
|
|
119
|
+
return this.renderComponent(child, {
|
|
120
|
+
...childContext,
|
|
121
|
+
path: childPath
|
|
122
|
+
});
|
|
123
|
+
}).join("\n");
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Render conditional component using syntax-mapper
|
|
127
|
+
*/
|
|
128
|
+
renderConditional(component, mappedProps, context) {
|
|
129
|
+
const innerComponent = this.renderAdapterComponent(
|
|
130
|
+
component.type,
|
|
131
|
+
mappedProps,
|
|
132
|
+
component.children ? this.renderChildren(component.children, context) : void 0,
|
|
133
|
+
context
|
|
134
|
+
);
|
|
135
|
+
return getSyntaxPattern("conditionalRender", this.config.framework, {
|
|
136
|
+
condition: component.condition,
|
|
137
|
+
Component: this.getComponentName(component.type),
|
|
138
|
+
props: this.formatProps(mappedProps)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Render list (loop) component using syntax-mapper
|
|
143
|
+
*/
|
|
144
|
+
renderList(component, mappedProps, context) {
|
|
145
|
+
const itemName = this.getItemName(component.dataSource);
|
|
146
|
+
const keyProperty = this.getKeyProperty(component);
|
|
147
|
+
const childContext = {
|
|
148
|
+
...context,
|
|
149
|
+
depth: context.depth + 1,
|
|
150
|
+
dataContext: itemName
|
|
151
|
+
};
|
|
152
|
+
return getSyntaxPattern("loopRender", this.config.framework, {
|
|
153
|
+
array: component.dataSource,
|
|
154
|
+
item: itemName,
|
|
155
|
+
key: keyProperty,
|
|
156
|
+
Component: this.getComponentName(component.type)
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Flatten component when depth exceeded
|
|
161
|
+
*
|
|
162
|
+
* Extracts nested children into sibling components to reduce nesting
|
|
163
|
+
*/
|
|
164
|
+
renderFlattened(component, context) {
|
|
165
|
+
const componentDef = ATOMIC_COMPONENTS_REGISTRY[component.type];
|
|
166
|
+
const mappedProps = this.mapComponentProperties(component, componentDef);
|
|
167
|
+
const flatComponent = this.renderAdapterComponent(
|
|
168
|
+
component.type,
|
|
169
|
+
mappedProps,
|
|
170
|
+
void 0,
|
|
171
|
+
// No children
|
|
172
|
+
context
|
|
173
|
+
);
|
|
174
|
+
const flattenedChildren = component.children ? component.children.map((child, index) => {
|
|
175
|
+
return this.renderComponent(child, {
|
|
176
|
+
depth: context.depth,
|
|
177
|
+
// Same depth (sibling)
|
|
178
|
+
path: [...context.path, `flattened_${index}`]
|
|
179
|
+
});
|
|
180
|
+
}).join("\n") : "";
|
|
181
|
+
return flatComponent + "\n" + flattenedChildren;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Delegate to adapter for actual component rendering
|
|
185
|
+
*/
|
|
186
|
+
renderAdapterComponent(type, properties, children, context) {
|
|
187
|
+
const adapterComponent = this.adapter.components[type];
|
|
188
|
+
if (!adapterComponent) {
|
|
189
|
+
this.addWarning(`Adapter missing component: ${type}`);
|
|
190
|
+
return `<!-- Missing adapter for: ${type} -->`;
|
|
191
|
+
}
|
|
192
|
+
return adapterComponent.render({
|
|
193
|
+
properties,
|
|
194
|
+
children
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// ============================================================================
|
|
198
|
+
// Helper Methods
|
|
199
|
+
// ============================================================================
|
|
200
|
+
/**
|
|
201
|
+
* Get component name for import/usage
|
|
202
|
+
*/
|
|
203
|
+
getComponentName(type) {
|
|
204
|
+
const componentDef = ATOMIC_COMPONENTS_REGISTRY[type];
|
|
205
|
+
return componentDef?.name || type.charAt(0).toUpperCase() + type.slice(1);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Get item variable name for loop rendering
|
|
209
|
+
*/
|
|
210
|
+
getItemName(dataSource) {
|
|
211
|
+
if (dataSource.endsWith("s")) {
|
|
212
|
+
return dataSource.slice(0, -1);
|
|
213
|
+
}
|
|
214
|
+
return dataSource + "Item";
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get key property for list items
|
|
218
|
+
*/
|
|
219
|
+
getKeyProperty(component) {
|
|
220
|
+
return component.properties?.keyProperty || "id";
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Format properties for inline rendering
|
|
224
|
+
*/
|
|
225
|
+
formatProps(properties) {
|
|
226
|
+
return Object.entries(properties).map(([key, value]) => {
|
|
227
|
+
if (typeof value === "string") {
|
|
228
|
+
return `${key}="${value}"`;
|
|
229
|
+
}
|
|
230
|
+
return `${key}={${JSON.stringify(value)}}`;
|
|
231
|
+
}).join(" ");
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Add warning message
|
|
235
|
+
*/
|
|
236
|
+
addWarning(message) {
|
|
237
|
+
if (this.ENABLE_WARNINGS) {
|
|
238
|
+
this.warnings.push(message);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Reset generator state for new generation
|
|
243
|
+
*/
|
|
244
|
+
reset() {
|
|
245
|
+
this.warnings = [];
|
|
246
|
+
this.imports = /* @__PURE__ */ new Set();
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Add import statement
|
|
250
|
+
*/
|
|
251
|
+
addImport(importStatement) {
|
|
252
|
+
this.imports.add(importStatement);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function validateNestingDepth(component, maxDepth = 3) {
|
|
256
|
+
const issues = [];
|
|
257
|
+
function calculateDepth(comp, currentDepth) {
|
|
258
|
+
if (!comp.children || comp.children.length === 0) {
|
|
259
|
+
return currentDepth;
|
|
260
|
+
}
|
|
261
|
+
const childDepths = comp.children.map(
|
|
262
|
+
(child) => calculateDepth(child, currentDepth + 1)
|
|
263
|
+
);
|
|
264
|
+
return Math.max(...childDepths);
|
|
265
|
+
}
|
|
266
|
+
const actualDepth = calculateDepth(component, 0);
|
|
267
|
+
if (actualDepth > maxDepth) {
|
|
268
|
+
issues.push(
|
|
269
|
+
`Component nesting depth (${actualDepth}) exceeds maximum (${maxDepth})`
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
valid: actualDepth <= maxDepth,
|
|
274
|
+
actualDepth,
|
|
275
|
+
issues
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function extractComponentTypes(components) {
|
|
279
|
+
const types = /* @__PURE__ */ new Set();
|
|
280
|
+
function walk(component) {
|
|
281
|
+
types.add(component.type);
|
|
282
|
+
if (component.children) {
|
|
283
|
+
component.children.forEach(walk);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
Object.values(components).forEach(walk);
|
|
287
|
+
return types;
|
|
288
|
+
}
|
|
289
|
+
function countComponents(components) {
|
|
290
|
+
let count = 0;
|
|
291
|
+
function walk(component) {
|
|
292
|
+
count++;
|
|
293
|
+
if (component.children) {
|
|
294
|
+
component.children.forEach(walk);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
Object.values(components).forEach(walk);
|
|
298
|
+
return count;
|
|
299
|
+
}
|
|
300
|
+
export {
|
|
301
|
+
BaseComponentGenerator,
|
|
302
|
+
countComponents,
|
|
303
|
+
extractComponentTypes,
|
|
304
|
+
validateNestingDepth
|
|
305
|
+
};
|