@arikajs/database 0.0.1
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/LICENSE +21 -0
- package/README.md +333 -0
- package/dist/Connections/MySQLConnection.d.ts +39 -0
- package/dist/Connections/MySQLConnection.d.ts.map +1 -0
- package/dist/Connections/MySQLConnection.js +91 -0
- package/dist/Connections/MySQLConnection.js.map +1 -0
- package/dist/Connections/PostgreSQLConnection.d.ts +39 -0
- package/dist/Connections/PostgreSQLConnection.d.ts.map +1 -0
- package/dist/Connections/PostgreSQLConnection.js +85 -0
- package/dist/Connections/PostgreSQLConnection.js.map +1 -0
- package/dist/Connections/SQLiteConnection.d.ts +51 -0
- package/dist/Connections/SQLiteConnection.d.ts.map +1 -0
- package/dist/Connections/SQLiteConnection.js +111 -0
- package/dist/Connections/SQLiteConnection.js.map +1 -0
- package/dist/Contracts/Database.d.ts +131 -0
- package/dist/Contracts/Database.d.ts.map +1 -0
- package/dist/Contracts/Database.js +3 -0
- package/dist/Contracts/Database.js.map +1 -0
- package/dist/Contracts/Schema.d.ts +124 -0
- package/dist/Contracts/Schema.d.ts.map +1 -0
- package/dist/Contracts/Schema.js +3 -0
- package/dist/Contracts/Schema.js.map +1 -0
- package/dist/Database.d.ts +38 -0
- package/dist/Database.d.ts.map +1 -0
- package/dist/Database.js +55 -0
- package/dist/Database.js.map +1 -0
- package/dist/DatabaseManager.d.ts +36 -0
- package/dist/DatabaseManager.d.ts.map +1 -0
- package/dist/DatabaseManager.js +126 -0
- package/dist/DatabaseManager.js.map +1 -0
- package/dist/Migrations/Migration.d.ts +17 -0
- package/dist/Migrations/Migration.d.ts.map +1 -0
- package/dist/Migrations/Migration.js +10 -0
- package/dist/Migrations/Migration.js.map +1 -0
- package/dist/Migrations/Migrator.d.ts +51 -0
- package/dist/Migrations/Migrator.d.ts.map +1 -0
- package/dist/Migrations/Migrator.js +166 -0
- package/dist/Migrations/Migrator.js.map +1 -0
- package/dist/Model/Model.d.ts +309 -0
- package/dist/Model/Model.d.ts.map +1 -0
- package/dist/Model/Model.js +607 -0
- package/dist/Model/Model.js.map +1 -0
- package/dist/Model/Relations.d.ts +53 -0
- package/dist/Model/Relations.d.ts.map +1 -0
- package/dist/Model/Relations.js +124 -0
- package/dist/Model/Relations.js.map +1 -0
- package/dist/Model/SoftDeletes.d.ts +24 -0
- package/dist/Model/SoftDeletes.d.ts.map +1 -0
- package/dist/Model/SoftDeletes.js +95 -0
- package/dist/Model/SoftDeletes.js.map +1 -0
- package/dist/Query/QueryBuilder.d.ts +94 -0
- package/dist/Query/QueryBuilder.d.ts.map +1 -0
- package/dist/Query/QueryBuilder.js +276 -0
- package/dist/Query/QueryBuilder.js.map +1 -0
- package/dist/Schema/Grammars/Grammar.d.ts +27 -0
- package/dist/Schema/Grammars/Grammar.d.ts.map +1 -0
- package/dist/Schema/Grammars/Grammar.js +25 -0
- package/dist/Schema/Grammars/Grammar.js.map +1 -0
- package/dist/Schema/Grammars/MySQLGrammar.d.ts +13 -0
- package/dist/Schema/Grammars/MySQLGrammar.d.ts.map +1 -0
- package/dist/Schema/Grammars/MySQLGrammar.js +78 -0
- package/dist/Schema/Grammars/MySQLGrammar.js.map +1 -0
- package/dist/Schema/Grammars/PostgreSQLGrammar.d.ts +13 -0
- package/dist/Schema/Grammars/PostgreSQLGrammar.d.ts.map +1 -0
- package/dist/Schema/Grammars/PostgreSQLGrammar.js +57 -0
- package/dist/Schema/Grammars/PostgreSQLGrammar.js.map +1 -0
- package/dist/Schema/Grammars/SQLiteGrammar.d.ts +13 -0
- package/dist/Schema/Grammars/SQLiteGrammar.d.ts.map +1 -0
- package/dist/Schema/Grammars/SQLiteGrammar.js +53 -0
- package/dist/Schema/Grammars/SQLiteGrammar.js.map +1 -0
- package/dist/Schema/Schema.d.ts +120 -0
- package/dist/Schema/Schema.d.ts.map +1 -0
- package/dist/Schema/Schema.js +226 -0
- package/dist/Schema/Schema.js.map +1 -0
- package/dist/Schema/SchemaBuilder.d.ts +24 -0
- package/dist/Schema/SchemaBuilder.d.ts.map +1 -0
- package/dist/Schema/SchemaBuilder.js +49 -0
- package/dist/Schema/SchemaBuilder.js.map +1 -0
- package/dist/Seeders/SeedRunner.d.ts +22 -0
- package/dist/Seeders/SeedRunner.d.ts.map +1 -0
- package/dist/Seeders/SeedRunner.js +72 -0
- package/dist/Seeders/SeedRunner.js.map +1 -0
- package/dist/Seeders/Seeder.d.ts +11 -0
- package/dist/Seeders/Seeder.d.ts.map +1 -0
- package/dist/Seeders/Seeder.js +10 -0
- package/dist/Seeders/Seeder.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Connection } from '../Contracts/Database';
|
|
2
|
+
import { SchemaCallback } from '../Contracts/Schema';
|
|
3
|
+
/**
|
|
4
|
+
* Schema builder for creating and modifying tables
|
|
5
|
+
*/
|
|
6
|
+
export declare class SchemaBuilder {
|
|
7
|
+
private connection;
|
|
8
|
+
private resolvedConnection;
|
|
9
|
+
constructor(connection: Connection | Promise<Connection>);
|
|
10
|
+
private getResolvedConnection;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new table on the schema
|
|
13
|
+
*/
|
|
14
|
+
create(tableName: string, callback: SchemaCallback): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Drop a table from the schema
|
|
17
|
+
*/
|
|
18
|
+
drop(tableName: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Drop a table from the schema if it exists
|
|
21
|
+
*/
|
|
22
|
+
dropIfExists(tableName: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=SchemaBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaBuilder.d.ts","sourceRoot":"","sources":["../../src/Schema/SchemaBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH,qBAAa,aAAa;IAGV,OAAO,CAAC,UAAU;IAF9B,OAAO,CAAC,kBAAkB,CAA2B;gBAEjC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;YAElD,qBAAqB;IAOnC;;OAEG;IACU,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/E;;OAEG;IACU,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnD;;OAEG;IACU,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAM9D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaBuilder = void 0;
|
|
4
|
+
const Schema_1 = require("./Schema");
|
|
5
|
+
/**
|
|
6
|
+
* Schema builder for creating and modifying tables
|
|
7
|
+
*/
|
|
8
|
+
class SchemaBuilder {
|
|
9
|
+
constructor(connection) {
|
|
10
|
+
this.connection = connection;
|
|
11
|
+
this.resolvedConnection = null;
|
|
12
|
+
}
|
|
13
|
+
async getResolvedConnection() {
|
|
14
|
+
if (!this.resolvedConnection) {
|
|
15
|
+
this.resolvedConnection = await this.connection;
|
|
16
|
+
}
|
|
17
|
+
return this.resolvedConnection;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a new table on the schema
|
|
21
|
+
*/
|
|
22
|
+
async create(tableName, callback) {
|
|
23
|
+
const blueprint = Schema_1.Schema.create(tableName, callback);
|
|
24
|
+
const connection = await this.getResolvedConnection();
|
|
25
|
+
const grammar = connection.getSchemaGrammar();
|
|
26
|
+
const sql = grammar.compileCreate(blueprint);
|
|
27
|
+
await connection.query(sql);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Drop a table from the schema
|
|
31
|
+
*/
|
|
32
|
+
async drop(tableName) {
|
|
33
|
+
const connection = await this.getResolvedConnection();
|
|
34
|
+
const grammar = connection.getSchemaGrammar();
|
|
35
|
+
const sql = grammar.compileDrop(tableName);
|
|
36
|
+
await connection.query(sql);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Drop a table from the schema if it exists
|
|
40
|
+
*/
|
|
41
|
+
async dropIfExists(tableName) {
|
|
42
|
+
const connection = await this.getResolvedConnection();
|
|
43
|
+
const grammar = connection.getSchemaGrammar();
|
|
44
|
+
const sql = grammar.compileDropIfExists(tableName);
|
|
45
|
+
await connection.query(sql);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.SchemaBuilder = SchemaBuilder;
|
|
49
|
+
//# sourceMappingURL=SchemaBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaBuilder.js","sourceRoot":"","sources":["../../src/Schema/SchemaBuilder.ts"],"names":[],"mappings":";;;AAGA,qCAAkC;AAElC;;GAEG;AACH,MAAa,aAAa;IAGtB,YAAoB,UAA4C;QAA5C,eAAU,GAAV,UAAU,CAAkC;QAFxD,uBAAkB,GAAsB,IAAI,CAAC;IAEe,CAAC;IAE7D,KAAK,CAAC,qBAAqB;QAC/B,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC3B,IAAI,CAAC,kBAAkB,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,SAAiB,EAAE,QAAwB;QAC3D,MAAM,SAAS,GAAG,eAAM,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACtD,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAC7C,MAAM,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,SAAiB;QAC/B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACtD,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,YAAY,CAAC,SAAiB;QACvC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACtD,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACnD,MAAM,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;CACJ;AA1CD,sCA0CC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DatabaseManager } from '../DatabaseManager';
|
|
2
|
+
/**
|
|
3
|
+
* SeedRunner class for executing database seeders
|
|
4
|
+
*/
|
|
5
|
+
export declare class SeedRunner {
|
|
6
|
+
private db;
|
|
7
|
+
private seedersPath;
|
|
8
|
+
constructor(db: DatabaseManager, seedersPath: string);
|
|
9
|
+
/**
|
|
10
|
+
* Run a specific seeder or all seeders if none specified
|
|
11
|
+
*/
|
|
12
|
+
run(seederName?: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Run a specific seeder
|
|
15
|
+
*/
|
|
16
|
+
private runSeeder;
|
|
17
|
+
/**
|
|
18
|
+
* Get all seeder files in the directory
|
|
19
|
+
*/
|
|
20
|
+
private getSeederFiles;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=SeedRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeedRunner.d.ts","sourceRoot":"","sources":["../../src/Seeders/SeedRunner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AACH,qBAAa,UAAU;IAEf,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,WAAW;gBADX,EAAE,EAAE,eAAe,EACnB,WAAW,EAAE,MAAM;IAG/B;;OAEG;IACU,GAAG,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcpD;;OAEG;YACW,SAAS;IA8BvB;;OAEG;IACH,OAAO,CAAC,cAAc;CAMzB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SeedRunner = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
/**
|
|
10
|
+
* SeedRunner class for executing database seeders
|
|
11
|
+
*/
|
|
12
|
+
class SeedRunner {
|
|
13
|
+
constructor(db, seedersPath) {
|
|
14
|
+
this.db = db;
|
|
15
|
+
this.seedersPath = seedersPath;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Run a specific seeder or all seeders if none specified
|
|
19
|
+
*/
|
|
20
|
+
async run(seederName) {
|
|
21
|
+
if (seederName) {
|
|
22
|
+
await this.runSeeder(seederName);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// Default to DatabaseSeeder if it exists
|
|
26
|
+
const files = this.getSeederFiles();
|
|
27
|
+
if (files.includes('DatabaseSeeder.ts') || files.includes('DatabaseSeeder.js')) {
|
|
28
|
+
await this.runSeeder('DatabaseSeeder');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.log('\x1b[33mNo DatabaseSeeder found. Please specify a seeder name.\x1b[0m');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Run a specific seeder
|
|
37
|
+
*/
|
|
38
|
+
async runSeeder(name) {
|
|
39
|
+
// Remove extension if provided
|
|
40
|
+
const cleanName = name.replace(/\.(ts|js)$/, '');
|
|
41
|
+
const files = this.getSeederFiles();
|
|
42
|
+
const file = files.find(f => f.startsWith(cleanName));
|
|
43
|
+
if (!file) {
|
|
44
|
+
throw new Error(`Seeder "${name}" not found in ${this.seedersPath}`);
|
|
45
|
+
}
|
|
46
|
+
console.log(`\x1b[33mSeeding: ${cleanName}\x1b[0m`);
|
|
47
|
+
const fullPath = path_1.default.resolve(this.seedersPath, file);
|
|
48
|
+
const module = require(fullPath);
|
|
49
|
+
let SeederClass = module.default || module;
|
|
50
|
+
if (typeof SeederClass !== 'function' && typeof SeederClass === 'object') {
|
|
51
|
+
SeederClass = Object.values(SeederClass).find(v => typeof v === 'function');
|
|
52
|
+
}
|
|
53
|
+
if (typeof SeederClass !== 'function') {
|
|
54
|
+
throw new Error(`Seeder ${file} does not export a valid Seeder class.`);
|
|
55
|
+
}
|
|
56
|
+
const seeder = new SeederClass();
|
|
57
|
+
await seeder.run(this.db);
|
|
58
|
+
console.log(`\x1b[32mSeeded: ${cleanName}\x1b[0m`);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get all seeder files in the directory
|
|
62
|
+
*/
|
|
63
|
+
getSeederFiles() {
|
|
64
|
+
if (!fs_1.default.existsSync(this.seedersPath))
|
|
65
|
+
return [];
|
|
66
|
+
return fs_1.default.readdirSync(this.seedersPath)
|
|
67
|
+
.filter(file => (file.endsWith('.ts') || file.endsWith('.js')) && !file.endsWith('.d.ts'))
|
|
68
|
+
.sort();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.SeedRunner = SeedRunner;
|
|
72
|
+
//# sourceMappingURL=SeedRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeedRunner.js","sourceRoot":"","sources":["../../src/Seeders/SeedRunner.ts"],"names":[],"mappings":";;;;;;AACA,4CAAoB;AACpB,gDAAwB;AAGxB;;GAEG;AACH,MAAa,UAAU;IACnB,YACY,EAAmB,EACnB,WAAmB;QADnB,OAAE,GAAF,EAAE,CAAiB;QACnB,gBAAW,GAAX,WAAW,CAAQ;IAC3B,CAAC;IAEL;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,UAAmB;QAChC,IAAI,UAAU,EAAE,CAAC;YACb,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;aAAM,CAAC;YACJ,yCAAyC;YACzC,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBAC7E,MAAM,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,GAAG,CAAC,uEAAuE,CAAC,CAAC;YACzF,CAAC;QACL,CAAC;IACL,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,SAAS,CAAC,IAAY;QAChC,+BAA+B;QAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAEpC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,kBAAkB,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,oBAAoB,SAAS,SAAS,CAAC,CAAC;QAEpD,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEjC,IAAI,WAAW,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC;QAC3C,IAAI,OAAO,WAAW,KAAK,UAAU,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACvE,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC;QAChF,CAAC;QAED,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,wCAAwC,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE1B,OAAO,CAAC,GAAG,CAAC,oBAAoB,SAAS,SAAS,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACK,cAAc;QAClB,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC;YAAE,OAAO,EAAE,CAAC;QAChD,OAAO,YAAE,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC;aAClC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;aACzF,IAAI,EAAE,CAAC;IAChB,CAAC;CACJ;AAjED,gCAiEC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DatabaseManager } from '../DatabaseManager';
|
|
2
|
+
/**
|
|
3
|
+
* Base Seeder class
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class Seeder {
|
|
6
|
+
/**
|
|
7
|
+
* Run the database seeds.
|
|
8
|
+
*/
|
|
9
|
+
abstract run(db: DatabaseManager): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=Seeder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Seeder.d.ts","sourceRoot":"","sources":["../../src/Seeders/Seeder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AACH,8BAAsB,MAAM;IACxB;;OAEG;aACa,GAAG,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Seeder.js","sourceRoot":"","sources":["../../src/Seeders/Seeder.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAsB,MAAM;CAK3B;AALD,wBAKC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { Database } from './Database';
|
|
2
|
+
export { DatabaseManager } from './DatabaseManager';
|
|
3
|
+
export { Database as DB } from './Database';
|
|
4
|
+
export { MySQLConnection } from './Connections/MySQLConnection';
|
|
5
|
+
export { PostgreSQLConnection } from './Connections/PostgreSQLConnection';
|
|
6
|
+
export { SQLiteConnection } from './Connections/SQLiteConnection';
|
|
7
|
+
export { QueryBuilder } from './Query/QueryBuilder';
|
|
8
|
+
export { Model, ModelQueryBuilder } from './Model/Model';
|
|
9
|
+
export { HasOne, HasMany, BelongsTo, BelongsToMany, Relation } from './Model/Relations';
|
|
10
|
+
export { withSoftDeletes, SoftDeletes } from './Model/SoftDeletes';
|
|
11
|
+
export { Schema, TableBlueprint, ColumnDefinition, ForeignKeyDefinition } from './Schema/Schema';
|
|
12
|
+
export { SchemaBuilder } from './Schema/SchemaBuilder';
|
|
13
|
+
export { Migration } from './Migrations/Migration';
|
|
14
|
+
export { Migrator } from './Migrations/Migrator';
|
|
15
|
+
export { Seeder } from './Seeders/Seeder';
|
|
16
|
+
export { SeedRunner } from './Seeders/SeedRunner';
|
|
17
|
+
export type { Connection, ConnectionConfig, DatabaseConfig, QueryBuilder as QueryBuilderInterface, } from './Contracts/Database';
|
|
18
|
+
export type { Blueprint, ColumnDefinition as ColumnDefinitionInterface, ForeignKeyDefinition as ForeignKeyDefinitionInterface, SchemaCallback, } from './Contracts/Schema';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,YAAY,EACR,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,YAAY,IAAI,qBAAqB,GACxC,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACR,SAAS,EACT,gBAAgB,IAAI,yBAAyB,EAC7C,oBAAoB,IAAI,6BAA6B,EACrD,cAAc,GACjB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SeedRunner = exports.Seeder = exports.Migrator = exports.Migration = exports.SchemaBuilder = exports.ForeignKeyDefinition = exports.ColumnDefinition = exports.TableBlueprint = exports.Schema = exports.withSoftDeletes = exports.Relation = exports.BelongsToMany = exports.BelongsTo = exports.HasMany = exports.HasOne = exports.ModelQueryBuilder = exports.Model = exports.QueryBuilder = exports.SQLiteConnection = exports.PostgreSQLConnection = exports.MySQLConnection = exports.DB = exports.DatabaseManager = exports.Database = void 0;
|
|
4
|
+
// Core exports
|
|
5
|
+
var Database_1 = require("./Database");
|
|
6
|
+
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return Database_1.Database; } });
|
|
7
|
+
var DatabaseManager_1 = require("./DatabaseManager");
|
|
8
|
+
Object.defineProperty(exports, "DatabaseManager", { enumerable: true, get: function () { return DatabaseManager_1.DatabaseManager; } });
|
|
9
|
+
// DB Facade alias (for convenience)
|
|
10
|
+
var Database_2 = require("./Database");
|
|
11
|
+
Object.defineProperty(exports, "DB", { enumerable: true, get: function () { return Database_2.Database; } });
|
|
12
|
+
// Connections
|
|
13
|
+
var MySQLConnection_1 = require("./Connections/MySQLConnection");
|
|
14
|
+
Object.defineProperty(exports, "MySQLConnection", { enumerable: true, get: function () { return MySQLConnection_1.MySQLConnection; } });
|
|
15
|
+
var PostgreSQLConnection_1 = require("./Connections/PostgreSQLConnection");
|
|
16
|
+
Object.defineProperty(exports, "PostgreSQLConnection", { enumerable: true, get: function () { return PostgreSQLConnection_1.PostgreSQLConnection; } });
|
|
17
|
+
var SQLiteConnection_1 = require("./Connections/SQLiteConnection");
|
|
18
|
+
Object.defineProperty(exports, "SQLiteConnection", { enumerable: true, get: function () { return SQLiteConnection_1.SQLiteConnection; } });
|
|
19
|
+
// Query Builder
|
|
20
|
+
var QueryBuilder_1 = require("./Query/QueryBuilder");
|
|
21
|
+
Object.defineProperty(exports, "QueryBuilder", { enumerable: true, get: function () { return QueryBuilder_1.QueryBuilder; } });
|
|
22
|
+
// Model
|
|
23
|
+
var Model_1 = require("./Model/Model");
|
|
24
|
+
Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return Model_1.Model; } });
|
|
25
|
+
Object.defineProperty(exports, "ModelQueryBuilder", { enumerable: true, get: function () { return Model_1.ModelQueryBuilder; } });
|
|
26
|
+
var Relations_1 = require("./Model/Relations");
|
|
27
|
+
Object.defineProperty(exports, "HasOne", { enumerable: true, get: function () { return Relations_1.HasOne; } });
|
|
28
|
+
Object.defineProperty(exports, "HasMany", { enumerable: true, get: function () { return Relations_1.HasMany; } });
|
|
29
|
+
Object.defineProperty(exports, "BelongsTo", { enumerable: true, get: function () { return Relations_1.BelongsTo; } });
|
|
30
|
+
Object.defineProperty(exports, "BelongsToMany", { enumerable: true, get: function () { return Relations_1.BelongsToMany; } });
|
|
31
|
+
Object.defineProperty(exports, "Relation", { enumerable: true, get: function () { return Relations_1.Relation; } });
|
|
32
|
+
var SoftDeletes_1 = require("./Model/SoftDeletes");
|
|
33
|
+
Object.defineProperty(exports, "withSoftDeletes", { enumerable: true, get: function () { return SoftDeletes_1.withSoftDeletes; } });
|
|
34
|
+
// Schema
|
|
35
|
+
var Schema_1 = require("./Schema/Schema");
|
|
36
|
+
Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return Schema_1.Schema; } });
|
|
37
|
+
Object.defineProperty(exports, "TableBlueprint", { enumerable: true, get: function () { return Schema_1.TableBlueprint; } });
|
|
38
|
+
Object.defineProperty(exports, "ColumnDefinition", { enumerable: true, get: function () { return Schema_1.ColumnDefinition; } });
|
|
39
|
+
Object.defineProperty(exports, "ForeignKeyDefinition", { enumerable: true, get: function () { return Schema_1.ForeignKeyDefinition; } });
|
|
40
|
+
var SchemaBuilder_1 = require("./Schema/SchemaBuilder");
|
|
41
|
+
Object.defineProperty(exports, "SchemaBuilder", { enumerable: true, get: function () { return SchemaBuilder_1.SchemaBuilder; } });
|
|
42
|
+
// Migrations
|
|
43
|
+
var Migration_1 = require("./Migrations/Migration");
|
|
44
|
+
Object.defineProperty(exports, "Migration", { enumerable: true, get: function () { return Migration_1.Migration; } });
|
|
45
|
+
var Migrator_1 = require("./Migrations/Migrator");
|
|
46
|
+
Object.defineProperty(exports, "Migrator", { enumerable: true, get: function () { return Migrator_1.Migrator; } });
|
|
47
|
+
// Seeders
|
|
48
|
+
var Seeder_1 = require("./Seeders/Seeder");
|
|
49
|
+
Object.defineProperty(exports, "Seeder", { enumerable: true, get: function () { return Seeder_1.Seeder; } });
|
|
50
|
+
var SeedRunner_1 = require("./Seeders/SeedRunner");
|
|
51
|
+
Object.defineProperty(exports, "SeedRunner", { enumerable: true, get: function () { return SeedRunner_1.SeedRunner; } });
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,eAAe;AACf,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AAExB,oCAAoC;AACpC,uCAA4C;AAAnC,8FAAA,QAAQ,OAAM;AAEvB,cAAc;AACd,iEAAgE;AAAvD,kHAAA,eAAe,OAAA;AACxB,2EAA0E;AAAjE,4HAAA,oBAAoB,OAAA;AAC7B,mEAAkE;AAAzD,oHAAA,gBAAgB,OAAA;AAEzB,gBAAgB;AAChB,qDAAoD;AAA3C,4GAAA,YAAY,OAAA;AAErB,QAAQ;AACR,uCAAyD;AAAhD,8FAAA,KAAK,OAAA;AAAE,0GAAA,iBAAiB,OAAA;AACjC,+CAAwF;AAA/E,mGAAA,MAAM,OAAA;AAAE,oGAAA,OAAO,OAAA;AAAE,sGAAA,SAAS,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAC5D,mDAAmE;AAA1D,8GAAA,eAAe,OAAA;AAExB,SAAS;AACT,0CAAiG;AAAxF,gGAAA,MAAM,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAAE,8GAAA,oBAAoB,OAAA;AACvE,wDAAuD;AAA9C,8GAAA,aAAa,OAAA;AAEtB,aAAa;AACb,oDAAmD;AAA1C,sGAAA,SAAS,OAAA;AAClB,kDAAiD;AAAxC,oGAAA,QAAQ,OAAA;AAEjB,UAAU;AACV,2CAA0C;AAAjC,gGAAA,MAAM,OAAA;AACf,mDAAkD;AAAzC,wGAAA,UAAU,OAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arikajs/database",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Database layer for the ArikaJS framework with MySQL & PostgreSQL support.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc -p tsconfig.json",
|
|
10
|
+
"build:tests": "tsc -p tsconfig.test.json",
|
|
11
|
+
"clean": "rm -rf dist",
|
|
12
|
+
"prepare": "echo skip",
|
|
13
|
+
"test": "npm run build && npm run build:tests && node scripts/fix-test-imports.js && node --test 'dist/tests/**/*.test.js'",
|
|
14
|
+
"test:watch": "npm run build && npm run build:tests && node --test --watch 'dist/tests/**/*.test.js'"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"arika",
|
|
21
|
+
"arika-js",
|
|
22
|
+
"database",
|
|
23
|
+
"mysql",
|
|
24
|
+
"postgresql",
|
|
25
|
+
"query-builder",
|
|
26
|
+
"orm",
|
|
27
|
+
"active-record",
|
|
28
|
+
"migrations"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20.0.0"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/arikajs/database.git"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/arikajs/database/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/arikajs/database#readme",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"better-sqlite3": "^11.7.0",
|
|
43
|
+
"mysql2": "^3.11.5",
|
|
44
|
+
"pg": "^8.13.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/better-sqlite3": "^7.6.12",
|
|
48
|
+
"@types/node": "^20.11.24",
|
|
49
|
+
"@types/pg": "^8.11.10",
|
|
50
|
+
"typescript": "^5.3.3"
|
|
51
|
+
},
|
|
52
|
+
"author": "Prakash Tank"
|
|
53
|
+
}
|