@stryke/prisma-trpc-generator 0.13.26 → 0.13.34
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/README.md +18 -10
- package/dist/generator.cjs +1 -4205
- package/dist/generator.d.cts +1 -0
- package/dist/{generator.d.ts → generator.d.mts} +1 -0
- package/dist/generator.mjs +2 -0
- package/dist/index.cjs +63 -4149
- package/dist/index.d.cts +1 -2
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +117 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +13 -41
- package/dist/generator.js +0 -4211
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -4207
package/dist/index.cjs
CHANGED
|
@@ -1,2728 +1,50 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __esm = (fn, res) => function __init() {
|
|
10
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
-
};
|
|
12
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
13
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from))
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
|
-
|
|
32
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.1_@types+node@24.10.1__@swc+core@1.15.3_@swc+h_88727a58a5077acdeb714aa851988eef/node_modules/tsup/assets/cjs_shims.js
|
|
33
|
-
var init_cjs_shims = __esm({
|
|
34
|
-
"../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.1_@types+node@24.10.1__@swc+core@1.15.3_@swc+h_88727a58a5077acdeb714aa851988eef/node_modules/tsup/assets/cjs_shims.js"() {
|
|
35
|
-
"use strict";
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// ../../node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.js
|
|
40
|
-
var require_pluralize = __commonJS({
|
|
41
|
-
"../../node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.js"(exports2, module2) {
|
|
42
|
-
"use strict";
|
|
43
|
-
init_cjs_shims();
|
|
44
|
-
(function(root, pluralize2) {
|
|
45
|
-
if (typeof require === "function" && typeof exports2 === "object" && typeof module2 === "object") {
|
|
46
|
-
module2.exports = pluralize2();
|
|
47
|
-
} else if (typeof define === "function" && define.amd) {
|
|
48
|
-
define(function() {
|
|
49
|
-
return pluralize2();
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
root.pluralize = pluralize2();
|
|
53
|
-
}
|
|
54
|
-
})(exports2, function() {
|
|
55
|
-
var pluralRules = [];
|
|
56
|
-
var singularRules = [];
|
|
57
|
-
var uncountables = {};
|
|
58
|
-
var irregularPlurals = {};
|
|
59
|
-
var irregularSingles = {};
|
|
60
|
-
function sanitizeRule(rule) {
|
|
61
|
-
if (typeof rule === "string") {
|
|
62
|
-
return new RegExp("^" + rule + "$", "i");
|
|
63
|
-
}
|
|
64
|
-
return rule;
|
|
65
|
-
}
|
|
66
|
-
__name(sanitizeRule, "sanitizeRule");
|
|
67
|
-
function restoreCase(word, token) {
|
|
68
|
-
if (word === token) return token;
|
|
69
|
-
if (word === word.toLowerCase()) return token.toLowerCase();
|
|
70
|
-
if (word === word.toUpperCase()) return token.toUpperCase();
|
|
71
|
-
if (word[0] === word[0].toUpperCase()) {
|
|
72
|
-
return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
|
|
73
|
-
}
|
|
74
|
-
return token.toLowerCase();
|
|
75
|
-
}
|
|
76
|
-
__name(restoreCase, "restoreCase");
|
|
77
|
-
function interpolate(str, args) {
|
|
78
|
-
return str.replace(/\$(\d{1,2})/g, function(match, index) {
|
|
79
|
-
return args[index] || "";
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
__name(interpolate, "interpolate");
|
|
83
|
-
function replace(word, rule) {
|
|
84
|
-
return word.replace(rule[0], function(match, index) {
|
|
85
|
-
var result = interpolate(rule[1], arguments);
|
|
86
|
-
if (match === "") {
|
|
87
|
-
return restoreCase(word[index - 1], result);
|
|
88
|
-
}
|
|
89
|
-
return restoreCase(match, result);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
__name(replace, "replace");
|
|
93
|
-
function sanitizeWord(token, word, rules) {
|
|
94
|
-
if (!token.length || uncountables.hasOwnProperty(token)) {
|
|
95
|
-
return word;
|
|
96
|
-
}
|
|
97
|
-
var len = rules.length;
|
|
98
|
-
while (len--) {
|
|
99
|
-
var rule = rules[len];
|
|
100
|
-
if (rule[0].test(word)) return replace(word, rule);
|
|
101
|
-
}
|
|
102
|
-
return word;
|
|
103
|
-
}
|
|
104
|
-
__name(sanitizeWord, "sanitizeWord");
|
|
105
|
-
function replaceWord(replaceMap, keepMap, rules) {
|
|
106
|
-
return function(word) {
|
|
107
|
-
var token = word.toLowerCase();
|
|
108
|
-
if (keepMap.hasOwnProperty(token)) {
|
|
109
|
-
return restoreCase(word, token);
|
|
110
|
-
}
|
|
111
|
-
if (replaceMap.hasOwnProperty(token)) {
|
|
112
|
-
return restoreCase(word, replaceMap[token]);
|
|
113
|
-
}
|
|
114
|
-
return sanitizeWord(token, word, rules);
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
__name(replaceWord, "replaceWord");
|
|
118
|
-
function checkWord(replaceMap, keepMap, rules, bool) {
|
|
119
|
-
return function(word) {
|
|
120
|
-
var token = word.toLowerCase();
|
|
121
|
-
if (keepMap.hasOwnProperty(token)) return true;
|
|
122
|
-
if (replaceMap.hasOwnProperty(token)) return false;
|
|
123
|
-
return sanitizeWord(token, token, rules) === token;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
__name(checkWord, "checkWord");
|
|
127
|
-
function pluralize2(word, count, inclusive) {
|
|
128
|
-
var pluralized = count === 1 ? pluralize2.singular(word) : pluralize2.plural(word);
|
|
129
|
-
return (inclusive ? count + " " : "") + pluralized;
|
|
130
|
-
}
|
|
131
|
-
__name(pluralize2, "pluralize");
|
|
132
|
-
pluralize2.plural = replaceWord(irregularSingles, irregularPlurals, pluralRules);
|
|
133
|
-
pluralize2.isPlural = checkWord(irregularSingles, irregularPlurals, pluralRules);
|
|
134
|
-
pluralize2.singular = replaceWord(irregularPlurals, irregularSingles, singularRules);
|
|
135
|
-
pluralize2.isSingular = checkWord(irregularPlurals, irregularSingles, singularRules);
|
|
136
|
-
pluralize2.addPluralRule = function(rule, replacement) {
|
|
137
|
-
pluralRules.push([
|
|
138
|
-
sanitizeRule(rule),
|
|
139
|
-
replacement
|
|
140
|
-
]);
|
|
141
|
-
};
|
|
142
|
-
pluralize2.addSingularRule = function(rule, replacement) {
|
|
143
|
-
singularRules.push([
|
|
144
|
-
sanitizeRule(rule),
|
|
145
|
-
replacement
|
|
146
|
-
]);
|
|
147
|
-
};
|
|
148
|
-
pluralize2.addUncountableRule = function(word) {
|
|
149
|
-
if (typeof word === "string") {
|
|
150
|
-
uncountables[word.toLowerCase()] = true;
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
pluralize2.addPluralRule(word, "$0");
|
|
154
|
-
pluralize2.addSingularRule(word, "$0");
|
|
155
|
-
};
|
|
156
|
-
pluralize2.addIrregularRule = function(single, plural) {
|
|
157
|
-
plural = plural.toLowerCase();
|
|
158
|
-
single = single.toLowerCase();
|
|
159
|
-
irregularSingles[single] = plural;
|
|
160
|
-
irregularPlurals[plural] = single;
|
|
161
|
-
};
|
|
162
|
-
[
|
|
163
|
-
// Pronouns.
|
|
164
|
-
[
|
|
165
|
-
"I",
|
|
166
|
-
"we"
|
|
167
|
-
],
|
|
168
|
-
[
|
|
169
|
-
"me",
|
|
170
|
-
"us"
|
|
171
|
-
],
|
|
172
|
-
[
|
|
173
|
-
"he",
|
|
174
|
-
"they"
|
|
175
|
-
],
|
|
176
|
-
[
|
|
177
|
-
"she",
|
|
178
|
-
"they"
|
|
179
|
-
],
|
|
180
|
-
[
|
|
181
|
-
"them",
|
|
182
|
-
"them"
|
|
183
|
-
],
|
|
184
|
-
[
|
|
185
|
-
"myself",
|
|
186
|
-
"ourselves"
|
|
187
|
-
],
|
|
188
|
-
[
|
|
189
|
-
"yourself",
|
|
190
|
-
"yourselves"
|
|
191
|
-
],
|
|
192
|
-
[
|
|
193
|
-
"itself",
|
|
194
|
-
"themselves"
|
|
195
|
-
],
|
|
196
|
-
[
|
|
197
|
-
"herself",
|
|
198
|
-
"themselves"
|
|
199
|
-
],
|
|
200
|
-
[
|
|
201
|
-
"himself",
|
|
202
|
-
"themselves"
|
|
203
|
-
],
|
|
204
|
-
[
|
|
205
|
-
"themself",
|
|
206
|
-
"themselves"
|
|
207
|
-
],
|
|
208
|
-
[
|
|
209
|
-
"is",
|
|
210
|
-
"are"
|
|
211
|
-
],
|
|
212
|
-
[
|
|
213
|
-
"was",
|
|
214
|
-
"were"
|
|
215
|
-
],
|
|
216
|
-
[
|
|
217
|
-
"has",
|
|
218
|
-
"have"
|
|
219
|
-
],
|
|
220
|
-
[
|
|
221
|
-
"this",
|
|
222
|
-
"these"
|
|
223
|
-
],
|
|
224
|
-
[
|
|
225
|
-
"that",
|
|
226
|
-
"those"
|
|
227
|
-
],
|
|
228
|
-
// Words ending in with a consonant and `o`.
|
|
229
|
-
[
|
|
230
|
-
"echo",
|
|
231
|
-
"echoes"
|
|
232
|
-
],
|
|
233
|
-
[
|
|
234
|
-
"dingo",
|
|
235
|
-
"dingoes"
|
|
236
|
-
],
|
|
237
|
-
[
|
|
238
|
-
"volcano",
|
|
239
|
-
"volcanoes"
|
|
240
|
-
],
|
|
241
|
-
[
|
|
242
|
-
"tornado",
|
|
243
|
-
"tornadoes"
|
|
244
|
-
],
|
|
245
|
-
[
|
|
246
|
-
"torpedo",
|
|
247
|
-
"torpedoes"
|
|
248
|
-
],
|
|
249
|
-
// Ends with `us`.
|
|
250
|
-
[
|
|
251
|
-
"genus",
|
|
252
|
-
"genera"
|
|
253
|
-
],
|
|
254
|
-
[
|
|
255
|
-
"viscus",
|
|
256
|
-
"viscera"
|
|
257
|
-
],
|
|
258
|
-
// Ends with `ma`.
|
|
259
|
-
[
|
|
260
|
-
"stigma",
|
|
261
|
-
"stigmata"
|
|
262
|
-
],
|
|
263
|
-
[
|
|
264
|
-
"stoma",
|
|
265
|
-
"stomata"
|
|
266
|
-
],
|
|
267
|
-
[
|
|
268
|
-
"dogma",
|
|
269
|
-
"dogmata"
|
|
270
|
-
],
|
|
271
|
-
[
|
|
272
|
-
"lemma",
|
|
273
|
-
"lemmata"
|
|
274
|
-
],
|
|
275
|
-
[
|
|
276
|
-
"schema",
|
|
277
|
-
"schemata"
|
|
278
|
-
],
|
|
279
|
-
[
|
|
280
|
-
"anathema",
|
|
281
|
-
"anathemata"
|
|
282
|
-
],
|
|
283
|
-
// Other irregular rules.
|
|
284
|
-
[
|
|
285
|
-
"ox",
|
|
286
|
-
"oxen"
|
|
287
|
-
],
|
|
288
|
-
[
|
|
289
|
-
"axe",
|
|
290
|
-
"axes"
|
|
291
|
-
],
|
|
292
|
-
[
|
|
293
|
-
"die",
|
|
294
|
-
"dice"
|
|
295
|
-
],
|
|
296
|
-
[
|
|
297
|
-
"yes",
|
|
298
|
-
"yeses"
|
|
299
|
-
],
|
|
300
|
-
[
|
|
301
|
-
"foot",
|
|
302
|
-
"feet"
|
|
303
|
-
],
|
|
304
|
-
[
|
|
305
|
-
"eave",
|
|
306
|
-
"eaves"
|
|
307
|
-
],
|
|
308
|
-
[
|
|
309
|
-
"goose",
|
|
310
|
-
"geese"
|
|
311
|
-
],
|
|
312
|
-
[
|
|
313
|
-
"tooth",
|
|
314
|
-
"teeth"
|
|
315
|
-
],
|
|
316
|
-
[
|
|
317
|
-
"quiz",
|
|
318
|
-
"quizzes"
|
|
319
|
-
],
|
|
320
|
-
[
|
|
321
|
-
"human",
|
|
322
|
-
"humans"
|
|
323
|
-
],
|
|
324
|
-
[
|
|
325
|
-
"proof",
|
|
326
|
-
"proofs"
|
|
327
|
-
],
|
|
328
|
-
[
|
|
329
|
-
"carve",
|
|
330
|
-
"carves"
|
|
331
|
-
],
|
|
332
|
-
[
|
|
333
|
-
"valve",
|
|
334
|
-
"valves"
|
|
335
|
-
],
|
|
336
|
-
[
|
|
337
|
-
"looey",
|
|
338
|
-
"looies"
|
|
339
|
-
],
|
|
340
|
-
[
|
|
341
|
-
"thief",
|
|
342
|
-
"thieves"
|
|
343
|
-
],
|
|
344
|
-
[
|
|
345
|
-
"groove",
|
|
346
|
-
"grooves"
|
|
347
|
-
],
|
|
348
|
-
[
|
|
349
|
-
"pickaxe",
|
|
350
|
-
"pickaxes"
|
|
351
|
-
],
|
|
352
|
-
[
|
|
353
|
-
"passerby",
|
|
354
|
-
"passersby"
|
|
355
|
-
]
|
|
356
|
-
].forEach(function(rule) {
|
|
357
|
-
return pluralize2.addIrregularRule(rule[0], rule[1]);
|
|
358
|
-
});
|
|
359
|
-
[
|
|
360
|
-
[
|
|
361
|
-
/s?$/i,
|
|
362
|
-
"s"
|
|
363
|
-
],
|
|
364
|
-
[
|
|
365
|
-
/[^\u0000-\u007F]$/i,
|
|
366
|
-
"$0"
|
|
367
|
-
],
|
|
368
|
-
[
|
|
369
|
-
/([^aeiou]ese)$/i,
|
|
370
|
-
"$1"
|
|
371
|
-
],
|
|
372
|
-
[
|
|
373
|
-
/(ax|test)is$/i,
|
|
374
|
-
"$1es"
|
|
375
|
-
],
|
|
376
|
-
[
|
|
377
|
-
/(alias|[^aou]us|t[lm]as|gas|ris)$/i,
|
|
378
|
-
"$1es"
|
|
379
|
-
],
|
|
380
|
-
[
|
|
381
|
-
/(e[mn]u)s?$/i,
|
|
382
|
-
"$1s"
|
|
383
|
-
],
|
|
384
|
-
[
|
|
385
|
-
/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,
|
|
386
|
-
"$1"
|
|
387
|
-
],
|
|
388
|
-
[
|
|
389
|
-
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
390
|
-
"$1i"
|
|
391
|
-
],
|
|
392
|
-
[
|
|
393
|
-
/(alumn|alg|vertebr)(?:a|ae)$/i,
|
|
394
|
-
"$1ae"
|
|
395
|
-
],
|
|
396
|
-
[
|
|
397
|
-
/(seraph|cherub)(?:im)?$/i,
|
|
398
|
-
"$1im"
|
|
399
|
-
],
|
|
400
|
-
[
|
|
401
|
-
/(her|at|gr)o$/i,
|
|
402
|
-
"$1oes"
|
|
403
|
-
],
|
|
404
|
-
[
|
|
405
|
-
/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,
|
|
406
|
-
"$1a"
|
|
407
|
-
],
|
|
408
|
-
[
|
|
409
|
-
/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,
|
|
410
|
-
"$1a"
|
|
411
|
-
],
|
|
412
|
-
[
|
|
413
|
-
/sis$/i,
|
|
414
|
-
"ses"
|
|
415
|
-
],
|
|
416
|
-
[
|
|
417
|
-
/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,
|
|
418
|
-
"$1$2ves"
|
|
419
|
-
],
|
|
420
|
-
[
|
|
421
|
-
/([^aeiouy]|qu)y$/i,
|
|
422
|
-
"$1ies"
|
|
423
|
-
],
|
|
424
|
-
[
|
|
425
|
-
/([^ch][ieo][ln])ey$/i,
|
|
426
|
-
"$1ies"
|
|
427
|
-
],
|
|
428
|
-
[
|
|
429
|
-
/(x|ch|ss|sh|zz)$/i,
|
|
430
|
-
"$1es"
|
|
431
|
-
],
|
|
432
|
-
[
|
|
433
|
-
/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,
|
|
434
|
-
"$1ices"
|
|
435
|
-
],
|
|
436
|
-
[
|
|
437
|
-
/\b((?:tit)?m|l)(?:ice|ouse)$/i,
|
|
438
|
-
"$1ice"
|
|
439
|
-
],
|
|
440
|
-
[
|
|
441
|
-
/(pe)(?:rson|ople)$/i,
|
|
442
|
-
"$1ople"
|
|
443
|
-
],
|
|
444
|
-
[
|
|
445
|
-
/(child)(?:ren)?$/i,
|
|
446
|
-
"$1ren"
|
|
447
|
-
],
|
|
448
|
-
[
|
|
449
|
-
/eaux$/i,
|
|
450
|
-
"$0"
|
|
451
|
-
],
|
|
452
|
-
[
|
|
453
|
-
/m[ae]n$/i,
|
|
454
|
-
"men"
|
|
455
|
-
],
|
|
456
|
-
[
|
|
457
|
-
"thou",
|
|
458
|
-
"you"
|
|
459
|
-
]
|
|
460
|
-
].forEach(function(rule) {
|
|
461
|
-
return pluralize2.addPluralRule(rule[0], rule[1]);
|
|
462
|
-
});
|
|
463
|
-
[
|
|
464
|
-
[
|
|
465
|
-
/s$/i,
|
|
466
|
-
""
|
|
467
|
-
],
|
|
468
|
-
[
|
|
469
|
-
/(ss)$/i,
|
|
470
|
-
"$1"
|
|
471
|
-
],
|
|
472
|
-
[
|
|
473
|
-
/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,
|
|
474
|
-
"$1fe"
|
|
475
|
-
],
|
|
476
|
-
[
|
|
477
|
-
/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,
|
|
478
|
-
"$1f"
|
|
479
|
-
],
|
|
480
|
-
[
|
|
481
|
-
/ies$/i,
|
|
482
|
-
"y"
|
|
483
|
-
],
|
|
484
|
-
[
|
|
485
|
-
/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,
|
|
486
|
-
"$1ie"
|
|
487
|
-
],
|
|
488
|
-
[
|
|
489
|
-
/\b(mon|smil)ies$/i,
|
|
490
|
-
"$1ey"
|
|
491
|
-
],
|
|
492
|
-
[
|
|
493
|
-
/\b((?:tit)?m|l)ice$/i,
|
|
494
|
-
"$1ouse"
|
|
495
|
-
],
|
|
496
|
-
[
|
|
497
|
-
/(seraph|cherub)im$/i,
|
|
498
|
-
"$1"
|
|
499
|
-
],
|
|
500
|
-
[
|
|
501
|
-
/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,
|
|
502
|
-
"$1"
|
|
503
|
-
],
|
|
504
|
-
[
|
|
505
|
-
/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,
|
|
506
|
-
"$1sis"
|
|
507
|
-
],
|
|
508
|
-
[
|
|
509
|
-
/(movie|twelve|abuse|e[mn]u)s$/i,
|
|
510
|
-
"$1"
|
|
511
|
-
],
|
|
512
|
-
[
|
|
513
|
-
/(test)(?:is|es)$/i,
|
|
514
|
-
"$1is"
|
|
515
|
-
],
|
|
516
|
-
[
|
|
517
|
-
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
518
|
-
"$1us"
|
|
519
|
-
],
|
|
520
|
-
[
|
|
521
|
-
/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,
|
|
522
|
-
"$1um"
|
|
523
|
-
],
|
|
524
|
-
[
|
|
525
|
-
/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,
|
|
526
|
-
"$1on"
|
|
527
|
-
],
|
|
528
|
-
[
|
|
529
|
-
/(alumn|alg|vertebr)ae$/i,
|
|
530
|
-
"$1a"
|
|
531
|
-
],
|
|
532
|
-
[
|
|
533
|
-
/(cod|mur|sil|vert|ind)ices$/i,
|
|
534
|
-
"$1ex"
|
|
535
|
-
],
|
|
536
|
-
[
|
|
537
|
-
/(matr|append)ices$/i,
|
|
538
|
-
"$1ix"
|
|
539
|
-
],
|
|
540
|
-
[
|
|
541
|
-
/(pe)(rson|ople)$/i,
|
|
542
|
-
"$1rson"
|
|
543
|
-
],
|
|
544
|
-
[
|
|
545
|
-
/(child)ren$/i,
|
|
546
|
-
"$1"
|
|
547
|
-
],
|
|
548
|
-
[
|
|
549
|
-
/(eau)x?$/i,
|
|
550
|
-
"$1"
|
|
551
|
-
],
|
|
552
|
-
[
|
|
553
|
-
/men$/i,
|
|
554
|
-
"man"
|
|
555
|
-
]
|
|
556
|
-
].forEach(function(rule) {
|
|
557
|
-
return pluralize2.addSingularRule(rule[0], rule[1]);
|
|
558
|
-
});
|
|
559
|
-
[
|
|
560
|
-
// Singular words with no plurals.
|
|
561
|
-
"adulthood",
|
|
562
|
-
"advice",
|
|
563
|
-
"agenda",
|
|
564
|
-
"aid",
|
|
565
|
-
"aircraft",
|
|
566
|
-
"alcohol",
|
|
567
|
-
"ammo",
|
|
568
|
-
"analytics",
|
|
569
|
-
"anime",
|
|
570
|
-
"athletics",
|
|
571
|
-
"audio",
|
|
572
|
-
"bison",
|
|
573
|
-
"blood",
|
|
574
|
-
"bream",
|
|
575
|
-
"buffalo",
|
|
576
|
-
"butter",
|
|
577
|
-
"carp",
|
|
578
|
-
"cash",
|
|
579
|
-
"chassis",
|
|
580
|
-
"chess",
|
|
581
|
-
"clothing",
|
|
582
|
-
"cod",
|
|
583
|
-
"commerce",
|
|
584
|
-
"cooperation",
|
|
585
|
-
"corps",
|
|
586
|
-
"debris",
|
|
587
|
-
"diabetes",
|
|
588
|
-
"digestion",
|
|
589
|
-
"elk",
|
|
590
|
-
"energy",
|
|
591
|
-
"equipment",
|
|
592
|
-
"excretion",
|
|
593
|
-
"expertise",
|
|
594
|
-
"firmware",
|
|
595
|
-
"flounder",
|
|
596
|
-
"fun",
|
|
597
|
-
"gallows",
|
|
598
|
-
"garbage",
|
|
599
|
-
"graffiti",
|
|
600
|
-
"hardware",
|
|
601
|
-
"headquarters",
|
|
602
|
-
"health",
|
|
603
|
-
"herpes",
|
|
604
|
-
"highjinks",
|
|
605
|
-
"homework",
|
|
606
|
-
"housework",
|
|
607
|
-
"information",
|
|
608
|
-
"jeans",
|
|
609
|
-
"justice",
|
|
610
|
-
"kudos",
|
|
611
|
-
"labour",
|
|
612
|
-
"literature",
|
|
613
|
-
"machinery",
|
|
614
|
-
"mackerel",
|
|
615
|
-
"mail",
|
|
616
|
-
"media",
|
|
617
|
-
"mews",
|
|
618
|
-
"moose",
|
|
619
|
-
"music",
|
|
620
|
-
"mud",
|
|
621
|
-
"manga",
|
|
622
|
-
"news",
|
|
623
|
-
"only",
|
|
624
|
-
"personnel",
|
|
625
|
-
"pike",
|
|
626
|
-
"plankton",
|
|
627
|
-
"pliers",
|
|
628
|
-
"police",
|
|
629
|
-
"pollution",
|
|
630
|
-
"premises",
|
|
631
|
-
"rain",
|
|
632
|
-
"research",
|
|
633
|
-
"rice",
|
|
634
|
-
"salmon",
|
|
635
|
-
"scissors",
|
|
636
|
-
"series",
|
|
637
|
-
"sewage",
|
|
638
|
-
"shambles",
|
|
639
|
-
"shrimp",
|
|
640
|
-
"software",
|
|
641
|
-
"species",
|
|
642
|
-
"staff",
|
|
643
|
-
"swine",
|
|
644
|
-
"tennis",
|
|
645
|
-
"traffic",
|
|
646
|
-
"transportation",
|
|
647
|
-
"trout",
|
|
648
|
-
"tuna",
|
|
649
|
-
"wealth",
|
|
650
|
-
"welfare",
|
|
651
|
-
"whiting",
|
|
652
|
-
"wildebeest",
|
|
653
|
-
"wildlife",
|
|
654
|
-
"you",
|
|
655
|
-
/pok[eé]mon$/i,
|
|
656
|
-
// Regexes.
|
|
657
|
-
/[^aeiou]ese$/i,
|
|
658
|
-
/deer$/i,
|
|
659
|
-
/fish$/i,
|
|
660
|
-
/measles$/i,
|
|
661
|
-
/o[iu]s$/i,
|
|
662
|
-
/pox$/i,
|
|
663
|
-
/sheep$/i
|
|
664
|
-
].forEach(pluralize2.addUncountableRule);
|
|
665
|
-
return pluralize2;
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
// src/index.ts
|
|
671
|
-
init_cjs_shims();
|
|
672
|
-
|
|
673
|
-
// src/prisma-generator.ts
|
|
674
|
-
init_cjs_shims();
|
|
675
|
-
var import_exists = require("@stryke/fs/exists");
|
|
676
|
-
var import_helpers2 = require("@stryke/fs/helpers");
|
|
677
|
-
var import_join_paths4 = require("@stryke/path/join-paths");
|
|
678
|
-
|
|
679
|
-
// ../string-format/src/lower-case-first.ts
|
|
680
|
-
init_cjs_shims();
|
|
681
|
-
function lowerCaseFirst(input) {
|
|
682
|
-
return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
|
|
683
|
-
}
|
|
684
|
-
__name(lowerCaseFirst, "lowerCaseFirst");
|
|
685
|
-
|
|
686
|
-
// src/prisma-generator.ts
|
|
687
|
-
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
688
|
-
var import_pluralize = __toESM(require_pluralize(), 1);
|
|
689
|
-
|
|
690
|
-
// src/config.ts
|
|
691
|
-
init_cjs_shims();
|
|
692
|
-
var import_zod = require("zod");
|
|
693
|
-
var ModelAction = /* @__PURE__ */ (function(ModelAction2) {
|
|
694
|
-
ModelAction2["findUnique"] = "findUnique";
|
|
695
|
-
ModelAction2["findUniqueOrThrow"] = "findUniqueOrThrow";
|
|
696
|
-
ModelAction2["findFirst"] = "findFirst";
|
|
697
|
-
ModelAction2["findFirstOrThrow"] = "findFirstOrThrow";
|
|
698
|
-
ModelAction2["findMany"] = "findMany";
|
|
699
|
-
ModelAction2["create"] = "create";
|
|
700
|
-
ModelAction2["createMany"] = "createMany";
|
|
701
|
-
ModelAction2["createManyAndReturn"] = "createManyAndReturn";
|
|
702
|
-
ModelAction2["update"] = "update";
|
|
703
|
-
ModelAction2["updateMany"] = "updateMany";
|
|
704
|
-
ModelAction2["updateManyAndReturn"] = "updateManyAndReturn";
|
|
705
|
-
ModelAction2["upsert"] = "upsert";
|
|
706
|
-
ModelAction2["delete"] = "delete";
|
|
707
|
-
ModelAction2["deleteMany"] = "deleteMany";
|
|
708
|
-
ModelAction2["groupBy"] = "groupBy";
|
|
709
|
-
ModelAction2["count"] = "count";
|
|
710
|
-
ModelAction2["aggregate"] = "aggregate";
|
|
711
|
-
ModelAction2["findRaw"] = "findRaw";
|
|
712
|
-
ModelAction2["aggregateRaw"] = "aggregateRaw";
|
|
713
|
-
return ModelAction2;
|
|
714
|
-
})({});
|
|
715
|
-
var modelActionEnum = import_zod.z.nativeEnum(ModelAction);
|
|
716
|
-
var configBoolean = import_zod.z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
|
|
717
|
-
var configSchema = import_zod.z.object({
|
|
718
|
-
debug: configBoolean.default("false"),
|
|
719
|
-
withNext: configBoolean.default("true"),
|
|
720
|
-
withMiddleware: configBoolean.default("false"),
|
|
721
|
-
withShield: configBoolean.default("false"),
|
|
722
|
-
contextPath: import_zod.z.string().trim().default("../context"),
|
|
723
|
-
trpcOptions: configBoolean.default("true"),
|
|
724
|
-
showModelNameInProcedure: configBoolean.default("false"),
|
|
725
|
-
generateModelActions: import_zod.z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
|
|
726
|
-
return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
|
|
727
|
-
}),
|
|
728
|
-
// Zod configuration
|
|
729
|
-
withZod: configBoolean.default("true"),
|
|
730
|
-
relationModel: configBoolean.default("true").or(import_zod.z.literal("default")),
|
|
731
|
-
modelSuffix: import_zod.z.string().default("Schema"),
|
|
732
|
-
modelCase: import_zod.z.enum([
|
|
733
|
-
"PascalCase",
|
|
734
|
-
"camelCase"
|
|
735
|
-
]).default("camelCase"),
|
|
736
|
-
useDecimalJs: configBoolean.default("true"),
|
|
737
|
-
imports: import_zod.z.string().optional(),
|
|
738
|
-
prismaJsonNullability: configBoolean.default("true")
|
|
739
|
-
});
|
|
740
|
-
|
|
741
|
-
// src/helpers.ts
|
|
742
|
-
init_cjs_shims();
|
|
743
|
-
var import_file_path_fns = require("@stryke/path/file-path-fns");
|
|
744
|
-
var import_join_paths3 = require("@stryke/path/join-paths");
|
|
745
|
-
|
|
746
|
-
// src/project.ts
|
|
747
|
-
init_cjs_shims();
|
|
748
|
-
var import_ts_morph = require("ts-morph");
|
|
749
|
-
var compilerOptions = {
|
|
750
|
-
target: import_ts_morph.ScriptTarget.ESNext,
|
|
751
|
-
module: import_ts_morph.ModuleKind.ESNext,
|
|
752
|
-
emitDecoratorMetadata: true,
|
|
753
|
-
experimentalDecorators: true,
|
|
754
|
-
esModuleInterop: true
|
|
755
|
-
};
|
|
756
|
-
var project = new import_ts_morph.Project({
|
|
757
|
-
compilerOptions: {
|
|
758
|
-
...compilerOptions
|
|
759
|
-
}
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
// src/utils/get-prisma-internals.ts
|
|
763
|
-
init_cjs_shims();
|
|
764
|
-
|
|
765
|
-
// src/utils/get-jiti.ts
|
|
766
|
-
init_cjs_shims();
|
|
767
|
-
|
|
768
|
-
// ../env/src/get-env-paths.ts
|
|
769
|
-
init_cjs_shims();
|
|
770
|
-
var import_join_paths = require("@stryke/path/join-paths");
|
|
771
|
-
|
|
772
|
-
// ../string-format/src/title-case.ts
|
|
773
|
-
init_cjs_shims();
|
|
774
|
-
|
|
775
|
-
// ../string-format/src/combine.ts
|
|
776
|
-
init_cjs_shims();
|
|
777
|
-
function combine(acc, str) {
|
|
778
|
-
return `${acc} ${str}`;
|
|
779
|
-
}
|
|
780
|
-
__name(combine, "combine");
|
|
781
|
-
|
|
782
|
-
// ../string-format/src/decamelize.ts
|
|
783
|
-
init_cjs_shims();
|
|
784
|
-
function decamelize(value) {
|
|
785
|
-
return value.replace(/([a-z\d])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1_$2").toLowerCase();
|
|
786
|
-
}
|
|
787
|
-
__name(decamelize, "decamelize");
|
|
788
|
-
|
|
789
|
-
// ../string-format/src/format-special-cases.ts
|
|
790
|
-
init_cjs_shims();
|
|
791
|
-
|
|
792
|
-
// ../string-format/src/acronyms.ts
|
|
793
|
-
init_cjs_shims();
|
|
794
|
-
var ACRONYMS = {
|
|
795
|
-
"2D": {
|
|
796
|
-
description: "Two-Dimensional",
|
|
797
|
-
display: "2d"
|
|
798
|
-
},
|
|
799
|
-
"3D": {
|
|
800
|
-
description: "Three-Dimensional",
|
|
801
|
-
display: "3d"
|
|
802
|
-
},
|
|
803
|
-
"4D": {
|
|
804
|
-
description: "Four-Dimensional",
|
|
805
|
-
display: "4d"
|
|
806
|
-
},
|
|
807
|
-
"5G": {
|
|
808
|
-
description: "Fifth Generation (mobile networks)"
|
|
809
|
-
},
|
|
810
|
-
"6G": {
|
|
811
|
-
description: "Sixth Generation (mobile networks)"
|
|
812
|
-
},
|
|
813
|
-
"7G": {
|
|
814
|
-
description: "Seventh Generation (mobile networks)"
|
|
815
|
-
},
|
|
816
|
-
"8G": {
|
|
817
|
-
description: "Eighth Generation (mobile networks)"
|
|
818
|
-
},
|
|
819
|
-
"ACID": {
|
|
820
|
-
description: "Atomicity, Consistency, Isolation, Durability"
|
|
821
|
-
},
|
|
822
|
-
"AITA": {
|
|
823
|
-
description: "Am I The Asshole"
|
|
824
|
-
},
|
|
825
|
-
"AES": {
|
|
826
|
-
description: "Advanced Encryption Standard"
|
|
827
|
-
},
|
|
828
|
-
"AI": {
|
|
829
|
-
description: "Artificial Intelligence"
|
|
830
|
-
},
|
|
831
|
-
"AJAX": {
|
|
832
|
-
description: "Asynchronous JavaScript and XML"
|
|
833
|
-
},
|
|
834
|
-
"API": {
|
|
835
|
-
description: "Application Programming Interface"
|
|
836
|
-
},
|
|
837
|
-
"AR": {
|
|
838
|
-
description: "Augmented Reality"
|
|
839
|
-
},
|
|
840
|
-
"ASCII": {
|
|
841
|
-
description: "American Standard Code for Information Interchange"
|
|
842
|
-
},
|
|
843
|
-
"ATF": {
|
|
844
|
-
description: "Bureau of Alcohol, Tobacco, Firearms and Explosives"
|
|
845
|
-
},
|
|
846
|
-
"ATM": {
|
|
847
|
-
description: "Automated Teller Machine"
|
|
848
|
-
},
|
|
849
|
-
"B2B": {
|
|
850
|
-
description: "Business to Business"
|
|
851
|
-
},
|
|
852
|
-
"B2C": {
|
|
853
|
-
description: "Business to Consumer"
|
|
854
|
-
},
|
|
855
|
-
"BATFE": {
|
|
856
|
-
description: "Bureau of Alcohol, Tobacco, Firearms and Explosives"
|
|
857
|
-
},
|
|
858
|
-
"BFF": {
|
|
859
|
-
description: "Best Friends Forever"
|
|
860
|
-
},
|
|
861
|
-
"BFFS": {
|
|
862
|
-
description: "Best Friends Forever (plural)"
|
|
863
|
-
},
|
|
864
|
-
"BI": {
|
|
865
|
-
description: "Business Intelligence"
|
|
866
|
-
},
|
|
867
|
-
"BIOS": {
|
|
868
|
-
description: "Basic Input/Output System"
|
|
869
|
-
},
|
|
870
|
-
"BGP": {
|
|
871
|
-
description: "Border Gateway Protocol"
|
|
872
|
-
},
|
|
873
|
-
"BOM": {
|
|
874
|
-
description: "Bill of Materials / Byte Order Mark"
|
|
875
|
-
},
|
|
876
|
-
"BSON": {
|
|
877
|
-
description: "Binary JSON"
|
|
878
|
-
},
|
|
879
|
-
"BYOD": {
|
|
880
|
-
description: "Bring Your Own Device"
|
|
881
|
-
},
|
|
882
|
-
"C2C": {
|
|
883
|
-
description: "Consumer to Consumer"
|
|
884
|
-
},
|
|
885
|
-
"CAGR": {
|
|
886
|
-
description: "Compound Annual Growth Rate"
|
|
887
|
-
},
|
|
888
|
-
"CAPTCHA": {
|
|
889
|
-
description: "Completely Automated Public Turing test to tell Computers and Humans Apart"
|
|
890
|
-
},
|
|
891
|
-
"CCTV": {
|
|
892
|
-
description: "Closed-Circuit Television"
|
|
893
|
-
},
|
|
894
|
-
"CD": {
|
|
895
|
-
description: "Continuous Delivery / Compact Disc"
|
|
896
|
-
},
|
|
897
|
-
"CDN": {
|
|
898
|
-
description: "Content Delivery Network"
|
|
899
|
-
},
|
|
900
|
-
"CDP": {
|
|
901
|
-
description: "Customer Data Platform"
|
|
902
|
-
},
|
|
903
|
-
"CDT": {
|
|
904
|
-
description: "Central Daylight Time"
|
|
905
|
-
},
|
|
906
|
-
"CIA": {
|
|
907
|
-
description: "Central Intelligence Agency"
|
|
908
|
-
},
|
|
909
|
-
"CI": {
|
|
910
|
-
description: "Continuous Integration"
|
|
911
|
-
},
|
|
912
|
-
"CI/CD": {
|
|
913
|
-
description: "Continuous Integration/Continuous Delivery"
|
|
914
|
-
},
|
|
915
|
-
"CIAM": {
|
|
916
|
-
description: "Customer Identity and Access Management"
|
|
917
|
-
},
|
|
918
|
-
"CICD": {
|
|
919
|
-
description: "Continuous Integration Continuous Delivery",
|
|
920
|
-
display: "CI/CD"
|
|
921
|
-
},
|
|
922
|
-
"CLI": {
|
|
923
|
-
description: "Command Line Interface"
|
|
924
|
-
},
|
|
925
|
-
"CMDB": {
|
|
926
|
-
description: "Configuration Management Database"
|
|
927
|
-
},
|
|
928
|
-
"CORS": {
|
|
929
|
-
description: "Cross-Origin Resource Sharing"
|
|
930
|
-
},
|
|
931
|
-
"CPA": {
|
|
932
|
-
description: "Certified Public Accountant"
|
|
933
|
-
},
|
|
934
|
-
"CPU": {
|
|
935
|
-
description: "Central Processing Unit"
|
|
936
|
-
},
|
|
937
|
-
"CRUD": {
|
|
938
|
-
description: "Create, Read, Update, Delete"
|
|
939
|
-
},
|
|
940
|
-
"CSR": {
|
|
941
|
-
description: "Certificate Signing Request / Corporate Social Responsibility"
|
|
942
|
-
},
|
|
943
|
-
"CSS": {
|
|
944
|
-
description: "Cascading Style Sheets"
|
|
945
|
-
},
|
|
946
|
-
"CST": {
|
|
947
|
-
description: "Central Standard Time"
|
|
948
|
-
},
|
|
949
|
-
"CTA": {
|
|
950
|
-
description: "Call To Action"
|
|
951
|
-
},
|
|
952
|
-
"CWD": {
|
|
953
|
-
description: "Current Working Directory"
|
|
954
|
-
},
|
|
955
|
-
"CX": {
|
|
956
|
-
description: "Customer Experience"
|
|
957
|
-
},
|
|
958
|
-
"DAG": {
|
|
959
|
-
description: "Directed Acyclic Graph"
|
|
960
|
-
},
|
|
961
|
-
"DBMS": {
|
|
962
|
-
description: "Database Management System"
|
|
963
|
-
},
|
|
964
|
-
"DDOS": {
|
|
965
|
-
description: "Distributed Denial of Service",
|
|
966
|
-
display: "DDoS"
|
|
967
|
-
},
|
|
968
|
-
"DEA": {
|
|
969
|
-
description: "Drug Enforcement Administration"
|
|
970
|
-
},
|
|
971
|
-
"DEVENV": {
|
|
972
|
-
description: "Devenv",
|
|
973
|
-
display: "Devenv"
|
|
974
|
-
},
|
|
975
|
-
"DEVOPS": {
|
|
976
|
-
description: "Development Operations",
|
|
977
|
-
display: "DevOps"
|
|
978
|
-
},
|
|
979
|
-
"DHS": {
|
|
980
|
-
description: "Department of Homeland Security"
|
|
981
|
-
},
|
|
982
|
-
"DIRENV": {
|
|
983
|
-
description: "DirEnv",
|
|
984
|
-
display: "DirEnv"
|
|
985
|
-
},
|
|
986
|
-
"DNC": {
|
|
987
|
-
description: "Democratic National Committee / Do Not Call"
|
|
988
|
-
},
|
|
989
|
-
"DNS": {
|
|
990
|
-
description: "Domain Name System"
|
|
991
|
-
},
|
|
992
|
-
"DNSSEC": {
|
|
993
|
-
description: "Domain Name System Security Extensions"
|
|
994
|
-
},
|
|
995
|
-
"DOD": {
|
|
996
|
-
description: "Department of Defense",
|
|
997
|
-
display: "DoD"
|
|
998
|
-
},
|
|
999
|
-
"DOJ": {
|
|
1000
|
-
description: "Department of Justice",
|
|
1001
|
-
display: "DoJ"
|
|
1002
|
-
},
|
|
1003
|
-
"DOM": {
|
|
1004
|
-
description: "Document Object Model"
|
|
1005
|
-
},
|
|
1006
|
-
"DOT": {
|
|
1007
|
-
description: "Department of Transportation",
|
|
1008
|
-
display: "DoT"
|
|
1009
|
-
},
|
|
1010
|
-
"DOTENV": {
|
|
1011
|
-
description: "Dotenv (.env)",
|
|
1012
|
-
display: "Dotenv"
|
|
1013
|
-
},
|
|
1014
|
-
"DR": {
|
|
1015
|
-
description: "Disaster Recovery"
|
|
1016
|
-
},
|
|
1017
|
-
"DRM": {
|
|
1018
|
-
description: "Digital Rights Management"
|
|
1019
|
-
},
|
|
1020
|
-
"DSN": {
|
|
1021
|
-
description: "Data Source Name"
|
|
1022
|
-
},
|
|
1023
|
-
"DWH": {
|
|
1024
|
-
description: "Data Warehouse"
|
|
1025
|
-
},
|
|
1026
|
-
"E2E": {
|
|
1027
|
-
description: "End to End"
|
|
1028
|
-
},
|
|
1029
|
-
"EAI": {
|
|
1030
|
-
description: "Enterprise Application Integration"
|
|
1031
|
-
},
|
|
1032
|
-
"EDT": {
|
|
1033
|
-
description: "Eastern Daylight Time"
|
|
1034
|
-
},
|
|
1035
|
-
"EEA": {
|
|
1036
|
-
description: "European Economic Area"
|
|
1037
|
-
},
|
|
1038
|
-
"EKS": {
|
|
1039
|
-
description: "Elastic Kubernetes Service"
|
|
1040
|
-
},
|
|
1041
|
-
"EOF": {
|
|
1042
|
-
description: "End Of File"
|
|
1043
|
-
},
|
|
1044
|
-
"EOD": {
|
|
1045
|
-
description: "End Of Day / Explosive Ordnance Disposal"
|
|
1046
|
-
},
|
|
1047
|
-
"EPA": {
|
|
1048
|
-
description: "Environmental Protection Agency"
|
|
1049
|
-
},
|
|
1050
|
-
"ER": {
|
|
1051
|
-
description: "Emergency Room / Entity Relationship"
|
|
1052
|
-
},
|
|
1053
|
-
"EST": {
|
|
1054
|
-
description: "Eastern Standard Time"
|
|
1055
|
-
},
|
|
1056
|
-
"ETC": {
|
|
1057
|
-
description: "Et Cetera"
|
|
1058
|
-
},
|
|
1059
|
-
"ETL": {
|
|
1060
|
-
description: "Extract, Transform, Load"
|
|
1061
|
-
},
|
|
1062
|
-
"EULA": {
|
|
1063
|
-
description: "End User License Agreement"
|
|
1064
|
-
},
|
|
1065
|
-
"FAAS": {
|
|
1066
|
-
description: "Function as a Service",
|
|
1067
|
-
display: "FaaS"
|
|
1068
|
-
},
|
|
1069
|
-
"FAQ": {
|
|
1070
|
-
description: "Frequently Asked Questions",
|
|
1071
|
-
display: "FAQs"
|
|
1072
|
-
},
|
|
1073
|
-
"FAQS": {
|
|
1074
|
-
description: "Frequently Asked Questions"
|
|
1075
|
-
},
|
|
1076
|
-
"FBI": {
|
|
1077
|
-
description: "Federal Bureau of Investigation"
|
|
1078
|
-
},
|
|
1079
|
-
"FCC": {
|
|
1080
|
-
description: "Federal Communications Commission"
|
|
1081
|
-
},
|
|
1082
|
-
"FDA": {
|
|
1083
|
-
description: "Food and Drug Administration"
|
|
1084
|
-
},
|
|
1085
|
-
"FIDO": {
|
|
1086
|
-
description: "Fast IDentity Online"
|
|
1087
|
-
},
|
|
1088
|
-
"FLOTUS": {
|
|
1089
|
-
description: "First Lady of the United States"
|
|
1090
|
-
},
|
|
1091
|
-
"FQDN": {
|
|
1092
|
-
description: "Fully Qualified Domain Name"
|
|
1093
|
-
},
|
|
1094
|
-
"FTC": {
|
|
1095
|
-
description: "Federal Trade Commission"
|
|
1096
|
-
},
|
|
1097
|
-
"FTP": {
|
|
1098
|
-
description: "File Transfer Protocol"
|
|
1099
|
-
},
|
|
1100
|
-
"GC": {
|
|
1101
|
-
description: "Garbage Collection"
|
|
1102
|
-
},
|
|
1103
|
-
"GCP": {
|
|
1104
|
-
description: "Google Cloud Platform"
|
|
1105
|
-
},
|
|
1106
|
-
"GDPR": {
|
|
1107
|
-
description: "General Data Protection Regulation"
|
|
1108
|
-
},
|
|
1109
|
-
"GMT": {
|
|
1110
|
-
description: "Greenwich Mean Time"
|
|
1111
|
-
},
|
|
1112
|
-
"GOP": {
|
|
1113
|
-
description: "Grand Old Party"
|
|
1114
|
-
},
|
|
1115
|
-
"GPU": {
|
|
1116
|
-
description: "Graphics Processing Unit"
|
|
1117
|
-
},
|
|
1118
|
-
"GUID": {
|
|
1119
|
-
description: "Globally Unique Identifier"
|
|
1120
|
-
},
|
|
1121
|
-
"GUI": {
|
|
1122
|
-
description: "Graphical User Interface"
|
|
1123
|
-
},
|
|
1124
|
-
"GZIP": {
|
|
1125
|
-
description: "GNU Zip"
|
|
1126
|
-
},
|
|
1127
|
-
"HCI": {
|
|
1128
|
-
description: "Human Computer Interaction / Hyper-Converged Infrastructure"
|
|
1129
|
-
},
|
|
1130
|
-
"HDD": {
|
|
1131
|
-
description: "Hard Disk Drive"
|
|
1132
|
-
},
|
|
1133
|
-
"HDFS": {
|
|
1134
|
-
description: "Hadoop Distributed File System"
|
|
1135
|
-
},
|
|
1136
|
-
"HHS": {
|
|
1137
|
-
description: "Health and Human Services"
|
|
1138
|
-
},
|
|
1139
|
-
"HIPAA": {
|
|
1140
|
-
description: "Health Insurance Portability and Accountability Act"
|
|
1141
|
-
},
|
|
1142
|
-
"HMAC": {
|
|
1143
|
-
description: "Hash-based Message Authentication Code"
|
|
1144
|
-
},
|
|
1145
|
-
"HOTP": {
|
|
1146
|
-
description: "HMAC-based One-Time Password"
|
|
1147
|
-
},
|
|
1148
|
-
"HSM": {
|
|
1149
|
-
description: "Hardware Security Module"
|
|
1150
|
-
},
|
|
1151
|
-
"HTML": {
|
|
1152
|
-
description: "HyperText Markup Language"
|
|
1153
|
-
},
|
|
1154
|
-
"HTTP": {
|
|
1155
|
-
description: "HyperText Transfer Protocol (HTTP)"
|
|
1156
|
-
},
|
|
1157
|
-
"HTTP/2": {
|
|
1158
|
-
description: "HyperText Transfer Protocol Version 2 (HTTP/2)"
|
|
1159
|
-
},
|
|
1160
|
-
"HTTP/2.0": {
|
|
1161
|
-
description: "HyperText Transfer Protocol Version 2 (HTTP/2)",
|
|
1162
|
-
display: "HTTP2"
|
|
1163
|
-
},
|
|
1164
|
-
"HTTP/3": {
|
|
1165
|
-
description: "HyperText Transfer Protocol Version 3 (HTTP/3)"
|
|
1166
|
-
},
|
|
1167
|
-
"HTTP/3.0": {
|
|
1168
|
-
description: "HyperText Transfer Protocol Version 3 (HTTP/3)",
|
|
1169
|
-
display: "HTTP3"
|
|
1170
|
-
},
|
|
1171
|
-
"HTTP2": {
|
|
1172
|
-
description: "HyperText Transfer Protocol Version 2 (HTTP/2)",
|
|
1173
|
-
display: "HTTP2"
|
|
1174
|
-
},
|
|
1175
|
-
"HTTP2.0": {
|
|
1176
|
-
description: "HyperText Transfer Protocol Version 2 (HTTP/2)",
|
|
1177
|
-
display: "HTTP2"
|
|
1178
|
-
},
|
|
1179
|
-
"HTTP3": {
|
|
1180
|
-
description: "HyperText Transfer Protocol Version 3 (HTTP/3)",
|
|
1181
|
-
display: "HTTP3"
|
|
1182
|
-
},
|
|
1183
|
-
"HTTP3.0": {
|
|
1184
|
-
description: "HyperText Transfer Protocol Version 3 (HTTP/3)",
|
|
1185
|
-
display: "HTTP3"
|
|
1186
|
-
},
|
|
1187
|
-
"HTTPS": {
|
|
1188
|
-
description: "HyperText Transfer Protocol Secure (HTTPS)"
|
|
1189
|
-
},
|
|
1190
|
-
"HTTPS/2": {
|
|
1191
|
-
description: "HyperText Transfer Protocol Secure Version 2 (HTTPS/2)"
|
|
1192
|
-
},
|
|
1193
|
-
"HTTPS/2.0": {
|
|
1194
|
-
description: "HyperText Transfer Protocol Secure Version 2 (HTTPS/2)",
|
|
1195
|
-
display: "HTTPS2"
|
|
1196
|
-
},
|
|
1197
|
-
"HTTPS/3": {
|
|
1198
|
-
description: "HyperText Transfer Protocol Secure Version 3 (HTTPS/3)"
|
|
1199
|
-
},
|
|
1200
|
-
"HTTPS/3.0": {
|
|
1201
|
-
description: "HyperText Transfer Protocol Secure Version 3 (HTTPS/3)",
|
|
1202
|
-
display: "HTTPS3"
|
|
1203
|
-
},
|
|
1204
|
-
"HTTPS2": {
|
|
1205
|
-
description: "HyperText Transfer Protocol Secure Version 2 (HTTPS/2)",
|
|
1206
|
-
display: "HTTPS2"
|
|
1207
|
-
},
|
|
1208
|
-
"HTTPS2.0": {
|
|
1209
|
-
description: "HyperText Transfer Protocol Secure Version 2 (HTTPS/2)",
|
|
1210
|
-
display: "HTTPS2"
|
|
1211
|
-
},
|
|
1212
|
-
"HTTPS3": {
|
|
1213
|
-
description: "HyperText Transfer Protocol Secure Version 3 (HTTPS/3)",
|
|
1214
|
-
display: "HTTPS3"
|
|
1215
|
-
},
|
|
1216
|
-
"HTTPS3.0": {
|
|
1217
|
-
description: "HyperText Transfer Protocol Secure Version 3 (HTTPS/3)",
|
|
1218
|
-
display: "HTTPS3"
|
|
1219
|
-
},
|
|
1220
|
-
"IAAS": {
|
|
1221
|
-
description: "Infrastructure as a Service",
|
|
1222
|
-
display: "IaaS"
|
|
1223
|
-
},
|
|
1224
|
-
"IAM": {
|
|
1225
|
-
description: "Identity and Access Management"
|
|
1226
|
-
},
|
|
1227
|
-
"IAMM": {
|
|
1228
|
-
description: "Identity and Access Management and Monitoring"
|
|
1229
|
-
},
|
|
1230
|
-
"IAMT": {
|
|
1231
|
-
description: "Identity and Access Management Tool"
|
|
1232
|
-
},
|
|
1233
|
-
"ID": {
|
|
1234
|
-
description: "Identifier",
|
|
1235
|
-
display: "Id"
|
|
1236
|
-
},
|
|
1237
|
-
"IFTTT": {
|
|
1238
|
-
description: "If This Then That"
|
|
1239
|
-
},
|
|
1240
|
-
"IMAP": {
|
|
1241
|
-
description: "Internet Message Access Protocol"
|
|
1242
|
-
},
|
|
1243
|
-
"IO": {
|
|
1244
|
-
description: "Input/Output"
|
|
1245
|
-
},
|
|
1246
|
-
"IP": {
|
|
1247
|
-
description: "Internet Protocol"
|
|
1248
|
-
},
|
|
1249
|
-
"IPFS": {
|
|
1250
|
-
description: "InterPlanetary File System"
|
|
1251
|
-
},
|
|
1252
|
-
"IPS": {
|
|
1253
|
-
description: "Intrusion Prevention System"
|
|
1254
|
-
},
|
|
1255
|
-
"ISO": {
|
|
1256
|
-
description: "International Organization for Standardization"
|
|
1257
|
-
},
|
|
1258
|
-
"IQ": {
|
|
1259
|
-
description: "Intelligence Quotient",
|
|
1260
|
-
display: "IQ"
|
|
1261
|
-
},
|
|
1262
|
-
"IOT": {
|
|
1263
|
-
description: "Internet of Things",
|
|
1264
|
-
display: "IoT"
|
|
1265
|
-
},
|
|
1266
|
-
"JSON": {
|
|
1267
|
-
description: "JavaScript Object Notation"
|
|
1268
|
-
},
|
|
1269
|
-
"JSONP": {
|
|
1270
|
-
description: "JSON with Padding"
|
|
1271
|
-
},
|
|
1272
|
-
"JWT": {
|
|
1273
|
-
description: "JSON Web Token"
|
|
1274
|
-
},
|
|
1275
|
-
"K8S": {
|
|
1276
|
-
description: "Kubernetes",
|
|
1277
|
-
display: "K8s"
|
|
1278
|
-
},
|
|
1279
|
-
"KMS": {
|
|
1280
|
-
description: "Key Management Service"
|
|
1281
|
-
},
|
|
1282
|
-
"KPI": {
|
|
1283
|
-
description: "Key Performance Indicator"
|
|
1284
|
-
},
|
|
1285
|
-
"KV": {
|
|
1286
|
-
description: "Key Value"
|
|
1287
|
-
},
|
|
1288
|
-
"LAN": {
|
|
1289
|
-
description: "Local Area Network"
|
|
1290
|
-
},
|
|
1291
|
-
"LHS": {
|
|
1292
|
-
description: "Left Hand Side"
|
|
1293
|
-
},
|
|
1294
|
-
"LPGA": {
|
|
1295
|
-
description: "Ladies Professional Golf Association"
|
|
1296
|
-
},
|
|
1297
|
-
"LXC": {
|
|
1298
|
-
description: "Linux Containers"
|
|
1299
|
-
},
|
|
1300
|
-
"MDT": {
|
|
1301
|
-
description: "Mountain Daylight Time"
|
|
1302
|
-
},
|
|
1303
|
-
"MFA": {
|
|
1304
|
-
description: "Multi-Factor Authentication"
|
|
1305
|
-
},
|
|
1306
|
-
"ML": {
|
|
1307
|
-
description: "Machine Learning"
|
|
1308
|
-
},
|
|
1309
|
-
"MLB": {
|
|
1310
|
-
description: "Major League Baseball"
|
|
1311
|
-
},
|
|
1312
|
-
"MLOps": {
|
|
1313
|
-
description: "Machine Learning Operations"
|
|
1314
|
-
},
|
|
1315
|
-
"MPA": {
|
|
1316
|
-
description: "Multi-Page Application"
|
|
1317
|
-
},
|
|
1318
|
-
"MST": {
|
|
1319
|
-
description: "Mountain Standard Time"
|
|
1320
|
-
},
|
|
1321
|
-
"MVC": {
|
|
1322
|
-
description: "Model View Controller"
|
|
1323
|
-
},
|
|
1324
|
-
"MVP": {
|
|
1325
|
-
description: "Minimum Viable Product / Most Valuable Player"
|
|
1326
|
-
},
|
|
1327
|
-
"NAIA": {
|
|
1328
|
-
description: "National Association of Intercollegiate Athletics"
|
|
1329
|
-
},
|
|
1330
|
-
"NAS": {
|
|
1331
|
-
description: "Network Attached Storage"
|
|
1332
|
-
},
|
|
1333
|
-
"NASA": {
|
|
1334
|
-
description: "National Aeronautics and Space Administration"
|
|
1335
|
-
},
|
|
1336
|
-
"NASCAR": {
|
|
1337
|
-
description: "National Association for Stock Car Auto Racing"
|
|
1338
|
-
},
|
|
1339
|
-
"NAT": {
|
|
1340
|
-
description: "Network Address Translation"
|
|
1341
|
-
},
|
|
1342
|
-
"NBA": {
|
|
1343
|
-
description: "National Basketball Association"
|
|
1344
|
-
},
|
|
1345
|
-
"NCAA": {
|
|
1346
|
-
description: "National Collegiate Athletic Association"
|
|
1347
|
-
},
|
|
1348
|
-
"NDA": {
|
|
1349
|
-
description: "Non-Disclosure Agreement"
|
|
1350
|
-
},
|
|
1351
|
-
"NFS": {
|
|
1352
|
-
description: "Network File System"
|
|
1353
|
-
},
|
|
1354
|
-
"NHL": {
|
|
1355
|
-
description: "National Hockey League"
|
|
1356
|
-
},
|
|
1357
|
-
"NIST": {
|
|
1358
|
-
description: "National Institute of Standards and Technology"
|
|
1359
|
-
},
|
|
1360
|
-
"NLP": {
|
|
1361
|
-
description: "Natural Language Processing"
|
|
1362
|
-
},
|
|
1363
|
-
"NPS": {
|
|
1364
|
-
description: "Net Promoter Score"
|
|
1365
|
-
},
|
|
1366
|
-
"NRA": {
|
|
1367
|
-
description: "National Rifle Association"
|
|
1368
|
-
},
|
|
1369
|
-
"NSFW": {
|
|
1370
|
-
description: "Not Safe For Work"
|
|
1371
|
-
},
|
|
1372
|
-
"NX": {
|
|
1373
|
-
description: "Nx",
|
|
1374
|
-
display: "Nx"
|
|
1375
|
-
},
|
|
1376
|
-
"OCR": {
|
|
1377
|
-
description: "Optical Character Recognition"
|
|
1378
|
-
},
|
|
1379
|
-
"OEM": {
|
|
1380
|
-
description: "Original Equipment Manufacturer"
|
|
1381
|
-
},
|
|
1382
|
-
"OKR": {
|
|
1383
|
-
description: "Objectives and Key Results"
|
|
1384
|
-
},
|
|
1385
|
-
"OLAP": {
|
|
1386
|
-
description: "Online Analytical Processing"
|
|
1387
|
-
},
|
|
1388
|
-
"OLTP": {
|
|
1389
|
-
description: "Online Transaction Processing"
|
|
1390
|
-
},
|
|
1391
|
-
"OOP": {
|
|
1392
|
-
description: "Object Oriented Programming"
|
|
1393
|
-
},
|
|
1394
|
-
"ORM": {
|
|
1395
|
-
description: "Object Relational Mapping"
|
|
1396
|
-
},
|
|
1397
|
-
"OS": {
|
|
1398
|
-
description: "Operating System"
|
|
1399
|
-
},
|
|
1400
|
-
"OSINT": {
|
|
1401
|
-
description: "Open Source Intelligence"
|
|
1402
|
-
},
|
|
1403
|
-
"OSS": {
|
|
1404
|
-
description: "Open Source Software"
|
|
1405
|
-
},
|
|
1406
|
-
"OTP": {
|
|
1407
|
-
description: "One-Time Password"
|
|
1408
|
-
},
|
|
1409
|
-
"P2P": {
|
|
1410
|
-
description: "Peer to Peer"
|
|
1411
|
-
},
|
|
1412
|
-
"PAAS": {
|
|
1413
|
-
description: "Platform as a Service",
|
|
1414
|
-
display: "PaaS"
|
|
1415
|
-
},
|
|
1416
|
-
"PCI": {
|
|
1417
|
-
description: "Payment Card Industry"
|
|
1418
|
-
},
|
|
1419
|
-
"PDP": {
|
|
1420
|
-
description: "Policy Decision Point / Product Detail Page"
|
|
1421
|
-
},
|
|
1422
|
-
"PDT": {
|
|
1423
|
-
description: "Pacific Daylight Time"
|
|
1424
|
-
},
|
|
1425
|
-
"PGA": {
|
|
1426
|
-
description: "Professional Golfers' Association"
|
|
1427
|
-
},
|
|
1428
|
-
"POTUS": {
|
|
1429
|
-
description: "President of the United States"
|
|
1430
|
-
},
|
|
1431
|
-
"PP": {
|
|
1432
|
-
description: "Pages / PayPal / Percentage Points"
|
|
1433
|
-
},
|
|
1434
|
-
"PST": {
|
|
1435
|
-
description: "Pacific Standard Time"
|
|
1436
|
-
},
|
|
1437
|
-
"PTO": {
|
|
1438
|
-
description: "Paid Time Off / Power Take-Off"
|
|
1439
|
-
},
|
|
1440
|
-
"PKI": {
|
|
1441
|
-
description: "Public Key Infrastructure"
|
|
1442
|
-
},
|
|
1443
|
-
"PWA": {
|
|
1444
|
-
description: "Progressive Web App"
|
|
1445
|
-
},
|
|
1446
|
-
"PX": {
|
|
1447
|
-
description: "Pixel"
|
|
1448
|
-
},
|
|
1449
|
-
"QA": {
|
|
1450
|
-
description: "Quality Assurance"
|
|
1451
|
-
},
|
|
1452
|
-
"R2": {
|
|
1453
|
-
description: "R2"
|
|
1454
|
-
},
|
|
1455
|
-
"RAID": {
|
|
1456
|
-
description: "Redundant Array of Independent Disks"
|
|
1457
|
-
},
|
|
1458
|
-
"RAM": {
|
|
1459
|
-
description: "Random Access Memory"
|
|
1460
|
-
},
|
|
1461
|
-
"RDS": {
|
|
1462
|
-
description: "Relational Database Service"
|
|
1463
|
-
},
|
|
1464
|
-
"REST": {
|
|
1465
|
-
description: "Representational State Transfer"
|
|
1466
|
-
},
|
|
1467
|
-
"RHS": {
|
|
1468
|
-
description: "Right Hand Side"
|
|
1469
|
-
},
|
|
1470
|
-
"ROI": {
|
|
1471
|
-
description: "Return on Investment"
|
|
1472
|
-
},
|
|
1473
|
-
"RPC": {
|
|
1474
|
-
description: "Remote Procedure Call"
|
|
1475
|
-
},
|
|
1476
|
-
"RPA": {
|
|
1477
|
-
description: "Robotic Process Automation"
|
|
1478
|
-
},
|
|
1479
|
-
"RSC": {
|
|
1480
|
-
description: "React Server Components"
|
|
1481
|
-
},
|
|
1482
|
-
"RSS": {
|
|
1483
|
-
description: "Really Simple Syndication"
|
|
1484
|
-
},
|
|
1485
|
-
"RUM": {
|
|
1486
|
-
description: "Real User Monitoring"
|
|
1487
|
-
},
|
|
1488
|
-
"S3": {
|
|
1489
|
-
description: "Simple Storage Service (S3)"
|
|
1490
|
-
},
|
|
1491
|
-
"SAN": {
|
|
1492
|
-
description: "Storage Area Network"
|
|
1493
|
-
},
|
|
1494
|
-
"SASE": {
|
|
1495
|
-
description: "Secure Access Service Edge"
|
|
1496
|
-
},
|
|
1497
|
-
"SCOTUS": {
|
|
1498
|
-
description: "Supreme Court of the United States"
|
|
1499
|
-
},
|
|
1500
|
-
"SDLC": {
|
|
1501
|
-
description: "Software Development Life Cycle"
|
|
1502
|
-
},
|
|
1503
|
-
"SDK": {
|
|
1504
|
-
description: "Software Development Kit"
|
|
1505
|
-
},
|
|
1506
|
-
"SEC": {
|
|
1507
|
-
description: "Securities and Exchange Commission"
|
|
1508
|
-
},
|
|
1509
|
-
"SEO": {
|
|
1510
|
-
description: "Search Engine Optimization"
|
|
1511
|
-
},
|
|
1512
|
-
"SFTP": {
|
|
1513
|
-
description: "SSH File Transfer Protocol / Secure File Transfer Protocol"
|
|
1514
|
-
},
|
|
1515
|
-
"SIEM": {
|
|
1516
|
-
description: "Security Information and Event Management"
|
|
1517
|
-
},
|
|
1518
|
-
"SLA": {
|
|
1519
|
-
description: "Service Level Agreement"
|
|
1520
|
-
},
|
|
1521
|
-
"SMB": {
|
|
1522
|
-
description: "Server Message Block / Small and Medium Business"
|
|
1523
|
-
},
|
|
1524
|
-
"SMTP": {
|
|
1525
|
-
description: "Simple Mail Transfer Protocol"
|
|
1526
|
-
},
|
|
1527
|
-
"SOAP": {
|
|
1528
|
-
description: "Simple Object Access Protocol"
|
|
1529
|
-
},
|
|
1530
|
-
"SOA": {
|
|
1531
|
-
description: "Service Oriented Architecture"
|
|
1532
|
-
},
|
|
1533
|
-
"SOC": {
|
|
1534
|
-
description: "Security Operations Center / System on Chip"
|
|
1535
|
-
},
|
|
1536
|
-
"SPA": {
|
|
1537
|
-
description: "Single Page Application"
|
|
1538
|
-
},
|
|
1539
|
-
"SPDY": {
|
|
1540
|
-
description: 'Speedy (pronounced "SPeeDY")'
|
|
1541
|
-
},
|
|
1542
|
-
"SPF": {
|
|
1543
|
-
description: "Sender Policy Framework"
|
|
1544
|
-
},
|
|
1545
|
-
"SQL": {
|
|
1546
|
-
description: "Structured Query Language"
|
|
1547
|
-
},
|
|
1548
|
-
"SRV": {
|
|
1549
|
-
description: "Service"
|
|
1550
|
-
},
|
|
1551
|
-
"SRE": {
|
|
1552
|
-
description: "Site Reliability Engineering"
|
|
1553
|
-
},
|
|
1554
|
-
"SSH": {
|
|
1555
|
-
description: "Secure Shell"
|
|
1556
|
-
},
|
|
1557
|
-
"SSDL": {
|
|
1558
|
-
description: "Secure Software Development Lifecycle"
|
|
1559
|
-
},
|
|
1560
|
-
"SSG": {
|
|
1561
|
-
description: "Static Site Generation"
|
|
1562
|
-
},
|
|
1563
|
-
"SSR": {
|
|
1564
|
-
description: "Server Side Rendering"
|
|
1565
|
-
},
|
|
1566
|
-
"SSO": {
|
|
1567
|
-
description: "Single Sign-On"
|
|
1568
|
-
},
|
|
1569
|
-
"SSL": {
|
|
1570
|
-
description: "Secure Sockets Layer"
|
|
1571
|
-
},
|
|
1572
|
-
"TDD": {
|
|
1573
|
-
description: "Test Driven Development"
|
|
1574
|
-
},
|
|
1575
|
-
"TLD": {
|
|
1576
|
-
description: "Top Level Domain"
|
|
1577
|
-
},
|
|
1578
|
-
"TLS": {
|
|
1579
|
-
description: "Transport Layer Security"
|
|
1580
|
-
},
|
|
1581
|
-
"TLS1.3": {
|
|
1582
|
-
description: "Transport Layer Security 1.3"
|
|
1583
|
-
},
|
|
1584
|
-
"TOR": {
|
|
1585
|
-
description: "The Onion Router"
|
|
1586
|
-
},
|
|
1587
|
-
"TOTP": {
|
|
1588
|
-
description: "Time-based One-Time Password"
|
|
1589
|
-
},
|
|
1590
|
-
"TRPC": {
|
|
1591
|
-
description: "TypeScript Remote Procedure Call"
|
|
1592
|
-
},
|
|
1593
|
-
"TSA": {
|
|
1594
|
-
description: "Transportation Security Administration"
|
|
1595
|
-
},
|
|
1596
|
-
"TTL": {
|
|
1597
|
-
description: "Time To Live"
|
|
1598
|
-
},
|
|
1599
|
-
"UDP": {
|
|
1600
|
-
description: "User Datagram Protocol"
|
|
1601
|
-
},
|
|
1602
|
-
"UI": {
|
|
1603
|
-
description: "User Interface"
|
|
1604
|
-
},
|
|
1605
|
-
"UID": {
|
|
1606
|
-
description: "Unique Identifier"
|
|
1607
|
-
},
|
|
1608
|
-
"URI": {
|
|
1609
|
-
description: "Uniform Resource Identifier"
|
|
1610
|
-
},
|
|
1611
|
-
"URL": {
|
|
1612
|
-
description: "Uniform Resource Locator"
|
|
1613
|
-
},
|
|
1614
|
-
"USOPC": {
|
|
1615
|
-
description: "United States Olympic & Paralympic Committee"
|
|
1616
|
-
},
|
|
1617
|
-
"USPS": {
|
|
1618
|
-
description: "United States Postal Service"
|
|
1619
|
-
},
|
|
1620
|
-
"USTA": {
|
|
1621
|
-
description: "United States Tennis Association"
|
|
1622
|
-
},
|
|
1623
|
-
"UTF": {
|
|
1624
|
-
description: "Unicode Transformation Format"
|
|
1625
|
-
},
|
|
1626
|
-
"UTC": {
|
|
1627
|
-
description: "Coordinated Universal Time"
|
|
1628
|
-
},
|
|
1629
|
-
"UUID": {
|
|
1630
|
-
description: "Universally Unique Identifier"
|
|
1631
|
-
},
|
|
1632
|
-
"UX": {
|
|
1633
|
-
description: "User Experience"
|
|
1634
|
-
},
|
|
1635
|
-
"VM": {
|
|
1636
|
-
description: "Virtual Machine"
|
|
1637
|
-
},
|
|
1638
|
-
"VLAN": {
|
|
1639
|
-
description: "Virtual Local Area Network"
|
|
1640
|
-
},
|
|
1641
|
-
"VPN": {
|
|
1642
|
-
description: "Virtual Private Network"
|
|
1643
|
-
},
|
|
1644
|
-
"VPPA": {
|
|
1645
|
-
description: "Video Privacy Protection Act"
|
|
1646
|
-
},
|
|
1647
|
-
"VR": {
|
|
1648
|
-
description: "Virtual Reality"
|
|
1649
|
-
},
|
|
1650
|
-
"WAF": {
|
|
1651
|
-
description: "Web Application Firewall"
|
|
1652
|
-
},
|
|
1653
|
-
"WAN": {
|
|
1654
|
-
description: "Wide Area Network"
|
|
1655
|
-
},
|
|
1656
|
-
"WNBA": {
|
|
1657
|
-
description: "Women's National Basketball Association"
|
|
1658
|
-
},
|
|
1659
|
-
"WLAN": {
|
|
1660
|
-
description: "Wireless Local Area Network"
|
|
1661
|
-
},
|
|
1662
|
-
"WPA": {
|
|
1663
|
-
description: "Wi-Fi Protected Access"
|
|
1664
|
-
},
|
|
1665
|
-
"WPA2": {
|
|
1666
|
-
description: "Wi-Fi Protected Access II"
|
|
1667
|
-
},
|
|
1668
|
-
"WPA3": {
|
|
1669
|
-
description: "Wi-Fi Protected Access III"
|
|
1670
|
-
},
|
|
1671
|
-
"WWW": {
|
|
1672
|
-
description: "World Wide Web"
|
|
1673
|
-
},
|
|
1674
|
-
"WYSIWYG": {
|
|
1675
|
-
description: "What You See Is What You Get"
|
|
1676
|
-
},
|
|
1677
|
-
"XACML": {
|
|
1678
|
-
description: "eXtensible Access Control Markup Language"
|
|
1679
|
-
},
|
|
1680
|
-
"XDG": {
|
|
1681
|
-
description: "Cross-Desktop Group"
|
|
1682
|
-
},
|
|
1683
|
-
"XML": {
|
|
1684
|
-
description: "eXtensible Markup Language"
|
|
1685
|
-
},
|
|
1686
|
-
"XSRF": {
|
|
1687
|
-
description: "Cross-Site Request Forgery"
|
|
1688
|
-
},
|
|
1689
|
-
"XSS": {
|
|
1690
|
-
description: "Cross-Site Scripting"
|
|
1691
|
-
},
|
|
1692
|
-
"XR": {
|
|
1693
|
-
description: "Extended Reality"
|
|
1694
|
-
},
|
|
1695
|
-
"YAML": {
|
|
1696
|
-
description: "YAML Ain't Markup Language"
|
|
1697
|
-
},
|
|
1698
|
-
"YMCA": {
|
|
1699
|
-
description: "Young Men's Christian Association"
|
|
1700
|
-
},
|
|
1701
|
-
"YWCA": {
|
|
1702
|
-
description: "Young Women's Christian Association"
|
|
1703
|
-
},
|
|
1704
|
-
"ZTA": {
|
|
1705
|
-
description: "Zero Trust Architecture"
|
|
1706
|
-
}
|
|
1707
|
-
};
|
|
1708
|
-
var ACRONYM_DISPLAY = Object.fromEntries(Object.entries(ACRONYMS).map(([key, value]) => [
|
|
1709
|
-
key,
|
|
1710
|
-
value.display ?? key
|
|
1711
|
-
]));
|
|
1712
|
-
var ACRONYM_DESCRIPTION = Object.fromEntries(Object.entries(ACRONYMS).map(([key, value]) => [
|
|
1713
|
-
key,
|
|
1714
|
-
value.description
|
|
1715
|
-
]));
|
|
1716
|
-
var ACRONYM_LIST = Object.keys(ACRONYMS);
|
|
1717
|
-
|
|
1718
|
-
// ../string-format/src/articles.ts
|
|
1719
|
-
init_cjs_shims();
|
|
1720
|
-
var ARTICLES = [
|
|
1721
|
-
"a",
|
|
1722
|
-
"an",
|
|
1723
|
-
"the"
|
|
1724
|
-
];
|
|
1725
|
-
|
|
1726
|
-
// ../string-format/src/conjunctions.ts
|
|
1727
|
-
init_cjs_shims();
|
|
1728
|
-
var CONJUNCTIONS = [
|
|
1729
|
-
"and",
|
|
1730
|
-
"that",
|
|
1731
|
-
"but",
|
|
1732
|
-
"or",
|
|
1733
|
-
"as",
|
|
1734
|
-
"if",
|
|
1735
|
-
"when",
|
|
1736
|
-
"than",
|
|
1737
|
-
"because",
|
|
1738
|
-
"while",
|
|
1739
|
-
"where",
|
|
1740
|
-
"after",
|
|
1741
|
-
"so",
|
|
1742
|
-
"though",
|
|
1743
|
-
"since",
|
|
1744
|
-
"until",
|
|
1745
|
-
"whether",
|
|
1746
|
-
"before",
|
|
1747
|
-
"although",
|
|
1748
|
-
"nor",
|
|
1749
|
-
"like",
|
|
1750
|
-
"once",
|
|
1751
|
-
"unless",
|
|
1752
|
-
"now",
|
|
1753
|
-
"except"
|
|
1754
|
-
];
|
|
1755
|
-
|
|
1756
|
-
// ../string-format/src/prepositions.ts
|
|
1757
|
-
init_cjs_shims();
|
|
1758
|
-
var PREPOSITIONS = [
|
|
1759
|
-
"about",
|
|
1760
|
-
"above",
|
|
1761
|
-
"across",
|
|
1762
|
-
"after",
|
|
1763
|
-
"against",
|
|
1764
|
-
"along",
|
|
1765
|
-
"among",
|
|
1766
|
-
"around",
|
|
1767
|
-
"at",
|
|
1768
|
-
"because of",
|
|
1769
|
-
"before",
|
|
1770
|
-
"behind",
|
|
1771
|
-
"below",
|
|
1772
|
-
"beneath",
|
|
1773
|
-
"beside",
|
|
1774
|
-
"besides",
|
|
1775
|
-
"between",
|
|
1776
|
-
"beyond",
|
|
1777
|
-
"but",
|
|
1778
|
-
"by",
|
|
1779
|
-
"concerning",
|
|
1780
|
-
"despite",
|
|
1781
|
-
"down",
|
|
1782
|
-
"during",
|
|
1783
|
-
"except",
|
|
1784
|
-
"excepting",
|
|
1785
|
-
"for",
|
|
1786
|
-
"from",
|
|
1787
|
-
"in",
|
|
1788
|
-
"in front of",
|
|
1789
|
-
"inside",
|
|
1790
|
-
"in spite of",
|
|
1791
|
-
"instead of",
|
|
1792
|
-
"into",
|
|
1793
|
-
"like",
|
|
1794
|
-
"near",
|
|
1795
|
-
"of",
|
|
1796
|
-
"off",
|
|
1797
|
-
"on",
|
|
1798
|
-
"onto",
|
|
1799
|
-
"out",
|
|
1800
|
-
"outside",
|
|
1801
|
-
"over",
|
|
1802
|
-
"past",
|
|
1803
|
-
"regarding",
|
|
1804
|
-
"since",
|
|
1805
|
-
"through",
|
|
1806
|
-
"throughout",
|
|
1807
|
-
"to",
|
|
1808
|
-
"toward",
|
|
1809
|
-
"under",
|
|
1810
|
-
"underneath",
|
|
1811
|
-
"until",
|
|
1812
|
-
"up",
|
|
1813
|
-
"upon",
|
|
1814
|
-
"up to",
|
|
1815
|
-
"with",
|
|
1816
|
-
"within",
|
|
1817
|
-
"without",
|
|
1818
|
-
"with regard to",
|
|
1819
|
-
"with respect to"
|
|
1820
|
-
];
|
|
1821
|
-
|
|
1822
|
-
// ../string-format/src/special-cases.ts
|
|
1823
|
-
init_cjs_shims();
|
|
1824
|
-
var SPECIAL_CASES = [
|
|
1825
|
-
"2FA",
|
|
1826
|
-
"4K",
|
|
1827
|
-
"5K",
|
|
1828
|
-
"8K",
|
|
1829
|
-
"AGI",
|
|
1830
|
-
"BI",
|
|
1831
|
-
"ChatGPT",
|
|
1832
|
-
"CTA",
|
|
1833
|
-
"DateTime",
|
|
1834
|
-
"FMS",
|
|
1835
|
-
"GitHub",
|
|
1836
|
-
"GPT",
|
|
1837
|
-
"HD",
|
|
1838
|
-
"IBMid",
|
|
1839
|
-
"IDs",
|
|
1840
|
-
"iMac",
|
|
1841
|
-
"IMAX",
|
|
1842
|
-
"iOS",
|
|
1843
|
-
"iPad",
|
|
1844
|
-
"iPhone",
|
|
1845
|
-
"iPod",
|
|
1846
|
-
"LDAP",
|
|
1847
|
-
"LinkedIn",
|
|
1848
|
-
"LLM",
|
|
1849
|
-
"macOS",
|
|
1850
|
-
"McDonalds",
|
|
1851
|
-
"MCP",
|
|
1852
|
-
"ML",
|
|
1853
|
-
"MySQL",
|
|
1854
|
-
"NLG",
|
|
1855
|
-
"NLP",
|
|
1856
|
-
"NLU",
|
|
1857
|
-
"OpenAI",
|
|
1858
|
-
"PDFs",
|
|
1859
|
-
"PIM",
|
|
1860
|
-
"PEFT",
|
|
1861
|
-
"pH",
|
|
1862
|
-
"PostgreSQL",
|
|
1863
|
-
"SEO",
|
|
1864
|
-
"TTS",
|
|
1865
|
-
"UHD",
|
|
1866
|
-
"UUID",
|
|
1867
|
-
"XSS",
|
|
1868
|
-
"YouTube",
|
|
1869
|
-
"CSpell",
|
|
1870
|
-
"ESLint"
|
|
1871
|
-
];
|
|
1872
|
-
|
|
1873
|
-
// ../string-format/src/format-special-cases.ts
|
|
1874
|
-
function formatSpecialCases(value, index, words, options) {
|
|
1875
|
-
const lowercaseStr = value.toLowerCase();
|
|
1876
|
-
const uppercaseStr = value.toUpperCase();
|
|
1877
|
-
for (const special of SPECIAL_CASES) {
|
|
1878
|
-
if (special.toLowerCase() === lowercaseStr) {
|
|
1879
|
-
return special;
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
if (ACRONYMS[uppercaseStr]) {
|
|
1883
|
-
return options?.useDescriptions !== false ? ACRONYMS[uppercaseStr].description : ACRONYMS[uppercaseStr].display || uppercaseStr;
|
|
1884
|
-
}
|
|
1885
|
-
if (index === 0) {
|
|
1886
|
-
return value;
|
|
1887
|
-
}
|
|
1888
|
-
if (index === words.length - 1) {
|
|
1889
|
-
return value;
|
|
1890
|
-
}
|
|
1891
|
-
if (value.length >= 4) {
|
|
1892
|
-
return value;
|
|
1893
|
-
}
|
|
1894
|
-
if (PREPOSITIONS.includes(lowercaseStr)) {
|
|
1895
|
-
return lowercaseStr;
|
|
1896
|
-
}
|
|
1897
|
-
if (CONJUNCTIONS.includes(lowercaseStr)) {
|
|
1898
|
-
return lowercaseStr;
|
|
1899
|
-
}
|
|
1900
|
-
if (ARTICLES.includes(lowercaseStr)) {
|
|
1901
|
-
return lowercaseStr;
|
|
1902
|
-
}
|
|
1903
|
-
return value;
|
|
1904
|
-
}
|
|
1905
|
-
__name(formatSpecialCases, "formatSpecialCases");
|
|
1906
|
-
|
|
1907
|
-
// ../string-format/src/upper-case-first.ts
|
|
1908
|
-
init_cjs_shims();
|
|
1909
|
-
function upperCaseFirst(input) {
|
|
1910
|
-
return input ? input.charAt(0).toUpperCase() + input.slice(1) : input;
|
|
1911
|
-
}
|
|
1912
|
-
__name(upperCaseFirst, "upperCaseFirst");
|
|
1913
|
-
|
|
1914
|
-
// ../string-format/src/title-case.ts
|
|
1915
|
-
function titleCase(input, options) {
|
|
1916
|
-
return input?.split(/\s+-\s+/).map((segment) => decamelize(segment).split(/[\s\-_]/).map(upperCaseFirst).map((value, index, array) => formatSpecialCases(value, index, array, options)).reduce(combine)).join(" - ");
|
|
1917
|
-
}
|
|
1918
|
-
__name(titleCase, "titleCase");
|
|
1919
|
-
|
|
1920
|
-
// ../env/src/get-env-paths.ts
|
|
1921
|
-
var import_node_os = __toESM(require("node:os"), 1);
|
|
1922
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
1923
|
-
var homedir = import_node_os.default.homedir();
|
|
1924
|
-
var tmpdir = import_node_os.default.tmpdir();
|
|
1925
|
-
var macos = /* @__PURE__ */ __name((orgId) => {
|
|
1926
|
-
const library = (0, import_join_paths.joinPaths)(homedir, "Library");
|
|
1927
|
-
return {
|
|
1928
|
-
data: (0, import_join_paths.joinPaths)(library, "Application Support", orgId),
|
|
1929
|
-
config: (0, import_join_paths.joinPaths)(library, "Preferences", orgId),
|
|
1930
|
-
cache: (0, import_join_paths.joinPaths)(library, "Caches", orgId),
|
|
1931
|
-
log: (0, import_join_paths.joinPaths)(library, "Logs", orgId),
|
|
1932
|
-
temp: (0, import_join_paths.joinPaths)(tmpdir, orgId)
|
|
1933
|
-
};
|
|
1934
|
-
}, "macos");
|
|
1935
|
-
var windows = /* @__PURE__ */ __name((orgId) => {
|
|
1936
|
-
const appData = process.env.APPDATA || (0, import_join_paths.joinPaths)(homedir, "AppData", "Roaming");
|
|
1937
|
-
const localAppData = process.env.LOCALAPPDATA || (0, import_join_paths.joinPaths)(homedir, "AppData", "Local");
|
|
1938
|
-
const windowsFormattedOrgId = titleCase(orgId).trim().replace(/\s+/g, "");
|
|
1939
|
-
return {
|
|
1940
|
-
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
1941
|
-
data: (0, import_join_paths.joinPaths)(localAppData, windowsFormattedOrgId, "Data"),
|
|
1942
|
-
config: (0, import_join_paths.joinPaths)(appData, windowsFormattedOrgId, "Config"),
|
|
1943
|
-
cache: (0, import_join_paths.joinPaths)(localAppData, "Cache", orgId),
|
|
1944
|
-
log: (0, import_join_paths.joinPaths)(localAppData, windowsFormattedOrgId, "Log"),
|
|
1945
|
-
temp: (0, import_join_paths.joinPaths)(tmpdir, orgId)
|
|
1946
|
-
};
|
|
1947
|
-
}, "windows");
|
|
1948
|
-
var linux = /* @__PURE__ */ __name((orgId) => {
|
|
1949
|
-
const username = import_node_path.default.basename(homedir);
|
|
1950
|
-
return {
|
|
1951
|
-
data: (0, import_join_paths.joinPaths)(process.env.XDG_DATA_HOME || (0, import_join_paths.joinPaths)(homedir, ".local", "share"), orgId),
|
|
1952
|
-
config: (0, import_join_paths.joinPaths)(process.env.XDG_CONFIG_HOME || (0, import_join_paths.joinPaths)(homedir, ".config"), orgId),
|
|
1953
|
-
cache: (0, import_join_paths.joinPaths)(process.env.XDG_CACHE_HOME || (0, import_join_paths.joinPaths)(homedir, ".cache"), orgId),
|
|
1954
|
-
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
1955
|
-
log: (0, import_join_paths.joinPaths)(process.env.XDG_STATE_HOME || (0, import_join_paths.joinPaths)(homedir, ".local", "state"), orgId),
|
|
1956
|
-
// https://devenv.sh/files-and-variables/#devenv_root
|
|
1957
|
-
temp: process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR ? (0, import_join_paths.joinPaths)(process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR, orgId) : (0, import_join_paths.joinPaths)(tmpdir, username, orgId)
|
|
1958
|
-
};
|
|
1959
|
-
}, "linux");
|
|
1960
|
-
function getEnvPaths(options = {}) {
|
|
1961
|
-
let orgId = options.orgId || "storm-software";
|
|
1962
|
-
if (!orgId) {
|
|
1963
|
-
throw new Error("You need to provide an orgId to the `getEnvPaths` function");
|
|
1964
|
-
}
|
|
1965
|
-
if (options.suffix) {
|
|
1966
|
-
orgId += `-${typeof options.suffix === "string" ? options.suffix : "nodejs"}`;
|
|
1967
|
-
}
|
|
1968
|
-
let result = {};
|
|
1969
|
-
if (process.platform === "darwin") {
|
|
1970
|
-
result = macos(orgId);
|
|
1971
|
-
} else if (process.platform === "win32") {
|
|
1972
|
-
result = windows(orgId);
|
|
1973
|
-
} else {
|
|
1974
|
-
result = linux(orgId);
|
|
1975
|
-
}
|
|
1976
|
-
if (process.env.STORM_DATA_DIR) {
|
|
1977
|
-
result.data = process.env.STORM_DATA_DIR;
|
|
1978
|
-
} else if (process.env.STORM_CONFIG_DIR) {
|
|
1979
|
-
result.config = process.env.STORM_CONFIG_DIR;
|
|
1980
|
-
} else if (process.env.STORM_CACHE_DIR) {
|
|
1981
|
-
result.cache = process.env.STORM_CACHE_DIR;
|
|
1982
|
-
} else if (process.env.STORM_LOG_DIR) {
|
|
1983
|
-
result.log = process.env.STORM_LOG_DIR;
|
|
1984
|
-
} else if (process.env.STORM_TEMP_DIR) {
|
|
1985
|
-
result.temp = process.env.STORM_TEMP_DIR;
|
|
1986
|
-
}
|
|
1987
|
-
if (options.workspaceRoot) {
|
|
1988
|
-
result.cache ??= (0, import_join_paths.joinPaths)(options.workspaceRoot, "node_modules", ".cache", orgId);
|
|
1989
|
-
result.temp ??= (0, import_join_paths.joinPaths)(options.workspaceRoot, "tmp", orgId);
|
|
1990
|
-
result.log ??= (0, import_join_paths.joinPaths)(result.temp, "logs");
|
|
1991
|
-
result.config ??= (0, import_join_paths.joinPaths)(options.workspaceRoot, ".config", orgId);
|
|
1992
|
-
}
|
|
1993
|
-
return Object.keys(result).reduce((ret, key) => {
|
|
1994
|
-
if (result[key]) {
|
|
1995
|
-
const filePath = result[key];
|
|
1996
|
-
ret[key] = options.appId && options.appId !== options.orgId && options.appId !== options.nestedDir ? (0, import_join_paths.joinPaths)(filePath, options.appId) : filePath;
|
|
1997
|
-
if (options.nestedDir && options.nestedDir !== options.orgId && options.nestedDir !== options.appId) {
|
|
1998
|
-
ret[key] = (0, import_join_paths.joinPaths)(ret[key], options.nestedDir);
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2001
|
-
return ret;
|
|
2002
|
-
}, {});
|
|
2003
|
-
}
|
|
2004
|
-
__name(getEnvPaths, "getEnvPaths");
|
|
2005
|
-
|
|
2006
|
-
// src/utils/get-jiti.ts
|
|
2007
|
-
var import_get_workspace_root = require("@stryke/fs/get-workspace-root");
|
|
2008
|
-
var import_join_paths2 = require("@stryke/path/join-paths");
|
|
2009
|
-
var import_jiti = require("jiti");
|
|
2010
|
-
var jiti;
|
|
2011
|
-
function getJiti() {
|
|
2012
|
-
if (!jiti) {
|
|
2013
|
-
const envPaths = getEnvPaths();
|
|
2014
|
-
jiti = (0, import_jiti.createJiti)((0, import_get_workspace_root.getWorkspaceRoot)(), {
|
|
2015
|
-
fsCache: (0, import_join_paths2.joinPaths)(envPaths.cache, "jiti"),
|
|
2016
|
-
interopDefault: true
|
|
2017
|
-
});
|
|
2018
|
-
}
|
|
2019
|
-
return jiti;
|
|
2020
|
-
}
|
|
2021
|
-
__name(getJiti, "getJiti");
|
|
2022
|
-
|
|
2023
|
-
// src/utils/get-prisma-internals.ts
|
|
2024
|
-
async function getPrismaInternals() {
|
|
2025
|
-
return getJiti().import(getJiti().esmResolve("@prisma/internals"));
|
|
2026
|
-
}
|
|
2027
|
-
__name(getPrismaInternals, "getPrismaInternals");
|
|
2028
|
-
async function getPrismaGeneratorHelper() {
|
|
2029
|
-
return getJiti().import(getJiti().esmResolve("@prisma/generator-helper"));
|
|
2030
|
-
}
|
|
2031
|
-
__name(getPrismaGeneratorHelper, "getPrismaGeneratorHelper");
|
|
2032
|
-
|
|
2033
|
-
// src/zod/model-helpers.ts
|
|
2034
|
-
init_cjs_shims();
|
|
2035
|
-
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
2036
|
-
var import_ts_morph2 = require("ts-morph");
|
|
2037
|
-
|
|
2038
|
-
// src/zod/docs-helpers.ts
|
|
2039
|
-
init_cjs_shims();
|
|
2040
|
-
var import_parenthesis = __toESM(require("parenthesis"), 1);
|
|
2041
|
-
var getJSDocs = /* @__PURE__ */ __name((docString) => {
|
|
2042
|
-
const lines = [];
|
|
2043
|
-
if (docString) {
|
|
2044
|
-
const docLines = docString.split("\n").filter((dL) => !dL.trimStart().startsWith("@zod"));
|
|
2045
|
-
if (docLines.length) {
|
|
2046
|
-
lines.push("/**");
|
|
2047
|
-
docLines.forEach((dL) => lines.push(` * ${dL}`));
|
|
2048
|
-
lines.push(" */");
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
return lines;
|
|
2052
|
-
}, "getJSDocs");
|
|
2053
|
-
var getZodDocElements = /* @__PURE__ */ __name((docString) => docString.split("\n").filter((line) => line.trimStart().startsWith("@zod")).map((line) => line.trimStart().slice(4)).flatMap((line) => (
|
|
2054
|
-
// Array.from(line.matchAll(/\.([^().]+\(.*?\))/g), (m) => m.slice(1)).flat()
|
|
2055
|
-
chunk(import_parenthesis.default.parse(line), 2).slice(0, -1).map(([each, contents]) => `${each.replace(/\)?\./, "")}${import_parenthesis.default.stringify(contents)})`)
|
|
2056
|
-
)), "getZodDocElements");
|
|
2057
|
-
|
|
2058
|
-
// src/zod/model-helpers.ts
|
|
2059
|
-
function checkModelHasModelRelation(model) {
|
|
2060
|
-
const { fields: modelFields } = model;
|
|
2061
|
-
for (const modelField of modelFields) {
|
|
2062
|
-
const isRelationField = checkIsModelRelationField(modelField);
|
|
2063
|
-
if (isRelationField) {
|
|
2064
|
-
return true;
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
return false;
|
|
2068
|
-
}
|
|
2069
|
-
__name(checkModelHasModelRelation, "checkModelHasModelRelation");
|
|
2070
|
-
function checkModelHasManyModelRelation(model) {
|
|
2071
|
-
const { fields: modelFields } = model;
|
|
2072
|
-
for (const modelField of modelFields) {
|
|
2073
|
-
const isManyRelationField = checkIsManyModelRelationField(modelField);
|
|
2074
|
-
if (isManyRelationField) {
|
|
2075
|
-
return true;
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
return false;
|
|
2079
|
-
}
|
|
2080
|
-
__name(checkModelHasManyModelRelation, "checkModelHasManyModelRelation");
|
|
2081
|
-
function checkIsModelRelationField(modelField) {
|
|
2082
|
-
const { kind, relationName } = modelField;
|
|
2083
|
-
return kind === "object" && !!relationName;
|
|
2084
|
-
}
|
|
2085
|
-
__name(checkIsModelRelationField, "checkIsModelRelationField");
|
|
2086
|
-
function checkIsManyModelRelationField(modelField) {
|
|
2087
|
-
return checkIsModelRelationField(modelField) && modelField.isList;
|
|
2088
|
-
}
|
|
2089
|
-
__name(checkIsManyModelRelationField, "checkIsManyModelRelationField");
|
|
2090
|
-
function findModelByName(models, modelName) {
|
|
2091
|
-
return models.find(({ name }) => name === modelName);
|
|
2092
|
-
}
|
|
2093
|
-
__name(findModelByName, "findModelByName");
|
|
2094
|
-
var writeArray = /* @__PURE__ */ __name((writer, array, newLine = true) => array.forEach((line) => writer.write(line).conditionalNewLine(newLine)), "writeArray");
|
|
2095
|
-
var useModelNames = /* @__PURE__ */ __name(({ modelCase, modelSuffix, relationModel }) => {
|
|
2096
|
-
const formatModelName = /* @__PURE__ */ __name((name, prefix = "") => {
|
|
2097
|
-
if (modelCase === "camelCase") {
|
|
2098
|
-
name = name.slice(0, 1).toLowerCase() + name.slice(1);
|
|
2099
|
-
}
|
|
2100
|
-
return `${prefix}${name}${modelSuffix}`;
|
|
2101
|
-
}, "formatModelName");
|
|
2102
|
-
return {
|
|
2103
|
-
modelName: /* @__PURE__ */ __name((name) => formatModelName(name, relationModel === "default" ? "_" : ""), "modelName"),
|
|
2104
|
-
relatedModelName: /* @__PURE__ */ __name((name) => formatModelName(relationModel === "default" ? name.toString() : `Related${name.toString()}`), "relatedModelName")
|
|
2105
|
-
};
|
|
2106
|
-
}, "useModelNames");
|
|
2107
|
-
var dotSlash = /* @__PURE__ */ __name((input) => {
|
|
2108
|
-
const converted = input.replace(/^\\\\\?\\/, "").replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
2109
|
-
if (converted.includes(`/node_modules/`)) return converted.split(`/node_modules/`).slice(-1)[0];
|
|
2110
|
-
if (converted.startsWith(`../`)) return converted;
|
|
2111
|
-
return `./${converted}`;
|
|
2112
|
-
}, "dotSlash");
|
|
2113
|
-
var chunk = /* @__PURE__ */ __name((input, size) => {
|
|
2114
|
-
return input.reduce((arr, item, idx) => {
|
|
2115
|
-
return idx % size === 0 ? [
|
|
2116
|
-
...arr,
|
|
2117
|
-
[
|
|
2118
|
-
item
|
|
2119
|
-
]
|
|
2120
|
-
] : [
|
|
2121
|
-
...arr.slice(0, -1),
|
|
2122
|
-
[
|
|
2123
|
-
...arr.slice(-1)[0],
|
|
2124
|
-
item
|
|
2125
|
-
]
|
|
2126
|
-
];
|
|
2127
|
-
}, []);
|
|
2128
|
-
}, "chunk");
|
|
2129
|
-
var needsRelatedModel = /* @__PURE__ */ __name((model, config) => model.fields.some((field) => field.kind === "object") && config.relationModel !== false, "needsRelatedModel");
|
|
2130
|
-
var writeImportsForModel = /* @__PURE__ */ __name(async (model, sourceFile, config, options) => {
|
|
2131
|
-
const internals = await getPrismaInternals();
|
|
2132
|
-
const outputPath = internals.parseEnvValue(options.generator.output);
|
|
2133
|
-
const { relatedModelName } = useModelNames(config);
|
|
2134
|
-
const importList = [
|
|
2135
|
-
{
|
|
2136
|
-
kind: import_ts_morph2.StructureKind.ImportDeclaration,
|
|
2137
|
-
namespaceImport: "z",
|
|
2138
|
-
moduleSpecifier: "zod"
|
|
2139
|
-
}
|
|
2140
|
-
];
|
|
2141
|
-
if (config.imports) {
|
|
2142
|
-
importList.push({
|
|
2143
|
-
kind: import_ts_morph2.StructureKind.ImportDeclaration,
|
|
2144
|
-
namespaceImport: "imports",
|
|
2145
|
-
moduleSpecifier: dotSlash(import_node_path2.default.relative(outputPath, import_node_path2.default.resolve(import_node_path2.default.dirname(options.schemaPath), config.imports)))
|
|
2146
|
-
});
|
|
2147
|
-
}
|
|
2148
|
-
if (config.useDecimalJs && model.fields.some((f) => f.type === "Decimal")) {
|
|
2149
|
-
importList.push({
|
|
2150
|
-
kind: import_ts_morph2.StructureKind.ImportDeclaration,
|
|
2151
|
-
namedImports: [
|
|
2152
|
-
"Decimal"
|
|
2153
|
-
],
|
|
2154
|
-
moduleSpecifier: "decimal.js"
|
|
2155
|
-
});
|
|
2156
|
-
}
|
|
2157
|
-
const enumFields = model.fields.filter((f) => f.kind === "enum");
|
|
2158
|
-
const relationFields = model.fields.filter((f) => f.kind === "object");
|
|
2159
|
-
const clientPath = options.otherGenerators.find((each) => each.provider.value === "prisma-client-js").output.value;
|
|
2160
|
-
const relativePath2 = import_node_path2.default.relative(outputPath, clientPath);
|
|
2161
|
-
if (enumFields.length > 0) {
|
|
2162
|
-
importList.push({
|
|
2163
|
-
kind: import_ts_morph2.StructureKind.ImportDeclaration,
|
|
2164
|
-
isTypeOnly: enumFields.length === 0,
|
|
2165
|
-
moduleSpecifier: dotSlash(relativePath2),
|
|
2166
|
-
namedImports: enumFields.map((f) => f.type)
|
|
2167
|
-
});
|
|
2168
|
-
}
|
|
2169
|
-
if (config.relationModel !== false && relationFields.length > 0) {
|
|
2170
|
-
const filteredFields = relationFields.filter((f) => f.type !== model.name);
|
|
2171
|
-
if (filteredFields.length > 0) {
|
|
2172
|
-
importList.push({
|
|
2173
|
-
kind: import_ts_morph2.StructureKind.ImportDeclaration,
|
|
2174
|
-
moduleSpecifier: "./index",
|
|
2175
|
-
namedImports: Array.from(new Set(filteredFields.flatMap((f) => [
|
|
2176
|
-
`${f.type}`,
|
|
2177
|
-
relatedModelName(f.type)
|
|
2178
|
-
])))
|
|
2179
|
-
});
|
|
2180
|
-
}
|
|
2181
|
-
}
|
|
2182
|
-
sourceFile.addImportDeclarations(importList);
|
|
2183
|
-
}, "writeImportsForModel");
|
|
2184
|
-
var computeCustomSchema = /* @__PURE__ */ __name((docString) => {
|
|
2185
|
-
return getZodDocElements(docString).find((modifier) => modifier.startsWith("custom("))?.slice(7).slice(0, -1);
|
|
2186
|
-
}, "computeCustomSchema");
|
|
2187
|
-
var computeModifiers = /* @__PURE__ */ __name((docString) => {
|
|
2188
|
-
return getZodDocElements(docString).filter((each) => !each.startsWith("custom("));
|
|
2189
|
-
}, "computeModifiers");
|
|
2190
|
-
var getZodConstructor = /* @__PURE__ */ __name((field, getRelatedModelName = (name) => name.toString()) => {
|
|
2191
|
-
let zodType = "z.unknown()";
|
|
2192
|
-
const extraModifiers = [
|
|
2193
|
-
""
|
|
2194
|
-
];
|
|
2195
|
-
if (field.kind === "scalar") {
|
|
2196
|
-
switch (field.type) {
|
|
2197
|
-
case "String":
|
|
2198
|
-
zodType = "z.string()";
|
|
2199
|
-
break;
|
|
2200
|
-
case "Int":
|
|
2201
|
-
zodType = "z.number()";
|
|
2202
|
-
extraModifiers.push("int()");
|
|
2203
|
-
break;
|
|
2204
|
-
case "BigInt":
|
|
2205
|
-
zodType = "z.bigint()";
|
|
2206
|
-
break;
|
|
2207
|
-
case "DateTime":
|
|
2208
|
-
zodType = "z.date()";
|
|
2209
|
-
break;
|
|
2210
|
-
case "Float":
|
|
2211
|
-
zodType = "z.number()";
|
|
2212
|
-
break;
|
|
2213
|
-
case "Decimal":
|
|
2214
|
-
zodType = "z.number()";
|
|
2215
|
-
break;
|
|
2216
|
-
case "Json":
|
|
2217
|
-
zodType = "jsonSchema";
|
|
2218
|
-
break;
|
|
2219
|
-
case "Boolean":
|
|
2220
|
-
zodType = "z.boolean()";
|
|
2221
|
-
break;
|
|
2222
|
-
// TODO: Proper type for bytes fields
|
|
2223
|
-
case "Bytes":
|
|
2224
|
-
zodType = "z.unknown()";
|
|
2225
|
-
break;
|
|
2226
|
-
}
|
|
2227
|
-
} else if (field.kind === "enum") {
|
|
2228
|
-
zodType = `z.nativeEnum(${field.type})`;
|
|
2229
|
-
} else if (field.kind === "object") {
|
|
2230
|
-
zodType = getRelatedModelName(field.type);
|
|
2231
|
-
}
|
|
2232
|
-
if (field.isList) extraModifiers.push("array()");
|
|
2233
|
-
if (field.documentation) {
|
|
2234
|
-
zodType = computeCustomSchema(field.documentation) ?? zodType;
|
|
2235
|
-
extraModifiers.push(...computeModifiers(field.documentation));
|
|
2236
|
-
}
|
|
2237
|
-
if (!field.isRequired && field.type !== "Json") extraModifiers.push("nullish()");
|
|
2238
|
-
return `${zodType}${extraModifiers.join(".")}`;
|
|
2239
|
-
}, "getZodConstructor");
|
|
2240
|
-
var writeTypeSpecificSchemas = /* @__PURE__ */ __name((model, sourceFile, config) => {
|
|
2241
|
-
if (model.fields.some((f) => f.type === "Json")) {
|
|
2242
|
-
sourceFile.addStatements((writer) => {
|
|
2243
|
-
writer.newLine();
|
|
2244
|
-
writeArray(writer, [
|
|
2245
|
-
"// Helper schema for JSON fields",
|
|
2246
|
-
`type Literal = boolean | number | string${config.prismaJsonNullability ? "" : "| null"}`,
|
|
2247
|
-
"type Json = Literal | { [key: string]: Json } | Json[]",
|
|
2248
|
-
`const literalSchema = z.union([z.string(), z.number(), z.boolean()${config.prismaJsonNullability ? "" : ", z.null()"}])`,
|
|
2249
|
-
"const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))"
|
|
2250
|
-
]);
|
|
2251
|
-
});
|
|
2252
|
-
}
|
|
2253
|
-
if (config.useDecimalJs && model.fields.some((f) => f.type === "Decimal")) {
|
|
2254
|
-
sourceFile.addStatements((writer) => {
|
|
2255
|
-
writer.newLine();
|
|
2256
|
-
writeArray(writer, [
|
|
2257
|
-
"// Helper schema for Decimal fields",
|
|
2258
|
-
"z",
|
|
2259
|
-
".instanceof(Decimal)",
|
|
2260
|
-
".or(z.string())",
|
|
2261
|
-
".or(z.number())",
|
|
2262
|
-
".refine((value) => {",
|
|
2263
|
-
" try {",
|
|
2264
|
-
" return new Decimal(value);",
|
|
2265
|
-
" } catch (error) {",
|
|
2266
|
-
" return false;",
|
|
2267
|
-
" }",
|
|
2268
|
-
"})",
|
|
2269
|
-
".transform((value) => new Decimal(value));"
|
|
2270
|
-
]);
|
|
2271
|
-
});
|
|
2272
|
-
}
|
|
2273
|
-
}, "writeTypeSpecificSchemas");
|
|
2274
|
-
var generateSchemaForModel = /* @__PURE__ */ __name((model, sourceFile, config) => {
|
|
2275
|
-
const { modelName } = useModelNames(config);
|
|
2276
|
-
sourceFile.addVariableStatement({
|
|
2277
|
-
declarationKind: import_ts_morph2.VariableDeclarationKind.Const,
|
|
2278
|
-
isExported: true,
|
|
2279
|
-
leadingTrivia: /* @__PURE__ */ __name((writer) => writer.blankLineIfLastNot(), "leadingTrivia"),
|
|
2280
|
-
declarations: [
|
|
2281
|
-
{
|
|
2282
|
-
name: modelName(model.name),
|
|
2283
|
-
initializer(writer) {
|
|
2284
|
-
writer.write("z.object(").inlineBlock(() => {
|
|
2285
|
-
model.fields.filter((f) => f.kind !== "object").forEach((field) => {
|
|
2286
|
-
writeArray(writer, getJSDocs(field.documentation));
|
|
2287
|
-
writer.write(`${field.name}: ${getZodConstructor(field)}`).write(",").newLine();
|
|
2288
|
-
});
|
|
2289
|
-
}).write(")");
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
]
|
|
2293
|
-
});
|
|
2294
|
-
}, "generateSchemaForModel");
|
|
2295
|
-
var generateRelatedSchemaForModel = /* @__PURE__ */ __name((model, sourceFile, config) => {
|
|
2296
|
-
const { modelName, relatedModelName } = useModelNames(config);
|
|
2297
|
-
const relationFields = model.fields.filter((f) => f.kind === "object");
|
|
2298
|
-
sourceFile.addInterface({
|
|
2299
|
-
name: `${model.name}`,
|
|
2300
|
-
isExported: true,
|
|
2301
|
-
extends: [
|
|
2302
|
-
`z.infer<typeof ${modelName(model.name)}>`
|
|
2303
|
-
],
|
|
2304
|
-
properties: relationFields.map((f) => ({
|
|
2305
|
-
hasQuestionToken: !f.isRequired,
|
|
2306
|
-
name: f.name,
|
|
2307
|
-
type: `${f.type}${f.isList ? "[]" : ""}${!f.isRequired ? " | null" : ""}`
|
|
2308
|
-
}))
|
|
2309
|
-
});
|
|
2310
|
-
sourceFile.addStatements((writer) => writeArray(writer, [
|
|
2311
|
-
"",
|
|
2312
|
-
"/**",
|
|
2313
|
-
` * ${relatedModelName(model.name)} contains all relations on your model in addition to the scalars`,
|
|
2314
|
-
" *",
|
|
2315
|
-
" * NOTE: Lazy required in case of potential circular dependencies within schema",
|
|
2316
|
-
" */"
|
|
2317
|
-
]));
|
|
2318
|
-
sourceFile.addVariableStatement({
|
|
2319
|
-
declarationKind: import_ts_morph2.VariableDeclarationKind.Const,
|
|
2320
|
-
isExported: true,
|
|
2321
|
-
declarations: [
|
|
2322
|
-
{
|
|
2323
|
-
name: relatedModelName(model.name),
|
|
2324
|
-
type: `z.ZodSchema<${model.name}>`,
|
|
2325
|
-
initializer(writer) {
|
|
2326
|
-
writer.write(`z.lazy(() => ${modelName(model.name)}.extend(`).inlineBlock(() => {
|
|
2327
|
-
relationFields.forEach((field) => {
|
|
2328
|
-
writeArray(writer, getJSDocs(field.documentation));
|
|
2329
|
-
writer.write(`${field.name}: ${getZodConstructor(field, relatedModelName)}`).write(",").newLine();
|
|
2330
|
-
});
|
|
2331
|
-
}).write("))");
|
|
2332
|
-
}
|
|
2333
|
-
}
|
|
2334
|
-
]
|
|
2335
|
-
});
|
|
2336
|
-
}, "generateRelatedSchemaForModel");
|
|
2337
|
-
var populateModelFile = /* @__PURE__ */ __name(async (model, sourceFile, config, options) => {
|
|
2338
|
-
await writeImportsForModel(model, sourceFile, config, options);
|
|
2339
|
-
writeTypeSpecificSchemas(model, sourceFile, config);
|
|
2340
|
-
generateSchemaForModel(model, sourceFile, config);
|
|
2341
|
-
if (needsRelatedModel(model, config)) generateRelatedSchemaForModel(model, sourceFile, config);
|
|
2342
|
-
}, "populateModelFile");
|
|
2343
|
-
var generateBarrelFile = /* @__PURE__ */ __name((models, indexFile) => {
|
|
2344
|
-
models.forEach((model) => indexFile.addExportDeclaration({
|
|
2345
|
-
moduleSpecifier: `./${lowerCaseFirst(model.name)}.schema`
|
|
2346
|
-
}));
|
|
2347
|
-
}, "generateBarrelFile");
|
|
2348
|
-
|
|
2349
|
-
// src/helpers.ts
|
|
2350
|
-
var getProcedureName = /* @__PURE__ */ __name((config) => {
|
|
2351
|
-
return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
|
|
2352
|
-
}, "getProcedureName");
|
|
2353
|
-
var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config }) => {
|
|
2354
|
-
const imports = [
|
|
2355
|
-
"t"
|
|
2356
|
-
];
|
|
2357
|
-
if (config) {
|
|
2358
|
-
imports.push(getProcedureName(config));
|
|
2359
|
-
}
|
|
2360
|
-
sourceFile.addImportDeclaration({
|
|
2361
|
-
moduleSpecifier: "../trpc",
|
|
2362
|
-
namedImports: imports
|
|
2363
|
-
});
|
|
2364
|
-
}, "generateCreateRouterImport");
|
|
2365
|
-
var generateRouterImport = /* @__PURE__ */ __name((sourceFile, modelNamePlural, modelNameCamelCase) => {
|
|
2366
|
-
sourceFile.addImportDeclaration({
|
|
2367
|
-
moduleSpecifier: `./${lowerCaseFirst(modelNameCamelCase)}.router`,
|
|
2368
|
-
namedImports: [
|
|
2369
|
-
`${modelNamePlural}Router`
|
|
2370
|
-
]
|
|
2371
|
-
});
|
|
2372
|
-
}, "generateRouterImport");
|
|
2373
|
-
async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
2374
|
-
if (config.withShield) {
|
|
2375
|
-
sourceFile.addImportDeclaration({
|
|
2376
|
-
moduleSpecifier: (0, import_file_path_fns.relativePath)(outputDir, (0, import_join_paths3.joinPaths)(outputDir, typeof config.withShield === "string" ? config.withShield : "shield")),
|
|
2377
|
-
namedImports: [
|
|
2378
|
-
"permissions"
|
|
2379
|
-
]
|
|
2380
|
-
});
|
|
2381
|
-
}
|
|
2382
|
-
sourceFile.addStatements(
|
|
2383
|
-
/* ts */
|
|
2384
|
-
`import type { Context } from '${(0, import_file_path_fns.relativePath)(outputDir, (0, import_join_paths3.joinPaths)(outputDir, config.contextPath))}';`
|
|
2385
|
-
);
|
|
2386
|
-
if (config.trpcOptions) {
|
|
2387
|
-
sourceFile.addStatements(
|
|
2388
|
-
/* ts */
|
|
2389
|
-
`import trpcOptions from '${typeof config.trpcOptions === "string" ? (0, import_file_path_fns.relativePath)(outputDir, (0, import_join_paths3.joinPaths)(outputDir, config.trpcOptions)) : "./options"}';`
|
|
2390
|
-
);
|
|
2391
|
-
}
|
|
2392
|
-
if (config.withNext) {
|
|
2393
|
-
sourceFile.addStatements(
|
|
2394
|
-
/* ts */
|
|
2395
|
-
`import { createContext } from '${(0, import_file_path_fns.relativePath)(outputDir, (0, import_join_paths3.joinPaths)(outputDir, config.contextPath))}';
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`@stryke/fs/exists`),u=require(`@stryke/fs/helpers`),d=require(`@stryke/path/join-paths`),f=require(`node:path`);f=c(f);let p=require(`zod`),m=require(`@stryke/path/file-path-fns`),h=require(`ts-morph`),g=require(`node:os`);g=c(g);let _=require(`@stryke/fs/get-workspace-root`),v=require(`jiti`),y=require(`parenthesis`);y=c(y);let b=require(`@stryke/fs/write-file`),x=require(`@stryke/path/correct-path`),S=require(`prettier`);S=c(S);function C(e){return e&&e.charAt(0).toLowerCase()+e.slice(1)}var w=o(((e,t)=>{(function(n,r){typeof require==`function`&&typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(function(){return r()}):n.pluralize=r()})(e,function(){var e=[],t=[],n={},r={},i={};function a(e){return typeof e==`string`?RegExp(`^`+e+`$`,`i`):e}function o(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||``})}function c(e,t){return e.replace(t[0],function(n,r){var i=s(t[1],arguments);return o(n===``?e[r-1]:n,i)})}function l(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var a=r[i];if(a[0].test(t))return c(t,a)}return t}function u(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?o(r,i):e.hasOwnProperty(i)?o(r,e[i]):l(i,r,n)}}function d(e,t,n,r){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?!0:e.hasOwnProperty(i)?!1:l(i,i,n)===i}}function f(e,t,n){var r=t===1?f.singular(e):f.plural(e);return(n?t+` `:``)+r}return f.plural=u(i,r,e),f.isPlural=d(i,r,e),f.singular=u(r,i,t),f.isSingular=d(r,i,t),f.addPluralRule=function(t,n){e.push([a(t),n])},f.addSingularRule=function(e,n){t.push([a(e),n])},f.addUncountableRule=function(e){if(typeof e==`string`){n[e.toLowerCase()]=!0;return}f.addPluralRule(e,`$0`),f.addSingularRule(e,`$0`)},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[[`I`,`we`],[`me`,`us`],[`he`,`they`],[`she`,`they`],[`them`,`them`],[`myself`,`ourselves`],[`yourself`,`yourselves`],[`itself`,`themselves`],[`herself`,`themselves`],[`himself`,`themselves`],[`themself`,`themselves`],[`is`,`are`],[`was`,`were`],[`has`,`have`],[`this`,`these`],[`that`,`those`],[`echo`,`echoes`],[`dingo`,`dingoes`],[`volcano`,`volcanoes`],[`tornado`,`tornadoes`],[`torpedo`,`torpedoes`],[`genus`,`genera`],[`viscus`,`viscera`],[`stigma`,`stigmata`],[`stoma`,`stomata`],[`dogma`,`dogmata`],[`lemma`,`lemmata`],[`schema`,`schemata`],[`anathema`,`anathemata`],[`ox`,`oxen`],[`axe`,`axes`],[`die`,`dice`],[`yes`,`yeses`],[`foot`,`feet`],[`eave`,`eaves`],[`goose`,`geese`],[`tooth`,`teeth`],[`quiz`,`quizzes`],[`human`,`humans`],[`proof`,`proofs`],[`carve`,`carves`],[`valve`,`valves`],[`looey`,`looies`],[`thief`,`thieves`],[`groove`,`grooves`],[`pickaxe`,`pickaxes`],[`passerby`,`passersby`]].forEach(function(e){return f.addIrregularRule(e[0],e[1])}),[[/s?$/i,`s`],[/[^\u0000-\u007F]$/i,`$0`],[/([^aeiou]ese)$/i,`$1`],[/(ax|test)is$/i,`$1es`],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,`$1es`],[/(e[mn]u)s?$/i,`$1s`],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,`$1`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1i`],[/(alumn|alg|vertebr)(?:a|ae)$/i,`$1ae`],[/(seraph|cherub)(?:im)?$/i,`$1im`],[/(her|at|gr)o$/i,`$1oes`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,`$1a`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,`$1a`],[/sis$/i,`ses`],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,`$1$2ves`],[/([^aeiouy]|qu)y$/i,`$1ies`],[/([^ch][ieo][ln])ey$/i,`$1ies`],[/(x|ch|ss|sh|zz)$/i,`$1es`],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,`$1ices`],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,`$1ice`],[/(pe)(?:rson|ople)$/i,`$1ople`],[/(child)(?:ren)?$/i,`$1ren`],[/eaux$/i,`$0`],[/m[ae]n$/i,`men`],[`thou`,`you`]].forEach(function(e){return f.addPluralRule(e[0],e[1])}),[[/s$/i,``],[/(ss)$/i,`$1`],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,`$1fe`],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,`$1f`],[/ies$/i,`y`],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,`$1ie`],[/\b(mon|smil)ies$/i,`$1ey`],[/\b((?:tit)?m|l)ice$/i,`$1ouse`],[/(seraph|cherub)im$/i,`$1`],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,`$1`],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,`$1sis`],[/(movie|twelve|abuse|e[mn]u)s$/i,`$1`],[/(test)(?:is|es)$/i,`$1is`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1us`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,`$1um`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,`$1on`],[/(alumn|alg|vertebr)ae$/i,`$1a`],[/(cod|mur|sil|vert|ind)ices$/i,`$1ex`],[/(matr|append)ices$/i,`$1ix`],[/(pe)(rson|ople)$/i,`$1rson`],[/(child)ren$/i,`$1`],[/(eau)x?$/i,`$1`],[/men$/i,`man`]].forEach(function(e){return f.addSingularRule(e[0],e[1])}),[`adulthood`,`advice`,`agenda`,`aid`,`aircraft`,`alcohol`,`ammo`,`analytics`,`anime`,`athletics`,`audio`,`bison`,`blood`,`bream`,`buffalo`,`butter`,`carp`,`cash`,`chassis`,`chess`,`clothing`,`cod`,`commerce`,`cooperation`,`corps`,`debris`,`diabetes`,`digestion`,`elk`,`energy`,`equipment`,`excretion`,`expertise`,`firmware`,`flounder`,`fun`,`gallows`,`garbage`,`graffiti`,`hardware`,`headquarters`,`health`,`herpes`,`highjinks`,`homework`,`housework`,`information`,`jeans`,`justice`,`kudos`,`labour`,`literature`,`machinery`,`mackerel`,`mail`,`media`,`mews`,`moose`,`music`,`mud`,`manga`,`news`,`only`,`personnel`,`pike`,`plankton`,`pliers`,`police`,`pollution`,`premises`,`rain`,`research`,`rice`,`salmon`,`scissors`,`series`,`sewage`,`shambles`,`shrimp`,`software`,`species`,`staff`,`swine`,`tennis`,`traffic`,`transportation`,`trout`,`tuna`,`wealth`,`welfare`,`whiting`,`wildebeest`,`wildlife`,`you`,/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f})})),ee=c(w(),1);let T=function(e){return e.findUnique=`findUnique`,e.findUniqueOrThrow=`findUniqueOrThrow`,e.findFirst=`findFirst`,e.findFirstOrThrow=`findFirstOrThrow`,e.findMany=`findMany`,e.create=`create`,e.createMany=`createMany`,e.createManyAndReturn=`createManyAndReturn`,e.update=`update`,e.updateMany=`updateMany`,e.updateManyAndReturn=`updateManyAndReturn`,e.upsert=`upsert`,e.delete=`delete`,e.deleteMany=`deleteMany`,e.groupBy=`groupBy`,e.count=`count`,e.aggregate=`aggregate`,e.findRaw=`findRaw`,e.aggregateRaw=`aggregateRaw`,e}({});const E=p.z.nativeEnum(T),D=p.z.string().trim().transform(e=>!e||e.toLowerCase()===`false`||e.toLowerCase()===`n`||e.toLowerCase()===`no`||e===`0`?!1:e.toLowerCase()===`true`||e.toLowerCase()===`y`||e.toLowerCase()===`yes`||e===`1`?!0:e),te=p.z.object({debug:D.default(`false`),withNext:D.default(`true`),withMiddleware:D.default(`false`),withShield:D.default(`false`),contextPath:p.z.string().trim().default(`../context`),trpcOptions:D.default(`true`),showModelNameInProcedure:D.default(`false`),generateModelActions:p.z.string().default(Object.values(T).join(`,`)).transform(e=>e.split(`,`).map(e=>E.parse(e.trim()))),withZod:D.default(`true`),relationModel:D.default(`true`).or(p.z.literal(`default`)),modelSuffix:p.z.string().default(`Schema`),modelCase:p.z.enum([`PascalCase`,`camelCase`]).default(`camelCase`),useDecimalJs:D.default(`true`),imports:p.z.string().optional(),prismaJsonNullability:D.default(`true`)}),ne={target:h.ScriptTarget.ESNext,module:h.ModuleKind.ESNext,emitDecoratorMetadata:!0,experimentalDecorators:!0,esModuleInterop:!0},O=new h.Project({compilerOptions:{...ne}});function re(e,t){return`${e} ${t}`}function ie(e){return e.replace(/([a-z\d])([A-Z])/g,`$1_$2`).replace(/([A-Z]+)([A-Z][a-z\d]+)/g,`$1_$2`).toLowerCase()}const k={"2D":{description:`Two-Dimensional`,display:`2d`},"3D":{description:`Three-Dimensional`,display:`3d`},"4D":{description:`Four-Dimensional`,display:`4d`},"5G":{description:`Fifth Generation (mobile networks)`},"6G":{description:`Sixth Generation (mobile networks)`},"7G":{description:`Seventh Generation (mobile networks)`},"8G":{description:`Eighth Generation (mobile networks)`},ACID:{description:`Atomicity, Consistency, Isolation, Durability`},AITA:{description:`Am I The Asshole`},AES:{description:`Advanced Encryption Standard`},AI:{description:`Artificial Intelligence`},AJAX:{description:`Asynchronous JavaScript and XML`},API:{description:`Application Programming Interface`},AR:{description:`Augmented Reality`},ASCII:{description:`American Standard Code for Information Interchange`},ATF:{description:`Bureau of Alcohol, Tobacco, Firearms and Explosives`},ATM:{description:`Automated Teller Machine`},B2B:{description:`Business to Business`},B2C:{description:`Business to Consumer`},BATFE:{description:`Bureau of Alcohol, Tobacco, Firearms and Explosives`},BFF:{description:`Best Friends Forever`},BFFS:{description:`Best Friends Forever (plural)`},BI:{description:`Business Intelligence`},BIOS:{description:`Basic Input/Output System`},BGP:{description:`Border Gateway Protocol`},BOM:{description:`Bill of Materials / Byte Order Mark`},BSON:{description:`Binary JSON`},BYOD:{description:`Bring Your Own Device`},C2C:{description:`Consumer to Consumer`},CAGR:{description:`Compound Annual Growth Rate`},CAPTCHA:{description:`Completely Automated Public Turing test to tell Computers and Humans Apart`},CCTV:{description:`Closed-Circuit Television`},CD:{description:`Continuous Delivery / Compact Disc`},CDN:{description:`Content Delivery Network`},CDP:{description:`Customer Data Platform`},CDT:{description:`Central Daylight Time`},CIA:{description:`Central Intelligence Agency`},CI:{description:`Continuous Integration`},"CI/CD":{description:`Continuous Integration/Continuous Delivery`},CIAM:{description:`Customer Identity and Access Management`},CICD:{description:`Continuous Integration Continuous Delivery`,display:`CI/CD`},CLI:{description:`Command Line Interface`},CMDB:{description:`Configuration Management Database`},CORS:{description:`Cross-Origin Resource Sharing`},CPA:{description:`Certified Public Accountant`},CPU:{description:`Central Processing Unit`},CRUD:{description:`Create, Read, Update, Delete`},CSR:{description:`Certificate Signing Request / Corporate Social Responsibility`},CSS:{description:`Cascading Style Sheets`},CST:{description:`Central Standard Time`},CTA:{description:`Call To Action`},CWD:{description:`Current Working Directory`},CX:{description:`Customer Experience`},DAG:{description:`Directed Acyclic Graph`},DBMS:{description:`Database Management System`},DDOS:{description:`Distributed Denial of Service`,display:`DDoS`},DEA:{description:`Drug Enforcement Administration`},DEVENV:{description:`Devenv`,display:`Devenv`},DEVOPS:{description:`Development Operations`,display:`DevOps`},DHS:{description:`Department of Homeland Security`},DIRENV:{description:`DirEnv`,display:`DirEnv`},DNC:{description:`Democratic National Committee / Do Not Call`},DNS:{description:`Domain Name System`},DNSSEC:{description:`Domain Name System Security Extensions`},DOD:{description:`Department of Defense`,display:`DoD`},DOJ:{description:`Department of Justice`,display:`DoJ`},DOM:{description:`Document Object Model`},DOT:{description:`Department of Transportation`,display:`DoT`},DOTENV:{description:`Dotenv (.env)`,display:`Dotenv`},DR:{description:`Disaster Recovery`},DRM:{description:`Digital Rights Management`},DSN:{description:`Data Source Name`},DWH:{description:`Data Warehouse`},E2E:{description:`End to End`},EAI:{description:`Enterprise Application Integration`},EDT:{description:`Eastern Daylight Time`},EEA:{description:`European Economic Area`},EKS:{description:`Elastic Kubernetes Service`},EOF:{description:`End Of File`},EOD:{description:`End Of Day / Explosive Ordnance Disposal`},EPA:{description:`Environmental Protection Agency`},ER:{description:`Emergency Room / Entity Relationship`},EST:{description:`Eastern Standard Time`},ETC:{description:`Et Cetera`},ETL:{description:`Extract, Transform, Load`},EULA:{description:`End User License Agreement`},FAAS:{description:`Function as a Service`,display:`FaaS`},FAQ:{description:`Frequently Asked Questions`,display:`FAQs`},FAQS:{description:`Frequently Asked Questions`},FBI:{description:`Federal Bureau of Investigation`},FCC:{description:`Federal Communications Commission`},FDA:{description:`Food and Drug Administration`},FIDO:{description:`Fast IDentity Online`},FLOTUS:{description:`First Lady of the United States`},FQDN:{description:`Fully Qualified Domain Name`},FTC:{description:`Federal Trade Commission`},FTP:{description:`File Transfer Protocol`},GC:{description:`Garbage Collection`},GCP:{description:`Google Cloud Platform`},GDPR:{description:`General Data Protection Regulation`},GMT:{description:`Greenwich Mean Time`},GOP:{description:`Grand Old Party`},GPU:{description:`Graphics Processing Unit`},GUID:{description:`Globally Unique Identifier`},GUI:{description:`Graphical User Interface`},GZIP:{description:`GNU Zip`},HCI:{description:`Human Computer Interaction / Hyper-Converged Infrastructure`},HDD:{description:`Hard Disk Drive`},HDFS:{description:`Hadoop Distributed File System`},HHS:{description:`Health and Human Services`},HIPAA:{description:`Health Insurance Portability and Accountability Act`},HMAC:{description:`Hash-based Message Authentication Code`},HOTP:{description:`HMAC-based One-Time Password`},HSM:{description:`Hardware Security Module`},HTML:{description:`HyperText Markup Language`},HTTP:{description:`HyperText Transfer Protocol (HTTP)`},"HTTP/2":{description:`HyperText Transfer Protocol Version 2 (HTTP/2)`},"HTTP/2.0":{description:`HyperText Transfer Protocol Version 2 (HTTP/2)`,display:`HTTP2`},"HTTP/3":{description:`HyperText Transfer Protocol Version 3 (HTTP/3)`},"HTTP/3.0":{description:`HyperText Transfer Protocol Version 3 (HTTP/3)`,display:`HTTP3`},HTTP2:{description:`HyperText Transfer Protocol Version 2 (HTTP/2)`,display:`HTTP2`},"HTTP2.0":{description:`HyperText Transfer Protocol Version 2 (HTTP/2)`,display:`HTTP2`},HTTP3:{description:`HyperText Transfer Protocol Version 3 (HTTP/3)`,display:`HTTP3`},"HTTP3.0":{description:`HyperText Transfer Protocol Version 3 (HTTP/3)`,display:`HTTP3`},HTTPS:{description:`HyperText Transfer Protocol Secure (HTTPS)`},"HTTPS/2":{description:`HyperText Transfer Protocol Secure Version 2 (HTTPS/2)`},"HTTPS/2.0":{description:`HyperText Transfer Protocol Secure Version 2 (HTTPS/2)`,display:`HTTPS2`},"HTTPS/3":{description:`HyperText Transfer Protocol Secure Version 3 (HTTPS/3)`},"HTTPS/3.0":{description:`HyperText Transfer Protocol Secure Version 3 (HTTPS/3)`,display:`HTTPS3`},HTTPS2:{description:`HyperText Transfer Protocol Secure Version 2 (HTTPS/2)`,display:`HTTPS2`},"HTTPS2.0":{description:`HyperText Transfer Protocol Secure Version 2 (HTTPS/2)`,display:`HTTPS2`},HTTPS3:{description:`HyperText Transfer Protocol Secure Version 3 (HTTPS/3)`,display:`HTTPS3`},"HTTPS3.0":{description:`HyperText Transfer Protocol Secure Version 3 (HTTPS/3)`,display:`HTTPS3`},IAAS:{description:`Infrastructure as a Service`,display:`IaaS`},IAM:{description:`Identity and Access Management`},IAMM:{description:`Identity and Access Management and Monitoring`},IAMT:{description:`Identity and Access Management Tool`},ID:{description:`Identifier`,display:`Id`},IFTTT:{description:`If This Then That`},IMAP:{description:`Internet Message Access Protocol`},IO:{description:`Input/Output`},IP:{description:`Internet Protocol`},IPFS:{description:`InterPlanetary File System`},IPS:{description:`Intrusion Prevention System`},ISO:{description:`International Organization for Standardization`},IQ:{description:`Intelligence Quotient`,display:`IQ`},IOT:{description:`Internet of Things`,display:`IoT`},JSON:{description:`JavaScript Object Notation`},JSONP:{description:`JSON with Padding`},JWT:{description:`JSON Web Token`},K8S:{description:`Kubernetes`,display:`K8s`},KMS:{description:`Key Management Service`},KPI:{description:`Key Performance Indicator`},KV:{description:`Key Value`},LAN:{description:`Local Area Network`},LHS:{description:`Left Hand Side`},LPGA:{description:`Ladies Professional Golf Association`},LXC:{description:`Linux Containers`},MDT:{description:`Mountain Daylight Time`},MFA:{description:`Multi-Factor Authentication`},ML:{description:`Machine Learning`},MLB:{description:`Major League Baseball`},MLOps:{description:`Machine Learning Operations`},MPA:{description:`Multi-Page Application`},MST:{description:`Mountain Standard Time`},MVC:{description:`Model View Controller`},MVP:{description:`Minimum Viable Product / Most Valuable Player`},NAIA:{description:`National Association of Intercollegiate Athletics`},NAS:{description:`Network Attached Storage`},NASA:{description:`National Aeronautics and Space Administration`},NASCAR:{description:`National Association for Stock Car Auto Racing`},NAT:{description:`Network Address Translation`},NBA:{description:`National Basketball Association`},NCAA:{description:`National Collegiate Athletic Association`},NDA:{description:`Non-Disclosure Agreement`},NFS:{description:`Network File System`},NHL:{description:`National Hockey League`},NIST:{description:`National Institute of Standards and Technology`},NLP:{description:`Natural Language Processing`},NPS:{description:`Net Promoter Score`},NRA:{description:`National Rifle Association`},NSFW:{description:`Not Safe For Work`},NX:{description:`Nx`,display:`Nx`},OCR:{description:`Optical Character Recognition`},OEM:{description:`Original Equipment Manufacturer`},OKR:{description:`Objectives and Key Results`},OLAP:{description:`Online Analytical Processing`},OLTP:{description:`Online Transaction Processing`},OOP:{description:`Object Oriented Programming`},ORM:{description:`Object Relational Mapping`},OS:{description:`Operating System`},OSINT:{description:`Open Source Intelligence`},OSS:{description:`Open Source Software`},OTP:{description:`One-Time Password`},P2P:{description:`Peer to Peer`},PAAS:{description:`Platform as a Service`,display:`PaaS`},PCI:{description:`Payment Card Industry`},PDP:{description:`Policy Decision Point / Product Detail Page`},PDT:{description:`Pacific Daylight Time`},PGA:{description:`Professional Golfers' Association`},POTUS:{description:`President of the United States`},PP:{description:`Pages / PayPal / Percentage Points`},PST:{description:`Pacific Standard Time`},PTO:{description:`Paid Time Off / Power Take-Off`},PKI:{description:`Public Key Infrastructure`},PWA:{description:`Progressive Web App`},PX:{description:`Pixel`},QA:{description:`Quality Assurance`},R2:{description:`R2`},RAID:{description:`Redundant Array of Independent Disks`},RAM:{description:`Random Access Memory`},RDS:{description:`Relational Database Service`},REST:{description:`Representational State Transfer`},RHS:{description:`Right Hand Side`},ROI:{description:`Return on Investment`},RPC:{description:`Remote Procedure Call`},RPA:{description:`Robotic Process Automation`},RSC:{description:`React Server Components`},RSS:{description:`Really Simple Syndication`},RUM:{description:`Real User Monitoring`},S3:{description:`Simple Storage Service (S3)`},SAN:{description:`Storage Area Network`},SASE:{description:`Secure Access Service Edge`},SCOTUS:{description:`Supreme Court of the United States`},SDLC:{description:`Software Development Life Cycle`},SDK:{description:`Software Development Kit`},SEC:{description:`Securities and Exchange Commission`},SEO:{description:`Search Engine Optimization`},SFTP:{description:`SSH File Transfer Protocol / Secure File Transfer Protocol`},SIEM:{description:`Security Information and Event Management`},SLA:{description:`Service Level Agreement`},SMB:{description:`Server Message Block / Small and Medium Business`},SMTP:{description:`Simple Mail Transfer Protocol`},SOAP:{description:`Simple Object Access Protocol`},SOA:{description:`Service Oriented Architecture`},SOC:{description:`Security Operations Center / System on Chip`},SPA:{description:`Single Page Application`},SPDY:{description:`Speedy (pronounced "SPeeDY")`},SPF:{description:`Sender Policy Framework`},SQL:{description:`Structured Query Language`},SRV:{description:`Service`},SRE:{description:`Site Reliability Engineering`},SSH:{description:`Secure Shell`},SSDL:{description:`Secure Software Development Lifecycle`},SSG:{description:`Static Site Generation`},SSR:{description:`Server Side Rendering`},SSO:{description:`Single Sign-On`},SSL:{description:`Secure Sockets Layer`},TDD:{description:`Test Driven Development`},TLD:{description:`Top Level Domain`},TLS:{description:`Transport Layer Security`},"TLS1.3":{description:`Transport Layer Security 1.3`},TOR:{description:`The Onion Router`},TOTP:{description:`Time-based One-Time Password`},TRPC:{description:`TypeScript Remote Procedure Call`},TSA:{description:`Transportation Security Administration`},TTL:{description:`Time To Live`},UDP:{description:`User Datagram Protocol`},UI:{description:`User Interface`},UID:{description:`Unique Identifier`},URI:{description:`Uniform Resource Identifier`},URL:{description:`Uniform Resource Locator`},USOPC:{description:`United States Olympic & Paralympic Committee`},USPS:{description:`United States Postal Service`},USTA:{description:`United States Tennis Association`},UTF:{description:`Unicode Transformation Format`},UTC:{description:`Coordinated Universal Time`},UUID:{description:`Universally Unique Identifier`},UX:{description:`User Experience`},VM:{description:`Virtual Machine`},VLAN:{description:`Virtual Local Area Network`},VPN:{description:`Virtual Private Network`},VPPA:{description:`Video Privacy Protection Act`},VR:{description:`Virtual Reality`},WAF:{description:`Web Application Firewall`},WAN:{description:`Wide Area Network`},WNBA:{description:`Women's National Basketball Association`},WLAN:{description:`Wireless Local Area Network`},WPA:{description:`Wi-Fi Protected Access`},WPA2:{description:`Wi-Fi Protected Access II`},WPA3:{description:`Wi-Fi Protected Access III`},WWW:{description:`World Wide Web`},WYSIWYG:{description:`What You See Is What You Get`},XACML:{description:`eXtensible Access Control Markup Language`},XDG:{description:`Cross-Desktop Group`},XML:{description:`eXtensible Markup Language`},XSRF:{description:`Cross-Site Request Forgery`},XSS:{description:`Cross-Site Scripting`},XR:{description:`Extended Reality`},YAML:{description:`YAML Ain't Markup Language`},YMCA:{description:`Young Men's Christian Association`},YWCA:{description:`Young Women's Christian Association`},ZTA:{description:`Zero Trust Architecture`}},ae=Object.fromEntries(Object.entries(k).map(([e,t])=>[e,t.display??e])),oe=Object.fromEntries(Object.entries(k).map(([e,t])=>[e,t.description])),se=Object.keys(k),ce=[`a`,`an`,`the`],le=[`and`,`that`,`but`,`or`,`as`,`if`,`when`,`than`,`because`,`while`,`where`,`after`,`so`,`though`,`since`,`until`,`whether`,`before`,`although`,`nor`,`like`,`once`,`unless`,`now`,`except`],ue=`about.above.across.after.against.along.among.around.at.because of.before.behind.below.beneath.beside.besides.between.beyond.but.by.concerning.despite.down.during.except.excepting.for.from.in.in front of.inside.in spite of.instead of.into.like.near.of.off.on.onto.out.outside.over.past.regarding.since.through.throughout.to.toward.under.underneath.until.up.upon.up to.with.within.without.with regard to.with respect to`.split(`.`),de=`2FA.4K.5K.8K.AGI.BI.ChatGPT.CTA.DateTime.FMS.GitHub.GPT.HD.IBMid.IDs.iMac.IMAX.iOS.iPad.iPhone.iPod.LDAP.LinkedIn.LLM.macOS.McDonalds.MCP.ML.MySQL.NLG.NLP.NLU.OpenAI.PDFs.PIM.PEFT.pH.PostgreSQL.SEO.TTS.UHD.UUID.XSS.YouTube.CSpell.ESLint`.split(`.`);function fe(e,t,n,r){let i=e.toLowerCase(),a=e.toUpperCase();for(let e of de)if(e.toLowerCase()===i)return e;return k[a]?r?.useDescriptions===!1?k[a].display||a:k[a].description:t===0||t===n.length-1||e.length>=4?e:ue.includes(i)||le.includes(i)||ce.includes(i)?i:e}function A(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function pe(e,t){return e?.split(/\s+-\s+/).map(e=>ie(e).split(/[\s\-_]/).map(A).map((e,n,r)=>fe(e,n,r,t)).reduce(re)).join(` - `)}const j=g.default.homedir(),M=g.default.tmpdir(),me=e=>{let t=(0,d.joinPaths)(j,`Library`);return{data:(0,d.joinPaths)(t,`Application Support`,e),config:(0,d.joinPaths)(t,`Preferences`,e),cache:(0,d.joinPaths)(t,`Caches`,e),log:(0,d.joinPaths)(t,`Logs`,e),temp:(0,d.joinPaths)(M,e)}},he=e=>{let t=process.env.APPDATA||(0,d.joinPaths)(j,`AppData`,`Roaming`),n=process.env.LOCALAPPDATA||(0,d.joinPaths)(j,`AppData`,`Local`),r=pe(e).trim().replace(/\s+/g,``);return{data:(0,d.joinPaths)(n,r,`Data`),config:(0,d.joinPaths)(t,r,`Config`),cache:(0,d.joinPaths)(n,`Cache`,e),log:(0,d.joinPaths)(n,r,`Log`),temp:(0,d.joinPaths)(M,e)}},ge=e=>{let t=f.default.basename(j);return{data:(0,d.joinPaths)(process.env.XDG_DATA_HOME||(0,d.joinPaths)(j,`.local`,`share`),e),config:(0,d.joinPaths)(process.env.XDG_CONFIG_HOME||(0,d.joinPaths)(j,`.config`),e),cache:(0,d.joinPaths)(process.env.XDG_CACHE_HOME||(0,d.joinPaths)(j,`.cache`),e),log:(0,d.joinPaths)(process.env.XDG_STATE_HOME||(0,d.joinPaths)(j,`.local`,`state`),e),temp:process.env.DEVENV_RUNTIME||process.env.XDG_RUNTIME_DIR?(0,d.joinPaths)(process.env.DEVENV_RUNTIME||process.env.XDG_RUNTIME_DIR,e):(0,d.joinPaths)(M,t,e)}};function _e(e={}){let t=e.orgId||`storm-software`;if(!t)throw Error("You need to provide an orgId to the `getEnvPaths` function");e.suffix&&(t+=`-${typeof e.suffix==`string`?e.suffix:`nodejs`}`);let n={};return n=process.platform===`darwin`?me(t):process.platform===`win32`?he(t):ge(t),process.env.STORM_DATA_DIR?n.data=process.env.STORM_DATA_DIR:process.env.STORM_CONFIG_DIR?n.config=process.env.STORM_CONFIG_DIR:process.env.STORM_CACHE_DIR?n.cache=process.env.STORM_CACHE_DIR:process.env.STORM_LOG_DIR?n.log=process.env.STORM_LOG_DIR:process.env.STORM_TEMP_DIR&&(n.temp=process.env.STORM_TEMP_DIR),e.workspaceRoot&&(n.cache??=(0,d.joinPaths)(e.workspaceRoot,`node_modules`,`.cache`,t),n.temp??=(0,d.joinPaths)(e.workspaceRoot,`tmp`,t),n.log??=(0,d.joinPaths)(n.temp,`logs`),n.config??=(0,d.joinPaths)(e.workspaceRoot,`.config`,t)),Object.keys(n).reduce((t,r)=>{if(n[r]){let i=n[r];t[r]=e.appId&&e.appId!==e.orgId&&e.appId!==e.nestedDir?(0,d.joinPaths)(i,e.appId):i,e.nestedDir&&e.nestedDir!==e.orgId&&e.nestedDir!==e.appId&&(t[r]=(0,d.joinPaths)(t[r],e.nestedDir))}return t},{})}let N;function P(){if(!N){let e=_e();N=(0,v.createJiti)((0,_.getWorkspaceRoot)(),{fsCache:(0,d.joinPaths)(e.cache,`jiti`),interopDefault:!0})}return N}async function F(){return P().import(P().esmResolve(`@prisma/internals`))}async function ve(){return P().import(P().esmResolve(`@prisma/generator-helper`))}const I=e=>{let t=[];if(e){let n=e.split(`
|
|
2
|
+
`).filter(e=>!e.trimStart().startsWith(`@zod`));n.length&&(t.push(`/**`),n.forEach(e=>t.push(` * ${e}`)),t.push(` */`))}return t},L=e=>e.split(`
|
|
3
|
+
`).filter(e=>e.trimStart().startsWith(`@zod`)).map(e=>e.trimStart().slice(4)).flatMap(e=>xe(y.default.parse(e),2).slice(0,-1).map(([e,t])=>`${e.replace(/\)?\./,``)}${y.default.stringify(t)})`));function R(e){let{fields:t}=e;for(let e of t)if(B(e))return!0;return!1}function z(e){let{fields:t}=e;for(let e of t)if(ye(e))return!0;return!1}function B(e){let{kind:t,relationName:n}=e;return t===`object`&&!!n}function ye(e){return B(e)&&e.isList}function be(e,t){return e.find(({name:e})=>e===t)}const V=(e,t,n=!0)=>t.forEach(t=>e.write(t).conditionalNewLine(n)),H=({modelCase:e,modelSuffix:t,relationModel:n})=>{let r=(n,r=``)=>(e===`camelCase`&&(n=n.slice(0,1).toLowerCase()+n.slice(1)),`${r}${n}${t}`);return{modelName:e=>r(e,n===`default`?`_`:``),relatedModelName:e=>r(n===`default`?e.toString():`Related${e.toString()}`)}},U=e=>{let t=e.replace(/^\\\\\?\\/,``).replace(/\\/g,`/`).replace(/\/{2,}/g,`/`);return t.includes(`/node_modules/`)?t.split(`/node_modules/`).slice(-1)[0]:t.startsWith(`../`)?t:`./${t}`},xe=(e,t)=>e.reduce((e,n,r)=>r%t===0?[...e,[n]]:[...e.slice(0,-1),[...e.slice(-1)[0],n]],[]),Se=(e,t)=>e.fields.some(e=>e.kind===`object`)&&t.relationModel!==!1,Ce=async(e,t,n,r)=>{let i=(await F()).parseEnvValue(r.generator.output),{relatedModelName:a}=H(n),o=[{kind:h.StructureKind.ImportDeclaration,namespaceImport:`z`,moduleSpecifier:`zod`}];n.imports&&o.push({kind:h.StructureKind.ImportDeclaration,namespaceImport:`imports`,moduleSpecifier:U(f.default.relative(i,f.default.resolve(f.default.dirname(r.schemaPath),n.imports)))}),n.useDecimalJs&&e.fields.some(e=>e.type===`Decimal`)&&o.push({kind:h.StructureKind.ImportDeclaration,namedImports:[`Decimal`],moduleSpecifier:`decimal.js`});let s=e.fields.filter(e=>e.kind===`enum`),c=e.fields.filter(e=>e.kind===`object`),l=r.otherGenerators.find(e=>e.provider.value===`prisma-client-js`).output.value,u=f.default.relative(i,l);if(s.length>0&&o.push({kind:h.StructureKind.ImportDeclaration,isTypeOnly:s.length===0,moduleSpecifier:U(u),namedImports:s.map(e=>e.type)}),n.relationModel!==!1&&c.length>0){let t=c.filter(t=>t.type!==e.name);t.length>0&&o.push({kind:h.StructureKind.ImportDeclaration,moduleSpecifier:`./index`,namedImports:Array.from(new Set(t.flatMap(e=>[`${e.type}`,a(e.type)])))})}t.addImportDeclarations(o)},we=e=>L(e).find(e=>e.startsWith(`custom(`))?.slice(7).slice(0,-1),Te=e=>L(e).filter(e=>!e.startsWith(`custom(`)),W=(e,t=e=>e.toString())=>{let n=`z.unknown()`,r=[``];if(e.kind===`scalar`)switch(e.type){case`String`:n=`z.string()`;break;case`Int`:n=`z.number()`,r.push(`int()`);break;case`BigInt`:n=`z.bigint()`;break;case`DateTime`:n=`z.date()`;break;case`Float`:n=`z.number()`;break;case`Decimal`:n=`z.number()`;break;case`Json`:n=`jsonSchema`;break;case`Boolean`:n=`z.boolean()`;break;case`Bytes`:n=`z.unknown()`;break}else e.kind===`enum`?n=`z.nativeEnum(${e.type})`:e.kind===`object`&&(n=t(e.type));return e.isList&&r.push(`array()`),e.documentation&&(n=we(e.documentation)??n,r.push(...Te(e.documentation))),!e.isRequired&&e.type!==`Json`&&r.push(`nullish()`),`${n}${r.join(`.`)}`},Ee=(e,t,n)=>{e.fields.some(e=>e.type===`Json`)&&t.addStatements(e=>{e.newLine(),V(e,[`// Helper schema for JSON fields`,`type Literal = boolean | number | string${n.prismaJsonNullability?``:`| null`}`,`type Json = Literal | { [key: string]: Json } | Json[]`,`const literalSchema = z.union([z.string(), z.number(), z.boolean()${n.prismaJsonNullability?``:`, z.null()`}])`,`const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))`])}),n.useDecimalJs&&e.fields.some(e=>e.type===`Decimal`)&&t.addStatements(e=>{e.newLine(),V(e,[`// Helper schema for Decimal fields`,`z`,`.instanceof(Decimal)`,`.or(z.string())`,`.or(z.number())`,`.refine((value) => {`,` try {`,` return new Decimal(value);`,` } catch (error) {`,` return false;`,` }`,`})`,`.transform((value) => new Decimal(value));`])})},De=(e,t,n)=>{let{modelName:r}=H(n);t.addVariableStatement({declarationKind:h.VariableDeclarationKind.Const,isExported:!0,leadingTrivia:e=>e.blankLineIfLastNot(),declarations:[{name:r(e.name),initializer(t){t.write(`z.object(`).inlineBlock(()=>{e.fields.filter(e=>e.kind!==`object`).forEach(e=>{V(t,I(e.documentation)),t.write(`${e.name}: ${W(e)}`).write(`,`).newLine()})}).write(`)`)}}]})},Oe=(e,t,n)=>{let{modelName:r,relatedModelName:i}=H(n),a=e.fields.filter(e=>e.kind===`object`);t.addInterface({name:`${e.name}`,isExported:!0,extends:[`z.infer<typeof ${r(e.name)}>`],properties:a.map(e=>({hasQuestionToken:!e.isRequired,name:e.name,type:`${e.type}${e.isList?`[]`:``}${e.isRequired?``:` | null`}`}))}),t.addStatements(t=>V(t,[``,`/**`,` * ${i(e.name)} contains all relations on your model in addition to the scalars`,` *`,` * NOTE: Lazy required in case of potential circular dependencies within schema`,` */`])),t.addVariableStatement({declarationKind:h.VariableDeclarationKind.Const,isExported:!0,declarations:[{name:i(e.name),type:`z.ZodSchema<${e.name}>`,initializer(t){t.write(`z.lazy(() => ${r(e.name)}.extend(`).inlineBlock(()=>{a.forEach(e=>{V(t,I(e.documentation)),t.write(`${e.name}: ${W(e,i)}`).write(`,`).newLine()})}).write(`))`)}}]})},ke=async(e,t,n,r)=>{await Ce(e,t,n,r),Ee(e,t,n),De(e,t,n),Se(e,n)&&Oe(e,t,n)},Ae=(e,t)=>{e.forEach(e=>t.addExportDeclaration({moduleSpecifier:`./${C(e.name)}.schema`}))},G=e=>e.withShield?`shieldedProcedure`:e.withMiddleware?`protectedProcedure`:`publicProcedure`,K=({sourceFile:e,config:t})=>{let n=[`t`];t&&n.push(G(t)),e.addImportDeclaration({moduleSpecifier:`../trpc`,namedImports:n})},je=(e,t,n)=>{e.addImportDeclaration({moduleSpecifier:`./${C(n)}.router`,namedImports:[`${t}Router`]})};async function Me(e,t,n,r){t.withShield&&e.addImportDeclaration({moduleSpecifier:(0,m.relativePath)(r,(0,d.joinPaths)(r,typeof t.withShield==`string`?t.withShield:`shield`)),namedImports:[`permissions`]}),e.addStatements(`import type { Context } from '${(0,m.relativePath)(r,(0,d.joinPaths)(r,t.contextPath))}';`),t.trpcOptions&&e.addStatements(`import trpcOptions from '${typeof t.trpcOptions==`string`?(0,m.relativePath)(r,(0,d.joinPaths)(r,t.trpcOptions)):`./options`}';`),t.withNext&&e.addStatements(`import { createContext } from '${(0,m.relativePath)(r,(0,d.joinPaths)(r,t.contextPath))}';
|
|
2396
4
|
import { initTRPC } from '@trpc/server';
|
|
2397
5
|
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
|
|
2398
|
-
import { cookies } from "next/headers";`
|
|
2399
|
-
|
|
2400
|
-
}
|
|
2401
|
-
sourceFile.addStatements(
|
|
2402
|
-
/* ts */
|
|
2403
|
-
`
|
|
2404
|
-
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});`
|
|
2405
|
-
);
|
|
2406
|
-
const middlewares = [];
|
|
2407
|
-
if (config.withMiddleware && typeof config.withMiddleware === "boolean") {
|
|
2408
|
-
sourceFile.addStatements(
|
|
2409
|
-
/* ts */
|
|
2410
|
-
`
|
|
6
|
+
import { cookies } from "next/headers";`),e.addStatements(`
|
|
7
|
+
export const t = initTRPC.context<Context>().create(${t.trpcOptions?`trpcOptions`:``});`);let i=[];if(t.withMiddleware&&typeof t.withMiddleware==`boolean`&&(e.addStatements(`
|
|
2411
8
|
export const globalMiddleware = t.middleware(async ({ ctx, next }) => {
|
|
2412
9
|
console.log('inside middleware!')
|
|
2413
10
|
return next()
|
|
2414
|
-
});`
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
value: (
|
|
2419
|
-
/* ts */
|
|
2420
|
-
`.use(globalMiddleware)`
|
|
2421
|
-
)
|
|
2422
|
-
});
|
|
2423
|
-
}
|
|
2424
|
-
if (config.withMiddleware && typeof config.withMiddleware === "string") {
|
|
2425
|
-
sourceFile.addStatements(
|
|
2426
|
-
/* ts */
|
|
2427
|
-
`
|
|
2428
|
-
import middleware from '${(0, import_file_path_fns.relativePath)(outputDir, (0, import_join_paths3.joinPaths)(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
|
|
2429
|
-
`
|
|
2430
|
-
);
|
|
2431
|
-
sourceFile.addStatements(
|
|
2432
|
-
/* ts */
|
|
2433
|
-
`
|
|
2434
|
-
export const globalMiddleware = t.middleware(middleware);`
|
|
2435
|
-
);
|
|
2436
|
-
middlewares.push({
|
|
2437
|
-
type: "global",
|
|
2438
|
-
value: (
|
|
2439
|
-
/* ts */
|
|
2440
|
-
`.use(globalMiddleware)`
|
|
2441
|
-
)
|
|
2442
|
-
});
|
|
2443
|
-
}
|
|
2444
|
-
if (config.withShield) {
|
|
2445
|
-
sourceFile.addStatements(
|
|
2446
|
-
/* ts */
|
|
2447
|
-
`
|
|
11
|
+
});`),i.push({type:`global`,value:`.use(globalMiddleware)`})),t.withMiddleware&&typeof t.withMiddleware==`string`&&(e.addStatements(`
|
|
12
|
+
import middleware from '${(0,m.relativePath)(r,(0,d.joinPaths)(r,typeof t.withMiddleware==`string`?t.withMiddleware:`middleware`))}';
|
|
13
|
+
`),e.addStatements(`
|
|
14
|
+
export const globalMiddleware = t.middleware(middleware);`),i.push({type:`global`,value:`.use(globalMiddleware)`})),t.withShield&&(e.addStatements(`
|
|
2448
15
|
export const permissionsMiddleware = t.middleware(permissions);
|
|
2449
|
-
`
|
|
2450
|
-
|
|
2451
|
-
middlewares.push({
|
|
2452
|
-
type: "shield",
|
|
2453
|
-
value: (
|
|
2454
|
-
/* ts */
|
|
2455
|
-
`
|
|
2456
|
-
.use(permissions)`
|
|
2457
|
-
)
|
|
2458
|
-
});
|
|
2459
|
-
}
|
|
2460
|
-
sourceFile.addStatements(
|
|
2461
|
-
/* ts */
|
|
2462
|
-
`
|
|
16
|
+
`),i.push({type:`shield`,value:`
|
|
17
|
+
.use(permissions)`})),e.addStatements(`
|
|
2463
18
|
/**
|
|
2464
19
|
* Create a server-side caller
|
|
2465
20
|
* @see https://trpc.io/docs/server/server-side-calls
|
|
2466
21
|
*/
|
|
2467
|
-
export const createCallerFactory = t.createCallerFactory;`
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
/* ts */
|
|
2471
|
-
`
|
|
2472
|
-
export const publicProcedure = t.procedure; `
|
|
2473
|
-
);
|
|
2474
|
-
if (middlewares.length > 0) {
|
|
2475
|
-
const procName = getProcedureName(config);
|
|
2476
|
-
middlewares.forEach((middleware, i) => {
|
|
2477
|
-
if (i === 0) {
|
|
2478
|
-
sourceFile.addStatements(
|
|
2479
|
-
/* ts */
|
|
2480
|
-
`
|
|
2481
|
-
export const ${procName} = t.procedure`
|
|
2482
|
-
);
|
|
2483
|
-
}
|
|
2484
|
-
sourceFile.addStatements(
|
|
2485
|
-
/* ts */
|
|
2486
|
-
`.use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})`
|
|
2487
|
-
);
|
|
2488
|
-
});
|
|
2489
|
-
}
|
|
2490
|
-
if (config.withNext) {
|
|
2491
|
-
sourceFile.addStatements(
|
|
2492
|
-
/* ts */
|
|
2493
|
-
`
|
|
22
|
+
export const createCallerFactory = t.createCallerFactory;`),e.addStatements(`
|
|
23
|
+
export const publicProcedure = t.procedure; `),i.length>0){let n=G(t);i.forEach((t,r)=>{r===0&&e.addStatements(`
|
|
24
|
+
export const ${n} = t.procedure`),e.addStatements(`.use(${t.type===`shield`?`permissionsMiddleware`:`globalMiddleware`})`)})}t.withNext&&e.addStatements(`
|
|
2494
25
|
export const createAction: ReturnType<typeof createTRPCServerActionHandler> =
|
|
2495
26
|
createTRPCServerActionHandler(cookies, t, createContext);
|
|
2496
|
-
`
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
}
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
`${config.showModelNameInProcedure ? name : nameWithoutModel}: ${getProcedureName(config)}
|
|
2513
|
-
${config.withZod ? `.input(${lowerCaseFirst(typeName)})` : ""}.${getProcedureTypeByOpName(baseOpType)}(async ({ ctx, input }) => {
|
|
2514
|
-
const ${name} = await ctx.prisma.${lowerCaseFirst(modelName)}.${opType.replace("One", "")}(${input});
|
|
2515
|
-
return ${name};
|
|
2516
|
-
}),`
|
|
2517
|
-
);
|
|
2518
|
-
}
|
|
2519
|
-
__name(generateProcedure, "generateProcedure");
|
|
2520
|
-
function generateRouterSchemaImports(sourceFile, modelName, modelActions) {
|
|
2521
|
-
sourceFile.addStatements(
|
|
2522
|
-
/* ts */
|
|
2523
|
-
[
|
|
2524
|
-
// remove any duplicate import statements
|
|
2525
|
-
...new Set(modelActions.map((opName) => getRouterSchemaImportByOpName(opName, modelName)))
|
|
2526
|
-
].join("\n")
|
|
2527
|
-
);
|
|
2528
|
-
}
|
|
2529
|
-
__name(generateRouterSchemaImports, "generateRouterSchemaImports");
|
|
2530
|
-
var getRouterSchemaImportByOpName = /* @__PURE__ */ __name((opName, modelName) => {
|
|
2531
|
-
const opType = opName.replace("OrThrow", "").replace("ManyAndReturn", "");
|
|
2532
|
-
const inputType = getInputTypeByOpName(opType, modelName);
|
|
2533
|
-
return inputType ? `import { ${lowerCaseFirst(inputType)} } from "../schemas/${lowerCaseFirst(opType)}${modelName}.schema"; ` : "";
|
|
2534
|
-
}, "getRouterSchemaImportByOpName");
|
|
2535
|
-
var getInputTypeByOpName = /* @__PURE__ */ __name((opName, modelName) => {
|
|
2536
|
-
let inputType;
|
|
2537
|
-
switch (opName) {
|
|
2538
|
-
case "findUnique":
|
|
2539
|
-
inputType = `${modelName}FindUniqueSchema`;
|
|
2540
|
-
break;
|
|
2541
|
-
case "findFirst":
|
|
2542
|
-
inputType = `${modelName}FindFirstSchema`;
|
|
2543
|
-
break;
|
|
2544
|
-
case "findMany":
|
|
2545
|
-
inputType = `${modelName}FindManySchema`;
|
|
2546
|
-
break;
|
|
2547
|
-
case "findRaw":
|
|
2548
|
-
inputType = `${modelName}FindRawObjectSchema`;
|
|
2549
|
-
break;
|
|
2550
|
-
case "createOne":
|
|
2551
|
-
inputType = `${modelName}CreateOneSchema`;
|
|
2552
|
-
break;
|
|
2553
|
-
case "createMany":
|
|
2554
|
-
inputType = `${modelName}CreateManySchema`;
|
|
2555
|
-
break;
|
|
2556
|
-
case "createManyAndReturn":
|
|
2557
|
-
inputType = `${modelName}CreateManySchema`;
|
|
2558
|
-
break;
|
|
2559
|
-
case "deleteOne":
|
|
2560
|
-
inputType = `${modelName}DeleteOneSchema`;
|
|
2561
|
-
break;
|
|
2562
|
-
case "deleteMany":
|
|
2563
|
-
inputType = `${modelName}DeleteManySchema`;
|
|
2564
|
-
break;
|
|
2565
|
-
case "updateOne":
|
|
2566
|
-
inputType = `${modelName}UpdateOneSchema`;
|
|
2567
|
-
break;
|
|
2568
|
-
case "updateMany":
|
|
2569
|
-
inputType = `${modelName}UpdateManySchema`;
|
|
2570
|
-
break;
|
|
2571
|
-
case "updateManyAndReturn":
|
|
2572
|
-
inputType = `${modelName}UpdateManySchema`;
|
|
2573
|
-
break;
|
|
2574
|
-
case "upsertOne":
|
|
2575
|
-
inputType = `${modelName}UpsertSchema`;
|
|
2576
|
-
break;
|
|
2577
|
-
case "aggregate":
|
|
2578
|
-
inputType = `${modelName}AggregateSchema`;
|
|
2579
|
-
break;
|
|
2580
|
-
case "aggregateRaw":
|
|
2581
|
-
inputType = `${modelName}AggregateRawObjectSchema`;
|
|
2582
|
-
break;
|
|
2583
|
-
case "groupBy":
|
|
2584
|
-
inputType = `${modelName}GroupBySchema`;
|
|
2585
|
-
break;
|
|
2586
|
-
default:
|
|
2587
|
-
console.log("getInputTypeByOpName: ", {
|
|
2588
|
-
opName,
|
|
2589
|
-
modelName
|
|
2590
|
-
});
|
|
2591
|
-
}
|
|
2592
|
-
return inputType;
|
|
2593
|
-
}, "getInputTypeByOpName");
|
|
2594
|
-
var getProcedureTypeByOpName = /* @__PURE__ */ __name((opName) => {
|
|
2595
|
-
let procType;
|
|
2596
|
-
switch (opName) {
|
|
2597
|
-
case "findUnique":
|
|
2598
|
-
case "findFirst":
|
|
2599
|
-
case "findMany":
|
|
2600
|
-
case "findRaw":
|
|
2601
|
-
case "aggregate":
|
|
2602
|
-
case "aggregateRaw":
|
|
2603
|
-
case "groupBy":
|
|
2604
|
-
procType = "query";
|
|
2605
|
-
break;
|
|
2606
|
-
case "createOne":
|
|
2607
|
-
case "createMany":
|
|
2608
|
-
case "createManyAndReturn":
|
|
2609
|
-
case "deleteOne":
|
|
2610
|
-
case "updateOne":
|
|
2611
|
-
case "deleteMany":
|
|
2612
|
-
case "updateMany":
|
|
2613
|
-
case "updateManyAndReturn":
|
|
2614
|
-
case "upsertOne":
|
|
2615
|
-
procType = "mutation";
|
|
2616
|
-
break;
|
|
2617
|
-
default:
|
|
2618
|
-
console.log("getProcedureTypeByOpName: ", {
|
|
2619
|
-
opName
|
|
2620
|
-
});
|
|
2621
|
-
}
|
|
2622
|
-
return procType;
|
|
2623
|
-
}, "getProcedureTypeByOpName");
|
|
2624
|
-
function resolveModelsComments(models, hiddenModels) {
|
|
2625
|
-
const modelAttributeRegex2 = /(?:@@Gen\.)+[A-z]+\(.+\)/;
|
|
2626
|
-
const attributeNameRegex2 = /\.+[A-Z]+\(+/i;
|
|
2627
|
-
const attributeArgsRegex2 = /\(+[A-Z]+:.+\)/i;
|
|
2628
|
-
for (const model of models) {
|
|
2629
|
-
if (model.documentation) {
|
|
2630
|
-
const attribute = model.documentation?.match(modelAttributeRegex2)?.[0];
|
|
2631
|
-
const attributeName = attribute?.match(attributeNameRegex2)?.[0]?.slice(1, -1);
|
|
2632
|
-
if (attributeName !== "model") continue;
|
|
2633
|
-
const rawAttributeArgs = attribute?.match(attributeArgsRegex2)?.[0]?.slice(1, -1);
|
|
2634
|
-
const parsedAttributeArgs = {};
|
|
2635
|
-
if (rawAttributeArgs) {
|
|
2636
|
-
const rawAttributeArgsParts = rawAttributeArgs.split(":").map((it) => it.trim()).map((part) => part.startsWith("[") ? part : part.split(",")).flat().map((it) => it.trim());
|
|
2637
|
-
for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {
|
|
2638
|
-
const key = rawAttributeArgsParts[i];
|
|
2639
|
-
const value = rawAttributeArgsParts[i + 1];
|
|
2640
|
-
parsedAttributeArgs[key] = JSON.parse(value);
|
|
2641
|
-
}
|
|
2642
|
-
}
|
|
2643
|
-
if (parsedAttributeArgs.hide) {
|
|
2644
|
-
hiddenModels.push(model.name);
|
|
2645
|
-
}
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
}
|
|
2649
|
-
__name(resolveModelsComments, "resolveModelsComments");
|
|
2650
|
-
var getImports = /* @__PURE__ */ __name((type, newPath) => {
|
|
2651
|
-
let statement = "";
|
|
2652
|
-
if (type === "trpc") {
|
|
2653
|
-
statement = "import * as trpc from '@trpc/server';\n";
|
|
2654
|
-
} else if (type === "trpc-shield") {
|
|
2655
|
-
statement = "import { shield, allow } from '@stryke/trpc-next/shield';\n";
|
|
2656
|
-
} else if (type === "context") {
|
|
2657
|
-
statement = `import type { Context } from '${newPath}';
|
|
2658
|
-
`;
|
|
2659
|
-
}
|
|
2660
|
-
return statement;
|
|
2661
|
-
}, "getImports");
|
|
2662
|
-
var wrapWithObject = /* @__PURE__ */ __name(({ shieldItemLines }) => {
|
|
2663
|
-
let wrapped = "{";
|
|
2664
|
-
wrapped += "\n";
|
|
2665
|
-
wrapped += Array.isArray(shieldItemLines) ? ` ${shieldItemLines.join(",\r\n")}` : ` ${shieldItemLines}`;
|
|
2666
|
-
wrapped += "\n";
|
|
2667
|
-
wrapped += "}";
|
|
2668
|
-
return wrapped;
|
|
2669
|
-
}, "wrapWithObject");
|
|
2670
|
-
var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }) => {
|
|
2671
|
-
let wrapped = "shield<Context>(";
|
|
2672
|
-
wrapped += "\n";
|
|
2673
|
-
wrapped += ` ${shieldObjectTextWrapped}`;
|
|
2674
|
-
wrapped += "\n";
|
|
2675
|
-
wrapped += ")";
|
|
2676
|
-
return wrapped;
|
|
2677
|
-
}, "wrapWithTrpcShieldCall");
|
|
2678
|
-
var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
|
|
2679
|
-
return `export const permissions: ReturnType<typeof shield<Context>> = ${shieldObjectText};`;
|
|
2680
|
-
}, "wrapWithExport");
|
|
2681
|
-
var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, outputDir) => {
|
|
2682
|
-
if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
|
|
2683
|
-
return "";
|
|
2684
|
-
}
|
|
2685
|
-
let rootItems = "";
|
|
2686
|
-
if (queries.length > 0) {
|
|
2687
|
-
const queryLinesWrapped = `query: ${wrapWithObject({
|
|
2688
|
-
shieldItemLines: queries.map((query) => `${query}: allow`)
|
|
2689
|
-
})},`;
|
|
2690
|
-
rootItems += queryLinesWrapped;
|
|
2691
|
-
}
|
|
2692
|
-
if (mutations.length > 0) {
|
|
2693
|
-
const mutationLinesWrapped = `mutation: ${wrapWithObject({
|
|
2694
|
-
shieldItemLines: mutations.map((mutation) => `${mutation}: allow`)
|
|
2695
|
-
})},`;
|
|
2696
|
-
rootItems += mutationLinesWrapped;
|
|
2697
|
-
}
|
|
2698
|
-
if (subscriptions.length > 0) {
|
|
2699
|
-
const subscriptionLinesWrapped = `subscription: ${wrapWithObject({
|
|
2700
|
-
shieldItemLines: subscriptions.map((subscription) => `${subscription}: allow`)
|
|
2701
|
-
})},`;
|
|
2702
|
-
rootItems += subscriptionLinesWrapped;
|
|
2703
|
-
}
|
|
2704
|
-
if (rootItems.length === 0) {
|
|
2705
|
-
return "";
|
|
2706
|
-
}
|
|
2707
|
-
let shieldText = getImports("trpc-shield");
|
|
2708
|
-
shieldText += getImports("context", (0, import_file_path_fns.relativePath)(outputDir, (0, import_join_paths3.joinPaths)(outputDir, config.contextPath)));
|
|
2709
|
-
shieldText += "\n\n";
|
|
2710
|
-
shieldText += wrapWithExport({
|
|
2711
|
-
shieldObjectText: wrapWithTrpcShieldCall({
|
|
2712
|
-
shieldObjectTextWrapped: wrapWithObject({
|
|
2713
|
-
shieldItemLines: rootItems
|
|
2714
|
-
})
|
|
2715
|
-
})
|
|
2716
|
-
});
|
|
2717
|
-
return shieldText;
|
|
2718
|
-
}, "constructShield");
|
|
2719
|
-
var constructDefaultOptions = /* @__PURE__ */ __name((config, options, outputDir) => {
|
|
2720
|
-
return `import { ZodError } from 'zod';${config.withNext ? '\nimport { transformer } from "@stryke/trpc-next/shared";' : ""}
|
|
27
|
+
`),e.formatText({indentSize:2})}function Ne(e,t,n,r,i,a,o){let s=`input${o.withZod?``:` as any`}`,c=t.replace(r,``);c===`groupBy`&&o.withZod&&(s=`{ where: input.where, orderBy: input.orderBy, by: input.by, having: input.having, take: input.take, skip: input.skip }`),e.addStatements(`${o.showModelNameInProcedure?t:c}: ${G(o)}
|
|
28
|
+
${o.withZod?`.input(${C(n)})`:``}.${Ie(a)}(async ({ ctx, input }) => {
|
|
29
|
+
const ${t} = await ctx.prisma.${C(r)}.${i.replace(`One`,``)}(${s});
|
|
30
|
+
return ${t};
|
|
31
|
+
}),`)}function Pe(e,t,n){e.addStatements([...new Set(n.map(e=>Fe(e,t)))].join(`
|
|
32
|
+
`))}const Fe=(e,t)=>{let n=e.replace(`OrThrow`,``).replace(`ManyAndReturn`,``),r=q(n,t);return r?`import { ${C(r)} } from "../schemas/${C(n)}${t}.schema"; `:``},q=(e,t)=>{let n;switch(e){case`findUnique`:n=`${t}FindUniqueSchema`;break;case`findFirst`:n=`${t}FindFirstSchema`;break;case`findMany`:n=`${t}FindManySchema`;break;case`findRaw`:n=`${t}FindRawObjectSchema`;break;case`createOne`:n=`${t}CreateOneSchema`;break;case`createMany`:n=`${t}CreateManySchema`;break;case`createManyAndReturn`:n=`${t}CreateManySchema`;break;case`deleteOne`:n=`${t}DeleteOneSchema`;break;case`deleteMany`:n=`${t}DeleteManySchema`;break;case`updateOne`:n=`${t}UpdateOneSchema`;break;case`updateMany`:n=`${t}UpdateManySchema`;break;case`updateManyAndReturn`:n=`${t}UpdateManySchema`;break;case`upsertOne`:n=`${t}UpsertSchema`;break;case`aggregate`:n=`${t}AggregateSchema`;break;case`aggregateRaw`:n=`${t}AggregateRawObjectSchema`;break;case`groupBy`:n=`${t}GroupBySchema`;break;default:console.log(`getInputTypeByOpName: `,{opName:e,modelName:t})}return n},Ie=e=>{let t;switch(e){case`findUnique`:case`findFirst`:case`findMany`:case`findRaw`:case`aggregate`:case`aggregateRaw`:case`groupBy`:t=`query`;break;case`createOne`:case`createMany`:case`createManyAndReturn`:case`deleteOne`:case`updateOne`:case`deleteMany`:case`updateMany`:case`updateManyAndReturn`:case`upsertOne`:t=`mutation`;break;default:console.log(`getProcedureTypeByOpName: `,{opName:e})}return t};function Le(e,t){let n=/(?:@@Gen\.)+[A-z]+\(.+\)/,r=/\.+[A-Z]+\(+/i,i=/\(+[A-Z]+:.+\)/i;for(let a of e)if(a.documentation){let e=a.documentation?.match(n)?.[0];if(e?.match(r)?.[0]?.slice(1,-1)!==`model`)continue;let o=e?.match(i)?.[0]?.slice(1,-1),s={};if(o){let e=o.split(`:`).map(e=>e.trim()).map(e=>e.startsWith(`[`)?e:e.split(`,`)).flat().map(e=>e.trim());for(let t=0;t<e.length;t+=2){let n=e[t],r=e[t+1];s[n]=JSON.parse(r)}}s.hide&&t.push(a.name)}}const J=(e,t)=>{let n=``;return e===`trpc`?n=`import * as trpc from '@trpc/server';
|
|
33
|
+
`:e===`trpc-shield`?n=`import { shield, allow } from '@stryke/trpc-next/shield';
|
|
34
|
+
`:e===`context`&&(n=`import type { Context } from '${t}';\n`),n},Y=({shieldItemLines:e})=>{let t=`{`;return t+=`
|
|
35
|
+
`,t+=Array.isArray(e)?` ${e.join(`,\r
|
|
36
|
+
`)}`:` ${e}`,t+=`
|
|
37
|
+
`,t+=`}`,t},Re=({shieldObjectTextWrapped:e})=>{let t=`shield<Context>(`;return t+=`
|
|
38
|
+
`,t+=` ${e}`,t+=`
|
|
39
|
+
`,t+=`)`,t},ze=({shieldObjectText:e})=>`export const permissions: ReturnType<typeof shield<Context>> = ${e};`,Be=async({queries:e,mutations:t,subscriptions:n},r,i,a)=>{if(e.length===0&&t.length===0&&n.length===0)return``;let o=``;if(e.length>0){let t=`query: ${Y({shieldItemLines:e.map(e=>`${e}: allow`)})},`;o+=t}if(t.length>0){let e=`mutation: ${Y({shieldItemLines:t.map(e=>`${e}: allow`)})},`;o+=e}if(n.length>0){let e=`subscription: ${Y({shieldItemLines:n.map(e=>`${e}: allow`)})},`;o+=e}if(o.length===0)return``;let s=J(`trpc-shield`);return s+=J(`context`,(0,m.relativePath)(a,(0,d.joinPaths)(a,r.contextPath))),s+=`
|
|
40
|
+
|
|
41
|
+
`,s+=ze({shieldObjectText:Re({shieldObjectTextWrapped:Y({shieldItemLines:o})})}),s},Ve=(e,t,n)=>`import { ZodError } from 'zod';${e.withNext?`
|
|
42
|
+
import { transformer } from "@stryke/trpc-next/shared";`:``}
|
|
2721
43
|
import type {
|
|
2722
44
|
DataTransformerOptions,
|
|
2723
45
|
RootConfig
|
|
2724
46
|
} from "@trpc/server/unstable-core-do-not-import";
|
|
2725
|
-
import type { Context } from "${(0,
|
|
47
|
+
import type { Context } from "${(0,m.relativePath)(n,(0,d.joinPaths)(n,e.contextPath))}";
|
|
2726
48
|
|
|
2727
49
|
interface RuntimeConfigOptions<
|
|
2728
50
|
TContext extends object,
|
|
@@ -2745,7 +67,8 @@ interface RuntimeConfigOptions<
|
|
|
2745
67
|
transformer?: DataTransformerOptions;
|
|
2746
68
|
}
|
|
2747
69
|
|
|
2748
|
-
const options: RuntimeConfigOptions<Context> = {${
|
|
70
|
+
const options: RuntimeConfigOptions<Context> = {${e.withNext?`
|
|
71
|
+
transformer,`:``}
|
|
2749
72
|
errorFormatter({ shape, error }) {
|
|
2750
73
|
return {
|
|
2751
74
|
...shape,
|
|
@@ -2761,1442 +84,33 @@ const options: RuntimeConfigOptions<Context> = {${config.withNext ? "\n transfor
|
|
|
2761
84
|
};
|
|
2762
85
|
|
|
2763
86
|
export default options;
|
|
2764
|
-
|
|
2765
|
-
},
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
}));
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
init_cjs_shims();
|
|
2795
|
-
var import_prettier = __toESM(require("prettier"), 1);
|
|
2796
|
-
async function formatFile(content) {
|
|
2797
|
-
const options = await import_prettier.default.resolveConfig(process.cwd());
|
|
2798
|
-
let formatOptions = options;
|
|
2799
|
-
if (!options) {
|
|
2800
|
-
formatOptions = {
|
|
2801
|
-
trailingComma: "all",
|
|
2802
|
-
tabWidth: 2,
|
|
2803
|
-
printWidth: 80,
|
|
2804
|
-
bracketSpacing: true,
|
|
2805
|
-
semi: true,
|
|
2806
|
-
singleQuote: true,
|
|
2807
|
-
useTabs: false
|
|
2808
|
-
};
|
|
2809
|
-
}
|
|
2810
|
-
const formatted = await import_prettier.default.format(content, {
|
|
2811
|
-
...formatOptions,
|
|
2812
|
-
parser: "typescript"
|
|
2813
|
-
});
|
|
2814
|
-
return formatted;
|
|
2815
|
-
}
|
|
2816
|
-
__name(formatFile, "formatFile");
|
|
2817
|
-
|
|
2818
|
-
// src/utils/write-file-safely.ts
|
|
2819
|
-
var indexExports = /* @__PURE__ */ new Set();
|
|
2820
|
-
var addIndexExport = /* @__PURE__ */ __name((filePath) => {
|
|
2821
|
-
indexExports.add(filePath);
|
|
2822
|
-
}, "addIndexExport");
|
|
2823
|
-
var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addToIndex = true) => {
|
|
2824
|
-
const [fileContent] = await Promise.all([
|
|
2825
|
-
formatFile(content),
|
|
2826
|
-
(0, import_helpers.createDirectory)((0, import_file_path_fns2.findFilePath)(writeLocation))
|
|
2827
|
-
]);
|
|
2828
|
-
await (0, import_write_file.writeFile)(writeLocation, fileContent);
|
|
2829
|
-
if (addToIndex) {
|
|
2830
|
-
addIndexExport(writeLocation);
|
|
2831
|
-
}
|
|
2832
|
-
}, "writeFileSafely");
|
|
2833
|
-
var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
|
|
2834
|
-
const rows = Array.from(indexExports).map((filePath) => {
|
|
2835
|
-
let relativePath2 = import_node_path3.default.relative(import_node_path3.default.dirname(indexPath), filePath);
|
|
2836
|
-
if (relativePath2.endsWith(".ts")) {
|
|
2837
|
-
relativePath2 = relativePath2.slice(0, relativePath2.lastIndexOf(".ts"));
|
|
2838
|
-
}
|
|
2839
|
-
const normalized = (0, import_correct_path.correctPath)(relativePath2);
|
|
2840
|
-
return `export * from './${normalized}';`;
|
|
2841
|
-
});
|
|
2842
|
-
rows.push("export * from './models';");
|
|
2843
|
-
await writeFileSafely(indexPath, rows.join("\n"), false);
|
|
2844
|
-
}, "writeIndexFile");
|
|
2845
|
-
|
|
2846
|
-
// src/zod/aggregate-helpers.ts
|
|
2847
|
-
init_cjs_shims();
|
|
2848
|
-
var isAggregateOutputType = /* @__PURE__ */ __name((name) => /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(name), "isAggregateOutputType");
|
|
2849
|
-
var isAggregateInputType = /* @__PURE__ */ __name((name) => name.endsWith("CountAggregateInput") || name.endsWith("SumAggregateInput") || name.endsWith("AvgAggregateInput") || name.endsWith("MinAggregateInput") || name.endsWith("MaxAggregateInput"), "isAggregateInputType");
|
|
2850
|
-
function addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes) {
|
|
2851
|
-
const aggregateOutputTypes = outputObjectTypes.filter(({ name }) => isAggregateOutputType(name));
|
|
2852
|
-
for (const aggregateOutputType of aggregateOutputTypes) {
|
|
2853
|
-
const name = aggregateOutputType.name.replace(/(?:OutputType|Output)$/, "");
|
|
2854
|
-
inputObjectTypes.push({
|
|
2855
|
-
constraints: {
|
|
2856
|
-
maxNumFields: null,
|
|
2857
|
-
minNumFields: null
|
|
2858
|
-
},
|
|
2859
|
-
name: `${name}Input`,
|
|
2860
|
-
fields: aggregateOutputType.fields.map((field) => ({
|
|
2861
|
-
name: field.name,
|
|
2862
|
-
isNullable: false,
|
|
2863
|
-
isRequired: false,
|
|
2864
|
-
inputTypes: [
|
|
2865
|
-
{
|
|
2866
|
-
isList: false,
|
|
2867
|
-
type: "True",
|
|
2868
|
-
location: "scalar"
|
|
2869
|
-
}
|
|
2870
|
-
]
|
|
2871
|
-
}))
|
|
2872
|
-
});
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
2875
|
-
__name(addMissingInputObjectTypesForAggregate, "addMissingInputObjectTypesForAggregate");
|
|
2876
|
-
function resolveZodAggregateOperationSupport(inputObjectTypes) {
|
|
2877
|
-
const aggregateOperationSupport = {};
|
|
2878
|
-
for (const inputType of inputObjectTypes) {
|
|
2879
|
-
if (isAggregateInputType(inputType.name)) {
|
|
2880
|
-
const name = inputType.name.replace("AggregateInput", "");
|
|
2881
|
-
if (name.endsWith("Count")) {
|
|
2882
|
-
const model = name.replace("Count", "");
|
|
2883
|
-
aggregateOperationSupport[model] = {
|
|
2884
|
-
...aggregateOperationSupport[model],
|
|
2885
|
-
count: true
|
|
2886
|
-
};
|
|
2887
|
-
} else if (name.endsWith("Min")) {
|
|
2888
|
-
const model = name.replace("Min", "");
|
|
2889
|
-
aggregateOperationSupport[model] = {
|
|
2890
|
-
...aggregateOperationSupport[model],
|
|
2891
|
-
min: true
|
|
2892
|
-
};
|
|
2893
|
-
} else if (name.endsWith("Max")) {
|
|
2894
|
-
const model = name.replace("Max", "");
|
|
2895
|
-
aggregateOperationSupport[model] = {
|
|
2896
|
-
...aggregateOperationSupport[model],
|
|
2897
|
-
max: true
|
|
2898
|
-
};
|
|
2899
|
-
} else if (name.endsWith("Sum")) {
|
|
2900
|
-
const model = name.replace("Sum", "");
|
|
2901
|
-
aggregateOperationSupport[model] = {
|
|
2902
|
-
...aggregateOperationSupport[model],
|
|
2903
|
-
sum: true
|
|
2904
|
-
};
|
|
2905
|
-
} else if (name.endsWith("Avg")) {
|
|
2906
|
-
const model = name.replace("Avg", "");
|
|
2907
|
-
aggregateOperationSupport[model] = {
|
|
2908
|
-
...aggregateOperationSupport[model],
|
|
2909
|
-
avg: true
|
|
2910
|
-
};
|
|
2911
|
-
}
|
|
2912
|
-
}
|
|
2913
|
-
}
|
|
2914
|
-
return aggregateOperationSupport;
|
|
2915
|
-
}
|
|
2916
|
-
__name(resolveZodAggregateOperationSupport, "resolveZodAggregateOperationSupport");
|
|
2917
|
-
|
|
2918
|
-
// src/zod/comments-helpers.ts
|
|
2919
|
-
init_cjs_shims();
|
|
2920
|
-
var modelAttributeRegex = /(?:@@Gen\.)+[A-z]+\(.+\)/;
|
|
2921
|
-
var attributeNameRegex = /\.+[A-Z]+\(+/i;
|
|
2922
|
-
var attributeArgsRegex = /\(+[A-Z]+:.+\)/i;
|
|
2923
|
-
function resolveZodModelsComments(models, modelOperations, enumTypes, hiddenModels, hiddenFields) {
|
|
2924
|
-
models = collectHiddenModels(models, hiddenModels);
|
|
2925
|
-
collectHiddenFields(models, hiddenModels, hiddenFields);
|
|
2926
|
-
hideModelOperations(models, modelOperations);
|
|
2927
|
-
hideEnums(enumTypes, hiddenModels);
|
|
2928
|
-
}
|
|
2929
|
-
__name(resolveZodModelsComments, "resolveZodModelsComments");
|
|
2930
|
-
function collectHiddenModels(models, hiddenModels) {
|
|
2931
|
-
return models.map((model) => {
|
|
2932
|
-
if (model.documentation) {
|
|
2933
|
-
const attribute = model.documentation?.match(modelAttributeRegex)?.[0];
|
|
2934
|
-
const attributeName = attribute?.match(attributeNameRegex)?.[0]?.slice(1, -1);
|
|
2935
|
-
if (attributeName !== "model") {
|
|
2936
|
-
return model;
|
|
2937
|
-
}
|
|
2938
|
-
const rawAttributeArgs = attribute?.match(attributeArgsRegex)?.[0]?.slice(1, -1);
|
|
2939
|
-
const parsedAttributeArgs = {};
|
|
2940
|
-
if (rawAttributeArgs) {
|
|
2941
|
-
const rawAttributeArgsParts = rawAttributeArgs.split(":").map((it) => it.trim()).map((part) => part.startsWith("[") ? part : part.split(",")).flat().map((it) => it.trim());
|
|
2942
|
-
for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {
|
|
2943
|
-
const key = rawAttributeArgsParts[i];
|
|
2944
|
-
const value = rawAttributeArgsParts[i + 1];
|
|
2945
|
-
parsedAttributeArgs[key] = JSON.parse(value);
|
|
2946
|
-
}
|
|
2947
|
-
}
|
|
2948
|
-
if (parsedAttributeArgs.hide) {
|
|
2949
|
-
hiddenModels.push(model.name);
|
|
2950
|
-
return null;
|
|
2951
|
-
}
|
|
2952
|
-
}
|
|
2953
|
-
return model;
|
|
2954
|
-
}).filter(Boolean);
|
|
2955
|
-
}
|
|
2956
|
-
__name(collectHiddenModels, "collectHiddenModels");
|
|
2957
|
-
function collectHiddenFields(models, hiddenModels, hiddenFields) {
|
|
2958
|
-
models.forEach((model) => {
|
|
2959
|
-
model.fields.forEach((field) => {
|
|
2960
|
-
if (hiddenModels.includes(field.type)) {
|
|
2961
|
-
hiddenFields.push(field.name);
|
|
2962
|
-
if (field.relationFromFields) {
|
|
2963
|
-
field.relationFromFields.forEach((item) => hiddenFields.push(item));
|
|
2964
|
-
}
|
|
2965
|
-
}
|
|
2966
|
-
});
|
|
2967
|
-
});
|
|
2968
|
-
}
|
|
2969
|
-
__name(collectHiddenFields, "collectHiddenFields");
|
|
2970
|
-
function hideEnums(enumTypes, hiddenModels) {
|
|
2971
|
-
enumTypes.prisma = enumTypes.prisma.filter((item) => !hiddenModels.find((model) => item.name.startsWith(model)));
|
|
2972
|
-
}
|
|
2973
|
-
__name(hideEnums, "hideEnums");
|
|
2974
|
-
function hideModelOperations(models, modelOperations) {
|
|
2975
|
-
let i = modelOperations.length;
|
|
2976
|
-
while (i >= 0) {
|
|
2977
|
-
--i;
|
|
2978
|
-
const modelOperation = modelOperations[i];
|
|
2979
|
-
if (modelOperation && !models.find((model) => {
|
|
2980
|
-
return model.name === modelOperation.model;
|
|
2981
|
-
})) {
|
|
2982
|
-
modelOperations.splice(i, 1);
|
|
2983
|
-
}
|
|
2984
|
-
}
|
|
2985
|
-
}
|
|
2986
|
-
__name(hideModelOperations, "hideModelOperations");
|
|
2987
|
-
function hideZodInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels, hiddenFields) {
|
|
2988
|
-
let j = inputObjectTypes.length;
|
|
2989
|
-
while (j >= 0) {
|
|
2990
|
-
--j;
|
|
2991
|
-
const inputType = inputObjectTypes[j];
|
|
2992
|
-
if (inputType && (hiddenModels.includes(inputType?.meta?.source) || hiddenModels.find((model) => inputType.name.startsWith(model)))) {
|
|
2993
|
-
inputObjectTypes.splice(j, 1);
|
|
2994
|
-
} else {
|
|
2995
|
-
let k = inputType?.fields?.length ?? 0;
|
|
2996
|
-
while (k >= 0) {
|
|
2997
|
-
--k;
|
|
2998
|
-
const field = inputType?.fields?.[k];
|
|
2999
|
-
if (field && hiddenFields.includes(field.name)) {
|
|
3000
|
-
inputObjectTypes[j].fields.slice(k, 1);
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
}
|
|
3004
|
-
}
|
|
3005
|
-
}
|
|
3006
|
-
__name(hideZodInputObjectTypesAndRelatedFields, "hideZodInputObjectTypesAndRelatedFields");
|
|
3007
|
-
|
|
3008
|
-
// src/zod/generator-helpers.ts
|
|
3009
|
-
init_cjs_shims();
|
|
3010
|
-
|
|
3011
|
-
// src/zod/transformer.ts
|
|
3012
|
-
init_cjs_shims();
|
|
3013
|
-
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
3014
|
-
|
|
3015
|
-
// src/zod/mongodb-helpers.ts
|
|
3016
|
-
init_cjs_shims();
|
|
3017
|
-
function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes) {
|
|
3018
|
-
const rawOpsMap = resolveMongoDbRawOperations(modelOperations);
|
|
3019
|
-
Transformer.rawOpsMap = rawOpsMap ?? {};
|
|
3020
|
-
const mongoDbRawQueryInputObjectTypes = resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes);
|
|
3021
|
-
for (const mongoDbRawQueryInputType of mongoDbRawQueryInputObjectTypes) {
|
|
3022
|
-
inputObjectTypes.push(mongoDbRawQueryInputType);
|
|
3023
|
-
}
|
|
3024
|
-
}
|
|
3025
|
-
__name(addMissingInputObjectTypesForMongoDbRawOpsAndQueries, "addMissingInputObjectTypesForMongoDbRawOpsAndQueries");
|
|
3026
|
-
function resolveMongoDbRawOperations(modelOperations) {
|
|
3027
|
-
const rawOpsMap = {};
|
|
3028
|
-
const rawOpsNames = [
|
|
3029
|
-
...new Set(modelOperations.reduce((result, current) => {
|
|
3030
|
-
const keys = Object.keys(current);
|
|
3031
|
-
keys?.forEach((key) => {
|
|
3032
|
-
if (key.includes("Raw")) {
|
|
3033
|
-
result.push(key);
|
|
3034
|
-
}
|
|
3035
|
-
});
|
|
3036
|
-
return result;
|
|
3037
|
-
}, []))
|
|
3038
|
-
];
|
|
3039
|
-
const modelNames = modelOperations.map((item) => item.model);
|
|
3040
|
-
rawOpsNames.forEach((opName) => {
|
|
3041
|
-
modelNames.forEach((modelName) => {
|
|
3042
|
-
const isFind = opName === "findRaw";
|
|
3043
|
-
const opWithModel = `${opName.replace("Raw", "")}${modelName}Raw`;
|
|
3044
|
-
rawOpsMap[opWithModel] = isFind ? `${modelName}FindRawArgs` : `${modelName}AggregateRawArgs`;
|
|
3045
|
-
});
|
|
3046
|
-
});
|
|
3047
|
-
return rawOpsMap;
|
|
3048
|
-
}
|
|
3049
|
-
__name(resolveMongoDbRawOperations, "resolveMongoDbRawOperations");
|
|
3050
|
-
function resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes) {
|
|
3051
|
-
const mongoDbRawQueries = getMongoDbRawQueries(outputObjectTypes);
|
|
3052
|
-
const mongoDbRawQueryInputObjectTypes = mongoDbRawQueries.map((item) => ({
|
|
3053
|
-
name: item.name,
|
|
3054
|
-
constraints: {
|
|
3055
|
-
maxNumFields: null,
|
|
3056
|
-
minNumFields: null
|
|
3057
|
-
},
|
|
3058
|
-
fields: item.args.map((arg) => ({
|
|
3059
|
-
name: arg.name,
|
|
3060
|
-
isRequired: arg.isRequired,
|
|
3061
|
-
isNullable: arg.isNullable,
|
|
3062
|
-
inputTypes: arg.inputTypes
|
|
3063
|
-
}))
|
|
3064
|
-
}));
|
|
3065
|
-
return mongoDbRawQueryInputObjectTypes;
|
|
3066
|
-
}
|
|
3067
|
-
__name(resolveMongoDbRawQueryInputObjectTypes, "resolveMongoDbRawQueryInputObjectTypes");
|
|
3068
|
-
function getMongoDbRawQueries(outputObjectTypes) {
|
|
3069
|
-
const queryOutputTypes = outputObjectTypes.filter((item) => item.name === "Query");
|
|
3070
|
-
const mongodbRawQueries = queryOutputTypes?.[0].fields.filter((field) => field.name.includes("Raw")) ?? [];
|
|
3071
|
-
return mongodbRawQueries;
|
|
3072
|
-
}
|
|
3073
|
-
__name(getMongoDbRawQueries, "getMongoDbRawQueries");
|
|
3074
|
-
var isMongodbRawOp = /* @__PURE__ */ __name((name) => /find[\s\S]*?Raw/.test(name) || /aggregate[\s\S]*?Raw/.test(name), "isMongodbRawOp");
|
|
3075
|
-
|
|
3076
|
-
// src/zod/transformer.ts
|
|
3077
|
-
var Transformer = class _Transformer {
|
|
3078
|
-
static {
|
|
3079
|
-
__name(this, "Transformer");
|
|
3080
|
-
}
|
|
3081
|
-
name;
|
|
3082
|
-
fields;
|
|
3083
|
-
schemaImports = /* @__PURE__ */ new Set();
|
|
3084
|
-
models;
|
|
3085
|
-
modelOperations;
|
|
3086
|
-
aggregateOperationSupport;
|
|
3087
|
-
enumTypes;
|
|
3088
|
-
static enumNames = [];
|
|
3089
|
-
static rawOpsMap = {};
|
|
3090
|
-
static provider;
|
|
3091
|
-
static previewFeatures;
|
|
3092
|
-
static outputPath = "./generated";
|
|
3093
|
-
hasJson = false;
|
|
3094
|
-
static prismaClientOutputPath = "@prisma/client";
|
|
3095
|
-
static isCustomPrismaClientOutputPath = false;
|
|
3096
|
-
static isGenerateSelect = true;
|
|
3097
|
-
static isGenerateInclude = true;
|
|
3098
|
-
constructor(params) {
|
|
3099
|
-
this.name = params.name ?? "";
|
|
3100
|
-
this.fields = params.fields ?? [];
|
|
3101
|
-
this.models = params.models ?? [];
|
|
3102
|
-
this.modelOperations = params.modelOperations ?? [];
|
|
3103
|
-
this.aggregateOperationSupport = params.aggregateOperationSupport ?? {};
|
|
3104
|
-
this.enumTypes = params.enumTypes ?? [];
|
|
3105
|
-
}
|
|
3106
|
-
static setOutputPath(outPath) {
|
|
3107
|
-
this.outputPath = outPath;
|
|
3108
|
-
}
|
|
3109
|
-
static setIsGenerateSelect(isGenerateSelect) {
|
|
3110
|
-
this.isGenerateSelect = isGenerateSelect;
|
|
3111
|
-
}
|
|
3112
|
-
static setIsGenerateInclude(isGenerateInclude) {
|
|
3113
|
-
this.isGenerateInclude = isGenerateInclude;
|
|
3114
|
-
}
|
|
3115
|
-
static getOutputPath() {
|
|
3116
|
-
return this.outputPath;
|
|
3117
|
-
}
|
|
3118
|
-
static setPrismaClientOutputPath(prismaClientCustomPath) {
|
|
3119
|
-
this.prismaClientOutputPath = prismaClientCustomPath;
|
|
3120
|
-
this.isCustomPrismaClientOutputPath = prismaClientCustomPath !== "@prisma/client";
|
|
3121
|
-
}
|
|
3122
|
-
static async generateIndex() {
|
|
3123
|
-
const indexPath = import_node_path4.default.join(_Transformer.outputPath, "schemas/index.ts");
|
|
3124
|
-
await writeIndexFile(indexPath);
|
|
3125
|
-
}
|
|
3126
|
-
async generateEnumSchemas() {
|
|
3127
|
-
for (const enumType of this.enumTypes) {
|
|
3128
|
-
const { name, values } = enumType;
|
|
3129
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/enums/${lowerCaseFirst(name)}.schema.ts`), `${this.generateImportZodStatement()}
|
|
3130
|
-
${this.generateExportSchemaStatement(`${lowerCaseFirst(name)}`, `z.enum(${JSON.stringify(values)})`)}`);
|
|
3131
|
-
}
|
|
3132
|
-
}
|
|
3133
|
-
generateImportZodStatement() {
|
|
3134
|
-
return "import { z } from 'zod';\n";
|
|
3135
|
-
}
|
|
3136
|
-
generateExportSchemaStatement(name, schema) {
|
|
3137
|
-
return `export const ${lowerCaseFirst(name)}Schema = ${schema}`;
|
|
3138
|
-
}
|
|
3139
|
-
async generateObjectSchema() {
|
|
3140
|
-
const zodObjectSchemaFields = this.generateObjectSchemaFields();
|
|
3141
|
-
const objectSchema = this.prepareObjectSchema(zodObjectSchemaFields);
|
|
3142
|
-
const objectSchemaName = this.resolveObjectSchemaName();
|
|
3143
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/objects/${lowerCaseFirst(objectSchemaName)}.schema.ts`), objectSchema);
|
|
3144
|
-
}
|
|
3145
|
-
generateObjectSchemaFields() {
|
|
3146
|
-
const zodObjectSchemaFields = this.fields.map((field) => this.generateObjectSchemaField(field)).flatMap((item) => item).map((item) => {
|
|
3147
|
-
const [zodStringWithMainType, field, skipValidators] = item;
|
|
3148
|
-
const value = skipValidators ? zodStringWithMainType : this.generateFieldValidators(zodStringWithMainType, field);
|
|
3149
|
-
return value.trim();
|
|
3150
|
-
});
|
|
3151
|
-
return zodObjectSchemaFields;
|
|
3152
|
-
}
|
|
3153
|
-
generateObjectSchemaField(field) {
|
|
3154
|
-
const lines = field.inputTypes;
|
|
3155
|
-
if (lines.length === 0) {
|
|
3156
|
-
return [];
|
|
3157
|
-
}
|
|
3158
|
-
let alternatives = lines.reduce((result, inputType) => {
|
|
3159
|
-
if (inputType.type === "String") {
|
|
3160
|
-
result.push(this.wrapWithZodValidators("z.string()", field));
|
|
3161
|
-
} else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
|
|
3162
|
-
result.push(this.wrapWithZodValidators("z.number()", field));
|
|
3163
|
-
} else if (inputType.type === "BigInt") {
|
|
3164
|
-
result.push(this.wrapWithZodValidators("z.bigint()", field));
|
|
3165
|
-
} else if (inputType.type === "Boolean") {
|
|
3166
|
-
result.push(this.wrapWithZodValidators("z.boolean()", field));
|
|
3167
|
-
} else if (inputType.type === "DateTime") {
|
|
3168
|
-
result.push(this.wrapWithZodValidators("z.coerce.date()", field));
|
|
3169
|
-
} else if (inputType.type === "Json") {
|
|
3170
|
-
this.hasJson = true;
|
|
3171
|
-
result.push(this.wrapWithZodValidators("jsonSchema", field));
|
|
3172
|
-
} else if (inputType.type === "True") {
|
|
3173
|
-
result.push(this.wrapWithZodValidators("z.literal(true)", field));
|
|
3174
|
-
} else if (inputType.type === "Bytes") {
|
|
3175
|
-
result.push(this.wrapWithZodValidators("z.instanceof(Buffer)", field));
|
|
3176
|
-
} else if (!inputType.type.endsWith("FieldRefInput")) {
|
|
3177
|
-
const isEnum = inputType.location === "enumTypes";
|
|
3178
|
-
if (inputType.namespace === "prisma" || isEnum) {
|
|
3179
|
-
if (inputType.type !== this.name && typeof inputType.type === "string") {
|
|
3180
|
-
this.addSchemaImport(inputType.type);
|
|
3181
|
-
}
|
|
3182
|
-
result.push(this.generatePrismaStringLine(field, inputType, lines.length));
|
|
3183
|
-
}
|
|
3184
|
-
}
|
|
3185
|
-
return result;
|
|
3186
|
-
}, []);
|
|
3187
|
-
if (alternatives.length === 0) {
|
|
3188
|
-
return [];
|
|
3189
|
-
}
|
|
3190
|
-
if (alternatives.length > 1) {
|
|
3191
|
-
alternatives = alternatives.map((alter) => alter.replace(".optional()", ""));
|
|
3192
|
-
}
|
|
3193
|
-
const fieldName = alternatives.some((alt) => alt.includes(":")) ? "" : ` ${field.name}:`;
|
|
3194
|
-
const opt = !field.isRequired ? ".optional()" : "";
|
|
3195
|
-
let resString = alternatives.length === 1 ? alternatives.join(",\r\n") : `z.union([${alternatives.join(",\r\n")}])${opt}`;
|
|
3196
|
-
if (field.isNullable) {
|
|
3197
|
-
resString += ".nullable()";
|
|
3198
|
-
}
|
|
3199
|
-
return [
|
|
3200
|
-
[
|
|
3201
|
-
` ${fieldName} ${resString} `,
|
|
3202
|
-
field,
|
|
3203
|
-
true
|
|
3204
|
-
]
|
|
3205
|
-
];
|
|
3206
|
-
}
|
|
3207
|
-
wrapWithZodValidators(mainValidator, field) {
|
|
3208
|
-
let line = "";
|
|
3209
|
-
line = mainValidator;
|
|
3210
|
-
if (field.inputTypes.some((inputType) => inputType.isList)) {
|
|
3211
|
-
line += ".array()";
|
|
3212
|
-
}
|
|
3213
|
-
if (!field.isRequired) {
|
|
3214
|
-
line += ".optional()";
|
|
3215
|
-
}
|
|
3216
|
-
return line;
|
|
3217
|
-
}
|
|
3218
|
-
addSchemaImport(name) {
|
|
3219
|
-
this.schemaImports.add(name);
|
|
3220
|
-
}
|
|
3221
|
-
generatePrismaStringLine(field, inputType, inputsLength) {
|
|
3222
|
-
const isEnum = inputType.location === "enumTypes";
|
|
3223
|
-
const inputTypeString = inputType.type;
|
|
3224
|
-
const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
|
|
3225
|
-
const objectSchemaLine = isModelQueryType ? this.resolveModelQuerySchemaName(modelName, queryName) : `${inputTypeString}ObjectSchema`;
|
|
3226
|
-
const enumSchemaLine = `${inputTypeString}Schema`;
|
|
3227
|
-
const schema = inputType.type === this.name ? objectSchemaLine : isEnum ? enumSchemaLine : objectSchemaLine;
|
|
3228
|
-
const arr = inputType.isList ? ".array()" : "";
|
|
3229
|
-
const opt = !field.isRequired ? ".optional()" : "";
|
|
3230
|
-
return inputsLength === 1 ? ` ${field.name}: z.lazy(() => ${lowerCaseFirst(schema)})${arr}${opt}` : `z.lazy(() => ${lowerCaseFirst(schema)})${arr}${opt}`;
|
|
3231
|
-
}
|
|
3232
|
-
generateFieldValidators(zodStringWithMainType, field) {
|
|
3233
|
-
const { isRequired, isNullable } = field;
|
|
3234
|
-
if (!isRequired) {
|
|
3235
|
-
zodStringWithMainType += ".optional()";
|
|
3236
|
-
}
|
|
3237
|
-
if (isNullable) {
|
|
3238
|
-
zodStringWithMainType += ".nullable()";
|
|
3239
|
-
}
|
|
3240
|
-
return zodStringWithMainType;
|
|
3241
|
-
}
|
|
3242
|
-
prepareObjectSchema(zodObjectSchemaFields) {
|
|
3243
|
-
const objectSchema = `${this.generateExportObjectSchemaStatement(this.addFinalWrappers({
|
|
3244
|
-
zodStringFields: zodObjectSchemaFields
|
|
3245
|
-
}))}
|
|
3246
|
-
`;
|
|
3247
|
-
const prismaImportStatement = this.generateImportPrismaStatement();
|
|
3248
|
-
const json = this.generateJsonSchemaImplementation();
|
|
3249
|
-
return `${this.generateObjectSchemaImportStatements()}${prismaImportStatement}${json}${objectSchema}`;
|
|
3250
|
-
}
|
|
3251
|
-
generateExportObjectSchemaStatement(schema) {
|
|
3252
|
-
let name = this.name;
|
|
3253
|
-
let exportName = this.name;
|
|
3254
|
-
if (_Transformer.provider === "mongodb") {
|
|
3255
|
-
if (isMongodbRawOp(name)) {
|
|
3256
|
-
name = _Transformer.rawOpsMap[name];
|
|
3257
|
-
exportName = name.replace("Args", "");
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
if (isAggregateInputType(name)) {
|
|
3261
|
-
name = `${name}Type`;
|
|
3262
|
-
}
|
|
3263
|
-
const end = `export const ${lowerCaseFirst(exportName)}ObjectSchema = schema`;
|
|
3264
|
-
return `const schema: z.ZodType<Prisma.${name}> = ${schema};
|
|
3265
|
-
|
|
3266
|
-
${end}`;
|
|
3267
|
-
}
|
|
3268
|
-
addFinalWrappers({ zodStringFields }) {
|
|
3269
|
-
const fields = [
|
|
3270
|
-
...zodStringFields
|
|
3271
|
-
];
|
|
3272
|
-
return `${this.wrapWithZodObject(fields)}.strict()`;
|
|
3273
|
-
}
|
|
3274
|
-
generateImportPrismaStatement() {
|
|
3275
|
-
let prismaClientImportPath;
|
|
3276
|
-
if (_Transformer.isCustomPrismaClientOutputPath) {
|
|
3277
|
-
const fromPath = import_node_path4.default.join(_Transformer.outputPath, "schemas", "objects");
|
|
3278
|
-
const toPath = _Transformer.prismaClientOutputPath;
|
|
3279
|
-
const relativePathFromOutputToPrismaClient = import_node_path4.default.relative(fromPath, toPath).split(import_node_path4.default.sep).join(import_node_path4.default.posix.sep);
|
|
3280
|
-
prismaClientImportPath = relativePathFromOutputToPrismaClient;
|
|
3281
|
-
} else {
|
|
3282
|
-
prismaClientImportPath = _Transformer.prismaClientOutputPath;
|
|
3283
|
-
}
|
|
3284
|
-
return `import type { Prisma } from '${prismaClientImportPath}';
|
|
3285
|
-
|
|
3286
|
-
`;
|
|
3287
|
-
}
|
|
3288
|
-
generateJsonSchemaImplementation() {
|
|
3289
|
-
let jsonSchemaImplementation = "";
|
|
3290
|
-
if (this.hasJson) {
|
|
3291
|
-
jsonSchemaImplementation += `
|
|
3292
|
-
`;
|
|
3293
|
-
jsonSchemaImplementation += `const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
3294
|
-
`;
|
|
3295
|
-
jsonSchemaImplementation += `const jsonSchema: z.ZodType<Prisma.InputJsonValue> = z.lazy(() =>
|
|
3296
|
-
`;
|
|
3297
|
-
jsonSchemaImplementation += ` z.union([literalSchema, z.array(jsonSchema.nullable()), z.record(jsonSchema.nullable())])
|
|
3298
|
-
`;
|
|
3299
|
-
jsonSchemaImplementation += `);
|
|
3300
|
-
|
|
3301
|
-
`;
|
|
3302
|
-
}
|
|
3303
|
-
return jsonSchemaImplementation;
|
|
3304
|
-
}
|
|
3305
|
-
generateObjectSchemaImportStatements() {
|
|
3306
|
-
let generatedImports = this.generateImportZodStatement();
|
|
3307
|
-
generatedImports += this.generateSchemaImports();
|
|
3308
|
-
generatedImports += "\n\n";
|
|
3309
|
-
return generatedImports;
|
|
3310
|
-
}
|
|
3311
|
-
generateSchemaImports() {
|
|
3312
|
-
return [
|
|
3313
|
-
...this.schemaImports
|
|
3314
|
-
].map((name) => {
|
|
3315
|
-
const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(name);
|
|
3316
|
-
if (isModelQueryType) {
|
|
3317
|
-
return `import { ${this.resolveModelQuerySchemaName(modelName, queryName)} } from '../${queryName}${modelName}.schema'`;
|
|
3318
|
-
} else if (_Transformer.enumNames.includes(name)) {
|
|
3319
|
-
return `import { ${lowerCaseFirst(name)}Schema } from '../enums/${lowerCaseFirst(name)}.schema'`;
|
|
3320
|
-
} else {
|
|
3321
|
-
return `import { ${lowerCaseFirst(name)}ObjectSchema } from './${lowerCaseFirst(name)}.schema'`;
|
|
3322
|
-
}
|
|
3323
|
-
}).join(";\r\n");
|
|
3324
|
-
}
|
|
3325
|
-
checkIsModelQueryType(type) {
|
|
3326
|
-
const modelQueryTypeSuffixToQueryName = {
|
|
3327
|
-
FindManyArgs: "findMany"
|
|
3328
|
-
};
|
|
3329
|
-
for (const modelQueryType of [
|
|
3330
|
-
"FindManyArgs"
|
|
3331
|
-
]) {
|
|
3332
|
-
if (type.includes(modelQueryType)) {
|
|
3333
|
-
const modelQueryTypeSuffixIndex = type.indexOf(modelQueryType);
|
|
3334
|
-
return {
|
|
3335
|
-
isModelQueryType: true,
|
|
3336
|
-
modelName: type.substring(0, modelQueryTypeSuffixIndex),
|
|
3337
|
-
queryName: modelQueryTypeSuffixToQueryName[modelQueryType]
|
|
3338
|
-
};
|
|
3339
|
-
}
|
|
3340
|
-
}
|
|
3341
|
-
return {
|
|
3342
|
-
isModelQueryType: false
|
|
3343
|
-
};
|
|
3344
|
-
}
|
|
3345
|
-
resolveModelQuerySchemaName(modelName, queryName) {
|
|
3346
|
-
const modelNameUncapitalized = lowerCaseFirst(modelName);
|
|
3347
|
-
const queryNameCapitalized = upperCaseFirst(queryName);
|
|
3348
|
-
return `${modelNameUncapitalized}${queryNameCapitalized}Schema`;
|
|
3349
|
-
}
|
|
3350
|
-
wrapWithZodUnion(zodStringFields) {
|
|
3351
|
-
let wrapped = "";
|
|
3352
|
-
wrapped += "z.union([";
|
|
3353
|
-
wrapped += "\n";
|
|
3354
|
-
wrapped += ` ${zodStringFields.join(",")}`;
|
|
3355
|
-
wrapped += "\n";
|
|
3356
|
-
wrapped += "])";
|
|
3357
|
-
return wrapped;
|
|
3358
|
-
}
|
|
3359
|
-
wrapWithZodObject(zodStringFields) {
|
|
3360
|
-
let wrapped = "";
|
|
3361
|
-
wrapped += "z.object({";
|
|
3362
|
-
wrapped += "\n";
|
|
3363
|
-
wrapped += ` ${typeof zodStringFields === "string" ? zodStringFields : zodStringFields.join(",\n ")}`;
|
|
3364
|
-
wrapped += "\n";
|
|
3365
|
-
wrapped += "})";
|
|
3366
|
-
return wrapped;
|
|
3367
|
-
}
|
|
3368
|
-
resolveObjectSchemaName() {
|
|
3369
|
-
let name = this.name;
|
|
3370
|
-
let exportName = this.name;
|
|
3371
|
-
if (isMongodbRawOp(name)) {
|
|
3372
|
-
name = _Transformer.rawOpsMap[name];
|
|
3373
|
-
exportName = name.replace("Args", "");
|
|
3374
|
-
}
|
|
3375
|
-
return lowerCaseFirst(exportName);
|
|
3376
|
-
}
|
|
3377
|
-
async generateModelSchemas() {
|
|
3378
|
-
for (const modelOperation of this.modelOperations) {
|
|
3379
|
-
const {
|
|
3380
|
-
findUnique,
|
|
3381
|
-
findFirst,
|
|
3382
|
-
findMany,
|
|
3383
|
-
// @ts-ignore
|
|
3384
|
-
createOne,
|
|
3385
|
-
createMany,
|
|
3386
|
-
createManyAndReturn,
|
|
3387
|
-
// @ts-ignore
|
|
3388
|
-
deleteOne,
|
|
3389
|
-
// @ts-ignore
|
|
3390
|
-
updateOne,
|
|
3391
|
-
deleteMany,
|
|
3392
|
-
updateMany,
|
|
3393
|
-
updateManyAndReturn,
|
|
3394
|
-
// @ts-ignore
|
|
3395
|
-
upsertOne,
|
|
3396
|
-
aggregate,
|
|
3397
|
-
groupBy
|
|
3398
|
-
} = modelOperation;
|
|
3399
|
-
const model = findModelByName(this.models, modelOperation.model);
|
|
3400
|
-
const modelName = lowerCaseFirst(modelOperation.model);
|
|
3401
|
-
const { selectImport, includeImport, selectZodSchemaLine, includeZodSchemaLine, selectZodSchemaLineLazy, includeZodSchemaLineLazy } = this.resolveSelectIncludeImportAndZodSchemaLine(model);
|
|
3402
|
-
const { orderByImport, orderByZodSchemaLine } = this.resolveOrderByWithRelationImportAndZodSchemaLine(model);
|
|
3403
|
-
if (findUnique) {
|
|
3404
|
-
const imports = [
|
|
3405
|
-
selectImport,
|
|
3406
|
-
includeImport,
|
|
3407
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
3408
|
-
];
|
|
3409
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${findUnique}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindUnique`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
|
|
3410
|
-
}
|
|
3411
|
-
if (findFirst) {
|
|
3412
|
-
const imports = [
|
|
3413
|
-
selectImport,
|
|
3414
|
-
includeImport,
|
|
3415
|
-
orderByImport,
|
|
3416
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
|
|
3417
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
3418
|
-
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
3419
|
-
];
|
|
3420
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${findFirst}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindFirst`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${modelName}ScalarFieldEnumSchema).optional() })`)}`);
|
|
3421
|
-
}
|
|
3422
|
-
if (findMany) {
|
|
3423
|
-
const imports = [
|
|
3424
|
-
selectImport,
|
|
3425
|
-
includeImport,
|
|
3426
|
-
orderByImport,
|
|
3427
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
|
|
3428
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
3429
|
-
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
3430
|
-
];
|
|
3431
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${findMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}FindMany`, `z.object({ ${selectZodSchemaLineLazy} ${includeZodSchemaLineLazy} ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${modelName}ScalarFieldEnumSchema).optional() })`)}`);
|
|
3432
|
-
}
|
|
3433
|
-
if (createOne) {
|
|
3434
|
-
const imports = [
|
|
3435
|
-
selectImport,
|
|
3436
|
-
includeImport,
|
|
3437
|
-
`import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
|
|
3438
|
-
`import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`
|
|
3439
|
-
];
|
|
3440
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${createOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} data: z.union([${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema]) })`)}`);
|
|
3441
|
-
}
|
|
3442
|
-
if (createMany) {
|
|
3443
|
-
const imports = [
|
|
3444
|
-
`import { ${modelName}CreateManyInputObjectSchema } from './objects/${modelName}CreateManyInput.schema'`
|
|
3445
|
-
];
|
|
3446
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${createMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateMany`, `z.object({ data: z.union([ ${modelName}CreateManyInputObjectSchema, z.array(${modelName}CreateManyInputObjectSchema) ]), ${_Transformer.provider === "mongodb" || _Transformer.provider === "sqlserver" ? "" : "skipDuplicates: z.boolean().optional()"} })`)}`);
|
|
3447
|
-
}
|
|
3448
|
-
if (createManyAndReturn) {
|
|
3449
|
-
const imports = [
|
|
3450
|
-
`import { ${modelName}CreateManyAndReturnInputObjectSchema } from './objects/${modelName}CreateManyAndReturnInput.schema'`
|
|
3451
|
-
];
|
|
3452
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${createManyAndReturn}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}CreateManyAndReturn`, `z.object({ data: z.union([ ${modelName}CreateManyAndReturnInputObjectSchema, z.array(${modelName}CreateManyAndReturnInputObjectSchema) ]), ${_Transformer.provider === "mongodb" || _Transformer.provider === "sqlserver" ? "" : "skipDuplicates: z.boolean().optional()"} })`)}`);
|
|
3453
|
-
}
|
|
3454
|
-
if (deleteOne) {
|
|
3455
|
-
const imports = [
|
|
3456
|
-
selectImport,
|
|
3457
|
-
includeImport,
|
|
3458
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
3459
|
-
];
|
|
3460
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${deleteOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
|
|
3461
|
-
}
|
|
3462
|
-
if (deleteMany) {
|
|
3463
|
-
const imports = [
|
|
3464
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
|
|
3465
|
-
];
|
|
3466
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${deleteMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}DeleteMany`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
|
|
3467
|
-
}
|
|
3468
|
-
if (updateOne) {
|
|
3469
|
-
const imports = [
|
|
3470
|
-
selectImport,
|
|
3471
|
-
includeImport,
|
|
3472
|
-
`import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
|
|
3473
|
-
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`,
|
|
3474
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
3475
|
-
];
|
|
3476
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${updateOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateOne`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} data: z.union([${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema]), where: ${modelName}WhereUniqueInputObjectSchema })`)}`);
|
|
3477
|
-
}
|
|
3478
|
-
if (updateMany) {
|
|
3479
|
-
const imports = [
|
|
3480
|
-
`import { ${modelName}UpdateManyMutationInputObjectSchema } from './objects/${modelName}UpdateManyMutationInput.schema'`,
|
|
3481
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`
|
|
3482
|
-
];
|
|
3483
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${updateMany}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateMany`, `z.object({ data: ${modelName}UpdateManyMutationInputObjectSchema, where: ${modelName}WhereInputObjectSchema.optional() })`)}`);
|
|
3484
|
-
}
|
|
3485
|
-
if (updateManyAndReturn) {
|
|
3486
|
-
const imports = [
|
|
3487
|
-
`import { ${modelName}UpdateManyAndReturnInputObjectSchema } from './objects/${modelName}UpdateManyAndReturnInput.schema'`
|
|
3488
|
-
];
|
|
3489
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${updateManyAndReturn}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}UpdateManyAndReturn`, `z.object({ data: z.union([ ${modelName}UpdateManyAndReturnInputObjectSchema, z.array(${modelName}UpdateManyAndReturnInputObjectSchema) ]), ${_Transformer.provider === "mongodb" || _Transformer.provider === "sqlserver" ? "" : "skipDuplicates: z.boolean().optional()"} })`)}`);
|
|
3490
|
-
}
|
|
3491
|
-
if (upsertOne) {
|
|
3492
|
-
const imports = [
|
|
3493
|
-
selectImport,
|
|
3494
|
-
includeImport,
|
|
3495
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
|
|
3496
|
-
`import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
|
|
3497
|
-
`import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`,
|
|
3498
|
-
`import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
|
|
3499
|
-
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`
|
|
3500
|
-
];
|
|
3501
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${upsertOne}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}Upsert`, `z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema, create: z.union([ ${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema ]), update: z.union([ ${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema ]) })`)}`);
|
|
3502
|
-
}
|
|
3503
|
-
if (aggregate) {
|
|
3504
|
-
const imports = [
|
|
3505
|
-
orderByImport,
|
|
3506
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
|
|
3507
|
-
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`
|
|
3508
|
-
];
|
|
3509
|
-
const aggregateOperations = [];
|
|
3510
|
-
if (this.aggregateOperationSupport[modelName]) {
|
|
3511
|
-
if (this.aggregateOperationSupport[modelName].count) {
|
|
3512
|
-
imports.push(`import { ${modelName}CountAggregateInputObjectSchema } from './objects/${modelName}CountAggregateInput.schema'`);
|
|
3513
|
-
aggregateOperations.push(`_count: z.union([ z.literal(true), ${modelName}CountAggregateInputObjectSchema ]).optional()`);
|
|
3514
|
-
}
|
|
3515
|
-
if (this.aggregateOperationSupport[modelName].min) {
|
|
3516
|
-
imports.push(`import { ${modelName}MinAggregateInputObjectSchema } from './objects/${modelName}MinAggregateInput.schema'`);
|
|
3517
|
-
aggregateOperations.push(`_min: ${modelName}MinAggregateInputObjectSchema.optional()`);
|
|
3518
|
-
}
|
|
3519
|
-
if (this.aggregateOperationSupport[modelName].max) {
|
|
3520
|
-
imports.push(`import { ${modelName}MaxAggregateInputObjectSchema } from './objects/${modelName}MaxAggregateInput.schema'`);
|
|
3521
|
-
aggregateOperations.push(`_max: ${modelName}MaxAggregateInputObjectSchema.optional()`);
|
|
3522
|
-
}
|
|
3523
|
-
if (this.aggregateOperationSupport[modelName].avg) {
|
|
3524
|
-
imports.push(`import { ${modelName}AvgAggregateInputObjectSchema } from './objects/${modelName}AvgAggregateInput.schema'`);
|
|
3525
|
-
aggregateOperations.push(`_avg: ${modelName}AvgAggregateInputObjectSchema.optional()`);
|
|
3526
|
-
}
|
|
3527
|
-
if (this.aggregateOperationSupport[modelName].sum) {
|
|
3528
|
-
imports.push(`import { ${modelName}SumAggregateInputObjectSchema } from './objects/${modelName}SumAggregateInput.schema'`);
|
|
3529
|
-
aggregateOperations.push(`_sum: ${modelName}SumAggregateInputObjectSchema.optional()`);
|
|
3530
|
-
}
|
|
3531
|
-
}
|
|
3532
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${aggregate}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}Aggregate`, `z.object({ ${orderByZodSchemaLine} where: ${modelName}WhereInputObjectSchema.optional(), cursor: ${modelName}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), ${aggregateOperations.join(", ")} })`)}`);
|
|
3533
|
-
}
|
|
3534
|
-
if (groupBy) {
|
|
3535
|
-
const imports = [
|
|
3536
|
-
`import { ${modelName}WhereInputObjectSchema } from './objects/${modelName}WhereInput.schema'`,
|
|
3537
|
-
`import { ${modelName}OrderByWithAggregationInputObjectSchema } from './objects/${modelName}OrderByWithAggregationInput.schema'`,
|
|
3538
|
-
`import { ${modelName}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${modelName}ScalarWhereWithAggregatesInput.schema'`,
|
|
3539
|
-
`import { ${modelName}ScalarFieldEnumSchema } from './enums/${modelName}ScalarFieldEnum.schema'`
|
|
3540
|
-
];
|
|
3541
|
-
await writeFileSafely(import_node_path4.default.join(_Transformer.outputPath, `schemas/${groupBy}.schema.ts`), `${this.generateImportStatements(imports)}${this.generateExportSchemaStatement(`${modelName}GroupBy`, `z.object({ where: ${modelName}WhereInputObjectSchema.optional(), orderBy: z.union([${modelName}OrderByWithAggregationInputObjectSchema, ${modelName}OrderByWithAggregationInputObjectSchema.array()]).optional(), having: ${modelName}ScalarWhereWithAggregatesInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), by: z.array(${modelName}ScalarFieldEnumSchema) })`)}`);
|
|
3542
|
-
}
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
|
-
generateImportStatements(imports) {
|
|
3546
|
-
let generatedImports = this.generateImportZodStatement();
|
|
3547
|
-
generatedImports += imports?.filter((importItem) => !!importItem).join(";\r\n") ?? "";
|
|
3548
|
-
generatedImports += "\n\n";
|
|
3549
|
-
return generatedImports;
|
|
3550
|
-
}
|
|
3551
|
-
resolveSelectIncludeImportAndZodSchemaLine(model) {
|
|
3552
|
-
const { name: modelName } = model;
|
|
3553
|
-
const hasRelationToAnotherModel = checkModelHasModelRelation(model);
|
|
3554
|
-
const selectImport = _Transformer.isGenerateSelect ? `import { ${lowerCaseFirst(modelName)}SelectObjectSchema } from './objects/${lowerCaseFirst(modelName)}Select.schema'` : "";
|
|
3555
|
-
const includeImport = _Transformer.isGenerateInclude && hasRelationToAnotherModel ? `import { ${lowerCaseFirst(modelName)}IncludeObjectSchema } from './objects/${lowerCaseFirst(modelName)}Include.schema'` : "";
|
|
3556
|
-
let selectZodSchemaLine = "";
|
|
3557
|
-
let includeZodSchemaLine = "";
|
|
3558
|
-
let selectZodSchemaLineLazy = "";
|
|
3559
|
-
let includeZodSchemaLineLazy = "";
|
|
3560
|
-
if (_Transformer.isGenerateSelect) {
|
|
3561
|
-
const zodSelectObjectSchema = `${lowerCaseFirst(modelName)}SelectObjectSchema.optional()`;
|
|
3562
|
-
selectZodSchemaLine = `select: ${zodSelectObjectSchema},`;
|
|
3563
|
-
selectZodSchemaLineLazy = `select: z.lazy(() => ${zodSelectObjectSchema}),`;
|
|
3564
|
-
}
|
|
3565
|
-
if (_Transformer.isGenerateInclude && hasRelationToAnotherModel) {
|
|
3566
|
-
const zodIncludeObjectSchema = `${lowerCaseFirst(modelName)}IncludeObjectSchema.optional()`;
|
|
3567
|
-
includeZodSchemaLine = `include: ${zodIncludeObjectSchema},`;
|
|
3568
|
-
includeZodSchemaLineLazy = `include: z.lazy(() => ${zodIncludeObjectSchema}),`;
|
|
3569
|
-
}
|
|
3570
|
-
return {
|
|
3571
|
-
selectImport,
|
|
3572
|
-
includeImport,
|
|
3573
|
-
selectZodSchemaLine,
|
|
3574
|
-
includeZodSchemaLine,
|
|
3575
|
-
selectZodSchemaLineLazy,
|
|
3576
|
-
includeZodSchemaLineLazy
|
|
3577
|
-
};
|
|
3578
|
-
}
|
|
3579
|
-
resolveOrderByWithRelationImportAndZodSchemaLine(model) {
|
|
3580
|
-
const { name: modelName } = model;
|
|
3581
|
-
let modelOrderBy = "";
|
|
3582
|
-
if ([
|
|
3583
|
-
"postgresql",
|
|
3584
|
-
"mysql"
|
|
3585
|
-
].includes(_Transformer.provider) && _Transformer.previewFeatures?.includes("fullTextSearch")) {
|
|
3586
|
-
modelOrderBy = `${lowerCaseFirst(modelName)}OrderByWithRelationAndSearchRelevanceInput`;
|
|
3587
|
-
} else {
|
|
3588
|
-
modelOrderBy = `${lowerCaseFirst(modelName)}OrderByWithRelationInput`;
|
|
3589
|
-
}
|
|
3590
|
-
const orderByImport = `import { ${modelOrderBy}ObjectSchema } from './objects/${modelOrderBy}.schema'`;
|
|
3591
|
-
const orderByZodSchemaLine = `orderBy: z.union([${modelOrderBy}ObjectSchema, ${modelOrderBy}ObjectSchema.array()]).optional(),`;
|
|
3592
|
-
return {
|
|
3593
|
-
orderByImport,
|
|
3594
|
-
orderByZodSchemaLine
|
|
3595
|
-
};
|
|
3596
|
-
}
|
|
3597
|
-
};
|
|
3598
|
-
|
|
3599
|
-
// src/zod/generator-helpers.ts
|
|
3600
|
-
async function generateZodEnumSchemas(prismaSchemaEnum, modelSchemaEnum) {
|
|
3601
|
-
const enumTypes = [
|
|
3602
|
-
...prismaSchemaEnum,
|
|
3603
|
-
...modelSchemaEnum
|
|
3604
|
-
];
|
|
3605
|
-
const enumNames = enumTypes.map((enumItem) => enumItem.name);
|
|
3606
|
-
Transformer.enumNames = enumNames ?? [];
|
|
3607
|
-
const transformer = new Transformer({
|
|
3608
|
-
enumTypes
|
|
3609
|
-
});
|
|
3610
|
-
await transformer.generateEnumSchemas();
|
|
3611
|
-
}
|
|
3612
|
-
__name(generateZodEnumSchemas, "generateZodEnumSchemas");
|
|
3613
|
-
async function generateZodObjectSchemas(inputObjectTypes) {
|
|
3614
|
-
for (let i = 0; i < inputObjectTypes.length; i += 1) {
|
|
3615
|
-
const fields = inputObjectTypes[i]?.fields;
|
|
3616
|
-
const name = inputObjectTypes[i]?.name;
|
|
3617
|
-
const transformer = new Transformer({
|
|
3618
|
-
name,
|
|
3619
|
-
fields
|
|
3620
|
-
});
|
|
3621
|
-
await transformer.generateObjectSchema();
|
|
3622
|
-
}
|
|
3623
|
-
}
|
|
3624
|
-
__name(generateZodObjectSchemas, "generateZodObjectSchemas");
|
|
3625
|
-
async function generateZodModelSchemas(models, modelOperations, aggregateOperationSupport) {
|
|
3626
|
-
const transformer = new Transformer({
|
|
3627
|
-
models,
|
|
3628
|
-
modelOperations,
|
|
3629
|
-
aggregateOperationSupport
|
|
3630
|
-
});
|
|
3631
|
-
await transformer.generateModelSchemas();
|
|
3632
|
-
}
|
|
3633
|
-
__name(generateZodModelSchemas, "generateZodModelSchemas");
|
|
3634
|
-
async function generateZodIndex() {
|
|
3635
|
-
await Transformer.generateIndex();
|
|
3636
|
-
}
|
|
3637
|
-
__name(generateZodIndex, "generateZodIndex");
|
|
3638
|
-
|
|
3639
|
-
// src/zod/helpers.ts
|
|
3640
|
-
init_cjs_shims();
|
|
3641
|
-
|
|
3642
|
-
// src/zod/include-helpers.ts
|
|
3643
|
-
init_cjs_shims();
|
|
3644
|
-
function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
|
|
3645
|
-
const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
|
|
3646
|
-
for (const includeInputObjectType of generatedIncludeInputObjectTypes) {
|
|
3647
|
-
inputObjectTypes.push(includeInputObjectType);
|
|
3648
|
-
}
|
|
3649
|
-
}
|
|
3650
|
-
__name(addMissingInputObjectTypesForInclude, "addMissingInputObjectTypesForInclude");
|
|
3651
|
-
function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
|
|
3652
|
-
const modelIncludeInputObjectTypes = [];
|
|
3653
|
-
for (const model of models) {
|
|
3654
|
-
const { name: modelName, fields: modelFields } = model;
|
|
3655
|
-
const fields = [];
|
|
3656
|
-
for (const modelField of modelFields) {
|
|
3657
|
-
const { name: modelFieldName, isList, type } = modelField;
|
|
3658
|
-
const isRelationField = checkIsModelRelationField(modelField);
|
|
3659
|
-
if (isRelationField) {
|
|
3660
|
-
const field = {
|
|
3661
|
-
name: modelFieldName,
|
|
3662
|
-
isRequired: false,
|
|
3663
|
-
isNullable: false,
|
|
3664
|
-
inputTypes: [
|
|
3665
|
-
{
|
|
3666
|
-
isList: false,
|
|
3667
|
-
type: "Boolean",
|
|
3668
|
-
location: "scalar"
|
|
3669
|
-
},
|
|
3670
|
-
{
|
|
3671
|
-
isList: false,
|
|
3672
|
-
type: isList ? `${type}FindManyArgs` : `${type}DefaultArgs`,
|
|
3673
|
-
location: "inputObjectTypes",
|
|
3674
|
-
namespace: "prisma"
|
|
3675
|
-
}
|
|
3676
|
-
]
|
|
3677
|
-
};
|
|
3678
|
-
fields.push(field);
|
|
3679
|
-
}
|
|
3680
|
-
}
|
|
3681
|
-
const hasRelationToAnotherModel = checkModelHasModelRelation(model);
|
|
3682
|
-
if (!hasRelationToAnotherModel) {
|
|
3683
|
-
continue;
|
|
3684
|
-
}
|
|
3685
|
-
const hasManyRelationToAnotherModel = checkModelHasManyModelRelation(model);
|
|
3686
|
-
const shouldAddCountField = hasManyRelationToAnotherModel;
|
|
3687
|
-
if (shouldAddCountField) {
|
|
3688
|
-
const inputTypes = [
|
|
3689
|
-
{
|
|
3690
|
-
isList: false,
|
|
3691
|
-
type: "Boolean",
|
|
3692
|
-
location: "scalar"
|
|
3693
|
-
}
|
|
3694
|
-
];
|
|
3695
|
-
if (isGenerateSelect) {
|
|
3696
|
-
inputTypes.push({
|
|
3697
|
-
isList: false,
|
|
3698
|
-
type: `${modelName}CountOutputTypeDefaultArgs`,
|
|
3699
|
-
location: "inputObjectTypes",
|
|
3700
|
-
namespace: "prisma"
|
|
3701
|
-
});
|
|
3702
|
-
}
|
|
3703
|
-
const _countField = {
|
|
3704
|
-
name: "_count",
|
|
3705
|
-
isRequired: false,
|
|
3706
|
-
isNullable: false,
|
|
3707
|
-
inputTypes
|
|
3708
|
-
};
|
|
3709
|
-
fields.push(_countField);
|
|
3710
|
-
}
|
|
3711
|
-
const modelIncludeInputObjectType = {
|
|
3712
|
-
name: `${modelName}Include`,
|
|
3713
|
-
constraints: {
|
|
3714
|
-
maxNumFields: null,
|
|
3715
|
-
minNumFields: null
|
|
3716
|
-
},
|
|
3717
|
-
fields
|
|
3718
|
-
};
|
|
3719
|
-
modelIncludeInputObjectTypes.push(modelIncludeInputObjectType);
|
|
3720
|
-
}
|
|
3721
|
-
return modelIncludeInputObjectTypes;
|
|
3722
|
-
}
|
|
3723
|
-
__name(generateModelIncludeInputObjectTypes, "generateModelIncludeInputObjectTypes");
|
|
3724
|
-
|
|
3725
|
-
// src/zod/modelArgs-helpers.ts
|
|
3726
|
-
init_cjs_shims();
|
|
3727
|
-
function addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, isGenerateSelect, isGenerateInclude) {
|
|
3728
|
-
const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude);
|
|
3729
|
-
for (const modelArgsInputObjectType of modelArgsInputObjectTypes) {
|
|
3730
|
-
inputObjectTypes.push(modelArgsInputObjectType);
|
|
3731
|
-
}
|
|
3732
|
-
}
|
|
3733
|
-
__name(addMissingInputObjectTypesForModelArgs, "addMissingInputObjectTypesForModelArgs");
|
|
3734
|
-
function generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude) {
|
|
3735
|
-
const modelArgsInputObjectTypes = [];
|
|
3736
|
-
for (const model of models) {
|
|
3737
|
-
const { name: modelName } = model;
|
|
3738
|
-
const fields = [];
|
|
3739
|
-
if (isGenerateSelect) {
|
|
3740
|
-
const selectField = {
|
|
3741
|
-
name: "select",
|
|
3742
|
-
isRequired: false,
|
|
3743
|
-
isNullable: false,
|
|
3744
|
-
inputTypes: [
|
|
3745
|
-
{
|
|
3746
|
-
isList: false,
|
|
3747
|
-
type: `${modelName}Select`,
|
|
3748
|
-
location: "inputObjectTypes",
|
|
3749
|
-
namespace: "prisma"
|
|
3750
|
-
}
|
|
3751
|
-
]
|
|
3752
|
-
};
|
|
3753
|
-
fields.push(selectField);
|
|
3754
|
-
}
|
|
3755
|
-
const hasRelationToAnotherModel = checkModelHasModelRelation(model);
|
|
3756
|
-
if (isGenerateInclude && hasRelationToAnotherModel) {
|
|
3757
|
-
const includeField = {
|
|
3758
|
-
name: "include",
|
|
3759
|
-
isRequired: false,
|
|
3760
|
-
isNullable: false,
|
|
3761
|
-
inputTypes: [
|
|
3762
|
-
{
|
|
3763
|
-
isList: false,
|
|
3764
|
-
type: `${modelName}Include`,
|
|
3765
|
-
location: "inputObjectTypes",
|
|
3766
|
-
namespace: "prisma"
|
|
3767
|
-
}
|
|
3768
|
-
]
|
|
3769
|
-
};
|
|
3770
|
-
fields.push(includeField);
|
|
3771
|
-
}
|
|
3772
|
-
const modelArgsInputObjectType = {
|
|
3773
|
-
name: `${modelName}DefaultArgs`,
|
|
3774
|
-
constraints: {
|
|
3775
|
-
maxNumFields: null,
|
|
3776
|
-
minNumFields: null
|
|
3777
|
-
},
|
|
3778
|
-
fields
|
|
3779
|
-
};
|
|
3780
|
-
modelArgsInputObjectTypes.push(modelArgsInputObjectType);
|
|
3781
|
-
}
|
|
3782
|
-
return modelArgsInputObjectTypes;
|
|
3783
|
-
}
|
|
3784
|
-
__name(generateModelArgsInputObjectTypes, "generateModelArgsInputObjectTypes");
|
|
3785
|
-
|
|
3786
|
-
// src/zod/select-helpers.ts
|
|
3787
|
-
init_cjs_shims();
|
|
3788
|
-
function addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models) {
|
|
3789
|
-
const modelCountOutputTypes = getModelCountOutputTypes(outputObjectTypes);
|
|
3790
|
-
const modelCountOutputTypeSelectInputObjectTypes = generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes);
|
|
3791
|
-
const modelCountOutputTypeArgsInputObjectTypes = generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes);
|
|
3792
|
-
const modelSelectInputObjectTypes = generateModelSelectInputObjectTypes(models);
|
|
3793
|
-
const generatedInputObjectTypes = [
|
|
3794
|
-
modelCountOutputTypeSelectInputObjectTypes,
|
|
3795
|
-
modelCountOutputTypeArgsInputObjectTypes,
|
|
3796
|
-
modelSelectInputObjectTypes
|
|
3797
|
-
].flat();
|
|
3798
|
-
for (const inputObjectType of generatedInputObjectTypes) {
|
|
3799
|
-
inputObjectTypes.push(inputObjectType);
|
|
3800
|
-
}
|
|
3801
|
-
}
|
|
3802
|
-
__name(addMissingInputObjectTypesForSelect, "addMissingInputObjectTypesForSelect");
|
|
3803
|
-
function getModelCountOutputTypes(outputObjectTypes) {
|
|
3804
|
-
return outputObjectTypes.filter(({ name }) => name.includes("CountOutputType"));
|
|
3805
|
-
}
|
|
3806
|
-
__name(getModelCountOutputTypes, "getModelCountOutputTypes");
|
|
3807
|
-
function generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes) {
|
|
3808
|
-
const modelCountOutputTypeSelectInputObjectTypes = [];
|
|
3809
|
-
for (const modelCountOutputType of modelCountOutputTypes) {
|
|
3810
|
-
const { name: modelCountOutputTypeName, fields: modelCountOutputTypeFields } = modelCountOutputType;
|
|
3811
|
-
const modelCountOutputTypeSelectInputObjectType = {
|
|
3812
|
-
name: `${modelCountOutputTypeName}Select`,
|
|
3813
|
-
constraints: {
|
|
3814
|
-
maxNumFields: null,
|
|
3815
|
-
minNumFields: null
|
|
3816
|
-
},
|
|
3817
|
-
fields: modelCountOutputTypeFields.map(({ name }) => ({
|
|
3818
|
-
name,
|
|
3819
|
-
isRequired: false,
|
|
3820
|
-
isNullable: false,
|
|
3821
|
-
inputTypes: [
|
|
3822
|
-
{
|
|
3823
|
-
isList: false,
|
|
3824
|
-
type: `Boolean`,
|
|
3825
|
-
location: "scalar"
|
|
3826
|
-
}
|
|
3827
|
-
]
|
|
3828
|
-
}))
|
|
3829
|
-
};
|
|
3830
|
-
modelCountOutputTypeSelectInputObjectTypes.push(modelCountOutputTypeSelectInputObjectType);
|
|
3831
|
-
}
|
|
3832
|
-
return modelCountOutputTypeSelectInputObjectTypes;
|
|
3833
|
-
}
|
|
3834
|
-
__name(generateModelCountOutputTypeSelectInputObjectTypes, "generateModelCountOutputTypeSelectInputObjectTypes");
|
|
3835
|
-
function generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes) {
|
|
3836
|
-
const modelCountOutputTypeArgsInputObjectTypes = [];
|
|
3837
|
-
for (const modelCountOutputType of modelCountOutputTypes) {
|
|
3838
|
-
const { name: modelCountOutputTypeName } = modelCountOutputType;
|
|
3839
|
-
const modelCountOutputTypeArgsInputObjectType = {
|
|
3840
|
-
name: `${modelCountOutputTypeName}DefaultArgs`,
|
|
3841
|
-
constraints: {
|
|
3842
|
-
maxNumFields: null,
|
|
3843
|
-
minNumFields: null
|
|
3844
|
-
},
|
|
3845
|
-
fields: [
|
|
3846
|
-
{
|
|
3847
|
-
name: "select",
|
|
3848
|
-
isRequired: false,
|
|
3849
|
-
isNullable: false,
|
|
3850
|
-
inputTypes: [
|
|
3851
|
-
{
|
|
3852
|
-
isList: false,
|
|
3853
|
-
type: `${modelCountOutputTypeName}Select`,
|
|
3854
|
-
location: "inputObjectTypes",
|
|
3855
|
-
namespace: "prisma"
|
|
3856
|
-
}
|
|
3857
|
-
]
|
|
3858
|
-
}
|
|
3859
|
-
]
|
|
3860
|
-
};
|
|
3861
|
-
modelCountOutputTypeArgsInputObjectTypes.push(modelCountOutputTypeArgsInputObjectType);
|
|
3862
|
-
}
|
|
3863
|
-
return modelCountOutputTypeArgsInputObjectTypes;
|
|
3864
|
-
}
|
|
3865
|
-
__name(generateModelCountOutputTypeArgsInputObjectTypes, "generateModelCountOutputTypeArgsInputObjectTypes");
|
|
3866
|
-
function generateModelSelectInputObjectTypes(models) {
|
|
3867
|
-
const modelSelectInputObjectTypes = [];
|
|
3868
|
-
for (const model of models) {
|
|
3869
|
-
const { name: modelName, fields: modelFields } = model;
|
|
3870
|
-
const fields = [];
|
|
3871
|
-
for (const modelField of modelFields) {
|
|
3872
|
-
const { name: modelFieldName, isList, type } = modelField;
|
|
3873
|
-
const isRelationField = checkIsModelRelationField(modelField);
|
|
3874
|
-
const field = {
|
|
3875
|
-
name: modelFieldName,
|
|
3876
|
-
isRequired: false,
|
|
3877
|
-
isNullable: false,
|
|
3878
|
-
inputTypes: [
|
|
3879
|
-
{
|
|
3880
|
-
isList: false,
|
|
3881
|
-
type: "Boolean",
|
|
3882
|
-
location: "scalar"
|
|
3883
|
-
}
|
|
3884
|
-
]
|
|
3885
|
-
};
|
|
3886
|
-
if (isRelationField) {
|
|
3887
|
-
const schemaArgInputType = {
|
|
3888
|
-
isList: false,
|
|
3889
|
-
type: isList ? `${type}FindManyArgs` : `${type}DefaultArgs`,
|
|
3890
|
-
location: "inputObjectTypes",
|
|
3891
|
-
namespace: "prisma"
|
|
3892
|
-
};
|
|
3893
|
-
field.inputTypes.push(schemaArgInputType);
|
|
3894
|
-
}
|
|
3895
|
-
fields.push(field);
|
|
3896
|
-
}
|
|
3897
|
-
const hasManyRelationToAnotherModel = checkModelHasManyModelRelation(model);
|
|
3898
|
-
const shouldAddCountField = hasManyRelationToAnotherModel;
|
|
3899
|
-
if (shouldAddCountField) {
|
|
3900
|
-
const _countField = {
|
|
3901
|
-
name: "_count",
|
|
3902
|
-
isRequired: false,
|
|
3903
|
-
isNullable: false,
|
|
3904
|
-
inputTypes: [
|
|
3905
|
-
{
|
|
3906
|
-
isList: false,
|
|
3907
|
-
type: "Boolean",
|
|
3908
|
-
location: "scalar"
|
|
3909
|
-
},
|
|
3910
|
-
{
|
|
3911
|
-
isList: false,
|
|
3912
|
-
type: `${modelName}CountOutputTypeDefaultArgs`,
|
|
3913
|
-
location: "inputObjectTypes",
|
|
3914
|
-
namespace: "prisma"
|
|
3915
|
-
}
|
|
3916
|
-
]
|
|
3917
|
-
};
|
|
3918
|
-
fields.push(_countField);
|
|
3919
|
-
}
|
|
3920
|
-
const modelSelectInputObjectType = {
|
|
3921
|
-
name: `${modelName}Select`,
|
|
3922
|
-
constraints: {
|
|
3923
|
-
maxNumFields: null,
|
|
3924
|
-
minNumFields: null
|
|
3925
|
-
},
|
|
3926
|
-
fields
|
|
3927
|
-
};
|
|
3928
|
-
modelSelectInputObjectTypes.push(modelSelectInputObjectType);
|
|
3929
|
-
}
|
|
3930
|
-
return modelSelectInputObjectTypes;
|
|
3931
|
-
}
|
|
3932
|
-
__name(generateModelSelectInputObjectTypes, "generateModelSelectInputObjectTypes");
|
|
3933
|
-
|
|
3934
|
-
// src/zod/whereUniqueInput-helpers.ts
|
|
3935
|
-
init_cjs_shims();
|
|
3936
|
-
function changeOptionalToRequiredFields(inputObjectTypes) {
|
|
3937
|
-
inputObjectTypes.map((item) => {
|
|
3938
|
-
if (item.name.includes("WhereUniqueInput") && // eslint-disable-next-line ts/no-non-null-asserted-optional-chain
|
|
3939
|
-
item.constraints.fields?.length > 0) {
|
|
3940
|
-
item.fields = item.fields.map((subItem) => {
|
|
3941
|
-
if (item.constraints.fields?.includes(subItem.name)) {
|
|
3942
|
-
subItem.isRequired = true;
|
|
3943
|
-
return subItem;
|
|
3944
|
-
}
|
|
3945
|
-
return subItem;
|
|
3946
|
-
});
|
|
3947
|
-
}
|
|
3948
|
-
return item;
|
|
3949
|
-
});
|
|
3950
|
-
}
|
|
3951
|
-
__name(changeOptionalToRequiredFields, "changeOptionalToRequiredFields");
|
|
3952
|
-
|
|
3953
|
-
// src/zod/helpers.ts
|
|
3954
|
-
function addMissingZodInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
|
|
3955
|
-
if (dataSourceProvider === "mongodb") {
|
|
3956
|
-
addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes);
|
|
3957
|
-
}
|
|
3958
|
-
addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes);
|
|
3959
|
-
if (options.isGenerateSelect) {
|
|
3960
|
-
addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models);
|
|
3961
|
-
Transformer.setIsGenerateSelect(true);
|
|
3962
|
-
}
|
|
3963
|
-
if (options.isGenerateSelect || options.isGenerateInclude) {
|
|
3964
|
-
addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, options.isGenerateSelect, options.isGenerateInclude);
|
|
3965
|
-
}
|
|
3966
|
-
if (options.isGenerateInclude) {
|
|
3967
|
-
addMissingInputObjectTypesForInclude(inputObjectTypes, models, options.isGenerateSelect);
|
|
3968
|
-
Transformer.setIsGenerateInclude(true);
|
|
3969
|
-
}
|
|
3970
|
-
changeOptionalToRequiredFields(inputObjectTypes);
|
|
3971
|
-
}
|
|
3972
|
-
__name(addMissingZodInputObjectTypes, "addMissingZodInputObjectTypes");
|
|
3973
|
-
|
|
3974
|
-
// src/prisma-generator.ts
|
|
3975
|
-
async function generate(options) {
|
|
3976
|
-
console.log("[STORM]: Running the Storm Software - Prisma tRPC generator \n");
|
|
3977
|
-
const internals = await getPrismaInternals();
|
|
3978
|
-
console.log(`[STORM]: Validating configuration options
|
|
3979
|
-
`);
|
|
3980
|
-
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
3981
|
-
const results = await configSchema.safeParseAsync(options.generator.config);
|
|
3982
|
-
if (!results.success) {
|
|
3983
|
-
throw new Error("Invalid options passed");
|
|
3984
|
-
}
|
|
3985
|
-
const config = results.data;
|
|
3986
|
-
const consoleLog = /* @__PURE__ */ __name((message) => {
|
|
3987
|
-
if (config.debug) {
|
|
3988
|
-
console.log(`[STORM]: ${message}
|
|
3989
|
-
`);
|
|
3990
|
-
}
|
|
3991
|
-
}, "consoleLog");
|
|
3992
|
-
consoleLog(`Using configuration parameters:
|
|
3993
|
-
${JSON.stringify(config)}`);
|
|
3994
|
-
consoleLog(`Preparing output directory: ${outputDir}`);
|
|
3995
|
-
await (0, import_helpers2.removeDirectory)(outputDir);
|
|
3996
|
-
await (0, import_helpers2.createDirectory)(outputDir);
|
|
3997
|
-
consoleLog("Finding Prisma Client generator");
|
|
3998
|
-
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
3999
|
-
if (!prismaClientProvider) {
|
|
4000
|
-
throw new Error("No Prisma Client generator found. Please add `prisma-client-js` to your generator list.");
|
|
4001
|
-
}
|
|
4002
|
-
consoleLog("Generating Prisma Client DMMF");
|
|
4003
|
-
const prismaClientDmmf = await internals.getDMMF({
|
|
4004
|
-
datamodel: options.datamodel,
|
|
4005
|
-
previewFeatures: prismaClientProvider?.previewFeatures
|
|
4006
|
-
});
|
|
4007
|
-
const modelOperations = prismaClientDmmf.mappings.modelOperations;
|
|
4008
|
-
const inputObjectTypes = prismaClientDmmf.schema.inputObjectTypes.prisma;
|
|
4009
|
-
const outputObjectTypes = prismaClientDmmf.schema.outputObjectTypes.prisma;
|
|
4010
|
-
const enumTypes = prismaClientDmmf.schema.enumTypes;
|
|
4011
|
-
const models = prismaClientDmmf.datamodel.models;
|
|
4012
|
-
const hiddenModels = [];
|
|
4013
|
-
const hiddenFields = [];
|
|
4014
|
-
if (config.withZod !== false) {
|
|
4015
|
-
consoleLog("Generating Zod schemas");
|
|
4016
|
-
const zodOutputPath = internals.parseEnvValue(options.generator.output);
|
|
4017
|
-
await (0, import_helpers2.createDirectory)(zodOutputPath);
|
|
4018
|
-
Transformer.setOutputPath(zodOutputPath);
|
|
4019
|
-
if (prismaClientProvider?.isCustomOutput) {
|
|
4020
|
-
Transformer.setPrismaClientOutputPath(prismaClientProvider.output?.value);
|
|
4021
|
-
}
|
|
4022
|
-
await constructZodModels(models, (0, import_join_paths4.joinPaths)(zodOutputPath, "schemas", "models"), config, options);
|
|
4023
|
-
resolveZodModelsComments(models, modelOperations, enumTypes, hiddenModels, hiddenFields);
|
|
4024
|
-
await generateZodEnumSchemas(enumTypes.prisma, enumTypes.model);
|
|
4025
|
-
const dataSource = options.datasources?.[0];
|
|
4026
|
-
if (!dataSource) {
|
|
4027
|
-
throw new Error("No datasource found");
|
|
4028
|
-
}
|
|
4029
|
-
const previewFeatures = prismaClientProvider?.previewFeatures;
|
|
4030
|
-
Transformer.provider = dataSource.provider;
|
|
4031
|
-
Transformer.previewFeatures = previewFeatures;
|
|
4032
|
-
addMissingZodInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSource.provider, {
|
|
4033
|
-
isGenerateSelect: true,
|
|
4034
|
-
isGenerateInclude: true
|
|
4035
|
-
});
|
|
4036
|
-
const aggregateOperationSupport = resolveZodAggregateOperationSupport(inputObjectTypes);
|
|
4037
|
-
hideZodInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels, hiddenFields);
|
|
4038
|
-
await generateZodObjectSchemas(inputObjectTypes);
|
|
4039
|
-
await generateZodModelSchemas(models, modelOperations, aggregateOperationSupport);
|
|
4040
|
-
await generateZodIndex();
|
|
4041
|
-
} else {
|
|
4042
|
-
consoleLog("Skipping Zod schemas generation");
|
|
4043
|
-
}
|
|
4044
|
-
const queries = [];
|
|
4045
|
-
const mutations = [];
|
|
4046
|
-
const subscriptions = [];
|
|
4047
|
-
prismaClientDmmf.mappings.modelOperations.forEach((modelOperation) => {
|
|
4048
|
-
const { model: _model, plural: _plural, ...operations } = modelOperation;
|
|
4049
|
-
for (const [opType, opNameWithModel] of Object.entries(operations)) {
|
|
4050
|
-
if ([
|
|
4051
|
-
"findUnique",
|
|
4052
|
-
"findUniqueOrThrow",
|
|
4053
|
-
"findFirst",
|
|
4054
|
-
"findFirstOrThrow",
|
|
4055
|
-
"findRaw",
|
|
4056
|
-
"findMany",
|
|
4057
|
-
"aggregateRaw",
|
|
4058
|
-
"count",
|
|
4059
|
-
"aggregate",
|
|
4060
|
-
"groupBy"
|
|
4061
|
-
].includes(opType)) {
|
|
4062
|
-
queries.push(opNameWithModel);
|
|
4063
|
-
}
|
|
4064
|
-
if ([
|
|
4065
|
-
"createOne",
|
|
4066
|
-
"createMany",
|
|
4067
|
-
"createManyAndReturn",
|
|
4068
|
-
"deleteOne",
|
|
4069
|
-
"deleteMany",
|
|
4070
|
-
"updateOne",
|
|
4071
|
-
"updateMany",
|
|
4072
|
-
"updateManyAndReturn",
|
|
4073
|
-
"upsertOne"
|
|
4074
|
-
].includes(opType)) {
|
|
4075
|
-
mutations.push(opNameWithModel);
|
|
4076
|
-
}
|
|
4077
|
-
}
|
|
4078
|
-
});
|
|
4079
|
-
queries.sort();
|
|
4080
|
-
mutations.sort();
|
|
4081
|
-
subscriptions.sort();
|
|
4082
|
-
if (config.withShield && !(typeof config.withShield === "string" && ((0, import_exists.existsSync)((0, import_join_paths4.joinPaths)(outputDir, config.withShield)) || (0, import_exists.existsSync)((0, import_join_paths4.joinPaths)(outputDir, `./${config.withShield}.ts`)) || (0, import_exists.existsSync)((0, import_join_paths4.joinPaths)(outputDir, config.withShield, "./shield.ts"))))) {
|
|
4083
|
-
consoleLog(`Generating tRPC Shield source file to ${outputDir}`);
|
|
4084
|
-
await writeFileSafely((0, import_join_paths4.joinPaths)(outputDir, "./shield.ts"), await constructShield({
|
|
4085
|
-
queries,
|
|
4086
|
-
mutations,
|
|
4087
|
-
subscriptions
|
|
4088
|
-
}, config, options, outputDir));
|
|
4089
|
-
} else {
|
|
4090
|
-
consoleLog("Skipping tRPC Shield generation");
|
|
4091
|
-
}
|
|
4092
|
-
consoleLog(`Generating tRPC source code for ${models.length} models`);
|
|
4093
|
-
if (config.trpcOptions && typeof config.trpcOptions === "boolean") {
|
|
4094
|
-
consoleLog(`Generating tRPC options source file to ${outputDir}`);
|
|
4095
|
-
await writeFileSafely((0, import_join_paths4.joinPaths)(outputDir, "./options.ts"), constructDefaultOptions(config, options, outputDir));
|
|
4096
|
-
}
|
|
4097
|
-
resolveModelsComments(models, hiddenModels);
|
|
4098
|
-
consoleLog("Generating tRPC export file");
|
|
4099
|
-
const trpcExports = project.createSourceFile(import_node_path5.default.resolve(outputDir, "trpc.ts"), void 0, {
|
|
4100
|
-
overwrite: true
|
|
4101
|
-
});
|
|
4102
|
-
await generateTRPCExports(trpcExports, config, options, outputDir);
|
|
4103
|
-
consoleLog("Generating tRPC app router");
|
|
4104
|
-
const appRouter = project.createSourceFile(import_node_path5.default.resolve(outputDir, "routers", `index.ts`), void 0, {
|
|
4105
|
-
overwrite: true
|
|
4106
|
-
});
|
|
4107
|
-
consoleLog("Generating tRPC router imports");
|
|
4108
|
-
generateCreateRouterImport({
|
|
4109
|
-
sourceFile: appRouter
|
|
4110
|
-
});
|
|
4111
|
-
const routerStatements = [];
|
|
4112
|
-
for (const modelOperation of modelOperations) {
|
|
4113
|
-
const { model, ...operations } = modelOperation;
|
|
4114
|
-
if (hiddenModels.includes(model)) {
|
|
4115
|
-
consoleLog(`Skipping model ${model} as it is hidden`);
|
|
4116
|
-
continue;
|
|
4117
|
-
}
|
|
4118
|
-
if (!model) {
|
|
4119
|
-
consoleLog(`Skipping model ${model} as it is not defined`);
|
|
4120
|
-
continue;
|
|
4121
|
-
}
|
|
4122
|
-
const modelActions = Object.keys(operations).filter((opType) => (
|
|
4123
|
-
// eslint-disable-next-line unicorn/prefer-includes
|
|
4124
|
-
config.generateModelActions.some((generateModelAction) => generateModelAction === opType.replace("One", ""))
|
|
4125
|
-
));
|
|
4126
|
-
if (!modelActions.length) {
|
|
4127
|
-
consoleLog(`Skipping model ${model} as it has no actions to generate`);
|
|
4128
|
-
continue;
|
|
4129
|
-
}
|
|
4130
|
-
const plural = (0, import_pluralize.default)(lowerCaseFirst(model));
|
|
4131
|
-
consoleLog(`Generating tRPC router for model ${model}`);
|
|
4132
|
-
generateRouterImport(appRouter, plural, model);
|
|
4133
|
-
const modelRouter = project.createSourceFile(import_node_path5.default.resolve(outputDir, "routers", `${lowerCaseFirst(model)}.router.ts`), void 0, {
|
|
4134
|
-
overwrite: true
|
|
4135
|
-
});
|
|
4136
|
-
generateCreateRouterImport({
|
|
4137
|
-
sourceFile: modelRouter,
|
|
4138
|
-
config
|
|
4139
|
-
});
|
|
4140
|
-
if (config.withZod) {
|
|
4141
|
-
consoleLog("Generating Zod schemas imports");
|
|
4142
|
-
generateRouterSchemaImports(modelRouter, model, modelActions);
|
|
4143
|
-
}
|
|
4144
|
-
modelRouter.addStatements(
|
|
4145
|
-
/* ts */
|
|
4146
|
-
`
|
|
4147
|
-
export const ${plural}Router = t.router({`
|
|
4148
|
-
);
|
|
4149
|
-
for (const opType of modelActions) {
|
|
4150
|
-
const opNameWithModel = operations[opType];
|
|
4151
|
-
if (opNameWithModel) {
|
|
4152
|
-
const baseOpType = opType.replace("OrThrow", "");
|
|
4153
|
-
generateProcedure(modelRouter, opNameWithModel, getInputTypeByOpName(baseOpType, model), model, opType, baseOpType, config);
|
|
4154
|
-
}
|
|
4155
|
-
}
|
|
4156
|
-
modelRouter.addStatements(
|
|
4157
|
-
/* ts */
|
|
4158
|
-
`
|
|
4159
|
-
})`
|
|
4160
|
-
);
|
|
4161
|
-
modelRouter.formatText({
|
|
4162
|
-
indentSize: 2
|
|
4163
|
-
});
|
|
4164
|
-
routerStatements.push(
|
|
4165
|
-
/* ts */
|
|
4166
|
-
`
|
|
4167
|
-
${lowerCaseFirst(model)}: ${plural}Router`
|
|
4168
|
-
);
|
|
4169
|
-
consoleLog(`Generated tRPC router for model ${model} with ${modelActions.length} actions`);
|
|
4170
|
-
}
|
|
4171
|
-
consoleLog("Generating tRPC app router");
|
|
4172
|
-
appRouter.addStatements(
|
|
4173
|
-
/* ts */
|
|
4174
|
-
`
|
|
4175
|
-
export const appRouter = t.router({${routerStatements.join()}});
|
|
4176
|
-
|
|
4177
|
-
export type AppRouter = typeof appRouter;`
|
|
4178
|
-
);
|
|
4179
|
-
appRouter.formatText({
|
|
4180
|
-
indentSize: 2
|
|
4181
|
-
});
|
|
4182
|
-
consoleLog("Saving tRPC router source files to disk");
|
|
4183
|
-
await project.save();
|
|
4184
|
-
consoleLog("Storm Software - Prisma tRPC generator completed successfully");
|
|
4185
|
-
}
|
|
4186
|
-
__name(generate, "generate");
|
|
4187
|
-
|
|
4188
|
-
// src/index.ts
|
|
4189
|
-
getPrismaGeneratorHelper().then((helpers) => {
|
|
4190
|
-
helpers.generatorHandler({
|
|
4191
|
-
onManifest: /* @__PURE__ */ __name(() => ({
|
|
4192
|
-
defaultOutput: "./generated",
|
|
4193
|
-
prettyName: "Storm Software - Prisma tRPC Generator",
|
|
4194
|
-
requiresGenerators: [
|
|
4195
|
-
"prisma-client-js"
|
|
4196
|
-
]
|
|
4197
|
-
}), "onManifest"),
|
|
4198
|
-
onGenerate: generate
|
|
4199
|
-
});
|
|
4200
|
-
}).catch((reason) => {
|
|
4201
|
-
console.error(`An error occured while generating prisma tRPC source code: ${reason}`);
|
|
4202
|
-
});
|
|
87
|
+
`,He=async(e,t,n,r)=>{let i=O.createSourceFile(`${t}/index.ts`,{},{overwrite:!0});Ae(e,i),i.formatText({indentSize:2}),await Promise.all(e.map(async e=>{let i=O.createSourceFile(`${t}/${C(e.name)}.schema.ts`,{},{overwrite:!0});await ke(e,i,n,r),i.formatText({indentSize:2})}))};async function Ue(e){let t=await S.default.resolveConfig(process.cwd()),n=t;return t||(n={trailingComma:`all`,tabWidth:2,printWidth:80,bracketSpacing:!0,semi:!0,singleQuote:!0,useTabs:!1}),await S.default.format(e,{...n,parser:`typescript`})}const X=new Set,We=e=>{X.add(e)},Z=async(e,t,n=!0)=>{let[r]=await Promise.all([Ue(t),(0,u.createDirectory)((0,m.findFilePath)(e))]);await(0,b.writeFile)(e,r),n&&We(e)},Ge=async e=>{let t=Array.from(X).map(t=>{let n=f.default.relative(f.default.dirname(e),t);return n.endsWith(`.ts`)&&(n=n.slice(0,n.lastIndexOf(`.ts`))),`export * from './${(0,x.correctPath)(n)}';`});t.push(`export * from './models';`),await Z(e,t.join(`
|
|
88
|
+
`),!1)},Ke=e=>/(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(e),Q=e=>e.endsWith(`CountAggregateInput`)||e.endsWith(`SumAggregateInput`)||e.endsWith(`AvgAggregateInput`)||e.endsWith(`MinAggregateInput`)||e.endsWith(`MaxAggregateInput`);function qe(e,t){let n=t.filter(({name:e})=>Ke(e));for(let t of n){let n=t.name.replace(/(?:OutputType|Output)$/,``);e.push({constraints:{maxNumFields:null,minNumFields:null},name:`${n}Input`,fields:t.fields.map(e=>({name:e.name,isNullable:!1,isRequired:!1,inputTypes:[{isList:!1,type:`True`,location:`scalar`}]}))})}}function Je(e){let t={};for(let n of e)if(Q(n.name)){let e=n.name.replace(`AggregateInput`,``);if(e.endsWith(`Count`)){let n=e.replace(`Count`,``);t[n]={...t[n],count:!0}}else if(e.endsWith(`Min`)){let n=e.replace(`Min`,``);t[n]={...t[n],min:!0}}else if(e.endsWith(`Max`)){let n=e.replace(`Max`,``);t[n]={...t[n],max:!0}}else if(e.endsWith(`Sum`)){let n=e.replace(`Sum`,``);t[n]={...t[n],sum:!0}}else if(e.endsWith(`Avg`)){let n=e.replace(`Avg`,``);t[n]={...t[n],avg:!0}}}return t}const Ye=/(?:@@Gen\.)+[A-z]+\(.+\)/,Xe=/\.+[A-Z]+\(+/i,Ze=/\(+[A-Z]+:.+\)/i;function Qe(e,t,n,r,i){e=$e(e,r),et(e,r,i),nt(e,t),tt(n,r)}function $e(e,t){return e.map(e=>{if(e.documentation){let n=e.documentation?.match(Ye)?.[0];if(n?.match(Xe)?.[0]?.slice(1,-1)!==`model`)return e;let r=n?.match(Ze)?.[0]?.slice(1,-1),i={};if(r){let e=r.split(`:`).map(e=>e.trim()).map(e=>e.startsWith(`[`)?e:e.split(`,`)).flat().map(e=>e.trim());for(let t=0;t<e.length;t+=2){let n=e[t],r=e[t+1];i[n]=JSON.parse(r)}}if(i.hide)return t.push(e.name),null}return e}).filter(Boolean)}function et(e,t,n){e.forEach(e=>{e.fields.forEach(e=>{t.includes(e.type)&&(n.push(e.name),e.relationFromFields&&e.relationFromFields.forEach(e=>n.push(e)))})})}function tt(e,t){e.prisma=e.prisma.filter(e=>!t.find(t=>e.name.startsWith(t)))}function nt(e,t){let n=t.length;for(;n>=0;){--n;let r=t[n];r&&!e.find(e=>e.name===r.model)&&t.splice(n,1)}}function rt(e,t,n){let r=e.length;for(;r>=0;){--r;let i=e[r];if(i&&(t.includes(i?.meta?.source)||t.find(e=>i.name.startsWith(e))))e.splice(r,1);else{let t=i?.fields?.length??0;for(;t>=0;){--t;let a=i?.fields?.[t];a&&n.includes(a.name)&&e[r].fields.slice(t,1)}}}}function it(e,t,n){$.rawOpsMap=at(e)??{};let r=ot(t);for(let e of r)n.push(e)}function at(e){let t={},n=[...new Set(e.reduce((e,t)=>(Object.keys(t)?.forEach(t=>{t.includes(`Raw`)&&e.push(t)}),e),[]))],r=e.map(e=>e.model);return n.forEach(e=>{r.forEach(n=>{let r=e===`findRaw`,i=`${e.replace(`Raw`,``)}${n}Raw`;t[i]=r?`${n}FindRawArgs`:`${n}AggregateRawArgs`})}),t}function ot(e){return st(e).map(e=>({name:e.name,constraints:{maxNumFields:null,minNumFields:null},fields:e.args.map(e=>({name:e.name,isRequired:e.isRequired,isNullable:e.isNullable,inputTypes:e.inputTypes}))}))}function st(e){return e.filter(e=>e.name===`Query`)?.[0].fields.filter(e=>e.name.includes(`Raw`))??[]}const ct=e=>/find[\s\S]*?Raw/.test(e)||/aggregate[\s\S]*?Raw/.test(e);var $=class e{name;fields;schemaImports=new Set;models;modelOperations;aggregateOperationSupport;enumTypes;static enumNames=[];static rawOpsMap={};static provider;static previewFeatures;static outputPath=`./generated`;hasJson=!1;static prismaClientOutputPath=`@prisma/client`;static isCustomPrismaClientOutputPath=!1;static isGenerateSelect=!0;static isGenerateInclude=!0;constructor(e){this.name=e.name??``,this.fields=e.fields??[],this.models=e.models??[],this.modelOperations=e.modelOperations??[],this.aggregateOperationSupport=e.aggregateOperationSupport??{},this.enumTypes=e.enumTypes??[]}static setOutputPath(e){this.outputPath=e}static setIsGenerateSelect(e){this.isGenerateSelect=e}static setIsGenerateInclude(e){this.isGenerateInclude=e}static getOutputPath(){return this.outputPath}static setPrismaClientOutputPath(e){this.prismaClientOutputPath=e,this.isCustomPrismaClientOutputPath=e!==`@prisma/client`}static async generateIndex(){await Ge(f.default.join(e.outputPath,`schemas/index.ts`))}async generateEnumSchemas(){for(let t of this.enumTypes){let{name:n,values:r}=t;await Z(f.default.join(e.outputPath,`schemas/enums/${C(n)}.schema.ts`),`${this.generateImportZodStatement()}\n${this.generateExportSchemaStatement(`${C(n)}`,`z.enum(${JSON.stringify(r)})`)}`)}}generateImportZodStatement(){return`import { z } from 'zod';
|
|
89
|
+
`}generateExportSchemaStatement(e,t){return`export const ${C(e)}Schema = ${t}`}async generateObjectSchema(){let t=this.generateObjectSchemaFields(),n=this.prepareObjectSchema(t),r=this.resolveObjectSchemaName();await Z(f.default.join(e.outputPath,`schemas/objects/${C(r)}.schema.ts`),n)}generateObjectSchemaFields(){return this.fields.map(e=>this.generateObjectSchemaField(e)).flatMap(e=>e).map(e=>{let[t,n,r]=e;return(r?t:this.generateFieldValidators(t,n)).trim()})}generateObjectSchemaField(e){let t=e.inputTypes;if(t.length===0)return[];let n=t.reduce((n,r)=>{if(r.type===`String`)n.push(this.wrapWithZodValidators(`z.string()`,e));else if(r.type===`Int`||r.type===`Float`||r.type===`Decimal`)n.push(this.wrapWithZodValidators(`z.number()`,e));else if(r.type===`BigInt`)n.push(this.wrapWithZodValidators(`z.bigint()`,e));else if(r.type===`Boolean`)n.push(this.wrapWithZodValidators(`z.boolean()`,e));else if(r.type===`DateTime`)n.push(this.wrapWithZodValidators(`z.coerce.date()`,e));else if(r.type===`Json`)this.hasJson=!0,n.push(this.wrapWithZodValidators(`jsonSchema`,e));else if(r.type===`True`)n.push(this.wrapWithZodValidators(`z.literal(true)`,e));else if(r.type===`Bytes`)n.push(this.wrapWithZodValidators(`z.instanceof(Buffer)`,e));else if(!r.type.endsWith(`FieldRefInput`)){let i=r.location===`enumTypes`;(r.namespace===`prisma`||i)&&(r.type!==this.name&&typeof r.type==`string`&&this.addSchemaImport(r.type),n.push(this.generatePrismaStringLine(e,r,t.length)))}return n},[]);if(n.length===0)return[];n.length>1&&(n=n.map(e=>e.replace(`.optional()`,``)));let r=n.some(e=>e.includes(`:`))?``:` ${e.name}:`,i=e.isRequired?``:`.optional()`,a=n.length===1?n.join(`,\r
|
|
90
|
+
`):`z.union([${n.join(`,\r
|
|
91
|
+
`)}])${i}`;return e.isNullable&&(a+=`.nullable()`),[[` ${r} ${a} `,e,!0]]}wrapWithZodValidators(e,t){let n=``;return n=e,t.inputTypes.some(e=>e.isList)&&(n+=`.array()`),t.isRequired||(n+=`.optional()`),n}addSchemaImport(e){this.schemaImports.add(e)}generatePrismaStringLine(e,t,n){let r=t.location===`enumTypes`,i=t.type,{isModelQueryType:a,modelName:o,queryName:s}=this.checkIsModelQueryType(i),c=a?this.resolveModelQuerySchemaName(o,s):`${i}ObjectSchema`,l=`${i}Schema`,u=t.type===this.name?c:r?l:c,d=t.isList?`.array()`:``,f=e.isRequired?``:`.optional()`;return n===1?` ${e.name}: z.lazy(() => ${C(u)})${d}${f}`:`z.lazy(() => ${C(u)})${d}${f}`}generateFieldValidators(e,t){let{isRequired:n,isNullable:r}=t;return n||(e+=`.optional()`),r&&(e+=`.nullable()`),e}prepareObjectSchema(e){let t=`${this.generateExportObjectSchemaStatement(this.addFinalWrappers({zodStringFields:e}))}\n`,n=this.generateImportPrismaStatement(),r=this.generateJsonSchemaImplementation();return`${this.generateObjectSchemaImportStatements()}${n}${r}${t}`}generateExportObjectSchemaStatement(t){let n=this.name,r=this.name;e.provider===`mongodb`&&ct(n)&&(n=e.rawOpsMap[n],r=n.replace(`Args`,``)),Q(n)&&(n=`${n}Type`);let i=`export const ${C(r)}ObjectSchema = schema`;return`const schema: z.ZodType<Prisma.${n}> = ${t};\n\n ${i}`}addFinalWrappers({zodStringFields:e}){let t=[...e];return`${this.wrapWithZodObject(t)}.strict()`}generateImportPrismaStatement(){let t;if(e.isCustomPrismaClientOutputPath){let n=f.default.join(e.outputPath,`schemas`,`objects`),r=e.prismaClientOutputPath;t=f.default.relative(n,r).split(f.default.sep).join(f.default.posix.sep)}else t=e.prismaClientOutputPath;return`import type { Prisma } from '${t}';\n\n`}generateJsonSchemaImplementation(){let e=``;return this.hasJson&&(e+=`
|
|
92
|
+
`,e+=`const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
93
|
+
`,e+=`const jsonSchema: z.ZodType<Prisma.InputJsonValue> = z.lazy(() =>
|
|
94
|
+
`,e+=` z.union([literalSchema, z.array(jsonSchema.nullable()), z.record(jsonSchema.nullable())])
|
|
95
|
+
`,e+=`);
|
|
96
|
+
|
|
97
|
+
`),e}generateObjectSchemaImportStatements(){let e=this.generateImportZodStatement();return e+=this.generateSchemaImports(),e+=`
|
|
98
|
+
|
|
99
|
+
`,e}generateSchemaImports(){return[...this.schemaImports].map(t=>{let{isModelQueryType:n,modelName:r,queryName:i}=this.checkIsModelQueryType(t);return n?`import { ${this.resolveModelQuerySchemaName(r,i)} } from '../${i}${r}.schema'`:e.enumNames.includes(t)?`import { ${C(t)}Schema } from '../enums/${C(t)}.schema'`:`import { ${C(t)}ObjectSchema } from './${C(t)}.schema'`}).join(`;\r
|
|
100
|
+
`)}checkIsModelQueryType(e){let t={FindManyArgs:`findMany`};for(let n of[`FindManyArgs`])if(e.includes(n)){let r=e.indexOf(n);return{isModelQueryType:!0,modelName:e.substring(0,r),queryName:t[n]}}return{isModelQueryType:!1}}resolveModelQuerySchemaName(e,t){return`${C(e)}${A(t)}Schema`}wrapWithZodUnion(e){let t=``;return t+=`z.union([`,t+=`
|
|
101
|
+
`,t+=` ${e.join(`,`)}`,t+=`
|
|
102
|
+
`,t+=`])`,t}wrapWithZodObject(e){let t=``;return t+=`z.object({`,t+=`
|
|
103
|
+
`,t+=` ${typeof e==`string`?e:e.join(`,
|
|
104
|
+
`)}`,t+=`
|
|
105
|
+
`,t+=`})`,t}resolveObjectSchemaName(){let t=this.name,n=this.name;return ct(t)&&(t=e.rawOpsMap[t],n=t.replace(`Args`,``)),C(n)}async generateModelSchemas(){for(let t of this.modelOperations){let{findUnique:n,findFirst:r,findMany:i,createOne:a,createMany:o,createManyAndReturn:s,deleteOne:c,updateOne:l,deleteMany:u,updateMany:d,updateManyAndReturn:p,upsertOne:m,aggregate:h,groupBy:g}=t,_=be(this.models,t.model),v=C(t.model),{selectImport:y,includeImport:b,selectZodSchemaLine:x,includeZodSchemaLine:S,selectZodSchemaLineLazy:w,includeZodSchemaLineLazy:ee}=this.resolveSelectIncludeImportAndZodSchemaLine(_),{orderByImport:T,orderByZodSchemaLine:E}=this.resolveOrderByWithRelationImportAndZodSchemaLine(_);if(n){let t=[y,b,`import { ${v}WhereUniqueInputObjectSchema } from './objects/${v}WhereUniqueInput.schema'`];await Z(f.default.join(e.outputPath,`schemas/${n}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}FindUnique`,`z.object({ ${x} ${S} where: ${v}WhereUniqueInputObjectSchema })`)}`)}if(r){let t=[y,b,T,`import { ${v}WhereInputObjectSchema } from './objects/${v}WhereInput.schema'`,`import { ${v}WhereUniqueInputObjectSchema } from './objects/${v}WhereUniqueInput.schema'`,`import { ${v}ScalarFieldEnumSchema } from './enums/${v}ScalarFieldEnum.schema'`];await Z(f.default.join(e.outputPath,`schemas/${r}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}FindFirst`,`z.object({ ${x} ${S} ${E} where: ${v}WhereInputObjectSchema.optional(), cursor: ${v}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${v}ScalarFieldEnumSchema).optional() })`)}`)}if(i){let t=[y,b,T,`import { ${v}WhereInputObjectSchema } from './objects/${v}WhereInput.schema'`,`import { ${v}WhereUniqueInputObjectSchema } from './objects/${v}WhereUniqueInput.schema'`,`import { ${v}ScalarFieldEnumSchema } from './enums/${v}ScalarFieldEnum.schema'`];await Z(f.default.join(e.outputPath,`schemas/${i}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}FindMany`,`z.object({ ${w} ${ee} ${E} where: ${v}WhereInputObjectSchema.optional(), cursor: ${v}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), distinct: z.array(${v}ScalarFieldEnumSchema).optional() })`)}`)}if(a){let t=[y,b,`import { ${v}CreateInputObjectSchema } from './objects/${v}CreateInput.schema'`,`import { ${v}UncheckedCreateInputObjectSchema } from './objects/${v}UncheckedCreateInput.schema'`];await Z(f.default.join(e.outputPath,`schemas/${a}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}CreateOne`,`z.object({ ${x} ${S} data: z.union([${v}CreateInputObjectSchema, ${v}UncheckedCreateInputObjectSchema]) })`)}`)}if(o){let t=[`import { ${v}CreateManyInputObjectSchema } from './objects/${v}CreateManyInput.schema'`];await Z(f.default.join(e.outputPath,`schemas/${o}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}CreateMany`,`z.object({ data: z.union([ ${v}CreateManyInputObjectSchema, z.array(${v}CreateManyInputObjectSchema) ]), ${e.provider===`mongodb`||e.provider===`sqlserver`?``:`skipDuplicates: z.boolean().optional()`} })`)}`)}if(s){let t=[`import { ${v}CreateManyAndReturnInputObjectSchema } from './objects/${v}CreateManyAndReturnInput.schema'`];await Z(f.default.join(e.outputPath,`schemas/${s}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}CreateManyAndReturn`,`z.object({ data: z.union([ ${v}CreateManyAndReturnInputObjectSchema, z.array(${v}CreateManyAndReturnInputObjectSchema) ]), ${e.provider===`mongodb`||e.provider===`sqlserver`?``:`skipDuplicates: z.boolean().optional()`} })`)}`)}if(c){let t=[y,b,`import { ${v}WhereUniqueInputObjectSchema } from './objects/${v}WhereUniqueInput.schema'`];await Z(f.default.join(e.outputPath,`schemas/${c}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}DeleteOne`,`z.object({ ${x} ${S} where: ${v}WhereUniqueInputObjectSchema })`)}`)}if(u){let t=[`import { ${v}WhereInputObjectSchema } from './objects/${v}WhereInput.schema'`];await Z(f.default.join(e.outputPath,`schemas/${u}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}DeleteMany`,`z.object({ where: ${v}WhereInputObjectSchema.optional() })`)}`)}if(l){let t=[y,b,`import { ${v}UpdateInputObjectSchema } from './objects/${v}UpdateInput.schema'`,`import { ${v}UncheckedUpdateInputObjectSchema } from './objects/${v}UncheckedUpdateInput.schema'`,`import { ${v}WhereUniqueInputObjectSchema } from './objects/${v}WhereUniqueInput.schema'`];await Z(f.default.join(e.outputPath,`schemas/${l}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}UpdateOne`,`z.object({ ${x} ${S} data: z.union([${v}UpdateInputObjectSchema, ${v}UncheckedUpdateInputObjectSchema]), where: ${v}WhereUniqueInputObjectSchema })`)}`)}if(d){let t=[`import { ${v}UpdateManyMutationInputObjectSchema } from './objects/${v}UpdateManyMutationInput.schema'`,`import { ${v}WhereInputObjectSchema } from './objects/${v}WhereInput.schema'`];await Z(f.default.join(e.outputPath,`schemas/${d}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}UpdateMany`,`z.object({ data: ${v}UpdateManyMutationInputObjectSchema, where: ${v}WhereInputObjectSchema.optional() })`)}`)}if(p){let t=[`import { ${v}UpdateManyAndReturnInputObjectSchema } from './objects/${v}UpdateManyAndReturnInput.schema'`];await Z(f.default.join(e.outputPath,`schemas/${p}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}UpdateManyAndReturn`,`z.object({ data: z.union([ ${v}UpdateManyAndReturnInputObjectSchema, z.array(${v}UpdateManyAndReturnInputObjectSchema) ]), ${e.provider===`mongodb`||e.provider===`sqlserver`?``:`skipDuplicates: z.boolean().optional()`} })`)}`)}if(m){let t=[y,b,`import { ${v}WhereUniqueInputObjectSchema } from './objects/${v}WhereUniqueInput.schema'`,`import { ${v}CreateInputObjectSchema } from './objects/${v}CreateInput.schema'`,`import { ${v}UncheckedCreateInputObjectSchema } from './objects/${v}UncheckedCreateInput.schema'`,`import { ${v}UpdateInputObjectSchema } from './objects/${v}UpdateInput.schema'`,`import { ${v}UncheckedUpdateInputObjectSchema } from './objects/${v}UncheckedUpdateInput.schema'`];await Z(f.default.join(e.outputPath,`schemas/${m}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}Upsert`,`z.object({ ${x} ${S} where: ${v}WhereUniqueInputObjectSchema, create: z.union([ ${v}CreateInputObjectSchema, ${v}UncheckedCreateInputObjectSchema ]), update: z.union([ ${v}UpdateInputObjectSchema, ${v}UncheckedUpdateInputObjectSchema ]) })`)}`)}if(h){let t=[T,`import { ${v}WhereInputObjectSchema } from './objects/${v}WhereInput.schema'`,`import { ${v}WhereUniqueInputObjectSchema } from './objects/${v}WhereUniqueInput.schema'`],n=[];this.aggregateOperationSupport[v]&&(this.aggregateOperationSupport[v].count&&(t.push(`import { ${v}CountAggregateInputObjectSchema } from './objects/${v}CountAggregateInput.schema'`),n.push(`_count: z.union([ z.literal(true), ${v}CountAggregateInputObjectSchema ]).optional()`)),this.aggregateOperationSupport[v].min&&(t.push(`import { ${v}MinAggregateInputObjectSchema } from './objects/${v}MinAggregateInput.schema'`),n.push(`_min: ${v}MinAggregateInputObjectSchema.optional()`)),this.aggregateOperationSupport[v].max&&(t.push(`import { ${v}MaxAggregateInputObjectSchema } from './objects/${v}MaxAggregateInput.schema'`),n.push(`_max: ${v}MaxAggregateInputObjectSchema.optional()`)),this.aggregateOperationSupport[v].avg&&(t.push(`import { ${v}AvgAggregateInputObjectSchema } from './objects/${v}AvgAggregateInput.schema'`),n.push(`_avg: ${v}AvgAggregateInputObjectSchema.optional()`)),this.aggregateOperationSupport[v].sum&&(t.push(`import { ${v}SumAggregateInputObjectSchema } from './objects/${v}SumAggregateInput.schema'`),n.push(`_sum: ${v}SumAggregateInputObjectSchema.optional()`))),await Z(f.default.join(e.outputPath,`schemas/${h}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}Aggregate`,`z.object({ ${E} where: ${v}WhereInputObjectSchema.optional(), cursor: ${v}WhereUniqueInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), ${n.join(`, `)} })`)}`)}if(g){let t=[`import { ${v}WhereInputObjectSchema } from './objects/${v}WhereInput.schema'`,`import { ${v}OrderByWithAggregationInputObjectSchema } from './objects/${v}OrderByWithAggregationInput.schema'`,`import { ${v}ScalarWhereWithAggregatesInputObjectSchema } from './objects/${v}ScalarWhereWithAggregatesInput.schema'`,`import { ${v}ScalarFieldEnumSchema } from './enums/${v}ScalarFieldEnum.schema'`];await Z(f.default.join(e.outputPath,`schemas/${g}.schema.ts`),`${this.generateImportStatements(t)}${this.generateExportSchemaStatement(`${v}GroupBy`,`z.object({ where: ${v}WhereInputObjectSchema.optional(), orderBy: z.union([${v}OrderByWithAggregationInputObjectSchema, ${v}OrderByWithAggregationInputObjectSchema.array()]).optional(), having: ${v}ScalarWhereWithAggregatesInputObjectSchema.optional(), take: z.number().optional(), skip: z.number().optional(), by: z.array(${v}ScalarFieldEnumSchema) })`)}`)}}}generateImportStatements(e){let t=this.generateImportZodStatement();return t+=e?.filter(e=>!!e).join(`;\r
|
|
106
|
+
`)??``,t+=`
|
|
107
|
+
|
|
108
|
+
`,t}resolveSelectIncludeImportAndZodSchemaLine(t){let{name:n}=t,r=R(t),i=e.isGenerateSelect?`import { ${C(n)}SelectObjectSchema } from './objects/${C(n)}Select.schema'`:``,a=e.isGenerateInclude&&r?`import { ${C(n)}IncludeObjectSchema } from './objects/${C(n)}Include.schema'`:``,o=``,s=``,c=``,l=``;if(e.isGenerateSelect){let e=`${C(n)}SelectObjectSchema.optional()`;o=`select: ${e},`,c=`select: z.lazy(() => ${e}),`}if(e.isGenerateInclude&&r){let e=`${C(n)}IncludeObjectSchema.optional()`;s=`include: ${e},`,l=`include: z.lazy(() => ${e}),`}return{selectImport:i,includeImport:a,selectZodSchemaLine:o,includeZodSchemaLine:s,selectZodSchemaLineLazy:c,includeZodSchemaLineLazy:l}}resolveOrderByWithRelationImportAndZodSchemaLine(t){let{name:n}=t,r=``;return r=[`postgresql`,`mysql`].includes(e.provider)&&e.previewFeatures?.includes(`fullTextSearch`)?`${C(n)}OrderByWithRelationAndSearchRelevanceInput`:`${C(n)}OrderByWithRelationInput`,{orderByImport:`import { ${r}ObjectSchema } from './objects/${r}.schema'`,orderByZodSchemaLine:`orderBy: z.union([${r}ObjectSchema, ${r}ObjectSchema.array()]).optional(),`}}};async function lt(e,t){let n=[...e,...t];$.enumNames=n.map(e=>e.name)??[],await new $({enumTypes:n}).generateEnumSchemas()}async function ut(e){for(let t=0;t<e.length;t+=1){let n=e[t]?.fields,r=e[t]?.name;await new $({name:r,fields:n}).generateObjectSchema()}}async function dt(e,t,n){await new $({models:e,modelOperations:t,aggregateOperationSupport:n}).generateModelSchemas()}async function ft(){await $.generateIndex()}function pt(e,t,n){let r=mt(t,n);for(let t of r)e.push(t)}function mt(e,t){let n=[];for(let r of e){let{name:e,fields:i}=r,a=[];for(let e of i){let{name:t,isList:n,type:r}=e;if(B(e)){let e={name:t,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`},{isList:!1,type:n?`${r}FindManyArgs`:`${r}DefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`}]};a.push(e)}}if(!R(r))continue;if(z(r)){let n=[{isList:!1,type:`Boolean`,location:`scalar`}];t&&n.push({isList:!1,type:`${e}CountOutputTypeDefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`});let r={name:`_count`,isRequired:!1,isNullable:!1,inputTypes:n};a.push(r)}let o={name:`${e}Include`,constraints:{maxNumFields:null,minNumFields:null},fields:a};n.push(o)}return n}function ht(e,t,n,r){let i=gt(t,n,r);for(let t of i)e.push(t)}function gt(e,t,n){let r=[];for(let i of e){let{name:e}=i,a=[];if(t){let t={name:`select`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`${e}Select`,location:`inputObjectTypes`,namespace:`prisma`}]};a.push(t)}let o=R(i);if(n&&o){let t={name:`include`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`${e}Include`,location:`inputObjectTypes`,namespace:`prisma`}]};a.push(t)}let s={name:`${e}DefaultArgs`,constraints:{maxNumFields:null,minNumFields:null},fields:a};r.push(s)}return r}function _t(e,t,n){let r=vt(t),i=[yt(r),bt(r),xt(n)].flat();for(let t of i)e.push(t)}function vt(e){return e.filter(({name:e})=>e.includes(`CountOutputType`))}function yt(e){let t=[];for(let n of e){let{name:e,fields:r}=n,i={name:`${e}Select`,constraints:{maxNumFields:null,minNumFields:null},fields:r.map(({name:e})=>({name:e,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`}]}))};t.push(i)}return t}function bt(e){let t=[];for(let n of e){let{name:e}=n,r={name:`${e}DefaultArgs`,constraints:{maxNumFields:null,minNumFields:null},fields:[{name:`select`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`${e}Select`,location:`inputObjectTypes`,namespace:`prisma`}]}]};t.push(r)}return t}function xt(e){let t=[];for(let n of e){let{name:e,fields:r}=n,i=[];for(let e of r){let{name:t,isList:n,type:r}=e,a=B(e),o={name:t,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`}]};if(a){let e={isList:!1,type:n?`${r}FindManyArgs`:`${r}DefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`};o.inputTypes.push(e)}i.push(o)}if(z(n)){let t={name:`_count`,isRequired:!1,isNullable:!1,inputTypes:[{isList:!1,type:`Boolean`,location:`scalar`},{isList:!1,type:`${e}CountOutputTypeDefaultArgs`,location:`inputObjectTypes`,namespace:`prisma`}]};i.push(t)}let a={name:`${e}Select`,constraints:{maxNumFields:null,minNumFields:null},fields:i};t.push(a)}return t}function St(e){e.map(e=>(e.name.includes(`WhereUniqueInput`)&&e.constraints.fields?.length>0&&(e.fields=e.fields.map(t=>(e.constraints.fields?.includes(t.name)&&(t.isRequired=!0),t))),e))}function Ct(e,t,n,r,i,a){i===`mongodb`&&it(r,t,e),qe(e,t),a.isGenerateSelect&&(_t(e,t,n),$.setIsGenerateSelect(!0)),(a.isGenerateSelect||a.isGenerateInclude)&&ht(e,n,a.isGenerateSelect,a.isGenerateInclude),a.isGenerateInclude&&(pt(e,n,a.isGenerateSelect),$.setIsGenerateInclude(!0)),St(e)}async function wt(e){console.log(`[STORM]: Running the Storm Software - Prisma tRPC generator
|
|
109
|
+
`);let t=await F();console.log(`[STORM]: Validating configuration options
|
|
110
|
+
`);let n=t.parseEnvValue(e.generator.output),r=await te.safeParseAsync(e.generator.config);if(!r.success)throw Error(`Invalid options passed`);let i=r.data,a=e=>{i.debug&&console.log(`[STORM]: ${e} \n`)};a(`Using configuration parameters: \n${JSON.stringify(i)}`),a(`Preparing output directory: ${n}`),await(0,u.removeDirectory)(n),await(0,u.createDirectory)(n),a(`Finding Prisma Client generator`);let o=e.otherGenerators.find(e=>t.parseEnvValue(e.provider)===`prisma-client-js`);if(!o)throw Error("No Prisma Client generator found. Please add `prisma-client-js` to your generator list.");a(`Generating Prisma Client DMMF`);let s=await t.getDMMF({datamodel:e.datamodel,previewFeatures:o?.previewFeatures}),c=s.mappings.modelOperations,p=s.schema.inputObjectTypes.prisma,m=s.schema.outputObjectTypes.prisma,h=s.schema.enumTypes,g=s.datamodel.models,_=[],v=[];if(i.withZod!==!1){a(`Generating Zod schemas`);let n=t.parseEnvValue(e.generator.output);await(0,u.createDirectory)(n),$.setOutputPath(n),o?.isCustomOutput&&$.setPrismaClientOutputPath(o.output?.value),await He(g,(0,d.joinPaths)(n,`schemas`,`models`),i,e),Qe(g,c,h,_,v),await lt(h.prisma,h.model);let r=e.datasources?.[0];if(!r)throw Error(`No datasource found`);let s=o?.previewFeatures;$.provider=r.provider,$.previewFeatures=s,Ct(p,m,g,c,r.provider,{isGenerateSelect:!0,isGenerateInclude:!0});let l=Je(p);rt(p,_,v),await ut(p),await dt(g,c,l),await ft()}else a(`Skipping Zod schemas generation`);let y=[],b=[],x=[];s.mappings.modelOperations.forEach(e=>{let{model:t,plural:n,...r}=e;for(let[e,t]of Object.entries(r))[`findUnique`,`findUniqueOrThrow`,`findFirst`,`findFirstOrThrow`,`findRaw`,`findMany`,`aggregateRaw`,`count`,`aggregate`,`groupBy`].includes(e)&&y.push(t),[`createOne`,`createMany`,`createManyAndReturn`,`deleteOne`,`deleteMany`,`updateOne`,`updateMany`,`updateManyAndReturn`,`upsertOne`].includes(e)&&b.push(t)}),y.sort(),b.sort(),x.sort(),i.withShield&&!(typeof i.withShield==`string`&&((0,l.existsSync)((0,d.joinPaths)(n,i.withShield))||(0,l.existsSync)((0,d.joinPaths)(n,`./${i.withShield}.ts`))||(0,l.existsSync)((0,d.joinPaths)(n,i.withShield,`./shield.ts`))))?(a(`Generating tRPC Shield source file to ${n}`),await Z((0,d.joinPaths)(n,`./shield.ts`),await Be({queries:y,mutations:b,subscriptions:x},i,e,n))):a(`Skipping tRPC Shield generation`),a(`Generating tRPC source code for ${g.length} models`),i.trpcOptions&&typeof i.trpcOptions==`boolean`&&(a(`Generating tRPC options source file to ${n}`),await Z((0,d.joinPaths)(n,`./options.ts`),Ve(i,e,n))),Le(g,_),a(`Generating tRPC export file`),await Me(O.createSourceFile(f.default.resolve(n,`trpc.ts`),void 0,{overwrite:!0}),i,e,n),a(`Generating tRPC app router`);let S=O.createSourceFile(f.default.resolve(n,`routers`,`index.ts`),void 0,{overwrite:!0});a(`Generating tRPC router imports`),K({sourceFile:S});let w=[];for(let e of c){let{model:t,...r}=e;if(_.includes(t)){a(`Skipping model ${t} as it is hidden`);continue}if(!t){a(`Skipping model ${t} as it is not defined`);continue}let o=Object.keys(r).filter(e=>i.generateModelActions.some(t=>t===e.replace(`One`,``)));if(!o.length){a(`Skipping model ${t} as it has no actions to generate`);continue}let s=(0,ee.default)(C(t));a(`Generating tRPC router for model ${t}`),je(S,s,t);let c=O.createSourceFile(f.default.resolve(n,`routers`,`${C(t)}.router.ts`),void 0,{overwrite:!0});K({sourceFile:c,config:i}),i.withZod&&(a(`Generating Zod schemas imports`),Pe(c,t,o)),c.addStatements(`
|
|
111
|
+
export const ${s}Router = t.router({`);for(let e of o){let n=r[e];if(n){let r=e.replace(`OrThrow`,``);Ne(c,n,q(r,t),t,e,r,i)}}c.addStatements(`
|
|
112
|
+
})`),c.formatText({indentSize:2}),w.push(`
|
|
113
|
+
${C(t)}: ${s}Router`),a(`Generated tRPC router for model ${t} with ${o.length} actions`)}a(`Generating tRPC app router`),S.addStatements(`
|
|
114
|
+
export const appRouter = t.router({${w.join()}});
|
|
115
|
+
|
|
116
|
+
export type AppRouter = typeof appRouter;`),S.formatText({indentSize:2}),a(`Saving tRPC router source files to disk`),await O.save(),a(`Storm Software - Prisma tRPC generator completed successfully`)}ve().then(e=>{e.generatorHandler({onManifest:()=>({defaultOutput:`./generated`,prettyName:`Storm Software - Prisma tRPC Generator`,requiresGenerators:[`prisma-client-js`]}),onGenerate:wt})}).catch(e=>{console.error(`An error occured while generating prisma tRPC source code: ${e}`)});
|