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,248 @@
1
+ "use strict";
2
+ /**
3
+ * Zod Validation Schema Generator
4
+ *
5
+ * Generates Zod validation schemas for entity CRUD operations.
6
+ * Supports internationalized error messages via next-intl.
7
+ *
8
+ * Generated files:
9
+ * - schemas/{entity}.ts - Create and Update schemas with types
10
+ *
11
+ * Features:
12
+ * - Maps field types to Zod validators (z.string(), z.number(), etc.)
13
+ * - Generates validation rules from field config (min, max, email, url, regex)
14
+ * - Supports i18n error messages when multiple languages configured
15
+ * - Creates both static and i18n-aware schema factory functions
16
+ * - Exports TypeScript types derived from schemas
17
+ *
18
+ * @module generators/validation
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.validationGenerator = void 0;
22
+ /**
23
+ * Generate Zod schema chain for a single field
24
+ *
25
+ * @param fieldName - Field name for error messages
26
+ * @param config - Field configuration with type and validations
27
+ * @param useI18n - Whether to use i18n translation function for messages
28
+ * @returns Zod schema chain as string (e.g., "z.string().email().min(1)")
29
+ */
30
+ function generateFieldSchema(fieldName, config, useI18n) {
31
+ const parts = [];
32
+ const label = config.label || fieldName;
33
+ // Base type - handle enum fields specially with z.enum()
34
+ if (config.type === 'enum' && config.enumValues) {
35
+ const values = config.enumValues.map(v => `'${v}'`).join(', ');
36
+ parts.push(`z.enum([${values}])`);
37
+ // Optional (must come after base type)
38
+ if (!config.required) {
39
+ parts.push('.optional()');
40
+ }
41
+ // Default (must come after optional)
42
+ if (config.default !== undefined && !config.required) {
43
+ parts.push(`.default('${config.default}')`);
44
+ }
45
+ return parts.join('');
46
+ }
47
+ // Regular field types
48
+ switch (config.type) {
49
+ case 'text':
50
+ parts.push('z.string()');
51
+ break;
52
+ case 'number':
53
+ parts.push('z.number()');
54
+ break;
55
+ case 'boolean':
56
+ parts.push('z.boolean()');
57
+ break;
58
+ case 'date':
59
+ parts.push('z.string()');
60
+ break;
61
+ }
62
+ // Required check for text (must come before validations and optional)
63
+ if (config.required && config.type === 'text') {
64
+ if (useI18n) {
65
+ parts.push(`.min(1, { message: t('required', { field: '${label}' }) })`);
66
+ }
67
+ else {
68
+ parts.push(`.min(1, { message: '${label} is required' })`);
69
+ }
70
+ }
71
+ // Validations (must come before optional)
72
+ for (const validation of config.validations) {
73
+ parts.push(generateValidation(validation, label, useI18n));
74
+ }
75
+ // Optional (must come after validations)
76
+ if (!config.required) {
77
+ parts.push('.optional()');
78
+ }
79
+ // Default (must come after optional)
80
+ if (config.default !== undefined && !config.required) {
81
+ if (typeof config.default === 'string') {
82
+ parts.push(`.default('${config.default}')`);
83
+ }
84
+ else {
85
+ parts.push(`.default(${config.default})`);
86
+ }
87
+ }
88
+ return parts.join('');
89
+ }
90
+ /**
91
+ * Generate Zod validation method for a specific validation rule
92
+ *
93
+ * @param v - Validation rule from field config
94
+ * @param label - Field label for error messages
95
+ * @param useI18n - Whether to use i18n translation function
96
+ * @returns Zod method call as string (e.g., ".min(5, { message: ... })")
97
+ */
98
+ function generateValidation(v, label, useI18n) {
99
+ const msg = (key, params = {}) => {
100
+ if (useI18n) {
101
+ const paramStr = Object.entries({ field: label, ...params })
102
+ .map(([k, val]) => {
103
+ if (typeof val === 'string')
104
+ return `${k}: '${val}'`;
105
+ if (Array.isArray(val))
106
+ return `${k}: '${val.join(', ')}'`;
107
+ return `${k}: ${val}`;
108
+ })
109
+ .join(', ');
110
+ return `{ message: t('${key}', { ${paramStr} }) }`;
111
+ }
112
+ // Static messages
113
+ const messages = {
114
+ minLength: `${label} must be at least ${params.min} characters`,
115
+ maxLength: `${label} must be at most ${params.max} characters`,
116
+ min: `${label} must be at least ${params.min}`,
117
+ max: `${label} must be at most ${params.max}`,
118
+ email: `Invalid email address`,
119
+ url: `Invalid URL`,
120
+ integer: `${label} must be a whole number`,
121
+ positive: `${label} must be positive`,
122
+ pattern: `${label} format is invalid`,
123
+ oneOf: `${label} must be one of: ${params.values?.join(', ')}`,
124
+ };
125
+ return `{ message: '${messages[key] || `Invalid ${label}`}' }`;
126
+ };
127
+ switch (v.type) {
128
+ case 'minLength': return `.min(${v.value}, ${msg('minLength', { min: v.value })})`;
129
+ case 'maxLength': return `.max(${v.value}, ${msg('maxLength', { max: v.value })})`;
130
+ case 'min': return `.min(${v.value}, ${msg('min', { min: v.value })})`;
131
+ case 'max': return `.max(${v.value}, ${msg('max', { max: v.value })})`;
132
+ case 'email': return `.email(${msg('email')})`;
133
+ case 'url': return `.url(${msg('url')})`;
134
+ case 'regex': return `.regex(/${v.value}/, ${msg('pattern')})`;
135
+ case 'integer': return `.int(${msg('integer')})`;
136
+ case 'positive': return `.positive(${msg('positive')})`;
137
+ case 'oneOf':
138
+ const values = v.value;
139
+ return `.refine(v => ${JSON.stringify(values)}.includes(v), ${msg('oneOf', { values })})`;
140
+ case 'trim': return '.trim()';
141
+ case 'lowercase': return '.toLowerCase()';
142
+ case 'uppercase': return '.toUpperCase()';
143
+ default: return '';
144
+ }
145
+ }
146
+ /**
147
+ * Generate complete validation schema file for an entity
148
+ *
149
+ * Creates both static schemas and i18n-aware factory functions when i18n is enabled.
150
+ *
151
+ * @param entity - Entity IR with fields and relations
152
+ * @param useI18n - Whether to generate i18n-aware schema factories
153
+ * @returns Complete schema file content as string
154
+ */
155
+ function generateEntitySchema(entity, useI18n) {
156
+ const name = entity.name;
157
+ const lowerName = name.toLowerCase();
158
+ const staticFields = [];
159
+ for (const [fieldName, config] of Object.entries(entity.fields)) {
160
+ // Skip computed fields - they're derived at runtime, not user input
161
+ if (config.type === 'computed')
162
+ continue;
163
+ staticFields.push(` ${fieldName}: ${generateFieldSchema(fieldName, config, false)},`);
164
+ }
165
+ for (const [relName, rel] of Object.entries(entity.relations)) {
166
+ if (rel.type === 'hasOne') {
167
+ const fkField = rel.field || `${relName}Id`;
168
+ // Skip if this field was already defined in entity.fields
169
+ if (entity.fields[fkField])
170
+ continue;
171
+ // Match required status from relation - if relation is optional, FK is optional
172
+ const zodType = rel.optional ? 'z.string().optional()' : 'z.string()';
173
+ staticFields.push(` ${fkField}: ${zodType},`);
174
+ }
175
+ }
176
+ if (useI18n) {
177
+ const i18nFields = [];
178
+ for (const [fieldName, config] of Object.entries(entity.fields)) {
179
+ // Skip computed fields - they're derived at runtime, not user input
180
+ if (config.type === 'computed')
181
+ continue;
182
+ i18nFields.push(` ${fieldName}: ${generateFieldSchema(fieldName, config, true)},`);
183
+ }
184
+ for (const [relName, rel] of Object.entries(entity.relations)) {
185
+ if (rel.type === 'hasOne') {
186
+ const fkField = rel.field || `${relName}Id`;
187
+ // Skip if this field was already defined in entity.fields
188
+ if (entity.fields[fkField])
189
+ continue;
190
+ // Match required status from relation - if relation is optional, FK is optional
191
+ const zodType = rel.optional ? 'z.string().optional()' : 'z.string()';
192
+ i18nFields.push(` ${fkField}: ${zodType},`);
193
+ }
194
+ }
195
+ return `// Auto-generated Zod schema for ${name}
196
+ // Do not edit manually - regenerate with: npx archetype generate
197
+
198
+ import { z } from 'zod'
199
+ import { useTranslations } from 'next-intl'
200
+
201
+ type TranslationFn = ReturnType<typeof useTranslations<'validation'>>
202
+
203
+ export const ${lowerName}CreateSchema = z.object({
204
+ ${staticFields.join('\n')}
205
+ })
206
+
207
+ export const ${lowerName}UpdateSchema = ${lowerName}CreateSchema.partial()
208
+
209
+ export function ${lowerName}CreateSchemaI18n(t: TranslationFn) {
210
+ return z.object({
211
+ ${i18nFields.join('\n')}
212
+ })
213
+ }
214
+
215
+ export function ${lowerName}UpdateSchemaI18n(t: TranslationFn) {
216
+ return ${lowerName}CreateSchemaI18n(t).partial()
217
+ }
218
+
219
+ export type ${name}Create = z.input<typeof ${lowerName}CreateSchema>
220
+ export type ${name}Update = z.input<typeof ${lowerName}UpdateSchema>
221
+ `;
222
+ }
223
+ return `// Auto-generated Zod schema for ${name}
224
+ // Do not edit manually - regenerate with: npx archetype generate
225
+
226
+ import { z } from 'zod'
227
+
228
+ export const ${lowerName}CreateSchema = z.object({
229
+ ${staticFields.join('\n')}
230
+ })
231
+
232
+ export const ${lowerName}UpdateSchema = ${lowerName}CreateSchema.partial()
233
+
234
+ export type ${name}Create = z.input<typeof ${lowerName}CreateSchema>
235
+ export type ${name}Update = z.input<typeof ${lowerName}UpdateSchema>
236
+ `;
237
+ }
238
+ exports.validationGenerator = {
239
+ name: 'zod-schemas',
240
+ description: 'Generate Zod validation schemas',
241
+ generate(manifest, ctx) {
242
+ const useI18n = manifest.i18n.languages.length > 1;
243
+ return manifest.entities.map(entity => ({
244
+ path: `schemas/${entity.name.toLowerCase()}.ts`,
245
+ content: generateEntitySchema(entity, useI18n),
246
+ }));
247
+ },
248
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Next.js + Drizzle + tRPC Template
3
+ *
4
+ * Full-stack template for Next.js applications with:
5
+ * - Drizzle ORM for database access
6
+ * - tRPC for type-safe API routes
7
+ * - Zod for runtime validation
8
+ * - React Hook Form integration for forms
9
+ *
10
+ * Supports both database-backed and external API-backed entities.
11
+ * Can run in full mode (with database) or headless mode (API-only).
12
+ *
13
+ * @module templates/nextjs-drizzle-trpc
14
+ */
15
+ import type { Template } from '../../template/types';
16
+ /**
17
+ * Template definition for Next.js + Drizzle + tRPC stack
18
+ *
19
+ * Generators run in order, with some conditionally skipped:
20
+ * 1. schemaGenerator - Drizzle tables (skipped in headless mode)
21
+ * 2. authGenerator - Auth.js tables (only if auth.enabled)
22
+ * 3. validationGenerator - Zod schemas (always runs)
23
+ * 4. serviceGenerator - API client (only for external entities)
24
+ * 5. apiGenerator - tRPC routers (adapts to source type)
25
+ * 6. hooksGenerator - React hooks (always runs)
26
+ * 7. i18nGenerator - Translation files (only if i18n configured)
27
+ */
28
+ export declare const template: Template;
29
+ export default template;
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/templates/nextjs-drizzle-trpc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAUpD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,EAAE,QAgCtB,CAAA;AAED,eAAe,QAAQ,CAAA"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ /**
3
+ * Next.js + Drizzle + tRPC Template
4
+ *
5
+ * Full-stack template for Next.js applications with:
6
+ * - Drizzle ORM for database access
7
+ * - tRPC for type-safe API routes
8
+ * - Zod for runtime validation
9
+ * - React Hook Form integration for forms
10
+ *
11
+ * Supports both database-backed and external API-backed entities.
12
+ * Can run in full mode (with database) or headless mode (API-only).
13
+ *
14
+ * @module templates/nextjs-drizzle-trpc
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.template = void 0;
18
+ const schema_1 = require("./generators/schema");
19
+ const auth_1 = require("./generators/auth");
20
+ const validation_1 = require("./generators/validation");
21
+ const service_1 = require("./generators/service");
22
+ const api_1 = require("./generators/api");
23
+ const hooks_1 = require("./generators/hooks");
24
+ const crud_hooks_1 = require("./generators/crud-hooks");
25
+ const i18n_1 = require("./generators/i18n");
26
+ /**
27
+ * Template definition for Next.js + Drizzle + tRPC stack
28
+ *
29
+ * Generators run in order, with some conditionally skipped:
30
+ * 1. schemaGenerator - Drizzle tables (skipped in headless mode)
31
+ * 2. authGenerator - Auth.js tables (only if auth.enabled)
32
+ * 3. validationGenerator - Zod schemas (always runs)
33
+ * 4. serviceGenerator - API client (only for external entities)
34
+ * 5. apiGenerator - tRPC routers (adapts to source type)
35
+ * 6. hooksGenerator - React hooks (always runs)
36
+ * 7. i18nGenerator - Translation files (only if i18n configured)
37
+ */
38
+ exports.template = {
39
+ meta: {
40
+ id: 'nextjs-drizzle-trpc',
41
+ name: 'Next.js + Drizzle + tRPC',
42
+ description: 'Full-stack Next.js with Drizzle ORM, tRPC API, and React hooks. Supports headless mode with external APIs.',
43
+ framework: 'nextjs',
44
+ stack: {
45
+ database: 'drizzle',
46
+ validation: 'zod',
47
+ api: 'trpc',
48
+ ui: 'react',
49
+ },
50
+ },
51
+ defaultConfig: {
52
+ outputDir: 'generated',
53
+ importAliases: {
54
+ '@/': 'src/',
55
+ '@/server': 'src/server',
56
+ '@/lib': 'src/lib',
57
+ '@/generated': 'generated',
58
+ },
59
+ },
60
+ generators: [
61
+ schema_1.schemaGenerator, // Skipped in headless mode
62
+ auth_1.authGenerator, // Only if auth enabled
63
+ validation_1.validationGenerator, // Always runs
64
+ service_1.serviceGenerator, // Only for external entities
65
+ api_1.apiGenerator, // Adapts to source type + auth
66
+ hooks_1.hooksGenerator, // Always runs
67
+ crud_hooks_1.crudHooksGenerator, // Only if hooks enabled
68
+ i18n_1.i18nGenerator, // Only if i18n enabled
69
+ ],
70
+ };
71
+ exports.default = exports.template;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Validation Module for AI Agent Input
3
+ *
4
+ * Provides structured validation with error codes that AI agents can parse
5
+ * and use to fix their output.
6
+ *
7
+ * @module validation
8
+ */
9
+ import { ManifestJSON } from '../json/types';
10
+ /**
11
+ * Validation error with structured information for AI parsing
12
+ */
13
+ export interface ValidationError {
14
+ /** Error code for programmatic handling */
15
+ code: string;
16
+ /** JSON path to the error location */
17
+ path: string;
18
+ /** Human-readable error message */
19
+ message: string;
20
+ /** Suggestion for how to fix the error */
21
+ suggestion?: string;
22
+ }
23
+ /**
24
+ * Validation result
25
+ */
26
+ export interface ValidationResult {
27
+ /** Whether the manifest is valid */
28
+ valid: boolean;
29
+ /** Validation errors (blocking) */
30
+ errors: ValidationError[];
31
+ /** Validation warnings (non-blocking) */
32
+ warnings: ValidationError[];
33
+ }
34
+ export declare const ValidationCodes: {
35
+ readonly INVALID_ENTITY_NAME: "INVALID_ENTITY_NAME";
36
+ readonly DUPLICATE_ENTITY: "DUPLICATE_ENTITY";
37
+ readonly MISSING_ENTITY_FIELDS: "MISSING_ENTITY_FIELDS";
38
+ readonly INVALID_FIELD_TYPE: "INVALID_FIELD_TYPE";
39
+ readonly INVALID_FIELD_NAME: "INVALID_FIELD_NAME";
40
+ readonly RELATION_TARGET_NOT_FOUND: "RELATION_TARGET_NOT_FOUND";
41
+ readonly INVALID_RELATION_TYPE: "INVALID_RELATION_TYPE";
42
+ readonly DATABASE_REQUIRED: "DATABASE_REQUIRED";
43
+ readonly INVALID_DATABASE_TYPE: "INVALID_DATABASE_TYPE";
44
+ readonly SQLITE_REQUIRES_FILE: "SQLITE_REQUIRES_FILE";
45
+ readonly POSTGRES_REQUIRES_URL: "POSTGRES_REQUIRES_URL";
46
+ readonly AUTH_REQUIRED_FOR_PROTECTED: "AUTH_REQUIRED_FOR_PROTECTED";
47
+ readonly INVALID_PROVIDER: "INVALID_PROVIDER";
48
+ readonly INVALID_MODE: "INVALID_MODE";
49
+ readonly INVALID_PROTECTED_VALUE: "INVALID_PROTECTED_VALUE";
50
+ readonly EXTERNAL_SOURCE_INVALID: "EXTERNAL_SOURCE_INVALID";
51
+ };
52
+ /**
53
+ * Validate a JSON manifest
54
+ *
55
+ * @param manifest - JSON manifest to validate
56
+ * @returns Validation result with errors and warnings
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const result = validateManifest({
61
+ * entities: [{ name: 'User', fields: { email: { type: 'text' } } }],
62
+ * database: { type: 'sqlite', file: './app.db' }
63
+ * })
64
+ *
65
+ * if (!result.valid) {
66
+ * console.log('Errors:', result.errors)
67
+ * }
68
+ * ```
69
+ */
70
+ export declare function validateManifest(manifest: ManifestJSON): ValidationResult;
71
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/validation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAuC,MAAM,eAAe,CAAA;AAEjF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,KAAK,EAAE,OAAO,CAAA;IACd,mCAAmC;IACnC,MAAM,EAAE,eAAe,EAAE,CAAA;IACzB,yCAAyC;IACzC,QAAQ,EAAE,eAAe,EAAE,CAAA;CAC5B;AAGD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;CAgClB,CAAA;AA6PV;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,gBAAgB,CA2DzE"}