@riao/dbal 1.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/CHANGELOG.md +3 -0
- package/LICENSE.md +20 -0
- package/README.md +241 -0
- package/builder/builder.d.ts +41 -0
- package/builder/builder.js +73 -0
- package/builder/builder.js.map +1 -0
- package/builder/index.d.ts +1 -0
- package/builder/index.js +6 -0
- package/builder/index.js.map +1 -0
- package/column/column-options.d.ts +141 -0
- package/column/column-options.js +3 -0
- package/column/column-options.js.map +1 -0
- package/column/column-type.d.ts +17 -0
- package/column/column-type.js +26 -0
- package/column/column-type.js.map +1 -0
- package/column/column-values.d.ts +29 -0
- package/column/column-values.js +3 -0
- package/column/column-values.js.map +1 -0
- package/column/index.d.ts +3 -0
- package/column/index.js +20 -0
- package/column/index.js.map +1 -0
- package/config/configure-db.d.ts +14 -0
- package/config/configure-db.js +19 -0
- package/config/configure-db.js.map +1 -0
- package/config/database-env.d.ts +16 -0
- package/config/database-env.js +15 -0
- package/config/database-env.js.map +1 -0
- package/config/index.d.ts +2 -0
- package/config/index.js +8 -0
- package/config/index.js.map +1 -0
- package/database/connection-options.d.ts +7 -0
- package/database/connection-options.js +3 -0
- package/database/connection-options.js.map +1 -0
- package/database/database.d.ts +185 -0
- package/database/database.js +257 -0
- package/database/database.js.map +1 -0
- package/database/driver-query.d.ts +10 -0
- package/database/driver-query.js +3 -0
- package/database/driver-query.js.map +1 -0
- package/database/driver.d.ts +9 -0
- package/database/driver.js +43 -0
- package/database/driver.js.map +1 -0
- package/database/get-database-path.d.ts +6 -0
- package/database/get-database-path.js +13 -0
- package/database/get-database-path.js.map +1 -0
- package/database/index.d.ts +6 -0
- package/database/index.js +27 -0
- package/database/index.js.map +1 -0
- package/database/load-database.d.ts +9 -0
- package/database/load-database.js +37 -0
- package/database/load-database.js.map +1 -0
- package/ddl/alter-table.d.ts +26 -0
- package/ddl/alter-table.js +3 -0
- package/ddl/alter-table.js.map +1 -0
- package/ddl/create-database.d.ts +3 -0
- package/ddl/create-database.js +3 -0
- package/ddl/create-database.js.map +1 -0
- package/ddl/create-table.d.ts +8 -0
- package/ddl/create-table.js +3 -0
- package/ddl/create-table.js.map +1 -0
- package/ddl/create-user.d.ts +4 -0
- package/ddl/create-user.js +3 -0
- package/ddl/create-user.js.map +1 -0
- package/ddl/ddl-builder.d.ts +68 -0
- package/ddl/ddl-builder.js +358 -0
- package/ddl/ddl-builder.js.map +1 -0
- package/ddl/ddl-repository.d.ts +104 -0
- package/ddl/ddl-repository.js +176 -0
- package/ddl/ddl-repository.js.map +1 -0
- package/ddl/drop-database.d.ts +4 -0
- package/ddl/drop-database.js +3 -0
- package/ddl/drop-database.js.map +1 -0
- package/ddl/drop-table.d.ts +4 -0
- package/ddl/drop-table.js +3 -0
- package/ddl/drop-table.js.map +1 -0
- package/ddl/drop-user.d.ts +4 -0
- package/ddl/drop-user.js +3 -0
- package/ddl/drop-user.js.map +1 -0
- package/ddl/foreign-key-constraint.d.ts +9 -0
- package/ddl/foreign-key-constraint.js +3 -0
- package/ddl/foreign-key-constraint.js.map +1 -0
- package/ddl/grant.d.ts +12 -0
- package/ddl/grant.js +3 -0
- package/ddl/grant.js.map +1 -0
- package/ddl/index.d.ts +12 -0
- package/ddl/index.js +24 -0
- package/ddl/index.js.map +1 -0
- package/ddl/truncate.d.ts +3 -0
- package/ddl/truncate.js +3 -0
- package/ddl/truncate.js.map +1 -0
- package/dml/column-name.d.ts +3 -0
- package/dml/column-name.js +12 -0
- package/dml/column-name.js.map +1 -0
- package/dml/delete.d.ts +8 -0
- package/dml/delete.js +3 -0
- package/dml/delete.js.map +1 -0
- package/dml/index.d.ts +10 -0
- package/dml/index.js +30 -0
- package/dml/index.js.map +1 -0
- package/dml/insert.d.ts +11 -0
- package/dml/insert.js +3 -0
- package/dml/insert.js.map +1 -0
- package/dml/join.d.ts +15 -0
- package/dml/join.js +3 -0
- package/dml/join.js.map +1 -0
- package/dml/order-by.d.ts +2 -0
- package/dml/order-by.js +3 -0
- package/dml/order-by.js.map +1 -0
- package/dml/query-builder.d.ts +53 -0
- package/dml/query-builder.js +398 -0
- package/dml/query-builder.js.map +1 -0
- package/dml/query-repository.d.ts +67 -0
- package/dml/query-repository.js +140 -0
- package/dml/query-repository.js.map +1 -0
- package/dml/select.d.ts +23 -0
- package/dml/select.js +3 -0
- package/dml/select.js.map +1 -0
- package/dml/update.d.ts +9 -0
- package/dml/update.js +3 -0
- package/dml/update.js.map +1 -0
- package/dml/where.d.ts +26 -0
- package/dml/where.js +67 -0
- package/dml/where.js.map +1 -0
- package/functions/function-interface.d.ts +18 -0
- package/functions/function-interface.js +8 -0
- package/functions/function-interface.js.map +1 -0
- package/functions/functions.d.ts +5 -0
- package/functions/functions.js +18 -0
- package/functions/functions.js.map +1 -0
- package/functions/index.d.ts +1 -0
- package/functions/index.js +18 -0
- package/functions/index.js.map +1 -0
- package/index.d.ts +9 -0
- package/index.js +26 -0
- package/index.js.map +1 -0
- package/migration/create-migration-table.d.ts +8 -0
- package/migration/create-migration-table.js +54 -0
- package/migration/create-migration-table.js.map +1 -0
- package/migration/index.d.ts +2 -0
- package/migration/index.js +8 -0
- package/migration/index.js.map +1 -0
- package/migration/migration-record.d.ts +9 -0
- package/migration/migration-record.js +3 -0
- package/migration/migration-record.js.map +1 -0
- package/migration/migration-runner.d.ts +19 -0
- package/migration/migration-runner.js +114 -0
- package/migration/migration-runner.js.map +1 -0
- package/migration/migration.d.ts +11 -0
- package/migration/migration.js +27 -0
- package/migration/migration.js.map +1 -0
- package/package.json +28 -0
- package/record/index.d.ts +1 -0
- package/record/index.js +18 -0
- package/record/index.js.map +1 -0
- package/record/record.d.ts +2 -0
- package/record/record.js +3 -0
- package/record/record.js.map +1 -0
- package/repository/index.d.ts +2 -0
- package/repository/index.js +6 -0
- package/repository/index.js.map +1 -0
- package/repository/repository-options.d.ts +4 -0
- package/repository/repository-options.js +3 -0
- package/repository/repository-options.js.map +1 -0
- package/repository/repository.d.ts +6 -0
- package/repository/repository.js +10 -0
- package/repository/repository.js.map +1 -0
- package/schema/index.d.ts +3 -0
- package/schema/index.js +6 -0
- package/schema/index.js.map +1 -0
- package/schema/schema-query-repository.d.ts +45 -0
- package/schema/schema-query-repository.js +154 -0
- package/schema/schema-query-repository.js.map +1 -0
- package/schema/schema-table.d.ts +9 -0
- package/schema/schema-table.js +3 -0
- package/schema/schema-table.js.map +1 -0
- package/schema/schema.d.ts +4 -0
- package/schema/schema.js +3 -0
- package/schema/schema.js.map +1 -0
- package/seed/auto-seed.d.ts +8 -0
- package/seed/auto-seed.js +58 -0
- package/seed/auto-seed.js.map +1 -0
- package/seed/create-seed-table.d.ts +8 -0
- package/seed/create-seed-table.js +64 -0
- package/seed/create-seed-table.js.map +1 -0
- package/seed/index.d.ts +4 -0
- package/seed/index.js +10 -0
- package/seed/index.js.map +1 -0
- package/seed/seed-record.d.ts +11 -0
- package/seed/seed-record.js +3 -0
- package/seed/seed-record.js.map +1 -0
- package/seed/seed-runner.d.ts +20 -0
- package/seed/seed-runner.js +91 -0
- package/seed/seed-runner.js.map +1 -0
- package/seed/seed.d.ts +12 -0
- package/seed/seed.js +28 -0
- package/seed/seed.js.map +1 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureDb = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const ts_appconfig_1 = require("ts-appconfig");
|
|
6
|
+
/**
|
|
7
|
+
* Load the database's .env
|
|
8
|
+
*
|
|
9
|
+
* @param env Environment Type (must extend DatabaseEnv)
|
|
10
|
+
* @param path Path to env file
|
|
11
|
+
* @param name Database name
|
|
12
|
+
* @param options ts-appconfig options
|
|
13
|
+
* @returns Returns the loaded environment variables
|
|
14
|
+
*/
|
|
15
|
+
function configureDb(env, path, name, options = {}) {
|
|
16
|
+
return (0, ts_appconfig_1.configure)(env, Object.assign({ relativePath: (0, path_1.join)(path, name, `${name}.db.env`), fromProcessEnv: false, overwriteProcessEnv: false }, options));
|
|
17
|
+
}
|
|
18
|
+
exports.configureDb = configureDb;
|
|
19
|
+
//# sourceMappingURL=configure-db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure-db.js","sourceRoot":"","sources":["../../../src/config/configure-db.ts"],"names":[],"mappings":";;;AAAA,+BAAwC;AAExC,+CAA+D;AAG/D;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAC1B,GAAkB,EAClB,IAAY,EACZ,IAAY,EACZ,UAAgC,EAAE;IAElC,OAAoB,IAAA,wBAAS,EAAC,GAAG,kBAChC,YAAY,EAAE,IAAA,WAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,SAAS,CAAC,EACpD,cAAc,EAAE,KAAK,EACrB,mBAAmB,EAAE,KAAK,IACvB,OAAO,EACR,CAAC;AACL,CAAC;AAZD,kCAYC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AppConfig } from 'ts-appconfig';
|
|
2
|
+
import { DatabaseConnectionOptions } from '../database';
|
|
3
|
+
/**
|
|
4
|
+
* Loads & stores the database's configuration.
|
|
5
|
+
*
|
|
6
|
+
* The configuration file should be named `database-name.db.env` and
|
|
7
|
+
* live in the database's folder, i.e. `database/main/main.db.env`.
|
|
8
|
+
* The .env file should be .gitignore'd!
|
|
9
|
+
*/
|
|
10
|
+
export declare class DatabaseEnv extends AppConfig implements DatabaseConnectionOptions {
|
|
11
|
+
readonly host: string;
|
|
12
|
+
readonly port: number;
|
|
13
|
+
readonly username: string;
|
|
14
|
+
readonly password: string;
|
|
15
|
+
readonly database: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseEnv = void 0;
|
|
4
|
+
const ts_appconfig_1 = require("ts-appconfig");
|
|
5
|
+
/**
|
|
6
|
+
* Loads & stores the database's configuration.
|
|
7
|
+
*
|
|
8
|
+
* The configuration file should be named `database-name.db.env` and
|
|
9
|
+
* live in the database's folder, i.e. `database/main/main.db.env`.
|
|
10
|
+
* The .env file should be .gitignore'd!
|
|
11
|
+
*/
|
|
12
|
+
class DatabaseEnv extends ts_appconfig_1.AppConfig {
|
|
13
|
+
}
|
|
14
|
+
exports.DatabaseEnv = DatabaseEnv;
|
|
15
|
+
//# sourceMappingURL=database-env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-env.js","sourceRoot":"","sources":["../../../src/config/database-env.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAGzC;;;;;;GAMG;AACH,MAAa,WACZ,SAAQ,wBAAS;CAOjB;AARD,kCAQC"}
|
package/config/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseEnv = exports.configureDb = void 0;
|
|
4
|
+
var configure_db_1 = require("./configure-db");
|
|
5
|
+
Object.defineProperty(exports, "configureDb", { enumerable: true, get: function () { return configure_db_1.configureDb; } });
|
|
6
|
+
var database_env_1 = require("./database-env");
|
|
7
|
+
Object.defineProperty(exports, "DatabaseEnv", { enumerable: true, get: function () { return database_env_1.DatabaseEnv; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,+CAA6C;AAApC,2GAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-options.js","sourceRoot":"","sources":["../../../src/database/connection-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { DatabaseDriver } from './driver';
|
|
2
|
+
import { DatabaseEnv } from '../config';
|
|
3
|
+
import { DataDefinitionBuilder, DataDefinitionRepository } from '../ddl';
|
|
4
|
+
import { DatabaseConnectionOptions } from './connection-options';
|
|
5
|
+
import { DatabaseRecord } from '../record';
|
|
6
|
+
import { DatabaseQueryBuilder, QueryRepository, QueryRepositoryOptions } from '../dml';
|
|
7
|
+
import { SchemaQueryRepository } from '../schema/schema-query-repository';
|
|
8
|
+
import { Schema } from '../schema';
|
|
9
|
+
import { DatabaseFunctions } from '../functions';
|
|
10
|
+
/**
|
|
11
|
+
* Represents a single database instance, including a driver,
|
|
12
|
+
* configuration, connection, etc.
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class Database {
|
|
15
|
+
/**
|
|
16
|
+
* Database driver class
|
|
17
|
+
*/
|
|
18
|
+
driverType: typeof DatabaseDriver;
|
|
19
|
+
/**
|
|
20
|
+
* Database driver intance
|
|
21
|
+
*/
|
|
22
|
+
driver: DatabaseDriver;
|
|
23
|
+
/**
|
|
24
|
+
* Database configuration class
|
|
25
|
+
*/
|
|
26
|
+
envType: typeof DatabaseEnv;
|
|
27
|
+
/**
|
|
28
|
+
* Database configuration
|
|
29
|
+
*/
|
|
30
|
+
env: DatabaseEnv;
|
|
31
|
+
/**
|
|
32
|
+
* Parent path (database path)
|
|
33
|
+
*/
|
|
34
|
+
databasePath: any;
|
|
35
|
+
/**
|
|
36
|
+
* Database name (must match folder name!)
|
|
37
|
+
*/
|
|
38
|
+
name: any;
|
|
39
|
+
/**
|
|
40
|
+
* Migrations directory, relative to this database
|
|
41
|
+
* e.g. If the migrations are in `database/main/migrations`,
|
|
42
|
+
* set this to `migrations`
|
|
43
|
+
*/
|
|
44
|
+
migrations: string;
|
|
45
|
+
/**
|
|
46
|
+
* Seeds directory, relative to this database
|
|
47
|
+
* e.g. If the seeds are in `database/main/seeds`,
|
|
48
|
+
* set this to `seeds`
|
|
49
|
+
*/
|
|
50
|
+
seeds: string;
|
|
51
|
+
/**
|
|
52
|
+
* Schema storage directory, relative to this database
|
|
53
|
+
* e.g. If the schema is in `database/main/.schema`,
|
|
54
|
+
* set this to `.schema`
|
|
55
|
+
*/
|
|
56
|
+
schemaDirectory: string;
|
|
57
|
+
/**
|
|
58
|
+
* Query builder class type used to create new query builders
|
|
59
|
+
*/
|
|
60
|
+
queryBuilderType: typeof DatabaseQueryBuilder;
|
|
61
|
+
/**
|
|
62
|
+
* Query repository class type used to create new repos
|
|
63
|
+
*/
|
|
64
|
+
queryRepositoryType: typeof QueryRepository;
|
|
65
|
+
/**
|
|
66
|
+
* Query repository
|
|
67
|
+
*/
|
|
68
|
+
query: QueryRepository;
|
|
69
|
+
/**
|
|
70
|
+
* DDL builder class type used to create new builders
|
|
71
|
+
*/
|
|
72
|
+
ddlBuilderType: typeof DataDefinitionBuilder;
|
|
73
|
+
/**
|
|
74
|
+
* DDL repository class type used to create new repos
|
|
75
|
+
*/
|
|
76
|
+
ddlRepositoryType: typeof DataDefinitionRepository;
|
|
77
|
+
/**
|
|
78
|
+
* Data definition repository
|
|
79
|
+
*/
|
|
80
|
+
ddl: DataDefinitionRepository;
|
|
81
|
+
/**
|
|
82
|
+
* Schema Query repository class type used to create new repos
|
|
83
|
+
*/
|
|
84
|
+
schemaQueryRepositoryType: typeof SchemaQueryRepository;
|
|
85
|
+
/**
|
|
86
|
+
* Schema query repository
|
|
87
|
+
*/
|
|
88
|
+
schemaQuery: SchemaQueryRepository;
|
|
89
|
+
/**
|
|
90
|
+
* Database schema
|
|
91
|
+
*/
|
|
92
|
+
protected schema: Schema;
|
|
93
|
+
/**
|
|
94
|
+
* Functions
|
|
95
|
+
*/
|
|
96
|
+
functions: DatabaseFunctions;
|
|
97
|
+
/**
|
|
98
|
+
* Initialize the database
|
|
99
|
+
*
|
|
100
|
+
* @param options Database options
|
|
101
|
+
*/
|
|
102
|
+
init(options?: {
|
|
103
|
+
connectionOptions?: DatabaseConnectionOptions;
|
|
104
|
+
}): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Load the configuration .env
|
|
107
|
+
*/
|
|
108
|
+
configureFromEnv(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Connect to the database
|
|
111
|
+
*/
|
|
112
|
+
connect(): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Disconnect from the database
|
|
115
|
+
*/
|
|
116
|
+
disconnect(): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Get the full relative path to this database's migrations folder
|
|
119
|
+
*
|
|
120
|
+
* @returns Returns the relative file path
|
|
121
|
+
*/
|
|
122
|
+
getMigrationsDirectory(): string;
|
|
123
|
+
/**
|
|
124
|
+
* Get the full relative path to this database's seeds folder
|
|
125
|
+
*
|
|
126
|
+
* @returns Returns the relative file path
|
|
127
|
+
*/
|
|
128
|
+
getSeedsDirectory(): string;
|
|
129
|
+
/**
|
|
130
|
+
* Get the full relative path to this database's schema folder
|
|
131
|
+
*
|
|
132
|
+
* @returns Returns the relative file path
|
|
133
|
+
*/
|
|
134
|
+
getSchemaDirectory(): string;
|
|
135
|
+
/**
|
|
136
|
+
* Get a new DDL builder
|
|
137
|
+
*
|
|
138
|
+
* @returns DDL builder
|
|
139
|
+
*/
|
|
140
|
+
getDataDefinitionBuilder(): DataDefinitionBuilder;
|
|
141
|
+
/**
|
|
142
|
+
* Get a new DDL repository
|
|
143
|
+
*
|
|
144
|
+
* @param options Repository options
|
|
145
|
+
* @returns Returns the DDL repository
|
|
146
|
+
*/
|
|
147
|
+
getDataDefinitionRepository(): DataDefinitionRepository;
|
|
148
|
+
/**
|
|
149
|
+
* Get a new query builder
|
|
150
|
+
*
|
|
151
|
+
* @returns Query builder
|
|
152
|
+
*/
|
|
153
|
+
getQueryBuilder(): DatabaseQueryBuilder;
|
|
154
|
+
/**
|
|
155
|
+
* Get a new query repository
|
|
156
|
+
*
|
|
157
|
+
* @param options Repository options
|
|
158
|
+
* @returns Returns the query repository
|
|
159
|
+
*/
|
|
160
|
+
getQueryRepository<T extends DatabaseRecord = DatabaseRecord>(options?: Omit<QueryRepositoryOptions, 'driver' | 'queryBuilderType'>): QueryRepository<T>;
|
|
161
|
+
/**
|
|
162
|
+
* Get a new schema query repository
|
|
163
|
+
*
|
|
164
|
+
* @returns Schema Query Repository
|
|
165
|
+
*/
|
|
166
|
+
getSchemaQueryRepository(): SchemaQueryRepository;
|
|
167
|
+
/**
|
|
168
|
+
* Build & save the database schema
|
|
169
|
+
*/
|
|
170
|
+
buildSchema(): Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* Save the database schema
|
|
173
|
+
*/
|
|
174
|
+
saveSchema(): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Load the database schema
|
|
177
|
+
*/
|
|
178
|
+
loadSchema(): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Get schema metadata
|
|
181
|
+
*
|
|
182
|
+
* @returns Schema
|
|
183
|
+
*/
|
|
184
|
+
getSchema(): Promise<Schema>;
|
|
185
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Database = void 0;
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const config_1 = require("../config");
|
|
16
|
+
const get_database_path_1 = require("./get-database-path");
|
|
17
|
+
const ddl_1 = require("../ddl");
|
|
18
|
+
const dml_1 = require("../dml");
|
|
19
|
+
const schema_query_repository_1 = require("../schema/schema-query-repository");
|
|
20
|
+
const functions_1 = require("../functions");
|
|
21
|
+
/**
|
|
22
|
+
* Represents a single database instance, including a driver,
|
|
23
|
+
* configuration, connection, etc.
|
|
24
|
+
*/
|
|
25
|
+
class Database {
|
|
26
|
+
constructor() {
|
|
27
|
+
/**
|
|
28
|
+
* Migrations directory, relative to this database
|
|
29
|
+
* e.g. If the migrations are in `database/main/migrations`,
|
|
30
|
+
* set this to `migrations`
|
|
31
|
+
*/
|
|
32
|
+
this.migrations = 'migrations';
|
|
33
|
+
/**
|
|
34
|
+
* Seeds directory, relative to this database
|
|
35
|
+
* e.g. If the seeds are in `database/main/seeds`,
|
|
36
|
+
* set this to `seeds`
|
|
37
|
+
*/
|
|
38
|
+
this.seeds = 'seeds';
|
|
39
|
+
/**
|
|
40
|
+
* Schema storage directory, relative to this database
|
|
41
|
+
* e.g. If the schema is in `database/main/.schema`,
|
|
42
|
+
* set this to `.schema`
|
|
43
|
+
*/
|
|
44
|
+
this.schemaDirectory = '.schema';
|
|
45
|
+
/**
|
|
46
|
+
* Query builder class type used to create new query builders
|
|
47
|
+
*/
|
|
48
|
+
this.queryBuilderType = dml_1.DatabaseQueryBuilder;
|
|
49
|
+
/**
|
|
50
|
+
* Query repository class type used to create new repos
|
|
51
|
+
*/
|
|
52
|
+
this.queryRepositoryType = dml_1.QueryRepository;
|
|
53
|
+
/**
|
|
54
|
+
* DDL builder class type used to create new builders
|
|
55
|
+
*/
|
|
56
|
+
this.ddlBuilderType = ddl_1.DataDefinitionBuilder;
|
|
57
|
+
/**
|
|
58
|
+
* DDL repository class type used to create new repos
|
|
59
|
+
*/
|
|
60
|
+
this.ddlRepositoryType = ddl_1.DataDefinitionRepository;
|
|
61
|
+
/**
|
|
62
|
+
* Schema Query repository class type used to create new repos
|
|
63
|
+
*/
|
|
64
|
+
this.schemaQueryRepositoryType = schema_query_repository_1.SchemaQueryRepository;
|
|
65
|
+
/**
|
|
66
|
+
* Functions
|
|
67
|
+
*/
|
|
68
|
+
this.functions = new functions_1.DatabaseFunctions();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Initialize the database
|
|
72
|
+
*
|
|
73
|
+
* @param options Database options
|
|
74
|
+
*/
|
|
75
|
+
init(options) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
options = options !== null && options !== void 0 ? options : {};
|
|
78
|
+
if (!this.name) {
|
|
79
|
+
throw new Error('Cannot load database without a name');
|
|
80
|
+
}
|
|
81
|
+
if (!this.databasePath) {
|
|
82
|
+
this.databasePath = (0, get_database_path_1.getDatabasePath)();
|
|
83
|
+
}
|
|
84
|
+
if (!this.driver) {
|
|
85
|
+
this.driver = new this.driverType();
|
|
86
|
+
}
|
|
87
|
+
if (options.connectionOptions) {
|
|
88
|
+
this.env = options.connectionOptions;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.configureFromEnv();
|
|
92
|
+
}
|
|
93
|
+
yield this.connect();
|
|
94
|
+
this.schemaQuery = this.getSchemaQueryRepository();
|
|
95
|
+
yield this.loadSchema();
|
|
96
|
+
this.query = this.getQueryRepository();
|
|
97
|
+
this.ddl = this.getDataDefinitionRepository();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Load the configuration .env
|
|
102
|
+
*/
|
|
103
|
+
configureFromEnv() {
|
|
104
|
+
this.env = (0, config_1.configureDb)(this.envType, this.databasePath, this.name);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Connect to the database
|
|
108
|
+
*/
|
|
109
|
+
connect() {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
if (!this.env) {
|
|
112
|
+
throw new Error(`Cannot connect() database "${this.name}" before init()`);
|
|
113
|
+
}
|
|
114
|
+
yield this.driver.connect(this.env);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Disconnect from the database
|
|
119
|
+
*/
|
|
120
|
+
disconnect() {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
yield this.driver.disconnect();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get the full relative path to this database's migrations folder
|
|
127
|
+
*
|
|
128
|
+
* @returns Returns the relative file path
|
|
129
|
+
*/
|
|
130
|
+
getMigrationsDirectory() {
|
|
131
|
+
return (0, path_1.join)(this.databasePath, this.name, this.migrations);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get the full relative path to this database's seeds folder
|
|
135
|
+
*
|
|
136
|
+
* @returns Returns the relative file path
|
|
137
|
+
*/
|
|
138
|
+
getSeedsDirectory() {
|
|
139
|
+
return (0, path_1.join)(this.databasePath, this.name, this.seeds);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get the full relative path to this database's schema folder
|
|
143
|
+
*
|
|
144
|
+
* @returns Returns the relative file path
|
|
145
|
+
*/
|
|
146
|
+
getSchemaDirectory() {
|
|
147
|
+
return (0, path_1.join)(this.databasePath, this.name, this.schemaDirectory);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get a new DDL builder
|
|
151
|
+
*
|
|
152
|
+
* @returns DDL builder
|
|
153
|
+
*/
|
|
154
|
+
getDataDefinitionBuilder() {
|
|
155
|
+
return new this.ddlBuilderType();
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get a new DDL repository
|
|
159
|
+
*
|
|
160
|
+
* @param options Repository options
|
|
161
|
+
* @returns Returns the DDL repository
|
|
162
|
+
*/
|
|
163
|
+
getDataDefinitionRepository() {
|
|
164
|
+
if (!this.driver) {
|
|
165
|
+
this.driver = new this.driverType();
|
|
166
|
+
}
|
|
167
|
+
return new this.ddlRepositoryType({
|
|
168
|
+
driver: this.driver,
|
|
169
|
+
ddlBuilderType: this.ddlBuilderType,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get a new query builder
|
|
174
|
+
*
|
|
175
|
+
* @returns Query builder
|
|
176
|
+
*/
|
|
177
|
+
getQueryBuilder() {
|
|
178
|
+
return new this.queryBuilderType();
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get a new query repository
|
|
182
|
+
*
|
|
183
|
+
* @param options Repository options
|
|
184
|
+
* @returns Returns the query repository
|
|
185
|
+
*/
|
|
186
|
+
getQueryRepository(options) {
|
|
187
|
+
if (!this.driver) {
|
|
188
|
+
this.driver = new this.driverType();
|
|
189
|
+
}
|
|
190
|
+
return new this.queryRepositoryType(Object.assign(Object.assign({}, (options !== null && options !== void 0 ? options : {})), { driver: this.driver, schema: this.schema, queryBuilderType: this.queryBuilderType }));
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get a new schema query repository
|
|
194
|
+
*
|
|
195
|
+
* @returns Schema Query Repository
|
|
196
|
+
*/
|
|
197
|
+
getSchemaQueryRepository() {
|
|
198
|
+
if (!this.driver) {
|
|
199
|
+
this.driver = new this.driverType();
|
|
200
|
+
}
|
|
201
|
+
return new this.schemaQueryRepositoryType({
|
|
202
|
+
driver: this.driver,
|
|
203
|
+
database: this.env.database,
|
|
204
|
+
queryBuilderType: this.queryBuilderType,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Build & save the database schema
|
|
209
|
+
*/
|
|
210
|
+
buildSchema() {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
this.schema = yield this.schemaQuery.getSchema();
|
|
213
|
+
yield this.saveSchema();
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Save the database schema
|
|
218
|
+
*/
|
|
219
|
+
saveSchema() {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
(0, fs_1.mkdirSync)(this.getSchemaDirectory(), { recursive: true });
|
|
222
|
+
const filepath = (0, path_1.join)(this.getSchemaDirectory(), 'schema.json');
|
|
223
|
+
const data = JSON.stringify(this.schema);
|
|
224
|
+
(0, fs_1.writeFileSync)(filepath, data);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Load the database schema
|
|
229
|
+
*/
|
|
230
|
+
loadSchema() {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
const filepath = (0, path_1.join)(this.getSchemaDirectory(), 'schema.json');
|
|
233
|
+
if ((0, fs_1.existsSync)(filepath)) {
|
|
234
|
+
const data = (0, fs_1.readFileSync)(filepath).toString();
|
|
235
|
+
this.schema = JSON.parse(data);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
yield this.buildSchema();
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Get schema metadata
|
|
244
|
+
*
|
|
245
|
+
* @returns Schema
|
|
246
|
+
*/
|
|
247
|
+
getSchema() {
|
|
248
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
249
|
+
if (!this.schema) {
|
|
250
|
+
yield this.loadSchema();
|
|
251
|
+
}
|
|
252
|
+
return this.schema;
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
exports.Database = Database;
|
|
257
|
+
//# sourceMappingURL=database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../../src/database/database.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAAwE;AACxE,+BAAwC;AAExC,sCAAqD;AACrD,2DAAsD;AACtD,gCAAyE;AAGzE,gCAIgB;AAChB,+EAA0E;AAE1E,4CAAiD;AAEjD;;;GAGG;AACH,MAAsB,QAAQ;IAA9B;QA+BC;;;;WAIG;QACI,eAAU,GAAG,YAAY,CAAC;QAEjC;;;;WAIG;QAC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AAC;YAC1D,MAAM,QAAQ,GAAG,IAAA,WAAQ,EAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,aAAa,CAAC,CAAC;YACpE,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAA,kBAAa,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC/B,CAAC;KAAA;IAED;;OAEG;IACU,UAAU;;YACtB,MAAM,QAAQ,GAAG,IAAA,WAAQ,EAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,aAAa,CAAC,CAAC;YAEpE,IAAI,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE;gBACzB,MAAM,IAAI,GAAG,IAAA,iBAAY,EAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;gBAE/C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC/B;iBACI;gBACJ,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;aACzB;QACF,CAAC;KAAA;IAED;;;;OAIG;IACU,SAAS;;YACrB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBACjB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;aACxB;YAED,OAAO,IAAI,CAAC,MAAM,CAAC;QACpB,CAAC;KAAA;CACD;AA3TD,4BA2TC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DataDefinitionBuilder } from '../ddl';
|
|
2
|
+
import { DatabaseQueryBuilder } from '../dml';
|
|
3
|
+
export interface DatabaseQueryOptions {
|
|
4
|
+
sql: string;
|
|
5
|
+
params?: any[];
|
|
6
|
+
}
|
|
7
|
+
export type DatabaseQueryTypes = DatabaseQueryOptions | DataDefinitionBuilder | DatabaseQueryBuilder;
|
|
8
|
+
export interface DatabaseQueryResult {
|
|
9
|
+
results?: Record<string, any>[];
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver-query.js","sourceRoot":"","sources":["../../../src/database/driver-query.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DatabaseConnectionOptions } from './connection-options';
|
|
2
|
+
import { DatabaseQueryOptions, DatabaseQueryResult, DatabaseQueryTypes } from './driver-query';
|
|
3
|
+
export declare class DatabaseDriver {
|
|
4
|
+
connect(options: DatabaseConnectionOptions): Promise<this>;
|
|
5
|
+
disconnect(): Promise<void>;
|
|
6
|
+
query(options: DatabaseQueryTypes): Promise<DatabaseQueryResult>;
|
|
7
|
+
getVersion(): Promise<string>;
|
|
8
|
+
protected toDatabaseQueryOptions(from: DatabaseQueryTypes): DatabaseQueryOptions;
|
|
9
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DatabaseDriver = void 0;
|
|
13
|
+
const builder_1 = require("../builder");
|
|
14
|
+
class DatabaseDriver {
|
|
15
|
+
connect(options) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
throw new Error('DatabaseDriver missing connect method');
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
disconnect() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
throw new Error('DatabaseDriver missing disconnect method');
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
query(options) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
throw new Error('DatabaseDriver missing query method');
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getVersion() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
throw new Error('DatabaseDriver missing getVersion method');
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
toDatabaseQueryOptions(from) {
|
|
36
|
+
if (from instanceof builder_1.Builder) {
|
|
37
|
+
return from.toDatabaseQuery();
|
|
38
|
+
}
|
|
39
|
+
return from;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.DatabaseDriver = DatabaseDriver;
|
|
43
|
+
//# sourceMappingURL=driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../../src/database/driver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,wCAAqC;AAErC,MAAa,cAAc;IACb,OAAO,CAAC,OAAkC;;YACtD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC1D,CAAC;KAAA;IAEY,UAAU;;YACtB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC7D,CAAC;KAAA;IAEY,KAAK,CACjB,OAA2B;;YAE3B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACxD,CAAC;KAAA;IAEY,UAAU;;YACtB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC7D,CAAC;KAAA;IAES,sBAAsB,CAC/B,IAAwB;QAExB,IAAI,IAAI,YAAY,iBAAO,EAAE;YAC5B,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;SAC9B;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AA5BD,wCA4BC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDatabasePath = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Get the root database path. TODO: Load from global config?
|
|
6
|
+
*
|
|
7
|
+
* @returns Returns the relative path.
|
|
8
|
+
*/
|
|
9
|
+
function getDatabasePath() {
|
|
10
|
+
return 'database';
|
|
11
|
+
}
|
|
12
|
+
exports.getDatabasePath = getDatabasePath;
|
|
13
|
+
//# sourceMappingURL=get-database-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-database-path.js","sourceRoot":"","sources":["../../../src/database/get-database-path.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,SAAgB,eAAe;IAC9B,OAAO,UAAU,CAAC;AACnB,CAAC;AAFD,0CAEC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DatabaseConnectionOptions } from './connection-options';
|
|
2
|
+
export { Database } from './database';
|
|
3
|
+
export * from './driver-query';
|
|
4
|
+
export { DatabaseDriver } from './driver';
|
|
5
|
+
export { getDatabasePath } from './get-database-path';
|
|
6
|
+
export { loadDatabase } from './load-database';
|