Initial commit

This commit is contained in:
Ammaar Reshi
2025-01-04 14:06:53 +00:00
parent 7082408604
commit d6025af146
23760 changed files with 3299690 additions and 0 deletions

113
node_modules/drizzle-orm/postgres-js/driver.cjs generated vendored Normal file
View File

@ -0,0 +1,113 @@
"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 driver_exports = {};
__export(driver_exports, {
PostgresJsDatabase: () => PostgresJsDatabase,
drizzle: () => drizzle
});
module.exports = __toCommonJS(driver_exports);
var import_postgres = __toESM(require("postgres"), 1);
var import_entity = require("../entity.cjs");
var import_logger = require("../logger.cjs");
var import_db = require("../pg-core/db.cjs");
var import_dialect = require("../pg-core/dialect.cjs");
var import_relations = require("../relations.cjs");
var import_utils = require("../utils.cjs");
var import_session = require("./session.cjs");
class PostgresJsDatabase extends import_db.PgDatabase {
static [import_entity.entityKind] = "PostgresJsDatabase";
}
function construct(client, config = {}) {
const transparentParser = (val) => val;
for (const type of ["1184", "1082", "1083", "1114"]) {
client.options.parsers[type] = transparentParser;
client.options.serializers[type] = transparentParser;
}
client.options.serializers["114"] = transparentParser;
client.options.serializers["3802"] = transparentParser;
const dialect = new import_dialect.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 session = new import_session.PostgresJsSession(client, dialect, schema, { logger });
const db = new PostgresJsDatabase(dialect, session, schema);
db.$client = client;
return db;
}
function drizzle(...params) {
if (typeof params[0] === "string") {
const instance = (0, import_postgres.default)(params[0]);
return construct(instance, params[1]);
}
if ((0, import_utils.isConfig)(params[0])) {
const { connection, client, ...drizzleConfig } = params[0];
if (client)
return construct(client, drizzleConfig);
if (typeof connection === "object" && connection.url !== void 0) {
const { url, ...config } = connection;
const instance2 = (0, import_postgres.default)(url, config);
return construct(instance2, drizzleConfig);
}
const instance = (0, import_postgres.default)(connection);
return construct(instance, drizzleConfig);
}
return construct(params[0], params[1]);
}
((drizzle2) => {
function mock(config) {
return construct({
options: {
parsers: {},
serializers: {}
}
}, config);
}
drizzle2.mock = mock;
})(drizzle || (drizzle = {}));
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
PostgresJsDatabase,
drizzle
});
//# sourceMappingURL=driver.cjs.map

1
node_modules/drizzle-orm/postgres-js/driver.cjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

29
node_modules/drizzle-orm/postgres-js/driver.d.cts generated vendored Normal file
View File

@ -0,0 +1,29 @@
import { type Options, type PostgresType, type Sql } from 'postgres';
import { entityKind } from "../entity.cjs";
import { PgDatabase } from "../pg-core/db.cjs";
import { type DrizzleConfig } from "../utils.cjs";
import type { PostgresJsQueryResultHKT } from "./session.cjs";
export declare class PostgresJsDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<PostgresJsQueryResultHKT, TSchema> {
static readonly [entityKind]: string;
}
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends Sql = Sql>(...params: [
TClient | string
] | [
TClient | string,
DrizzleConfig<TSchema>
] | [
(DrizzleConfig<TSchema> & ({
connection: string | ({
url?: string;
} & Options<Record<string, PostgresType>>);
} | {
client: TClient;
}))
]): PostgresJsDatabase<TSchema> & {
$client: TClient;
};
export declare namespace drizzle {
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): PostgresJsDatabase<TSchema> & {
$client: '$client is not available on drizzle.mock()';
};
}

29
node_modules/drizzle-orm/postgres-js/driver.d.ts generated vendored Normal file
View File

