@egi/smart-db 2.4.10 → 2.5.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 (54) hide show
  1. package/assets/oracle/smart-db-core-init.sql +116 -0
  2. package/drivers/smart-db-better-sqlite3.d.ts +3 -2
  3. package/drivers/smart-db-better-sqlite3.js +1 -1
  4. package/drivers/smart-db-mysql.d.ts +3 -1
  5. package/drivers/smart-db-mysql.js +1 -1
  6. package/drivers/smart-db-mysql2.d.ts +3 -1
  7. package/drivers/smart-db-mysql2.js +1 -1
  8. package/drivers/smart-db-oracle.d.ts +36 -0
  9. package/drivers/smart-db-oracle.js +1 -0
  10. package/drivers/smart-db-sqlite3.d.ts +2 -0
  11. package/drivers/smart-db-sqlite3.js +1 -1
  12. package/helpers/extract-db-api.js +1 -1
  13. package/models/abstract-model.js +1 -1
  14. package/models/oracle-cat-model.d.ts +23 -0
  15. package/models/oracle-cat-model.js +1 -0
  16. package/models/oracle-user-tab-columns-model.d.ts +39 -0
  17. package/models/oracle-user-tab-columns-model.js +1 -0
  18. package/models/oracle-user-tab-columns-view-model.d.ts +43 -0
  19. package/models/oracle-user-tab-columns-view-model.js +1 -0
  20. package/models/smart-db-core-table-model.d.ts +6 -0
  21. package/models/smart-db-core-table-model.js +1 -1
  22. package/models/smart-db-dictionary.d.ts +2 -1
  23. package/models/smart-db-dictionary.js +1 -1
  24. package/models/smart-db-log-model.d.ts +22 -5
  25. package/models/smart-db-log-model.js +1 -1
  26. package/models/smart-db-user-tab-columns-view-model.d.ts +305 -0
  27. package/models/smart-db-user-tab-columns-view-model.js +1 -0
  28. package/models/smart-db-version-model.d.ts +22 -5
  29. package/models/smart-db-version-model.js +1 -1
  30. package/models/smart-db-version-view-model.d.ts +28 -10
  31. package/models/smart-db-version-view-model.js +1 -1
  32. package/models.generated/abstract-model.d.ts +23 -0
  33. package/models.generated/abstract-model.js +1 -0
  34. package/models.generated/smart-db-core-table-model.d.ts +41 -0
  35. package/models.generated/smart-db-core-table-model.js +1 -0
  36. package/models.generated/smart-db-dictionary.d.ts +14 -0
  37. package/models.generated/smart-db-dictionary.js +1 -0
  38. package/models.generated/smart-db-log-model.d.ts +82 -0
  39. package/models.generated/smart-db-log-model.js +1 -0
  40. package/models.generated/smart-db-user-tab-columns-view-model.d.ts +305 -0
  41. package/models.generated/smart-db-user-tab-columns-view-model.js +1 -0
  42. package/models.generated/smart-db-version-model.d.ts +82 -0
  43. package/models.generated/smart-db-version-model.js +1 -0
  44. package/models.generated/smart-db-version-view-model.d.ts +90 -0
  45. package/models.generated/smart-db-version-view-model.js +1 -0
  46. package/package.json +6 -2
  47. package/smart-db-globals.d.ts +3 -1
  48. package/smart-db-globals.js +1 -1
  49. package/smart-db-interfaces.d.ts +2 -0
  50. package/smart-db-log.d.ts +1 -1
  51. package/smart-db-log.js +1 -1
  52. package/smart-db-upgrade-manager.js +1 -1
  53. package/smart-db.d.ts +12 -2
  54. package/smart-db.js +1 -1
@@ -0,0 +1,116 @@
1
+ drop table smart_db_version;
2
+ drop table smart_db_log;
3
+ drop table smart_db_core_table;
4
+
5
+ drop sequence smart_db_version_seq;
6
+ drop sequence smart_db_log_seq;
7
+ drop sequence smart_db_core_table_seq;
8
+
9
+ create table smart_db_core_table (
10
+ ctb_id integer,
11
+ ctb_name varchar2(32),
12
+ ctb_type varchar2(32),
13
+ constraint smart_db_core_table_pk primary key (ctb_id) enable
14
+ );
15
+
16
+ create sequence smart_db_core_table_seq;
17
+
18
+ create or replace trigger smart_db_core_table_ins
19
+ before insert on smart_db_core_table
20
+ for each row
21
+ begin
22
+ if :new.ctb_id is null then
23
+ select smart_db_core_table_seq.nextval into :new.ctb_id from dual;
24
+ end if;
25
+ end;
26
+ /
27
+
28
+ insert into smart_db_core_table (ctb_name, ctb_type) values ('smart_db_core_table', 'table');
29
+ insert into smart_db_core_table (ctb_name, ctb_type) values ('smart_db_log', 'table');
30
+ insert into smart_db_core_table (ctb_name, ctb_type) values ('smart_db_version', 'table');
31
+ insert into smart_db_core_table (ctb_name, ctb_type) values ('smart_db_version_view', 'view');
32
+ insert into smart_db_core_table (ctb_name, ctb_type) values ('smart_db_user_tab_columns_view', 'view');
33
+
34
+ create table smart_db_log (
35
+ log_id integer,
36
+ log_severity varchar2(1) not null,
37
+ log_type varchar2(32) not null,
38
+ log_location varchar2(32) not null,
39
+ log_info varchar2(100) not null,
40
+ log_data varchar2(4000),
41
+ log_user varchar2(100),
42
+ log_timestamp timestamp default current_timestamp,
43
+ constraint smart_db_log_pk primary key (log_id) enable
44
+ );
45
+
46
+ create index smart_db_log_i1 on smart_db_log (log_type);
47
+ create index smart_db_log_i2 on smart_db_log (log_user);
48
+
49
+ create sequence smart_db_log_seq;
50
+
51
+ create or replace trigger smart_db_log_ins
52
+ before insert on smart_db_log
53
+ for each row
54
+ begin
55
+ if :new.log_id is null then
56
+ select smart_db_log_seq.nextval into :new.log_id from dual;
57
+ end if;
58
+ end;
59
+ /
60
+
61
+ create table smart_db_version
62
+ (
63
+ ver_id integer,
64
+ ver_module varchar2(32) not null,
65
+ ver_sequence integer not null,
66
+ ver_version varchar2(3) not null,
67
+ ver_sub_version varchar2(3),
68
+ ver_revision varchar2(3),
69
+ ver_release_type varchar2(32),
70
+ ver_install_date timestamp default current_timestamp,
71
+ constraint smart_db_version_pk primary key (ver_id) enable
72
+ );
73
+
74
+ create index smart_db_version_i1 on smart_db_version (ver_module, ver_sequence desc);
75
+
76
+ create sequence smart_db_version_seq;
77
+
78
+ create or replace trigger smart_db_version_ins
79
+ before insert on smart_db_version
80
+ for each row
81
+ begin
82
+ if :new.ver_id is null then
83
+ select smart_db_version_seq.nextval into :new.ver_id from dual;
84
+ end if;
85
+ end;
86
+ /
87
+
88
+ --
89
+ -- create this last -> its present is used to verify the whole script ran through correctly
90
+ --
91
+ create or replace view smart_db_version_view as
92
+ select a.*,
93
+ ver_version ||
94
+ decode(ver_sub_version, null, '', '.' || ver_sub_version) ||
95
+ decode(ver_release_type, null, '', ver_release_type) ||
96
+ decode(ver_revision, null, '', decode(ver_release_type, null, '.', '') || ver_revision) as ver_version_string
97
+ from smart_db_version a
98
+ where a.ver_sequence = (select max(b.ver_sequence) from smart_db_version b where a.ver_module = b.ver_module);
99
+
100
+ create or replace view smart_db_user_tab_columns_view as
101
+ select (
102
+ select cons.constraint_type
103
+ from user_constraints cons,
104
+ user_cons_columns cons_cols
105
+ where cols.table_name = cons.table_name
106
+ and cons.table_name = cons_cols.table_name
107
+ and cols.column_name = cons_cols.column_name
108
+ and cons.constraint_name = cons_cols.constraint_name
109
+ and cons.owner = cons_cols.owner
110
+ and cons.constraint_type = 'P'
111
+ ) constraint_type,
112
+ cols.*
113
+ from user_tab_columns cols;
114
+
115
+ insert into smart_db_version (ver_sequence, ver_module, ver_version, ver_sub_version, ver_revision, ver_release_type)
116
+ values (0, 'smart-db-core', '1', '0', '0', null);
@@ -1,8 +1,8 @@
1
1
  import BetterSqlite3 from "better-sqlite3";
2
- import { SmartDbSqlBuildData } from "../smart-db-sql-build-data";
3
2
  import { AbstractModel } from "../models/abstract-model";
4
3
  import { SmartDb } from "../smart-db";
5
4
  import { GenericModelData, SmartDbConnector, SmartDbRunResult, SmartDbTableInfo } from "../smart-db-interfaces";
5
+ import { SmartDbSqlBuildData } from "../smart-db-sql-build-data";
6
6
  declare type VariableArgFunction = (...params: any[]) => any;
7
7
  export declare class SmartDbBetterSqlite3 extends SmartDb {
8
8
  protected db: BetterSqlite3.Database;
@@ -11,13 +11,14 @@ export declare class SmartDbBetterSqlite3 extends SmartDb {
11
11
  getDbQuote(): string;
12
12
  getDbConnector(): string | SmartDbConnector;
13
13
  hasConcurrentTransactions(): boolean;
14
+ supportSyncCalls(): boolean;
15
+ supportAsyncCalls(): boolean;
14
16
  exists<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): Promise<boolean>;
15
17
  existsSync<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): boolean;
16
18
  exec(script: string): Promise<any>;
17
19
  execSync(script: string): BetterSqlite3.Database | false;
18
20
  transaction<F extends VariableArgFunction>(fn: F): BetterSqlite3.Transaction | false;
19
21
  pragma(source: string, options?: BetterSqlite3.PragmaOptions): unknown;
20
- checkpoint(databaseName?: string): BetterSqlite3.Database | false;
21
22
  func(name: string, options: BetterSqlite3.RegistrationOptions, cb: VariableArgFunction): BetterSqlite3.Database | false;
22
23
  aggregate(name: string, options: BetterSqlite3.AggregateOptions): BetterSqlite3.Database | false;
23
24
  loadExtension(path: string): BetterSqlite3.Database | false;
