initial commit

This commit is contained in:
Bhavnoor Singh Saroya 2025-01-07 04:45:03 -08:00
commit b25eb51ff0
280 changed files with 178550 additions and 0 deletions

View file

@ -0,0 +1,5 @@
export declare enum BinaryType {
QueryEngineBinary = "query-engine",
QueryEngineLibrary = "libquery-engine",
SchemaEngineBinary = "schema-engine"
}

View file

@ -0,0 +1,25 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var BinaryType_exports = {};
__export(BinaryType_exports, {
BinaryType: () => import_chunk_X37PZICB.BinaryType
});
module.exports = __toCommonJS(BinaryType_exports);
var import_chunk_X37PZICB = require("./chunk-X37PZICB.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");

View file

@ -0,0 +1 @@
export declare function chmodPlusX(file: string): void;

View file

@ -0,0 +1,25 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var chmodPlusX_exports = {};
__export(chmodPlusX_exports, {
chmodPlusX: () => import_chunk_MX3HXAU2.chmodPlusX
});
module.exports = __toCommonJS(chmodPlusX_exports);
var import_chunk_MX3HXAU2 = require("./chunk-MX3HXAU2.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");

View file

@ -0,0 +1,161 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var chunk_4LX3XBNY_exports = {};
__export(chunk_4LX3XBNY_exports, {
getBar: () => getBar
});
module.exports = __toCommonJS(chunk_4LX3XBNY_exports);
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");
var require_node_progress = (0, import_chunk_AH6QHEOA.__commonJS)({
"../../node_modules/.pnpm/progress@2.0.3/node_modules/progress/lib/node-progress.js"(exports, module2) {
"use strict";
exports = module2.exports = ProgressBar;
function ProgressBar(fmt, options) {
this.stream = options.stream || process.stderr;
if (typeof options == "number") {
var total = options;
options = {};
options.total = total;
} else {
options = options || {};
if ("string" != typeof fmt) throw new Error("format required");
if ("number" != typeof options.total) throw new Error("total required");
}
this.fmt = fmt;
this.curr = options.curr || 0;
this.total = options.total;
this.width = options.width || this.total;
this.clear = options.clear;
this.chars = {
complete: options.complete || "=",
incomplete: options.incomplete || "-",
head: options.head || (options.complete || "=")
};
this.renderThrottle = options.renderThrottle !== 0 ? options.renderThrottle || 16 : 0;
this.lastRender = -Infinity;
this.callback = options.callback || function() {
};
this.tokens = {};
this.lastDraw = "";
}
ProgressBar.prototype.tick = function(len, tokens) {
if (len !== 0)
len = len || 1;
if ("object" == typeof len) tokens = len, len = 1;
if (tokens) this.tokens = tokens;
if (0 == this.curr) this.start = /* @__PURE__ */ new Date();
this.curr += len;
this.render();
if (this.curr >= this.total) {
this.render(void 0, true);
this.complete = true;
this.terminate();
this.callback(this);
return;
}
};
ProgressBar.prototype.render = function(tokens, force) {
force = force !== void 0 ? force : false;
if (tokens) this.tokens = tokens;
if (!this.stream.isTTY) return;
var now = Date.now();
var delta = now - this.lastRender;
if (!force && delta < this.renderThrottle) {
return;
} else {
this.lastRender = now;
}
var ratio = this.curr / this.total;
ratio = Math.min(Math.max(ratio, 0), 1);
var percent = Math.floor(ratio * 100);
var incomplete, complete, completeLength;
var elapsed = /* @__PURE__ */ new Date() - this.start;
var eta = percent == 100 ? 0 : elapsed * (this.total / this.curr - 1);
var rate = this.curr / (elapsed / 1e3);
var str = this.fmt.replace(":current", this.curr).replace(":total", this.total).replace(":elapsed", isNaN(elapsed) ? "0.0" : (elapsed / 1e3).toFixed(1)).replace(":eta", isNaN(eta) || !isFinite(eta) ? "0.0" : (eta / 1e3).toFixed(1)).replace(":percent", percent.toFixed(0) + "%").replace(":rate", Math.round(rate));
var availableSpace = Math.max(0, this.stream.columns - str.replace(":bar", "").length);
if (availableSpace && process.platform === "win32") {
availableSpace = availableSpace - 1;
}
var width = Math.min(this.width, availableSpace);
completeLength = Math.round(width * ratio);
complete = Array(Math.max(0, completeLength + 1)).join(this.chars.complete);
incomplete = Array(Math.max(0, width - completeLength + 1)).join(this.chars.incomplete);
if (completeLength > 0)
complete = complete.slice(0, -1) + this.chars.head;
str = str.replace(":bar", complete + incomplete);
if (this.tokens) for (var key in this.tokens) str = str.replace(":" + key, this.tokens[key]);
if (this.lastDraw !== str) {
this.stream.cursorTo(0);
this.stream.write(str);
this.stream.clearLine(1);
this.lastDraw = str;
}
};
ProgressBar.prototype.update = function(ratio, tokens) {
var goal = Math.floor(ratio * this.total);
var delta = goal - this.curr;
this.tick(delta, tokens);
};
ProgressBar.prototype.interrupt = function(message) {
this.stream.clearLine();
this.stream.cursorTo(0);
this.stream.write(message);
this.stream.write("\n");
this.stream.write(this.lastDraw);
};
ProgressBar.prototype.terminate = function() {
if (this.clear) {
if (this.stream.clearLine) {
this.stream.clearLine();
this.stream.cursorTo(0);
}
} else {
this.stream.write("\n");
}
};
}
});
var require_progress = (0, import_chunk_AH6QHEOA.__commonJS)({
"../../node_modules/.pnpm/progress@2.0.3/node_modules/progress/index.js"(exports, module2) {
"use strict";
module2.exports = require_node_progress();
}
});
var import_progress = (0, import_chunk_AH6QHEOA.__toESM)(require_progress());
function getBar(text) {
return new import_progress.default(`> ${text} [:bar] :percent`, {
stream: process.stdout,
width: 20,
complete: "=",
incomplete: " ",
total: 100,
head: "",
clear: true
});
}
/*! Bundled license information:
progress/lib/node-progress.js:
(*!
* node-progress
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*)
*/

