@specverse/engines 4.2.0 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/assets/templates/default/specs/main.specly +65 -0
  2. package/dist/libs/instance-factories/CURVED-INTERFACE.md +278 -0
  3. package/dist/libs/instance-factories/README.md +73 -0
  4. package/dist/libs/instance-factories/applications/README.md +51 -0
  5. package/dist/libs/instance-factories/applications/generic-app.yaml +52 -0
  6. package/dist/libs/instance-factories/applications/react-app-runtime.yaml +139 -0
  7. package/dist/libs/instance-factories/applications/react-app-starter.yaml +143 -0
  8. package/dist/libs/instance-factories/applications/templates/react/env-example-generator.js +24 -2
  9. package/dist/libs/instance-factories/applications/templates/react/vite-config-generator.js +54 -33
  10. package/dist/libs/instance-factories/applications/templates/react-starter/README.md +211 -0
  11. package/dist/libs/instance-factories/applications/templates/react-starter/api-types-starter-generator.js +69 -0
  12. package/dist/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.js +1 -1
  13. package/dist/libs/instance-factories/applications/templates/react-starter/belongs-to.js +40 -0
  14. package/dist/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.js +11 -3
  15. package/dist/libs/instance-factories/applications/templates/react-starter/detail-body-composer.js +18 -16
  16. package/dist/libs/instance-factories/applications/templates/react-starter/form-body-composer.js +50 -23
  17. package/dist/libs/instance-factories/applications/templates/react-starter/helpers-emitter.js +9 -3
  18. package/dist/libs/instance-factories/applications/templates/react-starter/list-body-composer.js +17 -7
  19. package/dist/libs/instance-factories/applications/templates/react-starter/orchestrator.js +16 -5
  20. package/dist/libs/instance-factories/applications/templates/react-starter/skeletons/dashboard.tsx.template +49 -0
  21. package/dist/libs/instance-factories/applications/templates/react-starter/skeletons/detail.tsx.template +96 -0
  22. package/dist/libs/instance-factories/applications/templates/react-starter/skeletons/form.tsx.template +116 -0
  23. package/dist/libs/instance-factories/applications/templates/react-starter/skeletons/list.tsx.template +74 -0
  24. package/dist/libs/instance-factories/applications/templates/react-starter/use-api-hooks-starter-generator.js +95 -0
  25. package/dist/libs/instance-factories/applications/templates/react-starter/view-emitter.js +26 -1
  26. package/dist/libs/instance-factories/archived/fastify-prisma.yaml +104 -0
  27. package/dist/libs/instance-factories/cli/README.md +43 -0
  28. package/dist/libs/instance-factories/cli/commander-js.yaml +55 -0
  29. package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +49 -1
  30. package/dist/libs/instance-factories/communication/README.md +47 -0
  31. package/dist/libs/instance-factories/communication/event-emitter.yaml +60 -0
  32. package/dist/libs/instance-factories/communication/rabbitmq-events.yaml +87 -0
  33. package/dist/libs/instance-factories/controllers/README.md +42 -0
  34. package/dist/libs/instance-factories/controllers/fastify.yaml +139 -0
  35. package/dist/libs/instance-factories/controllers/templates/fastify/server-generator.js +29 -2
  36. package/dist/libs/instance-factories/infrastructure/README.md +29 -0
  37. package/dist/libs/instance-factories/infrastructure/docker-k8s.yaml +61 -0
  38. package/dist/libs/instance-factories/orms/README.md +54 -0
  39. package/dist/libs/instance-factories/orms/prisma.yaml +89 -0
  40. package/dist/libs/instance-factories/orms/templates/prisma/schema-generator.js +2 -2
  41. package/dist/libs/instance-factories/scaffolding/README.md +49 -0
  42. package/dist/libs/instance-factories/scaffolding/generic-scaffold.yaml +65 -0
  43. package/dist/libs/instance-factories/sdks/README.md +28 -0
  44. package/dist/libs/instance-factories/sdks/python-sdk.yaml +66 -0
  45. package/dist/libs/instance-factories/sdks/typescript-sdk.yaml +59 -0
  46. package/dist/libs/instance-factories/services/README.md +55 -0
  47. package/dist/libs/instance-factories/services/prisma-services.yaml +71 -0
  48. package/dist/libs/instance-factories/storage/README.md +34 -0
  49. package/dist/libs/instance-factories/storage/mongodb.yaml +79 -0
  50. package/dist/libs/instance-factories/storage/postgresql.yaml +75 -0
  51. package/dist/libs/instance-factories/storage/redis.yaml +79 -0
  52. package/dist/libs/instance-factories/testing/README.md +40 -0
  53. package/dist/libs/instance-factories/testing/vitest-tests.yaml +63 -0
  54. package/dist/libs/instance-factories/tools/README.md +70 -0
  55. package/dist/libs/instance-factories/tools/mcp.yaml +36 -0
  56. package/dist/libs/instance-factories/tools/vscode.yaml +35 -0
  57. package/dist/libs/instance-factories/validation/README.md +38 -0
  58. package/dist/libs/instance-factories/validation/zod.yaml +56 -0
  59. package/dist/realize/engines/code-generator.d.ts.map +1 -1
  60. package/dist/realize/engines/code-generator.js +3 -0
  61. package/dist/realize/engines/code-generator.js.map +1 -1
  62. package/libs/instance-factories/applications/react-app-starter.yaml +10 -17
  63. package/libs/instance-factories/applications/templates/react/env-example-generator.ts +24 -2
  64. package/libs/instance-factories/applications/templates/react/vite-config-generator.ts +54 -33
  65. package/libs/instance-factories/applications/templates/react-starter/__tests__/detail-body-composer.test.ts +5 -4
  66. package/libs/instance-factories/applications/templates/react-starter/__tests__/form-body-composer.test.ts +18 -5
  67. package/libs/instance-factories/applications/templates/react-starter/__tests__/orchestrator.test.ts +83 -62
  68. package/libs/instance-factories/applications/templates/react-starter/api-types-starter-generator.ts +98 -0
  69. package/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.ts +1 -1
  70. package/libs/instance-factories/applications/templates/react-starter/belongs-to.ts +82 -0
  71. package/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.ts +20 -5
  72. package/libs/instance-factories/applications/templates/react-starter/detail-body-composer.ts +33 -33
  73. package/libs/instance-factories/applications/templates/react-starter/form-body-composer.ts +107 -30
  74. package/libs/instance-factories/applications/templates/react-starter/helpers-emitter.ts +9 -3
  75. package/libs/instance-factories/applications/templates/react-starter/list-body-composer.ts +34 -8
  76. package/libs/instance-factories/applications/templates/react-starter/orchestrator.ts +41 -26
  77. package/libs/instance-factories/applications/templates/react-starter/skeletons/dashboard.tsx.template +2 -0
  78. package/libs/instance-factories/applications/templates/react-starter/skeletons/detail.tsx.template +2 -0
  79. package/libs/instance-factories/applications/templates/react-starter/skeletons/form.tsx.template +2 -0
  80. package/libs/instance-factories/applications/templates/react-starter/skeletons/list.tsx.template +2 -0
  81. package/libs/instance-factories/applications/templates/react-starter/use-api-hooks-starter-generator.ts +124 -0
  82. package/libs/instance-factories/applications/templates/react-starter/view-emitter.ts +58 -0
  83. package/libs/instance-factories/cli/templates/commander/command-generator.ts +49 -1
  84. package/libs/instance-factories/controllers/fastify.yaml +7 -0
  85. package/libs/instance-factories/controllers/templates/fastify/server-generator.ts +36 -2
  86. package/libs/instance-factories/orms/templates/prisma/schema-generator.ts +11 -4
  87. package/package.json +2 -1