@@ -1 +1 @@
1
- import BetterSqlite3 from"better-sqlite3";import _ from"lodash";import{SqliteMasterModel}from"../models/sqlite-master-model";import{SmartDb}from"../smart-db";export class SmartDbBetterSqlite3 extends SmartDb{constructor(t,e){_.isString(t)?(super(t),this.db=new BetterSqlite3(t,e)):(super(null),this.db=t,this.db.inTransaction)}getDatabaseType(){return"sqlite3"}getDbQuote(){return'"'}getDbConnector(){return this.dbConnector}hasConcurrentTransactions(){return!1}exists(t,e,s){return new Promise((r,n)=>{const a=_.isString(t)?t:t.getTableName();this.getFirst(SqliteMasterModel,{name:a,type:e,tblName:s}).then(t=>{null===t?n(this.getLastError()):r(!!t)}).catch(t=>{n(t)})})}existsSync(t,e,s){let r=!1;const n=_.isString(t)?t:t.getTableName(),a=this.getFirstSync(SqliteMasterModel,{name:n,type:e,tblName:s});if(!1===a)throw this.getLastError();return r=!!a,r}exec(t){return new Promise((e,s)=>{const r=this.execSync(t);!1===r?s("unable to execute script"):e(r)})}execSync(t){return this.saveExecute(()=>this.db.exec(t))}transaction(t){return this.saveExecute(()=>this.db.transaction(t))}pragma(t,e){return this.saveExecute(()=>this.db.pragma(t,e))}checkpoint(t){return this.saveExecute(()=>this.db.checkpoint(t))}func(t,e,s){return this.saveExecute(()=>{let r;return r=_.isFunction(e)?this.db.function(t,e):this.db.function(t,e,s),r})}aggregate(t,e){return this.saveExecute(()=>this.db.aggregate(t,e))}loadExtension(t){return this.saveExecute(()=>this.db.loadExtension(t))}closeSync(){return this.saveExecute(()=>(this.smartDbLog.setDb(null),!!this.db.close()))}defaultSafeIntegers(t){return this.saveExecute(()=>this.db.defaultSafeIntegers(t))}backup(t,e){return this.saveExecute(()=>this.db.backup(t,e))}getTableInfo(t){return new Promise(e=>{const s=this.pragma(`table_info(${t})`);let r=[];s&&(r=s.map(t=>({cid:t.cid,name:t.name,type:t.type,notNull:0!==t.notnull,defaultValue:t.dflt_value,isPk:0!==t.pk})),e({name:t,fields:r}))})}statementRun(t,e=0){return new Promise((s,r)=>{try{s(this.statementRunSync(t))}catch(n){"SQLITE_BUSY"==n.code&&e<10?setTimeout(()=>{this.statementRun(t,e+1).then(t=>{s(t)}).catch(t=>{r(t)})},100):r(n)}})}statementRunSync(t){const e=this.db.prepare(t.sql),s=e&&e.run(t.values);return s&&{changes:s.changes,affected:s.changes,lastId:s.lastInsertRowid}}statementGet(t){return new Promise((e,s)=>{try{e(this.db.prepare(t.sql).get(t.values))}catch(t){s(t)}})}statementGetSync(t){const e=this.db.prepare(t.sql);return e&&e.get(t.values)}statementGetAll(t){return new Promise((e,s)=>{try{e(this.db.prepare(t.sql).all(t.values))}catch(t){s(t)}})}statementGetAllSync(t){const e=this.db.prepare(t.sql);return e&&e.all(t.values)}close(){return new Promise((t,e)=>{try{this.smartDbLog.setDb(null),this.db.close(),t()}catch(t){e(t)}})}}
1
+ import BetterSqlite3 from"better-sqlite3";import _ from"lodash";import{SqliteMasterModel}from"../models/sqlite-master-model";import{SmartDb}from"../smart-db";export class SmartDbBetterSqlite3 extends SmartDb{constructor(t,e){_.isString(t)?(super(t),this.db=new BetterSqlite3(t,e)):(super(null),this.db=t,this.db.inTransaction)}getDatabaseType(){return"sqlite3"}getDbQuote(){return'"'}getDbConnector(){return this.dbConnector}hasConcurrentTransactions(){return!1}supportSyncCalls(){return!0}supportAsyncCalls(){return!1}exists(t,e,s){return new Promise(((r,n)=>{const a=_.isString(t)?t:t.getTableName();this.getFirst(SqliteMasterModel,{name:a,type:e,tblName:s}).then((t=>{null===t?n(this.getLastError()):r(!!t)})).catch((t=>{n(t)}))}))}existsSync(t,e,s){let r=!1;const n=_.isString(t)?t:t.getTableName(),a=this.getFirstSync(SqliteMasterModel,{name:n,type:e,tblName:s});if(!1===a)throw this.getLastError();return r=!!a,r}exec(t){return new Promise(((e,s)=>{const r=this.execSync(t);!1===r?s("unable to execute script"):e(r)}))}execSync(t){return this.saveExecute((()=>this.db.exec(t)))}transaction(t){return this.saveExecute((()=>this.db.transaction(t)))}pragma(t,e){return this.saveExecute((()=>this.db.pragma(t,e)))}func(t,e,s){return this.saveExecute((()=>{let r;return r=_.isFunction(e)?this.db.function(t,e):this.db.function(t,e,s),r}))}aggregate(t,e){return this.saveExecute((()=>this.db.aggregate(t,e)))}loadExtension(t){return this.saveExecute((()=>this.db.loadExtension(t)))}closeSync(){return this.saveExecute((()=>(this.smartDbLog.setDb(null),!!this.db.close())))}defaultSafeIntegers(t){return this.saveExecute((()=>this.db.defaultSafeIntegers(t)))}backup(t,e){return this.saveExecute((()=>this.db.backup(t,e)))}getTableInfo(t){return new Promise((e=>{const s=this.pragma(`table_info(${t})`);let r=[];s&&(r=s.map((t=>({cid:t.cid,name:t.name,type:t.type,notNull:0!==t.notnull,defaultValue:t.dflt_value,isPk:0!==t.pk}))),e({name:t,fields:r}))}))}statementRun(t,e=0){return new Promise(((s,r)=>{try{s(this.statementRunSync(t))}catch(n){"SQLITE_BUSY"==n.code&&e<10?setTimeout((()=>{this.statementRun(t,e+1).then((t=>{s(t)})).catch((t=>{r(t)}))}),100):r(n)}}))}statementRunSync(t){const e=this.db.prepare(t.sql),s=e&&e.run(t.values);return s&&{changes:s.changes,affected:s.changes,lastId:s.lastInsertRowid}}statementGet(t){return new Promise(((e,s)=>{try{e(this.db.prepare(t.sql).get(t.values))}catch(t){s(t)}}))}statementGetSync(t){const e=this.db.prepare(t.sql);return e&&e.get(t.values)}statementGetAll(t){return new Promise(((e,s)=>{try{e(this.db.prepare(t.sql).all(t.values))}catch(t){s(t)}}))}statementGetAllSync(t){const e=this.db.prepare(t.sql);return e&&e.all(t.values)}close(){return new Promise(((t,e)=>{try{this.smartDbLog.setDb(null),this.db.close(),t()}catch(t){e(t)}}))}}
@@ -1,8 +1,8 @@
1
1
  import Mysql, { Connection, ConnectionConfig } from "mysql";
2
- import { SmartDbSqlBuildData } from "../smart-db-sql-build-data";
3
2
  import { AbstractModel } from "../models/abstract-model";
4
3
  import { SmartDb } from "../smart-db";
5
4
  import { GenericModelData, SmartDbRunResult, SmartDbTableInfo } from "../smart-db-interfaces";
5
+ import { SmartDbSqlBuildData } from "../smart-db-sql-build-data";
6
6
  export declare class SmartDbMysql extends SmartDb {
7
7
  protected db: Mysql.Connection;
8
8
  constructor(connectorOrDb: string | ConnectionConfig | Connection);
@@ -10,6 +10,8 @@ export declare class SmartDbMysql extends SmartDb {
10
10
  getDbConnector(): string | Mysql.ConnectionConfig;
11
11
  getDbQuote(): string;
12
12
  hasConcurrentTransactions(): boolean;
13
+ supportSyncCalls(): boolean;
14
+ supportAsyncCalls(): boolean;
13
15
  closeSync(): boolean;
14
16
  exists<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): Promise<boolean>;
15
17
  existsSync<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): boolean;
@@ -1 +1 @@
1
- import _ from"lodash";import Mysql from"mysql";import{SmartDb}from"../smart-db";export class SmartDbMysql extends SmartDb{constructor(e){e.config&&e.connect?(super(e.config),this.db=e):(super(e),this.db=Mysql.createConnection(e))}getDatabaseType(){return"mysql"}getDbConnector(){return this.dbConnector}getDbQuote(){return"`"}hasConcurrentTransactions(){return!0}closeSync(){throw new Error("Method not implemented.")}exists(e,t,r){return new Promise((t,r)=>{const n=_.isString(e)?e:e.getTableName();this.db.query(`show tables like '${n}'`,(e,n,o)=>{e?r(e):t(n&&n.length>0)})})}existsSync(e,t,r){throw new Error("Method not implemented.")}exec(e){return new Promise((t,r)=>{try{this.db.query(e,(e,n,o)=>{e?r(e):t()})}catch(e){r(e)}})}execSync(e){throw new Error("Method not implemented.")}getTableInfo(e){return new Promise((e,t)=>{})}statementGet(e){return new Promise((t,r)=>{try{this.db.query(e.sql,e.values,(e,n,o)=>{e?r(e):t(n&&n[0])})}catch(e){r(e)}})}statementGetSync(e){throw new Error("Method not implemented.")}statementGetAll(e){return new Promise((t,r)=>{this.db.query(e.sql,e.values,(e,n,o)=>{e?r(e):(console.log(o),t(n&&n))})})}statementGetAllSync(e){throw new Error("Method not implemented.")}statementRun(e){return new Promise((t,r)=>{this.db.query(e.sql,e.values,(e,n,o)=>{if(e)r(e);else{const e={changes:n.changedRows,affected:n.affectedRows,lastId:n.insertId};t(e)}})})}statementRunSync(e){throw new Error("Method not implemented.")}close(){return new Promise((e,t)=>{this.db.end(r=>{r?t(r):e()})})}}
1
+ import _ from"lodash";import Mysql from"mysql";import{SmartDb}from"../smart-db";export class SmartDbMysql extends SmartDb{constructor(e){e.config&&e.connect?(super(e.config),this.db=e):(super(e),this.db=Mysql.createConnection(e))}getDatabaseType(){return"mysql"}getDbConnector(){return this.dbConnector}getDbQuote(){return"`"}hasConcurrentTransactions(){return!0}supportSyncCalls(){return!1}supportAsyncCalls(){return!0}closeSync(){throw new Error("Method not implemented.")}exists(e,t,r){return new Promise(((t,r)=>{const n=_.isString(e)?e:e.getTableName();this.db.query(`show tables like '${n}'`,((e,n,s)=>{e?r(e):t(n&&n.length>0)}))}))}existsSync(e,t,r){throw new Error("Method not implemented.")}exec(e){return new Promise(((t,r)=>{try{this.db.query(e,((e,n,s)=>{e?r(e):t()}))}catch(e){r(e)}}))}execSync(e){throw new Error("Method not implemented.")}getTableInfo(e){return new Promise(((e,t)=>{}))}statementGet(e){return new Promise(((t,r)=>{try{this.db.query(e.sql,e.values,((e,n,s)=>{e?r(e):t(n&&n[0])}))}catch(e){r(e)}}))}statementGetSync(e){throw new Error("Method not implemented.")}statementGetAll(e){return new Promise(((t,r)=>{this.db.query(e.sql,e.values,((e,n,s)=>{e?r(e):(console.log(s),t(n&&n))}))}))}statementGetAllSync(e){throw new Error("Method not implemented.")}statementRun(e){return new Promise(((t,r)=>{this.db.query(e.sql,e.values,((e,n,s)=>{if(e)r(e);else{const e={changes:n.changedRows,affected:n.affectedRows,lastId:n.insertId};t(e)}}))}))}statementRunSync(e){throw new Error("Method not implemented.")}close(){return new Promise(((e,t)=>{this.db.end((r=>{r?t(r):e()}))}))}}
@@ -1,8 +1,8 @@
1
1
  import Mysql, { Connection, ConnectionConfig } from "mysql";
