@stryke/prisma-trpc-generator 0.8.0 → 0.8.2

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.
@@ -2484,40 +2484,25 @@ var exists = /* @__PURE__ */ __name(async (filePath) => {
2484
2484
 
2485
2485
  // ../fs/src/helpers.ts
2486
2486
  var import_promises2 = require("node:fs/promises");
2487
- async function createDirectory(path6) {
2488
- if (await exists(path6)) {
2487
+ async function createDirectory(path5) {
2488
+ if (await exists(path5)) {
2489
2489
  return;
2490
2490
  }
2491
- return (0, import_promises2.mkdir)(path6, {
2491
+ return (0, import_promises2.mkdir)(path5, {
2492
2492
  recursive: true
2493
2493
  });
2494
2494
  }
2495
2495
  __name(createDirectory, "createDirectory");
2496
- async function removeDirectory(path6) {
2497
- if (!existsSync(path6)) {
2496
+ async function removeDirectory(path5) {
2497
+ if (!existsSync(path5)) {
2498
2498
  return;
2499
2499
  }
2500
- return (0, import_promises2.rm)(path6, {
2500
+ return (0, import_promises2.rm)(path5, {
2501
2501
  recursive: true
2502
2502
  });
2503
2503
  }
2504
2504
  __name(removeDirectory, "removeDirectory");
2505
2505
 
2506
- // ../path/src/file-path-fns.ts
2507
- init_cjs_shims();
2508
-
2509
- // ../types/src/base.ts
2510
- init_cjs_shims();
2511
- var EMPTY_STRING = "";
2512
- var $NestedValue = Symbol("NestedValue");
2513
-
2514
- // ../path/src/correct-path.ts
2515
- init_cjs_shims();
2516
-
2517
- // ../path/src/is-file.ts
2518
- init_cjs_shims();
2519
- var import_node_fs2 = require("node:fs");
2520
-
2521
2506
  // ../path/src/join-paths.ts
2522
2507
  init_cjs_shims();
2523
2508
  var _DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
@@ -2534,65 +2519,65 @@ var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
2534
2519
  var isAbsolute = /* @__PURE__ */ __name(function(p) {
2535
2520
  return _IS_ABSOLUTE_RE.test(p);
2536
2521
  }, "isAbsolute");
2537
- var correctPaths = /* @__PURE__ */ __name(function(path6) {
2538
- if (!path6 || path6.length === 0) {
2522
+ var correctPaths = /* @__PURE__ */ __name(function(path5) {
2523
+ if (!path5 || path5.length === 0) {
2539
2524
  return ".";
2540
2525
  }
2541
- path6 = normalizeWindowsPath(path6);
2542
- const isUNCPath = path6.match(_UNC_REGEX);
2543
- const isPathAbsolute = isAbsolute(path6);
2544
- const trailingSeparator = path6[path6.length - 1] === "/";
2545
- path6 = normalizeString(path6, !isPathAbsolute);
2546
- if (path6.length === 0) {
2526
+ path5 = normalizeWindowsPath(path5);
2527
+ const isUNCPath = path5.match(_UNC_REGEX);
2528
+ const isPathAbsolute = isAbsolute(path5);
2529
+ const trailingSeparator = path5[path5.length - 1] === "/";
2530
+ path5 = normalizeString(path5, !isPathAbsolute);
2531
+ if (path5.length === 0) {
2547
2532
  if (isPathAbsolute) {
2548
2533
  return "/";
2549
2534
  }
2550
2535
  return trailingSeparator ? "./" : ".";
2551
2536
  }
2552
2537
  if (trailingSeparator) {
2553
- path6 += "/";
2538
+ path5 += "/";
2554
2539
  }
2555
- if (_DRIVE_LETTER_RE.test(path6)) {
2556
- path6 += "/";
2540
+ if (_DRIVE_LETTER_RE.test(path5)) {
2541
+ path5 += "/";
2557
2542
  }
2558
2543
  if (isUNCPath) {
2559
2544
  if (!isPathAbsolute) {
2560
- return `//./${path6}`;
2545
+ return `//./${path5}`;
2561
2546
  }
2562
- return `//${path6}`;
2547
+ return `//${path5}`;
2563
2548
  }
2564
- return isPathAbsolute && !isAbsolute(path6) ? `/${path6}` : path6;
2549
+ return isPathAbsolute && !isAbsolute(path5) ? `/${path5}` : path5;
2565
2550
  }, "correctPaths");
2566
2551
  var joinPaths = /* @__PURE__ */ __name(function(...segments) {
2567
- let path6 = "";
2552
+ let path5 = "";
2568
2553
  for (const seg of segments) {
2569
2554
  if (!seg) {
2570
2555
  continue;
2571
2556
  }
2572
- if (path6.length > 0) {
2573
- const pathTrailing = path6[path6.length - 1] === "/";
2557
+ if (path5.length > 0) {
2558
+ const pathTrailing = path5[path5.length - 1] === "/";
2574
2559
  const segLeading = seg[0] === "/";
2575
2560
  const both = pathTrailing && segLeading;
2576
2561
  if (both) {
2577
- path6 += seg.slice(1);
2562
+ path5 += seg.slice(1);
2578
2563
  } else {
2579
- path6 += pathTrailing || segLeading ? seg : `/${seg}`;
2564
+ path5 += pathTrailing || segLeading ? seg : `/${seg}`;
2580
2565
  }
2581
2566
  } else {
2582
- path6 += seg;
2567
+ path5 += seg;
2583
2568
  }
2584
2569
  }
2585
- return correctPaths(path6);
2570
+ return correctPaths(path5);
2586
2571
  }, "joinPaths");
2587
- function normalizeString(path6, allowAboveRoot) {
2572
+ function normalizeString(path5, allowAboveRoot) {
2588
2573
  let res = "";
2589
2574
  let lastSegmentLength = 0;
2590
2575
  let lastSlash = -1;
2591
2576
  let dots = 0;
2592
2577
  let char = null;
2593
- for (let index = 0; index <= path6.length; ++index) {
2594
- if (index < path6.length) {
2595
- char = path6[index];
2578
+ for (let index = 0; index <= path5.length; ++index) {
2579
+ if (index < path5.length) {
2580
+ char = path5[index];
2596
2581
  } else if (char === "/") {
2597
2582
  break;
2598
2583
  } else {
@@ -2628,9 +2613,9 @@ function normalizeString(path6, allowAboveRoot) {
2628
2613
  }
2629
2614
  } else {
2630
2615
  if (res.length > 0) {
2631
- res += `/${path6.slice(lastSlash + 1, index)}`;
2616
+ res += `/${path5.slice(lastSlash + 1, index)}`;
2632
2617
  } else {
2633
- res = path6.slice(lastSlash + 1, index);
2618
+ res = path5.slice(lastSlash + 1, index);
2634
2619
  }
2635
2620
  lastSegmentLength = index - lastSlash - 1;
2636
2621
  }
@@ -2646,408 +2631,78 @@ function normalizeString(path6, allowAboveRoot) {
2646
2631
  }
2647
2632
  __name(normalizeString, "normalizeString");
2648
2633
 
2649
- // ../path/src/is-file.ts
2650
- function isFile(path6, additionalPath) {
2651
- return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath, path6) : path6, {
2652
- throwIfNoEntry: false
2653
- })?.isFile());
2654
- }
2655
- __name(isFile, "isFile");
2656
- function isDirectory(path6, additionalPath) {
2657
- return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath, path6) : path6, {
2658
- throwIfNoEntry: false
2659
- })?.isDirectory());
2660
- }
2661
- __name(isDirectory, "isDirectory");
2662
- function isAbsolutePath(path6) {
2663
- return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path6);
2664
- }
2665
- __name(isAbsolutePath, "isAbsolutePath");
2666
-
2667
- // ../path/src/correct-path.ts
2668
- var _DRIVE_LETTER_START_RE2 = /^[A-Z]:\//i;
2669
- function normalizeWindowsPath2(input = "") {
2670
- if (!input) {
2671
- return input;
2672
- }
2673
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE2, (r) => r.toUpperCase());
2674
- }
2675
- __name(normalizeWindowsPath2, "normalizeWindowsPath");
2676
- var _UNC_REGEX2 = /^[/\\]{2}/;
2677
- var _DRIVE_LETTER_RE2 = /^[A-Z]:$/i;
2678
- function correctPath(path6) {
2679
- if (!path6 || path6.length === 0) {
2680
- return ".";
2681
- }
2682
- path6 = normalizeWindowsPath2(path6);
2683
- const isUNCPath = path6.match(_UNC_REGEX2);
2684
- const isPathAbsolute = isAbsolutePath(path6);
2685
- const trailingSeparator = path6[path6.length - 1] === "/";
2686
- path6 = normalizeString2(path6, !isPathAbsolute);
2687
- if (path6.length === 0) {
2688
- if (isPathAbsolute) {
2689
- return "/";
2690
- }
2691
- return trailingSeparator ? "./" : ".";
2692
- }
2693
- if (trailingSeparator) {
2694
- path6 += "/";
2695
- }
2696
- if (_DRIVE_LETTER_RE2.test(path6)) {
2697
- path6 += "/";
2698
- }
2699
- if (isUNCPath) {
2700
- if (!isPathAbsolute) {
2701
- return `//./${path6}`;
2702
- }
2703
- return `//${path6}`;
2704
- }
2705
- return isPathAbsolute && !isAbsolutePath(path6) ? `/${path6}` : path6;
2706
- }
2707
- __name(correctPath, "correctPath");
2708
- function normalizeString2(path6, allowAboveRoot) {
2709
- let res = "";
2710
- let lastSegmentLength = 0;
2711
- let lastSlash = -1;
2712
- let dots = 0;
2713
- let char = null;
2714
- for (let index = 0; index <= path6.length; ++index) {
2715
- if (index < path6.length) {
2716
- char = path6[index];
2717
- } else if (char === "/") {
2718
- break;
2719
- } else {
2720
- char = "/";
2721
- }
2722
- if (char === "/") {
2723
- if (lastSlash === index - 1 || dots === 1) {
2724
- } else if (dots === 2) {
2725
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
2726
- if (res.length > 2) {
2727
- const lastSlashIndex = res.lastIndexOf("/");
2728
- if (lastSlashIndex === -1) {
2729
- res = "";
2730
- lastSegmentLength = 0;
2731
- } else {
2732
- res = res.slice(0, lastSlashIndex);
2733
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
2734
- }
2735
- lastSlash = index;
2736
- dots = 0;
2737
- continue;
2738
- } else if (res.length > 0) {
2739
- res = "";
2740
- lastSegmentLength = 0;
2741
- lastSlash = index;
2742
- dots = 0;
2743
- continue;
2744
- }
2745
- }
2746
- if (allowAboveRoot) {
2747
- res += res.length > 0 ? "/.." : "..";
2748
- lastSegmentLength = 2;
2749
- }
2750
- } else {
2751
- if (res.length > 0) {
2752
- res += `/${path6.slice(lastSlash + 1, index)}`;
2753
- } else {
2754
- res = path6.slice(lastSlash + 1, index);
2755
- }
2756
- lastSegmentLength = index - lastSlash - 1;
2757
- }
2758
- lastSlash = index;
2759
- dots = 0;
2760
- } else if (char === "." && dots !== -1) {
2761
- ++dots;
2762
- } else {
2763
- dots = -1;
2764
- }
2765
- }
2766
- return res;
2767
- }
2768
- __name(normalizeString2, "normalizeString");
2769
-
2770
- // ../path/src/get-workspace-root.ts
2771
- init_cjs_shims();
2772
-
2773
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/index.js
2774
- init_cjs_shims();
2775
-
2776
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-K6PUXRK3.js
2634
+ // ../string-format/src/lower-case-first.ts
2777
2635
  init_cjs_shims();
2636
+ var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
2637
+ return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
2638
+ }, "lowerCaseFirst");
2778
2639
 
2779
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-NQFXB5CV.js
2780
- init_cjs_shims();
2640
+ // src/prisma-generator.ts
2641
+ var import_node_path5 = __toESM(require("node:path"), 1);
2642
+ var import_pluralize = __toESM(require_pluralize(), 1);
2781
2643
 
2782
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-SHUYVCID.js
2644
+ // src/config.ts
2783
2645
  init_cjs_shims();
2784
- var __defProp2 = Object.defineProperty;
2785
- var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", {
2786
- value,
2787
- configurable: true
2788
- }), "__name");
2789
-
2790
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-NQFXB5CV.js
2791
- var import_node_fs3 = require("node:fs");
2792
- var import_node_path = require("node:path");
2793
- var MAX_PATH_SEARCH_DEPTH = 30;
2794
- var depth = 0;
2795
- function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
2796
- const _startPath = startPath ?? process.cwd();
2797
- if (endDirectoryNames.some((endDirName) => (0, import_node_fs3.existsSync)((0, import_node_path.join)(_startPath, endDirName)))) {
2798
- return _startPath;
2799
- }
2800
- if (endFileNames.some((endFileName) => (0, import_node_fs3.existsSync)((0, import_node_path.join)(_startPath, endFileName)))) {
2801
- return _startPath;
2802
- }
2803
- if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
2804
- const parent = (0, import_node_path.join)(_startPath, "..");
2805
- return findFolderUp(parent, endFileNames, endDirectoryNames);
2806
- }
2807
- return void 0;
2808
- }
2809
- __name(findFolderUp, "findFolderUp");
2810
- __name2(findFolderUp, "findFolderUp");
2811
2646
 
2812
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-D6E6GZD2.js
2647
+ // ../../node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.mjs
2813
2648
  init_cjs_shims();
2814
- var _DRIVE_LETTER_START_RE3 = /^[A-Za-z]:\//;
2815
- function normalizeWindowsPath3(input = "") {
2816
- if (!input) {
2817
- return input;
2649
+ var util;
2650
+ (function(util2) {
2651
+ util2.assertEqual = (val) => val;
2652
+ function assertIs(_arg) {
2818
2653
  }
2819
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE3, (r) => r.toUpperCase());
2820
- }
2821
- __name(normalizeWindowsPath3, "normalizeWindowsPath");
2822
- __name2(normalizeWindowsPath3, "normalizeWindowsPath");
2823
- var _UNC_REGEX3 = /^[/\\]{2}/;
2824
- var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
2825
- var _DRIVE_LETTER_RE3 = /^[A-Za-z]:$/;
2826
- var correctPaths2 = /* @__PURE__ */ __name2(function(path6) {
2827
- if (!path6 || path6.length === 0) {
2828
- return ".";
2654
+ __name(assertIs, "assertIs");
2655
+ util2.assertIs = assertIs;
2656
+ function assertNever(_x) {
2657
+ throw new Error();
2829
2658
  }
2830
- path6 = normalizeWindowsPath3(path6);
2831
- const isUNCPath = path6.match(_UNC_REGEX3);
2832
- const isPathAbsolute = isAbsolute2(path6);
2833
- const trailingSeparator = path6[path6.length - 1] === "/";
2834
- path6 = normalizeString3(path6, !isPathAbsolute);
2835
- if (path6.length === 0) {
2836
- if (isPathAbsolute) {
2837
- return "/";
2659
+ __name(assertNever, "assertNever");
2660
+ util2.assertNever = assertNever;
2661
+ util2.arrayToEnum = (items) => {
2662
+ const obj = {};
2663
+ for (const item of items) {
2664
+ obj[item] = item;
2838
2665
  }
2839
- return trailingSeparator ? "./" : ".";
2840
- }
2841
- if (trailingSeparator) {
2842
- path6 += "/";
2843
- }
2844
- if (_DRIVE_LETTER_RE3.test(path6)) {
2845
- path6 += "/";
2846
- }
2847
- if (isUNCPath) {
2848
- if (!isPathAbsolute) {
2849
- return `//./${path6}`;
2666
+ return obj;
2667
+ };
2668
+ util2.getValidEnumValues = (obj) => {
2669
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
2670
+ const filtered = {};
2671
+ for (const k of validKeys) {
2672
+ filtered[k] = obj[k];
2850
2673
  }
2851
- return `//${path6}`;
2852
- }
2853
- return isPathAbsolute && !isAbsolute2(path6) ? `/${path6}` : path6;
2854
- }, "correctPaths");
2855
- function cwd() {
2856
- if (typeof process !== "undefined" && typeof process.cwd === "function") {
2857
- return process.cwd().replace(/\\/g, "/");
2674
+ return util2.objectValues(filtered);
2675
+ };
2676
+ util2.objectValues = (obj) => {
2677
+ return util2.objectKeys(obj).map(function(e) {
2678
+ return obj[e];
2679
+ });
2680
+ };
2681
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
2682
+ const keys = [];
2683
+ for (const key in object) {
2684
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
2685
+ keys.push(key);
2686
+ }
2687
+ }
2688
+ return keys;
2689
+ };
2690
+ util2.find = (arr, checker) => {
2691
+ for (const item of arr) {
2692
+ if (checker(item))
2693
+ return item;
2694
+ }
2695
+ return void 0;
2696
+ };
2697
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
2698
+ function joinValues(array, separator = " | ") {
2699
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
2858
2700
  }
2859
- return "/";
2860
- }
2861
- __name(cwd, "cwd");
2862
- __name2(cwd, "cwd");
2863
- function normalizeString3(path6, allowAboveRoot) {
2864
- let res = "";
2865
- let lastSegmentLength = 0;
2866
- let lastSlash = -1;
2867
- let dots = 0;
2868
- let char = null;
2869
- for (let index = 0; index <= path6.length; ++index) {
2870
- if (index < path6.length) {
2871
- char = path6[index];
2872
- } else if (char === "/") {
2873
- break;
2874
- } else {
2875
- char = "/";
2876
- }
2877
- if (char === "/") {
2878
- if (lastSlash === index - 1 || dots === 1) {
2879
- } else if (dots === 2) {
2880
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
2881
- if (res.length > 2) {
2882
- const lastSlashIndex = res.lastIndexOf("/");
2883
- if (lastSlashIndex === -1) {
2884
- res = "";
2885
- lastSegmentLength = 0;
2886
- } else {
2887
- res = res.slice(0, lastSlashIndex);
2888
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
2889
- }
2890
- lastSlash = index;
2891
- dots = 0;
2892
- continue;
2893
- } else if (res.length > 0) {
2894
- res = "";
2895
- lastSegmentLength = 0;
2896
- lastSlash = index;
2897
- dots = 0;
2898
- continue;
2899
- }
2900
- }
2901
- if (allowAboveRoot) {
2902
- res += res.length > 0 ? "/.." : "..";
2903
- lastSegmentLength = 2;
2904
- }
2905
- } else {
2906
- if (res.length > 0) {
2907
- res += `/${path6.slice(lastSlash + 1, index)}`;
2908
- } else {
2909
- res = path6.slice(lastSlash + 1, index);
2910
- }
2911
- lastSegmentLength = index - lastSlash - 1;
2912
- }
2913
- lastSlash = index;
2914
- dots = 0;
2915
- } else if (char === "." && dots !== -1) {
2916
- ++dots;
2917
- } else {
2918
- dots = -1;
2919
- }
2920
- }
2921
- return res;
2922
- }
2923
- __name(normalizeString3, "normalizeString");
2924
- __name2(normalizeString3, "normalizeString");
2925
- var isAbsolute2 = /* @__PURE__ */ __name2(function(p) {
2926
- return _IS_ABSOLUTE_RE2.test(p);
2927
- }, "isAbsolute");
2928
-
2929
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-K6PUXRK3.js
2930
- var rootFiles = [
2931
- "storm-workspace.json",
2932
- "storm-workspace.json",
2933
- "storm-workspace.yaml",
2934
- "storm-workspace.yml",
2935
- "storm-workspace.js",
2936
- "storm-workspace.ts",
2937
- ".storm-workspace.json",
2938
- ".storm-workspace.yaml",
2939
- ".storm-workspace.yml",
2940
- ".storm-workspace.js",
2941
- ".storm-workspace.ts",
2942
- "lerna.json",
2943
- "nx.json",
2944
- "turbo.json",
2945
- "npm-workspace.json",
2946
- "yarn-workspace.json",
2947
- "pnpm-workspace.json",
2948
- "npm-workspace.yaml",
2949
- "yarn-workspace.yaml",
2950
- "pnpm-workspace.yaml",
2951
- "npm-workspace.yml",
2952
- "yarn-workspace.yml",
2953
- "pnpm-workspace.yml",
2954
- "npm-lock.json",
2955
- "yarn-lock.json",
2956
- "pnpm-lock.json",
2957
- "npm-lock.yaml",
2958
- "yarn-lock.yaml",
2959
- "pnpm-lock.yaml",
2960
- "npm-lock.yml",
2961
- "yarn-lock.yml",
2962
- "pnpm-lock.yml",
2963
- "bun.lockb"
2964
- ];
2965
- var rootDirectories = [
2966
- ".storm-workspace",
2967
- ".nx",
2968
- ".github",
2969
- ".vscode",
2970
- ".verdaccio"
2971
- ];
2972
- function findWorkspaceRootSafe(pathInsideMonorepo) {
2973
- if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
2974
- return correctPaths2(process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH);
2975
- }
2976
- return correctPaths2(findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles, rootDirectories));
2977
- }
2978
- __name(findWorkspaceRootSafe, "findWorkspaceRootSafe");
2979
- __name2(findWorkspaceRootSafe, "findWorkspaceRootSafe");
2980
- function findWorkspaceRoot(pathInsideMonorepo) {
2981
- const result = findWorkspaceRootSafe(pathInsideMonorepo);
2982
- if (!result) {
2983
- throw new Error(`Cannot find workspace root upwards from known path. Files search list includes:
2984
- ${rootFiles.join("\n")}
2985
- Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`);
2986
- }
2987
- return result;
2988
- }
2989
- __name(findWorkspaceRoot, "findWorkspaceRoot");
2990
- __name2(findWorkspaceRoot, "findWorkspaceRoot");
2991
-
2992
- // ../../node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.mjs
2993
- init_cjs_shims();
2994
- var util;
2995
- (function(util2) {
2996
- util2.assertEqual = (val) => val;
2997
- function assertIs(_arg) {
2998
- }
2999
- __name(assertIs, "assertIs");
3000
- util2.assertIs = assertIs;
3001
- function assertNever(_x) {
3002
- throw new Error();
3003
- }
3004
- __name(assertNever, "assertNever");
3005
- util2.assertNever = assertNever;
3006
- util2.arrayToEnum = (items) => {
3007
- const obj = {};
3008
- for (const item of items) {
3009
- obj[item] = item;
3010
- }
3011
- return obj;
3012
- };
3013
- util2.getValidEnumValues = (obj) => {
3014
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
3015
- const filtered = {};
3016
- for (const k of validKeys) {
3017
- filtered[k] = obj[k];
3018
- }
3019
- return util2.objectValues(filtered);
3020
- };
3021
- util2.objectValues = (obj) => {
3022
- return util2.objectKeys(obj).map(function(e) {
3023
- return obj[e];
3024
- });
3025
- };
3026
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
3027
- const keys = [];
3028
- for (const key in object) {
3029
- if (Object.prototype.hasOwnProperty.call(object, key)) {
3030
- keys.push(key);
3031
- }
3032
- }
3033
- return keys;
3034
- };
3035
- util2.find = (arr, checker) => {
3036
- for (const item of arr) {
3037
- if (checker(item))
3038
- return item;
3039
- }
3040
- return void 0;
3041
- };
3042
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
3043
- function joinValues(array, separator = " | ") {
3044
- return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
3045
- }
3046
- __name(joinValues, "joinValues");
3047
- util2.joinValues = joinValues;
3048
- util2.jsonStringifyReplacer = (_, value) => {
3049
- if (typeof value === "bigint") {
3050
- return value.toString();
2701
+ __name(joinValues, "joinValues");
2702
+ util2.joinValues = joinValues;
2703
+ util2.jsonStringifyReplacer = (_, value) => {
2704
+ if (typeof value === "bigint") {
2705
+ return value.toString();
3051
2706
  }
3052
2707
  return value;
3053
2708
  };
@@ -3351,8 +3006,8 @@ function getErrorMap() {
3351
3006
  }
3352
3007
  __name(getErrorMap, "getErrorMap");
3353
3008
  var makeIssue = /* @__PURE__ */ __name((params) => {
3354
- const { data, path: path6, errorMaps, issueData } = params;
3355
- const fullPath = [...path6, ...issueData.path || []];
3009
+ const { data, path: path5, errorMaps, issueData } = params;
3010
+ const fullPath = [...path5, ...issueData.path || []];
3356
3011
  const fullIssue = {
3357
3012
  ...issueData,
3358
3013
  path: fullPath
@@ -3486,11 +3141,11 @@ var ParseInputLazyPath = class {
3486
3141
  static {
3487
3142
  __name(this, "ParseInputLazyPath");
3488
3143
  }
3489
- constructor(parent, value, path6, key) {
3144
+ constructor(parent, value, path5, key) {
3490
3145
  this._cachedPath = [];
3491
3146
  this.parent = parent;
3492
3147
  this.data = value;
3493
- this._path = path6;
3148
+ this._path = path5;
3494
3149
  this._key = key;
3495
3150
  }
3496
3151
  get path() {
@@ -7195,221 +6850,48 @@ var z = /* @__PURE__ */ Object.freeze({
7195
6850
  ZodError
7196
6851
  });
7197
6852
 
7198
- // ../path/src/get-parent-path.ts
6853
+ // src/config.ts
6854
+ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
6855
+ ModelAction2["findUnique"] = "findUnique";
6856
+ ModelAction2["findUniqueOrThrow"] = "findUniqueOrThrow";
6857
+ ModelAction2["findFirst"] = "findFirst";
6858
+ ModelAction2["findFirstOrThrow"] = "findFirstOrThrow";
6859
+ ModelAction2["findMany"] = "findMany";
6860
+ ModelAction2["create"] = "create";
6861
+ ModelAction2["createMany"] = "createMany";
6862
+ ModelAction2["createManyAndReturn"] = "createManyAndReturn";
6863
+ ModelAction2["update"] = "update";
6864
+ ModelAction2["updateMany"] = "updateMany";
6865
+ ModelAction2["updateManyAndReturn"] = "updateManyAndReturn";
6866
+ ModelAction2["upsert"] = "upsert";
6867
+ ModelAction2["delete"] = "delete";
6868
+ ModelAction2["deleteMany"] = "deleteMany";
6869
+ ModelAction2["groupBy"] = "groupBy";
6870
+ ModelAction2["count"] = "count";
6871
+ ModelAction2["aggregate"] = "aggregate";
6872
+ ModelAction2["findRaw"] = "findRaw";
6873
+ ModelAction2["aggregateRaw"] = "aggregateRaw";
6874
+ return ModelAction2;
6875
+ }(ModelAction || {});
6876
+ var modelActionEnum = z.nativeEnum(ModelAction);
6877
+ var configSchema = z.object({
6878
+ debug: z.coerce.boolean().or(z.string()).default(false),
6879
+ withMiddleware: z.coerce.boolean().or(z.string()).default(false),
6880
+ withShield: z.coerce.boolean().or(z.string()).default(true),
6881
+ withZod: z.coerce.boolean().or(z.string()).default(true),
6882
+ withNext: z.coerce.boolean().or(z.string()).default(true),
6883
+ contextPath: z.string().default("../src/trpc/context"),
6884
+ trpcOptions: z.coerce.boolean().or(z.string()).default(true),
6885
+ showModelNameInProcedure: z.coerce.boolean().or(z.string()).default(true),
6886
+ generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
6887
+ return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
6888
+ })
6889
+ });
6890
+
6891
+ // src/helpers.ts
7199
6892
  init_cjs_shims();
7200
- var resolveParentPath = /* @__PURE__ */ __name((path6) => {
7201
- return resolvePaths(path6, "..");
7202
- }, "resolveParentPath");
7203
- var getParentPath = /* @__PURE__ */ __name((name, cwd2, options) => {
7204
- const ignoreCase = options?.ignoreCase ?? true;
7205
- const skipCwd = options?.skipCwd ?? false;
7206
- const targetType = options?.targetType ?? "both";
7207
- let dir = cwd2;
7208
- if (skipCwd) {
7209
- dir = resolveParentPath(cwd2);
7210
- }
7211
- let names = Array.isArray(name) ? name : [
7212
- name
7213
- ];
7214
- if (ignoreCase) {
7215
- names = names.map((name2) => name2.toLowerCase());
7216
- }
7217
- while (true) {
7218
- const target = names.find((name2) => isFile(joinPaths(dir, name2)) && (targetType === "file" || targetType === "both") || isDirectory(joinPaths(dir, name2)) && (targetType === "directory" || targetType === "both"));
7219
- if (target) {
7220
- return joinPaths(dir, target);
7221
- }
7222
- const parentDir = resolveParentPath(dir);
7223
- if (parentDir === dir) {
7224
- return void 0;
7225
- }
7226
- dir = parentDir;
7227
- }
7228
- }, "getParentPath");
7229
6893
 
7230
- // ../path/src/is-root-dir.ts
7231
- init_cjs_shims();
7232
- var isSystemRoot = /* @__PURE__ */ __name((dir) => {
7233
- return Boolean(dir === "/" || dir === "c:\\" || dir === "C:\\");
7234
- }, "isSystemRoot");
7235
-
7236
- // ../path/src/get-workspace-root.ts
7237
- var getWorkspaceRoot = /* @__PURE__ */ __name((dir = process.cwd()) => {
7238
- if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
7239
- return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
7240
- }
7241
- const root = findWorkspaceRootSafe(dir);
7242
- if (root) {
7243
- return root;
7244
- }
7245
- let result = getParentPath([
7246
- "package-lock.json",
7247
- "yarn.lock",
7248
- "pnpm-lock.yaml",
7249
- "bun.lock",
7250
- "nx.json",
7251
- "knip.json",
7252
- "pnpm-workspace.yaml",
7253
- "LICENSE",
7254
- ".all-contributorsrc",
7255
- ".whitesource",
7256
- "syncpack.config.js",
7257
- "syncpack.json",
7258
- "socket.yaml",
7259
- "lefthook.yaml",
7260
- ".npmrc",
7261
- ".log4brains.yml",
7262
- ".huskyrc",
7263
- ".husky",
7264
- ".lintstagedrc",
7265
- ".commitlintrc",
7266
- "lefthook.yml",
7267
- ".github",
7268
- ".nx",
7269
- ".vscode",
7270
- "patches"
7271
- ], dir);
7272
- if (result) {
7273
- return result;
7274
- }
7275
- result = dir;
7276
- while (result && !isSystemRoot(result)) {
7277
- result = getParentPath("storm.json", result, {
7278
- skipCwd: true
7279
- });
7280
- if (result) {
7281
- return result;
7282
- }
7283
- }
7284
- return dir;
7285
- }, "getWorkspaceRoot");
7286
-
7287
- // ../path/src/file-path-fns.ts
7288
- function findFileName(filePath, { requireExtension, withExtension } = {}) {
7289
- const result = normalizeWindowsPath2(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
7290
- if (requireExtension === true && !result.includes(".")) {
7291
- return EMPTY_STRING;
7292
- }
7293
- if (withExtension === false && result.includes(".")) {
7294
- return result.split(".").slice(-1).join(".") || EMPTY_STRING;
7295
- }
7296
- return result;
7297
- }
7298
- __name(findFileName, "findFileName");
7299
- function findFilePath(filePath) {
7300
- const normalizedPath = normalizeWindowsPath2(filePath);
7301
- return normalizedPath.replace(findFileName(normalizedPath, {
7302
- requireExtension: true
7303
- }), "");
7304
- }
7305
- __name(findFilePath, "findFilePath");
7306
- function findFileExtension(filePath) {
7307
- if (filePath === "..") {
7308
- return "";
7309
- }
7310
- const match = /.(\.[^./]+|\.)$/.exec(normalizeWindowsPath2(filePath));
7311
- return match && match[1] || EMPTY_STRING;
7312
- }
7313
- __name(findFileExtension, "findFileExtension");
7314
- function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
7315
- const paths = normalizeWindowsPath2(path6).split("/");
7316
- let resolvedPath = "";
7317
- let resolvedAbsolute = false;
7318
- for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
7319
- const path7 = index >= 0 ? paths[index] : cwd2;
7320
- if (!path7 || path7.length === 0) {
7321
- continue;
7322
- }
7323
- resolvedPath = joinPaths(path7, resolvedPath);
7324
- resolvedAbsolute = isAbsolutePath(path7);
7325
- }
7326
- resolvedPath = normalizeString2(resolvedPath, !resolvedAbsolute);
7327
- if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {
7328
- return `/${resolvedPath}`;
7329
- }
7330
- return resolvedPath.length > 0 ? resolvedPath : ".";
7331
- }
7332
- __name(resolvePath, "resolvePath");
7333
- function resolvePaths(...paths) {
7334
- return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath2(path6))));
7335
- }
7336
- __name(resolvePaths, "resolvePaths");
7337
- function relativePath(from, to) {
7338
- const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7339
- const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7340
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7341
- return _to.join("/");
7342
- }
7343
- const _fromCopy = [
7344
- ..._from
7345
- ];
7346
- for (const segment of _fromCopy) {
7347
- if (_to[0] !== segment) {
7348
- break;
7349
- }
7350
- _from.shift();
7351
- _to.shift();
7352
- }
7353
- return [
7354
- ..._from.map(() => ".."),
7355
- ..._to
7356
- ].join("/");
7357
- }
7358
- __name(relativePath, "relativePath");
7359
-
7360
- // ../string-format/src/lower-case-first.ts
7361
- init_cjs_shims();
7362
- var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
7363
- return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
7364
- }, "lowerCaseFirst");
7365
-
7366
- // src/prisma-generator.ts
7367
- var import_node_path6 = __toESM(require("node:path"), 1);
7368
- var import_pluralize = __toESM(require_pluralize(), 1);
7369
-
7370
- // src/config.ts
7371
- init_cjs_shims();
7372
- var ModelAction = /* @__PURE__ */ function(ModelAction2) {
7373
- ModelAction2["findUnique"] = "findUnique";
7374
- ModelAction2["findUniqueOrThrow"] = "findUniqueOrThrow";
7375
- ModelAction2["findFirst"] = "findFirst";
7376
- ModelAction2["findFirstOrThrow"] = "findFirstOrThrow";
7377
- ModelAction2["findMany"] = "findMany";
7378
- ModelAction2["create"] = "create";
7379
- ModelAction2["createMany"] = "createMany";
7380
- ModelAction2["createManyAndReturn"] = "createManyAndReturn";
7381
- ModelAction2["update"] = "update";
7382
- ModelAction2["updateMany"] = "updateMany";
7383
- ModelAction2["updateManyAndReturn"] = "updateManyAndReturn";
7384
- ModelAction2["upsert"] = "upsert";
7385
- ModelAction2["delete"] = "delete";
7386
- ModelAction2["deleteMany"] = "deleteMany";
7387
- ModelAction2["groupBy"] = "groupBy";
7388
- ModelAction2["count"] = "count";
7389
- ModelAction2["aggregate"] = "aggregate";
7390
- ModelAction2["findRaw"] = "findRaw";
7391
- ModelAction2["aggregateRaw"] = "aggregateRaw";
7392
- return ModelAction2;
7393
- }(ModelAction || {});
7394
- var modelActionEnum = z.nativeEnum(ModelAction);
7395
- var configSchema = z.object({
7396
- debug: z.coerce.boolean().or(z.string()).default(false),
7397
- withMiddleware: z.coerce.boolean().or(z.string()).default(false),
7398
- withShield: z.coerce.boolean().or(z.string()).default(true),
7399
- withZod: z.coerce.boolean().or(z.string()).default(true),
7400
- withNext: z.coerce.boolean().or(z.string()).default(true),
7401
- contextPath: z.string().default("../src/trpc/context"),
7402
- trpcOptions: z.coerce.boolean().or(z.string()).default(true),
7403
- showModelNameInProcedure: z.coerce.boolean().or(z.string()).default(true),
7404
- generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
7405
- return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
7406
- })
7407
- });
7408
-
7409
- // src/helpers.ts
7410
- init_cjs_shims();
7411
-
7412
- // src/utils/get-prisma-internals.ts
6894
+ // src/utils/get-prisma-internals.ts
7413
6895
  init_cjs_shims();
7414
6896
 
7415
6897
  // src/utils/get-jiti.ts
@@ -7477,103 +6959,615 @@ var titleCase = /* @__PURE__ */ __name((input) => {
7477
6959
  if (!input) {
7478
6960
  return "";
7479
6961
  }
7480
- return input.split(/(?=[A-Z])|[\s._-]/).map((s) => s.trim()).filter(Boolean).map((s) => ACRONYMS.includes(s) ? s.toUpperCase() : upperCaseFirst(s.toLowerCase())).join(" ");
7481
- }, "titleCase");
7482
-
7483
- // ../type-checks/src/is-string.ts
7484
- init_cjs_shims();
7485
- var isString = /* @__PURE__ */ __name((value) => {
7486
- try {
7487
- return typeof value === "string";
7488
- } catch {
7489
- return false;
6962
+ return input.split(/(?=[A-Z])|[\s._-]/).map((s) => s.trim()).filter(Boolean).map((s) => ACRONYMS.includes(s) ? s.toUpperCase() : upperCaseFirst(s.toLowerCase())).join(" ");
6963
+ }, "titleCase");
6964
+
6965
+ // ../type-checks/src/is-string.ts
6966
+ init_cjs_shims();
6967
+ var isString = /* @__PURE__ */ __name((value) => {
6968
+ try {
6969
+ return typeof value === "string";
6970
+ } catch {
6971
+ return false;
6972
+ }
6973
+ }, "isString");
6974
+
6975
+ // ../env/src/get-env-paths.ts
6976
+ var import_node_os = __toESM(require("node:os"), 1);
6977
+ var import_node_path = __toESM(require("node:path"), 1);
6978
+ var homedir = import_node_os.default.homedir();
6979
+ var tmpdir = import_node_os.default.tmpdir();
6980
+ var macos = /* @__PURE__ */ __name((orgId) => {
6981
+ const library = joinPaths(homedir, "Library");
6982
+ return {
6983
+ data: joinPaths(library, "Application Support", orgId),
6984
+ config: joinPaths(library, "Preferences", orgId),
6985
+ cache: joinPaths(library, "Caches", orgId),
6986
+ log: joinPaths(library, "Logs", orgId),
6987
+ temp: joinPaths(tmpdir, orgId)
6988
+ };
6989
+ }, "macos");
6990
+ var windows = /* @__PURE__ */ __name((orgId) => {
6991
+ const appData = process.env.APPDATA || joinPaths(homedir, "AppData", "Roaming");
6992
+ const localAppData = process.env.LOCALAPPDATA || joinPaths(homedir, "AppData", "Local");
6993
+ const windowsFormattedOrgId = titleCase(orgId).trim().replace(/\s+/g, "");
6994
+ return {
6995
+ // Data/config/cache/log are invented by me as Windows isn't opinionated about this
6996
+ data: joinPaths(localAppData, windowsFormattedOrgId, "Data"),
6997
+ config: joinPaths(appData, windowsFormattedOrgId, "Config"),
6998
+ cache: joinPaths(localAppData, "Cache", orgId),
6999
+ log: joinPaths(localAppData, windowsFormattedOrgId, "Log"),
7000
+ temp: joinPaths(tmpdir, orgId)
7001
+ };
7002
+ }, "windows");
7003
+ var linux = /* @__PURE__ */ __name((orgId) => {
7004
+ const username = import_node_path.default.basename(homedir);
7005
+ return {
7006
+ data: joinPaths(process.env.XDG_DATA_HOME || joinPaths(homedir, ".local", "share"), orgId),
7007
+ config: joinPaths(process.env.XDG_CONFIG_HOME || joinPaths(homedir, ".config"), orgId),
7008
+ cache: joinPaths(process.env.XDG_CACHE_HOME || joinPaths(homedir, ".cache"), orgId),
7009
+ // https://wiki.debian.org/XDGBaseDirectorySpecification#state
7010
+ log: joinPaths(process.env.XDG_STATE_HOME || joinPaths(homedir, ".local", "state"), orgId),
7011
+ temp: joinPaths(tmpdir, username, orgId)
7012
+ };
7013
+ }, "linux");
7014
+ function getEnvPaths(options = {}) {
7015
+ let orgId = options.orgId || "storm-software";
7016
+ if (!orgId) {
7017
+ throw new Error("You need to provide an orgId to the `getEnvPaths` function");
7018
+ }
7019
+ if (options.suffix) {
7020
+ orgId += `-${isString(options.suffix) ? options.suffix : "nodejs"}`;
7021
+ }
7022
+ let result = {};
7023
+ if (process.platform === "darwin") {
7024
+ result = macos(orgId);
7025
+ } else if (process.platform === "win32") {
7026
+ result = windows(orgId);
7027
+ } else {
7028
+ result = linux(orgId);
7029
+ }
7030
+ if (process.env.STORM_DATA_DIRECTORY) {
7031
+ result.data = process.env.STORM_DATA_DIRECTORY;
7032
+ } else if (process.env.STORM_CONFIG_DIRECTORY) {
7033
+ result.config = process.env.STORM_CONFIG_DIRECTORY;
7034
+ } else if (process.env.STORM_CACHE_DIRECTORY) {
7035
+ result.cache = process.env.STORM_CACHE_DIRECTORY;
7036
+ } else if (process.env.STORM_LOG_DIRECTORY) {
7037
+ result.log = process.env.STORM_LOG_DIRECTORY;
7038
+ } else if (process.env.STORM_TEMP_DIRECTORY) {
7039
+ result.temp = process.env.STORM_TEMP_DIRECTORY;
7040
+ }
7041
+ if (options.workspaceRoot) {
7042
+ result.cache ??= joinPaths(options.workspaceRoot, "node_modules", ".cache", orgId);
7043
+ result.temp ??= joinPaths(options.workspaceRoot, "tmp", orgId);
7044
+ result.log ??= joinPaths(result.temp, "logs");
7045
+ result.config ??= joinPaths(options.workspaceRoot, ".config", orgId);
7046
+ }
7047
+ return Object.keys(result).reduce((ret, key) => {
7048
+ if (result[key]) {
7049
+ const filePath = result[key];
7050
+ ret[key] = options.appId && options.appId !== options.orgId && options.appId !== options.nestedDir ? joinPaths(filePath, options.appId) : filePath;
7051
+ if (options.nestedDir && options.nestedDir !== options.orgId && options.nestedDir !== options.appId) {
7052
+ ret[key] = joinPaths(ret[key], options.nestedDir);
7053
+ }
7054
+ }
7055
+ return ret;
7056
+ }, {});
7057
+ }
7058
+ __name(getEnvPaths, "getEnvPaths");
7059
+
7060
+ // ../path/src/get-workspace-root.ts
7061
+ init_cjs_shims();
7062
+
7063
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/index.js
7064
+ init_cjs_shims();
7065
+
7066
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-K6PUXRK3.js
7067
+ init_cjs_shims();
7068
+
7069
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-NQFXB5CV.js
7070
+ init_cjs_shims();
7071
+
7072
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-SHUYVCID.js
7073
+ init_cjs_shims();
7074
+ var __defProp2 = Object.defineProperty;
7075
+ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", {
7076
+ value,
7077
+ configurable: true
7078
+ }), "__name");
7079
+
7080
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-NQFXB5CV.js
7081
+ var import_node_fs2 = require("node:fs");
7082
+ var import_node_path2 = require("node:path");
7083
+ var MAX_PATH_SEARCH_DEPTH = 30;
7084
+ var depth = 0;
7085
+ function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
7086
+ const _startPath = startPath ?? process.cwd();
7087
+ if (endDirectoryNames.some((endDirName) => (0, import_node_fs2.existsSync)((0, import_node_path2.join)(_startPath, endDirName)))) {
7088
+ return _startPath;
7089
+ }
7090
+ if (endFileNames.some((endFileName) => (0, import_node_fs2.existsSync)((0, import_node_path2.join)(_startPath, endFileName)))) {
7091
+ return _startPath;
7092
+ }
7093
+ if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
7094
+ const parent = (0, import_node_path2.join)(_startPath, "..");
7095
+ return findFolderUp(parent, endFileNames, endDirectoryNames);
7096
+ }
7097
+ return void 0;
7098
+ }
7099
+ __name(findFolderUp, "findFolderUp");
7100
+ __name2(findFolderUp, "findFolderUp");
7101
+
7102
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-D6E6GZD2.js
7103
+ init_cjs_shims();
7104
+ var _DRIVE_LETTER_START_RE2 = /^[A-Za-z]:\//;
7105
+ function normalizeWindowsPath2(input = "") {
7106
+ if (!input) {
7107
+ return input;
7108
+ }
7109
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE2, (r) => r.toUpperCase());
7110
+ }
7111
+ __name(normalizeWindowsPath2, "normalizeWindowsPath");
7112
+ __name2(normalizeWindowsPath2, "normalizeWindowsPath");
7113
+ var _UNC_REGEX2 = /^[/\\]{2}/;
7114
+ var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
7115
+ var _DRIVE_LETTER_RE2 = /^[A-Za-z]:$/;
7116
+ var correctPaths2 = /* @__PURE__ */ __name2(function(path5) {
7117
+ if (!path5 || path5.length === 0) {
7118
+ return ".";
7119
+ }
7120
+ path5 = normalizeWindowsPath2(path5);
7121
+ const isUNCPath = path5.match(_UNC_REGEX2);
7122
+ const isPathAbsolute = isAbsolute2(path5);
7123
+ const trailingSeparator = path5[path5.length - 1] === "/";
7124
+ path5 = normalizeString2(path5, !isPathAbsolute);
7125
+ if (path5.length === 0) {
7126
+ if (isPathAbsolute) {
7127
+ return "/";
7128
+ }
7129
+ return trailingSeparator ? "./" : ".";
7130
+ }
7131
+ if (trailingSeparator) {
7132
+ path5 += "/";
7133
+ }
7134
+ if (_DRIVE_LETTER_RE2.test(path5)) {
7135
+ path5 += "/";
7136
+ }
7137
+ if (isUNCPath) {
7138
+ if (!isPathAbsolute) {
7139
+ return `//./${path5}`;
7140
+ }
7141
+ return `//${path5}`;
7142
+ }
7143
+ return isPathAbsolute && !isAbsolute2(path5) ? `/${path5}` : path5;
7144
+ }, "correctPaths");
7145
+ function cwd() {
7146
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
7147
+ return process.cwd().replace(/\\/g, "/");
7148
+ }
7149
+ return "/";
7150
+ }
7151
+ __name(cwd, "cwd");
7152
+ __name2(cwd, "cwd");
7153
+ function normalizeString2(path5, allowAboveRoot) {
7154
+ let res = "";
7155
+ let lastSegmentLength = 0;
7156
+ let lastSlash = -1;
7157
+ let dots = 0;
7158
+ let char = null;
7159
+ for (let index = 0; index <= path5.length; ++index) {
7160
+ if (index < path5.length) {
7161
+ char = path5[index];
7162
+ } else if (char === "/") {
7163
+ break;
7164
+ } else {
7165
+ char = "/";
7166
+ }
7167
+ if (char === "/") {
7168
+ if (lastSlash === index - 1 || dots === 1) {
7169
+ } else if (dots === 2) {
7170
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
7171
+ if (res.length > 2) {
7172
+ const lastSlashIndex = res.lastIndexOf("/");
7173
+ if (lastSlashIndex === -1) {
7174
+ res = "";
7175
+ lastSegmentLength = 0;
7176
+ } else {
7177
+ res = res.slice(0, lastSlashIndex);
7178
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
7179
+ }
7180
+ lastSlash = index;
7181
+ dots = 0;
7182
+ continue;
7183
+ } else if (res.length > 0) {
7184
+ res = "";
7185
+ lastSegmentLength = 0;
7186
+ lastSlash = index;
7187
+ dots = 0;
7188
+ continue;
7189
+ }
7190
+ }
7191
+ if (allowAboveRoot) {
7192
+ res += res.length > 0 ? "/.." : "..";
7193
+ lastSegmentLength = 2;
7194
+ }
7195
+ } else {
7196
+ if (res.length > 0) {
7197
+ res += `/${path5.slice(lastSlash + 1, index)}`;
7198
+ } else {
7199
+ res = path5.slice(lastSlash + 1, index);
7200
+ }
7201
+ lastSegmentLength = index - lastSlash - 1;
7202
+ }
7203
+ lastSlash = index;
7204
+ dots = 0;
7205
+ } else if (char === "." && dots !== -1) {
7206
+ ++dots;
7207
+ } else {
7208
+ dots = -1;
7209
+ }
7210
+ }
7211
+ return res;
7212
+ }
7213
+ __name(normalizeString2, "normalizeString");
7214
+ __name2(normalizeString2, "normalizeString");
7215
+ var isAbsolute2 = /* @__PURE__ */ __name2(function(p) {
7216
+ return _IS_ABSOLUTE_RE2.test(p);
7217
+ }, "isAbsolute");
7218
+
7219
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-K6PUXRK3.js
7220
+ var rootFiles = [
7221
+ "storm-workspace.json",
7222
+ "storm-workspace.json",
7223
+ "storm-workspace.yaml",
7224
+ "storm-workspace.yml",
7225
+ "storm-workspace.js",
7226
+ "storm-workspace.ts",
7227
+ ".storm-workspace.json",
7228
+ ".storm-workspace.yaml",
7229
+ ".storm-workspace.yml",
7230
+ ".storm-workspace.js",
7231
+ ".storm-workspace.ts",
7232
+ "lerna.json",
7233
+ "nx.json",
7234
+ "turbo.json",
7235
+ "npm-workspace.json",
7236
+ "yarn-workspace.json",
7237
+ "pnpm-workspace.json",
7238
+ "npm-workspace.yaml",
7239
+ "yarn-workspace.yaml",
7240
+ "pnpm-workspace.yaml",
7241
+ "npm-workspace.yml",
7242
+ "yarn-workspace.yml",
7243
+ "pnpm-workspace.yml",
7244
+ "npm-lock.json",
7245
+ "yarn-lock.json",
7246
+ "pnpm-lock.json",
7247
+ "npm-lock.yaml",
7248
+ "yarn-lock.yaml",
7249
+ "pnpm-lock.yaml",
7250
+ "npm-lock.yml",
7251
+ "yarn-lock.yml",
7252
+ "pnpm-lock.yml",
7253
+ "bun.lockb"
7254
+ ];
7255
+ var rootDirectories = [
7256
+ ".storm-workspace",
7257
+ ".nx",
7258
+ ".github",
7259
+ ".vscode",
7260
+ ".verdaccio"
7261
+ ];
7262
+ function findWorkspaceRootSafe(pathInsideMonorepo) {
7263
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
7264
+ return correctPaths2(process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH);
7265
+ }
7266
+ return correctPaths2(findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles, rootDirectories));
7267
+ }
7268
+ __name(findWorkspaceRootSafe, "findWorkspaceRootSafe");
7269
+ __name2(findWorkspaceRootSafe, "findWorkspaceRootSafe");
7270
+ function findWorkspaceRoot(pathInsideMonorepo) {
7271
+ const result = findWorkspaceRootSafe(pathInsideMonorepo);
7272
+ if (!result) {
7273
+ throw new Error(`Cannot find workspace root upwards from known path. Files search list includes:
7274
+ ${rootFiles.join("\n")}
7275
+ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`);
7276
+ }
7277
+ return result;
7278
+ }
7279
+ __name(findWorkspaceRoot, "findWorkspaceRoot");
7280
+ __name2(findWorkspaceRoot, "findWorkspaceRoot");
7281
+
7282
+ // ../path/src/get-parent-path.ts
7283
+ init_cjs_shims();
7284
+
7285
+ // ../path/src/file-path-fns.ts
7286
+ init_cjs_shims();
7287
+
7288
+ // ../types/src/base.ts
7289
+ init_cjs_shims();
7290
+ var EMPTY_STRING = "";
7291
+ var $NestedValue = Symbol("NestedValue");
7292
+
7293
+ // ../path/src/correct-path.ts
7294
+ init_cjs_shims();
7295
+
7296
+ // ../path/src/is-file.ts
7297
+ init_cjs_shims();
7298
+ var import_node_fs3 = require("node:fs");
7299
+ function isFile(path5, additionalPath) {
7300
+ return Boolean((0, import_node_fs3.statSync)(additionalPath ? joinPaths(additionalPath, path5) : path5, {
7301
+ throwIfNoEntry: false
7302
+ })?.isFile());
7303
+ }
7304
+ __name(isFile, "isFile");
7305
+ function isDirectory(path5, additionalPath) {
7306
+ return Boolean((0, import_node_fs3.statSync)(additionalPath ? joinPaths(additionalPath, path5) : path5, {
7307
+ throwIfNoEntry: false
7308
+ })?.isDirectory());
7309
+ }
7310
+ __name(isDirectory, "isDirectory");
7311
+ function isAbsolutePath(path5) {
7312
+ return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path5);
7313
+ }
7314
+ __name(isAbsolutePath, "isAbsolutePath");
7315
+
7316
+ // ../path/src/correct-path.ts
7317
+ var _DRIVE_LETTER_START_RE3 = /^[A-Z]:\//i;
7318
+ function normalizeWindowsPath3(input = "") {
7319
+ if (!input) {
7320
+ return input;
7321
+ }
7322
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE3, (r) => r.toUpperCase());
7323
+ }
7324
+ __name(normalizeWindowsPath3, "normalizeWindowsPath");
7325
+ var _UNC_REGEX3 = /^[/\\]{2}/;
7326
+ var _DRIVE_LETTER_RE3 = /^[A-Z]:$/i;
7327
+ function correctPath(path5) {
7328
+ if (!path5 || path5.length === 0) {
7329
+ return ".";
7330
+ }
7331
+ path5 = normalizeWindowsPath3(path5);
7332
+ const isUNCPath = path5.match(_UNC_REGEX3);
7333
+ const isPathAbsolute = isAbsolutePath(path5);
7334
+ const trailingSeparator = path5[path5.length - 1] === "/";
7335
+ path5 = normalizeString3(path5, !isPathAbsolute);
7336
+ if (path5.length === 0) {
7337
+ if (isPathAbsolute) {
7338
+ return "/";
7339
+ }
7340
+ return trailingSeparator ? "./" : ".";
7341
+ }
7342
+ if (trailingSeparator) {
7343
+ path5 += "/";
7344
+ }
7345
+ if (_DRIVE_LETTER_RE3.test(path5)) {
7346
+ path5 += "/";
7347
+ }
7348
+ if (isUNCPath) {
7349
+ if (!isPathAbsolute) {
7350
+ return `//./${path5}`;
7351
+ }
7352
+ return `//${path5}`;
7353
+ }
7354
+ return isPathAbsolute && !isAbsolutePath(path5) ? `/${path5}` : path5;
7355
+ }
7356
+ __name(correctPath, "correctPath");
7357
+ function normalizeString3(path5, allowAboveRoot) {
7358
+ let res = "";
7359
+ let lastSegmentLength = 0;
7360
+ let lastSlash = -1;
7361
+ let dots = 0;
7362
+ let char = null;
7363
+ for (let index = 0; index <= path5.length; ++index) {
7364
+ if (index < path5.length) {
7365
+ char = path5[index];
7366
+ } else if (char === "/") {
7367
+ break;
7368
+ } else {
7369
+ char = "/";
7370
+ }
7371
+ if (char === "/") {
7372
+ if (lastSlash === index - 1 || dots === 1) {
7373
+ } else if (dots === 2) {
7374
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
7375
+ if (res.length > 2) {
7376
+ const lastSlashIndex = res.lastIndexOf("/");
7377
+ if (lastSlashIndex === -1) {
7378
+ res = "";
7379
+ lastSegmentLength = 0;
7380
+ } else {
7381
+ res = res.slice(0, lastSlashIndex);
7382
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
7383
+ }
7384
+ lastSlash = index;
7385
+ dots = 0;
7386
+ continue;
7387
+ } else if (res.length > 0) {
7388
+ res = "";
7389
+ lastSegmentLength = 0;
7390
+ lastSlash = index;
7391
+ dots = 0;
7392
+ continue;
7393
+ }
7394
+ }
7395
+ if (allowAboveRoot) {
7396
+ res += res.length > 0 ? "/.." : "..";
7397
+ lastSegmentLength = 2;
7398
+ }
7399
+ } else {
7400
+ if (res.length > 0) {
7401
+ res += `/${path5.slice(lastSlash + 1, index)}`;
7402
+ } else {
7403
+ res = path5.slice(lastSlash + 1, index);
7404
+ }
7405
+ lastSegmentLength = index - lastSlash - 1;
7406
+ }
7407
+ lastSlash = index;
7408
+ dots = 0;
7409
+ } else if (char === "." && dots !== -1) {
7410
+ ++dots;
7411
+ } else {
7412
+ dots = -1;
7413
+ }
7414
+ }
7415
+ return res;
7416
+ }
7417
+ __name(normalizeString3, "normalizeString");
7418
+
7419
+ // ../path/src/file-path-fns.ts
7420
+ function findFileName(filePath, { requireExtension, withExtension } = {}) {
7421
+ const result = normalizeWindowsPath3(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
7422
+ if (requireExtension === true && !result.includes(".")) {
7423
+ return EMPTY_STRING;
7424
+ }
7425
+ if (withExtension === false && result.includes(".")) {
7426
+ return result.split(".").slice(-1).join(".") || EMPTY_STRING;
7427
+ }
7428
+ return result;
7429
+ }
7430
+ __name(findFileName, "findFileName");
7431
+ function findFilePath(filePath) {
7432
+ const normalizedPath = normalizeWindowsPath3(filePath);
7433
+ return normalizedPath.replace(findFileName(normalizedPath, {
7434
+ requireExtension: true
7435
+ }), "");
7436
+ }
7437
+ __name(findFilePath, "findFilePath");
7438
+ function resolvePath(path5, cwd2 = getWorkspaceRoot()) {
7439
+ const paths = normalizeWindowsPath3(path5).split("/");
7440
+ let resolvedPath = "";
7441
+ let resolvedAbsolute = false;
7442
+ for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
7443
+ const path6 = index >= 0 ? paths[index] : cwd2;
7444
+ if (!path6 || path6.length === 0) {
7445
+ continue;
7446
+ }
7447
+ resolvedPath = joinPaths(path6, resolvedPath);
7448
+ resolvedAbsolute = isAbsolutePath(path6);
7490
7449
  }
7491
- }, "isString");
7450
+ resolvedPath = normalizeString3(resolvedPath, !resolvedAbsolute);
7451
+ if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {
7452
+ return `/${resolvedPath}`;
7453
+ }
7454
+ return resolvedPath.length > 0 ? resolvedPath : ".";
7455
+ }
7456
+ __name(resolvePath, "resolvePath");
7457
+ function resolvePaths(...paths) {
7458
+ return resolvePath(joinPaths(...paths.map((path5) => normalizeWindowsPath3(path5))));
7459
+ }
7460
+ __name(resolvePaths, "resolvePaths");
7461
+ function relativePath(from, to) {
7462
+ const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7463
+ const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7464
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7465
+ return _to.join("/");
7466
+ }
7467
+ const _fromCopy = [
7468
+ ..._from
7469
+ ];
7470
+ for (const segment of _fromCopy) {
7471
+ if (_to[0] !== segment) {
7472
+ break;
7473
+ }
7474
+ _from.shift();
7475
+ _to.shift();
7476
+ }
7477
+ return [
7478
+ ..._from.map(() => ".."),
7479
+ ..._to
7480
+ ].join("/");
7481
+ }
7482
+ __name(relativePath, "relativePath");
7492
7483
 
