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

107
node_modules/drizzle-orm/neon-serverless/driver.cjs generated vendored Normal file
View File

@ -0,0 +1,107 @@
"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, {
NeonDatabase: () => NeonDatabase,
NeonDriver: () => NeonDriver,
drizzle: () => drizzle
});
module.exports = __toCommonJS(driver_exports);
var import_serverless = require("@neondatabase/serverless");
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 NeonDriver {
constructor(client, dialect, options = {}) {
this.client = client;
this.dialect = dialect;
this.options = options;
}
static [import_entity.entityKind] = "NeonDriver";
createSession(schema) {
return new import_session.NeonSession(this.client, this.dialect, schema, { logger: this.options.logger });
}
}
class NeonDatabase extends import_db.PgDatabase {
static [import_entity.entityKind] = "NeonServerlessDatabase";
}
function construct(client, config = {}) {
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 driver = new NeonDriver(client, dialect, { logger });
const session = driver.createSession(schema);
const db = new NeonDatabase(dialect, session, schema);
db.$client = client;
return db;
}
function drizzle(...params) {
if (typeof params[0] === "string") {
const instance = new import_serverless.Pool({
connectionString: params[0]
});
return construct(instance, params[1]);
}
if ((0, import_utils.isConfig)(params[0])) {
const { connection, client, ws, ...drizzleConfig } = params[0];
if (ws) {
import_serverless.neonConfig.webSocketConstructor = ws;
}
if (client)
return construct(client, drizzleConfig);
const instance = typeof connection === "string" ? new import_serverless.Pool({
connectionString: connection
}) : new import_serverless.Pool(connection);
return construct(instance, drizzleConfig);
}
return construct(params[0], 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 = {
NeonDatabase,
NeonDriver,
drizzle
});
//# sourceMappingURL=driver.cjs.map

File diff suppressed because one or more lines are too long

44
node_modules/drizzle-orm/neon-serverless/driver.d.cts generated vendored Normal file
View File

@ -0,0 +1,44 @@
import { Pool, type PoolConfig } from '@neondatabase/serverless';
import { entityKind } from "../entity.cjs";
import type { Logger } from "../logger.cjs";
import { PgDatabase } from "../pg-core/db.cjs";
import { PgDialect } from "../pg-core/dialect.cjs";
import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.cjs";
import { type DrizzleConfig } from "../utils.cjs";
import type { NeonClient, NeonQueryResultHKT } from "./session.cjs";
import { NeonSession } from "./session.cjs";
export interface NeonDriverOptions {
logger?: Logger;
}
export declare class NeonDriver {
private client;
private dialect;
private options;
static readonly [entityKind]: string;
constructor(client: NeonClient, dialect: PgDialect, options?: NeonDriverOptions);
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): NeonSession<Record<string, unknown>, TablesRelationalConfig>;
}
export declare class NeonDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<NeonQueryResultHKT, TSchema> {
static readonly [entityKind]: string;
}
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends NeonClient = Pool>(...params: [
TClient | string
] | [
TClient | string,
DrizzleConfig<TSchema>
] | [
(DrizzleConfig<TSchema> & ({
connection: string | PoolConfig;
} | {
client: TClient;
}) & {
ws?: any;
})
]): NeonDatabase<TSchema> & {
$client: TClient;
};
export declare namespace drizzle {
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): NeonDatabase<TSchema> & {
$client: '$client is not available on drizzle.mock()';
};
}

44
node_modules/drizzle-orm/neon-serverless/driver.d.ts generated vendored Normal file
View File

@ -0,0 +1,44 @@
import { Pool, type PoolConfig } from '@neondatabase/serverless';
import { entityKind } from "../entity.js";
import type { Logger } from "../logger.js";
import { PgDatabase } from "../pg-core/db.js";
import { PgDialect } from "../pg-core/dialect.js";
import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.js";
import { type DrizzleConfig } from "../utils.js";
import type { NeonClient, NeonQueryResultHKT } from "./session.js";
import { NeonSession } from "./session.js";
export interface NeonDriverOptions {
logger?: Logger;
}
export declare class NeonDriver {
private client;
private dialect;
private options;
static readonly [entityKind]: string;
constructor(client: NeonClient, dialect: PgDialect, options?: NeonDriverOptions);
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): NeonSession<Record<string, unknown>, TablesRelationalConfig>;
}
export declare class NeonDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<NeonQueryResultHKT, TSchema> {
static readonly [entityKind]: string;
}
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends NeonClient = Pool>(...params: [
TClient | string
] | [
TClient | string,
DrizzleConfig<TSchema>
] | [
(DrizzleConfig<TSchema> & ({
connection: string | PoolConfig;
} | {
client: TClient;
}) & {
ws?: any;
})
]): NeonDatabase<TSchema> & {
$client: TClient;
};
export declare namespace drizzle {
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): NeonDatabase<TSchema> & {
$client: '$client is not available on drizzle.mock()';
};
}

84
node_modules/drizzle-orm/neon-serverless/driver.js generated vendored Normal file
View File

