@stryke/prisma-trpc-generator 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2503,21 +2503,6 @@ async function removeDirectory(path5) {
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;
@@ -2633,361 +2618,31 @@ function normalizeString(path5, allowAboveRoot) {
2633
2618
  res = path5.slice(lastSlash + 1, index);
2634
2619
  }
2635
2620
  lastSegmentLength = index - lastSlash - 1;
2636
- }
2637
- lastSlash = index;
2638
- dots = 0;
2639
- } else if (char === "." && dots !== -1) {
2640
- ++dots;
2641
- } else {
2642
- dots = -1;
2643
- }
2644
- }
2645
- return res;
2646
- }
2647
- __name(normalizeString, "normalizeString");
2648
-
2649
- // ../path/src/is-file.ts
2650
- function isFile(path5, additionalPath) {
2651
- return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath, path5) : path5, {
2652
- throwIfNoEntry: false
2653
- })?.isFile());
2654
- }
2655
- __name(isFile, "isFile");
2656
- function isDirectory(path5, additionalPath) {
2657
- return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath, path5) : path5, {
2658
- throwIfNoEntry: false
2659
- })?.isDirectory());
2660
- }
2661
- __name(isDirectory, "isDirectory");
2662
- function isAbsolutePath(path5) {
2663
- return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path5);
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(path5) {
2679
- if (!path5 || path5.length === 0) {
2680
- return ".";
2681
- }
2682
- path5 = normalizeWindowsPath2(path5);
2683
- const isUNCPath = path5.match(_UNC_REGEX2);
2684
- const isPathAbsolute = isAbsolutePath(path5);
2685
- const trailingSeparator = path5[path5.length - 1] === "/";
2686
- path5 = normalizeString2(path5, !isPathAbsolute);
2687
- if (path5.length === 0) {
2688
- if (isPathAbsolute) {
2689
- return "/";
2690
- }
2691
- return trailingSeparator ? "./" : ".";
2692
- }
2693
- if (trailingSeparator) {
2694
- path5 += "/";
2695
- }
2696
- if (_DRIVE_LETTER_RE2.test(path5)) {
2697
- path5 += "/";
2698
- }
2699
- if (isUNCPath) {
2700
- if (!isPathAbsolute) {
2701
- return `//./${path5}`;
2702
- }
2703
- return `//${path5}`;
2704
- }
2705
- return isPathAbsolute && !isAbsolutePath(path5) ? `/${path5}` : path5;
2706
- }
2707
- __name(correctPath, "correctPath");
2708
- function normalizeString2(path5, 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 <= path5.length; ++index) {
2715
- if (index < path5.length) {
2716
- char = path5[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 += `/${path5.slice(lastSlash + 1, index)}`;
2753
- } else {
2754
- res = path5.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
2777
- init_cjs_shims();
2778
-
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();
2781
-
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
2783
- 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
-
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
2813
- init_cjs_shims();
2814
- var _DRIVE_LETTER_START_RE3 = /^[A-Za-z]:\//;
2815
- function normalizeWindowsPath3(input = "") {
2816
- if (!input) {
2817
- return input;
2818
- }
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(path5) {
2827
- if (!path5 || path5.length === 0) {
2828
- return ".";
2829
- }
2830
- path5 = normalizeWindowsPath3(path5);
2831
- const isUNCPath = path5.match(_UNC_REGEX3);
2832
- const isPathAbsolute = isAbsolute2(path5);
2833
- const trailingSeparator = path5[path5.length - 1] === "/";
2834
- path5 = normalizeString3(path5, !isPathAbsolute);
2835
- if (path5.length === 0) {
2836
- if (isPathAbsolute) {
2837
- return "/";
2838
- }
2839
- return trailingSeparator ? "./" : ".";
2840
- }
2841
- if (trailingSeparator) {
2842
- path5 += "/";
2843
- }
2844
- if (_DRIVE_LETTER_RE3.test(path5)) {
2845
- path5 += "/";
2846
- }
2847
- if (isUNCPath) {
2848
- if (!isPathAbsolute) {
2849
- return `//./${path5}`;
2850
- }
2851
- return `//${path5}`;
2852
- }
2853
- return isPathAbsolute && !isAbsolute2(path5) ? `/${path5}` : path5;
2854
- }, "correctPaths");
2855
- function cwd() {
2856
- if (typeof process !== "undefined" && typeof process.cwd === "function") {
2857
- return process.cwd().replace(/\\/g, "/");
2858
- }
2859
- return "/";
2860
- }
2861
- __name(cwd, "cwd");
2862
- __name2(cwd, "cwd");
2863
- function normalizeString3(path5, 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 <= path5.length; ++index) {
2870
- if (index < path5.length) {
2871
- char = path5[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 += `/${path5.slice(lastSlash + 1, index)}`;
2908
- } else {
2909
- res = path5.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()}`);
2621
+ }
2622
+ lastSlash = index;
2623
+ dots = 0;
2624
+ } else if (char === "." && dots !== -1) {
2625
+ ++dots;
2626
+ } else {
2627
+ dots = -1;
2628
+ }
2986
2629
  }
2987
- return result;
2630
+ return res;
2988
2631
  }
2989
- __name(findWorkspaceRoot, "findWorkspaceRoot");
2990
- __name2(findWorkspaceRoot, "findWorkspaceRoot");
2632
+ __name(normalizeString, "normalizeString");
2633
+
2634
+ // ../string-format/src/lower-case-first.ts
2635
+ init_cjs_shims();
2636
+ var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
2637
+ return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
2638
+ }, "lowerCaseFirst");
2639
+
2640
+ // src/prisma-generator.ts
2641
+ var import_node_path5 = __toESM(require("node:path"), 1);
2642
+ var import_pluralize = __toESM(require_pluralize(), 1);
2643
+
2644
+ // src/config.ts
2645
+ init_cjs_shims();
2991
2646
 
2992
2647
  // ../../node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.mjs
2993
2648
  init_cjs_shims();
@@ -7195,6 +6850,403 @@ var z = /* @__PURE__ */ Object.freeze({
7195
6850
  ZodError
7196
6851
  });
7197
6852
 
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("../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
6892
+ init_cjs_shims();
6893
+
6894
+ // ../path/src/file-path-fns.ts
6895
+ init_cjs_shims();
6896
+
6897
+ // ../types/src/base.ts
6898
+ init_cjs_shims();
6899
+ var EMPTY_STRING = "";
6900
+ var $NestedValue = Symbol("NestedValue");
6901
+
6902
+ // ../path/src/correct-path.ts
6903
+ init_cjs_shims();
6904
+
6905
+ // ../path/src/is-file.ts
6906
+ init_cjs_shims();
6907
+ var import_node_fs2 = require("node:fs");
6908
+ function isFile(path5, additionalPath) {
6909
+ return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath, path5) : path5, {
6910
+ throwIfNoEntry: false
6911
+ })?.isFile());
6912
+ }
6913
+ __name(isFile, "isFile");
6914
+ function isDirectory(path5, additionalPath) {
6915
+ return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath, path5) : path5, {
6916
+ throwIfNoEntry: false
6917
+ })?.isDirectory());
6918
+ }
6919
+ __name(isDirectory, "isDirectory");
6920
+ function isAbsolutePath(path5) {
6921
+ return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path5);
6922
+ }
6923
+ __name(isAbsolutePath, "isAbsolutePath");
6924
+
6925
+ // ../path/src/correct-path.ts
6926
+ var _DRIVE_LETTER_START_RE2 = /^[A-Z]:\//i;
6927
+ function normalizeWindowsPath2(input = "") {
6928
+ if (!input) {
6929
+ return input;
6930
+ }
6931
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE2, (r) => r.toUpperCase());
6932
+ }
6933
+ __name(normalizeWindowsPath2, "normalizeWindowsPath");
6934
+ var _UNC_REGEX2 = /^[/\\]{2}/;
6935
+ var _DRIVE_LETTER_RE2 = /^[A-Z]:$/i;
6936
+ function correctPath(path5) {
6937
+ if (!path5 || path5.length === 0) {
6938
+ return ".";
6939
+ }
6940
+ path5 = normalizeWindowsPath2(path5);
6941
+ const isUNCPath = path5.match(_UNC_REGEX2);
6942
+ const isPathAbsolute = isAbsolutePath(path5);
6943
+ const trailingSeparator = path5[path5.length - 1] === "/";
6944
+ path5 = normalizeString2(path5, !isPathAbsolute);
6945
+ if (path5.length === 0) {
6946
+ if (isPathAbsolute) {
6947
+ return "/";
6948
+ }
6949
+ return trailingSeparator ? "./" : ".";
6950
+ }
6951
+ if (trailingSeparator) {
6952
+ path5 += "/";
6953
+ }
6954
+ if (_DRIVE_LETTER_RE2.test(path5)) {
6955
+ path5 += "/";
6956
+ }
6957
+ if (isUNCPath) {
6958
+ if (!isPathAbsolute) {
6959
+ return `//./${path5}`;
6960
+ }
6961
+ return `//${path5}`;
6962
+ }
6963
+ return isPathAbsolute && !isAbsolutePath(path5) ? `/${path5}` : path5;
6964
+ }
6965
+ __name(correctPath, "correctPath");
6966
+ function normalizeString2(path5, allowAboveRoot) {
6967
+ let res = "";
6968
+ let lastSegmentLength = 0;
6969
+ let lastSlash = -1;
6970
+ let dots = 0;
6971
+ let char = null;
6972
+ for (let index = 0; index <= path5.length; ++index) {
6973
+ if (index < path5.length) {
6974
+ char = path5[index];
6975
+ } else if (char === "/") {
6976
+ break;
6977
+ } else {
6978
+ char = "/";
6979
+ }
6980
+ if (char === "/") {
6981
+ if (lastSlash === index - 1 || dots === 1) {
6982
+ } else if (dots === 2) {
6983
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
6984
+ if (res.length > 2) {
6985
+ const lastSlashIndex = res.lastIndexOf("/");
6986
+ if (lastSlashIndex === -1) {
6987
+ res = "";
6988
+ lastSegmentLength = 0;
6989
+ } else {
6990
+ res = res.slice(0, lastSlashIndex);
6991
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
6992
+ }
6993
+ lastSlash = index;
6994
+ dots = 0;
6995
+ continue;
6996
+ } else if (res.length > 0) {
6997
+ res = "";
6998
+ lastSegmentLength = 0;
6999
+ lastSlash = index;
7000
+ dots = 0;
7001
+ continue;
7002
+ }
7003
+ }
7004
+ if (allowAboveRoot) {
7005
+ res += res.length > 0 ? "/.." : "..";
7006
+ lastSegmentLength = 2;
7007
+ }
7008
+ } else {
7009
+ if (res.length > 0) {
7010
+ res += `/${path5.slice(lastSlash + 1, index)}`;
7011
+ } else {
7012
+ res = path5.slice(lastSlash + 1, index);
7013
+ }
7014
+ lastSegmentLength = index - lastSlash - 1;
7015
+ }
7016
+ lastSlash = index;
7017
+ dots = 0;
7018
+ } else if (char === "." && dots !== -1) {
7019
+ ++dots;
7020
+ } else {
7021
+ dots = -1;
7022
+ }
7023
+ }
7024
+ return res;
7025
+ }
7026
+ __name(normalizeString2, "normalizeString");
7027
+
7028
+ // ../path/src/get-workspace-root.ts
7029
+ init_cjs_shims();
7030
+
7031
+ // ../../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
7032
+ init_cjs_shims();
7033
+
7034
+ // ../../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
7035
+ init_cjs_shims();
7036
+
7037
+ // ../../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
7038
+ init_cjs_shims();
7039
+
7040
+ // ../../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
7041
+ init_cjs_shims();
7042
+ var __defProp2 = Object.defineProperty;
7043
+ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", {
7044
+ value,
7045
+ configurable: true
7046
+ }), "__name");
7047
+
7048
+ // ../../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
7049
+ var import_node_fs3 = require("node:fs");
7050
+ var import_node_path = require("node:path");
7051
+ var MAX_PATH_SEARCH_DEPTH = 30;
7052
+ var depth = 0;
7053
+ function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
7054
+ const _startPath = startPath ?? process.cwd();
7055
+ if (endDirectoryNames.some((endDirName) => (0, import_node_fs3.existsSync)((0, import_node_path.join)(_startPath, endDirName)))) {
7056
+ return _startPath;
7057
+ }
7058
+ if (endFileNames.some((endFileName) => (0, import_node_fs3.existsSync)((0, import_node_path.join)(_startPath, endFileName)))) {
7059
+ return _startPath;
7060
+ }
7061
+ if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
7062
+ const parent = (0, import_node_path.join)(_startPath, "..");
7063
+ return findFolderUp(parent, endFileNames, endDirectoryNames);
7064
+ }
7065
+ return void 0;
7066
+ }
7067
+ __name(findFolderUp, "findFolderUp");
7068
+ __name2(findFolderUp, "findFolderUp");
7069
+
7070
+ // ../../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
7071
+ init_cjs_shims();
7072
+ var _DRIVE_LETTER_START_RE3 = /^[A-Za-z]:\//;
7073
+ function normalizeWindowsPath3(input = "") {
7074
+ if (!input) {
7075
+ return input;
7076
+ }
7077
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE3, (r) => r.toUpperCase());
7078
+ }
7079
+ __name(normalizeWindowsPath3, "normalizeWindowsPath");
7080
+ __name2(normalizeWindowsPath3, "normalizeWindowsPath");
7081
+ var _UNC_REGEX3 = /^[/\\]{2}/;
7082
+ var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
7083
+ var _DRIVE_LETTER_RE3 = /^[A-Za-z]:$/;
7084
+ var correctPaths2 = /* @__PURE__ */ __name2(function(path5) {
7085
+ if (!path5 || path5.length === 0) {
7086
+ return ".";
7087
+ }
7088
+ path5 = normalizeWindowsPath3(path5);
7089
+ const isUNCPath = path5.match(_UNC_REGEX3);
7090
+ const isPathAbsolute = isAbsolute2(path5);
7091
+ const trailingSeparator = path5[path5.length - 1] === "/";
7092
+ path5 = normalizeString3(path5, !isPathAbsolute);
7093
+ if (path5.length === 0) {
7094
+ if (isPathAbsolute) {
7095
+ return "/";
7096
+ }
7097
+ return trailingSeparator ? "./" : ".";
7098
+ }
7099
+ if (trailingSeparator) {
7100
+ path5 += "/";
7101
+ }
7102
+ if (_DRIVE_LETTER_RE3.test(path5)) {
7103
+ path5 += "/";
7104
+ }
7105
+ if (isUNCPath) {
7106
+ if (!isPathAbsolute) {
7107
+ return `//./${path5}`;
7108
+ }
7109
+ return `//${path5}`;
7110
+ }
7111
+ return isPathAbsolute && !isAbsolute2(path5) ? `/${path5}` : path5;
7112
+ }, "correctPaths");
7113
+ function cwd() {
7114
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
7115
+ return process.cwd().replace(/\\/g, "/");
7116
+ }
7117
+ return "/";
7118
+ }
7119
+ __name(cwd, "cwd");
7120
+ __name2(cwd, "cwd");
7121
+ function normalizeString3(path5, allowAboveRoot) {
7122
+ let res = "";
7123
+ let lastSegmentLength = 0;
7124
+ let lastSlash = -1;
7125
+ let dots = 0;
7126
+ let char = null;
7127
+ for (let index = 0; index <= path5.length; ++index) {
7128
+ if (index < path5.length) {
7129
+ char = path5[index];
7130
+ } else if (char === "/") {
7131
+ break;
7132
+ } else {
7133
+ char = "/";
7134
+ }
7135
+ if (char === "/") {
7136
+ if (lastSlash === index - 1 || dots === 1) {
7137
+ } else if (dots === 2) {
7138
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
7139
+ if (res.length > 2) {
7140
+ const lastSlashIndex = res.lastIndexOf("/");
7141
+ if (lastSlashIndex === -1) {
7142
+ res = "";
7143
+ lastSegmentLength = 0;
7144
+ } else {
7145
+ res = res.slice(0, lastSlashIndex);
7146
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
7147
+ }
7148
+ lastSlash = index;
7149
+ dots = 0;
7150
+ continue;
7151
+ } else if (res.length > 0) {
7152
+ res = "";
7153
+ lastSegmentLength = 0;
7154
+ lastSlash = index;
7155
+ dots = 0;
7156
+ continue;
7157
+ }
7158
+ }
7159
+ if (allowAboveRoot) {
7160
+ res += res.length > 0 ? "/.." : "..";
7161
+ lastSegmentLength = 2;
7162
+ }
7163
+ } else {
7164
+ if (res.length > 0) {
7165
+ res += `/${path5.slice(lastSlash + 1, index)}`;
7166
+ } else {
7167
+ res = path5.slice(lastSlash + 1, index);
7168
+ }
7169
+ lastSegmentLength = index - lastSlash - 1;
7170
+ }
7171
+ lastSlash = index;
7172
+ dots = 0;
7173
+ } else if (char === "." && dots !== -1) {
7174
+ ++dots;
7175
+ } else {
7176
+ dots = -1;
7177
+ }
7178
+ }
7179
+ return res;
7180
+ }
7181
+ __name(normalizeString3, "normalizeString");
7182
+ __name2(normalizeString3, "normalizeString");
7183
+ var isAbsolute2 = /* @__PURE__ */ __name2(function(p) {
7184
+ return _IS_ABSOLUTE_RE2.test(p);
7185
+ }, "isAbsolute");
7186
+
7187
+ // ../../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
7188
+ var rootFiles = [
7189
+ "storm-workspace.json",
7190
+ "storm-workspace.json",
7191
+ "storm-workspace.yaml",
7192
+ "storm-workspace.yml",
7193
+ "storm-workspace.js",
7194
+ "storm-workspace.ts",
7195
+ ".storm-workspace.json",
7196
+ ".storm-workspace.yaml",
7197
+ ".storm-workspace.yml",
7198
+ ".storm-workspace.js",
7199
+ ".storm-workspace.ts",
7200
+ "lerna.json",
7201
+ "nx.json",
7202
+ "turbo.json",
7203
+ "npm-workspace.json",
7204
+ "yarn-workspace.json",
7205
+ "pnpm-workspace.json",
7206
+ "npm-workspace.yaml",
7207
+ "yarn-workspace.yaml",
7208
+ "pnpm-workspace.yaml",
7209
+ "npm-workspace.yml",
7210
+ "yarn-workspace.yml",
7211
+ "pnpm-workspace.yml",
7212
+ "npm-lock.json",
7213
+ "yarn-lock.json",
7214
+ "pnpm-lock.json",
7215
+ "npm-lock.yaml",
7216
+ "yarn-lock.yaml",
7217
+ "pnpm-lock.yaml",
7218
+ "npm-lock.yml",
7219
+ "yarn-lock.yml",
7220
+ "pnpm-lock.yml",
7221
+ "bun.lockb"
7222
+ ];
7223
+ var rootDirectories = [
7224
+ ".storm-workspace",
7225
+ ".nx",
7226
+ ".github",
7227
+ ".vscode",
7228
+ ".verdaccio"
7229
+ ];
7230
+ function findWorkspaceRootSafe(pathInsideMonorepo) {
7231
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
7232
+ return correctPaths2(process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH);
7233
+ }
7234
+ return correctPaths2(findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles, rootDirectories));
7235
+ }
7236
+ __name(findWorkspaceRootSafe, "findWorkspaceRootSafe");
7237
+ __name2(findWorkspaceRootSafe, "findWorkspaceRootSafe");
7238
+ function findWorkspaceRoot(pathInsideMonorepo) {
7239
+ const result = findWorkspaceRootSafe(pathInsideMonorepo);
7240
+ if (!result) {
7241
+ throw new Error(`Cannot find workspace root upwards from known path. Files search list includes:
7242
+ ${rootFiles.join("\n")}
7243
+ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`);
7244
+ }
7245
+ return result;
7246
+ }
7247
+ __name(findWorkspaceRoot, "findWorkspaceRoot");
7248
+ __name2(findWorkspaceRoot, "findWorkspaceRoot");
7249
+
7198
7250
  // ../path/src/get-parent-path.ts
