midway-model-gen 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.
Files changed (65) hide show
  1. package/.idea/codeStyles/Project.xml +57 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/prettier.xml +6 -0
  6. package/.idea/test.iml +8 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/CHANGELOG.md +161 -0
  9. package/CONTRIBUTING.md +51 -0
  10. package/DEVELOPER.md +30 -0
  11. package/LICENSE +21 -0
  12. package/README.md +94 -0
  13. package/USECASES.md +53 -0
  14. package/bin/typeorm-model-generator +6 -0
  15. package/dist/package.json +106 -0
  16. package/dist/src/Engine.d.ts +7 -0
  17. package/dist/src/Engine.js +47 -0
  18. package/dist/src/IConnectionOptions.d.ts +14 -0
  19. package/dist/src/IConnectionOptions.js +22 -0
  20. package/dist/src/IGenerationOptions.d.ts +24 -0
  21. package/dist/src/IGenerationOptions.js +33 -0
  22. package/dist/src/ModelCustomization.d.ts +4 -0
  23. package/dist/src/ModelCustomization.js +256 -0
  24. package/dist/src/ModelGeneration.d.ts +4 -0
  25. package/dist/src/ModelGeneration.js +247 -0
  26. package/dist/src/NamingStrategy.d.ts +10 -0
  27. package/dist/src/NamingStrategy.js +61 -0
  28. package/dist/src/Utils.d.ts +6 -0
  29. package/dist/src/Utils.js +68 -0
  30. package/dist/src/drivers/AbstractDriver.d.ts +30 -0
  31. package/dist/src/drivers/AbstractDriver.js +258 -0
  32. package/dist/src/drivers/MariaDbDriver.d.ts +4 -0
  33. package/dist/src/drivers/MariaDbDriver.js +11 -0
  34. package/dist/src/drivers/MssqlDriver.d.ts +25 -0
  35. package/dist/src/drivers/MssqlDriver.js +408 -0
  36. package/dist/src/drivers/MysqlDriver.d.ts +27 -0
  37. package/dist/src/drivers/MysqlDriver.js +439 -0
  38. package/dist/src/drivers/OracleDriver.d.ts +25 -0
  39. package/dist/src/drivers/OracleDriver.js +316 -0
  40. package/dist/src/drivers/PostgresDriver.d.ts +31 -0
  41. package/dist/src/drivers/PostgresDriver.js +542 -0
  42. package/dist/src/drivers/SqliteDriver.d.ts +28 -0
  43. package/dist/src/drivers/SqliteDriver.js +308 -0
  44. package/dist/src/index.d.ts +1 -0
  45. package/dist/src/index.js +667 -0
  46. package/dist/src/library.d.ts +11 -0
  47. package/dist/src/library.js +14 -0
  48. package/dist/src/models/Column.d.ts +24 -0
  49. package/dist/src/models/Column.js +3 -0
  50. package/dist/src/models/Entity.d.ts +21 -0
  51. package/dist/src/models/Entity.js +3 -0
  52. package/dist/src/models/Index.d.ts +9 -0
  53. package/dist/src/models/Index.js +3 -0
  54. package/dist/src/models/Relation.d.ts +11 -0
  55. package/dist/src/models/Relation.js +3 -0
  56. package/dist/src/models/RelationId.d.ts +5 -0
  57. package/dist/src/models/RelationId.js +3 -0
  58. package/dist/src/models/RelationInternal.d.ts +11 -0
  59. package/dist/src/models/RelationInternal.js +3 -0
  60. package/dist/src/templates/entity.mst +47 -0
  61. package/dist/src/templates/index.mst +5 -0
  62. package/dist/src/templates/ormconfig.mst +17 -0
  63. package/dist/src/templates/tsconfig.mst +10 -0
  64. package/npminstall-debug.log +175 -0
  65. package/package.json +106 -0