7493
- // ../env/src/get-env-paths.ts
7494
- var import_node_os = __toESM(require("node:os"), 1);
7495
- var import_node_path2 = __toESM(require("node:path"), 1);
7496
- var homedir = import_node_os.default.homedir();
7497
- var tmpdir = import_node_os.default.tmpdir();
7498
- var macos = /* @__PURE__ */ __name((orgId) => {
7499
- const library = joinPaths(homedir, "Library");
7500
- return {
7501
- data: joinPaths(library, "Application Support", orgId),
7502
- config: joinPaths(library, "Preferences", orgId),
7503
- cache: joinPaths(library, "Caches", orgId),
7504
- log: joinPaths(library, "Logs", orgId),
7505
- temp: joinPaths(tmpdir, orgId)
7506
- };
7507
- }, "macos");
7508
- var windows = /* @__PURE__ */ __name((orgId) => {
7509
- const appData = process.env.APPDATA || joinPaths(homedir, "AppData", "Roaming");
7510
- const localAppData = process.env.LOCALAPPDATA || joinPaths(homedir, "AppData", "Local");
7511
- const windowsFormattedOrgId = titleCase(orgId).trim().replace(/\s+/g, "");
7512
- return {
7513
- // Data/config/cache/log are invented by me as Windows isn't opinionated about this
7514
- data: joinPaths(localAppData, windowsFormattedOrgId, "Data"),
7515
- config: joinPaths(appData, windowsFormattedOrgId, "Config"),
7516
- cache: joinPaths(localAppData, "Cache", orgId),
7517
- log: joinPaths(localAppData, windowsFormattedOrgId, "Log"),
7518
- temp: joinPaths(tmpdir, orgId)
7519
- };
7520
- }, "windows");
7521
- var linux = /* @__PURE__ */ __name((orgId) => {
7522
- const username = import_node_path2.default.basename(homedir);
7523
- return {
7524
- data: joinPaths(process.env.XDG_DATA_HOME || joinPaths(homedir, ".local", "share"), orgId),
7525
- config: joinPaths(process.env.XDG_CONFIG_HOME || joinPaths(homedir, ".config"), orgId),
7526
- cache: joinPaths(process.env.XDG_CACHE_HOME || joinPaths(homedir, ".cache"), orgId),
7527
- // https://wiki.debian.org/XDGBaseDirectorySpecification#state
7528
- log: joinPaths(process.env.XDG_STATE_HOME || joinPaths(homedir, ".local", "state"), orgId),
7529
- temp: joinPaths(tmpdir, username, orgId)
7530
- };
7531
- }, "linux");
7532
- function getEnvPaths(options = {}) {
7533
- let orgId = options.orgId || "storm-software";
7534
- if (!orgId) {
7535
- throw new Error("You need to provide an orgId to the `getEnvPaths` function");
7484
+ // ../path/src/get-parent-path.ts
7485
+ var resolveParentPath = /* @__PURE__ */ __name((path5) => {
7486
+ return resolvePaths(path5, "..");
7487
+ }, "resolveParentPath");
7488
+ var getParentPath = /* @__PURE__ */ __name((name, cwd2, options) => {
7489
+ const ignoreCase = options?.ignoreCase ?? true;
7490
+ const skipCwd = options?.skipCwd ?? false;
7491
+ const targetType = options?.targetType ?? "both";
7492
+ let dir = cwd2;
7493
+ if (skipCwd) {
7494
+ dir = resolveParentPath(cwd2);
7536
7495
  }
7537
- if (options.suffix) {
7538
- orgId += `-${isString(options.suffix) ? options.suffix : "nodejs"}`;
7496
+ let names = Array.isArray(name) ? name : [
7497
+ name
7498
+ ];
7499
+ if (ignoreCase) {
7500
+ names = names.map((name2) => name2.toLowerCase());
7539
7501
  }
7540
- let result = {};
7541
- if (process.platform === "darwin") {
7542
- result = macos(orgId);
7543
- } else if (process.platform === "win32") {
7544
- result = windows(orgId);
7545
- } else {
7546
- result = linux(orgId);
7502
+ while (true) {
7503
+ const target = names.find((name2) => isFile(joinPaths(dir, name2)) && (targetType === "file" || targetType === "both") || isDirectory(joinPaths(dir, name2)) && (targetType === "directory" || targetType === "both"));
7504
+ if (target) {
7505
+ return joinPaths(dir, target);
7506
+ }
7507
+ const parentDir = resolveParentPath(dir);
7508
+ if (parentDir === dir) {
7509
+ return void 0;
7510
+ }
7511
+ dir = parentDir;
7547
7512
  }
7548
- if (process.env.STORM_DATA_DIRECTORY) {
7549
- result.data = process.env.STORM_DATA_DIRECTORY;
7550
- } else if (process.env.STORM_CONFIG_DIRECTORY) {
7551
- result.config = process.env.STORM_CONFIG_DIRECTORY;
7552
- } else if (process.env.STORM_CACHE_DIRECTORY) {
7553
- result.cache = process.env.STORM_CACHE_DIRECTORY;
7554
- } else if (process.env.STORM_LOG_DIRECTORY) {
7555
- result.log = process.env.STORM_LOG_DIRECTORY;
7556
- } else if (process.env.STORM_TEMP_DIRECTORY) {
7557
- result.temp = process.env.STORM_TEMP_DIRECTORY;
7513
+ }, "getParentPath");
7514
+
7515
+ // ../path/src/is-root-dir.ts
7516
+ init_cjs_shims();
7517
+ var isSystemRoot = /* @__PURE__ */ __name((dir) => {
7518
+ return Boolean(dir === "/" || dir === "c:\\" || dir === "C:\\");
7519
+ }, "isSystemRoot");
7520
+
7521
+ // ../path/src/get-workspace-root.ts
7522
+ var getWorkspaceRoot = /* @__PURE__ */ __name((dir = process.cwd()) => {
7523
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
7524
+ return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
7558
7525
  }
7559
- if (options.workspaceRoot) {
7560
- result.cache ??= joinPaths(options.workspaceRoot, "node_modules", ".cache", orgId);
7561
- result.temp ??= joinPaths(options.workspaceRoot, "tmp", orgId);
7562
- result.log ??= joinPaths(result.temp, "logs");
7563
- result.config ??= joinPaths(options.workspaceRoot, ".config", orgId);
7526
+ const root = findWorkspaceRootSafe(dir);
7527
+ if (root) {
7528
+ return root;
7564
7529
  }
7565
- return Object.keys(result).reduce((ret, key) => {
7566
- if (result[key]) {
7567
- const filePath = result[key];
7568
- ret[key] = options.appId && options.appId !== options.orgId && options.appId !== options.nestedDir ? joinPaths(filePath, options.appId) : filePath;
7569
- if (options.nestedDir && options.nestedDir !== options.orgId && options.nestedDir !== options.appId) {
7570
- ret[key] = joinPaths(ret[key], options.nestedDir);
7571
- }
7530
+ let result = getParentPath([
7531
+ "package-lock.json",
7532
+ "yarn.lock",
7533
+ "pnpm-lock.yaml",
7534
+ "bun.lock",
7535
+ "nx.json",
7536
+ "knip.json",
7537
+ "pnpm-workspace.yaml",
7538
+ "LICENSE",
7539
+ ".all-contributorsrc",
7540
+ ".whitesource",
7541
+ "syncpack.config.js",
7542
+ "syncpack.json",
7543
+ "socket.yaml",
7544
+ "lefthook.yaml",
7545
+ ".npmrc",
7546
+ ".log4brains.yml",
7547
+ ".huskyrc",
7548
+ ".husky",
7549
+ ".lintstagedrc",
7550
+ ".commitlintrc",
7551
+ "lefthook.yml",
7552
+ ".github",
7553
+ ".nx",
7554
+ ".vscode",
7555
+ "patches"
7556
+ ], dir);
7557
+ if (result) {
7558
+ return result;
7559
+ }
7560
+ result = dir;
7561
+ while (result && !isSystemRoot(result)) {
7562
+ result = getParentPath("storm.json", result, {
7563
+ skipCwd: true
7564
+ });
7565
+ if (result) {
7566
+ return result;
7572
7567
  }
7573
- return ret;
7574
- }, {});
7575
- }
7576
- __name(getEnvPaths, "getEnvPaths");
7568
+ }
7569
+ return dir;
7570
+ }, "getWorkspaceRoot");
7577
7571
 
7578
7572
  // src/utils/get-jiti.ts
7579
7573
  var import_jiti = require("jiti");
@@ -7602,17 +7596,12 @@ __name(getPrismaGeneratorHelper, "getPrismaGeneratorHelper");
7602
7596
 
7603
7597
  // src/utils/get-relative-path.ts
7604
7598
  init_cjs_shims();
7605
- var import_node_path3 = __toESM(require("node:path"), 1);
7606
7599
  function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath, fromPath) {
7607
- const _fromPath = fromPath || outputPath;
7608
- let toPath = import_node_path3.default.join(outputPath, filePath);
7609
- if (isOutsideOutputPath) {
7610
- const schemaPathSplit = schemaPath?.split(import_node_path3.default.sep);
7611
- const schemaPathWithoutFileAndExtension = schemaPathSplit.slice(0, schemaPathSplit.length - 1).join(import_node_path3.default.posix.sep);
7612
- toPath = import_node_path3.default.join(schemaPathWithoutFileAndExtension, filePath);
7613
- }
7614
- const newPath = relativePath(_fromPath, toPath).split(import_node_path3.default.sep).join(import_node_path3.default.posix.sep);
7615
- return newPath;
7600
+ let toPath = joinPaths(outputPath, filePath.endsWith(".ts") ? findFilePath(filePath) : filePath);
7601
+ if (isOutsideOutputPath && schemaPath) {
7602
+ toPath = joinPaths(schemaPath.endsWith(".prisma") ? findFilePath(schemaPath) : schemaPath, filePath);
7603
+ }
7604
+ return relativePath(fromPath || outputPath, toPath);
7616
7605
  }
7617
7606
  __name(getRelativePath, "getRelativePath");
7618
7607
 
@@ -7632,18 +7621,6 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7632
7621
  namedImports: imports
7633
7622
  });
7634
7623
  }, "generateCreateRouterImport");