@@ -0,0 +1,139 @@
1
+ name: FastifyAPI
2
+ version: "1.0.0"
3
+ category: controller
4
+ description: "Fastify REST API server with WebSocket support"
5
+
6
+ metadata:
7
+ author: "SpecVerse Team"
8
+ license: "MIT"
9
+ tags: [fastify, rest-api, websocket, controller]
10
+
11
+ compatibility:
12
+ specverse: ">=3.3.0"
13
+ node: ">=18.0.0"
14
+
15
+ capabilities:
16
+ provides:
17
+ - "api.rest"
18
+ - "api.rest.crud"
19
+ - "api.websocket"
20
+ requires:
21
+ - "storage.database" # Needs a database for data persistence
22
+ - "validation.runtime" # Needs validation schemas
23
+
24
+ technology:
25
+ runtime: "node"
26
+ language: "typescript"
27
+ framework: "fastify"
28
+ version: "^4.24.0"
29
+
30
+ dependencies:
31
+ runtime:
32
+ - name: "fastify"
33
+ version: "^4.24.0"
34
+ - name: "@fastify/cors"
35
+ version: "^8.4.0"
36
+ - name: "@fastify/helmet"
37
+ version: "^11.1.0"
38
+ - name: "@fastify/rate-limit"
39
+ version: "^9.0.0"
40
+ # .env loading — main.ts calls `import 'dotenv/config'` first so
41
+ # PORT and other env vars populate before any module reads them.
42
+ # Mirrors vite's loadEnv on the frontend side, so `npm run
43
+ # dev:backend` honours the project's .env without a set -a dance.
44
+ - name: "dotenv"
45
+ version: "^16.4.0"
46
+
47
+ dev:
48
+ - name: "@types/node"
49
+ version: "^20.8.0"
50
+ - name: "typescript"
51
+ version: "^5.2.0"
52
+ - name: "tsx"
53
+ version: "^4.0.0"
54
+
55
+ codeTemplates:
56
+ routes:
57
+ engine: typescript
58
+ generator: "libs/instance-factories/controllers/templates/fastify/routes-generator.ts"
59
+ outputPattern: "{backendDir}/src/routes/{controller}.ts"
60
+
61
+ serviceRoutes:
62
+ engine: typescript
63
+ generator: "libs/instance-factories/services/templates/fastify/service-routes-generator.ts"
64
+ outputPattern: "{backendDir}/src/routes/{service}Routes.ts"
65
+
66
+ meta:
67
+ engine: typescript
68
+ generator: "libs/instance-factories/controllers/templates/fastify/meta-routes-generator.ts"
69
+ outputPattern: "{backendDir}/src/routes/MetaRoutes.ts"
70
+
71
+ server:
72
+ engine: typescript
73
+ generator: "libs/instance-factories/controllers/templates/fastify/server-generator.ts"
74
+ outputPattern: "{backendDir}/src/server.ts"
75
+
76
+ configuration:
77
+ outputStructure: "monorepo"
78
+ backendDir: "backend"
79
+
80
+ server:
81
+ port: 3000
82
+ host: "0.0.0.0"
83
+ trustProxy: true
84
+ requestIdLogLabel: "reqId"
85
+ logger:
86
+ level: "info"
87
+ prettyPrint: true
88
+
89
+ middleware:
90
+ cors:
91
+ origin: true
92
+ credentials: true
93
+ helmet:
94
+ enabled: true
95
+ rateLimit:
96
+ max: 100
97
+ timeWindow: "1 minute"
98
+
99
+ # Requirements for generic scaffolding (runtime-agnostic structure)
100
+ requirements:
101
+ # Package dependencies (Node.js/npm-specific)
102
+ dependencies:
103
+ npm:
104
+ dependencies:
105
+ "fastify": "^5.8.3"
106
+ "@fastify/cors": "^10.0.0"
107
+ "yaml": "^2.3.0"
108
+ "dotenv": "^16.4.0"
109
+ devDependencies:
110
+ "tsx": "^4.0.0"
111
+ scripts:
112
+ "dev": "tsx watch src/main.ts"
113
+ "start": "node dist/main.js"
114
+
115
+ # Environment variables (universal structure)
116
+ environment:
117
+ - name: "PORT"
118
+ description: "Server port"
119
+ example: "3000"
120
+ required: false
121
+ category: "Server"
122
+ - name: "HOST"
123
+ description: "Server host"
124
+ example: "0.0.0.0"
125
+ required: false
126
+ category: "Server"
127
+ - name: "LOG_LEVEL"
128
+ description: "Logging level (trace, debug, info, warn, error, fatal)"
129
+ example: "info"
130
+ required: false
131
+ category: "Server"
132
+
133
+ # Build/runtime configuration (TypeScript-specific)
134
+ configuration:
135
+ tsconfig:
136
+ compilerOptions:
137
+ target: "ES2022"
138
+ module: "ESNext"
139
+ moduleResolution: "node"
@@ -29,6 +29,27 @@ function generateFastifyServer(context) {
29
29
  * Generated from SpecVerse specification
30
30
  */
31
31
 
32
+ // Load .env from the closest ancestor that has one. Walks up from
33
+ // this file's directory so the backend picks up the project-root
34
+ // .env whether it's running in the monorepo layout
35
+ // (generated/code/backend/src/main.ts with .env at generated/code/)
36
+ // or the standalone layout (generated/code/src/main.ts with .env at
37
+ // generated/code/). dotenv's default cwd-based behaviour doesn't
38
+ // handle the monorepo case because npm workspaces \`cd\`s into the
39
+ // workspace before running the script.
40
+ import { config as loadEnv } from 'dotenv';
41
+ import { existsSync } from 'fs';
42
+ import { resolve as resolvePath, dirname, join } from 'path';
43
+ import { fileURLToPath } from 'url';
44
+ {
45
+ let dir = dirname(fileURLToPath(import.meta.url));
46
+ while (dir !== '/' && dir !== dirname(dir)) {
47
+ const candidate = join(dir, '.env');
48
+ if (existsSync(candidate)) { loadEnv({ path: candidate }); break; }
49
+ dir = dirname(dir);
50
+ }
51
+ }
52
+
32
53
  import Fastify from 'fastify';
33
54
  import cors from '@fastify/cors';
34
55
  import { PrismaClient } from '@prisma/client';
@@ -94,9 +115,9 @@ ${hasEvents ? ` // Register WebSocket bridge for real-time frontend events
94
115
  // fall back to 127.0.0.1 cleanly. Binding :: fixes both cases.
95
116
  await fastify.listen({ port, host: '::' });
96
117
  console.log(\`Server running at http://localhost:\${port}\`);
97
- console.log(\`API endpoints: ${modelNames.map((n) => `/api/${n.toLowerCase()}s`).join(", ")}\`);
118
+ console.log(\`API endpoints: ${modelNames.map((n) => `/api/${pluralizeLower(n)}`).join(", ")}\`);
98
119
  ${hasEvents ? ` console.log(\`WebSocket: ws://localhost:\${port}/ws\`);
99
- console.log(\`Events: ${specEvents.join(", ")}\`);` : ""}
120
+ console.log(\`Events: ${specEvents.length} wired (GET /api/runtime/events for the full list)\`);` : ""}
100
121
  } catch (err) {
101
122
  fastify.log.error(err);
102
123
  process.exit(1);
@@ -106,6 +127,12 @@ ${hasEvents ? ` console.log(\`WebSocket: ws://localhost:\${port}/ws\`);
106
127
  start();
107
128
  `;
108
129
  }
130
+ function pluralizeLower(s) {
131
+ const lower = s.toLowerCase();
132
+ if (/[^aeiou]y$/.test(lower)) return lower.slice(0, -1) + "ies";
133
+ if (/(s|x|z|ch|sh)$/.test(lower)) return lower + "es";
134
+ return lower + "s";
135
+ }
109
136
  export {
110
137
  generateFastifyServer as default
111
138
  };
@@ -0,0 +1,29 @@
1
+ # Infrastructure Instance Factory
2
+
3
+ Generates Docker, Kubernetes, and CI/CD pipeline configurations from a SpecVerse specification.
4
+
5
+ ## Definition
6
+
7
+ - **`docker-k8s.yaml`** -- Single definition covering Docker, Kubernetes, and GitHub Actions CI/CD.
8
+
9
+ ## Generator
10
+
11
+ - `templates/docker-k8s/infrastructure-generator.ts` -- Wrapper that delegates to the existing `generate-infrastructure.js` script (650+ lines). Produces multi-stage Dockerfiles, docker-compose files, K8s manifests (deployments, services, ingress), and CI/CD pipelines.
12
+
13
+ ## Capabilities
14
+
15
+ | Capability | Description |
16
+ |---|---|
17
+ | `infrastructure.docker` | Multi-stage Dockerfiles (Node 20 Alpine) |
18
+ | `infrastructure.kubernetes` | K8s deployments, services, ingress (3 replicas, resource limits) |
19
+ | `infrastructure.cicd` | GitHub Actions pipelines (build on push, deploy on tag) |
20
+
21
+ ## Default Configuration
22
+
23
+ - **Docker**: Multi-stage builds, `node:20-alpine` base image
24
+ - **Kubernetes**: `default` namespace, 3 replicas, 100m-500m CPU, 128Mi-512Mi memory
25
+ - **CI/CD**: GitHub Actions with build-on-push and deploy-on-tag
26
+
27
+ ## Status
28
+
29
+ Wrapper implementation. The YAML notes a future TODO to break the monolithic JS script into native TypeScript template generators (Dockerfile, docker-compose, K8s manifests, CI/CD, env config).
@@ -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)
@@ -0,0 +1,54 @@
1
+ # ORMs Factory
2
+
3
+ Prisma schema and service generation from spec models.
4
+
5
+ ## Definition
6
+
7
+ | File | Description |
8
+ |------|-------------|
9
+ | `prisma.yaml` | Prisma ^5.5 ORM with schema generation and typed client |
10
+
11
+ ## Generated Output
12
+
13
+ | Generator | Output | Purpose |
14
+ |-----------|--------|---------|
15
+ | `schema-generator` | `backend/prisma/schema.prisma` | Full Prisma schema from spec models (tables, relations, enums) |
16
+ | `services-generator` | (per-model service) | Prisma service classes with ORM integration |
17
+
18
+ The schema generator reads all spec models, maps SpecVerse types to Prisma types,
19
+ generates relation fields (1:1, 1:N, N:M), and produces a complete `schema.prisma`
20
+ file. It uses the `pluralize` utility from `@specverse/types` for table naming.
21
+
22
+ ## Technology
23
+
24
+ - **ORM**: Prisma ^5.5.0
25
+ - **Client**: @prisma/client (auto-generated)
26
+ - **Default provider**: PostgreSQL (configurable)
27
+
28
+ ## Capabilities
29
+
30
+ | Provides | Requires |
31
+ |----------|----------|
32
+ | `orm.prisma` | `storage.database` |
33
+ | `orm.schema` | |
34
+ | `orm.client` | |
35
+ | `database.migrations` | |
36
+
37
+ ## Configuration
38
+
39
+ - Provider: `postgresql` (default, overridable)
40
+ - Relation mode: `foreignKeys`
41
+ - Log levels: query, error, warn
42
+
43
+ ## Scripts
44
+
45
+ ```
46
+ db:generate — prisma generate
47
+ db:migrate — prisma migrate dev
48
+ db:push — prisma db push
49
+ db:studio — prisma studio
50
+ ```
51
+
52
+ ## Environment
53
+
54
+ Requires `DATABASE_URL` (e.g., `postgresql://user:password@localhost:5432/dbname`)
@@ -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"
@@ -83,7 +83,7 @@ function buildMissingBackRefs(allModels, relationMap) {
83
83
  (r) => r.target === target && (r.type === "hasMany" || r.type === "hasOne")
84
84
  );
85
85
  const needsFieldInFk = parentRelsToSameTarget.length > 1;
86
- const fkSuffix = needsFieldInFk ? camelToSnake(fieldName) + "_id" : camelToSnake(model.name.charAt(0).toLowerCase() + model.name.slice(1)) + "_id";
86
+ const fkSuffix = needsFieldInFk ? fieldName + "Id" : model.name.charAt(0).toLowerCase() + model.name.slice(1) + "Id";
87
87
  const fkName = fkSuffix;
88
88
  const fkPadding = " ".repeat(Math.max(1, 15 - fkName.length));
89
89
  const refFieldName = needsFieldInFk ? fieldName + model.name : model.name.charAt(0).toLowerCase() + model.name.slice(1);
@@ -270,7 +270,7 @@ function generateRelationship(rel, model, relationMap, hasOneTargets, allModels)
270
270
  const relAnnotation = ` @relation("${relName}")`;
271
271
  switch (rel.type) {
272
272
  case "belongsTo":
273
- const fkBase = rel.foreignKey || camelToSnake(name) + "_id";
273
+ const fkBase = rel.foreignKey || name + "Id";
274
274
  const fkPadding = " ".repeat(Math.max(1, 15 - fkBase.length));
275
275
  const isUniqueFK = hasOneTargets.has(`${rel.target}->${model.name}`);
276
276
  let fkType = "String";
@@ -0,0 +1,49 @@
1
+ # Scaffolding Factory
2
+
3
+ Project-level configuration files that adapt to manifest choices.
4
+
5
+ ## Definition
6
+
7
+ | File | Description |
8
+ |------|-------------|
9
+ | `generic-scaffold.yaml` | Generic project scaffolding — aggregates requirements from all factories |
10
+
11
+ ## Generated Output
12
+
13
+ | Generator | Output | Purpose |
14
+ |-----------|--------|---------|
15
+ | `package-json-generator` | `package.json` | Root package.json aggregating deps from all implementation types |
16
+ | `tsconfig-generator` | `tsconfig.json` | TypeScript configuration |
17
+ | `tsconfig-react-generator` | `tsconfig.react.json` | React-specific TypeScript config |
18
+ | `env-generator` | `.env` | Environment variables with values |
19
+ | `env-example-generator` | `.env.example` | Environment variable template (safe to commit) |
20
+ | `gitignore-generator` | `.gitignore` | Git ignore rules |
21
+ | `readme-generator` | `README.md` | Project README with tech stack and setup instructions |
22
+
23
+ The package.json generator is the key file — it walks all instance factories in
24
+ the manifest, aggregates their `requirements.dependencies` sections, and merges
25
+ them into a single `package.json` with combined scripts, dependencies, and
26
+ devDependencies.
27
+
28
+ ## Technology
29
+
30
+ - **Runtime**: Node.js ^18.0.0
31
+ - **Language**: TypeScript
32
+ - **License**: MIT (default)
33
+
34
+ ## Capabilities
35
+
36
+ | Provides | Requires |
37
+ |----------|----------|
38
+ | `project.scaffold` | (none) |
39
+ | `project.package.json` | |
40
+ | `project.tsconfig` | |
41
+ | `project.gitignore` | |
42
+ | `project.env` | |
43
+
44
+ ## How It Works
45
+
46
+ Unlike other factories that generate domain-specific code, the scaffolding factory
47
+ generates project infrastructure. It reads the full manifest to understand which
48
+ other factories are in use, then aggregates their requirements into unified
49
+ project files.
@@ -0,0 +1,65 @@
1
+ name: GenericScaffold
2
+ version: "1.0.0"
3
+ category: scaffolding
4
+ description: "Generic project scaffolding that adapts to manifest choices"
5
+
6
+ metadata:
7
+ author: "SpecVerse Team"
8
+ license: "MIT"
9
+ tags: [scaffolding, project-setup, generic]
10
+
11
+ compatibility:
12
+ specverse: ">=3.3.0"
13
+ node: ">=18.0.0"
14
+
15
+ capabilities:
16
+ provides:
17
+ - "project.scaffold"
18
+ - "project.package.json"
19
+ - "project.tsconfig"
20
+ - "project.gitignore"
21
+ - "project.env"
22
+
23
+ technology:
24
+ runtime: "node"
25
+ language: "typescript"
26
+
27
+ codeTemplates:
28
+ packageJson:
29
+ engine: typescript
30
+ generator: "libs/instance-factories/scaffolding/templates/generic/package-json-generator.ts"
31
+ outputPattern: "package.json"
32
+
33
+ tsconfig:
34
+ engine: typescript
35
+ generator: "libs/instance-factories/scaffolding/templates/generic/tsconfig-generator.ts"
36
+ outputPattern: "tsconfig.json"
37
+
38
+ tsconfigReact:
39
+ engine: typescript
40
+ generator: "libs/instance-factories/scaffolding/templates/generic/tsconfig-react-generator.ts"
41
+ outputPattern: "tsconfig.react.json"
42
+
43
+ env:
44
+ engine: typescript
45
+ generator: "libs/instance-factories/scaffolding/templates/generic/env-generator.ts"
46
+ outputPattern: ".env"
47
+
48
+ envExample:
49
+ engine: typescript
50
+ generator: "libs/instance-factories/scaffolding/templates/generic/env-example-generator.ts"
51
+ outputPattern: ".env.example"
52
+
53
+ gitignore:
54
+ engine: typescript
55
+ generator: "libs/instance-factories/scaffolding/templates/generic/gitignore-generator.ts"
56
+ outputPattern: ".gitignore"
57
+
58
+ readme:
59
+ engine: typescript
60
+ generator: "libs/instance-factories/scaffolding/templates/generic/readme-generator.ts"
61
+ outputPattern: "README.md"
62
+
63
+ configuration:
64
+ defaultNodeVersion: "18.0.0"
65
+ defaultLicense: "MIT"
@@ -0,0 +1,28 @@
1
+ # SDKs Instance Factory
2
+
3
+ Generates typed client SDKs for consuming REST APIs produced by a SpecVerse specification.
4
+
5
+ ## Definitions
6
+
7
+ - **`python-sdk.yaml`** -- Python SDK with async support (aiohttp + Pydantic)
8
+ - **`typescript-sdk.yaml`** -- TypeScript SDK with native fetch (zero runtime dependencies)
9
+
10
+ ## Generators
11
+
12
+ - `templates/python/sdk-generator.ts` -- Wraps `generate-sdk-python.js` (1000+ lines). Produces a complete Python package: async client class, per-controller resource classes, Pydantic models, exception classes, `setup.py`, and `requirements.txt`.
13
+ - `templates/typescript/sdk-generator.ts` -- Wraps `generate-sdk-typescript.js` (900+ lines). Produces a complete npm package: client class, resource classes, TypeScript interfaces, error classes, `package.json`, and `tsconfig.json`.
14
+
15
+ ## Capabilities
16
+
17
+ | SDK | Provides | Requires |
18
+ |---|---|---|
19
+ | Python | `sdk.python`, `client.rest.async` | `api.rest`, `api.rest.crud` |
20
+ | TypeScript | `sdk.typescript`, `client.rest` | `api.rest`, `api.rest.crud` |
21
+
22
+ ## Default Configuration
23
+
24
+ Both SDKs include authentication support, automatic retries (3 attempts), and a 30s timeout. The Python SDK defaults to package name `specverse_client`; TypeScript defaults to `@specverse/sdk`.
25
+
26
+ ## Status
27
+
28
+ Wrapper implementations. Both YAMLs note future TODOs to convert the monolithic JS generators into native TypeScript template generators.
@@ -0,0 +1,66 @@
1
+ name: PythonSDK
2
+ version: "1.0.0"
3
+ category: view
4
+ description: "Python SDK generator for consuming REST APIs with async support and type hints"
5
+
6
+ metadata:
7
+ author: "SpecVerse Team"
8
+ license: "MIT"
9
+ tags: [python, sdk, client, rest-api, async]
10
+
11
+ compatibility:
12
+ specverse: ">=3.3.0"
13
+ python: ">=3.8"
14
+
15
+ capabilities:
16
+ provides:
17
+ - "sdk.python"
18
+ - "client.rest.async"
19
+ requires:
20
+ - "api.rest"
21
+ - "api.rest.crud"
22
+
23
+ technology:
24
+ runtime: "python"
25
+ language: "python"
26
+ framework: "native"
27
+ httpClient: "aiohttp"
28
+
29
+ dependencies:
30
+ runtime:
31
+ - name: "aiohttp"
32
+ version: "^3.9.0"
33
+ - name: "pydantic"
34
+ version: "^2.0.0"
35
+ dev:
36
+ - name: "mypy"
37
+ version: "^1.7.0"
38
+ - name: "pytest"
39
+ version: "^7.4.0"
40
+ - name: "pytest-asyncio"
41
+ version: "^0.21.0"
42
+
43
+ codeTemplates:
44
+ sdk:
45
+ engine: typescript
46
+ generator: "libs/instance-factories/sdks/templates/python/sdk-generator.ts"
47
+ outputPattern: "sdk-python/"
48
+
49
+ configuration:
50
+ packageName: "specverse_client"
51
+ packageVersion: "1.0.0"
52
+ includeAuth: true
53
+ includeRetry: true
54
+ includeAsync: true
55
+ timeout: 30000
56
+ retries: 3
57
+
58
+ # NOTE: This implementation type wraps the existing generate-sdk-python.js script
59
+ # TODO: Future enhancement - Convert generate-sdk-python.js to native TypeScript template generator
60
+ # The current script is 1000+ lines and generates a complete Python package structure.
61
+ # Converting to native templates would require breaking it into multiple template files:
62
+ # - client-generator.ts (main async client class)
63
+ # - resource-generator.ts (per-controller resource classes)
64
+ # - types-generator.ts (Pydantic models)
65
+ # - errors-generator.ts (exception classes)
66
+ # - package-generator.ts (setup.py, requirements.txt)