@specverse/engines 4.1.30 → 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 (226) 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/react-starter/app-tsx-generator.js +110 -0
  45. package/dist/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.js +121 -0
  46. package/dist/libs/instance-factories/applications/templates/react-starter/detail-body-composer.js +78 -0
  47. package/dist/libs/instance-factories/applications/templates/react-starter/form-body-composer.js +190 -0
  48. package/dist/libs/instance-factories/applications/templates/react-starter/helpers-emitter.js +45 -0
  49. package/dist/libs/instance-factories/applications/templates/react-starter/html-to-jsx.js +192 -0
  50. package/dist/libs/instance-factories/applications/templates/react-starter/list-body-composer.js +46 -0
  51. package/dist/libs/instance-factories/applications/templates/react-starter/orchestrator.js +30 -0
  52. package/dist/libs/instance-factories/applications/templates/react-starter/package-json-generator.js +38 -0
  53. package/dist/libs/instance-factories/applications/templates/react-starter/regen-safety.js +89 -0
  54. package/dist/libs/instance-factories/applications/templates/react-starter/view-emitter.js +56 -0
  55. package/dist/libs/instance-factories/applications/templates/react-starter/views-generator.js +66 -0
  56. package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +14 -11
  57. package/dist/realize/index.d.ts.map +1 -1
  58. package/dist/realize/index.js +15 -22
  59. package/dist/realize/index.js.map +1 -1
  60. package/dist/registry/utils/manifest-adapter.d.ts +8 -1
  61. package/dist/registry/utils/manifest-adapter.d.ts.map +1 -1
  62. package/dist/registry/utils/manifest-adapter.js +8 -1
  63. package/dist/registry/utils/manifest-adapter.js.map +1 -1
  64. package/libs/instance-factories/applications/react-app-starter.yaml +150 -0
  65. package/libs/instance-factories/applications/templates/react-starter/README.md +211 -0
  66. package/libs/instance-factories/applications/templates/react-starter/__tests__/dashboard-body-composer.test.ts +153 -0
  67. package/libs/instance-factories/applications/templates/react-starter/__tests__/detail-body-composer.test.ts +145 -0
  68. package/libs/instance-factories/applications/templates/react-starter/__tests__/form-body-composer.test.ts +175 -0
  69. package/libs/instance-factories/applications/templates/react-starter/__tests__/helpers-emitter.test.ts +55 -0
  70. package/libs/instance-factories/applications/templates/react-starter/__tests__/html-to-jsx.test.ts +140 -0
  71. package/libs/instance-factories/applications/templates/react-starter/__tests__/list-body-composer.test.ts +146 -0
  72. package/libs/instance-factories/applications/templates/react-starter/__tests__/orchestrator.test.ts +163 -0
  73. package/libs/instance-factories/applications/templates/react-starter/__tests__/parity-p2-factory-imports.test.ts +116 -0
  74. package/libs/instance-factories/applications/templates/react-starter/__tests__/parity-p3-rendered-output.test.ts +183 -0
  75. package/libs/instance-factories/applications/templates/react-starter/__tests__/regen-safety.test.ts +144 -0
  76. package/libs/instance-factories/applications/templates/react-starter/__tests__/starter-generators.test.ts +114 -0
  77. package/libs/instance-factories/applications/templates/react-starter/__tests__/view-emitter.test.ts +107 -0
  78. package/libs/instance-factories/applications/templates/react-starter/__tests__/views-generator.test.ts +139 -0
  79. package/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.ts +141 -0
  80. package/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.ts +174 -0
  81. package/libs/instance-factories/applications/templates/react-starter/detail-body-composer.ts +135 -0
  82. package/libs/instance-factories/applications/templates/react-starter/form-body-composer.ts +306 -0
  83. package/libs/instance-factories/applications/templates/react-starter/helpers-emitter.ts +60 -0
  84. package/libs/instance-factories/applications/templates/react-starter/html-to-jsx.ts +334 -0
  85. package/libs/instance-factories/applications/templates/react-starter/list-body-composer.ts +120 -0
  86. package/libs/instance-factories/applications/templates/react-starter/orchestrator.ts +80 -0
  87. package/libs/instance-factories/applications/templates/react-starter/package-json-generator.ts +57 -0
  88. package/libs/instance-factories/applications/templates/react-starter/regen-safety.ts +157 -0
  89. package/libs/instance-factories/applications/templates/react-starter/skeletons/dashboard.tsx.template +47 -0
  90. package/libs/instance-factories/applications/templates/react-starter/skeletons/detail.tsx.template +94 -0
  91. package/libs/instance-factories/applications/templates/react-starter/skeletons/form.tsx.template +114 -0
  92. package/libs/instance-factories/applications/templates/react-starter/skeletons/list.tsx.template +72 -0
  93. package/libs/instance-factories/applications/templates/react-starter/view-emitter.ts +151 -0
  94. package/libs/instance-factories/applications/templates/react-starter/views-generator.ts +137 -0
  95. package/libs/instance-factories/cli/templates/commander/command-generator.ts +14 -11
  96. package/package.json +3 -3
  97. package/dist/libs/instance-factories/applications/templates/react/_view-components-source.js +0 -530
  98. package/dist/libs/instance-factories/applications/templates/react/app-tsx-generator.js +0 -73
  99. package/dist/libs/instance-factories/applications/templates/react/field-helpers-generator.js +0 -99
  100. package/dist/libs/instance-factories/applications/templates/react/package-json-generator.js +0 -49
  101. package/dist/libs/instance-factories/applications/templates/react/pattern-adapter-generator.js +0 -156
  102. package/dist/libs/instance-factories/applications/templates/react/react-pattern-adapter.js +0 -935
  103. package/dist/libs/instance-factories/applications/templates/react/relationship-field-generator.js +0 -143
  104. package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.js +0 -646
  105. package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.js +0 -65
  106. package/dist/libs/instance-factories/applications/templates/react/view-dashboard-generator.js +0 -143
  107. package/dist/libs/instance-factories/applications/templates/react/view-detail-generator.js +0 -143
  108. package/dist/libs/instance-factories/applications/templates/react/view-form-generator.js +0 -355
  109. package/dist/libs/instance-factories/applications/templates/react/view-list-generator.js +0 -91
  110. package/dist/libs/instance-factories/applications/templates/react/view-router-generator.js +0 -79
  111. package/dist/libs/instance-factories/views/index.js +0 -48
  112. package/dist/libs/instance-factories/views/templates/react/adapters/antd-adapter.js +0 -742
  113. package/dist/libs/instance-factories/views/templates/react/adapters/mui-adapter.js +0 -824
  114. package/dist/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.js +0 -719
  115. package/dist/libs/instance-factories/views/templates/react/app-generator.js +0 -45
  116. package/dist/libs/instance-factories/views/templates/react/components-generator.js +0 -820
  117. package/dist/libs/instance-factories/views/templates/react/forms-generator.js +0 -275
  118. package/dist/libs/instance-factories/views/templates/react/frontend-package-json-generator.js +0 -46
  119. package/dist/libs/instance-factories/views/templates/react/hooks-generator.js +0 -81
  120. package/dist/libs/instance-factories/views/templates/react/index-css-generator.js +0 -9
  121. package/dist/libs/instance-factories/views/templates/react/index-html-generator.js +0 -23
  122. package/dist/libs/instance-factories/views/templates/react/main-tsx-generator.js +0 -21
  123. package/dist/libs/instance-factories/views/templates/react/react-component-generator.js +0 -299
  124. package/dist/libs/instance-factories/views/templates/react/router-generator.js +0 -136
  125. package/dist/libs/instance-factories/views/templates/react/router-generic-generator.js +0 -107
  126. package/dist/libs/instance-factories/views/templates/react/shared-utils-generator.js +0 -187
  127. package/dist/libs/instance-factories/views/templates/react/spec-json-generator.js +0 -7
  128. package/dist/libs/instance-factories/views/templates/react/types-generator.js +0 -56
  129. package/dist/libs/instance-factories/views/templates/react/views-metadata-generator.js +0 -27
  130. package/dist/libs/instance-factories/views/templates/react/vite-config-generator.js +0 -29
  131. package/dist/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js +0 -261
  132. package/dist/libs/instance-factories/views/templates/shared/adapter-types.js +0 -34
  133. package/dist/libs/instance-factories/views/templates/shared/atomic-components-registry.js +0 -800
  134. package/dist/libs/instance-factories/views/templates/shared/base-generator.js +0 -305
  135. package/dist/libs/instance-factories/views/templates/shared/component-metadata.js +0 -517
  136. package/dist/libs/instance-factories/views/templates/shared/composite-pattern-types.js +0 -0
  137. package/dist/libs/instance-factories/views/templates/shared/composite-patterns.js +0 -445
  138. package/dist/libs/instance-factories/views/templates/shared/index.js +0 -80
  139. package/dist/libs/instance-factories/views/templates/shared/pattern-validator.js +0 -210
  140. package/dist/libs/instance-factories/views/templates/shared/property-mapper.js +0 -492
  141. package/dist/libs/instance-factories/views/templates/shared/syntax-mapper.js +0 -321
  142. package/dist/realize/index.js.bak +0 -758
  143. package/libs/instance-factories/applications/react-app.yaml +0 -186
  144. package/libs/instance-factories/applications/templates/react/_view-components-source.ts +0 -555
  145. package/libs/instance-factories/applications/templates/react/app-tsx-generator.ts +0 -94
  146. package/libs/instance-factories/applications/templates/react/field-helpers-generator.ts +0 -106
  147. package/libs/instance-factories/applications/templates/react/package-json-generator.ts +0 -57
  148. package/libs/instance-factories/applications/templates/react/pattern-adapter-generator.ts +0 -179
  149. package/libs/instance-factories/applications/templates/react/react-pattern-adapter.tsx +0 -1347
  150. package/libs/instance-factories/applications/templates/react/relationship-field-generator.ts +0 -150
  151. package/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.ts +0 -704
  152. package/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.ts +0 -84
  153. package/libs/instance-factories/applications/templates/react/view-dashboard-generator.ts +0 -150
  154. package/libs/instance-factories/applications/templates/react/view-detail-generator.ts +0 -150
  155. package/libs/instance-factories/applications/templates/react/view-form-generator.ts +0 -362
  156. package/libs/instance-factories/applications/templates/react/view-list-generator.ts +0 -98
  157. package/libs/instance-factories/applications/templates/react/view-router-generator.ts +0 -89
  158. package/libs/instance-factories/views/README.md +0 -62
  159. package/libs/instance-factories/views/index.d.ts +0 -13
  160. package/libs/instance-factories/views/index.d.ts.map +0 -1
  161. package/libs/instance-factories/views/index.js +0 -18
  162. package/libs/instance-factories/views/index.js.map +0 -1
  163. package/libs/instance-factories/views/index.ts +0 -45
  164. package/libs/instance-factories/views/react-components.yaml +0 -129
  165. package/libs/instance-factories/views/templates/ARCHITECTURE.md +0 -198
  166. package/libs/instance-factories/views/templates/react/adapters/antd-adapter.ts +0 -869
  167. package/libs/instance-factories/views/templates/react/adapters/mui-adapter.ts +0 -953
  168. package/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.ts +0 -806
  169. package/libs/instance-factories/views/templates/react/app-generator.ts +0 -55
  170. package/libs/instance-factories/views/templates/react/components-generator.ts +0 -938
  171. package/libs/instance-factories/views/templates/react/forms-generator.ts +0 -325
  172. package/libs/instance-factories/views/templates/react/frontend-package-json-generator.ts +0 -57
  173. package/libs/instance-factories/views/templates/react/hooks-generator.ts +0 -106
  174. package/libs/instance-factories/views/templates/react/index-css-generator.ts +0 -14
  175. package/libs/instance-factories/views/templates/react/index-html-generator.ts +0 -34
  176. package/libs/instance-factories/views/templates/react/main-tsx-generator.ts +0 -29
  177. package/libs/instance-factories/views/templates/react/react-component-generator.d.ts +0 -152
  178. package/libs/instance-factories/views/templates/react/react-component-generator.d.ts.map +0 -1
  179. package/libs/instance-factories/views/templates/react/react-component-generator.js +0 -398
  180. package/libs/instance-factories/views/templates/react/react-component-generator.js.map +0 -1
  181. package/libs/instance-factories/views/templates/react/react-component-generator.ts +0 -533
  182. package/libs/instance-factories/views/templates/react/router-generator.ts +0 -197
  183. package/libs/instance-factories/views/templates/react/router-generic-generator.ts +0 -132
  184. package/libs/instance-factories/views/templates/react/shared-utils-generator.ts +0 -196
  185. package/libs/instance-factories/views/templates/react/spec-json-generator.ts +0 -17
  186. package/libs/instance-factories/views/templates/react/types-generator.ts +0 -76
  187. package/libs/instance-factories/views/templates/react/views-metadata-generator.ts +0 -42
  188. package/libs/instance-factories/views/templates/react/vite-config-generator.ts +0 -38
  189. package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.d.ts.map +0 -1
  190. package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js.map +0 -1
  191. package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.ts +0 -474
  192. package/libs/instance-factories/views/templates/shared/__tests__/composite-patterns.test.ts +0 -242
  193. package/libs/instance-factories/views/templates/shared/adapter-types.d.ts +0 -77
  194. package/libs/instance-factories/views/templates/shared/adapter-types.d.ts.map +0 -1
  195. package/libs/instance-factories/views/templates/shared/adapter-types.js +0 -47
  196. package/libs/instance-factories/views/templates/shared/adapter-types.js.map +0 -1
  197. package/libs/instance-factories/views/templates/shared/adapter-types.ts +0 -142
  198. package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts +0 -63
  199. package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts.map +0 -1
  200. package/libs/instance-factories/views/templates/shared/atomic-components-registry.js +0 -822
  201. package/libs/instance-factories/views/templates/shared/atomic-components-registry.js.map +0 -1
  202. package/libs/instance-factories/views/templates/shared/atomic-components-registry.ts +0 -908
  203. package/libs/instance-factories/views/templates/shared/base-generator.d.ts +0 -247
  204. package/libs/instance-factories/views/templates/shared/base-generator.d.ts.map +0 -1
  205. package/libs/instance-factories/views/templates/shared/base-generator.js +0 -363
  206. package/libs/instance-factories/views/templates/shared/base-generator.js.map +0 -1
  207. package/libs/instance-factories/views/templates/shared/base-generator.ts +0 -608
  208. package/libs/instance-factories/views/templates/shared/component-metadata.d.ts +0 -254
  209. package/libs/instance-factories/views/templates/shared/component-metadata.d.ts.map +0 -1
  210. package/libs/instance-factories/views/templates/shared/component-metadata.js +0 -602
  211. package/libs/instance-factories/views/templates/shared/component-metadata.js.map +0 -1
  212. package/libs/instance-factories/views/templates/shared/component-metadata.ts +0 -803
  213. package/libs/instance-factories/views/templates/shared/composite-pattern-types.ts +0 -250
  214. package/libs/instance-factories/views/templates/shared/composite-patterns.ts +0 -535
  215. package/libs/instance-factories/views/templates/shared/index.ts +0 -68
  216. package/libs/instance-factories/views/templates/shared/pattern-validator.ts +0 -279
  217. package/libs/instance-factories/views/templates/shared/property-mapper.d.ts +0 -149
  218. package/libs/instance-factories/views/templates/shared/property-mapper.d.ts.map +0 -1
  219. package/libs/instance-factories/views/templates/shared/property-mapper.js +0 -580
  220. package/libs/instance-factories/views/templates/shared/property-mapper.js.map +0 -1
  221. package/libs/instance-factories/views/templates/shared/property-mapper.ts +0 -700
  222. package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts +0 -143
  223. package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts.map +0 -1
  224. package/libs/instance-factories/views/templates/shared/syntax-mapper.js +0 -420
  225. package/libs/instance-factories/views/templates/shared/syntax-mapper.js.map +0 -1
  226. package/libs/instance-factories/views/templates/shared/syntax-mapper.ts +0 -539
