archetype-engine 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +241 -0
  3. package/dist/src/ai/adapters/anthropic.d.ts +31 -0
  4. package/dist/src/ai/adapters/anthropic.d.ts.map +1 -0
  5. package/dist/src/ai/adapters/anthropic.js +75 -0
  6. package/dist/src/ai/adapters/openai.d.ts +33 -0
  7. package/dist/src/ai/adapters/openai.d.ts.map +1 -0
  8. package/dist/src/ai/adapters/openai.js +120 -0
  9. package/dist/src/ai/adapters/vercel.d.ts +434 -0
  10. package/dist/src/ai/adapters/vercel.d.ts.map +1 -0
  11. package/dist/src/ai/adapters/vercel.js +162 -0
  12. package/dist/src/ai/index.d.ts +492 -0
  13. package/dist/src/ai/index.d.ts.map +1 -0
  14. package/dist/src/ai/index.js +71 -0
  15. package/dist/src/ai/state.d.ts +13 -0
  16. package/dist/src/ai/state.d.ts.map +1 -0
  17. package/dist/src/ai/state.js +215 -0
  18. package/dist/src/ai/tools.d.ts +13 -0
  19. package/dist/src/ai/tools.d.ts.map +1 -0
  20. package/dist/src/ai/tools.js +257 -0
  21. package/dist/src/ai/types.d.ts +196 -0
  22. package/dist/src/ai/types.d.ts.map +1 -0
  23. package/dist/src/ai/types.js +9 -0
  24. package/dist/src/cli.d.ts +3 -0
  25. package/dist/src/cli.d.ts.map +1 -0
  26. package/dist/src/cli.js +540 -0
  27. package/dist/src/core/utils.d.ts +27 -0
  28. package/dist/src/core/utils.d.ts.map +1 -0
  29. package/dist/src/core/utils.js +56 -0
  30. package/dist/src/entity.d.ts +165 -0
  31. package/dist/src/entity.d.ts.map +1 -0
  32. package/dist/src/entity.js +108 -0
  33. package/dist/src/fields.d.ts +207 -0
  34. package/dist/src/fields.d.ts.map +1 -0
  35. package/dist/src/fields.js +291 -0
  36. package/dist/src/generators/erd-ir.d.ts +10 -0
  37. package/dist/src/generators/erd-ir.d.ts.map +1 -0
  38. package/dist/src/generators/erd-ir.js +119 -0
  39. package/dist/src/index.d.ts +51 -0
  40. package/dist/src/index.d.ts.map +1 -0
  41. package/dist/src/index.js +101 -0
  42. package/dist/src/init/dependencies.d.ts +31 -0
  43. package/dist/src/init/dependencies.d.ts.map +1 -0
  44. package/dist/src/init/dependencies.js +101 -0
  45. package/dist/src/init/entity-templates.d.ts +42 -0
  46. package/dist/src/init/entity-templates.d.ts.map +1 -0
  47. package/dist/src/init/entity-templates.js +367 -0
  48. package/dist/src/init/index.d.ts +10 -0
  49. package/dist/src/init/index.d.ts.map +1 -0
  50. package/dist/src/init/index.js +250 -0
  51. package/dist/src/init/prompts.d.ts +11 -0
  52. package/dist/src/init/prompts.d.ts.map +1 -0
  53. package/dist/src/init/prompts.js +275 -0
  54. package/dist/src/init/templates.d.ts +24 -0
  55. package/dist/src/init/templates.d.ts.map +1 -0
  56. package/dist/src/init/templates.js +587 -0
  57. package/dist/src/json/index.d.ts +11 -0
  58. package/dist/src/json/index.d.ts.map +1 -0
  59. package/dist/src/json/index.js +26 -0
  60. package/dist/src/json/parser.d.ts +61 -0
  61. package/dist/src/json/parser.d.ts.map +1 -0
  62. package/dist/src/json/parser.js +309 -0
  63. package/dist/src/json/types.d.ts +275 -0
  64. package/dist/src/json/types.d.ts.map +1 -0
  65. package/dist/src/json/types.js +10 -0
  66. package/dist/src/manifest.d.ts +147 -0
  67. package/dist/src/manifest.d.ts.map +1 -0
  68. package/dist/src/manifest.js +104 -0
  69. package/dist/src/relations.d.ts +96 -0
  70. package/dist/src/relations.d.ts.map +1 -0
  71. package/dist/src/relations.js +108 -0
  72. package/dist/src/source.d.ts +93 -0
  73. package/dist/src/source.d.ts.map +1 -0
  74. package/dist/src/source.js +89 -0
  75. package/dist/src/template/context.d.ts +34 -0
  76. package/dist/src/template/context.d.ts.map +1 -0
  77. package/dist/src/template/context.js +31 -0
  78. package/dist/src/template/index.d.ts +6 -0
  79. package/dist/src/template/index.d.ts.map +1 -0
  80. package/dist/src/template/index.js +12 -0
  81. package/dist/src/template/registry.d.ts +18 -0
  82. package/dist/src/template/registry.d.ts.map +1 -0
  83. package/dist/src/template/registry.js +89 -0
  84. package/dist/src/template/runner.d.ts +9 -0
  85. package/dist/src/template/runner.d.ts.map +1 -0
  86. package/dist/src/template/runner.js +125 -0
  87. package/dist/src/template/types.d.ts +73 -0
  88. package/dist/src/template/types.d.ts.map +1 -0
  89. package/dist/src/template/types.js +3 -0
  90. package/dist/src/templates/nextjs-drizzle-trpc/generators/api.d.ts +22 -0
  91. package/dist/src/templates/nextjs-drizzle-trpc/generators/api.d.ts.map +1 -0
  92. package/dist/src/templates/nextjs-drizzle-trpc/generators/api.js +866 -0
  93. package/dist/src/templates/nextjs-drizzle-trpc/generators/auth.d.ts +20 -0
  94. package/dist/src/templates/nextjs-drizzle-trpc/generators/auth.d.ts.map +1 -0
  95. package/dist/src/templates/nextjs-drizzle-trpc/generators/auth.js +273 -0
  96. package/dist/src/templates/nextjs-drizzle-trpc/generators/crud-hooks.d.ts +22 -0
  97. package/dist/src/templates/nextjs-drizzle-trpc/generators/crud-hooks.d.ts.map +1 -0
  98. package/dist/src/templates/nextjs-drizzle-trpc/generators/crud-hooks.js +237 -0
  99. package/dist/src/templates/nextjs-drizzle-trpc/generators/hooks.d.ts +30 -0
  100. package/dist/src/templates/nextjs-drizzle-trpc/generators/hooks.d.ts.map +1 -0
  101. package/dist/src/templates/nextjs-drizzle-trpc/generators/hooks.js +345 -0
  102. package/dist/src/templates/nextjs-drizzle-trpc/generators/i18n.d.ts +25 -0
  103. package/dist/src/templates/nextjs-drizzle-trpc/generators/i18n.d.ts.map +1 -0
  104. package/dist/src/templates/nextjs-drizzle-trpc/generators/i18n.js +199 -0
  105. package/dist/src/templates/nextjs-drizzle-trpc/generators/index.d.ts +8 -0
  106. package/dist/src/templates/nextjs-drizzle-trpc/generators/index.d.ts.map +1 -0
  107. package/dist/src/templates/nextjs-drizzle-trpc/generators/index.js +18 -0
  108. package/dist/src/templates/nextjs-drizzle-trpc/generators/schema.d.ts +22 -0
  109. package/dist/src/templates/nextjs-drizzle-trpc/generators/schema.d.ts.map +1 -0
  110. package/dist/src/templates/nextjs-drizzle-trpc/generators/schema.js +270 -0
  111. package/dist/src/templates/nextjs-drizzle-trpc/generators/service.d.ts +23 -0
  112. package/dist/src/templates/nextjs-drizzle-trpc/generators/service.d.ts.map +1 -0
  113. package/dist/src/templates/nextjs-drizzle-trpc/generators/service.js +304 -0
  114. package/dist/src/templates/nextjs-drizzle-trpc/generators/validation.d.ts +21 -0
  115. package/dist/src/templates/nextjs-drizzle-trpc/generators/validation.d.ts.map +1 -0
  116. package/dist/src/templates/nextjs-drizzle-trpc/generators/validation.js +248 -0
  117. package/dist/src/templates/nextjs-drizzle-trpc/index.d.ts +30 -0
  118. package/dist/src/templates/nextjs-drizzle-trpc/index.d.ts.map +1 -0
  119. package/dist/src/templates/nextjs-drizzle-trpc/index.js +71 -0
  120. package/dist/src/validation/index.d.ts +71 -0
  121. package/dist/src/validation/index.d.ts.map +1 -0
  122. package/dist/src/validation/index.js +314 -0
  123. package/package.json +86 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/template/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EACL,WAAW,EACX,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACd,MAAM,eAAe,CAAA;AAEtB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B;IAC7B,MAAM,EAAE,cAAc,CAAA;IAEtB,uBAAuB;IACvB,MAAM,EAAE;QACN,WAAW,EAAE,OAAO,WAAW,CAAA;QAC/B,SAAS,EAAE,OAAO,SAAS,CAAA;QAC3B,WAAW,EAAE,OAAO,WAAW,CAAA;QAC/B,YAAY,EAAE,OAAO,YAAY,CAAA;QACjC,YAAY,EAAE,OAAO,YAAY,CAAA;QACjC,aAAa,EAAE,OAAO,aAAa,CAAA;KACpC,CAAA;IAED,+DAA+D;IAC/D,QAAQ,EAAE;QACR,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAA;QACjD,QAAQ,EAAE,OAAO,CAAA;QACjB,UAAU,EAAE,OAAO,CAAA;QACnB,OAAO,EAAE,OAAO,CAAA;QAChB,UAAU,EAAE,OAAO,CAAA;KACpB,CAAA;IAED,wCAAwC;IACxC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;CACvC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,UAAU,EACpB,MAAM,EAAE,cAAc,GACrB,gBAAgB,CAuBlB"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // Generator context with common utilities
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createContext = createContext;
5
+ const utils_1 = require("../core/utils");
6
+ /**
7
+ * Create a generator context from manifest and config
8
+ */
9
+ function createContext(manifest, config) {
10
+ const dbType = manifest.database?.type;
11
+ const isHeadless = manifest.mode.type === 'headless' || !manifest.database;
12
+ return {
13
+ config,
14
+ naming: {
15
+ toSnakeCase: utils_1.toSnakeCase,
16
+ pluralize: utils_1.pluralize,
17
+ toCamelCase: utils_1.toCamelCase,
18
+ toPascalCase: utils_1.toPascalCase,
19
+ getTableName: utils_1.getTableName,
20
+ getColumnName: utils_1.getColumnName,
21
+ },
22
+ database: {
23
+ type: dbType,
24
+ isSqlite: dbType === 'sqlite',
25
+ isPostgres: dbType === 'postgres',
26
+ isMysql: dbType === 'mysql',
27
+ isHeadless,
28
+ },
29
+ resolvePath: (alias) => config.importAliases[alias] || alias,
30
+ };
31
+ }
@@ -0,0 +1,6 @@
1
+ export type { GeneratedFile, Generator, GeneratorOutput, TemplateMetadata, TemplateConfig, Template, } from './types';
2
+ export type { GeneratorContext } from './context';
3
+ export { createContext } from './context';
4
+ export { runTemplate } from './runner';
5
+ export { getTemplate, listTemplates, hasTemplate, } from './registry';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/template/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,QAAQ,GACT,MAAM,SAAS,CAAA;AAEhB,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC,OAAO,EACL,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ // Template system exports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.hasTemplate = exports.listTemplates = exports.getTemplate = exports.runTemplate = exports.createContext = void 0;
5
+ var context_1 = require("./context");
6
+ Object.defineProperty(exports, "createContext", { enumerable: true, get: function () { return context_1.createContext; } });
7
+ var runner_1 = require("./runner");
8
+ Object.defineProperty(exports, "runTemplate", { enumerable: true, get: function () { return runner_1.runTemplate; } });
9
+ var registry_1 = require("./registry");
10
+ Object.defineProperty(exports, "getTemplate", { enumerable: true, get: function () { return registry_1.getTemplate; } });
11
+ Object.defineProperty(exports, "listTemplates", { enumerable: true, get: function () { return registry_1.listTemplates; } });
12
+ Object.defineProperty(exports, "hasTemplate", { enumerable: true, get: function () { return registry_1.hasTemplate; } });
@@ -0,0 +1,18 @@
1
+ import type { Template, TemplateMetadata } from './types';
2
+ /**
3
+ * Get a template by ID
4
+ */
5
+ export declare function getTemplate(id: string): Promise<Template | null>;
6
+ /**
7
+ * List all available templates
8
+ */
9
+ export declare function listTemplates(): TemplateMetadata[];
10
+ /**
11
+ * Check if a template exists
12
+ */
13
+ export declare function hasTemplate(id: string): boolean;
14
+ /**
15
+ * Get default template ID
16
+ */
17
+ export declare function getDefaultTemplateId(): string;
18
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/template/registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAYzD;;GAEG;AACH,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAItE;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,gBAAgB,EAAE,CAelD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ // Template registry - discovers and loads templates
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.getTemplate = getTemplate;
38
+ exports.listTemplates = listTemplates;
39
+ exports.hasTemplate = hasTemplate;
40
+ exports.getDefaultTemplateId = getDefaultTemplateId;
41
+ // Template loaders - lazy import for each template
42
+ const templateLoaders = {
43
+ 'nextjs-drizzle-trpc': async () => {
44
+ const mod = await Promise.resolve().then(() => __importStar(require('../templates/nextjs-drizzle-trpc')));
45
+ return mod.default;
46
+ },
47
+ // Future templates:
48
+ // 'sveltekit-prisma': async () => (await import('../templates/sveltekit-prisma')).default,
49
+ };
50
+ /**
51
+ * Get a template by ID
52
+ */
53
+ async function getTemplate(id) {
54
+ const loader = templateLoaders[id];
55
+ if (!loader)
56
+ return null;
57
+ return loader();
58
+ }
59
+ /**
60
+ * List all available templates
61
+ */
62
+ function listTemplates() {
63
+ return [
64
+ {
65
+ id: 'nextjs-drizzle-trpc',
66
+ name: 'Next.js + Drizzle + tRPC',
67
+ description: 'Full-stack Next.js with Drizzle ORM, tRPC API, and React hooks',
68
+ framework: 'nextjs',
69
+ stack: {
70
+ database: 'drizzle',
71
+ validation: 'zod',
72
+ api: 'trpc',
73
+ ui: 'react',
74
+ },
75
+ },
76
+ ];
77
+ }
78
+ /**
79
+ * Check if a template exists
80
+ */
81
+ function hasTemplate(id) {
82
+ return id in templateLoaders;
83
+ }
84
+ /**
85
+ * Get default template ID
86
+ */
87
+ function getDefaultTemplateId() {
88
+ return 'nextjs-drizzle-trpc';
89
+ }
@@ -0,0 +1,9 @@
1
+ import type { ManifestIR } from '../manifest';
2
+ import type { Template, GeneratedFile } from './types';
3
+ /**
4
+ * Run a template against a manifest and write output files
5
+ */
6
+ export declare function runTemplate(template: Template, manifest: ManifestIR, options?: {
7
+ dryRun?: boolean;
8
+ }): Promise<GeneratedFile[]>;
9
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/template/runner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAa,MAAM,SAAS,CAAA;AA6DjE;;GAEG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,UAAU,EACpB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,OAAO,CAAC,aAAa,EAAE,CAAC,CAqC1B"}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ // Template runner - orchestrates generators and writes files
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.runTemplate = runTemplate;
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const context_1 = require("./context");
41
+ /**
42
+ * Generator names that should be skipped in headless mode
43
+ */
44
+ const SKIP_IN_HEADLESS = ['drizzle-schema'];
45
+ const GENERATOR_CATEGORIES = {
46
+ 'drizzle-schema': 'schema',
47
+ 'zod-schemas': 'validation',
48
+ 'trpc-routers': 'api',
49
+ 'react-hooks': 'hooks',
50
+ 'i18n': 'i18n',
51
+ 'service-layer': 'services',
52
+ };
53
+ /**
54
+ * Check if a generator should run based on mode
55
+ */
56
+ function shouldRunGenerator(generator, mode) {
57
+ const name = generator.name;
58
+ // Full mode runs everything
59
+ if (mode.type === 'full') {
60
+ return true;
61
+ }
62
+ // Headless mode skips database-related generators
63
+ if (mode.type === 'headless') {
64
+ if (SKIP_IN_HEADLESS.includes(name)) {
65
+ return false;
66
+ }
67
+ // If include list is specified, check if generator category is included
68
+ if (mode.include) {
69
+ const category = GENERATOR_CATEGORIES[name];
70
+ // If we don't know the category, include it by default
71
+ if (!category)
72
+ return true;
73
+ return mode.include.includes(category);
74
+ }
75
+ return true;
76
+ }
77
+ // API-only mode runs schema, validation, and API generators
78
+ if (mode.type === 'api-only') {
79
+ const category = GENERATOR_CATEGORIES[name];
80
+ const apiOnlyCategories = ['schema', 'validation', 'api', 'services'];
81
+ if (!category)
82
+ return true;
83
+ return apiOnlyCategories.includes(category);
84
+ }
85
+ return true;
86
+ }
87
+ /**
88
+ * Run a template against a manifest and write output files
89
+ */
90
+ async function runTemplate(template, manifest, options = {}) {
91
+ const config = template.defaultConfig;
92
+ const ctx = (0, context_1.createContext)(manifest, config);
93
+ const allFiles = [];
94
+ const mode = manifest.mode;
95
+ // Filter generators based on mode
96
+ const activeGenerators = template.generators.filter(g => shouldRunGenerator(g, mode));
97
+ // Log mode info
98
+ console.log(` Mode: ${mode.type}`);
99
+ // Run each active generator
100
+ for (const generator of activeGenerators) {
101
+ console.log(` Running ${generator.name}...`);
102
+ const result = generator.generate(manifest, ctx);
103
+ const files = Array.isArray(result) ? result : [result];
104
+ allFiles.push(...files);
105
+ }
106
+ // Run post-generate hook if defined
107
+ if (template.postGenerate) {
108
+ template.postGenerate(manifest, ctx);
109
+ }
110
+ // Write files (unless dry run)
111
+ if (!options.dryRun) {
112
+ for (const file of allFiles) {
113
+ const fullPath = path.join(config.outputDir, file.path);
114
+ ensureDir(path.dirname(fullPath));
115
+ fs.writeFileSync(fullPath, file.content);
116
+ console.log(` Created: ${fullPath}`);
117
+ }
118
+ }
119
+ return allFiles;
120
+ }
121
+ function ensureDir(dir) {
122
+ if (!fs.existsSync(dir)) {
123
+ fs.mkdirSync(dir, { recursive: true });
124
+ }
125
+ }
@@ -0,0 +1,73 @@
1
+ import type { ManifestIR } from '../manifest';
2
+ import type { GeneratorContext } from './context';
3
+ /**
4
+ * A generated file with path and content
5
+ */
6
+ export interface GeneratedFile {
7
+ /** Relative path from output directory */
8
+ path: string;
9
+ /** File content */
10
+ content: string;
11
+ }
12
+ /**
13
+ * Generator output - single file or array of files
14
+ */
15
+ export type GeneratorOutput = GeneratedFile | GeneratedFile[];
16
+ /**
17
+ * A generator produces code for a specific aspect of the stack
18
+ */
19
+ export interface Generator {
20
+ /** Unique identifier */
21
+ name: string;
22
+ /** Human-readable description */
23
+ description: string;
24
+ /**
25
+ * Generate code from the manifest
26
+ */
27
+ generate(manifest: ManifestIR, ctx: GeneratorContext): GeneratorOutput;
28
+ }
29
+ /**
30
+ * Template metadata for discovery and CLI
31
+ */
32
+ export interface TemplateMetadata {
33
+ /** Unique template ID (e.g., "nextjs-drizzle-trpc") */
34
+ id: string;
35
+ /** Display name for CLI */
36
+ name: string;
37
+ /** Description shown in help */
38
+ description: string;
39
+ /** Framework this template targets */
40
+ framework: 'nextjs' | 'sveltekit' | 'remix' | 'astro' | 'generic';
41
+ /** Tech stack components */
42
+ stack: {
43
+ database: 'drizzle' | 'prisma' | 'kysely';
44
+ validation: 'zod' | 'valibot' | 'yup';
45
+ api?: 'trpc' | 'rest' | 'graphql';
46
+ ui?: 'react' | 'svelte' | 'vue' | 'none';
47
+ };
48
+ }
49
+ /**
50
+ * Configuration for output paths and import aliases
51
+ */
52
+ export interface TemplateConfig {
53
+ /** Output directory (default: 'generated') */
54
+ outputDir: string;
55
+ /** Import alias mapping (e.g., { '@/generated': './generated' }) */
56
+ importAliases: Record<string, string>;
57
+ }
58
+ /**
59
+ * A template bundles generators for a specific tech stack
60
+ */
61
+ export interface Template {
62
+ /** Template metadata */
63
+ meta: TemplateMetadata;
64
+ /** Default configuration */
65
+ defaultConfig: TemplateConfig;
66
+ /** List of generators in execution order */
67
+ generators: Generator[];
68
+ /**
69
+ * Optional hook to run after all generators complete
70
+ */
71
+ postGenerate?(manifest: ManifestIR, ctx: GeneratorContext): void;
72
+ }
73
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/template/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEjD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,mBAAmB;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,aAAa,EAAE,CAAA;AAE7D;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,gBAAgB,GAAG,eAAe,CAAA;CACvE;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAA;IACV,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAA;IACnB,sCAAsC;IACtC,SAAS,EAAE,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAA;IACjE,4BAA4B;IAC5B,KAAK,EAAE;QACL,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;QACzC,UAAU,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,CAAA;QACrC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;QACjC,EAAE,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAA;KACzC,CAAA;CACF;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAA;IACjB,oEAAoE;IACpE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,wBAAwB;IACxB,IAAI,EAAE,gBAAgB,CAAA;IACtB,4BAA4B;IAC5B,aAAa,EAAE,cAAc,CAAA;IAC7B,4CAA4C;IAC5C,UAAU,EAAE,SAAS,EAAE,CAAA;IACvB;;OAEG;IACH,YAAY,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAAA;CACjE"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // Template and Generator interfaces
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * tRPC Router Generator
3
+ *
4
+ * Generates type-safe tRPC routers with CRUD operations for each entity.
5
+ * Adapts to database or external API source based on entity/manifest configuration.
6
+ *
7
+ * Generated files:
8
+ * - trpc/routers/{entity}.ts - Individual entity routers with list, get, create, update, remove
9
+ * - trpc/routers/index.ts - App router combining all entity routers
10
+ *
11
+ * Features:
12
+ * - Automatic procedure type selection (publicProcedure vs protectedProcedure)
13
+ * - Multi-tenancy support with automatic tenant filtering
14
+ * - Soft delete support (updates deletedAt instead of hard delete)
15
+ * - External API integration via generated service layer
16
+ * - Input validation using generated Zod schemas
17
+ *
18
+ * @module generators/api
19
+ */
20
+ import type { Generator } from '../../../template/types';
21
+ export declare const apiGenerator: Generator;
22
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../src/templates/nextjs-drizzle-trpc/generators/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAA;AAu3BvE,eAAO,MAAM,YAAY,EAAE,SAuB1B,CAAA"}