@egi/smart-db 2.3.1 → 2.3.2

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 (74) hide show
  1. package/.eslintrc.json +212 -0
  2. package/README.md +2 -0
  3. package/bin/copy-assets +6 -0
  4. package/package.json +1 -1
  5. package/src/drivers/smart-db-better-sqlite3.ts +284 -0
  6. package/src/drivers/smart-db-mysql.ts +159 -0
  7. package/src/drivers/smart-db-mysql2.ts +159 -0
  8. package/src/drivers/smart-db-sqlite3.ts +198 -0
  9. package/src/helpers/extract-db-api.ts +465 -0
  10. package/src/helpers/terser-tree.ts +39 -0
  11. package/src/models/abstract-model.ts +209 -0
  12. package/src/models/smart-db-core-table-model.ts +161 -0
  13. package/src/models/smart-db-dictionary.ts +28 -0
  14. package/src/models/smart-db-log-model.ts +316 -0
  15. package/src/models/smart-db-version-model.ts +316 -0
  16. package/src/models/smart-db-version-view-model.ts +347 -0
  17. package/src/models/sqlite-master-model.ts +140 -0
  18. package/src/models/sqlite-sequence-model.ts +91 -0
  19. package/{smart-db-api.d.ts → src/smart-db-api.ts} +3 -0
  20. package/src/smart-db-globals.ts +136 -0
  21. package/{smart-db-interfaces.d.ts → src/smart-db-interfaces.ts} +82 -34
  22. package/src/smart-db-log.ts +262 -0
  23. package/src/smart-db-sql-build-data.ts +28 -0
  24. package/src/smart-db-upgrade-manager.ts +171 -0
  25. package/src/smart-db.ts +854 -0
  26. package/test/data/sql-engine-tests.json +232 -0
  27. package/test/db/mysql/database-init.sql +11 -0
  28. package/test/db/sqlite3/database-init.sql +11 -0
  29. package/test/exer.js +28 -0
  30. package/test/model/smart-db-dictionary.ts +19 -0
  31. package/test/model/test-table-model.ts +214 -0
  32. package/test/test.js +273 -0
  33. package/test/test2.js +252 -0
  34. package/tsconfig.json +32 -0
  35. package/tsconfig.pro.json +32 -0
  36. package/tsconfig.test-model.json +23 -0
  37. package/drivers/smart-db-better-sqlite3.d.ts +0 -36
  38. package/drivers/smart-db-better-sqlite3.js +0 -1
  39. package/drivers/smart-db-mysql.d.ts +0 -26
  40. package/drivers/smart-db-mysql.js +0 -1
  41. package/drivers/smart-db-mysql2.d.ts +0 -26
  42. package/drivers/smart-db-mysql2.js +0 -1
  43. package/drivers/smart-db-sqlite3.d.ts +0 -30
  44. package/drivers/smart-db-sqlite3.js +0 -1
  45. package/helpers/extract-db-api.d.ts +0 -1
  46. package/helpers/extract-db-api.js +0 -1
  47. package/models/abstract-model.d.ts +0 -22
  48. package/models/abstract-model.js +0 -1
  49. package/models/smart-db-core-table-model.d.ts +0 -35
  50. package/models/smart-db-core-table-model.js +0 -1
  51. package/models/smart-db-dictionary.d.ts +0 -13
  52. package/models/smart-db-dictionary.js +0 -1
  53. package/models/smart-db-log-model.d.ts +0 -65
  54. package/models/smart-db-log-model.js +0 -1
  55. package/models/smart-db-version-model.d.ts +0 -65
  56. package/models/smart-db-version-model.js +0 -1
  57. package/models/smart-db-version-view-model.d.ts +0 -71
  58. package/models/smart-db-version-view-model.js +0 -1
  59. package/models/sqlite-master-model.d.ts +0 -36
  60. package/models/sqlite-master-model.js +0 -1
  61. package/models/sqlite-sequence-model.d.ts +0 -24
  62. package/models/sqlite-sequence-model.js +0 -1
  63. package/smart-db-api.js +0 -1
  64. package/smart-db-globals.d.ts +0 -22
  65. package/smart-db-globals.js +0 -1
  66. package/smart-db-interfaces.js +0 -1
  67. package/smart-db-log.d.ts +0 -58
  68. package/smart-db-log.js +0 -1
  69. package/smart-db-sql-build-data.d.ts +0 -9
  70. package/smart-db-sql-build-data.js +0 -1
  71. package/smart-db-upgrade-manager.d.ts +0 -13
  72. package/smart-db-upgrade-manager.js +0 -1
  73. package/smart-db.d.ts +0 -67
  74. package/smart-db.js +0 -1
