Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prisma/adapter-libsql

Package Overview
Dependencies
Maintainers
10
Versions
1973
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma/adapter-libsql - npm Package Compare versions

Comparing version 5.6.0-dev.23 to 5.6.0-integration-chore-client-adapter-porting-nits.1

176

dist/index.d.ts

@@ -1,8 +0,78 @@

import { Client, Transaction as Transaction$1 } from '@libsql/client';
import { DriverAdapter, Result, Transaction, Queryable, Query, ResultSet } from '@prisma/driver-adapter-utils';
import type { Client } from '@libsql/client';
import { Mutex } from 'async-mutex';
import type { Transaction } from '@libsql/client';
type StdClient = Client;
type TransactionClient = Transaction$1;
declare const LOCK_TAG: unique symbol;
declare type ColumnType = (typeof ColumnTypeEnum)[keyof typeof ColumnTypeEnum];
declare const ColumnTypeEnum: {
readonly Int32: 0;
readonly Int64: 1;
readonly Float: 2;
readonly Double: 3;
readonly Numeric: 4;
readonly Boolean: 5;
readonly Char: 6;
readonly Text: 7;
readonly Date: 8;
readonly Time: 9;
readonly DateTime: 10;
readonly Json: 11;
readonly Enum: 12;
readonly Bytes: 13;
readonly Set: 14;
readonly Uuid: 15;
readonly Int32Array: 64;
readonly Int64Array: 65;
readonly FloatArray: 66;
readonly DoubleArray: 67;
readonly NumericArray: 68;
readonly BooleanArray: 69;
readonly CharArray: 70;
readonly TextArray: 71;
readonly DateArray: 72;
readonly TimeArray: 73;
readonly DateTimeArray: 74;
readonly JsonArray: 75;
readonly EnumArray: 76;
readonly BytesArray: 77;
readonly UuidArray: 78;
readonly UnknownNumber: 128;
};
declare interface DriverAdapter extends Queryable {
/**
* Starts new transation.
*/
startTransaction(): Promise<Result<Transaction_2>>;
/**
* Closes the connection to the database, if any.
*/
close: () => Promise<Result<void>>;
}
declare type Error_2 = {
kind: 'GenericJs';
id: number;
} | {
kind: 'Postgres';
code: string;
severity: string;
message: string;
detail: string | undefined;
column: string | undefined;
hint: string | undefined;
} | {
kind: 'Mysql';
code: number;
message: string;
state: string;
} | {
kind: 'Sqlite';
/**
* Sqlite extended error code: https://www.sqlite.org/rescode.html
*/
extendedCode: number;
message: string;
};
declare class LibSqlQueryable<ClientT extends StdClient | TransactionClient> implements Queryable {

@@ -30,8 +100,98 @@ protected readonly client: ClientT;

}
declare class PrismaLibSQL extends LibSqlQueryable<StdClient> implements DriverAdapter {
declare const LOCK_TAG: unique symbol;
export declare class PrismaLibSQL extends LibSqlQueryable<StdClient> implements DriverAdapter {
constructor(client: StdClient);
startTransaction(): Promise<Result<Transaction>>;
startTransaction(): Promise<Result<Transaction_2>>;
close(): Promise<Result<void>>;
}
export { PrismaLibSQL };
declare type Query = {
sql: string;
args: Array<unknown>;
};
declare interface Queryable {
readonly flavour: 'mysql' | 'postgres' | 'sqlite';
/**
* Execute a query given as SQL, interpolating the given parameters,
* and returning the type-aware result set of the query.
*
* This is the preferred way of executing `SELECT` queries.
*/
queryRaw(params: Query): Promise<Result<ResultSet>>;
/**
* Execute a query given as SQL, interpolating the given parameters,
* and returning the number of affected rows.
*
* This is the preferred way of executing `INSERT`, `UPDATE`, `DELETE` queries,
* as well as transactional queries.
*/
executeRaw(params: Query): Promise<Result<number>>;
}
declare type Result<T> = {
map<U>(fn: (value: T) => U): Result<U>;
flatMap<U>(fn: (value: T) => Result<U>): Result<U>;
} & ({
readonly ok: true;
readonly value: T;
} | {
readonly ok: false;
readonly error: Error_2;
});
declare interface ResultSet {
/**
* List of column types appearing in a database query, in the same order as `columnNames`.
* They are used within the Query Engine to convert values from JS to Quaint values.
*/
columnTypes: Array<ColumnType>;
/**
* List of column names appearing in a database query, in the same order as `columnTypes`.
*/
columnNames: Array<string>;
/**
* List of rows retrieved from a database query.
* Each row is a list of values, whose length matches `columnNames` and `columnTypes`.
*/
rows: Array<Array<unknown>>;
/**
* The last ID of an `INSERT` statement, if any.
* This is required for `AUTO_INCREMENT` columns in MySQL and SQLite-flavoured databases.
*/
lastInsertId?: string;
}
declare type StdClient = Client;
declare interface Transaction_2 extends Queryable {
/**
* Transaction options.
*/
readonly options: TransactionOptions;
/**
* Commit the transaction.
*/
commit(): Promise<Result<void>>;
/**
* Rolls back the transaction.
*/
rollback(): Promise<Result<void>>;
/**
* Discards and closes the transaction which may or may not have been committed or rolled back.
* This operation must be synchronous. If the implementation requires calling creating new
* asynchronous tasks on the event loop, the driver is responsible for handling the errors
* appropriately to ensure they don't crash the application.
*/
dispose(): Result<void>;
}
declare type TransactionClient = Transaction;
declare type TransactionOptions = {
usePhantomQuery: boolean;
};
export { }
"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 __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {

@@ -18,4 +23,846 @@ for (var name in all)

};
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);
// ../../node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
var require_ms = __commonJS({
"../../node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module2) {
"use strict";
var s = 1e3;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var w = d * 7;
var y = d * 365.25;
module2.exports = function(val, options) {
options = options || {};
var type = typeof val;
if (type === "string" && val.length > 0) {
return parse(val);
} else if (type === "number" && isFinite(val)) {
return options.long ? fmtLong(val) : fmtShort(val);
}
throw new Error(
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
);
};
function parse(str) {
str = String(str);
if (str.length > 100) {
return;
}
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
str
);
if (!match) {
return;
}
var n = parseFloat(match[1]);
var type = (match[2] || "ms").toLowerCase();
switch (type) {
case "years":
case "year":
case "yrs":
case "yr":
case "y":
return n * y;
case "weeks":
case "week":
case "w":
return n * w;
case "days":
case "day":
case "d":
return n * d;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
return n * h;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
return n * m;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
return n * s;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
return n;
default:
return void 0;
}
}
function fmtShort(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d) {
return Math.round(ms / d) + "d";
}
if (msAbs >= h) {
return Math.round(ms / h) + "h";
}
if (msAbs >= m) {
return Math.round(ms / m) + "m";
}
if (msAbs >= s) {
return Math.round(ms / s) + "s";
}
return ms + "ms";
}
function fmtLong(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d) {
return plural(ms, msAbs, d, "day");
}
if (msAbs >= h) {
return plural(ms, msAbs, h, "hour");
}
if (msAbs >= m) {
return plural(ms, msAbs, m, "minute");
}
if (msAbs >= s) {
return plural(ms, msAbs, s, "second");
}
return ms + " ms";
}
function plural(ms, msAbs, n, name) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
}
}
});
// ../../node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/common.js
var require_common = __commonJS({
"../../node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/common.js"(exports, module2) {
"use strict";
function setup(env) {
createDebug.debug = createDebug;
createDebug.default = createDebug;
createDebug.coerce = coerce;
createDebug.disable = disable;
createDebug.enable = enable;
createDebug.enabled = enabled;
createDebug.humanize = require_ms();
createDebug.destroy = destroy;
Object.keys(env).forEach((key) => {
createDebug[key] = env[key];
});
createDebug.names = [];
createDebug.skips = [];
createDebug.formatters = {};
function selectColor(namespace) {
let hash = 0;
for (let i = 0; i < namespace.length; i++) {
hash = (hash << 5) - hash + namespace.charCodeAt(i);
hash |= 0;
}
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
}
createDebug.selectColor = selectColor;
function createDebug(namespace) {
let prevTime;
let enableOverride = null;
let namespacesCache;
let enabledCache;
function debug3(...args) {
if (!debug3.enabled) {
return;
}
const self = debug3;
const curr = Number(/* @__PURE__ */ new Date());
const ms = curr - (prevTime || curr);
self.diff = ms;
self.prev = prevTime;
self.curr = curr;
prevTime = curr;
args[0] = createDebug.coerce(args[0]);
if (typeof args[0] !== "string") {
args.unshift("%O");
}
let index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
if (match === "%%") {
return "%";
}
index++;
const formatter = createDebug.formatters[format];
if (typeof formatter === "function") {
const val = args[index];
match = formatter.call(self, val);
args.splice(index, 1);
index--;
}
return match;
});
createDebug.formatArgs.call(self, args);
const logFn = self.log || createDebug.log;
logFn.apply(self, args);
}
debug3.namespace = namespace;
debug3.useColors = createDebug.useColors();
debug3.color = createDebug.selectColor(namespace);
debug3.extend = extend;
debug3.destroy = createDebug.destroy;
Object.defineProperty(debug3, "enabled", {
enumerable: true,
configurable: false,
get: () => {
if (enableOverride !== null) {
return enableOverride;
}
if (namespacesCache !== createDebug.namespaces) {
namespacesCache = createDebug.namespaces;
enabledCache = createDebug.enabled(namespace);
}
return enabledCache;
},
set: (v) => {
enableOverride = v;
}
});
if (typeof createDebug.init === "function") {
createDebug.init(debug3);
}
return debug3;
}
function extend(namespace, delimiter) {
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
newDebug.log = this.log;
return newDebug;
}
function enable(namespaces) {
createDebug.save(namespaces);
createDebug.namespaces = namespaces;
createDebug.names = [];
createDebug.skips = [];
let i;
const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
const len = split.length;
for (i = 0; i < len; i++) {
if (!split[i]) {
continue;
}
namespaces = split[i].replace(/\*/g, ".*?");
if (namespaces[0] === "-") {
createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
} else {
createDebug.names.push(new RegExp("^" + namespaces + "$"));
}
}
}
function disable() {
const namespaces = [
...createDebug.names.map(toNamespace),
...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
].join(",");
createDebug.enable("");
return namespaces;
}
function enabled(name) {
if (name[name.length - 1] === "*") {
return true;
}
let i;
let len;
for (i = 0, len = createDebug.skips.length; i < len; i++) {
if (createDebug.skips[i].test(name)) {
return false;
}
}
for (i = 0, len = createDebug.names.length; i < len; i++) {
if (createDebug.names[i].test(name)) {
return true;
}
}
return false;
}
function toNamespace(regexp) {
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
}
function coerce(val) {
if (val instanceof Error) {
return val.stack || val.message;
}
return val;
}
function destroy() {
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
}
createDebug.enable(createDebug.load());
return createDebug;
}
module2.exports = setup;
}
});
// ../../node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/browser.js
var require_browser = __commonJS({
"../../node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/browser.js"(exports, module2) {
"use strict";
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
exports.storage = localstorage();
exports.destroy = (() => {
let warned = false;
return () => {
if (!warned) {
warned = true;
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
}
};
})();
exports.colors = [
"#0000CC",
"#0000FF",
"#0033CC",
"#0033FF",
"#0066CC",
"#0066FF",
"#0099CC",
"#0099FF",
"#00CC00",
"#00CC33",
"#00CC66",
"#00CC99",
"#00CCCC",
"#00CCFF",
"#3300CC",
"#3300FF",
"#3333CC",
"#3333FF",
"#3366CC",
"#3366FF",
"#3399CC",
"#3399FF",
"#33CC00",
"#33CC33",
"#33CC66",
"#33CC99",
"#33CCCC",
"#33CCFF",
"#6600CC",
"#6600FF",
"#6633CC",
"#6633FF",
"#66CC00",
"#66CC33",
"#9900CC",
"#9900FF",
"#9933CC",
"#9933FF",
"#99CC00",
"#99CC33",
"#CC0000",
"#CC0033",
"#CC0066",
"#CC0099",
"#CC00CC",
"#CC00FF",
"#CC3300",
"#CC3333",
"#CC3366",
"#CC3399",
"#CC33CC",
"#CC33FF",
"#CC6600",
"#CC6633",
"#CC9900",
"#CC9933",
"#CCCC00",
"#CCCC33",
"#FF0000",
"#FF0033",
"#FF0066",
"#FF0099",
"#FF00CC",
"#FF00FF",
"#FF3300",
"#FF3333",
"#FF3366",
"#FF3399",
"#FF33CC",
"#FF33FF",
"#FF6600",
"#FF6633",
"#FF9900",
"#FF9933",
"#FFCC00",
"#FFCC33"
];
function useColors() {
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
return true;
}
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
return false;
}
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
}
function formatArgs(args) {
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
if (!this.useColors) {
return;
}
const c = "color: " + this.color;
args.splice(1, 0, c, "color: inherit");
let index = 0;
let lastC = 0;
args[0].replace(/%[a-zA-Z%]/g, (match) => {
if (match === "%%") {
return;
}
index++;
if (match === "%c") {
lastC = index;
}
});
args.splice(lastC, 0, c);
}
exports.log = console.debug || console.log || (() => {
});
function save(namespaces) {
try {
if (namespaces) {
exports.storage.setItem("debug", namespaces);
} else {
exports.storage.removeItem("debug");
}
} catch (error) {
}
}
function load() {
let r;
try {
r = exports.storage.getItem("debug");
} catch (error) {
}
if (!r && typeof process !== "undefined" && "env" in process) {
r = process.env.DEBUG;
}
return r;
}
function localstorage() {
try {
return localStorage;
} catch (error) {
}
}
module2.exports = require_common()(exports);
var { formatters } = module2.exports;
formatters.j = function(v) {
try {
return JSON.stringify(v);
} catch (error) {
return "[UnexpectedJSONParseError]: " + error.message;
}
};
}
});
// ../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js
var require_has_flag = __commonJS({
"../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports, module2) {
"use strict";
module2.exports = (flag, argv = process.argv) => {
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
const position = argv.indexOf(prefix + flag);
const terminatorPosition = argv.indexOf("--");
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
};
}
});
// ../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js
var require_supports_color = __commonJS({
"../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module2) {
"use strict";
var os = require("os");
var tty = require("tty");
var hasFlag = require_has_flag();
var { env } = process;
var forceColor;
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
forceColor = 0;
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
forceColor = 1;
}
if ("FORCE_COLOR" in env) {
if (env.FORCE_COLOR === "true") {
forceColor = 1;
} else if (env.FORCE_COLOR === "false") {
forceColor = 0;
} else {
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
}
}
function translateLevel(level) {
if (level === 0) {
return false;
}
return {
level,
hasBasic: true,
has256: level >= 2,
has16m: level >= 3
};
}
function supportsColor(haveStream, streamIsTTY) {
if (forceColor === 0) {
return 0;
}
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
return 3;
}
if (hasFlag("color=256")) {
return 2;
}
if (haveStream && !streamIsTTY && forceColor === void 0) {
return 0;
}
const min = forceColor || 0;
if (env.TERM === "dumb") {
return min;
}
if (process.platform === "win32") {
const osRelease = os.release().split(".");
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
return Number(osRelease[2]) >= 14931 ? 3 : 2;
}
return 1;
}
if ("CI" in env) {
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
return 1;
}
return min;
}
if ("TEAMCITY_VERSION" in env) {
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
}
if (env.COLORTERM === "truecolor") {
return 3;
}
if ("TERM_PROGRAM" in env) {
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
switch (env.TERM_PROGRAM) {
case "iTerm.app":
return version >= 3 ? 3 : 2;
case "Apple_Terminal":
return 2;
}
}
if (/-256(color)?$/i.test(env.TERM)) {
return 2;
}
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
return 1;
}
if ("COLORTERM" in env) {
return 1;
}
return min;
}
function getSupportLevel(stream) {
const level = supportsColor(stream, stream && stream.isTTY);
return translateLevel(level);
}
module2.exports = {
supportsColor: getSupportLevel,
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
};
}
});
// ../../node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/node.js
var require_node = __commonJS({
"../../node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/node.js"(exports, module2) {
"use strict";
var tty = require("tty");
var util = require("util");
exports.init = init;
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
exports.destroy = util.deprecate(
() => {
},
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
);
exports.colors = [6, 2, 3, 4, 5, 1];
try {
const supportsColor = require_supports_color();
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
exports.colors = [
20,
21,
26,
27,
32,
33,
38,
39,
40,
41,
42,
43,
44,
45,
56,
57,
62,
63,
68,
69,
74,
75,
76,
77,
78,
79,
80,
81,
92,
93,
98,
99,
112,
113,
128,
129,
134,
135,
148,
149,
160,
161,
162,
163,
164,
165,
166,
167,
168,
169,
170,
171,
172,
173,
178,
179,
184,
185,
196,
197,
198,
199,
200,
201,
202,
203,
204,
205,
206,
207,
208,
209,
214,
215,
220,
221
];
}
} catch (error) {
}
exports.inspectOpts = Object.keys(process.env).filter((key) => {
return /^debug_/i.test(key);
}).reduce((obj, key) => {
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
return k.toUpperCase();
});
let val = process.env[key];
if (/^(yes|on|true|enabled)$/i.test(val)) {
val = true;
} else if (/^(no|off|false|disabled)$/i.test(val)) {
val = false;
} else if (val === "null") {
val = null;
} else {
val = Number(val);
}
obj[prop] = val;
return obj;
}, {});
function useColors() {
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
}
function formatArgs(args) {
const { namespace: name, useColors: useColors2 } = this;
if (useColors2) {
const c = this.color;
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m");
} else {
args[0] = getDate() + name + " " + args[0];
}
}
function getDate() {
if (exports.inspectOpts.hideDate) {
return "";
}
return (/* @__PURE__ */ new Date()).toISOString() + " ";
}
function log(...args) {
return process.stderr.write(util.format(...args) + "\n");
}
function save(namespaces) {
if (namespaces) {
process.env.DEBUG = namespaces;
} else {
delete process.env.DEBUG;
}
}
function load() {
return process.env.DEBUG;
}
function init(debug3) {
debug3.inspectOpts = {};
const keys = Object.keys(exports.inspectOpts);
for (let i = 0; i < keys.length; i++) {
debug3.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
}
}
module2.exports = require_common()(exports);
var { formatters } = module2.exports;
formatters.o = function(v) {
this.inspectOpts.colors = this.useColors;
return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
};
formatters.O = function(v) {
this.inspectOpts.colors = this.useColors;
return util.inspect(v, this.inspectOpts);
};
}
});
// ../../node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/index.js
var require_src = __commonJS({
"../../node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/index.js"(exports, module2) {
"use strict";
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
module2.exports = require_browser();
} else {
module2.exports = require_node();
}
}
});
// ../debug/dist/index.js
var require_dist = __commonJS({
"../debug/dist/index.js"(exports, module2) {
"use strict";
var __create2 = Object.create;
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __getProtoOf2 = Object.getPrototypeOf;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
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 __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(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 __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var src_exports2 = {};
__export2(src_exports2, {
Debug: () => Debug3,
clearLogs: () => clearLogs,
default: () => src_default,
getLogs: () => getLogs
});
module2.exports = __toCommonJS2(src_exports2);
var import_debug3 = __toESM2(require_src());
var MAX_LOGS = 100;
var debugArgsHistory = [];
if (typeof process !== "undefined" && typeof process.stderr?.write !== "function") {
import_debug3.default.log = console.debug ?? console.log;
}
function debugCall(namespace) {
const debugNamespace = (0, import_debug3.default)(namespace);
const call = Object.assign((...args) => {
debugNamespace.log = call.log;
if (args.length !== 0) {
debugArgsHistory.push([namespace, ...args]);
}
if (debugArgsHistory.length > MAX_LOGS) {
debugArgsHistory.shift();
}
return debugNamespace("", ...args);
}, debugNamespace);
return call;
}
var Debug3 = Object.assign(debugCall, import_debug3.default);
function getLogs(numChars = 7500) {
const output = debugArgsHistory.map(
(c) => c.map((item) => {
if (typeof item === "string") {
return item;
}
return JSON.stringify(item);
}).join(" ")
).join("\n");
if (output.length < numChars) {
return output;
}
return output.slice(-numChars);
}
function clearLogs() {
debugArgsHistory.length = 0;
}
var src_default = Debug3;
}
});
// src/index.ts

@@ -29,9 +876,246 @@ var src_exports = {};

// src/libsql.ts
var import_driver_adapter_utils2 = require("@prisma/driver-adapter-utils");
var import_async_mutex = require("async-mutex");
var import_debug2 = __toESM(require_dist());
// ../driver-adapter-utils/dist/index.mjs
function ok(value) {
return {
ok: true,
value,
map(fn) {
return ok(fn(value));
},
flatMap(fn) {
return fn(value);
}
};
}
function err(error) {
return {
ok: false,
error,
map() {
return err(error);
},
flatMap() {
return err(error);
}
};
}
var ColumnTypeEnum = {
// Scalars
Int32: 0,
Int64: 1,
Float: 2,
Double: 3,
Numeric: 4,
Boolean: 5,
Char: 6,
Text: 7,
Date: 8,
Time: 9,
DateTime: 10,
Json: 11,
Enum: 12,
Bytes: 13,
Set: 14,
Uuid: 15,
// Arrays
Int32Array: 64,
Int64Array: 65,
FloatArray: 66,
DoubleArray: 67,
NumericArray: 68,
BooleanArray: 69,
CharArray: 70,
TextArray: 71,
DateArray: 72,
TimeArray: 73,
DateTimeArray: 74,
JsonArray: 75,
EnumArray: 76,
BytesArray: 77,
UuidArray: 78,
// Custom
UnknownNumber: 128
};
// ../../node_modules/.pnpm/async-mutex@0.4.0/node_modules/async-mutex/index.mjs
var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
var E_ALREADY_LOCKED = new Error("mutex already locked");
var E_CANCELED = new Error("request for lock canceled");
var __awaiter$2 = function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var Semaphore = class {
constructor(_value, _cancelError = E_CANCELED) {
this._value = _value;
this._cancelError = _cancelError;
this._weightedQueues = [];
this._weightedWaiters = [];
}
acquire(weight = 1) {
if (weight <= 0)
throw new Error(`invalid weight ${weight}: must be positive`);
return new Promise((resolve, reject) => {
if (!this._weightedQueues[weight - 1])
this._weightedQueues[weight - 1] = [];
this._weightedQueues[weight - 1].push({ resolve, reject });
this._dispatch();
});
}
runExclusive(callback, weight = 1) {
return __awaiter$2(this, void 0, void 0, function* () {
const [value, release] = yield this.acquire(weight);
try {
return yield callback(value);
} finally {
release();
}
});
}
waitForUnlock(weight = 1) {
if (weight <= 0)
throw new Error(`invalid weight ${weight}: must be positive`);
return new Promise((resolve) => {
if (!this._weightedWaiters[weight - 1])
this._weightedWaiters[weight - 1] = [];
this._weightedWaiters[weight - 1].push(resolve);
this._dispatch();
});
}
isLocked() {
return this._value <= 0;
}
getValue() {
return this._value;
}
setValue(value) {
this._value = value;
this._dispatch();
}
release(weight = 1) {
if (weight <= 0)
throw new Error(`invalid weight ${weight}: must be positive`);
this._value += weight;
this._dispatch();
}
cancel() {
this._weightedQueues.forEach((queue) => queue.forEach((entry) => entry.reject(this._cancelError)));
this._weightedQueues = [];
}
_dispatch() {
var _a2;
for (let weight = this._value; weight > 0; weight--) {
const queueEntry = (_a2 = this._weightedQueues[weight - 1]) === null || _a2 === void 0 ? void 0 : _a2.shift();
if (!queueEntry)
continue;
const previousValue = this._value;
const previousWeight = weight;
this._value -= weight;
weight = this._value + 1;
queueEntry.resolve([previousValue, this._newReleaser(previousWeight)]);
}
this._drainUnlockWaiters();
}
_newReleaser(weight) {
let called = false;
return () => {
if (called)
return;
called = true;
this.release(weight);
};
}
_drainUnlockWaiters() {
for (let weight = this._value; weight > 0; weight--) {
if (!this._weightedWaiters[weight - 1])
continue;
this._weightedWaiters[weight - 1].forEach((waiter) => waiter());
this._weightedWaiters[weight - 1] = [];
}
}
};
var __awaiter$1 = function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var Mutex = class {
constructor(cancelError) {
this._semaphore = new Semaphore(1, cancelError);
}
acquire() {
return __awaiter$1(this, void 0, void 0, function* () {
const [, releaser] = yield this._semaphore.acquire();
return releaser;
});
}
runExclusive(callback) {
return this._semaphore.runExclusive(() => callback());
}
isLocked() {
return this._semaphore.isLocked();
}
waitForUnlock() {
return this._semaphore.waitForUnlock();
}
release() {
if (this._semaphore.isLocked())
this._semaphore.release();
}
cancel() {
return this._semaphore.cancel();
}
};
// src/conversion.ts
var import_types = require("util/types");
var import_driver_adapter_utils = require("@prisma/driver-adapter-utils");
var debug = (0, import_driver_adapter_utils.Debug)("prisma:driver-adapter:libsql:conversion");
var import_debug = __toESM(require_dist());
var debug = (0, import_debug.Debug)("prisma:driver-adapter:libsql:conversion");
function mapDeclType(declType) {

@@ -42,5 +1126,5 @@ switch (declType.toUpperCase()) {

case "DECIMAL":
return import_driver_adapter_utils.ColumnTypeEnum.Numeric;
return ColumnTypeEnum.Numeric;
case "FLOAT":
return import_driver_adapter_utils.ColumnTypeEnum.Float;
return ColumnTypeEnum.Float;
case "DOUBLE":

@@ -50,3 +1134,3 @@ case "DOUBLE PRECISION":

case "REAL":
return import_driver_adapter_utils.ColumnTypeEnum.Double;
return ColumnTypeEnum.Double;
case "TINYINT":

@@ -59,14 +1143,14 @@ case "SMALLINT":

case "INT2":
return import_driver_adapter_utils.ColumnTypeEnum.Int32;
return ColumnTypeEnum.Int32;
case "BIGINT":
case "UNSIGNED BIG INT":
case "INT8":
return import_driver_adapter_utils.ColumnTypeEnum.Int64;
return ColumnTypeEnum.Int64;
case "DATETIME":
case "TIMESTAMP":
return import_driver_adapter_utils.ColumnTypeEnum.DateTime;
return ColumnTypeEnum.DateTime;
case "TIME":
return import_driver_adapter_utils.ColumnTypeEnum.Time;
return ColumnTypeEnum.Time;
case "DATE":
return import_driver_adapter_utils.ColumnTypeEnum.Date;
return ColumnTypeEnum.Date;
case "TEXT":

@@ -80,7 +1164,7 @@ case "CLOB":

case "NVARCHAR":
return import_driver_adapter_utils.ColumnTypeEnum.Text;
return ColumnTypeEnum.Text;
case "BLOB":
return import_driver_adapter_utils.ColumnTypeEnum.Bytes;
return ColumnTypeEnum.Bytes;
case "BOOLEAN":
return import_driver_adapter_utils.ColumnTypeEnum.Boolean;
return ColumnTypeEnum.Boolean;
default:

@@ -116,3 +1200,3 @@ debug("unknown decltype:", declType);

}
columnTypes[columnIndex] = import_driver_adapter_utils.ColumnTypeEnum.Int32;
columnTypes[columnIndex] = ColumnTypeEnum.Int32;
}

@@ -124,9 +1208,9 @@ return columnTypes;

case "string":
return import_driver_adapter_utils.ColumnTypeEnum.Text;
return ColumnTypeEnum.Text;
case "bigint":
return import_driver_adapter_utils.ColumnTypeEnum.Int64;
return ColumnTypeEnum.Int64;
case "boolean":
return import_driver_adapter_utils.ColumnTypeEnum.Boolean;
return ColumnTypeEnum.Boolean;
case "number":
return import_driver_adapter_utils.ColumnTypeEnum.UnknownNumber;
return ColumnTypeEnum.UnknownNumber;
case "object":

@@ -140,3 +1224,3 @@ return inferObjectType(value);

if ((0, import_types.isArrayBuffer)(value)) {
return import_driver_adapter_utils.ColumnTypeEnum.Bytes;
return ColumnTypeEnum.Bytes;
}

@@ -146,3 +1230,2 @@ throw new UnexpectedTypeError(value);

var UnexpectedTypeError = class extends Error {
name = "UnexpectedTypeError";
constructor(value) {

@@ -152,2 +1235,3 @@ const type = typeof value;

super(`unexpected value of type ${type}: ${repr}`);
this.name = "UnexpectedTypeError";
}

@@ -165,3 +1249,3 @@ };

}
if (typeof value === "number" && (columnTypes[i] === import_driver_adapter_utils.ColumnTypeEnum.Int32 || columnTypes[i] === import_driver_adapter_utils.ColumnTypeEnum.Int64) && !Number.isInteger(value)) {
if (typeof value === "number" && (columnTypes[i] === ColumnTypeEnum.Int32 || columnTypes[i] === ColumnTypeEnum.Int64) && !Number.isInteger(value)) {
result[i] = Math.trunc(value);

@@ -174,10 +1258,11 @@ }

// src/libsql.ts
var debug2 = (0, import_driver_adapter_utils2.Debug)("prisma:driver-adapter:libsql");
var debug2 = (0, import_debug2.Debug)("prisma:driver-adapter:libsql");
var LOCK_TAG = Symbol();
var _a;
var LibSqlQueryable = class {
constructor(client) {
this.client = client;
this.flavour = "sqlite";
this[_a] = new Mutex();
}
flavour = "sqlite";
[LOCK_TAG] = new import_async_mutex.Mutex();
/**

@@ -218,3 +1303,3 @@ * Execute a query given as SQL, interpolating the given parameters.

const result = await this.client.execute(query);
return (0, import_driver_adapter_utils2.ok)(result);
return ok(result);
} catch (e) {

@@ -225,3 +1310,3 @@ const error = e;

if (typeof rawCode === "number") {
return (0, import_driver_adapter_utils2.err)({
return err({
kind: "Sqlite",

@@ -238,2 +1323,3 @@ extendedCode: rawCode,

};
_a = LOCK_TAG;
var LibSqlTransaction = class extends LibSqlQueryable {

@@ -244,4 +1330,4 @@ constructor(client, options, unlockParent) {

this.unlockParent = unlockParent;
this.finished = false;
}
finished = false;
async commit() {

@@ -255,3 +1341,3 @@ debug2(`[js::commit]`);

}
return (0, import_driver_adapter_utils2.ok)(void 0);
return ok(void 0);
}

@@ -268,3 +1354,3 @@ async rollback() {

}
return (0, import_driver_adapter_utils2.ok)(void 0);
return ok(void 0);
}

@@ -276,3 +1362,3 @@ dispose() {

}
return (0, import_driver_adapter_utils2.ok)(void 0);
return ok(void 0);
}

@@ -293,3 +1379,3 @@ };

const tx = await this.client.transaction("deferred");
return (0, import_driver_adapter_utils2.ok)(new LibSqlTransaction(tx, options, release));
return ok(new LibSqlTransaction(tx, options, release));
} catch (e) {

@@ -303,3 +1389,3 @@ release();

this.client.close();
return (0, import_driver_adapter_utils2.ok)(void 0);
return ok(void 0);
}

@@ -306,0 +1392,0 @@ };

17

package.json
{
"name": "@prisma/adapter-libsql",
"version": "5.6.0-dev.23",
"version": "5.6.0-integration-chore-client-adapter-porting-nits.1",
"description": "Prisma's driver adapter for libSQL and Turso",

@@ -16,9 +16,9 @@ "main": "dist/index.js",

"sideEffects": false,
"dependencies": {
"dependencies": {},
"devDependencies": {
"@libsql/client": "0.3.5",
"async-mutex": "0.4.0",
"@prisma/driver-adapter-utils": "5.6.0-dev.23"
"@prisma/debug": "5.6.0-integration-chore-client-adapter-porting-nits.1",
"@prisma/driver-adapter-utils": "5.6.0-integration-chore-client-adapter-porting-nits.1"
},
"devDependencies": {
"@libsql/client": "0.3.5"
},
"peerDependencies": {

@@ -28,6 +28,5 @@ "@libsql/client": "^0.3.5"

"scripts": {
"build": "tsup ./src/index.ts --format cjs,esm --dts",
"lint": "tsc -p ./tsconfig.build.json",
"test": "node --loader tsx --test tests/*.test.mts"
"dev": "DEV=true node -r esbuild-register helpers/build.ts",
"build": "node -r esbuild-register helpers/build.ts"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc