@specverse/engine-realize 3.5.3
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/09-api/ai-spec.yaml +194 -0
- package/assets/examples/09-api/converted.yaml +95 -0
- package/assets/examples/09-api/diagram-architecture.mmd +10 -0
- package/assets/examples/09-api/diagram-er.mmd +10 -0
- package/assets/examples/09-api/documentation.html +104 -0
- package/assets/examples/09-api/documentation.md +95 -0
- package/assets/examples/09-api/inferred-spec.yaml +420 -0
- package/assets/examples/09-api/openapi.json +61 -0
- package/assets/examples/10-api/README.md +216 -0
- package/assets/examples/10-api/ai-spec.yaml +194 -0
- package/assets/examples/10-api/converted.yaml +96 -0
- package/assets/examples/10-api/diagram-architecture.mmd +10 -0
- package/assets/examples/10-api/diagram-er.mmd +10 -0
- package/assets/examples/10-api/documentation.html +104 -0
- package/assets/examples/10-api/documentation.md +95 -0
- package/assets/examples/10-api/inferred-spec.yaml +7 -0
- package/assets/examples/10-api/metadata.yaml +89 -0
- package/assets/examples/10-api/openapi.json +61 -0
- package/assets/examples/10-api/package-integration-test.js +177 -0
- package/assets/examples/10-api/usage-example.js +323 -0
- package/assets/examples/10-api/usage-example.ts +363 -0
- package/assets/examples/10-api/workflow-test.js +113 -0
- package/assets/examples/manifests/01-simple-default-mappings.yaml +36 -0
- package/assets/examples/manifests/02-capability-mappings.yaml +55 -0
- package/assets/examples/manifests/03-hybrid-mappings.yaml +109 -0
- package/assets/examples/manifests/README.md +245 -0
- package/assets/examples/manifests/backend-only.yaml +43 -0
- package/assets/examples/manifests/blog-api.md +78 -0
- package/assets/examples/manifests/blog-api.specly +79 -0
- package/assets/examples/manifests/frontend-only.yaml +27 -0
- package/assets/examples/manifests/fullstack-app.yaml +44 -0
- package/assets/examples/manifests/fullstack-monorepo.yaml +62 -0
- package/assets/examples/validate-examples-with-expected-failures.cjs +328 -0
- package/assets/examples/validate-examples.cjs +225 -0
- package/assets/examples-decomposed/cloud-native-manifest.example.yaml +8 -0
- package/assets/examples-decomposed/cloud-native-manifest.md +379 -0
- package/assets/examples-decomposed/cloud-native-manifest.specly +60 -0
- package/assets/examples-decomposed/docker-compose-manifest.example.yaml +8 -0
- package/assets/examples-decomposed/docker-compose-manifest.md +326 -0
- package/assets/examples-decomposed/docker-compose-manifest.specly +40 -0
- package/assets/examples-decomposed/kubernetes-deployment-manifest.example.yaml +8 -0
- package/assets/examples-decomposed/kubernetes-deployment-manifest.md +237 -0
- package/assets/examples-decomposed/kubernetes-deployment-manifest.specly +41 -0
- package/assets/templates/README.md +559 -0
- package/assets/templates/TEMPLATE-ENHANCEMENTS-V33.md +462 -0
- package/assets/templates/backend-only/CLAUDE.md +73 -0
- package/assets/templates/backend-only/README.md +197 -0
- package/assets/templates/backend-only/deployments/README.md +149 -0
- package/assets/templates/backend-only/deployments/development.specly +53 -0
- package/assets/templates/backend-only/deployments/production.specly +87 -0
- package/assets/templates/backend-only/docs/README.md +50 -0
- package/assets/templates/backend-only/docs/api/README.md +7 -0
- package/assets/templates/backend-only/docs/diagrams/README.md +85 -0
- package/assets/templates/backend-only/docs/example-documentation-template.md +269 -0
- package/assets/templates/backend-only/docs/guides/README.md +15 -0
- package/assets/templates/backend-only/dot.env.example +18 -0
- package/assets/templates/backend-only/generated/README.md +56 -0
- package/assets/templates/backend-only/generated/code/integration-test.template.js +320 -0
- package/assets/templates/backend-only/generated/code/package.json.template +34 -0
- package/assets/templates/backend-only/generated/docs/README.md +49 -0
- package/assets/templates/backend-only/gitignore +54 -0
- package/assets/templates/backend-only/manifests/README.md +72 -0
- package/assets/templates/backend-only/manifests/docker-compose.specly +91 -0
- package/assets/templates/backend-only/manifests/implementation.yaml +100 -0
- package/assets/templates/backend-only/manifests/kubernetes.specly +140 -0
- package/assets/templates/backend-only/package.json +59 -0
- package/assets/templates/backend-only/scripts/test-all.sh +160 -0
- package/assets/templates/backend-only/scripts/test-generated-code.sh +165 -0
- package/assets/templates/backend-only/specs/main.specly +67 -0
- package/assets/templates/default/CLAUDE.md +141 -0
- package/assets/templates/default/README.md +404 -0
- package/assets/templates/default/deployments/README.md +149 -0
- package/assets/templates/default/deployments/development.specly +53 -0
- package/assets/templates/default/deployments/production.specly +87 -0
- package/assets/templates/default/docs/README.md +50 -0
- package/assets/templates/default/docs/api/README.md +7 -0
- package/assets/templates/default/docs/diagrams/README.md +85 -0
- package/assets/templates/default/docs/example-documentation-template.md +269 -0
- package/assets/templates/default/docs/guides/README.md +15 -0
- package/assets/templates/default/dot.env.example +18 -0
- package/assets/templates/default/generated/README.md +56 -0
- package/assets/templates/default/generated/code/integration-test.template.js +320 -0
- package/assets/templates/default/generated/code/package.json.template +34 -0
- package/assets/templates/default/generated/docs/README.md +49 -0
- package/assets/templates/default/gitignore +54 -0
- package/assets/templates/default/manifests/README.md +72 -0
- package/assets/templates/default/manifests/docker-compose.specly +91 -0
- package/assets/templates/default/manifests/implementation.yaml +176 -0
- package/assets/templates/default/manifests/kubernetes.specly +140 -0
- package/assets/templates/default/package.json +61 -0
- package/assets/templates/default/scripts/test-all.sh +160 -0
- package/assets/templates/default/scripts/test-generated-code.sh +165 -0
- package/assets/templates/default/specs/main.specly +67 -0
- package/assets/templates/frontend-only/CLAUDE.md +75 -0
- package/assets/templates/frontend-only/README.md +231 -0
- package/assets/templates/frontend-only/deployments/README.md +149 -0
- package/assets/templates/frontend-only/deployments/development.specly +53 -0
- package/assets/templates/frontend-only/deployments/production.specly +87 -0
- package/assets/templates/frontend-only/docs/README.md +50 -0
- package/assets/templates/frontend-only/docs/api/README.md +7 -0
- package/assets/templates/frontend-only/docs/diagrams/README.md +85 -0
- package/assets/templates/frontend-only/docs/example-documentation-template.md +269 -0
- package/assets/templates/frontend-only/docs/guides/README.md +15 -0
- package/assets/templates/frontend-only/dot.env.example +18 -0
- package/assets/templates/frontend-only/generated/README.md +56 -0
- package/assets/templates/frontend-only/generated/code/integration-test.template.js +320 -0
- package/assets/templates/frontend-only/generated/code/package.json.template +34 -0
- package/assets/templates/frontend-only/generated/docs/README.md +49 -0
- package/assets/templates/frontend-only/gitignore +54 -0
- package/assets/templates/frontend-only/manifests/README.md +72 -0
- package/assets/templates/frontend-only/manifests/docker-compose.specly +91 -0
- package/assets/templates/frontend-only/manifests/implementation.yaml +58 -0
- package/assets/templates/frontend-only/manifests/kubernetes.specly +140 -0
- package/assets/templates/frontend-only/package.json +59 -0
- package/assets/templates/frontend-only/scripts/test-all.sh +160 -0
- package/assets/templates/frontend-only/scripts/test-generated-code.sh +165 -0
- package/assets/templates/frontend-only/specs/main.specly +57 -0
- package/assets/templates/full-stack/AI-GUIDE.md +60 -0
- package/assets/templates/full-stack/CLAUDE.md +141 -0
- package/assets/templates/full-stack/README.md +382 -0
- package/assets/templates/full-stack/archive/AI-GUIDE-legacy.md +392 -0
- package/assets/templates/full-stack/deployments/README.md +149 -0
- package/assets/templates/full-stack/deployments/development.specly +53 -0
- package/assets/templates/full-stack/deployments/production.specly +87 -0
- package/assets/templates/full-stack/docs/README.md +51 -0
- package/assets/templates/full-stack/docs/api/README.md +7 -0
- package/assets/templates/full-stack/docs/diagrams/README.md +85 -0
- package/assets/templates/full-stack/docs/example-documentation-template.md +269 -0
- package/assets/templates/full-stack/docs/guides/README.md +15 -0
- package/assets/templates/full-stack/generated/README.md +56 -0
- package/assets/templates/full-stack/generated/code/integration-test.template.js +320 -0
- package/assets/templates/full-stack/generated/code/package.json.template +34 -0
- package/assets/templates/full-stack/generated/docs/README.md +49 -0
- package/assets/templates/full-stack/gitignore +54 -0
- package/assets/templates/full-stack/manifests/README.md +72 -0
- package/assets/templates/full-stack/manifests/docker-compose.specly +91 -0
- package/assets/templates/full-stack/manifests/implementation.yaml +155 -0
- package/assets/templates/full-stack/manifests/kubernetes.specly +140 -0
- package/assets/templates/full-stack/package.json +45 -0
- package/assets/templates/full-stack/scripts/test-all.sh +160 -0
- package/assets/templates/full-stack/scripts/test-generated-code.sh +165 -0
- package/assets/templates/full-stack/specs/example-v33.specly +297 -0
- package/assets/templates/full-stack/specs/main-simple.specly +73 -0
- package/assets/templates/full-stack/specs/main.specly +408 -0
- package/dist/engines/code-generator.d.ts +86 -0
- package/dist/engines/code-generator.d.ts.map +1 -0
- package/dist/engines/code-generator.js +159 -0
- package/dist/engines/code-generator.js.map +1 -0
- package/dist/engines/engine-registry.d.ts +94 -0
- package/dist/engines/engine-registry.d.ts.map +1 -0
- package/dist/engines/engine-registry.js +163 -0
- package/dist/engines/engine-registry.js.map +1 -0
- package/dist/engines/index.d.ts +10 -0
- package/dist/engines/index.d.ts.map +1 -0
- package/dist/engines/index.js +12 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/engines/typescript-engine.d.ts +74 -0
- package/dist/engines/typescript-engine.d.ts.map +1 -0
- package/dist/engines/typescript-engine.js +288 -0
- package/dist/engines/typescript-engine.js.map +1 -0
- package/dist/generators/index.d.ts +11 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +11 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +434 -0
- package/dist/index.js.map +1 -0
- package/dist/library/index.d.ts +12 -0
- package/dist/library/index.d.ts.map +1 -0
- package/dist/library/index.js +15 -0
- package/dist/library/index.js.map +1 -0
- package/dist/library/library.d.ts +132 -0
- package/dist/library/library.d.ts.map +1 -0
- package/dist/library/library.js +343 -0
- package/dist/library/library.js.map +1 -0
- package/dist/library/loader.d.ts +73 -0
- package/dist/library/loader.d.ts.map +1 -0
- package/dist/library/loader.js +150 -0
- package/dist/library/loader.js.map +1 -0
- package/dist/library/resolver.d.ts +104 -0
- package/dist/library/resolver.d.ts.map +1 -0
- package/dist/library/resolver.js +299 -0
- package/dist/library/resolver.js.map +1 -0
- package/dist/library/validator.d.ts +65 -0
- package/dist/library/validator.d.ts.map +1 -0
- package/dist/library/validator.js +203 -0
- package/dist/library/validator.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/instance-factory.d.ts +289 -0
- package/dist/types/instance-factory.d.ts.map +1 -0
- package/dist/types/instance-factory.js +8 -0
- package/dist/types/instance-factory.js.map +1 -0
- package/dist/types/unified-mappings.d.ts +163 -0
- package/dist/types/unified-mappings.d.ts.map +1 -0
- package/dist/types/unified-mappings.js +110 -0
- package/dist/types/unified-mappings.js.map +1 -0
- package/dist/utils/ai-spec-loader.d.ts +77 -0
- package/dist/utils/ai-spec-loader.d.ts.map +1 -0
- package/dist/utils/ai-spec-loader.js +138 -0
- package/dist/utils/ai-spec-loader.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/manifest-loader.d.ts +107 -0
- package/dist/utils/manifest-loader.d.ts.map +1 -0
- package/dist/utils/manifest-loader.js +168 -0
- package/dist/utils/manifest-loader.js.map +1 -0
- package/dist/utils/mapping-migration.d.ts +53 -0
- package/dist/utils/mapping-migration.d.ts.map +1 -0
- package/dist/utils/mapping-migration.js +194 -0
- package/dist/utils/mapping-migration.js.map +1 -0
- package/libs/instance-factories/CURVED-INTERFACE.md +278 -0
- package/libs/instance-factories/README.md +433 -0
- package/libs/instance-factories/applications/generic-app.yaml +52 -0
- package/libs/instance-factories/applications/react-app.yaml +186 -0
- package/libs/instance-factories/applications/templates/generic/backend-env-generator.ts +31 -0
- package/libs/instance-factories/applications/templates/generic/backend-package-json-generator.ts +80 -0
- package/libs/instance-factories/applications/templates/generic/backend-tsconfig-generator.ts +69 -0
- package/libs/instance-factories/applications/templates/generic/main-generator.ts +308 -0
- package/libs/instance-factories/applications/templates/react/_view-components-source.ts +555 -0
- package/libs/instance-factories/applications/templates/react/api-client-generator.ts +436 -0
- package/libs/instance-factories/applications/templates/react/api-types-generator.ts +153 -0
- package/libs/instance-factories/applications/templates/react/app-tsx-generator.ts +94 -0
- package/libs/instance-factories/applications/templates/react/env-example-generator.ts +24 -0
- package/libs/instance-factories/applications/templates/react/field-helpers-generator.ts +106 -0
- package/libs/instance-factories/applications/templates/react/gitignore-generator.ts +38 -0
- package/libs/instance-factories/applications/templates/react/index-css-generator.ts +85 -0
- package/libs/instance-factories/applications/templates/react/index-html-generator.ts +30 -0
- package/libs/instance-factories/applications/templates/react/main-tsx-generator.ts +34 -0
- package/libs/instance-factories/applications/templates/react/package-json-generator.ts +54 -0
- package/libs/instance-factories/applications/templates/react/pattern-adapter-generator.ts +179 -0
- package/libs/instance-factories/applications/templates/react/react-pattern-adapter.tsx +1347 -0
- package/libs/instance-factories/applications/templates/react/relationship-field-generator.ts +150 -0
- package/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.ts +704 -0
- package/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.ts +84 -0
- package/libs/instance-factories/applications/templates/react/tsconfig-generator.ts +35 -0
- package/libs/instance-factories/applications/templates/react/use-api-hooks-generator.ts +121 -0
- package/libs/instance-factories/applications/templates/react/view-dashboard-generator.ts +150 -0
- package/libs/instance-factories/applications/templates/react/view-detail-generator.ts +150 -0
- package/libs/instance-factories/applications/templates/react/view-form-generator.ts +362 -0
- package/libs/instance-factories/applications/templates/react/view-list-generator.ts +98 -0
- package/libs/instance-factories/applications/templates/react/view-router-generator.ts +89 -0
- package/libs/instance-factories/applications/templates/react/vite-config-generator.ts +49 -0
- package/libs/instance-factories/archived/fastify-prisma.yaml +104 -0
- package/libs/instance-factories/cli/commander-js.yaml +55 -0
- package/libs/instance-factories/cli/templates/commander/cli-entry-generator.d.ts +12 -0
- package/libs/instance-factories/cli/templates/commander/cli-entry-generator.d.ts.map +1 -0
- package/libs/instance-factories/cli/templates/commander/cli-entry-generator.js +115 -0
- package/libs/instance-factories/cli/templates/commander/cli-entry-generator.js.map +1 -0
- package/libs/instance-factories/cli/templates/commander/cli-entry-generator.ts +145 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.d.ts +14 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.d.ts.map +1 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.js +182 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.js.map +1 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.ts +992 -0
- package/libs/instance-factories/communication/event-emitter.yaml +56 -0
- package/libs/instance-factories/communication/rabbitmq-events.yaml +87 -0
- package/libs/instance-factories/communication/templates/eventemitter/bus-generator.ts +93 -0
- package/libs/instance-factories/communication/templates/eventemitter/publisher-generator.ts +117 -0
- package/libs/instance-factories/communication/templates/eventemitter/subscriber-generator.ts +101 -0
- package/libs/instance-factories/controllers/fastify.yaml +127 -0
- package/libs/instance-factories/controllers/templates/fastify/meta-routes-generator.ts +103 -0
- package/libs/instance-factories/controllers/templates/fastify/routes-generator.ts +389 -0
- package/libs/instance-factories/controllers/templates/fastify/server-generator.ts +76 -0
- package/libs/instance-factories/infrastructure/docker-k8s.yaml +61 -0
- package/libs/instance-factories/infrastructure/templates/docker-k8s/infrastructure-generator.ts +46 -0
- package/libs/instance-factories/orms/prisma.yaml +89 -0
- package/libs/instance-factories/orms/templates/prisma/schema-generator.ts +563 -0
- package/libs/instance-factories/orms/templates/prisma/services-generator.ts +408 -0
- package/libs/instance-factories/scaffolding/generic-scaffold.yaml +65 -0
- package/libs/instance-factories/scaffolding/templates/generic/env-example-generator.ts +73 -0
- package/libs/instance-factories/scaffolding/templates/generic/env-generator.ts +85 -0
- package/libs/instance-factories/scaffolding/templates/generic/gitignore-generator.ts +69 -0
- package/libs/instance-factories/scaffolding/templates/generic/package-json-generator.ts +176 -0
- package/libs/instance-factories/scaffolding/templates/generic/readme-generator.ts +207 -0
- package/libs/instance-factories/scaffolding/templates/generic/tsconfig-generator.ts +78 -0
- package/libs/instance-factories/scaffolding/templates/generic/tsconfig-react-generator.ts +41 -0
- package/libs/instance-factories/sdks/python-sdk.yaml +66 -0
- package/libs/instance-factories/sdks/templates/python/sdk-generator.ts +50 -0
- package/libs/instance-factories/sdks/templates/typescript/sdk-generator.ts +49 -0
- package/libs/instance-factories/sdks/typescript-sdk.yaml +59 -0
- package/libs/instance-factories/services/prisma-services.yaml +71 -0
- package/libs/instance-factories/services/templates/prisma/behavior-generator.ts +303 -0
- package/libs/instance-factories/services/templates/prisma/controller-generator.ts +532 -0
- package/libs/instance-factories/services/templates/prisma/service-generator.ts +315 -0
- package/libs/instance-factories/shared/path-resolver.ts +111 -0
- package/libs/instance-factories/storage/mongodb.yaml +79 -0
- package/libs/instance-factories/storage/postgresql.yaml +75 -0
- package/libs/instance-factories/storage/redis.yaml +79 -0
- package/libs/instance-factories/storage/templates/mongodb/config-generator.ts +15 -0
- package/libs/instance-factories/storage/templates/mongodb/docker-generator.ts +18 -0
- package/libs/instance-factories/storage/templates/postgresql/config-generator.ts +54 -0
- package/libs/instance-factories/storage/templates/postgresql/docker-generator.ts +55 -0
- package/libs/instance-factories/storage/templates/redis/config-generator.ts +16 -0
- package/libs/instance-factories/storage/templates/redis/docker-generator.ts +18 -0
- package/libs/instance-factories/test-generation.ts +192 -0
- package/libs/instance-factories/testing/templates/vitest/tests-generator.ts +51 -0
- package/libs/instance-factories/testing/vitest-tests.yaml +63 -0
- package/libs/instance-factories/tools/templates/mcp/mcp-server-generator.ts +136 -0
- package/libs/instance-factories/tools/templates/mcp/static/docs/DEPLOYMENT_GUIDE.md +630 -0
- package/libs/instance-factories/tools/templates/mcp/static/docs/HYBRID_RESOURCE_SYSTEM.md +330 -0
- package/libs/instance-factories/tools/templates/mcp/static/docs/deployments/EXTENSION_DEPLOYMENT.md +552 -0
- package/libs/instance-factories/tools/templates/mcp/static/docs/deployments/LOCAL_DEPLOYMENT.md +164 -0
- package/libs/instance-factories/tools/templates/mcp/static/docs/deployments/WEB_DEPLOYMENT.md +247 -0
- package/libs/instance-factories/tools/templates/mcp/static/package.json +92 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/build-enterprise.js +284 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/build-extension.js +139 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/build-local.js +74 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/build-web.js +156 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/copy-canonical-files.js +41 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/test-deployments.js +259 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/test-hybrid-resources.js +231 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/test-hybrid-simple.js +196 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/controllers/MCPServerController.ts +293 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/events/EventEmitter.ts +90 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/index.ts +24 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/interfaces/ResourceProvider.ts +15 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/models/LibrarySuggestion.ts +106 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/models/SpecVerseResource.ts +75 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/server/mcp-server.ts +239 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/CLIProxyService.ts +1501 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/EmbeddedResourcesAdapter.ts +211 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/EntityModuleService.ts +308 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/HybridResourcesProvider.ts +210 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/LibraryToolsService.ts +356 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/OrchestratorBridge.ts +524 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/OrchestratorToolsService.ts +530 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/PromptToolsService.ts +594 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/ResourcesProviderService.ts +170 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/tests/unit/CLIProxyService.init.test.ts +544 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/tests/unit/CLIProxyService.test.ts +189 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/tests/unit/ResourcesProviderService.test.ts +89 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/types/index.ts +110 -0
- package/libs/instance-factories/tools/templates/mcp/static/tsconfig.json +28 -0
- package/libs/instance-factories/tools/templates/vscode/static/extension.ts +1195 -0
- package/libs/instance-factories/tools/templates/vscode/static/language-configuration.json +34 -0
- package/libs/instance-factories/tools/templates/vscode/static/schemas/specverse-v3-schema.json +4279 -0
- package/libs/instance-factories/tools/templates/vscode/static/syntaxes/specverse.tmLanguage.json +138 -0
- package/libs/instance-factories/tools/templates/vscode/static/themes/README.md +74 -0
- package/libs/instance-factories/tools/templates/vscode/static/themes/complete-specverse-colors.json +122 -0
- package/libs/instance-factories/tools/templates/vscode/static/themes/specverse-basic-theme.json +65 -0
- package/libs/instance-factories/tools/templates/vscode/static/themes/specverse-complete-theme.json +123 -0
- package/libs/instance-factories/tools/templates/vscode/static/themes/specverse-theme-colors.json +64 -0
- package/libs/instance-factories/tools/templates/vscode/vscode-extension-generator.ts +214 -0
- package/libs/instance-factories/validation/templates/zod/validation-generator.ts +46 -0
- package/libs/instance-factories/validation/zod.yaml +56 -0
- package/libs/instance-factories/views/index.d.ts +13 -0
- package/libs/instance-factories/views/index.d.ts.map +1 -0
- package/libs/instance-factories/views/index.js +18 -0
- package/libs/instance-factories/views/index.js.map +1 -0
- package/libs/instance-factories/views/index.ts +45 -0
- package/libs/instance-factories/views/react-components.yaml +129 -0
- package/libs/instance-factories/views/templates/ARCHITECTURE.md +198 -0
- package/libs/instance-factories/views/templates/react/adapters/antd-adapter.ts +869 -0
- package/libs/instance-factories/views/templates/react/adapters/mui-adapter.ts +953 -0
- package/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.ts +806 -0
- package/libs/instance-factories/views/templates/react/app-generator.ts +55 -0
- package/libs/instance-factories/views/templates/react/components-generator.ts +391 -0
- package/libs/instance-factories/views/templates/react/forms-generator.ts +343 -0
- package/libs/instance-factories/views/templates/react/frontend-package-json-generator.ts +54 -0
- package/libs/instance-factories/views/templates/react/hooks-generator.ts +122 -0
- package/libs/instance-factories/views/templates/react/index-css-generator.ts +209 -0
- package/libs/instance-factories/views/templates/react/index-html-generator.ts +34 -0
- package/libs/instance-factories/views/templates/react/main-tsx-generator.ts +29 -0
- package/libs/instance-factories/views/templates/react/react-component-generator.d.ts +152 -0
- package/libs/instance-factories/views/templates/react/react-component-generator.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/react/react-component-generator.js +398 -0
- package/libs/instance-factories/views/templates/react/react-component-generator.js.map +1 -0
- package/libs/instance-factories/views/templates/react/react-component-generator.ts +533 -0
- package/libs/instance-factories/views/templates/react/router-generator.ts +197 -0
- package/libs/instance-factories/views/templates/react/router-generic-generator.ts +103 -0
- package/libs/instance-factories/views/templates/react/spec-json-generator.ts +17 -0
- package/libs/instance-factories/views/templates/react/types-generator.ts +76 -0
- package/libs/instance-factories/views/templates/react/views-metadata-generator.ts +42 -0
- package/libs/instance-factories/views/templates/react/vite-config-generator.ts +38 -0
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js.map +1 -0
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.ts +474 -0
- package/libs/instance-factories/views/templates/shared/__tests__/composite-patterns.test.ts +242 -0
- package/libs/instance-factories/views/templates/shared/adapter-types.d.ts +77 -0
- package/libs/instance-factories/views/templates/shared/adapter-types.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/adapter-types.js +47 -0
- package/libs/instance-factories/views/templates/shared/adapter-types.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/adapter-types.ts +142 -0
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts +63 -0
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.js +822 -0
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.ts +908 -0
- package/libs/instance-factories/views/templates/shared/base-generator.d.ts +247 -0
- package/libs/instance-factories/views/templates/shared/base-generator.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/base-generator.js +363 -0
- package/libs/instance-factories/views/templates/shared/base-generator.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/base-generator.ts +608 -0
- package/libs/instance-factories/views/templates/shared/component-metadata.d.ts +254 -0
- package/libs/instance-factories/views/templates/shared/component-metadata.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/component-metadata.js +602 -0
- package/libs/instance-factories/views/templates/shared/component-metadata.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/component-metadata.ts +803 -0
- package/libs/instance-factories/views/templates/shared/composite-pattern-types.ts +250 -0
- package/libs/instance-factories/views/templates/shared/composite-patterns.ts +535 -0
- package/libs/instance-factories/views/templates/shared/index.ts +68 -0
- package/libs/instance-factories/views/templates/shared/pattern-validator.ts +279 -0
- package/libs/instance-factories/views/templates/shared/property-mapper.d.ts +149 -0
- package/libs/instance-factories/views/templates/shared/property-mapper.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/property-mapper.js +580 -0
- package/libs/instance-factories/views/templates/shared/property-mapper.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/property-mapper.ts +700 -0
- package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts +143 -0
- package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/syntax-mapper.js +420 -0
- package/libs/instance-factories/views/templates/shared/syntax-mapper.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/syntax-mapper.ts +539 -0
- package/package.json +42 -0
- package/schema/SPECVERSE-SCHEMA.json +4274 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fastify Routes Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates Fastify route handlers from SpecVerse controllers
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { TemplateContext } from '@specverse/engine-realize';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Generate Fastify routes for a controller
|
|
11
|
+
*/
|
|
12
|
+
export default function generateFastifyRoutes(context: TemplateContext): string {
|
|
13
|
+
const { controller, model, spec, implType } = context;
|
|
14
|
+
|
|
15
|
+
if (!controller) {
|
|
16
|
+
throw new Error('Controller is required in template context');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const modelName = model?.name || controller.modelReference;
|
|
20
|
+
const controllerName = controller.name;
|
|
21
|
+
const routeName = controllerName || `${modelName}Controller`;
|
|
22
|
+
|
|
23
|
+
// Determine if this is a model controller or abstract service
|
|
24
|
+
const isModelController = !!modelName;
|
|
25
|
+
const handlerName = isModelController ? `${modelName}Controller` : controllerName;
|
|
26
|
+
|
|
27
|
+
// Generate imports
|
|
28
|
+
const imports = generateImports(controller, modelName, handlerName, isModelController, implType);
|
|
29
|
+
|
|
30
|
+
// Convert CURED operations to endpoints if endpoints don't exist
|
|
31
|
+
let endpoints = controller.endpoints;
|
|
32
|
+
if (!endpoints || endpoints.length === 0) {
|
|
33
|
+
if (controller.cured) {
|
|
34
|
+
endpoints = curedToEndpoints(controller.cured, modelName);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Generate route handlers for each endpoint
|
|
39
|
+
if (!endpoints || endpoints.length === 0) {
|
|
40
|
+
console.warn(`Warning: Controller ${controllerName} has no endpoints. Generating empty routes file.`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const routeHandlers = endpoints?.map((endpoint: any) => {
|
|
44
|
+
return generateRouteHandler(endpoint, modelName, handlerName, isModelController, implType, controllerName);
|
|
45
|
+
}).join('\n\n') || '';
|
|
46
|
+
|
|
47
|
+
// Generate the complete route file
|
|
48
|
+
return `${imports}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* ${routeName} Routes
|
|
52
|
+
* Generated from SpecVerse specification
|
|
53
|
+
*
|
|
54
|
+
* ${isModelController ? `Model: ${modelName}` : `Service: ${controllerName}`}
|
|
55
|
+
* Operations: ${controller.endpoints?.map((e: any) => e.operation).join(', ') || 'CURED'}
|
|
56
|
+
*/
|
|
57
|
+
export default async function ${routeName.replace('Controller', '')}Routes(
|
|
58
|
+
fastify: FastifyInstance,
|
|
59
|
+
options: any
|
|
60
|
+
) {
|
|
61
|
+
const handler = ${isModelController ? 'options.controllers' : 'options.services'}.${handlerName};
|
|
62
|
+
|
|
63
|
+
${routeHandlers.split('\n').map(line => ' ' + line).join('\n')}
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Generate imports for the route file
|
|
70
|
+
*/
|
|
71
|
+
function generateImports(
|
|
72
|
+
controller: any,
|
|
73
|
+
modelName: string,
|
|
74
|
+
handlerName: string,
|
|
75
|
+
isModelController: boolean,
|
|
76
|
+
implType: any
|
|
77
|
+
): string {
|
|
78
|
+
const imports = [
|
|
79
|
+
`import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';`,
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
// Don't import controller/service - they're passed via options
|
|
83
|
+
// Handlers are accessed via options.controllers or options.services
|
|
84
|
+
|
|
85
|
+
// Add validation imports if Zod is configured
|
|
86
|
+
if (implType?.technology?.validation === 'zod' && modelName) {
|
|
87
|
+
imports.push(`import { ${modelName}Schema } from '../validation/${modelName}.schema.js';`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return imports.join('\n');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Generate a single route handler
|
|
95
|
+
*/
|
|
96
|
+
function generateRouteHandler(
|
|
97
|
+
endpoint: any,
|
|
98
|
+
modelName: string,
|
|
99
|
+
handlerName: string,
|
|
100
|
+
isModelController: boolean,
|
|
101
|
+
implType: any,
|
|
102
|
+
controllerName?: string
|
|
103
|
+
): string {
|
|
104
|
+
// Try to get operation from multiple sources
|
|
105
|
+
let operation = endpoint.operation || endpoint.name;
|
|
106
|
+
|
|
107
|
+
// If operation is 'custom' from serviceOperation, extract from path
|
|
108
|
+
if (!operation || operation === 'custom') {
|
|
109
|
+
const serviceOp = endpoint.serviceOperation?.type;
|
|
110
|
+
if (serviceOp === 'custom' && endpoint.path) {
|
|
111
|
+
// Extract action name from path like "/user/attach-profile" → "attachProfile"
|
|
112
|
+
const pathParts = endpoint.path.split('/').filter((p: string) => p);
|
|
113
|
+
const lastPart = pathParts[pathParts.length - 1];
|
|
114
|
+
// Convert kebab-case to camelCase
|
|
115
|
+
operation = lastPart.replace(/-([a-z])/g, (_, letter: string) => letter.toUpperCase());
|
|
116
|
+
} else if (!operation) {
|
|
117
|
+
operation = serviceOp;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// If still no operation, try to infer from method and path
|
|
122
|
+
if (!operation) {
|
|
123
|
+
operation = inferOperationFromMethodAndPath(endpoint.method, endpoint.path);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Only warn if we couldn't infer operation after all attempts
|
|
127
|
+
if (!operation || operation === 'unknown') {
|
|
128
|
+
console.warn(`Warning: Could not determine operation for endpoint in ${controllerName || 'controller'}. Endpoint data:`, {
|
|
129
|
+
operation: endpoint.operation,
|
|
130
|
+
name: endpoint.name,
|
|
131
|
+
method: endpoint.method,
|
|
132
|
+
path: endpoint.path,
|
|
133
|
+
serviceOperation: endpoint.serviceOperation
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const method = endpoint.method?.toLowerCase() || inferHttpMethod(operation);
|
|
138
|
+
const path = inferPath(operation, endpoint); // Always call inferPath to handle path extraction
|
|
139
|
+
const handler = generateHandlerBody(operation, modelName, handlerName, isModelController, implType);
|
|
140
|
+
|
|
141
|
+
let route = `// ${operation} ${modelName}\n`;
|
|
142
|
+
route += `fastify.${method}('${path}', {\n`;
|
|
143
|
+
|
|
144
|
+
// Add schema if available
|
|
145
|
+
if (implType?.technology?.validation === 'zod') {
|
|
146
|
+
route += ` schema: {\n`;
|
|
147
|
+
|
|
148
|
+
if (operation === 'create' || operation === 'update' || operation === 'evolve') {
|
|
149
|
+
route += ` body: ${modelName}Schema.${operation},\n`;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (operation === 'retrieve' || operation === 'update' || operation === 'delete') {
|
|
153
|
+
route += ` params: ${modelName}Schema.params,\n`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
route += ` response: {\n`;
|
|
157
|
+
route += ` 200: ${modelName}Schema.response\n`;
|
|
158
|
+
route += ` }\n`;
|
|
159
|
+
route += ` },\n`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Use 'request' for operations that need request data (including custom actions with parameters)
|
|
163
|
+
const usesRequest = ['create', 'retrieve', 'update', 'evolve', 'delete', 'validate'].includes(operation) ||
|
|
164
|
+
!['list'].includes(operation); // Custom actions likely need request data
|
|
165
|
+
const requestParam = usesRequest ? 'request' : '_request';
|
|
166
|
+
|
|
167
|
+
route += ` handler: async (${requestParam}: FastifyRequest, reply: FastifyReply) => {\n`;
|
|
168
|
+
route += handler.split('\n').map(line => ' ' + line).join('\n') + '\n';
|
|
169
|
+
route += ` }\n`;
|
|
170
|
+
route += `});`;
|
|
171
|
+
|
|
172
|
+
return route;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Generate handler body for an operation
|
|
177
|
+
*/
|
|
178
|
+
function generateHandlerBody(
|
|
179
|
+
operation: string,
|
|
180
|
+
modelName: string,
|
|
181
|
+
handlerName: string,
|
|
182
|
+
isModelController: boolean,
|
|
183
|
+
implType: any
|
|
184
|
+
): string {
|
|
185
|
+
const rawLowerModel = modelName?.toLowerCase() || 'item';
|
|
186
|
+
// Avoid JavaScript reserved words as variable names
|
|
187
|
+
const RESERVED_WORDS = new Set(['import', 'export', 'default', 'class', 'function', 'return', 'delete', 'new', 'this', 'switch', 'case', 'break', 'continue', 'for', 'while', 'do', 'if', 'else', 'try', 'catch', 'finally', 'throw', 'typeof', 'instanceof', 'in', 'of', 'let', 'const', 'var', 'void', 'with', 'yield', 'async', 'await', 'enum', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'static', 'super', 'extends']);
|
|
188
|
+
const lowerModel = RESERVED_WORDS.has(rawLowerModel) ? `${rawLowerModel}Item` : rawLowerModel;
|
|
189
|
+
|
|
190
|
+
// Map service operation types to CURED operations
|
|
191
|
+
const operationMap: { [key: string]: string } = {
|
|
192
|
+
'custom': 'create', // POST without ID -> create
|
|
193
|
+
'findUnique': 'retrieve', // GET with ID -> retrieve
|
|
194
|
+
'findMany': 'list', // GET without ID -> list
|
|
195
|
+
'updateUnique': 'update', // PUT with ID -> update
|
|
196
|
+
'deleteUnique': 'delete' // DELETE with ID -> delete
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const mappedOperation = operationMap[operation] || operation;
|
|
200
|
+
|
|
201
|
+
switch (mappedOperation) {
|
|
202
|
+
case 'create':
|
|
203
|
+
return `try {
|
|
204
|
+
const ${lowerModel} = await handler.create(request.body as any);
|
|
205
|
+
return reply.status(201).send(${lowerModel});
|
|
206
|
+
} catch (error) {
|
|
207
|
+
return reply.status(400).send({
|
|
208
|
+
error: 'Failed to create ${lowerModel}',
|
|
209
|
+
message: error instanceof Error ? error.message : String(error)
|
|
210
|
+
});
|
|
211
|
+
}`;
|
|
212
|
+
|
|
213
|
+
case 'retrieve':
|
|
214
|
+
return `try {
|
|
215
|
+
const { id } = request.params as { id: string };
|
|
216
|
+
const ${lowerModel} = await handler.retrieve(id);
|
|
217
|
+
|
|
218
|
+
if (!${lowerModel}) {
|
|
219
|
+
return reply.status(404).send({ error: '${modelName} not found' });
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return reply.send(${lowerModel});
|
|
223
|
+
} catch (error) {
|
|
224
|
+
return reply.status(500).send({
|
|
225
|
+
error: 'Failed to retrieve ${lowerModel}',
|
|
226
|
+
message: error instanceof Error ? error.message : String(error)
|
|
227
|
+
});
|
|
228
|
+
}`;
|
|
229
|
+
|
|
230
|
+
case 'update':
|
|
231
|
+
case 'evolve':
|
|
232
|
+
return `try {
|
|
233
|
+
const { id } = request.params as { id: string };
|
|
234
|
+
const ${lowerModel} = await handler.${operation}(id, request.body as any);
|
|
235
|
+
return reply.send(${lowerModel});
|
|
236
|
+
} catch (error) {
|
|
237
|
+
return reply.status(400).send({
|
|
238
|
+
error: 'Failed to ${operation} ${lowerModel}',
|
|
239
|
+
message: error instanceof Error ? error.message : String(error)
|
|
240
|
+
});
|
|
241
|
+
}`;
|
|
242
|
+
|
|
243
|
+
case 'delete':
|
|
244
|
+
return `try {
|
|
245
|
+
const { id } = request.params as { id: string };
|
|
246
|
+
await handler.delete(id);
|
|
247
|
+
return reply.status(204).send();
|
|
248
|
+
} catch (error) {
|
|
249
|
+
return reply.status(500).send({
|
|
250
|
+
error: 'Failed to delete ${lowerModel}',
|
|
251
|
+
message: error instanceof Error ? error.message : String(error)
|
|
252
|
+
});
|
|
253
|
+
}`;
|
|
254
|
+
|
|
255
|
+
case 'list':
|
|
256
|
+
return `try {
|
|
257
|
+
const ${lowerModel}s = await handler.retrieveAll();
|
|
258
|
+
return reply.send(${lowerModel}s);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
return reply.status(500).send({
|
|
261
|
+
error: 'Failed to list ${lowerModel}s',
|
|
262
|
+
message: error instanceof Error ? error.message : String(error)
|
|
263
|
+
});
|
|
264
|
+
}`;
|
|
265
|
+
|
|
266
|
+
case 'validate':
|
|
267
|
+
return `try {
|
|
268
|
+
const { data, operation: op } = request.body as { data: any; operation: string };
|
|
269
|
+
const result = handler.validate(data, { operation: op });
|
|
270
|
+
return reply.send(result);
|
|
271
|
+
} catch (error) {
|
|
272
|
+
return reply.status(400).send({
|
|
273
|
+
error: 'Validation failed',
|
|
274
|
+
message: error instanceof Error ? error.message : String(error)
|
|
275
|
+
});
|
|
276
|
+
}`;
|
|
277
|
+
|
|
278
|
+
default:
|
|
279
|
+
// For custom actions, generate a handler that calls the action method
|
|
280
|
+
return `try {
|
|
281
|
+
const result = await handler.${operation}(request.body as any);
|
|
282
|
+
return reply.send(result);
|
|
283
|
+
} catch (error) {
|
|
284
|
+
return reply.status(400).send({
|
|
285
|
+
error: 'Failed to execute ${operation}',
|
|
286
|
+
message: error instanceof Error ? error.message : String(error)
|
|
287
|
+
});
|
|
288
|
+
}`;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Infer operation from HTTP method and path
|
|
294
|
+
*/
|
|
295
|
+
function inferOperationFromMethodAndPath(method: string, path: string): string {
|
|
296
|
+
if (!method || !path) return 'unknown';
|
|
297
|
+
|
|
298
|
+
const methodLower = method.toLowerCase();
|
|
299
|
+
const hasIdParam = path.includes(':id');
|
|
300
|
+
|
|
301
|
+
if (methodLower === 'post' && !hasIdParam) return 'create';
|
|
302
|
+
if (methodLower === 'get' && hasIdParam) return 'retrieve';
|
|
303
|
+
if (methodLower === 'get' && !hasIdParam) return 'list';
|
|
304
|
+
if (methodLower === 'put' && hasIdParam) return 'update';
|
|
305
|
+
if (methodLower === 'patch' && hasIdParam) return 'evolve';
|
|
306
|
+
if (methodLower === 'delete' && hasIdParam) return 'delete';
|
|
307
|
+
|
|
308
|
+
return 'unknown';
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Infer HTTP method from operation name
|
|
313
|
+
*/
|
|
314
|
+
function inferHttpMethod(operation: string): string {
|
|
315
|
+
if (!operation) {
|
|
316
|
+
console.warn('Warning: undefined operation in inferHttpMethod');
|
|
317
|
+
return 'post'; // default
|
|
318
|
+
}
|
|
319
|
+
const opLower = operation.toLowerCase();
|
|
320
|
+
|
|
321
|
+
if (opLower === 'create' || opLower === 'validate') return 'post';
|
|
322
|
+
if (opLower === 'retrieve' || opLower === 'list') return 'get';
|
|
323
|
+
if (opLower === 'update' || opLower === 'evolve') return 'put';
|
|
324
|
+
if (opLower === 'delete') return 'delete';
|
|
325
|
+
|
|
326
|
+
return 'post'; // default
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Infer path from operation name
|
|
331
|
+
* Returns relative path (without base path) for use with Fastify route prefix
|
|
332
|
+
*/
|
|
333
|
+
function inferPath(operation: string, endpoint: any): string {
|
|
334
|
+
// Endpoint paths from AI view generator are placeholders - ignore them
|
|
335
|
+
// Always generate relative paths from operation for Fastify route registration
|
|
336
|
+
// (The prefix is set in main.ts registration, e.g., prefix: '/api/users')
|
|
337
|
+
|
|
338
|
+
const opLower = operation.toLowerCase();
|
|
339
|
+
|
|
340
|
+
if (opLower === 'create') return '/';
|
|
341
|
+
if (opLower === 'list') return '/';
|
|
342
|
+
if (opLower === 'retrieve') return '/:id';
|
|
343
|
+
if (opLower === 'update') return '/:id';
|
|
344
|
+
if (opLower === 'evolve') return '/:id/evolve';
|
|
345
|
+
if (opLower === 'delete') return '/:id';
|
|
346
|
+
if (opLower === 'validate') return '/validate';
|
|
347
|
+
|
|
348
|
+
// For custom actions, extract relative path from endpoint.path
|
|
349
|
+
// e.g., "/user/attach-profile" → "/attach-profile"
|
|
350
|
+
if (endpoint.path && endpoint.serviceOperation?.type === 'custom') {
|
|
351
|
+
const pathParts = endpoint.path.split('/').filter((p: string) => p);
|
|
352
|
+
const lastPart = pathParts[pathParts.length - 1];
|
|
353
|
+
return `/${lastPart}`;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return `/${opLower}`;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Convert CURED operations to endpoints
|
|
361
|
+
*/
|
|
362
|
+
function curedToEndpoints(cured: any, modelName: string): any[] {
|
|
363
|
+
const endpoints: any[] = [];
|
|
364
|
+
|
|
365
|
+
// Map CURED operations to endpoints with correct paths
|
|
366
|
+
if (cured.create) {
|
|
367
|
+
endpoints.push({ operation: 'create', method: 'POST' });
|
|
368
|
+
}
|
|
369
|
+
if (cured.retrieve) {
|
|
370
|
+
endpoints.push({ operation: 'retrieve', method: 'GET' });
|
|
371
|
+
}
|
|
372
|
+
if (cured.retrieve_many) {
|
|
373
|
+
endpoints.push({ operation: 'list', method: 'GET' });
|
|
374
|
+
}
|
|
375
|
+
if (cured.update) {
|
|
376
|
+
endpoints.push({ operation: 'update', method: 'PUT' });
|
|
377
|
+
}
|
|
378
|
+
if (cured.evolve) {
|
|
379
|
+
endpoints.push({ operation: 'evolve', method: 'PATCH' });
|
|
380
|
+
}
|
|
381
|
+
if (cured.delete) {
|
|
382
|
+
endpoints.push({ operation: 'delete', method: 'DELETE' });
|
|
383
|
+
}
|
|
384
|
+
if (cured.validate) {
|
|
385
|
+
endpoints.push({ operation: 'validate', method: 'POST' });
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return endpoints;
|
|
389
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fastify Server Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates main Fastify server bootstrap file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { TemplateContext } from '@specverse/engine-realize';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Generate Fastify server bootstrap
|
|
11
|
+
*/
|
|
12
|
+
export default function generateFastifyServer(context: TemplateContext): string {
|
|
13
|
+
const { spec, models } = context;
|
|
14
|
+
|
|
15
|
+
// Extract model names for route registration
|
|
16
|
+
const allModels = models || (spec?.models ? Object.values(spec.models) : []);
|
|
17
|
+
const modelNames = allModels.map((m: any) => m.name).filter(Boolean);
|
|
18
|
+
|
|
19
|
+
// Generate route imports and registrations
|
|
20
|
+
const routeImports = modelNames.map((name: string) =>
|
|
21
|
+
`import ${name}Routes from './routes/${name}Controller.js';`
|
|
22
|
+
).join('\n');
|
|
23
|
+
|
|
24
|
+
const routeRegistrations = modelNames.map((name: string) => {
|
|
25
|
+
const path = `/api/${name.toLowerCase()}s`;
|
|
26
|
+
return ` await fastify.register(${name}Routes, { prefix: '${path}', controllers: { ${name}Controller: new (await import('./controllers/${name}Controller.js')).${name}Controller() } });`;
|
|
27
|
+
}).join('\n');
|
|
28
|
+
|
|
29
|
+
return `/**
|
|
30
|
+
* Fastify Server
|
|
31
|
+
* Generated from SpecVerse specification
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import Fastify from 'fastify';
|
|
35
|
+
import cors from '@fastify/cors';
|
|
36
|
+
import { PrismaClient } from '@prisma/client';
|
|
37
|
+
|
|
38
|
+
// Initialize Prisma
|
|
39
|
+
export const prisma = new PrismaClient();
|
|
40
|
+
|
|
41
|
+
// Initialize Fastify
|
|
42
|
+
const fastify = Fastify({
|
|
43
|
+
logger: { level: 'info' },
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Register plugins
|
|
47
|
+
await fastify.register(cors, { origin: true, credentials: true });
|
|
48
|
+
|
|
49
|
+
// Health check
|
|
50
|
+
fastify.get('/health', async () => ({ status: 'ok', timestamp: new Date().toISOString() }));
|
|
51
|
+
fastify.get('/', async () => ({ name: 'SpecVerse Generated API', models: ${JSON.stringify(modelNames)} }));
|
|
52
|
+
|
|
53
|
+
// Register routes
|
|
54
|
+
${routeImports}
|
|
55
|
+
|
|
56
|
+
async function registerRoutes() {
|
|
57
|
+
${routeRegistrations}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Start server
|
|
61
|
+
const start = async () => {
|
|
62
|
+
try {
|
|
63
|
+
await registerRoutes();
|
|
64
|
+
const port = parseInt(process.env.PORT || '3000');
|
|
65
|
+
await fastify.listen({ port, host: '0.0.0.0' });
|
|
66
|
+
console.log(\`Server running at http://localhost:\${port}\`);
|
|
67
|
+
console.log(\`API endpoints: ${modelNames.map((n: string) => `/api/${n.toLowerCase()}s`).join(', ')}\`);
|
|
68
|
+
} catch (err) {
|
|
69
|
+
fastify.log.error(err);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
start();
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: DockerKubernetes
|
|
2
|
+
version: "1.0.0"
|
|
3
|
+
category: infrastructure
|
|
4
|
+
description: "Docker and Kubernetes infrastructure generator with CI/CD pipelines"
|
|
5
|
+
|
|
6
|
+
metadata:
|
|
7
|
+
author: "SpecVerse Team"
|
|
8
|
+
license: "MIT"
|
|
9
|
+
tags: [docker, kubernetes, infrastructure, ci-cd, devops]
|
|
10
|
+
|
|
11
|
+
compatibility:
|
|
12
|
+
specverse: "^3.3.0"
|
|
13
|
+
|
|
14
|
+
capabilities:
|
|
15
|
+
provides:
|
|
16
|
+
- "infrastructure.docker"
|
|
17
|
+
- "infrastructure.kubernetes"
|
|
18
|
+
- "infrastructure.cicd"
|
|
19
|
+
requires: []
|
|
20
|
+
|
|
21
|
+
technology:
|
|
22
|
+
runtime: "node"
|
|
23
|
+
language: "typescript"
|
|
24
|
+
containerization: "docker"
|
|
25
|
+
orchestration: "kubernetes"
|
|
26
|
+
cicd: "github-actions"
|
|
27
|
+
|
|
28
|
+
codeTemplates:
|
|
29
|
+
infrastructure:
|
|
30
|
+
engine: typescript
|
|
31
|
+
generator: "libs/instance-factories/infrastructure/templates/docker-k8s/infrastructure-generator.ts"
|
|
32
|
+
outputPattern: "infrastructure/"
|
|
33
|
+
|
|
34
|
+
configuration:
|
|
35
|
+
docker:
|
|
36
|
+
multiStage: true
|
|
37
|
+
nodeVersion: "20-alpine"
|
|
38
|
+
kubernetes:
|
|
39
|
+
namespace: "default"
|
|
40
|
+
replicas: 3
|
|
41
|
+
resources:
|
|
42
|
+
requests:
|
|
43
|
+
cpu: "100m"
|
|
44
|
+
memory: "128Mi"
|
|
45
|
+
limits:
|
|
46
|
+
cpu: "500m"
|
|
47
|
+
memory: "512Mi"
|
|
48
|
+
cicd:
|
|
49
|
+
provider: "github-actions"
|
|
50
|
+
buildOnPush: true
|
|
51
|
+
deployOnTag: true
|
|
52
|
+
|
|
53
|
+
# NOTE: This implementation type wraps the existing generate-infrastructure.js script
|
|
54
|
+
# TODO: Future enhancement - Convert generate-infrastructure.js to native TypeScript template generator
|
|
55
|
+
# The current script is 650+ lines and generates complete infrastructure as code.
|
|
56
|
+
# Converting to native templates would require breaking it into multiple template files:
|
|
57
|
+
# - dockerfile-generator.ts (multi-stage Dockerfiles)
|
|
58
|
+
# - docker-compose-generator.ts (development and production compositions)
|
|
59
|
+
# - kubernetes-generator.ts (K8s manifests - deployments, services, ingress)
|
|
60
|
+
# - cicd-generator.ts (GitHub Actions / GitLab CI pipelines)
|
|
61
|
+
# - env-generator.ts (environment configuration templates)
|
package/libs/instance-factories/infrastructure/templates/docker-k8s/infrastructure-generator.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Docker/Kubernetes Infrastructure Generator Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Wraps the existing generate-infrastructure.js script for use with the
|
|
5
|
+
* implementation types system.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: This is a wrapper around scripts/generate-infrastructure.js
|
|
8
|
+
* TODO: Convert generate-infrastructure.js to native TypeScript template generator
|
|
9
|
+
* See docker-k8s.yaml for conversion notes.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { TemplateContext } from '@specverse/engine-realize';
|
|
13
|
+
import { generateInfrastructure } from '../../../../../scripts/generate-infrastructure.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generate infrastructure code by delegating to the existing generator
|
|
17
|
+
*/
|
|
18
|
+
export default function generateInfra(context: TemplateContext): string {
|
|
19
|
+
const { spec, implType, outputDir } = context;
|
|
20
|
+
|
|
21
|
+
if (!spec) {
|
|
22
|
+
throw new Error('Specification is required in template context');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Extract configuration from implementation type
|
|
26
|
+
const config = implType.configuration || {};
|
|
27
|
+
|
|
28
|
+
const options = {
|
|
29
|
+
docker: config.docker || {},
|
|
30
|
+
kubernetes: config.kubernetes || {},
|
|
31
|
+
cicd: config.cicd || {}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Call the existing generator
|
|
35
|
+
const result = generateInfrastructure(spec, outputDir || './infrastructure', options);
|
|
36
|
+
|
|
37
|
+
// Return summary information
|
|
38
|
+
return JSON.stringify({
|
|
39
|
+
message: 'Infrastructure code generated successfully',
|
|
40
|
+
dockerFiles: result.dockerFiles,
|
|
41
|
+
kubernetesFiles: result.kubernetesFiles,
|
|
42
|
+
cicdFiles: result.cicdFiles,
|
|
43
|
+
outputDir: result.outputDir,
|
|
44
|
+
files: result.files
|
|
45
|
+
}, null, 2);
|
|
46
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
name: PrismaORM
|
|
2
|
+
version: "1.0.0"
|
|
3
|
+
category: service
|
|
4
|
+
description: "Prisma ORM for type-safe database access with auto-generated client"
|
|
5
|
+
|
|
6
|
+
metadata:
|
|
7
|
+
author: "SpecVerse Team"
|
|
8
|
+
license: "MIT"
|
|
9
|
+
tags: [prisma, orm, database, typescript]
|
|
10
|
+
|
|
11
|
+
compatibility:
|
|
12
|
+
specverse: "^3.3.0"
|
|
13
|
+
node: ">=18.0.0"
|
|
14
|
+
|
|
15
|
+
capabilities:
|
|
16
|
+
provides:
|
|
17
|
+
- "orm.prisma"
|
|
18
|
+
- "orm.schema"
|
|
19
|
+
- "orm.client"
|
|
20
|
+
- "database.migrations"
|
|
21
|
+
requires:
|
|
22
|
+
- "storage.database" # Needs actual database instance
|
|
23
|
+
|
|
24
|
+
technology:
|
|
25
|
+
runtime: "node"
|
|
26
|
+
language: "typescript"
|
|
27
|
+
orm: "prisma"
|
|
28
|
+
version: "^5.5.0"
|
|
29
|
+
|
|
30
|
+
dependencies:
|
|
31
|
+
runtime:
|
|
32
|
+
- name: "@prisma/client"
|
|
33
|
+
version: "^5.5.0"
|
|
34
|
+
|
|
35
|
+
dev:
|
|
36
|
+
- name: "prisma"
|
|
37
|
+
version: "^5.5.0"
|
|
38
|
+
- name: "@types/node"
|
|
39
|
+
version: "^20.8.0"
|
|
40
|
+
- name: "typescript"
|
|
41
|
+
version: "^5.2.0"
|
|
42
|
+
|
|
43
|
+
codeTemplates:
|
|
44
|
+
schema:
|
|
45
|
+
engine: typescript
|
|
46
|
+
generator: "libs/instance-factories/orms/templates/prisma/schema-generator.ts"
|
|
47
|
+
outputPattern: "{backendDir}/prisma/schema.prisma"
|
|
48
|
+
|
|
49
|
+
configuration:
|
|
50
|
+
outputStructure: "monorepo"
|
|
51
|
+
backendDir: "backend"
|
|
52
|
+
|
|
53
|
+
provider: "postgresql" # Default, can be overridden
|
|
54
|
+
relationMode: "foreignKeys"
|
|
55
|
+
log: ["query", "error", "warn"]
|
|
56
|
+
previewFeatures: []
|
|
57
|
+
|
|
58
|
+
# Requirements for generic scaffolding (runtime-agnostic structure)
|
|
59
|
+
requirements:
|
|
60
|
+
# Package dependencies (Node.js/npm-specific)
|
|
61
|
+
dependencies:
|
|
62
|
+
npm:
|
|
63
|
+
dependencies:
|
|
64
|
+
"@prisma/client": "^5.5.0"
|
|
65
|
+
devDependencies:
|
|
66
|
+
"prisma": "^5.5.0"
|
|
67
|
+
scripts:
|
|
68
|
+
"db:generate": "prisma generate"
|
|
69
|
+
"db:migrate": "prisma migrate dev"
|
|
70
|
+
"db:push": "prisma db push"
|
|
71
|
+
"db:studio": "prisma studio"
|
|
72
|
+
|
|
73
|
+
# Environment variables (universal structure)
|
|
74
|
+
environment:
|
|
75
|
+
- name: "DATABASE_URL"
|
|
76
|
+
description: "Database connection string"
|
|
77
|
+
example: "postgresql://user:password@localhost:5432/dbname"
|
|
78
|
+
required: true
|
|
79
|
+
category: "Database"
|
|
80
|
+
|
|
81
|
+
# Build/runtime configuration (TypeScript-specific)
|
|
82
|
+
configuration: {}
|
|
83
|
+
|
|
84
|
+
# Generated files
|
|
85
|
+
files:
|
|
86
|
+
- path: ".env"
|
|
87
|
+
description: "Environment variables"
|
|
88
|
+
- path: "prisma/schema.prisma"
|
|
89
|
+
description: "Prisma schema definition"
|