@noormdev/sdk 1.0.0-alpha.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/dist/chunk-MERTHCAJ.js +299 -0
- package/dist/chunk-MERTHCAJ.js.map +1 -0
- package/dist/engine-B4JH5RQJ.js +3 -0
- package/dist/engine-B4JH5RQJ.js.map +1 -0
- package/dist/index.d.ts +2083 -0
- package/dist/index.js +8150 -0
- package/dist/index.js.map +1 -0
- package/dist/mssql-T4M7OGEC.js +46 -0
- package/dist/mssql-T4M7OGEC.js.map +1 -0
- package/dist/mysql-C2DR4TF7.js +28 -0
- package/dist/mysql-C2DR4TF7.js.map +1 -0
- package/dist/postgres-SIDJBSIT.js +29 -0
- package/dist/postgres-SIDJBSIT.js.map +1 -0
- package/dist/sqlite-5VZTBN5J.js +21 -0
- package/dist/sqlite-5VZTBN5J.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Kysely, MssqlDialect } from 'kysely';
|
|
2
|
+
|
|
3
|
+
// src/core/connection/dialects/mssql.ts
|
|
4
|
+
async function createMssqlConnection(config) {
|
|
5
|
+
const Tedious = await import('tedious');
|
|
6
|
+
const Tarn = await import('tarn');
|
|
7
|
+
const db = new Kysely({
|
|
8
|
+
dialect: new MssqlDialect({
|
|
9
|
+
tarn: {
|
|
10
|
+
...Tarn,
|
|
11
|
+
options: {
|
|
12
|
+
min: config.pool?.min ?? 0,
|
|
13
|
+
max: config.pool?.max ?? 10
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
tedious: {
|
|
17
|
+
...Tedious,
|
|
18
|
+
connectionFactory: () => new Tedious.Connection({
|
|
19
|
+
server: config.host ?? "localhost",
|
|
20
|
+
authentication: {
|
|
21
|
+
type: "default",
|
|
22
|
+
options: {
|
|
23
|
+
userName: config.user,
|
|
24
|
+
password: config.password
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
options: {
|
|
28
|
+
port: config.port ?? 1433,
|
|
29
|
+
database: config.database,
|
|
30
|
+
trustServerCertificate: !config.ssl,
|
|
31
|
+
encrypt: !!config.ssl
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
db,
|
|
39
|
+
dialect: "mssql",
|
|
40
|
+
destroy: () => db.destroy()
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { createMssqlConnection };
|
|
45
|
+
//# sourceMappingURL=mssql-T4M7OGEC.js.map
|
|
46
|
+
//# sourceMappingURL=mssql-T4M7OGEC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/connection/dialects/mssql.ts"],"names":[],"mappings":";;;AAwBA,eAAsB,sBAAsB,MAAA,EAAqD;AAG7F,EAAA,MAAM,OAAA,GAAU,MAAM,OAAO,SAAS,CAAA;AACtC,EAAA,MAAM,IAAA,GAAO,MAAM,OAAO,MAAM,CAAA;AAEhC,EAAA,MAAM,EAAA,GAAK,IAAI,MAAA,CAAgB;AAAA,IAC3B,OAAA,EAAS,IAAI,YAAA,CAAa;AAAA,MACtB,IAAA,EAAM;AAAA,QACF,GAAG,IAAA;AAAA,QACH,OAAA,EAAS;AAAA,UACL,GAAA,EAAK,MAAA,CAAO,IAAA,EAAM,GAAA,IAAO,CAAA;AAAA,UACzB,GAAA,EAAK,MAAA,CAAO,IAAA,EAAM,GAAA,IAAO;AAAA;AAC7B,OACJ;AAAA,MACA,OAAA,EAAS;AAAA,QACL,GAAG,OAAA;AAAA,QACH,iBAAA,EAAmB,MACf,IAAI,OAAA,CAAQ,UAAA,CAAW;AAAA,UACnB,MAAA,EAAQ,OAAO,IAAA,IAAQ,WAAA;AAAA,UACvB,cAAA,EAAgB;AAAA,YACZ,IAAA,EAAM,SAAA;AAAA,YACN,OAAA,EAAS;AAAA,cACL,UAAU,MAAA,CAAO,IAAA;AAAA,cACjB,UAAU,MAAA,CAAO;AAAA;AACrB,WACJ;AAAA,UACA,OAAA,EAAS;AAAA,YACL,IAAA,EAAM,OAAO,IAAA,IAAQ,IAAA;AAAA,YACrB,UAAU,MAAA,CAAO,QAAA;AAAA,YACjB,sBAAA,EAAwB,CAAC,MAAA,CAAO,GAAA;AAAA,YAChC,OAAA,EAAS,CAAC,CAAC,MAAA,CAAO;AAAA;AACtB,SACH;AAAA;AACT,KACH;AAAA,GACJ,CAAA;AAED,EAAA,OAAO;AAAA,IACH,EAAA;AAAA,IACA,OAAA,EAAS,OAAA;AAAA,IACT,OAAA,EAAS,MAAM,EAAA,CAAG,OAAA;AAAQ,GAC9B;AAEJ","file":"mssql-T4M7OGEC.js","sourcesContent":["/**\n * SQL Server (MSSQL) dialect adapter.\n *\n * Uses 'tedious' and 'tarn' packages for MSSQL connections.\n * Install with: npm install tedious tarn\n */\nimport { Kysely, MssqlDialect } from 'kysely';\nimport type { ConnectionConfig, ConnectionResult } from '../types.js';\n\n/**\n * Create a SQL Server connection.\n *\n * @example\n * ```typescript\n * const conn = createMssqlConnection({\n * dialect: 'mssql',\n * host: 'localhost',\n * port: 1433,\n * database: 'myapp',\n * user: 'sa',\n * password: 'secret',\n * })\n * ```\n */\nexport async function createMssqlConnection(config: ConnectionConfig): Promise<ConnectionResult> {\n\n // Dynamic import to avoid compile-time dependency\n const Tedious = await import('tedious');\n const Tarn = await import('tarn');\n\n const db = new Kysely<unknown>({\n dialect: new MssqlDialect({\n tarn: {\n ...Tarn,\n options: {\n min: config.pool?.min ?? 0,\n max: config.pool?.max ?? 10,\n },\n },\n tedious: {\n ...Tedious,\n connectionFactory: () =>\n new Tedious.Connection({\n server: config.host ?? 'localhost',\n authentication: {\n type: 'default',\n options: {\n userName: config.user,\n password: config.password,\n },\n },\n options: {\n port: config.port ?? 1433,\n database: config.database,\n trustServerCertificate: !config.ssl,\n encrypt: !!config.ssl,\n },\n }),\n },\n }),\n });\n\n return {\n db,\n dialect: 'mssql',\n destroy: () => db.destroy(),\n };\n\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Kysely, MysqlDialect } from 'kysely';
|
|
2
|
+
|
|
3
|
+
// src/core/connection/dialects/mysql.ts
|
|
4
|
+
async function createMysqlConnection(config) {
|
|
5
|
+
const mysql2 = await import('mysql2');
|
|
6
|
+
const createPool = mysql2.default?.createPool ?? mysql2.createPool;
|
|
7
|
+
const pool = createPool({
|
|
8
|
+
host: config.host ?? "localhost",
|
|
9
|
+
port: config.port ?? 3306,
|
|
10
|
+
user: config.user,
|
|
11
|
+
password: config.password,
|
|
12
|
+
database: config.database,
|
|
13
|
+
connectionLimit: config.pool?.max ?? 10,
|
|
14
|
+
ssl: config.ssl ? {} : void 0
|
|
15
|
+
});
|
|
16
|
+
const db = new Kysely({
|
|
17
|
+
dialect: new MysqlDialect({ pool })
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
db,
|
|
21
|
+
dialect: "mysql",
|
|
22
|
+
destroy: () => db.destroy()
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { createMysqlConnection };
|
|
27
|
+
//# sourceMappingURL=mysql-C2DR4TF7.js.map
|
|
28
|
+
//# sourceMappingURL=mysql-C2DR4TF7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/connection/dialects/mysql.ts"],"names":[],"mappings":";;;AAwBA,eAAsB,sBAAsB,MAAA,EAAqD;AAG7F,EAAA,MAAM,MAAA,GAAS,MAAM,OAAO,QAAQ,CAAA;AACpC,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,OAAA,EAAS,UAAA,IAAc,MAAA,CAAO,UAAA;AAExD,EAAA,MAAM,OAAO,UAAA,CAAW;AAAA,IACpB,IAAA,EAAM,OAAO,IAAA,IAAQ,WAAA;AAAA,IACrB,IAAA,EAAM,OAAO,IAAA,IAAQ,IAAA;AAAA,IACrB,MAAM,MAAA,CAAO,IAAA;AAAA,IACb,UAAU,MAAA,CAAO,QAAA;AAAA,IACjB,UAAU,MAAA,CAAO,QAAA;AAAA,IACjB,eAAA,EAAiB,MAAA,CAAO,IAAA,EAAM,GAAA,IAAO,EAAA;AAAA,IACrC,GAAA,EAAK,MAAA,CAAO,GAAA,GAAM,EAAC,GAAI;AAAA,GAC1B,CAAA;AAED,EAAA,MAAM,EAAA,GAAK,IAAI,MAAA,CAAgB;AAAA,IAC3B,OAAA,EAAS,IAAI,YAAA,CAAa,EAAE,MAAM;AAAA,GACrC,CAAA;AAED,EAAA,OAAO;AAAA,IACH,EAAA;AAAA,IACA,OAAA,EAAS,OAAA;AAAA,IACT,OAAA,EAAS,MAAM,EAAA,CAAG,OAAA;AAAQ,GAC9B;AAEJ","file":"mysql-C2DR4TF7.js","sourcesContent":["/**\n * MySQL dialect adapter.\n *\n * Uses the 'mysql2' package for MySQL connections.\n * Install with: npm install mysql2\n */\nimport { Kysely, MysqlDialect } from 'kysely';\nimport type { ConnectionConfig, ConnectionResult } from '../types.js';\n\n/**\n * Create a MySQL connection.\n *\n * @example\n * ```typescript\n * const conn = createMysqlConnection({\n * dialect: 'mysql',\n * host: 'localhost',\n * port: 3306,\n * database: 'myapp',\n * user: 'root',\n * password: 'secret',\n * })\n * ```\n */\nexport async function createMysqlConnection(config: ConnectionConfig): Promise<ConnectionResult> {\n\n // Dynamic import to avoid compile-time dependency\n const mysql2 = await import('mysql2');\n const createPool = mysql2.default?.createPool ?? mysql2.createPool;\n\n const pool = createPool({\n host: config.host ?? 'localhost',\n port: config.port ?? 3306,\n user: config.user,\n password: config.password,\n database: config.database,\n connectionLimit: config.pool?.max ?? 10,\n ssl: config.ssl ? {} : undefined,\n });\n\n const db = new Kysely<unknown>({\n dialect: new MysqlDialect({ pool }),\n });\n\n return {\n db,\n dialect: 'mysql',\n destroy: () => db.destroy(),\n };\n\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Kysely, PostgresDialect } from 'kysely';
|
|
2
|
+
|
|
3
|
+
// src/core/connection/dialects/postgres.ts
|
|
4
|
+
async function createPostgresConnection(config) {
|
|
5
|
+
const pg = await import('pg');
|
|
6
|
+
const Pool = pg.default?.Pool ?? pg.Pool;
|
|
7
|
+
const pool = new Pool({
|
|
8
|
+
host: config.host ?? "localhost",
|
|
9
|
+
port: config.port ?? 5432,
|
|
10
|
+
user: config.user,
|
|
11
|
+
password: config.password,
|
|
12
|
+
database: config.database,
|
|
13
|
+
min: config.pool?.min ?? 0,
|
|
14
|
+
max: config.pool?.max ?? 10,
|
|
15
|
+
ssl: config.ssl
|
|
16
|
+
});
|
|
17
|
+
const db = new Kysely({
|
|
18
|
+
dialect: new PostgresDialect({ pool })
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
db,
|
|
22
|
+
dialect: "postgres",
|
|
23
|
+
destroy: () => db.destroy()
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { createPostgresConnection };
|
|
28
|
+
//# sourceMappingURL=postgres-SIDJBSIT.js.map
|
|
29
|
+
//# sourceMappingURL=postgres-SIDJBSIT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/connection/dialects/postgres.ts"],"names":[],"mappings":";;;AAwBA,eAAsB,yBAClB,MAAA,EACyB;AAGzB,EAAA,MAAM,EAAA,GAAK,MAAM,OAAO,IAAI,CAAA;AAC5B,EAAA,MAAM,IAAA,GAAO,EAAA,CAAG,OAAA,EAAS,IAAA,IAAQ,EAAA,CAAG,IAAA;AAEpC,EAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK;AAAA,IAClB,IAAA,EAAM,OAAO,IAAA,IAAQ,WAAA;AAAA,IACrB,IAAA,EAAM,OAAO,IAAA,IAAQ,IAAA;AAAA,IACrB,MAAM,MAAA,CAAO,IAAA;AAAA,IACb,UAAU,MAAA,CAAO,QAAA;AAAA,IACjB,UAAU,MAAA,CAAO,QAAA;AAAA,IACjB,GAAA,EAAK,MAAA,CAAO,IAAA,EAAM,GAAA,IAAO,CAAA;AAAA,IACzB,GAAA,EAAK,MAAA,CAAO,IAAA,EAAM,GAAA,IAAO,EAAA;AAAA,IACzB,KAAK,MAAA,CAAO;AAAA,GACf,CAAA;AAED,EAAA,MAAM,EAAA,GAAK,IAAI,MAAA,CAAgB;AAAA,IAC3B,OAAA,EAAS,IAAI,eAAA,CAAgB,EAAE,MAAM;AAAA,GACxC,CAAA;AAED,EAAA,OAAO;AAAA,IACH,EAAA;AAAA,IACA,OAAA,EAAS,UAAA;AAAA,IACT,OAAA,EAAS,MAAM,EAAA,CAAG,OAAA;AAAQ,GAC9B;AAEJ","file":"postgres-SIDJBSIT.js","sourcesContent":["/**\n * PostgreSQL dialect adapter.\n *\n * Uses the 'pg' package for PostgreSQL connections.\n * Install with: npm install pg @types/pg\n */\nimport { Kysely, PostgresDialect } from 'kysely';\nimport type { ConnectionConfig, ConnectionResult } from '../types.js';\n\n/**\n * Create a PostgreSQL connection.\n *\n * @example\n * ```typescript\n * const conn = createPostgresConnection({\n * dialect: 'postgres',\n * host: 'localhost',\n * port: 5432,\n * database: 'myapp',\n * user: 'postgres',\n * password: 'secret',\n * })\n * ```\n */\nexport async function createPostgresConnection(\n config: ConnectionConfig,\n): Promise<ConnectionResult> {\n\n // Dynamic import to avoid compile-time dependency\n const pg = await import('pg');\n const Pool = pg.default?.Pool ?? pg.Pool;\n\n const pool = new Pool({\n host: config.host ?? 'localhost',\n port: config.port ?? 5432,\n user: config.user,\n password: config.password,\n database: config.database,\n min: config.pool?.min ?? 0,\n max: config.pool?.max ?? 10,\n ssl: config.ssl,\n });\n\n const db = new Kysely<unknown>({\n dialect: new PostgresDialect({ pool }),\n });\n\n return {\n db,\n dialect: 'postgres',\n destroy: () => db.destroy(),\n };\n\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Kysely, SqliteDialect } from 'kysely';
|
|
2
|
+
import Database from 'better-sqlite3';
|
|
3
|
+
|
|
4
|
+
// src/core/connection/dialects/sqlite.ts
|
|
5
|
+
function createSqliteConnection(config) {
|
|
6
|
+
const filename = config.filename ?? config.database;
|
|
7
|
+
const db = new Kysely({
|
|
8
|
+
dialect: new SqliteDialect({
|
|
9
|
+
database: new Database(filename)
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
db,
|
|
14
|
+
dialect: "sqlite",
|
|
15
|
+
destroy: () => db.destroy()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { createSqliteConnection };
|
|
20
|
+
//# sourceMappingURL=sqlite-5VZTBN5J.js.map
|
|
21
|
+
//# sourceMappingURL=sqlite-5VZTBN5J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/connection/dialects/sqlite.ts"],"names":[],"mappings":";;;;AAsBO,SAAS,uBAAuB,MAAA,EAA4C;AAE/E,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,QAAA;AAE3C,EAAA,MAAM,EAAA,GAAK,IAAI,MAAA,CAAgB;AAAA,IAC3B,OAAA,EAAS,IAAI,aAAA,CAAc;AAAA,MACvB,QAAA,EAAU,IAAI,QAAA,CAAS,QAAQ;AAAA,KAClC;AAAA,GACJ,CAAA;AAED,EAAA,OAAO;AAAA,IACH,EAAA;AAAA,IACA,OAAA,EAAS,QAAA;AAAA,IACT,OAAA,EAAS,MAAM,EAAA,CAAG,OAAA;AAAQ,GAC9B;AAEJ","file":"sqlite-5VZTBN5J.js","sourcesContent":["/**\n * SQLite dialect adapter.\n *\n * Uses better-sqlite3 for synchronous, fast SQLite access.\n * Great for local development and testing.\n */\nimport { Kysely, SqliteDialect } from 'kysely';\nimport Database from 'better-sqlite3';\nimport type { ConnectionConfig, ConnectionResult } from '../types.js';\n\n/**\n * Create a SQLite connection.\n *\n * @example\n * ```typescript\n * // In-memory database\n * const conn = createSqliteConnection({ dialect: 'sqlite', database: ':memory:' })\n *\n * // File-based database\n * const conn = createSqliteConnection({ dialect: 'sqlite', database: './data.db' })\n * ```\n */\nexport function createSqliteConnection(config: ConnectionConfig): ConnectionResult {\n\n const filename = config.filename ?? config.database;\n\n const db = new Kysely<unknown>({\n dialect: new SqliteDialect({\n database: new Database(filename),\n }),\n });\n\n return {\n db,\n dialect: 'sqlite',\n destroy: () => db.destroy(),\n };\n\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@noormdev/sdk",
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
|
+
"description": "Database schema & changeset manager SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"kysely": "^0.28.0",
|
|
21
|
+
"better-sqlite3": "^12.0.0",
|
|
22
|
+
"pg": "^8.0.0",
|
|
23
|
+
"mysql2": "^3.0.0",
|
|
24
|
+
"tedious": "^19.2.0",
|
|
25
|
+
"tarn": "^3.0.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependenciesMeta": {
|
|
28
|
+
"better-sqlite3": {
|
|
29
|
+
"optional": true
|
|
30
|
+
},
|
|
31
|
+
"pg": {
|
|
32
|
+
"optional": true
|
|
33
|
+
},
|
|
34
|
+
"mysql2": {
|
|
35
|
+
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"tedious": {
|
|
38
|
+
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"tarn": {
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"database",
|
|
49
|
+
"schema",
|
|
50
|
+
"migrations",
|
|
51
|
+
"sdk",
|
|
52
|
+
"kysely",
|
|
53
|
+
"noorm"
|
|
54
|
+
],
|
|
55
|
+
"license": "ISC"
|
|
56
|
+
}
|