@goodie-ts/kysely 0.7.0 → 2.0.0
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/README.md +18 -2
- package/dist/abstract-migration.d.ts +2 -2
- package/dist/abstract-migration.js +2 -2
- package/dist/components.json +1854 -0
- package/dist/decorators/migration.d.ts +1 -1
- package/dist/decorators/migration.js +1 -1
- package/dist/dialect.d.ts +4 -18
- package/dist/dialect.d.ts.map +1 -1
- package/dist/dialect.js +5 -27
- package/dist/dialect.js.map +1 -1
- package/dist/dialects/d1.d.ts +23 -0
- package/dist/dialects/d1.d.ts.map +1 -0
- package/dist/dialects/d1.js +126 -0
- package/dist/dialects/d1.js.map +1 -0
- package/dist/dialects/index.d.ts +8 -0
- package/dist/dialects/index.d.ts.map +1 -0
- package/dist/dialects/index.js +8 -0
- package/dist/dialects/index.js.map +1 -0
- package/dist/dialects/libsql.d.ts +19 -0
- package/dist/dialects/libsql.d.ts.map +1 -0
- package/dist/dialects/libsql.js +129 -0
- package/dist/dialects/libsql.js.map +1 -0
- package/dist/dialects/mysql.d.ts +24 -0
- package/dist/dialects/mysql.d.ts.map +1 -0
- package/dist/dialects/mysql.js +141 -0
- package/dist/dialects/mysql.js.map +1 -0
- package/dist/dialects/neon.d.ts +17 -0
- package/dist/dialects/neon.d.ts.map +1 -0
- package/dist/dialects/neon.js +126 -0
- package/dist/dialects/neon.js.map +1 -0
- package/dist/dialects/planetscale.d.ts +20 -0
- package/dist/dialects/planetscale.d.ts.map +1 -0
- package/dist/dialects/planetscale.js +132 -0
- package/dist/dialects/planetscale.js.map +1 -0
- package/dist/dialects/postgres.d.ts +30 -0
- package/dist/dialects/postgres.d.ts.map +1 -0
- package/dist/dialects/postgres.js +148 -0
- package/dist/dialects/postgres.js.map +1 -0
- package/dist/dialects/sqlite.d.ts +17 -0
- package/dist/dialects/sqlite.d.ts.map +1 -0
- package/dist/dialects/sqlite.js +126 -0
- package/dist/dialects/sqlite.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/kysely-database.d.ts +12 -19
- package/dist/kysely-database.d.ts.map +1 -1
- package/dist/kysely-database.js +7 -87
- package/dist/kysely-database.js.map +1 -1
- package/dist/kysely-transformer-plugin.d.ts +2 -5
- package/dist/kysely-transformer-plugin.d.ts.map +1 -1
- package/dist/kysely-transformer-plugin.js +18 -192
- package/dist/kysely-transformer-plugin.js.map +1 -1
- package/dist/migration-post-processor.d.ts +18 -0
- package/dist/migration-post-processor.d.ts.map +1 -0
- package/dist/migration-post-processor.js +117 -0
- package/dist/migration-post-processor.js.map +1 -0
- package/dist/pool-config.d.ts +12 -0
- package/dist/pool-config.d.ts.map +1 -0
- package/dist/{datasource-config.js → pool-config.js} +9 -57
- package/dist/pool-config.js.map +1 -0
- package/dist/transaction-manager.d.ts +9 -9
- package/dist/transaction-manager.d.ts.map +1 -1
- package/dist/transaction-manager.js +167 -123
- package/dist/transaction-manager.js.map +1 -1
- package/dist/transactional-interceptor.d.ts.map +1 -1
- package/dist/transactional-interceptor.js +68 -17
- package/dist/transactional-interceptor.js.map +1 -1
- package/package.json +23 -8
- package/dist/beans.json +0 -184
- package/dist/datasource-config.d.ts +0 -31
- package/dist/datasource-config.d.ts.map +0 -1
- package/dist/datasource-config.js.map +0 -1
- package/dist/dialect-factory.d.ts +0 -9
- package/dist/dialect-factory.d.ts.map +0 -1
- package/dist/dialect-factory.js +0 -48
- package/dist/dialect-factory.js.map +0 -1
- package/dist/migration-runner.d.ts +0 -16
- package/dist/migration-runner.d.ts.map +0 -1
- package/dist/migration-runner.js +0 -45
- package/dist/migration-runner.js.map +0 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import { ConditionalOnProperty, Config, Eager, OnDestroy, OnInit, Singleton, } from '@goodie-ts/core';
|
|
36
|
+
import { KyselyDatabase } from '../kysely-database.js';
|
|
37
|
+
let SqliteDatasourceConfig = (() => {
|
|
38
|
+
let _classDecorators = [Singleton(), Config('datasource'), ConditionalOnProperty('datasource.dialect', { havingValue: 'sqlite' })];
|
|
39
|
+
let _classDescriptor;
|
|
40
|
+
let _classExtraInitializers = [];
|
|
41
|
+
let _classThis;
|
|
42
|
+
var SqliteDatasourceConfig = class {
|
|
43
|
+
static { _classThis = this; }
|
|
44
|
+
static {
|
|
45
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
46
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
47
|
+
SqliteDatasourceConfig = _classThis = _classDescriptor.value;
|
|
48
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
49
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
50
|
+
}
|
|
51
|
+
dialect = '';
|
|
52
|
+
/** File path to the SQLite database (e.g. `./data/app.db`). */
|
|
53
|
+
url = '';
|
|
54
|
+
};
|
|
55
|
+
return SqliteDatasourceConfig = _classThis;
|
|
56
|
+
})();
|
|
57
|
+
export { SqliteDatasourceConfig };
|
|
58
|
+
let SqliteKyselyDatabase = (() => {
|
|
59
|
+
let _classDecorators = [Singleton(), Eager(), ConditionalOnProperty('datasource.dialect', { havingValue: 'sqlite' })];
|
|
60
|
+
let _classDescriptor;
|
|
61
|
+
let _classExtraInitializers = [];
|
|
62
|
+
let _classThis;
|
|
63
|
+
let _classSuper = KyselyDatabase;
|
|
64
|
+
let _instanceExtraInitializers = [];
|
|
65
|
+
let _init_decorators;
|
|
66
|
+
let _destroy_decorators;
|
|
67
|
+
var SqliteKyselyDatabase = class extends _classSuper {
|
|
68
|
+
static { _classThis = this; }
|
|
69
|
+
static {
|
|
70
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
71
|
+
_init_decorators = [OnInit()];
|
|
72
|
+
_destroy_decorators = [OnDestroy()];
|
|
73
|
+
__esDecorate(this, null, _init_decorators, { kind: "method", name: "init", static: false, private: false, access: { has: obj => "init" in obj, get: obj => obj.init }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
74
|
+
__esDecorate(this, null, _destroy_decorators, { kind: "method", name: "destroy", static: false, private: false, access: { has: obj => "destroy" in obj, get: obj => obj.destroy }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
75
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
76
|
+
SqliteKyselyDatabase = _classThis = _classDescriptor.value;
|
|
77
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
78
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
79
|
+
}
|
|
80
|
+
config = __runInitializers(this, _instanceExtraInitializers);
|
|
81
|
+
_kysely;
|
|
82
|
+
constructor(config) {
|
|
83
|
+
super();
|
|
84
|
+
this.config = config;
|
|
85
|
+
}
|
|
86
|
+
get kysely() {
|
|
87
|
+
if (!this._kysely) {
|
|
88
|
+
throw new Error('SqliteKyselyDatabase: not initialized. Wait for @OnInit to complete.');
|
|
89
|
+
}
|
|
90
|
+
return this._kysely;
|
|
91
|
+
}
|
|
92
|
+
get supportsReturning() {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
async init() {
|
|
96
|
+
try {
|
|
97
|
+
const BetterSqlite3 = await importOptional('better-sqlite3');
|
|
98
|
+
const { Kysely: KyselyCtor, SqliteDialect } = await importOptional('kysely');
|
|
99
|
+
this._kysely = new KyselyCtor({
|
|
100
|
+
dialect: new SqliteDialect({
|
|
101
|
+
database: new BetterSqlite3.default(this.config.url),
|
|
102
|
+
}),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
throw new Error(`[SqliteKyselyDatabase] Failed to initialize: ${err instanceof Error ? err.message : err}\n` +
|
|
107
|
+
` Review your 'datasource.*' configuration.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async destroy() {
|
|
111
|
+
await this._kysely?.destroy();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return SqliteKyselyDatabase = _classThis;
|
|
115
|
+
})();
|
|
116
|
+
export { SqliteKyselyDatabase };
|
|
117
|
+
async function importOptional(packageName) {
|
|
118
|
+
try {
|
|
119
|
+
return await import(packageName);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
throw new Error(`SqliteKyselyDatabase requires '${packageName}' but it is not installed. ` +
|
|
123
|
+
`Install it with your package manager.`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=sqlite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite.js","sourceRoot":"","sources":["../../src/dialects/sqlite.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,qBAAqB,EACrB,MAAM,EACN,KAAK,EACL,SAAS,EACT,MAAM,EACN,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;IAK1C,sBAAsB;4BAHlC,SAAS,EAAE,EACX,MAAM,CAAC,YAAY,CAAC,EACpB,qBAAqB,CAAC,oBAAoB,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;;;;;;;;YACvE,6KAIC;;;YAJY,uDAAsB;;QACjC,OAAO,GAAG,EAAE,CAAC;QACb,+DAA+D;QAC/D,GAAG,GAAG,EAAE,CAAC;;;;SAHE,sBAAsB;IAStB,oBAAoB;4BAHhC,SAAS,EAAE,EACX,KAAK,EAAE,EACP,qBAAqB,CAAC,oBAAoB,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;;;;sBAC7B,cAAc;;;;oCAAtB,SAAQ,WAAc;;;;gCAoBrD,MAAM,EAAE;mCAmBR,SAAS,EAAE;YAlBZ,+JAAM,IAAI,6DAgBT;YAGD,wKAAM,OAAO,6DAEZ;YA1CH,6KA2CC;;;YA3CY,uDAAoB;;QAGF,MAAM,GAHxB,mDAAoB;QACvB,OAAO,CAAe;QAE9B,YAA6B,MAA8B;YACzD,KAAK,EAAE,CAAC;YADmB,WAAM,GAAN,MAAM,CAAwB;QAE3D,CAAC;QAED,IAAI,MAAM;YACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;QAED,IAAI,iBAAiB;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;QAGD,KAAK,CAAC,IAAI;YACR,IAAI,CAAC;gBACH,MAAM,aAAa,GAAG,MAAM,cAAc,CAAC,gBAAgB,CAAC,CAAC;gBAC7D,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GACzC,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;gBACjC,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC;oBAC5B,OAAO,EAAE,IAAI,aAAa,CAAC;wBACzB,QAAQ,EAAE,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;qBACrD,CAAC;iBACH,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CACb,gDAAgD,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI;oBAC1F,6CAA6C,CAChD,CAAC;YACJ,CAAC;QACH,CAAC;QAGD,KAAK,CAAC,OAAO;YACX,MAAM,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QAChC,CAAC;;;;SA1CU,oBAAoB;AA6CjC,KAAK,UAAU,cAAc,CAAC,WAAmB;IAC/C,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,kCAAkC,WAAW,6BAA6B;YACxE,uCAAuC,CAC1C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export { AbstractMigration } from './abstract-migration.js';
|
|
2
|
-
export { DatasourceConfig, PoolConfig } from './datasource-config.js';
|
|
3
2
|
export { getMigrationName, Migration } from './decorators/migration.js';
|
|
4
3
|
export { Transactional } from './decorators/transactional.js';
|
|
5
4
|
export type { Dialect } from './dialect.js';
|
|
6
|
-
export { DIALECTS
|
|
5
|
+
export { DIALECTS } from './dialect.js';
|
|
6
|
+
export { D1DatasourceConfig, D1KyselyDatabase, LibsqlDatasourceConfig, LibsqlKyselyDatabase, MysqlDatasourceConfig, MysqlKyselyDatabase, NeonDatasourceConfig, NeonKyselyDatabase, PlanetscaleDatasourceConfig, PlanetscaleKyselyDatabase, PostgresDatasourceConfig, PostgresKyselyDatabase, SqliteDatasourceConfig, SqliteKyselyDatabase, } from './dialects/index.js';
|
|
7
7
|
export { KyselyDatabase } from './kysely-database.js';
|
|
8
8
|
export type { KyselyPluginOptions } from './kysely-transformer-plugin.js';
|
|
9
9
|
export { createKyselyPlugin } from './kysely-transformer-plugin.js';
|
|
10
|
-
export {
|
|
10
|
+
export { MigrationPostProcessor } from './migration-post-processor.js';
|
|
11
|
+
export { PoolConfig } from './pool-config.js';
|
|
11
12
|
export type { KyselyProvider } from './transaction-manager.js';
|
|
12
13
|
export { TransactionManager } from './transaction-manager.js';
|
|
13
14
|
export { TransactionalInterceptor } from './transactional-interceptor.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { AbstractMigration } from './abstract-migration.js';
|
|
2
|
-
export { DatasourceConfig, PoolConfig } from './datasource-config.js';
|
|
3
2
|
export { getMigrationName, Migration } from './decorators/migration.js';
|
|
4
3
|
export { Transactional } from './decorators/transactional.js';
|
|
5
|
-
export { DIALECTS
|
|
4
|
+
export { DIALECTS } from './dialect.js';
|
|
5
|
+
export { D1DatasourceConfig, D1KyselyDatabase, LibsqlDatasourceConfig, LibsqlKyselyDatabase, MysqlDatasourceConfig, MysqlKyselyDatabase, NeonDatasourceConfig, NeonKyselyDatabase, PlanetscaleDatasourceConfig, PlanetscaleKyselyDatabase, PostgresDatasourceConfig, PostgresKyselyDatabase, SqliteDatasourceConfig, SqliteKyselyDatabase, } from './dialects/index.js';
|
|
6
6
|
export { KyselyDatabase } from './kysely-database.js';
|
|
7
7
|
export { createKyselyPlugin } from './kysely-transformer-plugin.js';
|
|
8
|
-
export {
|
|
8
|
+
export { MigrationPostProcessor } from './migration-post-processor.js';
|
|
9
|
+
export { PoolConfig } from './pool-config.js';
|
|
9
10
|
export { TransactionManager } from './transaction-manager.js';
|
|
10
11
|
export { TransactionalInterceptor } from './transactional-interceptor.js';
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import type { Kysely } from 'kysely';
|
|
2
|
-
import type { DatasourceConfig } from './datasource-config.js';
|
|
3
|
-
import type { Dialect } from './dialect.js';
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Creates and manages a `Kysely<DB>` instance based on `DatasourceConfig`.
|
|
8
|
-
* Automatically selects the correct dialect driver via dynamic import:
|
|
9
|
-
* - `postgres` → `pg` + `PostgresDialect`
|
|
10
|
-
* - `mysql` → `mysql2` + `MysqlDialect`
|
|
11
|
-
* - `sqlite` → `better-sqlite3` + `SqliteDialect`
|
|
3
|
+
* Abstract base for Kysely database access.
|
|
12
4
|
*
|
|
13
5
|
* Non-generic (`Kysely<any>`) by design. Users bridge to their schema
|
|
14
|
-
* type via a `@
|
|
6
|
+
* type via a `@Factory` with `@Provides`:
|
|
15
7
|
* ```typescript
|
|
16
|
-
* @
|
|
8
|
+
* @Factory()
|
|
17
9
|
* class DatabaseModule {
|
|
18
10
|
* constructor(private db: KyselyDatabase) {}
|
|
19
11
|
*
|
|
@@ -24,14 +16,15 @@ import type { Dialect } from './dialect.js';
|
|
|
24
16
|
* }
|
|
25
17
|
* ```
|
|
26
18
|
*
|
|
27
|
-
*
|
|
19
|
+
* Concrete implementations are conditionally selected at build time
|
|
20
|
+
* based on `datasource.dialect` in the config.
|
|
28
21
|
*/
|
|
29
|
-
export declare class KyselyDatabase {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
export declare abstract class KyselyDatabase {
|
|
23
|
+
abstract get kysely(): Kysely<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the dialect supports `RETURNING` clauses natively.
|
|
26
|
+
* Used by `TransactionManager` for optimized insert/update/delete operations.
|
|
27
|
+
*/
|
|
28
|
+
abstract get supportsReturning(): boolean;
|
|
36
29
|
}
|
|
37
30
|
//# sourceMappingURL=kysely-database.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kysely-database.d.ts","sourceRoot":"","sources":["../src/kysely-database.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kysely-database.d.ts","sourceRoot":"","sources":["../src/kysely-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8BAAsB,cAAc;IAClC,QAAQ,KAAK,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;IAEnC;;;OAGG;IACH,QAAQ,KAAK,iBAAiB,IAAI,OAAO,CAAC;CAC3C"}
|
package/dist/kysely-database.js
CHANGED
|
@@ -1,51 +1,10 @@
|
|
|
1
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
-
var useValue = arguments.length > 2;
|
|
3
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
-
}
|
|
6
|
-
return useValue ? value : void 0;
|
|
7
|
-
};
|
|
8
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
-
var _, done = false;
|
|
14
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
-
var context = {};
|
|
16
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
-
if (kind === "accessor") {
|
|
21
|
-
if (result === void 0) continue;
|
|
22
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
-
}
|
|
27
|
-
else if (_ = accept(result)) {
|
|
28
|
-
if (kind === "field") initializers.unshift(_);
|
|
29
|
-
else descriptor[key] = _;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
-
done = true;
|
|
34
|
-
};
|
|
35
|
-
import { PostConstruct, PreDestroy, Singleton } from '@goodie-ts/core';
|
|
36
1
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* Creates and manages a `Kysely<DB>` instance based on `DatasourceConfig`.
|
|
40
|
-
* Automatically selects the correct dialect driver via dynamic import:
|
|
41
|
-
* - `postgres` → `pg` + `PostgresDialect`
|
|
42
|
-
* - `mysql` → `mysql2` + `MysqlDialect`
|
|
43
|
-
* - `sqlite` → `better-sqlite3` + `SqliteDialect`
|
|
2
|
+
* Abstract base for Kysely database access.
|
|
44
3
|
*
|
|
45
4
|
* Non-generic (`Kysely<any>`) by design. Users bridge to their schema
|
|
46
|
-
* type via a `@
|
|
5
|
+
* type via a `@Factory` with `@Provides`:
|
|
47
6
|
* ```typescript
|
|
48
|
-
* @
|
|
7
|
+
* @Factory()
|
|
49
8
|
* class DatabaseModule {
|
|
50
9
|
* constructor(private db: KyselyDatabase) {}
|
|
51
10
|
*
|
|
@@ -56,48 +15,9 @@ import { PostConstruct, PreDestroy, Singleton } from '@goodie-ts/core';
|
|
|
56
15
|
* }
|
|
57
16
|
* ```
|
|
58
17
|
*
|
|
59
|
-
*
|
|
18
|
+
* Concrete implementations are conditionally selected at build time
|
|
19
|
+
* based on `datasource.dialect` in the config.
|
|
60
20
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
let _classDescriptor;
|
|
64
|
-
let _classExtraInitializers = [];
|
|
65
|
-
let _classThis;
|
|
66
|
-
let _instanceExtraInitializers = [];
|
|
67
|
-
let _init_decorators;
|
|
68
|
-
let _destroy_decorators;
|
|
69
|
-
var KyselyDatabase = class {
|
|
70
|
-
static { _classThis = this; }
|
|
71
|
-
static {
|
|
72
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
73
|
-
_init_decorators = [PostConstruct()];
|
|
74
|
-
_destroy_decorators = [PreDestroy()];
|
|
75
|
-
__esDecorate(this, null, _init_decorators, { kind: "method", name: "init", static: false, private: false, access: { has: obj => "init" in obj, get: obj => obj.init }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
76
|
-
__esDecorate(this, null, _destroy_decorators, { kind: "method", name: "destroy", static: false, private: false, access: { has: obj => "destroy" in obj, get: obj => obj.destroy }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
77
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
78
|
-
KyselyDatabase = _classThis = _classDescriptor.value;
|
|
79
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
80
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
81
|
-
}
|
|
82
|
-
config = __runInitializers(this, _instanceExtraInitializers);
|
|
83
|
-
kysely;
|
|
84
|
-
constructor(config) {
|
|
85
|
-
this.config = config;
|
|
86
|
-
}
|
|
87
|
-
get dialect() {
|
|
88
|
-
return this.config.dialect;
|
|
89
|
-
}
|
|
90
|
-
async init() {
|
|
91
|
-
const { default: createDialect } = await import('./dialect-factory.js');
|
|
92
|
-
const kyselyDialect = await createDialect(this.config);
|
|
93
|
-
const { Kysely } = await import('kysely');
|
|
94
|
-
this.kysely = new Kysely({ dialect: kyselyDialect });
|
|
95
|
-
}
|
|
96
|
-
async destroy() {
|
|
97
|
-
await this.kysely?.destroy();
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
return KyselyDatabase = _classThis;
|
|
101
|
-
})();
|
|
102
|
-
export { KyselyDatabase };
|
|
21
|
+
export class KyselyDatabase {
|
|
22
|
+
}
|
|
103
23
|
//# sourceMappingURL=kysely-database.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kysely-database.js","sourceRoot":"","sources":["../src/kysely-database.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kysely-database.js","sourceRoot":"","sources":["../src/kysely-database.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAgB,cAAc;CAQnC"}
|
|
@@ -7,11 +7,8 @@ export type KyselyPluginOptions = Record<string, never>;
|
|
|
7
7
|
* Scans @Transactional decorators on methods and wires
|
|
8
8
|
* TransactionalInterceptor as an AOP interceptor dependency at compile time.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Wires TransactionManager and MigrationRunner using `KyselyDatabase` from
|
|
14
|
-
* library beans — no manual `database` option needed.
|
|
10
|
+
* Registers @Migration decorated classes as components so they are discovered
|
|
11
|
+
* by the MigrationPostProcessor library component via `ctx.getAll(AbstractMigration)`.
|
|
15
12
|
*
|
|
16
13
|
* **Limitation:** Propagation is detected via AST text matching
|
|
17
14
|
* (`text.includes('REQUIRES_NEW')`). Only string literal values in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kysely-transformer-plugin.d.ts","sourceRoot":"","sources":["../src/kysely-transformer-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"kysely-transformer-plugin.d.ts","sourceRoot":"","sources":["../src/kysely-transformer-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,iDAAiD;AACjD,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAQxD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,CAAC,EAAE,mBAAmB,GAC7B,iBAAiB,CA+FnB;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
* Scans @Transactional decorators on methods and wires
|
|
5
5
|
* TransactionalInterceptor as an AOP interceptor dependency at compile time.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Wires TransactionManager and MigrationRunner using `KyselyDatabase` from
|
|
11
|
-
* library beans — no manual `database` option needed.
|
|
7
|
+
* Registers @Migration decorated classes as components so they are discovered
|
|
8
|
+
* by the MigrationPostProcessor library component via `ctx.getAll(AbstractMigration)`.
|
|
12
9
|
*
|
|
13
10
|
* **Limitation:** Propagation is detected via AST text matching
|
|
14
11
|
* (`text.includes('REQUIRES_NEW')`). Only string literal values in the
|
|
@@ -17,22 +14,18 @@
|
|
|
17
14
|
*/
|
|
18
15
|
export function createKyselyPlugin(_options) {
|
|
19
16
|
const classTransactionalInfo = new Map();
|
|
20
|
-
/** @Migration decorated classes discovered during visitClass. */
|
|
21
|
-
const migrationClasses = [];
|
|
22
17
|
return {
|
|
23
18
|
name: 'kysely',
|
|
24
19
|
visitClass(ctx) {
|
|
25
|
-
// Detect @Migration('name')
|
|
20
|
+
// Detect @Migration('name') — register as a component so the scanner picks it up
|
|
26
21
|
for (const decorator of ctx.classDeclaration.getDecorators()) {
|
|
27
22
|
if (decorator.getName() !== 'Migration')
|
|
28
23
|
continue;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
className: ctx.className,
|
|
33
|
-
filePath: ctx.filePath,
|
|
34
|
-
migrationName: name,
|
|
24
|
+
ctx.registerComponent({
|
|
25
|
+
scope: 'singleton',
|
|
26
|
+
decoratorName: 'Migration',
|
|
35
27
|
});
|
|
28
|
+
break;
|
|
36
29
|
}
|
|
37
30
|
},
|
|
38
31
|
visitMethod(ctx) {
|
|
@@ -55,20 +48,20 @@ export function createKyselyPlugin(_options) {
|
|
|
55
48
|
classTransactionalInfo.set(key, existing);
|
|
56
49
|
}
|
|
57
50
|
},
|
|
58
|
-
afterResolve(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
afterResolve(components) {
|
|
52
|
+
// Wire @Transactional interceptor metadata onto components
|
|
53
|
+
for (const component of components) {
|
|
54
|
+
const className = component.tokenRef.kind === 'class'
|
|
55
|
+
? component.tokenRef.className
|
|
56
|
+
: undefined;
|
|
64
57
|
if (!className)
|
|
65
58
|
continue;
|
|
66
|
-
const key = `${
|
|
59
|
+
const key = `${component.tokenRef.importPath}:${className}`;
|
|
67
60
|
const infos = classTransactionalInfo.get(key);
|
|
68
61
|
if (!infos || infos.length === 0)
|
|
69
62
|
continue;
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
const existing = (component.metadata.interceptedMethods ??
|
|
64
|
+
[]);
|
|
72
65
|
for (const info of infos) {
|
|
73
66
|
const methodEntry = existing.find((m) => m.methodName === info.methodName);
|
|
74
67
|
const interceptorRef = {
|
|
@@ -88,176 +81,9 @@ export function createKyselyPlugin(_options) {
|
|
|
88
81
|
});
|
|
89
82
|
}
|
|
90
83
|
}
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
const hasMigrations = migrationClasses.length > 0;
|
|
94
|
-
if (!needsInterceptor && !hasMigrations)
|
|
95
|
-
return beans;
|
|
96
|
-
// Find KyselyDatabase from library beans for auto-wiring.
|
|
97
|
-
const kyselyDatabaseBean = beans.find((b) => b.tokenRef.kind === 'class' &&
|
|
98
|
-
b.tokenRef.className === 'KyselyDatabase' &&
|
|
99
|
-
b.tokenRef.importPath === '@goodie-ts/kysely');
|
|
100
|
-
const kyselyProviderDep = kyselyDatabaseBean && kyselyDatabaseBean.tokenRef.kind === 'class'
|
|
101
|
-
? [
|
|
102
|
-
{
|
|
103
|
-
tokenRef: {
|
|
104
|
-
kind: 'class',
|
|
105
|
-
className: 'KyselyDatabase',
|
|
106
|
-
importPath: '@goodie-ts/kysely',
|
|
107
|
-
},
|
|
108
|
-
optional: false,
|
|
109
|
-
collection: false,
|
|
110
|
-
sourceLocation: {
|
|
111
|
-
filePath: '@goodie-ts/kysely',
|
|
112
|
-
line: 0,
|
|
113
|
-
column: 0,
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
]
|
|
117
|
-
: [];
|
|
118
|
-
// --- Transactional synthetic beans ---
|
|
119
|
-
if (needsInterceptor) {
|
|
120
|
-
syntheticBeans.push({
|
|
121
|
-
tokenRef: {
|
|
122
|
-
kind: 'class',
|
|
123
|
-
className: 'TransactionManager',
|
|
124
|
-
importPath: '@goodie-ts/kysely',
|
|
125
|
-
},
|
|
126
|
-
scope: 'singleton',
|
|
127
|
-
eager: false,
|
|
128
|
-
name: undefined,
|
|
129
|
-
constructorDeps: kyselyProviderDep,
|
|
130
|
-
fieldDeps: [],
|
|
131
|
-
factoryKind: 'constructor',
|
|
132
|
-
providesSource: undefined,
|
|
133
|
-
metadata: {},
|
|
134
|
-
sourceLocation: {
|
|
135
|
-
filePath: '@goodie-ts/kysely',
|
|
136
|
-
line: 0,
|
|
137
|
-
column: 0,
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
syntheticBeans.push({
|
|
141
|
-
tokenRef: {
|
|
142
|
-
kind: 'class',
|
|
143
|
-
className: 'TransactionalInterceptor',
|
|
144
|
-
importPath: '@goodie-ts/kysely',
|
|
145
|
-
},
|
|
146
|
-
scope: 'singleton',
|
|
147
|
-
eager: false,
|
|
148
|
-
name: undefined,
|
|
149
|
-
constructorDeps: [
|
|
150
|
-
{
|
|
151
|
-
tokenRef: {
|
|
152
|
-
kind: 'class',
|
|
153
|
-
className: 'TransactionManager',
|
|
154
|
-
importPath: '@goodie-ts/kysely',
|
|
155
|
-
},
|
|
156
|
-
optional: false,
|
|
157
|
-
collection: false,
|
|
158
|
-
sourceLocation: {
|
|
159
|
-
filePath: '@goodie-ts/kysely',
|
|
160
|
-
line: 0,
|
|
161
|
-
column: 0,
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
fieldDeps: [],
|
|
166
|
-
factoryKind: 'constructor',
|
|
167
|
-
providesSource: undefined,
|
|
168
|
-
metadata: {},
|
|
169
|
-
sourceLocation: {
|
|
170
|
-
filePath: '@goodie-ts/kysely',
|
|
171
|
-
line: 0,
|
|
172
|
-
column: 0,
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
// --- @Migration synthetic beans ---
|
|
177
|
-
if (hasMigrations) {
|
|
178
|
-
if (kyselyProviderDep.length === 0) {
|
|
179
|
-
console.warn('[@goodie-ts/kysely] @Migration classes found but no Kysely provider detected. ' +
|
|
180
|
-
'MigrationRunner will not be created.');
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
// Sort migrations by name for deterministic execution order
|
|
184
|
-
migrationClasses.sort((a, b) => a.migrationName.localeCompare(b.migrationName));
|
|
185
|
-
// Synthetic bean per @Migration class (no baseTokenRefs — wired as individual deps)
|
|
186
|
-
const migrationDeps = [];
|
|
187
|
-
for (const m of migrationClasses) {
|
|
188
|
-
syntheticBeans.push({
|
|
189
|
-
tokenRef: {
|
|
190
|
-
kind: 'class',
|
|
191
|
-
className: m.className,
|
|
192
|
-
importPath: m.filePath,
|
|
193
|
-
},
|
|
194
|
-
scope: 'singleton',
|
|
195
|
-
eager: false,
|
|
196
|
-
name: undefined,
|
|
197
|
-
constructorDeps: [],
|
|
198
|
-
fieldDeps: [],
|
|
199
|
-
factoryKind: 'constructor',
|
|
200
|
-
providesSource: undefined,
|
|
201
|
-
metadata: {},
|
|
202
|
-
sourceLocation: {
|
|
203
|
-
filePath: m.filePath,
|
|
204
|
-
line: 0,
|
|
205
|
-
column: 0,
|
|
206
|
-
},
|
|
207
|
-
});
|
|
208
|
-
migrationDeps.push({
|
|
209
|
-
tokenRef: {
|
|
210
|
-
kind: 'class',
|
|
211
|
-
className: m.className,
|
|
212
|
-
importPath: m.filePath,
|
|
213
|
-
},
|
|
214
|
-
optional: false,
|
|
215
|
-
collection: false,
|
|
216
|
-
sourceLocation: {
|
|
217
|
-
filePath: '@goodie-ts/kysely',
|
|
218
|
-
line: 0,
|
|
219
|
-
column: 0,
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
// MigrationRunner: eager singleton, depends on KyselyProvider + individual migration deps
|
|
224
|
-
syntheticBeans.push({
|
|
225
|
-
tokenRef: {
|
|
226
|
-
kind: 'class',
|
|
227
|
-
className: 'MigrationRunner',
|
|
228
|
-
importPath: '@goodie-ts/kysely',
|
|
229
|
-
},
|
|
230
|
-
scope: 'singleton',
|
|
231
|
-
eager: true,
|
|
232
|
-
name: undefined,
|
|
233
|
-
constructorDeps: [kyselyProviderDep[0], ...migrationDeps],
|
|
234
|
-
fieldDeps: [],
|
|
235
|
-
factoryKind: 'constructor',
|
|
236
|
-
providesSource: undefined,
|
|
237
|
-
metadata: { postConstructMethods: ['migrate'] },
|
|
238
|
-
sourceLocation: {
|
|
239
|
-
filePath: '@goodie-ts/kysely',
|
|
240
|
-
line: 0,
|
|
241
|
-
column: 0,
|
|
242
|
-
},
|
|
243
|
-
});
|
|
244
|
-
}
|
|
84
|
+
component.metadata.interceptedMethods = existing;
|
|
245
85
|
}
|
|
246
|
-
return
|
|
247
|
-
},
|
|
248
|
-
codegen(beans) {
|
|
249
|
-
const hasTransactional = beans.some((b) => {
|
|
250
|
-
const methods = b.metadata.interceptedMethods;
|
|
251
|
-
return methods?.some((m) => m.interceptors.some((i) => i.className === 'TransactionalInterceptor'));
|
|
252
|
-
});
|
|
253
|
-
if (!hasTransactional)
|
|
254
|
-
return {};
|
|
255
|
-
// TransactionManager and TransactionalInterceptor imports are already
|
|
256
|
-
// generated by collectClassImports (they are synthetic bean tokens).
|
|
257
|
-
// Only need to contribute the buildInterceptorChain import.
|
|
258
|
-
return {
|
|
259
|
-
imports: ["import { buildInterceptorChain } from '@goodie-ts/core'"],
|
|
260
|
-
};
|
|
86
|
+
return components;
|
|
261
87
|
},
|
|
262
88
|
};
|
|
263
89
|
}
|