View file

@ -0,0 +1,66 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var chunk_AH6QHEOA_exports = {};
__export(chunk_AH6QHEOA_exports, {
__commonJS: () => __commonJS,
__privateAdd: () => __privateAdd,
__privateGet: () => __privateGet,
__privateSet: () => __privateSet,
__require: () => __require,
__toESM: () => __toESM
});
module.exports = __toCommonJS(chunk_AH6QHEOA_exports);
var __create = Object.create;
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __typeError = (msg) => {
throw TypeError(msg);
};
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps2 = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps2(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,49 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var chunk_CWGQAQ3T_exports = {};
__export(chunk_CWGQAQ3T_exports, {
getHash: () => getHash
});
module.exports = __toCommonJS(chunk_CWGQAQ3T_exports);
var import_crypto = __toESM(require("crypto"));
var import_fs = __toESM(require("fs"));
function getHash(filePath) {
const hash = import_crypto.default.createHash("sha256");
const input = import_fs.default.createReadStream(filePath);
return new Promise((resolve) => {
input.on("readable", () => {
const data = input.read();
if (data) {
hash.update(data);
} else {
resolve(hash.digest("hex"));
}
});
});
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,70 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var chunk_FKKOTNO6_exports = {};
__export(chunk_FKKOTNO6_exports, {
cleanupCache: () => cleanupCache
});
module.exports = __toCommonJS(chunk_FKKOTNO6_exports);
var import_chunk_ZAFWMCVK = require("./chunk-ZAFWMCVK.js");
var import_chunk_G7EM4XDM = require("./chunk-G7EM4XDM.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");
var import_debug = __toESM(require("@prisma/debug"));
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_util = require("util");
var import_p_map = (0, import_chunk_AH6QHEOA.__toESM)((0, import_chunk_ZAFWMCVK.require_p_map)());
var import_rimraf = (0, import_chunk_AH6QHEOA.__toESM)((0, import_chunk_ZAFWMCVK.require_rimraf)());
var debug = (0, import_debug.default)("cleanupCache");
var del = (0, import_util.promisify)(import_rimraf.default);
async function cleanupCache(n = 5) {
try {
const rootCacheDir = await (0, import_chunk_G7EM4XDM.getRootCacheDir)();
if (!rootCacheDir) {
debug("no rootCacheDir found");
return;
}
const channel = "master";
const cacheDir = import_path.default.join(rootCacheDir, channel);
const dirs = await import_fs.default.promises.readdir(cacheDir);
const dirsWithMeta = await Promise.all(
dirs.map(async (dirName) => {
const dir = import_path.default.join(cacheDir, dirName);
const statResult = await import_fs.default.promises.stat(dir);
return {
dir,
created: statResult.birthtime
};
})
);
dirsWithMeta.sort((a, b) => a.created < b.created ? 1 : -1);
const dirsToRemove = dirsWithMeta.slice(n);
await (0, import_p_map.default)(dirsToRemove, (dir) => del(dir.dir), { concurrency: 20 });
} catch (e) {
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,44 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var chunk_MX3HXAU2_exports = {};
__export(chunk_MX3HXAU2_exports, {
chmodPlusX: () => chmodPlusX
});
module.exports = __toCommonJS(chunk_MX3HXAU2_exports);
var import_fs = __toESM(require("fs"));
function chmodPlusX(file) {
if (process.platform === "win32") return;
const s = import_fs.default.statSync(file);
const newMode = s.mode | 64 | 8 | 1;
if (s.mode === newMode) {
return;
}
const base8 = newMode.toString(8).slice(-3);
import_fs.default.chmodSync(file, base8);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,159 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var chunk_PXQVM7NP_exports = {};
__export(chunk_PXQVM7NP_exports, {
allEngineEnvVarsSet: () => allEngineEnvVarsSet,
bold: () => bold,
deprecatedEnvVarMap: () => deprecatedEnvVarMap,
engineEnvVarMap: () => engineEnvVarMap,
getBinaryEnvVarPath: () => getBinaryEnvVarPath,
yellow: () => yellow
});
module.exports = __toCommonJS(chunk_PXQVM7NP_exports);
var import_debug = __toESM(require("@prisma/debug"));
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var FORCE_COLOR;
var NODE_DISABLE_COLORS;
var NO_COLOR;
var TERM;
var isTTY = true;
if (typeof process !== "undefined") {
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
isTTY = process.stdout && process.stdout.isTTY;
}
var $ = {
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY)
};
function init(x, y) {
let rgx = new RegExp(`\\x1b\\[${y}m`, "g");
let open = `\x1B[${x}m`, close = `\x1B[${y}m`;
return function(txt) {
if (!$.enabled || txt == null) return txt;
return open + (!!~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close;
};
}
var reset = init(0, 0);
var bold = init(1, 22);
var dim = init(2, 22);
var italic = init(3, 23);
var underline = init(4, 24);
var inverse = init(7, 27);
var hidden = init(8, 28);
var strikethrough = init(9, 29);
var black = init(30, 39);
var red = init(31, 39);
var green = init(32, 39);
var yellow = init(33, 39);
var blue = init(34, 39);
var magenta = init(35, 39);
var cyan = init(36, 39);
var white = init(37, 39);
var gray = init(90, 39);
var grey = init(90, 39);
var bgBlack = init(40, 49);
var bgRed = init(41, 49);
var bgGreen = init(42, 49);
var bgYellow = init(43, 49);
var bgBlue = init(44, 49);
var bgMagenta = init(45, 49);
var bgCyan = init(46, 49);
var bgWhite = init(47, 49);
var debug = (0, import_debug.default)("prisma:fetch-engine:env");
var engineEnvVarMap = {
[
"query-engine"
/* QueryEngineBinary */
]: "PRISMA_QUERY_ENGINE_BINARY",
[
"libquery-engine"
/* QueryEngineLibrary */
]: "PRISMA_QUERY_ENGINE_LIBRARY",
[
"schema-engine"
/* SchemaEngineBinary */
]: "PRISMA_SCHEMA_ENGINE_BINARY"
};
var deprecatedEnvVarMap = {
[
"schema-engine"
/* SchemaEngineBinary */
]: "PRISMA_MIGRATION_ENGINE_BINARY"
};
function getBinaryEnvVarPath(binaryName) {
const envVar = getEnvVarToUse(binaryName);
if (process.env[envVar]) {
const envVarPath = import_path.default.resolve(process.cwd(), process.env[envVar]);
if (!import_fs.default.existsSync(envVarPath)) {
throw new Error(
`Env var ${bold(envVar)} is provided but provided path ${underline(process.env[envVar])} can't be resolved.`
);
}
debug(
`Using env var ${bold(envVar)} for binary ${bold(binaryName)}, which points to ${underline(
process.env[envVar]
)}`
);
return {
path: envVarPath,
fromEnvVar: envVar
};
}
return null;
}
function getEnvVarToUse(binaryType) {
const envVar = engineEnvVarMap[binaryType];
const deprecatedEnvVar = deprecatedEnvVarMap[binaryType];
if (deprecatedEnvVar && process.env[deprecatedEnvVar]) {
if (process.env[envVar]) {
console.warn(
`${yellow("prisma:warn")} Both ${bold(envVar)} and ${bold(deprecatedEnvVar)} are specified, ${bold(
envVar
)} takes precedence. ${bold(deprecatedEnvVar)} is deprecated.`
);
return envVar;
} else {
console.warn(
`${yellow("prisma:warn")} ${bold(deprecatedEnvVar)} environment variable is deprecated, please use ${bold(
envVar
)} instead`
);
return deprecatedEnvVar;
}
}
return envVar;
}
function allEngineEnvVarsSet(binaries) {
for (const binaryType of binaries) {
if (!getBinaryEnvVarPath(binaryType)) {
return false;
}
}
return true;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,29 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var chunk_X37PZICB_exports = {};
__export(chunk_X37PZICB_exports, {
BinaryType: () => BinaryType
});
module.exports = __toCommonJS(chunk_X37PZICB_exports);
var BinaryType = /* @__PURE__ */ ((BinaryType2) => {
BinaryType2["QueryEngineBinary"] = "query-engine";
BinaryType2["QueryEngineLibrary"] = "libquery-engine";
BinaryType2["SchemaEngineBinary"] = "schema-engine";
return BinaryType2;
})(BinaryType || {});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
export declare function cleanupCache(n?: number): Promise<void>;

View file

@ -0,0 +1,28 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cleanupCache_exports = {};
__export(cleanupCache_exports, {
cleanupCache: () => import_chunk_FKKOTNO6.cleanupCache
});
module.exports = __toCommonJS(cleanupCache_exports);
var import_chunk_FKKOTNO6 = require("./chunk-FKKOTNO6.js");
var import_chunk_ZAFWMCVK = require("./chunk-ZAFWMCVK.js");
var import_chunk_G7EM4XDM = require("./chunk-G7EM4XDM.js");
var import_chunk_X37PZICB = require("./chunk-X37PZICB.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");

View file

@ -0,0 +1,27 @@
import { BinaryTarget } from '@prisma/get-platform';
import { BinaryType } from './BinaryType';
export declare const vercelPkgPathRegex: RegExp;
export type BinaryDownloadConfiguration = {
[binary in BinaryType]?: string;
};
export type BinaryPaths = {
[binary in BinaryType]?: {
[binaryTarget in BinaryTarget]: string;
};
};
export interface DownloadOptions {
binaries: BinaryDownloadConfiguration;
binaryTargets?: BinaryTarget[];
showProgress?: boolean;
progressCb?: (progress: number) => void;
version?: string;
skipDownload?: boolean;
failSilent?: boolean;
printVersion?: boolean;
skipCacheIntegrityCheck?: boolean;
}
export declare function download(options: DownloadOptions): Promise<BinaryPaths>;
export declare function getVersion(enginePath: string, binaryName: string): Promise<string | undefined>;
export declare function getBinaryName(binaryName: BinaryType, binaryTarget: BinaryTarget): string;
export declare function maybeCopyToTmp(file: string): Promise<string>;
export declare function plusX(file: any): void;

View file

@ -0,0 +1,41 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var download_exports = {};
__export(download_exports, {
download: () => import_chunk_DNEMWMSW.download,
getBinaryName: () => import_chunk_DNEMWMSW.getBinaryName,
getVersion: () => import_chunk_DNEMWMSW.getVersion,
maybeCopyToTmp: () => import_chunk_DNEMWMSW.maybeCopyToTmp,
plusX: () => import_chunk_DNEMWMSW.plusX,
vercelPkgPathRegex: () => import_chunk_DNEMWMSW.vercelPkgPathRegex
});
module.exports = __toCommonJS(download_exports);
var import_chunk_DNEMWMSW = require("./chunk-DNEMWMSW.js");
var import_chunk_4LX3XBNY = require("./chunk-4LX3XBNY.js");
var import_chunk_MX3HXAU2 = require("./chunk-MX3HXAU2.js");
var import_chunk_FKKOTNO6 = require("./chunk-FKKOTNO6.js");
var import_chunk_BBQM2DBF = require("./chunk-BBQM2DBF.js");
var import_chunk_TIRVZJHP = require("./chunk-TIRVZJHP.js");
var import_chunk_ZAFWMCVK = require("./chunk-ZAFWMCVK.js");
var import_chunk_G7EM4XDM = require("./chunk-G7EM4XDM.js");
var import_chunk_PXQVM7NP = require("./chunk-PXQVM7NP.js");
var import_chunk_X37PZICB = require("./chunk-X37PZICB.js");
var import_chunk_CWGQAQ3T = require("./chunk-CWGQAQ3T.js");
var import_chunk_OFSFRIEP = require("./chunk-OFSFRIEP.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");

View file

@ -0,0 +1,6 @@
export type DownloadResult = {
lastModified: string;
sha256: string | null;
zippedSha256: string | null;
};
export declare function downloadZip(url: string, target: string, progressCb?: (progress: number) => void): Promise<DownloadResult>;

View file

@ -0,0 +1,30 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var downloadZip_exports = {};
__export(downloadZip_exports, {
downloadZip: () => import_chunk_BBQM2DBF.downloadZip
});
module.exports = __toCommonJS(downloadZip_exports);
var import_chunk_BBQM2DBF = require("./chunk-BBQM2DBF.js");
var import_chunk_TIRVZJHP = require("./chunk-TIRVZJHP.js");
var import_chunk_ZAFWMCVK = require("./chunk-ZAFWMCVK.js");
var import_chunk_G7EM4XDM = require("./chunk-G7EM4XDM.js");
var import_chunk_X37PZICB = require("./chunk-X37PZICB.js");
var import_chunk_OFSFRIEP = require("./chunk-OFSFRIEP.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");

View file

@ -0,0 +1,14 @@
import { BinaryType } from './BinaryType';
export declare const engineEnvVarMap: {
"query-engine": string;
"libquery-engine": string;
"schema-engine": string;
};
export declare const deprecatedEnvVarMap: Partial<typeof engineEnvVarMap>;
type PathFromEnvValue = {
path: string;
fromEnvVar: string;
};
export declare function getBinaryEnvVarPath(binaryName: BinaryType): PathFromEnvValue | null;
export declare function allEngineEnvVarsSet(binaries: string[]): boolean;
export {};

View file

@ -0,0 +1,29 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var env_exports = {};
__export(env_exports, {
allEngineEnvVarsSet: () => import_chunk_PXQVM7NP.allEngineEnvVarsSet,
deprecatedEnvVarMap: () => import_chunk_PXQVM7NP.deprecatedEnvVarMap,
engineEnvVarMap: () => import_chunk_PXQVM7NP.engineEnvVarMap,
getBinaryEnvVarPath: () => import_chunk_PXQVM7NP.getBinaryEnvVarPath
});
module.exports = __toCommonJS(env_exports);
var import_chunk_PXQVM7NP = require("./chunk-PXQVM7NP.js");
var import_chunk_X37PZICB = require("./chunk-X37PZICB.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");

View file

@ -0,0 +1 @@
export declare function getHash(filePath: string): Promise<string>;

View file

@ -0,0 +1,25 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var getHash_exports = {};
__export(getHash_exports, {
getHash: () => import_chunk_CWGQAQ3T.getHash
});
module.exports = __toCommonJS(getHash_exports);
var import_chunk_CWGQAQ3T = require("./chunk-CWGQAQ3T.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");

View file

@ -0,0 +1,3 @@
import { HttpProxyAgent } from 'http-proxy-agent';
import { HttpsProxyAgent } from 'https-proxy-agent';
export declare function getProxyAgent(url: string): HttpProxyAgent<string> | HttpsProxyAgent<string> | undefined;

View file

@ -0,0 +1,25 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var getProxyAgent_exports = {};
__export(getProxyAgent_exports, {
getProxyAgent: () => import_chunk_OFSFRIEP.getProxyAgent
});
module.exports = __toCommonJS(getProxyAgent_exports);
var import_chunk_OFSFRIEP = require("./chunk-OFSFRIEP.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");

View file

@ -0,0 +1,5 @@
export * from './BinaryType';
export * from './download';
export * from './env';
export { getProxyAgent } from './getProxyAgent';
export { getCacheDir, overwriteFile } from './utils';

View file

@ -0,0 +1,49 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var dist_exports = {};
__export(dist_exports, {
BinaryType: () => import_chunk_X37PZICB.BinaryType,
allEngineEnvVarsSet: () => import_chunk_PXQVM7NP.allEngineEnvVarsSet,
deprecatedEnvVarMap: () => import_chunk_PXQVM7NP.deprecatedEnvVarMap,
download: () => import_chunk_DNEMWMSW.download,
engineEnvVarMap: () => import_chunk_PXQVM7NP.engineEnvVarMap,
getBinaryEnvVarPath: () => import_chunk_PXQVM7NP.getBinaryEnvVarPath,
getBinaryName: () => import_chunk_DNEMWMSW.getBinaryName,
getCacheDir: () => import_chunk_G7EM4XDM.getCacheDir,
getProxyAgent: () => import_chunk_OFSFRIEP.getProxyAgent,
getVersion: () => import_chunk_DNEMWMSW.getVersion,
maybeCopyToTmp: () => import_chunk_DNEMWMSW.maybeCopyToTmp,
overwriteFile: () => import_chunk_G7EM4XDM.overwriteFile,
plusX: () => import_chunk_DNEMWMSW.plusX,
vercelPkgPathRegex: () => import_chunk_DNEMWMSW.vercelPkgPathRegex
});
module.exports = __toCommonJS(dist_exports);
var import_chunk_DNEMWMSW = require("./chunk-DNEMWMSW.js");
var import_chunk_4LX3XBNY = require("./chunk-4LX3XBNY.js");
var import_chunk_MX3HXAU2 = require("./chunk-MX3HXAU2.js");
var import_chunk_FKKOTNO6 = require("./chunk-FKKOTNO6.js");
var import_chunk_BBQM2DBF = require("./chunk-BBQM2DBF.js");
var import_chunk_TIRVZJHP = require("./chunk-TIRVZJHP.js");
var import_chunk_ZAFWMCVK = require("./chunk-ZAFWMCVK.js");
var import_chunk_G7EM4XDM = require("./chunk-G7EM4XDM.js");
var import_chunk_PXQVM7NP = require("./chunk-PXQVM7NP.js");
var import_chunk_X37PZICB = require("./chunk-X37PZICB.js");
var import_chunk_CWGQAQ3T = require("./chunk-CWGQAQ3T.js");
var import_chunk_OFSFRIEP = require("./chunk-OFSFRIEP.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");

View file

@ -0,0 +1,2 @@
import Progress from 'progress';
export declare function getBar(text: any): Progress;

View file

@ -0,0 +1,25 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var log_exports = {};
__export(log_exports, {
getBar: () => import_chunk_4LX3XBNY.getBar
});
module.exports = __toCommonJS(log_exports);
var import_chunk_4LX3XBNY = require("./chunk-4LX3XBNY.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");

View file

@ -0,0 +1,374 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var multipart_parser_ITART6UP_exports = {};
__export(multipart_parser_ITART6UP_exports, {
toFormData: () => toFormData
});
module.exports = __toCommonJS(multipart_parser_ITART6UP_exports);
var import_chunk_TIRVZJHP = require("./chunk-TIRVZJHP.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");
var s = 0;
var S = {
START_BOUNDARY: s++,
HEADER_FIELD_START: s++,
HEADER_FIELD: s++,
HEADER_VALUE_START: s++,
HEADER_VALUE: s++,
HEADER_VALUE_ALMOST_DONE: s++,
HEADERS_ALMOST_DONE: s++,
PART_DATA_START: s++,
PART_DATA: s++,
END: s++
};
var f = 1;
var F = {
PART_BOUNDARY: f,
LAST_BOUNDARY: f *= 2
};
var LF = 10;
var CR = 13;
var SPACE = 32;
var HYPHEN = 45;
var COLON = 58;
var A = 97;
var Z = 122;
var lower = (c) => c | 32;
var noop = () => {
};
var MultipartParser = class {
/**
* @param {string} boundary
*/
constructor(boundary) {
this.index = 0;
this.flags = 0;
this.onHeaderEnd = noop;
this.onHeaderField = noop;
this.onHeadersEnd = noop;
this.onHeaderValue = noop;
this.onPartBegin = noop;
this.onPartData = noop;
this.onPartEnd = noop;
this.boundaryChars = {};
boundary = "\r\n--" + boundary;
const ui8a = new Uint8Array(boundary.length);
for (let i = 0; i < boundary.length; i++) {
ui8a[i] = boundary.charCodeAt(i);
this.boundaryChars[ui8a[i]] = true;
}
this.boundary = ui8a;
this.lookbehind = new Uint8Array(this.boundary.length + 8);
this.state = S.START_BOUNDARY;
}
/**
* @param {Uint8Array} data
*/
write(data) {
let i = 0;
const length_ = data.length;
let previousIndex = this.index;
let { lookbehind, boundary, boundaryChars, index, state, flags } = this;
const boundaryLength = this.boundary.length;
const boundaryEnd = boundaryLength - 1;
const bufferLength = data.length;
let c;
let cl;
const mark = (name) => {
this[name + "Mark"] = i;
};
const clear = (name) => {
delete this[name + "Mark"];
};
const callback = (callbackSymbol, start, end, ui8a) => {
if (start === void 0 || start !== end) {
this[callbackSymbol](ui8a && ui8a.subarray(start, end));
}
};
const dataCallback = (name, clear2) => {
const markSymbol = name + "Mark";
if (!(markSymbol in this)) {
return;
}
if (clear2) {
callback(name, this[markSymbol], i, data);
delete this[markSymbol];
} else {
callback(name, this[markSymbol], data.length, data);
this[markSymbol] = 0;
}
};
for (i = 0; i < length_; i++) {
c = data[i];
switch (state) {
case S.START_BOUNDARY:
if (index === boundary.length - 2) {
if (c === HYPHEN) {
flags |= F.LAST_BOUNDARY;
} else if (c !== CR) {
return;
}
index++;
break;
} else if (index - 1 === boundary.length - 2) {
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
state = S.END;
flags = 0;
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
index = 0;
callback("onPartBegin");
state = S.HEADER_FIELD_START;
} else {
return;
}
break;
}
if (c !== boundary[index + 2]) {
index = -2;
}
if (c === boundary[index + 2]) {
index++;
}
break;
case S.HEADER_FIELD_START:
state = S.HEADER_FIELD;
mark("onHeaderField");
index = 0;
// falls through
case S.HEADER_FIELD:
if (c === CR) {
clear("onHeaderField");
state = S.HEADERS_ALMOST_DONE;
break;
}
index++;
if (c === HYPHEN) {
break;
}
if (c === COLON) {
if (index === 1) {
return;
}
dataCallback("onHeaderField", true);
state = S.HEADER_VALUE_START;
break;
}
cl = lower(c);
if (cl < A || cl > Z) {
return;
}
break;
case S.HEADER_VALUE_START:
if (c === SPACE) {
break;
}
mark("onHeaderValue");
state = S.HEADER_VALUE;
// falls through
case S.HEADER_VALUE:
if (c === CR) {
dataCallback("onHeaderValue", true);
callback("onHeaderEnd");
state = S.HEADER_VALUE_ALMOST_DONE;
}
break;
case S.HEADER_VALUE_ALMOST_DONE:
if (c !== LF) {
return;
}
state = S.HEADER_FIELD_START;
break;
case S.HEADERS_ALMOST_DONE:
if (c !== LF) {
return;
}
callback("onHeadersEnd");
state = S.PART_DATA_START;
break;
case S.PART_DATA_START:
state = S.PART_DATA;
mark("onPartData");
// falls through
case S.PART_DATA:
previousIndex = index;
if (index === 0) {
i += boundaryEnd;
while (i < bufferLength && !(data[i] in boundaryChars)) {
i += boundaryLength;
}
i -= boundaryEnd;
c = data[i];
}
if (index < boundary.length) {
if (boundary[index] === c) {
if (index === 0) {
dataCallback("onPartData", true);
}
index++;
} else {
index = 0;
}
} else if (index === boundary.length) {
index++;
if (c === CR) {
flags |= F.PART_BOUNDARY;
} else if (c === HYPHEN) {
flags |= F.LAST_BOUNDARY;
} else {
index = 0;
}
} else if (index - 1 === boundary.length) {
if (flags & F.PART_BOUNDARY) {
index = 0;
if (c === LF) {
flags &= ~F.PART_BOUNDARY;
callback("onPartEnd");
callback("onPartBegin");
state = S.HEADER_FIELD_START;
break;
}
} else if (flags & F.LAST_BOUNDARY) {
if (c === HYPHEN) {
callback("onPartEnd");
state = S.END;
flags = 0;
} else {
index = 0;
}
} else {
index = 0;
}
}
if (index > 0) {
lookbehind[index - 1] = c;
} else if (previousIndex > 0) {
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
callback("onPartData", 0, previousIndex, _lookbehind);
previousIndex = 0;
mark("onPartData");
i--;
}
break;
case S.END:
break;
default:
throw new Error(`Unexpected state entered: ${state}`);
}
}
dataCallback("onHeaderField");
dataCallback("onHeaderValue");
dataCallback("onPartData");
this.index = index;
this.state = state;
this.flags = flags;
}
end() {
if (this.state === S.HEADER_FIELD_START && this.index === 0 || this.state === S.PART_DATA && this.index === this.boundary.length) {
this.onPartEnd();
} else if (this.state !== S.END) {
throw new Error("MultipartParser.end(): stream ended unexpectedly");
}
}
};
function _fileName(headerValue) {
const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
if (!m) {
return;
}
const match = m[2] || m[3] || "";
let filename = match.slice(match.lastIndexOf("\\") + 1);
filename = filename.replace(/%22/g, '"');
filename = filename.replace(/&#(\d{4});/g, (m2, code) => {
return String.fromCharCode(code);
});
return filename;
}
async function toFormData(Body, ct) {
if (!/multipart/i.test(ct)) {
throw new TypeError("Failed to fetch");
}
const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
if (!m) {
throw new TypeError("no or bad content-type header, no multipart boundary");
}
const parser = new MultipartParser(m[1] || m[2]);
let headerField;
let headerValue;
let entryValue;
let entryName;
let contentType;
let filename;
const entryChunks = [];
const formData = new import_chunk_TIRVZJHP.FormData();
const onPartData = (ui8a) => {
entryValue += decoder.decode(ui8a, { stream: true });
};
const appendToFile = (ui8a) => {
entryChunks.push(ui8a);
};
const appendFileToFormData = () => {
const file = new import_chunk_TIRVZJHP.file_default(entryChunks, filename, { type: contentType });
formData.append(entryName, file);
};
const appendEntryToFormData = () => {
formData.append(entryName, entryValue);
};
const decoder = new TextDecoder("utf-8");
decoder.decode();
parser.onPartBegin = function() {
parser.onPartData = onPartData;
parser.onPartEnd = appendEntryToFormData;
headerField = "";
headerValue = "";
entryValue = "";
entryName = "";
contentType = "";
filename = null;
entryChunks.length = 0;
};
parser.onHeaderField = function(ui8a) {
headerField += decoder.decode(ui8a, { stream: true });
};
parser.onHeaderValue = function(ui8a) {
headerValue += decoder.decode(ui8a, { stream: true });
};
parser.onHeaderEnd = function() {
headerValue += decoder.decode();
headerField = headerField.toLowerCase();
if (headerField === "content-disposition") {
const m2 = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
if (m2) {
entryName = m2[2] || m2[3] || "";
}
filename = _fileName(headerValue);
if (filename) {
parser.onPartData = appendToFile;
parser.onPartEnd = appendFileToFormData;
}
} else if (headerField === "content-type") {
contentType = headerValue;
}
headerValue = "";
headerField = "";
};
for await (const chunk of Body) {
parser.write(chunk);
}
parser.end();
return formData;
}

View file

@ -0,0 +1,11 @@
import { BinaryTarget } from '@prisma/get-platform';
export declare function getRootCacheDir(): Promise<string | null>;
export declare function getCacheDir(channel: string, version: string, binaryTarget: string): Promise<string | null>;
export declare function getDownloadUrl({ channel, version, binaryTarget, binaryName, extension, }: {
channel: string;
version: string;
binaryTarget: BinaryTarget;
binaryName: string;
extension?: string;
}): string;
export declare function overwriteFile(sourcePath: string, targetPath: string): Promise<void>;

View file

@ -0,0 +1,29 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var utils_exports = {};
__export(utils_exports, {
getCacheDir: () => import_chunk_G7EM4XDM.getCacheDir,
getDownloadUrl: () => import_chunk_G7EM4XDM.getDownloadUrl,
getRootCacheDir: () => import_chunk_G7EM4XDM.getRootCacheDir,
overwriteFile: () => import_chunk_G7EM4XDM.overwriteFile
});
module.exports = __toCommonJS(utils_exports);
var import_chunk_G7EM4XDM = require("./chunk-G7EM4XDM.js");
var import_chunk_X37PZICB = require("./chunk-X37PZICB.js");
var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");