@ -0,0 +1,84 @@
import { neonConfig, Pool } from "@neondatabase/serverless";
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 { NeonSession } from "./session.js";
class NeonDriver {
constructor(client, dialect, options = {}) {
this.client = client;
this.dialect = dialect;
this.options = options;
}
static [entityKind] = "NeonDriver";
createSession(schema) {
return new NeonSession(this.client, this.dialect, schema, { logger: this.options.logger });
}
}
class NeonDatabase extends PgDatabase {
static [entityKind] = "NeonServerlessDatabase";
}
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 NeonDriver(client, dialect, { logger });
const session = driver.createSession(schema);
const db = new NeonDatabase(dialect, session, schema);
db.$client = client;
return db;
}
function drizzle(...params) {
if (typeof params[0] === "string") {
const instance = new Pool({
connectionString: params[0]
});
return construct(instance, params[1]);
}
if (isConfig(params[0])) {
const { connection, client, ws, ...drizzleConfig } = params[0];
if (ws) {
neonConfig.webSocketConstructor = ws;
}
if (client)
return construct(client, drizzleConfig);
const instance = typeof connection === "string" ? new Pool({
connectionString: connection
}) : new Pool(connection);
return construct(instance, drizzleConfig);
}
return construct(params[0], params[1]);
}
((drizzle2) => {
function mock(config) {
return construct({}, config);
}
drizzle2.mock = mock;
})(drizzle || (drizzle = {}));
export {
NeonDatabase,
NeonDriver,
drizzle
};
//# sourceMappingURL=driver.js.map

File diff suppressed because one or more lines are too long