@ -0,0 +1,29 @@
import { type Options, type PostgresType, type Sql } from 'postgres';
import { entityKind } from "../entity.js";
import { PgDatabase } from "../pg-core/db.js";
import { type DrizzleConfig } from "../utils.js";
import type { PostgresJsQueryResultHKT } from "./session.js";
export declare class PostgresJsDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<PostgresJsQueryResultHKT, TSchema> {
static readonly [entityKind]: string;
}
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends Sql = Sql>(...params: [
TClient | string
] | [
TClient | string,
DrizzleConfig<TSchema>
] | [
(DrizzleConfig<TSchema> & ({
connection: string | ({
url?: string;
} & Options<Record<string, PostgresType>>);
} | {
client: TClient;
}))
]): PostgresJsDatabase<TSchema> & {
$client: TClient;
};
export declare namespace drizzle {
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): PostgresJsDatabase<TSchema> & {
$client: '$client is not available on drizzle.mock()';
};
}

81
node_modules/drizzle-orm/postgres-js/driver.js generated vendored Normal file
View File

@ -0,0 +1,81 @@
import pgClient from "postgres";
import { entityKind } from "../entity.js";
import { DefaultLogger } from "../logger.js";
import { PgDatabase } from "../pg-core/db.js";
import { PgDialect } from "../pg-core/dialect.js";
import {
createTableRelationsHelpers,
extractTablesRelationalConfig
} from "../relations.js";
import { isConfig } from "../utils.js";
import { PostgresJsSession } from "./session.js";
class PostgresJsDatabase extends PgDatabase {
static [entityKind] = "PostgresJsDatabase";
}
function construct(client, config = {}) {
const transparentParser = (val) => val;
for (const type of ["1184", "1082", "1083", "1114"]) {
client.options.parsers[type] = transparentParser;
client.options.serializers[type] = transparentParser;
}
client.options.serializers["114"] = transparentParser;
client.options.serializers["3802"] = transparentParser;
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 session = new PostgresJsSession(client, dialect, schema, { logger });
const db = new PostgresJsDatabase(dialect, session, schema);
db.$client = client;
return db;
}
function drizzle(...params) {
if (typeof params[0] === "string") {
const instance = pgClient(params[0]);
return construct(instance, params[1]);
}
if (isConfig(params[0])) {
const { connection, client, ...drizzleConfig } = params[0];
if (client)
return construct(client, drizzleConfig);
if (typeof connection === "object" && connection.url !== void 0) {
const { url, ...config } = connection;
const instance2 = pgClient(url, config);
return construct(instance2, drizzleConfig);
}
const instance = pgClient(connection);
return construct(instance, drizzleConfig);
}
return construct(params[0], params[1]);
}
((drizzle2) => {
function mock(config) {
return construct({
options: {
parsers: {},
serializers: {}
}
}, config);
}
drizzle2.mock = mock;
})(drizzle || (drizzle = {}));
export {
PostgresJsDatabase,
drizzle
};
//# sourceMappingURL=driver.js.map

1
node_modules/drizzle-orm/postgres-js/driver.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

25
node_modules/drizzle-orm/postgres-js/index.cjs generated vendored Normal file
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 __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 postgres_js_exports = {};
module.exports = __toCommonJS(postgres_js_exports);
__reExport(postgres_js_exports, require("./driver.cjs"), module.exports);
__reExport(postgres_js_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/postgres-js/index.cjs.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/postgres-js/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gCAAc,wBAAd;AACA,gCAAc,yBADd;","names":[]}

2
node_modules/drizzle-orm/postgres-js/index.d.cts generated vendored Normal file
View File

@ -0,0 +1,2 @@
export * from "./driver.cjs";
export * from "./session.cjs";

2
node_modules/drizzle-orm/postgres-js/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
export * from "./driver.js";
export * from "./session.js";

3
node_modules/drizzle-orm/postgres-js/index.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
export * from "./driver.js";
export * from "./session.js";
//# sourceMappingURL=index.js.map

1
node_modules/drizzle-orm/postgres-js/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/postgres-js/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}

