@stryke/prisma-trpc-generator 0.4.1 → 0.4.3
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 +154 -164
- package/dist/generator.js +154 -164
- package/dist/index.cjs +154 -164
- package/dist/index.js +154 -164
- package/package.json +1 -1
package/dist/generator.cjs
CHANGED
|
@@ -2484,15 +2484,24 @@ 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(path6) {
|
|
2488
|
+
if (await exists(path6)) {
|
|
2489
2489
|
return;
|
|
2490
2490
|
}
|
|
2491
|
-
return (0, import_promises2.mkdir)(
|
|
2491
|
+
return (0, import_promises2.mkdir)(path6, {
|
|
2492
2492
|
recursive: true
|
|
2493
2493
|
});
|
|
2494
2494
|
}
|
|
2495
2495
|
__name(createDirectory, "createDirectory");
|
|
2496
|
+
async function removeDirectory(path6) {
|
|
2497
|
+
if (!existsSync(path6)) {
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
return (0, import_promises2.rm)(path6, {
|
|
2501
|
+
recursive: true
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
__name(removeDirectory, "removeDirectory");
|
|
2496
2505
|
|
|
2497
2506
|
// ../path/src/join-paths.ts
|
|
2498
2507
|
init_cjs_shims();
|
|
@@ -2510,65 +2519,65 @@ var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
|
|
|
2510
2519
|
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
2511
2520
|
return _IS_ABSOLUTE_RE.test(p);
|
|
2512
2521
|
}, "isAbsolute");
|
|
2513
|
-
var correctPaths = /* @__PURE__ */ __name(function(
|
|
2514
|
-
if (!
|
|
2522
|
+
var correctPaths = /* @__PURE__ */ __name(function(path6) {
|
|
2523
|
+
if (!path6 || path6.length === 0) {
|
|
2515
2524
|
return ".";
|
|
2516
2525
|
}
|
|
2517
|
-
|
|
2518
|
-
const isUNCPath =
|
|
2519
|
-
const isPathAbsolute = isAbsolute(
|
|
2520
|
-
const trailingSeparator =
|
|
2521
|
-
|
|
2522
|
-
if (
|
|
2526
|
+
path6 = normalizeWindowsPath(path6);
|
|
2527
|
+
const isUNCPath = path6.match(_UNC_REGEX);
|
|
2528
|
+
const isPathAbsolute = isAbsolute(path6);
|
|
2529
|
+
const trailingSeparator = path6[path6.length - 1] === "/";
|
|
2530
|
+
path6 = normalizeString(path6, !isPathAbsolute);
|
|
2531
|
+
if (path6.length === 0) {
|
|
2523
2532
|
if (isPathAbsolute) {
|
|
2524
2533
|
return "/";
|
|
2525
2534
|
}
|
|
2526
2535
|
return trailingSeparator ? "./" : ".";
|
|
2527
2536
|
}
|
|
2528
2537
|
if (trailingSeparator) {
|
|
2529
|
-
|
|
2538
|
+
path6 += "/";
|
|
2530
2539
|
}
|
|
2531
|
-
if (_DRIVE_LETTER_RE.test(
|
|
2532
|
-
|
|
2540
|
+
if (_DRIVE_LETTER_RE.test(path6)) {
|
|
2541
|
+
path6 += "/";
|
|
2533
2542
|
}
|
|
2534
2543
|
if (isUNCPath) {
|
|
2535
2544
|
if (!isPathAbsolute) {
|
|
2536
|
-
return `//./${
|
|
2545
|
+
return `//./${path6}`;
|
|
2537
2546
|
}
|
|
2538
|
-
return `//${
|
|
2547
|
+
return `//${path6}`;
|
|
2539
2548
|
}
|
|
2540
|
-
return isPathAbsolute && !isAbsolute(
|
|
2549
|
+
return isPathAbsolute && !isAbsolute(path6) ? `/${path6}` : path6;
|
|
2541
2550
|
}, "correctPaths");
|
|
2542
2551
|
var joinPaths = /* @__PURE__ */ __name(function(...segments) {
|
|
2543
|
-
let
|
|
2552
|
+
let path6 = "";
|
|
2544
2553
|
for (const seg of segments) {
|
|
2545
2554
|
if (!seg) {
|
|
2546
2555
|
continue;
|
|
2547
2556
|
}
|
|
2548
|
-
if (
|
|
2549
|
-
const pathTrailing =
|
|
2557
|
+
if (path6.length > 0) {
|
|
2558
|
+
const pathTrailing = path6[path6.length - 1] === "/";
|
|
2550
2559
|
const segLeading = seg[0] === "/";
|
|
2551
2560
|
const both = pathTrailing && segLeading;
|
|
2552
2561
|
if (both) {
|
|
2553
|
-
|
|
2562
|
+
path6 += seg.slice(1);
|
|
2554
2563
|
} else {
|
|
2555
|
-
|
|
2564
|
+
path6 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
2556
2565
|
}
|
|
2557
2566
|
} else {
|
|
2558
|
-
|
|
2567
|
+
path6 += seg;
|
|
2559
2568
|
}
|
|
2560
2569
|
}
|
|
2561
|
-
return correctPaths(
|
|
2570
|
+
return correctPaths(path6);
|
|
2562
2571
|
}, "joinPaths");
|
|
2563
|
-
function normalizeString(
|
|
2572
|
+
function normalizeString(path6, allowAboveRoot) {
|
|
2564
2573
|
let res = "";
|
|
2565
2574
|
let lastSegmentLength = 0;
|
|
2566
2575
|
let lastSlash = -1;
|
|
2567
2576
|
let dots = 0;
|
|
2568
2577
|
let char = null;
|
|
2569
|
-
for (let index = 0; index <=
|
|
2570
|
-
if (index <
|
|
2571
|
-
char =
|
|
2578
|
+
for (let index = 0; index <= path6.length; ++index) {
|
|
2579
|
+
if (index < path6.length) {
|
|
2580
|
+
char = path6[index];
|
|
2572
2581
|
} else if (char === "/") {
|
|
2573
2582
|
break;
|
|
2574
2583
|
} else {
|
|
@@ -2604,9 +2613,9 @@ function normalizeString(path7, allowAboveRoot) {
|
|
|
2604
2613
|
}
|
|
2605
2614
|
} else {
|
|
2606
2615
|
if (res.length > 0) {
|
|
2607
|
-
res += `/${
|
|
2616
|
+
res += `/${path6.slice(lastSlash + 1, index)}`;
|
|
2608
2617
|
} else {
|
|
2609
|
-
res =
|
|
2618
|
+
res = path6.slice(lastSlash + 1, index);
|
|
2610
2619
|
}
|
|
2611
2620
|
lastSegmentLength = index - lastSlash - 1;
|
|
2612
2621
|
}
|
|
@@ -2623,7 +2632,7 @@ function normalizeString(path7, allowAboveRoot) {
|
|
|
2623
2632
|
__name(normalizeString, "normalizeString");
|
|
2624
2633
|
|
|
2625
2634
|
// src/prisma-generator.ts
|
|
2626
|
-
var
|
|
2635
|
+
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
2627
2636
|
var import_pluralize = __toESM(require_pluralize(), 1);
|
|
2628
2637
|
|
|
2629
2638
|
// src/config.ts
|
|
@@ -2991,8 +3000,8 @@ function getErrorMap() {
|
|
|
2991
3000
|
}
|
|
2992
3001
|
__name(getErrorMap, "getErrorMap");
|
|
2993
3002
|
var makeIssue = /* @__PURE__ */ __name((params) => {
|
|
2994
|
-
const { data, path:
|
|
2995
|
-
const fullPath = [...
|
|
3003
|
+
const { data, path: path6, errorMaps, issueData } = params;
|
|
3004
|
+
const fullPath = [...path6, ...issueData.path || []];
|
|
2996
3005
|
const fullIssue = {
|
|
2997
3006
|
...issueData,
|
|
2998
3007
|
path: fullPath
|
|
@@ -3126,11 +3135,11 @@ var ParseInputLazyPath = class {
|
|
|
3126
3135
|
static {
|
|
3127
3136
|
__name(this, "ParseInputLazyPath");
|
|
3128
3137
|
}
|
|
3129
|
-
constructor(parent, value,
|
|
3138
|
+
constructor(parent, value, path6, key) {
|
|
3130
3139
|
this._cachedPath = [];
|
|
3131
3140
|
this.parent = parent;
|
|
3132
3141
|
this.data = value;
|
|
3133
|
-
this._path =
|
|
3142
|
+
this._path = path6;
|
|
3134
3143
|
this._key = key;
|
|
3135
3144
|
}
|
|
3136
3145
|
get path() {
|
|
@@ -7115,34 +7124,34 @@ __name2(normalizeWindowsPath2, "normalizeWindowsPath");
|
|
|
7115
7124
|
var _UNC_REGEX2 = /^[/\\]{2}/;
|
|
7116
7125
|
var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
7117
7126
|
var _DRIVE_LETTER_RE2 = /^[A-Za-z]:$/;
|
|
7118
|
-
var correctPaths2 = /* @__PURE__ */ __name2(function(
|
|
7119
|
-
if (!
|
|
7127
|
+
var correctPaths2 = /* @__PURE__ */ __name2(function(path6) {
|
|
7128
|
+
if (!path6 || path6.length === 0) {
|
|
7120
7129
|
return ".";
|
|
7121
7130
|
}
|
|
7122
|
-
|
|
7123
|
-
const isUNCPath =
|
|
7124
|
-
const isPathAbsolute = isAbsolute2(
|
|
7125
|
-
const trailingSeparator =
|
|
7126
|
-
|
|
7127
|
-
if (
|
|
7131
|
+
path6 = normalizeWindowsPath2(path6);
|
|
7132
|
+
const isUNCPath = path6.match(_UNC_REGEX2);
|
|
7133
|
+
const isPathAbsolute = isAbsolute2(path6);
|
|
7134
|
+
const trailingSeparator = path6[path6.length - 1] === "/";
|
|
7135
|
+
path6 = normalizeString2(path6, !isPathAbsolute);
|
|
7136
|
+
if (path6.length === 0) {
|
|
7128
7137
|
if (isPathAbsolute) {
|
|
7129
7138
|
return "/";
|
|
7130
7139
|
}
|
|
7131
7140
|
return trailingSeparator ? "./" : ".";
|
|
7132
7141
|
}
|
|
7133
7142
|
if (trailingSeparator) {
|
|
7134
|
-
|
|
7143
|
+
path6 += "/";
|
|
7135
7144
|
}
|
|
7136
|
-
if (_DRIVE_LETTER_RE2.test(
|
|
7137
|
-
|
|
7145
|
+
if (_DRIVE_LETTER_RE2.test(path6)) {
|
|
7146
|
+
path6 += "/";
|
|
7138
7147
|
}
|
|
7139
7148
|
if (isUNCPath) {
|
|
7140
7149
|
if (!isPathAbsolute) {
|
|
7141
|
-
return `//./${
|
|
7150
|
+
return `//./${path6}`;
|
|
7142
7151
|
}
|
|
7143
|
-
return `//${
|
|
7152
|
+
return `//${path6}`;
|
|
7144
7153
|
}
|
|
7145
|
-
return isPathAbsolute && !isAbsolute2(
|
|
7154
|
+
return isPathAbsolute && !isAbsolute2(path6) ? `/${path6}` : path6;
|
|
7146
7155
|
}, "correctPaths");
|
|
7147
7156
|
function cwd() {
|
|
7148
7157
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
@@ -7152,15 +7161,15 @@ function cwd() {
|
|
|
7152
7161
|
}
|
|
7153
7162
|
__name(cwd, "cwd");
|
|
7154
7163
|
__name2(cwd, "cwd");
|
|
7155
|
-
function normalizeString2(
|
|
7164
|
+
function normalizeString2(path6, allowAboveRoot) {
|
|
7156
7165
|
let res = "";
|
|
7157
7166
|
let lastSegmentLength = 0;
|
|
7158
7167
|
let lastSlash = -1;
|
|
7159
7168
|
let dots = 0;
|
|
7160
7169
|
let char = null;
|
|
7161
|
-
for (let index = 0; index <=
|
|
7162
|
-
if (index <
|
|
7163
|
-
char =
|
|
7170
|
+
for (let index = 0; index <= path6.length; ++index) {
|
|
7171
|
+
if (index < path6.length) {
|
|
7172
|
+
char = path6[index];
|
|
7164
7173
|
} else if (char === "/") {
|
|
7165
7174
|
break;
|
|
7166
7175
|
} else {
|
|
@@ -7196,9 +7205,9 @@ function normalizeString2(path7, allowAboveRoot) {
|
|
|
7196
7205
|
}
|
|
7197
7206
|
} else {
|
|
7198
7207
|
if (res.length > 0) {
|
|
7199
|
-
res += `/${
|
|
7208
|
+
res += `/${path6.slice(lastSlash + 1, index)}`;
|
|
7200
7209
|
} else {
|
|
7201
|
-
res =
|
|
7210
|
+
res = path6.slice(lastSlash + 1, index);
|
|
7202
7211
|
}
|
|
7203
7212
|
lastSegmentLength = index - lastSlash - 1;
|
|
7204
7213
|
}
|
|
@@ -7298,20 +7307,20 @@ init_cjs_shims();
|
|
|
7298
7307
|
// ../path/src/is-file.ts
|
|
7299
7308
|
init_cjs_shims();
|
|
7300
7309
|
var import_node_fs3 = require("node:fs");
|
|
7301
|
-
function isFile(
|
|
7302
|
-
return Boolean((0, import_node_fs3.statSync)(additionalPath ? joinPaths(additionalPath,
|
|
7310
|
+
function isFile(path6, additionalPath) {
|
|
7311
|
+
return Boolean((0, import_node_fs3.statSync)(additionalPath ? joinPaths(additionalPath, path6) : path6, {
|
|
7303
7312
|
throwIfNoEntry: false
|
|
7304
7313
|
})?.isFile());
|
|
7305
7314
|
}
|
|
7306
7315
|
__name(isFile, "isFile");
|
|
7307
|
-
function isDirectory(
|
|
7308
|
-
return Boolean((0, import_node_fs3.statSync)(additionalPath ? joinPaths(additionalPath,
|
|
7316
|
+
function isDirectory(path6, additionalPath) {
|
|
7317
|
+
return Boolean((0, import_node_fs3.statSync)(additionalPath ? joinPaths(additionalPath, path6) : path6, {
|
|
7309
7318
|
throwIfNoEntry: false
|
|
7310
7319
|
})?.isDirectory());
|
|
7311
7320
|
}
|
|
7312
7321
|
__name(isDirectory, "isDirectory");
|
|
7313
|
-
function isAbsolutePath(
|
|
7314
|
-
return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(
|
|
7322
|
+
function isAbsolutePath(path6) {
|
|
7323
|
+
return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path6);
|
|
7315
7324
|
}
|
|
7316
7325
|
__name(isAbsolutePath, "isAbsolutePath");
|
|
7317
7326
|
|
|
@@ -7326,45 +7335,45 @@ function normalizeWindowsPath3(input = "") {
|
|
|
7326
7335
|
__name(normalizeWindowsPath3, "normalizeWindowsPath");
|
|
7327
7336
|
var _UNC_REGEX3 = /^[/\\]{2}/;
|
|
7328
7337
|
var _DRIVE_LETTER_RE3 = /^[A-Z]:$/i;
|
|
7329
|
-
function correctPath(
|
|
7330
|
-
if (!
|
|
7338
|
+
function correctPath(path6) {
|
|
7339
|
+
if (!path6 || path6.length === 0) {
|
|
7331
7340
|
return ".";
|
|
7332
7341
|
}
|
|
7333
|
-
|
|
7334
|
-
const isUNCPath =
|
|
7335
|
-
const isPathAbsolute = isAbsolutePath(
|
|
7336
|
-
const trailingSeparator =
|
|
7337
|
-
|
|
7338
|
-
if (
|
|
7342
|
+
path6 = normalizeWindowsPath3(path6);
|
|
7343
|
+
const isUNCPath = path6.match(_UNC_REGEX3);
|
|
7344
|
+
const isPathAbsolute = isAbsolutePath(path6);
|
|
7345
|
+
const trailingSeparator = path6[path6.length - 1] === "/";
|
|
7346
|
+
path6 = normalizeString3(path6, !isPathAbsolute);
|
|
7347
|
+
if (path6.length === 0) {
|
|
7339
7348
|
if (isPathAbsolute) {
|
|
7340
7349
|
return "/";
|
|
7341
7350
|
}
|
|
7342
7351
|
return trailingSeparator ? "./" : ".";
|
|
7343
7352
|
}
|
|
7344
7353
|
if (trailingSeparator) {
|
|
7345
|
-
|
|
7354
|
+
path6 += "/";
|
|
7346
7355
|
}
|
|
7347
|
-
if (_DRIVE_LETTER_RE3.test(
|
|
7348
|
-
|
|
7356
|
+
if (_DRIVE_LETTER_RE3.test(path6)) {
|
|
7357
|
+
path6 += "/";
|
|
7349
7358
|
}
|
|
7350
7359
|
if (isUNCPath) {
|
|
7351
7360
|
if (!isPathAbsolute) {
|
|
7352
|
-
return `//./${
|
|
7361
|
+
return `//./${path6}`;
|
|
7353
7362
|
}
|
|
7354
|
-
return `//${
|
|
7363
|
+
return `//${path6}`;
|
|
7355
7364
|
}
|
|
7356
|
-
return isPathAbsolute && !isAbsolutePath(
|
|
7365
|
+
return isPathAbsolute && !isAbsolutePath(path6) ? `/${path6}` : path6;
|
|
7357
7366
|
}
|
|
7358
7367
|
__name(correctPath, "correctPath");
|
|
7359
|
-
function normalizeString3(
|
|
7368
|
+
function normalizeString3(path6, allowAboveRoot) {
|
|
7360
7369
|
let res = "";
|
|
7361
7370
|
let lastSegmentLength = 0;
|
|
7362
7371
|
let lastSlash = -1;
|
|
7363
7372
|
let dots = 0;
|
|
7364
7373
|
let char = null;
|
|
7365
|
-
for (let index = 0; index <=
|
|
7366
|
-
if (index <
|
|
7367
|
-
char =
|
|
7374
|
+
for (let index = 0; index <= path6.length; ++index) {
|
|
7375
|
+
if (index < path6.length) {
|
|
7376
|
+
char = path6[index];
|
|
7368
7377
|
} else if (char === "/") {
|
|
7369
7378
|
break;
|
|
7370
7379
|
} else {
|
|
@@ -7400,9 +7409,9 @@ function normalizeString3(path7, allowAboveRoot) {
|
|
|
7400
7409
|
}
|
|
7401
7410
|
} else {
|
|
7402
7411
|
if (res.length > 0) {
|
|
7403
|
-
res += `/${
|
|
7412
|
+
res += `/${path6.slice(lastSlash + 1, index)}`;
|
|
7404
7413
|
} else {
|
|
7405
|
-
res =
|
|
7414
|
+
res = path6.slice(lastSlash + 1, index);
|
|
7406
7415
|
}
|
|
7407
7416
|
lastSegmentLength = index - lastSlash - 1;
|
|
7408
7417
|
}
|
|
@@ -7437,17 +7446,17 @@ function findFilePath(filePath) {
|
|
|
7437
7446
|
}), "");
|
|
7438
7447
|
}
|
|
7439
7448
|
__name(findFilePath, "findFilePath");
|
|
7440
|
-
function resolvePath(
|
|
7441
|
-
const paths = normalizeWindowsPath3(
|
|
7449
|
+
function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
|
|
7450
|
+
const paths = normalizeWindowsPath3(path6).split("/");
|
|
7442
7451
|
let resolvedPath = "";
|
|
7443
7452
|
let resolvedAbsolute = false;
|
|
7444
7453
|
for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
7445
|
-
const
|
|
7446
|
-
if (!
|
|
7454
|
+
const path7 = index >= 0 ? paths[index] : cwd2;
|
|
7455
|
+
if (!path7 || path7.length === 0) {
|
|
7447
7456
|
continue;
|
|
7448
7457
|
}
|
|
7449
|
-
resolvedPath = joinPaths(
|
|
7450
|
-
resolvedAbsolute = isAbsolutePath(
|
|
7458
|
+
resolvedPath = joinPaths(path7, resolvedPath);
|
|
7459
|
+
resolvedAbsolute = isAbsolutePath(path7);
|
|
7451
7460
|
}
|
|
7452
7461
|
resolvedPath = normalizeString3(resolvedPath, !resolvedAbsolute);
|
|
7453
7462
|
if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {
|
|
@@ -7457,13 +7466,13 @@ function resolvePath(path7, cwd2 = getWorkspaceRoot()) {
|
|
|
7457
7466
|
}
|
|
7458
7467
|
__name(resolvePath, "resolvePath");
|
|
7459
7468
|
function resolvePaths(...paths) {
|
|
7460
|
-
return resolvePath(joinPaths(...paths.map((
|
|
7469
|
+
return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath3(path6))));
|
|
7461
7470
|
}
|
|
7462
7471
|
__name(resolvePaths, "resolvePaths");
|
|
7463
7472
|
|
|
7464
7473
|
// ../path/src/get-parent-path.ts
|
|
7465
|
-
var resolveParentPath = /* @__PURE__ */ __name((
|
|
7466
|
-
return resolvePaths(
|
|
7474
|
+
var resolveParentPath = /* @__PURE__ */ __name((path6) => {
|
|
7475
|
+
return resolvePaths(path6, "..");
|
|
7467
7476
|
}, "resolveParentPath");
|
|
7468
7477
|
var getParentPath = /* @__PURE__ */ __name((name, cwd2, options) => {
|
|
7469
7478
|
const ignoreCase = options?.ignoreCase ?? true;
|
|
@@ -7960,24 +7969,6 @@ var project = new import_ts_morph.Project({
|
|
|
7960
7969
|
}
|
|
7961
7970
|
});
|
|
7962
7971
|
|
|
7963
|
-
// src/utils/remove-dir.ts
|
|
7964
|
-
init_cjs_shims();
|
|
7965
|
-
var import_node_fs4 = require("node:fs");
|
|
7966
|
-
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
7967
|
-
async function removeDir(dirPath, onlyContent) {
|
|
7968
|
-
const dirEntries = await import_node_fs4.promises.readdir(dirPath, {
|
|
7969
|
-
withFileTypes: true
|
|
7970
|
-
});
|
|
7971
|
-
await Promise.all(dirEntries.map(async (dirEntry) => {
|
|
7972
|
-
const fullPath = import_node_path4.default.join(dirPath, dirEntry.name);
|
|
7973
|
-
return dirEntry.isDirectory() ? removeDir(fullPath, false) : import_node_fs4.promises.unlink(fullPath);
|
|
7974
|
-
}));
|
|
7975
|
-
if (!onlyContent) {
|
|
7976
|
-
await import_node_fs4.promises.rmdir(dirPath);
|
|
7977
|
-
}
|
|
7978
|
-
}
|
|
7979
|
-
__name(removeDir, "removeDir");
|
|
7980
|
-
|
|
7981
7972
|
// src/utils/write-file-safely.ts
|
|
7982
7973
|
init_cjs_shims();
|
|
7983
7974
|
|
|
@@ -9166,7 +9157,7 @@ var isURL = /* @__PURE__ */ __name((payload) => payload instanceof URL, "isURL")
|
|
|
9166
9157
|
// ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.js
|
|
9167
9158
|
init_cjs_shims();
|
|
9168
9159
|
var escapeKey = /* @__PURE__ */ __name((key) => key.replace(/\./g, "\\."), "escapeKey");
|
|
9169
|
-
var stringifyPath = /* @__PURE__ */ __name((
|
|
9160
|
+
var stringifyPath = /* @__PURE__ */ __name((path6) => path6.map(String).map(escapeKey).join("."), "stringifyPath");
|
|
9170
9161
|
var parsePath = /* @__PURE__ */ __name((string) => {
|
|
9171
9162
|
const result = [];
|
|
9172
9163
|
let segment = "";
|
|
@@ -9429,27 +9420,27 @@ var getNthKey = /* @__PURE__ */ __name((value, n) => {
|
|
|
9429
9420
|
}
|
|
9430
9421
|
return keys.next().value;
|
|
9431
9422
|
}, "getNthKey");
|
|
9432
|
-
function validatePath(
|
|
9433
|
-
if (includes(
|
|
9423
|
+
function validatePath(path6) {
|
|
9424
|
+
if (includes(path6, "__proto__")) {
|
|
9434
9425
|
throw new Error("__proto__ is not allowed as a property");
|
|
9435
9426
|
}
|
|
9436
|
-
if (includes(
|
|
9427
|
+
if (includes(path6, "prototype")) {
|
|
9437
9428
|
throw new Error("prototype is not allowed as a property");
|
|
9438
9429
|
}
|
|
9439
|
-
if (includes(
|
|
9430
|
+
if (includes(path6, "constructor")) {
|
|
9440
9431
|
throw new Error("constructor is not allowed as a property");
|
|
9441
9432
|
}
|
|
9442
9433
|
}
|
|
9443
9434
|
__name(validatePath, "validatePath");
|
|
9444
|
-
var getDeep = /* @__PURE__ */ __name((object,
|
|
9445
|
-
validatePath(
|
|
9446
|
-
for (let i = 0; i <
|
|
9447
|
-
const key =
|
|
9435
|
+
var getDeep = /* @__PURE__ */ __name((object, path6) => {
|
|
9436
|
+
validatePath(path6);
|
|
9437
|
+
for (let i = 0; i < path6.length; i++) {
|
|
9438
|
+
const key = path6[i];
|
|
9448
9439
|
if (isSet(object)) {
|
|
9449
9440
|
object = getNthKey(object, +key);
|
|
9450
9441
|
} else if (isMap(object)) {
|
|
9451
9442
|
const row = +key;
|
|
9452
|
-
const type = +
|
|
9443
|
+
const type = +path6[++i] === 0 ? "key" : "value";
|
|
9453
9444
|
const keyOfRow = getNthKey(object, row);
|
|
9454
9445
|
switch (type) {
|
|
9455
9446
|
case "key":
|
|
@@ -9465,14 +9456,14 @@ var getDeep = /* @__PURE__ */ __name((object, path7) => {
|
|
|
9465
9456
|
}
|
|
9466
9457
|
return object;
|
|
9467
9458
|
}, "getDeep");
|
|
9468
|
-
var setDeep = /* @__PURE__ */ __name((object,
|
|
9469
|
-
validatePath(
|
|
9470
|
-
if (
|
|
9459
|
+
var setDeep = /* @__PURE__ */ __name((object, path6, mapper) => {
|
|
9460
|
+
validatePath(path6);
|
|
9461
|
+
if (path6.length === 0) {
|
|
9471
9462
|
return mapper(object);
|
|
9472
9463
|
}
|
|
9473
9464
|
let parent = object;
|
|
9474
|
-
for (let i = 0; i <
|
|
9475
|
-
const key =
|
|
9465
|
+
for (let i = 0; i < path6.length - 1; i++) {
|
|
9466
|
+
const key = path6[i];
|
|
9476
9467
|
if (isArray(parent)) {
|
|
9477
9468
|
const index = +key;
|
|
9478
9469
|
parent = parent[index];
|
|
@@ -9482,12 +9473,12 @@ var setDeep = /* @__PURE__ */ __name((object, path7, mapper) => {
|
|
|
9482
9473
|
const row = +key;
|
|
9483
9474
|
parent = getNthKey(parent, row);
|
|
9484
9475
|
} else if (isMap(parent)) {
|
|
9485
|
-
const isEnd = i ===
|
|
9476
|
+
const isEnd = i === path6.length - 2;
|
|
9486
9477
|
if (isEnd) {
|
|
9487
9478
|
break;
|
|
9488
9479
|
}
|
|
9489
9480
|
const row = +key;
|
|
9490
|
-
const type = +
|
|
9481
|
+
const type = +path6[++i] === 0 ? "key" : "value";
|
|
9491
9482
|
const keyOfRow = getNthKey(parent, row);
|
|
9492
9483
|
switch (type) {
|
|
9493
9484
|
case "key":
|
|
@@ -9499,7 +9490,7 @@ var setDeep = /* @__PURE__ */ __name((object, path7, mapper) => {
|
|
|
9499
9490
|
}
|
|
9500
9491
|
}
|
|
9501
9492
|
}
|
|
9502
|
-
const lastKey =
|
|
9493
|
+
const lastKey = path6[path6.length - 1];
|
|
9503
9494
|
if (isArray(parent)) {
|
|
9504
9495
|
parent[+lastKey] = mapper(parent[+lastKey]);
|
|
9505
9496
|
} else if (isPlainObject2(parent)) {
|
|
@@ -9514,7 +9505,7 @@ var setDeep = /* @__PURE__ */ __name((object, path7, mapper) => {
|
|
|
9514
9505
|
}
|
|
9515
9506
|
}
|
|
9516
9507
|
if (isMap(parent)) {
|
|
9517
|
-
const row = +
|
|
9508
|
+
const row = +path6[path6.length - 2];
|
|
9518
9509
|
const keyToRow = getNthKey(parent, row);
|
|
9519
9510
|
const type = +lastKey === 0 ? "key" : "value";
|
|
9520
9511
|
switch (type) {
|
|
@@ -9560,15 +9551,15 @@ function traverse(tree, walker2, origin = []) {
|
|
|
9560
9551
|
}
|
|
9561
9552
|
__name(traverse, "traverse");
|
|
9562
9553
|
function applyValueAnnotations(plain, annotations, superJson) {
|
|
9563
|
-
traverse(annotations, (type,
|
|
9564
|
-
plain = setDeep(plain,
|
|
9554
|
+
traverse(annotations, (type, path6) => {
|
|
9555
|
+
plain = setDeep(plain, path6, (v) => untransformValue(v, type, superJson));
|
|
9565
9556
|
});
|
|
9566
9557
|
return plain;
|
|
9567
9558
|
}
|
|
9568
9559
|
__name(applyValueAnnotations, "applyValueAnnotations");
|
|
9569
9560
|
function applyReferentialEqualityAnnotations(plain, annotations) {
|
|
9570
|
-
function apply(identicalPaths,
|
|
9571
|
-
const object = getDeep(plain, parsePath(
|
|
9561
|
+
function apply(identicalPaths, path6) {
|
|
9562
|
+
const object = getDeep(plain, parsePath(path6));
|
|
9572
9563
|
identicalPaths.map(parsePath).forEach((identicalObjectPath) => {
|
|
9573
9564
|
plain = setDeep(plain, identicalObjectPath, () => object);
|
|
9574
9565
|
});
|
|
@@ -9589,13 +9580,13 @@ function applyReferentialEqualityAnnotations(plain, annotations) {
|
|
|
9589
9580
|
}
|
|
9590
9581
|
__name(applyReferentialEqualityAnnotations, "applyReferentialEqualityAnnotations");
|
|
9591
9582
|
var isDeep = /* @__PURE__ */ __name((object, superJson) => isPlainObject2(object) || isArray(object) || isMap(object) || isSet(object) || isInstanceOfRegisteredClass(object, superJson), "isDeep");
|
|
9592
|
-
function addIdentity(object,
|
|
9583
|
+
function addIdentity(object, path6, identities) {
|
|
9593
9584
|
const existingSet = identities.get(object);
|
|
9594
9585
|
if (existingSet) {
|
|
9595
|
-
existingSet.push(
|
|
9586
|
+
existingSet.push(path6);
|
|
9596
9587
|
} else {
|
|
9597
9588
|
identities.set(object, [
|
|
9598
|
-
|
|
9589
|
+
path6
|
|
9599
9590
|
]);
|
|
9600
9591
|
}
|
|
9601
9592
|
}
|
|
@@ -9608,7 +9599,7 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
|
|
9608
9599
|
return;
|
|
9609
9600
|
}
|
|
9610
9601
|
if (!dedupe) {
|
|
9611
|
-
paths = paths.map((
|
|
9602
|
+
paths = paths.map((path6) => path6.map(String)).sort((a, b) => a.length - b.length);
|
|
9612
9603
|
}
|
|
9613
9604
|
const [representativePath, ...identicalPaths] = paths;
|
|
9614
9605
|
if (representativePath.length === 0) {
|
|
@@ -9633,10 +9624,10 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
|
|
9633
9624
|
}
|
|
9634
9625
|
}
|
|
9635
9626
|
__name(generateReferentialEqualityAnnotations, "generateReferentialEqualityAnnotations");
|
|
9636
|
-
var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe,
|
|
9627
|
+
var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path6 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
|
|
9637
9628
|
const primitive = isPrimitive(object);
|
|
9638
9629
|
if (!primitive) {
|
|
9639
|
-
addIdentity(object,
|
|
9630
|
+
addIdentity(object, path6, identities);
|
|
9640
9631
|
const seen = seenObjects.get(object);
|
|
9641
9632
|
if (seen) {
|
|
9642
9633
|
return dedupe ? {
|
|
@@ -9673,7 +9664,7 @@ var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path
|
|
|
9673
9664
|
throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
|
|
9674
9665
|
}
|
|
9675
9666
|
const recursiveResult = walker(value, identities, superJson, dedupe, [
|
|
9676
|
-
...
|
|
9667
|
+
...path6,
|
|
9677
9668
|
index
|
|
9678
9669
|
], [
|
|
9679
9670
|
...objectsInThisPath,
|
|
@@ -10253,7 +10244,7 @@ var writeFile = /* @__PURE__ */ __name(async (filePath, content, options) => {
|
|
|
10253
10244
|
}, "writeFile");
|
|
10254
10245
|
|
|
10255
10246
|
// src/utils/write-file-safely.ts
|
|
10256
|
-
var
|
|
10247
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
10257
10248
|
|
|
10258
10249
|
// src/utils/format-file.ts
|
|
10259
10250
|
init_cjs_shims();
|
|
@@ -10297,7 +10288,7 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
|
|
|
10297
10288
|
}, "writeFileSafely");
|
|
10298
10289
|
var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
|
|
10299
10290
|
const rows = Array.from(indexExports).map((filePath) => {
|
|
10300
|
-
let relativePath =
|
|
10291
|
+
let relativePath = import_node_path4.default.relative(import_node_path4.default.dirname(indexPath), filePath);
|
|
10301
10292
|
if (relativePath.endsWith(".ts")) {
|
|
10302
10293
|
relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
|
|
10303
10294
|
}
|
|
@@ -10474,7 +10465,7 @@ init_cjs_shims();
|
|
|
10474
10465
|
|
|
10475
10466
|
// src/zod-helpers/transformer.ts
|
|
10476
10467
|
init_cjs_shims();
|
|
10477
|
-
var
|
|
10468
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
10478
10469
|
|
|
10479
10470
|
// src/zod-helpers/model-helpers.ts
|
|
10480
10471
|
init_cjs_shims();
|
|
@@ -10622,13 +10613,13 @@ var Transformer = class _Transformer {
|
|
|
10622
10613
|
this.isCustomPrismaClientOutputPath = prismaClientCustomPath !== "@prisma/client";
|
|
10623
10614
|
}
|
|
10624
10615
|
static async generateIndex() {
|
|
10625
|
-
const indexPath =
|
|
10616
|
+
const indexPath = import_node_path5.default.join(_Transformer.outputPath, "schemas/index.ts");
|
|
10626
10617
|
await writeIndexFile(indexPath);
|
|
10627
10618
|
}
|
|
10628
10619
|
async generateEnumSchemas() {
|
|
10629
10620
|
for (const enumType2 of this.enumTypes) {
|
|
10630
10621
|
const { name, values } = enumType2;
|
|
10631
|
-
await writeFileSafely(
|
|
10622
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/enums/${name}.schema.ts`), `${this.generateImportZodStatement()}
|
|
10632
10623
|
${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)})`)}`);
|
|
10633
10624
|
}
|
|
10634
10625
|
}
|
|
@@ -10642,7 +10633,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10642
10633
|
const zodObjectSchemaFields = this.generateObjectSchemaFields();
|
|
10643
10634
|
const objectSchema = this.prepareObjectSchema(zodObjectSchemaFields);
|
|
10644
10635
|
const objectSchemaName = this.resolveObjectSchemaName();
|
|
10645
|
-
await writeFileSafely(
|
|
10636
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/objects/${objectSchemaName}.schema.ts`), objectSchema);
|
|
10646
10637
|
}
|
|
10647
10638
|
generateObjectSchemaFields() {
|
|
10648
10639
|
const zodObjectSchemaFields = this.fields.map((field) => this.generateObjectSchemaField(field)).flatMap((item) => item).map((item) => {
|
|
@@ -10734,7 +10725,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10734
10725
|
const arr = inputType.isList ? ".array()" : "";
|
|
10735
10726
|
const opt = !field.isRequired ? ".optional()" : "";
|
|
10736
10727
|
const nullable = field.inputTypes.length > 1 && field.inputTypes[1]?.type === "Null" ? ".nullable()" : "";
|
|
10737
|
-
return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}` : `z.lazy(() => ${schema})${arr}${opt}${nullable}`;
|
|
10728
|
+
return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${schema})${arr}${opt}${nullable}` : `z.lazy(() => ${schema})${arr}${opt}${nullable}`;
|
|
10738
10729
|
}
|
|
10739
10730
|
generateFieldValidators(zodStringWithMainType, field) {
|
|
10740
10731
|
const { isRequired, isNullable } = field;
|
|
@@ -10781,9 +10772,9 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10781
10772
|
generateImportPrismaStatement() {
|
|
10782
10773
|
let prismaClientImportPath;
|
|
10783
10774
|
if (_Transformer.isCustomPrismaClientOutputPath) {
|
|
10784
|
-
const fromPath =
|
|
10775
|
+
const fromPath = import_node_path5.default.join(_Transformer.outputPath, "schemas", "objects");
|
|
10785
10776
|
const toPath = _Transformer.prismaClientOutputPath;
|
|
10786
|
-
const relativePathFromOutputToPrismaClient =
|
|
10777
|
+
const relativePathFromOutputToPrismaClient = import_node_path5.default.relative(fromPath, toPath).split(import_node_path5.default.sep).join(import_node_path5.default.posix.sep);
|
|
10787
10778
|
prismaClientImportPath = relativePathFromOutputToPrismaClient;
|
|
10788
10779
|
} else {
|
|
10789
10780
|
prismaClientImportPath = _Transformer.prismaClientOutputPath;
|
|
@@ -10911,7 +10902,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10911
10902
|
includeImport,
|
|
10912
10903
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
10913
10904
|
];
|
|
10914
|
-
await writeFileSafely(
|
|
10905
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${findUnique}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindUnique`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
|
|
10915
10906
|
}
|
|
10916
10907
|
if (findFirst) {
|
|
10917
10908
|
const imports = [
|
|
@@ -10922,7 +10913,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10922
10913
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
10923
10914
|
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
10924
10915
|
];
|
|
10925
|
-
await writeFileSafely(
|
|
10916
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${findFirst}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindFirst`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${modelName}ScalarFieldEnumSchema).optional() })`)}`);
|
|
10926
10917
|
}
|
|
10927
10918
|
if (findMany) {
|
|
10928
10919
|
const imports = [
|
|
@@ -10933,7 +10924,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10933
10924
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
10934
10925
|
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
10935
10926
|
];
|
|
10936
|
-
await writeFileSafely(
|
|
10927
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${findMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindMany`, `z.object({ ${selectZodSchemaLineLazy} ${includeZodSchemaLineLazy} ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${modelName}ScalarFieldEnumSchema).optional() })`)}`);
|
|
10937
10928
|
}
|
|
10938
10929
|
if (createOne) {
|
|
10939
10930
|
const imports = [
|
|
@@ -10942,13 +10933,13 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10942
10933
|
`import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
|
|
10943
10934
|
`import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`
|
|
10944
10935
|
];
|
|
10945
|
-
await writeFileSafely(
|
|
10936
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${createOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} data: z.union([${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema]) })`)}`);
|
|
10946
10937
|
}
|
|
10947
10938
|
if (createMany) {
|
|
10948
10939
|
const imports = [
|
|
10949
10940
|
`import { ${modelName}CreateManyInputObjectSchema } from './objects/${modelName}CreateManyInput.schema'`
|
|
10950
10941
|
];
|
|
10951
|
-
await writeFileSafely(
|
|
10942
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${createMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateMany`, `z.object({ data: z.union([ ${modelName}CreateManyInputObjectSchema, z.array(${modelName}CreateManyInputObjectSchema) ]), ${_Transformer.provider === "mongodb" || _Transformer.provider === "sqlserver" ? "" : "skipDuplicates: z.boolean().optional()"} })`)}`);
|
|
10952
10943
|
}
|
|
10953
10944
|
if (deleteOne) {
|
|
10954
10945
|
const imports = [
|
|
@@ -10956,13 +10947,13 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10956
10947
|
includeImport,
|
|
10957
10948
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
10958
10949
|
];
|
|
10959
|
-
await writeFileSafely(
|
|
10950
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${deleteOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
|
|
10960
10951
|
}
|
|
10961
10952
|
if (deleteMany) {
|
|
10962
10953
|
const imports = [
|
|
10963
10954
|
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
|
|
10964
10955
|
];
|
|
10965
|
-
await writeFileSafely(
|
|
10956
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${deleteMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteMany`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
|
|
10966
10957
|
}
|
|
10967
10958
|
if (updateOne) {
|
|
10968
10959
|
const imports = [
|
|
@@ -10972,14 +10963,14 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10972
10963
|
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`,
|
|
10973
10964
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
10974
10965
|
];
|
|
10975
|
-
await writeFileSafely(
|
|
10966
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${updateOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} data: z.union([${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema]), where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
|
|
10976
10967
|
}
|
|
10977
10968
|
if (updateMany) {
|
|
10978
10969
|
const imports = [
|
|
10979
10970
|
`import { ${modelName}UpdateManyMutationInputObjectSchema } from './objects/${modelName}UpdateManyMutationInput.schema'`,
|
|
10980
10971
|
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
|
|
10981
10972
|
];
|
|
10982
|
-
await writeFileSafely(
|
|
10973
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${updateMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateMany`, `z.object({ data: ${modelName}UpdateManyMutationInputObjectSchema, where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
|
|
10983
10974
|
}
|
|
10984
10975
|
if (upsertOne) {
|
|
10985
10976
|
const imports = [
|
|
@@ -10991,7 +10982,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10991
10982
|
`import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
|
|
10992
10983
|
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`
|
|
10993
10984
|
];
|
|
10994
|
-
await writeFileSafely(
|
|
10985
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${upsertOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}Upsert`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema, create: z.union([ ${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema ]), update: z.union([ ${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema ]) })`)}`);
|
|
10995
10986
|
}
|
|
10996
10987
|
if (aggregate) {
|
|
10997
10988
|
const imports = [
|
|
@@ -11022,7 +11013,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11022
11013
|
aggregateOperations.push(`_sum: ${modelName}SumAggregateInputObjectSchema.optional()`);
|
|
11023
11014
|
}
|
|
11024
11015
|
}
|
|
11025
|
-
await writeFileSafely(
|
|
11016
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${aggregate}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}Aggregate`, `z.object({ ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), ${aggregateOperations.join(", ")} })`)}`);
|
|
11026
11017
|
}
|
|
11027
11018
|
if (groupBy) {
|
|
11028
11019
|
const imports = [
|
|
@@ -11031,7 +11022,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11031
11022
|
`import { ${modelName}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${modelName}ScalarWhereWithAggregatesInput.schema'`,
|
|
11032
11023
|
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
11033
11024
|
];
|
|
11034
|
-
await writeFileSafely(
|
|
11025
|
+
await writeFileSafely(import_node_path5.default.join(_Transformer.outputPath, `schemas/${groupBy}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}GroupBy`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional(), orderBy: z.union([${modelName}OrderByWithAggregationInputObjectSchema, ${modelName}OrderByWithAggregationInputObjectSchema.array()]).optional(), having: ${modelName}ScalarWhereWithAggregatesInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), by: z.array(${modelName}ScalarFieldEnumSchema) })`)}`);
|
|
11035
11026
|
}
|
|
11036
11027
|
}
|
|
11037
11028
|
}
|
|
@@ -11482,8 +11473,8 @@ async function generate(options) {
|
|
|
11482
11473
|
}
|
|
11483
11474
|
}, "consoleLog");
|
|
11484
11475
|
consoleLog(`Preparing output directory: ${outputDir}`);
|
|
11476
|
+
await removeDirectory(outputDir);
|
|
11485
11477
|
await createDirectory(outputDir);
|
|
11486
|
-
await removeDir(outputDir, true);
|
|
11487
11478
|
consoleLog("Finding Prisma Client generator");
|
|
11488
11479
|
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
11489
11480
|
if (!prismaClientProvider) {
|
|
@@ -11535,7 +11526,6 @@ async function generate(options) {
|
|
|
11535
11526
|
const shieldOutputDir = joinPaths(outputDir, "shield");
|
|
11536
11527
|
consoleLog("Preparing tRPC Shield output directory");
|
|
11537
11528
|
await createDirectory(shieldOutputDir);
|
|
11538
|
-
await removeDir(shieldOutputDir, true);
|
|
11539
11529
|
const queries = [];
|
|
11540
11530
|
const mutations = [];
|
|
11541
11531
|
const subscriptions = [];
|
|
@@ -11593,7 +11583,7 @@ async function generate(options) {
|
|
|
11593
11583
|
}
|
|
11594
11584
|
consoleLog(`Generating tRPC source code for ${models.length} models`);
|
|
11595
11585
|
resolveModelsComments(models, hiddenModels);
|
|
11596
|
-
const createRouter = project.createSourceFile(
|
|
11586
|
+
const createRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
|
|
11597
11587
|
overwrite: true
|
|
11598
11588
|
});
|
|
11599
11589
|
consoleLog("Generating tRPC imports");
|
|
@@ -11606,7 +11596,7 @@ async function generate(options) {
|
|
|
11606
11596
|
createRouter.formatText({
|
|
11607
11597
|
indentSize: 2
|
|
11608
11598
|
});
|
|
11609
|
-
const appRouter = project.createSourceFile(
|
|
11599
|
+
const appRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "routers", `index.ts`), void 0, {
|
|
11610
11600
|
overwrite: true
|
|
11611
11601
|
});
|
|
11612
11602
|
consoleLog("Generating tRPC router imports");
|
|
@@ -11628,7 +11618,7 @@ async function generate(options) {
|
|
|
11628
11618
|
const plural = (0, import_pluralize.default)(model.toLowerCase());
|
|
11629
11619
|
consoleLog(`Generating tRPC router for model ${model}`);
|
|
11630
11620
|
generateRouterImport(appRouter, plural, model);
|
|
11631
|
-
const modelRouter = project.createSourceFile(
|
|
11621
|
+
const modelRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
|
|
11632
11622
|
overwrite: true
|
|
11633
11623
|
});
|
|
11634
11624
|
generateCreateRouterImport({
|