25
node_modules/drizzle-orm/neon-serverless/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 neon_serverless_exports = {};
module.exports = __toCommonJS(neon_serverless_exports);
__reExport(neon_serverless_exports, require("./driver.cjs"), module.exports);
__reExport(neon_serverless_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

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/neon-serverless/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/neon-serverless/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/neon-serverless/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/neon-serverless/index.js generated vendored Normal file
View File

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

View File

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

33
node_modules/drizzle-orm/neon-serverless/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/neon-serverless/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { NeonDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: NeonDatabase<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":[]}

View File

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

View File

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

9
node_modules/drizzle-orm/neon-serverless/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

View File

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

196
node_modules/drizzle-orm/neon-serverless/session.cjs generated vendored Normal file
View File

@ -0,0 +1,196 @@
"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, {
NeonPreparedQuery: () => NeonPreparedQuery,
NeonSession: () => NeonSession,
NeonTransaction: () => NeonTransaction
});
module.exports = __toCommonJS(session_exports);
var import_serverless = require("@neondatabase/serverless");
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 NeonPreparedQuery 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.rawQueryConfig = {
name,
text: queryString,
types: {
// @ts-ignore
getTypeParser: (typeId, format) => {
if (typeId === import_serverless.types.builtins.TIMESTAMPTZ) {
return (val) => val;
}
if (typeId === import_serverless.types.builtins.TIMESTAMP) {
return (val) => val;
}
if (typeId === import_serverless.types.builtins.DATE) {
return (val) => val;
}
if (typeId === import_serverless.types.builtins.INTERVAL) {
return (val) => val;
}
return import_serverless.types.getTypeParser(typeId, format);
}
}
};
this.queryConfig = {
name,
text: queryString,
rowMode: "array",
types: {
// @ts-ignore
getTypeParser: (typeId, format) => {
if (typeId === import_serverless.types.builtins.TIMESTAMPTZ) {
return (val) => val;
}
if (typeId === import_serverless.types.builtins.TIMESTAMP) {
return (val) => val;
}
if (typeId === import_serverless.types.builtins.DATE) {
return (val) => val;
}
if (typeId === import_serverless.types.builtins.INTERVAL) {
return (val) => val;
}
return import_serverless.types.getTypeParser(typeId, format);
}
}
};
}
static [import_entity.entityKind] = "NeonPreparedQuery";
rawQueryConfig;
queryConfig;
async execute(placeholderValues = {}) {
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
this.logger.logQuery(this.rawQueryConfig.text, params);
const { fields, client, rawQueryConfig: rawQuery, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;
if (!fields && !customResultMapper) {
return client.query(rawQuery, params);
}
const result = await client.query(query, params);
return customResultMapper ? customResultMapper(result.rows) : result.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.rawQueryConfig.text, params);
return this.client.query(this.rawQueryConfig, params).then((result) => result.rows);
}
values(placeholderValues = {}) {
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
this.logger.logQuery(this.rawQueryConfig.text, params);
return this.client.query(this.queryConfig, params).then((result) => result.rows);
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
class NeonSession 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] = "NeonSession";
logger;
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
return new NeonPreparedQuery(
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 count(sql2) {
const res = await this.execute(sql2);
return Number(
res["rows"][0]["count"]
);
}
async transaction(transaction, config = {}) {
const session = this.client instanceof import_serverless.Pool ? new NeonSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
const tx = new NeonTransaction(this.dialect, session, this.schema);
await tx.execute(import_sql.sql`begin ${tx.getTransactionConfigSQL(config)}`);
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_serverless.Pool) {
session.client.release();
}
}
}
}
class NeonTransaction extends import_pg_core.PgTransaction {
static [import_entity.entityKind] = "NeonTransaction";
async transaction(transaction) {
const savepointName = `sp${this.nestedIndex + 1}`;
const tx = new NeonTransaction(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 (e) {
await tx.execute(import_sql.sql.raw(`rollback to savepoint ${savepointName}`));
throw e;
}
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
NeonPreparedQuery,
NeonSession,
NeonTransaction
});
//# sourceMappingURL=session.cjs.map

File diff suppressed because one or more lines are too long

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

@ -0,0 +1,50 @@
import { type Client, Pool, type PoolClient, type QueryResult, type QueryResultRow } from '@neondatabase/serverless';
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, type SQL } from "../sql/sql.cjs";
import { type Assume } from "../utils.cjs";
export type NeonClient = Pool | PoolClient | Client;
export declare class NeonPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
private client;
private params;
private logger;
private fields;
private _isResponseInArrayMode;
private customResultMapper?;
static readonly [entityKind]: string;
private rawQueryConfig;
private queryConfig;
constructor(client: NeonClient, 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 NeonSessionOptions {
logger?: Logger;
}
export declare class NeonSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<NeonQueryResultHKT, TFullSchema, TSchema> {
private client;
private schema;
private options;
static readonly [entityKind]: string;
private logger;
constructor(client: NeonClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: NeonSessionOptions);
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>>;
count(sql: SQL): Promise<number>;
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
}
export declare class NeonTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<NeonQueryResultHKT, TFullSchema, TSchema> {
static readonly [entityKind]: string;
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
}
export interface NeonQueryResultHKT extends PgQueryResultHKT {
type: QueryResult<Assume<this['row'], QueryResultRow>>;
}

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

@ -0,0 +1,50 @@
import { type Client, Pool, type PoolClient, type QueryResult, type QueryResultRow } from '@neondatabase/serverless';
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, type SQL } from "../sql/sql.js";
import { type Assume } from "../utils.js";
export type NeonClient = Pool | PoolClient | Client;
export declare class NeonPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
private client;
private params;
private logger;
private fields;
private _isResponseInArrayMode;
private customResultMapper?;
static readonly [entityKind]: string;
private rawQueryConfig;
private queryConfig;
constructor(client: NeonClient, 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 NeonSessionOptions {
logger?: Logger;
}
export declare class NeonSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<NeonQueryResultHKT, TFullSchema, TSchema> {
private client;
private schema;
private options;
static readonly [entityKind]: string;
private logger;
constructor(client: NeonClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: NeonSessionOptions);
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>>;
count(sql: SQL): Promise<number>;
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
}
export declare class NeonTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<NeonQueryResultHKT, TFullSchema, TSchema> {
static readonly [entityKind]: string;
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
}
export interface NeonQueryResultHKT extends PgQueryResultHKT {
type: QueryResult<Assume<this['row'], QueryResultRow>>;
}

173
node_modules/drizzle-orm/neon-serverless/session.js generated vendored Normal file
View File

@ -0,0 +1,173 @@
import {
Pool,
types
} from "@neondatabase/serverless";
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 NeonPreparedQuery 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.rawQueryConfig = {
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] = "NeonPreparedQuery";
rawQueryConfig;
queryConfig;
async execute(placeholderValues = {}) {
const params = fillPlaceholders(this.params, placeholderValues);
this.logger.logQuery(this.rawQueryConfig.text, params);
const { fields, client, rawQueryConfig: rawQuery, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;
if (!fields && !customResultMapper) {
return client.query(rawQuery, params);
}
const result = await client.query(query, params);
return customResultMapper ? customResultMapper(result.rows) : result.rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
}
all(placeholderValues = {}) {
const params = fillPlaceholders(this.params, placeholderValues);
this.logger.logQuery(this.rawQueryConfig.text, params);
return this.client.query(this.rawQueryConfig, params).then((result) => result.rows);
}
values(placeholderValues = {}) {
const params = fillPlaceholders(this.params, placeholderValues);
this.logger.logQuery(this.rawQueryConfig.text, params);
return this.client.query(this.queryConfig, params).then((result) => result.rows);
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
class NeonSession 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] = "NeonSession";
logger;
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
return new NeonPreparedQuery(
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 count(sql2) {
const res = await this.execute(sql2);
return Number(
res["rows"][0]["count"]
);
}
async transaction(transaction, config = {}) {
const session = this.client instanceof Pool ? new NeonSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
const tx = new NeonTransaction(this.dialect, session, this.schema);
await tx.execute(sql`begin ${tx.getTransactionConfigSQL(config)}`);
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 Pool) {
session.client.release();
}
}
}
}
class NeonTransaction extends PgTransaction {
static [entityKind] = "NeonTransaction";
async transaction(transaction) {
const savepointName = `sp${this.nestedIndex + 1}`;
const tx = new NeonTransaction(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 (e) {
await tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));
throw e;
}
}
}
export {
NeonPreparedQuery,
NeonSession,
NeonTransaction
};
//# sourceMappingURL=session.js.map

File diff suppressed because one or more lines are too long