7635
- var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, outputDir, value) => {
7636
- let shieldPath = joinPaths(outputDir, "shield");
7637
- if (typeof value === "string") {
7638
- shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
7639
- }
7640
- sourceFile.addImportDeclaration({
7641
- moduleSpecifier: shieldPath,
7642
- namedImports: [
7643
- "permissions"
7644
- ]
7645
- });
7646
- }, "generateShieldImport");
7647
7624
  var generateRouterImport = /* @__PURE__ */ __name((sourceFile, modelNamePlural, modelNameCamelCase) => {
7648
7625
  sourceFile.addImportDeclaration({
7649
7626
  moduleSpecifier: `./${modelNameCamelCase}.router`,
@@ -7652,9 +7629,22 @@ var generateRouterImport = /* @__PURE__ */ __name((sourceFile, modelNamePlural,
7652
7629
  ]
7653
7630
  });
7654
7631
  }, "generateRouterImport");
7655
- async function generateBaseRouter(sourceFile, config, options) {
7656
- const internals = await getPrismaInternals();
7657
- const outputDir = internals.parseEnvValue(options.generator.output);
7632
+ async function generateTRPCExports(sourceFile, config, options, outputDir) {
7633
+ if (config.withShield) {
7634
+ let shieldPath = joinPaths(outputDir, "shield");
7635
+ if (typeof config.withShield === "string") {
7636
+ shieldPath = getRelativePath(outputDir, config.withShield, true, options.schemaPath);
7637
+ }
7638
+ sourceFile.addImportDeclaration({
7639
+ moduleSpecifier: shieldPath,
7640
+ namedImports: [
7641
+ "permissions"
7642
+ ]
7643
+ });
7644
+ sourceFile.formatText({
7645
+ indentSize: 2
7646
+ });
7647
+ }
7658
7648
  sourceFile.addStatements(
7659
7649
  /* ts */
7660
7650
  `
@@ -7774,7 +7764,7 @@ export const createCallerFactory = t.createCallerFactory;`
7774
7764
  );
7775
7765
  }
7776
7766
  }
7777
- __name(generateBaseRouter, "generateBaseRouter");
7767
+ __name(generateTRPCExports, "generateTRPCExports");
7778
7768
  function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
7779
7769
  let input = `input${!config.withZod ? " as any" : ""}`;
7780
7770
  const nameWithoutModel = name.replace(modelName, "");
@@ -7990,6 +7980,53 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
7990
7980
  });
