@drzl/cli 4.31.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,6 +509,7 @@ 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",
@@ -556,6 +557,16 @@ var GeneratorSchema = import_zod.z.object({
556
557
  apiName: import_zod.z.string().optional(),
557
558
  /** The identifier the assembled root contract carries. `ts-rest` only, defaults to `'contract'`. */
558
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(),
559
570
  /**
560
571
  * Prefixed to every path in the emitted contract. `ts-rest` only.
561
572
  *
@@ -791,7 +802,16 @@ var GeneratorSchema = import_zod.z.object({
791
802
  // router validation sharing (orpc, trpc)
792
803
  validation: import_zod.z.object({
793
804
  useShared: import_zod.z.boolean().default(false).optional(),
794
- 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(),
795
815
  importPath: import_zod.z.string().optional(),
796
816
  schemaSuffix: import_zod.z.string().optional(),
797
817
  /**
@@ -962,7 +982,8 @@ var ROUTER_KINDS = /* @__PURE__ */ new Set([
962
982
  "tanstack-start",
963
983
  "h3",
964
984
  "effect-http",
965
- "ts-rest"
985
+ "ts-rest",
986
+ "elysia"
966
987
  ]);
967
988
  var INJECTION_KINDS = /* @__PURE__ */ new Set(["orpc", "trpc"]);
968
989
  function trpcOutDir(g, cfg) {
@@ -1004,6 +1025,9 @@ function effectHttpOutDir(g, cfg) {
1004
1025
  function tsRestOutDir(g, cfg) {
1005
1026
  return g.path ?? cfg.outDir;
1006
1027
  }
1028
+ function elysiaOutDir(g, cfg) {
1029
+ return g.path ?? cfg.outDir;
1030
+ }
1007
1031
  function sharedSchemaNames(opts) {
1008
1032
  const resolved = (0, import_validation_core.resolveAffix)(opts);
1009
1033
  return import_validation_core.NAME_MODES.map((mode) => (0, import_validation_core.schemaName)(mode, import_validation_core.AFFIX_PROBE_TABLE, resolved));
@@ -1069,6 +1093,24 @@ function resolveConfig(cfg) {
1069
1093
  }
1070
1094
  continue;
1071
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
+ }
1072
1114
  if (g.kind === "effect-http") {
1073
1115
  if (g.validation?.library) {
1074
1116
  warnings.push(
@@ -1301,6 +1343,7 @@ function computeGeneratorOutputDirs(cfg, cwd = process.cwd()) {
1301
1343
  if (g.kind === "h3") dirs.add(abs(h3OutDir(g, cfg)));
1302
1344
  if (g.kind === "effect-http") dirs.add(abs(effectHttpOutDir(g, cfg)));
1303
1345
  if (g.kind === "ts-rest") dirs.add(abs(tsRestOutDir(g, cfg)));
1346
+ if (g.kind === "elysia") dirs.add(abs(elysiaOutDir(g, cfg)));
1304
1347
  if (g.kind === "service") dirs.add(abs(g.path ?? "src/services"));
1305
1348
  if (g.kind === "zod") dirs.add(abs(g.path ?? "src/validators/zod"));
1306
1349
  if (g.kind === "valibot") dirs.add(abs(g.path ?? "src/validators/valibot"));
@@ -1532,7 +1575,8 @@ function projectRelative2(p) {
1532
1575
  return p.startsWith("./") ? p.slice(2) : p;
1533
1576
  }
1534
1577
  function tsRestOptions(g, cfg) {
1535
- const library = g.validation?.library ?? "zod";
1578
+ const configured = g.validation?.library ?? "zod";
1579
+ const library = configured === "typebox" ? "zod" : configured;
1536
1580
  const siblings = cfg.generators.filter((s) => s.kind === library);
1537
1581
  const derived = siblings.length === 1 ? projectRelative2(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS2[library]) : void 0;
1538
1582
  return {
@@ -1552,19 +1596,51 @@ function tsRestOptions(g, cfg) {
1552
1596
  };
1553
1597
  }
1554
1598
 
1555
- // src/h3-options.ts
1599
+ // src/elysia-options.ts
1556
1600
  var VALIDATOR_DEFAULT_DIRS3 = {
1557
1601
  zod: "src/validators/zod",
1558
1602
  valibot: "src/validators/valibot",
1559
- arktype: "src/validators/arktype"
1603
+ arktype: "src/validators/arktype",
1604
+ typebox: "src/validators/typebox"
1560
1605
  };
1561
1606
  function projectRelative3(p) {
1562
1607
  return p.startsWith("./") ? p.slice(2) : p;
1563
1608
  }
1564
- function h3Options(g, cfg) {
1609
+ function elysiaOptions(g, cfg) {
1565
1610
  const library = g.validation?.library ?? "zod";
1566
1611
  const siblings = cfg.generators.filter((s) => s.kind === library);
1567
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;
1568
1644
  return {
1569
1645
  outputDir: h3OutDir(g, cfg),
1570
1646
  h3: g.h3,
@@ -1598,18 +1674,19 @@ function mcpOptions(g, cfg) {
1598
1674
  }
1599
1675
 
1600
1676
  // src/next-options.ts
1601
- var VALIDATOR_DEFAULT_DIRS4 = {
1677
+ var VALIDATOR_DEFAULT_DIRS5 = {
1602
1678
  zod: "src/validators/zod",
1603
1679
  valibot: "src/validators/valibot",
1604
1680
  arktype: "src/validators/arktype"
1605
1681
  };
1606
- function projectRelative4(p) {
1682
+ function projectRelative5(p) {
1607
1683
  return p.startsWith("./") ? p.slice(2) : p;
1608
1684
  }
1609
1685
  function nextOptions(g, cfg) {
1610
- const library = g.validation?.library ?? "zod";
1686
+ const configured = g.validation?.library ?? "zod";
1687
+ const library = configured === "typebox" ? "zod" : configured;
1611
1688
  const siblings = cfg.generators.filter((s) => s.kind === library);
1612
- const derived = siblings.length === 1 ? projectRelative4(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS4[library]) : void 0;
1689
+ const derived = siblings.length === 1 ? projectRelative5(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS5[library]) : void 0;
1613
1690
  return {
1614
1691
  outputDir: nextOutDir(g, cfg),
1615
1692
  naming: g.naming,
@@ -1626,18 +1703,19 @@ function nextOptions(g, cfg) {
1626
1703
  }
1627
1704
 
1628
1705
  // src/tanstack-start-options.ts
1629
- var VALIDATOR_DEFAULT_DIRS5 = {
1706
+ var VALIDATOR_DEFAULT_DIRS6 = {
1630
1707
  zod: "src/validators/zod",
1631
1708
  valibot: "src/validators/valibot",
1632
1709
  arktype: "src/validators/arktype"
1633
1710
  };
1634
- function projectRelative5(p) {
1711
+ function projectRelative6(p) {
1635
1712
  return p.startsWith("./") ? p.slice(2) : p;
1636
1713
  }
1637
1714
  function tanstackStartOptions(g, cfg) {
1638
- const library = g.validation?.library ?? "zod";
1715
+ const configured = g.validation?.library ?? "zod";
1716
+ const library = configured === "typebox" ? "zod" : configured;
1639
1717
  const siblings = cfg.generators.filter((s) => s.kind === library);
1640
- const derived = siblings.length === 1 ? projectRelative5(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS5[library]) : void 0;
1718
+ const derived = siblings.length === 1 ? projectRelative6(siblings[0].path ?? VALIDATOR_DEFAULT_DIRS6[library]) : void 0;
1641
1719
  return {
1642
1720
  outputDir: tanstackStartOutDir(g, cfg),
1643
1721
  naming: g.naming,
@@ -1721,7 +1799,7 @@ function trpcOptions(g, cfg, servicesDir) {
1721
1799
  }
1722
1800
 
1723
1801
  // src/generator-registry.ts
1724
- var VALIDATOR_DEFAULT_DIRS6 = {
1802
+ var VALIDATOR_DEFAULT_DIRS7 = {
1725
1803
  zod: "src/validators/zod",
1726
1804
  valibot: "src/validators/valibot",
1727
1805
  arktype: "src/validators/arktype",
@@ -1866,6 +1944,14 @@ var GENERATORS = [
1866
1944
  outputDir: (g, cfg) => tsRestOutDir(g, cfg),
1867
1945
  options: (g, cfg) => tsRestOptions(g, cfg)
1868
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
+ },
1869
1955
  {
1870
1956
  kind: "service",
1871
1957
  specifier: "@drzl/generator-service",
@@ -1879,7 +1965,7 @@ var GENERATORS = [
1879
1965
  specifier: "@drzl/generator-zod",
1880
1966
  load: () => import("@drzl/generator-zod"),
1881
1967
  construct: (m, analysis) => new m.ZodGenerator(analysis),
1882
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS6.zod,
1968
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7.zod,
1883
1969
  // `meta` is zod-only; see `GeneratorCapabilities.meta` for why it is not passed to the other
1884
1970
  // four rather than being passed and ignored.
1885
1971
  options: (g, cfg, ctx) => validationOptions(g, cfg, ctx.outDir, {
@@ -1893,7 +1979,7 @@ var GENERATORS = [
1893
1979
  specifier: "@drzl/generator-valibot",
1894
1980
  load: () => import("@drzl/generator-valibot"),
1895
1981
  construct: (m, analysis) => new m.ValibotGenerator(analysis),
1896
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS6.valibot,
1982
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7.valibot,
1897
1983
  options: (g, cfg, ctx) => validationOptions(g, cfg, ctx.outDir, { schemaTypes: true, constraints: true })
1898
1984
  },
1899
1985
  {
@@ -1901,7 +1987,7 @@ var GENERATORS = [
1901
1987
  specifier: "@drzl/generator-arktype",
1902
1988
  load: () => import("@drzl/generator-arktype"),
1903
1989
  construct: (m, analysis) => new m.ArkTypeGenerator(analysis),
1904
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS6.arktype,
1990
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7.arktype,
1905
1991
  options: (g, cfg, ctx) => validationOptions(g, cfg, ctx.outDir, { schemaTypes: false })
1906
1992
  },
1907
1993
  {
@@ -1909,7 +1995,7 @@ var GENERATORS = [
1909
1995
  specifier: "@drzl/generator-typebox",
1910
1996
  load: () => import("@drzl/generator-typebox"),
1911
1997
  construct: (m, analysis) => new m.TypeBoxGenerator(analysis),
1912
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS6.typebox,
1998
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7.typebox,
1913
1999
  options: (g, cfg, ctx) => validationOptions(g, cfg, ctx.outDir, { schemaTypes: true, standardSchema: true })
1914
2000
  },
1915
2001
  {
@@ -1917,7 +2003,7 @@ var GENERATORS = [
1917
2003
  specifier: "@drzl/generator-effect",
1918
2004
  load: () => import("@drzl/generator-effect"),
1919
2005
  construct: (m, analysis) => new m.EffectGenerator(analysis),
1920
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS6.effect,
2006
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7.effect,
1921
2007
  options: (g, cfg, ctx) => validationOptions(g, cfg, ctx.outDir, { schemaTypes: true })
1922
2008
  },
1923
2009
  {
@@ -1925,7 +2011,7 @@ var GENERATORS = [
1925
2011
  specifier: "@drzl/generator-json-schema",
1926
2012
  load: () => import("@drzl/generator-json-schema"),
1927
2013
  construct: (m, analysis) => new m.JsonSchemaGenerator(analysis),
1928
- outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS6["json-schema"],
2014
+ outputDir: (g) => g.path ?? VALIDATOR_DEFAULT_DIRS7["json-schema"],
1929
2015
  options: (g, cfg, ctx) => jsonSchemaOptions(g, cfg, ctx.outDir)
1930
2016
  }
1931
2017
  ];