@vrplatform/kysely 1.3.45-38079069519 → 1.3.45-38086988914
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.
|
@@ -8,18 +8,26 @@ const plugins_1 = require("./plugins");
|
|
|
8
8
|
const isomorphic_1 = require("./isomorphic");
|
|
9
9
|
/** Bounded TCP connections for multi-day migration reads under Bun. */
|
|
10
10
|
async function useMigrationSourceKysely(connectionString, options) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
const pool = new pg_1.Pool({
|
|
12
|
+
connectionString,
|
|
13
|
+
// Long snapshot reads otherwise look idle to NATs and proxies.
|
|
14
|
+
keepAlive: true,
|
|
15
|
+
keepAliveInitialDelayMillis: 10000,
|
|
16
|
+
// Match the existing operator's SSL=require connection policy.
|
|
17
|
+
ssl: { rejectUnauthorized: false },
|
|
18
|
+
max: 5,
|
|
19
|
+
maxUses: 10,
|
|
20
|
+
maxLifetimeSeconds: 60,
|
|
21
|
+
idleTimeoutMillis: 10000,
|
|
22
|
+
// Also bounds the wait for a free pooled client: parallel backfill lanes
|
|
23
|
+
// queue for the five connections and must not fail while waiting.
|
|
24
|
+
connectionTimeoutMillis: 120000,
|
|
25
|
+
});
|
|
26
|
+
// A dropped idle client must not become an unhandled process-level error.
|
|
27
|
+
pool.on('error', () => { });
|
|
28
|
+
const db = (0, plugins_1.getKysely)(new kysely_1.PostgresDialect({ pool }), {
|
|
29
|
+
repositoryName: options?.repositoryName,
|
|
30
|
+
});
|
|
23
31
|
try {
|
|
24
32
|
const result = await (0, isomorphic_1.sql) `
|
|
25
33
|
select current_setting('transaction_read_only') as "readOnly"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-source.js","sourceRoot":"src/","sources":["migration-source.ts"],"names":[],"mappings":";;AAOA,
|
|
1
|
+
{"version":3,"file":"migration-source.js","sourceRoot":"src/","sources":["migration-source.ts"],"names":[],"mappings":";;AAOA,4DAoCC;AA3CD,mCAAyC;AACzC,2BAA0B;AAC1B,mCAAsC;AACtC,uCAAsC;AACtC,6CAAmC;AAEnC,uEAAuE;AAChE,KAAK,UAAU,wBAAwB,CAC5C,gBAAwB,EACxB,OAAqC;IAErC,MAAM,IAAI,GAAG,IAAI,SAAI,CAAC;QACpB,gBAAgB;QAChB,+DAA+D;QAC/D,SAAS,EAAE,IAAI;QACf,2BAA2B,EAAE,KAAM;QACnC,+DAA+D;QAC/D,GAAG,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE;QAClC,GAAG,EAAE,CAAC;QACN,OAAO,EAAE,EAAE;QACX,kBAAkB,EAAE,EAAE;QACtB,iBAAiB,EAAE,KAAM;QACzB,yEAAyE;QACzE,kEAAkE;QAClE,uBAAuB,EAAE,MAAO;KACjC,CAAC,CAAC;IACH,0EAA0E;IAC1E,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,IAAA,mBAAS,EAAC,IAAI,wBAAe,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;QAClD,cAAc,EAAE,OAAO,EAAE,cAAc;KACxC,CAAC,CAAC;IACH,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 pool = new Pool({\n connectionString,\n // Long snapshot reads otherwise look idle to NATs and proxies.\n keepAlive: true,\n keepAliveInitialDelayMillis: 10_000,\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 // Also bounds the wait for a free pooled client: parallel backfill lanes\n // queue for the five connections and must not fail while waiting.\n connectionTimeoutMillis: 120_000,\n });\n // A dropped idle client must not become an unhandled process-level error.\n pool.on('error', () => {});\n const db = getKysely(new PostgresDialect({ pool }), {\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"]}
|
|
@@ -5,18 +5,26 @@ import { getKysely } from './plugins';
|
|
|
5
5
|
import { sql } from './isomorphic';
|
|
6
6
|
/** Bounded TCP connections for multi-day migration reads under Bun. */
|
|
7
7
|
export async function useMigrationSourceKysely(connectionString, options) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
const pool = new Pool({
|
|
9
|
+
connectionString,
|
|
10
|
+
// Long snapshot reads otherwise look idle to NATs and proxies.
|
|
11
|
+
keepAlive: true,
|
|
12
|
+
keepAliveInitialDelayMillis: 10_000,
|
|
13
|
+
// Match the existing operator's SSL=require connection policy.
|
|
14
|
+
ssl: { rejectUnauthorized: false },
|
|
15
|
+
max: 5,
|
|
16
|
+
maxUses: 10,
|
|
17
|
+
maxLifetimeSeconds: 60,
|
|
18
|
+
idleTimeoutMillis: 10_000,
|
|
19
|
+
// Also bounds the wait for a free pooled client: parallel backfill lanes
|
|
20
|
+
// queue for the five connections and must not fail while waiting.
|
|
21
|
+
connectionTimeoutMillis: 120_000,
|
|
22
|
+
});
|
|
23
|
+
// A dropped idle client must not become an unhandled process-level error.
|
|
24
|
+
pool.on('error', () => { });
|
|
25
|
+
const db = getKysely(new PostgresDialect({ pool }), {
|
|
26
|
+
repositoryName: options?.repositoryName,
|
|
27
|
+
});
|
|
20
28
|
try {
|
|
21
29
|
const result = await sql `
|
|
22
30
|
select current_setting('transaction_read_only') as "readOnly"
|
|
@@ -1 +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,
|
|
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,IAAI,GAAG,IAAI,IAAI,CAAC;QACpB,gBAAgB;QAChB,+DAA+D;QAC/D,SAAS,EAAE,IAAI;QACf,2BAA2B,EAAE,MAAM;QACnC,+DAA+D;QAC/D,GAAG,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE;QAClC,GAAG,EAAE,CAAC;QACN,OAAO,EAAE,EAAE;QACX,kBAAkB,EAAE,EAAE;QACtB,iBAAiB,EAAE,MAAM;QACzB,yEAAyE;QACzE,kEAAkE;QAClE,uBAAuB,EAAE,OAAO;KACjC,CAAC,CAAC;IACH,0EAA0E;IAC1E,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,SAAS,CAAC,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;QAClD,cAAc,EAAE,OAAO,EAAE,cAAc;KACxC,CAAC,CAAC;IACH,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 pool = new Pool({\n connectionString,\n // Long snapshot reads otherwise look idle to NATs and proxies.\n keepAlive: true,\n keepAliveInitialDelayMillis: 10_000,\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 // Also bounds the wait for a free pooled client: parallel backfill lanes\n // queue for the five connections and must not fail while waiting.\n connectionTimeoutMillis: 120_000,\n });\n // A dropped idle client must not become an unhandled process-level error.\n pool.on('error', () => {});\n const db = getKysely(new PostgresDialect({ pool }), {\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"]}
|