@drzl/cli 4.14.4 → 4.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.cjs CHANGED
@@ -43,7 +43,8 @@ __export(config_exports, {
43
43
  filterTables: () => filterTables,
44
44
  loadConfig: () => loadConfig,
45
45
  resolveConfig: () => resolveConfig,
46
- resolveTemplateDirsSync: () => resolveTemplateDirsSync
46
+ resolveTemplateDirsSync: () => resolveTemplateDirsSync,
47
+ trpcOutDir: () => trpcOutDir
47
48
  });
48
49
  module.exports = __toCommonJS(config_exports);
49
50
  var import_validation_core = require("@drzl/validation-core");
@@ -84,7 +85,7 @@ var AffixSchema = import_zod.z.object({
84
85
  }).strict();
85
86
  var ImportExtensionSchema = import_zod.z.enum(import_validation_core.IMPORT_EXTENSIONS);
86
87
  var GeneratorSchema = import_zod.z.object({
87
- kind: import_zod.z.enum(["orpc", "service", "zod", "valibot", "arktype", "typebox", "json-schema"]),
88
+ kind: import_zod.z.enum(["orpc", "trpc", "service", "zod", "valibot", "arktype", "typebox", "json-schema"]),
88
89
  /**
89
90
  * Overrides the top-level `importExtension` for this generator alone, for a project whose
90
91
  * generated directories are compiled by different tsconfigs.
@@ -155,7 +156,22 @@ var GeneratorSchema = import_zod.z.object({
155
156
  * Omitting it reproduces the output of every previous release exactly.
156
157
  */
157
158
  affix: AffixSchema.optional(),
158
- // orpc validation sharing
159
+ /**
160
+ * How the router generators reach a database handle: through the request context, rather than
161
+ * through a module-level import in the service layer.
162
+ *
163
+ * Documented on the oRPC generator since it was added and, until now, absent from this schema
164
+ * entirely. `GeneratorSchema` is not strict, so zod stripped the key without a word and the
165
+ * option did nothing at all when set from a config file. It was only ever reachable by calling
166
+ * the generator's API directly.
167
+ */
168
+ databaseInjection: import_zod.z.object({
169
+ enabled: import_zod.z.boolean().optional(),
170
+ /** The type annotation for the injected handle, e.g. `DrizzleD1Database`. */
171
+ databaseType: import_zod.z.string().optional(),
172
+ databaseTypeImport: import_zod.z.object({ name: import_zod.z.string(), from: import_zod.z.string() }).optional()
173
+ }).optional(),
174
+ // router validation sharing (orpc, trpc)
159
175
  validation: import_zod.z.object({
160
176
  useShared: import_zod.z.boolean().default(false).optional(),
161
177
  library: import_zod.z.enum(["zod", "valibot", "arktype"]).default("zod").optional(),
@@ -230,6 +246,10 @@ var ConfigSchema = import_zod.z.object({
230
246
  function defineConfig(cfg) {
231
247
  return cfg;
232
248
  }
249
+ var ROUTER_KINDS = /* @__PURE__ */ new Set(["orpc", "trpc"]);
250
+ function trpcOutDir(g, cfg) {
251
+ return g.path ?? cfg.outDir;
252
+ }
233
253
  function sharedSchemaNames(opts) {
234
254
  const resolved = (0, import_validation_core.resolveAffix)(opts);
235
255
  return import_validation_core.NAME_MODES.map((mode) => (0, import_validation_core.schemaName)(mode, import_validation_core.AFFIX_PROBE_TABLE, resolved));
@@ -241,7 +261,23 @@ function resolveConfig(cfg) {
241
261
  importExtension: g.importExtension ?? cfg.importExtension
242
262
  }));
243
263
  for (const g of generators) {
244
- if (g.kind !== "orpc") continue;
264
+ if (!ROUTER_KINDS.has(g.kind)) continue;
265
+ if (g.databaseInjection?.enabled) {
266
+ for (const s of generators.filter((x) => x.kind === "service")) {
267
+ if (!s.databaseInjection) {
268
+ s.databaseInjection = g.databaseInjection;
269
+ } else if (!s.databaseInjection.enabled) {
270
+ warnings.push(
271
+ `drzl config: the "${g.kind}" generator sets databaseInjection.enabled while the "service" generator sets it to false. The router will call Service.method(ctx.db, ...) against services that take no database parameter, so the generated project will not compile. Set both, or neither.`
272
+ );
273
+ }
274
+ if ((s.dataAccess ?? "stub") === "stub") {
275
+ warnings.push(
276
+ `drzl config: the "${g.kind}" generator sets databaseInjection.enabled, so its handlers call Service.method(ctx.db, ...). The "service" generator emits stub bodies, which take no database parameter whatever this option says, so those calls will not compile. Set dataAccess: 'drizzle' on the "service" generator, or drop databaseInjection.`
277
+ );
278
+ }
279
+ }
280
+ }
245
281
  const v = g.validation;
246
282
  if (!v?.useShared) continue;
247
283
  const library = v.library ?? "zod";
@@ -266,7 +302,7 @@ function resolveConfig(cfg) {
266
302
  const mine2 = sharedSchemaNames({ schemaSuffix: v.schemaSuffix });
267
303
  if (mine2.join(",") !== theirs.join(",")) {
268
304
  warnings.push(
269
- `drzl config: the "orpc" generator's validation.schemaSuffix (${JSON.stringify(v.schemaSuffix ?? "Schema")}) does not match the "${library}" generator's schemaSuffix (${JSON.stringify(sibling.schemaSuffix ?? "Schema")}). The router will import ${mine2.join(", ")} but the "${library}" generator exports ${theirs.join(", ")}, so the generated router will not compile. Set both to the same value, or move to "affix", which is inherited automatically.`
305
+ `drzl config: the "${g.kind}" generator's validation.schemaSuffix (${JSON.stringify(v.schemaSuffix ?? "Schema")}) does not match the "${library}" generator's schemaSuffix (${JSON.stringify(sibling.schemaSuffix ?? "Schema")}). The router will import ${mine2.join(", ")} but the "${library}" generator exports ${theirs.join(", ")}, so the generated router will not compile. Set both to the same value, or move to "affix", which is inherited automatically.`
270
306
  );
271
307
  }
272
308
  continue;
@@ -277,7 +313,7 @@ function resolveConfig(cfg) {
277
313
  });
278
314
  if (mine.join(",") !== theirs.join(",")) {
279
315
  throw new Error(
280
- `drzl config: the "orpc" generator imports shared ${library} schemas, but its validation.affix disagrees with the "${library}" generator's own naming. The router would import ${mine.join(", ")} while the "${library}" generator exports ${theirs.join(", ")}. Make them match, or drop validation.affix and let it be inherited from the "${library}" generator.`
316
+ `drzl config: the "${g.kind}" generator imports shared ${library} schemas, but its validation.affix disagrees with the "${library}" generator's own naming. The router would import ${mine.join(", ")} while the "${library}" generator exports ${theirs.join(", ")}. Make them match, or drop validation.affix and let it be inherited from the "${library}" generator.`
281
317
  );
282
318
  }
283
319
  }
@@ -335,6 +371,7 @@ function computeGeneratorOutputDirs(cfg, cwd = process.cwd()) {
335
371
  const dirs = /* @__PURE__ */ new Set();
336
372
  dirs.add(abs(cfg.outDir));
337
373
  for (const g of cfg.generators) {
374
+ if (g.kind === "trpc") dirs.add(abs(trpcOutDir(g, cfg)));
338
375
  if (g.kind === "service") dirs.add(abs(g.path ?? "src/services"));
339
376
  if (g.kind === "zod") dirs.add(abs(g.path ?? "src/validators/zod"));
340
377
  if (g.kind === "valibot") dirs.add(abs(g.path ?? "src/validators/valibot"));
@@ -351,7 +388,7 @@ function resolveTemplateDirsSync(cfg, cwd = process.cwd()) {
351
388
  );
352
389
  for (const g of cfg.generators) {
353
390
  const t = g.template;
354
- if (!t || t === "standard" || t === "minimal") continue;
391
+ if (!t || t === "standard" || t === "minimal" || t === "service") continue;
355
392
  let pkgDir = null;
356
393
  try {
357
394
  const pkg = req.resolve(`${t}/package.json`, { paths: [cwd] });
@@ -406,6 +443,7 @@ function computeWatchTargets(cfg, cwd = process.cwd()) {
406
443
  filterTables,
407
444
  loadConfig,
408
445
  resolveConfig,
409
- resolveTemplateDirsSync
446
+ resolveTemplateDirsSync,
447
+ trpcOutDir
410
448
  });
411
449
  //# sourceMappingURL=config.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import type { AffixOptions } from '@drzl/validation-core';\nimport {\n AFFIX_PROBE_TABLE,\n DEFAULT_IMPORT_EXTENSION,\n IMPORT_EXTENSIONS,\n NAME_MODES,\n resolveAffix,\n schemaName,\n validateAffix,\n} from '@drzl/validation-core';\nimport * as fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport * as path from 'node:path';\nimport { z } from 'zod';\n\nexport const NamingSchema = z\n .object({\n routerSuffix: z.string().default('Router'),\n procedureCase: z.enum(['camel', 'kebab', 'snake']).default('camel'),\n })\n .partial();\n\n/** One affix for every mode, or a per-mode map. Keys match drzl's internal mode names. */\nconst AffixValueSchema = z.union(\n [\n z.string(),\n z\n .object({\n insert: z.string().optional(),\n update: z.string().optional(),\n select: z.string().optional(),\n })\n .strict(),\n ],\n {\n error:\n 'Expected a string to use for every mode, or an object with any of the keys \"insert\", ' +\n '\"update\" and \"select\". Those keys are lowercase, matching the mode names drzl uses ' +\n 'everywhere else.',\n }\n);\n\nconst AffixPartSchema = z\n .object({\n prefix: AffixValueSchema.optional(),\n suffix: AffixValueSchema.optional(),\n })\n .strict();\n\nexport const AffixSchema = z\n .object({\n /**\n * `preserve` (default) keeps today's output: the Drizzle export name goes into the\n * identifier verbatim, so `export const users` yields `InsertusersSchema`. `pascal`\n * upper-camels it first, yielding `InsertUsersSchema`.\n */\n tableCase: z.enum(['preserve', 'pascal']).optional(),\n schema: AffixPartSchema.optional(),\n type: AffixPartSchema.optional(),\n })\n .strict();\n\n/**\n * How every relative specifier drzl invents spells its extension.\n *\n * The generated files land in the consumer's own source tree, so the consumer's\n * `moduleResolution` decides which forms resolve. `js` is the only one that resolves under\n * all of `bundler`, `node10`, `node16` and `nodenext` with no compiler flag, so it is the\n * default. See the `ImportExtension` docs in `@drzl/validation-core` for the measured grid.\n */\nexport const ImportExtensionSchema = z.enum(IMPORT_EXTENSIONS);\n\nexport const GeneratorSchema = z.object({\n kind: z.enum(['orpc', 'service', 'zod', 'valibot', 'arktype', 'typebox', 'json-schema']),\n /**\n * Overrides the top-level `importExtension` for this generator alone, for a project whose\n * generated directories are compiled by different tsconfigs.\n */\n importExtension: ImportExtensionSchema.optional(),\n template: z.string().optional(),\n includeRelations: z.boolean().optional(),\n /**\n * Type `json` and `jsonb` columns from the schema rather than leaving them wide.\n *\n * `.$type<T>()` is a compile-time cast, so no runtime-derived validator can see it and\n * `drizzle-orm/zod` types every json column as its generic `Json`. A generator can reference\n * `typeof <table>.$inferSelect['<column>']` instead, which is the declared type resolved by\n * TypeScript itself, so generics, unions and imported interfaces all work.\n *\n * Off by default because it makes the generated file import your schema module, as a\n * type-only import that disappears at build time.\n */\n // What a date column accepts. Documented on the zod generator and, until now, accepted by the\n // config parser and then dropped on the floor: the generators default it to 'input' themselves,\n // so setting it here changed nothing.\n coerceDates: z.enum(['input', 'all', 'none']).optional(),\n typedJson: z.boolean().optional(),\n // The wider form: every column's static type comes from Drizzle, not just the untyped ones.\n typedColumns: z.boolean().optional(),\n // Reproduce literal column defaults in the insert schema, so parsing fills them in.\n applyDefaults: z.boolean().optional(),\n /**\n * Emit `findDuplicate<Table>` beside the schemas: the rows in a batch that collide with an\n * earlier row on a unique constraint.\n *\n * Uniqueness is the one constraint a per-row validator structurally cannot see, since it is a\n * fact about the table rather than the row. This checks the half that needs no database.\n */\n duplicateFinder: z.boolean().optional(),\n naming: NamingSchema.optional(),\n outputHeader: z\n .object({\n enabled: z.boolean().default(true).optional(),\n text: z.string().optional(),\n })\n .optional(),\n format: z\n .object({\n enabled: z.boolean().default(true).optional(),\n engine: z.enum(['auto', 'prettier', 'biome']).default('auto').optional(),\n configPath: z.string().optional(),\n })\n .optional(),\n /**\n * Which spelling of JSON Schema the `json-schema` generator emits.\n *\n * OpenAPI 3.0 is not an older superset of the 2020-12 draft, it is a different dialect: a\n * nullable type is `nullable: true` rather than a type array, and an exclusive bound is a\n * boolean flag beside the bound rather than its own keyword. An unknown keyword is not an error\n * in JSON Schema, it is ignored, so emitting the wrong dialect produces a document that\n * validates and then accepts the values the constraints exist to reject.\n */\n target: z.enum(['draft-2020-12', 'openapi-3.1', 'openapi-3.0']).optional(),\n /** Also emit `components.ts` for the `json-schema` generator, ready for an OpenAPI document. */\n components: z.boolean().optional(),\n // service generator specific options\n path: z.string().optional(),\n dataAccess: z.enum(['stub', 'drizzle']).default('stub').optional(),\n dbImportPath: z.string().optional(),\n schemaImportPath: z.string().optional(),\n // zod/valibot/arktype generator specific options\n schemaSuffix: z.string().optional(),\n fileSuffix: z.string().optional(),\n /**\n * Prefixes, suffixes and table casing for generated identifiers (zod/valibot/arktype).\n * Omitting it reproduces the output of every previous release exactly.\n */\n affix: AffixSchema.optional(),\n // orpc validation sharing\n validation: z\n .object({\n useShared: z.boolean().default(false).optional(),\n library: z.enum(['zod', 'valibot', 'arktype']).default('zod').optional(),\n importPath: z.string().optional(),\n schemaSuffix: z.string().optional(),\n /**\n * How the validation generator named its exports. Usually left unset: the CLI copies\n * it from the sibling generator whose `kind` matches `library`.\n */\n affix: AffixSchema.optional(),\n })\n .optional(),\n // template options\n templateOptions: z.record(z.string(), z.any()).optional(),\n});\n\nexport const AnalyzerSchema = z.object({\n includeRelations: z.boolean().default(true),\n validateConstraints: z.boolean().default(true),\n includeHeuristicRelations: z.boolean().default(false),\n});\n\nexport const ConfigSchema = z\n .object({\n schema: z.string(),\n outDir: z.string().default('src/api'),\n /**\n * Which tables to generate for, matched against the database table name.\n *\n * There was no way to say this, and every generator loops over every table it finds, so\n * DRZL emitted unauthenticated CRUD over whatever shared the schema file. That is noise for\n * a migrations table and a genuine leak for an auth one: Better Auth puts `user`, `session`,\n * `account` and `verification` alongside your own tables, and `account` holds\n * `accessToken`, `refreshToken`, `idToken` and `password`.\n *\n * Deliberately name-based and explicit rather than detecting any particular library. Auth\n * table names are all renameable, so a built-in list would miss renamed tables and, worse,\n * silently skip an ordinary table that happened to be called `user`, which is usually the\n * application's main entity.\n *\n * `exclude` wins over `include`. Patterns support `*`, matching within a name.\n */\n include: z.array(z.string()).optional(),\n exclude: z.array(z.string()).optional(),\n /**\n * How every relative specifier drzl invents spells its extension, for every generator.\n * A generator may override it. Defaults to `js`, which is the only form that resolves\n * under every `moduleResolution` without a compiler flag.\n */\n importExtension: ImportExtensionSchema.default(DEFAULT_IMPORT_EXTENSION),\n analyzer: AnalyzerSchema.default({\n includeRelations: true,\n validateConstraints: true,\n includeHeuristicRelations: false,\n }),\n generators: z\n .array(GeneratorSchema)\n .min(1)\n .default([{ kind: 'orpc' } as any]),\n })\n // Reject an affix before anything is written, rather than emitting a file that cannot\n // compile. Only `affix` is inspected; the legacy flat `schemaSuffix` is left alone so\n // configs that parse today keep parsing.\n .superRefine((cfg, ctx) => {\n cfg.generators.forEach((g, i) => {\n const report = (base: (string | number)[], affix?: AffixOptions, schemaSuffix?: string) => {\n for (const issue of validateAffix(affix, schemaSuffix)) {\n ctx.addIssue({\n code: 'custom',\n path: ['generators', i, ...base, ...issue.path],\n message: issue.message,\n });\n }\n };\n report(['affix'], g.affix as AffixOptions | undefined, g.schemaSuffix);\n report(\n ['validation', 'affix'],\n g.validation?.affix as AffixOptions | undefined,\n g.validation?.schemaSuffix\n );\n });\n });\n\n// ✨ Separate input vs output types\nexport type DrzlConfigInput = z.input<typeof ConfigSchema>;\nexport type DrzlConfig = z.output<typeof ConfigSchema>;\n\nexport function defineConfig<T extends DrzlConfigInput>(cfg: T): T {\n return cfg;\n}\n\ntype GeneratorConfig = DrzlConfig['generators'][number];\n\nfunction sharedSchemaNames(opts: { affix?: AffixOptions; schemaSuffix?: string }): string[] {\n const resolved = resolveAffix(opts);\n return NAME_MODES.map((mode) => schemaName(mode, AFFIX_PROBE_TABLE, resolved));\n}\n\n/**\n * Fill in cross-generator defaults and refuse configs whose generators would disagree.\n *\n * An oRPC router that imports shared schemas has to spell the exact names the validation\n * generator exported. Both sides used to be configured independently, so they could silently\n * drift into a router that does not compile. When an oRPC generator uses shared validation\n * and exactly one sibling generator produces that library, its `affix` is copied across.\n *\n * Deliberately conservative about the pre-existing flat `schemaSuffix`: a disagreement there\n * is only reported, never repaired, because repairing it would change the bytes an existing\n * config emits.\n *\n * `importExtension` is pushed down here too. A consumer compiles the whole generated tree\n * with one tsconfig, so the setting that has to hold is the same for every generator, and\n * every call site downstream can then read it off the generator without knowing about the\n * top-level default.\n */\nexport function resolveConfig(cfg: DrzlConfig): { config: DrzlConfig; warnings: string[] } {\n const warnings: string[] = [];\n const generators: GeneratorConfig[] = cfg.generators.map((g) => ({\n ...g,\n importExtension: g.importExtension ?? cfg.importExtension,\n }));\n\n for (const g of generators) {\n if (g.kind !== 'orpc') continue;\n const v = g.validation;\n if (!v?.useShared) continue;\n\n const library = v.library ?? 'zod';\n const siblings = generators.filter((s) => s.kind === library);\n // Zero siblings means the user points at a barrel drzl does not generate; more than one\n // means there is no single source of truth. Either way, leave the config alone.\n if (siblings.length !== 1) continue;\n const sibling = siblings[0];\n\n const theirs = sharedSchemaNames({\n affix: sibling.affix as AffixOptions | undefined,\n schemaSuffix: sibling.schemaSuffix,\n });\n\n if (!v.affix) {\n if (sibling.affix) {\n // Bake the sibling's fully resolved naming in, so its own schemaSuffix fallback\n // travels with it and cannot be re-interpreted on the oRPC side.\n g.validation = {\n ...v,\n affix: resolveAffix({\n affix: sibling.affix as AffixOptions,\n schemaSuffix: sibling.schemaSuffix,\n }),\n };\n continue;\n }\n const mine = sharedSchemaNames({ schemaSuffix: v.schemaSuffix });\n if (mine.join(',') !== theirs.join(',')) {\n warnings.push(\n `drzl config: the \"orpc\" generator's validation.schemaSuffix ` +\n `(${JSON.stringify(v.schemaSuffix ?? 'Schema')}) does not match the \"${library}\" ` +\n `generator's schemaSuffix (${JSON.stringify(sibling.schemaSuffix ?? 'Schema')}). ` +\n `The router will import ${mine.join(', ')} but the \"${library}\" generator exports ` +\n `${theirs.join(', ')}, so the generated router will not compile. Set both to the ` +\n `same value, or move to \"affix\", which is inherited automatically.`\n );\n }\n continue;\n }\n\n const mine = sharedSchemaNames({\n affix: v.affix as AffixOptions,\n schemaSuffix: v.schemaSuffix,\n });\n if (mine.join(',') !== theirs.join(',')) {\n throw new Error(\n `drzl config: the \"orpc\" generator imports shared ${library} schemas, but its ` +\n `validation.affix disagrees with the \"${library}\" generator's own naming. The router ` +\n `would import ${mine.join(', ')} while the \"${library}\" generator exports ` +\n `${theirs.join(', ')}. Make them match, or drop validation.affix and let it be ` +\n `inherited from the \"${library}\" generator.`\n );\n }\n }\n\n return { config: { ...cfg, generators }, warnings };\n}\n\n/**\n * Parse, then resolve cross-generator defaults. Both `generate` and `watch` go through\n * loadConfig, so putting the resolution here is what keeps the two duplicated generator\n * dispatch blocks in cli.ts from needing the logic twice.\n */\nfunction finalize(raw: unknown): DrzlConfig {\n const { config, warnings } = resolveConfig(ConfigSchema.parse(raw));\n for (const w of warnings) console.warn(w);\n return config;\n}\n\nexport async function loadConfig(customPath?: string): Promise<DrzlConfig | null> {\n const fsp = await import('node:fs/promises');\n\n const candidates = customPath\n ? [customPath]\n : [\n 'drzl.config.ts',\n 'drzl.config.mjs',\n 'drzl.config.js',\n 'drzl.config.cjs',\n 'drzl.config.json',\n ];\n\n for (const c of candidates) {\n const p = path.resolve(process.cwd(), c);\n try {\n await fsp.access(p);\n } catch {\n continue;\n }\n\n const ext = path.extname(p).toLowerCase();\n\n // JSON: read directly\n if (ext === '.json') {\n const raw = JSON.parse(await fsp.readFile(p, 'utf8'));\n return finalize(raw);\n }\n\n // Everything else (TS/JS/MJS/CJS) -> Jiti with cache-busting\n const { createJiti } = await import('jiti');\n const stat = await fsp.stat(p);\n\n // Passing __filename is safe in CJS; fallback to cwd if not defined.\n const base =\n typeof __filename !== 'undefined' ? __filename : path.join(process.cwd(), 'index.js');\n\n const jiti = createJiti(base, {\n moduleCache: false, // re-evaluate each time\n fsCache: true, // keep transform cache\n cacheVersion: String(stat.mtimeMs), // bump on edit\n interopDefault: true,\n tryNative: false, // <-- prevent native import of .ts\n // debug: true,\n }) as any;\n\n const mod = await jiti.import(p);\n const raw = mod?.default ?? mod;\n return finalize(raw);\n }\n\n return null;\n}\n\n/** Absolute output dirs for all generators (to ignore in watcher). */\nexport function computeGeneratorOutputDirs(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const abs = (p: string) => path.resolve(cwd, p);\n const dirs = new Set<string>();\n dirs.add(abs(cfg.outDir)); // orpc\n for (const g of cfg.generators) {\n if (g.kind === 'service') dirs.add(abs(g.path ?? 'src/services'));\n if (g.kind === 'zod') dirs.add(abs(g.path ?? 'src/validators/zod'));\n if (g.kind === 'valibot') dirs.add(abs(g.path ?? 'src/validators/valibot'));\n if (g.kind === 'arktype') dirs.add(abs(g.path ?? 'src/validators/arktype'));\n if (g.kind === 'typebox') dirs.add(abs(g.path ?? 'src/validators/typebox'));\n if (g.kind === 'json-schema') dirs.add(abs(g.path ?? 'src/validators/json-schema'));\n }\n return [...dirs];\n}\n\n/** Resolve custom template directories (local path or installed package). */\nexport function resolveTemplateDirsSync(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const results: string[] = [];\n const req = createRequire(\n typeof __filename !== 'undefined' ? __filename : path.join(process.cwd(), 'index.js')\n );\n\n for (const g of cfg.generators) {\n const t = g.template;\n if (!t || t === 'standard' || t === 'minimal') continue;\n\n // Try package resolution relative to cwd\n let pkgDir: string | null = null;\n try {\n const pkg = req.resolve(`${t}/package.json`, { paths: [cwd] as any });\n pkgDir = path.dirname(pkg);\n } catch {}\n\n if (pkgDir) {\n results.push(pkgDir);\n continue;\n }\n\n // Local path-like template\n if (/[./\\\\]/.test(t)) {\n const abs = path.resolve(cwd, t);\n if (fs.existsSync(abs)) results.push(abs);\n }\n }\n\n return Array.from(new Set(results));\n}\n\n/** Build watch targets (exclude output dirs; watcher will ignore those). */\n/**\n * Narrow an analysis's tables to the ones the config asked for.\n *\n * Matching is on the database table name, anchored, with `*` as the only metacharacter. Anchored\n * matters: `user` must not also drop `users`, and a substring match would. `exclude` is applied\n * after `include`, so the safer direction wins when both name the same table.\n */\nexport function filterTables<T extends { name: string }>(\n tables: T[],\n opts: { include?: string[]; exclude?: string[] }\n): T[] {\n const toRegExp = (pattern: string) =>\n new RegExp(\n '^' +\n pattern\n .split('*')\n .map((part) => part.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('.*') +\n '$'\n );\n\n const matches = (patterns: string[], name: string) =>\n patterns.some((p) => toRegExp(p).test(name));\n\n let out = tables;\n if (opts.include?.length) out = out.filter((t) => matches(opts.include!, t.name));\n if (opts.exclude?.length) out = out.filter((t) => !matches(opts.exclude!, t.name));\n return out;\n}\n\nexport function computeWatchTargets(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const abs = (p: string) => path.resolve(cwd, p);\n const schemaAbs = abs(cfg.schema);\n // The schema's directory, not a glob under it. Chokidar removed glob support in v4 and treats\n // `<dir>/**/*.{ts,tsx,js}` as a literal path, so it watched a directory named `**` that does\n // not exist: no event ever fired and `drzl watch` did its initial build and then sat inert.\n // A directory is watched recursively by chokidar itself, and the extension filtering that the\n // glob was doing now happens on the event instead.\n const targets = new Set<string>([\n path.dirname(schemaAbs),\n abs('drzl.config.ts'),\n abs('drzl.config.js'),\n abs('drzl.config.mjs'),\n abs('drzl.config.cjs'),\n ]);\n for (const t of resolveTemplateDirsSync(cfg, cwd)) targets.add(t);\n return [...targets];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAQO;AACP,SAAoB;AACpB,yBAA8B;AAC9B,WAAsB;AACtB,iBAAkB;AAEX,IAAM,eAAe,aACzB,OAAO;AAAA,EACN,cAAc,aAAE,OAAO,EAAE,QAAQ,QAAQ;AAAA,EACzC,eAAe,aAAE,KAAK,CAAC,SAAS,SAAS,OAAO,CAAC,EAAE,QAAQ,OAAO;AACpE,CAAC,EACA,QAAQ;AAGX,IAAM,mBAAmB,aAAE;AAAA,EACzB;AAAA,IACE,aAAE,OAAO;AAAA,IACT,aACG,OAAO;AAAA,MACN,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,MAC5B,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,MAC5B,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,IAC9B,CAAC,EACA,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,IACE,OACE;AAAA,EAGJ;AACF;AAEA,IAAM,kBAAkB,aACrB,OAAO;AAAA,EACN,QAAQ,iBAAiB,SAAS;AAAA,EAClC,QAAQ,iBAAiB,SAAS;AACpC,CAAC,EACA,OAAO;AAEH,IAAM,cAAc,aACxB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMN,WAAW,aAAE,KAAK,CAAC,YAAY,QAAQ,CAAC,EAAE,SAAS;AAAA,EACnD,QAAQ,gBAAgB,SAAS;AAAA,EACjC,MAAM,gBAAgB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AiB;AAAA,EACvB,CAAC;AACD,aAAW,KAAK,wBAAwB,KAAK,GAAG,EAAG,SAAQ,IAAI,CAAC;AAChE,SAAO,CAAC,GAAG,OAAO;AACpB;","names":["mine","raw"]}
1
+ {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import type { AffixOptions } from '@drzl/validation-core';\nimport {\n AFFIX_PROBE_TABLE,\n DEFAULT_IMPORT_EXTENSION,\n IMPORT_EXTENSIONS,\n NAME_MODES,\n resolveAffix,\n schemaName,\n validateAffix,\n} from '@drzl/validation-core';\nimport * as fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport * as path from 'node:path';\nimport { z } from 'zod';\n\nexport const NamingSchema = z\n .object({\n routerSuffix: z.string().default('Router'),\n procedureCase: z.enum(['camel', 'kebab', 'snake']).default('camel'),\n })\n .partial();\n\n/** One affix for every mode, or a per-mode map. Keys match drzl's internal mode names. */\nconst AffixValueSchema = z.union(\n [\n z.string(),\n z\n .object({\n insert: z.string().optional(),\n update: z.string().optional(),\n select: z.string().optional(),\n })\n .strict(),\n ],\n {\n error:\n 'Expected a string to use for every mode, or an object with any of the keys \"insert\", ' +\n '\"update\" and \"select\". Those keys are lowercase, matching the mode names drzl uses ' +\n 'everywhere else.',\n }\n);\n\nconst AffixPartSchema = z\n .object({\n prefix: AffixValueSchema.optional(),\n suffix: AffixValueSchema.optional(),\n })\n .strict();\n\nexport const AffixSchema = z\n .object({\n /**\n * `preserve` (default) keeps today's output: the Drizzle export name goes into the\n * identifier verbatim, so `export const users` yields `InsertusersSchema`. `pascal`\n * upper-camels it first, yielding `InsertUsersSchema`.\n */\n tableCase: z.enum(['preserve', 'pascal']).optional(),\n schema: AffixPartSchema.optional(),\n type: AffixPartSchema.optional(),\n })\n .strict();\n\n/**\n * How every relative specifier drzl invents spells its extension.\n *\n * The generated files land in the consumer's own source tree, so the consumer's\n * `moduleResolution` decides which forms resolve. `js` is the only one that resolves under\n * all of `bundler`, `node10`, `node16` and `nodenext` with no compiler flag, so it is the\n * default. See the `ImportExtension` docs in `@drzl/validation-core` for the measured grid.\n */\nexport const ImportExtensionSchema = z.enum(IMPORT_EXTENSIONS);\n\nexport const GeneratorSchema = z.object({\n kind: z.enum(['orpc', 'trpc', 'service', 'zod', 'valibot', 'arktype', 'typebox', 'json-schema']),\n /**\n * Overrides the top-level `importExtension` for this generator alone, for a project whose\n * generated directories are compiled by different tsconfigs.\n */\n importExtension: ImportExtensionSchema.optional(),\n template: z.string().optional(),\n includeRelations: z.boolean().optional(),\n /**\n * Type `json` and `jsonb` columns from the schema rather than leaving them wide.\n *\n * `.$type<T>()` is a compile-time cast, so no runtime-derived validator can see it and\n * `drizzle-orm/zod` types every json column as its generic `Json`. A generator can reference\n * `typeof <table>.$inferSelect['<column>']` instead, which is the declared type resolved by\n * TypeScript itself, so generics, unions and imported interfaces all work.\n *\n * Off by default because it makes the generated file import your schema module, as a\n * type-only import that disappears at build time.\n */\n // What a date column accepts. Documented on the zod generator and, until now, accepted by the\n // config parser and then dropped on the floor: the generators default it to 'input' themselves,\n // so setting it here changed nothing.\n coerceDates: z.enum(['input', 'all', 'none']).optional(),\n typedJson: z.boolean().optional(),\n // The wider form: every column's static type comes from Drizzle, not just the untyped ones.\n typedColumns: z.boolean().optional(),\n // Reproduce literal column defaults in the insert schema, so parsing fills them in.\n applyDefaults: z.boolean().optional(),\n /**\n * Emit `findDuplicate<Table>` beside the schemas: the rows in a batch that collide with an\n * earlier row on a unique constraint.\n *\n * Uniqueness is the one constraint a per-row validator structurally cannot see, since it is a\n * fact about the table rather than the row. This checks the half that needs no database.\n */\n duplicateFinder: z.boolean().optional(),\n naming: NamingSchema.optional(),\n outputHeader: z\n .object({\n enabled: z.boolean().default(true).optional(),\n text: z.string().optional(),\n })\n .optional(),\n format: z\n .object({\n enabled: z.boolean().default(true).optional(),\n engine: z.enum(['auto', 'prettier', 'biome']).default('auto').optional(),\n configPath: z.string().optional(),\n })\n .optional(),\n /**\n * Which spelling of JSON Schema the `json-schema` generator emits.\n *\n * OpenAPI 3.0 is not an older superset of the 2020-12 draft, it is a different dialect: a\n * nullable type is `nullable: true` rather than a type array, and an exclusive bound is a\n * boolean flag beside the bound rather than its own keyword. An unknown keyword is not an error\n * in JSON Schema, it is ignored, so emitting the wrong dialect produces a document that\n * validates and then accepts the values the constraints exist to reject.\n */\n target: z.enum(['draft-2020-12', 'openapi-3.1', 'openapi-3.0']).optional(),\n /** Also emit `components.ts` for the `json-schema` generator, ready for an OpenAPI document. */\n components: z.boolean().optional(),\n // service generator specific options\n path: z.string().optional(),\n dataAccess: z.enum(['stub', 'drizzle']).default('stub').optional(),\n dbImportPath: z.string().optional(),\n schemaImportPath: z.string().optional(),\n // zod/valibot/arktype generator specific options\n schemaSuffix: z.string().optional(),\n fileSuffix: z.string().optional(),\n /**\n * Prefixes, suffixes and table casing for generated identifiers (zod/valibot/arktype).\n * Omitting it reproduces the output of every previous release exactly.\n */\n affix: AffixSchema.optional(),\n /**\n * How the router generators reach a database handle: through the request context, rather than\n * through a module-level import in the service layer.\n *\n * Documented on the oRPC generator since it was added and, until now, absent from this schema\n * entirely. `GeneratorSchema` is not strict, so zod stripped the key without a word and the\n * option did nothing at all when set from a config file. It was only ever reachable by calling\n * the generator's API directly.\n */\n databaseInjection: z\n .object({\n enabled: z.boolean().optional(),\n /** The type annotation for the injected handle, e.g. `DrizzleD1Database`. */\n databaseType: z.string().optional(),\n databaseTypeImport: z.object({ name: z.string(), from: z.string() }).optional(),\n })\n .optional(),\n // router validation sharing (orpc, trpc)\n validation: z\n .object({\n useShared: z.boolean().default(false).optional(),\n library: z.enum(['zod', 'valibot', 'arktype']).default('zod').optional(),\n importPath: z.string().optional(),\n schemaSuffix: z.string().optional(),\n /**\n * How the validation generator named its exports. Usually left unset: the CLI copies\n * it from the sibling generator whose `kind` matches `library`.\n */\n affix: AffixSchema.optional(),\n })\n .optional(),\n // template options\n templateOptions: z.record(z.string(), z.any()).optional(),\n});\n\nexport const AnalyzerSchema = z.object({\n includeRelations: z.boolean().default(true),\n validateConstraints: z.boolean().default(true),\n includeHeuristicRelations: z.boolean().default(false),\n});\n\nexport const ConfigSchema = z\n .object({\n schema: z.string(),\n outDir: z.string().default('src/api'),\n /**\n * Which tables to generate for, matched against the database table name.\n *\n * There was no way to say this, and every generator loops over every table it finds, so\n * DRZL emitted unauthenticated CRUD over whatever shared the schema file. That is noise for\n * a migrations table and a genuine leak for an auth one: Better Auth puts `user`, `session`,\n * `account` and `verification` alongside your own tables, and `account` holds\n * `accessToken`, `refreshToken`, `idToken` and `password`.\n *\n * Deliberately name-based and explicit rather than detecting any particular library. Auth\n * table names are all renameable, so a built-in list would miss renamed tables and, worse,\n * silently skip an ordinary table that happened to be called `user`, which is usually the\n * application's main entity.\n *\n * `exclude` wins over `include`. Patterns support `*`, matching within a name.\n */\n include: z.array(z.string()).optional(),\n exclude: z.array(z.string()).optional(),\n /**\n * How every relative specifier drzl invents spells its extension, for every generator.\n * A generator may override it. Defaults to `js`, which is the only form that resolves\n * under every `moduleResolution` without a compiler flag.\n */\n importExtension: ImportExtensionSchema.default(DEFAULT_IMPORT_EXTENSION),\n analyzer: AnalyzerSchema.default({\n includeRelations: true,\n validateConstraints: true,\n includeHeuristicRelations: false,\n }),\n generators: z\n .array(GeneratorSchema)\n .min(1)\n .default([{ kind: 'orpc' } as any]),\n })\n // Reject an affix before anything is written, rather than emitting a file that cannot\n // compile. Only `affix` is inspected; the legacy flat `schemaSuffix` is left alone so\n // configs that parse today keep parsing.\n .superRefine((cfg, ctx) => {\n cfg.generators.forEach((g, i) => {\n const report = (base: (string | number)[], affix?: AffixOptions, schemaSuffix?: string) => {\n for (const issue of validateAffix(affix, schemaSuffix)) {\n ctx.addIssue({\n code: 'custom',\n path: ['generators', i, ...base, ...issue.path],\n message: issue.message,\n });\n }\n };\n report(['affix'], g.affix as AffixOptions | undefined, g.schemaSuffix);\n report(\n ['validation', 'affix'],\n g.validation?.affix as AffixOptions | undefined,\n g.validation?.schemaSuffix\n );\n });\n });\n\n// ✨ Separate input vs output types\nexport type DrzlConfigInput = z.input<typeof ConfigSchema>;\nexport type DrzlConfig = z.output<typeof ConfigSchema>;\n\nexport function defineConfig<T extends DrzlConfigInput>(cfg: T): T {\n return cfg;\n}\n\ntype GeneratorConfig = DrzlConfig['generators'][number];\n\n/** The generators that emit an RPC router, and so share `outDir` and `validation`. */\nconst ROUTER_KINDS = new Set(['orpc', 'trpc']);\n\n/**\n * Where the tRPC generator writes.\n *\n * `outDir` by default, exactly like oRPC, so a config that names one router generator puts its\n * output where the top-level setting says. `path` is the escape hatch, and a config that runs\n * *both* router generators needs it: they would otherwise write two different `index.ts` files to\n * the same directory and the second would win.\n *\n * Exported because `computeGeneratorOutputDirs` has to agree with the dispatch in cli.ts about\n * this, and the watcher ignoring the wrong directory is an infinite regeneration loop.\n */\nexport function trpcOutDir(\n g: { path?: string },\n cfg: { outDir: string }\n): string {\n return g.path ?? cfg.outDir;\n}\n\nfunction sharedSchemaNames(opts: { affix?: AffixOptions; schemaSuffix?: string }): string[] {\n const resolved = resolveAffix(opts);\n return NAME_MODES.map((mode) => schemaName(mode, AFFIX_PROBE_TABLE, resolved));\n}\n\n/**\n * Fill in cross-generator defaults and refuse configs whose generators would disagree.\n *\n * An oRPC router that imports shared schemas has to spell the exact names the validation\n * generator exported. Both sides used to be configured independently, so they could silently\n * drift into a router that does not compile. When an oRPC generator uses shared validation\n * and exactly one sibling generator produces that library, its `affix` is copied across.\n *\n * Deliberately conservative about the pre-existing flat `schemaSuffix`: a disagreement there\n * is only reported, never repaired, because repairing it would change the bytes an existing\n * config emits.\n *\n * `importExtension` is pushed down here too. A consumer compiles the whole generated tree\n * with one tsconfig, so the setting that has to hold is the same for every generator, and\n * every call site downstream can then read it off the generator without knowing about the\n * top-level default.\n */\nexport function resolveConfig(cfg: DrzlConfig): { config: DrzlConfig; warnings: string[] } {\n const warnings: string[] = [];\n const generators: GeneratorConfig[] = cfg.generators.map((g) => ({\n ...g,\n importExtension: g.importExtension ?? cfg.importExtension,\n }));\n\n for (const g of generators) {\n // Both router generators import the validation generators' exports by name, so both have to\n // spell them the way the sibling generator wrote them.\n if (!ROUTER_KINDS.has(g.kind)) continue;\n\n /**\n * `databaseInjection` describes a contract between two generators, not a setting of one.\n *\n * A router in injection mode emits `Service.getById(ctx.db, id)`, and only a service\n * generated in the same mode has a `db` parameter to receive it. Declared once on the router\n * and pushed onto the service generator here, exactly as `validation.affix` is pulled the\n * other way, because the alternative is writing the same block twice and a project that\n * compiles in halves and not as a whole.\n *\n * `@drzl/generator-service` honours the flag only while emitting real Drizzle queries: its\n * stub bodies take no database whatever they are told. That combination cannot be repaired\n * from here without changing what an existing config emits, so it is reported instead.\n */\n if (g.databaseInjection?.enabled) {\n for (const s of generators.filter((x) => x.kind === 'service')) {\n if (!s.databaseInjection) {\n s.databaseInjection = g.databaseInjection;\n } else if (!s.databaseInjection.enabled) {\n warnings.push(\n `drzl config: the \"${g.kind}\" generator sets databaseInjection.enabled while the ` +\n `\"service\" generator sets it to false. The router will call ` +\n `Service.method(ctx.db, ...) against services that take no database parameter, so ` +\n `the generated project will not compile. Set both, or neither.`\n );\n }\n if ((s.dataAccess ?? 'stub') === 'stub') {\n warnings.push(\n `drzl config: the \"${g.kind}\" generator sets databaseInjection.enabled, so its ` +\n `handlers call Service.method(ctx.db, ...). The \"service\" generator emits stub ` +\n `bodies, which take no database parameter whatever this option says, so those ` +\n `calls will not compile. Set dataAccess: 'drizzle' on the \"service\" generator, or ` +\n `drop databaseInjection.`\n );\n }\n }\n }\n\n const v = g.validation;\n if (!v?.useShared) continue;\n\n const library = v.library ?? 'zod';\n const siblings = generators.filter((s) => s.kind === library);\n // Zero siblings means the user points at a barrel drzl does not generate; more than one\n // means there is no single source of truth. Either way, leave the config alone.\n if (siblings.length !== 1) continue;\n const sibling = siblings[0];\n\n const theirs = sharedSchemaNames({\n affix: sibling.affix as AffixOptions | undefined,\n schemaSuffix: sibling.schemaSuffix,\n });\n\n if (!v.affix) {\n if (sibling.affix) {\n // Bake the sibling's fully resolved naming in, so its own schemaSuffix fallback\n // travels with it and cannot be re-interpreted on the oRPC side.\n g.validation = {\n ...v,\n affix: resolveAffix({\n affix: sibling.affix as AffixOptions,\n schemaSuffix: sibling.schemaSuffix,\n }),\n };\n continue;\n }\n const mine = sharedSchemaNames({ schemaSuffix: v.schemaSuffix });\n if (mine.join(',') !== theirs.join(',')) {\n warnings.push(\n `drzl config: the \"${g.kind}\" generator's validation.schemaSuffix ` +\n `(${JSON.stringify(v.schemaSuffix ?? 'Schema')}) does not match the \"${library}\" ` +\n `generator's schemaSuffix (${JSON.stringify(sibling.schemaSuffix ?? 'Schema')}). ` +\n `The router will import ${mine.join(', ')} but the \"${library}\" generator exports ` +\n `${theirs.join(', ')}, so the generated router will not compile. Set both to the ` +\n `same value, or move to \"affix\", which is inherited automatically.`\n );\n }\n continue;\n }\n\n const mine = sharedSchemaNames({\n affix: v.affix as AffixOptions,\n schemaSuffix: v.schemaSuffix,\n });\n if (mine.join(',') !== theirs.join(',')) {\n throw new Error(\n `drzl config: the \"${g.kind}\" generator imports shared ${library} schemas, but its ` +\n `validation.affix disagrees with the \"${library}\" generator's own naming. The router ` +\n `would import ${mine.join(', ')} while the \"${library}\" generator exports ` +\n `${theirs.join(', ')}. Make them match, or drop validation.affix and let it be ` +\n `inherited from the \"${library}\" generator.`\n );\n }\n }\n\n return { config: { ...cfg, generators }, warnings };\n}\n\n/**\n * Parse, then resolve cross-generator defaults. Both `generate` and `watch` go through\n * loadConfig, so putting the resolution here is what keeps the two duplicated generator\n * dispatch blocks in cli.ts from needing the logic twice.\n */\nfunction finalize(raw: unknown): DrzlConfig {\n const { config, warnings } = resolveConfig(ConfigSchema.parse(raw));\n for (const w of warnings) console.warn(w);\n return config;\n}\n\nexport async function loadConfig(customPath?: string): Promise<DrzlConfig | null> {\n const fsp = await import('node:fs/promises');\n\n const candidates = customPath\n ? [customPath]\n : [\n 'drzl.config.ts',\n 'drzl.config.mjs',\n 'drzl.config.js',\n 'drzl.config.cjs',\n 'drzl.config.json',\n ];\n\n for (const c of candidates) {\n const p = path.resolve(process.cwd(), c);\n try {\n await fsp.access(p);\n } catch {\n continue;\n }\n\n const ext = path.extname(p).toLowerCase();\n\n // JSON: read directly\n if (ext === '.json') {\n const raw = JSON.parse(await fsp.readFile(p, 'utf8'));\n return finalize(raw);\n }\n\n // Everything else (TS/JS/MJS/CJS) -> Jiti with cache-busting\n const { createJiti } = await import('jiti');\n const stat = await fsp.stat(p);\n\n // Passing __filename is safe in CJS; fallback to cwd if not defined.\n const base =\n typeof __filename !== 'undefined' ? __filename : path.join(process.cwd(), 'index.js');\n\n const jiti = createJiti(base, {\n moduleCache: false, // re-evaluate each time\n fsCache: true, // keep transform cache\n cacheVersion: String(stat.mtimeMs), // bump on edit\n interopDefault: true,\n tryNative: false, // <-- prevent native import of .ts\n // debug: true,\n }) as any;\n\n const mod = await jiti.import(p);\n const raw = mod?.default ?? mod;\n return finalize(raw);\n }\n\n return null;\n}\n\n/** Absolute output dirs for all generators (to ignore in watcher). */\nexport function computeGeneratorOutputDirs(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const abs = (p: string) => path.resolve(cwd, p);\n const dirs = new Set<string>();\n dirs.add(abs(cfg.outDir)); // orpc\n for (const g of cfg.generators) {\n if (g.kind === 'trpc') dirs.add(abs(trpcOutDir(g, cfg)));\n if (g.kind === 'service') dirs.add(abs(g.path ?? 'src/services'));\n if (g.kind === 'zod') dirs.add(abs(g.path ?? 'src/validators/zod'));\n if (g.kind === 'valibot') dirs.add(abs(g.path ?? 'src/validators/valibot'));\n if (g.kind === 'arktype') dirs.add(abs(g.path ?? 'src/validators/arktype'));\n if (g.kind === 'typebox') dirs.add(abs(g.path ?? 'src/validators/typebox'));\n if (g.kind === 'json-schema') dirs.add(abs(g.path ?? 'src/validators/json-schema'));\n }\n return [...dirs];\n}\n\n/** Resolve custom template directories (local path or installed package). */\nexport function resolveTemplateDirsSync(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const results: string[] = [];\n const req = createRequire(\n typeof __filename !== 'undefined' ? __filename : path.join(process.cwd(), 'index.js')\n );\n\n for (const g of cfg.generators) {\n const t = g.template;\n // Built-in template names, not packages. `service` is the tRPC generator's, and without it\n // here every run would try to resolve a package called \"service\" and then watch a directory\n // of that name, neither of which exists.\n if (!t || t === 'standard' || t === 'minimal' || t === 'service') continue;\n\n // Try package resolution relative to cwd\n let pkgDir: string | null = null;\n try {\n const pkg = req.resolve(`${t}/package.json`, { paths: [cwd] as any });\n pkgDir = path.dirname(pkg);\n } catch {}\n\n if (pkgDir) {\n results.push(pkgDir);\n continue;\n }\n\n // Local path-like template\n if (/[./\\\\]/.test(t)) {\n const abs = path.resolve(cwd, t);\n if (fs.existsSync(abs)) results.push(abs);\n }\n }\n\n return Array.from(new Set(results));\n}\n\n/** Build watch targets (exclude output dirs; watcher will ignore those). */\n/**\n * Narrow an analysis's tables to the ones the config asked for.\n *\n * Matching is on the database table name, anchored, with `*` as the only metacharacter. Anchored\n * matters: `user` must not also drop `users`, and a substring match would. `exclude` is applied\n * after `include`, so the safer direction wins when both name the same table.\n */\nexport function filterTables<T extends { name: string }>(\n tables: T[],\n opts: { include?: string[]; exclude?: string[] }\n): T[] {\n const toRegExp = (pattern: string) =>\n new RegExp(\n '^' +\n pattern\n .split('*')\n .map((part) => part.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('.*') +\n '$'\n );\n\n const matches = (patterns: string[], name: string) =>\n patterns.some((p) => toRegExp(p).test(name));\n\n let out = tables;\n if (opts.include?.length) out = out.filter((t) => matches(opts.include!, t.name));\n if (opts.exclude?.length) out = out.filter((t) => !matches(opts.exclude!, t.name));\n return out;\n}\n\nexport function computeWatchTargets(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const abs = (p: string) => path.resolve(cwd, p);\n const schemaAbs = abs(cfg.schema);\n // The schema's directory, not a glob under it. Chokidar removed glob support in v4 and treats\n // `<dir>/**/*.{ts,tsx,js}` as a literal path, so it watched a directory named `**` that does\n // not exist: no event ever fired and `drzl watch` did its initial build and then sat inert.\n // A directory is watched recursively by chokidar itself, and the extension filtering that the\n // glob was doing now happens on the event instead.\n const targets = new Set<string>([\n path.dirname(schemaAbs),\n abs('drzl.config.ts'),\n abs('drzl.config.js'),\n abs('drzl.config.mjs'),\n abs('drzl.config.cjs'),\n ]);\n for (const t of resolveTemplateDirsSync(cfg, cwd)) targets.add(t);\n return [...targets];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAQO;AACP,SAAoB;AACpB,yBAA8B;AAC9B,WAAsB;AACtB,iBAAkB;AAEX,IAAM,eAAe,aACzB,OAAO;AAAA,EACN,cAAc,aAAE,OAAO,EAAE,QAAQ,QAAQ;AAAA,EACzC,eAAe,aAAE,KAAK,CAAC,SAAS,SAAS,OAAO,CAAC,EAAE,QAAQ,OAAO;AACpE,CAAC,EACA,QAAQ;AAGX,IAAM,mBAAmB,aAAE;AAAA,EACzB;AAAA,IACE,aAAE,OAAO;AAAA,IACT,aACG,OAAO;AAAA,MACN,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,MAC5B,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,MAC5B,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,IAC9B,CAAC,EACA,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,IACE,OACE;AAAA,EAGJ;AACF;AAEA,IAAM,kBAAkB,aACrB,OAAO;AAAA,EACN,QAAQ,iBAAiB,SAAS;AAAA,EAClC,QAAQ,iBAAiB,SAAS;AACpC,CAAC,EACA,OAAO;AAEH,IAAM,cAAc,aACxB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMN,WAAW,aAAE,KAAK,CAAC,YAAY,QAAQ,CA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,6 +54,7 @@ declare const ImportExtensionSchema: z.ZodEnum<{
54
54
  declare const GeneratorSchema: z.ZodObject<{
55
55
  kind: z.ZodEnum<{
56
56
  orpc: "orpc";
57
+ trpc: "trpc";
57
58
  service: "service";
58
59
  zod: "zod";
59
60
  valibot: "valibot";
@@ -69,9 +70,9 @@ declare const GeneratorSchema: z.ZodObject<{
69
70
  template: z.ZodOptional<z.ZodString>;
70
71
  includeRelations: z.ZodOptional<z.ZodBoolean>;
71
72
  coerceDates: z.ZodOptional<z.ZodEnum<{
72
- all: "all";
73
73
  none: "none";
74
74
  input: "input";
75
+ all: "all";
75
76
  }>>;
76
77
  typedJson: z.ZodOptional<z.ZodBoolean>;
77
78
  typedColumns: z.ZodOptional<z.ZodBoolean>;
@@ -143,6 +144,14 @@ declare const GeneratorSchema: z.ZodObject<{
143
144
  }, z.core.$strict>]>>;
144
145
  }, z.core.$strict>>;
145
146
  }, z.core.$strict>>;
147
+ databaseInjection: z.ZodOptional<z.ZodObject<{
148
+ enabled: z.ZodOptional<z.ZodBoolean>;
149
+ databaseType: z.ZodOptional<z.ZodString>;
150
+ databaseTypeImport: z.ZodOptional<z.ZodObject<{
151
+ name: z.ZodString;
152
+ from: z.ZodString;
153
+ }, z.core.$strip>>;
154
+ }, z.core.$strip>>;
146
155
  validation: z.ZodOptional<z.ZodObject<{
147
156
  useShared: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
148
157
  library: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
@@ -208,6 +217,7 @@ declare const ConfigSchema: z.ZodObject<{
208
217
  generators: z.ZodDefault<z.ZodArray<z.ZodObject<{
209
218
  kind: z.ZodEnum<{
210
219
  orpc: "orpc";
220
+ trpc: "trpc";
211
221
  service: "service";
212
222
  zod: "zod";
213
223
  valibot: "valibot";
@@ -223,9 +233,9 @@ declare const ConfigSchema: z.ZodObject<{
223
233
  template: z.ZodOptional<z.ZodString>;
224
234
  includeRelations: z.ZodOptional<z.ZodBoolean>;
225
235
  coerceDates: z.ZodOptional<z.ZodEnum<{
226
- all: "all";
227
236
  none: "none";
228
237
  input: "input";
238
+ all: "all";
229
239
  }>>;
230
240
  typedJson: z.ZodOptional<z.ZodBoolean>;
231
241
  typedColumns: z.ZodOptional<z.ZodBoolean>;
@@ -297,6 +307,14 @@ declare const ConfigSchema: z.ZodObject<{
297
307
  }, z.core.$strict>]>>;
298
308
  }, z.core.$strict>>;
299
309
  }, z.core.$strict>>;
310
+ databaseInjection: z.ZodOptional<z.ZodObject<{
311
+ enabled: z.ZodOptional<z.ZodBoolean>;
312
+ databaseType: z.ZodOptional<z.ZodString>;
313
+ databaseTypeImport: z.ZodOptional<z.ZodObject<{
314
+ name: z.ZodString;
315
+ from: z.ZodString;
316
+ }, z.core.$strip>>;
317
+ }, z.core.$strip>>;
300
318
  validation: z.ZodOptional<z.ZodObject<{
301
319
  useShared: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
302
320
  library: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
@@ -343,6 +361,22 @@ declare const ConfigSchema: z.ZodObject<{
343
361
  type DrzlConfigInput = z.input<typeof ConfigSchema>;
344
362
  type DrzlConfig = z.output<typeof ConfigSchema>;
345
363
  declare function defineConfig<T extends DrzlConfigInput>(cfg: T): T;
364
+ /**
365
+ * Where the tRPC generator writes.
366
+ *
367
+ * `outDir` by default, exactly like oRPC, so a config that names one router generator puts its
368
+ * output where the top-level setting says. `path` is the escape hatch, and a config that runs
369
+ * *both* router generators needs it: they would otherwise write two different `index.ts` files to
370
+ * the same directory and the second would win.
371
+ *
372
+ * Exported because `computeGeneratorOutputDirs` has to agree with the dispatch in cli.ts about
373
+ * this, and the watcher ignoring the wrong directory is an infinite regeneration loop.
374
+ */
375
+ declare function trpcOutDir(g: {
376
+ path?: string;
377
+ }, cfg: {
378
+ outDir: string;
379
+ }): string;
346
380
  /**
347
381
  * Fill in cross-generator defaults and refuse configs whose generators would disagree.
348
382
  *
@@ -385,4 +419,4 @@ declare function filterTables<T extends {
385
419
  }): T[];
386
420
  declare function computeWatchTargets(cfg: DrzlConfig, cwd?: string): string[];
387
421
 
388
- export { AffixSchema, AnalyzerSchema, ConfigSchema, type DrzlConfig, type DrzlConfigInput, GeneratorSchema, ImportExtensionSchema, NamingSchema, computeGeneratorOutputDirs, computeWatchTargets, defineConfig, filterTables, loadConfig, resolveConfig, resolveTemplateDirsSync };
422
+ export { AffixSchema, AnalyzerSchema, ConfigSchema, type DrzlConfig, type DrzlConfigInput, GeneratorSchema, ImportExtensionSchema, NamingSchema, computeGeneratorOutputDirs, computeWatchTargets, defineConfig, filterTables, loadConfig, resolveConfig, resolveTemplateDirsSync, trpcOutDir };
package/dist/config.d.ts CHANGED
@@ -54,6 +54,7 @@ declare const ImportExtensionSchema: z.ZodEnum<{
54
54
  declare const GeneratorSchema: z.ZodObject<{
55
55
  kind: z.ZodEnum<{
56
56
  orpc: "orpc";
57
+ trpc: "trpc";
57
58
  service: "service";
58
59
  zod: "zod";
59
60
  valibot: "valibot";
@@ -69,9 +70,9 @@ declare const GeneratorSchema: z.ZodObject<{
69
70
  template: z.ZodOptional<z.ZodString>;
70
71
  includeRelations: z.ZodOptional<z.ZodBoolean>;
71
72
  coerceDates: z.ZodOptional<z.ZodEnum<{
72
- all: "all";
73
73
  none: "none";
74
74
  input: "input";
75
+ all: "all";
75
76
  }>>;
76
77
  typedJson: z.ZodOptional<z.ZodBoolean>;
77
78
  typedColumns: z.ZodOptional<z.ZodBoolean>;
@@ -143,6 +144,14 @@ declare const GeneratorSchema: z.ZodObject<{
143
144
  }, z.core.$strict>]>>;
144
145
  }, z.core.$strict>>;
145
146
  }, z.core.$strict>>;
147
+ databaseInjection: z.ZodOptional<z.ZodObject<{
148
+ enabled: z.ZodOptional<z.ZodBoolean>;
149
+ databaseType: z.ZodOptional<z.ZodString>;
150
+ databaseTypeImport: z.ZodOptional<z.ZodObject<{
151
+ name: z.ZodString;
152
+ from: z.ZodString;
153
+ }, z.core.$strip>>;
154
+ }, z.core.$strip>>;
146
155
  validation: z.ZodOptional<z.ZodObject<{
147
156
  useShared: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
148
157
  library: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
@@ -208,6 +217,7 @@ declare const ConfigSchema: z.ZodObject<{
208
217
  generators: z.ZodDefault<z.ZodArray<z.ZodObject<{
209
218
  kind: z.ZodEnum<{
210
219
  orpc: "orpc";
220
+ trpc: "trpc";
211
221
  service: "service";
212
222
  zod: "zod";
213
223
  valibot: "valibot";
@@ -223,9 +233,9 @@ declare const ConfigSchema: z.ZodObject<{
223
233
  template: z.ZodOptional<z.ZodString>;
224
234
  includeRelations: z.ZodOptional<z.ZodBoolean>;
225
235
  coerceDates: z.ZodOptional<z.ZodEnum<{
226
- all: "all";
227
236
  none: "none";
228
237
  input: "input";
238
+ all: "all";
229
239
  }>>;
230
240
  typedJson: z.ZodOptional<z.ZodBoolean>;
231
241
  typedColumns: z.ZodOptional<z.ZodBoolean>;
@@ -297,6 +307,14 @@ declare const ConfigSchema: z.ZodObject<{
297
307
  }, z.core.$strict>]>>;
298
308
  }, z.core.$strict>>;
299
309
  }, z.core.$strict>>;
310
+ databaseInjection: z.ZodOptional<z.ZodObject<{
311
+ enabled: z.ZodOptional<z.ZodBoolean>;
312
+ databaseType: z.ZodOptional<z.ZodString>;
313
+ databaseTypeImport: z.ZodOptional<z.ZodObject<{
314
+ name: z.ZodString;
315
+ from: z.ZodString;
316
+ }, z.core.$strip>>;
317
+ }, z.core.$strip>>;
300
318
  validation: z.ZodOptional<z.ZodObject<{
301
319
  useShared: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
302
320
  library: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
@@ -343,6 +361,22 @@ declare const ConfigSchema: z.ZodObject<{
343
361
  type DrzlConfigInput = z.input<typeof ConfigSchema>;
344
362
  type DrzlConfig = z.output<typeof ConfigSchema>;
345
363
  declare function defineConfig<T extends DrzlConfigInput>(cfg: T): T;
364
+ /**
365
+ * Where the tRPC generator writes.
366
+ *
367
+ * `outDir` by default, exactly like oRPC, so a config that names one router generator puts its
368
+ * output where the top-level setting says. `path` is the escape hatch, and a config that runs
369
+ * *both* router generators needs it: they would otherwise write two different `index.ts` files to
370
+ * the same directory and the second would win.
371
+ *
372
+ * Exported because `computeGeneratorOutputDirs` has to agree with the dispatch in cli.ts about
373
+ * this, and the watcher ignoring the wrong directory is an infinite regeneration loop.
374
+ */
375
+ declare function trpcOutDir(g: {
376
+ path?: string;
377
+ }, cfg: {
378
+ outDir: string;
379
+ }): string;
346
380
  /**
347
381
  * Fill in cross-generator defaults and refuse configs whose generators would disagree.
348
382
  *
@@ -385,4 +419,4 @@ declare function filterTables<T extends {
385
419
  }): T[];
386
420
  declare function computeWatchTargets(cfg: DrzlConfig, cwd?: string): string[];
387
421
 
388
- export { AffixSchema, AnalyzerSchema, ConfigSchema, type DrzlConfig, type DrzlConfigInput, GeneratorSchema, ImportExtensionSchema, NamingSchema, computeGeneratorOutputDirs, computeWatchTargets, defineConfig, filterTables, loadConfig, resolveConfig, resolveTemplateDirsSync };
422
+ export { AffixSchema, AnalyzerSchema, ConfigSchema, type DrzlConfig, type DrzlConfigInput, GeneratorSchema, ImportExtensionSchema, NamingSchema, computeGeneratorOutputDirs, computeWatchTargets, defineConfig, filterTables, loadConfig, resolveConfig, resolveTemplateDirsSync, trpcOutDir };
package/dist/config.js CHANGED
@@ -11,8 +11,9 @@ import {
11
11
  filterTables,
12
12
  loadConfig,
13
13
  resolveConfig,
14
- resolveTemplateDirsSync
15
- } from "./chunk-HGD5CBM5.js";
14
+ resolveTemplateDirsSync,
15
+ trpcOutDir
16
+ } from "./chunk-FZNDWYBB.js";
16
17
  export {
17
18
  AffixSchema,
18
19
  AnalyzerSchema,
@@ -26,6 +27,7 @@ export {
26
27
  filterTables,
27
28
  loadConfig,
28
29
  resolveConfig,
29
- resolveTemplateDirsSync
30
+ resolveTemplateDirsSync,
31
+ trpcOutDir
30
32
  };
31
33
  //# sourceMappingURL=config.js.map