2
2
  import { AbstractModel } from "../models/abstract-model";
3
3
  import { SmartDb } from "../smart-db";
4
- import { SmartDbSqlBuildData } from "../smart-db-sql-build-data";
5
4
  import { GenericModelData, SmartDbRunResult, SmartDbTableInfo } from "../smart-db-interfaces";
5
+ import { SmartDbSqlBuildData } from "../smart-db-sql-build-data";
6
6
  export declare class SmartDbMysql2 extends SmartDb {
7
7
  protected db: Mysql.Connection;
8
8
  constructor(connectorOrDb: string | ConnectionConfig | Connection);
@@ -16,6 +16,8 @@ export declare class SmartDbMysql2 extends SmartDb {
16
16
  exec(script: string): Promise<void>;
17
17
  execSync(script: string): boolean;
18
18
  getTableInfo(table: string): Promise<SmartDbTableInfo>;
19
+ supportSyncCalls(): boolean;
20
+ supportAsyncCalls(): boolean;
19
21
  protected statementGet(buildData: SmartDbSqlBuildData): Promise<any>;
20
22
  protected statementGetSync(buildData: SmartDbSqlBuildData): any;
21
23
  protected statementGetAll(buildData: SmartDbSqlBuildData): Promise<any[]>;
@@ -1 +1 @@
1
- import _ from"lodash";import Mysql from"mysql";import{SmartDb}from"../smart-db";export class SmartDbMysql2 extends SmartDb{constructor(e){e.config&&e.connect?(super(e.config),this.db=e):(super(e),this.db=Mysql.createConnection(e))}getDatabaseType(){return"mysql"}getDbConnector(){return this.dbConnector}getDbQuote(){return"`"}hasConcurrentTransactions(){return!0}closeSync(){throw new Error("Method not implemented.")}exists(e,t,r){return new Promise((t,r)=>{const n=_.isString(e)?e:e.getTableName();this.db.query(`show tables like '${n}'`,(e,n,o)=>{e?r(e):t(n&&n.length>0)})})}existsSync(e,t,r){throw new Error("Method not implemented.")}exec(e){return new Promise((t,r)=>{try{this.db.query(e,(e,n,o)=>{e?r(e):t()})}catch(e){r(e)}})}execSync(e){throw new Error("Method not implemented.")}getTableInfo(e){return new Promise((e,t)=>{})}statementGet(e){return new Promise((t,r)=>{try{this.db.query(e.sql,e.values,(e,n,o)=>{e?r(e):t(n&&n[0])})}catch(e){r(e)}})}statementGetSync(e){throw new Error("Method not implemented.")}statementGetAll(e){return new Promise((t,r)=>{this.db.query(e.sql,e.values,(e,n,o)=>{e?r(e):(console.log(o),t(n&&n))})})}statementGetAllSync(e){throw new Error("Method not implemented.")}statementRun(e){return new Promise((t,r)=>{this.db.query(e.sql,e.values,(e,n,o)=>{if(e)r(e);else{const e={changes:n.changedRows,affected:n.affectedRows,lastId:n.insertId};t(e)}})})}statementRunSync(e){throw new Error("Method not implemented.")}close(){return new Promise((e,t)=>{this.db.end(r=>{r?t(r):e()})})}}
1
+ import _ from"lodash";import Mysql from"mysql";import{SmartDb}from"../smart-db";export class SmartDbMysql2 extends SmartDb{constructor(e){e.config&&e.connect?(super(e.config),this.db=e):(super(e),this.db=Mysql.createConnection(e))}getDatabaseType(){return"mysql"}getDbConnector(){return this.dbConnector}getDbQuote(){return"`"}hasConcurrentTransactions(){return!0}closeSync(){throw new Error("Method not implemented.")}exists(e,t,r){return new Promise(((t,r)=>{const n=_.isString(e)?e:e.getTableName();this.db.query(`show tables like '${n}'`,((e,n,s)=>{e?r(e):t(n&&n.length>0)}))}))}existsSync(e,t,r){throw new Error("Method not implemented.")}exec(e){return new Promise(((t,r)=>{try{this.db.query(e,((e,n,s)=>{e?r(e):t()}))}catch(e){r(e)}}))}execSync(e){throw new Error("Method not implemented.")}getTableInfo(e){return new Promise(((e,t)=>{}))}supportSyncCalls(){return!1}supportAsyncCalls(){return!0}statementGet(e){return new Promise(((t,r)=>{try{this.db.query(e.sql,e.values,((e,n,s)=>{e?r(e):t(n&&n[0])}))}catch(e){r(e)}}))}statementGetSync(e){throw new Error("Method not implemented.")}statementGetAll(e){return new Promise(((t,r)=>{this.db.query(e.sql,e.values,((e,n,s)=>{e?r(e):(console.log(s),t(n&&n))}))}))}statementGetAllSync(e){throw new Error("Method not implemented.")}statementRun(e){return new Promise(((t,r)=>{this.db.query(e.sql,e.values,((e,n,s)=>{if(e)r(e);else{const e={changes:n.changedRows,affected:n.affectedRows,lastId:n.insertId};t(e)}}))}))}statementRunSync(e){throw new Error("Method not implemented.")}close(){return new Promise(((e,t)=>{this.db.end((r=>{r?t(r):e()}))}))}}
@@ -0,0 +1,36 @@
1
+ import { Connection } from "oracledb";
2
+ import { AbstractModel } from "../models/abstract-model";
3
+ import { SmartDb } from "../smart-db";
4
+ import { GenericModelData, SmartDbConnector, SmartDbRunResult, SmartDbTableInfo } from "../smart-db-interfaces";
5
+ import { SmartDbSqlBuildData } from "../smart-db-sql-build-data";
6
+ export interface SmartDbOracleOptions {
7
+ user: string;
8
+ password: string;
9
+ silent?: boolean;
10
+ onReady?: (db: Connection, error?: any) => void;
11
+ noDbLogging?: boolean;
12
+ }
13
+ export declare class SmartDbOracle extends SmartDb {
14
+ protected db: Connection;
15
+ constructor(connectorOrDb: string | Connection, options?: SmartDbOracleOptions);
16
+ getDatabaseType(): string;
17
+ getDbConnector(): string | SmartDbConnector;
18
+ getDbQuote(): string;
19
+ hasConcurrentTransactions(): boolean;
20
+ supportSyncCalls(): boolean;
21
+ supportAsyncCalls(): boolean;
22
+ exists<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): Promise<boolean>;
23
+ existsSync<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): boolean;
24
+ exec(script: string): Promise<void>;
25
+ execSync(script: string): Connection | false;
26
+ closeSync(): boolean;
27
+ getTableInfo(tableName: string): Promise<SmartDbTableInfo>;
28
+ protected statementRun(buildData: SmartDbSqlBuildData): Promise<SmartDbRunResult>;
29
+ protected statementRunSync(buildData: SmartDbSqlBuildData): SmartDbRunResult;
30
+ protected statementGet<T extends object>(buildData: SmartDbSqlBuildData): Promise<T>;
31
+ protected statementGetSync(buildData: SmartDbSqlBuildData): void;
32
+ protected statementGetAll<T>(buildData: SmartDbSqlBuildData): Promise<T[]>;
33
+ protected statementGetAllSync(buildData: SmartDbSqlBuildData): any[];
34
+ private replacePlaceholders;
35
+ close(): Promise<void>;
36
+ }
@@ -0,0 +1 @@
1
+ import fs from"fs";import _ from"lodash";import process from"node:process";import oracleDb from"oracledb";import{take}from"rxjs";import{OracleCatModel}from"../models/oracle-cat-model";import{OracleUserTabColumnsViewModel}from"../models/oracle-user-tab-columns-view-model";import{SmartDb}from"../smart-db";export class SmartDbOracle extends SmartDb{constructor(e,t){if(_.isString(e)){let r;super(e,t?.noDbLogging),"darwin"===process.platform&&(r=process.env.ORACLE_HOME),r&&fs.existsSync(r)&&oracleDb.initOracleClient({libDir:r}),oracleDb.getConnection(Object.assign({connectString:e},t)).then((e=>{t&&t.onReady&&this.onReady().pipe(take(1)).subscribe((r=>{r&&t.onReady(e)})),this.db=e,this.exec("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'").then((e=>{this.exec("ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY:MM:DD HH24:MI:SS.FF'").then((e=>{this.isReady=!0})).catch((e=>{throw e}))})).catch((e=>{throw e}))})).catch((e=>{t&&t.onReady&&t.onReady(null,e),t.silent||console.log("unable prepare session database connection",e),this.isReady=null}))}else t.silent||console.log("missing Oracle SID"),super(null),this.db=e}getDatabaseType(){return"oracle"}getDbConnector(){return this.dbConnector}getDbQuote(){return'"'}hasConcurrentTransactions(){return!0}supportSyncCalls(){return!1}supportAsyncCalls(){return!0}exists(e,t,r){return new Promise(((r,s)=>{try{const o=_.isString(e)?e:e.getTableName();this.getFirst(OracleCatModel,{name:o.toUpperCase(),type:t?t.toUpperCase():void 0}).then((e=>{null===e?s(this.getLastError()):r(!!e)})).catch((e=>{s(e)}))}catch(e){s(e)}}))}existsSync(e,t,r){const s=_.isString(e)?e:e.getTableName();return!!this.getFirstSync(OracleCatModel,{name:s.toUpperCase(),type:t?t.toUpperCase():void 0})}exec(e){return new Promise(((t,r)=>{try{this.db.execute(e,(e=>{e?r(e):t()}))}catch(e){r(e)}}))}execSync(e){throw new Error("Method not implemented.")}closeSync(){throw new Error("Method not implemented.")}getTableInfo(e){return new Promise((async(t,r)=>{await this.getAll(OracleUserTabColumnsViewModel,{tableName:e.toUpperCase()}).then((s=>{if(!1!==s){let r=[];r=s.map((e=>({cid:e.columnId,name:e.columnName,type:e.dataType,notNull:"Y"!=e.nullable,defaultValue:e.defaultValue,isPk:"P"==e.constraintType}))),t({name:e,fields:r})}else r(this.getLastError())})).catch((e=>{r(e)}))}))}statementRun(e){return new Promise(((t,r)=>{try{this.db.execute(this.replacePlaceholders(e.sql),e.values,((e,s)=>{e?r(e):this.exec("COMMIT WORK").then((()=>{t({changes:s.rowsAffected,affected:s.rowsAffected,lastId:null})})).catch((e=>{r(e)}))}))}catch(e){r(e)}}))}statementRunSync(e){throw new Error("Method not implemented.")}statementGet(e){return new Promise(((t,r)=>{try{this.db.execute(this.replacePlaceholders(this.replacePlaceholders(e.sql)),e.values,{maxRows:1,outFormat:oracleDb.OUT_FORMAT_OBJECT},((e,s)=>{if(e)r(e);else{const e=s.rows[0],r={};Object.keys(e).forEach((t=>{r[t.toLowerCase()]=e[t]})),t(r)}}))}catch(e){r(e)}}))}statementGetSync(e){throw new Error("Method not implemented.")}statementGetAll(e){return new Promise(((t,r)=>{try{this.db.execute(this.replacePlaceholders(e.sql),e.values,{maxRows:0,outFormat:oracleDb.OUT_FORMAT_OBJECT}).then((e=>{t(e.rows)})).catch((e=>{r(e)}))}catch(e){r(e)}}))}statementGetAllSync(e){throw new Error("Method not implemented.")}replacePlaceholders(e){let t=1,r=!1;for(let s=0;s<e.length;s++)"'"==e[s]?r=!r:r||"?"!=e[s]||(e=e.substring(0,s)+":"+t+++e.substring(s+1));return e}close(){return new Promise(((e,t)=>{try{this.smartDbLog.setDb(null),this.db.close((r=>{r?t(r):e()}))}catch(e){t(e)}}))}}
@@ -14,6 +14,8 @@ export declare class SmartDbSqlite3 extends SmartDb {
14
14
  getDbConnector(): string | SmartDbConnector;
15
15
  getDbQuote(): string;
16
16
  hasConcurrentTransactions(): boolean;
17
+ supportSyncCalls(): boolean;
18
+ supportAsyncCalls(): boolean;
17
19
  exists<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): Promise<boolean>;
