@prisma/cli-security-rules 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/dist/index.d.ts +3 -0
- package/dist/index.js +1011 -0
- package/dist/template.js +58 -0
- package/package.json +55 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,1011 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined")
|
|
12
|
+
return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
};
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(from))
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
32
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
33
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
34
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
35
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
36
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
37
|
+
mod
|
|
38
|
+
));
|
|
39
|
+
|
|
40
|
+
// ../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/lib/XDGAppPaths.js
|
|
41
|
+
var require_XDGAppPaths = __commonJS({
|
|
42
|
+
"../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/lib/XDGAppPaths.js"(exports) {
|
|
43
|
+
"use strict";
|
|
44
|
+
exports.__esModule = true;
|
|
45
|
+
exports.Adapt = void 0;
|
|
46
|
+
function isBoolean(t) {
|
|
47
|
+
return typeOf(t) === "boolean";
|
|
48
|
+
}
|
|
49
|
+
function isObject(t) {
|
|
50
|
+
return typeOf(t) === "object";
|
|
51
|
+
}
|
|
52
|
+
function isString(t) {
|
|
53
|
+
return typeOf(t) === "string";
|
|
54
|
+
}
|
|
55
|
+
function typeOf(t) {
|
|
56
|
+
return typeof t;
|
|
57
|
+
}
|
|
58
|
+
function Adapt(adapter_) {
|
|
59
|
+
var meta = adapter_.meta, path2 = adapter_.path, xdg = adapter_.xdg;
|
|
60
|
+
var XDGAppPaths_ = /* @__PURE__ */ function() {
|
|
61
|
+
function XDGAppPaths_2(options_) {
|
|
62
|
+
if (options_ === void 0) {
|
|
63
|
+
options_ = {};
|
|
64
|
+
}
|
|
65
|
+
var _a, _b, _c;
|
|
66
|
+
function XDGAppPaths(options2) {
|
|
67
|
+
if (options2 === void 0) {
|
|
68
|
+
options2 = {};
|
|
69
|
+
}
|
|
70
|
+
return new XDGAppPaths_2(options2);
|
|
71
|
+
}
|
|
72
|
+
var options = isObject(options_) ? options_ : { name: options_ };
|
|
73
|
+
var suffix = (_a = options.suffix) !== null && _a !== void 0 ? _a : "";
|
|
74
|
+
var isolated_ = (_b = options.isolated) !== null && _b !== void 0 ? _b : true;
|
|
75
|
+
var namePriorityList = [
|
|
76
|
+
options.name,
|
|
77
|
+
meta.pkgMainFilename(),
|
|
78
|
+
meta.mainFilename()
|
|
79
|
+
];
|
|
80
|
+
var nameFallback = "$eval";
|
|
81
|
+
var name = path2.parse(((_c = namePriorityList.find(function(e) {
|
|
82
|
+
return isString(e);
|
|
83
|
+
})) !== null && _c !== void 0 ? _c : nameFallback) + suffix).name;
|
|
84
|
+
XDGAppPaths.$name = function $name() {
|
|
85
|
+
return name;
|
|
86
|
+
};
|
|
87
|
+
XDGAppPaths.$isolated = function $isolated() {
|
|
88
|
+
return isolated_;
|
|
89
|
+
};
|
|
90
|
+
function isIsolated(dirOptions) {
|
|
91
|
+
var _a2;
|
|
92
|
+
dirOptions = dirOptions !== null && dirOptions !== void 0 ? dirOptions : { isolated: isolated_ };
|
|
93
|
+
var isolated = isBoolean(dirOptions) ? dirOptions : (_a2 = dirOptions.isolated) !== null && _a2 !== void 0 ? _a2 : isolated_;
|
|
94
|
+
return isolated;
|
|
95
|
+
}
|
|
96
|
+
function finalPathSegment(dirOptions) {
|
|
97
|
+
return isIsolated(dirOptions) ? name : "";
|
|
98
|
+
}
|
|
99
|
+
XDGAppPaths.cache = function cache(dirOptions) {
|
|
100
|
+
return path2.join(xdg.cache(), finalPathSegment(dirOptions));
|
|
101
|
+
};
|
|
102
|
+
XDGAppPaths.config = function config(dirOptions) {
|
|
103
|
+
return path2.join(xdg.config(), finalPathSegment(dirOptions));
|
|
104
|
+
};
|
|
105
|
+
XDGAppPaths.data = function data(dirOptions) {
|
|
106
|
+
return path2.join(xdg.data(), finalPathSegment(dirOptions));
|
|
107
|
+
};
|
|
108
|
+
XDGAppPaths.runtime = function runtime(dirOptions) {
|
|
109
|
+
return xdg.runtime() ? path2.join(xdg.runtime(), finalPathSegment(dirOptions)) : void 0;
|
|
110
|
+
};
|
|
111
|
+
XDGAppPaths.state = function state(dirOptions) {
|
|
112
|
+
return path2.join(xdg.state(), finalPathSegment(dirOptions));
|
|
113
|
+
};
|
|
114
|
+
XDGAppPaths.configDirs = function configDirs(dirOptions) {
|
|
115
|
+
return xdg.configDirs().map(function(s) {
|
|
116
|
+
return path2.join(s, finalPathSegment(dirOptions));
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
XDGAppPaths.dataDirs = function dataDirs(dirOptions) {
|
|
120
|
+
return xdg.dataDirs().map(function(s) {
|
|
121
|
+
return path2.join(s, finalPathSegment(dirOptions));
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
return XDGAppPaths;
|
|
125
|
+
}
|
|
126
|
+
return XDGAppPaths_2;
|
|
127
|
+
}();
|
|
128
|
+
return { XDGAppPaths: new XDGAppPaths_() };
|
|
129
|
+
}
|
|
130
|
+
exports.Adapt = Adapt;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// ../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/lib/XDG.js
|
|
135
|
+
var require_XDG = __commonJS({
|
|
136
|
+
"../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/lib/XDG.js"(exports) {
|
|
137
|
+
"use strict";
|
|
138
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from) {
|
|
139
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
140
|
+
to[j] = from[i];
|
|
141
|
+
return to;
|
|
142
|
+
};
|
|
143
|
+
exports.__esModule = true;
|
|
144
|
+
exports.Adapt = void 0;
|
|
145
|
+
function Adapt(adapter_) {
|
|
146
|
+
var env = adapter_.env, osPaths = adapter_.osPaths, path2 = adapter_.path;
|
|
147
|
+
var isMacOS = /^darwin$/i.test(adapter_.process.platform);
|
|
148
|
+
var isWinOS = /^win/i.test(adapter_.process.platform);
|
|
149
|
+
function baseDir() {
|
|
150
|
+
return osPaths.home() || osPaths.temp();
|
|
151
|
+
}
|
|
152
|
+
function valOrPath(val, pathSegments) {
|
|
153
|
+
return val || path2.join.apply(path2, pathSegments);
|
|
154
|
+
}
|
|
155
|
+
var linux = function() {
|
|
156
|
+
var cache = function() {
|
|
157
|
+
return valOrPath(env.get("XDG_CACHE_HOME"), [baseDir(), ".cache"]);
|
|
158
|
+
};
|
|
159
|
+
var config = function() {
|
|
160
|
+
return valOrPath(env.get("XDG_CONFIG_HOME"), [baseDir(), ".config"]);
|
|
161
|
+
};
|
|
162
|
+
var data = function() {
|
|
163
|
+
return valOrPath(env.get("XDG_DATA_HOME"), [baseDir(), ".local", "share"]);
|
|
164
|
+
};
|
|
165
|
+
var runtime = function() {
|
|
166
|
+
return env.get("XDG_RUNTIME_DIR") || void 0;
|
|
167
|
+
};
|
|
168
|
+
var state = function() {
|
|
169
|
+
return valOrPath(env.get("XDG_STATE_HOME"), [baseDir(), ".local", "state"]);
|
|
170
|
+
};
|
|
171
|
+
return { cache, config, data, runtime, state };
|
|
172
|
+
};
|
|
173
|
+
var macos = function() {
|
|
174
|
+
var cache = function() {
|
|
175
|
+
return valOrPath(env.get("XDG_CACHE_HOME"), [baseDir(), "Library", "Caches"]);
|
|
176
|
+
};
|
|
177
|
+
var config = function() {
|
|
178
|
+
return valOrPath(env.get("XDG_CONFIG_HOME"), [baseDir(), "Library", "Preferences"]);
|
|
179
|
+
};
|
|
180
|
+
var data = function() {
|
|
181
|
+
return valOrPath(env.get("XDG_DATA_HOME"), [baseDir(), "Library", "Application Support"]);
|
|
182
|
+
};
|
|
183
|
+
var runtime = function() {
|
|
184
|
+
return env.get("XDG_RUNTIME_DIR") || void 0;
|
|
185
|
+
};
|
|
186
|
+
var state = function() {
|
|
187
|
+
return valOrPath(env.get("XDG_STATE_HOME"), [baseDir(), "Library", "State"]);
|
|
188
|
+
};
|
|
189
|
+
return { cache, config, data, runtime, state };
|
|
190
|
+
};
|
|
191
|
+
var windows = function() {
|
|
192
|
+
function appData() {
|
|
193
|
+
return valOrPath(env.get("APPDATA"), [baseDir(), "AppData", "Roaming"]);
|
|
194
|
+
}
|
|
195
|
+
function localAppData() {
|
|
196
|
+
return valOrPath(env.get("LOCALAPPDATA"), [baseDir(), "AppData", "Local"]);
|
|
197
|
+
}
|
|
198
|
+
var cache = function() {
|
|
199
|
+
return valOrPath(env.get("XDG_CACHE_HOME"), [localAppData(), "xdg.cache"]);
|
|
200
|
+
};
|
|
201
|
+
var config = function() {
|
|
202
|
+
return valOrPath(env.get("XDG_CONFIG_HOME"), [appData(), "xdg.config"]);
|
|
203
|
+
};
|
|
204
|
+
var data = function() {
|
|
205
|
+
return valOrPath(env.get("XDG_DATA_HOME"), [appData(), "xdg.data"]);
|
|
206
|
+
};
|
|
207
|
+
var runtime = function() {
|
|
208
|
+
return env.get("XDG_RUNTIME_DIR") || void 0;
|
|
209
|
+
};
|
|
210
|
+
var state = function() {
|
|
211
|
+
return valOrPath(env.get("XDG_STATE_HOME"), [localAppData(), "xdg.state"]);
|
|
212
|
+
};
|
|
213
|
+
return { cache, config, data, runtime, state };
|
|
214
|
+
};
|
|
215
|
+
var XDG_ = /* @__PURE__ */ function() {
|
|
216
|
+
function XDG_2() {
|
|
217
|
+
function XDG() {
|
|
218
|
+
return new XDG_2();
|
|
219
|
+
}
|
|
220
|
+
var extension = isMacOS ? macos() : isWinOS ? windows() : linux();
|
|
221
|
+
XDG.cache = extension.cache;
|
|
222
|
+
XDG.config = extension.config;
|
|
223
|
+
XDG.data = extension.data;
|
|
224
|
+
XDG.runtime = extension.runtime;
|
|
225
|
+
XDG.state = extension.state;
|
|
226
|
+
XDG.configDirs = function configDirs() {
|
|
227
|
+
var pathList = env.get("XDG_CONFIG_DIRS");
|
|
228
|
+
return __spreadArray([extension.config()], pathList ? pathList.split(path2.delimiter) : []);
|
|
229
|
+
};
|
|
230
|
+
XDG.dataDirs = function dataDirs() {
|
|
231
|
+
var pathList = env.get("XDG_DATA_DIRS");
|
|
232
|
+
return __spreadArray([extension.data()], pathList ? pathList.split(path2.delimiter) : []);
|
|
233
|
+
};
|
|
234
|
+
return XDG;
|
|
235
|
+
}
|
|
236
|
+
return XDG_2;
|
|
237
|
+
}();
|
|
238
|
+
return { XDG: new XDG_() };
|
|
239
|
+
}
|
|
240
|
+
exports.Adapt = Adapt;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// ../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/lib/OSPaths.js
|
|
245
|
+
var require_OSPaths = __commonJS({
|
|
246
|
+
"../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/lib/OSPaths.js"(exports) {
|
|
247
|
+
"use strict";
|
|
248
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from) {
|
|
249
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
250
|
+
to[j] = from[i];
|
|
251
|
+
return to;
|
|
252
|
+
};
|
|
253
|
+
exports.__esModule = true;
|
|
254
|
+
exports.Adapt = void 0;
|
|
255
|
+
function isEmpty(s) {
|
|
256
|
+
return !s;
|
|
257
|
+
}
|
|
258
|
+
function Adapt(adapter_) {
|
|
259
|
+
var env = adapter_.env, os = adapter_.os, path2 = adapter_.path;
|
|
260
|
+
var isWinOS = /^win/i.test(adapter_.process.platform);
|
|
261
|
+
function normalizePath(path_) {
|
|
262
|
+
return path_ ? adapter_.path.normalize(adapter_.path.join(path_, ".")) : void 0;
|
|
263
|
+
}
|
|
264
|
+
function home() {
|
|
265
|
+
var posix = function() {
|
|
266
|
+
return normalizePath((typeof os.homedir === "function" ? os.homedir() : void 0) || env.get("HOME"));
|
|
267
|
+
};
|
|
268
|
+
var windows = function() {
|
|
269
|
+
var priorityList = [
|
|
270
|
+
typeof os.homedir === "function" ? os.homedir() : void 0,
|
|
271
|
+
env.get("USERPROFILE"),
|
|
272
|
+
env.get("HOME"),
|
|
273
|
+
env.get("HOMEDRIVE") || env.get("HOMEPATH") ? path2.join(env.get("HOMEDRIVE") || "", env.get("HOMEPATH") || "") : void 0
|
|
274
|
+
];
|
|
275
|
+
return normalizePath(priorityList.find(function(v) {
|
|
276
|
+
return !isEmpty(v);
|
|
277
|
+
}));
|
|
278
|
+
};
|
|
279
|
+
return isWinOS ? windows() : posix();
|
|
280
|
+
}
|
|
281
|
+
function temp() {
|
|
282
|
+
function joinPathToBase(base, segments) {
|
|
283
|
+
return base ? path2.join.apply(path2, __spreadArray([base], segments)) : void 0;
|
|
284
|
+
}
|
|
285
|
+
function posix() {
|
|
286
|
+
var fallback = "/tmp";
|
|
287
|
+
var priorityList = [
|
|
288
|
+
typeof os.tmpdir === "function" ? os.tmpdir() : void 0,
|
|
289
|
+
env.get("TMPDIR"),
|
|
290
|
+
env.get("TEMP"),
|
|
291
|
+
env.get("TMP")
|
|
292
|
+
];
|
|
293
|
+
return normalizePath(priorityList.find(function(v) {
|
|
294
|
+
return !isEmpty(v);
|
|
295
|
+
})) || fallback;
|
|
296
|
+
}
|
|
297
|
+
function windows() {
|
|
298
|
+
var fallback = "C:\\Temp";
|
|
299
|
+
var priorityListLazy = [
|
|
300
|
+
typeof os.tmpdir === "function" ? os.tmpdir : function() {
|
|
301
|
+
return void 0;
|
|
302
|
+
},
|
|
303
|
+
function() {
|
|
304
|
+
return env.get("TEMP");
|
|
305
|
+
},
|
|
306
|
+
function() {
|
|
307
|
+
return env.get("TMP");
|
|
308
|
+
},
|
|
309
|
+
function() {
|
|
310
|
+
return joinPathToBase(env.get("LOCALAPPDATA"), ["Temp"]);
|
|
311
|
+
},
|
|
312
|
+
function() {
|
|
313
|
+
return joinPathToBase(home(), ["AppData", "Local", "Temp"]);
|
|
314
|
+
},
|
|
315
|
+
function() {
|
|
316
|
+
return joinPathToBase(env.get("ALLUSERSPROFILE"), ["Temp"]);
|
|
317
|
+
},
|
|
318
|
+
function() {
|
|
319
|
+
return joinPathToBase(env.get("SystemRoot"), ["Temp"]);
|
|
320
|
+
},
|
|
321
|
+
function() {
|
|
322
|
+
return joinPathToBase(env.get("windir"), ["Temp"]);
|
|
323
|
+
},
|
|
324
|
+
function() {
|
|
325
|
+
return joinPathToBase(env.get("SystemDrive"), ["\\", "Temp"]);
|
|
326
|
+
}
|
|
327
|
+
];
|
|
328
|
+
var v = priorityListLazy.find(function(v2) {
|
|
329
|
+
return v2 && !isEmpty(v2());
|
|
330
|
+
});
|
|
331
|
+
return v && normalizePath(v()) || fallback;
|
|
332
|
+
}
|
|
333
|
+
return isWinOS ? windows() : posix();
|
|
334
|
+
}
|
|
335
|
+
var OSPaths_ = /* @__PURE__ */ function() {
|
|
336
|
+
function OSPaths_2() {
|
|
337
|
+
function OSPaths() {
|
|
338
|
+
return new OSPaths_2();
|
|
339
|
+
}
|
|
340
|
+
OSPaths.home = home;
|
|
341
|
+
OSPaths.temp = temp;
|
|
342
|
+
return OSPaths;
|
|
343
|
+
}
|
|
344
|
+
return OSPaths_2;
|
|
345
|
+
}();
|
|
346
|
+
return { OSPaths: new OSPaths_() };
|
|
347
|
+
}
|
|
348
|
+
exports.Adapt = Adapt;
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// ../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/platform-adapters/node.js
|
|
353
|
+
var require_node = __commonJS({
|
|
354
|
+
"../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/platform-adapters/node.js"(exports) {
|
|
355
|
+
"use strict";
|
|
356
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k3, k22) {
|
|
357
|
+
if (k22 === void 0)
|
|
358
|
+
k22 = k3;
|
|
359
|
+
Object.defineProperty(o, k22, { enumerable: true, get: function() {
|
|
360
|
+
return m[k3];
|
|
361
|
+
} });
|
|
362
|
+
} : function(o, m, k3, k22) {
|
|
363
|
+
if (k22 === void 0)
|
|
364
|
+
k22 = k3;
|
|
365
|
+
o[k22] = m[k3];
|
|
366
|
+
});
|
|
367
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
368
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
369
|
+
} : function(o, v) {
|
|
370
|
+
o["default"] = v;
|
|
371
|
+
});
|
|
372
|
+
var __importStar = exports && exports.__importStar || function(mod) {
|
|
373
|
+
if (mod && mod.__esModule)
|
|
374
|
+
return mod;
|
|
375
|
+
var result = {};
|
|
376
|
+
if (mod != null) {
|
|
377
|
+
for (var k3 in mod)
|
|
378
|
+
if (k3 !== "default" && Object.prototype.hasOwnProperty.call(mod, k3))
|
|
379
|
+
__createBinding(result, mod, k3);
|
|
380
|
+
}
|
|
381
|
+
__setModuleDefault(result, mod);
|
|
382
|
+
return result;
|
|
383
|
+
};
|
|
384
|
+
exports.__esModule = true;
|
|
385
|
+
exports.adapter = void 0;
|
|
386
|
+
var os = __importStar(__require("os"));
|
|
387
|
+
var path2 = __importStar(__require("path"));
|
|
388
|
+
exports.adapter = {
|
|
389
|
+
atImportPermissions: { env: true },
|
|
390
|
+
env: {
|
|
391
|
+
get: function(s) {
|
|
392
|
+
return process.env[s];
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
os,
|
|
396
|
+
path: path2,
|
|
397
|
+
process
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
// ../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/mod.cjs.js
|
|
403
|
+
var require_mod_cjs = __commonJS({
|
|
404
|
+
"../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/mod.cjs.js"(exports, module) {
|
|
405
|
+
"use strict";
|
|
406
|
+
var OSPaths_js_1 = require_OSPaths();
|
|
407
|
+
var node_js_1 = require_node();
|
|
408
|
+
module.exports = OSPaths_js_1.Adapt(node_js_1.adapter).OSPaths;
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// ../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/platform-adapters/node.js
|
|
413
|
+
var require_node2 = __commonJS({
|
|
414
|
+
"../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/platform-adapters/node.js"(exports) {
|
|
415
|
+
"use strict";
|
|
416
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k3, k22) {
|
|
417
|
+
if (k22 === void 0)
|
|
418
|
+
k22 = k3;
|
|
419
|
+
Object.defineProperty(o, k22, { enumerable: true, get: function() {
|
|
420
|
+
return m[k3];
|
|
421
|
+
} });
|
|
422
|
+
} : function(o, m, k3, k22) {
|
|
423
|
+
if (k22 === void 0)
|
|
424
|
+
k22 = k3;
|
|
425
|
+
o[k22] = m[k3];
|
|
426
|
+
});
|
|
427
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
428
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
429
|
+
} : function(o, v) {
|
|
430
|
+
o["default"] = v;
|
|
431
|
+
});
|
|
432
|
+
var __importStar = exports && exports.__importStar || function(mod) {
|
|
433
|
+
if (mod && mod.__esModule)
|
|
434
|
+
return mod;
|
|
435
|
+
var result = {};
|
|
436
|
+
if (mod != null) {
|
|
437
|
+
for (var k3 in mod)
|
|
438
|
+
if (k3 !== "default" && Object.prototype.hasOwnProperty.call(mod, k3))
|
|
439
|
+
__createBinding(result, mod, k3);
|
|
440
|
+
}
|
|
441
|
+
__setModuleDefault(result, mod);
|
|
442
|
+
return result;
|
|
443
|
+
};
|
|
444
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
445
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
446
|
+
};
|
|
447
|
+
exports.__esModule = true;
|
|
448
|
+
exports.adapter = void 0;
|
|
449
|
+
var path2 = __importStar(__require("path"));
|
|
450
|
+
var os_paths_1 = __importDefault(require_mod_cjs());
|
|
451
|
+
exports.adapter = {
|
|
452
|
+
atImportPermissions: { env: true },
|
|
453
|
+
env: {
|
|
454
|
+
get: function(s) {
|
|
455
|
+
return process.env[s];
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
osPaths: os_paths_1["default"],
|
|
459
|
+
path: path2,
|
|
460
|
+
process
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
// ../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/mod.cjs.js
|
|
466
|
+
var require_mod_cjs2 = __commonJS({
|
|
467
|
+
"../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/mod.cjs.js"(exports, module) {
|
|
468
|
+
"use strict";
|
|
469
|
+
var XDG_js_1 = require_XDG();
|
|
470
|
+
var node_js_1 = require_node2();
|
|
471
|
+
module.exports = XDG_js_1.Adapt(node_js_1.adapter).XDG;
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
// ../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/platform-adapters/node.js
|
|
476
|
+
var require_node3 = __commonJS({
|
|
477
|
+
"../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/platform-adapters/node.js"(exports) {
|
|
478
|
+
"use strict";
|
|
479
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k3, k22) {
|
|
480
|
+
if (k22 === void 0)
|
|
481
|
+
k22 = k3;
|
|
482
|
+
Object.defineProperty(o, k22, { enumerable: true, get: function() {
|
|
483
|
+
return m[k3];
|
|
484
|
+
} });
|
|
485
|
+
} : function(o, m, k3, k22) {
|
|
486
|
+
if (k22 === void 0)
|
|
487
|
+
k22 = k3;
|
|
488
|
+
o[k22] = m[k3];
|
|
489
|
+
});
|
|
490
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
491
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
492
|
+
} : function(o, v) {
|
|
493
|
+
o["default"] = v;
|
|
494
|
+
});
|
|
495
|
+
var __importStar = exports && exports.__importStar || function(mod) {
|
|
496
|
+
if (mod && mod.__esModule)
|
|
497
|
+
return mod;
|
|
498
|
+
var result = {};
|
|
499
|
+
if (mod != null) {
|
|
500
|
+
for (var k3 in mod)
|
|
501
|
+
if (k3 !== "default" && Object.prototype.hasOwnProperty.call(mod, k3))
|
|
502
|
+
__createBinding(result, mod, k3);
|
|
503
|
+
}
|
|
504
|
+
__setModuleDefault(result, mod);
|
|
505
|
+
return result;
|
|
506
|
+
};
|
|
507
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
508
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
509
|
+
};
|
|
510
|
+
exports.__esModule = true;
|
|
511
|
+
exports.adapter = void 0;
|
|
512
|
+
var path2 = __importStar(__require("path"));
|
|
513
|
+
var xdg_portable_1 = __importDefault(require_mod_cjs2());
|
|
514
|
+
exports.adapter = {
|
|
515
|
+
atImportPermissions: { env: true, read: true },
|
|
516
|
+
meta: {
|
|
517
|
+
mainFilename: function() {
|
|
518
|
+
var requireMain = typeof __require !== "undefined" && __require !== null && __require.main ? __require.main : { filename: void 0 };
|
|
519
|
+
var requireMainFilename = requireMain.filename;
|
|
520
|
+
var filename = (requireMainFilename !== process.execArgv[0] ? requireMainFilename : void 0) || (typeof process._eval === "undefined" ? process.argv[1] : void 0);
|
|
521
|
+
return filename;
|
|
522
|
+
},
|
|
523
|
+
pkgMainFilename: function() {
|
|
524
|
+
return process.pkg ? process.execPath : void 0;
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
path: path2,
|
|
528
|
+
process,
|
|
529
|
+
xdg: xdg_portable_1["default"]
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// ../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/mod.cjs.js
|
|
535
|
+
var require_mod_cjs3 = __commonJS({
|
|
536
|
+
"../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/mod.cjs.js"(exports, module) {
|
|
537
|
+
"use strict";
|
|
538
|
+
var XDGAppPaths_js_1 = require_XDGAppPaths();
|
|
539
|
+
var node_js_1 = require_node3();
|
|
540
|
+
module.exports = XDGAppPaths_js_1.Adapt(node_js_1.adapter).XDGAppPaths;
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
// commands/index.ts
|
|
545
|
+
import { defineCommand as defineCommand2, runMain } from "citty";
|
|
546
|
+
|
|
547
|
+
// package.json
|
|
548
|
+
var version = "0.1.0";
|
|
549
|
+
|
|
550
|
+
// commands/deploy.ts
|
|
551
|
+
import { defineCommand, showUsage } from "citty";
|
|
552
|
+
|
|
553
|
+
// ../../common/cli-utils/error.ts
|
|
554
|
+
import k from "kleur";
|
|
555
|
+
function errorAndExit(message) {
|
|
556
|
+
console.error(message);
|
|
557
|
+
console.log("");
|
|
558
|
+
console.log(`${k.green(k.bold("Give us feedback"))} https://github.com/prisma/security-rules-feedback`);
|
|
559
|
+
console.log(`${k.magenta(k.bold("Join the discussion"))} https://discord.gg/community`);
|
|
560
|
+
process.exit(1);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// ../../common/cli-utils/getSchemaUrl.ts
|
|
564
|
+
import { isAbsolute, join } from "path";
|
|
565
|
+
import { default as prismaInternals } from "@prisma/internals";
|
|
566
|
+
var { getSchemaWithPath, getConfig, loadEnvFile, resolveUrl, getEffectiveUrl } = prismaInternals;
|
|
567
|
+
async function getSchemaUrl(schemaArg) {
|
|
568
|
+
let schemaPath = schemaArg;
|
|
569
|
+
if (schemaArg && isAbsolute(schemaArg) === false) {
|
|
570
|
+
schemaPath = join(process.cwd(), schemaArg);
|
|
571
|
+
}
|
|
572
|
+
await loadEnvFile({ schemaPath, printMessage: true });
|
|
573
|
+
const { schemas: datamodel } = await getSchemaWithPath(schemaPath);
|
|
574
|
+
const config = await getConfig({ datamodel, ignoreEnvVarErrors: false });
|
|
575
|
+
const datasource = config.datasources[0];
|
|
576
|
+
if (!datasource) {
|
|
577
|
+
return errorAndExit("No datasource found in schema.prisma");
|
|
578
|
+
}
|
|
579
|
+
return resolveUrl(getEffectiveUrl(datasource));
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// ../../common/cli-utils/getTokenOrError.ts
|
|
583
|
+
import { join as join2 } from "path";
|
|
584
|
+
import { readFile } from "fs/promises";
|
|
585
|
+
import { green } from "kleur/colors";
|
|
586
|
+
|
|
587
|
+
// ../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/esm-wrapper/mod.esm.js
|
|
588
|
+
var mod_esm_exports = {};
|
|
589
|
+
__export(mod_esm_exports, {
|
|
590
|
+
default: () => mod_esm_default
|
|
591
|
+
});
|
|
592
|
+
var import_mod_cjs = __toESM(require_mod_cjs3(), 1);
|
|
593
|
+
__reExport(mod_esm_exports, __toESM(require_mod_cjs3(), 1));
|
|
594
|
+
var mod_esm_default = import_mod_cjs.default;
|
|
595
|
+
|
|
596
|
+
// ../../node_modules/.pnpm/package-manager-detector@0.2.8/node_modules/package-manager-detector/dist/commands.mjs
|
|
597
|
+
function npmRun(agent) {
|
|
598
|
+
return (args) => {
|
|
599
|
+
if (args.length > 1) {
|
|
600
|
+
return [agent, "run", args[0], "--", ...args.slice(1)];
|
|
601
|
+
} else {
|
|
602
|
+
return [agent, "run", args[0]];
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
function denoExecute() {
|
|
607
|
+
return (args) => {
|
|
608
|
+
return ["deno", "run", `npm:${args[0]}`, ...args.slice(1)];
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
var npm = {
|
|
612
|
+
"agent": ["npm", 0],
|
|
613
|
+
"run": npmRun("npm"),
|
|
614
|
+
"install": ["npm", "i", 0],
|
|
615
|
+
"frozen": ["npm", "ci"],
|
|
616
|
+
"global": ["npm", "i", "-g", 0],
|
|
617
|
+
"add": ["npm", "i", 0],
|
|
618
|
+
"upgrade": ["npm", "update", 0],
|
|
619
|
+
"upgrade-interactive": null,
|
|
620
|
+
"execute": ["npx", 0],
|
|
621
|
+
"execute-local": ["npx", 0],
|
|
622
|
+
"uninstall": ["npm", "uninstall", 0],
|
|
623
|
+
"global_uninstall": ["npm", "uninstall", "-g", 0]
|
|
624
|
+
};
|
|
625
|
+
var yarn = {
|
|
626
|
+
"agent": ["yarn", 0],
|
|
627
|
+
"run": ["yarn", "run", 0],
|
|
628
|
+
"install": ["yarn", "install", 0],
|
|
629
|
+
"frozen": ["yarn", "install", "--frozen-lockfile"],
|
|
630
|
+
"global": ["yarn", "global", "add", 0],
|
|
631
|
+
"add": ["yarn", "add", 0],
|
|
632
|
+
"upgrade": ["yarn", "upgrade", 0],
|
|
633
|
+
"upgrade-interactive": ["yarn", "upgrade-interactive", 0],
|
|
634
|
+
"execute": ["npx", 0],
|
|
635
|
+
"execute-local": ["yarn", "exec", 0],
|
|
636
|
+
"uninstall": ["yarn", "remove", 0],
|
|
637
|
+
"global_uninstall": ["yarn", "global", "remove", 0]
|
|
638
|
+
};
|
|
639
|
+
var yarnBerry = {
|
|
640
|
+
...yarn,
|
|
641
|
+
"frozen": ["yarn", "install", "--immutable"],
|
|
642
|
+
"upgrade": ["yarn", "up", 0],
|
|
643
|
+
"upgrade-interactive": ["yarn", "up", "-i", 0],
|
|
644
|
+
"execute": ["yarn", "dlx", 0],
|
|
645
|
+
"execute-local": ["yarn", "exec", 0],
|
|
646
|
+
// Yarn 2+ removed 'global', see https://github.com/yarnpkg/berry/issues/821
|
|
647
|
+
"global": ["npm", "i", "-g", 0],
|
|
648
|
+
"global_uninstall": ["npm", "uninstall", "-g", 0]
|
|
649
|
+
};
|
|
650
|
+
var pnpm = {
|
|
651
|
+
"agent": ["pnpm", 0],
|
|
652
|
+
"run": ["pnpm", "run", 0],
|
|
653
|
+
"install": ["pnpm", "i", 0],
|
|
654
|
+
"frozen": ["pnpm", "i", "--frozen-lockfile"],
|
|
655
|
+
"global": ["pnpm", "add", "-g", 0],
|
|
656
|
+
"add": ["pnpm", "add", 0],
|
|
657
|
+
"upgrade": ["pnpm", "update", 0],
|
|
658
|
+
"upgrade-interactive": ["pnpm", "update", "-i", 0],
|
|
659
|
+
"execute": ["pnpm", "dlx", 0],
|
|
660
|
+
"execute-local": ["pnpm", "exec", 0],
|
|
661
|
+
"uninstall": ["pnpm", "remove", 0],
|
|
662
|
+
"global_uninstall": ["pnpm", "remove", "--global", 0]
|
|
663
|
+
};
|
|
664
|
+
var bun = {
|
|
665
|
+
"agent": ["bun", 0],
|
|
666
|
+
"run": ["bun", "run", 0],
|
|
667
|
+
"install": ["bun", "install", 0],
|
|
668
|
+
"frozen": ["bun", "install", "--frozen-lockfile"],
|
|
669
|
+
"global": ["bun", "add", "-g", 0],
|
|
670
|
+
"add": ["bun", "add", 0],
|
|
671
|
+
"upgrade": ["bun", "update", 0],
|
|
672
|
+
"upgrade-interactive": ["bun", "update", 0],
|
|
673
|
+
"execute": ["bun", "x", 0],
|
|
674
|
+
"execute-local": ["bun", "x", 0],
|
|
675
|
+
"uninstall": ["bun", "remove", 0],
|
|
676
|
+
"global_uninstall": ["bun", "remove", "-g", 0]
|
|
677
|
+
};
|
|
678
|
+
var deno = {
|
|
679
|
+
"agent": ["deno", 0],
|
|
680
|
+
"run": ["deno", "task", 0],
|
|
681
|
+
"install": ["deno", "install", 0],
|
|
682
|
+
"frozen": ["deno", "install", "--frozen"],
|
|
683
|
+
"global": ["deno", "install", "-g", 0],
|
|
684
|
+
"add": ["deno", "add", 0],
|
|
685
|
+
"upgrade": ["deno", "outdated", "--update", 0],
|
|
686
|
+
"upgrade-interactive": ["deno", "outdated", "--update", 0],
|
|
687
|
+
"execute": denoExecute(),
|
|
688
|
+
"execute-local": ["deno", "task", "--eval", 0],
|
|
689
|
+
"uninstall": ["deno", "remove", 0],
|
|
690
|
+
"global_uninstall": ["deno", "uninstall", "-g", 0]
|
|
691
|
+
};
|
|
692
|
+
var COMMANDS = {
|
|
693
|
+
"npm": npm,
|
|
694
|
+
"yarn": yarn,
|
|
695
|
+
"yarn@berry": yarnBerry,
|
|
696
|
+
"pnpm": pnpm,
|
|
697
|
+
// pnpm v6.x or below
|
|
698
|
+
"pnpm@6": {
|
|
699
|
+
...pnpm,
|
|
700
|
+
run: npmRun("pnpm")
|
|
701
|
+
},
|
|
702
|
+
"bun": bun,
|
|
703
|
+
"deno": deno
|
|
704
|
+
};
|
|
705
|
+
function resolveCommand(agent, command, args) {
|
|
706
|
+
const value = COMMANDS[agent][command];
|
|
707
|
+
return constructCommand(value, args);
|
|
708
|
+
}
|
|
709
|
+
function constructCommand(value, args) {
|
|
710
|
+
if (value == null)
|
|
711
|
+
return null;
|
|
712
|
+
const list = typeof value === "function" ? value(args) : value.flatMap((v) => {
|
|
713
|
+
if (typeof v === "number")
|
|
714
|
+
return args;
|
|
715
|
+
return [v];
|
|
716
|
+
});
|
|
717
|
+
return {
|
|
718
|
+
command: list[0],
|
|
719
|
+
args: list.slice(1)
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// ../../node_modules/.pnpm/package-manager-detector@0.2.8/node_modules/package-manager-detector/dist/constants.mjs
|
|
724
|
+
var AGENTS = [
|
|
725
|
+
"npm",
|
|
726
|
+
"yarn",
|
|
727
|
+
"yarn@berry",
|
|
728
|
+
"pnpm",
|
|
729
|
+
"pnpm@6",
|
|
730
|
+
"bun",
|
|
731
|
+
"deno"
|
|
732
|
+
];
|
|
733
|
+
var LOCKS = {
|
|
734
|
+
"bun.lock": "bun",
|
|
735
|
+
"bun.lockb": "bun",
|
|
736
|
+
"deno.lock": "deno",
|
|
737
|
+
"pnpm-lock.yaml": "pnpm",
|
|
738
|
+
"yarn.lock": "yarn",
|
|
739
|
+
"package-lock.json": "npm",
|
|
740
|
+
"npm-shrinkwrap.json": "npm"
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
// ../../node_modules/.pnpm/package-manager-detector@0.2.8/node_modules/package-manager-detector/dist/detect.mjs
|
|
744
|
+
import fs from "fs";
|
|
745
|
+
import fsPromises from "fs/promises";
|
|
746
|
+
import path from "path";
|
|
747
|
+
import process2 from "process";
|
|
748
|
+
async function detect(options = {}) {
|
|
749
|
+
const { cwd, onUnknown } = options;
|
|
750
|
+
for (const directory of lookup(cwd)) {
|
|
751
|
+
for (const lock of Object.keys(LOCKS)) {
|
|
752
|
+
if (await fileExists(path.join(directory, lock))) {
|
|
753
|
+
const name = LOCKS[lock];
|
|
754
|
+
const result2 = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
|
|
755
|
+
if (result2)
|
|
756
|
+
return result2;
|
|
757
|
+
else
|
|
758
|
+
return { name, agent: name };
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
const result = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
|
|
762
|
+
if (result)
|
|
763
|
+
return result;
|
|
764
|
+
}
|
|
765
|
+
return null;
|
|
766
|
+
}
|
|
767
|
+
function* lookup(cwd = process2.cwd()) {
|
|
768
|
+
let directory = path.resolve(cwd);
|
|
769
|
+
const { root } = path.parse(directory);
|
|
770
|
+
while (directory && directory !== root) {
|
|
771
|
+
yield directory;
|
|
772
|
+
directory = path.dirname(directory);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
async function parsePackageJson(filepath, onUnknown) {
|
|
776
|
+
return !filepath || !await fileExists(filepath) ? null : handlePackageManager(filepath, onUnknown);
|
|
777
|
+
}
|
|
778
|
+
function handlePackageManager(filepath, onUnknown) {
|
|
779
|
+
try {
|
|
780
|
+
const pkg = JSON.parse(fs.readFileSync(filepath, "utf8"));
|
|
781
|
+
let agent;
|
|
782
|
+
if (typeof pkg.packageManager === "string") {
|
|
783
|
+
const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
|
|
784
|
+
let version2 = ver;
|
|
785
|
+
if (name === "yarn" && Number.parseInt(ver) > 1) {
|
|
786
|
+
agent = "yarn@berry";
|
|
787
|
+
version2 = "berry";
|
|
788
|
+
return { name, agent, version: version2 };
|
|
789
|
+
} else if (name === "pnpm" && Number.parseInt(ver) < 7) {
|
|
790
|
+
agent = "pnpm@6";
|
|
791
|
+
return { name, agent, version: version2 };
|
|
792
|
+
} else if (AGENTS.includes(name)) {
|
|
793
|
+
agent = name;
|
|
794
|
+
return { name, agent, version: version2 };
|
|
795
|
+
} else {
|
|
796
|
+
return onUnknown?.(pkg.packageManager) ?? null;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
} catch {
|
|
800
|
+
}
|
|
801
|
+
return null;
|
|
802
|
+
}
|
|
803
|
+
async function fileExists(filePath) {
|
|
804
|
+
try {
|
|
805
|
+
const stats = await fsPromises.stat(filePath);
|
|
806
|
+
if (stats.isFile()) {
|
|
807
|
+
return true;
|
|
808
|
+
}
|
|
809
|
+
} catch {
|
|
810
|
+
}
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// ../../common/cli-utils/getCommand.ts
|
|
815
|
+
async function getCommand(command, args) {
|
|
816
|
+
const { agent } = await detect() ?? { agent: "npm" };
|
|
817
|
+
const result = resolveCommand(agent, command, args);
|
|
818
|
+
if (result === null) {
|
|
819
|
+
return `${command} ${args.join(" ")}`;
|
|
820
|
+
}
|
|
821
|
+
return `${result.command} ${result.args.join(" ")}`;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
// ../../common/cli-utils/getTokenOrError.ts
|
|
825
|
+
var credentialsFileDirectoryPath = new mod_esm_default("prisma-platform-cli").config();
|
|
826
|
+
var credentialsFilePath = join2(credentialsFileDirectoryPath, "auth.json");
|
|
827
|
+
async function getPlatformUnauthorizedError() {
|
|
828
|
+
const cmd = await getCommand("execute-local", ["prisma", "platform", "auth", "login", "--early-access"]);
|
|
829
|
+
return errorAndExit(
|
|
830
|
+
`No platform credentials found. Run ${green(cmd)} first. Alternatively you can provide a token via the \`--token\` or \`-t\` parameters, or set the 'PRISMA_TOKEN' environment variable with a token.`
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
async function getTokenOrError() {
|
|
834
|
+
try {
|
|
835
|
+
const credentialsContent = await readFile(credentialsFilePath, "utf-8");
|
|
836
|
+
const { token } = JSON.parse(credentialsContent);
|
|
837
|
+
return token;
|
|
838
|
+
} catch {
|
|
839
|
+
throw await getPlatformUnauthorizedError();
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// commands/deploy.ts
|
|
844
|
+
import { hc } from "hono/client";
|
|
845
|
+
import k2 from "kleur";
|
|
846
|
+
|
|
847
|
+
// bundler/bundle.ts
|
|
848
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
849
|
+
import * as esbuild from "esbuild";
|
|
850
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
851
|
+
import { builtinModules } from "module";
|
|
852
|
+
import { dirname, join as join3, resolve } from "path";
|
|
853
|
+
var external = [...builtinModules, ...builtinModules.map((m) => `node:${m}`)];
|
|
854
|
+
async function bundle(args) {
|
|
855
|
+
const { file, tsconfig, absWorkingDir } = args;
|
|
856
|
+
const result = await esbuild.build({
|
|
857
|
+
entryPoints: [`${import.meta.dirname}/template.js`],
|
|
858
|
+
conditions: ["workerd", "worker", "browser", "import", "require", "default"],
|
|
859
|
+
plugins: [injectUserFilePlugin({ file }), injectPrismaEdgeClientPlugin()],
|
|
860
|
+
platform: "neutral",
|
|
861
|
+
// !important
|
|
862
|
+
logLevel: "error",
|
|
863
|
+
format: "esm",
|
|
864
|
+
absWorkingDir,
|
|
865
|
+
bundle: true,
|
|
866
|
+
write: false,
|
|
867
|
+
external,
|
|
868
|
+
tsconfig
|
|
869
|
+
});
|
|
870
|
+
const output = result.outputFiles[0]?.contents ?? [];
|
|
871
|
+
const bundle2 = Buffer2.from(output).toString("utf-8");
|
|
872
|
+
return bundle2;
|
|
873
|
+
}
|
|
874
|
+
function injectUserFilePlugin(args) {
|
|
875
|
+
const { file } = args;
|
|
876
|
+
return {
|
|
877
|
+
name: "rules-inject-user-file",
|
|
878
|
+
setup(build2) {
|
|
879
|
+
build2.onResolve({ filter: /rules-path-to-prisma-client/ }, () => {
|
|
880
|
+
return { path: `${build2.initialOptions.absWorkingDir}/${file}` };
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
function isJsFile(path2) {
|
|
886
|
+
return /\.(?:js|mjs|cjs|ts|tsx|jsx|cts|ctsx|cjsx|mts|mtsx|mjsx)$/.test(path2);
|
|
887
|
+
}
|
|
888
|
+
function injectPrismaEdgeClientPlugin() {
|
|
889
|
+
return {
|
|
890
|
+
name: "rules-inject-prisma-edge-client",
|
|
891
|
+
setup(build2) {
|
|
892
|
+
build2.onResolve({ filter: /.*/ }, async ({ resolveDir, path: path2 }) => {
|
|
893
|
+
const fullPath = resolve(join3(resolveDir, path2));
|
|
894
|
+
const dirPath = isJsFile(path2) ? dirname(fullPath) : fullPath;
|
|
895
|
+
const pkgPath = join3(dirPath, "package.json");
|
|
896
|
+
const pkg = await readFile2(pkgPath, "utf-8").then((c) => JSON.parse(c)).catch(() => ({}));
|
|
897
|
+
if (pkg.name?.startsWith("prisma-client-")) {
|
|
898
|
+
return { path: join3(dirPath, "edge.js") };
|
|
899
|
+
}
|
|
900
|
+
return {};
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// utils/constants.ts
|
|
907
|
+
var PROD_DEPLOYER_URL = "https://rules-deployer.datacdn.workers.dev/";
|
|
908
|
+
|
|
909
|
+
// commands/deploy.ts
|
|
910
|
+
var deploy = defineCommand({
|
|
911
|
+
meta: {
|
|
912
|
+
name: "deploy",
|
|
913
|
+
description: "Deploy your security rules"
|
|
914
|
+
},
|
|
915
|
+
args: {
|
|
916
|
+
name: {
|
|
917
|
+
type: "positional",
|
|
918
|
+
required: true,
|
|
919
|
+
description: "Name of your security rules"
|
|
920
|
+
},
|
|
921
|
+
file: {
|
|
922
|
+
type: "string",
|
|
923
|
+
required: true,
|
|
924
|
+
alias: "f",
|
|
925
|
+
description: "Path to your exported rules file"
|
|
926
|
+
},
|
|
927
|
+
tsconfig: {
|
|
928
|
+
type: "string",
|
|
929
|
+
description: "Path to your tsconfig file"
|
|
930
|
+
},
|
|
931
|
+
schema: {
|
|
932
|
+
type: "string",
|
|
933
|
+
description: "Path to your schema.prisma file"
|
|
934
|
+
},
|
|
935
|
+
help: {
|
|
936
|
+
type: "boolean",
|
|
937
|
+
alias: "h",
|
|
938
|
+
default: false
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
async run(context) {
|
|
942
|
+
const { schema, help, endpoint } = context.args;
|
|
943
|
+
const { name } = context.args;
|
|
944
|
+
const endpointUrl = endpoint ?? PROD_DEPLOYER_URL;
|
|
945
|
+
if (help)
|
|
946
|
+
return await showUsage(deploy);
|
|
947
|
+
const url = await getSchemaUrl(schema);
|
|
948
|
+
const token = await getTokenOrError();
|
|
949
|
+
const code = await getCode(context);
|
|
950
|
+
const client = hc(endpointUrl);
|
|
951
|
+
const response = await client.deploy.$post({
|
|
952
|
+
json: { url, code, name, token }
|
|
953
|
+
});
|
|
954
|
+
const { error, data } = await response.json();
|
|
955
|
+
if (error) {
|
|
956
|
+
return errorAndExit(error);
|
|
957
|
+
}
|
|
958
|
+
if (data) {
|
|
959
|
+
logSuccessMessage(data);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
async function getCode(ctx) {
|
|
964
|
+
const { args } = ctx;
|
|
965
|
+
const { file, tsconfig } = args;
|
|
966
|
+
return await bundle({
|
|
967
|
+
file,
|
|
968
|
+
tsconfig,
|
|
969
|
+
absWorkingDir: process.cwd()
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
function logSuccessMessage(args) {
|
|
973
|
+
const { publicKey } = args;
|
|
974
|
+
const message = `Your new Policy rules were successfully deployed!
|
|
975
|
+
|
|
976
|
+
You can enforce these rules with your public key:
|
|
977
|
+
"${publicKey}"
|
|
978
|
+
|
|
979
|
+
\`\`\`ts
|
|
980
|
+
import { RulesProtectedClient } from "@prisma/extension-rules";
|
|
981
|
+
|
|
982
|
+
const rulesClient = new RulesProtectedClient({
|
|
983
|
+
publicKey: "${publicKey}",
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
// run your queries as usual
|
|
987
|
+
await rulesClient.user.findMany()
|
|
988
|
+
\`\`\``;
|
|
989
|
+
console.log(message);
|
|
990
|
+
console.log("");
|
|
991
|
+
console.log(`${k2.green(k2.bold("Give us feedback"))} https://github.com/prisma/security-rules-feedback`);
|
|
992
|
+
console.log(`${k2.magenta(k2.bold("Join the discussion"))} https://pris.ly/discord`);
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// commands/index.ts
|
|
996
|
+
var main = defineCommand2({
|
|
997
|
+
meta: {
|
|
998
|
+
name: "rules",
|
|
999
|
+
description: "CLI for managing your security rules",
|
|
1000
|
+
version
|
|
1001
|
+
},
|
|
1002
|
+
subCommands: {
|
|
1003
|
+
deploy
|
|
1004
|
+
}
|
|
1005
|
+
});
|
|
1006
|
+
function run(rawArgs) {
|
|
1007
|
+
void runMain(main, { rawArgs });
|
|
1008
|
+
}
|
|
1009
|
+
export {
|
|
1010
|
+
run
|
|
1011
|
+
};
|
package/dist/template.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { withAccelerate } from "@prisma/extension-accelerate";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the Prisma Client that will be bundled/injected into it. Performs
|
|
7
|
+
* the necessary setup to enable the Prisma Client to work with the executor.
|
|
8
|
+
* @type {import("../../deployer/user-worker/bundle.mjs").resolvePrismaClient}
|
|
9
|
+
*/
|
|
10
|
+
export async function resolvePrismaClient(ctx) {
|
|
11
|
+
const { env, request } = ctx;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
/** @type {any} **/
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
// @ts-ignore this is injected by the runtime
|
|
17
|
+
let { prisma } = await import("./rules-path-to-prisma-client.mjs");
|
|
18
|
+
|
|
19
|
+
const dbURL = new URL(env.DATABASE_URL ?? "MISSING_DATABASE_URL");
|
|
20
|
+
const itx = new URL(request.url).searchParams.get("itx");
|
|
21
|
+
|
|
22
|
+
const engine = prisma._originalClient._engine;
|
|
23
|
+
const dsName = Object.keys(engine.inlineDatasources ?? {})[0] ?? "db";
|
|
24
|
+
engine.config.overrideDatasources = { [dsName]: { url: dbURL.toString() } };
|
|
25
|
+
|
|
26
|
+
prisma = prisma.$extends(withAccelerate());
|
|
27
|
+
prisma = itx ? await getItxPrismaClient(prisma, JSON.parse(itx)) : prisma;
|
|
28
|
+
|
|
29
|
+
return [null, prisma];
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (error instanceof Error) {
|
|
32
|
+
return [error.message, null];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return [String(error), null];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// TODO: build this into the prisma client directly, at least as a private api or a test
|
|
40
|
+
async function getItxPrismaClient(/** @type {any} */ prisma, /** @type {any} */ options) {
|
|
41
|
+
const optionsWithDefaults = {
|
|
42
|
+
maxWait: options?.maxWait ?? prisma._engineConfig.transactionOptions.maxWait,
|
|
43
|
+
timeout: options?.timeout ?? prisma._engineConfig.transactionOptions.timeout,
|
|
44
|
+
isolationLevel: options?.isolationLevel ?? prisma._engineConfig.transactionOptions.isolationLevel,
|
|
45
|
+
};
|
|
46
|
+
const headers = { traceparent: prisma._tracingHelper.getTraceParent() };
|
|
47
|
+
const info = await prisma._engine.transaction("start", headers, optionsWithDefaults);
|
|
48
|
+
const tx = prisma._createItxClient({ kind: "itx", ...info });
|
|
49
|
+
|
|
50
|
+
return Object.assign(tx, {
|
|
51
|
+
$commit() {
|
|
52
|
+
return prisma._engine.transaction("commit", headers, info);
|
|
53
|
+
},
|
|
54
|
+
$rollback() {
|
|
55
|
+
return prisma._engine.transaction("rollback", headers, info);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prisma/cli-security-rules",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"description": "Policy CLI for Prisma",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./*": "./*"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsup",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"lint": "eslint --fix .",
|
|
19
|
+
"test": ""
|
|
20
|
+
},
|
|
21
|
+
"keywords": [],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@prisma/internals": "6.2.1",
|
|
24
|
+
"citty": "0.1.6",
|
|
25
|
+
"esbuild": "0.24.2",
|
|
26
|
+
"hono": "4.6.17",
|
|
27
|
+
"kleur": "4.1.5",
|
|
28
|
+
"ofetch": "1.4.1"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@prisma/client": "6.2.1",
|
|
32
|
+
"@types/node": "22.3.0",
|
|
33
|
+
"common-cli-utils": "workspace:^",
|
|
34
|
+
"npm-run-all": "4.1.5",
|
|
35
|
+
"rules-deployer": "workspace:^",
|
|
36
|
+
"rules-playground": "workspace:^",
|
|
37
|
+
"prisma": "6.2.1",
|
|
38
|
+
"tsup": "8.0.2",
|
|
39
|
+
"tsx": "4.17.0",
|
|
40
|
+
"typescript": "5.5.4",
|
|
41
|
+
"vitest": "1.5.3",
|
|
42
|
+
"wrangler": "3.105.1",
|
|
43
|
+
"zod": "3.24.1"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@prisma/extension-accelerate": ">=1.2.2",
|
|
47
|
+
"prisma": ">=6.2.0"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=22"
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"dist"
|
|
54
|
+
]
|
|
55
|
+
}
|