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