@vrplatform/kysely 1.3.17 → 1.3.20
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.
- package/build/.data.tar +0 -0
- package/build/main/index.d.ts +1 -0
- package/build/main/index.js +1 -0
- package/build/main/index.js.map +1 -1
- package/build/main/query/index.d.ts +1 -0
- package/build/main/query/index.js +18 -0
- package/build/main/query/index.js.map +1 -0
- package/build/main/query/listing/index.d.ts +1 -0
- package/build/main/query/listing/index.js +18 -0
- package/build/main/query/listing/index.js.map +1 -0
- package/build/main/query/listing/is-active-or-at-least-one-ownership-period-active.d.ts +6 -0
- package/build/main/query/listing/is-active-or-at-least-one-ownership-period-active.js +24 -0
- package/build/main/query/listing/is-active-or-at-least-one-ownership-period-active.js.map +1 -0
- package/build/main/tsconfig.main.tsbuildinfo +1 -1
- package/build/module/index.d.ts +1 -0
- package/build/module/index.js +1 -0
- package/build/module/index.js.map +1 -1
- package/build/module/query/index.d.ts +1 -0
- package/build/module/query/index.js +2 -0
- package/build/module/query/index.js.map +1 -0
- package/build/module/query/listing/index.d.ts +1 -0
- package/build/module/query/listing/index.js +2 -0
- package/build/module/query/listing/index.js.map +1 -0
- package/build/module/query/listing/is-active-or-at-least-one-ownership-period-active.d.ts +6 -0
- package/build/module/query/listing/is-active-or-at-least-one-ownership-period-active.js +21 -0
- package/build/module/query/listing/is-active-or-at-least-one-ownership-period-active.js.map +1 -0
- package/build/module/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +5 -1
- package/src/index.ts +1 -0
- package/src/query/index.ts +1 -0
- package/src/query/listing/index.ts +1 -0
- package/src/query/listing/is-active-or-at-least-one-ownership-period-active.ts +29 -0
- package/build/main/local.d.ts +0 -3
- package/build/main/local.js +0 -158
- package/build/main/local.js.map +0 -1
- package/build/main/test.d.ts +0 -4
- package/build/main/test.js +0 -19
- package/build/main/test.js.map +0 -1
- package/build/main/v0.generated.d.ts +0 -1996
- package/build/main/v0.generated.js +0 -7
- package/build/main/v0.generated.js.map +0 -1
- package/build/module/local.d.ts +0 -3
- package/build/module/local.js +0 -119
- package/build/module/local.js.map +0 -1
- package/build/module/test.d.ts +0 -4
- package/build/module/test.js +0 -16
- package/build/module/test.js.map +0 -1
- package/build/module/v0.generated.d.ts +0 -1996
- package/build/module/v0.generated.js +0 -6
- package/build/module/v0.generated.js.map +0 -1
package/build/.data.tar
CHANGED
|
Binary file
|
package/build/main/index.d.ts
CHANGED
package/build/main/index.js
CHANGED
|
@@ -28,6 +28,7 @@ const postgres_1 = __importDefault(require("postgres"));
|
|
|
28
28
|
const plugins_1 = require("./plugins");
|
|
29
29
|
__exportStar(require("./error"), exports);
|
|
30
30
|
__exportStar(require("./isomorphic"), exports);
|
|
31
|
+
__exportStar(require("./query"), exports);
|
|
31
32
|
/**
|
|
32
33
|
* @deprecated This method is deprecated in favor of the useAsyncKysely method.
|
|
33
34
|
*/
|
package/build/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,8BAsBC;AAGD,4CA6CC;AAED,wCAMC;AAKD,kCAeC;AAED,sDAUC;AAxID,2DAAuD;AACvD,wDAA8C;AAC9C,uCAAsC;AAGtC,0CAAwB;AACxB,+CAA6B;AAC7B,0CAAwB;AAgBxB;;GAEG;AACH,SAAgB,SAAS,CAAC,QAAa,EAAE,OAAoB;IAC3D,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAA,mBAAS,EACtB,IAAI,sCAAiB,CAAC;QACpB,QAAQ;KACT,CAAC,EACF;QACE,cAAc,EAAE,OAAO,EAAE,cAAc;QACvC,GAAG,EAAE,OAAO,EAAE,GAAG;KAClB,CAC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AC;IACrB,CAAC;CACF;AALD,sCAKC","sourcesContent":["import type { Kysely as K, LogConfig } from 'kysely';\nimport { PostgresJSDialect } from 'kysely-postgres-js';\nimport postgres, { type Sql } from 'postgres';\nimport { getKysely } from './plugins';\n\nexport type { LogEvent } from 'kysely';\nexport * from './error';\nexport * from './isomorphic';\nexport * from './query';\n\nimport type { DB } from './v1.generated';\n\ntype KyselyOpts = {\n repositoryName?: string;\n log?: true | LogConfig;\n};\n\ntype PgOpt = {\n forceDisableSSL?: boolean;\n retries?: false | number;\n};\n\nexport type Kysely = K<DB>;\nexport type Postgres = Sql;\n/**\n * @deprecated This method is deprecated in favor of the useAsyncKysely method.\n */\nexport function useKysely(postgres: Sql, options?: KyselyOpts) {\n console.debug('Creating Kysely instance');\n const kysely = getKysely(\n new PostgresJSDialect({\n postgres,\n }),\n {\n repositoryName: options?.repositoryName,\n log: options?.log,\n }\n );\n kysely.destroy = async () => {\n console.debug('Closing Kysely connection');\n await Promise.race([\n postgres.end({ timeout: 5000 }).catch(() => undefined),\n new Promise((res) => setTimeout(res, 6000)),\n ]);\n const index = _connections.indexOf(postgres);\n if (index !== -1) _connections.splice(index, 1);\n };\n\n return kysely;\n}\n\nlet _connections: postgres.Sql[] = [];\nexport async function useAsyncPostgres(connectionString: string, opt?: PgOpt) {\n const delayMs = 2500;\n const retries = opt?.retries === false ? 0 : opt?.retries || 3;\n const ssl = opt?.forceDisableSSL !== true;\n const url = new URL(connectionString);\n\n console.debug(\n `Creating Postgres connection with ${retries} retries and ssl=${ssl} and port=${url.port}`\n );\n if (_connections.length > 0)\n console.warn(`We already have ${_connections.length} Postgres connections`);\n\n for (let attempt = 1; attempt <= retries; attempt++) {\n try {\n const sql = postgres(connectionString, {\n ssl: ssl ? 'require' : false,\n // connect_timeout: 10\n // idle_timeout: 10\n // enable prepare statements, pgbouncer on crunchy allows for prepared statements\n prepare: true,\n connect_timeout: 10,\n idle_timeout: 60,\n });\n\n await sql`select 1`;\n try {\n // connect 30s, idle 60s, max lifetime 45min, statement 60s, lock 10s, log_min_duration 20s, log_lock_waits off\n await sql`set statement_timeout to '30s';`;\n await sql`set lock_timeout to '10s';`;\n } catch (e) {\n console.warn('Failed to set statement timeout, continuing', e);\n }\n\n _connections.push(sql);\n return sql;\n } catch (err) {\n if (attempt === retries) throw err;\n console.warn(\n `Postgres connection failed (attempt ${attempt}), retrying...`\n );\n console.error('error', err);\n await new Promise((res) => setTimeout(res, delayMs));\n }\n }\n throw new Error('Unable to connect to Postgres');\n}\n\nexport async function useAsyncKysely(\n connectionString: string,\n opt?: PgOpt & KyselyOpts\n) {\n const sql = await useAsyncPostgres(connectionString, opt);\n return useKysely(sql, opt);\n}\n\n/**\n * @deprecated This method is deprecated in favor of the useAsyncKysely method.\n */\nexport function usePostgres(\n connectionString?: string,\n opt?: Pick<PgOpt, 'forceDisableSSL'>\n) {\n if (!connectionString) throw new Error('No connection string');\n const ssl = opt?.forceDisableSSL !== true;\n const url = new URL(connectionString);\n console.debug(\n `Creating sync Postgres connection with ssl=${ssl} and port=${url.port}`\n );\n const pg = postgres(connectionString, {\n ssl: ssl ? 'require' : false,\n });\n _connections.push(pg);\n return pg;\n}\n\nexport async function forceCloseAllPostgres(timeoutMs = 5000) {\n await Promise.race([\n Promise.all(\n _connections.map((pg) =>\n pg.end({ timeout: timeoutMs }).catch(() => undefined)\n )\n ),\n new Promise((res) => setTimeout(res, timeoutMs + 1000)),\n ]);\n _connections = [];\n}\n\nexport class DatabaseError extends Error {\n constructor(message: string, cause: any) {\n super(message);\n this.cause = cause;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './listing';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./listing"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B","sourcesContent":["export * from './listing';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './is-active-or-at-least-one-ownership-period-active';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./is-active-or-at-least-one-ownership-period-active"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/listing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sFAAoE","sourcesContent":["export * from './is-active-or-at-least-one-ownership-period-active';\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DB, ExpressionBuilder, PublicListing } from '../../isomorphic';
|
|
2
|
+
export declare function isActiveOrAtLeastOneOwnershipPeriodActive(eb: ExpressionBuilder<DB & {
|
|
3
|
+
listing: PublicListing;
|
|
4
|
+
}, 'listing'>, today: string): import("kysely").ExpressionWrapper<DB & {
|
|
5
|
+
listing: PublicListing;
|
|
6
|
+
}, "listing", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isActiveOrAtLeastOneOwnershipPeriodActive = isActiveOrAtLeastOneOwnershipPeriodActive;
|
|
4
|
+
function isActiveOrAtLeastOneOwnershipPeriodActive(eb, today) {
|
|
5
|
+
return eb.or([
|
|
6
|
+
eb('listing.status', '=', 'active'),
|
|
7
|
+
eb.exists(eb
|
|
8
|
+
.selectFrom('public.listingOwnershipPeriod as period')
|
|
9
|
+
.select(eb.lit(1).as('one'))
|
|
10
|
+
.whereRef('period.listingId', '=', 'listing.id')
|
|
11
|
+
.where('period.setListingInactive', '=', false)
|
|
12
|
+
.where((eb2) => eb2.or([
|
|
13
|
+
eb2.and([
|
|
14
|
+
eb2('period.startAt', '<=', today),
|
|
15
|
+
eb2('period.endAt', '>=', today),
|
|
16
|
+
]),
|
|
17
|
+
eb2.and([
|
|
18
|
+
eb2('period.startAt', '<=', today),
|
|
19
|
+
eb2('period.endAt', 'is', null),
|
|
20
|
+
]),
|
|
21
|
+
]))),
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=is-active-or-at-least-one-ownership-period-active.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-active-or-at-least-one-ownership-period-active.js","sourceRoot":"src/","sources":["query/listing/is-active-or-at-least-one-ownership-period-active.ts"],"names":[],"mappings":";;AAEA,8FA0BC;AA1BD,SAAgB,yCAAyC,CACvD,EAAiE,EACjE,KAAa;IAEb,OAAO,EAAE,CAAC,EAAE,CAAC;QACX,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE,QAAQ,CAAC;QACnC,EAAE,CAAC,MAAM,CACP,EAAE;aACC,UAAU,CAAC,yCAAyC,CAAC;aACrD,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;aAC3B,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE,YAAY,CAAC;aAC/C,KAAK,CAAC,2BAA2B,EAAE,GAAG,EAAE,KAAK,CAAC;aAC9C,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CACb,GAAG,CAAC,EAAE,CAAC;YACL,GAAG,CAAC,GAAG,CAAC;gBACN,GAAG,CAAC,gBAAgB,EAAE,IAAI,EAAE,KAAK,CAAC;gBAClC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC;aACjC,CAAC;YACF,GAAG,CAAC,GAAG,CAAC;gBACN,GAAG,CAAC,gBAAgB,EAAE,IAAI,EAAE,KAAK,CAAC;gBAClC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,IAAI,CAAC;aAChC,CAAC;SACH,CAAC,CACH,CACJ;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { DB, ExpressionBuilder, PublicListing } from '../../isomorphic';\n\nexport function isActiveOrAtLeastOneOwnershipPeriodActive(\n eb: ExpressionBuilder<DB & { listing: PublicListing }, 'listing'>,\n today: string\n) {\n return eb.or([\n eb('listing.status', '=', 'active'),\n eb.exists(\n eb\n .selectFrom('public.listingOwnershipPeriod as period')\n .select(eb.lit(1).as('one'))\n .whereRef('period.listingId', '=', 'listing.id')\n .where('period.setListingInactive', '=', false)\n .where((eb2) =>\n eb2.or([\n eb2.and([\n eb2('period.startAt', '<=', today),\n eb2('period.endAt', '>=', today),\n ]),\n eb2.and([\n eb2('period.startAt', '<=', today),\n eb2('period.endAt', 'is', null),\n ]),\n ])\n )\n ),\n ]);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../src/error.ts","../../src/index.ts","../../src/isomorphic.ts","../../src/plugins.ts","../../src/v1.generated.ts","../../src/camel-case/index.ts","../../src/local/digest.ts","../../src/local/generate.ts","../../src/local/index.ts","../../src/pganalyze-comment-plugin/comment-transformer.ts","../../src/pganalyze-comment-plugin/index.ts","../../src/test/index.ts"],"version":"5.9.3"}
|
|
1
|
+
{"root":["../../src/error.ts","../../src/index.ts","../../src/isomorphic.ts","../../src/plugins.ts","../../src/v1.generated.ts","../../src/camel-case/index.ts","../../src/local/digest.ts","../../src/local/generate.ts","../../src/local/index.ts","../../src/pganalyze-comment-plugin/comment-transformer.ts","../../src/pganalyze-comment-plugin/index.ts","../../src/query/index.ts","../../src/query/listing/index.ts","../../src/query/listing/is-active-or-at-least-one-ownership-period-active.ts","../../src/test/index.ts"],"version":"5.9.3"}
|
package/build/module/index.d.ts
CHANGED
package/build/module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,QAAsB,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,cAAc,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AE,CAAC;AACZ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,SAAS,GAAG,IAAI;IAC1D,MAAM,OAAO,CAAC,IAAI,CAAC;QACjB,OAAO,CAAC,GAAG,CACT,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACtB,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CACtD,CACF;QACD,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC;KACxD,CAAC,CAAC;IACH,YAAY,GAAG,EAAE,CAAC;AACpB,CAAC;AAED,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe,EAAE,KAAU;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF","sourcesContent":["import type { Kysely as K, LogConfig } from 'kysely';\nimport { PostgresJSDialect } from 'kysely-postgres-js';\nimport postgres, { type Sql } from 'postgres';\nimport { getKysely } from './plugins';\n\nexport type { LogEvent } from 'kysely';\nexport * from './error';\nexport * from './isomorphic';\nexport * from './query';\n\nimport type { DB } from './v1.generated';\n\ntype KyselyOpts = {\n repositoryName?: string;\n log?: true | LogConfig;\n};\n\ntype PgOpt = {\n forceDisableSSL?: boolean;\n retries?: false | number;\n};\n\nexport type Kysely = K<DB>;\nexport type Postgres = Sql;\n/**\n * @deprecated This method is deprecated in favor of the useAsyncKysely method.\n */\nexport function useKysely(postgres: Sql, options?: KyselyOpts) {\n console.debug('Creating Kysely instance');\n const kysely = getKysely(\n new PostgresJSDialect({\n postgres,\n }),\n {\n repositoryName: options?.repositoryName,\n log: options?.log,\n }\n );\n kysely.destroy = async () => {\n console.debug('Closing Kysely connection');\n await Promise.race([\n postgres.end({ timeout: 5000 }).catch(() => undefined),\n new Promise((res) => setTimeout(res, 6000)),\n ]);\n const index = _connections.indexOf(postgres);\n if (index !== -1) _connections.splice(index, 1);\n };\n\n return kysely;\n}\n\nlet _connections: postgres.Sql[] = [];\nexport async function useAsyncPostgres(connectionString: string, opt?: PgOpt) {\n const delayMs = 2500;\n const retries = opt?.retries === false ? 0 : opt?.retries || 3;\n const ssl = opt?.forceDisableSSL !== true;\n const url = new URL(connectionString);\n\n console.debug(\n `Creating Postgres connection with ${retries} retries and ssl=${ssl} and port=${url.port}`\n );\n if (_connections.length > 0)\n console.warn(`We already have ${_connections.length} Postgres connections`);\n\n for (let attempt = 1; attempt <= retries; attempt++) {\n try {\n const sql = postgres(connectionString, {\n ssl: ssl ? 'require' : false,\n // connect_timeout: 10\n // idle_timeout: 10\n // enable prepare statements, pgbouncer on crunchy allows for prepared statements\n prepare: true,\n connect_timeout: 10,\n idle_timeout: 60,\n });\n\n await sql`select 1`;\n try {\n // connect 30s, idle 60s, max lifetime 45min, statement 60s, lock 10s, log_min_duration 20s, log_lock_waits off\n await sql`set statement_timeout to '30s';`;\n await sql`set lock_timeout to '10s';`;\n } catch (e) {\n console.warn('Failed to set statement timeout, continuing', e);\n }\n\n _connections.push(sql);\n return sql;\n } catch (err) {\n if (attempt === retries) throw err;\n console.warn(\n `Postgres connection failed (attempt ${attempt}), retrying...`\n );\n console.error('error', err);\n await new Promise((res) => setTimeout(res, delayMs));\n }\n }\n throw new Error('Unable to connect to Postgres');\n}\n\nexport async function useAsyncKysely(\n connectionString: string,\n opt?: PgOpt & KyselyOpts\n) {\n const sql = await useAsyncPostgres(connectionString, opt);\n return useKysely(sql, opt);\n}\n\n/**\n * @deprecated This method is deprecated in favor of the useAsyncKysely method.\n */\nexport function usePostgres(\n connectionString?: string,\n opt?: Pick<PgOpt, 'forceDisableSSL'>\n) {\n if (!connectionString) throw new Error('No connection string');\n const ssl = opt?.forceDisableSSL !== true;\n const url = new URL(connectionString);\n console.debug(\n `Creating sync Postgres connection with ssl=${ssl} and port=${url.port}`\n );\n const pg = postgres(connectionString, {\n ssl: ssl ? 'require' : false,\n });\n _connections.push(pg);\n return pg;\n}\n\nexport async function forceCloseAllPostgres(timeoutMs = 5000) {\n await Promise.race([\n Promise.all(\n _connections.map((pg) =>\n pg.end({ timeout: timeoutMs }).catch(() => undefined)\n )\n ),\n new Promise((res) => setTimeout(res, timeoutMs + 1000)),\n ]);\n _connections = [];\n}\n\nexport class DatabaseError extends Error {\n constructor(message: string, cause: any) {\n super(message);\n this.cause = cause;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './listing';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC","sourcesContent":["export * from './listing';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './is-active-or-at-least-one-ownership-period-active';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/listing/index.ts"],"names":[],"mappings":"AAAA,cAAc,qDAAqD,CAAC","sourcesContent":["export * from './is-active-or-at-least-one-ownership-period-active';\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DB, ExpressionBuilder, PublicListing } from '../../isomorphic';
|
|
2
|
+
export declare function isActiveOrAtLeastOneOwnershipPeriodActive(eb: ExpressionBuilder<DB & {
|
|
3
|
+
listing: PublicListing;
|
|
4
|
+
}, 'listing'>, today: string): import("kysely").ExpressionWrapper<DB & {
|
|
5
|
+
listing: PublicListing;
|
|
6
|
+
}, "listing", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function isActiveOrAtLeastOneOwnershipPeriodActive(eb, today) {
|
|
2
|
+
return eb.or([
|
|
3
|
+
eb('listing.status', '=', 'active'),
|
|
4
|
+
eb.exists(eb
|
|
5
|
+
.selectFrom('public.listingOwnershipPeriod as period')
|
|
6
|
+
.select(eb.lit(1).as('one'))
|
|
7
|
+
.whereRef('period.listingId', '=', 'listing.id')
|
|
8
|
+
.where('period.setListingInactive', '=', false)
|
|
9
|
+
.where((eb2) => eb2.or([
|
|
10
|
+
eb2.and([
|
|
11
|
+
eb2('period.startAt', '<=', today),
|
|
12
|
+
eb2('period.endAt', '>=', today),
|
|
13
|
+
]),
|
|
14
|
+
eb2.and([
|
|
15
|
+
eb2('period.startAt', '<=', today),
|
|
16
|
+
eb2('period.endAt', 'is', null),
|
|
17
|
+
]),
|
|
18
|
+
]))),
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=is-active-or-at-least-one-ownership-period-active.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-active-or-at-least-one-ownership-period-active.js","sourceRoot":"src/","sources":["query/listing/is-active-or-at-least-one-ownership-period-active.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,yCAAyC,CACvD,EAAiE,EACjE,KAAa;IAEb,OAAO,EAAE,CAAC,EAAE,CAAC;QACX,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE,QAAQ,CAAC;QACnC,EAAE,CAAC,MAAM,CACP,EAAE;aACC,UAAU,CAAC,yCAAyC,CAAC;aACrD,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;aAC3B,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE,YAAY,CAAC;aAC/C,KAAK,CAAC,2BAA2B,EAAE,GAAG,EAAE,KAAK,CAAC;aAC9C,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CACb,GAAG,CAAC,EAAE,CAAC;YACL,GAAG,CAAC,GAAG,CAAC;gBACN,GAAG,CAAC,gBAAgB,EAAE,IAAI,EAAE,KAAK,CAAC;gBAClC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC;aACjC,CAAC;YACF,GAAG,CAAC,GAAG,CAAC;gBACN,GAAG,CAAC,gBAAgB,EAAE,IAAI,EAAE,KAAK,CAAC;gBAClC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,IAAI,CAAC;aAChC,CAAC;SACH,CAAC,CACH,CACJ;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { DB, ExpressionBuilder, PublicListing } from '../../isomorphic';\n\nexport function isActiveOrAtLeastOneOwnershipPeriodActive(\n eb: ExpressionBuilder<DB & { listing: PublicListing }, 'listing'>,\n today: string\n) {\n return eb.or([\n eb('listing.status', '=', 'active'),\n eb.exists(\n eb\n .selectFrom('public.listingOwnershipPeriod as period')\n .select(eb.lit(1).as('one'))\n .whereRef('period.listingId', '=', 'listing.id')\n .where('period.setListingInactive', '=', false)\n .where((eb2) =>\n eb2.or([\n eb2.and([\n eb2('period.startAt', '<=', today),\n eb2('period.endAt', '>=', today),\n ]),\n eb2.and([\n eb2('period.startAt', '<=', today),\n eb2('period.endAt', 'is', null),\n ]),\n ])\n )\n ),\n ]);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../src/error.ts","../../src/index.ts","../../src/isomorphic.ts","../../src/plugins.ts","../../src/v1.generated.ts","../../src/camel-case/index.ts","../../src/local/digest.ts","../../src/local/generate.ts","../../src/local/index.ts","../../src/pganalyze-comment-plugin/comment-transformer.ts","../../src/pganalyze-comment-plugin/index.ts","../../src/test/index.ts"],"version":"5.9.3"}
|
|
1
|
+
{"root":["../../src/error.ts","../../src/index.ts","../../src/isomorphic.ts","../../src/plugins.ts","../../src/v1.generated.ts","../../src/camel-case/index.ts","../../src/local/digest.ts","../../src/local/generate.ts","../../src/local/index.ts","../../src/pganalyze-comment-plugin/comment-transformer.ts","../../src/pganalyze-comment-plugin/index.ts","../../src/query/index.ts","../../src/query/listing/index.ts","../../src/query/listing/is-active-or-at-least-one-ownership-period-active.ts","../../src/test/index.ts"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
-
"version": "1.3.
|
|
23
|
+
"version": "1.3.20",
|
|
24
24
|
"description": "",
|
|
25
25
|
"main": "build/main/index.js",
|
|
26
26
|
"module": "build/module/index.js",
|
|
@@ -66,10 +66,14 @@
|
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@dotenvx/dotenvx": "^1.51.1",
|
|
69
|
+
"@vrplatform/utils": "*",
|
|
69
70
|
"kysely-codegen": "^0.19.0",
|
|
70
71
|
"kysely-pglite": "^0.6.1",
|
|
71
72
|
"pg": "^8.16.3"
|
|
72
73
|
},
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"@vrplatform/utils": "*"
|
|
76
|
+
},
|
|
73
77
|
"files": [
|
|
74
78
|
"build/main",
|
|
75
79
|
"build/module",
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './listing';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './is-active-or-at-least-one-ownership-period-active';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DB, ExpressionBuilder, PublicListing } from '../../isomorphic';
|
|
2
|
+
|
|
3
|
+
export function isActiveOrAtLeastOneOwnershipPeriodActive(
|
|
4
|
+
eb: ExpressionBuilder<DB & { listing: PublicListing }, 'listing'>,
|
|
5
|
+
today: string
|
|
6
|
+
) {
|
|
7
|
+
return eb.or([
|
|
8
|
+
eb('listing.status', '=', 'active'),
|
|
9
|
+
eb.exists(
|
|
10
|
+
eb
|
|
11
|
+
.selectFrom('public.listingOwnershipPeriod as period')
|
|
12
|
+
.select(eb.lit(1).as('one'))
|
|
13
|
+
.whereRef('period.listingId', '=', 'listing.id')
|
|
14
|
+
.where('period.setListingInactive', '=', false)
|
|
15
|
+
.where((eb2) =>
|
|
16
|
+
eb2.or([
|
|
17
|
+
eb2.and([
|
|
18
|
+
eb2('period.startAt', '<=', today),
|
|
19
|
+
eb2('period.endAt', '>=', today),
|
|
20
|
+
]),
|
|
21
|
+
eb2.and([
|
|
22
|
+
eb2('period.startAt', '<=', today),
|
|
23
|
+
eb2('period.endAt', 'is', null),
|
|
24
|
+
]),
|
|
25
|
+
])
|
|
26
|
+
)
|
|
27
|
+
),
|
|
28
|
+
]);
|
|
29
|
+
}
|
package/build/main/local.d.ts
DELETED
package/build/main/local.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.useLocalKysely = useLocalKysely;
|
|
40
|
-
const node_fs_1 = require("node:fs");
|
|
41
|
-
const promises_1 = require("node:fs/promises");
|
|
42
|
-
const path = __importStar(require("node:path"));
|
|
43
|
-
const node_path_1 = require("node:path");
|
|
44
|
-
const pglite_1 = require("@electric-sql/pglite");
|
|
45
|
-
const kysely_1 = require("kysely");
|
|
46
|
-
const kysely_codegen_1 = __importDefault(require("kysely-codegen"));
|
|
47
|
-
const kysely_pglite_1 = require("kysely-pglite");
|
|
48
|
-
const root = (0, node_path_1.join)(__dirname, '..');
|
|
49
|
-
async function migrate(client) {
|
|
50
|
-
console.log('migrating pglite ....');
|
|
51
|
-
const glob = new Bun.Glob('initial/*.sql');
|
|
52
|
-
for await (const migration of glob.scan(root)) {
|
|
53
|
-
await client.exec(await Bun.file((0, node_path_1.join)(root, migration)).text());
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async function migrateKysely(kysely) {
|
|
57
|
-
console.log('init migrating kysely ....');
|
|
58
|
-
const migrator = new kysely_1.Migrator({
|
|
59
|
-
db: kysely,
|
|
60
|
-
migrationTableSchema: 'core',
|
|
61
|
-
migrationTableName: 'kysely_migration',
|
|
62
|
-
migrationLockTableName: 'kysely_migration_lock',
|
|
63
|
-
provider: new kysely_1.FileMigrationProvider({
|
|
64
|
-
fs: node_fs_1.promises,
|
|
65
|
-
path,
|
|
66
|
-
// This needs to be an absolute path.
|
|
67
|
-
migrationFolder: path.join(root, 'migrations'),
|
|
68
|
-
}),
|
|
69
|
-
});
|
|
70
|
-
console.log('migrating kysely ....');
|
|
71
|
-
const { error, results } = await migrator.migrateToLatest().catch(() => {
|
|
72
|
-
console.error('failed to migrate');
|
|
73
|
-
process.exit(1);
|
|
74
|
-
});
|
|
75
|
-
for (const it of results ?? []) {
|
|
76
|
-
if (it.status === 'Success') {
|
|
77
|
-
console.log(`migration "${it.migrationName}" was executed successfully`);
|
|
78
|
-
}
|
|
79
|
-
else if (it.status === 'Error') {
|
|
80
|
-
console.error(`failed to execute migration "${it.migrationName}"`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (error) {
|
|
84
|
-
console.error('failed to migrate');
|
|
85
|
-
console.error(error);
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const dumpPath = (0, node_path_1.join)(root, '.data.tar');
|
|
90
|
-
const dumpFile = (async () => {
|
|
91
|
-
const dataExists = await (0, promises_1.exists)(dumpPath).catch(() => false);
|
|
92
|
-
if (!dataExists) {
|
|
93
|
-
console.log('Creating initial dump');
|
|
94
|
-
const main = new pglite_1.PGlite();
|
|
95
|
-
await migrate(main).catch(async (err) => {
|
|
96
|
-
console.error('failed to migrate initial dump');
|
|
97
|
-
await Bun.write('../logs/migrate-initial-dump.json', JSON.stringify(err, null, 2));
|
|
98
|
-
process.exit(1);
|
|
99
|
-
});
|
|
100
|
-
const { dialect } = new kysely_pglite_1.KyselyPGlite(main);
|
|
101
|
-
const kysely = new kysely_1.Kysely({
|
|
102
|
-
dialect,
|
|
103
|
-
plugins: [new kysely_1.CamelCasePlugin()],
|
|
104
|
-
});
|
|
105
|
-
await migrateKysely(kysely).catch(() => {
|
|
106
|
-
console.error('failed to migrate kysely');
|
|
107
|
-
process.exit(1);
|
|
108
|
-
});
|
|
109
|
-
await kysely_codegen_1.default
|
|
110
|
-
.generate({
|
|
111
|
-
db: kysely,
|
|
112
|
-
outFile: path.join(root, 'src/v1.generated.ts'),
|
|
113
|
-
defaultSchemas: ['xxx'],
|
|
114
|
-
camelCase: true,
|
|
115
|
-
dialect: kysely_codegen_1.default.getDialect('postgres'),
|
|
116
|
-
})
|
|
117
|
-
.catch(() => {
|
|
118
|
-
console.error('failed to generate kysely');
|
|
119
|
-
process.exit(1);
|
|
120
|
-
});
|
|
121
|
-
const content = await main.dumpDataDir('none').catch(() => {
|
|
122
|
-
console.error('failed to dump data');
|
|
123
|
-
process.exit(1);
|
|
124
|
-
});
|
|
125
|
-
await Bun.write(dumpPath, content).catch(() => {
|
|
126
|
-
console.error('failed to write dump');
|
|
127
|
-
process.exit(1);
|
|
128
|
-
});
|
|
129
|
-
return content;
|
|
130
|
-
}
|
|
131
|
-
return Bun.file(dumpPath);
|
|
132
|
-
})();
|
|
133
|
-
async function useLocalKysely() {
|
|
134
|
-
let isDestroyed = false;
|
|
135
|
-
const now = performance.now();
|
|
136
|
-
const dump = await dumpFile;
|
|
137
|
-
const pglite = new pglite_1.PGlite({ loadDataDir: dump });
|
|
138
|
-
// warm up
|
|
139
|
-
await pglite.sql `SELECT 1`;
|
|
140
|
-
const { dialect } = new kysely_pglite_1.KyselyPGlite(pglite);
|
|
141
|
-
const kysely = new kysely_1.Kysely({
|
|
142
|
-
dialect,
|
|
143
|
-
plugins: [new kysely_1.CamelCasePlugin()],
|
|
144
|
-
});
|
|
145
|
-
const originalDestroy = kysely.destroy.bind(kysely);
|
|
146
|
-
kysely.destroy = async () => {
|
|
147
|
-
if (isDestroyed)
|
|
148
|
-
return;
|
|
149
|
-
isDestroyed = true;
|
|
150
|
-
const destroyTime = performance.now();
|
|
151
|
-
await originalDestroy().catch(() => undefined);
|
|
152
|
-
await pglite.close().catch(() => undefined);
|
|
153
|
-
console.log(`Database destroyed: ${Math.round(performance.now() - destroyTime)}ms`);
|
|
154
|
-
};
|
|
155
|
-
console.log(`Database initialized: ${Math.round(performance.now() - now)}ms`);
|
|
156
|
-
return kysely;
|
|
157
|
-
}
|
|
158
|
-
//# sourceMappingURL=local.js.map
|
package/build/main/local.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"src/","sources":["local.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,wCA8BC;AA1ID,qCAAyC;AACzC,+CAA0C;AAC1C,gDAAkC;AAClC,yCAAiC;AACjC,iDAA8C;AAC9C,mCAKgB;AAChB,oEAAqC;AACrC,iDAA6C;AAG7C,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACnC,KAAK,UAAU,OAAO,CAAC,MAAc;IACnC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC3C,IAAI,KAAK,EAAE,MAAM,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAA,gBAAI,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,MAAmB;IAC9C,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,iBAAQ,CAAC;QAC5B,EAAE,EAAE,MAAM;QACV,oBAAoB,EAAE,MAAM;QAC5B,kBAAkB,EAAE,kBAAkB;QACtC,sBAAsB,EAAE,uBAAuB;QAC/C,QAAQ,EAAE,IAAI,8BAAqB,CAAC;YAClC,EAAE,EAAF,kBAAE;YACF,IAAI;YACJ,qCAAqC;YACrC,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC;SAC/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G,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,OAAO,CAAC,GAAG,CACT,uBAAuB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,IAAI,CACvE,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IAE9E,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport { exists } from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { join } from 'node:path';\nimport { PGlite } from '@electric-sql/pglite';\nimport {\n CamelCasePlugin,\n FileMigrationProvider,\n Kysely,\n Migrator,\n} from 'kysely';\nimport codegen from 'kysely-codegen';\nimport { KyselyPGlite } from 'kysely-pglite';\nimport type { DB } from './v1.generated';\n\nconst root = join(__dirname, '..');\nasync function migrate(client: PGlite) {\n console.log('migrating pglite ....');\n const glob = new Bun.Glob('initial/*.sql');\n for await (const migration of glob.scan(root)) {\n await client.exec(await Bun.file(join(root, migration)).text());\n }\n}\n\nasync function migrateKysely(kysely: Kysely<any>) {\n console.log('init migrating kysely ....');\n const migrator = new Migrator({\n db: kysely,\n migrationTableSchema: 'core',\n migrationTableName: 'kysely_migration',\n migrationLockTableName: 'kysely_migration_lock',\n provider: new FileMigrationProvider({\n fs,\n path,\n // This needs to be an absolute path.\n migrationFolder: path.join(root, 'migrations'),\n }),\n });\n\n console.log('migrating kysely ....');\n const { error, results } = await migrator.migrateToLatest().catch(() => {\n console.error('failed to migrate');\n process.exit(1);\n });\n\n for (const it of results ?? []) {\n if (it.status === 'Success') {\n console.log(`migration \"${it.migrationName}\" was executed successfully`);\n } else if (it.status === 'Error') {\n console.error(`failed to execute migration \"${it.migrationName}\"`);\n }\n }\n\n if (error) {\n console.error('failed to migrate');\n console.error(error);\n process.exit(1);\n }\n}\n\nconst dumpPath = join(root, '.data.tar');\nconst dumpFile = (async () => {\n const dataExists = await exists(dumpPath).catch(() => false);\n if (!dataExists) {\n console.log('Creating initial dump');\n const main = new PGlite();\n await migrate(main).catch(async (err) => {\n console.error('failed to migrate initial dump');\n await Bun.write(\n '../logs/migrate-initial-dump.json',\n JSON.stringify(err as any, null, 2)\n );\n process.exit(1);\n });\n const { dialect } = new KyselyPGlite(main);\n const kysely = new Kysely<DB>({\n dialect,\n plugins: [new CamelCasePlugin()],\n });\n await migrateKysely(kysely).catch(() => {\n console.error('failed to migrate kysely');\n process.exit(1);\n });\n await codegen\n .generate({\n db: kysely,\n outFile: path.join(root, 'src/v1.generated.ts'),\n defaultSchemas: ['xxx'],\n camelCase: true,\n dialect: codegen.getDialect('postgres'),\n })\n .catch(() => {\n console.error('failed to generate kysely');\n process.exit(1);\n });\n const content = await main.dumpDataDir('none').catch(() => {\n console.error('failed to dump data');\n process.exit(1);\n });\n await Bun.write(dumpPath, content).catch(() => {\n console.error('failed to write dump');\n process.exit(1);\n });\n return content;\n }\n return Bun.file(dumpPath);\n})();\n\nexport async function useLocalKysely() {\n let isDestroyed = false;\n const now = performance.now();\n\n const dump = await dumpFile;\n\n const pglite = new PGlite({ loadDataDir: dump });\n // warm up\n await pglite.sql`SELECT 1`;\n const { dialect } = new KyselyPGlite(pglite);\n const kysely = new Kysely<DB>({\n dialect,\n plugins: [new CamelCasePlugin()],\n });\n\n const originalDestroy = kysely.destroy.bind(kysely);\n kysely.destroy = async () => {\n if (isDestroyed) return;\n isDestroyed = true;\n const destroyTime = performance.now();\n await originalDestroy().catch(() => undefined);\n await pglite.close().catch(() => undefined);\n console.log(\n `Database destroyed: ${Math.round(performance.now() - destroyTime)}ms`\n );\n };\n\n console.log(`Database initialized: ${Math.round(performance.now() - now)}ms`);\n\n return kysely;\n}\n"]}
|
package/build/main/test.d.ts
DELETED
package/build/main/test.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useTestKysely = useTestKysely;
|
|
4
|
-
const bun_test_1 = require("bun:test");
|
|
5
|
-
const local_1 = require("./local");
|
|
6
|
-
async function useTestKysely(cleanupStrategy) {
|
|
7
|
-
const kysely = await (0, local_1.useLocalKysely)();
|
|
8
|
-
if (cleanupStrategy === 'afterAll')
|
|
9
|
-
(0, bun_test_1.afterAll)(async () => {
|
|
10
|
-
await kysely.destroy();
|
|
11
|
-
});
|
|
12
|
-
return {
|
|
13
|
-
kysely,
|
|
14
|
-
[Symbol.dispose]: async () => {
|
|
15
|
-
await kysely.destroy();
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=test.js.map
|
package/build/main/test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"src/","sources":["test.ts"],"names":[],"mappings":";;AAGA,sCAeC;AAlBD,uCAAoC;AACpC,mCAAyC;AAElC,KAAK,UAAU,aAAa,CACjC,eAAgD;IAEhD,MAAM,MAAM,GAAG,MAAM,IAAA,sBAAc,GAAE,CAAC;IAEtC,IAAI,eAAe,KAAK,UAAU;QAChC,IAAA,mBAAQ,EAAC,KAAK,IAAI,EAAE;YAClB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,OAAO;QACL,MAAM;QACN,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,IAAI,EAAE;YAC3B,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { afterAll } from 'bun:test';\nimport { useLocalKysely } from './local';\n\nexport async function useTestKysely(\n cleanupStrategy: 'afterAll' | 'using' | 'manual'\n) {\n const kysely = await useLocalKysely();\n\n if (cleanupStrategy === 'afterAll')\n afterAll(async () => {\n await kysely.destroy();\n });\n return {\n kysely,\n [Symbol.dispose]: async () => {\n await kysely.destroy();\n },\n };\n}\n"]}
|