@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,275 +0,0 @@
|
|
|
1
|
-
function generateReactForm(context) {
|
|
2
|
-
const { model, spec } = context;
|
|
3
|
-
if (!model) {
|
|
4
|
-
throw new Error("Model is required in template context");
|
|
5
|
-
}
|
|
6
|
-
const modelName = model.name;
|
|
7
|
-
const formName = `${modelName}Form`;
|
|
8
|
-
return `/**
|
|
9
|
-
* ${formName}
|
|
10
|
-
* Form component for creating/editing ${modelName}
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { useForm } from 'react-hook-form';
|
|
14
|
-
import { zodResolver } from '@hookform/resolvers/zod';
|
|
15
|
-
import { z } from 'zod';
|
|
16
|
-
import { useEffect } from 'react';
|
|
17
|
-
import type { ${modelName} } from '../../types/${modelName}';
|
|
18
|
-
|
|
19
|
-
// Zod schema for form validation
|
|
20
|
-
const ${modelName.toLowerCase()}Schema = z.object({
|
|
21
|
-
${generateSchemaFields(model)}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
type ${modelName}FormData = z.infer<typeof ${modelName.toLowerCase()}Schema>;
|
|
25
|
-
|
|
26
|
-
interface ${formName}Props {
|
|
27
|
-
${modelName.toLowerCase()}?: ${modelName};
|
|
28
|
-
onSubmit: (data: ${modelName}FormData) => void;
|
|
29
|
-
onValidate?: (data: ${modelName}FormData) => void;
|
|
30
|
-
onDelete?: () => void;
|
|
31
|
-
onCancel?: () => void;
|
|
32
|
-
isDeleting?: boolean;
|
|
33
|
-
isValidating?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* ${formName} Component
|
|
38
|
-
*/
|
|
39
|
-
export function ${formName}({ ${modelName.toLowerCase()}, onSubmit, onValidate, onDelete, onCancel, isDeleting, isValidating }: ${formName}Props) {
|
|
40
|
-
const {
|
|
41
|
-
register,
|
|
42
|
-
handleSubmit,
|
|
43
|
-
getValues,
|
|
44
|
-
reset,
|
|
45
|
-
formState: { errors, isSubmitting },
|
|
46
|
-
} = useForm<${modelName}FormData>({
|
|
47
|
-
resolver: zodResolver(${modelName.toLowerCase()}Schema),
|
|
48
|
-
defaultValues: ${modelName.toLowerCase()} || {},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Reset form when ${modelName.toLowerCase()} changes
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (${modelName.toLowerCase()}) {
|
|
54
|
-
reset(${modelName.toLowerCase()});
|
|
55
|
-
} else {
|
|
56
|
-
reset({});
|
|
57
|
-
}
|
|
58
|
-
}, [${modelName.toLowerCase()}, reset]);
|
|
59
|
-
|
|
60
|
-
const handleValidateClick = () => {
|
|
61
|
-
if (onValidate) {
|
|
62
|
-
const data = getValues();
|
|
63
|
-
onValidate(data);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<form onSubmit={handleSubmit(onSubmit)} className="${modelName.toLowerCase()}-form space-y-4" autoComplete="off" data-lpignore="true" data-form-type="other">
|
|
69
|
-
{/* Hidden fake fields to trick password managers */}
|
|
70
|
-
<input type="text" name="fake-username" style={{ display: 'none' }} tabIndex={-1} autoComplete="off" aria-hidden="true" />
|
|
71
|
-
<input type="password" name="fake-password" style={{ display: 'none' }} tabIndex={-1} autoComplete="new-password" aria-hidden="true" />
|
|
72
|
-
|
|
73
|
-
${generateFormFields(model)}
|
|
74
|
-
|
|
75
|
-
<div className="form-actions flex flex-wrap gap-2 pt-4">
|
|
76
|
-
<button
|
|
77
|
-
type="submit"
|
|
78
|
-
disabled={isSubmitting}
|
|
79
|
-
className="px-6 py-2 bg-blue-600 text-white font-medium rounded hover:bg-blue-700 disabled:bg-slate-600 disabled:cursor-not-allowed transition-colors"
|
|
80
|
-
>
|
|
81
|
-
{isSubmitting ? 'Saving...' : 'Save'}
|
|
82
|
-
</button>
|
|
83
|
-
|
|
84
|
-
{onValidate && (
|
|
85
|
-
<button
|
|
86
|
-
type="button"
|
|
87
|
-
onClick={handleValidateClick}
|
|
88
|
-
disabled={isValidating}
|
|
89
|
-
className="px-6 py-2 bg-green-600 text-white font-medium rounded hover:bg-green-700 disabled:bg-slate-600 disabled:cursor-not-allowed transition-colors"
|
|
90
|
-
>
|
|
91
|
-
{isValidating ? 'Validating...' : 'Validate'}
|
|
92
|
-
</button>
|
|
93
|
-
)}
|
|
94
|
-
|
|
95
|
-
{onDelete && (
|
|
96
|
-
<button
|
|
97
|
-
type="button"
|
|
98
|
-
onClick={onDelete}
|
|
99
|
-
disabled={isDeleting}
|
|
100
|
-
className="px-6 py-2 bg-red-600 text-white font-medium rounded hover:bg-red-700 disabled:bg-slate-600 disabled:cursor-not-allowed transition-colors"
|
|
101
|
-
>
|
|
102
|
-
{isDeleting ? 'Deleting...' : 'Delete'}
|
|
103
|
-
</button>
|
|
104
|
-
)}
|
|
105
|
-
|
|
106
|
-
{onCancel && (
|
|
107
|
-
<button
|
|
108
|
-
type="button"
|
|
109
|
-
onClick={onCancel}
|
|
110
|
-
className="px-6 py-2 bg-slate-600 text-gray-200 font-medium rounded hover:bg-slate-500 transition-colors"
|
|
111
|
-
>
|
|
112
|
-
Cancel
|
|
113
|
-
</button>
|
|
114
|
-
)}
|
|
115
|
-
</div>
|
|
116
|
-
</form>
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
`;
|
|
120
|
-
}
|
|
121
|
-
function generateSchemaFields(model) {
|
|
122
|
-
let attributes = model.attributes || {};
|
|
123
|
-
if (Array.isArray(attributes)) {
|
|
124
|
-
const obj = {};
|
|
125
|
-
attributes.forEach((attr, index) => {
|
|
126
|
-
if (attr && typeof attr === "object" && attr.name) {
|
|
127
|
-
obj[attr.name] = attr;
|
|
128
|
-
} else if (Array.isArray(attr) && attr.length >= 2) {
|
|
129
|
-
obj[attr[0]] = attr[1];
|
|
130
|
-
} else {
|
|
131
|
-
obj[index.toString()] = attr;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
attributes = obj;
|
|
135
|
-
}
|
|
136
|
-
const fields = [];
|
|
137
|
-
for (const [name, config] of Object.entries(attributes)) {
|
|
138
|
-
const attr = config;
|
|
139
|
-
if (attr.category === "metadata") continue;
|
|
140
|
-
const type = attr.type || "String";
|
|
141
|
-
let zodType = "z.string()";
|
|
142
|
-
if (type === "Integer" || type === "Number") zodType = "z.number()";
|
|
143
|
-
if (type === "Boolean") zodType = "z.boolean()";
|
|
144
|
-
if (type === "Email") zodType = "z.string().email()";
|
|
145
|
-
if (type === "DateTime") zodType = "z.string()";
|
|
146
|
-
if (type === "UUID") zodType = "z.string().uuid()";
|
|
147
|
-
if (attr.required) {
|
|
148
|
-
} else {
|
|
149
|
-
zodType += ".optional()";
|
|
150
|
-
}
|
|
151
|
-
if (attr.min && type === "String") {
|
|
152
|
-
zodType = zodType.replace(")", `.min(${attr.min})`);
|
|
153
|
-
}
|
|
154
|
-
if (attr.max && type === "String") {
|
|
155
|
-
zodType = zodType.replace(")", `.max(${attr.max})`);
|
|
156
|
-
}
|
|
157
|
-
fields.push(` ${name}: ${zodType},`);
|
|
158
|
-
}
|
|
159
|
-
return fields.join("\n");
|
|
160
|
-
}
|
|
161
|
-
function generateFormFields(model) {
|
|
162
|
-
let attributes = model.attributes || {};
|
|
163
|
-
if (Array.isArray(attributes)) {
|
|
164
|
-
const obj = {};
|
|
165
|
-
attributes.forEach((attr, index) => {
|
|
166
|
-
if (attr && typeof attr === "object" && attr.name) {
|
|
167
|
-
obj[attr.name] = attr;
|
|
168
|
-
} else if (Array.isArray(attr) && attr.length >= 2) {
|
|
169
|
-
obj[attr[0]] = attr[1];
|
|
170
|
-
} else {
|
|
171
|
-
obj[index.toString()] = attr;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
attributes = obj;
|
|
175
|
-
}
|
|
176
|
-
const fields = [];
|
|
177
|
-
const regularFields = [];
|
|
178
|
-
const textAreaFields = [];
|
|
179
|
-
for (const [name, config] of Object.entries(attributes)) {
|
|
180
|
-
const attr = config;
|
|
181
|
-
if (attr.category === "metadata") continue;
|
|
182
|
-
const type = attr.type || "String";
|
|
183
|
-
const label = name.charAt(0).toUpperCase() + name.slice(1);
|
|
184
|
-
const isRequired = attr.required;
|
|
185
|
-
let inputType = "text";
|
|
186
|
-
if (type === "Email") inputType = "email";
|
|
187
|
-
if (type === "Number" || type === "Integer") inputType = "number";
|
|
188
|
-
if (type === "Boolean") inputType = "checkbox";
|
|
189
|
-
if (type === "DateTime") inputType = "datetime-local";
|
|
190
|
-
if (type === "Text") inputType = "textarea";
|
|
191
|
-
const field = inputType === "textarea" ? ` <div className="form-field">
|
|
192
|
-
<label htmlFor="${name}" className="block text-sm font-medium text-gray-300 mb-1">
|
|
193
|
-
${name}${isRequired ? ' <span className="text-red-400">*</span>' : ""}
|
|
194
|
-
</label>
|
|
195
|
-
<textarea
|
|
196
|
-
id="${name}"
|
|
197
|
-
{...register('${name}')}
|
|
198
|
-
rows={2}
|
|
199
|
-
className={\`w-full px-3 py-2 rounded bg-slate-700 border transition-colors text-gray-200
|
|
200
|
-
\${errors['${name}']
|
|
201
|
-
? 'border-red-500 focus:border-red-400'
|
|
202
|
-
: 'border-slate-600 focus:border-blue-500'
|
|
203
|
-
} focus:outline-none focus:ring-0 resize-none\`}
|
|
204
|
-
placeholder="Enter ${name}"
|
|
205
|
-
autoComplete="off"
|
|
206
|
-
data-lpignore="true"
|
|
207
|
-
data-form-type="other"
|
|
208
|
-
readOnly
|
|
209
|
-
onFocus={(e) => e.target.removeAttribute('readonly')}
|
|
210
|
-
/>
|
|
211
|
-
{errors['${name}'] && (
|
|
212
|
-
<p className="mt-1 text-xs text-red-400">{errors['${name}']?.message}</p>
|
|
213
|
-
)}
|
|
214
|
-
</div>` : inputType === "checkbox" ? ` <div className="form-field">
|
|
215
|
-
<label htmlFor="${name}" className="flex items-center text-sm font-medium text-gray-300">
|
|
216
|
-
<input
|
|
217
|
-
id="${name}"
|
|
218
|
-
type="checkbox"
|
|
219
|
-
{...register('${name}')}
|
|
220
|
-
className="mr-2"
|
|
221
|
-
autoComplete="off"
|
|
222
|
-
data-lpignore="true"
|
|
223
|
-
/>
|
|
224
|
-
${name}${isRequired ? ' <span className="ml-1 text-red-400">*</span>' : ""}
|
|
225
|
-
</label>
|
|
226
|
-
{errors['${name}'] && (
|
|
227
|
-
<p className="mt-1 text-xs text-red-400">{errors['${name}']?.message}</p>
|
|
228
|
-
)}
|
|
229
|
-
</div>` : ` <div className="form-field">
|
|
230
|
-
<label htmlFor="${name}" className="block text-sm font-medium text-gray-300 mb-1">
|
|
231
|
-
${name}${isRequired ? ' <span className="text-red-400">*</span>' : ""}
|
|
232
|
-
</label>
|
|
233
|
-
<input
|
|
234
|
-
id="${name}"
|
|
235
|
-
type="${inputType}"
|
|
236
|
-
{...register('${name}')}
|
|
237
|
-
className={\`w-full px-3 py-2 rounded bg-slate-700 border transition-colors text-gray-200
|
|
238
|
-
\${errors['${name}']
|
|
239
|
-
? 'border-red-500 focus:border-red-400'
|
|
240
|
-
: 'border-slate-600 focus:border-blue-500'
|
|
241
|
-
} focus:outline-none focus:ring-0\`}
|
|
242
|
-
placeholder="Enter ${name}"
|
|
243
|
-
autoComplete="off"
|
|
244
|
-
data-lpignore="true"
|
|
245
|
-
data-form-type="other"
|
|
246
|
-
readOnly
|
|
247
|
-
onFocus={(e) => e.target.removeAttribute('readonly')}
|
|
248
|
-
/>
|
|
249
|
-
{errors['${name}'] && (
|
|
250
|
-
<p className="mt-1 text-xs text-red-400">{errors['${name}']?.message}</p>
|
|
251
|
-
)}
|
|
252
|
-
</div>`;
|
|
253
|
-
if (inputType === "textarea") {
|
|
254
|
-
textAreaFields.push(field);
|
|
255
|
-
} else {
|
|
256
|
-
regularFields.push(field);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
let output = "";
|
|
260
|
-
if (regularFields.length > 0) {
|
|
261
|
-
output += ` <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
262
|
-
`;
|
|
263
|
-
output += regularFields.join("\n\n");
|
|
264
|
-
output += `
|
|
265
|
-
</div>`;
|
|
266
|
-
}
|
|
267
|
-
if (textAreaFields.length > 0) {
|
|
268
|
-
if (output) output += "\n\n";
|
|
269
|
-
output += textAreaFields.join("\n\n");
|
|
270
|
-
}
|
|
271
|
-
return output;
|
|
272
|
-
}
|
|
273
|
-
export {
|
|
274
|
-
generateReactForm as default
|
|
275
|
-
};
|
package/dist/libs/instance-factories/views/templates/react/frontend-package-json-generator.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
function generateFrontendPackageJson(context) {
|
|
2
|
-
const { spec } = context;
|
|
3
|
-
const componentName = spec?.name || "app";
|
|
4
|
-
const packageName = `${componentName.toLowerCase()}-frontend`;
|
|
5
|
-
const packageJson = {
|
|
6
|
-
name: packageName,
|
|
7
|
-
version: "1.0.0",
|
|
8
|
-
description: `Frontend for ${spec?.description || componentName}`,
|
|
9
|
-
private: true,
|
|
10
|
-
type: "module",
|
|
11
|
-
scripts: {
|
|
12
|
-
dev: "vite",
|
|
13
|
-
build: "tsc && vite build",
|
|
14
|
-
preview: "vite preview",
|
|
15
|
-
lint: "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
16
|
-
"type-check": "tsc --noEmit"
|
|
17
|
-
},
|
|
18
|
-
dependencies: {
|
|
19
|
-
"react": "^18.3.1",
|
|
20
|
-
"react-dom": "^18.3.1",
|
|
21
|
-
"react-router-dom": "^6.26.2",
|
|
22
|
-
"@tanstack/react-query": "^5.56.2",
|
|
23
|
-
"zustand": "^4.5.5",
|
|
24
|
-
"axios": "^1.7.7"
|
|
25
|
-
},
|
|
26
|
-
devDependencies: {
|
|
27
|
-
"@types/react": "^18.3.9",
|
|
28
|
-
"@types/react-dom": "^18.3.0",
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "^8.7.0",
|
|
30
|
-
"@typescript-eslint/parser": "^8.7.0",
|
|
31
|
-
"@vitejs/plugin-react": "^4.3.1",
|
|
32
|
-
"autoprefixer": "^10.4.20",
|
|
33
|
-
"eslint": "^9.11.1",
|
|
34
|
-
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
|
|
35
|
-
"eslint-plugin-react-refresh": "^0.4.12",
|
|
36
|
-
"postcss": "^8.4.47",
|
|
37
|
-
"tailwindcss": "^3.4.13",
|
|
38
|
-
"typescript": "^5.6.2",
|
|
39
|
-
"vite": "^5.4.8"
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
return JSON.stringify(packageJson, null, 2);
|
|
43
|
-
}
|
|
44
|
-
export {
|
|
45
|
-
generateFrontendPackageJson as default
|
|
46
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
function generateReactHook(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
|
-
const hookName = `use${modelName}`;
|
|
8
|
-
const controllerName = `${modelName}Controller`;
|
|
9
|
-
const singular = modelName.charAt(0).toLowerCase() + modelName.slice(1);
|
|
10
|
-
const plural = singular + "s";
|
|
11
|
-
return `/**
|
|
12
|
-
* ${hookName}
|
|
13
|
-
*
|
|
14
|
-
* Thin delegator over the canonical useApi hooks. All state flows
|
|
15
|
-
* through \`['entities', '${modelName}']\` so WebSocket invalidation
|
|
16
|
-
* reaches every view consuming this hook.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { useMemo } from 'react';
|
|
20
|
-
import {
|
|
21
|
-
useEntitiesQuery,
|
|
22
|
-
useExecuteOperationMutation,
|
|
23
|
-
} from './useApi';
|
|
24
|
-
import type { ${modelName} } from '../types/${modelName}';
|
|
25
|
-
|
|
26
|
-
interface ${capitalize(hookName)}Options {
|
|
27
|
-
id?: string;
|
|
28
|
-
list?: boolean;
|
|
29
|
-
filters?: Record<string, any>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function ${hookName}(opts: ${capitalize(hookName)}Options = {}) {
|
|
33
|
-
const { id, filters: _filters } = opts;
|
|
34
|
-
|
|
35
|
-
// Canonical list query \u2014 one cache key per model. The list flag
|
|
36
|
-
// is preserved for backwards compatibility but the query always
|
|
37
|
-
// runs; React Query dedupes across consumers automatically.
|
|
38
|
-
const query = useEntitiesQuery('${controllerName}', '${modelName}');
|
|
39
|
-
const ${plural} = (query.data as ${modelName}[] | undefined) || [];
|
|
40
|
-
|
|
41
|
-
// Single-entity lookup is client-side against the canonical list
|
|
42
|
-
// so both the detail view and the list view share one source of
|
|
43
|
-
// truth. If the caller needs server-side hydration for a single
|
|
44
|
-
// entity, they should call useEntitiesQuery directly with a
|
|
45
|
-
// filtered controller endpoint.
|
|
46
|
-
const ${singular} = useMemo<${modelName} | null>(() => {
|
|
47
|
-
if (!id) return null;
|
|
48
|
-
for (const entity of ${plural}) {
|
|
49
|
-
const entityId = (entity as any)?.id || (entity as any)?.data?.id;
|
|
50
|
-
if (entityId === id) return entity;
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
}, [id, ${plural}]);
|
|
54
|
-
|
|
55
|
-
const mutation = useExecuteOperationMutation();
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
${singular},
|
|
59
|
-
${plural},
|
|
60
|
-
isLoading: query.isLoading,
|
|
61
|
-
error: query.error,
|
|
62
|
-
refetch: () => { /* handled by useEntitiesQuery refetchInterval + WS invalidation */ },
|
|
63
|
-
create: (data: Partial<${modelName}>) =>
|
|
64
|
-
mutation.mutateAsync({ controllerName: '${controllerName}', operationName: 'create', data: data as Record<string, unknown> }),
|
|
65
|
-
update: (args: { id: string; data: Partial<${modelName}> }) =>
|
|
66
|
-
mutation.mutateAsync({ controllerName: '${controllerName}', operationName: 'update', entityId: args.id, data: args.data as Record<string, unknown> }),
|
|
67
|
-
delete: (entityId: string) =>
|
|
68
|
-
mutation.mutateAsync({ controllerName: '${controllerName}', operationName: 'delete', entityId, data: {} }),
|
|
69
|
-
isCreating: mutation.isPending,
|
|
70
|
-
isUpdating: mutation.isPending,
|
|
71
|
-
isDeleting: mutation.isPending,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
`;
|
|
75
|
-
}
|
|
76
|
-
function capitalize(s) {
|
|
77
|
-
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
78
|
-
}
|
|
79
|
-
export {
|
|
80
|
-
generateReactHook as default
|
|
81
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
function generateIndexHtml(context) {
|
|
2
|
-
const { spec } = context;
|
|
3
|
-
const componentName = spec?.metadata?.component || spec?.component?.name || "App";
|
|
4
|
-
const description = spec?.metadata?.description || spec?.component?.description || "Generated by SpecVerse";
|
|
5
|
-
return `<!DOCTYPE html>
|
|
6
|
-
<html lang="en">
|
|
7
|
-
<head>
|
|
8
|
-
<meta charset="UTF-8" />
|
|
9
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
10
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
11
|
-
<meta name="description" content="${description}" />
|
|
12
|
-
<title>${componentName}</title>
|
|
13
|
-
</head>
|
|
14
|
-
<body>
|
|
15
|
-
<div id="root"></div>
|
|
16
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
17
|
-
</body>
|
|
18
|
-
</html>
|
|
19
|
-
`;
|
|
20
|
-
}
|
|
21
|
-
export {
|
|
22
|
-
generateIndexHtml as default
|
|
23
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
function generateMainTsx(context) {
|
|
2
|
-
return `/**
|
|
3
|
-
* React Application Entry Point
|
|
4
|
-
* Auto-generated by SpecVerse
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import ReactDOM from 'react-dom/client';
|
|
9
|
-
import App from './App';
|
|
10
|
-
import './index.css';
|
|
11
|
-
|
|
12
|
-
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
13
|
-
<React.StrictMode>
|
|
14
|
-
<App />
|
|
15
|
-
</React.StrictMode>
|
|
16
|
-
);
|
|
17
|
-
`;
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
generateMainTsx as default
|
|
21
|
-
};
|