@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/generator.js
CHANGED
|
@@ -2489,15 +2489,24 @@ var exists = /* @__PURE__ */ __name(async (filePath) => {
|
|
|
2489
2489
|
|
|
2490
2490
|
// ../fs/src/helpers.ts
|
|
2491
2491
|
import { mkdir, readFile, rm } from "node:fs/promises";
|
|
2492
|
-
async function createDirectory(
|
|
2493
|
-
if (await exists(
|
|
2492
|
+
async function createDirectory(path6) {
|
|
2493
|
+
if (await exists(path6)) {
|
|
2494
2494
|
return;
|
|
2495
2495
|
}
|
|
2496
|
-
return mkdir(
|
|
2496
|
+
return mkdir(path6, {
|
|
2497
2497
|
recursive: true
|
|
2498
2498
|
});
|
|
2499
2499
|
}
|
|
2500
2500
|
__name(createDirectory, "createDirectory");
|
|
2501
|
+
async function removeDirectory(path6) {
|
|
2502
|
+
if (!existsSync(path6)) {
|
|
2503
|
+
return;
|
|
2504
|
+
}
|
|
2505
|
+
return rm(path6, {
|
|
2506
|
+
recursive: true
|
|
2507
|
+
});
|
|
2508
|
+
}
|
|
2509
|
+
__name(removeDirectory, "removeDirectory");
|
|
2501
2510
|
|
|
2502
2511
|
// ../path/src/join-paths.ts
|
|
2503
2512
|
init_esm_shims();
|
|
@@ -2515,65 +2524,65 @@ var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
|
|
|
2515
2524
|
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
2516
2525
|
return _IS_ABSOLUTE_RE.test(p);
|
|
2517
2526
|
}, "isAbsolute");
|
|
2518
|
-
var correctPaths = /* @__PURE__ */ __name(function(
|
|
2519
|
-
if (!
|
|
2527
|
+
var correctPaths = /* @__PURE__ */ __name(function(path6) {
|
|
2528
|
+
if (!path6 || path6.length === 0) {
|
|
2520
2529
|
return ".";
|
|
2521
2530
|
}
|
|
2522
|
-
|
|
2523
|
-
const isUNCPath =
|
|
2524
|
-
const isPathAbsolute = isAbsolute(
|
|
2525
|
-
const trailingSeparator =
|
|
2526
|
-
|
|
2527
|
-
if (
|
|
2531
|
+
path6 = normalizeWindowsPath(path6);
|
|
2532
|
+
const isUNCPath = path6.match(_UNC_REGEX);
|
|
2533
|
+
const isPathAbsolute = isAbsolute(path6);
|
|
2534
|
+
const trailingSeparator = path6[path6.length - 1] === "/";
|
|
2535
|
+
path6 = normalizeString(path6, !isPathAbsolute);
|
|
2536
|
+
if (path6.length === 0) {
|
|
2528
2537
|
if (isPathAbsolute) {
|
|
2529
2538
|
return "/";
|
|
2530
2539
|
}
|
|
2531
2540
|
return trailingSeparator ? "./" : ".";
|
|
2532
2541
|
}
|
|
2533
2542
|
if (trailingSeparator) {
|
|
2534
|
-
|
|
2543
|
+
path6 += "/";
|
|
2535
2544
|
}
|
|
2536
|
-
if (_DRIVE_LETTER_RE.test(
|
|
2537
|
-
|
|
2545
|
+
if (_DRIVE_LETTER_RE.test(path6)) {
|
|
2546
|
+
path6 += "/";
|
|
2538
2547
|
}
|
|
2539
2548
|
if (isUNCPath) {
|
|
2540
2549
|
if (!isPathAbsolute) {
|
|
2541
|
-
return `//./${
|
|
2550
|
+
return `//./${path6}`;
|
|
2542
2551
|
}
|
|
2543
|
-
return `//${
|
|
2552
|
+
return `//${path6}`;
|
|
2544
2553
|
}
|
|
2545
|
-
return isPathAbsolute && !isAbsolute(
|
|
2554
|
+
return isPathAbsolute && !isAbsolute(path6) ? `/${path6}` : path6;
|
|
2546
2555
|
}, "correctPaths");
|
|
2547
2556
|
var joinPaths = /* @__PURE__ */ __name(function(...segments) {
|
|
2548
|
-
let
|
|
2557
|
+
let path6 = "";
|
|
2549
2558
|
for (const seg of segments) {
|
|
2550
2559
|
if (!seg) {
|
|
2551
2560
|
continue;
|
|
2552
2561
|
}
|
|
2553
|
-
if (
|
|
2554
|
-
const pathTrailing =
|
|
2562
|
+
if (path6.length > 0) {
|
|
2563
|
+
const pathTrailing = path6[path6.length - 1] === "/";
|
|
2555
2564
|
const segLeading = seg[0] === "/";
|
|
2556
2565
|
const both = pathTrailing && segLeading;
|
|
2557
2566
|
if (both) {
|
|
2558
|
-
|
|
2567
|
+
path6 += seg.slice(1);
|
|
2559
2568
|
} else {
|
|
2560
|
-
|
|
2569
|
+
path6 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
2561
2570
|
}
|
|
2562
2571
|
} else {
|
|
2563
|
-
|
|
2572
|
+
path6 += seg;
|
|
2564
2573
|
}
|
|
2565
2574
|
}
|
|
2566
|
-
return correctPaths(
|
|
2575
|
+
return correctPaths(path6);
|
|
2567
2576
|
}, "joinPaths");
|
|
2568
|
-
function normalizeString(
|
|
2577
|
+
function normalizeString(path6, allowAboveRoot) {
|
|
2569
2578
|
let res = "";
|
|
2570
2579
|
let lastSegmentLength = 0;
|
|
2571
2580
|
let lastSlash = -1;
|
|
2572
2581
|
let dots = 0;
|
|
2573
2582
|
let char = null;
|
|
2574
|
-
for (let index = 0; index <=
|
|
2575
|
-
if (index <
|
|
2576
|
-
char =
|
|
2583
|
+
for (let index = 0; index <= path6.length; ++index) {
|
|
2584
|
+
if (index < path6.length) {
|
|
2585
|
+
char = path6[index];
|
|
2577
2586
|
} else if (char === "/") {
|
|
2578
2587
|
break;
|
|
2579
2588
|
} else {
|
|
@@ -2609,9 +2618,9 @@ function normalizeString(path7, allowAboveRoot) {
|
|
|
2609
2618
|
}
|
|
2610
2619
|
} else {
|
|
2611
2620
|
if (res.length > 0) {
|
|
2612
|
-
res += `/${
|
|
2621
|
+
res += `/${path6.slice(lastSlash + 1, index)}`;
|
|
2613
2622
|
} else {
|
|
2614
|
-
res =
|
|
2623
|
+
res = path6.slice(lastSlash + 1, index);
|
|
2615
2624
|
}
|
|
2616
2625
|
lastSegmentLength = index - lastSlash - 1;
|
|
2617
2626
|
}
|
|
@@ -2629,7 +2638,7 @@ __name(normalizeString, "normalizeString");
|
|
|
2629
2638
|
|
|
2630
2639
|
// src/prisma-generator.ts
|
|
2631
2640
|
var import_pluralize = __toESM(require_pluralize(), 1);
|
|
2632
|
-
import
|
|
2641
|
+
import path5 from "node:path";
|
|
2633
2642
|
|
|
2634
2643
|
// src/config.ts
|
|
2635
2644
|
init_esm_shims();
|
|
@@ -2996,8 +3005,8 @@ function getErrorMap() {
|
|
|
2996
3005
|
}
|
|
2997
3006
|
__name(getErrorMap, "getErrorMap");
|
|
2998
3007
|
var makeIssue = /* @__PURE__ */ __name((params) => {
|
|
2999
|
-
const { data, path:
|
|
3000
|
-
const fullPath = [...
|
|
3008
|
+
const { data, path: path6, errorMaps, issueData } = params;
|
|
3009
|
+
const fullPath = [...path6, ...issueData.path || []];
|
|
3001
3010
|
const fullIssue = {
|
|
3002
3011
|
...issueData,
|
|
3003
3012
|
path: fullPath
|
|
@@ -3131,11 +3140,11 @@ var ParseInputLazyPath = class {
|
|
|
3131
3140
|
static {
|
|
3132
3141
|
__name(this, "ParseInputLazyPath");
|
|
3133
3142
|
}
|
|
3134
|
-
constructor(parent, value,
|
|
3143
|
+
constructor(parent, value, path6, key) {
|
|
3135
3144
|
this._cachedPath = [];
|
|
3136
3145
|
this.parent = parent;
|
|
3137
3146
|
this.data = value;
|
|
3138
|
-
this._path =
|
|
3147
|
+
this._path = path6;
|
|
3139
3148
|
this._key = key;
|
|
3140
3149
|
}
|
|
3141
3150
|
get path() {
|
|
@@ -7120,34 +7129,34 @@ __name2(normalizeWindowsPath2, "normalizeWindowsPath");
|
|
|
7120
7129
|
var _UNC_REGEX2 = /^[/\\]{2}/;
|
|
7121
7130
|
var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
7122
7131
|
var _DRIVE_LETTER_RE2 = /^[A-Za-z]:$/;
|
|
7123
|
-
var correctPaths2 = /* @__PURE__ */ __name2(function(
|
|
7124
|
-
if (!
|
|
7132
|
+
var correctPaths2 = /* @__PURE__ */ __name2(function(path6) {
|
|
7133
|
+
if (!path6 || path6.length === 0) {
|
|
7125
7134
|
return ".";
|
|
7126
7135
|
}
|
|
7127
|
-
|
|
7128
|
-
const isUNCPath =
|
|
7129
|
-
const isPathAbsolute = isAbsolute2(
|
|
7130
|
-
const trailingSeparator =
|
|
7131
|
-
|
|
7132
|
-
if (
|
|
7136
|
+
path6 = normalizeWindowsPath2(path6);
|
|
7137
|
+
const isUNCPath = path6.match(_UNC_REGEX2);
|
|
7138
|
+
const isPathAbsolute = isAbsolute2(path6);
|
|
7139
|
+
const trailingSeparator = path6[path6.length - 1] === "/";
|
|
7140
|
+
path6 = normalizeString2(path6, !isPathAbsolute);
|
|
7141
|
+
if (path6.length === 0) {
|
|
7133
7142
|
if (isPathAbsolute) {
|
|
7134
7143
|
return "/";
|
|
7135
7144
|
}
|
|
7136
7145
|
return trailingSeparator ? "./" : ".";
|
|
7137
7146
|
}
|
|
7138
7147
|
if (trailingSeparator) {
|
|
7139
|
-
|
|
7148
|
+
path6 += "/";
|
|
7140
7149
|
}
|
|
7141
|
-
if (_DRIVE_LETTER_RE2.test(
|
|
7142
|
-
|
|
7150
|
+
if (_DRIVE_LETTER_RE2.test(path6)) {
|
|
7151
|
+
path6 += "/";
|
|
7143
7152
|
}
|
|
7144
7153
|
if (isUNCPath) {
|
|
7145
7154
|
if (!isPathAbsolute) {
|
|
7146
|
-
return `//./${
|
|
7155
|
+
return `//./${path6}`;
|
|
7147
7156
|
}
|
|
7148
|
-
return `//${
|
|
7157
|
+
return `//${path6}`;
|
|
7149
7158
|
}
|
|
7150
|
-
return isPathAbsolute && !isAbsolute2(
|
|
7159
|
+
return isPathAbsolute && !isAbsolute2(path6) ? `/${path6}` : path6;
|
|
7151
7160
|
}, "correctPaths");
|
|
7152
7161
|
function cwd() {
|
|
7153
7162
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
@@ -7157,15 +7166,15 @@ function cwd() {
|
|
|
7157
7166
|
}
|
|
7158
7167
|
__name(cwd, "cwd");
|
|
7159
7168
|
__name2(cwd, "cwd");
|
|
7160
|
-
function normalizeString2(
|
|
7169
|
+
function normalizeString2(path6, allowAboveRoot) {
|
|
7161
7170
|
let res = "";
|
|
7162
7171
|
let lastSegmentLength = 0;
|
|
7163
7172
|
let lastSlash = -1;
|
|
7164
7173
|
let dots = 0;
|
|
7165
7174
|
let char = null;
|
|
7166
|
-
for (let index = 0; index <=
|
|
7167
|
-
if (index <
|
|
7168
|
-
char =
|
|
7175
|
+
for (let index = 0; index <= path6.length; ++index) {
|
|
7176
|
+
if (index < path6.length) {
|
|
7177
|
+
char = path6[index];
|
|
7169
7178
|
} else if (char === "/") {
|
|
7170
7179
|
break;
|
|
7171
7180
|
} else {
|
|
@@ -7201,9 +7210,9 @@ function normalizeString2(path7, allowAboveRoot) {
|
|
|
7201
7210
|
}
|
|
7202
7211
|
} else {
|
|
7203
7212
|
if (res.length > 0) {
|
|
7204
|
-
res += `/${
|
|
7213
|
+
res += `/${path6.slice(lastSlash + 1, index)}`;
|
|
7205
7214
|
} else {
|
|
7206
|
-
res =
|
|
7215
|
+
res = path6.slice(lastSlash + 1, index);
|
|
7207
7216
|
}
|
|
7208
7217
|
lastSegmentLength = index - lastSlash - 1;
|
|
7209
7218
|
}
|
|
@@ -7303,20 +7312,20 @@ init_esm_shims();
|
|
|
7303
7312
|
// ../path/src/is-file.ts
|
|
7304
7313
|
init_esm_shims();
|
|
7305
7314
|
import { lstatSync, statSync } from "node:fs";
|
|
7306
|
-
function isFile(
|
|
7307
|
-
return Boolean(statSync(additionalPath ? joinPaths(additionalPath,
|
|
7315
|
+
function isFile(path6, additionalPath) {
|
|
7316
|
+
return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path6) : path6, {
|
|
7308
7317
|
throwIfNoEntry: false
|
|
7309
7318
|
})?.isFile());
|
|
7310
7319
|
}
|
|
7311
7320
|
__name(isFile, "isFile");
|
|
7312
|
-
function isDirectory(
|
|
7313
|
-
return Boolean(statSync(additionalPath ? joinPaths(additionalPath,
|
|
7321
|
+
function isDirectory(path6, additionalPath) {
|
|
7322
|
+
return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path6) : path6, {
|
|
7314
7323
|
throwIfNoEntry: false
|
|
7315
7324
|
})?.isDirectory());
|
|
7316
7325
|
}
|
|
7317
7326
|
__name(isDirectory, "isDirectory");
|
|
7318
|
-
function isAbsolutePath(
|
|
7319
|
-
return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(
|
|
7327
|
+
function isAbsolutePath(path6) {
|
|
7328
|
+
return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path6);
|
|
7320
7329
|
}
|
|
7321
7330
|
__name(isAbsolutePath, "isAbsolutePath");
|
|
7322
7331
|
|
|
@@ -7331,45 +7340,45 @@ function normalizeWindowsPath3(input = "") {
|
|
|
7331
7340
|
__name(normalizeWindowsPath3, "normalizeWindowsPath");
|
|
7332
7341
|
var _UNC_REGEX3 = /^[/\\]{2}/;
|
|
7333
7342
|
var _DRIVE_LETTER_RE3 = /^[A-Z]:$/i;
|
|
7334
|
-
function correctPath(
|
|
7335
|
-
if (!
|
|
7343
|
+
function correctPath(path6) {
|
|
7344
|
+
if (!path6 || path6.length === 0) {
|
|
7336
7345
|
return ".";
|
|
7337
7346
|
}
|
|
7338
|
-
|
|
7339
|
-
const isUNCPath =
|
|
7340
|
-
const isPathAbsolute = isAbsolutePath(
|
|
7341
|
-
const trailingSeparator =
|
|
7342
|
-
|
|
7343
|
-
if (
|
|
7347
|
+
path6 = normalizeWindowsPath3(path6);
|
|
7348
|
+
const isUNCPath = path6.match(_UNC_REGEX3);
|
|
7349
|
+
const isPathAbsolute = isAbsolutePath(path6);
|
|
7350
|
+
const trailingSeparator = path6[path6.length - 1] === "/";
|
|
7351
|
+
path6 = normalizeString3(path6, !isPathAbsolute);
|
|
7352
|
+
if (path6.length === 0) {
|
|
7344
7353
|
if (isPathAbsolute) {
|
|
7345
7354
|
return "/";
|
|
7346
7355
|
}
|
|
7347
7356
|
return trailingSeparator ? "./" : ".";
|
|
7348
7357
|
}
|
|
7349
7358
|
if (trailingSeparator) {
|
|
7350
|
-
|
|
7359
|
+
path6 += "/";
|
|
7351
7360
|
}
|
|
7352
|
-
if (_DRIVE_LETTER_RE3.test(
|
|
7353
|
-
|
|
7361
|
+
if (_DRIVE_LETTER_RE3.test(path6)) {
|
|
7362
|
+
path6 += "/";
|
|
7354
7363
|
}
|
|
7355
7364
|
if (isUNCPath) {
|
|
7356
7365
|
if (!isPathAbsolute) {
|
|
7357
|
-
return `//./${
|
|
7366
|
+
return `//./${path6}`;
|
|
7358
7367
|
}
|
|
7359
|
-
return `//${
|
|
7368
|
+
return `//${path6}`;
|
|
7360
7369
|
}
|
|
7361
|
-
return isPathAbsolute && !isAbsolutePath(
|
|
7370
|
+
return isPathAbsolute && !isAbsolutePath(path6) ? `/${path6}` : path6;
|
|
7362
7371
|
}
|
|
7363
7372
|
__name(correctPath, "correctPath");
|
|
7364
|
-
function normalizeString3(
|
|
7373
|
+
function normalizeString3(path6, allowAboveRoot) {
|
|
7365
7374
|
let res = "";
|
|
7366
7375
|
let lastSegmentLength = 0;
|
|
7367
7376
|
let lastSlash = -1;
|
|
7368
7377
|
let dots = 0;
|
|
7369
7378
|
let char = null;
|
|
7370
|
-
for (let index = 0; index <=
|
|
7371
|
-
if (index <
|
|
7372
|
-
char =
|
|
7379
|
+
for (let index = 0; index <= path6.length; ++index) {
|
|
7380
|
+
if (index < path6.length) {
|
|
7381
|
+
char = path6[index];
|
|
7373
7382
|
} else if (char === "/") {
|
|
7374
7383
|
break;
|
|
7375
7384
|
} else {
|
|
@@ -7405,9 +7414,9 @@ function normalizeString3(path7, allowAboveRoot) {
|
|
|
7405
7414
|
}
|
|
7406
7415
|
} else {
|
|
7407
7416
|
if (res.length > 0) {
|
|
7408
|
-
res += `/${
|
|
7417
|
+
res += `/${path6.slice(lastSlash + 1, index)}`;
|
|
7409
7418
|
} else {
|
|
7410
|
-
res =
|
|
7419
|
+
res = path6.slice(lastSlash + 1, index);
|
|
7411
7420
|
}
|
|
7412
7421
|
lastSegmentLength = index - lastSlash - 1;
|
|
7413
7422
|
}
|
|
@@ -7442,17 +7451,17 @@ function findFilePath(filePath) {
|
|
|
7442
7451
|
}), "");
|
|
7443
7452
|
}
|
|
7444
7453
|
__name(findFilePath, "findFilePath");
|
|
7445
|
-
function resolvePath(
|
|
7446
|
-
const paths = normalizeWindowsPath3(
|
|
7454
|
+
function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
|
|
7455
|
+
const paths = normalizeWindowsPath3(path6).split("/");
|
|
7447
7456
|
let resolvedPath = "";
|
|
7448
7457
|
let resolvedAbsolute = false;
|
|
7449
7458
|
for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
7450
|
-
const
|
|
7451
|
-
if (!
|
|
7459
|
+
const path7 = index >= 0 ? paths[index] : cwd2;
|
|
7460
|
+
if (!path7 || path7.length === 0) {
|
|
7452
7461
|
continue;
|
|
7453
7462
|
}
|
|
7454
|
-
resolvedPath = joinPaths(
|
|
7455
|
-
resolvedAbsolute = isAbsolutePath(
|
|
7463
|
+
resolvedPath = joinPaths(path7, resolvedPath);
|
|
7464
|
+
resolvedAbsolute = isAbsolutePath(path7);
|
|
7456
7465
|
}
|
|
7457
7466
|
resolvedPath = normalizeString3(resolvedPath, !resolvedAbsolute);
|
|
7458
7467
|
if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {
|
|
@@ -7462,13 +7471,13 @@ function resolvePath(path7, cwd2 = getWorkspaceRoot()) {
|
|
|
7462
7471
|
}
|
|
7463
7472
|
__name(resolvePath, "resolvePath");
|
|
7464
7473
|
function resolvePaths(...paths) {
|
|
7465
|
-
return resolvePath(joinPaths(...paths.map((
|
|
7474
|
+
return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath3(path6))));
|
|
7466
7475
|
}
|
|
7467
7476
|
__name(resolvePaths, "resolvePaths");
|
|
7468
7477
|
|
|
7469
7478
|
// ../path/src/get-parent-path.ts
|
|
7470
|
-
var resolveParentPath = /* @__PURE__ */ __name((
|
|
7471
|
-
return resolvePaths(
|
|
7479
|
+
var resolveParentPath = /* @__PURE__ */ __name((path6) => {
|
|
7480
|
+
return resolvePaths(path6, "..");
|
|
7472
7481
|
}, "resolveParentPath");
|
|
7473
7482
|
var getParentPath = /* @__PURE__ */ __name((name, cwd2, options) => {
|
|
7474
7483
|
const ignoreCase = options?.ignoreCase ?? true;
|
|
@@ -7965,24 +7974,6 @@ var project = new Project({
|
|
|
7965
7974
|
}
|
|
7966
7975
|
});
|
|
7967
7976
|
|
|
7968
|
-
// src/utils/remove-dir.ts
|
|
7969
|
-
init_esm_shims();
|
|
7970
|
-
import { promises as fs } from "node:fs";
|
|
7971
|
-
import path3 from "node:path";
|
|
7972
|
-
async function removeDir(dirPath, onlyContent) {
|
|
7973
|
-
const dirEntries = await fs.readdir(dirPath, {
|
|
7974
|
-
withFileTypes: true
|
|
7975
|
-
});
|
|
7976
|
-
await Promise.all(dirEntries.map(async (dirEntry) => {
|
|
7977
|
-
const fullPath = path3.join(dirPath, dirEntry.name);
|
|
7978
|
-
return dirEntry.isDirectory() ? removeDir(fullPath, false) : fs.unlink(fullPath);
|
|
7979
|
-
}));
|
|
7980
|
-
if (!onlyContent) {
|
|
7981
|
-
await fs.rmdir(dirPath);
|
|
7982
|
-
}
|
|
7983
|
-
}
|
|
7984
|
-
__name(removeDir, "removeDir");
|
|
7985
|
-
|
|
7986
7977
|
// src/utils/write-file-safely.ts
|
|
7987
7978
|
init_esm_shims();
|
|
7988
7979
|
|
|
@@ -9171,7 +9162,7 @@ var isURL = /* @__PURE__ */ __name((payload) => payload instanceof URL, "isURL")
|
|
|
9171
9162
|
// ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.js
|
|
9172
9163
|
init_esm_shims();
|
|
9173
9164
|
var escapeKey = /* @__PURE__ */ __name((key) => key.replace(/\./g, "\\."), "escapeKey");
|
|
9174
|
-
var stringifyPath = /* @__PURE__ */ __name((
|
|
9165
|
+
var stringifyPath = /* @__PURE__ */ __name((path6) => path6.map(String).map(escapeKey).join("."), "stringifyPath");
|
|
9175
9166
|
var parsePath = /* @__PURE__ */ __name((string) => {
|
|
9176
9167
|
const result = [];
|
|
9177
9168
|
let segment = "";
|
|
@@ -9434,27 +9425,27 @@ var getNthKey = /* @__PURE__ */ __name((value, n) => {
|
|
|
9434
9425
|
}
|
|
9435
9426
|
return keys.next().value;
|
|
9436
9427
|
}, "getNthKey");
|
|
9437
|
-
function validatePath(
|
|
9438
|
-
if (includes(
|
|
9428
|
+
function validatePath(path6) {
|
|
9429
|
+
if (includes(path6, "__proto__")) {
|
|
9439
9430
|
throw new Error("__proto__ is not allowed as a property");
|
|
9440
9431
|
}
|
|
9441
|
-
if (includes(
|
|
9432
|
+
if (includes(path6, "prototype")) {
|
|
9442
9433
|
throw new Error("prototype is not allowed as a property");
|
|
9443
9434
|
}
|
|
9444
|
-
if (includes(
|
|
9435
|
+
if (includes(path6, "constructor")) {
|
|
9445
9436
|
throw new Error("constructor is not allowed as a property");
|
|
9446
9437
|
}
|
|
9447
9438
|
}
|
|
9448
9439
|
__name(validatePath, "validatePath");
|
|
9449
|
-
var getDeep = /* @__PURE__ */ __name((object,
|
|
9450
|
-
validatePath(
|
|
9451
|
-
for (let i = 0; i <
|
|
9452
|
-
const key =
|
|
9440
|
+
var getDeep = /* @__PURE__ */ __name((object, path6) => {
|
|
9441
|
+
validatePath(path6);
|
|
9442
|
+
for (let i = 0; i < path6.length; i++) {
|
|
9443
|
+
const key = path6[i];
|
|
9453
9444
|
if (isSet(object)) {
|
|
9454
9445
|
object = getNthKey(object, +key);
|
|
9455
9446
|
} else if (isMap(object)) {
|
|
9456
9447
|
const row = +key;
|
|
9457
|
-
const type = +
|
|
9448
|
+
const type = +path6[++i] === 0 ? "key" : "value";
|
|
9458
9449
|
const keyOfRow = getNthKey(object, row);
|
|
9459
9450
|
switch (type) {
|
|
9460
9451
|
case "key":
|
|
@@ -9470,14 +9461,14 @@ var getDeep = /* @__PURE__ */ __name((object, path7) => {
|
|
|
9470
9461
|
}
|
|
9471
9462
|
return object;
|
|
9472
9463
|
}, "getDeep");
|
|
9473
|
-
var setDeep = /* @__PURE__ */ __name((object,
|
|
9474
|
-
validatePath(
|
|
9475
|
-
if (
|
|
9464
|
+
var setDeep = /* @__PURE__ */ __name((object, path6, mapper) => {
|
|
9465
|
+
validatePath(path6);
|
|
9466
|
+
if (path6.length === 0) {
|
|
9476
9467
|
return mapper(object);
|
|
9477
9468
|
}
|
|
9478
9469
|
let parent = object;
|
|
9479
|
-
for (let i = 0; i <
|
|
9480
|
-
const key =
|
|
9470
|
+
for (let i = 0; i < path6.length - 1; i++) {
|
|
9471
|
+
const key = path6[i];
|
|
9481
9472
|
if (isArray(parent)) {
|
|
9482
9473
|
const index = +key;
|
|
9483
9474
|
parent = parent[index];
|
|
@@ -9487,12 +9478,12 @@ var setDeep = /* @__PURE__ */ __name((object, path7, mapper) => {
|
|
|
9487
9478
|
const row = +key;
|
|
9488
9479
|
parent = getNthKey(parent, row);
|
|
9489
9480
|
} else if (isMap(parent)) {
|
|
9490
|
-
const isEnd = i ===
|
|
9481
|
+
const isEnd = i === path6.length - 2;
|
|
9491
9482
|
if (isEnd) {
|
|
9492
9483
|
break;
|
|
9493
9484
|
}
|
|
9494
9485
|
const row = +key;
|
|
9495
|
-
const type = +
|
|
9486
|
+
const type = +path6[++i] === 0 ? "key" : "value";
|
|
9496
9487
|
const keyOfRow = getNthKey(parent, row);
|
|
9497
9488
|
switch (type) {
|
|
9498
9489
|
case "key":
|
|
@@ -9504,7 +9495,7 @@ var setDeep = /* @__PURE__ */ __name((object, path7, mapper) => {
|
|
|
9504
9495
|
}
|
|
9505
9496
|
}
|
|
9506
9497
|
}
|
|
9507
|
-
const lastKey =
|
|
9498
|
+
const lastKey = path6[path6.length - 1];
|
|
9508
9499
|
if (isArray(parent)) {
|
|
9509
9500
|
parent[+lastKey] = mapper(parent[+lastKey]);
|
|
9510
9501
|
} else if (isPlainObject2(parent)) {
|
|
@@ -9519,7 +9510,7 @@ var setDeep = /* @__PURE__ */ __name((object, path7, mapper) => {
|
|
|
9519
9510
|
}
|
|
9520
9511
|
}
|
|
9521
9512
|
if (isMap(parent)) {
|
|
9522
|
-
const row = +
|
|
9513
|
+
const row = +path6[path6.length - 2];
|
|
9523
9514
|
const keyToRow = getNthKey(parent, row);
|
|
9524
9515
|
const type = +lastKey === 0 ? "key" : "value";
|
|
9525
9516
|
switch (type) {
|
|
@@ -9565,15 +9556,15 @@ function traverse(tree, walker2, origin = []) {
|
|
|
9565
9556
|
}
|
|
9566
9557
|
__name(traverse, "traverse");
|
|
9567
9558
|
function applyValueAnnotations(plain, annotations, superJson) {
|
|
9568
|
-
traverse(annotations, (type,
|
|
9569
|
-
plain = setDeep(plain,
|
|
9559
|
+
traverse(annotations, (type, path6) => {
|
|
9560
|
+
plain = setDeep(plain, path6, (v) => untransformValue(v, type, superJson));
|
|
9570
9561
|
});
|
|
9571
9562
|
return plain;
|
|
9572
9563
|
}
|
|
9573
9564
|
__name(applyValueAnnotations, "applyValueAnnotations");
|
|
9574
9565
|
function applyReferentialEqualityAnnotations(plain, annotations) {
|
|
9575
|
-
function apply(identicalPaths,
|
|
9576
|
-
const object = getDeep(plain, parsePath(
|
|
9566
|
+
function apply(identicalPaths, path6) {
|
|
9567
|
+
const object = getDeep(plain, parsePath(path6));
|
|
9577
9568
|
identicalPaths.map(parsePath).forEach((identicalObjectPath) => {
|
|
9578
9569
|
plain = setDeep(plain, identicalObjectPath, () => object);
|
|
9579
9570
|
});
|
|
@@ -9594,13 +9585,13 @@ function applyReferentialEqualityAnnotations(plain, annotations) {
|
|
|
9594
9585
|
}
|
|
9595
9586
|
__name(applyReferentialEqualityAnnotations, "applyReferentialEqualityAnnotations");
|
|
9596
9587
|
var isDeep = /* @__PURE__ */ __name((object, superJson) => isPlainObject2(object) || isArray(object) || isMap(object) || isSet(object) || isInstanceOfRegisteredClass(object, superJson), "isDeep");
|
|
9597
|
-
function addIdentity(object,
|
|
9588
|
+
function addIdentity(object, path6, identities) {
|
|
9598
9589
|
const existingSet = identities.get(object);
|
|
9599
9590
|
if (existingSet) {
|
|
9600
|
-
existingSet.push(
|
|
9591
|
+
existingSet.push(path6);
|
|
9601
9592
|
} else {
|
|
9602
9593
|
identities.set(object, [
|
|
9603
|
-
|
|
9594
|
+
path6
|
|
9604
9595
|
]);
|
|
9605
9596
|
}
|
|
9606
9597
|
}
|
|
@@ -9613,7 +9604,7 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
|
|
9613
9604
|
return;
|
|
9614
9605
|
}
|
|
9615
9606
|
if (!dedupe) {
|
|
9616
|
-
paths = paths.map((
|
|
9607
|
+
paths = paths.map((path6) => path6.map(String)).sort((a, b) => a.length - b.length);
|
|
9617
9608
|
}
|
|
9618
9609
|
const [representativePath, ...identicalPaths] = paths;
|
|
9619
9610
|
if (representativePath.length === 0) {
|
|
@@ -9638,10 +9629,10 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
|
|
9638
9629
|
}
|
|
9639
9630
|
}
|
|
9640
9631
|
__name(generateReferentialEqualityAnnotations, "generateReferentialEqualityAnnotations");
|
|
9641
|
-
var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe,
|
|
9632
|
+
var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path6 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
|
|
9642
9633
|
const primitive = isPrimitive(object);
|
|
9643
9634
|
if (!primitive) {
|
|
9644
|
-
addIdentity(object,
|
|
9635
|
+
addIdentity(object, path6, identities);
|
|
9645
9636
|
const seen = seenObjects.get(object);
|
|
9646
9637
|
if (seen) {
|
|
9647
9638
|
return dedupe ? {
|
|
@@ -9678,7 +9669,7 @@ var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path
|
|
|
9678
9669
|
throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
|
|
9679
9670
|
}
|
|
9680
9671
|
const recursiveResult = walker(value, identities, superJson, dedupe, [
|
|
9681
|
-
...
|
|
9672
|
+
...path6,
|
|
9682
9673
|
index
|
|
9683
9674
|
], [
|
|
9684
9675
|
...objectsInThisPath,
|
|
@@ -10258,7 +10249,7 @@ var writeFile = /* @__PURE__ */ __name(async (filePath, content, options) => {
|
|
|
10258
10249
|
}, "writeFile");
|
|
10259
10250
|
|
|
10260
10251
|
// src/utils/write-file-safely.ts
|
|
10261
|
-
import
|
|
10252
|
+
import path3 from "node:path";
|
|
10262
10253
|
|
|
10263
10254
|
// src/utils/format-file.ts
|
|
10264
10255
|
init_esm_shims();
|
|
@@ -10302,7 +10293,7 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
|
|
|
10302
10293
|
}, "writeFileSafely");
|
|
10303
10294
|
var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
|
|
10304
10295
|
const rows = Array.from(indexExports).map((filePath) => {
|
|
10305
|
-
let relativePath =
|
|
10296
|
+
let relativePath = path3.relative(path3.dirname(indexPath), filePath);
|
|
10306
10297
|
if (relativePath.endsWith(".ts")) {
|
|
10307
10298
|
relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
|
|
10308
10299
|
}
|
|
@@ -10479,7 +10470,7 @@ init_esm_shims();
|
|
|
10479
10470
|
|
|
10480
10471
|
// src/zod-helpers/transformer.ts
|
|
10481
10472
|
init_esm_shims();
|
|
10482
|
-
import
|
|
10473
|
+
import path4 from "node:path";
|
|
10483
10474
|
|
|
10484
10475
|
// src/zod-helpers/model-helpers.ts
|
|
10485
10476
|
init_esm_shims();
|
|
@@ -10627,13 +10618,13 @@ var Transformer = class _Transformer {
|
|
|
10627
10618
|
this.isCustomPrismaClientOutputPath = prismaClientCustomPath !== "@prisma/client";
|
|
10628
10619
|
}
|
|
10629
10620
|
static async generateIndex() {
|
|
10630
|
-
const indexPath =
|
|
10621
|
+
const indexPath = path4.join(_Transformer.outputPath, "schemas/index.ts");
|
|
10631
10622
|
await writeIndexFile(indexPath);
|
|
10632
10623
|
}
|
|
10633
10624
|
async generateEnumSchemas() {
|
|
10634
10625
|
for (const enumType2 of this.enumTypes) {
|
|
10635
10626
|
const { name, values } = enumType2;
|
|
10636
|
-
await writeFileSafely(
|
|
10627
|
+
await writeFileSafely(path4.join(_Transformer.outputPath, `schemas/enums/${name}.schema.ts`), `${this.generateImportZodStatement()}
|
|
10637
10628
|
${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)})`)}`);
|
|
10638
10629
|
}
|
|
10639
10630
|
}
|
|
@@ -10647,7 +10638,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10647
10638
|
const zodObjectSchemaFields = this.generateObjectSchemaFields();
|
|
10648
10639
|
const objectSchema = this.prepareObjectSchema(zodObjectSchemaFields);
|
|
10649
10640
|
const objectSchemaName = this.resolveObjectSchemaName();
|
|
10650
|
-
await writeFileSafely(
|
|
10641
|
+
await writeFileSafely(path4.join(_Transformer.outputPath, `schemas/objects/${objectSchemaName}.schema.ts`), objectSchema);
|
|
10651
10642
|
}
|
|
10652
10643
|
generateObjectSchemaFields() {
|
|
10653
10644
|
const zodObjectSchemaFields = this.fields.map((field) => this.generateObjectSchemaField(field)).flatMap((item) => item).map((item) => {
|
|
@@ -10786,9 +10777,9 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10786
10777
|
generateImportPrismaStatement() {
|
|
10787
10778
|
let prismaClientImportPath;
|
|
10788
10779
|
if (_Transformer.isCustomPrismaClientOutputPath) {
|
|
10789
|
-
const fromPath =
|
|
10780
|
+
const fromPath = path4.join(_Transformer.outputPath, "schemas", "objects");
|
|
10790
10781
|
const toPath = _Transformer.prismaClientOutputPath;
|
|
10791
|
-
const relativePathFromOutputToPrismaClient =
|
|
10782
|
+
const relativePathFromOutputToPrismaClient = path4.relative(fromPath, toPath).split(path4.sep).join(path4.posix.sep);
|
|
10792
10783
|
prismaClientImportPath = relativePathFromOutputToPrismaClient;
|
|
10793
10784
|
} else {
|
|
10794
10785
|
prismaClientImportPath = _Transformer.prismaClientOutputPath;
|
|
@@ -10916,7 +10907,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10916
10907
|
includeImport,
|
|
10917
10908
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
10918
10909
|
];
|
|
10919
|
-
await writeFileSafely(
|
|
10910
|
+
await writeFileSafely(path4.join(_Transformer.outputPath, `schemas/${findUnique}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindUnique`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
|
|
10920
10911
|
}
|
|
10921
10912
|
if (findFirst) {
|
|
10922
10913
|
const imports = [
|
|
@@ -10927,7 +10918,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10927
10918
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
10928
10919
|
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
10929
10920
|
];
|
|
10930
|
-
await writeFileSafely(
|
|
10921
|
+
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() })`)}`);
|
|
10931
10922
|
}
|
|
10932
10923
|
if (findMany) {
|
|
10933
10924
|
const imports = [
|
|
@@ -10938,7 +10929,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10938
10929
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
10939
10930
|
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
10940
10931
|
];
|
|
10941
|
-
await writeFileSafely(
|
|
10932
|
+
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() })`)}`);
|
|
10942
10933
|
}
|
|
10943
10934
|
if (createOne) {
|
|
10944
10935
|
const imports = [
|
|
@@ -10947,13 +10938,13 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10947
10938
|
`import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
|
|
10948
10939
|
`import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`
|
|
10949
10940
|
];
|
|
10950
|
-
await writeFileSafely(
|
|
10941
|
+
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]) })`)}`);
|
|
10951
10942
|
}
|
|
10952
10943
|
if (createMany) {
|
|
10953
10944
|
const imports = [
|
|
10954
10945
|
`import { ${modelName}CreateManyInputObjectSchema } from './objects/${modelName}CreateManyInput.schema'`
|
|
10955
10946
|
];
|
|
10956
|
-
await writeFileSafely(
|
|
10947
|
+
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()"} })`)}`);
|
|
10957
10948
|
}
|
|
10958
10949
|
if (deleteOne) {
|
|
10959
10950
|
const imports = [
|
|
@@ -10961,13 +10952,13 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10961
10952
|
includeImport,
|
|
10962
10953
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
10963
10954
|
];
|
|
10964
|
-
await writeFileSafely(
|
|
10955
|
+
await writeFileSafely(path4.join(_Transformer.outputPath, `schemas/${deleteOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
|
|
10965
10956
|
}
|
|
10966
10957
|
if (deleteMany) {
|
|
10967
10958
|
const imports = [
|
|
10968
10959
|
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
|
|
10969
10960
|
];
|
|
10970
|
-
await writeFileSafely(
|
|
10961
|
+
await writeFileSafely(path4.join(_Transformer.outputPath, `schemas/${deleteMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteMany`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
|
|
10971
10962
|
}
|
|
10972
10963
|
if (updateOne) {
|
|
10973
10964
|
const imports = [
|
|
@@ -10977,14 +10968,14 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10977
10968
|
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`,
|
|
10978
10969
|
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
10979
10970
|
];
|
|
10980
|
-
await writeFileSafely(
|
|
10971
|
+
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 })`)}`);
|
|
10981
10972
|
}
|
|
10982
10973
|
if (updateMany) {
|
|
10983
10974
|
const imports = [
|
|
10984
10975
|
`import { ${modelName}UpdateManyMutationInputObjectSchema } from './objects/${modelName}UpdateManyMutationInput.schema'`,
|
|
10985
10976
|
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
|
|
10986
10977
|
];
|
|
10987
|
-
await writeFileSafely(
|
|
10978
|
+
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() })`)}`);
|
|
10988
10979
|
}
|
|
10989
10980
|
if (upsertOne) {
|
|
10990
10981
|
const imports = [
|
|
@@ -10996,7 +10987,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
10996
10987
|
`import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
|
|
10997
10988
|
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`
|
|
10998
10989
|
];
|
|
10999
|
-
await writeFileSafely(
|
|
10990
|
+
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 ]) })`)}`);
|
|
11000
10991
|
}
|
|
11001
10992
|
if (aggregate) {
|
|
11002
10993
|
const imports = [
|
|
@@ -11027,7 +11018,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11027
11018
|
aggregateOperations.push(`_sum: ${modelName}SumAggregateInputObjectSchema.optional()`);
|
|
11028
11019
|
}
|
|
11029
11020
|
}
|
|
11030
|
-
await writeFileSafely(
|
|
11021
|
+
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(", ")} })`)}`);
|
|
11031
11022
|
}
|
|
11032
11023
|
if (groupBy) {
|
|
11033
11024
|
const imports = [
|
|
@@ -11036,7 +11027,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
|
|
|
11036
11027
|
`import { ${modelName}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${modelName}ScalarWhereWithAggregatesInput.schema'`,
|
|
11037
11028
|
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
11038
11029
|
];
|
|
11039
|
-
await writeFileSafely(
|
|
11030
|
+
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) })`)}`);
|
|
11040
11031
|
}
|
|
11041
11032
|
}
|
|
11042
11033
|
}
|
|
@@ -11487,8 +11478,8 @@ async function generate(options) {
|
|
|
11487
11478
|
}
|
|
11488
11479
|
}, "consoleLog");
|
|
11489
11480
|
consoleLog(`Preparing output directory: ${outputDir}`);
|
|
11481
|
+
await removeDirectory(outputDir);
|
|
11490
11482
|
await createDirectory(outputDir);
|
|
11491
|
-
await removeDir(outputDir, true);
|
|
11492
11483
|
consoleLog("Finding Prisma Client generator");
|
|
11493
11484
|
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
11494
11485
|
if (!prismaClientProvider) {
|
|
@@ -11540,7 +11531,6 @@ async function generate(options) {
|
|
|
11540
11531
|
const shieldOutputDir = joinPaths(outputDir, "shield");
|
|
11541
11532
|
consoleLog("Preparing tRPC Shield output directory");
|
|
11542
11533
|
await createDirectory(shieldOutputDir);
|
|
11543
|
-
await removeDir(shieldOutputDir, true);
|
|
11544
11534
|
const queries = [];
|
|
11545
11535
|
const mutations = [];
|
|
11546
11536
|
const subscriptions = [];
|
|
@@ -11598,7 +11588,7 @@ async function generate(options) {
|
|
|
11598
11588
|
}
|
|
11599
11589
|
consoleLog(`Generating tRPC source code for ${models.length} models`);
|
|
11600
11590
|
resolveModelsComments(models, hiddenModels);
|
|
11601
|
-
const createRouter = project.createSourceFile(
|
|
11591
|
+
const createRouter = project.createSourceFile(path5.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
|
|
11602
11592
|
overwrite: true
|
|
11603
11593
|
});
|
|
11604
11594
|
consoleLog("Generating tRPC imports");
|
|
@@ -11611,7 +11601,7 @@ async function generate(options) {
|
|
|
11611
11601
|
createRouter.formatText({
|
|
11612
11602
|
indentSize: 2
|
|
11613
11603
|
});
|
|
11614
|
-
const appRouter = project.createSourceFile(
|
|
11604
|
+
const appRouter = project.createSourceFile(path5.resolve(outputDir, "routers", `index.ts`), void 0, {
|
|
11615
11605
|
overwrite: true
|
|
11616
11606
|
});
|
|
11617
11607
|
consoleLog("Generating tRPC router imports");
|
|
@@ -11633,7 +11623,7 @@ async function generate(options) {
|
|
|
11633
11623
|
const plural = (0, import_pluralize.default)(model.toLowerCase());
|
|
11634
11624
|
consoleLog(`Generating tRPC router for model ${model}`);
|
|
11635
11625
|
generateRouterImport(appRouter, plural, model);
|
|
11636
|
-
const modelRouter = project.createSourceFile(
|
|
11626
|
+
const modelRouter = project.createSourceFile(path5.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
|
|
11637
11627
|
overwrite: true
|
|
11638
11628
|
});
|
|
11639
11629
|
generateCreateRouterImport({
|