@drzl/cli 4.21.0 → 4.23.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.d.ts CHANGED
@@ -1,5 +1,56 @@
1
1
  import { z } from 'zod';
2
2
 
3
+ /**
4
+ * drizzle-kit interop: read the schema path from `drizzle.config.ts`, so a drizzle-kit user
5
+ * does not have to state it a second time in `drzl.config.ts`.
6
+ *
7
+ * Everything here mirrors drizzle-kit's measured behavior, read from the published dist of
8
+ * drizzle-kit 0.31.10 rather than from its docs or from memory:
9
+ *
10
+ * - `Config.schema` is `string | string[]` and entries may be glob patterns (`index.d.mts`).
11
+ * - The CLI's default config candidates are `drizzle.config.ts`, then `.js`, then `.json`,
12
+ * in that order and nothing else (`drizzleConfigFromFile` in `bin.cjs`); a custom path can
13
+ * be anything its `--config` flag can name, which `drizzleKit: '<path>'` mirrors.
14
+ * - `prepareFilenames` (bin.cjs) expands each entry with glob.sync, expands a directory
15
+ * match one level with readdir rather than recursively, unions the results, and hard-errors
16
+ * when nothing matched. It also computes the list of code extensions (.ts .js .cjs .mjs
17
+ * .mts .cts) into a variable it never reads, and then requires every match; DRZL applies
18
+ * that filter for real, which is strictly friendlier than crashing on a README.md sitting
19
+ * in the schema directory.
20
+ * - `defineConfig` is the identity function (`index.mjs`), so evaluating the config module
21
+ * yields the plain object and no drizzle-kit installation is needed to read it.
22
+ *
23
+ * Globs are expanded with `node:fs.globSync`, present since Node 22.0 and quiet on the CLI's
24
+ * `engines` floor (measured: `*`, `**`, `{a,b}` and literal paths all behave; no
25
+ * ExperimentalWarning on stderr on 22.22). No new dependency, and the config itself is loaded
26
+ * through the same jiti path as `drzl.config.ts` (`importFreshConfigModule`), so the two
27
+ * config files cannot drift onto different loaders.
28
+ */
29
+
30
+ /**
31
+ * Where the schema will be read from, decided once and handed to both `generate` and `watch`,
32
+ * so the two commands cannot resolve differently.
33
+ */
34
+ interface ResolvedSchemaSource {
35
+ source: 'drzl' | 'drizzle-kit';
36
+ /**
37
+ * What `SchemaAnalyzer` is constructed with: the drzl config's `schema` string verbatim, or
38
+ * the expanded, sorted, absolute file list from the drizzle-kit config.
39
+ */
40
+ schema: string | string[];
41
+ /**
42
+ * Absolute directories that must be watched for schema edits. For a glob this is its static
43
+ * base, so a file created later that matches the pattern still raises an event; a missing
44
+ * entry here is the infinite-blindness half of the watch-loop rules.
45
+ */
46
+ watchDirs: string[];
47
+ /** Absolute path of the drizzle-kit config consulted, when source is 'drizzle-kit'. */
48
+ drizzleKitConfigPath?: string;
49
+ /** The dialect that config declares, verbatim, for the post-analysis cross-check. */
50
+ drizzleKitDialect?: string;
51
+ warnings: string[];
52
+ }
53
+
3
54
  declare const NamingSchema: z.ZodObject<{
4
55
  routerSuffix: z.ZodOptional<z.ZodDefault<z.ZodString>>;
5
56
  procedureCase: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
@@ -51,10 +102,44 @@ declare const ImportExtensionSchema: z.ZodEnum<{
51
102
  none: "none";
52
103
  ts: "ts";
53
104
  }>;
105
+ /**
106
+ * Every generator DRZL can run, named once.
107
+ *
108
+ * Extracted from `GeneratorSchema.kind` rather than restated beside it, because three surfaces
109
+ * have to agree about this list and two of them used to spell it themselves: the config parser,
110
+ * the JSON Schema editors validate a `drzl.config.json` against, and the CLI's `--only`. A kind
111
+ * added here is accepted by all three at once, which is the property `--only` needs to be able to
112
+ * refuse an unknown value by name instead of matching nothing in silence.
113
+ */
114
+ declare const GeneratorKindSchema: z.ZodEnum<{
115
+ orpc: "orpc";
116
+ trpc: "trpc";
117
+ hono: "hono";
118
+ express: "express";
119
+ fastify: "fastify";
120
+ nestjs: "nestjs";
121
+ graphql: "graphql";
122
+ service: "service";
123
+ zod: "zod";
124
+ valibot: "valibot";
125
+ arktype: "arktype";
126
+ typebox: "typebox";
127
+ effect: "effect";
128
+ "json-schema": "json-schema";
129
+ }>;
130
+ /** One generator kind, as the config spells it. */
131
+ type GeneratorKind = z.infer<typeof GeneratorKindSchema>;
132
+ /** The kinds in declaration order, for a message that has to list them. */
133
+ declare const GENERATOR_KINDS: readonly GeneratorKind[];
54
134
  declare const GeneratorSchema: z.ZodObject<{
55
135
  kind: z.ZodEnum<{
56
136
  orpc: "orpc";
57
137
  trpc: "trpc";
138
+ hono: "hono";
139
+ express: "express";
140
+ fastify: "fastify";
141
+ nestjs: "nestjs";
142
+ graphql: "graphql";
58
143
  service: "service";
59
144
  zod: "zod";
60
145
  valibot: "valibot";
@@ -63,6 +148,10 @@ declare const GeneratorSchema: z.ZodObject<{
63
148
  effect: "effect";
64
149
  "json-schema": "json-schema";
65
150
  }>;
151
+ validator: z.ZodOptional<z.ZodEnum<{
152
+ zod: "zod";
153
+ standard: "standard";
154
+ }>>;
66
155
  importExtension: z.ZodOptional<z.ZodEnum<{
67
156
  js: "js";
68
157
  none: "none";
@@ -70,15 +159,20 @@ declare const GeneratorSchema: z.ZodObject<{
70
159
  }>>;
71
160
  template: z.ZodOptional<z.ZodString>;
72
161
  includeRelations: z.ZodOptional<z.ZodBoolean>;
162
+ sharedEnums: z.ZodOptional<z.ZodBoolean>;
73
163
  coerceDates: z.ZodOptional<z.ZodEnum<{
74
- all: "all";
75
164
  input: "input";
76
165
  none: "none";
166
+ all: "all";
77
167
  }>>;
78
168
  typedJson: z.ZodOptional<z.ZodBoolean>;
79
169
  typedColumns: z.ZodOptional<z.ZodBoolean>;
80
170
  applyDefaults: z.ZodOptional<z.ZodBoolean>;
81
171
  duplicateFinder: z.ZodOptional<z.ZodBoolean>;
172
+ constraints: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
173
+ enabled: z.ZodOptional<z.ZodBoolean>;
174
+ errorMap: z.ZodOptional<z.ZodBoolean>;
175
+ }, z.core.$strict>]>>;
82
176
  meta: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
83
177
  enabled: z.ZodOptional<z.ZodBoolean>;
84
178
  description: z.ZodOptional<z.ZodBoolean>;
@@ -242,7 +336,8 @@ declare const AnalyzerSchema: z.ZodObject<{
242
336
  includeHeuristicRelations: z.ZodDefault<z.ZodBoolean>;
243
337
  }, z.core.$strip>;
244
338
  declare const ConfigSchema: z.ZodObject<{
245
- schema: z.ZodString;
339
+ schema: z.ZodOptional<z.ZodString>;
340
+ drizzleKit: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
246
341
  outDir: z.ZodDefault<z.ZodString>;
247
342
  include: z.ZodOptional<z.ZodArray<z.ZodString>>;
248
343
  exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -264,6 +359,11 @@ declare const ConfigSchema: z.ZodObject<{
264
359
  kind: z.ZodEnum<{
265
360
  orpc: "orpc";
266
361
  trpc: "trpc";
362
+ hono: "hono";
363
+ express: "express";
364
+ fastify: "fastify";
365
+ nestjs: "nestjs";
366
+ graphql: "graphql";
267
367
  service: "service";
268
368
  zod: "zod";
269
369
  valibot: "valibot";
@@ -272,6 +372,10 @@ declare const ConfigSchema: z.ZodObject<{
272
372
  effect: "effect";
273
373
  "json-schema": "json-schema";
274
374
  }>;
375
+ validator: z.ZodOptional<z.ZodEnum<{
376
+ zod: "zod";
377
+ standard: "standard";
378
+ }>>;
275
379
  importExtension: z.ZodOptional<z.ZodEnum<{
276
380
  js: "js";
277
381
  none: "none";
@@ -279,15 +383,20 @@ declare const ConfigSchema: z.ZodObject<{
279
383
  }>>;
280
384
  template: z.ZodOptional<z.ZodString>;
281
385
  includeRelations: z.ZodOptional<z.ZodBoolean>;
386
+ sharedEnums: z.ZodOptional<z.ZodBoolean>;
282
387
  coerceDates: z.ZodOptional<z.ZodEnum<{
283
- all: "all";
284
388
  input: "input";
285
389
  none: "none";
390
+ all: "all";
286
391
  }>>;
287
392
  typedJson: z.ZodOptional<z.ZodBoolean>;
288
393
  typedColumns: z.ZodOptional<z.ZodBoolean>;
289
394
  applyDefaults: z.ZodOptional<z.ZodBoolean>;
290
395
  duplicateFinder: z.ZodOptional<z.ZodBoolean>;
396
+ constraints: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
397
+ enabled: z.ZodOptional<z.ZodBoolean>;
398
+ errorMap: z.ZodOptional<z.ZodBoolean>;
399
+ }, z.core.$strict>]>>;
291
400
  meta: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
292
401
  enabled: z.ZodOptional<z.ZodBoolean>;
293
402
  description: z.ZodOptional<z.ZodBoolean>;
@@ -438,6 +547,34 @@ declare const ConfigSchema: z.ZodObject<{
438
547
  type DrzlConfigInput = z.input<typeof ConfigSchema>;
439
548
  type DrzlConfig = z.output<typeof ConfigSchema>;
440
549
  declare function defineConfig<T extends DrzlConfigInput>(cfg: T): T;
550
+ /**
551
+ * Every filename `drzl` will load a config from, in the order it tries them.
552
+ *
553
+ * One list because there were two. `computeWatchTargets` carried its own copy of four of these
554
+ * names, and the copy was missing `drzl.config.json`: a JSON config loaded fine, and then
555
+ * `drzl watch` never noticed an edit to it, because nothing was watching the file. The watcher's
556
+ * test spelled the same four names a third time, so it agreed with the bug.
557
+ */
558
+ declare const CONFIG_FILE_NAMES: readonly ["drzl.config.ts", "drzl.config.mjs", "drzl.config.js", "drzl.config.cjs", "drzl.config.json"];
559
+ /** Where the published schema answers from, and what `$schema` in a config should point at. */
560
+ declare const CONFIG_SCHEMA_ID = "https://use-drzl.github.io/drzl/drzl.config.schema.json";
561
+ /**
562
+ * `ConfigSchema` as a JSON Schema, for editors pointed at a `drzl.config.json`.
563
+ *
564
+ * Two things about `z.toJSONSchema` decide the arguments here, both measured rather than assumed:
565
+ *
566
+ * - `io` defaults to `'output'`, which marks every key carrying a `.default()` as `required`.
567
+ * That is four of the nine top-level keys, so the default would produce a schema that flags
568
+ * all 32 configs in the docs and every minimal config a reader writes. `'input'` describes
569
+ * what a user writes, which is what a config file is.
570
+ * - refinements are dropped silently. The only one here is the affix `.superRefine`; its
571
+ * character half is carried by the `pattern` annotations on `affixValueSchema`, and its
572
+ * collision half cannot be stated in JSON Schema at all and stays a CLI-only error.
573
+ *
574
+ * draft-07 rather than 2020-12 because that is the dialect every editor implements fully, and
575
+ * this schema uses nothing newer.
576
+ */
577
+ declare function buildConfigJsonSchema(): Record<string, unknown>;
441
578
  /**
442
579
  * Where the tRPC generator writes.
443
580
  *
@@ -454,6 +591,87 @@ declare function trpcOutDir(g: {
454
591
  }, cfg: {
455
592
  outDir: string;
456
593
  }): string;
594
+ /**
595
+ * Where the Hono generator writes.
596
+ *
597
+ * The same rule as the other two routers, and for the same reason: it writes an `index.ts` of its
598
+ * own, so a config running two router generators has to give at least one of them a `path`.
599
+ *
600
+ * Its own function rather than a call to `trpcOutDir`, because these are three separate decisions
601
+ * that happen to agree today, and a reader following `computeGeneratorOutputDirs` should not have
602
+ * to work out whether a function named for tRPC is authoritative for Hono.
603
+ */
604
+ declare function honoOutDir(g: {
605
+ path?: string;
606
+ }, cfg: {
607
+ outDir: string;
608
+ }): string;
609
+ /**
610
+ * Where the Express generator writes.
611
+ *
612
+ * The same rule as the other three routers, and for the same reason: it writes an `index.ts` of
613
+ * its own, so a config running two router generators has to give at least one of them a `path`.
614
+ *
615
+ * Its own function rather than a call to one of the others, for the reason `honoOutDir` records:
616
+ * these are separate decisions that happen to agree today, and a reader following
617
+ * `computeGeneratorOutputDirs` should not have to work out which router's function is
618
+ * authoritative for which kind.
619
+ */
620
+ declare function expressOutDir(g: {
621
+ path?: string;
622
+ }, cfg: {
623
+ outDir: string;
624
+ }): string;
625
+ /**
626
+ * Where the Fastify generator writes.
627
+ *
628
+ * The same rule as the other four routers, and for the same reason: it writes an `index.ts` of
629
+ * its own, so a config running two router generators has to give at least one of them a `path`.
630
+ *
631
+ * Its own function rather than a call to one of the others, for the reason `honoOutDir` records:
632
+ * these are separate decisions that happen to agree today, and a reader following
633
+ * `computeGeneratorOutputDirs` should not have to work out which router's function is
634
+ * authoritative for which kind.
635
+ */
636
+ declare function fastifyOutDir(g: {
637
+ path?: string;
638
+ }, cfg: {
639
+ outDir: string;
640
+ }): string;
641
+ /**
642
+ * Where the NestJS generator writes.
643
+ *
644
+ * The same rule as the five routers, though this one emits DTO modules rather than routes: it
645
+ * still writes an `index.ts` barrel and a `validation.ts` of its own, so a config that runs it
646
+ * beside a router generator has to give at least one of them a `path`.
647
+ *
648
+ * Its own function rather than a call to one of the others, for the reason `honoOutDir` records:
649
+ * these are separate decisions that happen to agree today, and a reader following
650
+ * `computeGeneratorOutputDirs` should not have to work out which kind's function is
651
+ * authoritative for which.
652
+ */
653
+ declare function nestjsOutDir(g: {
654
+ path?: string;
655
+ }, cfg: {
656
+ outDir: string;
657
+ }): string;
658
+ /**
659
+ * Where the GraphQL generator writes.
660
+ *
661
+ * The same rule as the routers and the NestJS kind, though this one emits SDL modules rather
662
+ * than routes: it still writes an `index.ts` barrel and a `scalars.ts` of its own, so a config
663
+ * that runs it beside a router generator has to give at least one of them a `path`.
664
+ *
665
+ * Its own function rather than a call to one of the others, for the reason `honoOutDir`
666
+ * records: these are separate decisions that happen to agree today, and a reader following
667
+ * `computeGeneratorOutputDirs` should not have to work out which kind's function is
668
+ * authoritative for which.
669
+ */
670
+ declare function graphqlOutDir(g: {
671
+ path?: string;
672
+ }, cfg: {
673
+ outDir: string;
674
+ }): string;
457
675
  /**
458
676
  * Fill in cross-generator defaults and refuse configs whose generators would disagree.
459
677
  *
@@ -475,7 +693,45 @@ declare function resolveConfig(cfg: DrzlConfig): {
475
693
  config: DrzlConfig;
476
694
  warnings: string[];
477
695
  };
478
- declare function loadConfig(customPath?: string): Promise<DrzlConfig | null>;
696
+ /**
697
+ * Load a config module fresh from disk: JSON parsed directly, everything else through jiti
698
+ * with cache-busting, exactly as `loadConfig` always has.
699
+ *
700
+ * Extracted so the drizzle-kit interop reads `drizzle.config.ts` through the same loader that
701
+ * reads `drzl.config.ts`, rather than through a second dependency or a second set of jiti
702
+ * options that could drift from this one.
703
+ */
704
+ declare function importFreshConfigModule(p: string): Promise<unknown>;
705
+ /**
706
+ * The config, or `null` when there is none.
707
+ *
708
+ * `onWarn` exists so the config's warnings reach the output layer rather than the process. They
709
+ * went to `console.warn` until now, which is stderr with no route through `--quiet` or `--json`:
710
+ * `drzl generate --json` printed them beside the document it promises is the only thing on
711
+ * stdout's channel, and `--quiet` could not remove them. Item 79 adds a warning to exactly this
712
+ * path, so the path is fixed here rather than gaining a second writer that bypasses `Output`.
713
+ *
714
+ * The default keeps the old behaviour for any caller that has no output layer to hand.
715
+ */
716
+ declare function loadConfig(customPath?: string, onWarn?: (warning: string) => void): Promise<DrzlConfig | null>;
717
+ /**
718
+ * A config nobody wrote to a file, built from what the command line said.
719
+ *
720
+ * `drzl generate --schema src/db/schema.ts --only orpc` is the config route with the config
721
+ * inlined, and it is what replaces the two per-kind commands: those took a schema path and a kind
722
+ * and could reach none of the config's features, because they had no config at all. This produces
723
+ * a real one, so everything downstream, the filters, the naming, the write plan, `--check`, is the
724
+ * same code reading the same shape whether the config came from disk or from two flags.
725
+ *
726
+ * Through `ConfigSchema` and `resolveConfig` rather than by hand, and that is the whole point: the
727
+ * defaults a config file gets are applied here too, `importExtension` is pushed down onto each
728
+ * generator exactly as it is for a file, and a hand-built object that skipped either would emit
729
+ * different bytes from the equivalent config for no reason a user could see.
730
+ *
731
+ * `schema` may be omitted, in which case the drizzle-kit config answers for it, exactly as it does
732
+ * for a `drzl.config.ts` with no `schema` key.
733
+ */
734
+ declare function configFromKinds(kinds: readonly GeneratorKind[], schema?: string, onWarn?: (warning: string) => void): DrzlConfig;
479
735
  /** Absolute output dirs for all generators (to ignore in watcher). */
480
736
  declare function computeGeneratorOutputDirs(cfg: DrzlConfig, cwd?: string): string[];
481
737
  /** Resolve custom template directories (local path or installed package). */
@@ -511,6 +767,6 @@ declare function tableFilterWarnings(tables: readonly {
511
767
  include?: string[];
512
768
  exclude?: string[];
513
769
  }): string[];
514
- declare function computeWatchTargets(cfg: DrzlConfig, cwd?: string): string[];
770
+ declare function computeWatchTargets(cfg: DrzlConfig, cwd?: string, source?: ResolvedSchemaSource): string[];
515
771
 
516
- export { AffixSchema, AnalyzerSchema, ColumnRulesSchema, ConfigSchema, type DrzlConfig, type DrzlConfigInput, GeneratorSchema, ImportExtensionSchema, NamingSchema, computeGeneratorOutputDirs, computeWatchTargets, defineConfig, filterTables, loadConfig, resolveConfig, resolveTemplateDirsSync, tableFilterWarnings, trpcOutDir };
772
+ export { AffixSchema, AnalyzerSchema, CONFIG_FILE_NAMES, CONFIG_SCHEMA_ID, ColumnRulesSchema, ConfigSchema, type DrzlConfig, type DrzlConfigInput, GENERATOR_KINDS, type GeneratorKind, GeneratorKindSchema, GeneratorSchema, ImportExtensionSchema, NamingSchema, buildConfigJsonSchema, computeGeneratorOutputDirs, computeWatchTargets, configFromKinds, defineConfig, expressOutDir, fastifyOutDir, filterTables, graphqlOutDir, honoOutDir, importFreshConfigModule, loadConfig, nestjsOutDir, resolveConfig, resolveTemplateDirsSync, tableFilterWarnings, trpcOutDir };
package/dist/config.js CHANGED
@@ -1,34 +1,58 @@
1
1
  import {
2
2
  AffixSchema,
3
3
  AnalyzerSchema,
4
+ CONFIG_FILE_NAMES,
5
+ CONFIG_SCHEMA_ID,
4
6
  ColumnRulesSchema,
5
7
  ConfigSchema,
8
+ GENERATOR_KINDS,
9
+ GeneratorKindSchema,
6
10
  GeneratorSchema,
7
11
  ImportExtensionSchema,
8
12
  NamingSchema,
13
+ buildConfigJsonSchema,
9
14
  computeGeneratorOutputDirs,
10
15
  computeWatchTargets,
16
+ configFromKinds,
11
17
  defineConfig,
18
+ expressOutDir,
19
+ fastifyOutDir,
12
20
  filterTables,
21
+ graphqlOutDir,
22
+ honoOutDir,
23
+ importFreshConfigModule,
13
24
  loadConfig,
25
+ nestjsOutDir,
14
26
  resolveConfig,
15
27
  resolveTemplateDirsSync,
16
28
  tableFilterWarnings,
17
29
  trpcOutDir
18
- } from "./chunk-XNNKHBGV.js";
30
+ } from "./chunk-54E2IO7N.js";
19
31
  export {
20
32
  AffixSchema,
21
33
  AnalyzerSchema,
34
+ CONFIG_FILE_NAMES,
35
+ CONFIG_SCHEMA_ID,
22
36
  ColumnRulesSchema,
23
37
  ConfigSchema,
38
+ GENERATOR_KINDS,
39
+ GeneratorKindSchema,
24
40
  GeneratorSchema,
25
41
  ImportExtensionSchema,
26
42
  NamingSchema,
43
+ buildConfigJsonSchema,
27
44
  computeGeneratorOutputDirs,
28
45
  computeWatchTargets,
46
+ configFromKinds,
29
47
  defineConfig,
48
+ expressOutDir,
49
+ fastifyOutDir,
30
50
  filterTables,
51
+ graphqlOutDir,
52
+ honoOutDir,
53
+ importFreshConfigModule,
31
54
  loadConfig,
55
+ nestjsOutDir,
32
56
  resolveConfig,
33
57
  resolveTemplateDirsSync,
34
58
  tableFilterWarnings,