@@ -0,0 +1,316 @@
1
+ /* eslint-disable @typescript-eslint/member-ordering */
2
+ // noinspection JSUnusedGlobalSymbols
3
+
4
+ import {GenericModelData, ModelAttributeMap} from "../smart-db-interfaces";
5
+ import {AbstractModel} from "./abstract-model";
6
+
7
+ export interface SmartDbVersionModelData extends GenericModelData {
8
+ id?: number;
9
+ module?: string;
10
+ sequence?: number;
11
+ version?: string;
12
+ subVersion?: string;
13
+ revision?: string;
14
+ releaseType?: string;
15
+ installDate?: Date;
16
+ }
17
+
18
+ export class SmartDbVersionModel extends AbstractModel<SmartDbVersionModel, SmartDbVersionModelData> {
19
+ private _id?: number;
20
+ private _module?: string;
21
+ private _sequence?: number;
22
+ private _version?: string;
23
+ private _subVersion?: string;
24
+ private _revision?: string;
25
+ private _releaseType?: string;
26
+ private _installDate?: Date;
27
+
28
+ static readonly attributeMap: ModelAttributeMap = {
29
+ id: {
30
+ alias: "ver_id",
31
+ typeScriptStyle: true,
32
+ type: "number",
33
+ attribute: "_id"
34
+ },
35
+ ver_id: {
36
+ physical: true,
37
+ type: "number",
38
+ attribute: "_id"
39
+ },
40
+ module: {
41
+ alias: "ver_module",
42
+ typeScriptStyle: true,
43
+ type: "string",
44
+ attribute: "_module"
45
+ },
46
+ ver_module: {
47
+ physical: true,
48
+ type: "string",
49
+ attribute: "_module"
50
+ },
51
+ sequence: {
52
+ alias: "ver_sequence",
53
+ typeScriptStyle: true,
54
+ type: "number",
55
+ attribute: "_sequence"
56
+ },
57
+ ver_sequence: {
58
+ physical: true,
59
+ type: "number",
60
+ attribute: "_sequence"
61
+ },
62
+ version: {
63
+ alias: "ver_version",
64
+ typeScriptStyle: true,
65
+ type: "string",
66
+ attribute: "_version"
67
+ },
68
+ ver_version: {
69
+ physical: true,
70
+ type: "string",
71
+ attribute: "_version"
72
+ },
73
+ subVersion: {
74
+ alias: "ver_sub_version",
75
+ typeScriptStyle: true,
76
+ type: "string",
77
+ attribute: "_subVersion"
78
+ },
79
+ ver_sub_version: {
80
+ physical: true,
81
+ type: "string",
82
+ attribute: "_subVersion"
83
+ },
84
+ revision: {
85
+ alias: "ver_revision",
86
+ typeScriptStyle: true,
87
+ type: "string",
88
+ attribute: "_revision"
89
+ },
90
+ ver_revision: {
91
+ physical: true,
92
+ type: "string",
93
+ attribute: "_revision"
94
+ },
95
+ releaseType: {
96
+ alias: "ver_release_type",
97
+ typeScriptStyle: true,
98
+ type: "string",
99
+ attribute: "_releaseType"
100
+ },
101
+ ver_release_type: {
102
+ physical: true,
103
+ type: "string",
104
+ attribute: "_releaseType"
105
+ },
106
+ installDate: {
107
+ alias: "ver_install_date",
108
+ typeScriptStyle: true,
109
+ type: "Date",
110
+ attribute: "_installDate"
111
+ },
112
+ ver_install_date: {
113
+ physical: true,
114
+ type: "Date",
115
+ attribute: "_installDate"
116
+ }
117
+ };
118
+
119
+ constructor(data?: SmartDbVersionModel | SmartDbVersionModelData) {
120
+ super();
121
+ if (data) {
122
+ this.assign(data);
123
+ }
124
+ }
125
+
126
+ static getClassName(): string {
127
+ return "SmartDbVersionModel";
128
+ }
129
+
130
+ static getTableName(): string {
131
+ return "smart_db_version";
132
+ }
133
+
134
+ static getPrimaryKey(): string {
135
+ return "ver_id";
136
+ }
137
+
138
+ static from(other: SmartDbVersionModel | SmartDbVersionModelData): SmartDbVersionModel {
139
+ let value: SmartDbVersionModel = null;
140
+ if (other) {
141
+ value = new SmartDbVersionModel();
142
+ if (other instanceof SmartDbVersionModel) {
143
+ Object.assign(value, other);
144
+ } else {
145
+ value.assign(other);
146
+ }
147
+ }
148
+ return value;
149
+ }
150
+
151
+ public clone(): SmartDbVersionModel {
152
+ return SmartDbVersionModel.from(this);
153
+ }
154
+
155
+ public getClassName(): string {
156
+ return "SmartDbVersionModel";
157
+ }
158
+
159
+ public getTableName(): string {
160
+ return "smart_db_version";
161
+ }
162
+
163
+ public getPrimaryKey(): string {
164
+ return "ver_id";
165
+ }
166
+
167
+ public getAttributeMap(): ModelAttributeMap {
168
+ return SmartDbVersionModel.attributeMap;
169
+ }
170
+
171
+ // noinspection FunctionNamingConventionJS
172
+ get id(): number {
173
+ return this._id;
174
+ }
175
+
176
+ // noinspection FunctionNamingConventionJS
177
+ set id(id: number) {
178
+ this._id = id;
179
+ }
180
+
181
+ get installDate(): Date {
182
+ return this._installDate;
183
+ }
184
+
185
+ set installDate(installDate: Date) {
186
+ this._installDate = installDate;
187
+ }
188
+
189
+ get module(): string {
190
+ return this._module;
191
+ }
192
+
193
+ set module(module: string) {
194
+ this._module = module;
195
+ }
196
+
197
+ get releaseType(): string {
198
+ return this._releaseType;
199
+ }
200
+
201
+ set releaseType(releaseType: string) {
202
+ this._releaseType = releaseType;
203
+ }
204
+
205
+ get revision(): string {
206
+ return this._revision;
207
+ }
208
+
209
+ set revision(revision: string) {
210
+ this._revision = revision;
211
+ }
212
+
213
+ get sequence(): number {
214
+ return this._sequence;
215
+ }
216
+
217
+ set sequence(sequence: number) {
218
+ this._sequence = sequence;
219
+ }
220
+
221
+ get subVersion(): string {
222
+ return this._subVersion;
223
+ }
224
+
225
+ set subVersion(subVersion: string) {
226
+ this._subVersion = subVersion;
227
+ }
228
+
229
+ // noinspection FunctionNamingConventionJS
230
+ get ver_id(): number {
231
+ return this._id;
232
+ }
233
+
234
+ // noinspection FunctionNamingConventionJS
235
+ set ver_id(id: number) {
236
+ this._id = id;
237
+ }
238
+
239
+ // noinspection FunctionNamingConventionJS
240
+ get ver_install_date(): Date {
241
+ return this._installDate;
242
+ }
243
+
244
+ // noinspection FunctionNamingConventionJS
245
+ set ver_install_date(installDate: Date) {
246
+ this._installDate = installDate;
247
+ }
248
+
249
+ // noinspection FunctionNamingConventionJS
250
+ get ver_module(): string {
251
+ return this._module;
252
+ }
253
+
254
+ // noinspection FunctionNamingConventionJS
255
+ set ver_module(module: string) {
256
+ this._module = module;
257
+ }
258
+
259
+ // noinspection FunctionNamingConventionJS
260
+ get ver_release_type(): string {
261
+ return this._releaseType;
262
+ }
263
+
264
+ // noinspection FunctionNamingConventionJS
265
+ set ver_release_type(releaseType: string) {
266
+ this._releaseType = releaseType;
267
+ }
268
+
269
+ // noinspection FunctionNamingConventionJS
270
+ get ver_revision(): string {
271
+ return this._revision;
272
+ }
273
+
274
+ // noinspection FunctionNamingConventionJS
275
+ set ver_revision(revision: string) {
276
+ this._revision = revision;
277
+ }
278
+
279
+ // noinspection FunctionNamingConventionJS
280
+ get ver_sequence(): number {
281
+ return this._sequence;
282
+ }
283
+
284
+ // noinspection FunctionNamingConventionJS
285
+ set ver_sequence(sequence: number) {
286
+ this._sequence = sequence;
287
+ }
288
+
289
+ // noinspection FunctionNamingConventionJS
290
+ get ver_sub_version(): string {
291
+ return this._subVersion;
292
+ }
293
+
294
+ // noinspection FunctionNamingConventionJS
295
+ set ver_sub_version(subVersion: string) {
296
+ this._subVersion = subVersion;
297
+ }
298
+
299
+ // noinspection FunctionNamingConventionJS
300
+ get ver_version(): string {
301
+ return this._version;
302
+ }
303
+
304
+ // noinspection FunctionNamingConventionJS
305
+ set ver_version(version: string) {
306
+ this._version = version;
307
+ }
308
+
309
+ get version(): string {
310
+ return this._version;
311
+ }
312
+
313
+ set version(version: string) {
314
+ this._version = version;
315
+ }
316
+ }
@@ -0,0 +1,347 @@
1
+ /* eslint-disable @typescript-eslint/member-ordering */
2
+ // noinspection JSUnusedGlobalSymbols
3
+
4
+ import {GenericModelData, ModelAttributeMap, SqlValueType} from "../smart-db-interfaces";
5
+ import {AbstractModel} from "./abstract-model";
6
+
7
+ export interface SmartDbVersionViewModelData extends GenericModelData {
8
+ id?: number;
9
+ module?: string;
10
+ sequence?: number;
11
+ version?: string;
12
+ subVersion?: string;
13
+ revision?: string;
14
+ releaseType?: string;
15
+ installDate?: Date;
16
+ versionString?: SqlValueType;
17
+ }
18
+
19
+ export class SmartDbVersionViewModel extends AbstractModel<SmartDbVersionViewModel, SmartDbVersionViewModelData> {
20
+ private _id?: number;
21
+ private _module?: string;
22
+ private _sequence?: number;
23
+ private _version?: string;
24
+ private _subVersion?: string;
25
+ private _revision?: string;
26
+ private _releaseType?: string;
27
+ private _installDate?: Date;
28
+ private _versionString?: SqlValueType;
29
+
30
+ static readonly attributeMap: ModelAttributeMap = {
31
+ id: {
32
+ alias: "ver_id",
33
+ typeScriptStyle: true,
34
+ type: "number",
35
+ attribute: "_id"
36
+ },
37
+ ver_id: {
38
+ physical: true,
39
+ type: "number",
40
+ attribute: "_id"
41
+ },
42
+ module: {
43
+ alias: "ver_module",
44
+ typeScriptStyle: true,
45
+ type: "string",
46
+ attribute: "_module"
47
+ },
48
+ ver_module: {
49
+ physical: true,
50
+ type: "string",
51
+ attribute: "_module"
52
+ },
53
+ sequence: {
54
+ alias: "ver_sequence",
55
+ typeScriptStyle: true,
56
+ type: "number",
57
+ attribute: "_sequence"
58
+ },
59
+ ver_sequence: {
60
+ physical: true,
61
+ type: "number",
62
+ attribute: "_sequence"
63
+ },
64
+ version: {
65
+ alias: "ver_version",
66
+ typeScriptStyle: true,
67
+ type: "string",
68
+ attribute: "_version"
69
+ },
70
+ ver_version: {
71
+ physical: true,
72
+ type: "string",
73
+ attribute: "_version"
74
+ },
75
+ subVersion: {
76
+ alias: "ver_sub_version",
77
+ typeScriptStyle: true,
78
+ type: "string",
79
+ attribute: "_subVersion"
80
+ },
81
+ ver_sub_version: {
82
+ physical: true,
83
+ type: "string",
84
+ attribute: "_subVersion"
85
+ },
86
+ revision: {
87
+ alias: "ver_revision",
88
+ typeScriptStyle: true,
89
+ type: "string",
90
+ attribute: "_revision"
91
+ },
92
+ ver_revision: {
93
+ physical: true,
94
+ type: "string",
95
+ attribute: "_revision"
96
+ },
97
+ releaseType: {
98
+ alias: "ver_release_type",
99
+ typeScriptStyle: true,
100
+ type: "string",
101
+ attribute: "_releaseType"
102
+ },
103
+ ver_release_type: {
104
+ physical: true,
105
+ type: "string",
106
+ attribute: "_releaseType"
107
+ },
108
+ installDate: {
109
+ alias: "ver_install_date",
110
+ typeScriptStyle: true,
111
+ type: "Date",
112
+ attribute: "_installDate"
113
+ },
114
+ ver_install_date: {
115
+ physical: true,
116
+ type: "Date",
117
+ attribute: "_installDate"
118
+ },
119
+ versionString: {
120
+ alias: "ver_version_string",
121
+ typeScriptStyle: true,
122
+ type: "SqlValueType",
123
+ attribute: "_versionString"
124
+ },
125
+ ver_version_string: {
126
+ physical: true,
127
+ type: "SqlValueType",
128
+ attribute: "_versionString"
129
+ }
130
+ };
131
+
132
+ constructor(data?: SmartDbVersionViewModel | SmartDbVersionViewModelData) {
133
+ super();
134
+ if (data) {
135
+ this.assign(data);
136
+ }
137
+ }
138
+
139
+ static getClassName(): string {
140
+ return "SmartDbVersionViewModel";
141
+ }
142
+
143
+ static getTableName(): string {
144
+ return "smart_db_version_view";
145
+ }
146
+
147
+ static getPrimaryKey(): string {
148
+ return "";
149
+ }
150
+
151
+ static from(other: SmartDbVersionViewModel | SmartDbVersionViewModelData): SmartDbVersionViewModel {
152
+ let value: SmartDbVersionViewModel = null;
153
+ if (other) {
154
+ value = new SmartDbVersionViewModel();
155
+ if (other instanceof SmartDbVersionViewModel) {
156
+ Object.assign(value, other);
157
+ } else {
158
+ value.assign(other);
159
+ }
160
+ }
161
+ return value;
162
+ }
163
+
164
+ public clone(): SmartDbVersionViewModel {
165
+ return SmartDbVersionViewModel.from(this);
166
+ }
167
+
168
+ public getClassName(): string {
169
+ return "SmartDbVersionViewModel";
170
+ }
171
+
172
+ public getTableName(): string {
173
+ return "smart_db_version_view";
174
+ }
175
+
176
+ public getPrimaryKey(): string {
177
+ return "";
178
+ }
179
+
180
+ public getAttributeMap(): ModelAttributeMap {
181
+ return SmartDbVersionViewModel.attributeMap;
182
+ }
183
+
184
+ // noinspection FunctionNamingConventionJS
185
+ get id(): number {
186
+ return this._id;
187
+ }
188
+
189
+ // noinspection FunctionNamingConventionJS
190
+ set id(id: number) {
191
+ this._id = id;
192
+ }
193
+
194
+ get installDate(): Date {
195
+ return this._installDate;
196
+ }
197
+
198
+ set installDate(installDate: Date) {
199
+ this._installDate = installDate;
200
+ }
201
+
202
+ get module(): string {
203
+ return this._module;
204
+ }
205
+
206
+ set module(module: string) {
207
+ this._module = module;
208
+ }
209
+
210
+ get releaseType(): string {
211
+ return this._releaseType;
212
+ }
213
+
214
+ set releaseType(releaseType: string) {
215
+ this._releaseType = releaseType;
216
+ }
217
+
218
+ get revision(): string {
219
+ return this._revision;
220
+ }
221
+
222
+ set revision(revision: string) {
223
+ this._revision = revision;
224
+ }
225
+
226
+ get sequence(): number {
227
+ return this._sequence;
228
+ }
229
+
230
+ set sequence(sequence: number) {
231
+ this._sequence = sequence;
232
+ }
233
+
234
+ get subVersion(): string {
235
+ return this._subVersion;
236
+ }
237
+
238
+ set subVersion(subVersion: string) {
239
+ this._subVersion = subVersion;
240
+ }
241
+
242
+ // noinspection FunctionNamingConventionJS
243
+ get ver_id(): number {
244
+ return this._id;
245
+ }
246
+
247
+ // noinspection FunctionNamingConventionJS
248
+ set ver_id(id: number) {
249
+ this._id = id;
250
+ }
251
+
252
+ // noinspection FunctionNamingConventionJS
253
+ get ver_install_date(): Date {
254
+ return this._installDate;
255
+ }
256
+
257
+ // noinspection FunctionNamingConventionJS
258
+ set ver_install_date(installDate: Date) {
259
+ this._installDate = installDate;
260
+ }
261
+
262
+ // noinspection FunctionNamingConventionJS
263
+ get ver_module(): string {
264
+ return this._module;
265
+ }
266
+
267
+ // noinspection FunctionNamingConventionJS
268
+ set ver_module(module: string) {
269
+ this._module = module;
270
+ }
271
+
272
+ // noinspection FunctionNamingConventionJS
273
+ get ver_release_type(): string {
274
+ return this._releaseType;
275
+ }
276
+
277
+ // noinspection FunctionNamingConventionJS
278
+ set ver_release_type(releaseType: string) {
279
+ this._releaseType = releaseType;
280
+ }
281
+
282
+ // noinspection FunctionNamingConventionJS
283
+ get ver_revision(): string {
284
+ return this._revision;
285
+ }
286
+
287
+ // noinspection FunctionNamingConventionJS
288
+ set ver_revision(revision: string) {
289
+ this._revision = revision;
290
+ }
291
+
292
+ // noinspection FunctionNamingConventionJS
293
+ get ver_sequence(): number {
294
+ return this._sequence;
295
+ }
296
+
297
+ // noinspection FunctionNamingConventionJS
298
+ set ver_sequence(sequence: number) {
299
+ this._sequence = sequence;
300
+ }
301
+
302
+ // noinspection FunctionNamingConventionJS
303
+ get ver_sub_version(): string {
304
+ return this._subVersion;
305
+ }
306
+
307
+ // noinspection FunctionNamingConventionJS
308
+ set ver_sub_version(subVersion: string) {
309
+ this._subVersion = subVersion;
310
+ }
311
+
312
+ // noinspection FunctionNamingConventionJS
313
+ get ver_version(): string {
314
+ return this._version;
315
+ }
316
+
317
+ // noinspection FunctionNamingConventionJS
318
+ set ver_version(version: string) {
319
+ this._version = version;
320
+ }
321
+
322
+ // noinspection FunctionNamingConventionJS
323
+ get ver_version_string(): SqlValueType {
324
+ return this._versionString;
325
+ }
326
+
327
+ // noinspection FunctionNamingConventionJS
328
+ set ver_version_string(versionString: SqlValueType) {
329
+ this._versionString = versionString;
330
+ }
331
+
332
+ get version(): string {
333
+ return this._version;
334
+ }
335
+
336
+ set version(version: string) {
337
+ this._version = version;
338
+ }
339
+
340
+ get versionString(): SqlValueType {
341
+ return this._versionString;
342
+ }
343
+
344
+ set versionString(versionString: SqlValueType) {
345
+ this._versionString = versionString;
346
+ }
347
+ }