Initial commit
This commit is contained in:
150
node_modules/drizzle-orm/neon-http/driver.cjs
generated
vendored
Normal file
150
node_modules/drizzle-orm/neon-http/driver.cjs
generated
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
"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, {
|
||||
NeonHttpDatabase: () => NeonHttpDatabase,
|
||||
NeonHttpDriver: () => NeonHttpDriver,
|
||||
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 NeonHttpDriver {
|
||||
constructor(client, dialect, options = {}) {
|
||||
this.client = client;
|
||||
this.dialect = dialect;
|
||||
this.options = options;
|
||||
this.initMappers();
|
||||
}
|
||||
static [import_entity.entityKind] = "NeonHttpDriver";
|
||||
createSession(schema) {
|
||||
return new import_session.NeonHttpSession(this.client, this.dialect, schema, { logger: this.options.logger });
|
||||
}
|
||||
initMappers() {
|
||||
import_serverless.types.setTypeParser(import_serverless.types.builtins.TIMESTAMPTZ, (val) => val);
|
||||
import_serverless.types.setTypeParser(import_serverless.types.builtins.TIMESTAMP, (val) => val);
|
||||
import_serverless.types.setTypeParser(import_serverless.types.builtins.DATE, (val) => val);
|
||||
import_serverless.types.setTypeParser(import_serverless.types.builtins.INTERVAL, (val) => val);
|
||||
}
|
||||
}
|
||||
function wrap(target, token, cb, deep) {
|
||||
return new Proxy(target, {
|
||||
get(target2, p) {
|
||||
const element = target2[p];
|
||||
if (typeof element !== "function" && (typeof element !== "object" || element === null))
|
||||
return element;
|
||||
if (deep)
|
||||
return wrap(element, token, cb);
|
||||
if (p === "query")
|
||||
return wrap(element, token, cb, true);
|
||||
return new Proxy(element, {
|
||||
apply(target3, thisArg, argArray) {
|
||||
const res = target3.call(thisArg, ...argArray);
|
||||
if (typeof res === "object" && res !== null && "setToken" in res && typeof res.setToken === "function") {
|
||||
res.setToken(token);
|
||||
}
|
||||
return cb(target3, p, res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
class NeonHttpDatabase extends import_db.PgDatabase {
|
||||
static [import_entity.entityKind] = "NeonHttpDatabase";
|
||||
$withAuth(token) {
|
||||
this.authToken = token;
|
||||
return wrap(this, token, (target, p, res) => {
|
||||
if (p === "with") {
|
||||
return wrap(res, token, (_, __, res2) => res2);
|
||||
}
|
||||
return res;
|
||||
});
|
||||
}
|
||||
async batch(batch) {
|
||||
return this.session.batch(batch);
|
||||
}
|
||||
}
|
||||
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 NeonHttpDriver(client, dialect, { logger });
|
||||
const session = driver.createSession(schema);
|
||||
const db = new NeonHttpDatabase(
|
||||
dialect,
|
||||
session,
|
||||
schema
|
||||
);
|
||||
db.$client = client;
|
||||
return db;
|
||||
}
|
||||
function drizzle(...params) {
|
||||
if (typeof params[0] === "string") {
|
||||
const instance = (0, import_serverless.neon)(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") {
|
||||
const { connectionString, ...options } = connection;
|
||||
const instance2 = (0, import_serverless.neon)(connectionString, options);
|
||||
return construct(instance2, drizzleConfig);
|
||||
}
|
||||
const instance = (0, import_serverless.neon)(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 = {
|
||||
NeonHttpDatabase,
|
||||
NeonHttpDriver,
|
||||
drizzle
|
||||
});
|
||||
//# sourceMappingURL=driver.cjs.map
|
||||
1
node_modules/drizzle-orm/neon-http/driver.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/neon-http/driver.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
47
node_modules/drizzle-orm/neon-http/driver.d.cts
generated
vendored
Normal file
47
node_modules/drizzle-orm/neon-http/driver.d.cts
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
import type { HTTPQueryOptions, HTTPTransactionOptions, NeonQueryFunction } from '@neondatabase/serverless';
|
||||
import type { BatchItem, BatchResponse } from "../batch.cjs";
|
||||
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, TablesRelationalConfig } from "../relations.cjs";
|
||||
import { type DrizzleConfig } from "../utils.cjs";
|
||||
import { type NeonHttpClient, type NeonHttpQueryResultHKT, NeonHttpSession } from "./session.cjs";
|
||||
export interface NeonDriverOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
export declare class NeonHttpDriver {
|
||||
private client;
|
||||
private dialect;
|
||||
private options;
|
||||
static readonly [entityKind]: string;
|
||||
constructor(client: NeonHttpClient, dialect: PgDialect, options?: NeonDriverOptions);
|
||||
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): NeonHttpSession<Record<string, unknown>, TablesRelationalConfig>;
|
||||
initMappers(): void;
|
||||
}
|
||||
export declare class NeonHttpDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<NeonHttpQueryResultHKT, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
$withAuth(token: Exclude<HTTPQueryOptions<true, true>['authToken'], undefined>): Omit<this, Exclude<keyof this, '$count' | 'delete' | 'select' | 'selectDistinct' | 'selectDistinctOn' | 'update' | 'insert' | 'with' | 'query' | 'execute' | 'refreshMaterializedView'>>;
|
||||
batch<U extends BatchItem<'pg'>, T extends Readonly<[U, ...U[]]>>(batch: T): Promise<BatchResponse<T>>;
|
||||
}
|
||||
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends NeonQueryFunction<any, any> = NeonQueryFunction<false, false>>(...params: [
|
||||
TClient | string
|
||||
] | [
|
||||
TClient | string,
|
||||
DrizzleConfig<TSchema>
|
||||
] | [
|
||||
(DrizzleConfig<TSchema> & ({
|
||||
connection: string | ({
|
||||
connectionString: string;
|
||||
} & HTTPTransactionOptions<boolean, boolean>);
|
||||
} | {
|
||||
client: TClient;
|
||||
}))
|
||||
]): NeonHttpDatabase<TSchema> & {
|
||||
$client: TClient;
|
||||
};
|
||||
export declare namespace drizzle {
|
||||
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): NeonHttpDatabase<TSchema> & {
|
||||
$client: '$client is not available on drizzle.mock()';
|
||||
};
|
||||
}
|
||||
47
node_modules/drizzle-orm/neon-http/driver.d.ts
generated
vendored
Normal file
47
node_modules/drizzle-orm/neon-http/driver.d.ts
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
import type { HTTPQueryOptions, HTTPTransactionOptions, NeonQueryFunction } from '@neondatabase/serverless';
|
||||
import type { BatchItem, BatchResponse } from "../batch.js";
|
||||
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, TablesRelationalConfig } from "../relations.js";
|
||||
import { type DrizzleConfig } from "../utils.js";
|
||||
import { type NeonHttpClient, type NeonHttpQueryResultHKT, NeonHttpSession } from "./session.js";
|
||||
export interface NeonDriverOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
export declare class NeonHttpDriver {
|
||||
private client;
|
||||
private dialect;
|
||||
private options;
|
||||
static readonly [entityKind]: string;
|
||||
constructor(client: NeonHttpClient, dialect: PgDialect, options?: NeonDriverOptions);
|
||||
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): NeonHttpSession<Record<string, unknown>, TablesRelationalConfig>;
|
||||
initMappers(): void;
|
||||
}
|
||||
export declare class NeonHttpDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<NeonHttpQueryResultHKT, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
$withAuth(token: Exclude<HTTPQueryOptions<true, true>['authToken'], undefined>): Omit<this, Exclude<keyof this, '$count' | 'delete' | 'select' | 'selectDistinct' | 'selectDistinctOn' | 'update' | 'insert' | 'with' | 'query' | 'execute' | 'refreshMaterializedView'>>;
|
||||
batch<U extends BatchItem<'pg'>, T extends Readonly<[U, ...U[]]>>(batch: T): Promise<BatchResponse<T>>;
|
||||
}
|
||||
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends NeonQueryFunction<any, any> = NeonQueryFunction<false, false>>(...params: [
|
||||
TClient | string
|
||||
] | [
|
||||
TClient | string,
|
||||
DrizzleConfig<TSchema>
|
||||
] | [
|
||||
(DrizzleConfig<TSchema> & ({
|
||||
connection: string | ({
|
||||
connectionString: string;
|
||||
} & HTTPTransactionOptions<boolean, boolean>);
|
||||
} | {
|
||||
client: TClient;
|
||||
}))
|
||||
]): NeonHttpDatabase<TSchema> & {
|
||||
$client: TClient;
|
||||
};
|
||||
export declare namespace drizzle {
|
||||
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): NeonHttpDatabase<TSchema> & {
|
||||
$client: '$client is not available on drizzle.mock()';
|
||||
};
|
||||
}
|
||||
124
node_modules/drizzle-orm/neon-http/driver.js
generated
vendored
Normal file
124
node_modules/drizzle-orm/neon-http/driver.js
generated
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
import { neon, types } 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 { NeonHttpSession } from "./session.js";
|
||||
class NeonHttpDriver {
|
||||
constructor(client, dialect, options = {}) {
|
||||
this.client = client;
|
||||
this.dialect = dialect;
|
||||
this.options = options;
|
||||
this.initMappers();
|
||||
}
|
||||
static [entityKind] = "NeonHttpDriver";
|
||||
createSession(schema) {
|
||||
return new NeonHttpSession(this.client, this.dialect, schema, { logger: this.options.logger });
|
||||
}
|
||||
initMappers() {
|
||||
types.setTypeParser(types.builtins.TIMESTAMPTZ, (val) => val);
|
||||
types.setTypeParser(types.builtins.TIMESTAMP, (val) => val);
|
||||
types.setTypeParser(types.builtins.DATE, (val) => val);
|
||||
types.setTypeParser(types.builtins.INTERVAL, (val) => val);
|
||||
}
|
||||
}
|
||||
function wrap(target, token, cb, deep) {
|
||||
return new Proxy(target, {
|
||||
get(target2, p) {
|
||||
const element = target2[p];
|
||||
if (typeof element !== "function" && (typeof element !== "object" || element === null))
|
||||
return element;
|
||||
if (deep)
|
||||
return wrap(element, token, cb);
|
||||
if (p === "query")
|
||||
return wrap(element, token, cb, true);
|
||||
return new Proxy(element, {
|
||||
apply(target3, thisArg, argArray) {
|
||||
const res = target3.call(thisArg, ...argArray);
|
||||
if (typeof res === "object" && res !== null && "setToken" in res && typeof res.setToken === "function") {
|
||||
res.setToken(token);
|
||||
}
|
||||
return cb(target3, p, res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
class NeonHttpDatabase extends PgDatabase {
|
||||
static [entityKind] = "NeonHttpDatabase";
|
||||
$withAuth(token) {
|
||||
this.authToken = token;
|
||||
return wrap(this, token, (target, p, res) => {
|
||||
if (p === "with") {
|
||||
return wrap(res, token, (_, __, res2) => res2);
|
||||
}
|
||||
return res;
|
||||
});
|
||||
}
|
||||
async batch(batch) {
|
||||
return this.session.batch(batch);
|
||||
}
|
||||
}
|
||||
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 NeonHttpDriver(client, dialect, { logger });
|
||||
const session = driver.createSession(schema);
|
||||
const db = new NeonHttpDatabase(
|
||||
dialect,
|
||||
session,
|
||||
schema
|
||||
);
|
||||
db.$client = client;
|
||||
return db;
|
||||
}
|
||||
function drizzle(...params) {
|
||||
if (typeof params[0] === "string") {
|
||||
const instance = neon(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") {
|
||||
const { connectionString, ...options } = connection;
|
||||
const instance2 = neon(connectionString, options);
|
||||
return construct(instance2, drizzleConfig);
|
||||
}
|
||||
const instance = neon(connection);
|
||||
return construct(instance, drizzleConfig);
|
||||
}
|
||||
return construct(params[0], params[1]);
|
||||
}
|
||||
((drizzle2) => {
|
||||
function mock(config) {
|
||||
return construct({}, config);
|
||||
}
|
||||
drizzle2.mock = mock;
|
||||
})(drizzle || (drizzle = {}));
|
||||
export {
|
||||
NeonHttpDatabase,
|
||||
NeonHttpDriver,
|
||||
drizzle
|
||||
};
|
||||
//# sourceMappingURL=driver.js.map
|
||||
1
node_modules/drizzle-orm/neon-http/driver.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/neon-http/driver.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
25
node_modules/drizzle-orm/neon-http/index.cjs
generated
vendored
Normal file
25
node_modules/drizzle-orm/neon-http/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 neon_http_exports = {};
|
||||
module.exports = __toCommonJS(neon_http_exports);
|
||||
__reExport(neon_http_exports, require("./driver.cjs"), module.exports);
|
||||
__reExport(neon_http_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/neon-http/index.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/neon-http/index.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/neon-http/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,8BAAc,wBAAd;AACA,8BAAc,yBADd;","names":[]}
|
||||
2
node_modules/drizzle-orm/neon-http/index.d.cts
generated
vendored
Normal file
2
node_modules/drizzle-orm/neon-http/index.d.cts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./driver.cjs";
|
||||
export * from "./session.cjs";
|
||||
2
node_modules/drizzle-orm/neon-http/index.d.ts
generated
vendored
Normal file
2
node_modules/drizzle-orm/neon-http/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./driver.js";
|
||||
export * from "./session.js";
|
||||
3
node_modules/drizzle-orm/neon-http/index.js
generated
vendored
Normal file
3
node_modules/drizzle-orm/neon-http/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/neon-http/index.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/neon-http/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/neon-http/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
||||
62
node_modules/drizzle-orm/neon-http/migrator.cjs
generated
vendored
Normal file
62
node_modules/drizzle-orm/neon-http/migrator.cjs
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
"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");
|
||||
var import_sql = require("../sql/sql.cjs");
|
||||
async function migrate(db, config) {
|
||||
const migrations = (0, import_migrator.readMigrationFiles)(config);
|
||||
const migrationsTable = config.migrationsTable ?? "__drizzle_migrations";
|
||||
const migrationsSchema = config.migrationsSchema ?? "drizzle";
|
||||
const migrationTableCreate = import_sql.sql`
|
||||
CREATE TABLE IF NOT EXISTS ${import_sql.sql.identifier(migrationsSchema)}.${import_sql.sql.identifier(migrationsTable)} (
|
||||
id SERIAL PRIMARY KEY,
|
||||
hash text NOT NULL,
|
||||
created_at bigint
|
||||
)
|
||||
`;
|
||||
await db.session.execute(import_sql.sql`CREATE SCHEMA IF NOT EXISTS ${import_sql.sql.identifier(migrationsSchema)}`);
|
||||
await db.session.execute(migrationTableCreate);
|
||||
const dbMigrations = await db.session.all(
|
||||
import_sql.sql`select id, hash, created_at from ${import_sql.sql.identifier(migrationsSchema)}.${import_sql.sql.identifier(migrationsTable)} order by created_at desc limit 1`
|
||||
);
|
||||
const lastDbMigration = dbMigrations[0];
|
||||
const rowsToInsert = [];
|
||||
for await (const migration of migrations) {
|
||||
if (!lastDbMigration || Number(lastDbMigration.created_at) < migration.folderMillis) {
|
||||
for (const stmt of migration.sql) {
|
||||
await db.session.execute(import_sql.sql.raw(stmt));
|
||||
}
|
||||
rowsToInsert.push(
|
||||
import_sql.sql`insert into ${import_sql.sql.identifier(migrationsSchema)}.${import_sql.sql.identifier(migrationsTable)} ("hash", "created_at") values(${migration.hash}, ${migration.folderMillis})`
|
||||
);
|
||||
}
|
||||
}
|
||||
for await (const rowToInsert of rowsToInsert) {
|
||||
await db.session.execute(rowToInsert);
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
migrate
|
||||
});
|
||||
//# sourceMappingURL=migrator.cjs.map
|
||||
1
node_modules/drizzle-orm/neon-http/migrator.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/neon-http/migrator.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/neon-http/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\nimport type { NeonHttpDatabase } from './driver.ts';\n\n/**\n * This function reads migrationFolder and execute each unapplied migration and mark it as executed in database\n *\n * NOTE: The Neon HTTP driver does not support transactions. This means that if any part of a migration fails,\n * no rollback will be executed. Currently, you will need to handle unsuccessful migration yourself.\n * @param db - drizzle db instance\n * @param config - path to migration folder generated by drizzle-kit\n */\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: NeonHttpDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tconst migrationsTable = config.migrationsTable ?? '__drizzle_migrations';\n\tconst migrationsSchema = config.migrationsSchema ?? 'drizzle';\n\tconst migrationTableCreate = sql`\n\t\tCREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)} (\n\t\t\tid SERIAL PRIMARY KEY,\n\t\t\thash text NOT NULL,\n\t\t\tcreated_at bigint\n\t\t)\n\t`;\n\tawait db.session.execute(sql`CREATE SCHEMA IF NOT EXISTS ${sql.identifier(migrationsSchema)}`);\n\tawait db.session.execute(migrationTableCreate);\n\n\tconst dbMigrations = await db.session.all<{ id: number; hash: string; created_at: string }>(\n\t\tsql`select id, hash, created_at from ${sql.identifier(migrationsSchema)}.${\n\t\t\tsql.identifier(migrationsTable)\n\t\t} order by created_at desc limit 1`,\n\t);\n\n\tconst lastDbMigration = dbMigrations[0];\n\tconst rowsToInsert: SQL[] = [];\n\tfor await (const migration of migrations) {\n\t\tif (\n\t\t\t!lastDbMigration\n\t\t\t|| Number(lastDbMigration.created_at) < migration.folderMillis\n\t\t) {\n\t\t\tfor (const stmt of migration.sql) {\n\t\t\t\tawait db.session.execute(sql.raw(stmt));\n\t\t\t}\n\n\t\t\trowsToInsert.push(\n\t\t\t\tsql`insert into ${sql.identifier(migrationsSchema)}.${\n\t\t\t\t\tsql.identifier(migrationsTable)\n\t\t\t\t} (\"hash\", \"created_at\") values(${migration.hash}, ${migration.folderMillis})`,\n\t\t\t);\n\t\t}\n\t}\n\n\tfor await (const rowToInsert of rowsToInsert) {\n\t\tawait db.session.execute(rowToInsert);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAmC;AACnC,iBAA8B;AAW9B,eAAsB,QACrB,IACA,QACC;AACD,QAAM,iBAAa,oCAAmB,MAAM;AAC5C,QAAM,kBAAkB,OAAO,mBAAmB;AAClD,QAAM,mBAAmB,OAAO,oBAAoB;AACpD,QAAM,uBAAuB;AAAA,+BACC,eAAI,WAAW,gBAAgB,CAAC,IAAI,eAAI,WAAW,eAAe,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAMjG,QAAM,GAAG,QAAQ,QAAQ,6CAAkC,eAAI,WAAW,gBAAgB,CAAC,EAAE;AAC7F,QAAM,GAAG,QAAQ,QAAQ,oBAAoB;AAE7C,QAAM,eAAe,MAAM,GAAG,QAAQ;AAAA,IACrC,kDAAuC,eAAI,WAAW,gBAAgB,CAAC,IACtE,eAAI,WAAW,eAAe,CAC/B;AAAA,EACD;AAEA,QAAM,kBAAkB,aAAa,CAAC;AACtC,QAAM,eAAsB,CAAC;AAC7B,mBAAiB,aAAa,YAAY;AACzC,QACC,CAAC,mBACE,OAAO,gBAAgB,UAAU,IAAI,UAAU,cACjD;AACD,iBAAW,QAAQ,UAAU,KAAK;AACjC,cAAM,GAAG,QAAQ,QAAQ,eAAI,IAAI,IAAI,CAAC;AAAA,MACvC;AAEA,mBAAa;AAAA,QACZ,6BAAkB,eAAI,WAAW,gBAAgB,CAAC,IACjD,eAAI,WAAW,eAAe,CAC/B,kCAAkC,UAAU,IAAI,KAAK,UAAU,YAAY;AAAA,MAC5E;AAAA,IACD;AAAA,EACD;AAEA,mBAAiB,eAAe,cAAc;AAC7C,UAAM,GAAG,QAAQ,QAAQ,WAAW;AAAA,EACrC;AACD;","names":[]}
|
||||
11
node_modules/drizzle-orm/neon-http/migrator.d.cts
generated
vendored
Normal file
11
node_modules/drizzle-orm/neon-http/migrator.d.cts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import type { MigrationConfig } from "../migrator.cjs";
|
||||
import type { NeonHttpDatabase } from "./driver.cjs";
|
||||
/**
|
||||
* This function reads migrationFolder and execute each unapplied migration and mark it as executed in database
|
||||
*
|
||||
* NOTE: The Neon HTTP driver does not support transactions. This means that if any part of a migration fails,
|
||||
* no rollback will be executed. Currently, you will need to handle unsuccessful migration yourself.
|
||||
* @param db - drizzle db instance
|
||||
* @param config - path to migration folder generated by drizzle-kit
|
||||
*/
|
||||
export declare function migrate<TSchema extends Record<string, unknown>>(db: NeonHttpDatabase<TSchema>, config: MigrationConfig): Promise<void>;
|
||||
11
node_modules/drizzle-orm/neon-http/migrator.d.ts
generated
vendored
Normal file
11
node_modules/drizzle-orm/neon-http/migrator.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import type { MigrationConfig } from "../migrator.js";
|
||||
import type { NeonHttpDatabase } from "./driver.js";
|
||||
/**
|
||||
* This function reads migrationFolder and execute each unapplied migration and mark it as executed in database
|
||||
*
|
||||
* NOTE: The Neon HTTP driver does not support transactions. This means that if any part of a migration fails,
|
||||
* no rollback will be executed. Currently, you will need to handle unsuccessful migration yourself.
|
||||
* @param db - drizzle db instance
|
||||
* @param config - path to migration folder generated by drizzle-kit
|
||||
*/
|
||||
export declare function migrate<TSchema extends Record<string, unknown>>(db: NeonHttpDatabase<TSchema>, config: MigrationConfig): Promise<void>;
|
||||
38
node_modules/drizzle-orm/neon-http/migrator.js
generated
vendored
Normal file
38
node_modules/drizzle-orm/neon-http/migrator.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
import { readMigrationFiles } from "../migrator.js";
|
||||
import { sql } from "../sql/sql.js";
|
||||
async function migrate(db, config) {
|
||||
const migrations = readMigrationFiles(config);
|
||||
const migrationsTable = config.migrationsTable ?? "__drizzle_migrations";
|
||||
const migrationsSchema = config.migrationsSchema ?? "drizzle";
|
||||
const migrationTableCreate = sql`
|
||||
CREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)} (
|
||||
id SERIAL PRIMARY KEY,
|
||||
hash text NOT NULL,
|
||||
created_at bigint
|
||||
)
|
||||
`;
|
||||
await db.session.execute(sql`CREATE SCHEMA IF NOT EXISTS ${sql.identifier(migrationsSchema)}`);
|
||||
await db.session.execute(migrationTableCreate);
|
||||
const dbMigrations = await db.session.all(
|
||||
sql`select id, hash, created_at from ${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)} order by created_at desc limit 1`
|
||||
);
|
||||
const lastDbMigration = dbMigrations[0];
|
||||
const rowsToInsert = [];
|
||||
for await (const migration of migrations) {
|
||||
if (!lastDbMigration || Number(lastDbMigration.created_at) < migration.folderMillis) {
|
||||
for (const stmt of migration.sql) {
|
||||
await db.session.execute(sql.raw(stmt));
|
||||
}
|
||||
rowsToInsert.push(
|
||||
sql`insert into ${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)} ("hash", "created_at") values(${migration.hash}, ${migration.folderMillis})`
|
||||
);
|
||||
}
|
||||
}
|
||||
for await (const rowToInsert of rowsToInsert) {
|
||||
await db.session.execute(rowToInsert);
|
||||
}
|
||||
}
|
||||
export {
|
||||
migrate
|
||||
};
|
||||
//# sourceMappingURL=migrator.js.map
|
||||
1
node_modules/drizzle-orm/neon-http/migrator.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/neon-http/migrator.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/neon-http/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\nimport type { NeonHttpDatabase } from './driver.ts';\n\n/**\n * This function reads migrationFolder and execute each unapplied migration and mark it as executed in database\n *\n * NOTE: The Neon HTTP driver does not support transactions. This means that if any part of a migration fails,\n * no rollback will be executed. Currently, you will need to handle unsuccessful migration yourself.\n * @param db - drizzle db instance\n * @param config - path to migration folder generated by drizzle-kit\n */\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: NeonHttpDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tconst migrationsTable = config.migrationsTable ?? '__drizzle_migrations';\n\tconst migrationsSchema = config.migrationsSchema ?? 'drizzle';\n\tconst migrationTableCreate = sql`\n\t\tCREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)} (\n\t\t\tid SERIAL PRIMARY KEY,\n\t\t\thash text NOT NULL,\n\t\t\tcreated_at bigint\n\t\t)\n\t`;\n\tawait db.session.execute(sql`CREATE SCHEMA IF NOT EXISTS ${sql.identifier(migrationsSchema)}`);\n\tawait db.session.execute(migrationTableCreate);\n\n\tconst dbMigrations = await db.session.all<{ id: number; hash: string; created_at: string }>(\n\t\tsql`select id, hash, created_at from ${sql.identifier(migrationsSchema)}.${\n\t\t\tsql.identifier(migrationsTable)\n\t\t} order by created_at desc limit 1`,\n\t);\n\n\tconst lastDbMigration = dbMigrations[0];\n\tconst rowsToInsert: SQL[] = [];\n\tfor await (const migration of migrations) {\n\t\tif (\n\t\t\t!lastDbMigration\n\t\t\t|| Number(lastDbMigration.created_at) < migration.folderMillis\n\t\t) {\n\t\t\tfor (const stmt of migration.sql) {\n\t\t\t\tawait db.session.execute(sql.raw(stmt));\n\t\t\t}\n\n\t\t\trowsToInsert.push(\n\t\t\t\tsql`insert into ${sql.identifier(migrationsSchema)}.${\n\t\t\t\t\tsql.identifier(migrationsTable)\n\t\t\t\t} (\"hash\", \"created_at\") values(${migration.hash}, ${migration.folderMillis})`,\n\t\t\t);\n\t\t}\n\t}\n\n\tfor await (const rowToInsert of rowsToInsert) {\n\t\tawait db.session.execute(rowToInsert);\n\t}\n}\n"],"mappings":"AACA,SAAS,0BAA0B;AACnC,SAAmB,WAAW;AAW9B,eAAsB,QACrB,IACA,QACC;AACD,QAAM,aAAa,mBAAmB,MAAM;AAC5C,QAAM,kBAAkB,OAAO,mBAAmB;AAClD,QAAM,mBAAmB,OAAO,oBAAoB;AACpD,QAAM,uBAAuB;AAAA,+BACC,IAAI,WAAW,gBAAgB,CAAC,IAAI,IAAI,WAAW,eAAe,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAMjG,QAAM,GAAG,QAAQ,QAAQ,kCAAkC,IAAI,WAAW,gBAAgB,CAAC,EAAE;AAC7F,QAAM,GAAG,QAAQ,QAAQ,oBAAoB;AAE7C,QAAM,eAAe,MAAM,GAAG,QAAQ;AAAA,IACrC,uCAAuC,IAAI,WAAW,gBAAgB,CAAC,IACtE,IAAI,WAAW,eAAe,CAC/B;AAAA,EACD;AAEA,QAAM,kBAAkB,aAAa,CAAC;AACtC,QAAM,eAAsB,CAAC;AAC7B,mBAAiB,aAAa,YAAY;AACzC,QACC,CAAC,mBACE,OAAO,gBAAgB,UAAU,IAAI,UAAU,cACjD;AACD,iBAAW,QAAQ,UAAU,KAAK;AACjC,cAAM,GAAG,QAAQ,QAAQ,IAAI,IAAI,IAAI,CAAC;AAAA,MACvC;AAEA,mBAAa;AAAA,QACZ,kBAAkB,IAAI,WAAW,gBAAgB,CAAC,IACjD,IAAI,WAAW,eAAe,CAC/B,kCAAkC,UAAU,IAAI,KAAK,UAAU,YAAY;AAAA,MAC5E;AAAA,IACD;AAAA,EACD;AAEA,mBAAiB,eAAe,cAAc;AAC7C,UAAM,GAAG,QAAQ,QAAQ,WAAW;AAAA,EACrC;AACD;","names":[]}
|
||||
178
node_modules/drizzle-orm/neon-http/session.cjs
generated
vendored
Normal file
178
node_modules/drizzle-orm/neon-http/session.cjs
generated
vendored
Normal file
@ -0,0 +1,178 @@
|
||||
"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, {
|
||||
NeonHttpPreparedQuery: () => NeonHttpPreparedQuery,
|
||||
NeonHttpSession: () => NeonHttpSession,
|
||||
NeonTransaction: () => NeonTransaction
|
||||
});
|
||||
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_utils = require("../utils.cjs");
|
||||
const rawQueryConfig = {
|
||||
arrayMode: false,
|
||||
fullResults: true
|
||||
};
|
||||
const queryConfig = {
|
||||
arrayMode: true,
|
||||
fullResults: true
|
||||
};
|
||||
class NeonHttpPreparedQuery extends import_session.PgPreparedQuery {
|
||||
constructor(client, query, logger, fields, _isResponseInArrayMode, customResultMapper) {
|
||||
super(query);
|
||||
this.client = client;
|
||||
this.logger = logger;
|
||||
this.fields = fields;
|
||||
this._isResponseInArrayMode = _isResponseInArrayMode;
|
||||
this.customResultMapper = customResultMapper;
|
||||
}
|
||||
static [import_entity.entityKind] = "NeonHttpPreparedQuery";
|
||||
/** @internal */
|
||||
async execute(placeholderValues = {}, token = this.authToken) {
|
||||
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues);
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
const { fields, client, query, customResultMapper } = this;
|
||||
if (!fields && !customResultMapper) {
|
||||
return client(
|
||||
query.sql,
|
||||
params,
|
||||
token === void 0 ? rawQueryConfig : {
|
||||
...rawQueryConfig,
|
||||
authToken: token
|
||||
}
|
||||
);
|
||||
}
|
||||
const result = await client(
|
||||
query.sql,
|
||||
params,
|
||||
token === void 0 ? queryConfig : {
|
||||
...queryConfig,
|
||||
authToken: token
|
||||
}
|
||||
);
|
||||
return this.mapResult(result);
|
||||
}
|
||||
mapResult(result) {
|
||||
if (!this.fields && !this.customResultMapper) {
|
||||
return result;
|
||||
}
|
||||
const rows = result.rows;
|
||||
if (this.customResultMapper) {
|
||||
return this.customResultMapper(rows);
|
||||
}
|
||||
return rows.map((row) => (0, import_utils.mapResultRow)(this.fields, row, this.joinsNotNullableMap));
|
||||
}
|
||||
all(placeholderValues = {}) {
|
||||
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues);
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
return this.client(
|
||||
this.query.sql,
|
||||
params,
|
||||
this.authToken === void 0 ? rawQueryConfig : {
|
||||
...rawQueryConfig,
|
||||
authToken: this.authToken
|
||||
}
|
||||
).then((result) => result.rows);
|
||||
}
|
||||
/** @internal */
|
||||
values(placeholderValues = {}, token) {
|
||||
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues);
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
return this.client(this.query.sql, params, { arrayMode: true, fullResults: true, authToken: token }).then((result) => result.rows);
|
||||
}
|
||||
/** @internal */
|
||||
isResponseInArrayMode() {
|
||||
return this._isResponseInArrayMode;
|
||||
}
|
||||
}
|
||||
class NeonHttpSession 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] = "NeonHttpSession";
|
||||
logger;
|
||||
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
|
||||
return new NeonHttpPreparedQuery(
|
||||
this.client,
|
||||
query,
|
||||
this.logger,
|
||||
fields,
|
||||
isResponseInArrayMode,
|
||||
customResultMapper
|
||||
);
|
||||
}
|
||||
async batch(queries) {
|
||||
const preparedQueries = [];
|
||||
const builtQueries = [];
|
||||
for (const query of queries) {
|
||||
const preparedQuery = query._prepare();
|
||||
const builtQuery = preparedQuery.getQuery();
|
||||
preparedQueries.push(preparedQuery);
|
||||
builtQueries.push(
|
||||
this.client(builtQuery.sql, builtQuery.params, {
|
||||
fullResults: true,
|
||||
arrayMode: preparedQuery.isResponseInArrayMode()
|
||||
})
|
||||
);
|
||||
}
|
||||
const batchResults = await this.client.transaction(builtQueries, queryConfig);
|
||||
return batchResults.map((result, i) => preparedQueries[i].mapResult(result, true));
|
||||
}
|
||||
// change return type to QueryRows<true>
|
||||
async query(query, params) {
|
||||
this.logger.logQuery(query, params);
|
||||
const result = await this.client(query, params, { arrayMode: true, fullResults: true });
|
||||
return result;
|
||||
}
|
||||
// change return type to QueryRows<false>
|
||||
async queryObjects(query, params) {
|
||||
return this.client(query, params, { arrayMode: false, fullResults: true });
|
||||
}
|
||||
/** @internal */
|
||||
async count(sql, token) {
|
||||
const res = await this.execute(sql, token);
|
||||
return Number(
|
||||
res["rows"][0]["count"]
|
||||
);
|
||||
}
|
||||
async transaction(_transaction, _config = {}) {
|
||||
throw new Error("No transactions support in neon-http driver");
|
||||
}
|
||||
}
|
||||
class NeonTransaction extends import_pg_core.PgTransaction {
|
||||
static [import_entity.entityKind] = "NeonHttpTransaction";
|
||||
async transaction(_transaction) {
|
||||
throw new Error("No transactions support in neon-http driver");
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
NeonHttpPreparedQuery,
|
||||
NeonHttpSession,
|
||||
NeonTransaction
|
||||
});
|
||||
//# sourceMappingURL=session.cjs.map
|
||||
1
node_modules/drizzle-orm/neon-http/session.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/neon-http/session.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
52
node_modules/drizzle-orm/neon-http/session.d.cts
generated
vendored
Normal file
52
node_modules/drizzle-orm/neon-http/session.d.cts
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
import type { FullQueryResults, NeonQueryFunction } from '@neondatabase/serverless';
|
||||
import type { BatchItem } from "../batch.cjs";
|
||||
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 as PgPreparedQuery, PgSession } from "../pg-core/session.cjs";
|
||||
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
||||
import { type Query, type SQL } from "../sql/sql.cjs";
|
||||
export type NeonHttpClient = NeonQueryFunction<any, any>;
|
||||
export declare class NeonHttpPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
||||
private client;
|
||||
private logger;
|
||||
private fields;
|
||||
private _isResponseInArrayMode;
|
||||
private customResultMapper?;
|
||||
static readonly [entityKind]: string;
|
||||
constructor(client: NeonHttpClient, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
||||
execute(placeholderValues: Record<string, unknown> | undefined): Promise<T['execute']>;
|
||||
mapResult(result: unknown): unknown;
|
||||
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
||||
values(placeholderValues: Record<string, unknown> | undefined): Promise<T['values']>;
|
||||
}
|
||||
export interface NeonHttpSessionOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
export declare class NeonHttpSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<NeonHttpQueryResultHKT, TFullSchema, TSchema> {
|
||||
private client;
|
||||
private schema;
|
||||
private options;
|
||||
static readonly [entityKind]: string;
|
||||
private logger;
|
||||
constructor(client: NeonHttpClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: NeonHttpSessionOptions);
|
||||
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
||||
batch<U extends BatchItem<'pg'>, T extends Readonly<[U, ...U[]]>>(queries: T): Promise<any>;
|
||||
query(query: string, params: unknown[]): Promise<FullQueryResults<true>>;
|
||||
queryObjects(query: string, params: unknown[]): Promise<FullQueryResults<false>>;
|
||||
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<NeonHttpQueryResultHKT, TFullSchema, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
transaction<T>(_transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
||||
}
|
||||
export type NeonHttpQueryResult<T> = Omit<FullQueryResults<false>, 'rows'> & {
|
||||
rows: T[];
|
||||
};
|
||||
export interface NeonHttpQueryResultHKT extends PgQueryResultHKT {
|
||||
type: NeonHttpQueryResult<this['row']>;
|
||||
}
|
||||
52
node_modules/drizzle-orm/neon-http/session.d.ts
generated
vendored
Normal file
52
node_modules/drizzle-orm/neon-http/session.d.ts
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
import type { FullQueryResults, NeonQueryFunction } from '@neondatabase/serverless';
|
||||
import type { BatchItem } from "../batch.js";
|
||||
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 as PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
||||
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
||||
import { type Query, type SQL } from "../sql/sql.js";
|
||||
export type NeonHttpClient = NeonQueryFunction<any, any>;
|
||||
export declare class NeonHttpPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
||||
private client;
|
||||
private logger;
|
||||
private fields;
|
||||
private _isResponseInArrayMode;
|
||||
private customResultMapper?;
|
||||
static readonly [entityKind]: string;
|
||||
constructor(client: NeonHttpClient, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
||||
execute(placeholderValues: Record<string, unknown> | undefined): Promise<T['execute']>;
|
||||
mapResult(result: unknown): unknown;
|
||||
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
||||
values(placeholderValues: Record<string, unknown> | undefined): Promise<T['values']>;
|
||||
}
|
||||
export interface NeonHttpSessionOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
export declare class NeonHttpSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<NeonHttpQueryResultHKT, TFullSchema, TSchema> {
|
||||
private client;
|
||||
private schema;
|
||||
private options;
|
||||
static readonly [entityKind]: string;
|
||||
private logger;
|
||||
constructor(client: NeonHttpClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: NeonHttpSessionOptions);
|
||||
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
||||
batch<U extends BatchItem<'pg'>, T extends Readonly<[U, ...U[]]>>(queries: T): Promise<any>;
|
||||
query(query: string, params: unknown[]): Promise<FullQueryResults<true>>;
|
||||
queryObjects(query: string, params: unknown[]): Promise<FullQueryResults<false>>;
|
||||
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<NeonHttpQueryResultHKT, TFullSchema, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
transaction<T>(_transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
||||
}
|
||||
export type NeonHttpQueryResult<T> = Omit<FullQueryResults<false>, 'rows'> & {
|
||||
rows: T[];
|
||||
};
|
||||
export interface NeonHttpQueryResultHKT extends PgQueryResultHKT {
|
||||
type: NeonHttpQueryResult<this['row']>;
|
||||
}
|
||||
152
node_modules/drizzle-orm/neon-http/session.js
generated
vendored
Normal file
152
node_modules/drizzle-orm/neon-http/session.js
generated
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
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 { mapResultRow } from "../utils.js";
|
||||
const rawQueryConfig = {
|
||||
arrayMode: false,
|
||||
fullResults: true
|
||||
};
|
||||
const queryConfig = {
|
||||
arrayMode: true,
|
||||
fullResults: true
|
||||
};
|
||||
class NeonHttpPreparedQuery extends PgPreparedQuery {
|
||||
constructor(client, query, logger, fields, _isResponseInArrayMode, customResultMapper) {
|
||||
super(query);
|
||||
this.client = client;
|
||||
this.logger = logger;
|
||||
this.fields = fields;
|
||||
this._isResponseInArrayMode = _isResponseInArrayMode;
|
||||
this.customResultMapper = customResultMapper;
|
||||
}
|
||||
static [entityKind] = "NeonHttpPreparedQuery";
|
||||
/** @internal */
|
||||
async execute(placeholderValues = {}, token = this.authToken) {
|
||||
const params = fillPlaceholders(this.query.params, placeholderValues);
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
const { fields, client, query, customResultMapper } = this;
|
||||
if (!fields && !customResultMapper) {
|
||||
return client(
|
||||
query.sql,
|
||||
params,
|
||||
token === void 0 ? rawQueryConfig : {
|
||||
...rawQueryConfig,
|
||||
authToken: token
|
||||
}
|
||||
);
|
||||
}
|
||||
const result = await client(
|
||||
query.sql,
|
||||
params,
|
||||
token === void 0 ? queryConfig : {
|
||||
...queryConfig,
|
||||
authToken: token
|
||||
}
|
||||
);
|
||||
return this.mapResult(result);
|
||||
}
|
||||
mapResult(result) {
|
||||
if (!this.fields && !this.customResultMapper) {
|
||||
return result;
|
||||
}
|
||||
const rows = result.rows;
|
||||
if (this.customResultMapper) {
|
||||
return this.customResultMapper(rows);
|
||||
}
|
||||
return rows.map((row) => mapResultRow(this.fields, row, this.joinsNotNullableMap));
|
||||
}
|
||||
all(placeholderValues = {}) {
|
||||
const params = fillPlaceholders(this.query.params, placeholderValues);
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
return this.client(
|
||||
this.query.sql,
|
||||
params,
|
||||
this.authToken === void 0 ? rawQueryConfig : {
|
||||
...rawQueryConfig,
|
||||
authToken: this.authToken
|
||||
}
|
||||
).then((result) => result.rows);
|
||||
}
|
||||
/** @internal */
|
||||
values(placeholderValues = {}, token) {
|
||||
const params = fillPlaceholders(this.query.params, placeholderValues);
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
return this.client(this.query.sql, params, { arrayMode: true, fullResults: true, authToken: token }).then((result) => result.rows);
|
||||
}
|
||||
/** @internal */
|
||||
isResponseInArrayMode() {
|
||||
return this._isResponseInArrayMode;
|
||||
}
|
||||
}
|
||||
class NeonHttpSession 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] = "NeonHttpSession";
|
||||
logger;
|
||||
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
|
||||
return new NeonHttpPreparedQuery(
|
||||
this.client,
|
||||
query,
|
||||
this.logger,
|
||||
fields,
|
||||
isResponseInArrayMode,
|
||||
customResultMapper
|
||||
);
|
||||
}
|
||||
async batch(queries) {
|
||||
const preparedQueries = [];
|
||||
const builtQueries = [];
|
||||
for (const query of queries) {
|
||||
const preparedQuery = query._prepare();
|
||||
const builtQuery = preparedQuery.getQuery();
|
||||
preparedQueries.push(preparedQuery);
|
||||
builtQueries.push(
|
||||
this.client(builtQuery.sql, builtQuery.params, {
|
||||
fullResults: true,
|
||||
arrayMode: preparedQuery.isResponseInArrayMode()
|
||||
})
|
||||
);
|
||||
}
|
||||
const batchResults = await this.client.transaction(builtQueries, queryConfig);
|
||||
return batchResults.map((result, i) => preparedQueries[i].mapResult(result, true));
|
||||
}
|
||||
// change return type to QueryRows<true>
|
||||
async query(query, params) {
|
||||
this.logger.logQuery(query, params);
|
||||
const result = await this.client(query, params, { arrayMode: true, fullResults: true });
|
||||
return result;
|
||||
}
|
||||
// change return type to QueryRows<false>
|
||||
async queryObjects(query, params) {
|
||||
return this.client(query, params, { arrayMode: false, fullResults: true });
|
||||
}
|
||||
/** @internal */
|
||||
async count(sql, token) {
|
||||
const res = await this.execute(sql, token);
|
||||
return Number(
|
||||
res["rows"][0]["count"]
|
||||
);
|
||||
}
|
||||
async transaction(_transaction, _config = {}) {
|
||||
throw new Error("No transactions support in neon-http driver");
|
||||
}
|
||||
}
|
||||
class NeonTransaction extends PgTransaction {
|
||||
static [entityKind] = "NeonHttpTransaction";
|
||||
async transaction(_transaction) {
|
||||
throw new Error("No transactions support in neon-http driver");
|
||||
}
|
||||
}
|
||||
export {
|
||||
NeonHttpPreparedQuery,
|
||||
NeonHttpSession,
|
||||
NeonTransaction
|
||||
};
|
||||
//# sourceMappingURL=session.js.map
|
||||
1
node_modules/drizzle-orm/neon-http/session.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/neon-http/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