@drzl/cli 4.30.0 → 4.32.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/cli.cjs CHANGED
@@ -509,10 +509,12 @@ var GeneratorKindSchema = import_zod.z.enum([
509
509
  "graphql",
510
510
  "ai",
511
511
  "effect-http",
512
+ "elysia",
512
513
  "h3",
513
514
  "mcp",
514
515
  "next",
515
516
  "tanstack-start",
517
+ "ts-rest",
516
518
  "service",
517
519
  "zod",
518
520
  "valibot",
@@ -553,6 +555,27 @@ var GeneratorSchema = import_zod.z.object({
553
555
  h3: import_zod.z.enum(["v1", "v2"]).optional(),
554
556
  /** The identifier the assembled `HttpApi` carries. `effect-http` only, defaults to `'api'`. */
555
557
  apiName: import_zod.z.string().optional(),
558
+ /** The identifier the assembled root contract carries. `ts-rest` only, defaults to `'contract'`. */
559
+ contractName: import_zod.z.string().optional(),
560
+ /** The identifier the assembled Elysia app is exported as. `elysia` only, defaults to `'app'`. */
561
+ appName: import_zod.z.string().optional(),
562
+ /**
563
+ * Prefixed to every table's mount point. `elysia` only.
564
+ *
565
+ * Passed to Elysia's own `new Elysia({ prefix })` on the assembled app rather than folded into
566
+ * each module's prefix, because Elysia lifts it into the app's type: the full path is what Eden
567
+ * Treaty reports.
568
+ */
569
+ prefix: import_zod.z.string().optional(),
570
+ /**
571
+ * Prefixed to every path in the emitted contract. `ts-rest` only.
572
+ *
573
+ * Passed through to ts-rest's own `c.router(..., { pathPrefix })` rather than written into each
574
+ * path, because ts-rest lifts the prefix into the contract's type: a client derived from the
575
+ * result reports the full path. Writing it into the strings by hand would produce the same
576
+ * requests and a different type.
577
+ */
578
+ pathPrefix: import_zod.z.string().optional(),
556
579
  /** The name and version the emitted MCP server reports at initialize. `mcp` only. */
557
580
  serverName: import_zod.z.string().optional(),
558
581
  serverVersion: import_zod.z.string().optional(),
@@ -779,7 +802,16 @@ var GeneratorSchema = import_zod.z.object({
779
802
  // router validation sharing (orpc, trpc)
780
803
  validation: import_zod.z.object({
781
804
  useShared: import_zod.z.boolean().default(false).optional(),
782
- library: import_zod.z.enum(["zod", "valibot", "arktype"]).default("zod").optional(),
805
+ /**
806
+ * Which validation generator's schemas this generator imports.
807
+ *
808
+ * `typebox` is accepted here and works for exactly one kind, `elysia`, whose validator slot
809
+ * takes a TypeBox schema natively because Elysia's own `t` is TypeBox. Every other router
810
+ * types its validators as a Standard Schema, which TypeBox does not implement, so a router
811
+ * wired to one would type against `any` and validate nothing. Naming it on any other kind is
812
+ * reported below rather than accepted, which is why the enum can be this wide.
813
+ */
814
+ library: import_zod.z.enum(["zod", "valibot", "arktype", "typebox"]).default("zod").optional(),
783
815
  importPath: import_zod.z.string().optional(),
784
816
  schemaSuffix: import_zod.z.string().optional(),
785
817
  /**
@@ -949,7 +981,9 @@ var ROUTER_KINDS = /* @__PURE__ */ new Set([
949
981
  "ai",
950
982
  "tanstack-start",
951
983
  "h3",
952
- "effect-http"
984
+ "effect-http",
985
+ "ts-rest",
986
+ "elysia"
953
987
  ]);
954
988
  var INJECTION_KINDS = /* @__PURE__ */ new Set(["orpc", "trpc"]);
955
989
  function trpcOutDir(g, cfg) {
@@ -988,6 +1022,12 @@ function h3OutDir(g, cfg) {
988
1022
  function effectHttpOutDir(g, cfg) {
989
1023
  return g.path ?? cfg.outDir;
990
1024
  }
1025
+ function tsRestOutDir(g, cfg) {
1026
+ return g.path ?? cfg.outDir;
1027
+ }
1028
+ function elysiaOutDir(g, cfg) {
1029
+ return g.path ?? cfg.outDir;
1030
+ }
991
1031
  function sharedSchemaNames(opts) {
992
1032
  const resolved = (0, import_validation_core.resolveAffix)(opts);
993
1033
  return import_validation_core.NAME_MODES.map((mode) => (0, import_validation_core.schemaName)(mode, import_validation_core.AFFIX_PROBE_TABLE, resolved));
@@ -1053,6 +1093,24 @@ function resolveConfig(cfg) {
1053
1093
  }
1054
1094
  continue;
1055
1095
  }
1096
+ if (g.validation?.library === "typebox" && g.kind !== "elysia") {
1097
+ warnings.push(
1098
+ `drzl config: the "${g.kind}" generator sets validation.library to "typebox", which it cannot validate with. TypeBox does not implement Standard Schema, so the schemas would be accepted and never checked. Use "zod", "valibot" or "arktype". The "elysia" generator is the one that takes TypeBox, because Elysia's own "t" is TypeBox.`
1099
+ );
1100
+ }
1101
+ if (g.kind === "elysia") {
1102
+ if (g.includeRelations) {
1103
+ warnings.push(
1104
+ `drzl config: the "elysia" generator sets includeRelations, which it does not read. Relation lookups are a route this generator does not emit. Remove the flag.`
1105
+ );
1106
+ }
1107
+ const library2 = g.validation?.library ?? "zod";
1108
+ if (!g.validation?.importPath && !generators.some((s) => s.kind === library2)) {
1109
+ warnings.push(
1110
+ `drzl config: the "elysia" generator validates with the schemas a validation generator writes, and this config has no "${library2}" generator for it to import from. Add { kind: "${library2}" }, or set validation.importPath to wherever those schemas live.`
1111
+ );
1112
+ }
1113
+ }
1056
1114
  if (g.kind === "effect-http") {
1057
1115
  if (g.validation?.library) {
1058
1116
  warnings.push(
@@ -1065,6 +1123,19 @@ function resolveConfig(cfg) {
1065
1123
  );
1066
1124
  }
1067
1125
  }
1126
+ if (g.kind === "ts-rest") {
1127
+ if (g.includeRelations) {
1128
+ warnings.push(
1129
+ `drzl config: the "ts-rest" generator sets includeRelations, which it does not read. Relation lookups are a route this generator does not declare. Remove the flag.`
1130
+ );
1131
+ }
1132
+ const library2 = g.validation?.library ?? "zod";
1133
+ if (!g.validation?.importPath && !generators.some((s) => s.kind === library2)) {
1134
+ warnings.push(
1135
+ `drzl config: the "ts-rest" generator declares its contract with the schemas a validation generator writes, and this config has no "${library2}" generator for it to import from. Add { kind: "${library2}" }, or set validation.importPath to wherever those schemas live.`
1136
+ );
1137
+ }
1138
+ }
1068
1139
  if (g.kind === "h3") {
1069
1140
  if (g.includeRelations) {
1070
1141
  warnings.push(
@@ -1271,6 +1342,8 @@ function computeGeneratorOutputDirs(cfg, cwd = process.cwd()) {
1271
1342
  if (g.kind === "tanstack-start") dirs.add(abs(tanstackStartOutDir(g, cfg)));
1272
1343
  if (g.kind === "h3") dirs.add(abs(h3OutDir(g, cfg)));
1273
1344
  if (g.kind === "effect-http") dirs.add(abs(effectHttpOutDir(g, cfg)));
1345
+ if (g.kind === "ts-rest") dirs.add(abs(tsRestOutDir(g, cfg)));
1346
+ if (g.kind === "elysia") dirs.add(abs(elysiaOutDir(g, cfg)));
1274
1347
  if (g.kind === "service") dirs.add(abs(g.path ?? "src/services"));
1275
1348
  if (g.kind === "zod") dirs.add(abs(g.path ?? "src/validators/zod"));
1276
1349
  if (g.kind === "valibot") dirs.add(abs(g.path ?? "src/validators/valibot"));
@@ -1492,7 +1565,7 @@ function effectHttpOptions(g, cfg) {
1492
1565
  };
1493
1566
  }
1494
1567
 
1495
- // src/h3-options.ts
1568
+ // src/ts-rest-options.ts
1496
1569
  var VALIDATOR_DEFAULT_DIRS2 = {
1497
1570
  zod: "src/validators/zod",
1498
1571
  valibot: "src/validators/valibot",
@@ -1501,10 +1574,73 @@ var VALIDATOR_DEFAULT_DIRS2 = {
1501
1574
  function projectRelative2(p) {
1502
1575
  return p.startsWith("./") ? p.slice(2) : p;
1503
1576
  }
1504
- function h3Options(g, cfg) {
1505
- const library = g.validation?.library ?? "zod";
1577
+ function tsRestOptions(g, cfg) {
1578
+ const configured = g.validation?.library ?? "zod";
1579
+ const library = configured === "typebox" ? "zod" : configured;
1506
1580
  const siblings = cfg.generators.filter((s) => s.kind === library);
1507
1581
  const derived = siblings.length === 1 ? projectRelative2(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS2[library]) : void 0;
1582
+ return {
1583
+ outputDir: tsRestOutDir(g, cfg),
1584
+ contractName: g.contractName,
1585
+ pathPrefix: g.pathPrefix,
1586
+ naming: g.naming,
1587
+ outputHeader: g.outputHeader,
1588
+ format: g.format,
1589
+ importExtension: g.importExtension,
1590
+ validation: {
1591
+ ...g.validation,
1592
+ library,
1593
+ useShared: true,
1594
+ importPath: g.validation?.importPath ?? derived
1595
+ }
1596
+ };
1597
+ }
1598
+
1599
+ // src/elysia-options.ts
1600
+ var VALIDATOR_DEFAULT_DIRS3 = {
1601
+ zod: "src/validators/zod",
1602
+ valibot: "src/validators/valibot",
1603
+ arktype: "src/validators/arktype",
1604
+ typebox: "src/validators/typebox"
1605
+ };
1606
+ function projectRelative3(p) {
1607
+ return p.startsWith("./") ? p.slice(2) : p;
1608
+ }
1609
+ function elysiaOptions(g, cfg) {
1610
+ const library = g.validation?.library ?? "zod";
1611
+ const siblings = cfg.generators.filter((s) => s.kind === library);
1612
+ const derived = siblings.length === 1 ? projectRelative3(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS3[library]) : void 0;
1613
+ return {
1614
+ outputDir: elysiaOutDir(g, cfg),
1615
+ appName: g.appName,
1616
+ prefix: g.prefix,
1617
+ naming: g.naming,
1618
+ outputHeader: g.outputHeader,
1619
+ format: g.format,
1620
+ importExtension: g.importExtension,
1621
+ validation: {
1622
+ ...g.validation,
1623
+ library,
1624
+ useShared: true,
1625
+ importPath: g.validation?.importPath ?? derived
1626
+ }
1627
+ };
1628
+ }
1629
+
1630
+ // src/h3-options.ts
1631
+ var VALIDATOR_DEFAULT_DIRS4 = {
1632
+ zod: "src/validators/zod",
1633
+ valibot: "src/validators/valibot",
1634
+ arktype: "src/validators/arktype"
1635
+ };
1636
+ function projectRelative4(p) {
1637
+ return p.startsWith("./") ? p.slice(2) : p;
1638
+ }
1639
+ function h3Options(g, cfg) {
1640
+ const configured = g.validation?.library ?? "zod";
1641
+ const library = configured === "typebox" ? "zod" : configured;
1642
+ const siblings = cfg.generators.filter((s) => s.kind === library);
1643
+ const derived = siblings.length === 1 ? projectRelative4(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS4[library]) : void 0;
1508
1644
  return {
1509
1645
  outputDir: h3OutDir(g, cfg),
1510
1646
  h3: g.h3,
@@ -1538,18 +1674,19 @@ function mcpOptions(g, cfg) {
1538
1674
  }
1539
1675
 
1540
1676
  // src/next-options.ts
1541
- var VALIDATOR_DEFAULT_DIRS3 = {
1677
+ var VALIDATOR_DEFAULT_DIRS5 = {
1542
1678
  zod: "src/validators/zod",
1543
1679
  valibot: "src/validators/valibot",
1544
1680
  arktype: "src/validators/arktype"
1545
1681
  };
1546
- function projectRelative3(p) {
1682
+ function projectRelative5(p) {
1547
1683
  return p.startsWith("./") ? p.slice(2) : p;
1548
1684
  }
1549
1685
  function nextOptions(g, cfg) {
1550
- const library = g.validation?.library ?? "zod";
1686
+ const configured = g.validation?.library ?? "zod";
1687
+ const library = configured === "typebox" ? "zod" : configured;
1551
1688
  const siblings = cfg.generators.filter((s) => s.kind === library);
1552
- const derived = siblings.length === 1 ? projectRelative3(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS3[library]) : void 0;
1689
+ const derived = siblings.length === 1 ? projectRelative5(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS5[library]) : void 0;
1553
1690
  return {
1554
1691
  outputDir: nextOutDir(g, cfg),
1555
1692
  naming: g.naming,
@@ -1566,18 +1703,19 @@ function nextOptions(g, cfg) {
1566
1703
  }
1567
1704
 
1568
1705
  // src/tanstack-start-options.ts
1569
- var VALIDATOR_DEFAULT_DIRS4 = {
1706
+ var VALIDATOR_DEFAULT_DIRS6 = {
1570
1707
  zod: "src/validators/zod",
1571
1708
  valibot: "src/validators/valibot",
1572
1709
  arktype: "src/validators/arktype"
1573
1710
  };
1574
- function projectRelative4(p) {
1711
+ function projectRelative6(p) {
1575
1712
  return p.startsWith("./") ? p.slice(2) : p;
1576
1713
  }
1577
1714
  function tanstackStartOptions(g, cfg) {
1578
- const library = g.validation?.library ?? "zod";
1715
+ const configured = g.validation?.library ?? "zod";
1716
+ const library = configured === "typebox" ? "zod" : configured;
1579
1717
  const siblings = cfg.generators.filter((s) => s.kind === library);
1580
- const derived = siblings.length === 1 ? projectRelative4(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS4[library]) : void 0;
1718
+ const derived = siblings.length === 1 ? projectRelative6(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS6[library]) : void 0;
1581
1719
  return {
1582
1720
  outputDir: tanstackStartOutDir(g, cfg),
1583
1721
  naming: g.naming,
@@ -1661,7 +1799,7 @@ function trpcOptions(g, cfg, servicesDir) {
1661
1799
  }
1662
1800
 
1663
1801
  // src/generator-registry.ts
1664
- var VALIDATOR_DEFAULT_DIRS5 = {
1802
+ var VALIDATOR_DEFAULT_DIRS7 = {
1665
1803
  zod: "src/validators/zod",
1666
1804
  valibot: "src/validators/valibot",
1667
1805
  arktype: "src/validators/arktype",
@@ -1798,6 +1936,22 @@ var GENERATORS = [
1798
1936
  outputDir: (g, cfg) => effectHttpOutDir(g, cfg),
1799
1937
  options: (g, cfg) => effectHttpOptions(g, cfg)
1800
1938
  },
1939
+ {
1940
+ kind: "ts-rest",
1941
+ specifier: "@drzl/generator-ts-rest",
1942
+ load: () => import("@drzl/generator-ts-rest"),
1943
+ construct: (m, analysis) => new m.TsRestGenerator(analysis),
1944
+ outputDir: (g, cfg) => tsRestOutDir(g, cfg),
1945
+ options: (g, cfg) => tsRestOptions(g, cfg)
1946
+ },
1947
+ {
1948
+ kind: "elysia",
1949
+ specifier: "@drzl/generator-elysia",
1950
+ load: () => import("@drzl/generator-elysia"),
1951
+ construct: (m, analysis) => new m.ElysiaGenerator(analysis),
1952
+ outputDir: (g, cfg) => elysiaOutDir(g, cfg),
1953
+ options: (g, cfg) => elysiaOptions(g, cfg)
1954
+ },
1801
1955
  {
1802
1956
  kind: "service",
1803
1957
  specifier: "@drzl/generator-service",
@@ -1811,7 +1965,7 @@ var GENERATORS = [
1811
1965
  specifier: "@drzl/generator-zod",
1812
1966
  load: () => import("@drzl/generator-zod"),
1813
1967
  construct: (m, analysis) => new m.ZodGenerator(analysis),
1814
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS5.zod,
1968
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7.zod,
1815
1969
  // `meta` is zod-only; see `GeneratorCapabilities.meta` for why it is not passed to the other
1816
1970
  // four rather than being passed and ignored.
1817
1971
  options: (g, cfg, ctx) => validationOptions(g, cfg, ctx.outDir, {
@@ -1825,7 +1979,7 @@ var GENERATORS = [
1825
1979
  specifier: "@drzl/generator-valibot",
1826
1980
  load: () => import("@drzl/generator-valibot"),
1827
1981
  construct: (m, analysis) => new m.ValibotGenerator(analysis),
1828
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS5.valibot,
1982
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7.valibot,
1829
1983
  options: (g, cfg, ctx) => validationOptions(g, cfg, ctx.outDir, { schemaTypes: true, constraints: true })
1830
1984
  },
1831
1985
  {
@@ -1833,7 +1987,7 @@ var GENERATORS = [
1833
1987
  specifier: "@drzl/generator-arktype",
1834
1988
  load: () => import("@drzl/generator-arktype"),
1835
1989
  construct: (m, analysis) => new m.ArkTypeGenerator(analysis),
1836
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS5.arktype,
1990
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7.arktype,
1837
1991
  options: (g, cfg, ctx) => validationOptions(g, cfg, ctx.outDir, { schemaTypes: false })
1838
1992
  },
1839
1993
  {
@@ -1841,7 +1995,7 @@ var GENERATORS = [
1841
1995
  specifier: "@drzl/generator-typebox",
1842
1996
  load: () => import("@drzl/generator-typebox"),
1843
1997
  construct: (m, analysis) => new m.TypeBoxGenerator(analysis),
1844
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS5.typebox,
1998
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7.typebox,
1845
1999
  options: (g, cfg, ctx) => validationOptions(g, cfg, ctx.outDir, { schemaTypes: true, standardSchema: true })
1846
2000
  },
1847
2001
  {
@@ -1849,7 +2003,7 @@ var GENERATORS = [
1849
2003
  specifier: "@drzl/generator-effect",
1850
2004
  load: () => import("@drzl/generator-effect"),
1851
2005
  construct: (m, analysis) => new m.EffectGenerator(analysis),
1852
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS5.effect,
2006
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7.effect,
1853
2007
  options: (g, cfg, ctx) => validationOptions(g, cfg, ctx.outDir, { schemaTypes: true })
1854
2008
  },
1855
2009
  {
@@ -1857,7 +2011,7 @@ var GENERATORS = [
1857
2011
  specifier: "@drzl/generator-json-schema",
1858
2012
  load: () => import("@drzl/generator-json-schema"),
1859
2013
  construct: (m, analysis) => new m.JsonSchemaGenerator(analysis),
1860
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS5["json-schema"],
2014
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7["json-schema"],
1861
2015
  options: (g, cfg, ctx) => jsonSchemaOptions(g, cfg, ctx.outDir)
1862
2016
  }
1863
2017
  ];