7991
7981
  return shieldText;
7992
7982
  }, "constructShield");
7983
+ var constructDefaultOptions = /* @__PURE__ */ __name((config, options, outputDir) => {
7984
+ return `import { ZodError } from 'zod';${config.withNext ? '\nimport { transformer } from "@stryke/trpc-next/shared";' : ""}
7985
+ import type {
7986
+ DataTransformerOptions,
7987
+ RootConfig
7988
+ } from "@trpc/server/unstable-core-do-not-import";
7989
+ import type { Context } from "${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}";
7990
+
7991
+ interface RuntimeConfigOptions<
7992
+ TContext extends object,
7993
+ TMeta extends object = object
7994
+ > extends Partial<
7995
+ Omit<
7996
+ RootConfig<{
7997
+ ctx: TContext;
7998
+ meta: TMeta;
7999
+ errorShape: any;
8000
+ transformer: any;
8001
+ }>,
8002
+ "$types" | "transformer"
8003
+ >
8004
+ > {
8005
+ /**
8006
+ * Use a data transformer
8007
+ * @see https://trpc.io/docs/v11/data-transformers
8008
+ */
8009
+ transformer?: DataTransformerOptions;
8010
+ }
8011
+
8012
+ const options: RuntimeConfigOptions<Context> = {${config.withNext ? "\n transformer," : ""}
8013
+ errorFormatter({ shape, error }) {
8014
+ return {
8015
+ ...shape,
8016
+ data: {
8017
+ ...shape.data,
8018
+ zodError:
8019
+ error.code === "BAD_REQUEST" && error.cause instanceof ZodError
8020
+ ? error.cause.flatten()
8021
+ : null
8022
+ }
8023
+ };
8024
+ }
8025
+ };
8026
+
8027
+ export default options;
8028
+ `;
8029
+ }, "constructDefaultOptions");
7993
8030
 
