@specverse/engines 4.1.28 → 4.2.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 (237) hide show
  1. package/assets/examples/manifests/frontend-only.yaml +3 -6
  2. package/assets/examples/manifests/fullstack-app.yaml +5 -7
  3. package/assets/examples/manifests/fullstack-monorepo.yaml +3 -6
  4. package/dist/inference/comprehensive-engine.d.ts.map +1 -1
  5. package/dist/inference/comprehensive-engine.js +3 -19
  6. package/dist/inference/comprehensive-engine.js.map +1 -1
  7. package/dist/inference/core/rule-engine.d.ts +31 -0
  8. package/dist/inference/core/rule-engine.d.ts.map +1 -1
  9. package/dist/inference/core/rule-engine.js +117 -33
  10. package/dist/inference/core/rule-engine.js.map +1 -1
  11. package/dist/inference/core/rule-file-types.d.ts +0 -2
  12. package/dist/inference/core/rule-file-types.d.ts.map +1 -1
  13. package/dist/inference/core/rule-file-types.js +3 -6
  14. package/dist/inference/core/rule-file-types.js.map +1 -1
  15. package/dist/inference/core/rule-loader.d.ts +5 -15
  16. package/dist/inference/core/rule-loader.d.ts.map +1 -1
  17. package/dist/inference/core/rule-loader.js +43 -132
  18. package/dist/inference/core/rule-loader.js.map +1 -1
  19. package/dist/inference/core/types.d.ts +0 -6
  20. package/dist/inference/core/types.d.ts.map +1 -1
  21. package/dist/inference/core/types.js +0 -4
  22. package/dist/inference/core/types.js.map +1 -1
  23. package/dist/inference/logical/generators/component-type-resolver.d.ts +0 -26
  24. package/dist/inference/logical/generators/component-type-resolver.d.ts.map +1 -1
  25. package/dist/inference/logical/generators/component-type-resolver.js +0 -19
  26. package/dist/inference/logical/generators/component-type-resolver.js.map +1 -1
  27. package/dist/inference/logical/generators/specialist-view-expander.d.ts +1 -17
  28. package/dist/inference/logical/generators/specialist-view-expander.d.ts.map +1 -1
  29. package/dist/inference/logical/generators/specialist-view-expander.js +0 -15
  30. package/dist/inference/logical/generators/specialist-view-expander.js.map +1 -1
  31. package/dist/inference/logical/generators/view-generator.d.ts +4 -14
  32. package/dist/inference/logical/generators/view-generator.d.ts.map +1 -1
  33. package/dist/inference/logical/generators/view-generator.js +6 -26
  34. package/dist/inference/logical/generators/view-generator.js.map +1 -1
  35. package/dist/inference/logical/index.d.ts +2 -2
  36. package/dist/inference/logical/index.d.ts.map +1 -1
  37. package/dist/inference/logical/logical-engine.d.ts.map +1 -1
  38. package/dist/inference/logical/logical-engine.js +17 -80
  39. package/dist/inference/logical/logical-engine.js.map +1 -1
  40. package/dist/inference/quint-transpiler.d.ts +5 -3
  41. package/dist/inference/quint-transpiler.d.ts.map +1 -1
  42. package/dist/inference/quint-transpiler.js +11 -6
  43. package/dist/inference/quint-transpiler.js.map +1 -1
  44. package/dist/libs/instance-factories/applications/templates/generic/main-generator.js +3 -3
  45. package/dist/libs/instance-factories/applications/templates/react/api-client-generator.js +16 -6
  46. package/dist/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.js +110 -0
  47. package/dist/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.js +121 -0
  48. package/dist/libs/instance-factories/applications/templates/react-starter/detail-body-composer.js +78 -0
  49. package/dist/libs/instance-factories/applications/templates/react-starter/form-body-composer.js +190 -0
  50. package/dist/libs/instance-factories/applications/templates/react-starter/helpers-emitter.js +45 -0
  51. package/dist/libs/instance-factories/applications/templates/react-starter/html-to-jsx.js +192 -0
  52. package/dist/libs/instance-factories/applications/templates/react-starter/list-body-composer.js +46 -0
  53. package/dist/libs/instance-factories/applications/templates/react-starter/orchestrator.js +30 -0
  54. package/dist/libs/instance-factories/applications/templates/react-starter/package-json-generator.js +38 -0
  55. package/dist/libs/instance-factories/applications/templates/react-starter/regen-safety.js +89 -0
  56. package/dist/libs/instance-factories/applications/templates/react-starter/view-emitter.js +56 -0
  57. package/dist/libs/instance-factories/applications/templates/react-starter/views-generator.js +66 -0
  58. package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +14 -11
  59. package/dist/libs/instance-factories/controllers/templates/fastify/server-generator.js +11 -3
  60. package/dist/libs/instance-factories/services/templates/prisma/controller-generator.js +27 -17
  61. package/dist/libs/instance-factories/shared/path-resolver.js +1 -1
  62. package/dist/realize/index.d.ts.map +1 -1
  63. package/dist/realize/index.js +15 -22
  64. package/dist/realize/index.js.map +1 -1
  65. package/dist/registry/utils/manifest-adapter.d.ts +8 -1
  66. package/dist/registry/utils/manifest-adapter.d.ts.map +1 -1
  67. package/dist/registry/utils/manifest-adapter.js +8 -1
  68. package/dist/registry/utils/manifest-adapter.js.map +1 -1
  69. package/libs/instance-factories/applications/react-app-starter.yaml +150 -0
  70. package/libs/instance-factories/applications/templates/generic/main-generator.ts +3 -3
  71. package/libs/instance-factories/applications/templates/react/api-client-generator.ts +16 -6
  72. package/libs/instance-factories/applications/templates/react-starter/README.md +211 -0
  73. package/libs/instance-factories/applications/templates/react-starter/__tests__/dashboard-body-composer.test.ts +153 -0
  74. package/libs/instance-factories/applications/templates/react-starter/__tests__/detail-body-composer.test.ts +145 -0
  75. package/libs/instance-factories/applications/templates/react-starter/__tests__/form-body-composer.test.ts +175 -0
  76. package/libs/instance-factories/applications/templates/react-starter/__tests__/helpers-emitter.test.ts +55 -0
  77. package/libs/instance-factories/applications/templates/react-starter/__tests__/html-to-jsx.test.ts +140 -0
  78. package/libs/instance-factories/applications/templates/react-starter/__tests__/list-body-composer.test.ts +146 -0
  79. package/libs/instance-factories/applications/templates/react-starter/__tests__/orchestrator.test.ts +163 -0
  80. package/libs/instance-factories/applications/templates/react-starter/__tests__/parity-p2-factory-imports.test.ts +116 -0
  81. package/libs/instance-factories/applications/templates/react-starter/__tests__/parity-p3-rendered-output.test.ts +183 -0
  82. package/libs/instance-factories/applications/templates/react-starter/__tests__/regen-safety.test.ts +144 -0
  83. package/libs/instance-factories/applications/templates/react-starter/__tests__/starter-generators.test.ts +114 -0
  84. package/libs/instance-factories/applications/templates/react-starter/__tests__/view-emitter.test.ts +107 -0
  85. package/libs/instance-factories/applications/templates/react-starter/__tests__/views-generator.test.ts +139 -0
  86. package/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.ts +141 -0
  87. package/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.ts +174 -0
  88. package/libs/instance-factories/applications/templates/react-starter/detail-body-composer.ts +135 -0
  89. package/libs/instance-factories/applications/templates/react-starter/form-body-composer.ts +306 -0
  90. package/libs/instance-factories/applications/templates/react-starter/helpers-emitter.ts +60 -0
  91. package/libs/instance-factories/applications/templates/react-starter/html-to-jsx.ts +334 -0
  92. package/libs/instance-factories/applications/templates/react-starter/list-body-composer.ts +120 -0
  93. package/libs/instance-factories/applications/templates/react-starter/orchestrator.ts +80 -0
  94. package/libs/instance-factories/applications/templates/react-starter/package-json-generator.ts +57 -0
  95. package/libs/instance-factories/applications/templates/react-starter/regen-safety.ts +157 -0
  96. package/libs/instance-factories/applications/templates/react-starter/skeletons/dashboard.tsx.template +47 -0
  97. package/libs/instance-factories/applications/templates/react-starter/skeletons/detail.tsx.template +94 -0
  98. package/libs/instance-factories/applications/templates/react-starter/skeletons/form.tsx.template +114 -0
  99. package/libs/instance-factories/applications/templates/react-starter/skeletons/list.tsx.template +72 -0
  100. package/libs/instance-factories/applications/templates/react-starter/view-emitter.ts +151 -0
  101. package/libs/instance-factories/applications/templates/react-starter/views-generator.ts +137 -0
  102. package/libs/instance-factories/cli/templates/commander/command-generator.ts +14 -11
  103. package/libs/instance-factories/controllers/templates/fastify/server-generator.ts +11 -3
  104. package/libs/instance-factories/services/templates/prisma/controller-generator.ts +27 -17
  105. package/libs/instance-factories/shared/path-resolver.ts +8 -2
  106. package/package.json +3 -3
  107. package/dist/libs/instance-factories/applications/templates/react/_view-components-source.js +0 -530
  108. package/dist/libs/instance-factories/applications/templates/react/app-tsx-generator.js +0 -73
  109. package/dist/libs/instance-factories/applications/templates/react/field-helpers-generator.js +0 -99
  110. package/dist/libs/instance-factories/applications/templates/react/package-json-generator.js +0 -49
  111. package/dist/libs/instance-factories/applications/templates/react/pattern-adapter-generator.js +0 -156
  112. package/dist/libs/instance-factories/applications/templates/react/react-pattern-adapter.js +0 -935
  113. package/dist/libs/instance-factories/applications/templates/react/relationship-field-generator.js +0 -143
  114. package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.js +0 -646
  115. package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.js +0 -65
  116. package/dist/libs/instance-factories/applications/templates/react/view-dashboard-generator.js +0 -143
  117. package/dist/libs/instance-factories/applications/templates/react/view-detail-generator.js +0 -143
  118. package/dist/libs/instance-factories/applications/templates/react/view-form-generator.js +0 -355
  119. package/dist/libs/instance-factories/applications/templates/react/view-list-generator.js +0 -91
  120. package/dist/libs/instance-factories/applications/templates/react/view-router-generator.js +0 -79
  121. package/dist/libs/instance-factories/tools/templates/vscode/vscode-extension-generator.js.bak +0 -244
  122. package/dist/libs/instance-factories/views/index.js +0 -48
  123. package/dist/libs/instance-factories/views/templates/react/adapters/antd-adapter.js +0 -742
  124. package/dist/libs/instance-factories/views/templates/react/adapters/mui-adapter.js +0 -824
  125. package/dist/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.js +0 -719
  126. package/dist/libs/instance-factories/views/templates/react/app-generator.js +0 -45
  127. package/dist/libs/instance-factories/views/templates/react/components-generator.js +0 -820
  128. package/dist/libs/instance-factories/views/templates/react/forms-generator.js +0 -275
  129. package/dist/libs/instance-factories/views/templates/react/frontend-package-json-generator.js +0 -46
  130. package/dist/libs/instance-factories/views/templates/react/hooks-generator.js +0 -81
  131. package/dist/libs/instance-factories/views/templates/react/index-css-generator.js +0 -9
  132. package/dist/libs/instance-factories/views/templates/react/index-html-generator.js +0 -23
  133. package/dist/libs/instance-factories/views/templates/react/main-tsx-generator.js +0 -21
  134. package/dist/libs/instance-factories/views/templates/react/react-component-generator.js +0 -299
  135. package/dist/libs/instance-factories/views/templates/react/router-generator.js +0 -136
  136. package/dist/libs/instance-factories/views/templates/react/router-generic-generator.js +0 -107
  137. package/dist/libs/instance-factories/views/templates/react/shared-utils-generator.js +0 -187
  138. package/dist/libs/instance-factories/views/templates/react/spec-json-generator.js +0 -7
  139. package/dist/libs/instance-factories/views/templates/react/types-generator.js +0 -56
  140. package/dist/libs/instance-factories/views/templates/react/views-metadata-generator.js +0 -27
  141. package/dist/libs/instance-factories/views/templates/react/vite-config-generator.js +0 -29
  142. package/dist/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js +0 -261
  143. package/dist/libs/instance-factories/views/templates/shared/adapter-types.js +0 -34
  144. package/dist/libs/instance-factories/views/templates/shared/atomic-components-registry.js +0 -800
  145. package/dist/libs/instance-factories/views/templates/shared/base-generator.js +0 -305
  146. package/dist/libs/instance-factories/views/templates/shared/component-metadata.js +0 -517
  147. package/dist/libs/instance-factories/views/templates/shared/composite-pattern-types.js +0 -0
  148. package/dist/libs/instance-factories/views/templates/shared/composite-patterns.js +0 -445
  149. package/dist/libs/instance-factories/views/templates/shared/index.js +0 -80
  150. package/dist/libs/instance-factories/views/templates/shared/pattern-validator.js +0 -210
  151. package/dist/libs/instance-factories/views/templates/shared/property-mapper.js +0 -492
  152. package/dist/libs/instance-factories/views/templates/shared/syntax-mapper.js +0 -321
  153. package/dist/realize/index.js.bak +0 -758
  154. package/libs/instance-factories/applications/react-app.yaml +0 -186
  155. package/libs/instance-factories/applications/templates/react/_view-components-source.ts +0 -555
  156. package/libs/instance-factories/applications/templates/react/app-tsx-generator.ts +0 -94
  157. package/libs/instance-factories/applications/templates/react/field-helpers-generator.ts +0 -106
  158. package/libs/instance-factories/applications/templates/react/package-json-generator.ts +0 -57
  159. package/libs/instance-factories/applications/templates/react/pattern-adapter-generator.ts +0 -179
  160. package/libs/instance-factories/applications/templates/react/react-pattern-adapter.tsx +0 -1347
  161. package/libs/instance-factories/applications/templates/react/relationship-field-generator.ts +0 -150
  162. package/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.ts +0 -704
  163. package/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.ts +0 -84
  164. package/libs/instance-factories/applications/templates/react/view-dashboard-generator.ts +0 -150
  165. package/libs/instance-factories/applications/templates/react/view-detail-generator.ts +0 -150
  166. package/libs/instance-factories/applications/templates/react/view-form-generator.ts +0 -362
  167. package/libs/instance-factories/applications/templates/react/view-list-generator.ts +0 -98
  168. package/libs/instance-factories/applications/templates/react/view-router-generator.ts +0 -89
  169. package/libs/instance-factories/views/README.md +0 -62
  170. package/libs/instance-factories/views/index.d.ts +0 -13
  171. package/libs/instance-factories/views/index.d.ts.map +0 -1
  172. package/libs/instance-factories/views/index.js +0 -18
  173. package/libs/instance-factories/views/index.js.map +0 -1
  174. package/libs/instance-factories/views/index.ts +0 -45
  175. package/libs/instance-factories/views/react-components.yaml +0 -129
  176. package/libs/instance-factories/views/templates/ARCHITECTURE.md +0 -198
  177. package/libs/instance-factories/views/templates/react/adapters/antd-adapter.ts +0 -869
  178. package/libs/instance-factories/views/templates/react/adapters/mui-adapter.ts +0 -953
  179. package/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.ts +0 -806
  180. package/libs/instance-factories/views/templates/react/app-generator.ts +0 -55
  181. package/libs/instance-factories/views/templates/react/components-generator.ts +0 -938
  182. package/libs/instance-factories/views/templates/react/forms-generator.ts +0 -325
  183. package/libs/instance-factories/views/templates/react/frontend-package-json-generator.ts +0 -57
  184. package/libs/instance-factories/views/templates/react/hooks-generator.ts +0 -106
  185. package/libs/instance-factories/views/templates/react/index-css-generator.ts +0 -14
  186. package/libs/instance-factories/views/templates/react/index-html-generator.ts +0 -34
  187. package/libs/instance-factories/views/templates/react/main-tsx-generator.ts +0 -29
  188. package/libs/instance-factories/views/templates/react/react-component-generator.d.ts +0 -152
  189. package/libs/instance-factories/views/templates/react/react-component-generator.d.ts.map +0 -1
  190. package/libs/instance-factories/views/templates/react/react-component-generator.js +0 -398
  191. package/libs/instance-factories/views/templates/react/react-component-generator.js.map +0 -1
  192. package/libs/instance-factories/views/templates/react/react-component-generator.ts +0 -533
  193. package/libs/instance-factories/views/templates/react/router-generator.ts +0 -197
  194. package/libs/instance-factories/views/templates/react/router-generic-generator.ts +0 -132
  195. package/libs/instance-factories/views/templates/react/shared-utils-generator.ts +0 -196
  196. package/libs/instance-factories/views/templates/react/spec-json-generator.ts +0 -17
  197. package/libs/instance-factories/views/templates/react/types-generator.ts +0 -76
  198. package/libs/instance-factories/views/templates/react/views-metadata-generator.ts +0 -42
  199. package/libs/instance-factories/views/templates/react/vite-config-generator.ts +0 -38
  200. package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.d.ts.map +0 -1
  201. package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js.map +0 -1
  202. package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.ts +0 -474
  203. package/libs/instance-factories/views/templates/shared/__tests__/composite-patterns.test.ts +0 -242
  204. package/libs/instance-factories/views/templates/shared/adapter-types.d.ts +0 -77
  205. package/libs/instance-factories/views/templates/shared/adapter-types.d.ts.map +0 -1
  206. package/libs/instance-factories/views/templates/shared/adapter-types.js +0 -47
  207. package/libs/instance-factories/views/templates/shared/adapter-types.js.map +0 -1
  208. package/libs/instance-factories/views/templates/shared/adapter-types.ts +0 -142
  209. package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts +0 -63
  210. package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts.map +0 -1
  211. package/libs/instance-factories/views/templates/shared/atomic-components-registry.js +0 -822
  212. package/libs/instance-factories/views/templates/shared/atomic-components-registry.js.map +0 -1
  213. package/libs/instance-factories/views/templates/shared/atomic-components-registry.ts +0 -908
  214. package/libs/instance-factories/views/templates/shared/base-generator.d.ts +0 -247
  215. package/libs/instance-factories/views/templates/shared/base-generator.d.ts.map +0 -1
  216. package/libs/instance-factories/views/templates/shared/base-generator.js +0 -363
  217. package/libs/instance-factories/views/templates/shared/base-generator.js.map +0 -1
  218. package/libs/instance-factories/views/templates/shared/base-generator.ts +0 -608
  219. package/libs/instance-factories/views/templates/shared/component-metadata.d.ts +0 -254
  220. package/libs/instance-factories/views/templates/shared/component-metadata.d.ts.map +0 -1
  221. package/libs/instance-factories/views/templates/shared/component-metadata.js +0 -602
  222. package/libs/instance-factories/views/templates/shared/component-metadata.js.map +0 -1
  223. package/libs/instance-factories/views/templates/shared/component-metadata.ts +0 -803
  224. package/libs/instance-factories/views/templates/shared/composite-pattern-types.ts +0 -250
  225. package/libs/instance-factories/views/templates/shared/composite-patterns.ts +0 -535
  226. package/libs/instance-factories/views/templates/shared/index.ts +0 -68
  227. package/libs/instance-factories/views/templates/shared/pattern-validator.ts +0 -279
  228. package/libs/instance-factories/views/templates/shared/property-mapper.d.ts +0 -149
  229. package/libs/instance-factories/views/templates/shared/property-mapper.d.ts.map +0 -1
  230. package/libs/instance-factories/views/templates/shared/property-mapper.js +0 -580
  231. package/libs/instance-factories/views/templates/shared/property-mapper.js.map +0 -1
  232. package/libs/instance-factories/views/templates/shared/property-mapper.ts +0 -700
  233. package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts +0 -143
  234. package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts.map +0 -1
  235. package/libs/instance-factories/views/templates/shared/syntax-mapper.js +0 -420
  236. package/libs/instance-factories/views/templates/shared/syntax-mapper.js.map +0 -1
  237. package/libs/instance-factories/views/templates/shared/syntax-mapper.ts +0 -539