7199
7251
  init_cjs_shims();
7200
7252
  var resolveParentPath = /* @__PURE__ */ __name((path5) => {
@@ -7349,58 +7401,6 @@ function relativePath(from, to) {
7349
7401
  }
7350
7402
  __name(relativePath, "relativePath");
7351
7403
 
7352
- // ../string-format/src/lower-case-first.ts
7353
- init_cjs_shims();
7354
- var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
7355
- return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
7356
- }, "lowerCaseFirst");
7357
-
7358
- // src/prisma-generator.ts
7359
- var import_node_path5 = __toESM(require("node:path"), 1);
7360
- var import_pluralize = __toESM(require_pluralize(), 1);
7361
-
7362
- // src/config.ts
7363
- init_cjs_shims();
7364
- var ModelAction = /* @__PURE__ */ function(ModelAction2) {
7365
- ModelAction2["findUnique"] = "findUnique";
7366
- ModelAction2["findUniqueOrThrow"] = "findUniqueOrThrow";
7367
- ModelAction2["findFirst"] = "findFirst";
7368
- ModelAction2["findFirstOrThrow"] = "findFirstOrThrow";
7369
- ModelAction2["findMany"] = "findMany";
7370
- ModelAction2["create"] = "create";
7371
- ModelAction2["createMany"] = "createMany";
7372
- ModelAction2["createManyAndReturn"] = "createManyAndReturn";
7373
- ModelAction2["update"] = "update";
7374
- ModelAction2["updateMany"] = "updateMany";
7375
- ModelAction2["updateManyAndReturn"] = "updateManyAndReturn";
7376
- ModelAction2["upsert"] = "upsert";
7377
- ModelAction2["delete"] = "delete";
7378
- ModelAction2["deleteMany"] = "deleteMany";
7379
- ModelAction2["groupBy"] = "groupBy";
7380
- ModelAction2["count"] = "count";
7381
- ModelAction2["aggregate"] = "aggregate";
7382
- ModelAction2["findRaw"] = "findRaw";
7383
- ModelAction2["aggregateRaw"] = "aggregateRaw";
7384
- return ModelAction2;
7385
- }(ModelAction || {});
7386
- var modelActionEnum = z.nativeEnum(ModelAction);
7387
- var configSchema = z.object({
7388
- debug: z.coerce.boolean().or(z.string()).default(false),
7389
- withMiddleware: z.coerce.boolean().or(z.string()).default(false),
7390
- withShield: z.coerce.boolean().or(z.string()).default(true),
7391
- withZod: z.coerce.boolean().or(z.string()).default(true),
7392
- withNext: z.coerce.boolean().or(z.string()).default(true),
7393
- contextPath: z.string().default("../src/trpc/context.ts"),
7394
- trpcOptions: z.coerce.boolean().or(z.string()).default(true),
7395
- showModelNameInProcedure: z.coerce.boolean().or(z.string()).default(true),
7396
- generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
7397
- return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
7398
- })
7399
- });
7400
-
7401
- // src/helpers.ts
7402
- init_cjs_shims();
7403
-
7404
7404
  // src/utils/get-prisma-internals.ts
