@stryke/prisma-trpc-generator 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generator.cjs +205 -215
- package/dist/generator.js +205 -215
- package/dist/index.cjs +205 -215
- package/dist/index.js +205 -215
- package/package.json +1 -1
package/dist/generator.cjs
CHANGED
|
@@ -2484,20 +2484,20 @@ 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(
|
|
2488
|
-
if (await exists(
|
|
2487
|
+
async function createDirectory(path5) {
|
|
2488
|
+
if (await exists(path5)) {
|
|
2489
2489
|
return;
|
|
2490
2490
|
}
|
|
2491
|
-
return (0, import_promises2.mkdir)(
|
|
2491
|
+
return (0, import_promises2.mkdir)(path5, {
|
|
2492
2492
|
recursive: true
|
|
2493
2493
|
});
|
|
2494
2494
|
}
|
|
2495
2495
|
__name(createDirectory, "createDirectory");
|
|
2496
|
-
async function removeDirectory(
|
|
2497
|
-
if (!existsSync(
|
|
2496
|
+
async function removeDirectory(path5) {
|
|
2497
|
+
if (!existsSync(path5)) {
|
|
2498
2498
|
return;
|
|
2499
2499
|
}
|
|
2500
|
-
return (0, import_promises2.rm)(
|
|
2500
|
+
return (0, import_promises2.rm)(path5, {
|
|
2501
2501
|
recursive: true
|
|
2502
2502
|
});
|
|
2503
2503
|
}
|
|
@@ -2534,65 +2534,65 @@ var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
|
|
|
2534
2534
|
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
2535
2535
|
return _IS_ABSOLUTE_RE.test(p);
|
|
2536
2536
|
}, "isAbsolute");
|
|
2537
|
-
var correctPaths = /* @__PURE__ */ __name(function(
|
|
2538
|
-
if (!
|
|
2537
|
+
var correctPaths = /* @__PURE__ */ __name(function(path5) {
|
|
2538
|
+
if (!path5 || path5.length === 0) {
|
|
2539
2539
|
return ".";
|
|
2540
2540
|
}
|
|
2541
|
-
|
|
2542
|
-
const isUNCPath =
|
|
2543
|
-
const isPathAbsolute = isAbsolute(
|
|
2544
|
-
const trailingSeparator =
|
|
2545
|
-
|
|
2546
|
-
if (
|
|
2541
|
+
path5 = normalizeWindowsPath(path5);
|
|
2542
|
+
const isUNCPath = path5.match(_UNC_REGEX);
|
|
2543
|
+
const isPathAbsolute = isAbsolute(path5);
|
|
2544
|
+
const trailingSeparator = path5[path5.length - 1] === "/";
|
|
2545
|
+
path5 = normalizeString(path5, !isPathAbsolute);
|
|
2546
|
+
if (path5.length === 0) {
|
|
2547
2547
|
if (isPathAbsolute) {
|
|
2548
2548
|
return "/";
|
|
2549
2549
|
}
|
|
2550
2550
|
return trailingSeparator ? "./" : ".";
|
|
2551
2551
|
}
|
|
2552
2552
|
if (trailingSeparator) {
|
|
2553
|
-
|
|
2553
|
+
path5 += "/";
|
|
2554
2554
|
}
|
|
2555
|
-
if (_DRIVE_LETTER_RE.test(
|
|
2556
|
-
|
|
2555
|
+
if (_DRIVE_LETTER_RE.test(path5)) {
|
|
2556
|
+
path5 += "/";
|
|
2557
2557
|
}
|
|
2558
2558
|
if (isUNCPath) {
|
|
2559
2559
|
if (!isPathAbsolute) {
|
|
2560
|
-
return `//./${
|
|
2560
|
+
return `//./${path5}`;
|
|
2561
2561
|
}
|
|
2562
|
-
return `//${
|
|
2562
|
+
return `//${path5}`;
|
|
2563
2563
|
}
|
|
2564
|
-
return isPathAbsolute && !isAbsolute(
|
|
2564
|
+
return isPathAbsolute && !isAbsolute(path5) ? `/${path5}` : path5;
|
|
2565
2565
|
}, "correctPaths");
|
|
2566
2566
|
var joinPaths = /* @__PURE__ */ __name(function(...segments) {
|
|
2567
|
-
let
|
|
2567
|
+
let path5 = "";
|
|
2568
2568
|
for (const seg of segments) {
|
|
2569
2569
|
if (!seg) {
|
|
2570
2570
|
continue;
|
|
2571
2571
|
}
|
|
2572
|
-
if (
|
|
2573
|
-
const pathTrailing =
|
|
2572
|
+
if (path5.length > 0) {
|
|
2573
|
+
const pathTrailing = path5[path5.length - 1] === "/";
|
|
2574
2574
|
const segLeading = seg[0] === "/";
|
|
2575
2575
|
const both = pathTrailing && segLeading;
|
|
2576
2576
|
if (both) {
|
|
2577
|
-
|
|
2577
|
+
path5 += seg.slice(1);
|
|
2578
2578
|
} else {
|
|
2579
|
-
|
|
2579
|
+
path5 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
2580
2580
|
}
|
|
2581
2581
|
} else {
|
|
2582
|
-
|
|
2582
|
+
path5 += seg;
|
|
2583
2583
|
}
|
|
2584
2584
|
}
|
|
2585
|
-
return correctPaths(
|
|
2585
|
+
return correctPaths(path5);
|
|
2586
2586
|
}, "joinPaths");
|
|
2587
|
-
function normalizeString(
|
|
2587
|
+
function normalizeString(path5, allowAboveRoot) {
|
|
2588
2588
|
let res = "";
|
|
2589
2589
|
let lastSegmentLength = 0;
|
|
2590
2590
|
let lastSlash = -1;
|
|
2591
2591
|
let dots = 0;
|
|
2592
2592
|
let char = null;
|
|
2593
|
-
for (let index = 0; index <=
|
|
2594
|
-
if (index <
|
|
2595
|
-
char =
|
|
2593
|
+
for (let index = 0; index <= path5.length; ++index) {
|
|
2594
|
+
if (index < path5.length) {
|
|
2595
|
+
char = path5[index];
|
|
2596
2596
|
} else if (char === "/") {
|
|
2597
2597
|
break;
|
|
2598
2598
|
} else {
|
|
@@ -2628,9 +2628,9 @@ function normalizeString(path6, allowAboveRoot) {
|
|
|
2628
2628
|
}
|
|
2629
2629
|
} else {
|
|
2630
2630
|
if (res.length > 0) {
|
|
2631
|
-
res += `/${
|
|
2631
|
+
res += `/${path5.slice(lastSlash + 1, index)}`;
|
|
2632
2632
|
} else {
|
|
2633
|
-
res =
|
|
2633
|
+
res = path5.slice(lastSlash + 1, index);
|
|
2634
2634
|
}
|
|
2635
2635
|
lastSegmentLength = index - lastSlash - 1;
|
|
2636
2636
|
}
|
|
@@ -2647,20 +2647,20 @@ function normalizeString(path6, allowAboveRoot) {
|
|
|
2647
2647
|
__name(normalizeString, "normalizeString");
|
|
2648
2648
|
|
|
2649
2649
|
// ../path/src/is-file.ts
|
|
2650
|
-
function isFile(
|
|
2651
|
-
return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath,
|
|
2650
|
+
function isFile(path5, additionalPath) {
|
|
2651
|
+
return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath, path5) : path5, {
|
|
2652
2652
|
throwIfNoEntry: false
|
|
2653
2653
|
})?.isFile());
|
|
2654
2654
|
}
|
|
2655
2655
|
__name(isFile, "isFile");
|
|
2656
|
-
function isDirectory(
|
|
2657
|
-
return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath,
|
|
2656
|
+
function isDirectory(path5, additionalPath) {
|
|
2657
|
+
return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath, path5) : path5, {
|
|
2658
2658
|
throwIfNoEntry: false
|
|
2659
2659
|
})?.isDirectory());
|
|
2660
2660
|
}
|
|
2661
2661
|
__name(isDirectory, "isDirectory");
|
|
2662
|
-
function isAbsolutePath(
|
|
2663
|
-
return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(
|
|
2662
|
+
function isAbsolutePath(path5) {
|
|
2663
|
+
return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path5);
|
|
2664
2664
|
}
|
|
2665
2665
|
__name(isAbsolutePath, "isAbsolutePath");
|
|
2666
2666
|
|
|
@@ -2675,45 +2675,45 @@ function normalizeWindowsPath2(input = "") {
|
|
|
2675
2675
|
__name(normalizeWindowsPath2, "normalizeWindowsPath");
|
|
2676
2676
|
var _UNC_REGEX2 = /^[/\\]{2}/;
|
|
2677
2677
|
var _DRIVE_LETTER_RE2 = /^[A-Z]:$/i;
|
|
2678
|
-
function correctPath(
|
|
2679
|
-
if (!
|
|
2678
|
+
function correctPath(path5) {
|
|
2679
|
+
if (!path5 || path5.length === 0) {
|
|
2680
2680
|
return ".";
|
|
2681
2681
|
}
|
|
2682
|
-
|
|
2683
|
-
const isUNCPath =
|
|
2684
|
-
const isPathAbsolute = isAbsolutePath(
|
|
2685
|
-
const trailingSeparator =
|
|
2686
|
-
|
|
2687
|
-
if (
|
|
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
2688
|
if (isPathAbsolute) {
|
|
2689
2689
|
return "/";
|
|
2690
2690
|
}
|
|
2691
2691
|
return trailingSeparator ? "./" : ".";
|
|
2692
2692
|
}
|
|
2693
2693
|
if (trailingSeparator) {
|
|
2694
|
-
|
|
2694
|
+
path5 += "/";
|
|
2695
2695
|
}
|
|
2696
|
-
if (_DRIVE_LETTER_RE2.test(
|
|
2697
|
-
|
|
2696
|
+
if (_DRIVE_LETTER_RE2.test(path5)) {
|
|
2697
|
+
path5 += "/";
|
|
2698
2698
|
}
|
|
2699
2699
|
if (isUNCPath) {
|
|
2700
2700
|
if (!isPathAbsolute) {
|
|
2701
|
-
return `//./${
|
|
2701
|
+
return `//./${path5}`;
|
|
2702
2702
|
}
|
|
2703
|
-
return `//${
|
|
2703
|
+
return `//${path5}`;
|
|
2704
2704
|
}
|
|
2705
|
-
return isPathAbsolute && !isAbsolutePath(
|
|
2705
|
+
return isPathAbsolute && !isAbsolutePath(path5) ? `/${path5}` : path5;
|
|
2706
2706
|
}
|
|
2707
2707
|
__name(correctPath, "correctPath");
|
|
2708
|
-
function normalizeString2(
|
|
2708
|
+
function normalizeString2(path5, allowAboveRoot) {
|
|
2709
2709
|
let res = "";
|
|
2710
2710
|
let lastSegmentLength = 0;
|
|
2711
2711
|
let lastSlash = -1;
|
|
2712
2712
|
let dots = 0;
|
|
2713
2713
|
let char = null;
|
|
2714
|
-
for (let index = 0; index <=
|
|
2715
|
-
if (index <
|
|
2716
|
-
char =
|
|
2714
|
+
for (let index = 0; index <= path5.length; ++index) {
|
|
2715
|
+
if (index < path5.length) {
|
|
2716
|
+
char = path5[index];
|
|
2717
2717
|
} else if (char === "/") {
|
|
2718
2718
|
break;
|
|
2719
2719
|
} else {
|
|
@@ -2749,9 +2749,9 @@ function normalizeString2(path6, allowAboveRoot) {
|
|
|
2749
2749
|
}
|
|
2750
2750
|
} else {
|
|
2751
2751
|
if (res.length > 0) {
|
|
2752
|
-
res += `/${
|
|
2752
|
+
res += `/${path5.slice(lastSlash + 1, index)}`;
|
|
2753
2753
|
} else {
|
|
2754
|
-
res =
|
|
2754
|
+
res = path5.slice(lastSlash + 1, index);
|
|
2755
2755
|
}
|
|
2756
2756
|
lastSegmentLength = index - lastSlash - 1;
|
|
2757
2757
|
}
|
|
@@ -2823,34 +2823,34 @@ __name2(normalizeWindowsPath3, "normalizeWindowsPath");
|
|
|
2823
2823
|
var _UNC_REGEX3 = /^[/\\]{2}/;
|
|
2824
2824
|
var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
2825
2825
|
var _DRIVE_LETTER_RE3 = /^[A-Za-z]:$/;
|
|
2826
|
-
var correctPaths2 = /* @__PURE__ */ __name2(function(
|
|
2827
|
-
if (!
|
|
2826
|
+
var correctPaths2 = /* @__PURE__ */ __name2(function(path5) {
|
|
2827
|
+
if (!path5 || path5.length === 0) {
|
|
2828
2828
|
return ".";
|
|
2829
2829
|
}
|
|
2830
|
-
|
|
2831
|
-
const isUNCPath =
|
|
2832
|
-
const isPathAbsolute = isAbsolute2(
|
|
2833
|
-
const trailingSeparator =
|
|
2834
|
-
|
|
2835
|
-
if (
|
|
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
2836
|
if (isPathAbsolute) {
|
|
2837
2837
|
return "/";
|
|
2838
2838
|
}
|
|
2839
2839
|
return trailingSeparator ? "./" : ".";
|
|
2840
2840
|
}
|
|
2841
2841
|
if (trailingSeparator) {
|
|
2842
|
-
|
|
2842
|
+
path5 += "/";
|
|
2843
2843
|
}
|
|
2844
|
-
if (_DRIVE_LETTER_RE3.test(
|
|
2845
|
-
|
|
2844
|
+
if (_DRIVE_LETTER_RE3.test(path5)) {
|
|
2845
|
+
path5 += "/";
|
|
2846
2846
|
}
|
|
2847
2847
|
if (isUNCPath) {
|
|
2848
2848
|
if (!isPathAbsolute) {
|
|
2849
|
-
return `//./${
|
|
2849
|
+
return `//./${path5}`;
|
|
2850
2850
|
}
|
|
2851
|
-
return `//${
|
|
2851
|
+
return `//${path5}`;
|
|
2852
2852
|
}
|
|
2853
|
-
return isPathAbsolute && !isAbsolute2(
|
|
2853
|
+
return isPathAbsolute && !isAbsolute2(path5) ? `/${path5}` : path5;
|
|
2854
2854
|
}, "correctPaths");
|
|
2855
2855
|
function cwd() {
|
|
2856
2856
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
@@ -2860,15 +2860,15 @@ function cwd() {
|
|
|
2860
2860
|
}
|
|
2861
2861
|
__name(cwd, "cwd");
|
|
2862
2862
|
__name2(cwd, "cwd");
|
|
2863
|
-
function normalizeString3(
|
|
2863
|
+
function normalizeString3(path5, allowAboveRoot) {
|
|
2864
2864
|
let res = "";
|
|
2865
2865
|
let lastSegmentLength = 0;
|
|
2866
2866
|
let lastSlash = -1;
|
|
2867
2867
|
let dots = 0;
|
|
2868
2868
|
let char = null;
|
|
2869
|
-
for (let index = 0; index <=
|
|
2870
|
-
if (index <
|
|
2871
|
-
char =
|
|
2869
|
+
for (let index = 0; index <= path5.length; ++index) {
|
|
2870
|
+
if (index < path5.length) {
|
|
2871
|
+
char = path5[index];
|
|
2872
2872
|
} else if (char === "/") {
|
|
2873
2873
|
break;
|
|
2874
2874
|
} else {
|
|
@@ -2904,9 +2904,9 @@ function normalizeString3(path6, allowAboveRoot) {
|
|
|
2904
2904
|
}
|
|
2905
2905
|
} else {
|
|
2906
2906
|
if (res.length > 0) {
|
|
2907
|
-
res += `/${
|
|
2907
|
+
res += `/${path5.slice(lastSlash + 1, index)}`;
|
|
2908
2908
|
} else {
|
|
2909
|
-
res =
|
|
2909
|
+
res = path5.slice(lastSlash + 1, index);
|
|
2910
2910
|
}
|
|
2911
2911
|
lastSegmentLength = index - lastSlash - 1;
|
|
2912
2912
|
}
|
|
@@ -3351,8 +3351,8 @@ function getErrorMap() {
|
|
|
3351
3351
|
}
|
|
3352
3352
|
__name(getErrorMap, "getErrorMap");
|
|
3353
3353
|
var makeIssue = /* @__PURE__ */ __name((params) => {
|
|
3354
|
-
const { data, path:
|
|
3355
|
-
const fullPath = [...
|
|
3354
|
+
const { data, path: path5, errorMaps, issueData } = params;
|
|
3355
|
+
const fullPath = [...path5, ...issueData.path || []];
|
|
3356
3356
|
const fullIssue = {
|
|
3357
3357
|
...issueData,
|
|
3358
3358
|
path: fullPath
|
|
@@ -3486,11 +3486,11 @@ var ParseInputLazyPath = class {
|
|
|
3486
3486
|
static {
|
|
3487
3487
|
__name(this, "ParseInputLazyPath");
|
|
3488
3488
|
}
|
|
3489
|
-
constructor(parent, value,
|
|
3489
|
+
constructor(parent, value, path5, key) {
|
|
3490
3490
|
this._cachedPath = [];
|
|
3491
3491
|
this.parent = parent;
|
|
3492
3492
|
this.data = value;
|
|
3493
|
-
this._path =
|
|
3493
|
+
this._path = path5;
|
|
3494
3494
|
this._key = key;
|
|
3495
3495
|
}
|
|
3496
3496
|
get path() {
|
|
@@ -7197,8 +7197,8 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
7197
7197
|
|
|
7198
7198
|
// ../path/src/get-parent-path.ts
|
|
7199
7199
|
init_cjs_shims();
|
|
7200
|
-
var resolveParentPath = /* @__PURE__ */ __name((
|
|
7201
|
-
return resolvePaths(
|
|
7200
|
+
var resolveParentPath = /* @__PURE__ */ __name((path5) => {
|
|
7201
|
+
return resolvePaths(path5, "..");
|
|
7202
7202
|
}, "resolveParentPath");
|
|
7203
7203
|
var getParentPath = /* @__PURE__ */ __name((name, cwd2, options) => {
|
|
7204
7204
|
const ignoreCase = options?.ignoreCase ?? true;
|
|
@@ -7303,25 +7303,17 @@ function findFilePath(filePath) {
|
|
|
7303
7303
|
}), "");
|
|
7304
7304
|
}
|
|
7305
7305
|
__name(findFilePath, "findFilePath");
|
|
7306
|
-
function
|
|
7307
|
-
|
|
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("/");
|
|
7306
|
+
function resolvePath(path5, cwd2 = getWorkspaceRoot()) {
|
|
7307
|
+
const paths = normalizeWindowsPath2(path5).split("/");
|
|
7316
7308
|
let resolvedPath = "";
|
|
7317
7309
|
let resolvedAbsolute = false;
|
|
7318
7310
|
for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
7319
|
-
const
|
|
7320
|
-
if (!
|
|
7311
|
+
const path6 = index >= 0 ? paths[index] : cwd2;
|
|
7312
|
+
if (!path6 || path6.length === 0) {
|
|
7321
7313
|
continue;
|
|
7322
7314
|
}
|
|
7323
|
-
resolvedPath = joinPaths(
|
|
7324
|
-
resolvedAbsolute = isAbsolutePath(
|
|
7315
|
+
resolvedPath = joinPaths(path6, resolvedPath);
|
|
7316
|
+
resolvedAbsolute = isAbsolutePath(path6);
|
|
7325
7317
|
}
|
|
7326
7318
|
resolvedPath = normalizeString2(resolvedPath, !resolvedAbsolute);
|
|
7327
7319
|
if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {
|
|
@@ -7331,7 +7323,7 @@ function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
|
|
|
7331
7323
|
}
|
|
7332
7324
|
__name(resolvePath, "resolvePath");
|
|
7333
7325
|
function resolvePaths(...paths) {
|
|
7334
|
-
return resolvePath(joinPaths(...paths.map((
|
|
7326
|
+
return resolvePath(joinPaths(...paths.map((path5) => normalizeWindowsPath2(path5))));
|
|
7335
7327
|
}
|
|
7336
7328
|
__name(resolvePaths, "resolvePaths");
|
|
7337
7329
|
function relativePath(from, to) {
|
|
@@ -7364,7 +7356,7 @@ var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
|
|
|
7364
7356
|
}, "lowerCaseFirst");
|
|
7365
7357
|
|
|
7366
7358
|
// src/prisma-generator.ts
|
|
7367
|
-
var
|
|
7359
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
7368
7360
|
var import_pluralize = __toESM(require_pluralize(), 1);
|
|
7369
7361
|
|
|
7370
7362
|
// src/config.ts
|
|
@@ -7398,7 +7390,7 @@ var configSchema = z.object({
|
|
|
7398
7390
|
withShield: z.coerce.boolean().or(z.string()).default(true),
|
|
7399
7391
|
withZod: z.coerce.boolean().or(z.string()).default(true),
|
|
7400
7392
|
withNext: z.coerce.boolean().or(z.string()).default(true),
|
|
7401
|
-
contextPath: z.string().default("../src/trpc/context"),
|
|
7393
|
+
contextPath: z.string().default("../src/trpc/context.ts"),
|
|
7402
7394
|
trpcOptions: z.coerce.boolean().or(z.string()).default(true),
|
|
7403
7395
|
showModelNameInProcedure: z.coerce.boolean().or(z.string()).default(true),
|
|
7404
7396
|
generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
|
|
@@ -7602,17 +7594,12 @@ __name(getPrismaGeneratorHelper, "getPrismaGeneratorHelper");
|
|
|
7602
7594
|
|
|
7603
7595
|
// src/utils/get-relative-path.ts
|
|
7604
7596
|
init_cjs_shims();
|
|
7605
|
-
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
7606
7597
|
function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath, fromPath) {
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
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;
|
|
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);
|
|
7616
7603
|
}
|
|
7617
7604
|
__name(getRelativePath, "getRelativePath");
|
|
7618
7605
|
|
|
@@ -7990,6 +7977,53 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
|
|
|
7990
7977
|
});
|
|
7991
7978
|
return shieldText;
|
|
7992
7979
|
}, "constructShield");
|
|
7980
|
+
var constructDefaultOptions = /* @__PURE__ */ __name((config, options, outputDir) => {
|
|
7981
|
+
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)}";
|
|
7987
|
+
|
|
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
|
+
}
|
|
8008
|
+
|
|
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
|
+
};
|
|
8023
|
+
|
|
8024
|
+
export default options;
|
|
8025
|
+
`;
|
|
8026
|
+
}, "constructDefaultOptions");
|
|
7993
8027
|
|
|
7994
8028
|
// src/project.ts
|
|
7995
8029
|
init_cjs_shims();
|
|
@@ -9195,7 +9229,7 @@ var isURL = /* @__PURE__ */ __name((payload) => payload instanceof URL, "isURL")
|
|
|
9195
9229
|
// ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.js
|
|
9196
9230
|
init_cjs_shims();
|
|
9197
9231
|
var escapeKey = /* @__PURE__ */ __name((key) => key.replace(/\./g, "\\."), "escapeKey");
|
|
9198
|
-
var stringifyPath = /* @__PURE__ */ __name((
|
|
9232
|
+
var stringifyPath = /* @__PURE__ */ __name((path5) => path5.map(String).map(escapeKey).join("."), "stringifyPath");
|
|
9199
9233
|
var parsePath = /* @__PURE__ */ __name((string) => {
|
|
9200
9234
|
const result = [];
|
|
9201
9235
|
let segment = "";
|
|
@@ -9458,27 +9492,27 @@ var getNthKey = /* @__PURE__ */ __name((value, n) => {
|
|
|
9458
9492
|
}
|
|
9459
9493
|
return keys.next().value;
|
|
9460
9494
|
}, "getNthKey");
|
|
9461
|
-
function validatePath(
|
|
9462
|
-
if (includes(
|
|
9495
|
+
function validatePath(path5) {
|
|
9496
|
+
if (includes(path5, "__proto__")) {
|
|
9463
9497
|
throw new Error("__proto__ is not allowed as a property");
|
|
9464
9498
|
}
|
|
9465
|
-
if (includes(
|
|
9499
|
+
if (includes(path5, "prototype")) {
|
|
9466
9500
|
throw new Error("prototype is not allowed as a property");
|
|
9467
9501
|
}
|
|
9468
|
-
if (includes(
|
|
9502
|
+
if (includes(path5, "constructor")) {
|
|
9469
9503
|
throw new Error("constructor is not allowed as a property");
|
|
9470
9504
|
}
|
|
9471
9505
|
}
|
|
9472
9506
|
__name(validatePath, "validatePath");
|
|
9473
|
-
var getDeep = /* @__PURE__ */ __name((object,
|
|
9474
|
-
validatePath(
|
|
9475
|
-
for (let i = 0; i <
|
|
9476
|
-
const key =
|
|
9507
|
+
var getDeep = /* @__PURE__ */ __name((object, path5) => {
|
|
9508
|
+
validatePath(path5);
|
|
9509
|
+
for (let i = 0; i < path5.length; i++) {
|
|
9510
|
+
const key = path5[i];
|
|
9477
9511
|
if (isSet(object)) {
|
|
9478
9512
|
object = getNthKey(object, +key);
|
|
9479
9513
|
} else if (isMap(object)) {
|
|
9480
9514
|
const row = +key;
|
|
9481
|
-
const type = +
|
|
9515
|
+
const type = +path5[++i] === 0 ? "key" : "value";
|
|
9482
9516
|
const keyOfRow = getNthKey(object, row);
|
|
9483
9517
|
switch (type) {
|
|
9484
9518
|
case "key":
|
|
@@ -9494,14 +9528,14 @@ var getDeep = /* @__PURE__ */ __name((object, path6) => {
|
|
|
9494
9528
|
}
|
|
9495
9529
|
return object;
|
|
9496
9530
|
}, "getDeep");
|
|
9497
|
-
var setDeep = /* @__PURE__ */ __name((object,
|
|
9498
|
-
validatePath(
|
|
9499
|
-
if (
|
|
9531
|
+
var setDeep = /* @__PURE__ */ __name((object, path5, mapper) => {
|
|
9532
|
+
validatePath(path5);
|
|
9533
|
+
if (path5.length === 0) {
|
|
9500
9534
|
return mapper(object);
|
|
9501
9535
|
}
|
|
9502
9536
|
let parent = object;
|
|
9503
|
-
for (let i = 0; i <
|
|
9504
|
-
const key =
|
|
9537
|
+
for (let i = 0; i < path5.length - 1; i++) {
|
|
9538
|
+
const key = path5[i];
|
|
9505
9539
|
if (isArray(parent)) {
|
|
9506
9540
|
const index = +key;
|
|
9507
9541
|
parent = parent[index];
|
|
@@ -9511,12 +9545,12 @@ var setDeep = /* @__PURE__ */ __name((object, path6, mapper) => {
|
|
|
9511
9545
|
const row = +key;
|
|
9512
9546
|
parent = getNthKey(parent, row);
|
|
9513
9547
|
} else if (isMap(parent)) {
|
|
9514
|
-
const isEnd = i ===
|
|
9548
|
+
const isEnd = i === path5.length - 2;
|
|
9515
9549
|
if (isEnd) {
|
|
9516
9550
|
break;
|
|
9517
9551
|
}
|
|
9518
9552
|
const row = +key;
|
|
9519
|
-
const type = +
|
|
9553
|
+
const type = +path5[++i] === 0 ? "key" : "value";
|
|
9520
9554
|
const keyOfRow = getNthKey(parent, row);
|
|
9521
9555
|
switch (type) {
|
|
9522
9556
|
case "key":
|
|
@@ -9528,7 +9562,7 @@ var setDeep = /* @__PURE__ */ __name((object, path6, mapper) => {
|
|
|
9528
9562
|
}
|
|
9529
9563
|
}
|
|
9530
9564
|
}
|
|
9531
|
-
const lastKey =
|
|
9565
|
+
const lastKey = path5[path5.length - 1];
|
|
9532
9566
|
if (isArray(parent)) {
|
|
9533
9567
|
parent[+lastKey] = mapper(parent[+lastKey]);
|
|
9534
9568
|
} else if (isPlainObject2(parent)) {
|
|
@@ -9543,7 +9577,7 @@ var setDeep = /* @__PURE__ */ __name((object, path6, mapper) => {
|
|
|
9543
9577
|
}
|
|
9544
9578
|
}
|
|
9545
9579
|
if (isMap(parent)) {
|
|
9546
|
-
const row = +
|
|
9580
|
+
const row = +path5[path5.length - 2];
|
|
9547
9581
|
const keyToRow = getNthKey(parent, row);
|
|
9548
9582
|
const type = +lastKey === 0 ? "key" : "value";
|
|
9549
9583
|
switch (type) {
|
|
@@ -9589,15 +9623,15 @@ function traverse(tree, walker2, origin = []) {
|
|
|
9589
9623
|
}
|
|
9590
9624
|
__name(traverse, "traverse");
|
|
9591
9625
|
function applyValueAnnotations(plain, annotations, superJson) {
|
|
9592
|
-
traverse(annotations, (type,
|
|
9593
|
-
plain = setDeep(plain,
|
|
9626
|
+
traverse(annotations, (type, path5) => {
|
|
9627
|
+
plain = setDeep(plain, path5, (v) => untransformValue(v, type, superJson));
|
|
9594
9628
|
});
|
|
9595
9629
|
return plain;
|
|
9596
9630
|
}
|
|
9597
9631
|
__name(applyValueAnnotations, "applyValueAnnotations");
|
|
9598
9632
|
function applyReferentialEqualityAnnotations(plain, annotations) {
|
|
9599
|
-
function apply(identicalPaths,
|
|
9600
|
-
const object = getDeep(plain, parsePath(
|
|
9633
|
+
function apply(identicalPaths, path5) {
|
|
9634
|
+
const object = getDeep(plain, parsePath(path5));
|
|
9601
9635
|
identicalPaths.map(parsePath).forEach((identicalObjectPath) => {
|
|
9602
9636
|
plain = setDeep(plain, identicalObjectPath, () => object);
|
|
9603
9637
|
});
|
|
@@ -9618,13 +9652,13 @@ function applyReferentialEqualityAnnotations(plain, annotations) {
|
|
|
9618
9652
|
}
|
|
9619
9653
|
__name(applyReferentialEqualityAnnotations, "applyReferentialEqualityAnnotations");
|
|
9620
9654
|
var isDeep = /* @__PURE__ */ __name((object, superJson) => isPlainObject2(object) || isArray(object) || isMap(object) || isSet(object) || isInstanceOfRegisteredClass(object, superJson), "isDeep");
|
|
9621
|
-
function addIdentity(object,
|
|
9655
|
+
function addIdentity(object, path5, identities) {
|
|
9622
9656
|
const existingSet = identities.get(object);
|
|
9623
9657
|
if (existingSet) {
|
|
9624
|
-
existingSet.push(
|
|
9658
|
+
existingSet.push(path5);
|
|
9625
9659
|
} else {
|
|
9626
9660
|
identities.set(object, [
|
|
9627
|
-
|
|
9661
|
+
path5
|
|
9628
9662
|
]);
|
|
9629
9663
|
}
|
|
9630
9664
|
}
|
|
@@ -9637,7 +9671,7 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
|
|
9637
9671
|
return;
|
|
9638
9672
|
}
|
|
9639
9673
|
if (!dedupe) {
|
|
9640
|
-
paths = paths.map((
|
|
9674
|
+
paths = paths.map((path5) => path5.map(String)).sort((a, b) => a.length - b.length);
|
|
9641
9675
|
}
|
|
9642
9676
|
const [representativePath, ...identicalPaths] = paths;
|
|
9643
9677
|
if (representativePath.length === 0) {
|
|
@@ -9662,10 +9696,10 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
|
|
9662
9696
|
}
|
|
9663
9697
|
}
|
|
9664
9698
|
__name(generateReferentialEqualityAnnotations, "generateReferentialEqualityAnnotations");
|
|
9665
|
-
var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe,
|
|
9699
|
+
var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path5 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
|
|
9666
9700
|
const primitive = isPrimitive(object);
|
|
9667
9701
|
if (!primitive) {
|
|
9668
|
-
addIdentity(object,
|
|
9702
|
+
addIdentity(object, path5, identities);
|
|
9669
9703
|
const seen = seenObjects.get(object);
|
|
9670
9704
|
if (seen) {
|
|
9671
9705
|
return dedupe ? {
|
|
@@ -9702,7 +9736,7 @@ var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path
|
|
|
9702
9736
|
throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
|
|
9703
9737
|
}
|
|
9704
9738
|
const recursiveResult = walker(value, identities, superJson, dedupe, [
|
|
9705
|
-
...
|
|
9739
|
+
...path5,
|
|
9706
9740
|
index
|
|
9707
9741
|
], [
|
|
9708
9742
|
...objectsInThisPath,
|
|
@@ -10282,7 +10316,7 @@ var writeFile = /* @__PURE__ */ __name(async (filePath, content, options) => {
|
|
|
10282
10316
|
}, "writeFile");
|
|
10283
10317
|
|
|
10284
10318
|
// src/utils/write-file-safely.ts
|
|
10285
|
-
var
|
|
10319
|
+
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
10286
10320
|
|
|
10287
10321
|
// src/utils/format-file.ts
|
|
10288
10322
|
init_cjs_shims();
|
|
@@ -10326,7 +10360,7 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
|
|
|
10326
10360
|
}, "writeFileSafely");
|
|
10327
10361
|
var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
|
|
10328
10362
|
const rows = Array.from(indexExports).map((filePath) => {
|
|
10329
|
-
let relativePath2 =
|
|
10363
|
+
let relativePath2 = import_node_path3.default.relative(import_node_path3.default.dirname(indexPath), filePath);
|
|
10330
10364
|
if (relativePath2.endsWith(".ts")) {
|
|
10331
10365
|
relativePath2 = relativePath2.slice(0, relativePath2.lastIndexOf(".ts"));
|
|
10332
10366
|
}
|
|
@@ -10503,7 +10537,7 @@ init_cjs_shims();
|
|
|
10503
10537
|
|
|
10504
10538
|
// src/zod-helpers/transformer.ts
|
|
10505
10539
|
init_cjs_shims();
|
|
10506
|
-
var
|
|
10540
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
10507
10541
|
|
|
10508
10542
|
// src/zod-helpers/model-helpers.ts
|
|
10509
10543
|
init_cjs_shims();
|
|
@@ -10651,13 +10685,13 @@ var Transformer = class _Transformer {
|
|
|
10651
10685
|
this.isCustomPrismaClientOutputPath = prismaClientCustomPath !== "@prisma/client";
|
|
10652
10686
|
}
|
|
10653
10687
|
static async generateIndex() {
|
|
10654
|
-
const indexPath =
|
|
10688
|
+
const indexPath = import_node_path4.default.join(_Transformer.outputPath, "schemas/index.ts");
|
|
10655
10689
|
await writeIndexFile(indexPath);
|
|
10656
10690
|
}
|
|
10657
10691
|
async generateEnumSchemas() {
|
|
10658
10692
|
for (const enumType2 of this.enumTypes) {
|
|
10659
10693
|
const { name, values } = enumType2;
|
|
10660
|
-
await writeFileSafely(
|
|
10694
|
+
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/enums/${name}.schema.ts`), `${this.generateImportZodStatement()}
|
|
10661
10695
|
${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)})`)}`);
|
|
10662
10696
|
}
|
|
10663
10697
|
}
|
|
@@ -10671,7 +10705,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10671
10705
|
const zodObjectSchemaFields = this.generateObjectSchemaFields();
|
|
10672
10706
|
const objectSchema = this.prepareObjectSchema(zodObjectSchemaFields);
|
|
10673
10707
|
const objectSchemaName = this.resolveObjectSchemaName();
|
|
10674
|
-
await writeFileSafely(
|
|
10708
|
+
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/objects/${objectSchemaName}.schema.ts`), objectSchema);
|
|
10675
10709
|
}
|
|
10676
10710
|
generateObjectSchemaFields() {
|
|
10677
10711
|
const zodObjectSchemaFields = this.fields.map((field) => this.generateObjectSchemaField(field)).flatMap((item) => item).map((item) => {
|
|
@@ -10810,9 +10844,9 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10810
10844
|
generateImportPrismaStatement() {
|
|
10811
10845
|
let prismaClientImportPath;
|
|
10812
10846
|
if (_Transformer.isCustomPrismaClientOutputPath) {
|
|
10813
|
-
const fromPath =
|
|
10847
|
+
const fromPath = import_node_path4.default.join(_Transformer.outputPath, "schemas", "objects");
|
|
10814
10848
|
const toPath = _Transformer.prismaClientOutputPath;
|
|
10815
|
-
const relativePathFromOutputToPrismaClient =
|
|
10849
|
+
const relativePathFromOutputToPrismaClient = import_node_path4.default.relative(fromPath, toPath).split(import_node_path4.default.sep).join(import_node_path4.default.posix.sep);
|
|
10816
10850
|
prismaClientImportPath = relativePathFromOutputToPrismaClient;
|
|
10817
10851
|
} else {
|
|
10818
10852
|
prismaClientImportPath = _Transformer.prismaClientOutputPath;
|
|
@@ -10942,7 +10976,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10942
10976
|
includeImport,
|
|
10943
10977
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
10944
10978
|
];
|
|
10945
|
-
await writeFileSafely(
|
|
10979
|
+
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
10980
|
}
|
|
10947
10981
|
if (findFirst) {
|
|
10948
10982
|
const imports = [
|
|
@@ -10953,7 +10987,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10953
10987
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
10954
10988
|
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
10955
10989
|
];
|
|
10956
|
-
await writeFileSafely(
|
|
10990
|
+
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
10991
|
}
|
|
10958
10992
|
if (findMany) {
|
|
10959
10993
|
const imports = [
|
|
@@ -10964,7 +10998,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10964
10998
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
10965
10999
|
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
10966
11000
|
];
|
|
10967
|
-
await writeFileSafely(
|
|
11001
|
+
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
11002
|
}
|
|
10969
11003
|
if (createOne) {
|
|
10970
11004
|
const imports = [
|
|
@@ -10973,19 +11007,19 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10973
11007
|
`import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
|
|
10974
11008
|
`import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`
|
|
10975
11009
|
];
|
|
10976
|
-
await writeFileSafely(
|
|
11010
|
+
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
11011
|
}
|
|
10978
11012
|
if (createMany) {
|
|
10979
11013
|
const imports = [
|
|
10980
11014
|
`import { ${modelName}CreateManyInputObjectSchema } from './objects/${modelName}CreateManyInput.schema'`
|
|
10981
11015
|
];
|
|
10982
|
-
await writeFileSafely(
|
|
11016
|
+
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
11017
|
}
|
|
10984
11018
|
if (createManyAndReturn) {
|
|
10985
11019
|
const imports = [
|
|
10986
11020
|
`import { ${modelName}CreateManyAndReturnInputObjectSchema } from './objects/${modelName}CreateManyAndReturnInput.schema'`
|
|
10987
11021
|
];
|
|
10988
|
-
await writeFileSafely(
|
|
11022
|
+
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
11023
|
}
|
|
10990
11024
|
if (deleteOne) {
|
|
10991
11025
|
const imports = [
|
|
@@ -10993,13 +11027,13 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10993
11027
|
includeImport,
|
|
10994
11028
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
10995
11029
|
];
|
|
10996
|
-
await writeFileSafely(
|
|
11030
|
+
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
11031
|
}
|
|
10998
11032
|
if (deleteMany) {
|
|
10999
11033
|
const imports = [
|
|
11000
11034
|
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
|
|
11001
11035
|
];
|
|
11002
|
-
await writeFileSafely(
|
|
11036
|
+
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
11037
|
}
|
|
11004
11038
|
if (updateOne) {
|
|
11005
11039
|
const imports = [
|
|
@@ -11009,20 +11043,20 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11009
11043
|
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`,
|
|
11010
11044
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
11011
11045
|
];
|
|
11012
|
-
await writeFileSafely(
|
|
11046
|
+
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
11047
|
}
|
|
11014
11048
|
if (updateMany) {
|
|
11015
11049
|
const imports = [
|
|
11016
11050
|
`import { ${modelName}UpdateManyMutationInputObjectSchema } from './objects/${modelName}UpdateManyMutationInput.schema'`,
|
|
11017
11051
|
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
|
|
11018
11052
|
];
|
|
11019
|
-
await writeFileSafely(
|
|
11053
|
+
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
11054
|
}
|
|
11021
11055
|
if (updateManyAndReturn) {
|
|
11022
11056
|
const imports = [
|
|
11023
11057
|
`import { ${modelName}UpdateManyAndReturnInputObjectSchema } from './objects/${modelName}UpdateManyAndReturnInput.schema'`
|
|
11024
11058
|
];
|
|
11025
|
-
await writeFileSafely(
|
|
11059
|
+
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
11060
|
}
|
|
11027
11061
|
if (upsertOne) {
|
|
11028
11062
|
const imports = [
|
|
@@ -11034,7 +11068,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11034
11068
|
`import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
|
|
11035
11069
|
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`
|
|
11036
11070
|
];
|
|
11037
|
-
await writeFileSafely(
|
|
11071
|
+
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
11072
|
}
|
|
11039
11073
|
if (aggregate) {
|
|
11040
11074
|
const imports = [
|
|
@@ -11065,7 +11099,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11065
11099
|
aggregateOperations.push(`_sum: ${modelName}SumAggregateInputObjectSchema.optional()`);
|
|
11066
11100
|
}
|
|
11067
11101
|
}
|
|
11068
|
-
await writeFileSafely(
|
|
11102
|
+
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
11103
|
}
|
|
11070
11104
|
if (groupBy) {
|
|
11071
11105
|
const imports = [
|
|
@@ -11074,7 +11108,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11074
11108
|
`import { ${modelName}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${modelName}ScalarWhereWithAggregatesInput.schema'`,
|
|
11075
11109
|
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
11076
11110
|
];
|
|
11077
|
-
await writeFileSafely(
|
|
11111
|
+
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
11112
|
}
|
|
11079
11113
|
}
|
|
11080
11114
|
}
|
|
@@ -11613,18 +11647,18 @@ async function generate(options) {
|
|
|
11613
11647
|
subscriptions.sort();
|
|
11614
11648
|
if (config.withShield !== false) {
|
|
11615
11649
|
consoleLog("Generating tRPC Shield");
|
|
11616
|
-
if (typeof config.withShield === "string" && (existsSync(config.withShield) || existsSync(joinPaths(config.withShield, "shield.ts")))) {
|
|
11650
|
+
if (typeof config.withShield === "string" && (existsSync(joinPaths(findFilePath(options.schemaPath), config.withShield)) || existsSync(joinPaths(findFilePath(options.schemaPath), config.withShield, "shield.ts")))) {
|
|
11617
11651
|
consoleLog("Skipping tRPC Shield generation as path provided already exists");
|
|
11618
11652
|
} else {
|
|
11619
11653
|
consoleLog("Constructing tRPC Shield source file");
|
|
11620
|
-
const shieldOutputDir = typeof config.withShield === "string" ?
|
|
11654
|
+
const shieldOutputDir = typeof config.withShield === "string" ? config.withShield : outputDir;
|
|
11621
11655
|
const shieldText = await constructShield({
|
|
11622
11656
|
queries,
|
|
11623
11657
|
mutations,
|
|
11624
11658
|
subscriptions
|
|
11625
11659
|
}, config, options, shieldOutputDir);
|
|
11626
11660
|
consoleLog("Saving tRPC Shield source file to disk");
|
|
11627
|
-
await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
|
|
11661
|
+
await writeFileSafely(shieldOutputDir.endsWith(".ts") ? shieldOutputDir : joinPaths(shieldOutputDir, "shield.ts"), shieldText);
|
|
11628
11662
|
}
|
|
11629
11663
|
} else {
|
|
11630
11664
|
consoleLog("Skipping tRPC Shield generation");
|
|
@@ -11633,54 +11667,10 @@ async function generate(options) {
|
|
|
11633
11667
|
if (config.trpcOptions && typeof config.trpcOptions === "boolean") {
|
|
11634
11668
|
const trpcOptionsOutputPath = joinPaths(outputDir, "options.ts");
|
|
11635
11669
|
consoleLog("Generating tRPC options source file");
|
|
11636
|
-
await writeFileSafely(trpcOptionsOutputPath,
|
|
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
|
-
`);
|
|
11670
|
+
await writeFileSafely(trpcOptionsOutputPath, constructDefaultOptions(config, options, trpcOptionsOutputPath));
|
|
11681
11671
|
}
|
|
11682
11672
|
resolveModelsComments(models, hiddenModels);
|
|
11683
|
-
const trpcExports = project.createSourceFile(
|
|
11673
|
+
const trpcExports = project.createSourceFile(import_node_path5.default.resolve(outputDir, "trpc.ts"), void 0, {
|
|
11684
11674
|
overwrite: true
|
|
11685
11675
|
});
|
|
11686
11676
|
consoleLog("Generating tRPC imports");
|
|
@@ -11692,7 +11682,7 @@ export default options;
|
|
|
11692
11682
|
trpcExports.formatText({
|
|
11693
11683
|
indentSize: 2
|
|
11694
11684
|
});
|
|
11695
|
-
const appRouter = project.createSourceFile(
|
|
11685
|
+
const appRouter = project.createSourceFile(import_node_path5.default.resolve(outputDir, "routers", `index.ts`), void 0, {
|
|
11696
11686
|
overwrite: true
|
|
11697
11687
|
});
|
|
11698
11688
|
consoleLog("Generating tRPC router imports");
|
|
@@ -11721,7 +11711,7 @@ export default options;
|
|
|
11721
11711
|
const plural = (0, import_pluralize.default)(lowerCaseFirst(model));
|
|
11722
11712
|
consoleLog(`Generating tRPC router for model ${model}`);
|
|
11723
11713
|
generateRouterImport(appRouter, plural, model);
|
|
11724
|
-
const modelRouter = project.createSourceFile(
|
|
11714
|
+
const modelRouter = project.createSourceFile(import_node_path5.default.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
|
|
11725
11715
|
overwrite: true
|
|
11726
11716
|
});
|
|
11727
11717
|
generateCreateRouterImport({
|