@@ -1,362 +0,0 @@
1
- /**
2
- * FormView Generator
3
- * Generates local FormView component that uses local hooks with instance-factory-specific API client
4
- */
5
-
6
- export interface ViewFormGeneratorContext {
7
- spec: any;
8
- manifest: any;
9
- }
10
-
11
- export async function generate(context: ViewFormGeneratorContext): Promise<string> {
12
- return `/**
13
- * StandardFormView - Controller-Based Form View Component
14
- *
15
- * LOCAL VERSION - Uses local hooks with instance-factory-specific API client
16
- *
17
- * Supports both Create and Edit modes with:
18
- * - Controller-driven form generation
19
- * - Smart input types (text, number, boolean, relationship selectors)
20
- * - Auto-generated field detection
21
- * - Validation and error handling
22
- * - Lifecycle management (Edit/Evolve tabs)
23
- * - Foreign key relationship fields
24
- * - Two-panel layout (form + entity list)
25
- */
26
-
27
- import { useState, useEffect } from 'react';
28
- import { useEntitiesQuery, useModelSchemaQuery, useExecuteOperationMutation, useTransitionStateMutation } from '../../hooks/useApi';
29
- import { isAutoGeneratedField, isFieldRequired, initializeFormData } from '../../utils/field-helpers';
30
- import { RelationshipField } from '../../components/fields/RelationshipField';
31
- import type { View, Entity } from '../../types/api';
32
-
33
- type FormMode = 'create' | 'update';
34
- type ActiveTab = 'edit' | 'evolve';
35
-
36
- interface StandardFormViewProps {
37
- view: View;
38
- spec?: any; // Full spec for controller access
39
- }
40
-
41
- export function FormView({ view, spec }: StandardFormViewProps) {
42
- // Determine controller and model
43
- let controllerName: string;
44
- let modelName: string;
45
-
46
- if (view.controller && spec) {
47
- // New: Controller-based
48
- controllerName = view.controller;
49
- const controller = spec.controllers[view.controller];
50
- modelName = controller.model;
51
- } else {
52
- // Legacy: Model-based
53
- modelName = view.model as string;
54
- controllerName = \`\${modelName}Controller\`;
55
- }
56
-
57
- const [selectedEntity, setSelectedEntity] = useState<Entity | null>(null);
58
- const [formMode, setFormMode] = useState<FormMode>('create');
59
- const [activeTab, setActiveTab] = useState<ActiveTab>('edit');
60
- const [formData, setFormData] = useState<Record<string, any>>({});
61
- const [errors, setErrors] = useState<Record<string, string>>({});
62
- const [selectedLifecycleStates, setSelectedLifecycleStates] = useState<Record<string, string>>({});
63
-
64
- // Fetch entities and schema - USES LOCAL HOOKS
65
- const { data: entities = [], isLoading: entitiesLoading } = useEntitiesQuery(controllerName, modelName);
66
- const { data: schema } = useModelSchemaQuery(modelName);
67
- const { mutate: executeOperation, isPending } = useExecuteOperationMutation();
68
- const { mutate: transitionState, isPending: isTransitioning } = useTransitionStateMutation();
69
-
70
- const attributes = schema?.attributes || {};
71
- const relationships = schema?.relationships || {};
72
- const lifecycles = schema?.lifecycles || {};
73
-
74
- // Sync selected entity with updated entities list
75
- useEffect(() => {
76
- if (selectedEntity && entities.length > 0) {
77
- const updatedEntity = entities.find((e) => e.id === selectedEntity.id);
78
- if (updatedEntity) {
79
- const oldStates = JSON.stringify(selectedEntity.metadata?.lifecycleStates || {});
80
- const newStates = JSON.stringify(updatedEntity.metadata?.lifecycleStates || {});
81
-
82
- if (oldStates !== newStates) {
83
- setSelectedEntity(updatedEntity);
84
- setSelectedLifecycleStates({ ...(updatedEntity.metadata?.lifecycleStates || {}) });
85
- }
86
- }
87
- }
88
- }, [entities, selectedEntity?.id]);
89
-
90
- // Initialize form data when schema changes or when switching modes
91
- useEffect(() => {
92
- if (selectedEntity && formMode === 'update') {
93
- setFormData({ ...selectedEntity.data });
94
- const currentStates = selectedEntity.metadata?.lifecycleStates || {};
95
- setSelectedLifecycleStates({ ...currentStates });
96
- } else if (schema?.attributes) {
97
- setFormData(initializeFormData(schema.attributes, { includeAutoGenerated: false }));
98
- setSelectedLifecycleStates({});
99
- }
100
- }, [selectedEntity, formMode, schema]);
101
-
102
- // Check if field should be shown
103
- const shouldShowField = (attrName: string, attrDef: any): boolean => {
104
- const isAuto = isAutoGeneratedField(attrName, attrDef);
105
- // In create mode, hide auto-generated fields
106
- if (formMode === 'create' && isAuto) {
107
- return false;
108
- }
109
- // In update mode, show all fields
110
- return true;
111
- };
112
-
113
- // Handle form submission
114
- const handleSubmit = async (e: React.FormEvent) => {
115
- e.preventDefault();
116
- setErrors({});
117
-
118
- const operation = formMode === 'create' ? 'create' : 'update';
119
- const params = formMode === 'update' && selectedEntity
120
- ? { ...formData, id: selectedEntity.id }
121
- : formData;
122
-
123
- executeOperation(
124
- { controllerName, operationName: operation, params },
125
- {
126
- onSuccess: () => {
127
- if (formMode === 'create' && schema?.attributes) {
128
- setFormData(initializeFormData(schema.attributes, { includeAutoGenerated: false }));
129
- }
130
- setFormMode('create');
131
- setSelectedEntity(null);
132
- },
133
- onError: (error: any) => {
134
- setErrors({ _form: error.message || 'Operation failed' });
135
- }
136
- }
137
- );
138
- };
139
-
140
- // Handle entity selection for editing
141
- const handleEntitySelect = (entity: Entity) => {
142
- setSelectedEntity(entity);
143
- setFormMode('update');
144
- setActiveTab('edit');
145
- };
146
-
147
- // Handle lifecycle state transition
148
- const handleLifecycleTransition = (lifecycleName: string, toState: string) => {
149
- if (!selectedEntity) return;
150
-
151
- transitionState(
152
- { modelName, entityId: selectedEntity.id, toState, lifecycleName },
153
- {
154
- onSuccess: () => {
155
- setSelectedLifecycleStates((prev) => ({ ...prev, [lifecycleName]: toState }));
156
- },
157
- onError: (error: any) => {
158
- setErrors({ _lifecycle: error.message || 'Transition failed' });
159
- }
160
- }
161
- );
162
- };
163
-
164
- // Render field input
165
- const renderFieldInput = (attrName: string, attrDef: any) => {
166
- const value = formData[attrName] ?? '';
167
- const isRequired = isFieldRequired(attrDef);
168
-
169
- const handleChange = (newValue: any) => {
170
- setFormData((prev) => ({ ...prev, [attrName]: newValue }));
171
- };
172
-
173
- // Boolean field
174
- if (attrDef.type === 'Boolean') {
175
- return (
176
- <input
177
- type="checkbox"
178
- checked={!!value}
179
- onChange={(e) => handleChange(e.target.checked)}
180
- className="h-4 w-4 rounded border-gray-300"
181
- />
182
- );
183
- }
184
-
185
- // Number field
186
- if (attrDef.type === 'Integer' || attrDef.type === 'Float' || attrDef.type === 'Decimal') {
187
- return (
188
- <input
189
- type="number"
190
- value={value}
191
- onChange={(e) => handleChange(e.target.value ? Number(e.target.value) : '')}
192
- required={isRequired}
193
- className="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
194
- />
195
- );
196
- }
197
-
198
- // Text field (default)
199
- return (
200
- <input
201
- type="text"
202
- value={value}
203
- onChange={(e) => handleChange(e.target.value)}
204
- required={isRequired}
205
- className="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
206
- />
207
- );
208
- };
209
-
210
- return (
211
- <div className="flex gap-4 h-full">
212
- {/* Form Panel */}
213
- <div className="flex-1 bg-white dark:bg-gray-800 rounded-lg shadow p-6">
214
- <h2 className="text-2xl font-bold mb-4 text-gray-800 dark:text-white">
215
- {formMode === 'create' ? \`Create \${modelName}\` : \`Edit \${modelName}\`}
216
- </h2>
217
-
218
- {/* Tabs for Edit/Evolve modes */}
219
- {formMode === 'update' && Object.keys(lifecycles).length > 0 && (
220
- <div className="flex gap-2 mb-4 border-b border-gray-200">
221
- <button
222
- onClick={() => setActiveTab('edit')}
223
- className={\`px-4 py-2 font-medium \${activeTab === 'edit' ? 'border-b-2 border-blue-500 text-blue-600' : 'text-gray-500'}\`}
224
- >
225
- Edit Data
226
- </button>
227
- <button
228
- onClick={() => setActiveTab('evolve')}
229
- className={\`px-4 py-2 font-medium \${activeTab === 'evolve' ? 'border-b-2 border-blue-500 text-blue-600' : 'text-gray-500'}\`}
230
- >
231
- Lifecycle
232
- </button>
233
- </div>
234
- )}
235
-
236
- {activeTab === 'edit' ? (
237
- <form onSubmit={handleSubmit} className="space-y-4">
238
- {errors._form && (
239
- <div className="p-3 bg-red-100 text-red-700 rounded-md">{errors._form}</div>
240
- )}
241
-
242
- {/* Attributes */}
243
- {Object.entries(attributes).map(([attrName, attrDef]: [string, any]) => {
244
- if (!shouldShowField(attrName, attrDef)) return null;
245
-
246
- return (
247
- <div key={attrName}>
248
- <label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
249
- {attrName}
250
- {isFieldRequired(attrDef) && <span className="text-red-500">*</span>}
251
- </label>
252
- {renderFieldInput(attrName, attrDef)}
253
- </div>
254
- );
255
- })}
256
-
257
- {/* Relationships */}
258
- {Object.entries(relationships).map(([relName, relDef]: [string, any]) => (
259
- <RelationshipField
260
- key={relName}
261
- name={relName}
262
- relationship={relDef}
263
- value={formData[relName]}
264
- onChange={(value) => setFormData((prev) => ({ ...prev, [relName]: value }))}
265
- />
266
- ))}
267
-
268
- <div className="flex gap-2 pt-4">
269
- <button
270
- type="submit"
271
- disabled={isPending}
272
- className="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50"
273
- >
274
- {isPending ? 'Saving...' : formMode === 'create' ? 'Create' : 'Update'}
275
- </button>
276
- {formMode === 'update' && (
277
- <button
278
- type="button"
279
- onClick={() => {
280
- setFormMode('create');
281
- setSelectedEntity(null);
282
- if (schema?.attributes) {
283
- setFormData(initializeFormData(schema.attributes, { includeAutoGenerated: false }));
284
- }
285
- }}
286
- className="px-4 py-2 bg-gray-500 text-white rounded-md hover:bg-gray-600"
287
- >
288
- Cancel
289
- </button>
290
- )}
291
- </div>
292
- </form>
293
- ) : (
294
- /* Lifecycle Tab */
295
- <div className="space-y-4">
296
- {errors._lifecycle && (
297
- <div className="p-3 bg-red-100 text-red-700 rounded-md">{errors._lifecycle}</div>
298
- )}
299
-
300
- {Object.entries(lifecycles).map(([lifecycleName, lifecycle]: [string, any]) => {
301
- const currentState = selectedLifecycleStates[lifecycleName] || lifecycle.initial;
302
-
303
- return (
304
- <div key={lifecycleName} className="border border-gray-200 rounded-lg p-4">
305
- <h3 className="font-semibold text-lg mb-2">{lifecycleName}</h3>
306
- <p className="text-sm text-gray-600 mb-3">Current: {currentState}</p>
307
-
308
- <div className="flex flex-wrap gap-2">
309
- {Object.keys(lifecycle.states || {}).map((state) => (
310
- <button
311
- key={state}
312
- onClick={() => handleLifecycleTransition(lifecycleName, state)}
313
- disabled={isTransitioning || state === currentState}
314
- className={\`px-3 py-1 rounded-md \${state === currentState ? 'bg-blue-600 text-white' : 'bg-gray-200 text-gray-700 hover:bg-gray-300'} disabled:opacity-50\`}
315
- >
316
- {state}
317
- </button>
318
- ))}
319
- </div>
320
- </div>
321
- );
322
- })}
323
- </div>
324
- )}
325
- </div>
326
-
327
- {/* Entity List Panel */}
328
- <div className="w-80 bg-white dark:bg-gray-800 rounded-lg shadow p-4">
329
- <h3 className="text-lg font-semibold mb-3 text-gray-800 dark:text-white">
330
- {modelName} List
331
- </h3>
332
-
333
- {entitiesLoading ? (
334
- <p className="text-gray-500">Loading...</p>
335
- ) : entities.length === 0 ? (
336
- <p className="text-gray-500 italic">No entities yet</p>
337
- ) : (
338
- <div className="space-y-2">
339
- {entities.map((entity) => (
340
- <div
341
- key={entity.id}
342
- onClick={() => handleEntitySelect(entity)}
343
- className={\`p-3 rounded-md cursor-pointer \${selectedEntity?.id === entity.id ? 'bg-blue-100 border-blue-500' : 'bg-gray-50 hover:bg-gray-100'} border\`}
344
- >
345
- <p className="font-medium text-sm">{entity.id}</p>
346
- {Object.entries(entity.data).slice(0, 2).map(([key, value]) => (
347
- <p key={key} className="text-xs text-gray-600">
348
- {key}: {String(value)}
349
- </p>
350
- ))}
351
- </div>
352
- ))}
353
- </div>
354
- )}
355
- </div>
356
- </div>
357
- );
358
- }
359
-
360
- export default FormView;
361
- `;
362
- }
@@ -1,98 +0,0 @@
1
- /**
2
- * ListView Generator (Pattern-Based v0.9.0)
3
- * Generates pattern-based ListView using RuntimeView architecture
4
- */
5
-
6
- export interface ViewListGeneratorContext {
7
- spec: any;
8
- manifest: any;
9
- }
10
-
11
- export async function generate(context: ViewListGeneratorContext): Promise<string> {
12
- return `/**
13
- * ListView - Pattern-Based List View Component
14
- *
15
- * Uses pattern-based rendering with ReactPatternAdapter.
16
- * Reads from modelSchemas for schema-driven field generation.
17
- */
18
-
19
- import { useMemo } from 'react';
20
- import { useEntitiesQuery, useModelSchemaQuery } from '../../hooks/useApi';
21
- import { usePatternAdapter, REACT_PROTOCOL_MAPPING } from '../../lib/react-pattern-adapter';
22
- import type { View } from '../../types/api';
23
-
24
- interface ListViewProps {
25
- view: View;
26
- spec?: any;
27
- }
28
-
29
- export function ListView({ view, spec }: ListViewProps) {
30
- const patternAdapter = usePatternAdapter();
31
-
32
- // Determine controller and model
33
- let controllerName: string;
34
- let modelName: string;
35
-
36
- if (view.controller && spec) {
37
- controllerName = view.controller;
38
- const controller = spec.controllers[view.controller];
39
- modelName = controller.model;
40
- } else {
41
- modelName = view.model as string;
42
- controllerName = \`\${modelName}Controller\`;
43
- }
44
-
45
- // Fetch data and schema
46
- const { data: entities = [], isLoading } = useEntitiesQuery(controllerName, modelName);
47
- const { data: schema } = useModelSchemaQuery(modelName);
48
-
49
- // Build model data and schemas
50
- const modelData = useMemo(() => ({
51
- [modelName]: entities
52
- }), [modelName, entities]);
53
-
54
- const modelSchemas = useMemo(() =>
55
- schema ? { [modelName]: schema } : {}
56
- , [modelName, schema]);
57
-
58
- if (isLoading) {
59
- return <div className="p-4">Loading...</div>;
60
- }
61
-
62
- // Detect pattern
63
- const pattern = patternAdapter.detectPattern({ ...view, type: 'list' });
64
-
65
- if (!pattern) {
66
- return (
67
- <div className="p-4 text-red-600">
68
- Pattern not found for list view
69
- </div>
70
- );
71
- }
72
-
73
- // Build render context
74
- const context = {
75
- pattern,
76
- viewSpec: { ...view, type: 'list', model: modelName },
77
- modelData,
78
- modelSchemas,
79
- primaryModel: modelName,
80
- selectedEntity: null,
81
- primaryEntities: entities,
82
- protocolMapping: REACT_PROTOCOL_MAPPING,
83
- tailwindAdapter: patternAdapter['tailwindAdapter']
84
- };
85
-
86
- // Render pattern
87
- const html = patternAdapter.renderPattern(context);
88
-
89
- return (
90
- <div className="runtime-view-container p-4 h-full overflow-auto">
91
- <div dangerouslySetInnerHTML={{ __html: html }} />
92
- </div>
93
- );
94
- }
95
-
96
- export default ListView;
97
- `;
98
- }
@@ -1,89 +0,0 @@
1
- /**
2
- * View Router Generator (Hybrid v0.9.0)
3
- *
4
- * Generates ViewRouter with hybrid routing:
5
- * - Forms → FormView (controller-based with React hooks)
6
- * - Display views → Pattern-based rendering
7
- */
8
-
9
- export interface ViewRouterGeneratorContext {
10
- spec: any;
11
- manifest: any;
12
- }
13
-
14
- export async function generate(context: ViewRouterGeneratorContext): Promise<string> {
15
- return `/**
16
- * ViewRouter - Hybrid View Router
17
- *
18
- * Pattern-Based Rendering Architecture:
19
- * - Forms (interactive) → FormView (controller-based with React hooks)
20
- * - Display views → Pattern-based rendering (list, detail, dashboard)
21
- *
22
- * Benefits:
23
- * - Forms get React hooks, state management, UUID handling
24
- * - Display views get schema-driven pattern rendering
25
- * - Both approaches coexist seamlessly
26
- */
27
-
28
- import type { View } from '../../types/api';
29
- import { FormView } from './FormView';
30
- import { ListView } from './ListView';
31
- import { DetailView } from './DetailView';
32
- import { DashboardView } from './DashboardView';
33
-
34
- interface ViewRouterProps {
35
- view: View;
36
- spec?: any; // Full spec for controller access
37
- }
38
-
39
- export function ViewRouter({ view, spec }: ViewRouterProps) {
40
- const viewType = view.type?.toLowerCase();
41
-
42
- // Determine rendering strategy
43
- const useFormRenderer = (type: string): boolean => {
44
- // Forms require React hooks and state - use FormView (controller-based)
45
- const interactiveTypes = ['form', 'create', 'edit', 'create-form', 'edit-form'];
46
- return interactiveTypes.includes(type);
47
- };
48
-
49
- // Route to appropriate renderer
50
- if (useFormRenderer(viewType)) {
51
- // Controller-based form with React hooks
52
- return <FormView view={view} spec={spec} />;
53
- }
54
-
55
- // Pattern-based rendering for display views
56
- switch (viewType) {
57
- case 'list':
58
- case 'table':
59
- return <ListView view={view} spec={spec} />;
60
-
61
- case 'detail':
62
- case 'master-detail':
63
- return <DetailView view={view} spec={spec} />;
64
-
65
- case 'dashboard':
66
- return <DashboardView view={view} spec={spec} />;
67
-
68
- default:
69
- return (
70
- <div className="flex items-center justify-center h-full p-8">
71
- <div className="text-center">
72
- <h3 className="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-2">
73
- Unknown View Type: {view.type}
74
- </h3>
75
- <p className="text-gray-500 dark:text-gray-400">
76
- View "{view.name}" has an unsupported type.
77
- </p>
78
- <p className="text-sm text-gray-400 dark:text-gray-500 mt-2">
79
- Supported types: list, detail, dashboard, form
80
- </p>
81
- </div>
82
- </div>
83
- );
84
- }
85
- }
86
-
87
- export default ViewRouter;
88
- `;
89
- }
@@ -1,62 +0,0 @@
1
- # Views Factory
2
-
3
- React component generation from spec views with adapter support and routing.
4
-
5
- ## Definition
6
-
7
- | File | Description |
8
- |------|-------------|
9
- | `react-components.yaml` | React 18 components with TypeScript, hooks, forms, and routing |
10
-
11
- ## Generated Output
12
-
13
- ### Components (`react/`)
14
-
15
- | Generator | Output | Purpose |
16
- |-----------|--------|---------|
17
- | `components-generator` | `frontend/src/components/{view}.tsx` | Direct React components from spec views (uses real model attributes) |
18
- | `forms-generator` | `frontend/src/components/forms/{model}Form.tsx` | Form components with react-hook-form and Zod validation |
19
- | `hooks-generator` | `frontend/src/hooks/use{model}.ts` | Custom hooks for data fetching and mutations |
20
- | `types-generator` | `frontend/src/types/{model}.ts` | TypeScript interfaces from spec models |
21
- | `app-generator` | `frontend/src/App.tsx` | Root component with React Query and Router setup |
22
- | `router-generator` | `frontend/src/router.tsx` | React Router v6 routes from spec views |
23
- | `router-generic-generator` | (alternative router) | Generic routing variant |
24
- | `main-tsx-generator` | `frontend/src/main.tsx` | React DOM render entry |
25
- | `vite-config-generator` | `frontend/vite.config.ts` | Vite bundler configuration |
26
- | `index-html-generator` | `frontend/index.html` | HTML shell |
27
- | `index-css-generator` | `frontend/src/index.css` | Base styles |
28
- | `frontend-package-json-generator` | `frontend/package.json` | Frontend dependencies |
29
- | `spec-json-generator` | (spec metadata) | Serialized spec for frontend consumption |
30
- | `views-metadata-generator` | (view metadata) | View definitions for runtime rendering |
31
-
32
- ### Adapters (`react/adapters/`)
33
-
34
- | Adapter | UI Library |
35
- |---------|-----------|
36
- | `shadcn-adapter` | shadcn/ui |
37
- | `mui-adapter` | Material UI |
38
- | `antd-adapter` | Ant Design |
39
-
40
- ### Shared Infrastructure (`shared/`)
41
-
42
- - `base-generator` — Abstract base class for all component generators
43
- - `adapter-types` — TypeScript types for UI library adapters
44
- - `property-mapper` — Maps spec properties to component props
45
- - `syntax-mapper` — Maps spec syntax to framework-specific JSX
46
- - `atomic-components-registry` — Registry of atomic UI components
47
- - `component-metadata` — Component metadata extraction
48
- - `composite-patterns` — Composite pattern support (master-detail, wizard, etc.)
49
- - `pattern-validator` — Validates view patterns against spec
50
-
51
- ### Runtime (`runtime/`)
52
-
53
- - `runtime-view-renderer` — Dynamic view renderer from spec metadata
54
-
55
- ## Technology
56
-
57
- - **Framework**: React ^18.2.0 with TypeScript
58
- - **Routing**: React Router ^6.18.0
59
- - **Data**: TanStack React Query ^5.0.0
60
- - **Forms**: react-hook-form ^7.48.0 + Zod ^3.22.0
61
- - **Bundler**: Vite ^5.0.0
62
- - **Styling**: Tailwind CSS (BEM class naming)
@@ -1,13 +0,0 @@
1
- /**
2
- * View Instance Factories - Public API
3
- *
4
- * Exports all view generation and rendering components
5
- */
6
- export * from './templates/shared/base-generator.js';
7
- export * from './templates/shared/property-mapper.js';
8
- export * from './templates/shared/syntax-mapper.js';
9
- export * from './templates/shared/component-metadata.js';
10
- export * from './templates/shared/adapter-types.js';
11
- export * from './templates/react/react-component-generator.js';
12
- export * from './templates/runtime/runtime-view-renderer.js';
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,cAAc,qCAAqC,CAAC;AAGpD,cAAc,gDAAgD,CAAC;AAG/D,cAAc,8CAA8C,CAAC"}
@@ -1,18 +0,0 @@
1
- /**
2
- * View Instance Factories - Public API
3
- *
4
- * Exports all view generation and rendering components
5
- */
6
- // Shared components
7
- export * from './templates/shared/base-generator.js';
8
- export * from './templates/shared/property-mapper.js';
9
- export * from './templates/shared/syntax-mapper.js';
10
- export * from './templates/shared/component-metadata.js';
11
- export * from './templates/shared/adapter-types.js';
12
- // React generator
13
- export * from './templates/react/react-component-generator.js';
14
- // Runtime renderer
15
- export * from './templates/runtime/runtime-view-renderer.js';
16
- // Adapters registry (when we add adapters)
17
- // export * from './adapters/index.js';
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oBAAoB;AACpB,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,cAAc,qCAAqC,CAAC;AAEpD,kBAAkB;AAClB,cAAc,gDAAgD,CAAC;AAE/D,mBAAmB;AACnB,cAAc,8CAA8C,CAAC;AAE7D,2CAA2C;AAC3C,uCAAuC"}