7405
7405
  init_cjs_shims();
7406
7406
 
@@ -7592,17 +7592,6 @@ async function getPrismaGeneratorHelper() {
7592
7592
  }
7593
7593
  __name(getPrismaGeneratorHelper, "getPrismaGeneratorHelper");
7594
7594
 
7595
- // src/utils/get-relative-path.ts
7596
- init_cjs_shims();
7597
- function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath, fromPath) {
7598
- let toPath = joinPaths(outputPath, filePath.endsWith(".ts") ? findFilePath(filePath) : filePath);
7599
- if (isOutsideOutputPath && schemaPath) {
7600
- toPath = joinPaths(schemaPath.endsWith(".prisma") ? findFilePath(schemaPath) : schemaPath, filePath);
7601
- }
7602
- return relativePath(fromPath || outputPath, toPath);
7603
- }
7604
- __name(getRelativePath, "getRelativePath");
7605
-
7606
7595
  // src/helpers.ts
7607
7596
  var getProcedureName = /* @__PURE__ */ __name((config) => {
7608
7597
  return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
@@ -7619,18 +7608,6 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7619
7608
  namedImports: imports
7620
7609
  });
7621
7610
  }, "generateCreateRouterImport");
7622
- var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, outputDir, value) => {
7623
- let shieldPath = joinPaths(outputDir, "shield");
7624
- if (typeof value === "string") {
7625
- shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
7626
- }
7627
- sourceFile.addImportDeclaration({
7628
- moduleSpecifier: shieldPath,
7629
- namedImports: [
7630
- "permissions"
7631
- ]
7632
- });
7633
- }, "generateShieldImport");
7634
7611
  var generateRouterImport = /* @__PURE__ */ __name((sourceFile, modelNamePlural, modelNameCamelCase) => {
7635
7612
  sourceFile.addImportDeclaration({
7636
7613
  moduleSpecifier: `./${modelNameCamelCase}.router`,
@@ -7639,25 +7616,34 @@ var generateRouterImport = /* @__PURE__ */ __name((sourceFile, modelNamePlural,
7639
7616
  ]
7640
7617
  });
7641
7618
  }, "generateRouterImport");
7642
- async function generateBaseRouter(sourceFile, config, options) {
7643
- const internals = await getPrismaInternals();
7644
- const outputDir = internals.parseEnvValue(options.generator.output);
7619
+ async function generateTRPCExports(sourceFile, config, options, outputDir) {
7620
+ if (config.withShield) {
7621
+ sourceFile.addImportDeclaration({
7622
+ moduleSpecifier: relativePath(outputDir, joinPaths(outputDir, typeof config.withShield === "string" ? config.withShield : "shield")),
7623
+ namedImports: [
7624
+ "permissions"
7625
+ ]
7626
+ });
7627
+ sourceFile.formatText({
7628
+ indentSize: 2
7629
+ });
7630
+ }
7645
7631
  sourceFile.addStatements(
7646
7632
  /* ts */
7647
7633
  `
7648
- import type { Context } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';`
7634
+ import type { Context } from '${relativePath(outputDir, joinPaths(outputDir, config.contextPath))}';`
7649
7635
  );
7650
7636
  if (config.trpcOptions) {
7651
7637
  sourceFile.addStatements(
7652
7638
  /* ts */
7653
7639
  `
7654
- import trpcOptions from '${getRelativePath(outputDir, typeof config.trpcOptions === "boolean" ? joinPaths(outputDir, "options") : config.trpcOptions, true, options.schemaPath)}';`
7640
+ import trpcOptions from '${relativePath(outputDir, joinPaths(outputDir, typeof config.trpcOptions === "string" ? config.trpcOptions : "options"))}';`
7655
7641
  );
7656
7642
  }
7657
7643
  if (config.withNext) {
7658
7644
  sourceFile.addStatements(
7659
7645
  /* ts */
7660
- `import { createContext } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';
7646
+ `import { createContext } from '${relativePath(outputDir, joinPaths(outputDir, config.contextPath))}';
7661
7647
  import { initTRPC } from '@trpc/server';
7662
7648
  import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';`
7663
7649
  );
@@ -7689,7 +7675,7 @@ async function generateBaseRouter(sourceFile, config, options) {
7689
7675
  sourceFile.addStatements(
7690
7676
  /* ts */
7691
7677
  `
7692
- import defaultMiddleware from '${getRelativePath(outputDir, config.withMiddleware, true, options.schemaPath)}';
7678
+ import defaultMiddleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
7693
7679
  `
7694
7680
  );
7695
7681
  sourceFile.addStatements(
@@ -7761,7 +7747,7 @@ export const createCallerFactory = t.createCallerFactory;`
7761
7747
  );
7762
7748
  }
7763
7749
  }
7764
- __name(generateBaseRouter, "generateBaseRouter");
7750
+ __name(generateTRPCExports, "generateTRPCExports");
7765
7751
  function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
7766
7752
  let input = `input${!config.withZod ? " as any" : ""}`;
7767
7753
  const nameWithoutModel = name.replace(modelName, "");
@@ -7966,7 +7952,7 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
7966
7952
  return "";
7967
7953
  }
7968
7954
  let shieldText = getImports("trpc-shield");
7969
- shieldText += getImports("context", getRelativePath(outputDir, config.contextPath, true, options.schemaPath));
7955
+ shieldText += getImports("context", relativePath(outputDir, joinPaths(outputDir, config.contextPath)));
7970
7956
  shieldText += "\n\n";
7971
7957
  shieldText += wrapWithExport({
7972
7958
  shieldObjectText: wrapWithTrpcShieldCall({
@@ -7979,50 +7965,50 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
7979
7965
  }, "constructShield");
7980
7966
  var constructDefaultOptions = /* @__PURE__ */ __name((config, options, outputDir) => {
7981
7967
  return `import { ZodError } from 'zod';${config.withNext ? '\nimport { transformer } from "@stryke/trpc-next/shared";' : ""}
7982
- import type {
7983
- DataTransformerOptions,
7984
- RootConfig
7985
- } from "@trpc/server/unstable-core-do-not-import";
7986
- import type { Context } from "${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}";
7968
+ import type {
7969
+ DataTransformerOptions,
7970
+ RootConfig
7971
+ } from "@trpc/server/unstable-core-do-not-import";
7972
+ import type { Context } from "${relativePath(outputDir, joinPaths(outputDir, config.contextPath))}";
7987
7973
 
7988
- interface RuntimeConfigOptions<
7989
- TContext extends object,
7990
- TMeta extends object = object
7991
- > extends Partial<
7992
- Omit<
7993
- RootConfig<{
7994
- ctx: TContext;
7995
- meta: TMeta;
7996
- errorShape: any;
7997
- transformer: any;
7998
- }>,
7999
- "$types" | "transformer"
8000
- >
8001
- > {
8002
- /**
8003
- * Use a data transformer
8004
- * @see https://trpc.io/docs/v11/data-transformers
8005
- */
8006
- transformer?: DataTransformerOptions;
8007
- }
7974
+ interface RuntimeConfigOptions<
7975
+ TContext extends object,
7976
+ TMeta extends object = object
7977
+ > extends Partial<
7978
+ Omit<
7979
+ RootConfig<{
7980
+ ctx: TContext;
7981
+ meta: TMeta;
7982
+ errorShape: any;
7983
+ transformer: any;
7984
+ }>,
7985
+ "$types" | "transformer"
7986
+ >
7987
+ > {
7988
+ /**
7989
+ * Use a data transformer
7990
+ * @see https://trpc.io/docs/v11/data-transformers
7991
+ */
7992
+ transformer?: DataTransformerOptions;
7993
+ }
8008
7994
 
8009
- const options: RuntimeConfigOptions<Context> = {${config.withNext ? "\n transformer," : ""}
8010
- errorFormatter({ shape, error }) {
8011
- return {
8012
- ...shape,
8013
- data: {
8014
- ...shape.data,
8015
- zodError:
8016
- error.code === "BAD_REQUEST" && error.cause instanceof ZodError
8017
- ? error.cause.flatten()
8018
- : null
8019
- }
8020
- };
8021
- }
8022
- };
7995
+ const options: RuntimeConfigOptions<Context> = {${config.withNext ? "\n transformer," : ""}
7996
+ errorFormatter({ shape, error }) {
7997
+ return {
7998
+ ...shape,
7999
+ data: {
8000
+ ...shape.data,
8001
+ zodError:
8002
+ error.code === "BAD_REQUEST" && error.cause instanceof ZodError
8003
+ ? error.cause.flatten()
8004
+ : null
8005
+ }
8006
+ };
8007
+ }
8008
+ };
8023
8009
 
8024
- export default options;
8025
- `;
8010
+ export default options;
8011
+ `;
8026
8012
  }, "constructDefaultOptions");
8027
8013
 
8028
8014
  // src/project.ts
@@ -11645,43 +11631,28 @@ async function generate(options) {
11645
11631
  queries.sort();
11646
11632
  mutations.sort();
11647
11633
  subscriptions.sort();
11648
- if (config.withShield !== false) {
11649
- consoleLog("Generating tRPC Shield");
11650
- if (typeof config.withShield === "string" && (existsSync(joinPaths(findFilePath(options.schemaPath), config.withShield)) || existsSync(joinPaths(findFilePath(options.schemaPath), config.withShield, "shield.ts")))) {
11651
- consoleLog("Skipping tRPC Shield generation as path provided already exists");
11652
- } else {
11653
- consoleLog("Constructing tRPC Shield source file");
11654
- const shieldOutputDir = typeof config.withShield === "string" ? config.withShield : outputDir;
11655
- const shieldText = await constructShield({
11656
- queries,
11657
- mutations,
11658
- subscriptions
11659
- }, config, options, shieldOutputDir);
11660
- consoleLog("Saving tRPC Shield source file to disk");
11661
- await writeFileSafely(shieldOutputDir.endsWith(".ts") ? shieldOutputDir : joinPaths(shieldOutputDir, "shield.ts"), shieldText);
11662
- }
11634
+ if (config.withShield !== false && (typeof config.withShield !== "string" || !existsSync(joinPaths(outputDir, config.withShield)) && !existsSync(joinPaths(outputDir, `${config.withShield}.ts`)) && !existsSync(joinPaths(outputDir, config.withShield, "shield.ts")))) {
11635
+ consoleLog(`Generating tRPC Shield source file to ${outputDir}`);
11636
+ await writeFileSafely(joinPaths(outputDir, "shield.ts"), await constructShield({
11637
+ queries,
11638
+ mutations,
11639
+ subscriptions
11640
+ }, config, options, outputDir));
11663
11641
  } else {
11664
11642
  consoleLog("Skipping tRPC Shield generation");
11665
11643
  }
11666
11644
  consoleLog(`Generating tRPC source code for ${models.length} models`);
11667
11645
  if (config.trpcOptions && typeof config.trpcOptions === "boolean") {
11668
- const trpcOptionsOutputPath = joinPaths(outputDir, "options.ts");
11669
- consoleLog("Generating tRPC options source file");
11670
- await writeFileSafely(trpcOptionsOutputPath, constructDefaultOptions(config, options, trpcOptionsOutputPath));
11646
+ consoleLog(`Generating tRPC options source file to ${outputDir}`);
11647
+ await writeFileSafely(joinPaths(outputDir, "options.ts"), constructDefaultOptions(config, options, outputDir));
11671
11648
  }
11672
11649
  resolveModelsComments(models, hiddenModels);
11650
+ consoleLog("Generating tRPC export file");
11673
11651
  const trpcExports = project.createSourceFile(import_node_path5.default.resolve(outputDir, "trpc.ts"), void 0, {
11674
11652
  overwrite: true
11675
11653
  });
11676
- consoleLog("Generating tRPC imports");
11677
- if (config.withShield) {
11678
- await generateShieldImport(trpcExports, options, outputDir, config.withShield);
11679
- }
11680
- consoleLog("Generating tRPC base router");
11681
- await generateBaseRouter(trpcExports, config, options);
11682
- trpcExports.formatText({
11683
- indentSize: 2
11684
- });
11654
+ await generateTRPCExports(trpcExports, config, options, outputDir);
11655
+ consoleLog("Generating tRPC app router");
11685
11656
  const appRouter = project.createSourceFile(import_node_path5.default.resolve(outputDir, "routers", `index.ts`), void 0, {
11686
11657
  overwrite: true
11687
11658
  });