@@ -0,0 +1,542 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const TypeormDriver = require("typeorm/driver/postgres/PostgresDriver");
4
+ const TomgUtils = require("../Utils");
5
+ const AbstractDriver_1 = require("./AbstractDriver");
6
+ class PostgresDriver extends AbstractDriver_1.default {
7
+ constructor() {
8
+ super();
9
+ this.defaultValues = new TypeormDriver.PostgresDriver({
10
+ options: { replication: undefined },
11
+ }).dataTypeDefaults;
12
+ this.standardPort = 5432;
13
+ this.standardUser = "postgres";
14
+ this.standardSchema = "public";
15
+ try {
16
+ // eslint-disable-next-line import/no-extraneous-dependencies, global-require, import/no-unresolved
17
+ this.PG = require("pg");
18
+ }
19
+ catch (error) {
20
+ TomgUtils.LogError("", false, error);
21
+ throw error;
22
+ }
23
+ }
24
+ async GetAllTables(schemas, dbNames) {
25
+ const response = (await this.Connection.query(`SELECT table_schema as "TABLE_SCHEMA",table_name as "TABLE_NAME", table_catalog as "DB_NAME" FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND table_schema in (${PostgresDriver.buildEscapedObjectList(schemas)})`)).rows;
26
+ const ret = [];
27
+ response.forEach((val) => {
28
+ ret.push({
29
+ columns: [],
30
+ indices: [],
31
+ relations: [],
32
+ relationIds: [],
33
+ sqlName: val.TABLE_NAME,
34
+ tscName: val.TABLE_NAME,
35
+ fileName: val.TABLE_NAME,
36
+ database: dbNames.length > 1 ? val.DB_NAME : "",
37
+ schema: val.TABLE_SCHEMA,
38
+ fileImports: [],
39
+ });
40
+ });
41
+ return ret;
42
+ }
43
+ async GetCoulmnsFromEntity(entities, schemas) {
44
+ const response = (await this.Connection
45
+ .query(`SELECT table_name,column_name,udt_name,column_default,is_nullable,
46
+ data_type,character_maximum_length,numeric_precision,numeric_scale,
47
+ case when column_default LIKE 'nextval%' then 'YES' else 'NO' end isidentity,
48
+ is_identity,
49
+ (SELECT count(*)
50
+ FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
51
+ inner join INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE cu
52
+ on cu.CONSTRAINT_NAME = tc.CONSTRAINT_NAME
53
+ where
54
+ tc.CONSTRAINT_TYPE = 'UNIQUE'
55
+ and tc.TABLE_NAME = c.TABLE_NAME
56
+ and cu.COLUMN_NAME = c.COLUMN_NAME
57
+ and tc.TABLE_SCHEMA=c.TABLE_SCHEMA) IsUnique,
58
+ (SELECT
59
+ string_agg(enumlabel, ',')
60
+ FROM "pg_enum" "e"
61
+ INNER JOIN "pg_type" "t" ON "t"."oid" = "e"."enumtypid"
62
+ INNER JOIN "pg_namespace" "n" ON "n"."oid" = "t"."typnamespace"
63
+ WHERE "n"."nspname" = table_schema AND "t"."typname"=udt_name
64
+ ) enumValues
65
+ FROM INFORMATION_SCHEMA.COLUMNS c
66
+ where table_schema in (${PostgresDriver.buildEscapedObjectList(schemas)})
67
+ order by ordinal_position`)).rows;
68
+ entities.forEach((ent) => {
69
+ response
70
+ .filter((filterVal) => filterVal.table_name === ent.tscName)
71
+ .forEach((resp) => {
72
+ const tscName = resp.column_name;
73
+ const options = {
74
+ name: resp.column_name,
75
+ };
76
+ if (resp.is_nullable === "YES")
77
+ options.nullable = true;
78
+ if (resp.isunique === "1")
79
+ options.unique = true;
80
+ const generated = resp.isidentity === "YES" || resp.is_identity === "YES"
81
+ ? true
82
+ : undefined;
83
+ const defaultValue = generated
84
+ ? undefined
85
+ : PostgresDriver.ReturnDefaultValueFunction(resp.column_default, resp.data_type);
86
+ const columnTypes = this.MatchColumnTypes(resp.data_type, resp.udt_name, resp.enumvalues);
87
+ if (columnTypes.tsType === "NonNullable<unknown>") {
88
+ if (resp.data_type === "USER-DEFINED" ||
89
+ resp.data_type === "ARRAY") {
90
+ TomgUtils.LogError(`Unknown ${resp.data_type} column type: ${resp.udt_name} table name: ${resp.table_name} column name: ${resp.column_name}`);
91
+ }
92
+ else {
93
+ TomgUtils.LogError(`Unknown column type: ${resp.data_type} table name: ${resp.table_name} column name: ${resp.column_name}`);
94
+ }
95
+ return;
96
+ }
97
+ const columnType = columnTypes.sqlType;
98
+ let tscType = columnTypes.tsType;
99
+ if (columnTypes.isArray)
100
+ options.array = true;
101
+ if (columnTypes.enumValues.length > 0)
102
+ options.enum = columnTypes.enumValues;
103
+ if (options.array) {
104
+ tscType = tscType
105
+ .split("|")
106
+ .map((x) => `${x.replace("|", "").trim()}[]`)
107
+ .join(" | ");
108
+ }
109
+ if (this.ColumnTypesWithPrecision.some((v) => v === columnType)) {
110
+ if (resp.numeric_precision !== null) {
111
+ options.precision = resp.numeric_precision;
112
+ }
113
+ if (resp.numeric_scale !== null) {
114
+ options.scale = resp.numeric_scale;
115
+ }
116
+ }
117
+ if (this.ColumnTypesWithLength.some((v) => v === columnType)) {
118
+ options.length =
119
+ resp.character_maximum_length > 0
120
+ ? resp.character_maximum_length
121
+ : undefined;
122
+ }
123
+ if (this.ColumnTypesWithWidth.some((v) => v === columnType)) {
124
+ options.width =
125
+ resp.character_maximum_length > 0
126
+ ? resp.character_maximum_length
127
+ : undefined;
128
+ }
129
+ ent.columns.push({
130
+ generated,
131
+ type: columnType,
132
+ default: defaultValue,
133
+ options,
134
+ tscName,
135
+ tscType,
136
+ });
137
+ });
138
+ });
139
+ return entities;
140
+ }
141
+ MatchColumnTypes(dataType, udtName, enumValues) {
142
+ let ret = {
143
+ tsType: "",
144
+ sqlType: dataType,
145
+ isArray: false,
146
+ enumValues: [],
147
+ };
148
+ switch (dataType) {
149
+ case "int2":
150
+ ret.tsType = "number";
151
+ break;
152
+ case "int4":
153
+ ret.tsType = "number";
154
+ break;
155
+ case "int8":
156
+ ret.tsType = "string";
157
+ break;
158
+ case "smallint":
159
+ ret.tsType = "number";
160
+ break;
161
+ case "integer":
162
+ ret.tsType = "number";
163
+ break;
164
+ case "bigint":
165
+ ret.tsType = "string";
166
+ break;
167
+ case "decimal":
168
+ ret.tsType = "string";
169
+ break;
170
+ case "numeric":
171
+ ret.tsType = "string";
172
+ break;
173
+ case "real":
174
+ ret.tsType = "number";
175
+ break;
176
+ case "float":
177
+ ret.tsType = "number";
178
+ break;
179
+ case "float4":
180
+ ret.tsType = "number";
181
+ break;
182
+ case "float8":
183
+ ret.tsType = "number";
184
+ break;
185
+ case "double precision":
186
+ ret.tsType = "number";
187
+ break;
188
+ case "money":
189
+ ret.tsType = "string";
190
+ break;
191
+ case "character varying":
192
+ ret.tsType = "string";
193
+ break;
194
+ case "varchar":
195
+ ret.tsType = "string";
196
+ break;
197
+ case "character":
198
+ ret.tsType = "string";
199
+ break;
200
+ case "char":
201
+ ret.tsType = "string";
202
+ break;
203
+ case "bpchar":
204
+ ret.sqlType = "char";
205
+ ret.tsType = "string";
206
+ break;
207
+ case "text":
208
+ ret.tsType = "string";
209
+ break;
210
+ case "citext":
211
+ ret.tsType = "string";
212
+ break;
213
+ case "hstore":
214
+ ret.tsType = "string";
215
+ break;
216
+ case "bytea":
217
+ ret.tsType = "Buffer";
218
+ break;
219
+ case "bit":
220
+ ret.tsType = "string";
221
+ break;
222
+ case "varbit":
223
+ ret.tsType = "string";
224
+ break;
225
+ case "bit varying":
226
+ ret.tsType = "string";
227
+ break;
228
+ case "timetz":
229
+ ret.tsType = "string";
230
+ break;
231
+ case "timestamptz":
232
+ ret.tsType = "Date";
233
+ break;
234
+ case "timestamp":
235
+ ret.tsType = "string";
236
+ break;
237
+ case "timestamp without time zone":
238
+ ret.tsType = "Date";
239
+ break;
240
+ case "timestamp with time zone":
241
+ ret.tsType = "Date";
242
+ break;
243
+ case "date":
244
+ ret.tsType = "string";
245
+ break;
246
+ case "time":
247
+ ret.tsType = "string";
248
+ break;
249
+ case "time without time zone":
250
+ ret.tsType = "string";
251
+ break;
252
+ case "time with time zone":
253
+ ret.tsType = "string";
254
+ break;
255
+ case "interval":
256
+ ret.tsType = "any";
257
+ break;
258
+ case "bool":
259
+ ret.tsType = "boolean";
260
+ break;
261
+ case "boolean":
262
+ ret.tsType = "boolean";
263
+ break;
264
+ case "point":
265
+ ret.tsType = "string | object";
266
+ break;
267
+ case "line":
268
+ ret.tsType = "string";
269
+ break;
270
+ case "lseg":
271
+ ret.tsType = "string | string[]";
272
+ break;
273
+ case "box":
274
+ ret.tsType = "string | object";
275
+ break;
276
+ case "path":
277
+ ret.tsType = "string";
278
+ break;
279
+ case "polygon":
280
+ ret.tsType = "string";
281
+ break;
282
+ case "circle":
283
+ ret.tsType = "string | object";
284
+ break;
285
+ case "cidr":
286
+ ret.tsType = "string";
287
+ break;
288
+ case "inet":
289
+ ret.tsType = "string";
290
+ break;
291
+ case "macaddr":
292
+ ret.tsType = "string";
293
+ break;
294
+ case "tsvector":
295
+ ret.tsType = "string";
296
+ break;
297
+ case "tsquery":
298
+ ret.tsType = "string";
299
+ break;
300
+ case "uuid":
301
+ ret.tsType = "string";
302
+ break;
303
+ case "xml":
304
+ ret.tsType = "string";
305
+ break;
306
+ case "json":
307
+ ret.tsType = "object";
308
+ break;
309
+ case "jsonb":
310
+ ret.tsType = "object";
311
+ break;
312
+ case "int4range":
313
+ ret.tsType = "string";
314
+ break;
315
+ case "int8range":
316
+ ret.tsType = "string";
317
+ break;
318
+ case "numrange":
319
+ ret.tsType = "string";
320
+ break;
321
+ case "tsrange":
322
+ ret.tsType = "string";
323
+ break;
324
+ case "tstzrange":
325
+ ret.tsType = "string";
326
+ break;
327
+ case "daterange":
328
+ ret.tsType = "string";
329
+ break;
330
+ case "ARRAY":
331
+ ret = this.MatchColumnTypes(udtName.substring(1), udtName, enumValues);
332
+ ret.isArray = true;
333
+ break;
334
+ case "USER-DEFINED":
335
+ ret.tsType = "string";
336
+ switch (udtName) {
337
+ case "citext":
338
+ case "hstore":
339
+ case "geography":
340
+ case "geometry":
341
+ case "ltree":
342
+ ret.sqlType = udtName;
343
+ break;
344
+ default:
345
+ if (enumValues) {
346
+ ret.tsType = `"${enumValues
347
+ .split(",")
348
+ .join('" | "')}"`;
349
+ ret.sqlType = "enum";
350
+ ret.enumValues = enumValues.split(",");
351
+ }
352
+ break;
353
+ }
354
+ break;
355
+ default:
356
+ ret.tsType = "NonNullable<unknown>";
357
+ break;
358
+ }
359
+ return ret;
360
+ }
361
+ async GetIndexesFromEntity(entities, schemas) {
362
+ const response = (await this.Connection.query(`SELECT
363
+ c.relname AS tablename,
364
+ i.relname as indexname,
365
+ f.attname AS columnname,
366
+ CASE
367
+ WHEN ix.indisunique = true THEN 1
368
+ ELSE 0
369
+ END AS is_unique,
370
+ CASE
371
+ WHEN ix.indisprimary='true' THEN 1
372
+ ELSE 0
373
+ END AS is_primary_key
374
+ FROM pg_attribute f
375
+ JOIN pg_class c ON c.oid = f.attrelid
376
+ JOIN pg_type t ON t.oid = f.atttypid
377
+ LEFT JOIN pg_attrdef d ON d.adrelid = c.oid AND d.adnum = f.attnum
378
+ LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
379
+ LEFT JOIN pg_index AS ix ON f.attnum = ANY(ix.indkey) and c.oid = f.attrelid and c.oid = ix.indrelid
380
+ LEFT JOIN pg_class AS i ON ix.indexrelid = i.oid
381
+ WHERE c.relkind = 'r'::char
382
+ AND n.nspname in (${PostgresDriver.buildEscapedObjectList(schemas)})
383
+ AND f.attnum > 0
384
+ AND i.oid<>0
385
+ ORDER BY c.relname,f.attname;`)).rows;
386
+ entities.forEach((ent) => {
387
+ const entityIndices = response.filter((filterVal) => filterVal.tablename === ent.tscName);
388
+ const indexNames = new Set(entityIndices.map((v) => v.indexname));
389
+ indexNames.forEach((indexName) => {
390
+ const records = entityIndices.filter((v) => v.indexname === indexName);
391
+ const indexInfo = {
392
+ columns: [],
393
+ options: {},
394
+ name: records[0].indexname,
395
+ };
396
+ if (records[0].is_primary_key === 1)
397
+ indexInfo.primary = true;
398
+ if (records[0].is_unique === 1)
399
+ indexInfo.options.unique = true;
400
+ records.forEach((record) => {
401
+ indexInfo.columns.push(record.columnname);
402
+ });
403
+ ent.indices.push(indexInfo);
404
+ });
405
+ });
406
+ return entities;
407
+ }
408
+ async GetRelations(entities, schemas, dbNames, generationOptions) {
409
+ const response = (await this.Connection.query(`SELECT DISTINCT
410
+ con.relname AS tablewithforeignkey,
411
+ att.attnum as fk_partno,
412
+ att2.attname AS foreignkeycolumn,
413
+ cl.relname AS tablereferenced,
414
+ att.attname AS foreignkeycolumnreferenced,
415
+ delete_rule as ondelete,
416
+ update_rule as onupdate,
417
+ concat(con.conname,con.conrelid,con.confrelid) as object_id
418
+ FROM (
419
+ SELECT
420
+ unnest(con1.conkey) AS parent,
421
+ unnest(con1.confkey) AS child,
422
+ con1.confrelid,
423
+ con1.conrelid,
424
+ cl_1.relname,
425
+ con1.conname,
426
+ nspname
427
+ FROM
428
+ pg_class cl_1,
429
+ pg_namespace ns,
430
+ pg_constraint con1
431
+ WHERE
432
+ con1.contype = 'f'::"char"
433
+ AND cl_1.relnamespace = ns.oid
434
+ AND con1.conrelid = cl_1.oid
435
+ and nspname in (${PostgresDriver.buildEscapedObjectList(schemas)})
436
+ ) con,
437
+ pg_attribute att,
438
+ pg_class cl,
439
+ pg_attribute att2,
440
+ information_schema.referential_constraints rc
441
+ WHERE
442
+ att.attrelid = con.confrelid
443
+ AND att.attnum = con.child
444
+ AND cl.oid = con.confrelid
445
+ AND att2.attrelid = con.conrelid
446
+ AND att2.attnum = con.parent
447
+ AND rc.constraint_name= con.conname AND constraint_catalog=current_database() AND rc.constraint_schema=nspname
448
+ `)).rows;
449
+ const relationsTemp = [];
450
+ const relationKeys = new Set(response.map((v) => v.object_id));
451
+ relationKeys.forEach((relationId) => {
452
+ const rows = response.filter((v) => v.object_id === relationId);
453
+ const ownerTable = entities.find((v) => v.sqlName === rows[0].tablewithforeignkey);
454
+ const relatedTable = entities.find((v) => v.sqlName === rows[0].tablereferenced);
455
+ if (!ownerTable || !relatedTable) {
456
+ TomgUtils.LogError(`Relation between tables ${rows[0].tablewithforeignkey} and ${rows[0].tablereferenced} wasn't found in entity model.`, true);
457
+ return;
458
+ }
459
+ const internal = {
460
+ ownerColumns: [],
461
+ relatedColumns: [],
462
+ ownerTable,
463
+ relatedTable,
464
+ };
465
+ if (rows[0].ondelete !== "NO ACTION") {
466
+ internal.onDelete = rows[0].ondelete;
467
+ }
468
+ if (rows[0].onupdate !== "NO ACTION") {
469
+ internal.onUpdate = rows[0].onupdate;
470
+ }
471
+ rows.forEach((row) => {
472
+ internal.ownerColumns.push(row.foreignkeycolumn);
473
+ internal.relatedColumns.push(row.foreignkeycolumnreferenced);
474
+ });
475
+ relationsTemp.push(internal);
476
+ });
477
+ const retVal = PostgresDriver.GetRelationsFromRelationTempInfo(relationsTemp, entities, generationOptions);
478
+ return retVal;
479
+ }
480
+ async DisconnectFromServer() {
481
+ if (this.Connection) {
482
+ const promise = new Promise((resolve, reject) => {
483
+ this.Connection.end((err) => {
484
+ if (!err) {
485
+ resolve(true);
486
+ }
487
+ else {
488
+ TomgUtils.LogError("Error disconnecting from to Postgres Server.", false, err.message);
489
+ reject(err);
490
+ }
491
+ });
492
+ });
493
+ await promise;
494
+ }
495
+ }
496
+ async ConnectToServer(connectionOptons) {
497
+ this.Connection = new this.PG.Client({
498
+ database: connectionOptons.databaseNames[0],
499
+ host: connectionOptons.host,
500
+ password: connectionOptons.password,
501
+ port: connectionOptons.port,
502
+ ssl: connectionOptons.ssl,
503
+ statement_timeout: 60 * 60 * 1000,
504
+ user: connectionOptons.user,
505
+ });
506
+ const promise = new Promise((resolve, reject) => {
507
+ this.Connection.connect((err) => {
508
+ if (!err) {
509
+ resolve(true);
510
+ }
511
+ else {
512
+ TomgUtils.LogError("Error connecting to Postgres Server.", false, err.message);
513
+ reject(err);
514
+ }
515
+ });
516
+ });
517
+ await promise;
518
+ }
519
+ async CreateDB(dbName) {
520
+ await this.Connection.query(`CREATE DATABASE ${dbName}; `);
521
+ }
522
+ async DropDB(dbName) {
523
+ await this.Connection.query(`DROP DATABASE ${dbName}; `);
524
+ }
525
+ async CheckIfDBExists(dbName) {
526
+ const resp = await this.Connection.query(`SELECT datname FROM pg_database WHERE datname ='${dbName}' `);
527
+ return resp.rowCount > 0;
528
+ }
529
+ static ReturnDefaultValueFunction(defVal, dataType) {
530
+ let defaultValue = defVal;
531
+ if (!defaultValue) {
532
+ return undefined;
533
+ }
534
+ defaultValue = defaultValue.replace(/'::[\w ]*/, "'");
535
+ if (["json", "jsonb"].some((x) => x === dataType)) {
536
+ return `${defaultValue.slice(1, defaultValue.length - 1)}`;
537
+ }
538
+ return `() => "${defaultValue}"`;
539
+ }
540
+ }
541
+ exports.default = PostgresDriver;
542
+ //# sourceMappingURL=PostgresDriver.js.map
@@ -0,0 +1,28 @@
1
+ import { DataTypeDefaults } from "typeorm/driver/types/DataTypeDefaults";
2
+ import AbstractDriver from "./AbstractDriver";
3
+ import IConnectionOptions from "../IConnectionOptions";
4
+ import { Entity } from "../models/Entity";
5
+ import IGenerationOptions from "../IGenerationOptions";
6
+ export default class SqliteDriver extends AbstractDriver {
7
+ defaultValues: DataTypeDefaults;
8
+ readonly standardPort = 0;
9
+ readonly standardUser = "";
10
+ readonly standardSchema = "";
11
+ private sqliteLib;
12
+ private sqlite;
13
+ private db;
14
+ private tablesWithGeneratedPrimaryKey;
15
+ GetAllTablesQuery: any;
16
+ constructor();
17
+ GetAllTables(schemas: string[], dbNames: string[]): Promise<Entity[]>;
18
+ GetCoulmnsFromEntity(entities: Entity[]): Promise<Entity[]>;
19
+ GetIndexesFromEntity(entities: Entity[]): Promise<Entity[]>;
20
+ GetRelations(entities: Entity[], schemas: string[], dbNames: string[], generationOptions: IGenerationOptions): Promise<Entity[]>;
21
+ DisconnectFromServer(): Promise<void>;
22
+ ConnectToServer(connectionOptons: IConnectionOptions): Promise<void>;
23
+ CreateDB(): Promise<void>;
24
+ DropDB(): Promise<void>;
25
+ CheckIfDBExists(): Promise<boolean>;
26
+ ExecQuery<T>(sql: string): Promise<T[]>;
27
+ private static ReturnDefaultValueFunction;
28
+ }