@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
package/dist/beans.json
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 1,
|
|
3
|
-
"package": "@goodie-ts/kysely",
|
|
4
|
-
"beans": [
|
|
5
|
-
{
|
|
6
|
-
"tokenRef": {
|
|
7
|
-
"kind": "class",
|
|
8
|
-
"className": "PoolConfig",
|
|
9
|
-
"importPath": "@goodie-ts/kysely"
|
|
10
|
-
},
|
|
11
|
-
"scope": "singleton",
|
|
12
|
-
"eager": false,
|
|
13
|
-
"name": null,
|
|
14
|
-
"constructorDeps": [],
|
|
15
|
-
"fieldDeps": [],
|
|
16
|
-
"factoryKind": "constructor",
|
|
17
|
-
"providesSource": null,
|
|
18
|
-
"baseTokenRefs": null,
|
|
19
|
-
"decorators": [
|
|
20
|
-
{
|
|
21
|
-
"name": "Singleton",
|
|
22
|
-
"importPath": "@goodie-ts/kysely"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "ConfigurationProperties",
|
|
26
|
-
"importPath": "@goodie-ts/kysely"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"methodDecorators": null,
|
|
30
|
-
"metadata": {
|
|
31
|
-
"valueFields": [
|
|
32
|
-
{
|
|
33
|
-
"fieldName": "min",
|
|
34
|
-
"key": "datasource.pool.min",
|
|
35
|
-
"default": "2"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"fieldName": "max",
|
|
39
|
-
"key": "datasource.pool.max",
|
|
40
|
-
"default": "10"
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
"sourceLocation": {
|
|
45
|
-
"filePath": "@goodie-ts/kysely",
|
|
46
|
-
"line": 11,
|
|
47
|
-
"column": 1
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"tokenRef": {
|
|
52
|
-
"kind": "class",
|
|
53
|
-
"className": "DatasourceConfig",
|
|
54
|
-
"importPath": "@goodie-ts/kysely"
|
|
55
|
-
},
|
|
56
|
-
"scope": "singleton",
|
|
57
|
-
"eager": false,
|
|
58
|
-
"name": null,
|
|
59
|
-
"constructorDeps": [
|
|
60
|
-
{
|
|
61
|
-
"tokenRef": {
|
|
62
|
-
"kind": "class",
|
|
63
|
-
"className": "PoolConfig",
|
|
64
|
-
"importPath": "@goodie-ts/kysely"
|
|
65
|
-
},
|
|
66
|
-
"optional": false,
|
|
67
|
-
"collection": false,
|
|
68
|
-
"sourceLocation": {
|
|
69
|
-
"filePath": "@goodie-ts/kysely",
|
|
70
|
-
"line": 40,
|
|
71
|
-
"column": 15
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
],
|
|
75
|
-
"fieldDeps": [],
|
|
76
|
-
"factoryKind": "constructor",
|
|
77
|
-
"providesSource": null,
|
|
78
|
-
"baseTokenRefs": null,
|
|
79
|
-
"decorators": [
|
|
80
|
-
{
|
|
81
|
-
"name": "Singleton",
|
|
82
|
-
"importPath": "@goodie-ts/kysely"
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
"name": "ConfigurationProperties",
|
|
86
|
-
"importPath": "@goodie-ts/kysely"
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
"methodDecorators": {
|
|
90
|
-
"validate": [
|
|
91
|
-
{
|
|
92
|
-
"name": "PostConstruct",
|
|
93
|
-
"importPath": "@goodie-ts/kysely"
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
"metadata": {
|
|
98
|
-
"postConstructMethods": [
|
|
99
|
-
"validate"
|
|
100
|
-
],
|
|
101
|
-
"valueFields": [
|
|
102
|
-
{
|
|
103
|
-
"fieldName": "url",
|
|
104
|
-
"key": "datasource.url",
|
|
105
|
-
"default": "''"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"fieldName": "dialect",
|
|
109
|
-
"key": "datasource.dialect",
|
|
110
|
-
"default": "''"
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
},
|
|
114
|
-
"sourceLocation": {
|
|
115
|
-
"filePath": "@goodie-ts/kysely",
|
|
116
|
-
"line": 34,
|
|
117
|
-
"column": 1
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
"tokenRef": {
|
|
122
|
-
"kind": "class",
|
|
123
|
-
"className": "KyselyDatabase",
|
|
124
|
-
"importPath": "@goodie-ts/kysely"
|
|
125
|
-
},
|
|
126
|
-
"scope": "singleton",
|
|
127
|
-
"eager": false,
|
|
128
|
-
"name": null,
|
|
129
|
-
"constructorDeps": [
|
|
130
|
-
{
|
|
131
|
-
"tokenRef": {
|
|
132
|
-
"kind": "class",
|
|
133
|
-
"className": "DatasourceConfig",
|
|
134
|
-
"importPath": "@goodie-ts/kysely"
|
|
135
|
-
},
|
|
136
|
-
"optional": false,
|
|
137
|
-
"collection": false,
|
|
138
|
-
"sourceLocation": {
|
|
139
|
-
"filePath": "@goodie-ts/kysely",
|
|
140
|
-
"line": 35,
|
|
141
|
-
"column": 15
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
],
|
|
145
|
-
"fieldDeps": [],
|
|
146
|
-
"factoryKind": "constructor",
|
|
147
|
-
"providesSource": null,
|
|
148
|
-
"baseTokenRefs": null,
|
|
149
|
-
"decorators": [
|
|
150
|
-
{
|
|
151
|
-
"name": "Singleton",
|
|
152
|
-
"importPath": "@goodie-ts/kysely"
|
|
153
|
-
}
|
|
154
|
-
],
|
|
155
|
-
"methodDecorators": {
|
|
156
|
-
"init": [
|
|
157
|
-
{
|
|
158
|
-
"name": "PostConstruct",
|
|
159
|
-
"importPath": "@goodie-ts/kysely"
|
|
160
|
-
}
|
|
161
|
-
],
|
|
162
|
-
"destroy": [
|
|
163
|
-
{
|
|
164
|
-
"name": "PreDestroy",
|
|
165
|
-
"importPath": "@goodie-ts/kysely"
|
|
166
|
-
}
|
|
167
|
-
]
|
|
168
|
-
},
|
|
169
|
-
"metadata": {
|
|
170
|
-
"preDestroyMethods": [
|
|
171
|
-
"destroy"
|
|
172
|
-
],
|
|
173
|
-
"postConstructMethods": [
|
|
174
|
-
"init"
|
|
175
|
-
]
|
|
176
|
-
},
|
|
177
|
-
"sourceLocation": {
|
|
178
|
-
"filePath": "@goodie-ts/kysely",
|
|
179
|
-
"line": 31,
|
|
180
|
-
"column": 1
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
]
|
|
184
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Connection pool configuration, bound from `datasource.pool.*` keys.
|
|
3
|
-
*/
|
|
4
|
-
export declare class PoolConfig {
|
|
5
|
-
min: number;
|
|
6
|
-
max: number;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Configuration properties for the datasource, bound from `datasource.*` keys.
|
|
10
|
-
*
|
|
11
|
-
* Users configure via `config/default.json`:
|
|
12
|
-
* ```json
|
|
13
|
-
* {
|
|
14
|
-
* "datasource": {
|
|
15
|
-
* "url": "postgres://localhost:5432/mydb",
|
|
16
|
-
* "dialect": "postgres",
|
|
17
|
-
* "pool": { "min": 2, "max": 10 }
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* Or via environment variables: `DATASOURCE_URL`, `DATASOURCE_DIALECT`, etc.
|
|
23
|
-
*/
|
|
24
|
-
export declare class DatasourceConfig {
|
|
25
|
-
readonly pool: PoolConfig;
|
|
26
|
-
url: string;
|
|
27
|
-
dialect: string;
|
|
28
|
-
constructor(pool: PoolConfig);
|
|
29
|
-
validate(): void;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=datasource-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datasource-config.d.ts","sourceRoot":"","sources":["../src/datasource-config.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,qBAEa,UAAU;IACrB,GAAG,SAAK;IACR,GAAG,SAAM;CACV;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAEa,gBAAgB;IAIf,QAAQ,CAAC,IAAI,EAAE,UAAU;IAHrC,GAAG,SAAM;IACT,OAAO,SAAM;gBAEQ,IAAI,EAAE,UAAU;IAGrC,QAAQ;CAcT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datasource-config.js","sourceRoot":"","sources":["../src/datasource-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;IAGU,UAAU;4BAFtB,SAAS,EAAE,EACX,uBAAuB,CAAC,iBAAiB,CAAC;;;;;;;;YAC3C,6KAGC;;;YAHY,uDAAU;;QACrB,GAAG,GAAG,CAAC,CAAC;QACR,GAAG,GAAG,EAAE,CAAC;;;;SAFE,UAAU;AAKvB;;;;;;;;;;;;;;;GAeG;IAGU,gBAAgB;4BAF5B,SAAS,EAAE,EACX,uBAAuB,CAAC,YAAY,CAAC;;;;;;;;;;oCAOnC,aAAa,EAAE;YAChB,2KAAA,QAAQ,6DAaP;YApBH,6KAqBC;;;YArBY,uDAAgB;;QAIN,IAAI,GAJd,mDAAgB;QAC3B,GAAG,GAAG,EAAE,CAAC;QACT,OAAO,GAAG,EAAE,CAAC;QAEb,YAAqB,IAAgB;YAAhB,SAAI,GAAJ,IAAI,CAAY;QAAG,CAAC;QAGzC,QAAQ;YACN,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,MAAM,IAAI,KAAK,CACb,iGAAiG,CAClG,CAAC;YACJ,CAAC;YACD,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAE9B,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;gBACd,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;YACJ,CAAC;QACH,CAAC;;;;SApBU,gBAAgB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { DatasourceConfig } from './datasource-config.js';
|
|
2
|
-
/**
|
|
3
|
-
* Create a Kysely dialect instance from DatasourceConfig.
|
|
4
|
-
*
|
|
5
|
-
* Dynamically imports the appropriate driver package based on `config.dialect`.
|
|
6
|
-
* The driver packages are optional peer dependencies — users install only what they need.
|
|
7
|
-
*/
|
|
8
|
-
export default function createDialect(config: DatasourceConfig): Promise<import("kysely").PostgresDialect | import("kysely").MysqlDialect | import("kysely").SqliteDialect>;
|
|
9
|
-
//# sourceMappingURL=dialect-factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialect-factory.d.ts","sourceRoot":"","sources":["../src/dialect-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;;;GAKG;AACH,wBAA8B,aAAa,CAAC,MAAM,EAAE,gBAAgB,8GAcnE"}
|
package/dist/dialect-factory.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a Kysely dialect instance from DatasourceConfig.
|
|
3
|
-
*
|
|
4
|
-
* Dynamically imports the appropriate driver package based on `config.dialect`.
|
|
5
|
-
* The driver packages are optional peer dependencies — users install only what they need.
|
|
6
|
-
*/
|
|
7
|
-
export default async function createDialect(config) {
|
|
8
|
-
const dialect = config.dialect;
|
|
9
|
-
switch (dialect) {
|
|
10
|
-
case 'postgres':
|
|
11
|
-
return createPostgresDialect(config);
|
|
12
|
-
case 'mysql':
|
|
13
|
-
return createMysqlDialect(config);
|
|
14
|
-
case 'sqlite':
|
|
15
|
-
return createSqliteDialect(config);
|
|
16
|
-
default:
|
|
17
|
-
throw new Error(`Unsupported dialect: '${dialect}'. Supported dialects: 'postgres', 'mysql', 'sqlite'.`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
async function createPostgresDialect(config) {
|
|
21
|
-
const { Pool } = await import('pg');
|
|
22
|
-
const { PostgresDialect } = await import('kysely');
|
|
23
|
-
return new PostgresDialect({
|
|
24
|
-
pool: new Pool({
|
|
25
|
-
connectionString: config.url,
|
|
26
|
-
min: config.pool.min,
|
|
27
|
-
max: config.pool.max,
|
|
28
|
-
}),
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
async function createMysqlDialect(config) {
|
|
32
|
-
const mysql2 = await import('mysql2/promise');
|
|
33
|
-
const { MysqlDialect } = await import('kysely');
|
|
34
|
-
return new MysqlDialect({
|
|
35
|
-
pool: mysql2.createPool({
|
|
36
|
-
uri: config.url,
|
|
37
|
-
connectionLimit: config.pool.max,
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
async function createSqliteDialect(config) {
|
|
42
|
-
const BetterSqlite3 = await import('better-sqlite3');
|
|
43
|
-
const { SqliteDialect } = await import('kysely');
|
|
44
|
-
return new SqliteDialect({
|
|
45
|
-
database: new BetterSqlite3.default(config.url),
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=dialect-factory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialect-factory.js","sourceRoot":"","sources":["../src/dialect-factory.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CAAC,MAAwB;IAClE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAkB,CAAC;IAC1C,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,UAAU;YACb,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;QACvC,KAAK,OAAO;YACV,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACpC,KAAK,QAAQ;YACX,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACrC;YACE,MAAM,IAAI,KAAK,CACb,yBAAyB,OAAO,uDAAuD,CACxF,CAAC;IACN,CAAC;AACH,CAAC;AAED,KAAK,UAAU,qBAAqB,CAAC,MAAwB;IAC3D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnD,OAAO,IAAI,eAAe,CAAC;QACzB,IAAI,EAAE,IAAI,IAAI,CAAC;YACb,gBAAgB,EAAE,MAAM,CAAC,GAAG;YAC5B,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;YACpB,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;SACrB,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,MAAwB;IACxD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC9C,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChD,OAAO,IAAI,YAAY,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC;YACtB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;SACjC,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,MAAwB;IACzD,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACrD,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjD,OAAO,IAAI,aAAa,CAAC;QACvB,QAAQ,EAAE,IAAI,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC;KAChD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { AbstractMigration } from './abstract-migration.js';
|
|
2
|
-
import type { KyselyProvider } from './transaction-manager.js';
|
|
3
|
-
/**
|
|
4
|
-
* Runs Kysely migrations at application startup.
|
|
5
|
-
*
|
|
6
|
-
* Auto-wired by the Kysely transformer plugin as an eager singleton
|
|
7
|
-
* with `@PostConstruct` on `migrate()`. Constructor receives the
|
|
8
|
-
* KyselyProvider and all discovered @Migration instances.
|
|
9
|
-
*/
|
|
10
|
-
export declare class MigrationRunner {
|
|
11
|
-
private readonly kyselyProvider;
|
|
12
|
-
private readonly migrations;
|
|
13
|
-
constructor(kyselyProvider: KyselyProvider, ...migrations: AbstractMigration[]);
|
|
14
|
-
migrate(): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=migration-runner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration-runner.d.ts","sourceRoot":"","sources":["../src/migration-runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;;;;GAMG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;gBAG/C,cAAc,EAAE,cAAc,EAC9B,GAAG,UAAU,EAAE,iBAAiB,EAAE;IAM9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAgC/B"}
|
package/dist/migration-runner.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Migrator } from 'kysely';
|
|
2
|
-
import { getMigrationName } from './decorators/migration.js';
|
|
3
|
-
/**
|
|
4
|
-
* Runs Kysely migrations at application startup.
|
|
5
|
-
*
|
|
6
|
-
* Auto-wired by the Kysely transformer plugin as an eager singleton
|
|
7
|
-
* with `@PostConstruct` on `migrate()`. Constructor receives the
|
|
8
|
-
* KyselyProvider and all discovered @Migration instances.
|
|
9
|
-
*/
|
|
10
|
-
export class MigrationRunner {
|
|
11
|
-
kyselyProvider;
|
|
12
|
-
migrations;
|
|
13
|
-
constructor(kyselyProvider, ...migrations) {
|
|
14
|
-
this.kyselyProvider = kyselyProvider;
|
|
15
|
-
this.migrations = migrations;
|
|
16
|
-
}
|
|
17
|
-
async migrate() {
|
|
18
|
-
const migrationMap = {};
|
|
19
|
-
for (const m of this.migrations) {
|
|
20
|
-
const name = getMigrationName(m);
|
|
21
|
-
if (!name) {
|
|
22
|
-
throw new Error(`MigrationRunner received an object without @Migration metadata: ${m.constructor.name}`);
|
|
23
|
-
}
|
|
24
|
-
// Kysely's Migrator spreads migration objects (...migration), which
|
|
25
|
-
// drops prototype methods from class instances. Bind explicitly.
|
|
26
|
-
migrationMap[name] = {
|
|
27
|
-
up: m.up.bind(m),
|
|
28
|
-
down: m.down?.bind(m),
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const migrator = new Migrator({
|
|
32
|
-
db: this.kyselyProvider.kysely,
|
|
33
|
-
provider: { getMigrations: async () => migrationMap },
|
|
34
|
-
});
|
|
35
|
-
const { error, results } = await migrator.migrateToLatest();
|
|
36
|
-
for (const r of results ?? []) {
|
|
37
|
-
if (r.status === 'Error') {
|
|
38
|
-
console.error(`Migration "${r.migrationName}" failed`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (error)
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=migration-runner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration-runner.js","sourceRoot":"","sources":["../src/migration-runner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IACT,cAAc,CAAiB;IAC/B,UAAU,CAAsB;IAEjD,YACE,cAA8B,EAC9B,GAAG,UAA+B;QAElC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,YAAY,GAAoC,EAAE,CAAC;QACzD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAChC,MAAM,IAAI,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;YACjC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CACb,mEAAmE,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,CACxF,CAAC;YACJ,CAAC;YACD,oEAAoE;YACpE,iEAAiE;YACjE,YAAY,CAAC,IAAI,CAAC,GAAG;gBACnB,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;gBAChB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;aACtB,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC;YAC5B,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM;YAC9B,QAAQ,EAAE,EAAE,aAAa,EAAE,KAAK,IAAI,EAAE,CAAC,YAAY,EAAE;SACtD,CAAC,CAAC;QAEH,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,eAAe,EAAE,CAAC;QAE5D,KAAK,MAAM,CAAC,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;YAC9B,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,aAAa,UAAU,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAED,IAAI,KAAK;YAAE,MAAM,KAAK,CAAC;IACzB,CAAC;CACF"}
|