18
20
  existsSync<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): boolean;
19
21
  exec(script: string): Promise<void>;
@@ -1 +1 @@
1
- import _ from"lodash";import Sqlite3 from"sqlite3";import{SqliteMasterModel}from"../models/sqlite-master-model";import{SmartDb}from"../smart-db";export class SmartDbSqlite3 extends SmartDb{constructor(t,e){_.isString(t)?(super(t),this.db=new Sqlite3.Database(t,e&&e.mode,e&&e.callback)):(super(null),this.db=t)}getDatabaseType(){return"sqlite3"}getDbConnector(){return this.dbConnector}getDbQuote(){return'"'}hasConcurrentTransactions(){return!1}exists(t,e,r){return new Promise((n,s)=>{try{const o=_.isString(t)?t:t.getTableName();this.getFirst(SqliteMasterModel,{name:o,type:e,tblName:r}).then(t=>{null===t?s(this.getLastError()):n(!!t)}).catch(t=>{s(t)})}catch(t){s(t)}})}existsSync(t,e,r){throw new Error("Method not implemented.")}exec(t){return new Promise((e,r)=>{try{this.db.exec(t,(function(t){t?r(t):e()}))}catch(t){r(t)}})}execSync(t){throw new Error("Method not implemented.")}closeSync(){throw new Error("Method not implemented.")}getTableInfo(t){throw new Error("Method not implemented.")}statementRun(t){return new Promise((e,r)=>{try{this.db.run(t.sql,t.values,(function(t){t?r(t):e({changes:this.changes,affected:this.changes,lastId:this.lastID})}))}catch(t){r(t)}})}statementRunSync(t){throw new Error("Method not implemented.")}statementGet(t){return new Promise((e,r)=>{try{this.db.prepare(t.sql,(function(n){n?r(n):this.get(t.values,(function(t,n){t?r(t):e(n)}))}))}catch(t){r(t)}})}statementGetSync(t){throw new Error("Method not implemented.")}statementGetAll(t){return new Promise((e,r)=>{try{this.db.prepare(t.sql,(function(n){n?r(n):this.all(t.values,(function(t,n){t?r(t):e(n)}))}))}catch(t){r(t)}})}statementGetAllSync(t){throw new Error("Method not implemented.")}close(){return new Promise((t,e)=>{try{this.smartDbLog.setDb(null),this.db.close((function(r){r?e(r):t()}))}catch(t){e(t)}})}}
1
+ import _ from"lodash";import Sqlite3 from"sqlite3";import{SqliteMasterModel}from"../models/sqlite-master-model";import{SmartDb}from"../smart-db";export class SmartDbSqlite3 extends SmartDb{constructor(t,e){_.isString(t)?(super(t),this.db=new Sqlite3.Database(t,e&&e.mode,e&&e.callback)):(super(null),this.db=t)}getDatabaseType(){return"sqlite3"}getDbConnector(){return this.dbConnector}getDbQuote(){return'"'}hasConcurrentTransactions(){return!1}supportSyncCalls(){return!0}supportAsyncCalls(){return!1}exists(t,e,r){return new Promise(((n,s)=>{try{const o=_.isString(t)?t:t.getTableName();this.getFirst(SqliteMasterModel,{name:o,type:e,tblName:r}).then((t=>{null===t?s(this.getLastError()):n(!!t)})).catch((t=>{s(t)}))}catch(t){s(t)}}))}existsSync(t,e,r){throw new Error("Method not implemented.")}exec(t){return new Promise(((e,r)=>{try{this.db.exec(t,(function(t){t?r(t):e()}))}catch(t){r(t)}}))}execSync(t){throw new Error("Method not implemented.")}closeSync(){throw new Error("Method not implemented.")}getTableInfo(t){throw new Error("Method not implemented.")}statementRun(t){return new Promise(((e,r)=>{try{this.db.run(t.sql,t.values,(function(t){t?r(t):e({changes:this.changes,affected:this.changes,lastId:this.lastID})}))}catch(t){r(t)}}))}statementRunSync(t){throw new Error("Method not implemented.")}statementGet(t){return new Promise(((e,r)=>{try{this.db.prepare(t.sql,(function(n){n?r(n):this.get(t.values,(function(t,n){t?r(t):e(n)}))}))}catch(t){r(t)}}))}statementGetSync(t){throw new Error("Method not implemented.")}statementGetAll(t){return new Promise(((e,r)=>{try{this.db.prepare(t.sql,(function(n){n?r(n):this.all(t.values,(function(t,n){t?r(t):e(n)}))}))}catch(t){r(t)}}))}statementGetAllSync(t){throw new Error("Method not implemented.")}close(){return new Promise(((t,e)=>{try{this.smartDbLog.setDb(null),this.db.close((function(r){r?e(r):t()}))}catch(t){e(t)}}))}}
@@ -1 +1 @@
1
- import fs from"fs";import _ from"lodash";import process from"process";import{SmartDbBetterSqlite3}from"../drivers/smart-db-better-sqlite3";import{SmartDbCoreTableModel}from"../models/smart-db-core-table-model";import{SqliteMasterModel}from"../models/sqlite-master-model";import{IN,NE}from"../smart-db-globals";function getType(e){let t;return t=e?e.match(/varchar/i)||e.match(/text/i)?"string":e.match(/integer\(1\)/i)?"boolean":e.match(/date/i)?"Date":e.match(/integer/i)||e.match(/number/i)?"number":e||"SqlValueType":"SqlValueType",t}function extractDbApi(e){console.log(`extract interface from '${e.db.getDbConnector()}' to '${e.modelDirectory}'`),fs.existsSync(e.modelDirectory)||fs.mkdirSync(e.modelDirectory,{recursive:!0});const t=e.db.getAllSync(SqliteMasterModel,{type:IN(["table","view"]),name:NE("sqlite_sequence")});if(!1===t)console.error(e.db.getLastError()),process.abort();else{let r=[];if(!e.includeCoreTables&&e.db.existsSync(SmartDbCoreTableModel)){const t=e.db.getAllSync(SmartDbCoreTableModel);if(!1===t)throw e.db.getLastError();t.forEach(e=>{r.push(e.name)})}const n=[];t.forEach(t=>{if(!r.includes(t.name)){const r=t.name[0].toUpperCase()+_.camelCase(t.name.substr(1))+"Model";n.push(r);const a=[];e.db.getTableInfo(t.name).then(n=>{const s=n.fields;let o=!1,i="",l="",c="",m="",p="";const b=t.name.replace(/[^[a-z0-9]/g,"-")+"-model";if(i+="/* eslint-disable @typescript-eslint/member-ordering */\n",i+="// noinspection JSUnusedGlobalSymbols\n",s){e.abstractModelModule==e.smartDbInterfaces?e.separateApi?(c+=`import {GenericModelData} from "${e.abstractModelModule}";\n`,p+=`import {AbstractModel, ModelAttributeMap} from "${e.abstractModelModule}";\n`,p+=`import {${r}Data} from "./${b}-api";\n`):p+=`import {AbstractModel, GenericModelData, ModelAttributeMap} from "${e.abstractModelModule}";\n`:e.separateApi?(c+=`import {GenericModelData} from "${e.smartDbInterfaces}";\n`,p+=`import {ModelAttributeMap} from "${e.smartDbInterfaces}";\n`,p+=`import {AbstractModel} from "${e.abstractModelModule}";\n`,p+=`import {${r}Data} from "./${b}-api";\n`):(p+=`import {GenericModelData, ModelAttributeMap} from "${e.smartDbInterfaces}";\n`,p+=`import {AbstractModel} from "${e.abstractModelModule}";\n`),l+=`export interface ${r}Data extends GenericModelData {\n`;let n,d="",u="",f=!1;const h=[];s.forEach(e=>{const t=e.name.match(/([a-z0-9]{1,4})_/i);e.isPk&&(d=e.name,t&&(u=t[1])),t?h.includes(t[1])||h.push(t[1]):f=!0}),u||f||1!=h.length||(u=h[0]),u&&(n=new RegExp(`^${u}_(.*)$`));const $={};s.forEach(r=>{const s=getType(r.type);let i;o||"SqlValueType"!=s||(c+=`import {SqlValueType} from "${e.smartDbInterfaces}";\n`,p+=`import {SqlValueType} from "${e.smartDbInterfaces}";\n`,o=!0);const m=n&&r.name.match(n);i=m?_.camelCase(m[1]):_.camelCase(r.name);let b=!0;i!=r.name&&(a.push({name:i,attribute:i,type:s,typeScriptStyle:b,alias:r.name}),b=!1),a.push({name:r.name,attribute:i,type:s,physical:void 0!==r.cid,typeScriptStyle:b}),$[i]=s,"user"==t.name&&"name"==i&&(l+=" // @ts-ignore"),l+=` ${i}?: ${s};\n`}),l+="}\n",m+=`export class ${r} extends AbstractModel<${r}, ${r}Data> {\n`,_.forEach($,(e,t)=>{m+=` private _${t}?: ${e};\n`}),"user"==t.name&&(m+=" private _hash?: string;\n",m+=" private _privileges?: string[];\n"),m+="\n",m+=" static readonly attributeMap: ModelAttributeMap = {\n",a.forEach((e,t)=>{t>0&&(m+=",\n"),m+=` ${e.name}: {\n`,e.physical&&(m+=" physical: true,\n"),e.alias&&(m+=` alias: "${e.alias}",\n`),e.virtual&&(m+=" virtual: true,\n"),e.typeScriptStyle&&(m+=" typeScriptStyle: true,\n"),m+=` type: "${e.type}",\n`,m+=` attribute: "_${e.attribute}"\n`,m+=" }"}),m+="\n",m+=" };\n",m+="\n",m+=" static getClassName(): string {\n",m+=` return "${r}";\n`,m+=" }\n",m+="\n",m+=" static getTableName(): string {\n",m+=` return "${t.name}";\n`,m+=" }\n",m+="\n",m+=" static getPrimaryKey(): string {\n",m+=` return "${d}";\n`,m+=" }\n",m+="\n",m+=` static from(other: ${r} | ${r}Data): ${r} {\n`,m+=` let value: ${r} = null;\n`,m+=" if (other) {\n",m+=` value = new ${r}();\n`,m+=` if (other instanceof ${r}) {\n`,m+=" Object.assign(value, other);\n",m+=" } else {\n",m+=" value.assign(other);\n",m+=" }\n",m+=" }\n",m+=" return value;\n",m+=" }\n",m+="\n",m+=` constructor(data?: ${r} | ${r}Data) {\n`,m+=" super();\n",m+=" if (data) {\n",m+=" this.assign(data);\n",m+=" }\n",m+=" }\n",m+="\n",m+=` public clone(): ${r} {\n`,m+=` return ${r}.from(this);\n`,m+=" }\n",m+="\n",m+=" public getClassName(): string {\n",m+=` return "${r}";\n`,m+=" }\n",m+="\n",m+=" public getTableName(): string {\n",m+=` return "${t.name}";\n`,m+=" }\n",m+="\n",m+=" public getPrimaryKey(): string {\n",m+=` return "${d}";\n`,m+=" }\n",m+="\n",m+=" public getAttributeMap(): ModelAttributeMap {\n",m+=` return ${r}.attributeMap;\n`,m+=" }\n",a.forEach(e=>{let t;m+="\n",t=e.name.length<3||e.name.match(/_/)?"FunctionNamingConventionJS":"",""!==t&&(m+=` // noinspection ${t}\n`),m+=` get ${e.name}(): ${e.type} {\n`,m+=` return this._${e.attribute};\n`,m+=" }\n\n",""!==t&&(m+=` // noinspection ${t}\n`),m+=` set ${e.name}(${e.attribute}: ${e.type}) {\n`,m+=` this._${e.attribute} = ${e.attribute};\n`,m+=" }\n"}),"user"==t.name&&(m+="\n",m+=" get hash(): string {\n",m+=" return this._hash;\n",m+=" }\n\n",m+=" set hash(hash: string) {\n",m+=" this._hash = hash;\n",m+=" }\n",m+="\n",m+=" get privileges(): string[] {\n",m+=" return this._privileges;\n",m+=" }\n\n",m+=" set privileges(p: string[]) {\n",m+=" this._privileges = p;\n",m+=" }\n"),m+="}\n",e.separateApi?(l=i+"\n"+c+"\n"+l,fs.writeFileSync(`${e.modelDirectory}/${b+"-api.ts"}`,l),m=i+"\n"+p+"\n"+m):m=i+"\n"+p+"\n"+l+"\n"+m,fs.writeFileSync(`${e.modelDirectory}/${b+".ts"}`,m)}else console.log("error: table has no fields")}).catch(e=>{console.error(e),process.abort()})}});let a=`import {AbstractModel} from "${e.abstractModelModule}";\n`;_.forEach(n,e=>{a+=`import {${e}} from "./${_.kebabCase(e)}";\n`}),a+="\n",a+="interface SmartDbDictionaryEntry {\n",a+=" cls: "+n.map(e=>"typeof "+e).join(" |\n "),a+=";\n",a+="}\n\n",a+="export class SmartDbDictionary {\n",a+=" static models: { [relation: string]: SmartDbDictionaryEntry; } = {\n",_.forEach(n,e=>{a+=` ${e}: {\n`,a+=` cls: ${e}\n`,a+=" },\n"}),a=a.substring(0,a.length-2)+"\n",a+=" };\n",a+="}\n",fs.writeFileSync(e.modelDirectory+"/smart-db-dictionary.ts",a)}e.db.closeSync()}(()=>{let e=!1;const t=Array.from(process.argv);if("--separate-api"==t[2]&&(e=!0,t.splice(2,1)),4==t.length){extractDbApi({modelDirectory:t[3],smartDbInterfaces:"@egi/smart-db",abstractModelModule:"@egi/smart-db",separateApi:e,db:new SmartDbBetterSqlite3(t[2],{verbose:(e,...t)=>{console.log("DB LOG",e,...t)}})})}else if(2==t.length&&fs.existsSync("src/helpers/extract-db-api.ts")){const t=`/tmp/smart-db-core.${process.pid}.sqlite3`,r={includeCoreTables:!0,modelDirectory:"src/models",smartDbInterfaces:"../smart-db-interfaces",abstractModelModule:"./abstract-model",separateApi:e,db:new SmartDbBetterSqlite3(t,{verbose:(e,...t)=>{console.log("DB LOG",e,...t)}})};r.db.initDb({module:"smart-db-core",sqlFilesDirectory:"assets/sqlite3"}).then(()=>{extractDbApi(r),fs.unlinkSync(t),r.db.closeSync()})}else console.log("usage: extract-db-api {db-connector|path-to-db} {target-models-directory}")})();
1
+ import fs from"fs";import _ from"lodash";import process from"process";import{SmartDbBetterSqlite3}from"../drivers/smart-db-better-sqlite3";import{SmartDbOracle}from"../drivers/smart-db-oracle";import{OracleCatModel}from"../models/oracle-cat-model";import{SmartDbCoreTableModel}from"../models/smart-db-core-table-model";import{SqliteMasterModel}from"../models/sqlite-master-model";import{IN,NE,NOT_LIKE}from"../smart-db-globals";function getType(e){let t;return t=e?e.match(/varchar/i)||e.match(/text/i)?"string":e.match(/integer\(1\)/i)?"boolean":e.match(/date/i)?"Date":e.match(/integer/i)||e.match(/number/i)?"number":e.match(/long/i)||e.match(/raw/i)?"any":"SqlValueType":"SqlValueType",t}function getRelations(e){return new Promise((async(t,r)=>{e instanceof SmartDbOracle?e.getAll(OracleCatModel,{type:IN(["TABLE","VIEW"]),name:NOT_LIKE("BIN$%")}).then((n=>{n?t(n.map((e=>e.name.toLowerCase()))):r(e.getLastError())})).catch((e=>{r(e)})):e instanceof SmartDbBetterSqlite3?e.getAll(SqliteMasterModel,{type:IN(["table","view"]),name:NE("sqlite_sequence")}).then((n=>{n?t(n.map((e=>e.name))):r(e.getLastError())})).catch((e=>{r(e)})):r("unimplemented database type")}))}async function extractDbApi(e){console.log(`extract interface from '${e.db.getDbConnector()}' to '${e.modelDirectory}'`);const t=["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","If","import","in","instanceOf","new","null","return","super","switch","this","throw","true","try","typeOf","var","void","while","with"];fs.existsSync(e.modelDirectory)||fs.mkdirSync(e.modelDirectory,{recursive:!0}),getRelations(e.db).then((async r=>{let n=[];if((e.skipCoreTables||e.justCoreTables)&&await e.db.exists(SmartDbCoreTableModel)){const t=await e.db.getAll(SmartDbCoreTableModel);if(!1===t)throw e.db.getLastError();t.forEach((e=>{n.push(e.name)}))}const a=[];for(const s of r){let r=!0;if(e.justCoreTables?r=n.includes(s):e.skipCoreTables&&(r=!n.includes(s)),r){const r=s[0].toUpperCase()+_.camelCase(s.substring(1))+"Model";a.push(r);const n=[];console.log("working on",s),await e.db.getTableInfo(s).then((a=>{const o=a.fields;let i=!1,l="",c="",m="",p="",d="";const b=s.toLowerCase().replace(/[^[a-z0-9]/g,"-")+"-model";if(l+="/* eslint-disable @typescript-eslint/member-ordering */\n",l+="// noinspection JSUnusedGlobalSymbols\n",o){e.abstractModelModule==e.smartDbInterfaces?e.separateApi?(m+=`import {GenericModelData} from "${e.abstractModelModule}";\n`,d+=`import {AbstractModel, ModelAttributeMap} from "${e.abstractModelModule}";\n`,d+=`import {${r}Data} from "./${b}-api";\n`):d+=`import {AbstractModel, GenericModelData, ModelAttributeMap} from "${e.abstractModelModule}";\n`:e.separateApi?(m+=`import {GenericModelData} from "${e.smartDbInterfaces}";\n`,d+=`import {ModelAttributeMap} from "${e.smartDbInterfaces}";\n`,d+=`import {AbstractModel} from "${e.abstractModelModule}";\n`,d+=`import {${r}Data} from "./${b}-api";\n`):(d+=`import {GenericModelData, ModelAttributeMap} from "${e.smartDbInterfaces}";\n`,d+=`import {AbstractModel} from "${e.abstractModelModule}";\n`),c+=`export interface ${r}Data extends GenericModelData {\n`;let a,u="",f="",h=!1;const g=[];o.forEach((e=>{const t=e.name.match(/([a-z0-9]{1,4})_/i);e.isPk&&(u=e.name,t&&(f=t[1])),t?g.includes(t[1])||g.push(t[1]):h=!0})),f||h||1!=g.length||(f=g[0]),f&&(a=new RegExp(`^${f}_(.*)$`));const y={};o.forEach((t=>{const r=getType(t.type);let o;i||"SqlValueType"!=r||(m+=`import {SqlValueType} from "${e.smartDbInterfaces}";\n`,d+=`import {SqlValueType} from "${e.smartDbInterfaces}";\n`,i=!0);const l=a&&t.name.match(a);o=l?_.camelCase(l[1]):_.camelCase(t.name);let p=!0;if(o!=t.name&&(n.push({name:o,attribute:o,type:r,typeScriptStyle:p,alias:t.name}),p=!1),o!=t.name.toLowerCase()&&(n.push({name:t.name.toLowerCase(),attribute:o,type:r,physical:void 0!==t.cid&&t.name==t.name.toLowerCase(),typeScriptStyle:p}),p=!1),o!=t.name.toUpperCase()&&n.push({name:t.name.toUpperCase(),attribute:o,type:r,physical:void 0!==t.cid&&t.name==t.name.toUpperCase(),typeScriptStyle:p}),t.cid){const e=n.find((e=>e.physical&&e.name.toLowerCase()==t.name.toLowerCase()));e||n.push({name:t.name,attribute:o,type:r,physical:!0,typeScriptStyle:p})}y[o]=r,"user"==s&&"name"==o&&(c+=" // @ts-ignore"),c+=` ${o}?: ${r};\n`})),c+="}\n",p+=`export class ${r} extends AbstractModel<${r}, ${r}Data> {\n`,_.forEach(y,((e,t)=>{p+=` private _${t}?: ${e};\n`})),"user"==s&&(p+=" private _hash?: string;\n",p+=" private _privileges?: string[];\n"),p+="\n",p+=" static readonly attributeMap: ModelAttributeMap = {\n",n.forEach(((e,t)=>{t>0&&(p+=",\n"),p+=` ${e.name}: {\n`,e.physical&&(p+=" physical: true,\n"),e.alias&&(p+=` alias: "${e.alias}",\n`),e.virtual&&(p+=" virtual: true,\n"),e.typeScriptStyle&&(p+=" typeScriptStyle: true,\n"),p+=` type: "${e.type}",\n`,p+=` attribute: "_${e.attribute}"\n`,p+=" }"})),p+="\n",p+=" };\n",p+="\n",p+=" static getClassName(): string {\n",p+=` return "${r}";\n`,p+=" }\n",p+="\n",p+=" static getTableName(): string {\n",p+=` return "${s}";\n`,p+=" }\n",p+="\n",p+=" static getPrimaryKey(): string {\n",p+=` return "${u}";\n`,p+=" }\n",p+="\n",p+=` static from(other: ${r} | ${r}Data): ${r} {\n`,p+=` let value: ${r} = null;\n`,p+=" if (other) {\n",p+=` value = new ${r}();\n`,p+=` if (other instanceof ${r}) {\n`,p+=" Object.assign(value, other);\n",p+=" } else {\n",p+=" value.assign(other);\n",p+=" }\n",p+=" }\n",p+=" return value;\n",p+=" }\n",p+="\n",p+=` constructor(data?: ${r} | ${r}Data) {\n`,p+=" super();\n",p+=" if (data) {\n",p+=" this.assign(data);\n",p+=" }\n",p+=" }\n",p+="\n",p+=` public clone(): ${r} {\n`,p+=` return ${r}.from(this);\n`,p+=" }\n",p+="\n",p+=" public getClassName(): string {\n",p+=` return "${r}";\n`,p+=" }\n",p+="\n",p+=" public getTableName(): string {\n",p+=` return "${s}";\n`,p+=" }\n",p+="\n",p+=" public getPrimaryKey(): string {\n",p+=` return "${u}";\n`,p+=" }\n",p+="\n",p+=" public getAttributeMap(): ModelAttributeMap {\n",p+=` return ${r}.attributeMap;\n`,p+=" }\n",n.forEach((e=>{let r;p+="\n",r=e.name.length<3||e.name.match(/_/)?"FunctionNamingConventionJS":"",""!==r&&(p+=` // noinspection ${r}\n`),p+=` get ${e.name}(): ${e.type} {\n`,p+=` return this._${e.attribute};\n`,p+=" }\n\n",""!==r&&(p+=` // noinspection ${r}\n`);let n=e.attribute;t.includes(n)&&(n="value"),p+=` set ${e.name}(${n}: ${e.type}) {\n`,p+=` this._${n} = ${n};\n`,p+=" }\n"})),"user"==s&&(p+="\n",p+=" get hash(): string {\n",p+=" return this._hash;\n",p+=" }\n\n",p+=" set hash(hash: string) {\n",p+=" this._hash = hash;\n",p+=" }\n",p+="\n",p+=" get privileges(): string[] {\n",p+=" return this._privileges;\n",p+=" }\n\n",p+=" set privileges(p: string[]) {\n",p+=" this._privileges = p;\n",p+=" }\n"),p+="}\n",e.separateApi?(c=l+"\n"+m+"\n"+c,fs.writeFileSync(`${e.modelDirectory}/${b+"-api.ts"}`,c),p=l+"\n"+d+"\n"+p):p=l+"\n"+d+"\n"+c+"\n"+p,fs.writeFileSync(`${e.modelDirectory}/${b+".ts"}`,p)}else console.log("error: table has no fields")})).catch((e=>{console.error(e),process.abort()}))}}let s=`import {AbstractModel} from "${e.abstractModelModule}";\n`;_.forEach(a,(e=>{s+=`import {${e}} from "./${_.kebabCase(e)}";\n`})),s+="\n",s+="interface SmartDbDictionaryEntry {\n",s+=" cls: "+a.map((e=>"typeof "+e)).join(" |\n "),s+=";\n",s+="}\n\n",s+="export class SmartDbDictionary {\n",s+=" static models: { [relation: string]: SmartDbDictionaryEntry; } = {\n",_.forEach(a,(e=>{s+=` ${e}: {\n`,s+=` cls: ${e}\n`,s+=" },\n"})),s=s.substring(0,s.length-2)+"\n",s+=" };\n",s+="}\n",fs.writeFileSync(`${e.modelDirectory}/smart-db-dictionary.ts`,s)})).catch((e=>{console.error("extraction error",e)}))}(async()=>{let e=!1;const t=Array.from(process.argv);let r,n,a,s=!1;for(t.shift(),t.shift();t[0]&&"--"==t[0].substring(0,2);)"--separate-api"==t[0]?(e=!0,t.shift()):"--connector"==t[0]?(r=t[1],t.shift(),t.shift()):"--username"==t[0]?(n=t[1],t.shift(),t.shift()):"--password"==t[0]?(r=t[1],t.shift(),t.shift()):"--create"==t[0]?(s=!0,t.shift()):(console.error(`unknown option '${t[2]}'`),process.exit(-1));if(r||(r=process.env.ORACLE_SID),n||(n=process.env.ORA_USER),a||(a=process.env.ORA_PASS),r&&t.length<=1){let o;n&&a?o=new SmartDbOracle(r,{user:n,password:a,noDbLogging:!0}):s||fs.existsSync(r)?o=new SmartDbBetterSqlite3(r,{verbose:(e,...t)=>{console.log("DB LOG",e,...t)}}):(console.error(`ERROR: missing sqlite3 database file ${r}`),process.exit(-1)),1==t.length?o.onReady().subscribe((async r=>{if(r){o.getLogger().setDbLogging(!1);const r={skipCoreTables:!0,modelDirectory:t[0],smartDbInterfaces:"@egi/smart-db",abstractModelModule:"@egi/smart-db",separateApi:e,db:o};await extractDbApi(r)}})):fs.existsSync("src/helpers/extract-db-api.ts")?o.onReady().subscribe((t=>{const r={justCoreTables:!0,modelDirectory:"src/models/generated",smartDbInterfaces:"../smart-db-interfaces",abstractModelModule:"./abstract-model",separateApi:e,db:o};r.db.initDb({module:"smart-db-core",sqlFilesDirectory:"assets/sqlite3"}).then((async()=>{await extractDbApi(r)}))})):console.log("command must be run at the root directory of the smart-db project")}else console.log("USAGE: extract-db-api --connector {db-connector|path-to-db} [{options}] {target-models-directory}\n"),console.log("Options are: [--username {username}]"),console.log(" [--password {password}]"),console.log(" [--create"),console.log(" [--separate-api]")})();
@@ -1 +1 @@
1
- import _ from"lodash";import{FieldNamingStyle}from"../smart-db-interfaces";export class AbstractModel{static getTableName(){return"overload this in child class"}static from(t){}assign(t,e){if("object"==typeof t){const i=this.getAttributeMap();let s=!e||!!e.skipUndefined;Object.keys(i).forEach(i=>{let a=!0;if(e&&(e.only&&!_.includes(e.only,i)&&(a=!1),e.exclude&&_.includes(e.exclude,i)&&(a=!1)),a)if(t instanceof AbstractModel&&t.hasAttribute(i)){const e=t.getValue(i);s&&void 0===e||this.setValue(i,e)}else if(t.hasOwnProperty(i)){const e=t[i];s&&void 0===e||this.setValue(i,e)}})}}setValue(t,e){const i=this.getAttributeMap()[t];if(!i)throw`unknown attribute ${t} for ${this.getClassName()}`;if(null===e)this[i.attribute]=null;else if(void 0===e)delete this[i.attribute];else{switch(i.type){case"SqlValueType":break;case"string":_.isNumber(e)?e=e.toString():_.isBoolean(e)?e=e?"true":"false":_.isDate(e)&&(e=this.toDbTimestamp(e));break;case"number":_.isString(e)?e=parseFloat(e):_.isBoolean(e)?e=e?1:0:_.isDate(e)&&(e=e.getTime());break;case"boolean":_.isString(e)?e=!e.match(/(F|N|false|no|0)/i):_.isNumber(e)?e=!!e:_.isDate(e)&&(e=!0);break;case"Date":_.isString(e)&&e.match(/^\d{4}-[01][0-9]-[0-3][0-9][ T][0-2][0-9]:[0-5][0-9]:[0-5][0-9]\s*$/)&&(e+=" GMT"),e=_.isNumber(e)||_.isString(e)||_.isDate(e)?new Date(e):new Date;break;default:throw`AbstractModel.setValue: unknown data type '${i.type}'`}this[i.attribute]=e}}getValue(t){return this[this.getAttributeMap()[t].attribute]}hasAttribute(t){return!!this.getAttributeMap()[t]}clear(t){_.isArray(t)||(t=[t]);const e=this.getAttributeMap();t.forEach(t=>{const i=e[t];i&&delete this[i.attribute]})}getPlainObject(t,e,i){let s,a=FieldNamingStyle.TypeScript,r=!1;void 0!==t&&("boolean"==typeof t?(r=t,s=e):(a=t,r=e,s=i));const l=this.getAttributeMap(),n=[];void 0===r&&(r=!0),_.forOwn(l,(t,e)=>{let i=a==FieldNamingStyle.All||r&&t.virtual;if(!i)if(a==FieldNamingStyle.Database)i=t.physical;else{if(a!=FieldNamingStyle.TypeScript)throw"unknown style "+a;i=t.typeScriptStyle}i&&(s&&!_.includes(s,e)||n.push(e))});const o={};return n.forEach(t=>{const e=l[t];if(e){const i=this[e.attribute];void 0!==i&&(o[t]=i)}}),o}toDbTimestamp(t){let e;return t&&(_.isNumber(t)&&(t=new Date(t)),e=t.toISOString().substr(0,23).replace("T"," ")),e}}AbstractModel.attributeMap={};
1
+ import _ from"lodash";import{FieldNamingStyle}from"../smart-db-interfaces";export class AbstractModel{static getTableName(){return"overload this in child class"}static from(t){}assign(t,e){if("object"==typeof t){const i=this.getAttributeMap();let s=!e||!!e.skipUndefined;Object.keys(i).forEach((i=>{let a=!0;if(e&&(e.only&&!_.includes(e.only,i)&&(a=!1),e.exclude&&_.includes(e.exclude,i)&&(a=!1)),a)if(t instanceof AbstractModel&&t.hasAttribute(i)){const e=t.getValue(i);s&&void 0===e||this.setValue(i,e)}else if(t.hasOwnProperty(i)){const e=t[i];s&&void 0===e||this.setValue(i,e)}}))}}setValue(t,e){const i=this.getAttributeMap()[t];if(!i)throw`unknown attribute ${t} for ${this.getClassName()}`;if(null===e)this[i.attribute]=null;else if(void 0===e)delete this[i.attribute];else{switch(i.type){case"SqlValueType":break;case"string":_.isNumber(e)?e=e.toString():_.isBoolean(e)?e=e?"true":"false":_.isDate(e)&&(e=this.toDbTimestamp(e));break;case"number":_.isString(e)?e=parseFloat(e):_.isBoolean(e)?e=e?1:0:_.isDate(e)&&(e=e.getTime());break;case"boolean":_.isString(e)?e=!e.match(/(F|N|false|no|0)/i):_.isNumber(e)?e=!!e:_.isDate(e)&&(e=!0);break;case"Date":_.isString(e)&&e.match(/^\d{4}-[01][0-9]-[0-3][0-9][ T][0-2][0-9]:[0-5][0-9]:[0-5][0-9]\s*$/)&&(e+=" GMT"),e=_.isNumber(e)||_.isString(e)||_.isDate(e)?new Date(e):new Date;break;default:throw`AbstractModel.setValue: unknown data type '${i.type}'`}this[i.attribute]=e}}getValue(t){return this[this.getAttributeMap()[t].attribute]}hasAttribute(t){return!!this.getAttributeMap()[t]}clear(t){_.isArray(t)||(t=[t]);const e=this.getAttributeMap();t.forEach((t=>{const i=e[t];i&&delete this[i.attribute]}))}getPlainObject(t,e,i){let s,a=FieldNamingStyle.TypeScript,r=!1;void 0!==t&&("boolean"==typeof t?(r=t,s=e):(a=t,r=e,s=i));const l=this.getAttributeMap(),n=[];void 0===r&&(r=!0),_.forOwn(l,((t,e)=>{let i=a==FieldNamingStyle.All||r&&t.virtual;if(!i)if(a==FieldNamingStyle.Database)i=t.physical;else{if(a!=FieldNamingStyle.TypeScript)throw`unknown style ${a}`;i=t.typeScriptStyle}i&&(s&&!_.includes(s,e)||n.push(e))}));const o={};return n.forEach((t=>{const e=l[t];if(e){const i=this[e.attribute];void 0!==i&&(o[t]=i)}})),o}toDbTimestamp(t){let e;return t&&(_.isNumber(t)&&(t=new Date(t)),e=t.toISOString().substr(0,23).replace("T"," ")),e}}AbstractModel.attributeMap={};
@@ -0,0 +1,23 @@
1
+ import { ModelAttributeMap } from "../smart-db-interfaces";
2
+ import { AbstractModel } from "./abstract-model";
3
+ export interface OracleCatModelData extends Record<string, any> {
4
+ name?: string;
5
+ type?: string;
6
+ }
7
+ export declare class OracleCatModel extends AbstractModel<OracleCatModel, OracleCatModelData> {
8
+ private _name?;
9
+ private _type;
10
+ static readonly attributeMap: ModelAttributeMap;
11
+ static getClassName(): string;
12
+ static getTableName(): string;
13
+ static from(other: OracleCatModel): OracleCatModel;
14
+ clone(): OracleCatModel;
15
+ getClassName(): string;
16
+ getTableName(): string;
17
+ getAttributeMap(): ModelAttributeMap;
18
+ getPrimaryKey(): string;
19
+ get name(): string;
20
+ set name(name: string);
21
+ get type(): string;
22
+ set type(type: string);
23
+ }
@@ -0,0 +1 @@
1
+ import{AbstractModel}from"./abstract-model";export class OracleCatModel extends AbstractModel{static getClassName(){return"OracleCatModel"}static getTableName(){return"cat"}static from(t){let e=null;return t&&(e=new OracleCatModel,t instanceof OracleCatModel?Object.assign(e,t):e.assign(t)),e}clone(){return OracleCatModel.from(this)}getClassName(){return"OracleCatModel"}getTableName(){return"cat"}getAttributeMap(){return OracleCatModel.attributeMap}getPrimaryKey(){return"name"}get name(){return this._name}set name(t){this._name=t}get type(){return this._type}set type(t){this._type=t}}OracleCatModel.attributeMap={TABLE_TYPE:{physical:!0,type:"string",attribute:"_type"},type:{alias:"TABLE_TYPE",typeScriptStyle:!0,type:"string",attribute:"_type"},TABLE_NAME:{physical:!0,type:"string",attribute:"_name"},name:{alias:"TABLE_NAME",typeScriptStyle:!0,type:"string",attribute:"_name"}};
@@ -0,0 +1,39 @@
1
+ import { ModelAttributeMap } from "../smart-db-interfaces";
2
+ import { AbstractModel } from "./abstract-model";
3
+ export interface OracleUserTabColumnsModelData extends Record<string, any> {
4
+ tableName?: string;
5
+ columnName?: string;
6
+ dataType?: string;
7
+ nullable?: string;
8
+ columnId?: string;
9
+ defaultValue?: string;
10
+ }
11
+ export declare class OracleUserTabColumnsModel extends AbstractModel<OracleUserTabColumnsModel, OracleUserTabColumnsModelData> {
12
+ private _tableName?;
13
+ private _columnName?;
14
+ private _dataType;
15
+ private _nullable;
16
+ private _columnId;
17
+ private _defaultValue;
18
+ static readonly attributeMap: ModelAttributeMap;
19
+ static getClassName(): string;
20
+ static getTableName(): string;
21
+ static from(other: OracleUserTabColumnsModel): OracleUserTabColumnsModel;
22
+ clone(): OracleUserTabColumnsModel;
23
+ getClassName(): string;
24
+ getTableName(): string;
25
+ getAttributeMap(): ModelAttributeMap;
26
+ getPrimaryKey(): string;
27
+ get columnId(): number;
28
+ set columnId(value: number);
29
+ get columnName(): string;
30
+ set columnName(type: string);
31
+ get dataType(): string;
32
+ set dataType(type: string);
33
+ get defaultValue(): string;
34
+ set defaultValue(value: string);
35
+ get nullable(): string;
36
+ set nullable(value: string);
37
+ get tableName(): string;
38
+ set tableName(name: string);
39
+ }
@@ -0,0 +1 @@
1
+ import{AbstractModel}from"./abstract-model";export class OracleUserTabColumnsModel extends AbstractModel{static getClassName(){return"OracleUserTabColumnsModel"}static getTableName(){return"user_tab_columns"}static from(t){let e=null;return t&&(e=new OracleUserTabColumnsModel,t instanceof OracleUserTabColumnsModel?Object.assign(e,t):e.assign(t)),e}clone(){return OracleUserTabColumnsModel.from(this)}getClassName(){return"OracleUserTabColumnsModel"}getTableName(){return"user_tab_columns"}getAttributeMap(){return OracleUserTabColumnsModel.attributeMap}getPrimaryKey(){return"name"}get columnId(){return this._columnId}set columnId(t){this._columnId=t}get columnName(){return this._columnName}set columnName(t){this._columnName=t}get dataType(){return this._dataType}set dataType(t){this._dataType=t}get defaultValue(){return this._defaultValue}set defaultValue(t){this._defaultValue=t}get nullable(){return this._nullable}set nullable(t){this._nullable=t}get tableName(){return this._tableName}set tableName(t){this._tableName=t}}OracleUserTabColumnsModel.attributeMap={DATA_TYPE:{physical:!0,type:"string",attribute:"_dataType"},dataType:{alias:"DATA_TYPE",typeScriptStyle:!0,type:"string",attribute:"_dataType"},TABLE_NAME:{physical:!0,type:"string",attribute:"_tableName"},tableName:{alias:"TABLE_NAME",typeScriptStyle:!0,type:"string",attribute:"_tableName"},COLUMN_NAME:{physical:!0,type:"string",attribute:"_columnName"},columnName:{alias:"COLUMN_NAME",typeScriptStyle:!0,type:"string",attribute:"_columnName"},DEFAULT_VALUE:{physical:!0,type:"string",attribute:"_defaultValue"},defaultValue:{alias:"DEFAULT_VALUE",typeScriptStyle:!0,type:"string",attribute:"_defaultValue"},COLUMN_ID:{physical:!0,type:"number",attribute:"_columnId"},columnId:{alias:"COLUMN_ID",typeScriptStyle:!0,type:"number",attribute:"_columnId"},NULLABLE:{physical:!0,type:"string",attribute:"_nullable"},nullable:{alias:"NULLABLE",typeScriptStyle:!0,type:"string",attribute:"_nullable"}};
@@ -0,0 +1,43 @@
1
+ import { ModelAttributeMap } from "../smart-db-interfaces";
2
+ import { AbstractModel } from "./abstract-model";
3
+ export interface OracleUserTabColumnsViewModelData extends Record<string, any> {
4
+ tableName?: string;
5
+ columnName?: string;
6
+ dataType?: string;
7
+ nullable?: string;
8
+ columnId?: string;
9
+ defaultValue?: string;
10
+ constraintType?: string;
11
+ }
12
+ export declare class OracleUserTabColumnsViewModel extends AbstractModel<OracleUserTabColumnsViewModel, OracleUserTabColumnsViewModelData> {
13
+ private _tableName?;
14
+ private _columnName?;
15
+ private _dataType;
16
+ private _nullable;
17
+ private _columnId;
18
+ private _defaultValue;
19
+ private _constraintType;
20
+ static readonly attributeMap: ModelAttributeMap;
21
+ static getClassName(): string;
22
+ static getTableName(): string;
23
+ static from(other: OracleUserTabColumnsViewModel): OracleUserTabColumnsViewModel;
24
+ clone(): OracleUserTabColumnsViewModel;
25
+ getClassName(): string;
26
+ getTableName(): string;
27
+ getAttributeMap(): ModelAttributeMap;
28
+ getPrimaryKey(): string;
29
+ get columnId(): number;
30
+ set columnId(value: number);
31
+ get columnName(): string;
32
+ set columnName(type: string);
33
+ get constraintType(): string;
34
+ set constraintType(value: string);
35
+ get dataType(): string;
36
+ set dataType(type: string);
37
+ get defaultValue(): string;
38
+ set defaultValue(value: string);
39
+ get nullable(): string;
40
+ set nullable(value: string);
41
+ get tableName(): string;
42
+ set tableName(name: string);
43
+ }
@@ -0,0 +1 @@
1
+ import{AbstractModel}from"./abstract-model";export class OracleUserTabColumnsViewModel extends AbstractModel{static getClassName(){return"OracleUserTabColumnsViewModel"}static getTableName(){return"smart_db_user_tab_columns_view"}static from(t){let e=null;return t&&(e=new OracleUserTabColumnsViewModel,t instanceof OracleUserTabColumnsViewModel?Object.assign(e,t):e.assign(t)),e}clone(){return OracleUserTabColumnsViewModel.from(this)}getClassName(){return"OracleUserTabColumnsViewModel"}getTableName(){return"smart_db_user_tab_columns_view"}getAttributeMap(){return OracleUserTabColumnsViewModel.attributeMap}getPrimaryKey(){return"columnId"}get columnId(){return this._columnId}set columnId(t){this._columnId=t}get columnName(){return this._columnName}set columnName(t){this._columnName=t}get constraintType(){return this._constraintType}set constraintType(t){this._constraintType=t}get dataType(){return this._dataType}set dataType(t){this._dataType=t}get defaultValue(){return this._defaultValue}set defaultValue(t){this._defaultValue=t}get nullable(){return this._nullable}set nullable(t){this._nullable=t}get tableName(){return this._tableName}set tableName(t){this._tableName=t}}OracleUserTabColumnsViewModel.attributeMap={DATA_TYPE:{physical:!0,type:"string",attribute:"_dataType"},dataType:{alias:"DATA_TYPE",typeScriptStyle:!0,type:"string",attribute:"_dataType"},TABLE_NAME:{physical:!0,type:"string",attribute:"_tableName"},tableName:{alias:"TABLE_NAME",typeScriptStyle:!0,type:"string",attribute:"_tableName"},COLUMN_NAME:{physical:!0,type:"string",attribute:"_columnName"},columnName:{alias:"COLUMN_NAME",typeScriptStyle:!0,type:"string",attribute:"_columnName"},DEFAULT_VALUE:{physical:!0,type:"string",attribute:"_defaultValue"},defaultValue:{alias:"DEFAULT_VALUE",typeScriptStyle:!0,type:"string",attribute:"_defaultValue"},COLUMN_ID:{physical:!0,type:"number",attribute:"_columnId"},columnId:{alias:"COLUMN_ID",typeScriptStyle:!0,type:"number",attribute:"_columnId"},NULLABLE:{physical:!0,type:"string",attribute:"_nullable"},nullable:{alias:"NULLABLE",typeScriptStyle:!0,type:"string",attribute:"_nullable"},CONSTRAINT_TYPE:{physical:!0,type:"string",attribute:"_constraintType"},constraintType:{alias:"CONSTRAINT_TYPE",typeScriptStyle:!0,type:"string",attribute:"_constraintType"}};
@@ -24,12 +24,18 @@ export declare class SmartDbCoreTableModel extends AbstractModel<SmartDbCoreTabl
24
24
  set id(id: number);
25
25
  get ctb_id(): number;
26
26
  set ctb_id(id: number);
27
+ get CTB_ID(): number;
28
+ set CTB_ID(id: number);
27
29
  get name(): string;
28
30
  set name(name: string);
29
31
  get ctb_name(): string;
30
32
  set ctb_name(name: string);
33
+ get CTB_NAME(): string;
34
+ set CTB_NAME(name: string);
31
35
  get type(): string;
32
36
  set type(type: string);
33
37
  get ctb_type(): string;
34
38
  set ctb_type(type: string);
39
+ get CTB_TYPE(): string;
40
+ set CTB_TYPE(type: string);
35
41
  }
@@ -1 +1 @@
1
- import{AbstractModel}from"./abstract-model";export class SmartDbCoreTableModel extends AbstractModel{constructor(t){super(),t&&this.assign(t)}static getClassName(){return"SmartDbCoreTableModel"}static getTableName(){return"smart_db_core_table"}static getPrimaryKey(){return"ctb_id"}static from(t){let e=null;return t&&(e=new SmartDbCoreTableModel,t instanceof SmartDbCoreTableModel?Object.assign(e,t):e.assign(t)),e}clone(){return SmartDbCoreTableModel.from(this)}getClassName(){return"SmartDbCoreTableModel"}getTableName(){return"smart_db_core_table"}getPrimaryKey(){return"ctb_id"}getAttributeMap(){return SmartDbCoreTableModel.attributeMap}get id(){return this._id}set id(t){this._id=t}get ctb_id(){return this._id}set ctb_id(t){this._id=t}get name(){return this._name}set name(t){this._name=t}get ctb_name(){return this._name}set ctb_name(t){this._name=t}get type(){return this._type}set type(t){this._type=t}get ctb_type(){return this._type}set ctb_type(t){this._type=t}}SmartDbCoreTableModel.attributeMap={id:{alias:"ctb_id",typeScriptStyle:!0,type:"number",attribute:"_id"},ctb_id:{physical:!0,type:"number",attribute:"_id"},name:{alias:"ctb_name",typeScriptStyle:!0,type:"string",attribute:"_name"},ctb_name:{physical:!0,type:"string",attribute:"_name"},type:{alias:"ctb_type",typeScriptStyle:!0,type:"string",attribute:"_type"},ctb_type:{physical:!0,type:"string",attribute:"_type"}};
1
+ import{AbstractModel}from"./abstract-model";export class SmartDbCoreTableModel extends AbstractModel{constructor(t){super(),t&&this.assign(t)}static getClassName(){return"SmartDbCoreTableModel"}static getTableName(){return"smart_db_core_table"}static getPrimaryKey(){return"CTB_ID"}static from(t){let e=null;return t&&(e=new SmartDbCoreTableModel,t instanceof SmartDbCoreTableModel?Object.assign(e,t):e.assign(t)),e}clone(){return SmartDbCoreTableModel.from(this)}getClassName(){return"SmartDbCoreTableModel"}getTableName(){return"smart_db_core_table"}getPrimaryKey(){return"CTB_ID"}getAttributeMap(){return SmartDbCoreTableModel.attributeMap}get id(){return this._id}set id(t){this._id=t}get ctb_id(){return this._id}set ctb_id(t){this._id=t}get CTB_ID(){return this._id}set CTB_ID(t){this._id=t}get name(){return this._name}set name(t){this._name=t}get ctb_name(){return this._name}set ctb_name(t){this._name=t}get CTB_NAME(){return this._name}set CTB_NAME(t){this._name=t}get type(){return this._type}set type(t){this._type=t}get ctb_type(){return this._type}set ctb_type(t){this._type=t}get CTB_TYPE(){return this._type}set CTB_TYPE(t){this._type=t}}SmartDbCoreTableModel.attributeMap={id:{alias:"CTB_ID",typeScriptStyle:!0,type:"number",attribute:"_id"},ctb_id:{type:"number",attribute:"_id"},CTB_ID:{physical:!0,type:"number",attribute:"_id"},name:{alias:"CTB_NAME",typeScriptStyle:!0,type:"string",attribute:"_name"},ctb_name:{type:"string",attribute:"_name"},CTB_NAME:{physical:!0,type:"string",attribute:"_name"},type:{alias:"CTB_TYPE",typeScriptStyle:!0,type:"string",attribute:"_type"},ctb_type:{type:"string",attribute:"_type"},CTB_TYPE:{physical:!0,type:"string",attribute:"_type"}};
@@ -1,9 +1,10 @@
1
1
  import { SmartDbCoreTableModel } from "./smart-db-core-table-model";
2
2
  import { SmartDbLogModel } from "./smart-db-log-model";
3
+ import { SmartDbUserTabColumnsViewModel } from "./smart-db-user-tab-columns-view-model";
3
4
  import { SmartDbVersionModel } from "./smart-db-version-model";
4
5
  import { SmartDbVersionViewModel } from "./smart-db-version-view-model";
5
6
  interface SmartDbDictionaryEntry {
6
- cls: typeof SmartDbCoreTableModel | typeof SmartDbLogModel | typeof SmartDbVersionModel | typeof SmartDbVersionViewModel;
7
+ cls: typeof SmartDbCoreTableModel | typeof SmartDbLogModel | typeof SmartDbUserTabColumnsViewModel | typeof SmartDbVersionModel | typeof SmartDbVersionViewModel;
7
8
  }
8
9
  export declare class SmartDbDictionary {
9
10
  static models: {
@@ -1 +1 @@
1
- import{SmartDbCoreTableModel}from"./smart-db-core-table-model";import{SmartDbLogModel}from"./smart-db-log-model";import{SmartDbVersionModel}from"./smart-db-version-model";import{SmartDbVersionViewModel}from"./smart-db-version-view-model";export class SmartDbDictionary{}SmartDbDictionary.models={SmartDbCoreTableModel:{cls:SmartDbCoreTableModel},SmartDbLogModel:{cls:SmartDbLogModel},SmartDbVersionModel:{cls:SmartDbVersionModel},SmartDbVersionViewModel:{cls:SmartDbVersionViewModel}};
1
+ import{SmartDbCoreTableModel}from"./smart-db-core-table-model";import{SmartDbLogModel}from"./smart-db-log-model";import{SmartDbUserTabColumnsViewModel}from"./smart-db-user-tab-columns-view-model";import{SmartDbVersionModel}from"./smart-db-version-model";import{SmartDbVersionViewModel}from"./smart-db-version-view-model";export class SmartDbDictionary{}SmartDbDictionary.models={SmartDbCoreTableModel:{cls:SmartDbCoreTableModel},SmartDbLogModel:{cls:SmartDbLogModel},SmartDbUserTabColumnsViewModel:{cls:SmartDbUserTabColumnsViewModel},SmartDbVersionModel:{cls:SmartDbVersionModel},SmartDbVersionViewModel:{cls:SmartDbVersionViewModel}};
@@ -1,5 +1,6 @@
1
1
  import { GenericModelData, ModelAttributeMap } from "../smart-db-interfaces";
2
2
  import { AbstractModel } from "./abstract-model";
3
+ import { SqlValueType } from "../smart-db-interfaces";
3
4
  export interface SmartDbLogModelData extends GenericModelData {
4
5
  id?: number;
5
6
  severity?: string;
@@ -8,7 +9,7 @@ export interface SmartDbLogModelData extends GenericModelData {
8
9
  info?: string;
9
10
  data?: string;
10
11
  user?: string;
11
- timestamp?: Date;
12
+ timestamp?: SqlValueType;
12
13
  }
13
14
  export declare class SmartDbLogModel extends AbstractModel<SmartDbLogModel, SmartDbLogModelData> {
14
15
  private _id?;
@@ -34,32 +35,48 @@ export declare class SmartDbLogModel extends AbstractModel<SmartDbLogModel, Smar
34
35
  set id(id: number);
35
36
  get log_id(): number;
36
37
  set log_id(id: number);
38
+ get LOG_ID(): number;
39
+ set LOG_ID(id: number);
37
40
  get severity(): string;
38
41
  set severity(severity: string);
39
42
  get log_severity(): string;
40
43
  set log_severity(severity: string);
44
+ get LOG_SEVERITY(): string;
45
+ set LOG_SEVERITY(severity: string);
41
46
  get type(): string;
42
47
  set type(type: string);
43
48
  get log_type(): string;
44
49
  set log_type(type: string);
50
+ get LOG_TYPE(): string;
51
+ set LOG_TYPE(type: string);
45
52
  get location(): string;
46
53
  set location(location: string);
47
54
  get log_location(): string;
48
55
  set log_location(location: string);
56
+ get LOG_LOCATION(): string;
57
+ set LOG_LOCATION(location: string);
49
58
  get info(): string;
50
59
  set info(info: string);
51
60
  get log_info(): string;
52
61
  set log_info(info: string);
62
+ get LOG_INFO(): string;
63
+ set LOG_INFO(info: string);
53
64
  get data(): string;
54
65
  set data(data: string);
55
66
  get log_data(): string;
56
67
  set log_data(data: string);
68
+ get LOG_DATA(): string;
69
+ set LOG_DATA(data: string);
57
70
  get user(): string;
58
71
  set user(user: string);
59
72
  get log_user(): string;
60
73
  set log_user(user: string);
61
- get timestamp(): Date;
62
- set timestamp(timestamp: Date);
63
- get log_timestamp(): Date;
64
- set log_timestamp(timestamp: Date);
74
+ get LOG_USER(): string;
75
+ set LOG_USER(user: string);
76
+ get timestamp(): SqlValueType;
77
+ set timestamp(timestamp: SqlValueType);
78
+ get log_timestamp(): SqlValueType;
79
+ set log_timestamp(timestamp: SqlValueType);
80
+ get LOG_TIMESTAMP(): SqlValueType;
81
+ set LOG_TIMESTAMP(timestamp: SqlValueType);
65
82
  }