@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.
- package/assets/examples/manifests/frontend-only.yaml +3 -6
- package/assets/examples/manifests/fullstack-app.yaml +5 -7
- package/assets/examples/manifests/fullstack-monorepo.yaml +3 -6
- package/dist/inference/comprehensive-engine.d.ts.map +1 -1
- package/dist/inference/comprehensive-engine.js +3 -19
- package/dist/inference/comprehensive-engine.js.map +1 -1
- package/dist/inference/core/rule-engine.d.ts +31 -0
- package/dist/inference/core/rule-engine.d.ts.map +1 -1
- package/dist/inference/core/rule-engine.js +117 -33
- package/dist/inference/core/rule-engine.js.map +1 -1
- package/dist/inference/core/rule-file-types.d.ts +0 -2
- package/dist/inference/core/rule-file-types.d.ts.map +1 -1
- package/dist/inference/core/rule-file-types.js +3 -6
- package/dist/inference/core/rule-file-types.js.map +1 -1
- package/dist/inference/core/rule-loader.d.ts +5 -15
- package/dist/inference/core/rule-loader.d.ts.map +1 -1
- package/dist/inference/core/rule-loader.js +43 -132
- package/dist/inference/core/rule-loader.js.map +1 -1
- package/dist/inference/core/types.d.ts +0 -6
- package/dist/inference/core/types.d.ts.map +1 -1
- package/dist/inference/core/types.js +0 -4
- package/dist/inference/core/types.js.map +1 -1
- package/dist/inference/logical/generators/component-type-resolver.d.ts +0 -26
- package/dist/inference/logical/generators/component-type-resolver.d.ts.map +1 -1
- package/dist/inference/logical/generators/component-type-resolver.js +0 -19
- package/dist/inference/logical/generators/component-type-resolver.js.map +1 -1
- package/dist/inference/logical/generators/specialist-view-expander.d.ts +1 -17
- package/dist/inference/logical/generators/specialist-view-expander.d.ts.map +1 -1
- package/dist/inference/logical/generators/specialist-view-expander.js +0 -15
- package/dist/inference/logical/generators/specialist-view-expander.js.map +1 -1
- package/dist/inference/logical/generators/view-generator.d.ts +4 -14
- package/dist/inference/logical/generators/view-generator.d.ts.map +1 -1
- package/dist/inference/logical/generators/view-generator.js +6 -26
- package/dist/inference/logical/generators/view-generator.js.map +1 -1
- package/dist/inference/logical/index.d.ts +2 -2
- package/dist/inference/logical/index.d.ts.map +1 -1
- package/dist/inference/logical/logical-engine.d.ts.map +1 -1
- package/dist/inference/logical/logical-engine.js +17 -80
- package/dist/inference/logical/logical-engine.js.map +1 -1
- package/dist/inference/quint-transpiler.d.ts +5 -3
- package/dist/inference/quint-transpiler.d.ts.map +1 -1
- package/dist/inference/quint-transpiler.js +11 -6
- package/dist/inference/quint-transpiler.js.map +1 -1
- package/dist/libs/instance-factories/applications/templates/generic/main-generator.js +3 -3
- package/dist/libs/instance-factories/applications/templates/react/api-client-generator.js +16 -6
- package/dist/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.js +110 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.js +121 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/detail-body-composer.js +78 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/form-body-composer.js +190 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/helpers-emitter.js +45 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/html-to-jsx.js +192 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/list-body-composer.js +46 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/orchestrator.js +30 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/package-json-generator.js +38 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/regen-safety.js +89 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/view-emitter.js +56 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/views-generator.js +66 -0
- package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +14 -11
- package/dist/libs/instance-factories/controllers/templates/fastify/server-generator.js +11 -3
- package/dist/libs/instance-factories/services/templates/prisma/controller-generator.js +27 -17
- package/dist/libs/instance-factories/shared/path-resolver.js +1 -1
- package/dist/realize/index.d.ts.map +1 -1
- package/dist/realize/index.js +15 -22
- package/dist/realize/index.js.map +1 -1
- package/dist/registry/utils/manifest-adapter.d.ts +8 -1
- package/dist/registry/utils/manifest-adapter.d.ts.map +1 -1
- package/dist/registry/utils/manifest-adapter.js +8 -1
- package/dist/registry/utils/manifest-adapter.js.map +1 -1
- package/libs/instance-factories/applications/react-app-starter.yaml +150 -0
- package/libs/instance-factories/applications/templates/generic/main-generator.ts +3 -3
- package/libs/instance-factories/applications/templates/react/api-client-generator.ts +16 -6
- package/libs/instance-factories/applications/templates/react-starter/README.md +211 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/dashboard-body-composer.test.ts +153 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/detail-body-composer.test.ts +145 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/form-body-composer.test.ts +175 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/helpers-emitter.test.ts +55 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/html-to-jsx.test.ts +140 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/list-body-composer.test.ts +146 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/orchestrator.test.ts +163 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/parity-p2-factory-imports.test.ts +116 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/parity-p3-rendered-output.test.ts +183 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/regen-safety.test.ts +144 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/starter-generators.test.ts +114 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/view-emitter.test.ts +107 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/views-generator.test.ts +139 -0
- package/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.ts +141 -0
- package/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.ts +174 -0
- package/libs/instance-factories/applications/templates/react-starter/detail-body-composer.ts +135 -0
- package/libs/instance-factories/applications/templates/react-starter/form-body-composer.ts +306 -0
- package/libs/instance-factories/applications/templates/react-starter/helpers-emitter.ts +60 -0
- package/libs/instance-factories/applications/templates/react-starter/html-to-jsx.ts +334 -0
- package/libs/instance-factories/applications/templates/react-starter/list-body-composer.ts +120 -0
- package/libs/instance-factories/applications/templates/react-starter/orchestrator.ts +80 -0
- package/libs/instance-factories/applications/templates/react-starter/package-json-generator.ts +57 -0
- package/libs/instance-factories/applications/templates/react-starter/regen-safety.ts +157 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/dashboard.tsx.template +47 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/detail.tsx.template +94 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/form.tsx.template +114 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/list.tsx.template +72 -0
- package/libs/instance-factories/applications/templates/react-starter/view-emitter.ts +151 -0
- package/libs/instance-factories/applications/templates/react-starter/views-generator.ts +137 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.ts +14 -11
- package/libs/instance-factories/controllers/templates/fastify/server-generator.ts +11 -3
- package/libs/instance-factories/services/templates/prisma/controller-generator.ts +27 -17
- package/libs/instance-factories/shared/path-resolver.ts +8 -2
- package/package.json +3 -3
- package/dist/libs/instance-factories/applications/templates/react/_view-components-source.js +0 -530
- package/dist/libs/instance-factories/applications/templates/react/app-tsx-generator.js +0 -73
- package/dist/libs/instance-factories/applications/templates/react/field-helpers-generator.js +0 -99
- package/dist/libs/instance-factories/applications/templates/react/package-json-generator.js +0 -49
- package/dist/libs/instance-factories/applications/templates/react/pattern-adapter-generator.js +0 -156
- package/dist/libs/instance-factories/applications/templates/react/react-pattern-adapter.js +0 -935
- package/dist/libs/instance-factories/applications/templates/react/relationship-field-generator.js +0 -143
- package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.js +0 -646
- package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.js +0 -65
- package/dist/libs/instance-factories/applications/templates/react/view-dashboard-generator.js +0 -143
- package/dist/libs/instance-factories/applications/templates/react/view-detail-generator.js +0 -143
- package/dist/libs/instance-factories/applications/templates/react/view-form-generator.js +0 -355
- package/dist/libs/instance-factories/applications/templates/react/view-list-generator.js +0 -91
- package/dist/libs/instance-factories/applications/templates/react/view-router-generator.js +0 -79
- package/dist/libs/instance-factories/tools/templates/vscode/vscode-extension-generator.js.bak +0 -244
- package/dist/libs/instance-factories/views/index.js +0 -48
- package/dist/libs/instance-factories/views/templates/react/adapters/antd-adapter.js +0 -742
- package/dist/libs/instance-factories/views/templates/react/adapters/mui-adapter.js +0 -824
- package/dist/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.js +0 -719
- package/dist/libs/instance-factories/views/templates/react/app-generator.js +0 -45
- package/dist/libs/instance-factories/views/templates/react/components-generator.js +0 -820
- package/dist/libs/instance-factories/views/templates/react/forms-generator.js +0 -275
- package/dist/libs/instance-factories/views/templates/react/frontend-package-json-generator.js +0 -46
- package/dist/libs/instance-factories/views/templates/react/hooks-generator.js +0 -81
- package/dist/libs/instance-factories/views/templates/react/index-css-generator.js +0 -9
- package/dist/libs/instance-factories/views/templates/react/index-html-generator.js +0 -23
- package/dist/libs/instance-factories/views/templates/react/main-tsx-generator.js +0 -21
- package/dist/libs/instance-factories/views/templates/react/react-component-generator.js +0 -299
- package/dist/libs/instance-factories/views/templates/react/router-generator.js +0 -136
- package/dist/libs/instance-factories/views/templates/react/router-generic-generator.js +0 -107
- package/dist/libs/instance-factories/views/templates/react/shared-utils-generator.js +0 -187
- package/dist/libs/instance-factories/views/templates/react/spec-json-generator.js +0 -7
- package/dist/libs/instance-factories/views/templates/react/types-generator.js +0 -56
- package/dist/libs/instance-factories/views/templates/react/views-metadata-generator.js +0 -27
- package/dist/libs/instance-factories/views/templates/react/vite-config-generator.js +0 -29
- package/dist/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js +0 -261
- package/dist/libs/instance-factories/views/templates/shared/adapter-types.js +0 -34
- package/dist/libs/instance-factories/views/templates/shared/atomic-components-registry.js +0 -800
- package/dist/libs/instance-factories/views/templates/shared/base-generator.js +0 -305
- package/dist/libs/instance-factories/views/templates/shared/component-metadata.js +0 -517
- 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 +0 -445
- package/dist/libs/instance-factories/views/templates/shared/index.js +0 -80
- package/dist/libs/instance-factories/views/templates/shared/pattern-validator.js +0 -210
- package/dist/libs/instance-factories/views/templates/shared/property-mapper.js +0 -492
- package/dist/libs/instance-factories/views/templates/shared/syntax-mapper.js +0 -321
- package/dist/realize/index.js.bak +0 -758
- package/libs/instance-factories/applications/react-app.yaml +0 -186
- package/libs/instance-factories/applications/templates/react/_view-components-source.ts +0 -555
- package/libs/instance-factories/applications/templates/react/app-tsx-generator.ts +0 -94
- package/libs/instance-factories/applications/templates/react/field-helpers-generator.ts +0 -106
- package/libs/instance-factories/applications/templates/react/package-json-generator.ts +0 -57
- package/libs/instance-factories/applications/templates/react/pattern-adapter-generator.ts +0 -179
- package/libs/instance-factories/applications/templates/react/react-pattern-adapter.tsx +0 -1347
- package/libs/instance-factories/applications/templates/react/relationship-field-generator.ts +0 -150
- package/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.ts +0 -704
- package/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.ts +0 -84
- package/libs/instance-factories/applications/templates/react/view-dashboard-generator.ts +0 -150
- package/libs/instance-factories/applications/templates/react/view-detail-generator.ts +0 -150
- package/libs/instance-factories/applications/templates/react/view-form-generator.ts +0 -362
- package/libs/instance-factories/applications/templates/react/view-list-generator.ts +0 -98
- package/libs/instance-factories/applications/templates/react/view-router-generator.ts +0 -89
- package/libs/instance-factories/views/README.md +0 -62
- package/libs/instance-factories/views/index.d.ts +0 -13
- package/libs/instance-factories/views/index.d.ts.map +0 -1
- package/libs/instance-factories/views/index.js +0 -18
- package/libs/instance-factories/views/index.js.map +0 -1
- package/libs/instance-factories/views/index.ts +0 -45
- package/libs/instance-factories/views/react-components.yaml +0 -129
- package/libs/instance-factories/views/templates/ARCHITECTURE.md +0 -198
- package/libs/instance-factories/views/templates/react/adapters/antd-adapter.ts +0 -869
- package/libs/instance-factories/views/templates/react/adapters/mui-adapter.ts +0 -953
- package/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.ts +0 -806
- package/libs/instance-factories/views/templates/react/app-generator.ts +0 -55
- package/libs/instance-factories/views/templates/react/components-generator.ts +0 -938
- package/libs/instance-factories/views/templates/react/forms-generator.ts +0 -325
- package/libs/instance-factories/views/templates/react/frontend-package-json-generator.ts +0 -57
- package/libs/instance-factories/views/templates/react/hooks-generator.ts +0 -106
- package/libs/instance-factories/views/templates/react/index-css-generator.ts +0 -14
- package/libs/instance-factories/views/templates/react/index-html-generator.ts +0 -34
- package/libs/instance-factories/views/templates/react/main-tsx-generator.ts +0 -29
- package/libs/instance-factories/views/templates/react/react-component-generator.d.ts +0 -152
- package/libs/instance-factories/views/templates/react/react-component-generator.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/react/react-component-generator.js +0 -398
- package/libs/instance-factories/views/templates/react/react-component-generator.js.map +0 -1
- package/libs/instance-factories/views/templates/react/react-component-generator.ts +0 -533
- package/libs/instance-factories/views/templates/react/router-generator.ts +0 -197
- package/libs/instance-factories/views/templates/react/router-generic-generator.ts +0 -132
- package/libs/instance-factories/views/templates/react/shared-utils-generator.ts +0 -196
- package/libs/instance-factories/views/templates/react/spec-json-generator.ts +0 -17
- package/libs/instance-factories/views/templates/react/types-generator.ts +0 -76
- package/libs/instance-factories/views/templates/react/views-metadata-generator.ts +0 -42
- package/libs/instance-factories/views/templates/react/vite-config-generator.ts +0 -38
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js.map +0 -1
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.ts +0 -474
- package/libs/instance-factories/views/templates/shared/__tests__/composite-patterns.test.ts +0 -242
- package/libs/instance-factories/views/templates/shared/adapter-types.d.ts +0 -77
- package/libs/instance-factories/views/templates/shared/adapter-types.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/adapter-types.js +0 -47
- package/libs/instance-factories/views/templates/shared/adapter-types.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/adapter-types.ts +0 -142
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts +0 -63
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.js +0 -822
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.ts +0 -908
- package/libs/instance-factories/views/templates/shared/base-generator.d.ts +0 -247
- package/libs/instance-factories/views/templates/shared/base-generator.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/base-generator.js +0 -363
- package/libs/instance-factories/views/templates/shared/base-generator.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/base-generator.ts +0 -608
- package/libs/instance-factories/views/templates/shared/component-metadata.d.ts +0 -254
- package/libs/instance-factories/views/templates/shared/component-metadata.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/component-metadata.js +0 -602
- package/libs/instance-factories/views/templates/shared/component-metadata.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/component-metadata.ts +0 -803
- package/libs/instance-factories/views/templates/shared/composite-pattern-types.ts +0 -250
- package/libs/instance-factories/views/templates/shared/composite-patterns.ts +0 -535
- package/libs/instance-factories/views/templates/shared/index.ts +0 -68
- package/libs/instance-factories/views/templates/shared/pattern-validator.ts +0 -279
- package/libs/instance-factories/views/templates/shared/property-mapper.d.ts +0 -149
- package/libs/instance-factories/views/templates/shared/property-mapper.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/property-mapper.js +0 -580
- package/libs/instance-factories/views/templates/shared/property-mapper.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/property-mapper.ts +0 -700
- package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts +0 -143
- package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/syntax-mapper.js +0 -420
- package/libs/instance-factories/views/templates/shared/syntax-mapper.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/syntax-mapper.ts +0 -539
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { readFileSync, existsSync } from "fs";
|
|
2
|
-
import { join, dirname } from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
async function generate(context) {
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = dirname(__filename);
|
|
7
|
-
const possiblePaths = [
|
|
8
|
-
// PRIORITY 1: Bundled with package (in libs/ directory)
|
|
9
|
-
join(__dirname, "../../../../../../libs/instance-factories/applications/templates/react/tailwind-adapter-generator.ts"),
|
|
10
|
-
// PRIORITY 2: Development environment (local)
|
|
11
|
-
join(__dirname, "./tailwind-adapter-generator.ts"),
|
|
12
|
-
join(__dirname, "../tailwind-adapter-generator.ts")
|
|
13
|
-
];
|
|
14
|
-
let adapterSource = null;
|
|
15
|
-
let foundPath = null;
|
|
16
|
-
for (const path of possiblePaths) {
|
|
17
|
-
if (existsSync(path)) {
|
|
18
|
-
try {
|
|
19
|
-
adapterSource = readFileSync(path, "utf-8");
|
|
20
|
-
foundPath = path;
|
|
21
|
-
break;
|
|
22
|
-
} catch (error) {
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (adapterSource) {
|
|
27
|
-
return `/**
|
|
28
|
-
* Universal Tailwind Adapter Generator
|
|
29
|
-
*
|
|
30
|
-
* AUTO-GENERATED: Copied from @specverse/lang
|
|
31
|
-
* Source: ${foundPath}
|
|
32
|
-
*
|
|
33
|
-
* This file provides Tailwind CSS rendering for all atomic component types.
|
|
34
|
-
* It is imported by react-pattern-adapter.tsx.
|
|
35
|
-
*
|
|
36
|
-
* DO NOT EDIT: Changes will be overwritten on next generation.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
${adapterSource}
|
|
40
|
-
`;
|
|
41
|
-
}
|
|
42
|
-
return `/**
|
|
43
|
-
* Tailwind Adapter Generator (STUB)
|
|
44
|
-
*
|
|
45
|
-
* \u26A0\uFE0F WARNING: Could not locate tailwind-adapter-generator.ts source file.
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
import type { ComponentAdapter } from '@specverse/lang';
|
|
49
|
-
|
|
50
|
-
export function createUniversalTailwindAdapter(): ComponentAdapter {
|
|
51
|
-
return {
|
|
52
|
-
renderComponent(type: string, properties: Record<string, any> = {}, children?: string): string {
|
|
53
|
-
return \`<div class="p-4 border border-gray-300 rounded bg-gray-50">
|
|
54
|
-
<span class="text-gray-700">\${type}</span>
|
|
55
|
-
</div>\`;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
console.warn('\u26A0\uFE0F Using stub Tailwind adapter - full source file not found during generation');
|
|
61
|
-
`;
|
|
62
|
-
}
|
|
63
|
-
export {
|
|
64
|
-
generate
|
|
65
|
-
};
|
package/dist/libs/instance-factories/applications/templates/react/view-dashboard-generator.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
async function generate(context) {
|
|
2
|
-
return `/**
|
|
3
|
-
* DashboardView - Pattern-Based Dashboard View Component
|
|
4
|
-
*
|
|
5
|
-
* Uses pattern-based rendering with ReactPatternAdapter.
|
|
6
|
-
* Supports multi-component dashboard layouts with entity selection.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { useState, useEffect, useMemo } from 'react';
|
|
10
|
-
import { useEntitiesQuery, useModelSchemaQuery } from '../../hooks/useApi';
|
|
11
|
-
import { usePatternAdapter, REACT_PROTOCOL_MAPPING } from '../../lib/react-pattern-adapter';
|
|
12
|
-
import type { View } from '../../types/api';
|
|
13
|
-
|
|
14
|
-
interface DashboardViewProps {
|
|
15
|
-
view: View;
|
|
16
|
-
spec?: any;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function DashboardView({ view, spec }: DashboardViewProps) {
|
|
20
|
-
const patternAdapter = usePatternAdapter();
|
|
21
|
-
|
|
22
|
-
// Determine controller and model
|
|
23
|
-
let controllerName: string;
|
|
24
|
-
let modelName: string;
|
|
25
|
-
|
|
26
|
-
if (view.controller && spec) {
|
|
27
|
-
controllerName = view.controller;
|
|
28
|
-
const controller = spec.controllers[view.controller];
|
|
29
|
-
modelName = controller.model;
|
|
30
|
-
} else {
|
|
31
|
-
modelName = view.model as string;
|
|
32
|
-
controllerName = \`\${modelName}Controller\`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Fetch data and schema
|
|
36
|
-
const { data: entities = [] } = useEntitiesQuery(controllerName, modelName);
|
|
37
|
-
const { data: schema } = useModelSchemaQuery(modelName);
|
|
38
|
-
|
|
39
|
-
// Track selected entity
|
|
40
|
-
const [selectedEntityId, setSelectedEntityId] = useState<string | null>(
|
|
41
|
-
entities.length > 0 ? entities[0].id : null
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
// Update selected entity when entities change
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (entities.length > 0 && !selectedEntityId) {
|
|
47
|
-
setSelectedEntityId(entities[0].id);
|
|
48
|
-
}
|
|
49
|
-
}, [entities, selectedEntityId]);
|
|
50
|
-
|
|
51
|
-
// Get selected entity
|
|
52
|
-
const selectedEntity = useMemo(
|
|
53
|
-
() => entities.find((e: any) => e.id === selectedEntityId) || null,
|
|
54
|
-
[entities, selectedEntityId]
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
// Build model data and schemas
|
|
58
|
-
const modelData = useMemo(() => ({
|
|
59
|
-
[modelName]: entities
|
|
60
|
-
}), [modelName, entities]);
|
|
61
|
-
|
|
62
|
-
const modelSchemas = useMemo(() =>
|
|
63
|
-
schema ? { [modelName]: schema } : {}
|
|
64
|
-
, [modelName, schema]);
|
|
65
|
-
|
|
66
|
-
if (entities.length === 0) {
|
|
67
|
-
return <div className="p-4">No entities found</div>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Detect pattern
|
|
71
|
-
const pattern = patternAdapter.detectPattern({ ...view, type: 'dashboard' });
|
|
72
|
-
|
|
73
|
-
if (!pattern) {
|
|
74
|
-
return (
|
|
75
|
-
<div className="p-4 text-red-600">
|
|
76
|
-
Pattern not found for dashboard view
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Build render context
|
|
82
|
-
const context = {
|
|
83
|
-
pattern,
|
|
84
|
-
viewSpec: { ...view, type: 'dashboard', model: modelName },
|
|
85
|
-
modelData,
|
|
86
|
-
modelSchemas,
|
|
87
|
-
primaryModel: modelName,
|
|
88
|
-
selectedEntity,
|
|
89
|
-
primaryEntities: entities,
|
|
90
|
-
protocolMapping: REACT_PROTOCOL_MAPPING,
|
|
91
|
-
tailwindAdapter: patternAdapter['tailwindAdapter']
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// Render entity selector
|
|
95
|
-
let html = '';
|
|
96
|
-
if (entities.length > 0) {
|
|
97
|
-
html += \`
|
|
98
|
-
<div class="mb-4 pb-4 border-b border-gray-200 dark:border-gray-700">
|
|
99
|
-
<label class="block text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2">
|
|
100
|
-
Select \${modelName}:
|
|
101
|
-
</label>
|
|
102
|
-
<select
|
|
103
|
-
id="entity-selector"
|
|
104
|
-
class="w-full max-w-md px-3 py-2 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
105
|
-
>
|
|
106
|
-
\${entities.map((entity: any) => {
|
|
107
|
-
const displayName = entity.data?.name || entity.data?.title || entity.id;
|
|
108
|
-
return \`<option value="\${entity.id}" \${entity.id === selectedEntityId ? 'selected' : ''}>\${displayName}</option>\`;
|
|
109
|
-
}).join('')}
|
|
110
|
-
</select>
|
|
111
|
-
</div>
|
|
112
|
-
\`;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Render pattern
|
|
116
|
-
html += patternAdapter.renderPattern(context);
|
|
117
|
-
|
|
118
|
-
// Add event handler for selector
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
const selector = document.getElementById('entity-selector') as HTMLSelectElement;
|
|
121
|
-
if (selector) {
|
|
122
|
-
const handler = (e: Event) => {
|
|
123
|
-
const newId = (e.target as HTMLSelectElement).value;
|
|
124
|
-
setSelectedEntityId(newId);
|
|
125
|
-
};
|
|
126
|
-
selector.addEventListener('change', handler);
|
|
127
|
-
return () => selector.removeEventListener('change', handler);
|
|
128
|
-
}
|
|
129
|
-
}, [html]);
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<div className="runtime-view-container p-4 h-full overflow-auto">
|
|
133
|
-
<div dangerouslySetInnerHTML={{ __html: html }} />
|
|
134
|
-
</div>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export default DashboardView;
|
|
139
|
-
`;
|
|
140
|
-
}
|
|
141
|
-
export {
|
|
142
|
-
generate
|
|
143
|
-
};
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
async function generate(context) {
|
|
2
|
-
return `/**
|
|
3
|
-
* DetailView - Pattern-Based Detail View Component
|
|
4
|
-
*
|
|
5
|
-
* Uses pattern-based rendering with ReactPatternAdapter.
|
|
6
|
-
* Supports entity selection and relationship display.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { useState, useEffect, useMemo } from 'react';
|
|
10
|
-
import { useEntitiesQuery, useModelSchemaQuery } from '../../hooks/useApi';
|
|
11
|
-
import { usePatternAdapter, REACT_PROTOCOL_MAPPING } from '../../lib/react-pattern-adapter';
|
|
12
|
-
import type { View } from '../../types/api';
|
|
13
|
-
|
|
14
|
-
interface DetailViewProps {
|
|
15
|
-
view: View;
|
|
16
|
-
spec?: any;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function DetailView({ view, spec }: DetailViewProps) {
|
|
20
|
-
const patternAdapter = usePatternAdapter();
|
|
21
|
-
|
|
22
|
-
// Determine controller and model
|
|
23
|
-
let controllerName: string;
|
|
24
|
-
let modelName: string;
|
|
25
|
-
|
|
26
|
-
if (view.controller && spec) {
|
|
27
|
-
controllerName = view.controller;
|
|
28
|
-
const controller = spec.controllers[view.controller];
|
|
29
|
-
modelName = controller.model;
|
|
30
|
-
} else {
|
|
31
|
-
modelName = view.model as string;
|
|
32
|
-
controllerName = \`\${modelName}Controller\`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Fetch data and schema
|
|
36
|
-
const { data: entities = [] } = useEntitiesQuery(controllerName, modelName);
|
|
37
|
-
const { data: schema } = useModelSchemaQuery(modelName);
|
|
38
|
-
|
|
39
|
-
// Track selected entity
|
|
40
|
-
const [selectedEntityId, setSelectedEntityId] = useState<string | null>(
|
|
41
|
-
entities.length > 0 ? entities[0].id : null
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
// Update selected entity when entities change
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (entities.length > 0 && !selectedEntityId) {
|
|
47
|
-
setSelectedEntityId(entities[0].id);
|
|
48
|
-
}
|
|
49
|
-
}, [entities, selectedEntityId]);
|
|
50
|
-
|
|
51
|
-
// Get selected entity
|
|
52
|
-
const selectedEntity = useMemo(
|
|
53
|
-
() => entities.find((e: any) => e.id === selectedEntityId) || null,
|
|
54
|
-
[entities, selectedEntityId]
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
// Build model data and schemas
|
|
58
|
-
const modelData = useMemo(() => ({
|
|
59
|
-
[modelName]: entities
|
|
60
|
-
}), [modelName, entities]);
|
|
61
|
-
|
|
62
|
-
const modelSchemas = useMemo(() =>
|
|
63
|
-
schema ? { [modelName]: schema } : {}
|
|
64
|
-
, [modelName, schema]);
|
|
65
|
-
|
|
66
|
-
if (entities.length === 0) {
|
|
67
|
-
return <div className="p-4">No entities found</div>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Detect pattern
|
|
71
|
-
const pattern = patternAdapter.detectPattern({ ...view, type: 'detail' });
|
|
72
|
-
|
|
73
|
-
if (!pattern) {
|
|
74
|
-
return (
|
|
75
|
-
<div className="p-4 text-red-600">
|
|
76
|
-
Pattern not found for detail view
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Build render context
|
|
82
|
-
const context = {
|
|
83
|
-
pattern,
|
|
84
|
-
viewSpec: { ...view, type: 'detail', model: modelName },
|
|
85
|
-
modelData,
|
|
86
|
-
modelSchemas,
|
|
87
|
-
primaryModel: modelName,
|
|
88
|
-
selectedEntity,
|
|
89
|
-
primaryEntities: entities,
|
|
90
|
-
protocolMapping: REACT_PROTOCOL_MAPPING,
|
|
91
|
-
tailwindAdapter: patternAdapter['tailwindAdapter']
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// Render entity selector
|
|
95
|
-
let html = '';
|
|
96
|
-
if (entities.length > 0) {
|
|
97
|
-
html += \`
|
|
98
|
-
<div class="mb-4 pb-4 border-b border-gray-200 dark:border-gray-700">
|
|
99
|
-
<label class="block text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2">
|
|
100
|
-
Select \${modelName}:
|
|
101
|
-
</label>
|
|
102
|
-
<select
|
|
103
|
-
id="entity-selector"
|
|
104
|
-
class="w-full max-w-md px-3 py-2 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
105
|
-
>
|
|
106
|
-
\${entities.map((entity: any) => {
|
|
107
|
-
const displayName = entity.data?.name || entity.data?.title || entity.id;
|
|
108
|
-
return \`<option value="\${entity.id}" \${entity.id === selectedEntityId ? 'selected' : ''}>\${displayName}</option>\`;
|
|
109
|
-
}).join('')}
|
|
110
|
-
</select>
|
|
111
|
-
</div>
|
|
112
|
-
\`;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Render pattern
|
|
116
|
-
html += patternAdapter.renderPattern(context);
|
|
117
|
-
|
|
118
|
-
// Add event handler for selector
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
const selector = document.getElementById('entity-selector') as HTMLSelectElement;
|
|
121
|
-
if (selector) {
|
|
122
|
-
const handler = (e: Event) => {
|
|
123
|
-
const newId = (e.target as HTMLSelectElement).value;
|
|
124
|
-
setSelectedEntityId(newId);
|
|
125
|
-
};
|
|
126
|
-
selector.addEventListener('change', handler);
|
|
127
|
-
return () => selector.removeEventListener('change', handler);
|
|
128
|
-
}
|
|
129
|
-
}, [html]);
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<div className="runtime-view-container p-4 h-full overflow-auto">
|
|
133
|
-
<div dangerouslySetInnerHTML={{ __html: html }} />
|
|
134
|
-
</div>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export default DetailView;
|
|
139
|
-
`;
|
|
140
|
-
}
|
|
141
|
-
export {
|
|
142
|
-
generate
|
|
143
|
-
};
|