@vrplatform/kysely 1.3.45-stage.1247 → 1.3.45-stage.1262

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ /** Bounded TCP connections for multi-day migration reads under Bun. */
2
+ export declare function useMigrationSourceKysely(connectionString: string, options?: {
3
+ repositoryName?: string;
4
+ }): Promise<import("kysely").Kysely<import("./v1.generated").DB>>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMigrationSourceKysely = useMigrationSourceKysely;
4
+ const kysely_1 = require("kysely");
5
+ const pg_1 = require("pg");
6
+ const error_1 = require("./error");
7
+ const plugins_1 = require("./plugins");
8
+ const isomorphic_1 = require("./isomorphic");
9
+ /** Bounded TCP connections for multi-day migration reads under Bun. */
10
+ async function useMigrationSourceKysely(connectionString, options) {
11
+ const db = (0, plugins_1.getKysely)(new kysely_1.PostgresDialect({
12
+ pool: new pg_1.Pool({
13
+ connectionString,
14
+ // Match the existing operator's SSL=require connection policy.
15
+ ssl: { rejectUnauthorized: false },
16
+ max: 5,
17
+ maxUses: 10,
18
+ maxLifetimeSeconds: 60,
19
+ idleTimeoutMillis: 10000,
20
+ connectionTimeoutMillis: 10000,
21
+ }),
22
+ }), { repositoryName: options?.repositoryName });
23
+ try {
24
+ const result = await (0, isomorphic_1.sql) `
25
+ select current_setting('transaction_read_only') as "readOnly"
26
+ `.execute(db);
27
+ if (result.rows[0]?.readOnly !== 'off') {
28
+ throw new error_1.KyselyError('Tenant migration source must be writable');
29
+ }
30
+ return db;
31
+ }
32
+ catch (error) {
33
+ await db.destroy();
34
+ throw error;
35
+ }
36
+ }
37
+ //# sourceMappingURL=migration-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-source.js","sourceRoot":"src/","sources":["migration-source.ts"],"names":[],"mappings":";;AAOA,4DA+BC;AAtCD,mCAAyC;AACzC,2BAA0B;AAC1B,mCAAsC;AACtC,uCAAsC;AACtC,6CAAmC;AAEnC,uEAAuE;AAChE,KAAK,UAAU,wBAAwB,CAC5C,gBAAwB,EACxB,OAAqC;IAErC,MAAM,EAAE,GAAG,IAAA,mBAAS,EAClB,IAAI,wBAAe,CAAC;QAClB,IAAI,EAAE,IAAI,SAAI,CAAC;YACb,gBAAgB;YAChB,+DAA+D;YAC/D,GAAG,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE;YAClC,GAAG,EAAE,CAAC;YACN,OAAO,EAAE,EAAE;YACX,kBAAkB,EAAE,EAAE;YACtB,iBAAiB,EAAE,KAAM;YACzB,uBAAuB,EAAE,KAAM;SAChC,CAAC;KACH,CAAC,EACF,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,CAC5C,CAAC;IACF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAA,gBAAG,EAAsB;;KAE7C,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACd,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,KAAK,KAAK,EAAE,CAAC;YACvC,MAAM,IAAI,mBAAW,CAAC,0CAA0C,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { PostgresDialect } from 'kysely';\nimport { Pool } from 'pg';\nimport { KyselyError } from './error';\nimport { getKysely } from './plugins';\nimport { sql } from './isomorphic';\n\n/** Bounded TCP connections for multi-day migration reads under Bun. */\nexport async function useMigrationSourceKysely(\n connectionString: string,\n options?: { repositoryName?: string }\n) {\n const db = getKysely(\n new PostgresDialect({\n pool: new Pool({\n connectionString,\n // Match the existing operator's SSL=require connection policy.\n ssl: { rejectUnauthorized: false },\n max: 5,\n maxUses: 10,\n maxLifetimeSeconds: 60,\n idleTimeoutMillis: 10_000,\n connectionTimeoutMillis: 10_000,\n }),\n }),\n { repositoryName: options?.repositoryName }\n );\n try {\n const result = await sql<{ readOnly: string }>`\n select current_setting('transaction_read_only') as \"readOnly\"\n `.execute(db);\n if (result.rows[0]?.readOnly !== 'off') {\n throw new KyselyError('Tenant migration source must be writable');\n }\n return db;\n } catch (error) {\n await db.destroy();\n throw error;\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ /** Bounded TCP connections for multi-day migration reads under Bun. */
2
+ export declare function useMigrationSourceKysely(connectionString: string, options?: {
3
+ repositoryName?: string;
4
+ }): Promise<import("kysely").Kysely<import("./v1.generated").DB>>;
@@ -0,0 +1,34 @@
1
+ import { PostgresDialect } from 'kysely';
2
+ import { Pool } from 'pg';
3
+ import { KyselyError } from './error';
4
+ import { getKysely } from './plugins';
5
+ import { sql } from './isomorphic';
6
+ /** Bounded TCP connections for multi-day migration reads under Bun. */
7
+ export async function useMigrationSourceKysely(connectionString, options) {
8
+ const db = getKysely(new PostgresDialect({
9
+ pool: new Pool({
10
+ connectionString,
11
+ // Match the existing operator's SSL=require connection policy.
12
+ ssl: { rejectUnauthorized: false },
13
+ max: 5,
14
+ maxUses: 10,
15
+ maxLifetimeSeconds: 60,
16
+ idleTimeoutMillis: 10_000,
17
+ connectionTimeoutMillis: 10_000,
18
+ }),
19
+ }), { repositoryName: options?.repositoryName });
20
+ try {
21
+ const result = await sql `
22
+ select current_setting('transaction_read_only') as "readOnly"
23
+ `.execute(db);
24
+ if (result.rows[0]?.readOnly !== 'off') {
25
+ throw new KyselyError('Tenant migration source must be writable');
26
+ }
27
+ return db;
28
+ }
29
+ catch (error) {
30
+ await db.destroy();
31
+ throw error;
32
+ }
33
+ }
34
+ //# sourceMappingURL=migration-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-source.js","sourceRoot":"src/","sources":["migration-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,gBAAwB,EACxB,OAAqC;IAErC,MAAM,EAAE,GAAG,SAAS,CAClB,IAAI,eAAe,CAAC;QAClB,IAAI,EAAE,IAAI,IAAI,CAAC;YACb,gBAAgB;YAChB,+DAA+D;YAC/D,GAAG,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE;YAClC,GAAG,EAAE,CAAC;YACN,OAAO,EAAE,EAAE;YACX,kBAAkB,EAAE,EAAE;YACtB,iBAAiB,EAAE,MAAM;YACzB,uBAAuB,EAAE,MAAM;SAChC,CAAC;KACH,CAAC,EACF,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,CAC5C,CAAC;IACF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,GAAG,CAAsB;;KAE7C,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACd,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,KAAK,KAAK,EAAE,CAAC;YACvC,MAAM,IAAI,WAAW,CAAC,0CAA0C,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { PostgresDialect } from 'kysely';\nimport { Pool } from 'pg';\nimport { KyselyError } from './error';\nimport { getKysely } from './plugins';\nimport { sql } from './isomorphic';\n\n/** Bounded TCP connections for multi-day migration reads under Bun. */\nexport async function useMigrationSourceKysely(\n connectionString: string,\n options?: { repositoryName?: string }\n) {\n const db = getKysely(\n new PostgresDialect({\n pool: new Pool({\n connectionString,\n // Match the existing operator's SSL=require connection policy.\n ssl: { rejectUnauthorized: false },\n max: 5,\n maxUses: 10,\n maxLifetimeSeconds: 60,\n idleTimeoutMillis: 10_000,\n connectionTimeoutMillis: 10_000,\n }),\n }),\n { repositoryName: options?.repositoryName }\n );\n try {\n const result = await sql<{ readOnly: string }>`\n select current_setting('transaction_read_only') as \"readOnly\"\n `.execute(db);\n if (result.rows[0]?.readOnly !== 'off') {\n throw new KyselyError('Tenant migration source must be writable');\n }\n return db;\n } catch (error) {\n await db.destroy();\n throw error;\n }\n}\n"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.3.45-stage.1247",
6
+ "version": "1.3.45-stage.1262",
7
7
  "description": "",
8
8
  "main": "build/main/index.js",
9
9
  "module": "build/module/index.js",