@stryke/prisma-trpc-generator 0.3.1 → 0.3.2
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 +275 -273
- package/dist/generator.js +278 -276
- package/dist/index.cjs +275 -273
- package/dist/index.js +278 -276
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -677,9 +677,160 @@ init_esm_shims();
|
|
|
677
677
|
|
|
678
678
|
// src/prisma-generator.ts
|
|
679
679
|
init_esm_shims();
|
|
680
|
+
|
|
681
|
+
// ../fs/src/helpers.ts
|
|
682
|
+
init_esm_shims();
|
|
683
|
+
|
|
684
|
+
// ../path/src/exists.ts
|
|
685
|
+
init_esm_shims();
|
|
686
|
+
import { access, constants } from "node:fs/promises";
|
|
687
|
+
var exists = /* @__PURE__ */ __name(async (filePath) => {
|
|
688
|
+
return access(filePath, constants.F_OK).then(() => true).catch(() => false);
|
|
689
|
+
}, "exists");
|
|
690
|
+
|
|
691
|
+
// ../fs/src/helpers.ts
|
|
692
|
+
import { mkdir, readFile, rm } from "node:fs/promises";
|
|
693
|
+
async function createDirectory(path6) {
|
|
694
|
+
if (await exists(path6)) {
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
return mkdir(path6, {
|
|
698
|
+
recursive: true
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
__name(createDirectory, "createDirectory");
|
|
702
|
+
|
|
703
|
+
// ../path/src/join-paths.ts
|
|
704
|
+
init_esm_shims();
|
|
705
|
+
var _DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
|
|
706
|
+
function normalizeWindowsPath(input = "") {
|
|
707
|
+
if (!input) {
|
|
708
|
+
return input;
|
|
709
|
+
}
|
|
710
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
711
|
+
}
|
|
712
|
+
__name(normalizeWindowsPath, "normalizeWindowsPath");
|
|
713
|
+
var _UNC_REGEX = /^[/\\]{2}/;
|
|
714
|
+
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
|
|
715
|
+
var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
|
|
716
|
+
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
717
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
718
|
+
}, "isAbsolute");
|
|
719
|
+
var correctPaths = /* @__PURE__ */ __name(function(path6) {
|
|
720
|
+
if (!path6 || path6.length === 0) {
|
|
721
|
+
return ".";
|
|
722
|
+
}
|
|
723
|
+
path6 = normalizeWindowsPath(path6);
|
|
724
|
+
const isUNCPath = path6.match(_UNC_REGEX);
|
|
725
|
+
const isPathAbsolute = isAbsolute(path6);
|
|
726
|
+
const trailingSeparator = path6[path6.length - 1] === "/";
|
|
727
|
+
path6 = normalizeString(path6, !isPathAbsolute);
|
|
728
|
+
if (path6.length === 0) {
|
|
729
|
+
if (isPathAbsolute) {
|
|
730
|
+
return "/";
|
|
731
|
+
}
|
|
732
|
+
return trailingSeparator ? "./" : ".";
|
|
733
|
+
}
|
|
734
|
+
if (trailingSeparator) {
|
|
735
|
+
path6 += "/";
|
|
736
|
+
}
|
|
737
|
+
if (_DRIVE_LETTER_RE.test(path6)) {
|
|
738
|
+
path6 += "/";
|
|
739
|
+
}
|
|
740
|
+
if (isUNCPath) {
|
|
741
|
+
if (!isPathAbsolute) {
|
|
742
|
+
return `//./${path6}`;
|
|
743
|
+
}
|
|
744
|
+
return `//${path6}`;
|
|
745
|
+
}
|
|
746
|
+
return isPathAbsolute && !isAbsolute(path6) ? `/${path6}` : path6;
|
|
747
|
+
}, "correctPaths");
|
|
748
|
+
var joinPaths = /* @__PURE__ */ __name(function(...segments) {
|
|
749
|
+
let path6 = "";
|
|
750
|
+
for (const seg of segments) {
|
|
751
|
+
if (!seg) {
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
754
|
+
if (path6.length > 0) {
|
|
755
|
+
const pathTrailing = path6[path6.length - 1] === "/";
|
|
756
|
+
const segLeading = seg[0] === "/";
|
|
757
|
+
const both = pathTrailing && segLeading;
|
|
758
|
+
if (both) {
|
|
759
|
+
path6 += seg.slice(1);
|
|
760
|
+
} else {
|
|
761
|
+
path6 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
762
|
+
}
|
|
763
|
+
} else {
|
|
764
|
+
path6 += seg;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
return correctPaths(path6);
|
|
768
|
+
}, "joinPaths");
|
|
769
|
+
function normalizeString(path6, allowAboveRoot) {
|
|
770
|
+
let res = "";
|
|
771
|
+
let lastSegmentLength = 0;
|
|
772
|
+
let lastSlash = -1;
|
|
773
|
+
let dots = 0;
|
|
774
|
+
let char = null;
|
|
775
|
+
for (let index = 0; index <= path6.length; ++index) {
|
|
776
|
+
if (index < path6.length) {
|
|
777
|
+
char = path6[index];
|
|
778
|
+
} else if (char === "/") {
|
|
779
|
+
break;
|
|
780
|
+
} else {
|
|
781
|
+
char = "/";
|
|
782
|
+
}
|
|
783
|
+
if (char === "/") {
|
|
784
|
+
if (lastSlash === index - 1 || dots === 1) {
|
|
785
|
+
} else if (dots === 2) {
|
|
786
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
787
|
+
if (res.length > 2) {
|
|
788
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
789
|
+
if (lastSlashIndex === -1) {
|
|
790
|
+
res = "";
|
|
791
|
+
lastSegmentLength = 0;
|
|
792
|
+
} else {
|
|
793
|
+
res = res.slice(0, lastSlashIndex);
|
|
794
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
795
|
+
}
|
|
796
|
+
lastSlash = index;
|
|
797
|
+
dots = 0;
|
|
798
|
+
continue;
|
|
799
|
+
} else if (res.length > 0) {
|
|
800
|
+
res = "";
|
|
801
|
+
lastSegmentLength = 0;
|
|
802
|
+
lastSlash = index;
|
|
803
|
+
dots = 0;
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
if (allowAboveRoot) {
|
|
808
|
+
res += res.length > 0 ? "/.." : "..";
|
|
809
|
+
lastSegmentLength = 2;
|
|
810
|
+
}
|
|
811
|
+
} else {
|
|
812
|
+
if (res.length > 0) {
|
|
813
|
+
res += `/${path6.slice(lastSlash + 1, index)}`;
|
|
814
|
+
} else {
|
|
815
|
+
res = path6.slice(lastSlash + 1, index);
|
|
816
|
+
}
|
|
817
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
818
|
+
}
|
|
819
|
+
lastSlash = index;
|
|
820
|
+
dots = 0;
|
|
821
|
+
} else if (char === "." && dots !== -1) {
|
|
822
|
+
++dots;
|
|
823
|
+
} else {
|
|
824
|
+
dots = -1;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return res;
|
|
828
|
+
}
|
|
829
|
+
__name(normalizeString, "normalizeString");
|
|
830
|
+
|
|
831
|
+
// src/prisma-generator.ts
|
|
680
832
|
var import_pluralize = __toESM(require_pluralize(), 1);
|
|
681
|
-
import
|
|
682
|
-
import path6 from "node:path";
|
|
833
|
+
import path5 from "node:path";
|
|
683
834
|
|
|
684
835
|
// src/config.ts
|
|
685
836
|
init_esm_shims();
|
|
@@ -1046,8 +1197,8 @@ function getErrorMap() {
|
|
|
1046
1197
|
}
|
|
1047
1198
|
__name(getErrorMap, "getErrorMap");
|
|
1048
1199
|
var makeIssue = /* @__PURE__ */ __name((params) => {
|
|
1049
|
-
const { data, path:
|
|
1050
|
-
const fullPath = [...
|
|
1200
|
+
const { data, path: path6, errorMaps, issueData } = params;
|
|
1201
|
+
const fullPath = [...path6, ...issueData.path || []];
|
|
1051
1202
|
const fullIssue = {
|
|
1052
1203
|
...issueData,
|
|
1053
1204
|
path: fullPath
|
|
@@ -1181,11 +1332,11 @@ var ParseInputLazyPath = class {
|
|
|
1181
1332
|
static {
|
|
1182
1333
|
__name(this, "ParseInputLazyPath");
|
|
1183
1334
|
}
|
|
1184
|
-
constructor(parent, value,
|
|
1335
|
+
constructor(parent, value, path6, key) {
|
|
1185
1336
|
this._cachedPath = [];
|
|
1186
1337
|
this.parent = parent;
|
|
1187
1338
|
this.data = value;
|
|
1188
|
-
this._path =
|
|
1339
|
+
this._path = path6;
|
|
1189
1340
|
this._key = key;
|
|
1190
1341
|
}
|
|
1191
1342
|
get path() {
|
|
@@ -4957,134 +5108,6 @@ init_esm_shims();
|
|
|
4957
5108
|
// ../env/src/get-env-paths.ts
|
|
4958
5109
|
init_esm_shims();
|
|
4959
5110
|
|
|
4960
|
-
// ../path/src/join-paths.ts
|
|
4961
|
-
init_esm_shims();
|
|
4962
|
-
var _DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
|
|
4963
|
-
function normalizeWindowsPath(input = "") {
|
|
4964
|
-
if (!input) {
|
|
4965
|
-
return input;
|
|
4966
|
-
}
|
|
4967
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
4968
|
-
}
|
|
4969
|
-
__name(normalizeWindowsPath, "normalizeWindowsPath");
|
|
4970
|
-
var _UNC_REGEX = /^[/\\]{2}/;
|
|
4971
|
-
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
|
|
4972
|
-
var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
|
|
4973
|
-
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
4974
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
4975
|
-
}, "isAbsolute");
|
|
4976
|
-
var correctPaths = /* @__PURE__ */ __name(function(path7) {
|
|
4977
|
-
if (!path7 || path7.length === 0) {
|
|
4978
|
-
return ".";
|
|
4979
|
-
}
|
|
4980
|
-
path7 = normalizeWindowsPath(path7);
|
|
4981
|
-
const isUNCPath = path7.match(_UNC_REGEX);
|
|
4982
|
-
const isPathAbsolute = isAbsolute(path7);
|
|
4983
|
-
const trailingSeparator = path7[path7.length - 1] === "/";
|
|
4984
|
-
path7 = normalizeString(path7, !isPathAbsolute);
|
|
4985
|
-
if (path7.length === 0) {
|
|
4986
|
-
if (isPathAbsolute) {
|
|
4987
|
-
return "/";
|
|
4988
|
-
}
|
|
4989
|
-
return trailingSeparator ? "./" : ".";
|
|
4990
|
-
}
|
|
4991
|
-
if (trailingSeparator) {
|
|
4992
|
-
path7 += "/";
|
|
4993
|
-
}
|
|
4994
|
-
if (_DRIVE_LETTER_RE.test(path7)) {
|
|
4995
|
-
path7 += "/";
|
|
4996
|
-
}
|
|
4997
|
-
if (isUNCPath) {
|
|
4998
|
-
if (!isPathAbsolute) {
|
|
4999
|
-
return `//./${path7}`;
|
|
5000
|
-
}
|
|
5001
|
-
return `//${path7}`;
|
|
5002
|
-
}
|
|
5003
|
-
return isPathAbsolute && !isAbsolute(path7) ? `/${path7}` : path7;
|
|
5004
|
-
}, "correctPaths");
|
|
5005
|
-
var joinPaths = /* @__PURE__ */ __name(function(...segments) {
|
|
5006
|
-
let path7 = "";
|
|
5007
|
-
for (const seg of segments) {
|
|
5008
|
-
if (!seg) {
|
|
5009
|
-
continue;
|
|
5010
|
-
}
|
|
5011
|
-
if (path7.length > 0) {
|
|
5012
|
-
const pathTrailing = path7[path7.length - 1] === "/";
|
|
5013
|
-
const segLeading = seg[0] === "/";
|
|
5014
|
-
const both = pathTrailing && segLeading;
|
|
5015
|
-
if (both) {
|
|
5016
|
-
path7 += seg.slice(1);
|
|
5017
|
-
} else {
|
|
5018
|
-
path7 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
5019
|
-
}
|
|
5020
|
-
} else {
|
|
5021
|
-
path7 += seg;
|
|
5022
|
-
}
|
|
5023
|
-
}
|
|
5024
|
-
return correctPaths(path7);
|
|
5025
|
-
}, "joinPaths");
|
|
5026
|
-
function normalizeString(path7, allowAboveRoot) {
|
|
5027
|
-
let res = "";
|
|
5028
|
-
let lastSegmentLength = 0;
|
|
5029
|
-
let lastSlash = -1;
|
|
5030
|
-
let dots = 0;
|
|
5031
|
-
let char = null;
|
|
5032
|
-
for (let index = 0; index <= path7.length; ++index) {
|
|
5033
|
-
if (index < path7.length) {
|
|
5034
|
-
char = path7[index];
|
|
5035
|
-
} else if (char === "/") {
|
|
5036
|
-
break;
|
|
5037
|
-
} else {
|
|
5038
|
-
char = "/";
|
|
5039
|
-
}
|
|
5040
|
-
if (char === "/") {
|
|
5041
|
-
if (lastSlash === index - 1 || dots === 1) {
|
|
5042
|
-
} else if (dots === 2) {
|
|
5043
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
5044
|
-
if (res.length > 2) {
|
|
5045
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
5046
|
-
if (lastSlashIndex === -1) {
|
|
5047
|
-
res = "";
|
|
5048
|
-
lastSegmentLength = 0;
|
|
5049
|
-
} else {
|
|
5050
|
-
res = res.slice(0, lastSlashIndex);
|
|
5051
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
5052
|
-
}
|
|
5053
|
-
lastSlash = index;
|
|
5054
|
-
dots = 0;
|
|
5055
|
-
continue;
|
|
5056
|
-
} else if (res.length > 0) {
|
|
5057
|
-
res = "";
|
|
5058
|
-
lastSegmentLength = 0;
|
|
5059
|
-
lastSlash = index;
|
|
5060
|
-
dots = 0;
|
|
5061
|
-
continue;
|
|
5062
|
-
}
|
|
5063
|
-
}
|
|
5064
|
-
if (allowAboveRoot) {
|
|
5065
|
-
res += res.length > 0 ? "/.." : "..";
|
|
5066
|
-
lastSegmentLength = 2;
|
|
5067
|
-
}
|
|
5068
|
-
} else {
|
|
5069
|
-
if (res.length > 0) {
|
|
5070
|
-
res += `/${path7.slice(lastSlash + 1, index)}`;
|
|
5071
|
-
} else {
|
|
5072
|
-
res = path7.slice(lastSlash + 1, index);
|
|
5073
|
-
}
|
|
5074
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
5075
|
-
}
|
|
5076
|
-
lastSlash = index;
|
|
5077
|
-
dots = 0;
|
|
5078
|
-
} else if (char === "." && dots !== -1) {
|
|
5079
|
-
++dots;
|
|
5080
|
-
} else {
|
|
5081
|
-
dots = -1;
|
|
5082
|
-
}
|
|
5083
|
-
}
|
|
5084
|
-
return res;
|
|
5085
|
-
}
|
|
5086
|
-
__name(normalizeString, "normalizeString");
|
|
5087
|
-
|
|
5088
5111
|
// ../string-format/src/title-case.ts
|
|
5089
5112
|
init_esm_shims();
|
|
5090
5113
|
|
|
@@ -5263,16 +5286,16 @@ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name
|
|
|
5263
5286
|
}), "__name");
|
|
5264
5287
|
|
|
5265
5288
|
// ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-NQFXB5CV.js
|
|
5266
|
-
import { existsSync } from "node:fs";
|
|
5289
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
5267
5290
|
import { join } from "node:path";
|
|
5268
5291
|
var MAX_PATH_SEARCH_DEPTH = 30;
|
|
5269
5292
|
var depth = 0;
|
|
5270
5293
|
function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
|
|
5271
5294
|
const _startPath = startPath ?? process.cwd();
|
|
5272
|
-
if (endDirectoryNames.some((endDirName) =>
|
|
5295
|
+
if (endDirectoryNames.some((endDirName) => existsSync2(join(_startPath, endDirName)))) {
|
|
5273
5296
|
return _startPath;
|
|
5274
5297
|
}
|
|
5275
|
-
if (endFileNames.some((endFileName) =>
|
|
5298
|
+
if (endFileNames.some((endFileName) => existsSync2(join(_startPath, endFileName)))) {
|
|
5276
5299
|
return _startPath;
|
|
5277
5300
|
}
|
|
5278
5301
|
if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
@@ -5298,34 +5321,34 @@ __name2(normalizeWindowsPath2, "normalizeWindowsPath");
|
|
|
5298
5321
|
var _UNC_REGEX2 = /^[/\\]{2}/;
|
|
5299
5322
|
var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
5300
5323
|
var _DRIVE_LETTER_RE2 = /^[A-Za-z]:$/;
|
|
5301
|
-
var correctPaths2 = /* @__PURE__ */ __name2(function(
|
|
5302
|
-
if (!
|
|
5324
|
+
var correctPaths2 = /* @__PURE__ */ __name2(function(path6) {
|
|
5325
|
+
if (!path6 || path6.length === 0) {
|
|
5303
5326
|
return ".";
|
|
5304
5327
|
}
|
|
5305
|
-
|
|
5306
|
-
const isUNCPath =
|
|
5307
|
-
const isPathAbsolute = isAbsolute2(
|
|
5308
|
-
const trailingSeparator =
|
|
5309
|
-
|
|
5310
|
-
if (
|
|
5328
|
+
path6 = normalizeWindowsPath2(path6);
|
|
5329
|
+
const isUNCPath = path6.match(_UNC_REGEX2);
|
|
5330
|
+
const isPathAbsolute = isAbsolute2(path6);
|
|
5331
|
+
const trailingSeparator = path6[path6.length - 1] === "/";
|
|
5332
|
+
path6 = normalizeString2(path6, !isPathAbsolute);
|
|
5333
|
+
if (path6.length === 0) {
|
|
5311
5334
|
if (isPathAbsolute) {
|
|
5312
5335
|
return "/";
|
|
5313
5336
|
}
|
|
5314
5337
|
return trailingSeparator ? "./" : ".";
|
|
5315
5338
|
}
|
|
5316
5339
|
if (trailingSeparator) {
|
|
5317
|
-
|
|
5340
|
+
path6 += "/";
|
|
5318
5341
|
}
|
|
5319
|
-
if (_DRIVE_LETTER_RE2.test(
|
|
5320
|
-
|
|
5342
|
+
if (_DRIVE_LETTER_RE2.test(path6)) {
|
|
5343
|
+
path6 += "/";
|
|
5321
5344
|
}
|
|
5322
5345
|
if (isUNCPath) {
|
|
5323
5346
|
if (!isPathAbsolute) {
|
|
5324
|
-
return `//./${
|
|
5347
|
+
return `//./${path6}`;
|
|
5325
5348
|
}
|
|
5326
|
-
return `//${
|
|
5349
|
+
return `//${path6}`;
|
|
5327
5350
|
}
|
|
5328
|
-
return isPathAbsolute && !isAbsolute2(
|
|
5351
|
+
return isPathAbsolute && !isAbsolute2(path6) ? `/${path6}` : path6;
|
|
5329
5352
|
}, "correctPaths");
|
|
5330
5353
|
function cwd() {
|
|
5331
5354
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
@@ -5335,15 +5358,15 @@ function cwd() {
|
|
|
5335
5358
|
}
|
|
5336
5359
|
__name(cwd, "cwd");
|
|
5337
5360
|
__name2(cwd, "cwd");
|
|
5338
|
-
function normalizeString2(
|
|
5361
|
+
function normalizeString2(path6, allowAboveRoot) {
|
|
5339
5362
|
let res = "";
|
|
5340
5363
|
let lastSegmentLength = 0;
|
|
5341
5364
|
let lastSlash = -1;
|
|
5342
5365
|
let dots = 0;
|
|
5343
5366
|
let char = null;
|
|
5344
|
-
for (let index = 0; index <=
|
|
5345
|
-
if (index <
|
|
5346
|
-
char =
|
|
5367
|
+
for (let index = 0; index <= path6.length; ++index) {
|
|
5368
|
+
if (index < path6.length) {
|
|
5369
|
+
char = path6[index];
|
|
5347
5370
|
} else if (char === "/") {
|
|
5348
5371
|
break;
|
|
5349
5372
|
} else {
|
|
@@ -5379,9 +5402,9 @@ function normalizeString2(path7, allowAboveRoot) {
|
|
|
5379
5402
|
}
|
|
5380
5403
|
} else {
|
|
5381
5404
|
if (res.length > 0) {
|
|
5382
|
-
res += `/${
|
|
5405
|
+
res += `/${path6.slice(lastSlash + 1, index)}`;
|
|
5383
5406
|
} else {
|
|
5384
|
-
res =
|
|
5407
|
+
res = path6.slice(lastSlash + 1, index);
|
|
5385
5408
|
}
|
|
5386
5409
|
lastSegmentLength = index - lastSlash - 1;
|
|
5387
5410
|
}
|
|
@@ -5480,20 +5503,20 @@ init_esm_shims();
|
|
|
5480
5503
|
// ../path/src/is-file.ts
|
|
5481
5504
|
init_esm_shims();
|
|
5482
5505
|
import { lstatSync, statSync } from "node:fs";
|
|
5483
|
-
function isFile(
|
|
5484
|
-
return Boolean(statSync(additionalPath ? joinPaths(additionalPath,
|
|
5506
|
+
function isFile(path6, additionalPath) {
|
|
5507
|
+
return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path6) : path6, {
|
|
5485
5508
|
throwIfNoEntry: false
|
|
5486
5509
|
})?.isFile());
|
|
5487
5510
|
}
|
|
5488
5511
|
__name(isFile, "isFile");
|
|
5489
|
-
function isDirectory(
|
|
5490
|
-
return Boolean(statSync(additionalPath ? joinPaths(additionalPath,
|
|
5512
|
+
function isDirectory(path6, additionalPath) {
|
|
5513
|
+
return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path6) : path6, {
|
|
5491
5514
|
throwIfNoEntry: false
|
|
5492
5515
|
})?.isDirectory());
|
|
5493
5516
|
}
|
|
5494
5517
|
__name(isDirectory, "isDirectory");
|
|
5495
|
-
function isAbsolutePath(
|
|
5496
|
-
return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(
|
|
5518
|
+
function isAbsolutePath(path6) {
|
|
5519
|
+
return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path6);
|
|
5497
5520
|
}
|
|
5498
5521
|
__name(isAbsolutePath, "isAbsolutePath");
|
|
5499
5522
|
|
|
@@ -5506,15 +5529,15 @@ function normalizeWindowsPath3(input = "") {
|
|
|
5506
5529
|
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE3, (r) => r.toUpperCase());
|
|
5507
5530
|
}
|
|
5508
5531
|
__name(normalizeWindowsPath3, "normalizeWindowsPath");
|
|
5509
|
-
function normalizeString3(
|
|
5532
|
+
function normalizeString3(path6, allowAboveRoot) {
|
|
5510
5533
|
let res = "";
|
|
5511
5534
|
let lastSegmentLength = 0;
|
|
5512
5535
|
let lastSlash = -1;
|
|
5513
5536
|
let dots = 0;
|
|
5514
5537
|
let char = null;
|
|
5515
|
-
for (let index = 0; index <=
|
|
5516
|
-
if (index <
|
|
5517
|
-
char =
|
|
5538
|
+
for (let index = 0; index <= path6.length; ++index) {
|
|
5539
|
+
if (index < path6.length) {
|
|
5540
|
+
char = path6[index];
|
|
5518
5541
|
} else if (char === "/") {
|
|
5519
5542
|
break;
|
|
5520
5543
|
} else {
|
|
@@ -5550,9 +5573,9 @@ function normalizeString3(path7, allowAboveRoot) {
|
|
|
5550
5573
|
}
|
|
5551
5574
|
} else {
|
|
5552
5575
|
if (res.length > 0) {
|
|
5553
|
-
res += `/${
|
|
5576
|
+
res += `/${path6.slice(lastSlash + 1, index)}`;
|
|
5554
5577
|
} else {
|
|
5555
|
-
res =
|
|
5578
|
+
res = path6.slice(lastSlash + 1, index);
|
|
5556
5579
|
}
|
|
5557
5580
|
lastSegmentLength = index - lastSlash - 1;
|
|
5558
5581
|
}
|
|
@@ -5569,17 +5592,17 @@ function normalizeString3(path7, allowAboveRoot) {
|
|
|
5569
5592
|
__name(normalizeString3, "normalizeString");
|
|
5570
5593
|
|
|
5571
5594
|
// ../path/src/file-path-fns.ts
|
|
5572
|
-
function resolvePath(
|
|
5573
|
-
const paths = normalizeWindowsPath3(
|
|
5595
|
+
function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
|
|
5596
|
+
const paths = normalizeWindowsPath3(path6).split("/");
|
|
5574
5597
|
let resolvedPath = "";
|
|
5575
5598
|
let resolvedAbsolute = false;
|
|
5576
5599
|
for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
5577
|
-
const
|
|
5578
|
-
if (!
|
|
5600
|
+
const path7 = index >= 0 ? paths[index] : cwd2;
|
|
5601
|
+
if (!path7 || path7.length === 0) {
|
|
5579
5602
|
continue;
|
|
5580
5603
|
}
|
|
5581
|
-
resolvedPath = joinPaths(
|
|
5582
|
-
resolvedAbsolute = isAbsolutePath(
|
|
5604
|
+
resolvedPath = joinPaths(path7, resolvedPath);
|
|
5605
|
+
resolvedAbsolute = isAbsolutePath(path7);
|
|
5583
5606
|
}
|
|
5584
5607
|
resolvedPath = normalizeString3(resolvedPath, !resolvedAbsolute);
|
|
5585
5608
|
if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {
|
|
@@ -5589,13 +5612,13 @@ function resolvePath(path7, cwd2 = getWorkspaceRoot()) {
|
|
|
5589
5612
|
}
|
|
5590
5613
|
__name(resolvePath, "resolvePath");
|
|
5591
5614
|
function resolvePaths(...paths) {
|
|
5592
|
-
return resolvePath(joinPaths(...paths.map((
|
|
5615
|
+
return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath3(path6))));
|
|
5593
5616
|
}
|
|
5594
5617
|
__name(resolvePaths, "resolvePaths");
|
|
5595
5618
|
|
|
5596
5619
|
// ../path/src/get-parent-path.ts
|
|
5597
|
-
var resolveParentPath = /* @__PURE__ */ __name((
|
|
5598
|
-
return resolvePaths(
|
|
5620
|
+
var resolveParentPath = /* @__PURE__ */ __name((path6) => {
|
|
5621
|
+
return resolvePaths(path6, "..");
|
|
5599
5622
|
}, "resolveParentPath");
|
|
5600
5623
|
var getParentPath = /* @__PURE__ */ __name((name, cwd2, options) => {
|
|
5601
5624
|
const ignoreCase = options?.ignoreCase ?? true;
|
|
@@ -6076,10 +6099,21 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
|
|
|
6076
6099
|
return shieldText;
|
|
6077
6100
|
}, "constructShield");
|
|
6078
6101
|
|
|
6079
|
-
// src/
|
|
6102
|
+
// src/project.ts
|
|
6080
6103
|
init_esm_shims();
|
|
6081
|
-
import {
|
|
6082
|
-
|
|
6104
|
+
import { ModuleKind, Project, ScriptTarget } from "ts-morph";
|
|
6105
|
+
var compilerOptions = {
|
|
6106
|
+
target: ScriptTarget.ESNext,
|
|
6107
|
+
module: ModuleKind.ESNext,
|
|
6108
|
+
emitDecoratorMetadata: true,
|
|
6109
|
+
experimentalDecorators: true,
|
|
6110
|
+
esModuleInterop: true
|
|
6111
|
+
};
|
|
6112
|
+
var project = new Project({
|
|
6113
|
+
compilerOptions: {
|
|
6114
|
+
...compilerOptions
|
|
6115
|
+
}
|
|
6116
|
+
});
|
|
6083
6117
|
|
|
6084
6118
|
// src/utils/remove-dir.ts
|
|
6085
6119
|
init_esm_shims();
|
|
@@ -6137,80 +6171,9 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content) => {
|
|
|
6137
6171
|
fs2.writeFileSync(writeLocation, await formatFile(content));
|
|
6138
6172
|
}, "writeFileSafely");
|
|
6139
6173
|
|
|
6140
|
-
// src/prisma-shield-generator.ts
|
|
6141
|
-
async function generateShield(options) {
|
|
6142
|
-
const internals = await getPrismaInternals();
|
|
6143
|
-
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
6144
|
-
const results = configSchema.safeParse(options.generator.config);
|
|
6145
|
-
if (!results.success) throw new Error("Invalid options passed");
|
|
6146
|
-
const config = results.data;
|
|
6147
|
-
await fs3.mkdir(outputDir, {
|
|
6148
|
-
recursive: true
|
|
6149
|
-
});
|
|
6150
|
-
await removeDir(outputDir, true);
|
|
6151
|
-
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6152
|
-
const prismaClientDmmf = await internals.getDMMF({
|
|
6153
|
-
datamodel: options.datamodel,
|
|
6154
|
-
previewFeatures: prismaClientProvider?.previewFeatures
|
|
6155
|
-
});
|
|
6156
|
-
const queries = [];
|
|
6157
|
-
const mutations = [];
|
|
6158
|
-
const subscriptions = [];
|
|
6159
|
-
prismaClientDmmf.mappings.modelOperations.forEach((modelOperation) => {
|
|
6160
|
-
const { model: _model, plural: _plural, ...operations } = modelOperation;
|
|
6161
|
-
for (const [opType, opNameWithModel] of Object.entries(operations)) {
|
|
6162
|
-
if ([
|
|
6163
|
-
"findUnique",
|
|
6164
|
-
"findFirst",
|
|
6165
|
-
"findMany",
|
|
6166
|
-
"aggregate",
|
|
6167
|
-
"groupBy"
|
|
6168
|
-
].includes(opType)) {
|
|
6169
|
-
queries.push(opNameWithModel);
|
|
6170
|
-
}
|
|
6171
|
-
if ([
|
|
6172
|
-
"createOne",
|
|
6173
|
-
"deleteOne",
|
|
6174
|
-
"updateOne",
|
|
6175
|
-
"deleteMany",
|
|
6176
|
-
"updateMany",
|
|
6177
|
-
"upsertOne"
|
|
6178
|
-
].includes(opType)) {
|
|
6179
|
-
mutations.push(opNameWithModel);
|
|
6180
|
-
}
|
|
6181
|
-
}
|
|
6182
|
-
});
|
|
6183
|
-
queries.sort();
|
|
6184
|
-
mutations.sort();
|
|
6185
|
-
subscriptions.sort();
|
|
6186
|
-
const shieldText = constructShield({
|
|
6187
|
-
queries,
|
|
6188
|
-
mutations,
|
|
6189
|
-
subscriptions
|
|
6190
|
-
}, config, options);
|
|
6191
|
-
await writeFileSafely(path5.join(outputDir, "shield.ts"), shieldText);
|
|
6192
|
-
}
|
|
6193
|
-
__name(generateShield, "generateShield");
|
|
6194
|
-
|
|
6195
|
-
// src/project.ts
|
|
6196
|
-
init_esm_shims();
|
|
6197
|
-
import { ModuleKind, Project, ScriptTarget } from "ts-morph";
|
|
6198
|
-
var compilerOptions = {
|
|
6199
|
-
target: ScriptTarget.ESNext,
|
|
6200
|
-
module: ModuleKind.ESNext,
|
|
6201
|
-
emitDecoratorMetadata: true,
|
|
6202
|
-
experimentalDecorators: true,
|
|
6203
|
-
esModuleInterop: true
|
|
6204
|
-
};
|
|
6205
|
-
var project = new Project({
|
|
6206
|
-
compilerOptions: {
|
|
6207
|
-
...compilerOptions
|
|
6208
|
-
}
|
|
6209
|
-
});
|
|
6210
|
-
|
|
6211
6174
|
// src/prisma-generator.ts
|
|
6212
6175
|
async function generate(options) {
|
|
6213
|
-
console.log("[STORM]: Running the Storm Software - Prisma tRPC generator
|
|
6176
|
+
console.log("[STORM]: Running the Storm Software - Prisma tRPC generator");
|
|
6214
6177
|
const internals = await getPrismaInternals();
|
|
6215
6178
|
console.log(`[STORM]: Validating configuration options`);
|
|
6216
6179
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
@@ -6221,13 +6184,12 @@ async function generate(options) {
|
|
|
6221
6184
|
const config = results.data;
|
|
6222
6185
|
const consoleLog = /* @__PURE__ */ __name((message) => {
|
|
6223
6186
|
if (config.debug) {
|
|
6224
|
-
console.log(`[STORM]: ${message}
|
|
6187
|
+
console.log(`[STORM]: ${message}
|
|
6188
|
+
`);
|
|
6225
6189
|
}
|
|
6226
6190
|
}, "consoleLog");
|
|
6227
6191
|
consoleLog(`Preparing output directory: ${outputDir}`);
|
|
6228
|
-
await
|
|
6229
|
-
recursive: true
|
|
6230
|
-
});
|
|
6192
|
+
await createDirectory(outputDir);
|
|
6231
6193
|
await removeDir(outputDir, true);
|
|
6232
6194
|
if (config.withZod !== false) {
|
|
6233
6195
|
consoleLog("Generating Zod schemas");
|
|
@@ -6236,17 +6198,68 @@ async function generate(options) {
|
|
|
6236
6198
|
} else {
|
|
6237
6199
|
consoleLog("Skipping Zod schemas generation");
|
|
6238
6200
|
}
|
|
6201
|
+
consoleLog("Finding Prisma Client generator");
|
|
6202
|
+
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6203
|
+
if (!prismaClientProvider) {
|
|
6204
|
+
throw new Error("No Prisma Client generator found. Please add `prisma-client-js` to your generator list.");
|
|
6205
|
+
}
|
|
6206
|
+
consoleLog("Generating Prisma Client DMMF");
|
|
6207
|
+
const prismaClientDmmf = await internals.getDMMF({
|
|
6208
|
+
datamodel: options.datamodel,
|
|
6209
|
+
previewFeatures: prismaClientProvider?.previewFeatures
|
|
6210
|
+
});
|
|
6211
|
+
const modelOperations = prismaClientDmmf.mappings.modelOperations;
|
|
6212
|
+
const models = prismaClientDmmf.datamodel.models;
|
|
6213
|
+
const hiddenModels = [];
|
|
6239
6214
|
if (config.withShield !== false) {
|
|
6240
6215
|
consoleLog("Generating tRPC Shield");
|
|
6241
|
-
const
|
|
6242
|
-
|
|
6216
|
+
const shieldOutputDir = joinPaths(outputDir, "shield");
|
|
6217
|
+
consoleLog("Preparing tRPC Shield output directory");
|
|
6218
|
+
await createDirectory(shieldOutputDir);
|
|
6219
|
+
await removeDir(shieldOutputDir, true);
|
|
6220
|
+
const queries = [];
|
|
6221
|
+
const mutations = [];
|
|
6222
|
+
const subscriptions = [];
|
|
6223
|
+
prismaClientDmmf.mappings.modelOperations.forEach((modelOperation) => {
|
|
6224
|
+
const { model: _model, plural: _plural, ...operations } = modelOperation;
|
|
6225
|
+
for (const [opType, opNameWithModel] of Object.entries(operations)) {
|
|
6226
|
+
if ([
|
|
6227
|
+
"findUnique",
|
|
6228
|
+
"findFirst",
|
|
6229
|
+
"findMany",
|
|
6230
|
+
"aggregate",
|
|
6231
|
+
"groupBy"
|
|
6232
|
+
].includes(opType)) {
|
|
6233
|
+
queries.push(opNameWithModel);
|
|
6234
|
+
}
|
|
6235
|
+
if ([
|
|
6236
|
+
"createOne",
|
|
6237
|
+
"deleteOne",
|
|
6238
|
+
"updateOne",
|
|
6239
|
+
"deleteMany",
|
|
6240
|
+
"updateMany",
|
|
6241
|
+
"upsertOne"
|
|
6242
|
+
].includes(opType)) {
|
|
6243
|
+
mutations.push(opNameWithModel);
|
|
6244
|
+
}
|
|
6245
|
+
}
|
|
6246
|
+
});
|
|
6247
|
+
queries.sort();
|
|
6248
|
+
mutations.sort();
|
|
6249
|
+
subscriptions.sort();
|
|
6250
|
+
consoleLog("Constructing tRPC Shield source file");
|
|
6251
|
+
const shieldText = constructShield({
|
|
6252
|
+
queries,
|
|
6253
|
+
mutations,
|
|
6254
|
+
subscriptions
|
|
6255
|
+
}, config, {
|
|
6243
6256
|
...options,
|
|
6244
6257
|
generator: {
|
|
6245
6258
|
...options.generator,
|
|
6246
6259
|
output: {
|
|
6247
6260
|
fromEnvVar: null,
|
|
6248
6261
|
...options.generator.output,
|
|
6249
|
-
value:
|
|
6262
|
+
value: shieldOutputDir
|
|
6250
6263
|
},
|
|
6251
6264
|
config: {
|
|
6252
6265
|
...options.generator.config,
|
|
@@ -6254,25 +6267,14 @@ async function generate(options) {
|
|
|
6254
6267
|
}
|
|
6255
6268
|
}
|
|
6256
6269
|
});
|
|
6270
|
+
consoleLog("Saving tRPC Shield source file to disk");
|
|
6271
|
+
await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
|
|
6257
6272
|
} else {
|
|
6258
6273
|
consoleLog("Skipping tRPC Shield generation");
|
|
6259
6274
|
}
|
|
6260
|
-
consoleLog("Finding Prisma Client generator");
|
|
6261
|
-
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6262
|
-
if (!prismaClientProvider) {
|
|
6263
|
-
throw new Error("No Prisma Client generator found. Please add `prisma-client-js` to your generator list.");
|
|
6264
|
-
}
|
|
6265
|
-
consoleLog("Generating Prisma Client DMMF");
|
|
6266
|
-
const prismaClientDmmf = await internals.getDMMF({
|
|
6267
|
-
datamodel: options.datamodel,
|
|
6268
|
-
previewFeatures: prismaClientProvider?.previewFeatures
|
|
6269
|
-
});
|
|
6270
|
-
const modelOperations = prismaClientDmmf.mappings.modelOperations;
|
|
6271
|
-
const models = prismaClientDmmf.datamodel.models;
|
|
6272
|
-
const hiddenModels = [];
|
|
6273
6275
|
consoleLog(`Generating tRPC source code for ${models.length} models`);
|
|
6274
6276
|
resolveModelsComments(models, hiddenModels);
|
|
6275
|
-
const createRouter = project.createSourceFile(
|
|
6277
|
+
const createRouter = project.createSourceFile(path5.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
|
|
6276
6278
|
overwrite: true
|
|
6277
6279
|
});
|
|
6278
6280
|
consoleLog("Generating tRPC imports");
|
|
@@ -6285,7 +6287,7 @@ async function generate(options) {
|
|
|
6285
6287
|
createRouter.formatText({
|
|
6286
6288
|
indentSize: 2
|
|
6287
6289
|
});
|
|
6288
|
-
const appRouter = project.createSourceFile(
|
|
6290
|
+
const appRouter = project.createSourceFile(path5.resolve(outputDir, "routers", `index.ts`), void 0, {
|
|
6289
6291
|
overwrite: true
|
|
6290
6292
|
});
|
|
6291
6293
|
consoleLog("Generating tRPC router imports");
|
|
@@ -6307,7 +6309,7 @@ async function generate(options) {
|
|
|
6307
6309
|
const plural = (0, import_pluralize.default)(model.toLowerCase());
|
|
6308
6310
|
consoleLog(`Generating tRPC router for model ${model}`);
|
|
6309
6311
|
generateRouterImport(appRouter, plural, model);
|
|
6310
|
-
const modelRouter = project.createSourceFile(
|
|
6312
|
+
const modelRouter = project.createSourceFile(path5.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
|
|
6311
6313
|
overwrite: true
|
|
6312
6314
|
});
|
|
6313
6315
|
generateCreateRouterImport({
|