@drzl/cli 4.19.0 → 4.21.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
@@ -33,6 +33,7 @@ var config_exports = {};
33
33
  __export(config_exports, {
34
34
  AffixSchema: () => AffixSchema,
35
35
  AnalyzerSchema: () => AnalyzerSchema,
36
+ ColumnRulesSchema: () => ColumnRulesSchema,
36
37
  ConfigSchema: () => ConfigSchema,
37
38
  GeneratorSchema: () => GeneratorSchema,
38
39
  ImportExtensionSchema: () => ImportExtensionSchema,
@@ -44,6 +45,7 @@ __export(config_exports, {
44
45
  loadConfig: () => loadConfig,
45
46
  resolveConfig: () => resolveConfig,
46
47
  resolveTemplateDirsSync: () => resolveTemplateDirsSync,
48
+ tableFilterWarnings: () => tableFilterWarnings,
47
49
  trpcOutDir: () => trpcOutDir
48
50
  });
49
51
  module.exports = __toCommonJS(config_exports);
@@ -52,6 +54,41 @@ var fs = __toESM(require("fs"), 1);
52
54
  var import_node_module = require("module");
53
55
  var path = __toESM(require("path"), 1);
54
56
  var import_zod = require("zod");
57
+
58
+ // src/patterns.ts
59
+ function patternToRegExp(pattern) {
60
+ return new RegExp(
61
+ "^" + pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*") + "$"
62
+ );
63
+ }
64
+ function matchesAny(patterns, name) {
65
+ return patterns.some((p) => patternToRegExp(p).test(name));
66
+ }
67
+ var DEFAULT_SCHEMA_ALIAS = "public";
68
+ function tableAliases(table) {
69
+ return [table.name, `${table.schema ?? DEFAULT_SCHEMA_ALIAS}.${table.name}`];
70
+ }
71
+ function matchesTable(patterns, table) {
72
+ return tableAliases(table).some((alias) => matchesAny(patterns, alias));
73
+ }
74
+ function addressableName(table) {
75
+ return `${table.schema ?? DEFAULT_SCHEMA_ALIAS}.${table.name}`;
76
+ }
77
+ function ambiguousPatternWarnings(patterns, tables, option) {
78
+ const out = [];
79
+ for (const pattern of patterns) {
80
+ if (pattern.includes(".")) continue;
81
+ const matched = tables.filter((t) => matchesTable([pattern], t));
82
+ const schemas = new Set(matched.map((t) => t.schema ?? DEFAULT_SCHEMA_ALIAS));
83
+ if (schemas.size < 2) continue;
84
+ out.push(
85
+ `drzl config: ${option} pattern ${JSON.stringify(pattern)} matches tables in more than one schema, and every one of them is affected: ${matched.map(addressableName).sort().join(", ")}. Write the schema to mean one of them, for example ${JSON.stringify(addressableName(matched[0]))}.`
86
+ );
87
+ }
88
+ return out;
89
+ }
90
+
91
+ // src/config.ts
55
92
  var NamingSchema = import_zod.z.object({
56
93
  routerSuffix: import_zod.z.string().default("Router"),
57
94
  procedureCase: import_zod.z.enum(["camel", "kebab", "snake"]).default("camel")
@@ -131,6 +168,36 @@ var GeneratorSchema = import_zod.z.object({
131
168
  * fact about the table rather than the row. This checks the half that needs no database.
132
169
  */
133
170
  duplicateFinder: import_zod.z.boolean().optional(),
171
+ /**
172
+ * zod only. Attach the facts the analyzer knows and a zod schema cannot state, as `.meta()` on
173
+ * every field and every table schema: the declared SQL type, the primary key, the unique
174
+ * constraints, whether the database generates or defaults the value, and the CHECK constraints,
175
+ * including the ones DRZL declined to enforce.
176
+ *
177
+ * `z.toJSONSchema` copies these through, so they are also how an OpenAPI document built from the
178
+ * emitted schemas gets the declared width back: DRZL enforces one as a `.refine()`, and
179
+ * `toJSONSchema` drops every refinement in silence.
180
+ *
181
+ * `true` is the shorthand for `{ enabled: true }`. `{ description: true }` additionally writes a
182
+ * `description`, which is what an OpenAPI viewer renders to a human.
183
+ */
184
+ meta: import_zod.z.union([
185
+ import_zod.z.boolean(),
186
+ import_zod.z.object({ enabled: import_zod.z.boolean().optional(), description: import_zod.z.boolean().optional() }).strict()
187
+ ]).optional(),
188
+ /**
189
+ * TypeBox only. Give every emitted schema a `~standard` key, so it can be handed to a tRPC or
190
+ * oRPC route.
191
+ *
192
+ * TypeBox is the one validator DRZL emits that carries none of its own: measured on 0.34.52, a
193
+ * bare `Type.Object()` has no `~standard` and the package exports nothing matching
194
+ * `/standard/i`. zod, valibot and arktype all put one on every schema they build, so the option
195
+ * does nothing for them and is not passed through.
196
+ *
197
+ * The property is non-enumerable, so the schema stays a TypeBox schema in every respect that was
198
+ * already observable, including the JSON Schema `JSON.stringify` produces.
199
+ */
200
+ standardSchema: import_zod.z.boolean().optional(),
134
201
  /**
135
202
  * Emit `NestedInsert<Table>` and `NestedSelect<Table>` beside the flat schemas: the table plus
136
203
  * one key per relation, so `{ ...user, posts: [...] }` can be validated whole.
@@ -147,6 +214,29 @@ var GeneratorSchema = import_zod.z.object({
147
214
  * it is also what terminates a cycle: `users -> posts -> users` stops here.
148
215
  */
149
216
  nestedDepth: import_zod.z.number().int().optional(),
217
+ /**
218
+ * Give every primary key, and every foreign key pointing at one, a nominal type, so a
219
+ * `users.id` cannot be passed where a `posts.id` is wanted.
220
+ *
221
+ * Type level only, in all five validators. Measured on zod 4.4.3, `.brand()` returns the same
222
+ * schema object it was called on and the parsed value of `1` is `1`, so nothing about what a
223
+ * schema accepts changes and no bytes are added to the bundle. TypeBox has no brand of its own
224
+ * and gets a `TUnsafe` cast, which leaves the schema object identical.
225
+ *
226
+ * Off by default: it changes the inferred type of every consumer of the select schemas, which
227
+ * is the point, but it is a change to existing call sites rather than an addition.
228
+ *
229
+ * `true` is the shorthand for `{ enabled: true }`. `{ foreignKeys: false }` brands only the
230
+ * keys themselves, and `{ aliases: false }` stops the `export type UsersId = ...` lines.
231
+ */
232
+ branded: import_zod.z.union([
233
+ import_zod.z.boolean(),
234
+ import_zod.z.object({
235
+ enabled: import_zod.z.boolean().optional(),
236
+ foreignKeys: import_zod.z.boolean().optional(),
237
+ aliases: import_zod.z.boolean().optional()
238
+ }).strict()
239
+ ]).optional(),
150
240
  naming: NamingSchema.optional(),
151
241
  outputHeader: import_zod.z.object({
152
242
  enabled: import_zod.z.boolean().default(true).optional(),
@@ -241,6 +331,10 @@ var GeneratorSchema = import_zod.z.object({
241
331
  // template options
242
332
  templateOptions: import_zod.z.record(import_zod.z.string(), import_zod.z.any()).optional()
243
333
  });
334
+ var ColumnRulesSchema = import_zod.z.object({
335
+ omit: import_zod.z.array(import_zod.z.string()).optional(),
336
+ pick: import_zod.z.array(import_zod.z.string()).optional()
337
+ }).strict();
244
338
  var AnalyzerSchema = import_zod.z.object({
245
339
  includeRelations: import_zod.z.boolean().default(true),
246
340
  validateConstraints: import_zod.z.boolean().default(true),
@@ -267,6 +361,37 @@ var ConfigSchema = import_zod.z.object({
267
361
  */
268
362
  include: import_zod.z.array(import_zod.z.string()).optional(),
269
363
  exclude: import_zod.z.array(import_zod.z.string()).optional(),
364
+ /**
365
+ * Which columns of those tables to generate for, keyed by table.
366
+ *
367
+ * `include`/`exclude` is all or nothing per table, and the column that should not be in a
368
+ * generated schema is usually sitting in a table you do want: `passwordHash` on `users`, an
369
+ * internal note beside the public fields, a `tenantId` the server sets from the session and a
370
+ * request body must not carry. Editing the emitted file is not an answer, because the next
371
+ * `drzl generate` overwrites it.
372
+ *
373
+ * ```ts
374
+ * columns: {
375
+ * users: { omit: ['passwordHash'] },
376
+ * 'app_*': { omit: ['deleted_at'] },
377
+ * }
378
+ * ```
379
+ *
380
+ * The key is a table pattern in the same language `include`/`exclude` uses: the database table
381
+ * name, anchored, with `*` as the only metacharacter. Column patterns are the same language
382
+ * again. Every matching entry applies, in the order written; within one entry `pick` narrows
383
+ * first and `omit` then removes, so `omit` wins, exactly as `exclude` wins over `include`.
384
+ *
385
+ * Applies to every mode and every generator at once, because it narrows the analysis rather
386
+ * than any one generator's output. A column cannot be kept in `select` and dropped from
387
+ * `insert`: see the docs for why that form was not taken on.
388
+ *
389
+ * A pattern that matches nothing is an error rather than a no-op, because a typo in `omit`
390
+ * that silently does nothing leaves the column exactly where it was while reading like a fix.
391
+ * Dropping a primary key column is an error too; dropping a NOT NULL column with no default is
392
+ * a warning.
393
+ */
394
+ columns: import_zod.z.record(import_zod.z.string(), ColumnRulesSchema).optional(),
270
395
  /**
271
396
  * How every relative specifier drzl invents spells its extension, for every generator.
272
397
  * A generator may override it. Defaults to `js`, which is the only form that resolves
@@ -463,15 +588,17 @@ function resolveTemplateDirsSync(cfg, cwd = process.cwd()) {
463
588
  return Array.from(new Set(results));
464
589
  }
465
590
  function filterTables(tables, opts) {
466
- const toRegExp = (pattern) => new RegExp(
467
- "^" + pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*") + "$"
468
- );
469
- const matches = (patterns, name) => patterns.some((p) => toRegExp(p).test(name));
470
591
  let out = tables;
471
- if (opts.include?.length) out = out.filter((t) => matches(opts.include, t.name));
472
- if (opts.exclude?.length) out = out.filter((t) => !matches(opts.exclude, t.name));
592
+ if (opts.include?.length) out = out.filter((t) => matchesTable(opts.include, t));
593
+ if (opts.exclude?.length) out = out.filter((t) => !matchesTable(opts.exclude, t));
473
594
  return out;
474
595
  }
596
+ function tableFilterWarnings(tables, opts) {
597
+ return [
598
+ ...ambiguousPatternWarnings(opts.include ?? [], tables, "include"),
599
+ ...ambiguousPatternWarnings(opts.exclude ?? [], tables, "exclude")
600
+ ];
601
+ }
475
602
  function computeWatchTargets(cfg, cwd = process.cwd()) {
476
603
  const abs = (p) => path.resolve(cwd, p);
477
604
  const schemaAbs = abs(cfg.schema);
@@ -489,6 +616,7 @@ function computeWatchTargets(cfg, cwd = process.cwd()) {
489
616
  0 && (module.exports = {
490
617
  AffixSchema,
491
618
  AnalyzerSchema,
619
+ ColumnRulesSchema,
492
620
  ConfigSchema,
493
621
  GeneratorSchema,
494
622
  ImportExtensionSchema,
@@ -500,6 +628,7 @@ function computeWatchTargets(cfg, cwd = process.cwd()) {
500
628
  loadConfig,
501
629
  resolveConfig,
502
630
  resolveTemplateDirsSync,
631
+ tableFilterWarnings,
503
632
  trpcOutDir
504
633
  });
505
634
  //# 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([\n 'orpc',\n 'trpc',\n 'service',\n 'zod',\n 'valibot',\n 'arktype',\n 'typebox',\n 'effect',\n 'json-schema',\n ]),\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 /**\n * Emit `NestedInsert<Table>` and `NestedSelect<Table>` beside the flat schemas: the table plus\n * one key per relation, so `{ ...user, posts: [...] }` can be validated whole.\n *\n * Nothing in the Drizzle validator ecosystem describes that payload, and `db.insert` drops the\n * relation key silently rather than refusing it, so the children are never written and nothing\n * says so.\n */\n nestedSchemas: z.boolean().optional(),\n /**\n * How many levels of children a nested schema describes. Defaults to 1, capped at 3.\n *\n * Nesting is expanded inline rather than by reference, so this multiplies the emitted size, and\n * it is also what terminates a cycle: `users -> posts -> users` stops here.\n */\n nestedDepth: z.number().int().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 /**\n * Also emit the whole OpenAPI document for the `json-schema` generator: paths, verbs, request and\n * response bodies per table, with `components.schemas` embedded so the file stands alone.\n *\n * `true` is the short form. The object form carries the three things a Drizzle schema genuinely\n * cannot say: what the API is called, where it is served, and which status code that particular\n * server answers a request that fails its schema with.\n */\n document: z\n .union([\n z.boolean(),\n z\n .object({\n enabled: z.boolean().optional(),\n /** `ts` (default) writes a module, `json` the file OpenAPI tooling reads directly. */\n format: z.enum(['ts', 'json', 'both']).optional(),\n info: z\n .object({\n title: z.string().optional(),\n version: z.string().optional(),\n description: z.string().optional(),\n })\n .strict()\n .optional(),\n /**\n * Omitted by default, which the specification reads as a single server at `/`: the\n * document describes whatever is serving it. A placeholder host would be a fabrication\n * that tooling then follows.\n */\n servers: z\n .array(z.object({ url: z.string(), description: z.string().optional() }).strict())\n .optional(),\n /** 400 by default. 422 is the other defensible reading; exactly one is emitted. */\n validationStatus: z.union([z.literal(400), z.literal(422)]).optional(),\n })\n .strict(),\n ])\n .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(g: { path?: string }, cfg: { outDir: string }): 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 === 'effect') dirs.add(abs(g.path ?? 'src/validators/effect'));\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;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AC,EAAE,KAAK,IAAI,CAAC;AAE7C,MAAI,MAAM;AACV,MAAI,KAAK,SAAS,OAAQ,OAAM,IAAI,OAAO,CAAC,MAAM,QAAQ,KAAK,SAAU,EAAE,IAAI,CAAC;AAChF,MAAI,KAAK,SAAS,OAAQ,OAAM,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAU,EAAE,IAAI,CAAC;AACjF,SAAO;AACT;AAEO,SAAS,oBAAoB,KAAiB,MAAM,QAAQ,IAAI,GAAa;AAClF,QAAM,MAAM,CAAC,MAAmB,aAAQ,KAAK,CAAC;AAC9C,QAAM,YAAY,IAAI,IAAI,MAAM;AAMhC,QAAM,UAAU,oBAAI,IAAY;AAAA,IACzB,aAAQ,SAAS;AAAA,IACtB,IAAI,gBAAgB;AAAA,IACpB,IAAI,gBAAgB;AAAA,IACpB,IAAI,iBAAiB;AAAA,IACrB,IAAI,iBAAiB;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","../src/patterns.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';\nimport { ambiguousPatternWarnings, matchesTable } from './patterns.js';\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([\n 'orpc',\n 'trpc',\n 'service',\n 'zod',\n 'valibot',\n 'arktype',\n 'typebox',\n 'effect',\n 'json-schema',\n ]),\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 /**\n * zod only. Attach the facts the analyzer knows and a zod schema cannot state, as `.meta()` on\n * every field and every table schema: the declared SQL type, the primary key, the unique\n * constraints, whether the database generates or defaults the value, and the CHECK constraints,\n * including the ones DRZL declined to enforce.\n *\n * `z.toJSONSchema` copies these through, so they are also how an OpenAPI document built from the\n * emitted schemas gets the declared width back: DRZL enforces one as a `.refine()`, and\n * `toJSONSchema` drops every refinement in silence.\n *\n * `true` is the shorthand for `{ enabled: true }`. `{ description: true }` additionally writes a\n * `description`, which is what an OpenAPI viewer renders to a human.\n */\n meta: z\n .union([\n z.boolean(),\n z.object({ enabled: z.boolean().optional(), description: z.boolean().optional() }).strict(),\n ])\n .optional(),\n /**\n * TypeBox only. Give every emitted schema a `~standard` key, so it can be handed to a tRPC or\n * oRPC route.\n *\n * TypeBox is the one validator DRZL emits that carries none of its own: measured on 0.34.52, a\n * bare `Type.Object()` has no `~standard` and the package exports nothing matching\n * `/standard/i`. zod, valibot and arktype all put one on every schema they build, so the option\n * does nothing for them and is not passed through.\n *\n * The property is non-enumerable, so the schema stays a TypeBox schema in every respect that was\n * already observable, including the JSON Schema `JSON.stringify` produces.\n */\n standardSchema: z.boolean().optional(),\n /**\n * Emit `NestedInsert<Table>` and `NestedSelect<Table>` beside the flat schemas: the table plus\n * one key per relation, so `{ ...user, posts: [...] }` can be validated whole.\n *\n * Nothing in the Drizzle validator ecosystem describes that payload, and `db.insert` drops the\n * relation key silently rather than refusing it, so the children are never written and nothing\n * says so.\n */\n nestedSchemas: z.boolean().optional(),\n /**\n * How many levels of children a nested schema describes. Defaults to 1, capped at 3.\n *\n * Nesting is expanded inline rather than by reference, so this multiplies the emitted size, and\n * it is also what terminates a cycle: `users -> posts -> users` stops here.\n */\n nestedDepth: z.number().int().optional(),\n /**\n * Give every primary key, and every foreign key pointing at one, a nominal type, so a\n * `users.id` cannot be passed where a `posts.id` is wanted.\n *\n * Type level only, in all five validators. Measured on zod 4.4.3, `.brand()` returns the same\n * schema object it was called on and the parsed value of `1` is `1`, so nothing about what a\n * schema accepts changes and no bytes are added to the bundle. TypeBox has no brand of its own\n * and gets a `TUnsafe` cast, which leaves the schema object identical.\n *\n * Off by default: it changes the inferred type of every consumer of the select schemas, which\n * is the point, but it is a change to existing call sites rather than an addition.\n *\n * `true` is the shorthand for `{ enabled: true }`. `{ foreignKeys: false }` brands only the\n * keys themselves, and `{ aliases: false }` stops the `export type UsersId = ...` lines.\n */\n branded: z\n .union([\n z.boolean(),\n z\n .object({\n enabled: z.boolean().optional(),\n foreignKeys: z.boolean().optional(),\n aliases: z.boolean().optional(),\n })\n .strict(),\n ])\n .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 /**\n * Also emit the whole OpenAPI document for the `json-schema` generator: paths, verbs, request and\n * response bodies per table, with `components.schemas` embedded so the file stands alone.\n *\n * `true` is the short form. The object form carries the three things a Drizzle schema genuinely\n * cannot say: what the API is called, where it is served, and which status code that particular\n * server answers a request that fails its schema with.\n */\n document: z\n .union([\n z.boolean(),\n z\n .object({\n enabled: z.boolean().optional(),\n /** `ts` (default) writes a module, `json` the file OpenAPI tooling reads directly. */\n format: z.enum(['ts', 'json', 'both']).optional(),\n info: z\n .object({\n title: z.string().optional(),\n version: z.string().optional(),\n description: z.string().optional(),\n })\n .strict()\n .optional(),\n /**\n * Omitted by default, which the specification reads as a single server at `/`: the\n * document describes whatever is serving it. A placeholder host would be a fabrication\n * that tooling then follows.\n */\n servers: z\n .array(z.object({ url: z.string(), description: z.string().optional() }).strict())\n .optional(),\n /** 400 by default. 422 is the other defensible reading; exactly one is emitted. */\n validationStatus: z.union([z.literal(400), z.literal(422)]).optional(),\n })\n .strict(),\n ])\n .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\n/**\n * One table's column rules. Strict, so `ommit` is refused by the parser rather than dropped.\n *\n * The whole option exists to remove a column, and a key zod strips in silence is a config that\n * looks like it removed one and did not. `GeneratorSchema` is deliberately not strict and has\n * already cost this repo two options that parsed and then did nothing.\n */\nexport const ColumnRulesSchema = z\n .object({\n omit: z.array(z.string()).optional(),\n pick: z.array(z.string()).optional(),\n })\n .strict();\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 * Which columns of those tables to generate for, keyed by table.\n *\n * `include`/`exclude` is all or nothing per table, and the column that should not be in a\n * generated schema is usually sitting in a table you do want: `passwordHash` on `users`, an\n * internal note beside the public fields, a `tenantId` the server sets from the session and a\n * request body must not carry. Editing the emitted file is not an answer, because the next\n * `drzl generate` overwrites it.\n *\n * ```ts\n * columns: {\n * users: { omit: ['passwordHash'] },\n * 'app_*': { omit: ['deleted_at'] },\n * }\n * ```\n *\n * The key is a table pattern in the same language `include`/`exclude` uses: the database table\n * name, anchored, with `*` as the only metacharacter. Column patterns are the same language\n * again. Every matching entry applies, in the order written; within one entry `pick` narrows\n * first and `omit` then removes, so `omit` wins, exactly as `exclude` wins over `include`.\n *\n * Applies to every mode and every generator at once, because it narrows the analysis rather\n * than any one generator's output. A column cannot be kept in `select` and dropped from\n * `insert`: see the docs for why that form was not taken on.\n *\n * A pattern that matches nothing is an error rather than a no-op, because a typo in `omit`\n * that silently does nothing leaves the column exactly where it was while reading like a fix.\n * Dropping a primary key column is an error too; dropping a NOT NULL column with no default is\n * a warning.\n */\n columns: z.record(z.string(), ColumnRulesSchema).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(g: { path?: string }, cfg: { outDir: string }): 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 === 'effect') dirs.add(abs(g.path ?? 'src/validators/effect'));\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 *\n * A table also answers to its schema-qualified name, so `reporting.users` addresses one of two\n * same-named tables and `reporting.*` addresses a whole schema. See `tableAliases`.\n */\nexport function filterTables<T extends { name: string; schema?: string }>(\n tables: T[],\n opts: { include?: string[]; exclude?: string[] }\n): T[] {\n let out = tables;\n if (opts.include?.length) out = out.filter((t) => matchesTable(opts.include!, t));\n if (opts.exclude?.length) out = out.filter((t) => !matchesTable(opts.exclude!, t));\n return out;\n}\n\n/**\n * What to warn about the table filter, before it is applied.\n *\n * Separate from `filterTables` so that returns a plain array, as every caller and every test\n * already expects it to.\n */\nexport function tableFilterWarnings(\n tables: readonly { name: string; schema?: string }[],\n opts: { include?: string[]; exclude?: string[] }\n): string[] {\n return [\n ...ambiguousPatternWarnings(opts.include ?? [], tables, 'include'),\n ...ambiguousPatternWarnings(opts.exclude ?? [], tables, 'exclude'),\n ];\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","/**\n * The one name-matching language every filter in a DRZL config speaks.\n *\n * Anchored, with `*` as the only metacharacter. Anchored is the whole point: `user` must not also\n * match `users`, and a substring match would, which for the table filter means silently dropping\n * the application's main entity while trying to drop an auth table.\n *\n * Shared rather than reimplemented. `include`/`exclude` and the per-table `columns` filter both\n * take patterns, and a reader who has learned one has learned the other only while there is one\n * implementation of \"learned\". Two copies of an anchored glob agree on the easy cases and drift on\n * exactly the corners that made this explicit in the first place.\n */\nexport function patternToRegExp(pattern: string): RegExp {\n return new RegExp(\n '^' +\n pattern\n .split('*')\n .map((part) => part.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('.*') +\n '$'\n );\n}\n\n/** Whether any of `patterns` matches `name` outright. */\nexport function matchesAny(patterns: string[], name: string): boolean {\n return patterns.some((p) => patternToRegExp(p).test(name));\n}\n\n/** The least a filter needs to know about a table. */\nexport interface NamedTable {\n name: string;\n schema?: string;\n}\n\n/** How the default SQL schema is spelled in a config, since a table in it carries no name for it. */\nexport const DEFAULT_SCHEMA_ALIAS = 'public';\n\n/**\n * Every name a table answers to in a config pattern.\n *\n * A table states one name and lives in one schema, and Postgres lets two schemas hold the same\n * name, so `users` alone stopped identifying a table the moment `pgSchema` entered the picture.\n * Each table therefore answers to two:\n *\n * - its bare database name, unchanged and listed first, so every pattern that matched before\n * matches now. That is not a compatibility gesture: `exclude: ['users']` written before a\n * `reporting` schema existed means \"the users tables\", and quietly narrowing it to one of them\n * would start generating an endpoint the config had already turned off.\n * - its qualified name, `reporting.users`, which is what addresses exactly one of them.\n *\n * A table with no schema answers to `public.users` rather than to a bare-schema form, because\n * Drizzle refuses `pgSchema('public')` outright: there is no other way to write a table in the\n * default schema, so there is no other name for it to have. That makes `public.` an alias this\n * file defines rather than something read back off the analysis, which is why it is only ever\n * offered to a table that names no schema.\n *\n * Order is the order they are tried, and the bare name being first is what keeps a table whose own\n * name contains a dot reachable by a pattern that spells it.\n */\nexport function tableAliases(table: NamedTable): string[] {\n return [table.name, `${table.schema ?? DEFAULT_SCHEMA_ALIAS}.${table.name}`];\n}\n\n/** Whether any of `patterns` matches the table under any of the names it answers to. */\nexport function matchesTable(patterns: string[], table: NamedTable): boolean {\n return tableAliases(table).some((alias) => matchesAny(patterns, alias));\n}\n\n/**\n * How a message names one table.\n *\n * Qualified only where the table names a schema, so every message in a project that uses none is\n * word for word what it was, and a project that uses several never has two of them reading alike.\n */\nexport function displayTableName(table: NamedTable): string {\n return table.schema ? `${table.schema}.${table.name}` : table.name;\n}\n\n/**\n * The spelling that addresses exactly this table and no other, `public.users` included.\n *\n * For a message whose job is to hand the reader something to paste into a config. Elsewhere\n * `displayTableName` is the one to use: spelling `public.` at someone who has only ever had one\n * schema names a concept their schema file does not contain.\n */\nexport function addressableName(table: NamedTable): string {\n return `${table.schema ?? DEFAULT_SCHEMA_ALIAS}.${table.name}`;\n}\n\n/** Whether an analysis has any table outside the default schema at all. */\nexport function hasNamedSchemas(tables: readonly NamedTable[]): boolean {\n return tables.some((t) => t.schema);\n}\n\n/**\n * Patterns that reach more than one SQL schema, which is nearly always a pattern written before\n * the second schema existed.\n *\n * Reported rather than refused. Matching every schema is what an unqualified pattern has always\n * done and is the reading that keeps an existing `exclude` doing its job, so it cannot be an\n * error. It is still worth a sentence, because the two tables are different tables: `columns: {\n * users: { pick: ['id', 'email'] } }` narrows both, and the table that has no `email` silently\n * loses every column that is not `id`, while the typo check stays quiet because the pattern did\n * match a column somewhere.\n *\n * Silent on a schema that uses no `pgSchema`, which is the shape of nearly every one: with one\n * schema in play no pattern can span two.\n */\nexport function ambiguousPatternWarnings(\n patterns: string[],\n tables: readonly NamedTable[],\n option: string\n): string[] {\n const out: string[] = [];\n for (const pattern of patterns) {\n // A pattern that already names a schema said which one it meant.\n if (pattern.includes('.')) continue;\n const matched = tables.filter((t) => matchesTable([pattern], t));\n const schemas = new Set(matched.map((t) => t.schema ?? DEFAULT_SCHEMA_ALIAS));\n if (schemas.size < 2) continue;\n out.push(\n `drzl config: ${option} pattern ${JSON.stringify(pattern)} matches tables in more than one ` +\n `schema, and every one of them is affected: ` +\n `${matched.map(addressableName).sort().join(', ')}. ` +\n `Write the schema to mean one of them, for example ${JSON.stringify(addressableName(matched[0]))}.`\n );\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;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;;;ACDX,SAAS,gBAAgB,SAAyB;AACvD,SAAO,IAAI;AAAA,IACT,MACE,QACG,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,QAAQ,uBAAuB,MAAM,CAAC,EACzD,KAAK,IAAI,IACZ;AAAA,EACJ;AACF;AAGO,SAAS,WAAW,UAAoB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AiB;AAAA,IACrB,IAAI,iBAAiB;AAAA,EACvB,CAAC;AACD,aAAW,KAAK,wBAAwB,KAAK,GAAG,EAAG,SAAQ,IAAI,CAAC;AAChE,SAAO,CAAC,GAAG,OAAO;AACpB;","names":["mine","raw"]}
package/dist/config.d.cts CHANGED
@@ -71,16 +71,26 @@ declare const GeneratorSchema: z.ZodObject<{
71
71
  template: z.ZodOptional<z.ZodString>;
72
72
  includeRelations: z.ZodOptional<z.ZodBoolean>;
73
73
  coerceDates: z.ZodOptional<z.ZodEnum<{
74
- none: "none";
75
- input: "input";
76
74
  all: "all";
75
+ input: "input";
76
+ none: "none";
77
77
  }>>;
78
78
  typedJson: z.ZodOptional<z.ZodBoolean>;
79
79
  typedColumns: z.ZodOptional<z.ZodBoolean>;
80
80
  applyDefaults: z.ZodOptional<z.ZodBoolean>;
81
81
  duplicateFinder: z.ZodOptional<z.ZodBoolean>;
82
+ meta: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
83
+ enabled: z.ZodOptional<z.ZodBoolean>;
84
+ description: z.ZodOptional<z.ZodBoolean>;
85
+ }, z.core.$strict>]>>;
86
+ standardSchema: z.ZodOptional<z.ZodBoolean>;
82
87
  nestedSchemas: z.ZodOptional<z.ZodBoolean>;
83
88
  nestedDepth: z.ZodOptional<z.ZodNumber>;
89
+ branded: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
90
+ enabled: z.ZodOptional<z.ZodBoolean>;
91
+ foreignKeys: z.ZodOptional<z.ZodBoolean>;
92
+ aliases: z.ZodOptional<z.ZodBoolean>;
93
+ }, z.core.$strict>]>>;
84
94
  naming: z.ZodOptional<z.ZodObject<{
85
95
  routerSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>;
86
96
  procedureCase: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
@@ -215,6 +225,17 @@ declare const GeneratorSchema: z.ZodObject<{
215
225
  }, z.core.$strip>>;
216
226
  templateOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
217
227
  }, z.core.$strip>;
228
+ /**
229
+ * One table's column rules. Strict, so `ommit` is refused by the parser rather than dropped.
230
+ *
231
+ * The whole option exists to remove a column, and a key zod strips in silence is a config that
232
+ * looks like it removed one and did not. `GeneratorSchema` is deliberately not strict and has
233
+ * already cost this repo two options that parsed and then did nothing.
234
+ */
235
+ declare const ColumnRulesSchema: z.ZodObject<{
236
+ omit: z.ZodOptional<z.ZodArray<z.ZodString>>;
237
+ pick: z.ZodOptional<z.ZodArray<z.ZodString>>;
238
+ }, z.core.$strict>;
218
239
  declare const AnalyzerSchema: z.ZodObject<{
219
240
  includeRelations: z.ZodDefault<z.ZodBoolean>;
220
241
  validateConstraints: z.ZodDefault<z.ZodBoolean>;
@@ -225,6 +246,10 @@ declare const ConfigSchema: z.ZodObject<{
225
246
  outDir: z.ZodDefault<z.ZodString>;
226
247
  include: z.ZodOptional<z.ZodArray<z.ZodString>>;
227
248
  exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
249
+ columns: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
250
+ omit: z.ZodOptional<z.ZodArray<z.ZodString>>;
251
+ pick: z.ZodOptional<z.ZodArray<z.ZodString>>;
252
+ }, z.core.$strict>>>;
228
253
  importExtension: z.ZodDefault<z.ZodEnum<{
229
254
  js: "js";
230
255
  none: "none";
@@ -255,16 +280,26 @@ declare const ConfigSchema: z.ZodObject<{
255
280
  template: z.ZodOptional<z.ZodString>;
256
281
  includeRelations: z.ZodOptional<z.ZodBoolean>;
257
282
  coerceDates: z.ZodOptional<z.ZodEnum<{
258
- none: "none";
259
- input: "input";
260
283
  all: "all";
284
+ input: "input";
285
+ none: "none";
261
286
  }>>;
262
287
  typedJson: z.ZodOptional<z.ZodBoolean>;
263
288
  typedColumns: z.ZodOptional<z.ZodBoolean>;
264
289
  applyDefaults: z.ZodOptional<z.ZodBoolean>;
265
290
  duplicateFinder: z.ZodOptional<z.ZodBoolean>;
291
+ meta: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
292
+ enabled: z.ZodOptional<z.ZodBoolean>;
293
+ description: z.ZodOptional<z.ZodBoolean>;
294
+ }, z.core.$strict>]>>;
295
+ standardSchema: z.ZodOptional<z.ZodBoolean>;
266
296
  nestedSchemas: z.ZodOptional<z.ZodBoolean>;
267
297
  nestedDepth: z.ZodOptional<z.ZodNumber>;
298
+ branded: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
299
+ enabled: z.ZodOptional<z.ZodBoolean>;
300
+ foreignKeys: z.ZodOptional<z.ZodBoolean>;
301
+ aliases: z.ZodOptional<z.ZodBoolean>;
302
+ }, z.core.$strict>]>>;
268
303
  naming: z.ZodOptional<z.ZodObject<{
269
304
  routerSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>;
270
305
  procedureCase: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
@@ -452,13 +487,30 @@ declare function resolveTemplateDirsSync(cfg: DrzlConfig, cwd?: string): string[
452
487
  * Matching is on the database table name, anchored, with `*` as the only metacharacter. Anchored
453
488
  * matters: `user` must not also drop `users`, and a substring match would. `exclude` is applied
454
489
  * after `include`, so the safer direction wins when both name the same table.
490
+ *
491
+ * A table also answers to its schema-qualified name, so `reporting.users` addresses one of two
492
+ * same-named tables and `reporting.*` addresses a whole schema. See `tableAliases`.
455
493
  */
456
494
  declare function filterTables<T extends {
457
495
  name: string;
496
+ schema?: string;
458
497
  }>(tables: T[], opts: {
459
498
  include?: string[];
460
499
  exclude?: string[];
461
500
  }): T[];
501
+ /**
502
+ * What to warn about the table filter, before it is applied.
503
+ *
504
+ * Separate from `filterTables` so that returns a plain array, as every caller and every test
505
+ * already expects it to.
506
+ */
507
+ declare function tableFilterWarnings(tables: readonly {
508
+ name: string;
509
+ schema?: string;
510
+ }[], opts: {
511
+ include?: string[];
512
+ exclude?: string[];
513
+ }): string[];
462
514
  declare function computeWatchTargets(cfg: DrzlConfig, cwd?: string): string[];
463
515
 
464
- export { AffixSchema, AnalyzerSchema, ConfigSchema, type DrzlConfig, type DrzlConfigInput, GeneratorSchema, ImportExtensionSchema, NamingSchema, computeGeneratorOutputDirs, computeWatchTargets, defineConfig, filterTables, loadConfig, resolveConfig, resolveTemplateDirsSync, trpcOutDir };
516
+ export { AffixSchema, AnalyzerSchema, ColumnRulesSchema, ConfigSchema, type DrzlConfig, type DrzlConfigInput, GeneratorSchema, ImportExtensionSchema, NamingSchema, computeGeneratorOutputDirs, computeWatchTargets, defineConfig, filterTables, loadConfig, resolveConfig, resolveTemplateDirsSync, tableFilterWarnings, trpcOutDir };