@stryke/prisma-trpc-generator 0.3.3 → 0.4.1

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/index.js CHANGED
@@ -2485,11 +2485,11 @@ var exists = /* @__PURE__ */ __name(async (filePath) => {
2485
2485
 
2486
2486
  // ../fs/src/helpers.ts
2487
2487
  import { mkdir, readFile, rm } from "node:fs/promises";
2488
- async function createDirectory(path5) {
2489
- if (await exists(path5)) {
2488
+ async function createDirectory(path7) {
2489
+ if (await exists(path7)) {
2490
2490
  return;
2491
2491
  }
2492
- return mkdir(path5, {
2492
+ return mkdir(path7, {
2493
2493
  recursive: true
2494
2494
  });
2495
2495
  }
@@ -2511,65 +2511,65 @@ var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
2511
2511
  var isAbsolute = /* @__PURE__ */ __name(function(p) {
2512
2512
  return _IS_ABSOLUTE_RE.test(p);
2513
2513
  }, "isAbsolute");
2514
- var correctPaths = /* @__PURE__ */ __name(function(path5) {
2515
- if (!path5 || path5.length === 0) {
2514
+ var correctPaths = /* @__PURE__ */ __name(function(path7) {
2515
+ if (!path7 || path7.length === 0) {
2516
2516
  return ".";
2517
2517
  }
2518
- path5 = normalizeWindowsPath(path5);
2519
- const isUNCPath = path5.match(_UNC_REGEX);
2520
- const isPathAbsolute = isAbsolute(path5);
2521
- const trailingSeparator = path5[path5.length - 1] === "/";
2522
- path5 = normalizeString(path5, !isPathAbsolute);
2523
- if (path5.length === 0) {
2518
+ path7 = normalizeWindowsPath(path7);
2519
+ const isUNCPath = path7.match(_UNC_REGEX);
2520
+ const isPathAbsolute = isAbsolute(path7);
2521
+ const trailingSeparator = path7[path7.length - 1] === "/";
2522
+ path7 = normalizeString(path7, !isPathAbsolute);
2523
+ if (path7.length === 0) {
2524
2524
  if (isPathAbsolute) {
2525
2525
  return "/";
2526
2526
  }
2527
2527
  return trailingSeparator ? "./" : ".";
2528
2528
  }
2529
2529
  if (trailingSeparator) {
2530
- path5 += "/";
2530
+ path7 += "/";
2531
2531
  }
2532
- if (_DRIVE_LETTER_RE.test(path5)) {
2533
- path5 += "/";
2532
+ if (_DRIVE_LETTER_RE.test(path7)) {
2533
+ path7 += "/";
2534
2534
  }
2535
2535
  if (isUNCPath) {
2536
2536
  if (!isPathAbsolute) {
2537
- return `//./${path5}`;
2537
+ return `//./${path7}`;
2538
2538
  }
2539
- return `//${path5}`;
2539
+ return `//${path7}`;
2540
2540
  }
2541
- return isPathAbsolute && !isAbsolute(path5) ? `/${path5}` : path5;
2541
+ return isPathAbsolute && !isAbsolute(path7) ? `/${path7}` : path7;
2542
2542
  }, "correctPaths");
2543
2543
  var joinPaths = /* @__PURE__ */ __name(function(...segments) {
2544
- let path5 = "";
2544
+ let path7 = "";
2545
2545
  for (const seg of segments) {
2546
2546
  if (!seg) {
2547
2547
  continue;
2548
2548
  }
2549
- if (path5.length > 0) {
2550
- const pathTrailing = path5[path5.length - 1] === "/";
2549
+ if (path7.length > 0) {
2550
+ const pathTrailing = path7[path7.length - 1] === "/";
2551
2551
  const segLeading = seg[0] === "/";
2552
2552
  const both = pathTrailing && segLeading;
2553
2553
  if (both) {
2554
- path5 += seg.slice(1);
2554
+ path7 += seg.slice(1);
2555
2555
  } else {
2556
- path5 += pathTrailing || segLeading ? seg : `/${seg}`;
2556
+ path7 += pathTrailing || segLeading ? seg : `/${seg}`;
2557
2557
  }
2558
2558
  } else {
2559
- path5 += seg;
2559
+ path7 += seg;
2560
2560
  }
2561
2561
  }
2562
- return correctPaths(path5);
2562
+ return correctPaths(path7);
2563
2563
  }, "joinPaths");
2564
- function normalizeString(path5, allowAboveRoot) {
2564
+ function normalizeString(path7, allowAboveRoot) {
2565
2565
  let res = "";
2566
2566
  let lastSegmentLength = 0;
2567
2567
  let lastSlash = -1;
2568
2568
  let dots = 0;
2569
2569
  let char = null;
2570
- for (let index = 0; index <= path5.length; ++index) {
2571
- if (index < path5.length) {
2572
- char = path5[index];
2570
+ for (let index = 0; index <= path7.length; ++index) {
2571
+ if (index < path7.length) {
2572
+ char = path7[index];
2573
2573
  } else if (char === "/") {
2574
2574
  break;
2575
2575
  } else {
@@ -2605,9 +2605,9 @@ function normalizeString(path5, allowAboveRoot) {
2605
2605
  }
2606
2606
  } else {
2607
2607
  if (res.length > 0) {
2608
- res += `/${path5.slice(lastSlash + 1, index)}`;
2608
+ res += `/${path7.slice(lastSlash + 1, index)}`;
2609
2609
  } else {
2610
- res = path5.slice(lastSlash + 1, index);
2610
+ res = path7.slice(lastSlash + 1, index);
2611
2611
  }
2612
2612
  lastSegmentLength = index - lastSlash - 1;
2613
2613
  }
@@ -2625,7 +2625,7 @@ __name(normalizeString, "normalizeString");
2625
2625
 
2626
2626
  // src/prisma-generator.ts
2627
2627
  var import_pluralize = __toESM(require_pluralize(), 1);
2628
- import path4 from "node:path";
2628
+ import path6 from "node:path";
2629
2629
 
2630
2630
  // src/config.ts
2631
2631
  init_esm_shims();
@@ -2992,8 +2992,8 @@ function getErrorMap() {
2992
2992
  }
2993
2993
  __name(getErrorMap, "getErrorMap");
2994
2994
  var makeIssue = /* @__PURE__ */ __name((params) => {
2995
- const { data, path: path5, errorMaps, issueData } = params;
2996
- const fullPath = [...path5, ...issueData.path || []];
2995
+ const { data, path: path7, errorMaps, issueData } = params;
2996
+ const fullPath = [...path7, ...issueData.path || []];
2997
2997
  const fullIssue = {
2998
2998
  ...issueData,
2999
2999
  path: fullPath
@@ -3127,11 +3127,11 @@ var ParseInputLazyPath = class {
3127
3127
  static {
3128
3128
  __name(this, "ParseInputLazyPath");
3129
3129
  }
3130
- constructor(parent, value, path5, key) {
3130
+ constructor(parent, value, path7, key) {
3131
3131
  this._cachedPath = [];
3132
3132
  this.parent = parent;
3133
3133
  this.data = value;
3134
- this._path = path5;
3134
+ this._path = path7;
3135
3135
  this._key = key;
3136
3136
  }
3137
3137
  get path() {
@@ -7116,34 +7116,34 @@ __name2(normalizeWindowsPath2, "normalizeWindowsPath");
7116
7116
  var _UNC_REGEX2 = /^[/\\]{2}/;
7117
7117
  var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
7118
7118
  var _DRIVE_LETTER_RE2 = /^[A-Za-z]:$/;
7119
- var correctPaths2 = /* @__PURE__ */ __name2(function(path5) {
7120
- if (!path5 || path5.length === 0) {
7119
+ var correctPaths2 = /* @__PURE__ */ __name2(function(path7) {
7120
+ if (!path7 || path7.length === 0) {
7121
7121
  return ".";
7122
7122
  }
7123
- path5 = normalizeWindowsPath2(path5);
7124
- const isUNCPath = path5.match(_UNC_REGEX2);
7125
- const isPathAbsolute = isAbsolute2(path5);
7126
- const trailingSeparator = path5[path5.length - 1] === "/";
7127
- path5 = normalizeString2(path5, !isPathAbsolute);
7128
- if (path5.length === 0) {
7123
+ path7 = normalizeWindowsPath2(path7);
7124
+ const isUNCPath = path7.match(_UNC_REGEX2);
7125
+ const isPathAbsolute = isAbsolute2(path7);
7126
+ const trailingSeparator = path7[path7.length - 1] === "/";
7127
+ path7 = normalizeString2(path7, !isPathAbsolute);
7128
+ if (path7.length === 0) {
7129
7129
  if (isPathAbsolute) {
7130
7130
  return "/";
7131
7131
  }
7132
7132
  return trailingSeparator ? "./" : ".";
7133
7133
  }
7134
7134
  if (trailingSeparator) {
7135
- path5 += "/";
7135
+ path7 += "/";
7136
7136
  }
7137
- if (_DRIVE_LETTER_RE2.test(path5)) {
7138
- path5 += "/";
7137
+ if (_DRIVE_LETTER_RE2.test(path7)) {
7138
+ path7 += "/";
7139
7139
  }
7140
7140
  if (isUNCPath) {
7141
7141
  if (!isPathAbsolute) {
7142
- return `//./${path5}`;
7142
+ return `//./${path7}`;
7143
7143
  }
7144
- return `//${path5}`;
7144
+ return `//${path7}`;
7145
7145
  }
7146
- return isPathAbsolute && !isAbsolute2(path5) ? `/${path5}` : path5;
7146
+ return isPathAbsolute && !isAbsolute2(path7) ? `/${path7}` : path7;
7147
7147
  }, "correctPaths");
7148
7148
  function cwd() {
7149
7149
  if (typeof process !== "undefined" && typeof process.cwd === "function") {
@@ -7153,15 +7153,15 @@ function cwd() {
7153
7153
  }
7154
7154
  __name(cwd, "cwd");
7155
7155
  __name2(cwd, "cwd");
7156
- function normalizeString2(path5, allowAboveRoot) {
7156
+ function normalizeString2(path7, allowAboveRoot) {
7157
7157
  let res = "";
7158
7158
  let lastSegmentLength = 0;
7159
7159
  let lastSlash = -1;
7160
7160
  let dots = 0;
7161
7161
  let char = null;
7162
- for (let index = 0; index <= path5.length; ++index) {
7163
- if (index < path5.length) {
7164
- char = path5[index];
7162
+ for (let index = 0; index <= path7.length; ++index) {
7163
+ if (index < path7.length) {
7164
+ char = path7[index];
7165
7165
  } else if (char === "/") {
7166
7166
  break;
7167
7167
  } else {
@@ -7197,9 +7197,9 @@ function normalizeString2(path5, allowAboveRoot) {
7197
7197
  }
7198
7198
  } else {
7199
7199
  if (res.length > 0) {
7200
- res += `/${path5.slice(lastSlash + 1, index)}`;
7200
+ res += `/${path7.slice(lastSlash + 1, index)}`;
7201
7201
  } else {
7202
- res = path5.slice(lastSlash + 1, index);
7202
+ res = path7.slice(lastSlash + 1, index);
7203
7203
  }
7204
7204
  lastSegmentLength = index - lastSlash - 1;
7205
7205
  }
@@ -7299,20 +7299,20 @@ init_esm_shims();
7299
7299
  // ../path/src/is-file.ts
7300
7300
  init_esm_shims();
7301
7301
  import { lstatSync, statSync } from "node:fs";
7302
- function isFile(path5, additionalPath) {
7303
- return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path5) : path5, {
7302
+ function isFile(path7, additionalPath) {
7303
+ return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path7) : path7, {
7304
7304
  throwIfNoEntry: false
7305
7305
  })?.isFile());
7306
7306
  }
7307
7307
  __name(isFile, "isFile");
7308
- function isDirectory(path5, additionalPath) {
7309
- return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path5) : path5, {
7308
+ function isDirectory(path7, additionalPath) {
7309
+ return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path7) : path7, {
7310
7310
  throwIfNoEntry: false
7311
7311
  })?.isDirectory());
7312
7312
  }
7313
7313
  __name(isDirectory, "isDirectory");
7314
- function isAbsolutePath(path5) {
7315
- return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path5);
7314
+ function isAbsolutePath(path7) {
7315
+ return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path7);
7316
7316
  }
7317
7317
  __name(isAbsolutePath, "isAbsolutePath");
7318
7318
 
@@ -7327,45 +7327,45 @@ function normalizeWindowsPath3(input = "") {
7327
7327
  __name(normalizeWindowsPath3, "normalizeWindowsPath");
7328
7328
  var _UNC_REGEX3 = /^[/\\]{2}/;
7329
7329
  var _DRIVE_LETTER_RE3 = /^[A-Z]:$/i;
7330
- function correctPath(path5) {
7331
- if (!path5 || path5.length === 0) {
7330
+ function correctPath(path7) {
7331
+ if (!path7 || path7.length === 0) {
7332
7332
  return ".";
7333
7333
  }
7334
- path5 = normalizeWindowsPath3(path5);
7335
- const isUNCPath = path5.match(_UNC_REGEX3);
7336
- const isPathAbsolute = isAbsolutePath(path5);
7337
- const trailingSeparator = path5[path5.length - 1] === "/";
7338
- path5 = normalizeString3(path5, !isPathAbsolute);
7339
- if (path5.length === 0) {
7334
+ path7 = normalizeWindowsPath3(path7);
7335
+ const isUNCPath = path7.match(_UNC_REGEX3);
7336
+ const isPathAbsolute = isAbsolutePath(path7);
7337
+ const trailingSeparator = path7[path7.length - 1] === "/";
7338
+ path7 = normalizeString3(path7, !isPathAbsolute);
7339
+ if (path7.length === 0) {
7340
7340
  if (isPathAbsolute) {
7341
7341
  return "/";
7342
7342
  }
7343
7343
  return trailingSeparator ? "./" : ".";
7344
7344
  }
7345
7345
  if (trailingSeparator) {
7346
- path5 += "/";
7346
+ path7 += "/";
7347
7347
  }
7348
- if (_DRIVE_LETTER_RE3.test(path5)) {
7349
- path5 += "/";
7348
+ if (_DRIVE_LETTER_RE3.test(path7)) {
7349
+ path7 += "/";
7350
7350
  }
7351
7351
  if (isUNCPath) {
7352
7352
  if (!isPathAbsolute) {
7353
- return `//./${path5}`;
7353
+ return `//./${path7}`;
7354
7354
  }
7355
- return `//${path5}`;
7355
+ return `//${path7}`;
7356
7356
  }
7357
- return isPathAbsolute && !isAbsolutePath(path5) ? `/${path5}` : path5;
7357
+ return isPathAbsolute && !isAbsolutePath(path7) ? `/${path7}` : path7;
7358
7358
  }
7359
7359
  __name(correctPath, "correctPath");
7360
- function normalizeString3(path5, allowAboveRoot) {
7360
+ function normalizeString3(path7, allowAboveRoot) {
7361
7361
  let res = "";
7362
7362
  let lastSegmentLength = 0;
7363
7363
  let lastSlash = -1;
7364
7364
  let dots = 0;
7365
7365
  let char = null;
7366
- for (let index = 0; index <= path5.length; ++index) {
7367
- if (index < path5.length) {
7368
- char = path5[index];
7366
+ for (let index = 0; index <= path7.length; ++index) {
7367
+ if (index < path7.length) {
7368
+ char = path7[index];
7369
7369
  } else if (char === "/") {
7370
7370
  break;
7371
7371
  } else {
@@ -7401,9 +7401,9 @@ function normalizeString3(path5, allowAboveRoot) {
7401
7401
  }
7402
7402
  } else {
7403
7403
  if (res.length > 0) {
7404
- res += `/${path5.slice(lastSlash + 1, index)}`;
7404
+ res += `/${path7.slice(lastSlash + 1, index)}`;
7405
7405
  } else {
7406
- res = path5.slice(lastSlash + 1, index);
7406
+ res = path7.slice(lastSlash + 1, index);
7407
7407
  }
7408
7408
  lastSegmentLength = index - lastSlash - 1;
7409
7409
  }
@@ -7438,17 +7438,17 @@ function findFilePath(filePath) {
7438
7438
  }), "");
7439
7439
  }
7440
7440
  __name(findFilePath, "findFilePath");
7441
- function resolvePath(path5, cwd2 = getWorkspaceRoot()) {
7442
- const paths = normalizeWindowsPath3(path5).split("/");
7441
+ function resolvePath(path7, cwd2 = getWorkspaceRoot()) {
7442
+ const paths = normalizeWindowsPath3(path7).split("/");
7443
7443
  let resolvedPath = "";
7444
7444
  let resolvedAbsolute = false;
7445
7445
  for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
7446
- const path6 = index >= 0 ? paths[index] : cwd2;
7447
- if (!path6 || path6.length === 0) {
7446
+ const path8 = index >= 0 ? paths[index] : cwd2;
7447
+ if (!path8 || path8.length === 0) {
7448
7448
  continue;
7449
7449
  }
7450
- resolvedPath = joinPaths(path6, resolvedPath);
7451
- resolvedAbsolute = isAbsolutePath(path6);
7450
+ resolvedPath = joinPaths(path8, resolvedPath);
7451
+ resolvedAbsolute = isAbsolutePath(path8);
7452
7452
  }
7453
7453
  resolvedPath = normalizeString3(resolvedPath, !resolvedAbsolute);
7454
7454
  if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {
@@ -7458,13 +7458,13 @@ function resolvePath(path5, cwd2 = getWorkspaceRoot()) {
7458
7458
  }
7459
7459
  __name(resolvePath, "resolvePath");
7460
7460
  function resolvePaths(...paths) {
7461
- return resolvePath(joinPaths(...paths.map((path5) => normalizeWindowsPath3(path5))));
7461
+ return resolvePath(joinPaths(...paths.map((path7) => normalizeWindowsPath3(path7))));
7462
7462
  }
7463
7463
  __name(resolvePaths, "resolvePaths");
7464
7464
 
7465
7465
  // ../path/src/get-parent-path.ts
7466
- var resolveParentPath = /* @__PURE__ */ __name((path5) => {
7467
- return resolvePaths(path5, "..");
7466
+ var resolveParentPath = /* @__PURE__ */ __name((path7) => {
7467
+ return resolvePaths(path7, "..");
7468
7468
  }, "resolveParentPath");
7469
7469
  var getParentPath = /* @__PURE__ */ __name((name, cwd2, options) => {
7470
7470
  const ignoreCase = options?.ignoreCase ?? true;
@@ -7850,15 +7850,15 @@ var getProcedureTypeByOpName = /* @__PURE__ */ __name((opName) => {
7850
7850
  return procType;
7851
7851
  }, "getProcedureTypeByOpName");
7852
7852
  function resolveModelsComments(models, hiddenModels) {
7853
- const modelAttributeRegex = /(?:@@Gen\.)+[A-z]+\(.+\)/;
7854
- const attributeNameRegex = /\.+[A-Z]+\(+/i;
7855
- const attributeArgsRegex = /\(+[A-Z]+:.+\)/i;
7853
+ const modelAttributeRegex2 = /(?:@@Gen\.)+[A-z]+\(.+\)/;
7854
+ const attributeNameRegex2 = /\.+[A-Z]+\(+/i;
7855
+ const attributeArgsRegex2 = /\(+[A-Z]+:.+\)/i;
7856
7856
  for (const model of models) {
7857
7857
  if (model.documentation) {
7858
- const attribute = model.documentation?.match(modelAttributeRegex)?.[0];
7859
- const attributeName = attribute?.match(attributeNameRegex)?.[0]?.slice(1, -1);
7858
+ const attribute = model.documentation?.match(modelAttributeRegex2)?.[0];
7859
+ const attributeName = attribute?.match(attributeNameRegex2)?.[0]?.slice(1, -1);
7860
7860
  if (attributeName !== "model") continue;
7861
- const rawAttributeArgs = attribute?.match(attributeArgsRegex)?.[0]?.slice(1, -1);
7861
+ const rawAttributeArgs = attribute?.match(attributeArgsRegex2)?.[0]?.slice(1, -1);
7862
7862
  const parsedAttributeArgs = {};
7863
7863
  if (rawAttributeArgs) {
7864
7864
  const rawAttributeArgsParts = rawAttributeArgs.split(":").map((it) => it.trim()).map((part) => part.startsWith("[") ? part : part.split(",")).flat().map((it) => it.trim());
@@ -9167,7 +9167,7 @@ var isURL = /* @__PURE__ */ __name((payload) => payload instanceof URL, "isURL")
9167
9167
  // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.js
9168
9168
  init_esm_shims();
9169
9169
  var escapeKey = /* @__PURE__ */ __name((key) => key.replace(/\./g, "\\."), "escapeKey");
9170
- var stringifyPath = /* @__PURE__ */ __name((path5) => path5.map(String).map(escapeKey).join("."), "stringifyPath");
9170
+ var stringifyPath = /* @__PURE__ */ __name((path7) => path7.map(String).map(escapeKey).join("."), "stringifyPath");
9171
9171
  var parsePath = /* @__PURE__ */ __name((string) => {
9172
9172
  const result = [];
9173
9173
  let segment = "";
@@ -9430,27 +9430,27 @@ var getNthKey = /* @__PURE__ */ __name((value, n) => {
9430
9430
  }
9431
9431
  return keys.next().value;
9432
9432
  }, "getNthKey");
9433
- function validatePath(path5) {
9434
- if (includes(path5, "__proto__")) {
9433
+ function validatePath(path7) {
9434
+ if (includes(path7, "__proto__")) {
9435
9435
  throw new Error("__proto__ is not allowed as a property");
9436
9436
  }
9437
- if (includes(path5, "prototype")) {
9437
+ if (includes(path7, "prototype")) {
9438
9438
  throw new Error("prototype is not allowed as a property");
9439
9439
  }
9440
- if (includes(path5, "constructor")) {
9440
+ if (includes(path7, "constructor")) {
9441
9441
  throw new Error("constructor is not allowed as a property");
9442
9442
  }
9443
9443
  }
9444
9444
  __name(validatePath, "validatePath");
9445
- var getDeep = /* @__PURE__ */ __name((object, path5) => {
9446
- validatePath(path5);
9447
- for (let i = 0; i < path5.length; i++) {
9448
- const key = path5[i];
9445
+ var getDeep = /* @__PURE__ */ __name((object, path7) => {
9446
+ validatePath(path7);
9447
+ for (let i = 0; i < path7.length; i++) {
9448
+ const key = path7[i];
9449
9449
  if (isSet(object)) {
9450
9450
  object = getNthKey(object, +key);
9451
9451
  } else if (isMap(object)) {
9452
9452
  const row = +key;
9453
- const type = +path5[++i] === 0 ? "key" : "value";
9453
+ const type = +path7[++i] === 0 ? "key" : "value";
9454
9454
  const keyOfRow = getNthKey(object, row);
9455
9455
  switch (type) {
9456
9456
  case "key":
@@ -9466,14 +9466,14 @@ var getDeep = /* @__PURE__ */ __name((object, path5) => {
9466
9466
  }
9467
9467
  return object;
9468
9468
  }, "getDeep");
9469
- var setDeep = /* @__PURE__ */ __name((object, path5, mapper) => {
9470
- validatePath(path5);
9471
- if (path5.length === 0) {
9469
+ var setDeep = /* @__PURE__ */ __name((object, path7, mapper) => {
9470
+ validatePath(path7);
9471
+ if (path7.length === 0) {
9472
9472
  return mapper(object);
9473
9473
  }
9474
9474
  let parent = object;
9475
- for (let i = 0; i < path5.length - 1; i++) {
9476
- const key = path5[i];
9475
+ for (let i = 0; i < path7.length - 1; i++) {
9476
+ const key = path7[i];
9477
9477
  if (isArray(parent)) {
9478
9478
  const index = +key;
9479
9479
  parent = parent[index];
@@ -9483,12 +9483,12 @@ var setDeep = /* @__PURE__ */ __name((object, path5, mapper) => {
9483
9483
  const row = +key;
9484
9484
  parent = getNthKey(parent, row);
9485
9485
  } else if (isMap(parent)) {
9486
- const isEnd = i === path5.length - 2;
9486
+ const isEnd = i === path7.length - 2;
9487
9487
  if (isEnd) {
9488
9488
  break;
9489
9489
  }
9490
9490
  const row = +key;
9491
- const type = +path5[++i] === 0 ? "key" : "value";
9491
+ const type = +path7[++i] === 0 ? "key" : "value";
9492
9492
  const keyOfRow = getNthKey(parent, row);
9493
9493
  switch (type) {
9494
9494
  case "key":
@@ -9500,7 +9500,7 @@ var setDeep = /* @__PURE__ */ __name((object, path5, mapper) => {
9500
9500
  }
9501
9501
  }
9502
9502
  }
9503
- const lastKey = path5[path5.length - 1];
9503
+ const lastKey = path7[path7.length - 1];
9504
9504
  if (isArray(parent)) {
9505
9505
  parent[+lastKey] = mapper(parent[+lastKey]);
9506
9506
  } else if (isPlainObject2(parent)) {
@@ -9515,7 +9515,7 @@ var setDeep = /* @__PURE__ */ __name((object, path5, mapper) => {
9515
9515
  }
9516
9516
  }
9517
9517
  if (isMap(parent)) {
9518
- const row = +path5[path5.length - 2];
9518
+ const row = +path7[path7.length - 2];
9519
9519
  const keyToRow = getNthKey(parent, row);
9520
9520
  const type = +lastKey === 0 ? "key" : "value";
9521
9521
  switch (type) {
@@ -9561,15 +9561,15 @@ function traverse(tree, walker2, origin = []) {
9561
9561
  }
9562
9562
  __name(traverse, "traverse");
9563
9563
  function applyValueAnnotations(plain, annotations, superJson) {
9564
- traverse(annotations, (type, path5) => {
9565
- plain = setDeep(plain, path5, (v) => untransformValue(v, type, superJson));
9564
+ traverse(annotations, (type, path7) => {
9565
+ plain = setDeep(plain, path7, (v) => untransformValue(v, type, superJson));
9566
9566
  });
9567
9567
  return plain;
9568
9568
  }
9569
9569
  __name(applyValueAnnotations, "applyValueAnnotations");
9570
9570
  function applyReferentialEqualityAnnotations(plain, annotations) {
9571
- function apply(identicalPaths, path5) {
9572
- const object = getDeep(plain, parsePath(path5));
9571
+ function apply(identicalPaths, path7) {
9572
+ const object = getDeep(plain, parsePath(path7));
9573
9573
  identicalPaths.map(parsePath).forEach((identicalObjectPath) => {
9574
9574
  plain = setDeep(plain, identicalObjectPath, () => object);
9575
9575
  });
@@ -9590,13 +9590,13 @@ function applyReferentialEqualityAnnotations(plain, annotations) {
9590
9590
  }
9591
9591
  __name(applyReferentialEqualityAnnotations, "applyReferentialEqualityAnnotations");
9592
9592
  var isDeep = /* @__PURE__ */ __name((object, superJson) => isPlainObject2(object) || isArray(object) || isMap(object) || isSet(object) || isInstanceOfRegisteredClass(object, superJson), "isDeep");
9593
- function addIdentity(object, path5, identities) {
9593
+ function addIdentity(object, path7, identities) {
9594
9594
  const existingSet = identities.get(object);
9595
9595
  if (existingSet) {
9596
- existingSet.push(path5);
9596
+ existingSet.push(path7);
9597
9597
  } else {
9598
9598
  identities.set(object, [
9599
- path5
9599
+ path7
9600
9600
  ]);
9601
9601
  }
9602
9602
  }
@@ -9609,7 +9609,7 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) {
9609
9609
  return;
9610
9610
  }
9611
9611
  if (!dedupe) {
9612
- paths = paths.map((path5) => path5.map(String)).sort((a, b) => a.length - b.length);
9612
+ paths = paths.map((path7) => path7.map(String)).sort((a, b) => a.length - b.length);
9613
9613
  }
9614
9614
  const [representativePath, ...identicalPaths] = paths;
9615
9615
  if (representativePath.length === 0) {
@@ -9634,10 +9634,10 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) {
9634
9634
  }
9635
9635
  }
9636
9636
  __name(generateReferentialEqualityAnnotations, "generateReferentialEqualityAnnotations");
9637
- var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path5 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
9637
+ var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path7 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
9638
9638
  const primitive = isPrimitive(object);
9639
9639
  if (!primitive) {
9640
- addIdentity(object, path5, identities);
9640
+ addIdentity(object, path7, identities);
9641
9641
  const seen = seenObjects.get(object);
9642
9642
  if (seen) {
9643
9643
  return dedupe ? {
@@ -9674,7 +9674,7 @@ var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path
9674
9674
  throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
9675
9675
  }
9676
9676
  const recursiveResult = walker(value, identities, superJson, dedupe, [
9677
- ...path5,
9677
+ ...path7,
9678
9678
  index
9679
9679
  ], [
9680
9680
  ...objectsInThisPath,
@@ -10253,6 +10253,9 @@ var writeFile = /* @__PURE__ */ __name(async (filePath, content, options) => {
10253
10253
  return writeFileFs(filePath, content || "", options);
10254
10254
  }, "writeFile");
10255
10255
 
10256
+ // src/utils/write-file-safely.ts
10257
+ import path4 from "node:path";
10258
+
10256
10259
  // src/utils/format-file.ts
10257
10260
  init_esm_shims();
10258
10261
  import prettier from "prettier";
@@ -10279,13 +10282,1188 @@ async function formatFile(content) {
10279
10282
  __name(formatFile, "formatFile");
10280
10283
 
10281
10284
  // src/utils/write-file-safely.ts
10282
- var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content) => {
10285
+ var indexExports = /* @__PURE__ */ new Set();
10286
+ var addIndexExport = /* @__PURE__ */ __name((filePath) => {
10287
+ indexExports.add(filePath);
10288
+ }, "addIndexExport");
10289
+ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addToIndex = true) => {
10283
10290
  const [fileContent] = await Promise.all([
10284
10291
  formatFile(content),
10285
10292
  createDirectory(findFilePath(writeLocation))
10286
10293
  ]);
10287
10294
  await writeFile(writeLocation, fileContent);
10295
+ if (addToIndex) {
10296
+ addIndexExport(writeLocation);
10297
+ }
10288
10298
  }, "writeFileSafely");
10299
+ var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10300
+ const rows = Array.from(indexExports).map((filePath) => {
10301
+ let relativePath = path4.relative(path4.dirname(indexPath), filePath);
10302
+ if (relativePath.endsWith(".ts")) {
10303
+ relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
10304
+ }
10305
+ const normalized = correctPath(relativePath);
10306
+ return `export * from './${normalized}'`;
10307
+ });
10308
+ await writeFileSafely(indexPath, rows.join("\n"), false);
10309
+ }, "writeIndexFile");
10310
+
10311
+ // src/zod-helpers/aggregate-helpers.ts
10312
+ init_esm_shims();
10313
+ var isAggregateOutputType = /* @__PURE__ */ __name((name) => /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(name), "isAggregateOutputType");
10314
+ var isAggregateInputType = /* @__PURE__ */ __name((name) => name.endsWith("CountAggregateInput") || name.endsWith("SumAggregateInput") || name.endsWith("AvgAggregateInput") || name.endsWith("MinAggregateInput") || name.endsWith("MaxAggregateInput"), "isAggregateInputType");
10315
+ function addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes) {
10316
+ const aggregateOutputTypes = outputObjectTypes.filter(({ name }) => isAggregateOutputType(name));
10317
+ for (const aggregateOutputType of aggregateOutputTypes) {
10318
+ const name = aggregateOutputType.name.replace(/(?:OutputType|Output)$/, "");
10319
+ inputObjectTypes.push({
10320
+ constraints: {
10321
+ maxNumFields: null,
10322
+ minNumFields: null
10323
+ },
10324
+ name: `${name}Input`,
10325
+ fields: aggregateOutputType.fields.map((field) => ({
10326
+ name: field.name,
10327
+ isNullable: false,
10328
+ isRequired: false,
10329
+ inputTypes: [
10330
+ {
10331
+ isList: false,
10332
+ type: "True",
10333
+ location: "scalar"
10334
+ }
10335
+ ]
10336
+ }))
10337
+ });
10338
+ }
10339
+ }
10340
+ __name(addMissingInputObjectTypesForAggregate, "addMissingInputObjectTypesForAggregate");
10341
+ function resolveZodAggregateOperationSupport(inputObjectTypes) {
10342
+ const aggregateOperationSupport = {};
10343
+ for (const inputType of inputObjectTypes) {
10344
+ if (isAggregateInputType(inputType.name)) {
10345
+ const name = inputType.name.replace("AggregateInput", "");
10346
+ if (name.endsWith("Count")) {
10347
+ const model = name.replace("Count", "");
10348
+ aggregateOperationSupport[model] = {
10349
+ ...aggregateOperationSupport[model],
10350
+ count: true
10351
+ };
10352
+ } else if (name.endsWith("Min")) {
10353
+ const model = name.replace("Min", "");
10354
+ aggregateOperationSupport[model] = {
10355
+ ...aggregateOperationSupport[model],
10356
+ min: true
10357
+ };
10358
+ } else if (name.endsWith("Max")) {
10359
+ const model = name.replace("Max", "");
10360
+ aggregateOperationSupport[model] = {
10361
+ ...aggregateOperationSupport[model],
10362
+ max: true
10363
+ };
10364
+ } else if (name.endsWith("Sum")) {
10365
+ const model = name.replace("Sum", "");
10366
+ aggregateOperationSupport[model] = {
10367
+ ...aggregateOperationSupport[model],
10368
+ sum: true
10369
+ };
10370
+ } else if (name.endsWith("Avg")) {
10371
+ const model = name.replace("Avg", "");
10372
+ aggregateOperationSupport[model] = {
10373
+ ...aggregateOperationSupport[model],
10374
+ avg: true
10375
+ };
10376
+ }
10377
+ }
10378
+ }
10379
+ return aggregateOperationSupport;
10380
+ }
10381
+ __name(resolveZodAggregateOperationSupport, "resolveZodAggregateOperationSupport");
10382
+
10383
+ // src/zod-helpers/comments-helpers.ts
10384
+ init_esm_shims();
10385
+ var modelAttributeRegex = /(?:@@Gen\.)+[A-z]+\(.+\)/;
10386
+ var attributeNameRegex = /\.+[A-Z]+\(+/i;
10387
+ var attributeArgsRegex = /\(+[A-Z]+:.+\)/i;
10388
+ function resolveZodModelsComments(models, modelOperations, enumTypes, hiddenModels, hiddenFields) {
10389
+ models = collectHiddenModels(models, hiddenModels);
10390
+ collectHiddenFields(models, hiddenModels, hiddenFields);
10391
+ hideModelOperations(models, modelOperations);
10392
+ hideEnums(enumTypes, hiddenModels);
10393
+ }
10394
+ __name(resolveZodModelsComments, "resolveZodModelsComments");
10395
+ function collectHiddenModels(models, hiddenModels) {
10396
+ return models.map((model) => {
10397
+ if (model.documentation) {
10398
+ const attribute = model.documentation?.match(modelAttributeRegex)?.[0];
10399
+ const attributeName = attribute?.match(attributeNameRegex)?.[0]?.slice(1, -1);
10400
+ if (attributeName !== "model") {
10401
+ return model;
10402
+ }
10403
+ const rawAttributeArgs = attribute?.match(attributeArgsRegex)?.[0]?.slice(1, -1);
10404
+ const parsedAttributeArgs = {};
10405
+ if (rawAttributeArgs) {
10406
+ const rawAttributeArgsParts = rawAttributeArgs.split(":").map((it) => it.trim()).map((part) => part.startsWith("[") ? part : part.split(",")).flat().map((it) => it.trim());
10407
+ for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {
10408
+ const key = rawAttributeArgsParts[i];
10409
+ const value = rawAttributeArgsParts[i + 1];
10410
+ parsedAttributeArgs[key] = JSON.parse(value);
10411
+ }
10412
+ }
10413
+ if (parsedAttributeArgs.hide) {
10414
+ hiddenModels.push(model.name);
10415
+ return null;
10416
+ }
10417
+ }
10418
+ return model;
10419
+ }).filter(Boolean);
10420
+ }
10421
+ __name(collectHiddenModels, "collectHiddenModels");
10422
+ function collectHiddenFields(models, hiddenModels, hiddenFields) {
10423
+ models.forEach((model) => {
10424
+ model.fields.forEach((field) => {
10425
+ if (hiddenModels.includes(field.type)) {
10426
+ hiddenFields.push(field.name);
10427
+ if (field.relationFromFields) {
10428
+ field.relationFromFields.forEach((item) => hiddenFields.push(item));
10429
+ }
10430
+ }
10431
+ });
10432
+ });
10433
+ }
10434
+ __name(collectHiddenFields, "collectHiddenFields");
10435
+ function hideEnums(enumTypes, hiddenModels) {
10436
+ enumTypes.prisma = enumTypes.prisma.filter((item) => !hiddenModels.find((model) => item.name.startsWith(model)));
10437
+ }
10438
+ __name(hideEnums, "hideEnums");
10439
+ function hideModelOperations(models, modelOperations) {
10440
+ let i = modelOperations.length;
10441
+ while (i >= 0) {
10442
+ --i;
10443
+ const modelOperation = modelOperations[i];
10444
+ if (modelOperation && !models.find((model) => {
10445
+ return model.name === modelOperation.model;
10446
+ })) {
10447
+ modelOperations.splice(i, 1);
10448
+ }
10449
+ }
10450
+ }
10451
+ __name(hideModelOperations, "hideModelOperations");
10452
+ function hideZodInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels, hiddenFields) {
10453
+ let j = inputObjectTypes.length;
10454
+ while (j >= 0) {
10455
+ --j;
10456
+ const inputType = inputObjectTypes[j];
10457
+ if (inputType && (hiddenModels.includes(inputType?.meta?.source) || hiddenModels.find((model) => inputType.name.startsWith(model)))) {
10458
+ inputObjectTypes.splice(j, 1);
10459
+ } else {
10460
+ let k = inputType?.fields?.length ?? 0;
10461
+ while (k >= 0) {
10462
+ --k;
10463
+ const field = inputType?.fields?.[k];
10464
+ if (field && hiddenFields.includes(field.name)) {
10465
+ inputObjectTypes[j].fields.slice(k, 1);
10466
+ }
10467
+ }
10468
+ }
10469
+ }
10470
+ }
10471
+ __name(hideZodInputObjectTypesAndRelatedFields, "hideZodInputObjectTypesAndRelatedFields");
10472
+
10473
+ // src/zod-helpers/generator-helpers.ts
10474
+ init_esm_shims();
10475
+
10476
+ // src/zod-helpers/transformer.ts
10477
+ init_esm_shims();
10478
+ import path5 from "node:path";
10479
+
10480
+ // src/zod-helpers/model-helpers.ts
10481
+ init_esm_shims();
10482
+ function checkModelHasModelRelation(model) {
10483
+ const { fields: modelFields } = model;
10484
+ for (const modelField of modelFields) {
10485
+ const isRelationField = checkIsModelRelationField(modelField);
10486
+ if (isRelationField) {
10487
+ return true;
10488
+ }
10489
+ }
10490
+ return false;
10491
+ }
10492
+ __name(checkModelHasModelRelation, "checkModelHasModelRelation");
10493
+ function checkModelHasManyModelRelation(model) {
10494
+ const { fields: modelFields } = model;
10495
+ for (const modelField of modelFields) {
10496
+ const isManyRelationField = checkIsManyModelRelationField(modelField);
10497
+ if (isManyRelationField) {
10498
+ return true;
10499
+ }
10500
+ }
10501
+ return false;
10502
+ }
10503
+ __name(checkModelHasManyModelRelation, "checkModelHasManyModelRelation");
10504
+ function checkIsModelRelationField(modelField) {
10505
+ const { kind, relationName } = modelField;
10506
+ return kind === "object" && !!relationName;
10507
+ }
10508
+ __name(checkIsModelRelationField, "checkIsModelRelationField");
10509
+ function checkIsManyModelRelationField(modelField) {
10510
+ return checkIsModelRelationField(modelField) && modelField.isList;
10511
+ }
10512
+ __name(checkIsManyModelRelationField, "checkIsManyModelRelationField");
10513
+ function findModelByName(models, modelName) {
10514
+ return models.find(({ name }) => name === modelName);
10515
+ }
10516
+ __name(findModelByName, "findModelByName");
10517
+
10518
+ // src/zod-helpers/mongodb-helpers.ts
10519
+ init_esm_shims();
10520
+ function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes) {
10521
+ const rawOpsMap = resolveMongoDbRawOperations(modelOperations);
10522
+ Transformer.rawOpsMap = rawOpsMap ?? {};
10523
+ const mongoDbRawQueryInputObjectTypes = resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes);
10524
+ for (const mongoDbRawQueryInputType of mongoDbRawQueryInputObjectTypes) {
10525
+ inputObjectTypes.push(mongoDbRawQueryInputType);
10526
+ }
10527
+ }
10528
+ __name(addMissingInputObjectTypesForMongoDbRawOpsAndQueries, "addMissingInputObjectTypesForMongoDbRawOpsAndQueries");
10529
+ function resolveMongoDbRawOperations(modelOperations) {
10530
+ const rawOpsMap = {};
10531
+ const rawOpsNames = [
10532
+ ...new Set(modelOperations.reduce((result, current) => {
10533
+ const keys = Object.keys(current);
10534
+ keys?.forEach((key) => {
10535
+ if (key.includes("Raw")) {
10536
+ result.push(key);
10537
+ }
10538
+ });
10539
+ return result;
10540
+ }, []))
10541
+ ];
10542
+ const modelNames = modelOperations.map((item) => item.model);
10543
+ rawOpsNames.forEach((opName) => {
10544
+ modelNames.forEach((modelName) => {
10545
+ const isFind = opName === "findRaw";
10546
+ const opWithModel = `${opName.replace("Raw", "")}${modelName}Raw`;
10547
+ rawOpsMap[opWithModel] = isFind ? `${modelName}FindRawArgs` : `${modelName}AggregateRawArgs`;
10548
+ });
10549
+ });
10550
+ return rawOpsMap;
10551
+ }
10552
+ __name(resolveMongoDbRawOperations, "resolveMongoDbRawOperations");
10553
+ function resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes) {
10554
+ const mongoDbRawQueries = getMongoDbRawQueries(outputObjectTypes);
10555
+ const mongoDbRawQueryInputObjectTypes = mongoDbRawQueries.map((item) => ({
10556
+ name: item.name,
10557
+ constraints: {
10558
+ maxNumFields: null,
10559
+ minNumFields: null
10560
+ },
10561
+ fields: item.args.map((arg) => ({
10562
+ name: arg.name,
10563
+ isRequired: arg.isRequired,
10564
+ isNullable: arg.isNullable,
10565
+ inputTypes: arg.inputTypes
10566
+ }))
10567
+ }));
10568
+ return mongoDbRawQueryInputObjectTypes;
10569
+ }
10570
+ __name(resolveMongoDbRawQueryInputObjectTypes, "resolveMongoDbRawQueryInputObjectTypes");
10571
+ function getMongoDbRawQueries(outputObjectTypes) {
10572
+ const queryOutputTypes = outputObjectTypes.filter((item) => item.name === "Query");
10573
+ const mongodbRawQueries = queryOutputTypes?.[0].fields.filter((field) => field.name.includes("Raw")) ?? [];
10574
+ return mongodbRawQueries;
10575
+ }
10576
+ __name(getMongoDbRawQueries, "getMongoDbRawQueries");
10577
+ var isMongodbRawOp = /* @__PURE__ */ __name((name) => /find[\s\S]*?Raw/.test(name) || /aggregate[\s\S]*?Raw/.test(name), "isMongodbRawOp");
10578
+
10579
+ // src/zod-helpers/transformer.ts
10580
+ var Transformer = class _Transformer {
10581
+ static {
10582
+ __name(this, "Transformer");
10583
+ }
10584
+ name;
10585
+ fields;
10586
+ schemaImports = /* @__PURE__ */ new Set();
10587
+ models;
10588
+ modelOperations;
10589
+ aggregateOperationSupport;
10590
+ enumTypes;
10591
+ static enumNames = [];
10592
+ static rawOpsMap = {};
10593
+ static provider;
10594
+ static previewFeatures;
10595
+ static outputPath = "./generated";
10596
+ hasJson = false;
10597
+ static prismaClientOutputPath = "@prisma/client";
10598
+ static isCustomPrismaClientOutputPath = false;
10599
+ static isGenerateSelect = false;
10600
+ static isGenerateInclude = false;
10601
+ constructor(params) {
10602
+ this.name = params.name ?? "";
10603
+ this.fields = params.fields ?? [];
10604
+ this.models = params.models ?? [];
10605
+ this.modelOperations = params.modelOperations ?? [];
10606
+ this.aggregateOperationSupport = params.aggregateOperationSupport ?? {};
10607
+ this.enumTypes = params.enumTypes ?? [];
10608
+ }
10609
+ static setOutputPath(outPath) {
10610
+ this.outputPath = outPath;
10611
+ }
10612
+ static setIsGenerateSelect(isGenerateSelect) {
10613
+ this.isGenerateSelect = isGenerateSelect;
10614
+ }
10615
+ static setIsGenerateInclude(isGenerateInclude) {
10616
+ this.isGenerateInclude = isGenerateInclude;
10617
+ }
10618
+ static getOutputPath() {
10619
+ return this.outputPath;
10620
+ }
10621
+ static setPrismaClientOutputPath(prismaClientCustomPath) {
10622
+ this.prismaClientOutputPath = prismaClientCustomPath;
10623
+ this.isCustomPrismaClientOutputPath = prismaClientCustomPath !== "@prisma/client";
10624
+ }
10625
+ static async generateIndex() {
10626
+ const indexPath = path5.join(_Transformer.outputPath, "schemas/index.ts");
10627
+ await writeIndexFile(indexPath);
10628
+ }
10629
+ async generateEnumSchemas() {
10630
+ for (const enumType2 of this.enumTypes) {
10631
+ const { name, values } = enumType2;
10632
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/enums/${name}.schema.ts`), `${this.generateImportZodStatement()}
10633
+ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)})`)}`);
10634
+ }
10635
+ }
10636
+ generateImportZodStatement() {
10637
+ return "import { z } from 'zod';\n";
10638
+ }
10639
+ generateExportSchemaStatement(name, schema) {
10640
+ return `export const ${name}Schema = ${schema}`;
10641
+ }
10642
+ async generateObjectSchema() {
10643
+ const zodObjectSchemaFields = this.generateObjectSchemaFields();
10644
+ const objectSchema = this.prepareObjectSchema(zodObjectSchemaFields);
10645
+ const objectSchemaName = this.resolveObjectSchemaName();
10646
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/objects/${objectSchemaName}.schema.ts`), objectSchema);
10647
+ }
10648
+ generateObjectSchemaFields() {
10649
+ const zodObjectSchemaFields = this.fields.map((field) => this.generateObjectSchemaField(field)).flatMap((item) => item).map((item) => {
10650
+ const [zodStringWithMainType, field, skipValidators] = item;
10651
+ const value = skipValidators ? zodStringWithMainType : this.generateFieldValidators(zodStringWithMainType, field);
10652
+ return value.trim();
10653
+ });
10654
+ return zodObjectSchemaFields;
10655
+ }
10656
+ generateObjectSchemaField(field) {
10657
+ const lines = field.inputTypes;
10658
+ if (lines.length === 0) {
10659
+ return [];
10660
+ }
10661
+ let alternatives = lines.reduce((result, inputType) => {
10662
+ if (inputType.type === "String") {
10663
+ result.push(this.wrapWithZodValidators("z.string()", field));
10664
+ } else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
10665
+ result.push(this.wrapWithZodValidators("z.number()", field));
10666
+ } else if (inputType.type === "BigInt") {
10667
+ result.push(this.wrapWithZodValidators("z.bigint()", field));
10668
+ } else if (inputType.type === "Boolean") {
10669
+ result.push(this.wrapWithZodValidators("z.boolean()", field));
10670
+ } else if (inputType.type === "DateTime") {
10671
+ result.push(this.wrapWithZodValidators("z.coerce.date()", field));
10672
+ } else if (inputType.type === "Json") {
10673
+ this.hasJson = true;
10674
+ result.push(this.wrapWithZodValidators("jsonSchema", field));
10675
+ } else if (inputType.type === "True") {
10676
+ result.push(this.wrapWithZodValidators("z.literal(true)", field));
10677
+ } else if (inputType.type === "Bytes") {
10678
+ result.push(this.wrapWithZodValidators("z.instanceof(Buffer)", field));
10679
+ } else {
10680
+ const isEnum = inputType.location === "enumTypes";
10681
+ if (inputType.namespace === "prisma" || isEnum) {
10682
+ if (inputType.type !== this.name && typeof inputType.type === "string") {
10683
+ this.addSchemaImport(inputType.type);
10684
+ }
10685
+ result.push(this.generatePrismaStringLine(field, lines.length));
10686
+ }
10687
+ }
10688
+ return result;
10689
+ }, []);
10690
+ if (alternatives.length === 0) {
10691
+ return [];
10692
+ }
10693
+ if (alternatives.length > 1) {
10694
+ alternatives = alternatives.map((alter) => alter.replace(".optional()", ""));
10695
+ }
10696
+ const fieldName = alternatives.some((alt) => alt.includes(":")) ? "" : ` ${field.name}:`;
10697
+ const opt = !field.isRequired ? ".optional()" : "";
10698
+ let resString = alternatives.length === 1 ? alternatives.join(",\r\n") : `z.union([${alternatives.join(",\r\n")}])${opt}`;
10699
+ if (field.isNullable) {
10700
+ resString += ".nullable()";
10701
+ }
10702
+ return [
10703
+ [
10704
+ ` ${fieldName} ${resString} `,
10705
+ field,
10706
+ true
10707
+ ]
10708
+ ];
10709
+ }
10710
+ wrapWithZodValidators(mainValidator, field) {
10711
+ let line = "";
10712
+ line = mainValidator;
10713
+ if (field.inputTypes.some((inputType) => inputType.isList)) {
10714
+ line += ".array()";
10715
+ }
10716
+ if (!field.isRequired) {
10717
+ line += ".optional()";
10718
+ }
10719
+ return line;
10720
+ }
10721
+ addSchemaImport(name) {
10722
+ this.schemaImports.add(name);
10723
+ }
10724
+ generatePrismaStringLine(field, inputsLength) {
10725
+ if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
10726
+ return "";
10727
+ }
10728
+ const inputType = field.inputTypes[0];
10729
+ const isEnum = inputType.location === "enumTypes";
10730
+ const inputTypeString = inputType.type;
10731
+ const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
10732
+ const objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputTypeString}ObjectSchema`;
10733
+ const enumSchemaLine = `${inputTypeString}Schema`;
10734
+ const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
10735
+ const arr = inputType.isList ? ".array()" : "";
10736
+ const opt = !field.isRequired ? ".optional()" : "";
10737
+ const nullable = field.inputTypes.length > 1 && field.inputTypes[1]?.type === "Null" ? ".nullable()" : "";
10738
+ return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}` : `z.lazy(() => ${schema})${arr}${opt}${nullable}`;
10739
+ }
10740
+ generateFieldValidators(zodStringWithMainType, field) {
10741
+ const { isRequired, isNullable } = field;
10742
+ if (!isRequired) {
10743
+ zodStringWithMainType += ".optional()";
10744
+ }
10745
+ if (isNullable) {
10746
+ zodStringWithMainType += ".nullable()";
10747
+ }
10748
+ return zodStringWithMainType;
10749
+ }
10750
+ prepareObjectSchema(zodObjectSchemaFields) {
10751
+ const objectSchema = `${this.generateExportObjectSchemaStatement(this.addFinalWrappers({
10752
+ zodStringFields: zodObjectSchemaFields
10753
+ }))}
10754
+ `;
10755
+ const prismaImportStatement = this.generateImportPrismaStatement();
10756
+ const json = this.generateJsonSchemaImplementation();
10757
+ return `${this.generateObjectSchemaImportStatements()}${prismaImportStatement}${json}${objectSchema}`;
10758
+ }
10759
+ generateExportObjectSchemaStatement(schema) {
10760
+ let name = this.name;
10761
+ let exportName = this.name;
10762
+ if (_Transformer.provider === "mongodb") {
10763
+ if (isMongodbRawOp(name)) {
10764
+ name = _Transformer.rawOpsMap[name];
10765
+ exportName = name.replace("Args", "");
10766
+ }
10767
+ }
10768
+ if (isAggregateInputType(name)) {
10769
+ name = `${name}Type`;
10770
+ }
10771
+ const end = `export const ${exportName}ObjectSchema = Schema`;
10772
+ return `const Schema: z.ZodType<Prisma.${name}> = ${schema};
10773
+
10774
+ ${end}`;
10775
+ }
10776
+ addFinalWrappers({ zodStringFields }) {
10777
+ const fields = [
10778
+ ...zodStringFields
10779
+ ];
10780
+ return `${this.wrapWithZodObject(fields)}.strict()`;
10781
+ }
10782
+ generateImportPrismaStatement() {
10783
+ let prismaClientImportPath;
10784
+ if (_Transformer.isCustomPrismaClientOutputPath) {
10785
+ const fromPath = path5.join(_Transformer.outputPath, "schemas", "objects");
10786
+ const toPath = _Transformer.prismaClientOutputPath;
10787
+ const relativePathFromOutputToPrismaClient = path5.relative(fromPath, toPath).split(path5.sep).join(path5.posix.sep);
10788
+ prismaClientImportPath = relativePathFromOutputToPrismaClient;
10789
+ } else {
10790
+ prismaClientImportPath = _Transformer.prismaClientOutputPath;
10791
+ }
10792
+ return `import type { Prisma } from '${prismaClientImportPath}';
10793
+
10794
+ `;
10795
+ }
10796
+ generateJsonSchemaImplementation() {
10797
+ let jsonSchemaImplementation = "";
10798
+ if (this.hasJson) {
10799
+ jsonSchemaImplementation += `
10800
+ `;
10801
+ jsonSchemaImplementation += `const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
10802
+ `;
10803
+ jsonSchemaImplementation += `const jsonSchema: z.ZodType<Prisma.InputJsonValue> = z.lazy(() =>
10804
+ `;
10805
+ jsonSchemaImplementation += ` z.union([literalSchema, z.array(jsonSchema.nullable()), z.record(jsonSchema.nullable())])
10806
+ `;
10807
+ jsonSchemaImplementation += `);
10808
+
10809
+ `;
10810
+ }
10811
+ return jsonSchemaImplementation;
10812
+ }
10813
+ generateObjectSchemaImportStatements() {
10814
+ let generatedImports = this.generateImportZodStatement();
10815
+ generatedImports += this.generateSchemaImports();
10816
+ generatedImports += "\n\n";
10817
+ return generatedImports;
10818
+ }
10819
+ generateSchemaImports() {
10820
+ return [
10821
+ ...this.schemaImports
10822
+ ].map((name) => {
10823
+ const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(name);
10824
+ if (isModelQueryType) {
10825
+ return `import { ${this.resolveModelQuerySchemaName(modelName, queryName)} } from '../${queryName}${modelName}.schema'`;
10826
+ } else if (_Transformer.enumNames.includes(name)) {
10827
+ return `import { ${name}Schema } from '../enums/${name}.schema'`;
10828
+ } else {
10829
+ return `import { ${name}ObjectSchema } from './${name}.schema'`;
10830
+ }
10831
+ }).join(";\r\n");
10832
+ }
10833
+ checkIsModelQueryType(type) {
10834
+ const modelQueryTypeSuffixToQueryName = {
10835
+ FindManyArgs: "findMany"
10836
+ };
10837
+ for (const modelQueryType of [
10838
+ "FindManyArgs"
10839
+ ]) {
10840
+ if (type.includes(modelQueryType)) {
10841
+ const modelQueryTypeSuffixIndex = type.indexOf(modelQueryType);
10842
+ return {
10843
+ isModelQueryType: true,
10844
+ modelName: type.substring(0, modelQueryTypeSuffixIndex),
10845
+ queryName: modelQueryTypeSuffixToQueryName[modelQueryType]
10846
+ };
10847
+ }
10848
+ }
10849
+ return {
10850
+ isModelQueryType: false
10851
+ };
10852
+ }
10853
+ resolveModelQuerySchemaName(modelName, queryName) {
10854
+ const modelNameCapitalized = modelName.charAt(0).toUpperCase() + modelName.slice(1);
10855
+ const queryNameCapitalized = queryName.charAt(0).toUpperCase() + queryName.slice(1);
10856
+ return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
10857
+ }
10858
+ wrapWithZodUnion(zodStringFields) {
10859
+ let wrapped = "";
10860
+ wrapped += "z.union([";
10861
+ wrapped += "\n";
10862
+ wrapped += ` ${zodStringFields.join(",")}`;
10863
+ wrapped += "\n";
10864
+ wrapped += "])";
10865
+ return wrapped;
10866
+ }
10867
+ wrapWithZodObject(zodStringFields) {
10868
+ let wrapped = "";
10869
+ wrapped += "z.object({";
10870
+ wrapped += "\n";
10871
+ wrapped += ` ${typeof zodStringFields === "string" ? zodStringFields : zodStringFields.join(",\n ")}`;
10872
+ wrapped += "\n";
10873
+ wrapped += "})";
10874
+ return wrapped;
10875
+ }
10876
+ resolveObjectSchemaName() {
10877
+ let name = this.name;
10878
+ let exportName = this.name;
10879
+ if (isMongodbRawOp(name)) {
10880
+ name = _Transformer.rawOpsMap[name];
10881
+ exportName = name.replace("Args", "");
10882
+ }
10883
+ return exportName;
10884
+ }
10885
+ async generateModelSchemas() {
10886
+ for (const modelOperation of this.modelOperations) {
10887
+ const {
10888
+ model: modelName,
10889
+ findUnique,
10890
+ findFirst,
10891
+ findMany,
10892
+ // @ts-ignore
10893
+ createOne,
10894
+ createMany,
10895
+ // @ts-ignore
10896
+ deleteOne,
10897
+ // @ts-ignore
10898
+ updateOne,
10899
+ deleteMany,
10900
+ updateMany,
10901
+ // @ts-ignore
10902
+ upsertOne,
10903
+ aggregate,
10904
+ groupBy
10905
+ } = modelOperation;
10906
+ const model = findModelByName(this.models, modelName);
10907
+ const { selectImport, includeImport, selectZodSchemaLine, includeZodSchemaLine, selectZodSchemaLineLazy, includeZodSchemaLineLazy } = this.resolveSelectIncludeImportAndZodSchemaLine(model);
10908
+ const { orderByImport, orderByZodSchemaLine } = this.resolveOrderByWithRelationImportAndZodSchemaLine(model);
10909
+ if (findUnique) {
10910
+ const imports = [
10911
+ selectImport,
10912
+ includeImport,
10913
+ `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
10914
+ ];
10915
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${findUnique}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindUnique`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
10916
+ }
10917
+ if (findFirst) {
10918
+ const imports = [
10919
+ selectImport,
10920
+ includeImport,
10921
+ orderByImport,
10922
+ `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
10923
+ `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
10924
+ `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
10925
+ ];
10926
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${findFirst}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindFirst`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${modelName}ScalarFieldEnumSchema).optional() })`)}`);
10927
+ }
10928
+ if (findMany) {
10929
+ const imports = [
10930
+ selectImport,
10931
+ includeImport,
10932
+ orderByImport,
10933
+ `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
10934
+ `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
10935
+ `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
10936
+ ];
10937
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${findMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindMany`, `z.object({ ${selectZodSchemaLineLazy} ${includeZodSchemaLineLazy} ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${modelName}ScalarFieldEnumSchema).optional() })`)}`);
10938
+ }
10939
+ if (createOne) {
10940
+ const imports = [
10941
+ selectImport,
10942
+ includeImport,
10943
+ `import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
10944
+ `import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`
10945
+ ];
10946
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${createOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} data: z.union([${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema]) })`)}`);
10947
+ }
10948
+ if (createMany) {
10949
+ const imports = [
10950
+ `import { ${modelName}CreateManyInputObjectSchema } from './objects/${modelName}CreateManyInput.schema'`
10951
+ ];
10952
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${createMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateMany`, `z.object({ data: z.union([ ${modelName}CreateManyInputObjectSchema, z.array(${modelName}CreateManyInputObjectSchema) ]), ${_Transformer.provider === "mongodb" || _Transformer.provider === "sqlserver" ? "" : "skipDuplicates: z.boolean().optional()"} })`)}`);
10953
+ }
10954
+ if (deleteOne) {
10955
+ const imports = [
10956
+ selectImport,
10957
+ includeImport,
10958
+ `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
10959
+ ];
10960
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${deleteOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
10961
+ }
10962
+ if (deleteMany) {
10963
+ const imports = [
10964
+ `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
10965
+ ];
10966
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${deleteMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteMany`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
10967
+ }
10968
+ if (updateOne) {
10969
+ const imports = [
10970
+ selectImport,
10971
+ includeImport,
10972
+ `import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
10973
+ `import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`,
10974
+ `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
10975
+ ];
10976
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${updateOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} data: z.union([${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema]), where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
10977
+ }
10978
+ if (updateMany) {
10979
+ const imports = [
10980
+ `import { ${modelName}UpdateManyMutationInputObjectSchema } from './objects/${modelName}UpdateManyMutationInput.schema'`,
10981
+ `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
10982
+ ];
10983
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${updateMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateMany`, `z.object({ data: ${modelName}UpdateManyMutationInputObjectSchema, where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
10984
+ }
10985
+ if (upsertOne) {
10986
+ const imports = [
10987
+ selectImport,
10988
+ includeImport,
10989
+ `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
10990
+ `import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
10991
+ `import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`,
10992
+ `import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
10993
+ `import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`
10994
+ ];
10995
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${upsertOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}Upsert`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema, create: z.union([ ${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema ]), update: z.union([ ${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema ]) })`)}`);
10996
+ }
10997
+ if (aggregate) {
10998
+ const imports = [
10999
+ orderByImport,
11000
+ `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
11001
+ `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
11002
+ ];
11003
+ const aggregateOperations = [];
11004
+ if (this.aggregateOperationSupport[modelName]) {
11005
+ if (this.aggregateOperationSupport[modelName].count) {
11006
+ imports.push(`import { ${modelName}CountAggregateInputObjectSchema } from './objects/${modelName}CountAggregateInput.schema'`);
11007
+ aggregateOperations.push(`_count: z.union([ z.literal(true), ${modelName}CountAggregateInputObjectSchema ]).optional()`);
11008
+ }
11009
+ if (this.aggregateOperationSupport[modelName].min) {
11010
+ imports.push(`import { ${modelName}MinAggregateInputObjectSchema } from './objects/${modelName}MinAggregateInput.schema'`);
11011
+ aggregateOperations.push(`_min: ${modelName}MinAggregateInputObjectSchema.optional()`);
11012
+ }
11013
+ if (this.aggregateOperationSupport[modelName].max) {
11014
+ imports.push(`import { ${modelName}MaxAggregateInputObjectSchema } from './objects/${modelName}MaxAggregateInput.schema'`);
11015
+ aggregateOperations.push(`_max: ${modelName}MaxAggregateInputObjectSchema.optional()`);
11016
+ }
11017
+ if (this.aggregateOperationSupport[modelName].avg) {
11018
+ imports.push(`import { ${modelName}AvgAggregateInputObjectSchema } from './objects/${modelName}AvgAggregateInput.schema'`);
11019
+ aggregateOperations.push(`_avg: ${modelName}AvgAggregateInputObjectSchema.optional()`);
11020
+ }
11021
+ if (this.aggregateOperationSupport[modelName].sum) {
11022
+ imports.push(`import { ${modelName}SumAggregateInputObjectSchema } from './objects/${modelName}SumAggregateInput.schema'`);
11023
+ aggregateOperations.push(`_sum: ${modelName}SumAggregateInputObjectSchema.optional()`);
11024
+ }
11025
+ }
11026
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${aggregate}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}Aggregate`, `z.object({ ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), ${aggregateOperations.join(", ")} })`)}`);
11027
+ }
11028
+ if (groupBy) {
11029
+ const imports = [
11030
+ `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
11031
+ `import { ${modelName}OrderByWithAggregationInputObjectSchema } from './objects/${modelName}OrderByWithAggregationInput.schema'`,
11032
+ `import { ${modelName}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${modelName}ScalarWhereWithAggregatesInput.schema'`,
11033
+ `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
11034
+ ];
11035
+ await writeFileSafely(path5.join(_Transformer.outputPath, `schemas/${groupBy}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}GroupBy`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional(), orderBy: z.union([${modelName}OrderByWithAggregationInputObjectSchema, ${modelName}OrderByWithAggregationInputObjectSchema.array()]).optional(), having: ${modelName}ScalarWhereWithAggregatesInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), by: z.array(${modelName}ScalarFieldEnumSchema) })`)}`);
11036
+ }
11037
+ }
11038
+ }
11039
+ generateImportStatements(imports) {
11040
+ let generatedImports = this.generateImportZodStatement();
11041
+ generatedImports += imports?.filter((importItem) => !!importItem).join(";\r\n") ?? "";
11042
+ generatedImports += "\n\n";
11043
+ return generatedImports;
11044
+ }
11045
+ resolveSelectIncludeImportAndZodSchemaLine(model) {
11046
+ const { name: modelName } = model;
11047
+ const hasRelationToAnotherModel = checkModelHasModelRelation(model);
11048
+ const selectImport = _Transformer.isGenerateSelect ? `import { ${modelName}SelectObjectSchema } from './objects/${modelName}Select.schema'` : "";
11049
+ const includeImport = _Transformer.isGenerateInclude && hasRelationToAnotherModel ? `import { ${modelName}IncludeObjectSchema } from './objects/${modelName}Include.schema'` : "";
11050
+ let selectZodSchemaLine = "";
11051
+ let includeZodSchemaLine = "";
11052
+ let selectZodSchemaLineLazy = "";
11053
+ let includeZodSchemaLineLazy = "";
11054
+ if (_Transformer.isGenerateSelect) {
11055
+ const zodSelectObjectSchema = `${modelName}SelectObjectSchema.optional()`;
11056
+ selectZodSchemaLine = `select: ${zodSelectObjectSchema},`;
11057
+ selectZodSchemaLineLazy = `select: z.lazy(() => ${zodSelectObjectSchema}),`;
11058
+ }
11059
+ if (_Transformer.isGenerateInclude && hasRelationToAnotherModel) {
11060
+ const zodIncludeObjectSchema = `${modelName}IncludeObjectSchema.optional()`;
11061
+ includeZodSchemaLine = `include: ${zodIncludeObjectSchema},`;
11062
+ includeZodSchemaLineLazy = `include: z.lazy(() => ${zodIncludeObjectSchema}),`;
11063
+ }
11064
+ return {
11065
+ selectImport,
11066
+ includeImport,
11067
+ selectZodSchemaLine,
11068
+ includeZodSchemaLine,
11069
+ selectZodSchemaLineLazy,
11070
+ includeZodSchemaLineLazy
11071
+ };
11072
+ }
11073
+ resolveOrderByWithRelationImportAndZodSchemaLine(model) {
11074
+ const { name: modelName } = model;
11075
+ let modelOrderBy = "";
11076
+ if ([
11077
+ "postgresql",
11078
+ "mysql"
11079
+ ].includes(_Transformer.provider) && _Transformer.previewFeatures?.includes("fullTextSearch")) {
11080
+ modelOrderBy = `${modelName}OrderByWithRelationAndSearchRelevanceInput`;
11081
+ } else {
11082
+ modelOrderBy = `${modelName}OrderByWithRelationInput`;
11083
+ }
11084
+ const orderByImport = `import { ${modelOrderBy}ObjectSchema } from './objects/${modelOrderBy}.schema'`;
11085
+ const orderByZodSchemaLine = `orderBy: z.union([${modelOrderBy}ObjectSchema, ${modelOrderBy}ObjectSchema.array()]).optional(),`;
11086
+ return {
11087
+ orderByImport,
11088
+ orderByZodSchemaLine
11089
+ };
11090
+ }
11091
+ };
11092
+
11093
+ // src/zod-helpers/generator-helpers.ts
11094
+ async function generateZodEnumSchemas(prismaSchemaEnum, modelSchemaEnum) {
11095
+ const enumTypes = [
11096
+ ...prismaSchemaEnum,
11097
+ ...modelSchemaEnum
11098
+ ];
11099
+ const enumNames = enumTypes.map((enumItem) => enumItem.name);
11100
+ Transformer.enumNames = enumNames ?? [];
11101
+ const transformer = new Transformer({
11102
+ enumTypes
11103
+ });
11104
+ await transformer.generateEnumSchemas();
11105
+ }
11106
+ __name(generateZodEnumSchemas, "generateZodEnumSchemas");
11107
+ async function generateZodObjectSchemas(inputObjectTypes) {
11108
+ for (let i = 0; i < inputObjectTypes.length; i += 1) {
11109
+ const fields = inputObjectTypes[i]?.fields;
11110
+ const name = inputObjectTypes[i]?.name;
11111
+ const transformer = new Transformer({
11112
+ name,
11113
+ fields
11114
+ });
11115
+ await transformer.generateObjectSchema();
11116
+ }
11117
+ }
11118
+ __name(generateZodObjectSchemas, "generateZodObjectSchemas");
11119
+ async function generateZodModelSchemas(models, modelOperations, aggregateOperationSupport) {
11120
+ const transformer = new Transformer({
11121
+ models,
11122
+ modelOperations,
11123
+ aggregateOperationSupport
11124
+ });
11125
+ await transformer.generateModelSchemas();
11126
+ }
11127
+ __name(generateZodModelSchemas, "generateZodModelSchemas");
11128
+ async function generateZodIndex() {
11129
+ await Transformer.generateIndex();
11130
+ }
11131
+ __name(generateZodIndex, "generateZodIndex");
11132
+
11133
+ // src/zod-helpers/helpers.ts
11134
+ init_esm_shims();
11135
+
11136
+ // src/zod-helpers/include-helpers.ts
11137
+ init_esm_shims();
11138
+ function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
11139
+ const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
11140
+ for (const includeInputObjectType of generatedIncludeInputObjectTypes) {
11141
+ inputObjectTypes.push(includeInputObjectType);
11142
+ }
11143
+ }
11144
+ __name(addMissingInputObjectTypesForInclude, "addMissingInputObjectTypesForInclude");
11145
+ function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
11146
+ const modelIncludeInputObjectTypes = [];
11147
+ for (const model of models) {
11148
+ const { name: modelName, fields: modelFields } = model;
11149
+ const fields = [];
11150
+ for (const modelField of modelFields) {
11151
+ const { name: modelFieldName, isList, type } = modelField;
11152
+ const isRelationField = checkIsModelRelationField(modelField);
11153
+ if (isRelationField) {
11154
+ const field = {
11155
+ name: modelFieldName,
11156
+ isRequired: false,
11157
+ isNullable: false,
11158
+ inputTypes: [
11159
+ {
11160
+ isList: false,
11161
+ type: "Boolean",
11162
+ location: "scalar"
11163
+ },
11164
+ {
11165
+ isList: false,
11166
+ type: isList ? `${type}FindManyArgs` : `${type}Args`,
11167
+ location: "inputObjectTypes",
11168
+ namespace: "prisma"
11169
+ }
11170
+ ]
11171
+ };
11172
+ fields.push(field);
11173
+ }
11174
+ }
11175
+ const hasRelationToAnotherModel = checkModelHasModelRelation(model);
11176
+ if (!hasRelationToAnotherModel) {
11177
+ continue;
11178
+ }
11179
+ const hasManyRelationToAnotherModel = checkModelHasManyModelRelation(model);
11180
+ const shouldAddCountField = hasManyRelationToAnotherModel;
11181
+ if (shouldAddCountField) {
11182
+ const inputTypes = [
11183
+ {
11184
+ isList: false,
11185
+ type: "Boolean",
11186
+ location: "scalar"
11187
+ }
11188
+ ];
11189
+ if (isGenerateSelect) {
11190
+ inputTypes.push({
11191
+ isList: false,
11192
+ type: `${modelName}CountOutputTypeArgs`,
11193
+ location: "inputObjectTypes",
11194
+ namespace: "prisma"
11195
+ });
11196
+ }
11197
+ const _countField = {
11198
+ name: "_count",
11199
+ isRequired: false,
11200
+ isNullable: false,
11201
+ inputTypes
11202
+ };
11203
+ fields.push(_countField);
11204
+ }
11205
+ const modelIncludeInputObjectType = {
11206
+ name: `${modelName}Include`,
11207
+ constraints: {
11208
+ maxNumFields: null,
11209
+ minNumFields: null
11210
+ },
11211
+ fields
11212
+ };
11213
+ modelIncludeInputObjectTypes.push(modelIncludeInputObjectType);
11214
+ }
11215
+ return modelIncludeInputObjectTypes;
11216
+ }
11217
+ __name(generateModelIncludeInputObjectTypes, "generateModelIncludeInputObjectTypes");
11218
+
11219
+ // src/zod-helpers/modelArgs-helpers.ts
11220
+ init_esm_shims();
11221
+ function addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, isGenerateSelect, isGenerateInclude) {
11222
+ const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude);
11223
+ for (const modelArgsInputObjectType of modelArgsInputObjectTypes) {
11224
+ inputObjectTypes.push(modelArgsInputObjectType);
11225
+ }
11226
+ }
11227
+ __name(addMissingInputObjectTypesForModelArgs, "addMissingInputObjectTypesForModelArgs");
11228
+ function generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude) {
11229
+ const modelArgsInputObjectTypes = [];
11230
+ for (const model of models) {
11231
+ const { name: modelName } = model;
11232
+ const fields = [];
11233
+ if (isGenerateSelect) {
11234
+ const selectField = {
11235
+ name: "select",
11236
+ isRequired: false,
11237
+ isNullable: false,
11238
+ inputTypes: [
11239
+ {
11240
+ isList: false,
11241
+ type: `${modelName}Select`,
11242
+ location: "inputObjectTypes",
11243
+ namespace: "prisma"
11244
+ }
11245
+ ]
11246
+ };
11247
+ fields.push(selectField);
11248
+ }
11249
+ const hasRelationToAnotherModel = checkModelHasModelRelation(model);
11250
+ if (isGenerateInclude && hasRelationToAnotherModel) {
11251
+ const includeField = {
11252
+ name: "include",
11253
+ isRequired: false,
11254
+ isNullable: false,
11255
+ inputTypes: [
11256
+ {
11257
+ isList: false,
11258
+ type: `${modelName}Include`,
11259
+ location: "inputObjectTypes",
11260
+ namespace: "prisma"
11261
+ }
11262
+ ]
11263
+ };
11264
+ fields.push(includeField);
11265
+ }
11266
+ const modelArgsInputObjectType = {
11267
+ name: `${modelName}Args`,
11268
+ constraints: {
11269
+ maxNumFields: null,
11270
+ minNumFields: null
11271
+ },
11272
+ fields
11273
+ };
11274
+ modelArgsInputObjectTypes.push(modelArgsInputObjectType);
11275
+ }
11276
+ return modelArgsInputObjectTypes;
11277
+ }
11278
+ __name(generateModelArgsInputObjectTypes, "generateModelArgsInputObjectTypes");
11279
+
11280
+ // src/zod-helpers/select-helpers.ts
11281
+ init_esm_shims();
11282
+ function addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models) {
11283
+ const modelCountOutputTypes = getModelCountOutputTypes(outputObjectTypes);
11284
+ const modelCountOutputTypeSelectInputObjectTypes = generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes);
11285
+ const modelCountOutputTypeArgsInputObjectTypes = generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes);
11286
+ const modelSelectInputObjectTypes = generateModelSelectInputObjectTypes(models);
11287
+ const generatedInputObjectTypes = [
11288
+ modelCountOutputTypeSelectInputObjectTypes,
11289
+ modelCountOutputTypeArgsInputObjectTypes,
11290
+ modelSelectInputObjectTypes
11291
+ ].flat();
11292
+ for (const inputObjectType of generatedInputObjectTypes) {
11293
+ inputObjectTypes.push(inputObjectType);
11294
+ }
11295
+ }
11296
+ __name(addMissingInputObjectTypesForSelect, "addMissingInputObjectTypesForSelect");
11297
+ function getModelCountOutputTypes(outputObjectTypes) {
11298
+ return outputObjectTypes.filter(({ name }) => name.includes("CountOutputType"));
11299
+ }
11300
+ __name(getModelCountOutputTypes, "getModelCountOutputTypes");
11301
+ function generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes) {
11302
+ const modelCountOutputTypeSelectInputObjectTypes = [];
11303
+ for (const modelCountOutputType of modelCountOutputTypes) {
11304
+ const { name: modelCountOutputTypeName, fields: modelCountOutputTypeFields } = modelCountOutputType;
11305
+ const modelCountOutputTypeSelectInputObjectType = {
11306
+ name: `${modelCountOutputTypeName}Select`,
11307
+ constraints: {
11308
+ maxNumFields: null,
11309
+ minNumFields: null
11310
+ },
11311
+ fields: modelCountOutputTypeFields.map(({ name }) => ({
11312
+ name,
11313
+ isRequired: false,
11314
+ isNullable: false,
11315
+ inputTypes: [
11316
+ {
11317
+ isList: false,
11318
+ type: `Boolean`,
11319
+ location: "scalar"
11320
+ }
11321
+ ]
11322
+ }))
11323
+ };
11324
+ modelCountOutputTypeSelectInputObjectTypes.push(modelCountOutputTypeSelectInputObjectType);
11325
+ }
11326
+ return modelCountOutputTypeSelectInputObjectTypes;
11327
+ }
11328
+ __name(generateModelCountOutputTypeSelectInputObjectTypes, "generateModelCountOutputTypeSelectInputObjectTypes");
11329
+ function generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes) {
11330
+ const modelCountOutputTypeArgsInputObjectTypes = [];
11331
+ for (const modelCountOutputType of modelCountOutputTypes) {
11332
+ const { name: modelCountOutputTypeName } = modelCountOutputType;
11333
+ const modelCountOutputTypeArgsInputObjectType = {
11334
+ name: `${modelCountOutputTypeName}Args`,
11335
+ constraints: {
11336
+ maxNumFields: null,
11337
+ minNumFields: null
11338
+ },
11339
+ fields: [
11340
+ {
11341
+ name: "select",
11342
+ isRequired: false,
11343
+ isNullable: false,
11344
+ inputTypes: [
11345
+ {
11346
+ isList: false,
11347
+ type: `${modelCountOutputTypeName}Select`,
11348
+ location: "inputObjectTypes",
11349
+ namespace: "prisma"
11350
+ }
11351
+ ]
11352
+ }
11353
+ ]
11354
+ };
11355
+ modelCountOutputTypeArgsInputObjectTypes.push(modelCountOutputTypeArgsInputObjectType);
11356
+ }
11357
+ return modelCountOutputTypeArgsInputObjectTypes;
11358
+ }
11359
+ __name(generateModelCountOutputTypeArgsInputObjectTypes, "generateModelCountOutputTypeArgsInputObjectTypes");
11360
+ function generateModelSelectInputObjectTypes(models) {
11361
+ const modelSelectInputObjectTypes = [];
11362
+ for (const model of models) {
11363
+ const { name: modelName, fields: modelFields } = model;
11364
+ const fields = [];
11365
+ for (const modelField of modelFields) {
11366
+ const { name: modelFieldName, isList, type } = modelField;
11367
+ const isRelationField = checkIsModelRelationField(modelField);
11368
+ const field = {
11369
+ name: modelFieldName,
11370
+ isRequired: false,
11371
+ isNullable: false,
11372
+ inputTypes: [
11373
+ {
11374
+ isList: false,
11375
+ type: "Boolean",
11376
+ location: "scalar"
11377
+ }
11378
+ ]
11379
+ };
11380
+ if (isRelationField) {
11381
+ const schemaArgInputType = {
11382
+ isList: false,
11383
+ type: isList ? `${type}FindManyArgs` : `${type}Args`,
11384
+ location: "inputObjectTypes",
11385
+ namespace: "prisma"
11386
+ };
11387
+ field.inputTypes.push(schemaArgInputType);
11388
+ }
11389
+ fields.push(field);
11390
+ }
11391
+ const hasManyRelationToAnotherModel = checkModelHasManyModelRelation(model);
11392
+ const shouldAddCountField = hasManyRelationToAnotherModel;
11393
+ if (shouldAddCountField) {
11394
+ const _countField = {
11395
+ name: "_count",
11396
+ isRequired: false,
11397
+ isNullable: false,
11398
+ inputTypes: [
11399
+ {
11400
+ isList: false,
11401
+ type: "Boolean",
11402
+ location: "scalar"
11403
+ },
11404
+ {
11405
+ isList: false,
11406
+ type: `${modelName}CountOutputTypeArgs`,
11407
+ location: "inputObjectTypes",
11408
+ namespace: "prisma"
11409
+ }
11410
+ ]
11411
+ };
11412
+ fields.push(_countField);
11413
+ }
11414
+ const modelSelectInputObjectType = {
11415
+ name: `${modelName}Select`,
11416
+ constraints: {
11417
+ maxNumFields: null,
11418
+ minNumFields: null
11419
+ },
11420
+ fields
11421
+ };
11422
+ modelSelectInputObjectTypes.push(modelSelectInputObjectType);
11423
+ }
11424
+ return modelSelectInputObjectTypes;
11425
+ }
11426
+ __name(generateModelSelectInputObjectTypes, "generateModelSelectInputObjectTypes");
11427
+
11428
+ // src/zod-helpers/whereUniqueInput-helpers.ts
11429
+ init_esm_shims();
11430
+ function changeOptionalToRequiredFields(inputObjectTypes) {
11431
+ inputObjectTypes.map((item) => {
11432
+ if (item.name.includes("WhereUniqueInput") && // eslint-disable-next-line ts/no-non-null-asserted-optional-chain
11433
+ item.constraints.fields?.length > 0) {
11434
+ item.fields = item.fields.map((subItem) => {
11435
+ if (item.constraints.fields?.includes(subItem.name)) {
11436
+ subItem.isRequired = true;
11437
+ return subItem;
11438
+ }
11439
+ return subItem;
11440
+ });
11441
+ }
11442
+ return item;
11443
+ });
11444
+ }
11445
+ __name(changeOptionalToRequiredFields, "changeOptionalToRequiredFields");
11446
+
11447
+ // src/zod-helpers/helpers.ts
11448
+ function addMissingZodInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
11449
+ if (dataSourceProvider === "mongodb") {
11450
+ addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes);
11451
+ }
11452
+ addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes);
11453
+ if (options.isGenerateSelect) {
11454
+ addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models);
11455
+ Transformer.setIsGenerateSelect(true);
11456
+ }
11457
+ if (options.isGenerateSelect || options.isGenerateInclude) {
11458
+ addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, options.isGenerateSelect, options.isGenerateInclude);
11459
+ }
11460
+ if (options.isGenerateInclude) {
11461
+ addMissingInputObjectTypesForInclude(inputObjectTypes, models, options.isGenerateSelect);
11462
+ Transformer.setIsGenerateInclude(true);
11463
+ }
11464
+ changeOptionalToRequiredFields(inputObjectTypes);
11465
+ }
11466
+ __name(addMissingZodInputObjectTypes, "addMissingZodInputObjectTypes");
10289
11467
 
10290
11468
  // src/prisma-generator.ts
10291
11469
  async function generate(options) {
@@ -10307,13 +11485,6 @@ async function generate(options) {
10307
11485
  consoleLog(`Preparing output directory: ${outputDir}`);
10308
11486
  await createDirectory(outputDir);
10309
11487
  await removeDir(outputDir, true);
10310
- if (config.withZod !== false) {
10311
- consoleLog("Generating Zod schemas");
10312
- const prismaZodGenerator = await getJiti().import(getJiti().esmResolve("prisma-zod-generator/lib/prisma-generator"));
10313
- await prismaZodGenerator.generate(options);
10314
- } else {
10315
- consoleLog("Skipping Zod schemas generation");
10316
- }
10317
11488
  consoleLog("Finding Prisma Client generator");
10318
11489
  const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
10319
11490
  if (!prismaClientProvider) {
@@ -10325,8 +11496,41 @@ async function generate(options) {
10325
11496
  previewFeatures: prismaClientProvider?.previewFeatures
10326
11497
  });
10327
11498
  const modelOperations = prismaClientDmmf.mappings.modelOperations;
11499
+ const inputObjectTypes = prismaClientDmmf.schema.inputObjectTypes.prisma;
11500
+ const outputObjectTypes = prismaClientDmmf.schema.outputObjectTypes.prisma;
11501
+ const enumTypes = prismaClientDmmf.schema.enumTypes;
10328
11502
  const models = prismaClientDmmf.datamodel.models;
10329
11503
  const hiddenModels = [];
11504
+ const hiddenFields = [];
11505
+ if (config.withZod !== false) {
11506
+ consoleLog("Generating Zod schemas");
11507
+ const zodOutputPath = internals.parseEnvValue(options.generator.output);
11508
+ await createDirectory(zodOutputPath);
11509
+ Transformer.setOutputPath(zodOutputPath);
11510
+ if (prismaClientProvider?.isCustomOutput) {
11511
+ Transformer.setPrismaClientOutputPath(prismaClientProvider.output?.value);
11512
+ }
11513
+ resolveZodModelsComments(models, modelOperations, enumTypes, hiddenModels, hiddenFields);
11514
+ await generateZodEnumSchemas(enumTypes.prisma, enumTypes.model);
11515
+ const dataSource = options.datasources?.[0];
11516
+ if (!dataSource) {
11517
+ throw new Error("No datasource found");
11518
+ }
11519
+ const previewFeatures = prismaClientProvider?.previewFeatures;
11520
+ Transformer.provider = dataSource.provider;
11521
+ Transformer.previewFeatures = previewFeatures;
11522
+ addMissingZodInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSource.provider, {
11523
+ isGenerateSelect: true,
11524
+ isGenerateInclude: true
11525
+ });
11526
+ const aggregateOperationSupport = resolveZodAggregateOperationSupport(inputObjectTypes);
11527
+ hideZodInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels, hiddenFields);
11528
+ await generateZodObjectSchemas(inputObjectTypes);
11529
+ await generateZodModelSchemas(models, modelOperations, aggregateOperationSupport);
11530
+ await generateZodIndex();
11531
+ } else {
11532
+ consoleLog("Skipping Zod schemas generation");
11533
+ }
10330
11534
  if (config.withShield !== false) {
10331
11535
  consoleLog("Generating tRPC Shield");
10332
11536
  const shieldOutputDir = joinPaths(outputDir, "shield");
@@ -10390,7 +11594,7 @@ async function generate(options) {
10390
11594
  }
10391
11595
  consoleLog(`Generating tRPC source code for ${models.length} models`);
10392
11596
  resolveModelsComments(models, hiddenModels);
10393
- const createRouter = project.createSourceFile(path4.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
11597
+ const createRouter = project.createSourceFile(path6.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
10394
11598
  overwrite: true
10395
11599
  });
10396
11600
  consoleLog("Generating tRPC imports");
@@ -10403,7 +11607,7 @@ async function generate(options) {
10403
11607
  createRouter.formatText({
10404
11608
  indentSize: 2
10405
11609
  });
10406
- const appRouter = project.createSourceFile(path4.resolve(outputDir, "routers", `index.ts`), void 0, {
11610
+ const appRouter = project.createSourceFile(path6.resolve(outputDir, "routers", `index.ts`), void 0, {
10407
11611
  overwrite: true
10408
11612
  });
10409
11613
  consoleLog("Generating tRPC router imports");
@@ -10425,7 +11629,7 @@ async function generate(options) {
10425
11629
  const plural = (0, import_pluralize.default)(model.toLowerCase());
10426
11630
  consoleLog(`Generating tRPC router for model ${model}`);
10427
11631
  generateRouterImport(appRouter, plural, model);
10428
- const modelRouter = project.createSourceFile(path4.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
11632
+ const modelRouter = project.createSourceFile(path6.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
10429
11633
  overwrite: true
10430
11634
  });
10431
11635
  generateCreateRouterImport({