Initial commit
This commit is contained in:
93
node_modules/drizzle-orm/vercel-postgres/driver.cjs
generated
vendored
Normal file
93
node_modules/drizzle-orm/vercel-postgres/driver.cjs
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
"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 driver_exports = {};
|
||||
__export(driver_exports, {
|
||||
VercelPgDatabase: () => VercelPgDatabase,
|
||||
VercelPgDriver: () => VercelPgDriver,
|
||||
drizzle: () => drizzle
|
||||
});
|
||||
module.exports = __toCommonJS(driver_exports);
|
||||
var import_postgres = require("@vercel/postgres");
|
||||
var import_entity = require("../entity.cjs");
|
||||
var import_logger = require("../logger.cjs");
|
||||
var import_db = require("../pg-core/db.cjs");
|
||||
var import_pg_core = require("../pg-core/index.cjs");
|
||||
var import_relations = require("../relations.cjs");
|
||||
var import_utils = require("../utils.cjs");
|
||||
var import_session = require("./session.cjs");
|
||||
class VercelPgDriver {
|
||||
constructor(client, dialect, options = {}) {
|
||||
this.client = client;
|
||||
this.dialect = dialect;
|
||||
this.options = options;
|
||||
}
|
||||
static [import_entity.entityKind] = "VercelPgDriver";
|
||||
createSession(schema) {
|
||||
return new import_session.VercelPgSession(this.client, this.dialect, schema, { logger: this.options.logger });
|
||||
}
|
||||
}
|
||||
class VercelPgDatabase extends import_db.PgDatabase {
|
||||
static [import_entity.entityKind] = "VercelPgDatabase";
|
||||
}
|
||||
function construct(client, config = {}) {
|
||||
const dialect = new import_pg_core.PgDialect({ casing: config.casing });
|
||||
let logger;
|
||||
if (config.logger === true) {
|
||||
logger = new import_logger.DefaultLogger();
|
||||
} else if (config.logger !== false) {
|
||||
logger = config.logger;
|
||||
}
|
||||
let schema;
|
||||
if (config.schema) {
|
||||
const tablesConfig = (0, import_relations.extractTablesRelationalConfig)(
|
||||
config.schema,
|
||||
import_relations.createTableRelationsHelpers
|
||||
);
|
||||
schema = {
|
||||
fullSchema: config.schema,
|
||||
schema: tablesConfig.tables,
|
||||
tableNamesMap: tablesConfig.tableNamesMap
|
||||
};
|
||||
}
|
||||
const driver = new VercelPgDriver(client, dialect, { logger });
|
||||
const session = driver.createSession(schema);
|
||||
const db = new VercelPgDatabase(dialect, session, schema);
|
||||
db.$client = client;
|
||||
return db;
|
||||
}
|
||||
function drizzle(...params) {
|
||||
if ((0, import_utils.isConfig)(params[0])) {
|
||||
const { client, ...drizzleConfig } = params[0];
|
||||
return construct(client ?? import_postgres.sql, drizzleConfig);
|
||||
}
|
||||
return construct(params[0] ?? import_postgres.sql, params[1]);
|
||||
}
|
||||
((drizzle2) => {
|
||||
function mock(config) {
|
||||
return construct({}, config);
|
||||
}
|
||||
drizzle2.mock = mock;
|
||||
})(drizzle || (drizzle = {}));
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
VercelPgDatabase,
|
||||
VercelPgDriver,
|
||||
drizzle
|
||||
});
|
||||
//# sourceMappingURL=driver.cjs.map
|
||||
1
node_modules/drizzle-orm/vercel-postgres/driver.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/vercel-postgres/driver.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/vercel-postgres/driver.ts"],"sourcesContent":["import { sql } from '@vercel/postgres';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { PgDatabase } from '~/pg-core/db.ts';\nimport { PgDialect } from '~/pg-core/index.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { type DrizzleConfig, isConfig } from '~/utils.ts';\nimport { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from './session.ts';\n\nexport interface VercelPgDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class VercelPgDriver {\n\tstatic readonly [entityKind]: string = 'VercelPgDriver';\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tprivate dialect: PgDialect,\n\t\tprivate options: VercelPgDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t): VercelPgSession<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new VercelPgSession(this.client, this.dialect, schema, { logger: this.options.logger });\n\t}\n}\n\nexport class VercelPgDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends PgDatabase<VercelPgQueryResultHKT, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgDatabase';\n}\n\nfunction construct<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: VercelPgClient,\n\tconfig: DrizzleConfig<TSchema> = {},\n): VercelPgDatabase<TSchema> & {\n\t$client: VercelPgClient;\n} {\n\tconst dialect = new PgDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst driver = new VercelPgDriver(client, dialect, { logger });\n\tconst session = driver.createSession(schema);\n\tconst db = new VercelPgDatabase(dialect, session, schema as any) as VercelPgDatabase<TSchema>;\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n\nexport function drizzle<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends VercelPgClient = typeof sql,\n>(\n\t...params: [] | [\n\t\tTClient,\n\t] | [\n\t\tTClient,\n\t\tDrizzleConfig<TSchema>,\n\t] | [\n\t\t(\n\t\t\t& DrizzleConfig<TSchema>\n\t\t\t& ({\n\t\t\t\tclient?: TClient;\n\t\t\t})\n\t\t),\n\t]\n): VercelPgDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tif (isConfig(params[0])) {\n\t\tconst { client, ...drizzleConfig } = params[0] as ({ client?: TClient } & DrizzleConfig<TSchema>);\n\t\treturn construct(client ?? sql, drizzleConfig) as any;\n\t}\n\n\treturn construct((params[0] ?? sql) as TClient, params[1] as DrizzleConfig<TSchema> | undefined) as any;\n}\n\nexport namespace drizzle {\n\texport function mock<TSchema extends Record<string, unknown> = Record<string, never>>(\n\t\tconfig?: DrizzleConfig<TSchema>,\n\t): VercelPgDatabase<TSchema> & {\n\t\t$client: '$client is not available on drizzle.mock()';\n\t} {\n\t\treturn construct({} as any, config) as any;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAoB;AACpB,oBAA2B;AAE3B,oBAA8B;AAC9B,gBAA2B;AAC3B,qBAA0B;AAC1B,uBAKO;AACP,mBAA6C;AAC7C,qBAAkF;AAM3E,MAAM,eAAe;AAAA,EAG3B,YACS,QACA,SACA,UAAiC,CAAC,GACzC;AAHO;AACA;AACA;AAAA,EAET;AAAA,EAPA,QAAiB,wBAAU,IAAY;AAAA,EASvC,cACC,QACmE;AACnE,WAAO,IAAI,+BAAgB,KAAK,QAAQ,KAAK,SAAS,QAAQ,EAAE,QAAQ,KAAK,QAAQ,OAAO,CAAC;AAAA,EAC9F;AACD;AAEO,MAAM,yBAEH,qBAA4C;AAAA,EACrD,QAA0B,wBAAU,IAAY;AACjD;AAEA,SAAS,UACR,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,yBAAU,EAAE,QAAQ,OAAO,OAAO,CAAC;AACvD,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,4BAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,mBAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,SAAS,IAAI,eAAe,QAAQ,SAAS,EAAE,OAAO,CAAC;AAC7D,QAAM,UAAU,OAAO,cAAc,MAAM;AAC3C,QAAM,KAAK,IAAI,iBAAiB,SAAS,SAAS,MAAa;AAC/D,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;AAEO,SAAS,WAIZ,QAeF;AACD,UAAI,uBAAS,OAAO,CAAC,CAAC,GAAG;AACxB,UAAM,EAAE,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC;AAC7C,WAAO,UAAU,UAAU,qBAAK,aAAa;AAAA,EAC9C;AAEA,SAAO,UAAW,OAAO,CAAC,KAAK,qBAAiB,OAAO,CAAC,CAAuC;AAChG;AAAA,CAEO,CAAUA,aAAV;AACC,WAAS,KACf,QAGC;AACD,WAAO,UAAU,CAAC,GAAU,MAAM;AAAA,EACnC;AANO,EAAAA,SAAS;AAAA,GADA;","names":["drizzle"]}
|
||||
39
node_modules/drizzle-orm/vercel-postgres/driver.d.cts
generated
vendored
Normal file
39
node_modules/drizzle-orm/vercel-postgres/driver.d.cts
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
import { sql } from '@vercel/postgres';
|
||||
import { entityKind } from "../entity.cjs";
|
||||
import type { Logger } from "../logger.cjs";
|
||||
import { PgDatabase } from "../pg-core/db.cjs";
|
||||
import { PgDialect } from "../pg-core/index.cjs";
|
||||
import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.cjs";
|
||||
import { type DrizzleConfig } from "../utils.cjs";
|
||||
import { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from "./session.cjs";
|
||||
export interface VercelPgDriverOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
export declare class VercelPgDriver {
|
||||
private client;
|
||||
private dialect;
|
||||
private options;
|
||||
static readonly [entityKind]: string;
|
||||
constructor(client: VercelPgClient, dialect: PgDialect, options?: VercelPgDriverOptions);
|
||||
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): VercelPgSession<Record<string, unknown>, TablesRelationalConfig>;
|
||||
}
|
||||
export declare class VercelPgDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<VercelPgQueryResultHKT, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
}
|
||||
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends VercelPgClient = typeof sql>(...params: [] | [
|
||||
TClient
|
||||
] | [
|
||||
TClient,
|
||||
DrizzleConfig<TSchema>
|
||||
] | [
|
||||
(DrizzleConfig<TSchema> & ({
|
||||
client?: TClient;
|
||||
}))
|
||||
]): VercelPgDatabase<TSchema> & {
|
||||
$client: TClient;
|
||||
};
|
||||
export declare namespace drizzle {
|
||||
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): VercelPgDatabase<TSchema> & {
|
||||
$client: '$client is not available on drizzle.mock()';
|
||||
};
|
||||
}
|
||||
39
node_modules/drizzle-orm/vercel-postgres/driver.d.ts
generated
vendored
Normal file
39
node_modules/drizzle-orm/vercel-postgres/driver.d.ts
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
import { sql } from '@vercel/postgres';
|
||||
import { entityKind } from "../entity.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import { PgDatabase } from "../pg-core/db.js";
|
||||
import { PgDialect } from "../pg-core/index.js";
|
||||
import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.js";
|
||||
import { type DrizzleConfig } from "../utils.js";
|
||||
import { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from "./session.js";
|
||||
export interface VercelPgDriverOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
export declare class VercelPgDriver {
|
||||
private client;
|
||||
private dialect;
|
||||
private options;
|
||||
static readonly [entityKind]: string;
|
||||
constructor(client: VercelPgClient, dialect: PgDialect, options?: VercelPgDriverOptions);
|
||||
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): VercelPgSession<Record<string, unknown>, TablesRelationalConfig>;
|
||||
}
|
||||
export declare class VercelPgDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<VercelPgQueryResultHKT, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
}
|
||||
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends VercelPgClient = typeof sql>(...params: [] | [
|
||||
TClient
|
||||
] | [
|
||||
TClient,
|
||||
DrizzleConfig<TSchema>
|
||||
] | [
|
||||
(DrizzleConfig<TSchema> & ({
|
||||
client?: TClient;
|
||||
}))
|
||||
]): VercelPgDatabase<TSchema> & {
|
||||
$client: TClient;
|
||||
};
|
||||
export declare namespace drizzle {
|
||||
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): VercelPgDatabase<TSchema> & {
|
||||
$client: '$client is not available on drizzle.mock()';
|
||||
};
|
||||
}
|
||||
70
node_modules/drizzle-orm/vercel-postgres/driver.js
generated
vendored
Normal file
70
node_modules/drizzle-orm/vercel-postgres/driver.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
import { sql } from "@vercel/postgres";
|
||||
import { entityKind } from "../entity.js";
|
||||
import { DefaultLogger } from "../logger.js";
|
||||
import { PgDatabase } from "../pg-core/db.js";
|
||||
import { PgDialect } from "../pg-core/index.js";
|
||||
import {
|
||||
createTableRelationsHelpers,
|
||||
extractTablesRelationalConfig
|
||||
} from "../relations.js";
|
||||
import { isConfig } from "../utils.js";
|
||||
import { VercelPgSession } from "./session.js";
|
||||
class VercelPgDriver {
|
||||
constructor(client, dialect, options = {}) {
|
||||
this.client = client;
|
||||
this.dialect = dialect;
|
||||
this.options = options;
|
||||
}
|
||||
static [entityKind] = "VercelPgDriver";
|
||||
createSession(schema) {
|
||||
return new VercelPgSession(this.client, this.dialect, schema, { logger: this.options.logger });
|
||||
}
|
||||
}
|
||||
class VercelPgDatabase extends PgDatabase {
|
||||
static [entityKind] = "VercelPgDatabase";
|
||||
}
|
||||
function construct(client, config = {}) {
|
||||
const dialect = new PgDialect({ casing: config.casing });
|
||||
let logger;
|
||||
if (config.logger === true) {
|
||||
logger = new DefaultLogger();
|
||||
} else if (config.logger !== false) {
|
||||
logger = config.logger;
|
||||
}
|
||||
let schema;
|
||||
if (config.schema) {
|
||||
const tablesConfig = extractTablesRelationalConfig(
|
||||
config.schema,
|
||||
createTableRelationsHelpers
|
||||
);
|
||||
schema = {
|
||||
fullSchema: config.schema,
|
||||
schema: tablesConfig.tables,
|
||||
tableNamesMap: tablesConfig.tableNamesMap
|
||||
};
|
||||
}
|
||||
const driver = new VercelPgDriver(client, dialect, { logger });
|
||||
const session = driver.createSession(schema);
|
||||
const db = new VercelPgDatabase(dialect, session, schema);
|
||||
db.$client = client;
|
||||
return db;
|
||||
}
|
||||
function drizzle(...params) {
|
||||
if (isConfig(params[0])) {
|
||||
const { client, ...drizzleConfig } = params[0];
|
||||
return construct(client ?? sql, drizzleConfig);
|
||||
}
|
||||
return construct(params[0] ?? sql, params[1]);
|
||||
}
|
||||
((drizzle2) => {
|
||||
function mock(config) {
|
||||
return construct({}, config);
|
||||
}
|
||||
drizzle2.mock = mock;
|
||||
})(drizzle || (drizzle = {}));
|
||||
export {
|
||||
VercelPgDatabase,
|
||||
VercelPgDriver,
|
||||
drizzle
|
||||
};
|
||||
//# sourceMappingURL=driver.js.map
|
||||
1
node_modules/drizzle-orm/vercel-postgres/driver.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/vercel-postgres/driver.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/vercel-postgres/driver.ts"],"sourcesContent":["import { sql } from '@vercel/postgres';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { PgDatabase } from '~/pg-core/db.ts';\nimport { PgDialect } from '~/pg-core/index.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { type DrizzleConfig, isConfig } from '~/utils.ts';\nimport { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from './session.ts';\n\nexport interface VercelPgDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class VercelPgDriver {\n\tstatic readonly [entityKind]: string = 'VercelPgDriver';\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tprivate dialect: PgDialect,\n\t\tprivate options: VercelPgDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t): VercelPgSession<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new VercelPgSession(this.client, this.dialect, schema, { logger: this.options.logger });\n\t}\n}\n\nexport class VercelPgDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends PgDatabase<VercelPgQueryResultHKT, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgDatabase';\n}\n\nfunction construct<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: VercelPgClient,\n\tconfig: DrizzleConfig<TSchema> = {},\n): VercelPgDatabase<TSchema> & {\n\t$client: VercelPgClient;\n} {\n\tconst dialect = new PgDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst driver = new VercelPgDriver(client, dialect, { logger });\n\tconst session = driver.createSession(schema);\n\tconst db = new VercelPgDatabase(dialect, session, schema as any) as VercelPgDatabase<TSchema>;\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n\nexport function drizzle<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends VercelPgClient = typeof sql,\n>(\n\t...params: [] | [\n\t\tTClient,\n\t] | [\n\t\tTClient,\n\t\tDrizzleConfig<TSchema>,\n\t] | [\n\t\t(\n\t\t\t& DrizzleConfig<TSchema>\n\t\t\t& ({\n\t\t\t\tclient?: TClient;\n\t\t\t})\n\t\t),\n\t]\n): VercelPgDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tif (isConfig(params[0])) {\n\t\tconst { client, ...drizzleConfig } = params[0] as ({ client?: TClient } & DrizzleConfig<TSchema>);\n\t\treturn construct(client ?? sql, drizzleConfig) as any;\n\t}\n\n\treturn construct((params[0] ?? sql) as TClient, params[1] as DrizzleConfig<TSchema> | undefined) as any;\n}\n\nexport namespace drizzle {\n\texport function mock<TSchema extends Record<string, unknown> = Record<string, never>>(\n\t\tconfig?: DrizzleConfig<TSchema>,\n\t): VercelPgDatabase<TSchema> & {\n\t\t$client: '$client is not available on drizzle.mock()';\n\t} {\n\t\treturn construct({} as any, config) as any;\n\t}\n}\n"],"mappings":"AAAA,SAAS,WAAW;AACpB,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAA6B,gBAAgB;AAC7C,SAA2D,uBAAuB;AAM3E,MAAM,eAAe;AAAA,EAG3B,YACS,QACA,SACA,UAAiC,CAAC,GACzC;AAHO;AACA;AACA;AAAA,EAET;AAAA,EAPA,QAAiB,UAAU,IAAY;AAAA,EASvC,cACC,QACmE;AACnE,WAAO,IAAI,gBAAgB,KAAK,QAAQ,KAAK,SAAS,QAAQ,EAAE,QAAQ,KAAK,QAAQ,OAAO,CAAC;AAAA,EAC9F;AACD;AAEO,MAAM,yBAEH,WAA4C;AAAA,EACrD,QAA0B,UAAU,IAAY;AACjD;AAEA,SAAS,UACR,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,UAAU,EAAE,QAAQ,OAAO,OAAO,CAAC;AACvD,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,cAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,eAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,SAAS,IAAI,eAAe,QAAQ,SAAS,EAAE,OAAO,CAAC;AAC7D,QAAM,UAAU,OAAO,cAAc,MAAM;AAC3C,QAAM,KAAK,IAAI,iBAAiB,SAAS,SAAS,MAAa;AAC/D,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;AAEO,SAAS,WAIZ,QAeF;AACD,MAAI,SAAS,OAAO,CAAC,CAAC,GAAG;AACxB,UAAM,EAAE,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC;AAC7C,WAAO,UAAU,UAAU,KAAK,aAAa;AAAA,EAC9C;AAEA,SAAO,UAAW,OAAO,CAAC,KAAK,KAAiB,OAAO,CAAC,CAAuC;AAChG;AAAA,CAEO,CAAUA,aAAV;AACC,WAAS,KACf,QAGC;AACD,WAAO,UAAU,CAAC,GAAU,MAAM;AAAA,EACnC;AANO,EAAAA,SAAS;AAAA,GADA;","names":["drizzle"]}
|
||||
25
node_modules/drizzle-orm/vercel-postgres/index.cjs
generated
vendored
Normal file
25
node_modules/drizzle-orm/vercel-postgres/index.cjs
generated
vendored
Normal 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 __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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var vercel_postgres_exports = {};
|
||||
module.exports = __toCommonJS(vercel_postgres_exports);
|
||||
__reExport(vercel_postgres_exports, require("./driver.cjs"), module.exports);
|
||||
__reExport(vercel_postgres_exports, require("./session.cjs"), module.exports);
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
...require("./driver.cjs"),
|
||||
...require("./session.cjs")
|
||||
});
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
1
node_modules/drizzle-orm/vercel-postgres/index.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/vercel-postgres/index.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/vercel-postgres/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,oCAAc,wBAAd;AACA,oCAAc,yBADd;","names":[]}
|
||||
2
node_modules/drizzle-orm/vercel-postgres/index.d.cts
generated
vendored
Normal file
2
node_modules/drizzle-orm/vercel-postgres/index.d.cts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./driver.cjs";
|
||||
export * from "./session.cjs";
|
||||
2
node_modules/drizzle-orm/vercel-postgres/index.d.ts
generated
vendored
Normal file
2
node_modules/drizzle-orm/vercel-postgres/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./driver.js";
|
||||
export * from "./session.js";
|
||||
3
node_modules/drizzle-orm/vercel-postgres/index.js
generated
vendored
Normal file
3
node_modules/drizzle-orm/vercel-postgres/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export * from "./driver.js";
|
||||
export * from "./session.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/drizzle-orm/vercel-postgres/index.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/vercel-postgres/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/vercel-postgres/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
||||
33
node_modules/drizzle-orm/vercel-postgres/migrator.cjs
generated
vendored
Normal file
33
node_modules/drizzle-orm/vercel-postgres/migrator.cjs
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
"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 migrator_exports = {};
|
||||
__export(migrator_exports, {
|
||||
migrate: () => migrate
|
||||
});
|
||||
module.exports = __toCommonJS(migrator_exports);
|
||||
var import_migrator = require("../migrator.cjs");
|
||||
async function migrate(db, config) {
|
||||
const migrations = (0, import_migrator.readMigrationFiles)(config);
|
||||
await db.dialect.migrate(migrations, db.session, config);
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
migrate
|
||||
});
|
||||
//# sourceMappingURL=migrator.cjs.map
|
||||
1
node_modules/drizzle-orm/vercel-postgres/migrator.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/vercel-postgres/migrator.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/vercel-postgres/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { VercelPgDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: VercelPgDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tawait db.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAmC;AAGnC,eAAsB,QACrB,IACA,QACC;AACD,QAAM,iBAAa,oCAAmB,MAAM;AAC5C,QAAM,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AACxD;","names":[]}
|
||||
3
node_modules/drizzle-orm/vercel-postgres/migrator.d.cts
generated
vendored
Normal file
3
node_modules/drizzle-orm/vercel-postgres/migrator.d.cts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import type { MigrationConfig } from "../migrator.cjs";
|
||||
import type { VercelPgDatabase } from "./driver.cjs";
|
||||
export declare function migrate<TSchema extends Record<string, unknown>>(db: VercelPgDatabase<TSchema>, config: MigrationConfig): Promise<void>;
|
||||
3
node_modules/drizzle-orm/vercel-postgres/migrator.d.ts
generated
vendored
Normal file
3
node_modules/drizzle-orm/vercel-postgres/migrator.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import type { MigrationConfig } from "../migrator.js";
|
||||
import type { VercelPgDatabase } from "./driver.js";
|
||||
export declare function migrate<TSchema extends Record<string, unknown>>(db: VercelPgDatabase<TSchema>, config: MigrationConfig): Promise<void>;
|
||||
9
node_modules/drizzle-orm/vercel-postgres/migrator.js
generated
vendored
Normal file
9
node_modules/drizzle-orm/vercel-postgres/migrator.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import { readMigrationFiles } from "../migrator.js";
|
||||
async function migrate(db, config) {
|
||||
const migrations = readMigrationFiles(config);
|
||||
await db.dialect.migrate(migrations, db.session, config);
|
||||
}
|
||||
export {
|
||||
migrate
|
||||
};
|
||||
//# sourceMappingURL=migrator.js.map
|
||||
1
node_modules/drizzle-orm/vercel-postgres/migrator.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/vercel-postgres/migrator.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/vercel-postgres/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { VercelPgDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: VercelPgDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tawait db.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":"AACA,SAAS,0BAA0B;AAGnC,eAAsB,QACrB,IACA,QACC;AACD,QAAM,aAAa,mBAAmB,MAAM;AAC5C,QAAM,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AACxD;","names":[]}
|
||||
198
node_modules/drizzle-orm/vercel-postgres/session.cjs
generated
vendored
Normal file
198
node_modules/drizzle-orm/vercel-postgres/session.cjs
generated
vendored
Normal file
@ -0,0 +1,198 @@
|
||||
"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 session_exports = {};
|
||||
__export(session_exports, {
|
||||
VercelPgPreparedQuery: () => VercelPgPreparedQuery,
|
||||
VercelPgSession: () => VercelPgSession,
|
||||
VercelPgTransaction: () => VercelPgTransaction
|
||||
});
|
||||
module.exports = __toCommonJS(session_exports);
|
||||
var import_postgres = require("@vercel/postgres");
|
||||
var import_entity = require("../entity.cjs");
|
||||
var import_logger = require("../logger.cjs");
|
||||
var import_pg_core = require("../pg-core/index.cjs");
|
||||
var import_session = require("../pg-core/session.cjs");
|
||||
var import_sql = require("../sql/sql.cjs");
|
||||
var import_utils = require("../utils.cjs");
|
||||
class VercelPgPreparedQuery extends import_session.PgPreparedQuery {
|
||||
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper) {
|
||||
super({ sql: queryString, params });
|
||||
this.client = client;
|
||||
this.params = params;
|
||||
this.logger = logger;
|
||||
this.fields = fields;
|
||||
this._isResponseInArrayMode = _isResponseInArrayMode;
|
||||
this.customResultMapper = customResultMapper;
|
||||
this.rawQuery = {
|
||||
name,
|
||||
text: queryString,
|
||||
types: {
|
||||
// @ts-ignore
|
||||
getTypeParser: (typeId, format) => {
|
||||
if (typeId === import_postgres.types.builtins.TIMESTAMPTZ) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === import_postgres.types.builtins.TIMESTAMP) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === import_postgres.types.builtins.DATE) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === import_postgres.types.builtins.INTERVAL) {
|
||||
return (val) => val;
|
||||
}
|
||||
return import_postgres.types.getTypeParser(typeId, format);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.queryConfig = {
|
||||
name,
|
||||
text: queryString,
|
||||
rowMode: "array",
|
||||
types: {
|
||||
// @ts-ignore
|
||||
getTypeParser: (typeId, format) => {
|
||||
if (typeId === import_postgres.types.builtins.TIMESTAMPTZ) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === import_postgres.types.builtins.TIMESTAMP) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === import_postgres.types.builtins.DATE) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === import_postgres.types.builtins.INTERVAL) {
|
||||
return (val) => val;
|
||||
}
|
||||
return import_postgres.types.getTypeParser(typeId, format);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
static [import_entity.entityKind] = "VercelPgPreparedQuery";
|
||||
rawQuery;
|
||||
queryConfig;
|
||||
async execute(placeholderValues = {}) {
|
||||
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
||||
this.logger.logQuery(this.rawQuery.text, params);
|
||||
const { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;
|
||||
if (!fields && !customResultMapper) {
|
||||
return client.query(rawQuery, params);
|
||||
}
|
||||
const { rows } = await client.query(query, params);
|
||||
if (customResultMapper) {
|
||||
return customResultMapper(rows);
|
||||
}
|
||||
return rows.map((row) => (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap));
|
||||
}
|
||||
all(placeholderValues = {}) {
|
||||
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
||||
this.logger.logQuery(this.rawQuery.text, params);
|
||||
return this.client.query(this.rawQuery, params).then((result) => result.rows);
|
||||
}
|
||||
values(placeholderValues = {}) {
|
||||
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
||||
this.logger.logQuery(this.rawQuery.text, params);
|
||||
return this.client.query(this.queryConfig, params).then((result) => result.rows);
|
||||
}
|
||||
/** @internal */
|
||||
isResponseInArrayMode() {
|
||||
return this._isResponseInArrayMode;
|
||||
}
|
||||
}
|
||||
class VercelPgSession extends import_session.PgSession {
|
||||
constructor(client, dialect, schema, options = {}) {
|
||||
super(dialect);
|
||||
this.client = client;
|
||||
this.schema = schema;
|
||||
this.options = options;
|
||||
this.logger = options.logger ?? new import_logger.NoopLogger();
|
||||
}
|
||||
static [import_entity.entityKind] = "VercelPgSession";
|
||||
logger;
|
||||
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
|
||||
return new VercelPgPreparedQuery(
|
||||
this.client,
|
||||
query.sql,
|
||||
query.params,
|
||||
this.logger,
|
||||
fields,
|
||||
name,
|
||||
isResponseInArrayMode,
|
||||
customResultMapper
|
||||
);
|
||||
}
|
||||
async query(query, params) {
|
||||
this.logger.logQuery(query, params);
|
||||
const result = await this.client.query({
|
||||
rowMode: "array",
|
||||
text: query,
|
||||
values: params
|
||||
});
|
||||
return result;
|
||||
}
|
||||
async queryObjects(query, params) {
|
||||
return this.client.query(query, params);
|
||||
}
|
||||
async transaction(transaction, config) {
|
||||
const session = this.client instanceof import_postgres.VercelPool ? new VercelPgSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
|
||||
const tx = new VercelPgTransaction(this.dialect, session, this.schema);
|
||||
await tx.execute(import_sql.sql`begin${config ? import_sql.sql` ${tx.getTransactionConfigSQL(config)}` : void 0}`);
|
||||
try {
|
||||
const result = await transaction(tx);
|
||||
await tx.execute(import_sql.sql`commit`);
|
||||
return result;
|
||||
} catch (error) {
|
||||
await tx.execute(import_sql.sql`rollback`);
|
||||
throw error;
|
||||
} finally {
|
||||
if (this.client instanceof import_postgres.VercelPool) {
|
||||
session.client.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class VercelPgTransaction extends import_pg_core.PgTransaction {
|
||||
static [import_entity.entityKind] = "VercelPgTransaction";
|
||||
async transaction(transaction) {
|
||||
const savepointName = `sp${this.nestedIndex + 1}`;
|
||||
const tx = new VercelPgTransaction(
|
||||
this.dialect,
|
||||
this.session,
|
||||
this.schema,
|
||||
this.nestedIndex + 1
|
||||
);
|
||||
await tx.execute(import_sql.sql.raw(`savepoint ${savepointName}`));
|
||||
try {
|
||||
const result = await transaction(tx);
|
||||
await tx.execute(import_sql.sql.raw(`release savepoint ${savepointName}`));
|
||||
return result;
|
||||
} catch (err) {
|
||||
await tx.execute(import_sql.sql.raw(`rollback to savepoint ${savepointName}`));
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
VercelPgPreparedQuery,
|
||||
VercelPgSession,
|
||||
VercelPgTransaction
|
||||
});
|
||||
//# sourceMappingURL=session.cjs.map
|
||||
1
node_modules/drizzle-orm/vercel-postgres/session.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/vercel-postgres/session.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
48
node_modules/drizzle-orm/vercel-postgres/session.d.cts
generated
vendored
Normal file
48
node_modules/drizzle-orm/vercel-postgres/session.d.cts
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
import { type QueryResult, type QueryResultRow, type VercelClient, VercelPool, type VercelPoolClient } from '@vercel/postgres';
|
||||
import { entityKind } from "../entity.cjs";
|
||||
import { type Logger } from "../logger.cjs";
|
||||
import { type PgDialect, PgTransaction } from "../pg-core/index.cjs";
|
||||
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.cjs";
|
||||
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.cjs";
|
||||
import { PgPreparedQuery, PgSession } from "../pg-core/session.cjs";
|
||||
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
||||
import { type Query } from "../sql/sql.cjs";
|
||||
import { type Assume } from "../utils.cjs";
|
||||
export type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;
|
||||
export declare class VercelPgPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
||||
private client;
|
||||
private params;
|
||||
private logger;
|
||||
private fields;
|
||||
private _isResponseInArrayMode;
|
||||
private customResultMapper?;
|
||||
static readonly [entityKind]: string;
|
||||
private rawQuery;
|
||||
private queryConfig;
|
||||
constructor(client: VercelPgClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
||||
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
||||
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
||||
values(placeholderValues?: Record<string, unknown> | undefined): Promise<T['values']>;
|
||||
}
|
||||
export interface VercelPgSessionOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
export declare class VercelPgSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {
|
||||
private client;
|
||||
private schema;
|
||||
private options;
|
||||
static readonly [entityKind]: string;
|
||||
private logger;
|
||||
constructor(client: VercelPgClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: VercelPgSessionOptions);
|
||||
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
||||
query(query: string, params: unknown[]): Promise<QueryResult>;
|
||||
queryObjects<T extends QueryResultRow>(query: string, params: unknown[]): Promise<QueryResult<T>>;
|
||||
transaction<T>(transaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig | undefined): Promise<T>;
|
||||
}
|
||||
export declare class VercelPgTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<VercelPgQueryResultHKT, TFullSchema, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
transaction<T>(transaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
||||
}
|
||||
export interface VercelPgQueryResultHKT extends PgQueryResultHKT {
|
||||
type: QueryResult<Assume<this['row'], QueryResultRow>>;
|
||||
}
|
||||
48
node_modules/drizzle-orm/vercel-postgres/session.d.ts
generated
vendored
Normal file
48
node_modules/drizzle-orm/vercel-postgres/session.d.ts
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
import { type QueryResult, type QueryResultRow, type VercelClient, VercelPool, type VercelPoolClient } from '@vercel/postgres';
|
||||
import { entityKind } from "../entity.js";
|
||||
import { type Logger } from "../logger.js";
|
||||
import { type PgDialect, PgTransaction } from "../pg-core/index.js";
|
||||
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.js";
|
||||
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.js";
|
||||
import { PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
||||
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
||||
import { type Query } from "../sql/sql.js";
|
||||
import { type Assume } from "../utils.js";
|
||||
export type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;
|
||||
export declare class VercelPgPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
||||
private client;
|
||||
private params;
|
||||
private logger;
|
||||
private fields;
|
||||
private _isResponseInArrayMode;
|
||||
private customResultMapper?;
|
||||
static readonly [entityKind]: string;
|
||||
private rawQuery;
|
||||
private queryConfig;
|
||||
constructor(client: VercelPgClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
||||
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
||||
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
||||
values(placeholderValues?: Record<string, unknown> | undefined): Promise<T['values']>;
|
||||
}
|
||||
export interface VercelPgSessionOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
export declare class VercelPgSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {
|
||||
private client;
|
||||
private schema;
|
||||
private options;
|
||||
static readonly [entityKind]: string;
|
||||
private logger;
|
||||
constructor(client: VercelPgClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: VercelPgSessionOptions);
|
||||
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
||||
query(query: string, params: unknown[]): Promise<QueryResult>;
|
||||
queryObjects<T extends QueryResultRow>(query: string, params: unknown[]): Promise<QueryResult<T>>;
|
||||
transaction<T>(transaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig | undefined): Promise<T>;
|
||||
}
|
||||
export declare class VercelPgTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<VercelPgQueryResultHKT, TFullSchema, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
transaction<T>(transaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
||||
}
|
||||
export interface VercelPgQueryResultHKT extends PgQueryResultHKT {
|
||||
type: QueryResult<Assume<this['row'], QueryResultRow>>;
|
||||
}
|
||||
175
node_modules/drizzle-orm/vercel-postgres/session.js
generated
vendored
Normal file
175
node_modules/drizzle-orm/vercel-postgres/session.js
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
import {
|
||||
types,
|
||||
VercelPool
|
||||
} from "@vercel/postgres";
|
||||
import { entityKind } from "../entity.js";
|
||||
import { NoopLogger } from "../logger.js";
|
||||
import { PgTransaction } from "../pg-core/index.js";
|
||||
import { PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
||||
import { fillPlaceholders, sql } from "../sql/sql.js";
|
||||
import { mapResultRow } from "../utils.js";
|
||||
class VercelPgPreparedQuery extends PgPreparedQuery {
|
||||
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper) {
|
||||
super({ sql: queryString, params });
|
||||
this.client = client;
|
||||
this.params = params;
|
||||
this.logger = logger;
|
||||
this.fields = fields;
|
||||
this._isResponseInArrayMode = _isResponseInArrayMode;
|
||||
this.customResultMapper = customResultMapper;
|
||||
this.rawQuery = {
|
||||
name,
|
||||
text: queryString,
|
||||
types: {
|
||||
// @ts-ignore
|
||||
getTypeParser: (typeId, format) => {
|
||||
if (typeId === types.builtins.TIMESTAMPTZ) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === types.builtins.TIMESTAMP) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === types.builtins.DATE) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === types.builtins.INTERVAL) {
|
||||
return (val) => val;
|
||||
}
|
||||
return types.getTypeParser(typeId, format);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.queryConfig = {
|
||||
name,
|
||||
text: queryString,
|
||||
rowMode: "array",
|
||||
types: {
|
||||
// @ts-ignore
|
||||
getTypeParser: (typeId, format) => {
|
||||
if (typeId === types.builtins.TIMESTAMPTZ) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === types.builtins.TIMESTAMP) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === types.builtins.DATE) {
|
||||
return (val) => val;
|
||||
}
|
||||
if (typeId === types.builtins.INTERVAL) {
|
||||
return (val) => val;
|
||||
}
|
||||
return types.getTypeParser(typeId, format);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
static [entityKind] = "VercelPgPreparedQuery";
|
||||
rawQuery;
|
||||
queryConfig;
|
||||
async execute(placeholderValues = {}) {
|
||||
const params = fillPlaceholders(this.params, placeholderValues);
|
||||
this.logger.logQuery(this.rawQuery.text, params);
|
||||
const { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;
|
||||
if (!fields && !customResultMapper) {
|
||||
return client.query(rawQuery, params);
|
||||
}
|
||||
const { rows } = await client.query(query, params);
|
||||
if (customResultMapper) {
|
||||
return customResultMapper(rows);
|
||||
}
|
||||
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
||||
}
|
||||
all(placeholderValues = {}) {
|
||||
const params = fillPlaceholders(this.params, placeholderValues);
|
||||
this.logger.logQuery(this.rawQuery.text, params);
|
||||
return this.client.query(this.rawQuery, params).then((result) => result.rows);
|
||||
}
|
||||
values(placeholderValues = {}) {
|
||||
const params = fillPlaceholders(this.params, placeholderValues);
|
||||
this.logger.logQuery(this.rawQuery.text, params);
|
||||
return this.client.query(this.queryConfig, params).then((result) => result.rows);
|
||||
}
|
||||
/** @internal */
|
||||
isResponseInArrayMode() {
|
||||
return this._isResponseInArrayMode;
|
||||
}
|
||||
}
|
||||
class VercelPgSession extends PgSession {
|
||||
constructor(client, dialect, schema, options = {}) {
|
||||
super(dialect);
|
||||
this.client = client;
|
||||
this.schema = schema;
|
||||
this.options = options;
|
||||
this.logger = options.logger ?? new NoopLogger();
|
||||
}
|
||||
static [entityKind] = "VercelPgSession";
|
||||
logger;
|
||||
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
|
||||
return new VercelPgPreparedQuery(
|
||||
this.client,
|
||||
query.sql,
|
||||
query.params,
|
||||
this.logger,
|
||||
fields,
|
||||
name,
|
||||
isResponseInArrayMode,
|
||||
customResultMapper
|
||||
);
|
||||
}
|
||||
async query(query, params) {
|
||||
this.logger.logQuery(query, params);
|
||||
const result = await this.client.query({
|
||||
rowMode: "array",
|
||||
text: query,
|
||||
values: params
|
||||
});
|
||||
return result;
|
||||
}
|
||||
async queryObjects(query, params) {
|
||||
return this.client.query(query, params);
|
||||
}
|
||||
async transaction(transaction, config) {
|
||||
const session = this.client instanceof VercelPool ? new VercelPgSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
|
||||
const tx = new VercelPgTransaction(this.dialect, session, this.schema);
|
||||
await tx.execute(sql`begin${config ? sql` ${tx.getTransactionConfigSQL(config)}` : void 0}`);
|
||||
try {
|
||||
const result = await transaction(tx);
|
||||
await tx.execute(sql`commit`);
|
||||
return result;
|
||||
} catch (error) {
|
||||
await tx.execute(sql`rollback`);
|
||||
throw error;
|
||||
} finally {
|
||||
if (this.client instanceof VercelPool) {
|
||||
session.client.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class VercelPgTransaction extends PgTransaction {
|
||||
static [entityKind] = "VercelPgTransaction";
|
||||
async transaction(transaction) {
|
||||
const savepointName = `sp${this.nestedIndex + 1}`;
|
||||
const tx = new VercelPgTransaction(
|
||||
this.dialect,
|
||||
this.session,
|
||||
this.schema,
|
||||
this.nestedIndex + 1
|
||||
);
|
||||
await tx.execute(sql.raw(`savepoint ${savepointName}`));
|
||||
try {
|
||||
const result = await transaction(tx);
|
||||
await tx.execute(sql.raw(`release savepoint ${savepointName}`));
|
||||
return result;
|
||||
} catch (err) {
|
||||
await tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
export {
|
||||
VercelPgPreparedQuery,
|
||||
VercelPgSession,
|
||||
VercelPgTransaction
|
||||
};
|
||||
//# sourceMappingURL=session.js.map
|
||||
1
node_modules/drizzle-orm/vercel-postgres/session.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/vercel-postgres/session.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user