33
node_modules/drizzle-orm/postgres-js/migrator.cjs generated vendored Normal file
View 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

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/postgres-js/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { PostgresJsDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: PostgresJsDatabase<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/postgres-js/migrator.d.cts generated vendored Normal file
View File

@ -0,0 +1,3 @@
import type { MigrationConfig } from "../migrator.cjs";
import type { PostgresJsDatabase } from "./driver.cjs";
export declare function migrate<TSchema extends Record<string, unknown>>(db: PostgresJsDatabase<TSchema>, config: MigrationConfig): Promise<void>;

3
node_modules/drizzle-orm/postgres-js/migrator.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
import type { MigrationConfig } from "../migrator.js";
import type { PostgresJsDatabase } from "./driver.js";
export declare function migrate<TSchema extends Record<string, unknown>>(db: PostgresJsDatabase<TSchema>, config: MigrationConfig): Promise<void>;

9
node_modules/drizzle-orm/postgres-js/migrator.js generated vendored Normal file
View 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/postgres-js/migrator.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/postgres-js/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { PostgresJsDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: PostgresJsDatabase<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":[]}

162
node_modules/drizzle-orm/postgres-js/session.cjs generated vendored Normal file
View File

@ -0,0 +1,162 @@
"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, {
PostgresJsPreparedQuery: () => PostgresJsPreparedQuery,
PostgresJsSession: () => PostgresJsSession,
PostgresJsTransaction: () => PostgresJsTransaction
});
module.exports = __toCommonJS(session_exports);
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_tracing = require("../tracing.cjs");
var import_utils = require("../utils.cjs");
class PostgresJsPreparedQuery extends import_session.PgPreparedQuery {
constructor(client, queryString, params, logger, fields, _isResponseInArrayMode, customResultMapper) {
super({ sql: queryString, params });
this.client = client;
this.queryString = queryString;
this.params = params;
this.logger = logger;
this.fields = fields;
this._isResponseInArrayMode = _isResponseInArrayMode;
this.customResultMapper = customResultMapper;
}
static [import_entity.entityKind] = "PostgresJsPreparedQuery";
async execute(placeholderValues = {}) {
return import_tracing.tracer.startActiveSpan("drizzle.execute", async (span) => {
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
span?.setAttributes({
"drizzle.query.text": this.queryString,
"drizzle.query.params": JSON.stringify(params)
});
this.logger.logQuery(this.queryString, params);
const { fields, queryString: query, client, joinsNotNullableMap, customResultMapper } = this;
if (!fields && !customResultMapper) {
return import_tracing.tracer.startActiveSpan("drizzle.driver.execute", () => {
return client.unsafe(query, params);
});
}
const rows = await import_tracing.tracer.startActiveSpan("drizzle.driver.execute", () => {
span?.setAttributes({
"drizzle.query.text": query,
"drizzle.query.params": JSON.stringify(params)
});
return client.unsafe(query, params).values();
});
return import_tracing.tracer.startActiveSpan("drizzle.mapResponse", () => {
return customResultMapper ? customResultMapper(rows) : rows.map((row) => (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap));
});
});
}
all(placeholderValues = {}) {
return import_tracing.tracer.startActiveSpan("drizzle.execute", async (span) => {
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
span?.setAttributes({
"drizzle.query.text": this.queryString,
"drizzle.query.params": JSON.stringify(params)
});
this.logger.logQuery(this.queryString, params);
return import_tracing.tracer.startActiveSpan("drizzle.driver.execute", () => {
span?.setAttributes({
"drizzle.query.text": this.queryString,
"drizzle.query.params": JSON.stringify(params)
});
return this.client.unsafe(this.queryString, params);
});
});
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
class PostgresJsSession 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] = "PostgresJsSession";
logger;
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
return new PostgresJsPreparedQuery(
this.client,
query.sql,
query.params,
this.logger,
fields,
isResponseInArrayMode,
customResultMapper
);
}
query(query, params) {
this.logger.logQuery(query, params);
return this.client.unsafe(query, params).values();
}
queryObjects(query, params) {
return this.client.unsafe(query, params);
}
transaction(transaction, config) {
return this.client.begin(async (client) => {
const session = new PostgresJsSession(
client,
this.dialect,
this.schema,
this.options
);
const tx = new PostgresJsTransaction(this.dialect, session, this.schema);
if (config) {
await tx.setTransaction(config);
}
return transaction(tx);
});
}
}
class PostgresJsTransaction extends import_pg_core.PgTransaction {
constructor(dialect, session, schema, nestedIndex = 0) {
super(dialect, session, schema, nestedIndex);
this.session = session;
}
static [import_entity.entityKind] = "PostgresJsTransaction";
transaction(transaction) {
return this.session.client.savepoint((client) => {
const session = new PostgresJsSession(
client,
this.dialect,
this.schema,
this.session.options
);
const tx = new PostgresJsTransaction(this.dialect, session, this.schema);
return transaction(tx);
});
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
PostgresJsPreparedQuery,
PostgresJsSession,
PostgresJsTransaction
});
//# sourceMappingURL=session.cjs.map