@@ -1,187 +0,0 @@
1
- function generateSharedUtils(context) {
2
- const files = [
3
- { path: "field-helpers.ts", content: generateFieldHelpers() },
4
- { path: "view-helpers.tsx", content: generateViewHelpers() }
5
- ];
6
- return { files };
7
- }
8
- function generateFieldHelpers() {
9
- return `/**
10
- * Field Helpers \u2014 shared utilities for field classification and display
11
- * Generated by SpecVerse React factory
12
- */
13
-
14
- const METADATA_FIELDS = new Set([
15
- 'id', 'createdAt', 'updatedAt', 'createdBy', 'updatedBy', 'deletedAt', 'version'
16
- ]);
17
-
18
- const AUTO_PATTERNS = new Set(['now', 'uuid4', 'autoincrement', 'auto']);
19
-
20
- /**
21
- * Check if a field is auto-generated (should be hidden from forms)
22
- */
23
- export function isAutoField(name: string, attr: any): boolean {
24
- if (attr?.auto && AUTO_PATTERNS.has(attr.auto)) return true;
25
- if (name === 'id') return true;
26
- if (METADATA_FIELDS.has(name) && attr?.type?.toLowerCase().includes('date')) return true;
27
- return false;
28
- }
29
-
30
- /**
31
- * Check if a field is metadata (shown last, styled muted)
32
- */
33
- export function isMetadataField(name: string): boolean {
34
- return METADATA_FIELDS.has(name);
35
- }
36
-
37
- /**
38
- * Get the best display name for an entity
39
- * Searches common name fields in priority order
40
- */
41
- export function getEntityDisplayName(entity: any): string {
42
- if (!entity) return 'Unknown';
43
- const METADATA = new Set(['id', 'createdAt', 'updatedAt', 'createdBy', 'updatedBy', 'deletedAt', 'version']);
44
- // Check common name fields first
45
- for (const field of ['name', 'title', 'displayName', 'label', 'username', 'email', 'subject', 'message', 'description']) {
46
- if (entity[field]) return String(entity[field]);
47
- }
48
- // Fall back to first non-metadata string value
49
- for (const [key, val] of Object.entries(entity)) {
50
- if (!METADATA.has(key) && val && typeof val === 'string' && !String(val).match(/^[0-9a-f-]{36}$/i)) {
51
- return String(val);
52
- }
53
- }
54
- return entity.id ? String(entity.id).slice(0, 8) + '...' : 'Unknown';
55
- }
56
-
57
- /**
58
- * Classify attributes into ordered groups for display
59
- */
60
- export function classifyFields(attributes: Array<{ name: string; type: string; auto?: string; required?: boolean }>): {
61
- business: typeof attributes;
62
- lifecycle: typeof attributes;
63
- metadata: typeof attributes;
64
- } {
65
- const business: typeof attributes = [];
66
- const lifecycle: typeof attributes = [];
67
- const metadata: typeof attributes = [];
68
-
69
- for (const attr of attributes) {
70
- if (isAutoField(attr.name, attr) || isMetadataField(attr.name)) {
71
- metadata.push(attr);
72
- } else if (attr.name === 'status' || attr.name === 'state' || attr.name === 'phase') {
73
- lifecycle.push(attr);
74
- } else {
75
- business.push(attr);
76
- }
77
- }
78
-
79
- return { business, lifecycle, metadata };
80
- }
81
- `;
82
- }
83
- function generateViewHelpers() {
84
- return `/**
85
- * View Helpers \u2014 formatting, colors, and UI utilities
86
- * Generated by SpecVerse React factory
87
- */
88
-
89
- /**
90
- * Format a value for display
91
- */
92
- export function formatValue(value: any, type?: string): string {
93
- if (value === null || value === undefined) return '\u2014';
94
- if (type?.toLowerCase().includes('date') || type?.toLowerCase().includes('timestamp')) {
95
- return formatDate(value);
96
- }
97
- if (typeof value === 'boolean') return value ? 'Yes' : 'No';
98
- return String(value);
99
- }
100
-
101
- /**
102
- * Format a date for display (relative for recent, absolute for old)
103
- */
104
- export function formatDate(value: any): string {
105
- if (!value) return '\u2014';
106
- const date = new Date(value);
107
- if (isNaN(date.getTime())) return String(value);
108
-
109
- const now = new Date();
110
- const diff = now.getTime() - date.getTime();
111
- const minutes = Math.floor(diff / 60000);
112
- const hours = Math.floor(diff / 3600000);
113
- const days = Math.floor(diff / 86400000);
114
-
115
- if (minutes < 1) return 'just now';
116
- if (minutes < 60) return \`\${minutes}m ago\`;
117
- if (hours < 24) return \`\${hours}h ago\`;
118
- if (days < 7) return \`\${days}d ago\`;
119
- return date.toLocaleDateString();
120
- }
121
-
122
- /**
123
- * Truncate text with ellipsis
124
- */
125
- export function truncate(text: string, max: number = 60): string {
126
- if (!text || text.length <= max) return text;
127
- return text.slice(0, max) + '...';
128
- }
129
-
130
- /**
131
- * Get a Tailwind color class for a lifecycle status
132
- */
133
- export function statusColor(status: string): { bg: string; text: string; dot: string } {
134
- const s = status?.toLowerCase().replace(/[_-]/g, '') || '';
135
-
136
- // Green states
137
- if (['active', 'done', 'completed', 'approved', 'published', 'resolved'].includes(s)) {
138
- return { bg: 'bg-green-50', text: 'text-green-700', dot: 'bg-green-500' };
139
- }
140
- // Blue states
141
- if (['inprogress', 'processing', 'review', 'pending'].includes(s)) {
142
- return { bg: 'bg-blue-50', text: 'text-blue-700', dot: 'bg-blue-500' };
143
- }
144
- // Yellow states
145
- if (['draft', 'todo', 'planning', 'waiting', 'scheduled'].includes(s)) {
146
- return { bg: 'bg-yellow-50', text: 'text-yellow-700', dot: 'bg-yellow-500' };
147
- }
148
- // Red states
149
- if (['cancelled', 'rejected', 'failed', 'overdue', 'blocked'].includes(s)) {
150
- return { bg: 'bg-red-50', text: 'text-red-700', dot: 'bg-red-500' };
151
- }
152
- // Gray states
153
- if (['archived', 'closed', 'deprecated', 'inactive', 'disabled'].includes(s)) {
154
- return { bg: 'bg-gray-50', text: 'text-gray-500', dot: 'bg-gray-400' };
155
- }
156
- // Default: indigo
157
- return { bg: 'bg-indigo-50', text: 'text-indigo-700', dot: 'bg-indigo-500' };
158
- }
159
-
160
- /**
161
- * StatusBadge component \u2014 matches app-demo's lifecycle badge styling
162
- */
163
- export function StatusBadge({ status, variant = 'default' }: { status: string; variant?: 'default' | 'lifecycle' }) {
164
- if (!status) return null;
165
-
166
- // Lifecycle badges use purple (matching app-demo)
167
- if (variant === 'lifecycle') {
168
- return (
169
- <span className="px-2 py-1 bg-purple-100 text-purple-700 rounded text-xs font-medium">
170
- {status.replace(/[_-]/g, ' ')}
171
- </span>
172
- );
173
- }
174
-
175
- const colors = statusColor(status);
176
- return (
177
- <span className={\`inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium \${colors.bg} \${colors.text}\`}>
178
- <span className={\`w-1.5 h-1.5 rounded-full \${colors.dot}\`}></span>
179
- {status.replace(/[_-]/g, ' ')}
180
- </span>
181
- );
182
- }
183
- `;
184
- }
185
- export {
186
- generateSharedUtils as default
187
- };
@@ -1,7 +0,0 @@
1
- function generateSpecJson(context) {
2
- const { spec } = context;
3
- return JSON.stringify(spec, null, 2);
4
- }
5
- export {
6
- generateSpecJson as default
7
- };
@@ -1,56 +0,0 @@
1
- function generateModelTypes(context) {
2
- const { model } = context;
3
- if (!model) {
4
- throw new Error("Model is required in template context");
5
- }
6
- const modelName = model.name;
7
- let attributes = model.attributes || {};
8
- if (Array.isArray(attributes)) {
9
- const obj = {};
10
- attributes.forEach((attr) => {
11
- if (attr && typeof attr === "object" && attr.name) {
12
- obj[attr.name] = attr;
13
- } else if (Array.isArray(attr) && attr.length >= 2) {
14
- obj[attr[0]] = attr[1];
15
- }
16
- });
17
- attributes = obj;
18
- }
19
- const properties = Object.entries(attributes).map(([name, attr]) => {
20
- const tsType = mapToTypeScript(attr.type);
21
- const optional = !attr.constraints?.required ? "?" : "";
22
- return ` ${name}${optional}: ${tsType};`;
23
- }).join("\n");
24
- return `/**
25
- * ${modelName} Type Definition
26
- * Auto-generated from SpecVerse model
27
- */
28
-
29
- export interface ${modelName} {
30
- ${properties}
31
- }
32
-
33
- export type Create${modelName}Input = Omit<${modelName}, 'id' | 'createdAt' | 'updatedAt'>;
34
- export type Update${modelName}Input = Partial<Create${modelName}Input>;
35
- `;
36
- }
37
- function mapToTypeScript(type) {
38
- const typeMap = {
39
- "String": "string",
40
- "Integer": "number",
41
- "Float": "number",
42
- "Boolean": "boolean",
43
- "Date": "string",
44
- "DateTime": "string",
45
- "Timestamp": "string",
46
- "UUID": "string",
47
- "Email": "string",
48
- "URL": "string",
49
- "JSON": "Record<string, any>",
50
- "Array": "any[]"
51
- };
52
- return typeMap[type] || "any";
53
- }
54
- export {
55
- generateModelTypes as default
56
- };
@@ -1,27 +0,0 @@
1
- function generateViewsMetadata(context) {
2
- const { spec, views = [] } = context;
3
- const specViews = views.length > 0 ? views : spec?.views || [];
4
- const viewsArray = Array.isArray(specViews) ? specViews : Object.values(specViews);
5
- const metadata = {};
6
- viewsArray.forEach((viewDef) => {
7
- const viewName = viewDef.name;
8
- metadata[viewName] = {
9
- name: viewName,
10
- type: viewDef.type || "list",
11
- ...viewDef.description && { description: viewDef.description },
12
- model: viewDef.model,
13
- // Keep as-is (string or array for multi-model views)
14
- ...viewDef.uiComponents && { uiComponents: viewDef.uiComponents },
15
- ...viewDef.subscriptions && viewDef.subscriptions.length > 0 && {
16
- subscriptions: viewDef.subscriptions
17
- },
18
- routing: viewDef.routing || {
19
- path: `/${viewName.toLowerCase().replace(/view$/, "")}`
20
- }
21
- };
22
- });
23
- return JSON.stringify(metadata, null, 2);
24
- }
25
- export {
26
- generateViewsMetadata as default
27
- };
@@ -1,29 +0,0 @@
1
- function generateViteConfig(context) {
2
- const { backendPort = 3e3 } = context;
3
- return `import { defineConfig } from 'vite';
4
- import react from '@vitejs/plugin-react';
5
-
6
- // https://vitejs.dev/config/
7
- export default defineConfig({
8
- plugins: [react()],
9
- server: {
10
- port: 5173,
11
- host: true,
12
- proxy: {
13
- '/api': {
14
- target: 'http://localhost:${backendPort}',
15
- changeOrigin: true,
16
- rewrite: (path) => path
17
- }
18
- }
19
- },
20
- build: {
21
- outDir: 'dist',
22
- sourcemap: true
23
- }
24
- });
25
- `;
26
- }
27
- export {
28
- generateViteConfig as default
29
- };
@@ -1,261 +0,0 @@
1
- import React, { createElement, useState, useMemo } from "react";
2
- import {
3
- BaseComponentGenerator
4
- } from "../shared/base-generator.js";
5
- import { mapProperties } from "../shared/property-mapper.js";
6
- import { getComponentMetadata } from "../shared/component-metadata.js";
7
- class RuntimeViewRenderer extends BaseComponentGenerator {
8
- runtimeConfig;
9
- viewContext;
10
- constructor(adapter, config) {
11
- super(adapter, config);
12
- this.runtimeConfig = config;
13
- }
14
- // ============================================================================
15
- // Public API - Runtime Rendering
16
- // ============================================================================
17
- /**
18
- * Render view as React element (runtime)
19
- *
20
- * @param viewSpec - View specification
21
- * @param context - Runtime context (state, data, handlers)
22
- * @returns React element
23
- */
24
- renderRuntime(viewSpec, context) {
25
- this.viewContext = this.initializeContext(viewSpec, context);
26
- const components = this.renderComponentsRuntime(viewSpec.components);
27
- return createElement(
28
- "div",
29
- { className: "specverse-runtime-view", "data-view": viewSpec.name },
30
- components
31
- );
32
- }
33
- /**
34
- * Create a React component from view spec
35
- *
36
- * Returns a React component function that can be used directly
37
- *
38
- * @param viewSpec - View specification
39
- * @returns React component function
40
- */
41
- createRuntimeComponent(viewSpec) {
42
- const renderer = this;
43
- return function RuntimeViewComponent(props) {
44
- const [state, setState] = useState(
45
- () => renderer.initializeState(viewSpec.state)
46
- );
47
- const handlers = useMemo(
48
- () => renderer.createEventHandlers(viewSpec.events, state, setState),
49
- [state]
50
- );
51
- const context = {
52
- state,
53
- setState: (updates) => setState((prev) => ({ ...prev, ...updates })),
54
- handlers,
55
- data: props.data || {}
56
- };
57
- return renderer.renderRuntime(viewSpec, context);
58
- };
59
- }
60
- // ============================================================================
61
- // Abstract Method Implementations (Not Used in Runtime)
62
- // ============================================================================
63
- generateImports(viewSpec) {
64
- return "";
65
- }
66
- generateComponent(parts) {
67
- return "";
68
- }
69
- generateState(state) {
70
- return "";
71
- }
72
- generateEvents(events) {
73
- return "";
74
- }
75
- getFileExtension() {
76
- return "";
77
- }
78
- getAdditionalFiles(viewSpec) {
79
- return {};
80
- }
81
- // ============================================================================
82
- // Runtime-Specific Methods
83
- // ============================================================================
84
- /**
85
- * Initialize runtime context
86
- */
87
- initializeContext(viewSpec, context) {
88
- return {
89
- state: context?.state || this.initializeState(viewSpec.state),
90
- setState: context?.setState || (() => {
91
- }),
92
- handlers: context?.handlers || this.createEventHandlers(viewSpec.events),
93
- data: context?.data || {}
94
- };
95
- }
96
- /**
97
- * Initialize state from view spec
98
- */
99
- initializeState(state) {
100
- if (!state) return {};
101
- const initialState = {};
102
- for (const [name, def] of Object.entries(state)) {
103
- initialState[name] = def.initial;
104
- }
105
- return initialState;
106
- }
107
- /**
108
- * Create event handlers from view spec
109
- */
110
- createEventHandlers(events, state, setState) {
111
- if (!events) return {};
112
- const handlers = {};
113
- for (const [name, def] of Object.entries(events)) {
114
- handlers[`handle${this.capitalize(name)}`] = (...args) => {
115
- if (this.runtimeConfig.debug) {
116
- console.log(`[RuntimeView] Event: ${name}`, args);
117
- }
118
- try {
119
- const fn = new Function("state", "setState", "args", def.body);
120
- fn(state, setState, args);
121
- } catch (error) {
122
- console.error(`[RuntimeView] Event handler error (${name}):`, error);
123
- }
124
- };
125
- }
126
- return handlers;
127
- }
128
- /**
129
- * Render components as React elements
130
- */
131
- renderComponentsRuntime(components) {
132
- return Object.entries(components).map(
133
- ([name, component]) => this.renderComponentRuntime(component, {
134
- depth: 0,
135
- path: [name]
136
- })
137
- );
138
- }
139
- /**
140
- * Render single component as React element
141
- */
142
- renderComponentRuntime(component, context) {
143
- if (context.depth > this.MAX_DEPTH) {
144
- if (this.runtimeConfig.debug) {
145
- console.warn(`[RuntimeView] Max depth exceeded at ${context.path.join(".")}`);
146
- }
147
- return null;
148
- }
149
- const metadata = getComponentMetadata(component.type);
150
- if (!metadata) {
151
- console.warn(`[RuntimeView] Unknown component type: ${component.type}`);
152
- return null;
153
- }
154
- const mappedProps = component.properties ? mapProperties(component.type, component.properties, "runtime") : {};
155
- const props = {
156
- ...mappedProps,
157
- key: context.path.join("-")
158
- };
159
- if (component.condition && this.viewContext) {
160
- const condition = this.evaluateCondition(component.condition, this.viewContext);
161
- if (!condition) return null;
162
- }
163
- if (component.dataSource && this.viewContext) {
164
- return this.renderListRuntime(component, props, context);
165
- }
166
- let children = null;
167
- if (component.children && component.children.length > 0) {
168
- children = component.children.map(
169
- (child, index) => this.renderComponentRuntime(child, {
170
- ...context,
171
- depth: context.depth + 1,
172
- path: [...context.path, `child_${index}`]
173
- })
174
- );
175
- }
176
- const adapterComponent = this.adapter.components[component.type];
177
- if (!adapterComponent) {
178
- console.warn(`[RuntimeView] No adapter for component: ${component.type}`);
179
- return null;
180
- }
181
- return this.createElementFromAdapter(component.type, props, children);
182
- }
183
- /**
184
- * Render list of items
185
- */
186
- renderListRuntime(component, props, context) {
187
- if (!this.viewContext) return null;
188
- const dataArray = this.viewContext.data[component.dataSource];
189
- if (!Array.isArray(dataArray)) {
190
- console.warn(`[RuntimeView] Data source not found: ${component.dataSource}`);
191
- return null;
192
- }
193
- const items = dataArray.map((item, index) => {
194
- const itemProps = {
195
- ...props,
196
- ...item,
197
- key: `${context.path.join("-")}-${index}`
198
- };
199
- return this.createElementFromAdapter(component.type, itemProps, null);
200
- });
201
- return createElement(React.Fragment, null, ...items);
202
- }
203
- /**
204
- * Create React element from adapter component
205
- */
206
- createElementFromAdapter(type, props, children) {
207
- return createElement(
208
- "div",
209
- {
210
- ...props,
211
- className: `specverse-runtime-${type} ${props.className || ""}`.trim(),
212
- "data-component": type
213
- },
214
- children
215
- );
216
- }
217
- /**
218
- * Evaluate condition expression
219
- */
220
- evaluateCondition(condition, context) {
221
- try {
222
- const fn = new Function("state", "data", `return ${condition}`);
223
- return fn(context.state, context.data);
224
- } catch (error) {
225
- console.error(`[RuntimeView] Condition evaluation error:`, error);
226
- return false;
227
- }
228
- }
229
- /**
230
- * Capitalize first letter
231
- */
232
- capitalize(str) {
233
- return str.charAt(0).toUpperCase() + str.slice(1);
234
- }
235
- }
236
- function createRuntimeRenderer(adapter, config) {
237
- const defaultConfig = {
238
- framework: "runtime",
239
- target: "runtime",
240
- liveReload: false,
241
- debug: false,
242
- maxDepth: 3,
243
- enableWarnings: true
244
- };
245
- const finalConfig = { ...defaultConfig, ...config };
246
- return new RuntimeViewRenderer(adapter, finalConfig);
247
- }
248
- function renderView(viewSpec, adapter, context) {
249
- const renderer = createRuntimeRenderer(adapter);
250
- return renderer.renderRuntime(viewSpec, context);
251
- }
252
- function createViewComponent(viewSpec, adapter) {
253
- const renderer = createRuntimeRenderer(adapter);
254
- return renderer.createRuntimeComponent(viewSpec);
255
- }
256
- export {
257
- RuntimeViewRenderer,
258
- createRuntimeRenderer,
259
- createViewComponent,
260
- renderView
261
- };
@@ -1,34 +0,0 @@
1
- function renderProps(props) {
2
- return Object.entries(props).filter(([_, value]) => value !== void 0 && value !== null).map(([key, value]) => {
3
- if (typeof value === "boolean") {
4
- return value ? key : "";
5
- }
6
- if (typeof value === "string") {
7
- return `${key}="${value}"`;
8
- }
9
- if (typeof value === "number") {
10
- return `${key}={${value}}`;
11
- }
12
- if (Array.isArray(value)) {
13
- return `${key}={${JSON.stringify(value)}}`;
14
- }
15
- if (typeof value === "object") {
16
- return `${key}={${JSON.stringify(value)}}`;
17
- }
18
- return `${key}={${value}}`;
19
- }).filter(Boolean).join(" ");
20
- }
21
- function indent(code, level = 0) {
22
- const spaces = " ".repeat(level);
23
- return code.split("\n").map((line) => line ? spaces + line : line).join("\n");
24
- }
25
- function wrapWithChildren(openTag, children, closeTag, indentLevel = 0) {
26
- return `${openTag}
27
- ${indent(children, indentLevel + 1)}
28
- ${indent(closeTag, indentLevel)}`;
29
- }
30
- export {
31
- indent,
32
- renderProps,
33
- wrapWithChildren
34
- };