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