1
node_modules/drizzle-orm/postgres-js/session.cjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

50
node_modules/drizzle-orm/postgres-js/session.d.cts generated vendored Normal file
View File

@ -0,0 +1,50 @@
import type { Row, RowList, Sql, TransactionSql } from 'postgres';
import { entityKind } from "../entity.cjs";
import type { Logger } from "../logger.cjs";
import type { PgDialect } from "../pg-core/dialect.cjs";
import { 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 declare class PostgresJsPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
private client;
private queryString;
private params;
private logger;
private fields;
private _isResponseInArrayMode;
private customResultMapper?;
static readonly [entityKind]: string;
constructor(client: Sql, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | 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']>;
}
export interface PostgresJsSessionOptions {
logger?: Logger;
}
export declare class PostgresJsSession<TSQL extends Sql, TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<PostgresJsQueryResultHKT, TFullSchema, TSchema> {
client: TSQL;
private schema;
static readonly [entityKind]: string;
logger: Logger;
constructor(client: TSQL, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined,
/** @internal */
options?: PostgresJsSessionOptions);
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<RowList<Row[]>>;
queryObjects<T extends Row>(query: string, params: unknown[]): Promise<RowList<T[]>>;
transaction<T>(transaction: (tx: PostgresJsTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
}
export declare class PostgresJsTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<PostgresJsQueryResultHKT, TFullSchema, TSchema> {
static readonly [entityKind]: string;
constructor(dialect: PgDialect,
/** @internal */
session: PostgresJsSession<TransactionSql, TFullSchema, TSchema>, schema: RelationalSchemaConfig<TSchema> | undefined, nestedIndex?: number);
transaction<T>(transaction: (tx: PostgresJsTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
}
export interface PostgresJsQueryResultHKT extends PgQueryResultHKT {
type: RowList<Assume<this['row'], Row>[]>;
}

50
node_modules/drizzle-orm/postgres-js/session.d.ts generated vendored Normal file
View File

@ -0,0 +1,50 @@
import type { Row, RowList, Sql, TransactionSql } from 'postgres';
import { entityKind } from "../entity.js";
import type { Logger } from "../logger.js";
import type { PgDialect } from "../pg-core/dialect.js";
import { 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 declare class PostgresJsPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
private client;
private queryString;
private params;
private logger;
private fields;
private _isResponseInArrayMode;
private customResultMapper?;
static readonly [entityKind]: string;
constructor(client: Sql, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | 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']>;
}
export interface PostgresJsSessionOptions {
logger?: Logger;
}
export declare class PostgresJsSession<TSQL extends Sql, TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<PostgresJsQueryResultHKT, TFullSchema, TSchema> {
client: TSQL;
private schema;
static readonly [entityKind]: string;
logger: Logger;
constructor(client: TSQL, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined,
/** @internal */
options?: PostgresJsSessionOptions);
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<RowList<Row[]>>;
queryObjects<T extends Row>(query: string, params: unknown[]): Promise<RowList<T[]>>;
transaction<T>(transaction: (tx: PostgresJsTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
}
export declare class PostgresJsTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<PostgresJsQueryResultHKT, TFullSchema, TSchema> {
static readonly [entityKind]: string;
constructor(dialect: PgDialect,
/** @internal */
session: PostgresJsSession<TransactionSql, TFullSchema, TSchema>, schema: RelationalSchemaConfig<TSchema> | undefined, nestedIndex?: number);
transaction<T>(transaction: (tx: PostgresJsTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
}
export interface PostgresJsQueryResultHKT extends PgQueryResultHKT {
type: RowList<Assume<this['row'], Row>[]>;
}

136
node_modules/drizzle-orm/postgres-js/session.js generated vendored Normal file
View File

@ -0,0 +1,136 @@
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 } from "../sql/sql.js";
import { tracer } from "../tracing.js";
import { mapResultRow } from "../utils.js";
class PostgresJsPreparedQuery extends PgPreparedQuery {
constructor(client, queryString, params, logger, fields, _isResponseInArrayMode, customResultMapper) {
super({ sql: queryString, params });
this.client = client;
this.queryString = queryString;
this.params = params;
this.logger = logger;
this.fields = fields;
this._isResponseInArrayMode = _isResponseInArrayMode;
this.customResultMapper = customResultMapper;
}
static [entityKind] = "PostgresJsPreparedQuery";
async execute(placeholderValues = {}) {
return tracer.startActiveSpan("drizzle.execute", async (span) => {
const params = fillPlaceholders(this.params, placeholderValues);
span?.setAttributes({
"drizzle.query.text": this.queryString,
"drizzle.query.params": JSON.stringify(params)
});
this.logger.logQuery(this.queryString, params);
const { fields, queryString: query, client, joinsNotNullableMap, customResultMapper } = this;
if (!fields && !customResultMapper) {
return tracer.startActiveSpan("drizzle.driver.execute", () => {
return client.unsafe(query, params);
});
}
const rows = await tracer.startActiveSpan("drizzle.driver.execute", () => {
span?.setAttributes({
"drizzle.query.text": query,
"drizzle.query.params": JSON.stringify(params)
});
return client.unsafe(query, params).values();
});
return tracer.startActiveSpan("drizzle.mapResponse", () => {
return customResultMapper ? customResultMapper(rows) : rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
});
});
}
all(placeholderValues = {}) {
return tracer.startActiveSpan("drizzle.execute", async (span) => {
const params = fillPlaceholders(this.params, placeholderValues);
span?.setAttributes({
"drizzle.query.text": this.queryString,
"drizzle.query.params": JSON.stringify(params)
});
this.logger.logQuery(this.queryString, params);
return tracer.startActiveSpan("drizzle.driver.execute", () => {
span?.setAttributes({
"drizzle.query.text": this.queryString,
"drizzle.query.params": JSON.stringify(params)
});
return this.client.unsafe(this.queryString, params);
});
});
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
class PostgresJsSession 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] = "PostgresJsSession";
logger;
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
return new PostgresJsPreparedQuery(
this.client,
query.sql,
query.params,
this.logger,
fields,
isResponseInArrayMode,
customResultMapper
);
}
query(query, params) {
this.logger.logQuery(query, params);
return this.client.unsafe(query, params).values();
}
queryObjects(query, params) {
return this.client.unsafe(query, params);
}
transaction(transaction, config) {
return this.client.begin(async (client) => {
const session = new PostgresJsSession(
client,
this.dialect,
this.schema,
this.options
);
const tx = new PostgresJsTransaction(this.dialect, session, this.schema);
if (config) {
await tx.setTransaction(config);
}
return transaction(tx);
});
}
}
class PostgresJsTransaction extends PgTransaction {
constructor(dialect, session, schema, nestedIndex = 0) {
super(dialect, session, schema, nestedIndex);
this.session = session;
}
static [entityKind] = "PostgresJsTransaction";
transaction(transaction) {
return this.session.client.savepoint((client) => {
const session = new PostgresJsSession(
client,
this.dialect,
this.schema,
this.session.options
);
const tx = new PostgresJsTransaction(this.dialect, session, this.schema);
return transaction(tx);
});
}
}
export {
PostgresJsPreparedQuery,
PostgresJsSession,
PostgresJsTransaction
};
//# sourceMappingURL=session.js.map

1
node_modules/drizzle-orm/postgres-js/session.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long