@orchestr-sh/orchestr 1.0.1 → 1.1.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/Database/Adapters/DrizzleAdapter.d.ts +119 -0
- package/dist/Database/Adapters/DrizzleAdapter.d.ts.map +1 -0
- package/dist/Database/Adapters/DrizzleAdapter.js +384 -0
- package/dist/Database/Adapters/DrizzleAdapter.js.map +1 -0
- package/dist/Database/Connection.d.ts +103 -0
- package/dist/Database/Connection.d.ts.map +1 -0
- package/dist/Database/Connection.js +164 -0
- package/dist/Database/Connection.js.map +1 -0
- package/dist/Database/Contracts/DatabaseAdapter.d.ts +85 -0
- package/dist/Database/Contracts/DatabaseAdapter.d.ts.map +1 -0
- package/dist/Database/Contracts/DatabaseAdapter.js +9 -0
- package/dist/Database/Contracts/DatabaseAdapter.js.map +1 -0
- package/dist/Database/Contracts/QueryBuilderInterface.d.ts +196 -0
- package/dist/Database/Contracts/QueryBuilderInterface.d.ts.map +1 -0
- package/dist/Database/Contracts/QueryBuilderInterface.js +8 -0
- package/dist/Database/Contracts/QueryBuilderInterface.js.map +1 -0
- package/dist/Database/Contracts/Schema.d.ts +234 -0
- package/dist/Database/Contracts/Schema.d.ts.map +1 -0
- package/dist/Database/Contracts/Schema.js +8 -0
- package/dist/Database/Contracts/Schema.js.map +1 -0
- package/dist/Database/DatabaseManager.d.ts +61 -0
- package/dist/Database/DatabaseManager.d.ts.map +1 -0
- package/dist/Database/DatabaseManager.js +102 -0
- package/dist/Database/DatabaseManager.js.map +1 -0
- package/dist/Database/DatabaseServiceProvider.d.ts +17 -0
- package/dist/Database/DatabaseServiceProvider.d.ts.map +1 -0
- package/dist/Database/DatabaseServiceProvider.js +44 -0
- package/dist/Database/DatabaseServiceProvider.js.map +1 -0
- package/dist/Database/Eloquent/Builder.d.ts +76 -0
- package/dist/Database/Eloquent/Builder.d.ts.map +1 -0
- package/dist/Database/Eloquent/Builder.js +154 -0
- package/dist/Database/Eloquent/Builder.js.map +1 -0
- package/dist/Database/Eloquent/Collection.d.ts +137 -0
- package/dist/Database/Eloquent/Collection.d.ts.map +1 -0
- package/dist/Database/Eloquent/Collection.js +284 -0
- package/dist/Database/Eloquent/Collection.js.map +1 -0
- package/dist/Database/Eloquent/Concerns/HasAttributes.d.ts +44 -0
- package/dist/Database/Eloquent/Concerns/HasAttributes.d.ts.map +1 -0
- package/dist/Database/Eloquent/Concerns/HasAttributes.js +8 -0
- package/dist/Database/Eloquent/Concerns/HasAttributes.js.map +1 -0
- package/dist/Database/Eloquent/Concerns/HasTimestamps.d.ts +41 -0
- package/dist/Database/Eloquent/Concerns/HasTimestamps.d.ts.map +1 -0
- package/dist/Database/Eloquent/Concerns/HasTimestamps.js +14 -0
- package/dist/Database/Eloquent/Concerns/HasTimestamps.js.map +1 -0
- package/dist/Database/Eloquent/Model.d.ts +265 -0
- package/dist/Database/Eloquent/Model.d.ts.map +1 -0
- package/dist/Database/Eloquent/Model.js +523 -0
- package/dist/Database/Eloquent/Model.js.map +1 -0
- package/dist/Database/Eloquent/SoftDeletes.d.ts +41 -0
- package/dist/Database/Eloquent/SoftDeletes.d.ts.map +1 -0
- package/dist/Database/Eloquent/SoftDeletes.js +22 -0
- package/dist/Database/Eloquent/SoftDeletes.js.map +1 -0
- package/dist/Database/Ensemble/Concerns/HasAttributes.d.ts +44 -0
- package/dist/Database/Ensemble/Concerns/HasAttributes.d.ts.map +1 -0
- package/dist/Database/Ensemble/Concerns/HasAttributes.js +8 -0
- package/dist/Database/Ensemble/Concerns/HasAttributes.js.map +1 -0
- package/dist/Database/Ensemble/Concerns/HasTimestamps.d.ts +41 -0
- package/dist/Database/Ensemble/Concerns/HasTimestamps.d.ts.map +1 -0
- package/dist/Database/Ensemble/Concerns/HasTimestamps.js +14 -0
- package/dist/Database/Ensemble/Concerns/HasTimestamps.js.map +1 -0
- package/dist/Database/Ensemble/Ensemble.d.ts +266 -0
- package/dist/Database/Ensemble/Ensemble.d.ts.map +1 -0
- package/dist/Database/Ensemble/Ensemble.js +524 -0
- package/dist/Database/Ensemble/Ensemble.js.map +1 -0
- package/dist/Database/Ensemble/EnsembleBuilder.d.ts +76 -0
- package/dist/Database/Ensemble/EnsembleBuilder.d.ts.map +1 -0
- package/dist/Database/Ensemble/EnsembleBuilder.js +154 -0
- package/dist/Database/Ensemble/EnsembleBuilder.js.map +1 -0
- package/dist/Database/Ensemble/EnsembleCollection.d.ts +137 -0
- package/dist/Database/Ensemble/EnsembleCollection.d.ts.map +1 -0
- package/dist/Database/Ensemble/EnsembleCollection.js +284 -0
- package/dist/Database/Ensemble/EnsembleCollection.js.map +1 -0
- package/dist/Database/Ensemble/SoftDeletes.d.ts +41 -0
- package/dist/Database/Ensemble/SoftDeletes.d.ts.map +1 -0
- package/dist/Database/Ensemble/SoftDeletes.js +22 -0
- package/dist/Database/Ensemble/SoftDeletes.js.map +1 -0
- package/dist/Database/Query/Builder.d.ts +219 -0
- package/dist/Database/Query/Builder.d.ts.map +1 -0
- package/dist/Database/Query/Builder.js +554 -0
- package/dist/Database/Query/Builder.js.map +1 -0
- package/dist/Database/Query/Expression.d.ts +22 -0
- package/dist/Database/Query/Expression.d.ts.map +1 -0
- package/dist/Database/Query/Expression.js +35 -0
- package/dist/Database/Query/Expression.js.map +1 -0
- package/dist/Facades/DB.d.ts +7 -0
- package/dist/Facades/DB.d.ts.map +1 -0
- package/dist/Facades/DB.js +42 -0
- package/dist/Facades/DB.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/package.json +13 -5
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema Interface
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for schema/migration operations
|
|
5
|
+
*/
|
|
6
|
+
export interface Schema {
|
|
7
|
+
/**
|
|
8
|
+
* Create a new table
|
|
9
|
+
*/
|
|
10
|
+
create(tableName: string, callback: (table: Blueprint) => void): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Drop a table
|
|
13
|
+
*/
|
|
14
|
+
drop(tableName: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Drop a table if it exists
|
|
17
|
+
*/
|
|
18
|
+
dropIfExists(tableName: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Rename a table
|
|
21
|
+
*/
|
|
22
|
+
rename(from: string, to: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Determine if a table exists
|
|
25
|
+
*/
|
|
26
|
+
hasTable(tableName: string): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Determine if a column exists on a table
|
|
29
|
+
*/
|
|
30
|
+
hasColumn(tableName: string, columnName: string): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Modify an existing table
|
|
33
|
+
*/
|
|
34
|
+
table(tableName: string, callback: (table: Blueprint) => void): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export interface Blueprint {
|
|
37
|
+
/**
|
|
38
|
+
* The table the blueprint describes
|
|
39
|
+
*/
|
|
40
|
+
table: string;
|
|
41
|
+
/**
|
|
42
|
+
* Add an auto-incrementing ID column
|
|
43
|
+
*/
|
|
44
|
+
id(column?: string): ColumnDefinition;
|
|
45
|
+
/**
|
|
46
|
+
* Add a big auto-incrementing ID column
|
|
47
|
+
*/
|
|
48
|
+
bigIncrements(column: string): ColumnDefinition;
|
|
49
|
+
/**
|
|
50
|
+
* Add an auto-incrementing column
|
|
51
|
+
*/
|
|
52
|
+
increments(column: string): ColumnDefinition;
|
|
53
|
+
/**
|
|
54
|
+
* Add a UUID column
|
|
55
|
+
*/
|
|
56
|
+
uuid(column: string): ColumnDefinition;
|
|
57
|
+
/**
|
|
58
|
+
* Add a string column
|
|
59
|
+
*/
|
|
60
|
+
string(column: string, length?: number): ColumnDefinition;
|
|
61
|
+
/**
|
|
62
|
+
* Add a text column
|
|
63
|
+
*/
|
|
64
|
+
text(column: string): ColumnDefinition;
|
|
65
|
+
/**
|
|
66
|
+
* Add a medium text column
|
|
67
|
+
*/
|
|
68
|
+
mediumText(column: string): ColumnDefinition;
|
|
69
|
+
/**
|
|
70
|
+
* Add a long text column
|
|
71
|
+
*/
|
|
72
|
+
longText(column: string): ColumnDefinition;
|
|
73
|
+
/**
|
|
74
|
+
* Add an integer column
|
|
75
|
+
*/
|
|
76
|
+
integer(column: string): ColumnDefinition;
|
|
77
|
+
/**
|
|
78
|
+
* Add a big integer column
|
|
79
|
+
*/
|
|
80
|
+
bigInteger(column: string): ColumnDefinition;
|
|
81
|
+
/**
|
|
82
|
+
* Add a small integer column
|
|
83
|
+
*/
|
|
84
|
+
smallInteger(column: string): ColumnDefinition;
|
|
85
|
+
/**
|
|
86
|
+
* Add a tiny integer column
|
|
87
|
+
*/
|
|
88
|
+
tinyInteger(column: string): ColumnDefinition;
|
|
89
|
+
/**
|
|
90
|
+
* Add a decimal column
|
|
91
|
+
*/
|
|
92
|
+
decimal(column: string, precision?: number, scale?: number): ColumnDefinition;
|
|
93
|
+
/**
|
|
94
|
+
* Add a float column
|
|
95
|
+
*/
|
|
96
|
+
float(column: string, precision?: number, scale?: number): ColumnDefinition;
|
|
97
|
+
/**
|
|
98
|
+
* Add a double column
|
|
99
|
+
*/
|
|
100
|
+
double(column: string, precision?: number, scale?: number): ColumnDefinition;
|
|
101
|
+
/**
|
|
102
|
+
* Add a boolean column
|
|
103
|
+
*/
|
|
104
|
+
boolean(column: string): ColumnDefinition;
|
|
105
|
+
/**
|
|
106
|
+
* Add a date column
|
|
107
|
+
*/
|
|
108
|
+
date(column: string): ColumnDefinition;
|
|
109
|
+
/**
|
|
110
|
+
* Add a datetime column
|
|
111
|
+
*/
|
|
112
|
+
datetime(column: string, precision?: number): ColumnDefinition;
|
|
113
|
+
/**
|
|
114
|
+
* Add a timestamp column
|
|
115
|
+
*/
|
|
116
|
+
timestamp(column: string, precision?: number): ColumnDefinition;
|
|
117
|
+
/**
|
|
118
|
+
* Add created_at and updated_at timestamp columns
|
|
119
|
+
*/
|
|
120
|
+
timestamps(precision?: number): void;
|
|
121
|
+
/**
|
|
122
|
+
* Add a JSON column
|
|
123
|
+
*/
|
|
124
|
+
json(column: string): ColumnDefinition;
|
|
125
|
+
/**
|
|
126
|
+
* Add a JSONB column
|
|
127
|
+
*/
|
|
128
|
+
jsonb(column: string): ColumnDefinition;
|
|
129
|
+
/**
|
|
130
|
+
* Add a binary column
|
|
131
|
+
*/
|
|
132
|
+
binary(column: string): ColumnDefinition;
|
|
133
|
+
/**
|
|
134
|
+
* Add an enum column
|
|
135
|
+
*/
|
|
136
|
+
enum(column: string, values: string[]): ColumnDefinition;
|
|
137
|
+
/**
|
|
138
|
+
* Add a remember token column
|
|
139
|
+
*/
|
|
140
|
+
rememberToken(): ColumnDefinition;
|
|
141
|
+
/**
|
|
142
|
+
* Add soft delete columns
|
|
143
|
+
*/
|
|
144
|
+
softDeletes(column?: string): ColumnDefinition;
|
|
145
|
+
/**
|
|
146
|
+
* Add an index
|
|
147
|
+
*/
|
|
148
|
+
index(columns: string | string[], indexName?: string): void;
|
|
149
|
+
/**
|
|
150
|
+
* Add a unique index
|
|
151
|
+
*/
|
|
152
|
+
unique(columns: string | string[], indexName?: string): void;
|
|
153
|
+
/**
|
|
154
|
+
* Add a primary key
|
|
155
|
+
*/
|
|
156
|
+
primary(columns: string | string[]): void;
|
|
157
|
+
/**
|
|
158
|
+
* Add a foreign key
|
|
159
|
+
*/
|
|
160
|
+
foreign(columns: string | string[], indexName?: string): ForeignKeyDefinition;
|
|
161
|
+
/**
|
|
162
|
+
* Drop a column
|
|
163
|
+
*/
|
|
164
|
+
dropColumn(column: string | string[]): void;
|
|
165
|
+
/**
|
|
166
|
+
* Drop an index
|
|
167
|
+
*/
|
|
168
|
+
dropIndex(indexName: string): void;
|
|
169
|
+
/**
|
|
170
|
+
* Drop a foreign key
|
|
171
|
+
*/
|
|
172
|
+
dropForeign(indexName: string): void;
|
|
173
|
+
/**
|
|
174
|
+
* Rename a column
|
|
175
|
+
*/
|
|
176
|
+
renameColumn(from: string, to: string): void;
|
|
177
|
+
}
|
|
178
|
+
export interface ColumnDefinition {
|
|
179
|
+
/**
|
|
180
|
+
* Allow NULL values
|
|
181
|
+
*/
|
|
182
|
+
nullable(): this;
|
|
183
|
+
/**
|
|
184
|
+
* Set a default value
|
|
185
|
+
*/
|
|
186
|
+
default(value: any): this;
|
|
187
|
+
/**
|
|
188
|
+
* Mark as unsigned (for numeric types)
|
|
189
|
+
*/
|
|
190
|
+
unsigned(): this;
|
|
191
|
+
/**
|
|
192
|
+
* Add a unique constraint
|
|
193
|
+
*/
|
|
194
|
+
unique(): this;
|
|
195
|
+
/**
|
|
196
|
+
* Add an index
|
|
197
|
+
*/
|
|
198
|
+
index(indexName?: string): this;
|
|
199
|
+
/**
|
|
200
|
+
* Set as primary key
|
|
201
|
+
*/
|
|
202
|
+
primary(): this;
|
|
203
|
+
/**
|
|
204
|
+
* Add a comment
|
|
205
|
+
*/
|
|
206
|
+
comment(comment: string): this;
|
|
207
|
+
/**
|
|
208
|
+
* Place column after another column
|
|
209
|
+
*/
|
|
210
|
+
after(column: string): this;
|
|
211
|
+
/**
|
|
212
|
+
* Place column first
|
|
213
|
+
*/
|
|
214
|
+
first(): this;
|
|
215
|
+
}
|
|
216
|
+
export interface ForeignKeyDefinition {
|
|
217
|
+
/**
|
|
218
|
+
* Specify the referenced column(s)
|
|
219
|
+
*/
|
|
220
|
+
references(columns: string | string[]): this;
|
|
221
|
+
/**
|
|
222
|
+
* Specify the referenced table
|
|
223
|
+
*/
|
|
224
|
+
on(table: string): this;
|
|
225
|
+
/**
|
|
226
|
+
* Set the ON DELETE action
|
|
227
|
+
*/
|
|
228
|
+
onDelete(action: 'cascade' | 'set null' | 'restrict' | 'no action'): this;
|
|
229
|
+
/**
|
|
230
|
+
* Set the ON UPDATE action
|
|
231
|
+
*/
|
|
232
|
+
onUpdate(action: 'cascade' | 'set null' | 'restrict' | 'no action'): this;
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=Schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../../src/Database/Contracts/Schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/E;;OAEG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE9C;;OAEG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnE;;OAEG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E;AAED,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;IAEtC;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAAC;IAEhD;;OAEG;IACH,UAAU,CAAC,MAAM,EA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ings":";AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DatabaseManager Class
|
|
3
|
+
*
|
|
4
|
+
* Manages multiple database connections
|
|
5
|
+
*/
|
|
6
|
+
import { Connection } from './Connection';
|
|
7
|
+
import { DatabaseAdapter, DatabaseConfig } from './Contracts/DatabaseAdapter';
|
|
8
|
+
export interface DatabaseConnectionConfig extends DatabaseConfig {
|
|
9
|
+
adapter: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DatabaseManagerConfig {
|
|
12
|
+
default: string;
|
|
13
|
+
connections: Record<string, DatabaseConnectionConfig>;
|
|
14
|
+
}
|
|
15
|
+
export declare class DatabaseManager {
|
|
16
|
+
protected config: DatabaseManagerConfig;
|
|
17
|
+
protected connections: Map<string, Connection>;
|
|
18
|
+
protected adapterFactories: Map<string, (config: DatabaseConfig) => DatabaseAdapter>;
|
|
19
|
+
constructor(config: DatabaseManagerConfig);
|
|
20
|
+
/**
|
|
21
|
+
* Register an adapter factory
|
|
22
|
+
*/
|
|
23
|
+
registerAdapter(name: string, factory: (config: DatabaseConfig) => DatabaseAdapter): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get a database connection
|
|
26
|
+
*/
|
|
27
|
+
connection(name?: string): Connection;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new connection
|
|
30
|
+
*/
|
|
31
|
+
protected createConnection(name: string): Connection;
|
|
32
|
+
/**
|
|
33
|
+
* Disconnect a connection
|
|
34
|
+
*/
|
|
35
|
+
disconnect(name?: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Disconnect all connections
|
|
38
|
+
*/
|
|
39
|
+
disconnectAll(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Purge a connection (disconnect and remove from cache)
|
|
42
|
+
*/
|
|
43
|
+
purge(name?: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Get the default connection name
|
|
46
|
+
*/
|
|
47
|
+
getDefaultConnection(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Set the default connection name
|
|
50
|
+
*/
|
|
51
|
+
setDefaultConnection(name: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get all connection names
|
|
54
|
+
*/
|
|
55
|
+
getConnections(): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Extend the database manager with a macro
|
|
58
|
+
*/
|
|
59
|
+
extend(name: string, resolver: () => any): void;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=DatabaseManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseManager.d.ts","sourceRoot":"","sources":["../../src/Database/DatabaseManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE9E,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;CACvD;AAED,qBAAa,eAAe;IAId,SAAS,CAAC,MAAM,EAAE,qBAAqB;IAHnD,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAa;IAC3D,SAAS,CAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,eAAe,CAAC,CAAa;gBAE3E,MAAM,EAAE,qBAAqB;IAEnD;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,eAAe,GAAG,IAAI;IAIzF;;OAEG;IACH,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU;IAerC;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAiBpD;;OAEG;IACG,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9C;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAKpC;;OAEG;IACG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC;;OAEG;IACH,oBAAoB,IAAI,MAAM;IAI9B;;OAEG;IACH,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIxC;;OAEG;IACH,cAAc,IAAI,MAAM,EAAE;IAI1B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,IAAI;CAGhD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DatabaseManager Class
|
|
4
|
+
*
|
|
5
|
+
* Manages multiple database connections
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DatabaseManager = void 0;
|
|
9
|
+
const Connection_1 = require("./Connection");
|
|
10
|
+
class DatabaseManager {
|
|
11
|
+
config;
|
|
12
|
+
connections = new Map();
|
|
13
|
+
adapterFactories = new Map();
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.config = config;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Register an adapter factory
|
|
19
|
+
*/
|
|
20
|
+
registerAdapter(name, factory) {
|
|
21
|
+
this.adapterFactories.set(name, factory);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get a database connection
|
|
25
|
+
*/
|
|
26
|
+
connection(name) {
|
|
27
|
+
const connectionName = name || this.config.default;
|
|
28
|
+
// Return existing connection if available
|
|
29
|
+
if (this.connections.has(connectionName)) {
|
|
30
|
+
return this.connections.get(connectionName);
|
|
31
|
+
}
|
|
32
|
+
// Create new connection
|
|
33
|
+
const connection = this.createConnection(connectionName);
|
|
34
|
+
this.connections.set(connectionName, connection);
|
|
35
|
+
return connection;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a new connection
|
|
39
|
+
*/
|
|
40
|
+
createConnection(name) {
|
|
41
|
+
const config = this.config.connections[name];
|
|
42
|
+
if (!config) {
|
|
43
|
+
throw new Error(`Database connection [${name}] not configured.`);
|
|
44
|
+
}
|
|
45
|
+
const adapterFactory = this.adapterFactories.get(config.adapter);
|
|
46
|
+
if (!adapterFactory) {
|
|
47
|
+
throw new Error(`Database adapter [${config.adapter}] not registered.`);
|
|
48
|
+
}
|
|
49
|
+
const adapter = adapterFactory(config);
|
|
50
|
+
return new Connection_1.Connection(adapter, config);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Disconnect a connection
|
|
54
|
+
*/
|
|
55
|
+
async disconnect(name) {
|
|
56
|
+
const connectionName = name || this.config.default;
|
|
57
|
+
const connection = this.connections.get(connectionName);
|
|
58
|
+
if (connection) {
|
|
59
|
+
await connection.disconnect();
|
|
60
|
+
this.connections.delete(connectionName);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Disconnect all connections
|
|
65
|
+
*/
|
|
66
|
+
async disconnectAll() {
|
|
67
|
+
const promises = Array.from(this.connections.keys()).map((name) => this.disconnect(name));
|
|
68
|
+
await Promise.all(promises);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Purge a connection (disconnect and remove from cache)
|
|
72
|
+
*/
|
|
73
|
+
async purge(name) {
|
|
74
|
+
await this.disconnect(name);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get the default connection name
|
|
78
|
+
*/
|
|
79
|
+
getDefaultConnection() {
|
|
80
|
+
return this.config.default;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Set the default connection name
|
|
84
|
+
*/
|
|
85
|
+
setDefaultConnection(name) {
|
|
86
|
+
this.config.default = name;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get all connection names
|
|
90
|
+
*/
|
|
91
|
+
getConnections() {
|
|
92
|
+
return Object.keys(this.config.connections);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Extend the database manager with a macro
|
|
96
|
+
*/
|
|
97
|
+
extend(name, resolver) {
|
|
98
|
+
this[name] = resolver;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.DatabaseManager = DatabaseManager;
|
|
102
|
+
//# sourceMappingURL=DatabaseManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseManager.js","sourceRoot":"","sources":["../../src/Database/DatabaseManager.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,6CAA0C;AAY1C,MAAa,eAAe;IAIJ;IAHZ,WAAW,GAA4B,IAAI,GAAG,EAAE,CAAC;IACjD,gBAAgB,GAA6D,IAAI,GAAG,EAAE,CAAC;IAEjG,YAAsB,MAA6B;QAA7B,WAAM,GAAN,MAAM,CAAuB;IAAG,CAAC;IAEvD;;OAEG;IACH,eAAe,CAAC,IAAY,EAAE,OAAoD;QAChF,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAAa;QACtB,MAAM,cAAc,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAEnD,0CAA0C;QAC1C,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;YACzC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,CAAE,CAAC;QAC/C,CAAC;QAED,wBAAwB;QACxB,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;QACzD,IA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AI,CAAC,CAAC,CAAC;QAC1F,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,IAAa;QACvB,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,oBAAoB,CAAC,IAAY;QAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAY,EAAE,QAAmB;QACrC,IAAY,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;IACjC,CAAC;CACF;AA1GD,0CA0GC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DatabaseServiceProvider
|
|
3
|
+
*
|
|
4
|
+
* Registers database services into the container
|
|
5
|
+
*/
|
|
6
|
+
import { ServiceProvider } from '../Foundation/ServiceProvider';
|
|
7
|
+
export declare class DatabaseServiceProvider extends ServiceProvider {
|
|
8
|
+
/**
|
|
9
|
+
* Register database services
|
|
10
|
+
*/
|
|
11
|
+
register(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Boot database services
|
|
14
|
+
*/
|
|
15
|
+
boot(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=DatabaseServiceProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseServiceProvider.d.ts","sourceRoot":"","sources":["../../src/Database/DatabaseServiceProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAIhE,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D;;OAEG;IACH,QAAQ,IAAI,IAAI;IAsBhB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DatabaseServiceProvider
|
|
4
|
+
*
|
|
5
|
+
* Registers database services into the container
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DatabaseServiceProvider = void 0;
|
|
9
|
+
const ServiceProvider_1 = require("../Foundation/ServiceProvider");
|
|
10
|
+
const DatabaseManager_1 = require("./DatabaseManager");
|
|
11
|
+
const DrizzleAdapter_1 = require("./Adapters/DrizzleAdapter");
|
|
12
|
+
class DatabaseServiceProvider extends ServiceProvider_1.ServiceProvider {
|
|
13
|
+
/**
|
|
14
|
+
* Register database services
|
|
15
|
+
*/
|
|
16
|
+
register() {
|
|
17
|
+
this.app.singleton('db', () => {
|
|
18
|
+
const config = this.app.make('config')?.database || {
|
|
19
|
+
default: 'sqlite',
|
|
20
|
+
connections: {
|
|
21
|
+
sqlite: {
|
|
22
|
+
adapter: 'drizzle',
|
|
23
|
+
driver: 'better-sqlite3',
|
|
24
|
+
database: ':memory:',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const manager = new DatabaseManager_1.DatabaseManager(config);
|
|
29
|
+
// Register Drizzle adapter
|
|
30
|
+
manager.registerAdapter('drizzle', (config) => new DrizzleAdapter_1.DrizzleAdapter(config));
|
|
31
|
+
return manager;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Boot database services
|
|
36
|
+
*/
|
|
37
|
+
async boot() {
|
|
38
|
+
// Optionally auto-connect to the default connection
|
|
39
|
+
// const db = this.app.make<DatabaseManager>('db');
|
|
40
|
+
// await db.connection().connect();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.DatabaseServiceProvider = DatabaseServiceProvider;
|
|
44
|
+
//# sourceMappingURL=DatabaseServiceProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseServiceProvider.js","sourceRoot":"","sources":["../../src/Database/DatabaseServiceProvider.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mEAAgE;AAChE,uDAAoD;AACpD,8DAA2D;AAE3D,MAAa,uBAAwB,SAAQ,iCAAe;IAC1D;;OAEG;IACH,QAAQ;QACN,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE;YAC5B,MAAM,MAAM,GAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAS,EAAE,QAAQ,IAAI;gBAC3D,OAAO,EAAE,QAAQ;gBACjB,WAAW,EAAE;oBACX,MAAM,EAAE;wBACN,OAAO,EAAE,SAAS;wBAClB,MAAM,EAAE,gBAAgB;wBACxB,QAAQ,EAAE,UAAU;qBACrB;iBACF;aACF,CAAC;YAEF,MAAM,OAAO,GAAG,IAAI,iCAAe,CAAC,MAAM,CAAC,CAAC;YAE5C,2BAA2B;YAC3B,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,+BAAc,CAAC,MAAM,CAAC,CAAC,CAAC;YAE3E,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,oDAAoD;QACpD,mDAAmD;QACnD,mCAAmC;IACrC,CAAC;CACF;AAlCD,0DAkCC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Eloquent Builder
|
|
3
|
+
*
|
|
4
|
+
* Extends the query builder to work with Eloquent models
|
|
5
|
+
*/
|
|
6
|
+
import { Builder as QueryBuilder } from '../Query/Builder';
|
|
7
|
+
import { DatabaseAdapter } from '../Contracts/DatabaseAdapter';
|
|
8
|
+
import { Model } from './Model';
|
|
9
|
+
export declare class Builder<T extends Model> extends QueryBuilder<T> {
|
|
10
|
+
/**
|
|
11
|
+
* The model being queried
|
|
12
|
+
*/
|
|
13
|
+
protected model: T;
|
|
14
|
+
/**
|
|
15
|
+
* The relationships that should be eager loaded
|
|
16
|
+
*/
|
|
17
|
+
protected eagerLoad: Record<string, any>;
|
|
18
|
+
constructor(adapter: DatabaseAdapter, model: T);
|
|
19
|
+
/**
|
|
20
|
+
* Find a model by its primary key
|
|
21
|
+
*/
|
|
22
|
+
find(id: any): Promise<T | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Execute the query and get all results
|
|
25
|
+
*/
|
|
26
|
+
get(): Promise<T[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Get the first record
|
|
29
|
+
*/
|
|
30
|
+
first(): Promise<T | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Create a collection of models from plain arrays
|
|
33
|
+
*/
|
|
34
|
+
protected hydrate(items: any[]): T[];
|
|
35
|
+
/**
|
|
36
|
+
* Create a new instance of the model
|
|
37
|
+
*/
|
|
38
|
+
protected newModelInstance(attributes?: Record<string, any>, exists?: boolean): T;
|
|
39
|
+
/**
|
|
40
|
+
* Set the relationships that should be eager loaded
|
|
41
|
+
*/
|
|
42
|
+
with(relations: string | string[]): this;
|
|
43
|
+
/**
|
|
44
|
+
* Create a new model and store it in the database
|
|
45
|
+
*/
|
|
46
|
+
create(attributes: Record<string, any>): Promise<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Update records in the database
|
|
49
|
+
*/
|
|
50
|
+
update(values: Record<string, any>): Promise<number>;
|
|
51
|
+
/**
|
|
52
|
+
* Delete records from the database
|
|
53
|
+
*/
|
|
54
|
+
delete(): Promise<number>;
|
|
55
|
+
/**
|
|
56
|
+
* Get a paginated result
|
|
57
|
+
*/
|
|
58
|
+
paginate(perPage?: number, page?: number): Promise<{
|
|
59
|
+
data: T[];
|
|
60
|
+
total: number;
|
|
61
|
+
perPage: number;
|
|
62
|
+
currentPage: number;
|
|
63
|
+
lastPage: number;
|
|
64
|
+
from: number;
|
|
65
|
+
to: number;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Chunk the results of the query
|
|
69
|
+
*/
|
|
70
|
+
chunk(count: number, callback: (models: T[]) => Promise<boolean | void>): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Clone the query builder
|
|
73
|
+
*/
|
|
74
|
+
clone(): Builder<T>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=Builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Builder.d.ts","sourceRoot":"","sources":["../../../src/Database/Eloquent/Builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,qBAAa,OAAO,CAAC,CAAC,SAAS,KAAK,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;IAC3D;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;gBAElC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;IAM9C;;OAEG;IACG,IAAI,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAItC;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC;IAKzB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAQhC;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC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