@goodie-ts/kysely 0.7.0 → 1.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 +16 -0
- package/dist/beans.json +963 -17
- 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 +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/kysely-database.d.ts +10 -17
- package/dist/kysely-database.d.ts.map +1 -1
- package/dist/kysely-database.js +5 -85
- package/dist/kysely-database.js.map +1 -1
- package/dist/kysely-transformer-plugin.d.ts.map +1 -1
- package/dist/kysely-transformer-plugin.js +15 -10
- package/dist/kysely-transformer-plugin.js.map +1 -1
- 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 +6 -8
- package/dist/transaction-manager.d.ts.map +1 -1
- package/dist/transaction-manager.js +13 -16
- package/dist/transaction-manager.js.map +1 -1
- package/package.json +22 -7
- 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/dialect.d.ts
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Supported database dialects.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* like `RETURNING` clause support.
|
|
4
|
+
* Each dialect has a corresponding `KyselyDatabase` subclass that is
|
|
5
|
+
* conditionally activated based on `datasource.dialect` config.
|
|
7
6
|
*/
|
|
8
|
-
export type Dialect = 'postgres' | 'mysql' | 'sqlite';
|
|
9
|
-
/** All valid dialect values.
|
|
7
|
+
export type Dialect = 'postgres' | 'mysql' | 'sqlite' | 'neon' | 'planetscale' | 'libsql' | 'd1';
|
|
8
|
+
/** All valid dialect values. */
|
|
10
9
|
export declare const DIALECTS: readonly Dialect[];
|
|
11
|
-
/**
|
|
12
|
-
* Whether the given dialect supports `RETURNING` clauses natively.
|
|
13
|
-
*
|
|
14
|
-
* - **postgres**: `INSERT/UPDATE/DELETE ... RETURNING *`
|
|
15
|
-
* - **sqlite**: `INSERT/UPDATE/DELETE ... RETURNING *` (since 3.35)
|
|
16
|
-
* - **mysql**: No native support — falls back to INSERT + SELECT
|
|
17
|
-
*/
|
|
18
|
-
export declare function supportsReturning(dialect: Dialect): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Validate that a string is a supported dialect.
|
|
21
|
-
* Throws at DI startup if the user provides an unsupported value.
|
|
22
|
-
*/
|
|
23
|
-
export declare function validateDialect(value: string): Dialect;
|
|
24
10
|
//# sourceMappingURL=dialect.d.ts.map
|
package/dist/dialect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialect.d.ts","sourceRoot":"","sources":["../src/dialect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dialect.d.ts","sourceRoot":"","sources":["../src/dialect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GACf,UAAU,GACV,OAAO,GACP,QAAQ,GACR,MAAM,GACN,aAAa,GACb,QAAQ,GACR,IAAI,CAAC;AAET,gCAAgC;AAChC,eAAO,MAAM,QAAQ,EAAE,SAAS,OAAO,EAQ7B,CAAC"}
|
package/dist/dialect.js
CHANGED
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
/** All valid dialect values.
|
|
1
|
+
/** All valid dialect values. */
|
|
2
2
|
export const DIALECTS = [
|
|
3
3
|
'postgres',
|
|
4
4
|
'mysql',
|
|
5
5
|
'sqlite',
|
|
6
|
+
'neon',
|
|
7
|
+
'planetscale',
|
|
8
|
+
'libsql',
|
|
9
|
+
'd1',
|
|
6
10
|
];
|
|
7
|
-
/**
|
|
8
|
-
* Whether the given dialect supports `RETURNING` clauses natively.
|
|
9
|
-
*
|
|
10
|
-
* - **postgres**: `INSERT/UPDATE/DELETE ... RETURNING *`
|
|
11
|
-
* - **sqlite**: `INSERT/UPDATE/DELETE ... RETURNING *` (since 3.35)
|
|
12
|
-
* - **mysql**: No native support — falls back to INSERT + SELECT
|
|
13
|
-
*/
|
|
14
|
-
export function supportsReturning(dialect) {
|
|
15
|
-
switch (dialect) {
|
|
16
|
-
case 'postgres':
|
|
17
|
-
case 'sqlite':
|
|
18
|
-
return true;
|
|
19
|
-
case 'mysql':
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Validate that a string is a supported dialect.
|
|
25
|
-
* Throws at DI startup if the user provides an unsupported value.
|
|
26
|
-
*/
|
|
27
|
-
export function validateDialect(value) {
|
|
28
|
-
if (DIALECTS.includes(value)) {
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
throw new Error(`Unsupported datasource dialect: '${value}'. Supported dialects: ${DIALECTS.join(', ')}`);
|
|
32
|
-
}
|
|
33
11
|
//# sourceMappingURL=dialect.js.map
|
package/dist/dialect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialect.js","sourceRoot":"","sources":["../src/dialect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialect.js","sourceRoot":"","sources":["../src/dialect.ts"],"names":[],"mappings":"AAeA,gCAAgC;AAChC,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,UAAU;IACV,OAAO;IACP,QAAQ;IACR,MAAM;IACN,aAAa;IACb,QAAQ;IACR,IAAI;CACI,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { KyselyDatabase } from '../kysely-database.js';
|
|
3
|
+
export declare class D1DatasourceConfig {
|
|
4
|
+
dialect: string;
|
|
5
|
+
/** The Cloudflare D1 binding name (default: `'DB'`). */
|
|
6
|
+
binding: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Request-scoped KyselyDatabase for Cloudflare D1.
|
|
10
|
+
*
|
|
11
|
+
* Each request gets a fresh Kysely instance backed by the D1 binding
|
|
12
|
+
* from the request's env (passed via `RequestScopeManager.run(fn, env)`).
|
|
13
|
+
*/
|
|
14
|
+
export declare class D1KyselyDatabase extends KyselyDatabase {
|
|
15
|
+
private readonly config;
|
|
16
|
+
private _kysely?;
|
|
17
|
+
constructor(config: D1DatasourceConfig);
|
|
18
|
+
get kysely(): Kysely<any>;
|
|
19
|
+
/** D1 is SQLite-based, which supports RETURNING since version 3.35.0. */
|
|
20
|
+
get supportsReturning(): boolean;
|
|
21
|
+
init(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=d1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d1.d.ts","sourceRoot":"","sources":["../../src/dialects/d1.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,qBAGa,kBAAkB;IAC7B,OAAO,SAAM;IACb,wDAAwD;IACxD,OAAO,SAAQ;CAChB;AAED;;;;;GAKG;AACH,qBAEa,gBAAiB,SAAQ,cAAc;IAGtC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,OAAO,CAAC,CAAc;gBAED,MAAM,EAAE,kBAAkB;IAIvD,IAAI,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,CAOxB;IAED,yEAAyE;IACzE,IAAI,iBAAiB,IAAI,OAAO,CAE/B;IAGK,IAAI;CAeX"}
|
|
@@ -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, ConfigurationProperties, PostConstruct, RequestScoped, RequestScopeManager, Singleton, } from '@goodie-ts/core';
|
|
36
|
+
import { KyselyDatabase } from '../kysely-database.js';
|
|
37
|
+
let D1DatasourceConfig = (() => {
|
|
38
|
+
let _classDecorators = [Singleton(), ConfigurationProperties('datasource'), ConditionalOnProperty('datasource.dialect', { havingValue: 'd1' })];
|
|
39
|
+
let _classDescriptor;
|
|
40
|
+
let _classExtraInitializers = [];
|
|
41
|
+
let _classThis;
|
|
42
|
+
var D1DatasourceConfig = 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
|
+
D1DatasourceConfig = _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
|
+
/** The Cloudflare D1 binding name (default: `'DB'`). */
|
|
53
|
+
binding = 'DB';
|
|
54
|
+
};
|
|
55
|
+
return D1DatasourceConfig = _classThis;
|
|
56
|
+
})();
|
|
57
|
+
export { D1DatasourceConfig };
|
|
58
|
+
/**
|
|
59
|
+
* Request-scoped KyselyDatabase for Cloudflare D1.
|
|
60
|
+
*
|
|
61
|
+
* Each request gets a fresh Kysely instance backed by the D1 binding
|
|
62
|
+
* from the request's env (passed via `RequestScopeManager.run(fn, env)`).
|
|
63
|
+
*/
|
|
64
|
+
let D1KyselyDatabase = (() => {
|
|
65
|
+
let _classDecorators = [RequestScoped(), ConditionalOnProperty('datasource.dialect', { havingValue: 'd1' })];
|
|
66
|
+
let _classDescriptor;
|
|
67
|
+
let _classExtraInitializers = [];
|
|
68
|
+
let _classThis;
|
|
69
|
+
let _classSuper = KyselyDatabase;
|
|
70
|
+
let _instanceExtraInitializers = [];
|
|
71
|
+
let _init_decorators;
|
|
72
|
+
var D1KyselyDatabase = class extends _classSuper {
|
|
73
|
+
static { _classThis = this; }
|
|
74
|
+
static {
|
|
75
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
76
|
+
_init_decorators = [PostConstruct()];
|
|
77
|
+
__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);
|
|
78
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
79
|
+
D1KyselyDatabase = _classThis = _classDescriptor.value;
|
|
80
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
81
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
82
|
+
}
|
|
83
|
+
config = __runInitializers(this, _instanceExtraInitializers);
|
|
84
|
+
_kysely;
|
|
85
|
+
constructor(config) {
|
|
86
|
+
super();
|
|
87
|
+
this.config = config;
|
|
88
|
+
}
|
|
89
|
+
get kysely() {
|
|
90
|
+
if (!this._kysely) {
|
|
91
|
+
throw new Error('D1KyselyDatabase: not initialized. Wait for @PostConstruct to complete.');
|
|
92
|
+
}
|
|
93
|
+
return this._kysely;
|
|
94
|
+
}
|
|
95
|
+
/** D1 is SQLite-based, which supports RETURNING since version 3.35.0. */
|
|
96
|
+
get supportsReturning() {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
async init() {
|
|
100
|
+
const d1 = RequestScopeManager.getBinding(this.config.binding);
|
|
101
|
+
try {
|
|
102
|
+
const { Kysely: KyselyCtor } = await importOptional('kysely');
|
|
103
|
+
const { D1Dialect } = await importOptional('kysely-d1');
|
|
104
|
+
this._kysely = new KyselyCtor({
|
|
105
|
+
dialect: new D1Dialect({ database: d1 }),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
throw new Error(`[D1KyselyDatabase] Failed to initialize: ${err instanceof Error ? err.message : err}\n` +
|
|
110
|
+
` Review your 'datasource.*' configuration.`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return D1KyselyDatabase = _classThis;
|
|
115
|
+
})();
|
|
116
|
+
export { D1KyselyDatabase };
|
|
117
|
+
async function importOptional(packageName) {
|
|
118
|
+
try {
|
|
119
|
+
return await import(packageName);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
throw new Error(`D1KyselyDatabase requires '${packageName}' but it is not installed. ` +
|
|
123
|
+
`Install it with your package manager.`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=d1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d1.js","sourceRoot":"","sources":["../../src/dialects/d1.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;IAK1C,kBAAkB;4BAH9B,SAAS,EAAE,EACX,uBAAuB,CAAC,YAAY,CAAC,EACrC,qBAAqB,CAAC,oBAAoB,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;;;;;;;;YACnE,6KAIC;;;YAJY,uDAAkB;;QAC7B,OAAO,GAAG,EAAE,CAAC;QACb,wDAAwD;QACxD,OAAO,GAAG,IAAI,CAAC;;;;SAHJ,kBAAkB;AAM/B;;;;;GAKG;IAGU,gBAAgB;4BAF5B,aAAa,EAAE,EACf,qBAAqB,CAAC,oBAAoB,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;;;;sBAC7B,cAAc;;;gCAAtB,SAAQ,WAAc;;;;gCAqBjD,aAAa,EAAE;YAChB,+JAAM,IA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MAAM,IAAI,KAAK,CACb,8BAA8B,WAAW,6BAA6B;YACpE,uCAAuC,CAC1C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { D1DatasourceConfig, D1KyselyDatabase } from './d1.js';
|
|
2
|
+
export { LibsqlDatasourceConfig, LibsqlKyselyDatabase, } from './libsql.js';
|
|
3
|
+
export { MysqlDatasourceConfig, MysqlKyselyDatabase, } from './mysql.js';
|
|
4
|
+
export { NeonDatasourceConfig, NeonKyselyDatabase } from './neon.js';
|
|
5
|
+
export { PlanetscaleDatasourceConfig, PlanetscaleKyselyDatabase, } from './planetscale.js';
|
|
6
|
+
export { PostgresDatasourceConfig, PostgresKyselyDatabase, } from './postgres.js';
|
|
7
|
+
export { SqliteDatasourceConfig, SqliteKyselyDatabase, } from './sqlite.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dialects/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { D1DatasourceConfig, D1KyselyDatabase } from './d1.js';
|
|
2
|
+
export { LibsqlDatasourceConfig, LibsqlKyselyDatabase, } from './libsql.js';
|
|
3
|
+
export { MysqlDatasourceConfig, MysqlKyselyDatabase, } from './mysql.js';
|
|
4
|
+
export { NeonDatasourceConfig, NeonKyselyDatabase } from './neon.js';
|
|
5
|
+
export { PlanetscaleDatasourceConfig, PlanetscaleKyselyDatabase, } from './planetscale.js';
|
|
6
|
+
export { PostgresDatasourceConfig, PostgresKyselyDatabase, } from './postgres.js';
|
|
7
|
+
export { SqliteDatasourceConfig, SqliteKyselyDatabase, } from './sqlite.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dialects/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { KyselyDatabase } from '../kysely-database.js';
|
|
3
|
+
export declare class LibsqlDatasourceConfig {
|
|
4
|
+
dialect: string;
|
|
5
|
+
/** LibSQL/Turso URL (e.g. `libsql://your-db.turso.io`). */
|
|
6
|
+
url: string;
|
|
7
|
+
/** Authentication token for Turso. */
|
|
8
|
+
authToken: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class LibsqlKyselyDatabase extends KyselyDatabase {
|
|
11
|
+
private readonly config;
|
|
12
|
+
private _kysely?;
|
|
13
|
+
constructor(config: LibsqlDatasourceConfig);
|
|
14
|
+
get kysely(): Kysely<any>;
|
|
15
|
+
get supportsReturning(): boolean;
|
|
16
|
+
init(): Promise<void>;
|
|
17
|
+
destroy(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=libsql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libsql.d.ts","sourceRoot":"","sources":["../../src/dialects/libsql.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,qBAGa,sBAAsB;IACjC,OAAO,SAAM;IACb,2DAA2D;IAC3D,GAAG,SAAM;IACT,sCAAsC;IACtC,SAAS,SAAM;CAChB;AAED,qBAEa,oBAAqB,SAAQ,cAAc;IAG1C,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,OAAO,CAAC,CAAc;gBAED,MAAM,EAAE,sBAAsB;IAI3D,IAAI,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,CAOxB;IAED,IAAI,iBAAiB,IAAI,OAAO,CAE/B;IAGK,IAAI;IAmBJ,OAAO;CAGd"}
|
|
@@ -0,0 +1,129 @@
|
|
|
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, ConfigurationProperties, PostConstruct, PreDestroy, Singleton, } from '@goodie-ts/core';
|
|
36
|
+
import { KyselyDatabase } from '../kysely-database.js';
|
|
37
|
+
let LibsqlDatasourceConfig = (() => {
|
|
38
|
+
let _classDecorators = [Singleton(), ConfigurationProperties('datasource'), ConditionalOnProperty('datasource.dialect', { havingValue: 'libsql' })];
|
|
39
|
+
let _classDescriptor;
|
|
40
|
+
let _classExtraInitializers = [];
|
|
41
|
+
let _classThis;
|
|
42
|
+
var LibsqlDatasourceConfig = 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
|
+
LibsqlDatasourceConfig = _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
|
+
/** LibSQL/Turso URL (e.g. `libsql://your-db.turso.io`). */
|
|
53
|
+
url = '';
|
|
54
|
+
/** Authentication token for Turso. */
|
|
55
|
+
authToken = '';
|
|
56
|
+
};
|
|
57
|
+
return LibsqlDatasourceConfig = _classThis;
|
|
58
|
+
})();
|
|
59
|
+
export { LibsqlDatasourceConfig };
|
|
60
|
+
let LibsqlKyselyDatabase = (() => {
|
|
61
|
+
let _classDecorators = [Singleton(), ConditionalOnProperty('datasource.dialect', { havingValue: 'libsql' })];
|
|
62
|
+
let _classDescriptor;
|
|
63
|
+
let _classExtraInitializers = [];
|
|
64
|
+
let _classThis;
|
|
65
|
+
let _classSuper = KyselyDatabase;
|
|
66
|
+
let _instanceExtraInitializers = [];
|
|
67
|
+
let _init_decorators;
|
|
68
|
+
let _destroy_decorators;
|
|
69
|
+
var LibsqlKyselyDatabase = class extends _classSuper {
|
|
70
|
+
static { _classThis = this; }
|
|
71
|
+
static {
|
|
72
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? 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
|
+
LibsqlKyselyDatabase = _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
|
+
super();
|
|
86
|
+
this.config = config;
|
|
87
|
+
}
|
|
88
|
+
get kysely() {
|
|
89
|
+
if (!this._kysely) {
|
|
90
|
+
throw new Error('LibsqlKyselyDatabase: not initialized. Wait for @PostConstruct to complete.');
|
|
91
|
+
}
|
|
92
|
+
return this._kysely;
|
|
93
|
+
}
|
|
94
|
+
get supportsReturning() {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
async init() {
|
|
98
|
+
try {
|
|
99
|
+
const mod = await importOptional('@libsql/kysely-libsql');
|
|
100
|
+
const { Kysely: KyselyCtor } = await importOptional('kysely');
|
|
101
|
+
this._kysely = new KyselyCtor({
|
|
102
|
+
dialect: new mod.LibsqlDialect({
|
|
103
|
+
url: this.config.url,
|
|
104
|
+
authToken: this.config.authToken || undefined,
|
|
105
|
+
}),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
throw new Error(`[LibsqlKyselyDatabase] Failed to initialize: ${err instanceof Error ? err.message : err}\n` +
|
|
110
|
+
` Review your 'datasource.*' configuration.`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async destroy() {
|
|
114
|
+
await this._kysely?.destroy();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return LibsqlKyselyDatabase = _classThis;
|
|
118
|
+
})();
|
|
119
|
+
export { LibsqlKyselyDatabase };
|
|
120
|
+
async function importOptional(packageName) {
|
|
121
|
+
try {
|
|
122
|
+
return await import(packageName);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
throw new Error(`LibsqlKyselyDatabase requires '${packageName}' but it is not installed. ` +
|
|
126
|
+
`Install it with your package manager.`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=libsql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libsql.js","sourceRoot":"","sources":["../../src/dialects/libsql.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,aAAa,EACb,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;IAK1C,sBAAsB;4BAHlC,SAAS,EAAE,EACX,uBAAuB,CAAC,YAAY,CAAC,EACrC,qBAAqB,CAAC,oBAAoB,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;;;;;;;;YACvE,6KAMC;;;YANY,uDAAsB;;QACjC,OAAO,GAAG,EAAE,CAAC;QACb,2DAA2D;QAC3D,GAAG,GAAG,EAAE,CAAC;QACT,sCAAsC;QACtC,SAAS,GAAG,EAAE,CAAC;;;;SALJ,sBAAsB;IAUtB,oBAAoB;4BAFhC,SAAS,EAAE,EACX,qBAAqB,CAAC,oBAAoB,EAAE,EAAE,WAAW,EAAE,QA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AAO;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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { KyselyDatabase } from '../kysely-database.js';
|
|
3
|
+
import type { PoolConfig } from '../pool-config.js';
|
|
4
|
+
export declare class MysqlDatasourceConfig {
|
|
5
|
+
dialect: string;
|
|
6
|
+
/** Connection URI (e.g. `mysql://user:pass@localhost:3306/mydb`). */
|
|
7
|
+
url: string;
|
|
8
|
+
host: string;
|
|
9
|
+
port: number;
|
|
10
|
+
database: string;
|
|
11
|
+
user: string;
|
|
12
|
+
password: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class MysqlKyselyDatabase extends KyselyDatabase {
|
|
15
|
+
private readonly config;
|
|
16
|
+
private readonly pool;
|
|
17
|
+
private _kysely?;
|
|
18
|
+
constructor(config: MysqlDatasourceConfig, pool: PoolConfig);
|
|
19
|
+
get kysely(): Kysely<any>;
|
|
20
|
+
get supportsReturning(): boolean;
|
|
21
|
+
init(): Promise<void>;
|
|
22
|
+
destroy(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=mysql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../../src/dialects/mysql.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAGa,qBAAqB;IAChC,OAAO,SAAM;IACb,qEAAqE;IACrE,GAAG,SAAM;IACT,IAAI,SAAM;IACV,IAAI,SAAQ;IACZ,QAAQ,SAAM;IACd,IAAI,SAAM;IACV,QAAQ,SAAM;CACf;AAED,qBAEa,mBAAoB,SAAQ,cAAc;IAInD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,OAAO,CAAC,OAAO,CAAC,CAAc;gBAGX,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE,UAAU;IAKnC,IAAI,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,CAOxB;IAED,IAAI,iBAAiB,IAAI,OAAO,CAE/B;IAGK,IAAI;IA2BJ,OAAO;CAGd"}
|
|
@@ -0,0 +1,141 @@
|
|
|
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, ConfigurationProperties, PostConstruct, PreDestroy, Singleton, } from '@goodie-ts/core';
|
|
36
|
+
import { KyselyDatabase } from '../kysely-database.js';
|
|
37
|
+
let MysqlDatasourceConfig = (() => {
|
|
38
|
+
let _classDecorators = [Singleton(), ConfigurationProperties('datasource'), ConditionalOnProperty('datasource.dialect', { havingValue: 'mysql' })];
|
|
39
|
+
let _classDescriptor;
|
|
40
|
+
let _classExtraInitializers = [];
|
|
41
|
+
let _classThis;
|
|
42
|
+
var MysqlDatasourceConfig = 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
|
+
MysqlDatasourceConfig = _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
|
+
/** Connection URI (e.g. `mysql://user:pass@localhost:3306/mydb`). */
|
|
53
|
+
url = '';
|
|
54
|
+
host = '';
|
|
55
|
+
port = 3306;
|
|
56
|
+
database = '';
|
|
57
|
+
user = '';
|
|
58
|
+
password = '';
|
|
59
|
+
};
|
|
60
|
+
return MysqlDatasourceConfig = _classThis;
|
|
61
|
+
})();
|
|
62
|
+
export { MysqlDatasourceConfig };
|
|
63
|
+
let MysqlKyselyDatabase = (() => {
|
|
64
|
+
let _classDecorators = [Singleton(), ConditionalOnProperty('datasource.dialect', { havingValue: 'mysql' })];
|
|
65
|
+
let _classDescriptor;
|
|
66
|
+
let _classExtraInitializers = [];
|
|
67
|
+
let _classThis;
|
|
68
|
+
let _classSuper = KyselyDatabase;
|
|
69
|
+
let _instanceExtraInitializers = [];
|
|
70
|
+
let _init_decorators;
|
|
71
|
+
let _destroy_decorators;
|
|
72
|
+
var MysqlKyselyDatabase = class extends _classSuper {
|
|
73
|
+
static { _classThis = this; }
|
|
74
|
+
static {
|
|
75
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
76
|
+
_init_decorators = [PostConstruct()];
|
|
77
|
+
_destroy_decorators = [PreDestroy()];
|
|
78
|
+
__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);
|
|
79
|
+
__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);
|
|
80
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
81
|
+
MysqlKyselyDatabase = _classThis = _classDescriptor.value;
|
|
82
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
83
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
84
|
+
}
|
|
85
|
+
config = __runInitializers(this, _instanceExtraInitializers);
|
|
86
|
+
pool;
|
|
87
|
+
_kysely;
|
|
88
|
+
constructor(config, pool) {
|
|
89
|
+
super();
|
|
90
|
+
this.config = config;
|
|
91
|
+
this.pool = pool;
|
|
92
|
+
}
|
|
93
|
+
get kysely() {
|
|
94
|
+
if (!this._kysely) {
|
|
95
|
+
throw new Error('MysqlKyselyDatabase: not initialized. Wait for @PostConstruct to complete.');
|
|
96
|
+
}
|
|
97
|
+
return this._kysely;
|
|
98
|
+
}
|
|
99
|
+
get supportsReturning() {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
async init() {
|
|
103
|
+
try {
|
|
104
|
+
const mysql2 = await importOptional('mysql2/promise');
|
|
105
|
+
const { Kysely: KyselyCtor, MysqlDialect } = await importOptional('kysely');
|
|
106
|
+
this._kysely = new KyselyCtor({
|
|
107
|
+
dialect: new MysqlDialect({
|
|
108
|
+
pool: mysql2.createPool({
|
|
109
|
+
uri: this.config.url || undefined,
|
|
110
|
+
host: this.config.host || undefined,
|
|
111
|
+
port: this.config.port,
|
|
112
|
+
database: this.config.database || undefined,
|
|
113
|
+
user: this.config.user || undefined,
|
|
114
|
+
password: this.config.password || undefined,
|
|
115
|
+
connectionLimit: this.pool.max,
|
|
116
|
+
}),
|
|
117
|
+
}),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
throw new Error(`[MysqlKyselyDatabase] Failed to initialize: ${err instanceof Error ? err.message : err}\n` +
|
|
122
|
+
` Review your 'datasource.*' configuration.`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async destroy() {
|
|
126
|
+
await this._kysely?.destroy();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return MysqlKyselyDatabase = _classThis;
|
|
130
|
+
})();
|
|
131
|
+
export { MysqlKyselyDatabase };
|
|
132
|
+
async function importOptional(packageName) {
|
|
133
|
+
try {
|
|
134
|
+
return await import(packageName);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
throw new Error(`MysqlKyselyDatabase requires '${packageName}' but it is not installed. ` +
|
|
138
|
+
`Install it with your package manager.`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=mysql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql.js","sourceRoot":"","sources":["../../src/dialects/mysql.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,aAAa,EACb,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;IAM1C,qBAAqB;4BAHjC,SAAS,EAAE,EACX,uBAAuB,CAAC,YAAY,CAAC,EACrC,qBAAqB,CAAC,oBAAoB,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;;;;;;;;YACtE,6KASC;;;YATY,uDAAqB;;QAChC,OAAO,GAAG,EAAE,CAAC;QACb,qEAAqE;QACrE,GAAG,GAAG,EAAE,CAAC;QACT,IAAI,GAAG,EAAE,CAAC;QACV,IAAI,GAAG,IAAI,CAAC;QACZ,QAAQ,GAAG,EAAE,CAAC;QACd,IAAI,GAAG,EAAE,CAAC;QACV,QAAQ,GAAG,EAAE,CAAC;;;;SARH,qBAAqB;IAarB,mBAAmB;4BAF/B,SAAS,EAAE,EAC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I,SAAS;4BAC3C,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,SAAS;4BACnC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,SAAS;4BAC3C,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG;yBAC/B,CAAC;qBACH,CAAC;iBACH,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CACb,+CAA+C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI;oBACzF,6CAA6C,CAChD,CAAC;YACJ,CAAC;QACH,CAAC;QAGD,KAAK,CAAC,OAAO;YACX,MAAM,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QAChC,CAAC;;;;SArDU,mBAAmB;AAwDhC,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,iCAAiC,WAAW,6BAA6B;YACvE,uCAAuC,CAC1C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { KyselyDatabase } from '../kysely-database.js';
|
|
3
|
+
export declare class NeonDatasourceConfig {
|
|
4
|
+
dialect: string;
|
|
5
|
+
/** Neon connection string (e.g. `postgres://user:pass@ep-xxx.us-east-2.aws.neon.tech/mydb`). */
|
|
6
|
+
url: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class NeonKyselyDatabase extends KyselyDatabase {
|
|
9
|
+
private readonly config;
|
|
10
|
+
private _kysely?;
|
|
11
|
+
constructor(config: NeonDatasourceConfig);
|
|
12
|
+
get kysely(): Kysely<any>;
|
|
13
|
+
get supportsReturning(): boolean;
|
|
14
|
+
init(): Promise<void>;
|
|
15
|
+
destroy(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=neon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neon.d.ts","sourceRoot":"","sources":["../../src/dialects/neon.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,qBAGa,oBAAoB;IAC/B,OAAO,SAAM;IACb,gGAAgG;IAChG,GAAG,SAAM;CACV;AAED,qBAEa,kBAAmB,SAAQ,cAAc;IAGxC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,OAAO,CAAC,CAAc;gBAED,MAAM,EAAE,oBAAoB;IAIzD,IAAI,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,CAOxB;IAED,IAAI,iBAAiB,IAAI,OAAO,CAE/B;IAGK,IAAI;IAkBJ,OAAO;CAGd"}
|