7994
8031
  // src/project.ts
7995
8032
  init_cjs_shims();
@@ -9195,7 +9232,7 @@ var isURL = /* @__PURE__ */ __name((payload) => payload instanceof URL, "isURL")
9195
9232
  // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.js
9196
9233
  init_cjs_shims();
9197
9234
  var escapeKey = /* @__PURE__ */ __name((key) => key.replace(/\./g, "\\."), "escapeKey");
9198
- var stringifyPath = /* @__PURE__ */ __name((path6) => path6.map(String).map(escapeKey).join("."), "stringifyPath");
9235
+ var stringifyPath = /* @__PURE__ */ __name((path5) => path5.map(String).map(escapeKey).join("."), "stringifyPath");
9199
9236
  var parsePath = /* @__PURE__ */ __name((string) => {
9200
9237
  const result = [];
9201
9238
  let segment = "";
@@ -9458,27 +9495,27 @@ var getNthKey = /* @__PURE__ */ __name((value, n) => {
9458
9495
  }
9459
9496
  return keys.next().value;
9460
9497
  }, "getNthKey");
9461
- function validatePath(path6) {
9462
- if (includes(path6, "__proto__")) {
9498
+ function validatePath(path5) {
9499
+ if (includes(path5, "__proto__")) {
9463
9500
  throw new Error("__proto__ is not allowed as a property");
9464
9501
  }
9465
- if (includes(path6, "prototype")) {
9502
+ if (includes(path5, "prototype")) {
9466
9503
  throw new Error("prototype is not allowed as a property");
9467
9504
  }
9468
- if (includes(path6, "constructor")) {
9505
+ if (includes(path5, "constructor")) {
9469
9506
  throw new Error("constructor is not allowed as a property");
9470
9507
  }
9471
9508
  }
9472
9509
  __name(validatePath, "validatePath");
9473
- var getDeep = /* @__PURE__ */ __name((object, path6) => {
9474
- validatePath(path6);
9475
- for (let i = 0; i < path6.length; i++) {
9476
- const key = path6[i];
9510
+ var getDeep = /* @__PURE__ */ __name((object, path5) => {
9511
+ validatePath(path5);
9512
+ for (let i = 0; i < path5.length; i++) {
9513
+ const key = path5[i];
9477
9514
  if (isSet(object)) {
9478
9515
  object = getNthKey(object, +key);
9479
9516
  } else if (isMap(object)) {
9480
9517
  const row = +key;
9481
- const type = +path6[++i] === 0 ? "key" : "value";
9518
+ const type = +path5[++i] === 0 ? "key" : "value";
9482
9519
  const keyOfRow = getNthKey(object, row);
9483
9520
  switch (type) {
9484
9521
  case "key":
@@ -9494,14 +9531,14 @@ var getDeep = /* @__PURE__ */ __name((object, path6) => {
9494
9531
  }
9495
9532
  return object;
9496
9533
  }, "getDeep");
9497
- var setDeep = /* @__PURE__ */ __name((object, path6, mapper) => {
9498
- validatePath(path6);
9499
- if (path6.length === 0) {
9534
+ var setDeep = /* @__PURE__ */ __name((object, path5, mapper) => {
9535
+ validatePath(path5);
9536
+ if (path5.length === 0) {
9500
9537
  return mapper(object);
9501
9538
  }
9502
9539
  let parent = object;
9503
- for (let i = 0; i < path6.length - 1; i++) {
9504
- const key = path6[i];
9540
+ for (let i = 0; i < path5.length - 1; i++) {
9541
+ const key = path5[i];
9505
9542
  if (isArray(parent)) {
9506
9543
  const index = +key;
9507
9544
  parent = parent[index];
@@ -9511,12 +9548,12 @@ var setDeep = /* @__PURE__ */ __name((object, path6, mapper) => {
9511
9548
  const row = +key;
9512
9549
  parent = getNthKey(parent, row);
9513
9550
  } else if (isMap(parent)) {
9514
- const isEnd = i === path6.length - 2;
9551
+ const isEnd = i === path5.length - 2;
9515
9552
  if (isEnd) {
9516
9553
  break;
9517
9554
  }
9518
9555
  const row = +key;
9519
- const type = +path6[++i] === 0 ? "key" : "value";
9556
+ const type = +path5[++i] === 0 ? "key" : "value";
9520
9557
  const keyOfRow = getNthKey(parent, row);
9521
9558
  switch (type) {
9522
9559
  case "key":
@@ -9528,7 +9565,7 @@ var setDeep = /* @__PURE__ */ __name((object, path6, mapper) => {
9528
9565
  }
9529
9566
  }
9530
9567
  }
9531
- const lastKey = path6[path6.length - 1];
9568
+ const lastKey = path5[path5.length - 1];
9532
9569
  if (isArray(parent)) {
9533
9570
  parent[+lastKey] = mapper(parent[+lastKey]);
9534
9571
  } else if (isPlainObject2(parent)) {
@@ -9543,7 +9580,7 @@ var setDeep = /* @__PURE__ */ __name((object, path6, mapper) => {
9543
9580
  }
9544
9581
  }
9545
9582
  if (isMap(parent)) {
9546
- const row = +path6[path6.length - 2];
9583
+ const row = +path5[path5.length - 2];
9547
9584
  const keyToRow = getNthKey(parent, row);
9548
9585
  const type = +lastKey === 0 ? "key" : "value";
9549
9586
  switch (type) {
@@ -9589,15 +9626,15 @@ function traverse(tree, walker2, origin = []) {
9589
9626
  }
9590
9627
  __name(traverse, "traverse");
9591
9628
  function applyValueAnnotations(plain, annotations, superJson) {
9592
- traverse(annotations, (type, path6) => {
9593
- plain = setDeep(plain, path6, (v) => untransformValue(v, type, superJson));
9629
+ traverse(annotations, (type, path5) => {
9630
+ plain = setDeep(plain, path5, (v) => untransformValue(v, type, superJson));
9594
9631
  });
9595
9632
  return plain;
9596
9633
  }
9597
9634
  __name(applyValueAnnotations, "applyValueAnnotations");
9598
9635
  function applyReferentialEqualityAnnotations(plain, annotations) {
9599
- function apply(identicalPaths, path6) {
9600
- const object = getDeep(plain, parsePath(path6));
9636
+ function apply(identicalPaths, path5) {
9637
+ const object = getDeep(plain, parsePath(path5));
9601
9638
  identicalPaths.map(parsePath).forEach((identicalObjectPath) => {
9602
9639
  plain = setDeep(plain, identicalObjectPath, () => object);
9603
9640
  });
@@ -9618,13 +9655,13 @@ function applyReferentialEqualityAnnotations(plain, annotations) {
9618
9655
  }
9619
9656
  __name(applyReferentialEqualityAnnotations, "applyReferentialEqualityAnnotations");
9620
9657
  var isDeep = /* @__PURE__ */ __name((object, superJson) => isPlainObject2(object) || isArray(object) || isMap(object) || isSet(object) || isInstanceOfRegisteredClass(object, superJson), "isDeep");
9621
- function addIdentity(object, path6, identities) {
9658
+ function addIdentity(object, path5, identities) {
9622
9659
  const existingSet = identities.get(object);
9623
9660
  if (existingSet) {
9624
- existingSet.push(path6);
9661
+ existingSet.push(path5);
9625
9662
  } else {
9626
9663
  identities.set(object, [
9627
- path6
9664
+ path5
9628
9665
  ]);
9629
9666
  }
9630
9667
  }
@@ -9637,7 +9674,7 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) {
9637
9674
  return;
9638
9675
  }
9639
9676
  if (!dedupe) {
9640
- paths = paths.map((path6) => path6.map(String)).sort((a, b) => a.length - b.length);
9677
+ paths = paths.map((path5) => path5.map(String)).sort((a, b) => a.length - b.length);
9641
9678
  }
9642
9679
  const [representativePath, ...identicalPaths] = paths;
9643
9680
  if (representativePath.length === 0) {
@@ -9662,10 +9699,10 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) {
9662
9699
  }
9663
9700
  }
9664
9701
  __name(generateReferentialEqualityAnnotations, "generateReferentialEqualityAnnotations");
9665
- var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path6 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
9702
+ var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path5 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
9666
9703
  const primitive = isPrimitive(object);
9667
9704
  if (!primitive) {
9668
- addIdentity(object, path6, identities);
9705
+ addIdentity(object, path5, identities);
9669
9706
  const seen = seenObjects.get(object);
9670
9707
  if (seen) {
9671
9708
  return dedupe ? {
@@ -9702,7 +9739,7 @@ var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path
9702
9739
  throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
9703
9740
  }
9704
9741
  const recursiveResult = walker(value, identities, superJson, dedupe, [
9705
- ...path6,
9742
+ ...path5,
9706
9743
  index
9707
9744
  ], [
9708
9745
  ...objectsInThisPath,
@@ -10282,7 +10319,7 @@ var writeFile = /* @__PURE__ */ __name(async (filePath, content, options) => {
10282
10319
  }, "writeFile");
10283
10320
 
10284
10321
  // src/utils/write-file-safely.ts
10285
- var import_node_path4 = __toESM(require("node:path"), 1);
10322
+ var import_node_path3 = __toESM(require("node:path"), 1);
10286
10323
 
10287
10324
  // src/utils/format-file.ts
10288
10325
  init_cjs_shims();
@@ -10326,7 +10363,7 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
10326
10363
  }, "writeFileSafely");
10327
10364
  var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10328
10365
  const rows = Array.from(indexExports).map((filePath) => {
10329
- let relativePath2 = import_node_path4.default.relative(import_node_path4.default.dirname(indexPath), filePath);
10366
+ let relativePath2 = import_node_path3.default.relative(import_node_path3.default.dirname(indexPath), filePath);
10330
10367
  if (relativePath2.endsWith(".ts")) {
10331
10368
  relativePath2 = relativePath2.slice(0, relativePath2.lastIndexOf(".ts"));
10332
10369
  }
@@ -10503,7 +10540,7 @@ init_cjs_shims();
10503
10540
 
10504
10541
  // src/zod-helpers/transformer.ts
10505
10542
  init_cjs_shims();
10506
- var import_node_path5 = __toESM(require("node:path"), 1);
10543
+ var import_node_path4 = __toESM(require("node:path"), 1);
10507
10544
 
10508
10545
  // src/zod-helpers/model-helpers.ts
10509
10546
  init_cjs_shims();
@@ -10651,13 +10688,13 @@ var Transformer = class _Transformer {
10651
10688
  this.isCustomPrismaClientOutputPath = prismaClientCustomPath !== "@prisma/client";
10652
10689
  }
10653
10690
  static async generateIndex() {
10654
- const indexPath = import_node_path5.default.join(_Transformer.outputPath, "schemas/index.ts");
10691
+ const indexPath = import_node_path4.default.join(_Transformer.outputPath, "schemas/index.ts");
10655
10692
  await writeIndexFile(indexPath);
10656
10693
  }
10657
10694
  async generateEnumSchemas() {
10658
10695
  for (const enumType2 of this.enumTypes) {
10659
10696
  const { name, values } = enumType2;
10660
- await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/enums/${name}.schema.ts`), `${this.generateImportZodStatement()}
10697
+ await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/enums/${name}.schema.ts`), `${this.generateImportZodStatement()}
10661
10698
  ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)})`)}`);
10662
10699
  }
10663
10700
  }
@@ -10671,7 +10708,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10671
10708
  const zodObjectSchemaFields = this.generateObjectSchemaFields();
10672
10709
  const objectSchema = this.prepareObjectSchema(zodObjectSchemaFields);
10673
10710
  const objectSchemaName = this.resolveObjectSchemaName();
10674
- await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/objects/${objectSchemaName}.schema.ts`), objectSchema);
10711
+ await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/objects/${objectSchemaName}.schema.ts`), objectSchema);
10675
10712
  }
10676
10713
  generateObjectSchemaFields() {
10677
10714
  const zodObjectSchemaFields = this.fields.map((field) => this.generateObjectSchemaField(field)).flatMap((item) => item).map((item) => {
@@ -10810,9 +10847,9 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10810
10847
  generateImportPrismaStatement() {
10811
10848
  let prismaClientImportPath;
10812
10849
  if (_Transformer.isCustomPrismaClientOutputPath) {
10813
- const fromPath = import_node_path5.default.join(_Transformer.outputPath, "schemas", "objects");
10850
+ const fromPath = import_node_path4.default.join(_Transformer.outputPath, "schemas", "objects");
10814
10851
  const toPath = _Transformer.prismaClientOutputPath;
10815
- const relativePathFromOutputToPrismaClient = import_node_path5.default.relative(fromPath, toPath).split(import_node_path5.default.sep).join(import_node_path5.default.posix.sep);
10852
+ const relativePathFromOutputToPrismaClient = import_node_path4.default.relative(fromPath, toPath).split(import_node_path4.default.sep).join(import_node_path4.default.posix.sep);
10816
10853
  prismaClientImportPath = relativePathFromOutputToPrismaClient;
10817
10854
  } else {
10818
10855
  prismaClientImportPath = _Transformer.prismaClientOutputPath;
@@ -10942,7 +10979,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10942
10979
  includeImport,
10943
10980
  `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
10944
10981
  ];
10945
- await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${findUnique}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindUnique`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
10982
+ await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${findUnique}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindUnique`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
10946
10983
  }
10947
10984
  if (findFirst) {
10948
10985
  const imports = [
@@ -10953,7 +10990,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10953
10990
  `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
10954
10991
  `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
10955
10992
  ];
10956
- await writeFileSafely(import_node_path5.default.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() })`)}`);
10993
+ await writeFileSafely(import_node_path4.default.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() })`)}`);
10957
10994
  }
10958
10995
  if (findMany) {
10959
10996
  const imports = [
@@ -10964,7 +11001,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10964
11001
  `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
10965
11002
  `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
10966
11003
  ];
10967
- await writeFileSafely(import_node_path5.default.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() })`)}`);
11004
+ await writeFileSafely(import_node_path4.default.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() })`)}`);
10968
11005
  }
10969
11006
  if (createOne) {
10970
11007
  const imports = [
@@ -10973,19 +11010,19 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10973
11010
  `import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
10974
11011
  `import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`
10975
11012
  ];
10976
- await writeFileSafely(import_node_path5.default.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]) })`)}`);
11013
+ await writeFileSafely(import_node_path4.default.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]) })`)}`);
10977
11014
  }
10978
11015
  if (createMany) {
10979
11016
  const imports = [
10980
11017
  `import { ${modelName}CreateManyInputObjectSchema } from './objects/${modelName}CreateManyInput.schema'`
10981
11018
  ];
10982
- await writeFileSafely(import_node_path5.default.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()"} })`)}`);
11019
+ await writeFileSafely(import_node_path4.default.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()"} })`)}`);
10983
11020
  }
10984
11021
  if (createManyAndReturn) {
10985
11022
  const imports = [
10986
11023
  `import { ${modelName}CreateManyAndReturnInputObjectSchema } from './objects/${modelName}CreateManyAndReturnInput.schema'`
10987
11024
  ];
10988
- await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${createManyAndReturn}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateManyAndReturn`, `z.object({ data: z.union([ ${modelName}CreateManyAndReturnInputObjectSchema, z.array(${modelName}CreateManyAndReturnInputObjectSchema) ]), ${_Transformer.provider === "mongodb" || _Transformer.provider === "sqlserver" ? "" : "skipDuplicates: z.boolean().optional()"} })`)}`);
11025
+ await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${createManyAndReturn}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateManyAndReturn`, `z.object({ data: z.union([ ${modelName}CreateManyAndReturnInputObjectSchema, z.array(${modelName}CreateManyAndReturnInputObjectSchema) ]), ${_Transformer.provider === "mongodb" || _Transformer.provider === "sqlserver" ? "" : "skipDuplicates: z.boolean().optional()"} })`)}`);
10989
11026
  }
10990
11027
  if (deleteOne) {
10991
11028
  const imports = [
@@ -10993,13 +11030,13 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10993
11030
  includeImport,
10994
11031
  `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
10995
11032
  ];
10996
- await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${deleteOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
11033
+ await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${deleteOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
10997
11034
  }
10998
11035
  if (deleteMany) {
10999
11036
  const imports = [
11000
11037
  `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
11001
11038
  ];
11002
- await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${deleteMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteMany`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
11039
+ await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${deleteMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteMany`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
11003
11040
  }
11004
11041
  if (updateOne) {
11005
11042
  const imports = [
@@ -11009,20 +11046,20 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
11009
11046
  `import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`,
11010
11047
  `import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
11011
11048
  ];
11012
- await writeFileSafely(import_node_path5.default.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 })`)}`);
11049
+ await writeFileSafely(import_node_path4.default.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 })`)}`);
11013
11050
  }
11014
11051
  if (updateMany) {
11015
11052
  const imports = [
11016
11053
  `import { ${modelName}UpdateManyMutationInputObjectSchema } from './objects/${modelName}UpdateManyMutationInput.schema'`,
11017
11054
  `import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
11018
11055
  ];
11019
- await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${updateMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateMany`, `z.object({ data: ${modelName}UpdateManyMutationInputObjectSchema, where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
11056
+ await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${updateMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateMany`, `z.object({ data: ${modelName}UpdateManyMutationInputObjectSchema, where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
11020
11057
  }
11021
11058
  if (updateManyAndReturn) {
11022
11059
  const imports = [
11023
11060
  `import { ${modelName}UpdateManyAndReturnInputObjectSchema } from './objects/${modelName}UpdateManyAndReturnInput.schema'`
11024
11061
  ];
11025
- await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${updateManyAndReturn}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateManyAndReturn`, `z.object({ data: z.union([ ${modelName}UpdateManyAndReturnInputObjectSchema, z.array(${modelName}UpdateManyAndReturnInputObjectSchema) ]), ${_Transformer.provider === "mongodb" || _Transformer.provider === "sqlserver" ? "" : "skipDuplicates: z.boolean().optional()"} })`)}`);
11062
+ await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${updateManyAndReturn}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateManyAndReturn`, `z.object({ data: z.union([ ${modelName}UpdateManyAndReturnInputObjectSchema, z.array(${modelName}UpdateManyAndReturnInputObjectSchema) ]), ${_Transformer.provider === "mongodb" || _Transformer.provider === "sqlserver" ? "" : "skipDuplicates: z.boolean().optional()"} })`)}`);
11026
11063
  }
11027
11064
  if (upsertOne) {
11028
11065
  const imports = [
@@ -11034,7 +11071,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
11034
11071
  `import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
11035
11072
  `import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`
11036
11073
  ];
11037
- await writeFileSafely(import_node_path5.default.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 ]) })`)}`);
11074
+ await writeFileSafely(import_node_path4.default.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 ]) })`)}`);
11038
11075
  }
11039
11076
  if (aggregate) {
11040
11077
  const imports = [
@@ -11065,7 +11102,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
11065
11102
  aggregateOperations.push(`_sum: ${modelName}SumAggregateInputObjectSchema.optional()`);
11066
11103
  }
11067
11104
  }
11068
- await writeFileSafely(import_node_path5.default.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(", ")} })`)}`);
11105
+ await writeFileSafely(import_node_path4.default.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(", ")} })`)}`);
11069
11106
  }
11070
11107
  if (groupBy) {
11071
11108
  const imports = [
@@ -11074,7 +11111,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
11074
11111
  `import { ${modelName}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${modelName}ScalarWhereWithAggregatesInput.schema'`,
11075
11112
  `import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
11076
11113
  ];
11077
- await writeFileSafely(import_node_path5.default.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) })`)}`);
11114
+ await writeFileSafely(import_node_path4.default.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) })`)}`);
11078
11115
  }
11079
11116
  }
11080
11117
  }
@@ -11613,18 +11650,18 @@ async function generate(options) {
11613
11650
  subscriptions.sort();
11614
11651
  if (config.withShield !== false) {
11615
11652
  consoleLog("Generating tRPC Shield");
11616
- if (typeof config.withShield === "string" && (existsSync(config.withShield) || existsSync(joinPaths(config.withShield, "shield.ts")))) {
11653
+ if (typeof config.withShield === "string" && (existsSync(config.withShield) || existsSync(`${config.withShield}.ts`) || existsSync(joinPaths(config.withShield, "shield.ts")))) {
11617
11654
  consoleLog("Skipping tRPC Shield generation as path provided already exists");
11618
11655
  } else {
11619
- consoleLog("Constructing tRPC Shield source file");
11620
- const shieldOutputDir = typeof config.withShield === "string" ? findFileExtension(config.withShield) ? findFilePath(config.withShield) : config.withShield : outputDir;
11656
+ const shieldOutputDir = typeof config.withShield === "string" ? config.withShield : outputDir;
11657
+ consoleLog(`Constructing tRPC Shield source file in ${shieldOutputDir}`);
11621
11658
  const shieldText = await constructShield({
11622
11659
  queries,
11623
11660
  mutations,
11624
11661
  subscriptions
11625
11662
  }, config, options, shieldOutputDir);
11626
11663
  consoleLog("Saving tRPC Shield source file to disk");
11627
- await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
11664
+ await writeFileSafely(shieldOutputDir.endsWith(".ts") ? shieldOutputDir : joinPaths(shieldOutputDir, "shield.ts"), shieldText);
11628
11665
  }
11629
11666
  } else {
11630
11667
  consoleLog("Skipping tRPC Shield generation");
@@ -11633,66 +11670,16 @@ async function generate(options) {
11633
11670
  if (config.trpcOptions && typeof config.trpcOptions === "boolean") {
11634
11671
  const trpcOptionsOutputPath = joinPaths(outputDir, "options.ts");
11635
11672
  consoleLog("Generating tRPC options source file");
11636
- await writeFileSafely(trpcOptionsOutputPath, `import { ZodError } from 'zod';${config.withNext ? '\nimport { transformer } from "@stryke/trpc-next/shared";' : ""}
11637
- import type {
11638
- DataTransformerOptions,
11639
- RootConfig
11640
- } from "@trpc/server/unstable-core-do-not-import";
11641
- import type { Context } from "../context";
11642
-
11643
- interface RuntimeConfigOptions<
11644
- TContext extends object,
11645
- TMeta extends object = object
11646
- > extends Partial<
11647
- Omit<
11648
- RootConfig<{
11649
- ctx: TContext;
11650
- meta: TMeta;
11651
- errorShape: any;
11652
- transformer: any;
11653
- }>,
11654
- "$types" | "transformer"
11655
- >
11656
- > {
11657
- /**
11658
- * Use a data transformer
11659
- * @see https://trpc.io/docs/v11/data-transformers
11660
- */
11661
- transformer?: DataTransformerOptions;
11662
- }
11663
-
11664
- const options: RuntimeConfigOptions<Context> = {${config.withNext ? "\n transformer," : ""}
11665
- errorFormatter({ shape, error }) {
11666
- return {
11667
- ...shape,
11668
- data: {
11669
- ...shape.data,
11670
- zodError:
11671
- error.code === "BAD_REQUEST" && error.cause instanceof ZodError
11672
- ? error.cause.flatten()
11673
- : null
11674
- }
11675
- };
11676
- }
11677
- };
11678
-
11679
- export default options;
11680
- `);
11673
+ await writeFileSafely(trpcOptionsOutputPath, constructDefaultOptions(config, options, trpcOptionsOutputPath));
11681
11674
  }
11682
11675
  resolveModelsComments(models, hiddenModels);
11683
- const trpcExports = project.createSourceFile(import_node_path6.default.resolve(outputDir, "trpc.ts"), void 0, {
11676
+ consoleLog("Generating tRPC export file");
11677
+ const trpcExports = project.createSourceFile(import_node_path5.default.resolve(outputDir, "trpc.ts"), void 0, {
11684
11678
  overwrite: true
11685
11679
  });
11686
- consoleLog("Generating tRPC imports");
11687
- if (config.withShield) {
11688
- await generateShieldImport(trpcExports, options, outputDir, config.withShield);
11689
- }
11690
- consoleLog("Generating tRPC base router");
11691
- await generateBaseRouter(trpcExports, config, options);
11692
- trpcExports.formatText({
11693
- indentSize: 2
11694
- });
11695
- const appRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "routers", `index.ts`), void 0, {
11680
+ await generateTRPCExports(trpcExports, config, options, outputDir);
11681
+ consoleLog("Generating tRPC app router");
11682
+ const appRouter = project.createSourceFile(import_node_path5.default.resolve(outputDir, "routers", `index.ts`), void 0, {
11696
11683
  overwrite: true
11697
11684
  });
11698
11685
  consoleLog("Generating tRPC router imports");
@@ -11721,7 +11708,7 @@ export default options;
11721
11708
  const plural = (0, import_pluralize.default)(lowerCaseFirst(model));
11722
11709
  consoleLog(`Generating tRPC router for model ${model}`);
11723
11710
  generateRouterImport(appRouter, plural, model);
11724
- const modelRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
11711
+ const modelRouter = project.createSourceFile(import_node_path5.default.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
11725
11712
  overwrite: true
11726
11713
  });
11727
11714
  generateCreateRouterImport({