@nonsoo/prisma-mermaid 0.1.0
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/LICENSE +21 -0
- package/README.md +65 -0
- package/build/index.cjs +383 -0
- package/build/index.d.cts +63 -0
- package/build/index.d.ts +63 -0
- package/build/index.js +345 -0
- package/build/lib/PrismaMermaidGenerators/bin.cjs +1844 -0
- package/build/lib/PrismaMermaidGenerators/bin.d.cts +1 -0
- package/build/lib/PrismaMermaidGenerators/bin.d.ts +1 -0
- package/build/lib/PrismaMermaidGenerators/bin.js +1849 -0
- package/package.json +74 -0
|
@@ -0,0 +1,1844 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
|
|
29
|
+
// node_modules/@prisma/generator-helper/dist/chunk-EOPVK4AE.js
|
|
30
|
+
var require_chunk_EOPVK4AE = __commonJS({
|
|
31
|
+
"node_modules/@prisma/generator-helper/dist/chunk-EOPVK4AE.js"(exports2, module2) {
|
|
32
|
+
"use strict";
|
|
33
|
+
var __create2 = Object.create;
|
|
34
|
+
var __defProp2 = Object.defineProperty;
|
|
35
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
36
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
37
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
38
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
39
|
+
var __export = (target, all) => {
|
|
40
|
+
for (var name in all)
|
|
41
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
42
|
+
};
|
|
43
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
44
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
45
|
+
for (let key of __getOwnPropNames2(from))
|
|
46
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
47
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
48
|
+
}
|
|
49
|
+
return to;
|
|
50
|
+
};
|
|
51
|
+
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
|
|
52
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
53
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
54
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
55
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
56
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
|
|
57
|
+
mod
|
|
58
|
+
));
|
|
59
|
+
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
60
|
+
var chunk_EOPVK4AE_exports = {};
|
|
61
|
+
__export(chunk_EOPVK4AE_exports, {
|
|
62
|
+
LineStream: () => LineStream,
|
|
63
|
+
byline: () => byline,
|
|
64
|
+
createLineStream: () => createLineStream,
|
|
65
|
+
createStream: () => createStream
|
|
66
|
+
});
|
|
67
|
+
module2.exports = __toCommonJS(chunk_EOPVK4AE_exports);
|
|
68
|
+
var import_stream = __toESM2(require("stream"));
|
|
69
|
+
var import_util = __toESM2(require("util"));
|
|
70
|
+
function byline(readStream, options) {
|
|
71
|
+
return createStream(readStream, options);
|
|
72
|
+
}
|
|
73
|
+
function createStream(readStream, options) {
|
|
74
|
+
if (readStream) {
|
|
75
|
+
return createLineStream(readStream, options);
|
|
76
|
+
} else {
|
|
77
|
+
return new LineStream(options);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function createLineStream(readStream, options) {
|
|
81
|
+
if (!readStream) {
|
|
82
|
+
throw new Error("expected readStream");
|
|
83
|
+
}
|
|
84
|
+
if (!readStream.readable) {
|
|
85
|
+
throw new Error("readStream must be readable");
|
|
86
|
+
}
|
|
87
|
+
const ls = new LineStream(options);
|
|
88
|
+
readStream.pipe(ls);
|
|
89
|
+
return ls;
|
|
90
|
+
}
|
|
91
|
+
function LineStream(options) {
|
|
92
|
+
import_stream.default.Transform.call(this, options);
|
|
93
|
+
options = options || {};
|
|
94
|
+
this._readableState.objectMode = true;
|
|
95
|
+
this._lineBuffer = [];
|
|
96
|
+
this._keepEmptyLines = options.keepEmptyLines || false;
|
|
97
|
+
this._lastChunkEndedWithCR = false;
|
|
98
|
+
this.on("pipe", function(src) {
|
|
99
|
+
if (!this.encoding) {
|
|
100
|
+
if (src instanceof import_stream.default.Readable) {
|
|
101
|
+
this.encoding = src._readableState.encoding;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
import_util.default.inherits(LineStream, import_stream.default.Transform);
|
|
107
|
+
LineStream.prototype._transform = function(chunk, encoding, done) {
|
|
108
|
+
encoding = encoding || "utf8";
|
|
109
|
+
if (Buffer.isBuffer(chunk)) {
|
|
110
|
+
if (encoding == "buffer") {
|
|
111
|
+
chunk = chunk.toString();
|
|
112
|
+
encoding = "utf8";
|
|
113
|
+
} else {
|
|
114
|
+
chunk = chunk.toString(encoding);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
this._chunkEncoding = encoding;
|
|
118
|
+
const lines = chunk.split(/\r\n|\r|\n/g);
|
|
119
|
+
if (this._lastChunkEndedWithCR && chunk[0] == "\n") {
|
|
120
|
+
lines.shift();
|
|
121
|
+
}
|
|
122
|
+
if (this._lineBuffer.length > 0) {
|
|
123
|
+
this._lineBuffer[this._lineBuffer.length - 1] += lines[0];
|
|
124
|
+
lines.shift();
|
|
125
|
+
}
|
|
126
|
+
this._lastChunkEndedWithCR = chunk[chunk.length - 1] == "\r";
|
|
127
|
+
this._lineBuffer = this._lineBuffer.concat(lines);
|
|
128
|
+
this._pushBuffer(encoding, 1, done);
|
|
129
|
+
};
|
|
130
|
+
LineStream.prototype._pushBuffer = function(encoding, keep, done) {
|
|
131
|
+
while (this._lineBuffer.length > keep) {
|
|
132
|
+
const line = this._lineBuffer.shift();
|
|
133
|
+
if (this._keepEmptyLines || line.length > 0) {
|
|
134
|
+
if (!this.push(this._reencode(line, encoding))) {
|
|
135
|
+
const self = this;
|
|
136
|
+
setImmediate(function() {
|
|
137
|
+
self._pushBuffer(encoding, keep, done);
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
done();
|
|
144
|
+
};
|
|
145
|
+
LineStream.prototype._flush = function(done) {
|
|
146
|
+
this._pushBuffer(this._chunkEncoding, 0, done);
|
|
147
|
+
};
|
|
148
|
+
LineStream.prototype._reencode = function(line, chunkEncoding) {
|
|
149
|
+
if (this.encoding && this.encoding != chunkEncoding) {
|
|
150
|
+
return Buffer.from(line, chunkEncoding).toString(this.encoding);
|
|
151
|
+
} else if (this.encoding) {
|
|
152
|
+
return line;
|
|
153
|
+
} else {
|
|
154
|
+
return Buffer.from(line, chunkEncoding);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// node_modules/@prisma/generator-helper/dist/chunk-KEYE2GFS.js
|
|
161
|
+
var require_chunk_KEYE2GFS = __commonJS({
|
|
162
|
+
"node_modules/@prisma/generator-helper/dist/chunk-KEYE2GFS.js"(exports2, module2) {
|
|
163
|
+
"use strict";
|
|
164
|
+
var __defProp2 = Object.defineProperty;
|
|
165
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
166
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
167
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
168
|
+
var __export = (target, all) => {
|
|
169
|
+
for (var name in all)
|
|
170
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
171
|
+
};
|
|
172
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
173
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
174
|
+
for (let key of __getOwnPropNames2(from))
|
|
175
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
176
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
177
|
+
}
|
|
178
|
+
return to;
|
|
179
|
+
};
|
|
180
|
+
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
181
|
+
var chunk_KEYE2GFS_exports = {};
|
|
182
|
+
__export(chunk_KEYE2GFS_exports, {
|
|
183
|
+
isErrorResponse: () => isErrorResponse
|
|
184
|
+
});
|
|
185
|
+
module2.exports = __toCommonJS(chunk_KEYE2GFS_exports);
|
|
186
|
+
function isErrorResponse(response) {
|
|
187
|
+
return response.error !== void 0;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// node_modules/@prisma/generator-helper/dist/chunk-QGM4M3NI.js
|
|
193
|
+
var require_chunk_QGM4M3NI = __commonJS({
|
|
194
|
+
"node_modules/@prisma/generator-helper/dist/chunk-QGM4M3NI.js"(exports2, module2) {
|
|
195
|
+
"use strict";
|
|
196
|
+
var __defProp2 = Object.defineProperty;
|
|
197
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
198
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
199
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
200
|
+
var __export = (target, all) => {
|
|
201
|
+
for (var name in all)
|
|
202
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
203
|
+
};
|
|
204
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
205
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
206
|
+
for (let key of __getOwnPropNames2(from))
|
|
207
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
208
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
209
|
+
}
|
|
210
|
+
return to;
|
|
211
|
+
};
|
|
212
|
+
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
213
|
+
var chunk_QGM4M3NI_exports = {};
|
|
214
|
+
__export(chunk_QGM4M3NI_exports, {
|
|
215
|
+
__commonJS: () => __commonJS2,
|
|
216
|
+
__require: () => __require,
|
|
217
|
+
__toESM: () => __toESM2
|
|
218
|
+
});
|
|
219
|
+
module2.exports = __toCommonJS(chunk_QGM4M3NI_exports);
|
|
220
|
+
var __create2 = Object.create;
|
|
221
|
+
var __defProp22 = Object.defineProperty;
|
|
222
|
+
var __getOwnPropDesc22 = Object.getOwnPropertyDescriptor;
|
|
223
|
+
var __getOwnPropNames22 = Object.getOwnPropertyNames;
|
|
224
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
225
|
+
var __hasOwnProp22 = Object.prototype.hasOwnProperty;
|
|
226
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
227
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
228
|
+
}) : x)(function(x) {
|
|
229
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
230
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
231
|
+
});
|
|
232
|
+
var __commonJS2 = (cb, mod) => function __require2() {
|
|
233
|
+
return mod || (0, cb[__getOwnPropNames22(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
234
|
+
};
|
|
235
|
+
var __copyProps22 = (to, from, except, desc) => {
|
|
236
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
237
|
+
for (let key of __getOwnPropNames22(from))
|
|
238
|
+
if (!__hasOwnProp22.call(to, key) && key !== except)
|
|
239
|
+
__defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc22(from, key)) || desc.enumerable });
|
|
240
|
+
}
|
|
241
|
+
return to;
|
|
242
|
+
};
|
|
243
|
+
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps22(
|
|
244
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
245
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
246
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
247
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
248
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp22(target, "default", { value: mod, enumerable: true }) : target,
|
|
249
|
+
mod
|
|
250
|
+
));
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// node_modules/@prisma/debug/dist/index.js
|
|
255
|
+
var require_dist = __commonJS({
|
|
256
|
+
"node_modules/@prisma/debug/dist/index.js"(exports2, module2) {
|
|
257
|
+
"use strict";
|
|
258
|
+
var __defProp2 = Object.defineProperty;
|
|
259
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
260
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
261
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
262
|
+
var __export = (target, all) => {
|
|
263
|
+
for (var name in all)
|
|
264
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
265
|
+
};
|
|
266
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
267
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
268
|
+
for (let key of __getOwnPropNames2(from))
|
|
269
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
270
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
271
|
+
}
|
|
272
|
+
return to;
|
|
273
|
+
};
|
|
274
|
+
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
275
|
+
var index_exports = {};
|
|
276
|
+
__export(index_exports, {
|
|
277
|
+
Debug: () => Debug,
|
|
278
|
+
clearLogs: () => clearLogs,
|
|
279
|
+
default: () => index_default,
|
|
280
|
+
getLogs: () => getLogs
|
|
281
|
+
});
|
|
282
|
+
module2.exports = __toCommonJS(index_exports);
|
|
283
|
+
var colors_exports = {};
|
|
284
|
+
__export(colors_exports, {
|
|
285
|
+
$: () => $,
|
|
286
|
+
bgBlack: () => bgBlack,
|
|
287
|
+
bgBlue: () => bgBlue,
|
|
288
|
+
bgCyan: () => bgCyan,
|
|
289
|
+
bgGreen: () => bgGreen,
|
|
290
|
+
bgMagenta: () => bgMagenta,
|
|
291
|
+
bgRed: () => bgRed,
|
|
292
|
+
bgWhite: () => bgWhite,
|
|
293
|
+
bgYellow: () => bgYellow,
|
|
294
|
+
black: () => black,
|
|
295
|
+
blue: () => blue,
|
|
296
|
+
bold: () => bold,
|
|
297
|
+
cyan: () => cyan,
|
|
298
|
+
dim: () => dim,
|
|
299
|
+
gray: () => gray,
|
|
300
|
+
green: () => green,
|
|
301
|
+
grey: () => grey,
|
|
302
|
+
hidden: () => hidden,
|
|
303
|
+
inverse: () => inverse,
|
|
304
|
+
italic: () => italic,
|
|
305
|
+
magenta: () => magenta,
|
|
306
|
+
red: () => red,
|
|
307
|
+
reset: () => reset,
|
|
308
|
+
strikethrough: () => strikethrough,
|
|
309
|
+
underline: () => underline,
|
|
310
|
+
white: () => white,
|
|
311
|
+
yellow: () => yellow
|
|
312
|
+
});
|
|
313
|
+
var FORCE_COLOR;
|
|
314
|
+
var NODE_DISABLE_COLORS;
|
|
315
|
+
var NO_COLOR;
|
|
316
|
+
var TERM;
|
|
317
|
+
var isTTY = true;
|
|
318
|
+
if (typeof process !== "undefined") {
|
|
319
|
+
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
|
|
320
|
+
isTTY = process.stdout && process.stdout.isTTY;
|
|
321
|
+
}
|
|
322
|
+
var $ = {
|
|
323
|
+
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY)
|
|
324
|
+
};
|
|
325
|
+
function init(x, y) {
|
|
326
|
+
let rgx = new RegExp(`\\x1b\\[${y}m`, "g");
|
|
327
|
+
let open = `\x1B[${x}m`, close = `\x1B[${y}m`;
|
|
328
|
+
return function(txt) {
|
|
329
|
+
if (!$.enabled || txt == null) return txt;
|
|
330
|
+
return open + (!!~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
var reset = init(0, 0);
|
|
334
|
+
var bold = init(1, 22);
|
|
335
|
+
var dim = init(2, 22);
|
|
336
|
+
var italic = init(3, 23);
|
|
337
|
+
var underline = init(4, 24);
|
|
338
|
+
var inverse = init(7, 27);
|
|
339
|
+
var hidden = init(8, 28);
|
|
340
|
+
var strikethrough = init(9, 29);
|
|
341
|
+
var black = init(30, 39);
|
|
342
|
+
var red = init(31, 39);
|
|
343
|
+
var green = init(32, 39);
|
|
344
|
+
var yellow = init(33, 39);
|
|
345
|
+
var blue = init(34, 39);
|
|
346
|
+
var magenta = init(35, 39);
|
|
347
|
+
var cyan = init(36, 39);
|
|
348
|
+
var white = init(37, 39);
|
|
349
|
+
var gray = init(90, 39);
|
|
350
|
+
var grey = init(90, 39);
|
|
351
|
+
var bgBlack = init(40, 49);
|
|
352
|
+
var bgRed = init(41, 49);
|
|
353
|
+
var bgGreen = init(42, 49);
|
|
354
|
+
var bgYellow = init(43, 49);
|
|
355
|
+
var bgBlue = init(44, 49);
|
|
356
|
+
var bgMagenta = init(45, 49);
|
|
357
|
+
var bgCyan = init(46, 49);
|
|
358
|
+
var bgWhite = init(47, 49);
|
|
359
|
+
var MAX_ARGS_HISTORY = 100;
|
|
360
|
+
var COLORS = ["green", "yellow", "blue", "magenta", "cyan", "red"];
|
|
361
|
+
var argsHistory = [];
|
|
362
|
+
var lastTimestamp = Date.now();
|
|
363
|
+
var lastColor = 0;
|
|
364
|
+
var processEnv = typeof process !== "undefined" ? process.env : {};
|
|
365
|
+
globalThis.DEBUG ??= processEnv.DEBUG ?? "";
|
|
366
|
+
globalThis.DEBUG_COLORS ??= processEnv.DEBUG_COLORS ? processEnv.DEBUG_COLORS === "true" : true;
|
|
367
|
+
var topProps = {
|
|
368
|
+
enable(namespace) {
|
|
369
|
+
if (typeof namespace === "string") {
|
|
370
|
+
globalThis.DEBUG = namespace;
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
disable() {
|
|
374
|
+
const prev = globalThis.DEBUG;
|
|
375
|
+
globalThis.DEBUG = "";
|
|
376
|
+
return prev;
|
|
377
|
+
},
|
|
378
|
+
// this is the core logic to check if logging should happen or not
|
|
379
|
+
enabled(namespace) {
|
|
380
|
+
const listenedNamespaces = globalThis.DEBUG.split(",").map((s) => {
|
|
381
|
+
return s.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
382
|
+
});
|
|
383
|
+
const isListened = listenedNamespaces.some((listenedNamespace) => {
|
|
384
|
+
if (listenedNamespace === "" || listenedNamespace[0] === "-") return false;
|
|
385
|
+
return namespace.match(RegExp(listenedNamespace.split("*").join(".*") + "$"));
|
|
386
|
+
});
|
|
387
|
+
const isExcluded = listenedNamespaces.some((listenedNamespace) => {
|
|
388
|
+
if (listenedNamespace === "" || listenedNamespace[0] !== "-") return false;
|
|
389
|
+
return namespace.match(RegExp(listenedNamespace.slice(1).split("*").join(".*") + "$"));
|
|
390
|
+
});
|
|
391
|
+
return isListened && !isExcluded;
|
|
392
|
+
},
|
|
393
|
+
log: (...args) => {
|
|
394
|
+
const [namespace, format, ...rest] = args;
|
|
395
|
+
const logWithFormatting = console.warn ?? console.log;
|
|
396
|
+
logWithFormatting(`${namespace} ${format}`, ...rest);
|
|
397
|
+
},
|
|
398
|
+
formatters: {}
|
|
399
|
+
// not implemented
|
|
400
|
+
};
|
|
401
|
+
function debugCreate(namespace) {
|
|
402
|
+
const instanceProps = {
|
|
403
|
+
color: COLORS[lastColor++ % COLORS.length],
|
|
404
|
+
enabled: topProps.enabled(namespace),
|
|
405
|
+
namespace,
|
|
406
|
+
log: topProps.log,
|
|
407
|
+
extend: () => {
|
|
408
|
+
}
|
|
409
|
+
// not implemented
|
|
410
|
+
};
|
|
411
|
+
const debugCall = (...args) => {
|
|
412
|
+
const { enabled, namespace: namespace2, color, log } = instanceProps;
|
|
413
|
+
if (args.length !== 0) {
|
|
414
|
+
argsHistory.push([namespace2, ...args]);
|
|
415
|
+
}
|
|
416
|
+
if (argsHistory.length > MAX_ARGS_HISTORY) {
|
|
417
|
+
argsHistory.shift();
|
|
418
|
+
}
|
|
419
|
+
if (topProps.enabled(namespace2) || enabled) {
|
|
420
|
+
const stringArgs = args.map((arg) => {
|
|
421
|
+
if (typeof arg === "string") {
|
|
422
|
+
return arg;
|
|
423
|
+
}
|
|
424
|
+
return safeStringify(arg);
|
|
425
|
+
});
|
|
426
|
+
const ms = `+${Date.now() - lastTimestamp}ms`;
|
|
427
|
+
lastTimestamp = Date.now();
|
|
428
|
+
if (globalThis.DEBUG_COLORS) {
|
|
429
|
+
log(colors_exports[color](bold(namespace2)), ...stringArgs, colors_exports[color](ms));
|
|
430
|
+
} else {
|
|
431
|
+
log(namespace2, ...stringArgs, ms);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
return new Proxy(debugCall, {
|
|
436
|
+
get: (_, prop) => instanceProps[prop],
|
|
437
|
+
set: (_, prop, value) => instanceProps[prop] = value
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
var Debug = new Proxy(debugCreate, {
|
|
441
|
+
get: (_, prop) => topProps[prop],
|
|
442
|
+
set: (_, prop, value) => topProps[prop] = value
|
|
443
|
+
});
|
|
444
|
+
function safeStringify(value, indent = 2) {
|
|
445
|
+
const cache = /* @__PURE__ */ new Set();
|
|
446
|
+
return JSON.stringify(
|
|
447
|
+
value,
|
|
448
|
+
(key, value2) => {
|
|
449
|
+
if (typeof value2 === "object" && value2 !== null) {
|
|
450
|
+
if (cache.has(value2)) {
|
|
451
|
+
return `[Circular *]`;
|
|
452
|
+
}
|
|
453
|
+
cache.add(value2);
|
|
454
|
+
} else if (typeof value2 === "bigint") {
|
|
455
|
+
return value2.toString();
|
|
456
|
+
}
|
|
457
|
+
return value2;
|
|
458
|
+
},
|
|
459
|
+
indent
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
function getLogs(numChars = 7500) {
|
|
463
|
+
const logs = argsHistory.map(([namespace, ...args]) => {
|
|
464
|
+
return `${namespace} ${args.map((arg) => {
|
|
465
|
+
if (typeof arg === "string") {
|
|
466
|
+
return arg;
|
|
467
|
+
} else {
|
|
468
|
+
return JSON.stringify(arg);
|
|
469
|
+
}
|
|
470
|
+
}).join(" ")}`;
|
|
471
|
+
}).join("\n");
|
|
472
|
+
if (logs.length < numChars) {
|
|
473
|
+
return logs;
|
|
474
|
+
}
|
|
475
|
+
return logs.slice(-numChars);
|
|
476
|
+
}
|
|
477
|
+
function clearLogs() {
|
|
478
|
+
argsHistory.length = 0;
|
|
479
|
+
}
|
|
480
|
+
var index_default = Debug;
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
// node_modules/@prisma/generator-helper/dist/chunk-MXZE5TCU.js
|
|
485
|
+
var require_chunk_MXZE5TCU = __commonJS({
|
|
486
|
+
"node_modules/@prisma/generator-helper/dist/chunk-MXZE5TCU.js"(exports2, module2) {
|
|
487
|
+
"use strict";
|
|
488
|
+
var __defProp2 = Object.defineProperty;
|
|
489
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
490
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
491
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
492
|
+
var __export = (target, all) => {
|
|
493
|
+
for (var name in all)
|
|
494
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
495
|
+
};
|
|
496
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
497
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
498
|
+
for (let key of __getOwnPropNames2(from))
|
|
499
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
500
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
501
|
+
}
|
|
502
|
+
return to;
|
|
503
|
+
};
|
|
504
|
+
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
505
|
+
var chunk_MXZE5TCU_exports = {};
|
|
506
|
+
__export(chunk_MXZE5TCU_exports, {
|
|
507
|
+
GeneratorError: () => GeneratorError,
|
|
508
|
+
GeneratorProcess: () => GeneratorProcess
|
|
509
|
+
});
|
|
510
|
+
module2.exports = __toCommonJS(chunk_MXZE5TCU_exports);
|
|
511
|
+
var import_chunk_EOPVK4AE = require_chunk_EOPVK4AE();
|
|
512
|
+
var import_chunk_KEYE2GFS = require_chunk_KEYE2GFS();
|
|
513
|
+
var import_chunk_QGM4M3NI = require_chunk_QGM4M3NI();
|
|
514
|
+
var import_node_child_process = require("child_process");
|
|
515
|
+
var import_debug = require_dist();
|
|
516
|
+
var require_windows = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
517
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports3, module22) {
|
|
518
|
+
"use strict";
|
|
519
|
+
module22.exports = isexe;
|
|
520
|
+
isexe.sync = sync;
|
|
521
|
+
var fs = (0, import_chunk_QGM4M3NI.__require)("fs");
|
|
522
|
+
function checkPathExt(path3, options) {
|
|
523
|
+
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
524
|
+
if (!pathext) {
|
|
525
|
+
return true;
|
|
526
|
+
}
|
|
527
|
+
pathext = pathext.split(";");
|
|
528
|
+
if (pathext.indexOf("") !== -1) {
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
532
|
+
var p = pathext[i].toLowerCase();
|
|
533
|
+
if (p && path3.substr(-p.length).toLowerCase() === p) {
|
|
534
|
+
return true;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
function checkStat(stat, path3, options) {
|
|
540
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
return checkPathExt(path3, options);
|
|
544
|
+
}
|
|
545
|
+
function isexe(path3, options, cb) {
|
|
546
|
+
fs.stat(path3, function(er, stat) {
|
|
547
|
+
cb(er, er ? false : checkStat(stat, path3, options));
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
function sync(path3, options) {
|
|
551
|
+
return checkStat(fs.statSync(path3), path3, options);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
var require_mode = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
556
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports3, module22) {
|
|
557
|
+
"use strict";
|
|
558
|
+
module22.exports = isexe;
|
|
559
|
+
isexe.sync = sync;
|
|
560
|
+
var fs = (0, import_chunk_QGM4M3NI.__require)("fs");
|
|
561
|
+
function isexe(path3, options, cb) {
|
|
562
|
+
fs.stat(path3, function(er, stat) {
|
|
563
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
function sync(path3, options) {
|
|
567
|
+
return checkStat(fs.statSync(path3), options);
|
|
568
|
+
}
|
|
569
|
+
function checkStat(stat, options) {
|
|
570
|
+
return stat.isFile() && checkMode(stat, options);
|
|
571
|
+
}
|
|
572
|
+
function checkMode(stat, options) {
|
|
573
|
+
var mod = stat.mode;
|
|
574
|
+
var uid = stat.uid;
|
|
575
|
+
var gid = stat.gid;
|
|
576
|
+
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
577
|
+
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
578
|
+
var u = parseInt("100", 8);
|
|
579
|
+
var g = parseInt("010", 8);
|
|
580
|
+
var o = parseInt("001", 8);
|
|
581
|
+
var ug = u | g;
|
|
582
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
583
|
+
return ret;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
var require_isexe = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
588
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports3, module22) {
|
|
589
|
+
"use strict";
|
|
590
|
+
var fs = (0, import_chunk_QGM4M3NI.__require)("fs");
|
|
591
|
+
var core;
|
|
592
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
593
|
+
core = require_windows();
|
|
594
|
+
} else {
|
|
595
|
+
core = require_mode();
|
|
596
|
+
}
|
|
597
|
+
module22.exports = isexe;
|
|
598
|
+
isexe.sync = sync;
|
|
599
|
+
function isexe(path3, options, cb) {
|
|
600
|
+
if (typeof options === "function") {
|
|
601
|
+
cb = options;
|
|
602
|
+
options = {};
|
|
603
|
+
}
|
|
604
|
+
if (!cb) {
|
|
605
|
+
if (typeof Promise !== "function") {
|
|
606
|
+
throw new TypeError("callback not provided");
|
|
607
|
+
}
|
|
608
|
+
return new Promise(function(resolve, reject) {
|
|
609
|
+
isexe(path3, options || {}, function(er, is) {
|
|
610
|
+
if (er) {
|
|
611
|
+
reject(er);
|
|
612
|
+
} else {
|
|
613
|
+
resolve(is);
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
core(path3, options || {}, function(er, is) {
|
|
619
|
+
if (er) {
|
|
620
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
621
|
+
er = null;
|
|
622
|
+
is = false;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
cb(er, is);
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
function sync(path3, options) {
|
|
629
|
+
try {
|
|
630
|
+
return core.sync(path3, options || {});
|
|
631
|
+
} catch (er) {
|
|
632
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
633
|
+
return false;
|
|
634
|
+
} else {
|
|
635
|
+
throw er;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
var require_which = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
642
|
+
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports3, module22) {
|
|
643
|
+
"use strict";
|
|
644
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
645
|
+
var path3 = (0, import_chunk_QGM4M3NI.__require)("path");
|
|
646
|
+
var COLON = isWindows ? ";" : ":";
|
|
647
|
+
var isexe = require_isexe();
|
|
648
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
649
|
+
var getPathInfo = (cmd, opt) => {
|
|
650
|
+
const colon = opt.colon || COLON;
|
|
651
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
652
|
+
// windows always checks the cwd first
|
|
653
|
+
...isWindows ? [process.cwd()] : [],
|
|
654
|
+
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
|
|
655
|
+
"").split(colon)
|
|
656
|
+
];
|
|
657
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
658
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
659
|
+
if (isWindows) {
|
|
660
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
661
|
+
pathExt.unshift("");
|
|
662
|
+
}
|
|
663
|
+
return {
|
|
664
|
+
pathEnv,
|
|
665
|
+
pathExt,
|
|
666
|
+
pathExtExe
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
var which = (cmd, opt, cb) => {
|
|
670
|
+
if (typeof opt === "function") {
|
|
671
|
+
cb = opt;
|
|
672
|
+
opt = {};
|
|
673
|
+
}
|
|
674
|
+
if (!opt)
|
|
675
|
+
opt = {};
|
|
676
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
677
|
+
const found = [];
|
|
678
|
+
const step = (i) => new Promise((resolve, reject) => {
|
|
679
|
+
if (i === pathEnv.length)
|
|
680
|
+
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
681
|
+
const ppRaw = pathEnv[i];
|
|
682
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
683
|
+
const pCmd = path3.join(pathPart, cmd);
|
|
684
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
685
|
+
resolve(subStep(p, i, 0));
|
|
686
|
+
});
|
|
687
|
+
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
688
|
+
if (ii === pathExt.length)
|
|
689
|
+
return resolve(step(i + 1));
|
|
690
|
+
const ext = pathExt[ii];
|
|
691
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
692
|
+
if (!er && is) {
|
|
693
|
+
if (opt.all)
|
|
694
|
+
found.push(p + ext);
|
|
695
|
+
else
|
|
696
|
+
return resolve(p + ext);
|
|
697
|
+
}
|
|
698
|
+
return resolve(subStep(p, i, ii + 1));
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
702
|
+
};
|
|
703
|
+
var whichSync = (cmd, opt) => {
|
|
704
|
+
opt = opt || {};
|
|
705
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
706
|
+
const found = [];
|
|
707
|
+
for (let i = 0; i < pathEnv.length; i++) {
|
|
708
|
+
const ppRaw = pathEnv[i];
|
|
709
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
710
|
+
const pCmd = path3.join(pathPart, cmd);
|
|
711
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
712
|
+
for (let j = 0; j < pathExt.length; j++) {
|
|
713
|
+
const cur = p + pathExt[j];
|
|
714
|
+
try {
|
|
715
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
716
|
+
if (is) {
|
|
717
|
+
if (opt.all)
|
|
718
|
+
found.push(cur);
|
|
719
|
+
else
|
|
720
|
+
return cur;
|
|
721
|
+
}
|
|
722
|
+
} catch (ex) {
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
if (opt.all && found.length)
|
|
727
|
+
return found;
|
|
728
|
+
if (opt.nothrow)
|
|
729
|
+
return null;
|
|
730
|
+
throw getNotFoundError(cmd);
|
|
731
|
+
};
|
|
732
|
+
module22.exports = which;
|
|
733
|
+
which.sync = whichSync;
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
var require_path_key = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
737
|
+
"../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports3, module22) {
|
|
738
|
+
"use strict";
|
|
739
|
+
var pathKey = (options = {}) => {
|
|
740
|
+
const environment = options.env || process.env;
|
|
741
|
+
const platform = options.platform || process.platform;
|
|
742
|
+
if (platform !== "win32") {
|
|
743
|
+
return "PATH";
|
|
744
|
+
}
|
|
745
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
746
|
+
};
|
|
747
|
+
module22.exports = pathKey;
|
|
748
|
+
module22.exports.default = pathKey;
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
var require_resolveCommand = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
752
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports3, module22) {
|
|
753
|
+
"use strict";
|
|
754
|
+
var path3 = (0, import_chunk_QGM4M3NI.__require)("path");
|
|
755
|
+
var which = require_which();
|
|
756
|
+
var getPathKey = require_path_key();
|
|
757
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
758
|
+
const env = parsed.options.env || process.env;
|
|
759
|
+
const cwd = process.cwd();
|
|
760
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
761
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
|
|
762
|
+
if (shouldSwitchCwd) {
|
|
763
|
+
try {
|
|
764
|
+
process.chdir(parsed.options.cwd);
|
|
765
|
+
} catch (err) {
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
let resolved;
|
|
769
|
+
try {
|
|
770
|
+
resolved = which.sync(parsed.command, {
|
|
771
|
+
path: env[getPathKey({ env })],
|
|
772
|
+
pathExt: withoutPathExt ? path3.delimiter : void 0
|
|
773
|
+
});
|
|
774
|
+
} catch (e) {
|
|
775
|
+
} finally {
|
|
776
|
+
if (shouldSwitchCwd) {
|
|
777
|
+
process.chdir(cwd);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
if (resolved) {
|
|
781
|
+
resolved = path3.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
782
|
+
}
|
|
783
|
+
return resolved;
|
|
784
|
+
}
|
|
785
|
+
function resolveCommand(parsed) {
|
|
786
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
787
|
+
}
|
|
788
|
+
module22.exports = resolveCommand;
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
var require_escape = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
792
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports3, module22) {
|
|
793
|
+
"use strict";
|
|
794
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
795
|
+
function escapeCommand(arg) {
|
|
796
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
797
|
+
return arg;
|
|
798
|
+
}
|
|
799
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
800
|
+
arg = `${arg}`;
|
|
801
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
|
|
802
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
803
|
+
arg = `"${arg}"`;
|
|
804
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
805
|
+
if (doubleEscapeMetaChars) {
|
|
806
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
807
|
+
}
|
|
808
|
+
return arg;
|
|
809
|
+
}
|
|
810
|
+
module22.exports.command = escapeCommand;
|
|
811
|
+
module22.exports.argument = escapeArgument;
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
var require_shebang_regex = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
815
|
+
"../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports3, module22) {
|
|
816
|
+
"use strict";
|
|
817
|
+
module22.exports = /^#!(.*)/;
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
var require_shebang_command = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
821
|
+
"../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports3, module22) {
|
|
822
|
+
"use strict";
|
|
823
|
+
var shebangRegex = require_shebang_regex();
|
|
824
|
+
module22.exports = (string = "") => {
|
|
825
|
+
const match = string.match(shebangRegex);
|
|
826
|
+
if (!match) {
|
|
827
|
+
return null;
|
|
828
|
+
}
|
|
829
|
+
const [path3, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
830
|
+
const binary = path3.split("/").pop();
|
|
831
|
+
if (binary === "env") {
|
|
832
|
+
return argument;
|
|
833
|
+
}
|
|
834
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
var require_readShebang = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
839
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports3, module22) {
|
|
840
|
+
"use strict";
|
|
841
|
+
var fs = (0, import_chunk_QGM4M3NI.__require)("fs");
|
|
842
|
+
var shebangCommand = require_shebang_command();
|
|
843
|
+
function readShebang(command) {
|
|
844
|
+
const size = 150;
|
|
845
|
+
const buffer = Buffer.alloc(size);
|
|
846
|
+
let fd;
|
|
847
|
+
try {
|
|
848
|
+
fd = fs.openSync(command, "r");
|
|
849
|
+
fs.readSync(fd, buffer, 0, size, 0);
|
|
850
|
+
fs.closeSync(fd);
|
|
851
|
+
} catch (e) {
|
|
852
|
+
}
|
|
853
|
+
return shebangCommand(buffer.toString());
|
|
854
|
+
}
|
|
855
|
+
module22.exports = readShebang;
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
var require_parse = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
859
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports3, module22) {
|
|
860
|
+
"use strict";
|
|
861
|
+
var path3 = (0, import_chunk_QGM4M3NI.__require)("path");
|
|
862
|
+
var resolveCommand = require_resolveCommand();
|
|
863
|
+
var escape = require_escape();
|
|
864
|
+
var readShebang = require_readShebang();
|
|
865
|
+
var isWin = process.platform === "win32";
|
|
866
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
867
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
868
|
+
function detectShebang(parsed) {
|
|
869
|
+
parsed.file = resolveCommand(parsed);
|
|
870
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
871
|
+
if (shebang) {
|
|
872
|
+
parsed.args.unshift(parsed.file);
|
|
873
|
+
parsed.command = shebang;
|
|
874
|
+
return resolveCommand(parsed);
|
|
875
|
+
}
|
|
876
|
+
return parsed.file;
|
|
877
|
+
}
|
|
878
|
+
function parseNonShell(parsed) {
|
|
879
|
+
if (!isWin) {
|
|
880
|
+
return parsed;
|
|
881
|
+
}
|
|
882
|
+
const commandFile = detectShebang(parsed);
|
|
883
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
884
|
+
if (parsed.options.forceShell || needsShell) {
|
|
885
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
886
|
+
parsed.command = path3.normalize(parsed.command);
|
|
887
|
+
parsed.command = escape.command(parsed.command);
|
|
888
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
889
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
890
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
891
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
892
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
893
|
+
}
|
|
894
|
+
return parsed;
|
|
895
|
+
}
|
|
896
|
+
function parse(command, args, options) {
|
|
897
|
+
if (args && !Array.isArray(args)) {
|
|
898
|
+
options = args;
|
|
899
|
+
args = null;
|
|
900
|
+
}
|
|
901
|
+
args = args ? args.slice(0) : [];
|
|
902
|
+
options = Object.assign({}, options);
|
|
903
|
+
const parsed = {
|
|
904
|
+
command,
|
|
905
|
+
args,
|
|
906
|
+
options,
|
|
907
|
+
file: void 0,
|
|
908
|
+
original: {
|
|
909
|
+
command,
|
|
910
|
+
args
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
914
|
+
}
|
|
915
|
+
module22.exports = parse;
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
var require_enoent = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
919
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports3, module22) {
|
|
920
|
+
"use strict";
|
|
921
|
+
var isWin = process.platform === "win32";
|
|
922
|
+
function notFoundError(original, syscall) {
|
|
923
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
924
|
+
code: "ENOENT",
|
|
925
|
+
errno: "ENOENT",
|
|
926
|
+
syscall: `${syscall} ${original.command}`,
|
|
927
|
+
path: original.command,
|
|
928
|
+
spawnargs: original.args
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
function hookChildProcess(cp, parsed) {
|
|
932
|
+
if (!isWin) {
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
const originalEmit = cp.emit;
|
|
936
|
+
cp.emit = function(name, arg1) {
|
|
937
|
+
if (name === "exit") {
|
|
938
|
+
const err = verifyENOENT(arg1, parsed);
|
|
939
|
+
if (err) {
|
|
940
|
+
return originalEmit.call(cp, "error", err);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return originalEmit.apply(cp, arguments);
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
function verifyENOENT(status, parsed) {
|
|
947
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
948
|
+
return notFoundError(parsed.original, "spawn");
|
|
949
|
+
}
|
|
950
|
+
return null;
|
|
951
|
+
}
|
|
952
|
+
function verifyENOENTSync(status, parsed) {
|
|
953
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
954
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
955
|
+
}
|
|
956
|
+
return null;
|
|
957
|
+
}
|
|
958
|
+
module22.exports = {
|
|
959
|
+
hookChildProcess,
|
|
960
|
+
verifyENOENT,
|
|
961
|
+
verifyENOENTSync,
|
|
962
|
+
notFoundError
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
var require_cross_spawn = (0, import_chunk_QGM4M3NI.__commonJS)({
|
|
967
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports3, module22) {
|
|
968
|
+
"use strict";
|
|
969
|
+
var cp = (0, import_chunk_QGM4M3NI.__require)("child_process");
|
|
970
|
+
var parse = require_parse();
|
|
971
|
+
var enoent = require_enoent();
|
|
972
|
+
function spawn2(command, args, options) {
|
|
973
|
+
const parsed = parse(command, args, options);
|
|
974
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
975
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
976
|
+
return spawned;
|
|
977
|
+
}
|
|
978
|
+
function spawnSync(command, args, options) {
|
|
979
|
+
const parsed = parse(command, args, options);
|
|
980
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
981
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
982
|
+
return result;
|
|
983
|
+
}
|
|
984
|
+
module22.exports = spawn2;
|
|
985
|
+
module22.exports.spawn = spawn2;
|
|
986
|
+
module22.exports.sync = spawnSync;
|
|
987
|
+
module22.exports._parse = parse;
|
|
988
|
+
module22.exports._enoent = enoent;
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
var import_cross_spawn = (0, import_chunk_QGM4M3NI.__toESM)(require_cross_spawn());
|
|
992
|
+
var FORCE_COLOR;
|
|
993
|
+
var NODE_DISABLE_COLORS;
|
|
994
|
+
var NO_COLOR;
|
|
995
|
+
var TERM;
|
|
996
|
+
var isTTY = true;
|
|
997
|
+
if (typeof process !== "undefined") {
|
|
998
|
+
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
|
|
999
|
+
isTTY = process.stdout && process.stdout.isTTY;
|
|
1000
|
+
}
|
|
1001
|
+
var $ = {
|
|
1002
|
+
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY)
|
|
1003
|
+
};
|
|
1004
|
+
function init(x, y) {
|
|
1005
|
+
let rgx = new RegExp(`\\x1b\\[${y}m`, "g");
|
|
1006
|
+
let open = `\x1B[${x}m`, close = `\x1B[${y}m`;
|
|
1007
|
+
return function(txt) {
|
|
1008
|
+
if (!$.enabled || txt == null) return txt;
|
|
1009
|
+
return open + (!!~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close;
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
var reset = init(0, 0);
|
|
1013
|
+
var bold = init(1, 22);
|
|
1014
|
+
var dim = init(2, 22);
|
|
1015
|
+
var italic = init(3, 23);
|
|
1016
|
+
var underline = init(4, 24);
|
|
1017
|
+
var inverse = init(7, 27);
|
|
1018
|
+
var hidden = init(8, 28);
|
|
1019
|
+
var strikethrough = init(9, 29);
|
|
1020
|
+
var black = init(30, 39);
|
|
1021
|
+
var red = init(31, 39);
|
|
1022
|
+
var green = init(32, 39);
|
|
1023
|
+
var yellow = init(33, 39);
|
|
1024
|
+
var blue = init(34, 39);
|
|
1025
|
+
var magenta = init(35, 39);
|
|
1026
|
+
var cyan = init(36, 39);
|
|
1027
|
+
var white = init(37, 39);
|
|
1028
|
+
var gray = init(90, 39);
|
|
1029
|
+
var grey = init(90, 39);
|
|
1030
|
+
var bgBlack = init(40, 49);
|
|
1031
|
+
var bgRed = init(41, 49);
|
|
1032
|
+
var bgGreen = init(42, 49);
|
|
1033
|
+
var bgYellow = init(43, 49);
|
|
1034
|
+
var bgBlue = init(44, 49);
|
|
1035
|
+
var bgMagenta = init(45, 49);
|
|
1036
|
+
var bgCyan = init(46, 49);
|
|
1037
|
+
var bgWhite = init(47, 49);
|
|
1038
|
+
var debug = (0, import_debug.Debug)("prisma:GeneratorProcess");
|
|
1039
|
+
var globalMessageId = 1;
|
|
1040
|
+
var GeneratorError = class extends Error {
|
|
1041
|
+
constructor(message, code, data) {
|
|
1042
|
+
super(message);
|
|
1043
|
+
this.code = code;
|
|
1044
|
+
this.data = data;
|
|
1045
|
+
if (data?.stack) {
|
|
1046
|
+
this.stack = data.stack;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
name = "GeneratorError";
|
|
1050
|
+
};
|
|
1051
|
+
var GeneratorProcess = class {
|
|
1052
|
+
constructor(pathOrCommand, { isNode = false } = {}) {
|
|
1053
|
+
this.pathOrCommand = pathOrCommand;
|
|
1054
|
+
this.isNode = isNode;
|
|
1055
|
+
}
|
|
1056
|
+
child;
|
|
1057
|
+
handlers = {};
|
|
1058
|
+
initPromise;
|
|
1059
|
+
isNode;
|
|
1060
|
+
errorLogs = "";
|
|
1061
|
+
pendingError;
|
|
1062
|
+
exited = false;
|
|
1063
|
+
async init() {
|
|
1064
|
+
if (!this.initPromise) {
|
|
1065
|
+
this.initPromise = this.initSingleton();
|
|
1066
|
+
}
|
|
1067
|
+
return this.initPromise;
|
|
1068
|
+
}
|
|
1069
|
+
initSingleton() {
|
|
1070
|
+
return new Promise((resolve, reject) => {
|
|
1071
|
+
if (this.isNode) {
|
|
1072
|
+
this.child = (0, import_node_child_process.fork)(this.pathOrCommand, [], {
|
|
1073
|
+
stdio: ["pipe", "inherit", "pipe", "ipc"],
|
|
1074
|
+
env: {
|
|
1075
|
+
...process.env,
|
|
1076
|
+
PRISMA_GENERATOR_INVOCATION: "true"
|
|
1077
|
+
},
|
|
1078
|
+
// TODO: this assumes the host has at least 8 GB of RAM which may not be the case.
|
|
1079
|
+
execArgv: ["--max-old-space-size=8096"]
|
|
1080
|
+
});
|
|
1081
|
+
} else {
|
|
1082
|
+
this.child = (0, import_cross_spawn.spawn)(this.pathOrCommand, {
|
|
1083
|
+
stdio: ["pipe", "inherit", "pipe"],
|
|
1084
|
+
env: {
|
|
1085
|
+
...process.env,
|
|
1086
|
+
PRISMA_GENERATOR_INVOCATION: "true"
|
|
1087
|
+
},
|
|
1088
|
+
shell: true
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
this.child.on("exit", (code, signal) => {
|
|
1092
|
+
debug(`child exited with code ${code} on signal ${signal}`);
|
|
1093
|
+
this.exited = true;
|
|
1094
|
+
if (code) {
|
|
1095
|
+
const error = new GeneratorError(
|
|
1096
|
+
`Generator ${JSON.stringify(this.pathOrCommand)} failed:
|
|
1097
|
+
|
|
1098
|
+
${this.errorLogs}`
|
|
1099
|
+
);
|
|
1100
|
+
this.pendingError = error;
|
|
1101
|
+
this.rejectAllHandlers(error);
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
this.child.stdin.on("error", () => {
|
|
1105
|
+
});
|
|
1106
|
+
this.child.on("error", (error) => {
|
|
1107
|
+
debug(error);
|
|
1108
|
+
this.pendingError = error;
|
|
1109
|
+
if (error.code === "EACCES") {
|
|
1110
|
+
reject(
|
|
1111
|
+
new Error(
|
|
1112
|
+
`The executable at ${this.pathOrCommand} lacks the right permissions. Please use ${bold(
|
|
1113
|
+
`chmod +x ${this.pathOrCommand}`
|
|
1114
|
+
)}`
|
|
1115
|
+
)
|
|
1116
|
+
);
|
|
1117
|
+
} else {
|
|
1118
|
+
reject(error);
|
|
1119
|
+
}
|
|
1120
|
+
this.rejectAllHandlers(error);
|
|
1121
|
+
});
|
|
1122
|
+
(0, import_chunk_EOPVK4AE.byline)(this.child.stderr).on("data", (line) => {
|
|
1123
|
+
const response = String(line);
|
|
1124
|
+
let data;
|
|
1125
|
+
try {
|
|
1126
|
+
data = JSON.parse(response);
|
|
1127
|
+
} catch (e) {
|
|
1128
|
+
this.errorLogs += response + "\n";
|
|
1129
|
+
debug(response);
|
|
1130
|
+
}
|
|
1131
|
+
if (data) {
|
|
1132
|
+
this.handleResponse(data);
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
this.child.on("spawn", resolve);
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
rejectAllHandlers(error) {
|
|
1139
|
+
for (const id of Object.keys(this.handlers)) {
|
|
1140
|
+
this.handlers[id].reject(error);
|
|
1141
|
+
delete this.handlers[id];
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
handleResponse(data) {
|
|
1145
|
+
if (data.jsonrpc && data.id) {
|
|
1146
|
+
if (typeof data.id !== "number") {
|
|
1147
|
+
throw new Error(`message.id has to be a number. Found value ${data.id}`);
|
|
1148
|
+
}
|
|
1149
|
+
if (this.handlers[data.id]) {
|
|
1150
|
+
if ((0, import_chunk_KEYE2GFS.isErrorResponse)(data)) {
|
|
1151
|
+
const error = new GeneratorError(data.error.message, data.error.code, data.error.data);
|
|
1152
|
+
this.handlers[data.id].reject(error);
|
|
1153
|
+
} else {
|
|
1154
|
+
this.handlers[data.id].resolve(data.result);
|
|
1155
|
+
}
|
|
1156
|
+
delete this.handlers[data.id];
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
sendMessage(message, callback) {
|
|
1161
|
+
if (!this.child) {
|
|
1162
|
+
callback(new GeneratorError("Generator process has not started yet"));
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
if (!this.child.stdin.writable) {
|
|
1166
|
+
callback(new GeneratorError("Cannot send data to the generator process, process already exited"));
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
this.child.stdin.write(JSON.stringify(message) + "\n", (error) => {
|
|
1170
|
+
if (!error) {
|
|
1171
|
+
return callback();
|
|
1172
|
+
}
|
|
1173
|
+
if (error.code === "EPIPE") {
|
|
1174
|
+
return callback();
|
|
1175
|
+
}
|
|
1176
|
+
callback(error);
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
getMessageId() {
|
|
1180
|
+
return globalMessageId++;
|
|
1181
|
+
}
|
|
1182
|
+
stop() {
|
|
1183
|
+
if (this.child && !this.child?.killed) {
|
|
1184
|
+
this.child.kill("SIGTERM");
|
|
1185
|
+
const timeoutMs = 2e3;
|
|
1186
|
+
const intervalMs = 200;
|
|
1187
|
+
let interval;
|
|
1188
|
+
let timeout;
|
|
1189
|
+
Promise.race([
|
|
1190
|
+
new Promise((resolve) => {
|
|
1191
|
+
timeout = setTimeout(resolve, timeoutMs);
|
|
1192
|
+
}),
|
|
1193
|
+
new Promise((resolve) => {
|
|
1194
|
+
interval = setInterval(() => {
|
|
1195
|
+
if (this.exited) {
|
|
1196
|
+
return resolve("exited");
|
|
1197
|
+
}
|
|
1198
|
+
}, intervalMs);
|
|
1199
|
+
})
|
|
1200
|
+
]).then((result) => {
|
|
1201
|
+
if (result !== "exited") {
|
|
1202
|
+
this.child?.kill("SIGKILL");
|
|
1203
|
+
}
|
|
1204
|
+
}).finally(() => {
|
|
1205
|
+
clearInterval(interval);
|
|
1206
|
+
clearTimeout(timeout);
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
rpcMethod(method, mapResult = (x) => x) {
|
|
1211
|
+
return (params) => new Promise((resolve, reject) => {
|
|
1212
|
+
if (this.pendingError) {
|
|
1213
|
+
reject(this.pendingError);
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
const messageId = this.getMessageId();
|
|
1217
|
+
this.handlers[messageId] = {
|
|
1218
|
+
resolve: (result) => resolve(mapResult(result)),
|
|
1219
|
+
reject
|
|
1220
|
+
};
|
|
1221
|
+
this.sendMessage(
|
|
1222
|
+
{
|
|
1223
|
+
jsonrpc: "2.0",
|
|
1224
|
+
method,
|
|
1225
|
+
params,
|
|
1226
|
+
id: messageId
|
|
1227
|
+
},
|
|
1228
|
+
(error) => {
|
|
1229
|
+
if (error) reject(error);
|
|
1230
|
+
}
|
|
1231
|
+
);
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
getManifest = this.rpcMethod(
|
|
1235
|
+
"getManifest",
|
|
1236
|
+
(result) => result.manifest ?? null
|
|
1237
|
+
);
|
|
1238
|
+
generate = this.rpcMethod("generate");
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
// node_modules/@prisma/generator-helper/dist/chunk-IH6S2YZX.js
|
|
1244
|
+
var require_chunk_IH6S2YZX = __commonJS({
|
|
1245
|
+
"node_modules/@prisma/generator-helper/dist/chunk-IH6S2YZX.js"(exports2, module2) {
|
|
1246
|
+
"use strict";
|
|
1247
|
+
var __defProp2 = Object.defineProperty;
|
|
1248
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
1249
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
1250
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
1251
|
+
var __export = (target, all) => {
|
|
1252
|
+
for (var name in all)
|
|
1253
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
1254
|
+
};
|
|
1255
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
1256
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
1257
|
+
for (let key of __getOwnPropNames2(from))
|
|
1258
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
1259
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
1260
|
+
}
|
|
1261
|
+
return to;
|
|
1262
|
+
};
|
|
1263
|
+
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
1264
|
+
var chunk_IH6S2YZX_exports = {};
|
|
1265
|
+
__export(chunk_IH6S2YZX_exports, {
|
|
1266
|
+
generatorHandler: () => generatorHandler2
|
|
1267
|
+
});
|
|
1268
|
+
module2.exports = __toCommonJS(chunk_IH6S2YZX_exports);
|
|
1269
|
+
var import_chunk_EOPVK4AE = require_chunk_EOPVK4AE();
|
|
1270
|
+
function generatorHandler2(handler) {
|
|
1271
|
+
(0, import_chunk_EOPVK4AE.byline)(process.stdin).on("data", async (line) => {
|
|
1272
|
+
const json = JSON.parse(String(line));
|
|
1273
|
+
if (json.method === "generate" && json.params) {
|
|
1274
|
+
try {
|
|
1275
|
+
const result = await handler.onGenerate(json.params);
|
|
1276
|
+
respond({
|
|
1277
|
+
jsonrpc: "2.0",
|
|
1278
|
+
result,
|
|
1279
|
+
id: json.id
|
|
1280
|
+
});
|
|
1281
|
+
} catch (_e) {
|
|
1282
|
+
const e = _e;
|
|
1283
|
+
respond({
|
|
1284
|
+
jsonrpc: "2.0",
|
|
1285
|
+
error: {
|
|
1286
|
+
code: -32e3,
|
|
1287
|
+
message: e.message,
|
|
1288
|
+
data: {
|
|
1289
|
+
stack: e.stack
|
|
1290
|
+
}
|
|
1291
|
+
},
|
|
1292
|
+
id: json.id
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
if (json.method === "getManifest") {
|
|
1297
|
+
if (handler.onManifest) {
|
|
1298
|
+
try {
|
|
1299
|
+
const manifest = await handler.onManifest(json.params);
|
|
1300
|
+
respond({
|
|
1301
|
+
jsonrpc: "2.0",
|
|
1302
|
+
result: {
|
|
1303
|
+
manifest
|
|
1304
|
+
},
|
|
1305
|
+
id: json.id
|
|
1306
|
+
});
|
|
1307
|
+
} catch (_e) {
|
|
1308
|
+
const e = _e;
|
|
1309
|
+
respond({
|
|
1310
|
+
jsonrpc: "2.0",
|
|
1311
|
+
error: {
|
|
1312
|
+
code: -32e3,
|
|
1313
|
+
message: e.message,
|
|
1314
|
+
data: {
|
|
1315
|
+
stack: e.stack
|
|
1316
|
+
}
|
|
1317
|
+
},
|
|
1318
|
+
id: json.id
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
} else {
|
|
1322
|
+
respond({
|
|
1323
|
+
jsonrpc: "2.0",
|
|
1324
|
+
result: {
|
|
1325
|
+
manifest: null
|
|
1326
|
+
},
|
|
1327
|
+
id: json.id
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
process.stdin.resume();
|
|
1333
|
+
}
|
|
1334
|
+
function respond(response) {
|
|
1335
|
+
process.stderr.write(JSON.stringify(response) + "\n");
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
|
|
1340
|
+
// node_modules/@prisma/generator-helper/dist/index.js
|
|
1341
|
+
var require_dist2 = __commonJS({
|
|
1342
|
+
"node_modules/@prisma/generator-helper/dist/index.js"(exports2, module2) {
|
|
1343
|
+
"use strict";
|
|
1344
|
+
var __defProp2 = Object.defineProperty;
|
|
1345
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
1346
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
1347
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
1348
|
+
var __export = (target, all) => {
|
|
1349
|
+
for (var name in all)
|
|
1350
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
1351
|
+
};
|
|
1352
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
1353
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
1354
|
+
for (let key of __getOwnPropNames2(from))
|
|
1355
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
1356
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
1357
|
+
}
|
|
1358
|
+
return to;
|
|
1359
|
+
};
|
|
1360
|
+
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
1361
|
+
var index_exports = {};
|
|
1362
|
+
__export(index_exports, {
|
|
1363
|
+
GeneratorError: () => import_chunk_MXZE5TCU.GeneratorError,
|
|
1364
|
+
GeneratorProcess: () => import_chunk_MXZE5TCU.GeneratorProcess,
|
|
1365
|
+
generatorHandler: () => import_chunk_IH6S2YZX.generatorHandler
|
|
1366
|
+
});
|
|
1367
|
+
module2.exports = __toCommonJS(index_exports);
|
|
1368
|
+
var import_chunk_MXZE5TCU = require_chunk_MXZE5TCU();
|
|
1369
|
+
var import_chunk_IH6S2YZX = require_chunk_IH6S2YZX();
|
|
1370
|
+
var import_chunk_EOPVK4AE = require_chunk_EOPVK4AE();
|
|
1371
|
+
var import_chunk_KEYE2GFS = require_chunk_KEYE2GFS();
|
|
1372
|
+
var import_chunk_QGM4M3NI = require_chunk_QGM4M3NI();
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
|
|
1376
|
+
// src/lib/PrismaMermaidGenerators/index.ts
|
|
1377
|
+
var import_generator_helper = __toESM(require_dist2(), 1);
|
|
1378
|
+
|
|
1379
|
+
// src/lib/MermaidClass/prismaMermaidClass.ts
|
|
1380
|
+
var import_internals = __toESM(require("@prisma/internals"), 1);
|
|
1381
|
+
var import_node_fs = require("fs");
|
|
1382
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
1383
|
+
|
|
1384
|
+
// src/constants/mermaid.ts
|
|
1385
|
+
var mermaidERDiagramConfig = {
|
|
1386
|
+
theme: "neutral",
|
|
1387
|
+
themeVariables: {
|
|
1388
|
+
fontSize: "20px",
|
|
1389
|
+
fontFamily: "Arial",
|
|
1390
|
+
padding: "12px",
|
|
1391
|
+
lineHeight: "1.4"
|
|
1392
|
+
},
|
|
1393
|
+
flowchart: {
|
|
1394
|
+
nodeSpacing: 80,
|
|
1395
|
+
rankSpacing: 120,
|
|
1396
|
+
htmlLabels: true
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
1399
|
+
var mermaidClassDiagramConfig = {
|
|
1400
|
+
theme: "neutral",
|
|
1401
|
+
themeVariables: {
|
|
1402
|
+
fontFamily: "Arial",
|
|
1403
|
+
lineHeight: "1.4"
|
|
1404
|
+
},
|
|
1405
|
+
flowchart: {
|
|
1406
|
+
nodeSpacing: 300,
|
|
1407
|
+
rankSpacing: 120,
|
|
1408
|
+
htmlLabels: true
|
|
1409
|
+
},
|
|
1410
|
+
class: {
|
|
1411
|
+
hideEmptyMembersBox: true
|
|
1412
|
+
}
|
|
1413
|
+
};
|
|
1414
|
+
var DEFAULT_BASE_NODE_SPACING = 100;
|
|
1415
|
+
var DEFAULT_BASE_EDGE_SPACING = 150;
|
|
1416
|
+
|
|
1417
|
+
// src/utils/mermaid.ts
|
|
1418
|
+
var generateDiagramSpacing = ({
|
|
1419
|
+
baseEdge,
|
|
1420
|
+
baseNode,
|
|
1421
|
+
models
|
|
1422
|
+
}) => {
|
|
1423
|
+
const totalFields = models.reduce((sum, m) => sum + m.fields.length, 0);
|
|
1424
|
+
const totalRelations = models.reduce(
|
|
1425
|
+
(sum, m) => sum + m.fields.filter((f) => f.relationName && f.relationFromFields?.length).length,
|
|
1426
|
+
0
|
|
1427
|
+
);
|
|
1428
|
+
return {
|
|
1429
|
+
nodeSpacing: baseNode + models.length * 6 + totalFields * 2,
|
|
1430
|
+
edgeSpacing: baseEdge + models.length * 4 + totalRelations * 4
|
|
1431
|
+
};
|
|
1432
|
+
};
|
|
1433
|
+
var generateMermaidConfig = (config, models) => {
|
|
1434
|
+
if (config["themeVariables"]) {
|
|
1435
|
+
const { edgeSpacing, nodeSpacing } = generateDiagramSpacing({
|
|
1436
|
+
baseEdge: DEFAULT_BASE_EDGE_SPACING,
|
|
1437
|
+
baseNode: DEFAULT_BASE_NODE_SPACING,
|
|
1438
|
+
models
|
|
1439
|
+
});
|
|
1440
|
+
config["themeVariables"] = {
|
|
1441
|
+
...config["themeVariables"],
|
|
1442
|
+
edgeSpacing,
|
|
1443
|
+
nodeSpacing
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
const json = JSON.stringify(config, null, 2);
|
|
1447
|
+
return `%%{init: ${json}}%%
|
|
1448
|
+
`;
|
|
1449
|
+
};
|
|
1450
|
+
|
|
1451
|
+
// src/lib/MermaidClass/utils.ts
|
|
1452
|
+
var generateCardinality = ({
|
|
1453
|
+
isList,
|
|
1454
|
+
isRequired
|
|
1455
|
+
}) => {
|
|
1456
|
+
if (isList) return '"*"';
|
|
1457
|
+
return isRequired ? '"1"' : '"0..1"';
|
|
1458
|
+
};
|
|
1459
|
+
var generateRelationships = ({
|
|
1460
|
+
relationships
|
|
1461
|
+
}) => {
|
|
1462
|
+
const lines = [];
|
|
1463
|
+
for (const relName in relationships) {
|
|
1464
|
+
const sides = relationships[relName];
|
|
1465
|
+
if (!sides) continue;
|
|
1466
|
+
if (sides.length === 1) {
|
|
1467
|
+
const a = sides[0];
|
|
1468
|
+
if (!a) continue;
|
|
1469
|
+
lines.push(
|
|
1470
|
+
`${a.model} ${generateCardinality({
|
|
1471
|
+
isList: a.isList,
|
|
1472
|
+
isRequired: a.isRequired
|
|
1473
|
+
})} --> "1" ${a.fieldType} : ${relName}`
|
|
1474
|
+
);
|
|
1475
|
+
} else if (sides.length === 2) {
|
|
1476
|
+
const a = sides[0];
|
|
1477
|
+
const b = sides[1];
|
|
1478
|
+
if (!a || !b) continue;
|
|
1479
|
+
lines.push(
|
|
1480
|
+
`${a.model} ${generateCardinality({
|
|
1481
|
+
isList: a.isList,
|
|
1482
|
+
isRequired: a.isRequired
|
|
1483
|
+
})} --> ${generateCardinality({
|
|
1484
|
+
isList: b.isList,
|
|
1485
|
+
isRequired: b.isRequired
|
|
1486
|
+
})} ${b.model} : ${relName}`
|
|
1487
|
+
);
|
|
1488
|
+
} else {
|
|
1489
|
+
for (let i = 1; i < sides.length; i++) {
|
|
1490
|
+
const a = sides[0];
|
|
1491
|
+
const b = sides[i];
|
|
1492
|
+
if (!a || !b) continue;
|
|
1493
|
+
lines.push(
|
|
1494
|
+
`${a.model} ${generateCardinality({
|
|
1495
|
+
isList: a.isList,
|
|
1496
|
+
isRequired: a.isRequired
|
|
1497
|
+
})} --> ${generateCardinality({
|
|
1498
|
+
isList: b.isList,
|
|
1499
|
+
isRequired: b.isRequired
|
|
1500
|
+
})} ${b.model} : ${relName}`
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
return lines;
|
|
1506
|
+
};
|
|
1507
|
+
|
|
1508
|
+
// src/lib/MermaidClass/prismaMermaidClass.ts
|
|
1509
|
+
var { getDMMF } = import_internals.default;
|
|
1510
|
+
var generateDiagram = async ({
|
|
1511
|
+
outputPath,
|
|
1512
|
+
schemaPath,
|
|
1513
|
+
generatorPrismaDocument
|
|
1514
|
+
}) => {
|
|
1515
|
+
const outputDir = outputPath ? import_node_path.default.resolve(outputPath) : import_node_path.default.join(`${process.cwd()}/src/generated/diagrams`);
|
|
1516
|
+
try {
|
|
1517
|
+
const prismaDocument = generatorPrismaDocument ?? await getDMMF({
|
|
1518
|
+
datamodel: (0, import_node_fs.readFileSync)(schemaPath, "utf-8")
|
|
1519
|
+
});
|
|
1520
|
+
const models = prismaDocument.datamodel.models;
|
|
1521
|
+
const enums = prismaDocument.datamodel.enums;
|
|
1522
|
+
const mermaidLines = [
|
|
1523
|
+
"%% --------------------------------------------",
|
|
1524
|
+
"%% Auto-generated Mermaid Class Diagram. Do Not Edit Directly.",
|
|
1525
|
+
"%% --------------------------------------------\n",
|
|
1526
|
+
generateMermaidConfig(mermaidClassDiagramConfig, models),
|
|
1527
|
+
"classDiagram"
|
|
1528
|
+
];
|
|
1529
|
+
const relationships = {};
|
|
1530
|
+
models.forEach((model) => {
|
|
1531
|
+
mermaidLines.push(`class ${model.name} {`);
|
|
1532
|
+
model.fields.forEach((field) => {
|
|
1533
|
+
mermaidLines.push(` ${field.type} ${field.name}`);
|
|
1534
|
+
if (field.relationName) {
|
|
1535
|
+
if (!relationships[field.relationName]) {
|
|
1536
|
+
relationships[field.relationName] = [];
|
|
1537
|
+
}
|
|
1538
|
+
relationships[field.relationName].push({
|
|
1539
|
+
model: model.name,
|
|
1540
|
+
fieldType: field.type,
|
|
1541
|
+
isList: field.isList ?? false,
|
|
1542
|
+
isRequired: field.isRequired ?? false
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
mermaidLines.push("}");
|
|
1547
|
+
});
|
|
1548
|
+
enums.forEach((enumDef) => {
|
|
1549
|
+
mermaidLines.push(`class ${enumDef.name} {`);
|
|
1550
|
+
enumDef.values.forEach((val) => {
|
|
1551
|
+
mermaidLines.push(` <<enumeration>> ${val.name}`);
|
|
1552
|
+
});
|
|
1553
|
+
mermaidLines.push("}");
|
|
1554
|
+
});
|
|
1555
|
+
const relationLines = generateRelationships({ relationships });
|
|
1556
|
+
const output = mermaidLines.concat(relationLines).join("\n");
|
|
1557
|
+
(0, import_node_fs.mkdirSync)(outputDir, { recursive: true });
|
|
1558
|
+
const outFile = import_node_path.default.join(outputDir, "mermaidClassDiagram.mmd");
|
|
1559
|
+
(0, import_node_fs.writeFileSync)(outFile, output, "utf-8");
|
|
1560
|
+
console.log(`Mermaid Class Diagram written to: ${outFile}`);
|
|
1561
|
+
return outFile;
|
|
1562
|
+
} catch (e) {
|
|
1563
|
+
console.error("Failed to generate Mermaid Class Diagram.", e);
|
|
1564
|
+
return "";
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
|
|
1568
|
+
// src/lib/MermaidERD/prismaMermaidErd.ts
|
|
1569
|
+
var import_internals2 = __toESM(require("@prisma/internals"), 1);
|
|
1570
|
+
var import_fs = require("fs");
|
|
1571
|
+
var import_node_fs2 = require("fs");
|
|
1572
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
1573
|
+
|
|
1574
|
+
// src/lib/MermaidERD/utils.ts
|
|
1575
|
+
var generateCardinality2 = ({
|
|
1576
|
+
isList,
|
|
1577
|
+
isRequired
|
|
1578
|
+
}) => {
|
|
1579
|
+
if (isList) {
|
|
1580
|
+
return "}|";
|
|
1581
|
+
}
|
|
1582
|
+
return isRequired ? "||" : "o|";
|
|
1583
|
+
};
|
|
1584
|
+
var getKeyConstraints = (isId, fieldName, foreignKeys, nativeTypes) => {
|
|
1585
|
+
if (isId) return "PK";
|
|
1586
|
+
if (nativeTypes) {
|
|
1587
|
+
const allNativeTypes = nativeTypes.flatMap((nativeType) => nativeType);
|
|
1588
|
+
if (!isId && allNativeTypes.includes("UniqueIdentifier")) {
|
|
1589
|
+
return "FK";
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
if (!isId && foreignKeys.has(fieldName)) return "FK";
|
|
1593
|
+
return "";
|
|
1594
|
+
};
|
|
1595
|
+
var getOptionalitySymbol = (isRequired) => {
|
|
1596
|
+
return isRequired ? "" : `"?"`;
|
|
1597
|
+
};
|
|
1598
|
+
var generateRelationships2 = ({
|
|
1599
|
+
relationships
|
|
1600
|
+
}) => {
|
|
1601
|
+
const relationLines = [];
|
|
1602
|
+
for (const relName in relationships) {
|
|
1603
|
+
const sides = relationships[relName];
|
|
1604
|
+
if (!sides) continue;
|
|
1605
|
+
if (sides.length === 1) {
|
|
1606
|
+
const a = sides[0];
|
|
1607
|
+
if (!a) continue;
|
|
1608
|
+
relationLines.push(
|
|
1609
|
+
` ${a.model} ${generateCardinality2({
|
|
1610
|
+
isList: a.isList,
|
|
1611
|
+
isRequired: a.isRequired
|
|
1612
|
+
})}--${generateCardinality2({ isList: false, isRequired: true })} ${a.fieldType} : ${relName}`
|
|
1613
|
+
);
|
|
1614
|
+
} else if (sides.length === 2) {
|
|
1615
|
+
const a = sides[0];
|
|
1616
|
+
const b = sides[1];
|
|
1617
|
+
if (!a || !b) continue;
|
|
1618
|
+
relationLines.push(
|
|
1619
|
+
` ${a.model} ${generateCardinality2({
|
|
1620
|
+
isList: a.isList,
|
|
1621
|
+
isRequired: a.isRequired
|
|
1622
|
+
})}--${generateCardinality2({
|
|
1623
|
+
isList: b.isList,
|
|
1624
|
+
isRequired: b.isRequired
|
|
1625
|
+
})} ${b.model} : ${relName}`
|
|
1626
|
+
);
|
|
1627
|
+
} else {
|
|
1628
|
+
for (let i = 1; i < sides.length; i++) {
|
|
1629
|
+
const a = sides[0];
|
|
1630
|
+
const b = sides[i];
|
|
1631
|
+
if (!a || !b) continue;
|
|
1632
|
+
relationLines.push(
|
|
1633
|
+
` ${a.model} ${generateCardinality2({
|
|
1634
|
+
isList: a.isList,
|
|
1635
|
+
isRequired: a.isRequired
|
|
1636
|
+
})}--${generateCardinality2({
|
|
1637
|
+
isList: b.isList,
|
|
1638
|
+
isRequired: b.isRequired
|
|
1639
|
+
})} ${b.model} : ${relName}`
|
|
1640
|
+
);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
return relationLines;
|
|
1645
|
+
};
|
|
1646
|
+
|
|
1647
|
+
// src/lib/MermaidERD/prismaMermaidErd.ts
|
|
1648
|
+
var { getDMMF: getDMMF2 } = import_internals2.default;
|
|
1649
|
+
var generateDiagram2 = async ({
|
|
1650
|
+
outputPath,
|
|
1651
|
+
schemaPath,
|
|
1652
|
+
generatorPrismaDocument
|
|
1653
|
+
}) => {
|
|
1654
|
+
const outputDir = outputPath ? import_node_path2.default.resolve(outputPath) : import_node_path2.default.join(`${process.cwd()}/src/generated/diagrams`);
|
|
1655
|
+
try {
|
|
1656
|
+
const prismaDocument = generatorPrismaDocument ?? await getDMMF2({
|
|
1657
|
+
datamodel: (0, import_fs.readFileSync)(schemaPath, "utf-8")
|
|
1658
|
+
});
|
|
1659
|
+
const schemaModels = prismaDocument.datamodel.models;
|
|
1660
|
+
const schemaEnums = prismaDocument.datamodel.enums;
|
|
1661
|
+
console.dir(schemaEnums, { depth: null });
|
|
1662
|
+
const mermaidLines = [
|
|
1663
|
+
"%% --------------------------------------------",
|
|
1664
|
+
"%% Auto-generated Mermaid ER Diagram. Do Not Edit Directly.",
|
|
1665
|
+
"%% --------------------------------------------\n",
|
|
1666
|
+
generateMermaidConfig(mermaidERDiagramConfig, schemaModels),
|
|
1667
|
+
"erDiagram"
|
|
1668
|
+
];
|
|
1669
|
+
const relationships = {};
|
|
1670
|
+
schemaModels.forEach((model) => {
|
|
1671
|
+
mermaidLines.push(` ${model.name} {`);
|
|
1672
|
+
const foreignKeys = /* @__PURE__ */ new Set();
|
|
1673
|
+
model.fields.forEach((field) => {
|
|
1674
|
+
if (field.relationFromFields && field.relationFromFields.length > 0) {
|
|
1675
|
+
field.relationFromFields.forEach((fk) => {
|
|
1676
|
+
foreignKeys.add(fk);
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
mermaidLines.push(
|
|
1680
|
+
` ${field.type} ${field.name} ${getKeyConstraints(
|
|
1681
|
+
field.isId,
|
|
1682
|
+
field.name,
|
|
1683
|
+
foreignKeys,
|
|
1684
|
+
field.nativeType
|
|
1685
|
+
)} ${getOptionalitySymbol(field.isRequired)}`
|
|
1686
|
+
);
|
|
1687
|
+
if (field.relationName) {
|
|
1688
|
+
if (!relationships[field.relationName]) {
|
|
1689
|
+
relationships[field.relationName] = [];
|
|
1690
|
+
}
|
|
1691
|
+
relationships[field.relationName].push({
|
|
1692
|
+
model: model.name,
|
|
1693
|
+
fieldType: field.type,
|
|
1694
|
+
isList: field.isList ?? false,
|
|
1695
|
+
isRequired: field.isRequired ?? false
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
});
|
|
1699
|
+
mermaidLines.push(` }`);
|
|
1700
|
+
});
|
|
1701
|
+
schemaEnums.forEach((enumDef) => {
|
|
1702
|
+
mermaidLines.push(` ${enumDef.name} {`);
|
|
1703
|
+
enumDef.values.forEach((enumValue) => {
|
|
1704
|
+
mermaidLines.push(` ${enumValue.name}`);
|
|
1705
|
+
});
|
|
1706
|
+
mermaidLines.push(` }`);
|
|
1707
|
+
});
|
|
1708
|
+
const relationLines = generateRelationships2({ relationships });
|
|
1709
|
+
const output = mermaidLines.concat(relationLines);
|
|
1710
|
+
(0, import_node_fs2.mkdirSync)(outputDir, { recursive: true });
|
|
1711
|
+
const outFile = import_node_path2.default.join(outputDir, "mermaidErdDiagram.mmd");
|
|
1712
|
+
(0, import_fs.writeFileSync)(outFile, output.join("\n"));
|
|
1713
|
+
console.log(`Mermaid ERD generated at: ${outFile}`);
|
|
1714
|
+
return outFile;
|
|
1715
|
+
} catch {
|
|
1716
|
+
console.error("Failed to generate Mermaid ER Diagram.");
|
|
1717
|
+
return "";
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1720
|
+
|
|
1721
|
+
// src/lib/PrismaMermaidGenerators/generator.ts
|
|
1722
|
+
var prismaGenerators = /* @__PURE__ */ new Map([
|
|
1723
|
+
["mermaid-erd", generateDiagram2],
|
|
1724
|
+
["mermaid-class", generateDiagram]
|
|
1725
|
+
]);
|
|
1726
|
+
|
|
1727
|
+
// package.json
|
|
1728
|
+
var package_default = {
|
|
1729
|
+
name: "@nonsoo/prisma-mermaid",
|
|
1730
|
+
version: "0.1.0",
|
|
1731
|
+
description: "A Prisma generator that generates Mermaid Class or ER diagrams from your Prisma schema.",
|
|
1732
|
+
main: "build/index.js",
|
|
1733
|
+
bin: {
|
|
1734
|
+
"prisma-mermaid": "./build/lib/PrismaMermaidGenerators/bin.cjs"
|
|
1735
|
+
},
|
|
1736
|
+
types: "build/lib/PrismaMermaidGenerators/index.d.js",
|
|
1737
|
+
files: [
|
|
1738
|
+
"build"
|
|
1739
|
+
],
|
|
1740
|
+
publishConfig: {
|
|
1741
|
+
access: "public"
|
|
1742
|
+
},
|
|
1743
|
+
scripts: {
|
|
1744
|
+
build: "tsup",
|
|
1745
|
+
lint: "eslint .",
|
|
1746
|
+
"lint:fix": "eslint --fix .",
|
|
1747
|
+
typecheck: "tsc",
|
|
1748
|
+
test: "vitest",
|
|
1749
|
+
"test:ci": "vitest run",
|
|
1750
|
+
"prettier:fix": "prettier --write .",
|
|
1751
|
+
"prettier:check": "prettier --check ."
|
|
1752
|
+
},
|
|
1753
|
+
keywords: [
|
|
1754
|
+
"prisma",
|
|
1755
|
+
"generator",
|
|
1756
|
+
"diagrams",
|
|
1757
|
+
"mermaid",
|
|
1758
|
+
"erd",
|
|
1759
|
+
"Entity Relationship Diagram",
|
|
1760
|
+
"typescript"
|
|
1761
|
+
],
|
|
1762
|
+
author: "Nonso O",
|
|
1763
|
+
license: "MIT",
|
|
1764
|
+
type: "module",
|
|
1765
|
+
repository: {
|
|
1766
|
+
type: "git",
|
|
1767
|
+
url: "https://github.com/nonsoo/prisma-mermaid.git"
|
|
1768
|
+
},
|
|
1769
|
+
engines: {
|
|
1770
|
+
node: ">=22.0.0"
|
|
1771
|
+
},
|
|
1772
|
+
exports: {
|
|
1773
|
+
".": {
|
|
1774
|
+
types: "./build/index.d.ts",
|
|
1775
|
+
import: "./build/index.js",
|
|
1776
|
+
require: "./build/index.cjs",
|
|
1777
|
+
default: "./build/index.js"
|
|
1778
|
+
}
|
|
1779
|
+
},
|
|
1780
|
+
devDependencies: {
|
|
1781
|
+
"@changesets/cli": "^2.29.7",
|
|
1782
|
+
"@eslint/js": "^9.39.1",
|
|
1783
|
+
"@types/node": "^24.10.1",
|
|
1784
|
+
eslint: "^9.39.1",
|
|
1785
|
+
"eslint-config-prettier": "^10.1.8",
|
|
1786
|
+
"eslint-plugin-perfectionist": "^4.15.1",
|
|
1787
|
+
globals: "^16.5.0",
|
|
1788
|
+
tsup: "^8.5.1",
|
|
1789
|
+
typescript: "^5.9.3",
|
|
1790
|
+
"typescript-eslint": "^8.47.0",
|
|
1791
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
1792
|
+
vitest: "^4.0.10"
|
|
1793
|
+
},
|
|
1794
|
+
peerDependencies: {
|
|
1795
|
+
prisma: "^6.10.0 || ^7.0.0",
|
|
1796
|
+
"@prisma/client": "^6.0.0 || ^7.0.0"
|
|
1797
|
+
},
|
|
1798
|
+
dependencies: {
|
|
1799
|
+
"@prisma/internals": "^7.0.0"
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
|
|
1803
|
+
// src/lib/PrismaMermaidGenerators/index.ts
|
|
1804
|
+
(0, import_generator_helper.generatorHandler)({
|
|
1805
|
+
onManifest: () => {
|
|
1806
|
+
return {
|
|
1807
|
+
version: package_default["version"],
|
|
1808
|
+
prettyName: "Mermaid Diagram"
|
|
1809
|
+
};
|
|
1810
|
+
},
|
|
1811
|
+
onGenerate: async (options) => {
|
|
1812
|
+
const schemaPath = options.schemaPath;
|
|
1813
|
+
const outputDir = options.generator.output?.value ?? void 0;
|
|
1814
|
+
const formats = options.generator.config.format ?? "mermaid-erd";
|
|
1815
|
+
const disabled = process.env.PRISMA_DIAGRAM_GENERATOR_DISABLE ?? "false";
|
|
1816
|
+
const generatorPrismaDocument = options.dmmf;
|
|
1817
|
+
if (disabled === "true") {
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
if (Array.isArray(formats)) {
|
|
1821
|
+
for (const format of formats) {
|
|
1822
|
+
const mermaidGenerator2 = prismaGenerators.get(
|
|
1823
|
+
format
|
|
1824
|
+
);
|
|
1825
|
+
if (!mermaidGenerator2) continue;
|
|
1826
|
+
mermaidGenerator2({
|
|
1827
|
+
schemaPath,
|
|
1828
|
+
outputPath: outputDir,
|
|
1829
|
+
generatorPrismaDocument
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
const mermaidGenerator = prismaGenerators.get(
|
|
1835
|
+
formats
|
|
1836
|
+
);
|
|
1837
|
+
if (!mermaidGenerator) return;
|
|
1838
|
+
mermaidGenerator({
|
|
1839
|
+
schemaPath,
|
|
1840
|
+
outputPath: outputDir,
|
|
1841
|
+
generatorPrismaDocument
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
});
|