@egi/smart-db 2.3.0 → 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.
- package/.eslintrc.json +212 -0
- package/README.md +2 -0
- package/bin/copy-assets +6 -0
- package/package.json +4 -4
- package/src/drivers/smart-db-better-sqlite3.ts +284 -0
- package/src/drivers/smart-db-mysql.ts +159 -0
- package/src/drivers/smart-db-mysql2.ts +159 -0
- package/src/drivers/smart-db-sqlite3.ts +198 -0
- package/src/helpers/extract-db-api.ts +465 -0
- package/src/helpers/terser-tree.ts +39 -0
- package/src/models/abstract-model.ts +209 -0
- package/src/models/smart-db-core-table-model.ts +161 -0
- package/src/models/smart-db-dictionary.ts +28 -0
- package/src/models/smart-db-log-model.ts +316 -0
- package/src/models/smart-db-version-model.ts +316 -0
- package/src/models/smart-db-version-view-model.ts +347 -0
- package/src/models/sqlite-master-model.ts +140 -0
- package/src/models/sqlite-sequence-model.ts +91 -0
- package/{smart-db-api.d.ts → src/smart-db-api.ts} +3 -0
- package/src/smart-db-globals.ts +136 -0
- package/{smart-db-interfaces.d.ts → src/smart-db-interfaces.ts} +82 -34
- package/src/smart-db-log.ts +262 -0
- package/src/smart-db-sql-build-data.ts +28 -0
- package/src/smart-db-upgrade-manager.ts +171 -0
- package/src/smart-db.ts +854 -0
- package/test/data/sql-engine-tests.json +232 -0
- package/test/db/mysql/database-init.sql +11 -0
- package/test/db/sqlite3/database-init.sql +11 -0
- package/test/exer.js +28 -0
- package/test/model/smart-db-dictionary.ts +19 -0
- package/test/model/test-table-model.ts +214 -0
- package/test/test.js +273 -0
- package/test/test2.js +252 -0
- package/tsconfig.json +32 -0
- package/tsconfig.pro.json +32 -0
- package/tsconfig.test-model.json +23 -0
- package/drivers/smart-db-better-sqlite3.d.ts +0 -36
- package/drivers/smart-db-better-sqlite3.js +0 -1
- package/drivers/smart-db-mysql.d.ts +0 -26
- package/drivers/smart-db-mysql.js +0 -1
- package/drivers/smart-db-mysql2.d.ts +0 -26
- package/drivers/smart-db-mysql2.js +0 -1
- package/drivers/smart-db-sqlite3.d.ts +0 -30
- package/drivers/smart-db-sqlite3.js +0 -1
- package/helpers/extract-db-api.d.ts +0 -1
- package/helpers/extract-db-api.js +0 -1
- package/models/abstract-model.d.ts +0 -22
- package/models/abstract-model.js +0 -1
- package/models/smart-db-core-table-model.d.ts +0 -35
- package/models/smart-db-core-table-model.js +0 -1
- package/models/smart-db-dictionary.d.ts +0 -13
- package/models/smart-db-dictionary.js +0 -1
- package/models/smart-db-log-model.d.ts +0 -65
- package/models/smart-db-log-model.js +0 -1
- package/models/smart-db-version-model.d.ts +0 -65
- package/models/smart-db-version-model.js +0 -1
- package/models/smart-db-version-view-model.d.ts +0 -71
- package/models/smart-db-version-view-model.js +0 -1
- package/models/sqlite-master-model.d.ts +0 -36
- package/models/sqlite-master-model.js +0 -1
- package/models/sqlite-sequence-model.d.ts +0 -24
- package/models/sqlite-sequence-model.js +0 -1
- package/smart-db-api.js +0 -1
- package/smart-db-globals.d.ts +0 -22
- package/smart-db-globals.js +0 -1
- package/smart-db-interfaces.js +0 -1
- package/smart-db-log.d.ts +0 -58
- package/smart-db-log.js +0 -1
- package/smart-db-sql-build-data.d.ts +0 -9
- package/smart-db-sql-build-data.js +0 -1
- package/smart-db-upgrade-manager.d.ts +0 -13
- package/smart-db-upgrade-manager.js +0 -1
- package/smart-db.d.ts +0 -67
- package/smart-db.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
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,26 +0,0 @@
|
|
|
1
|
-
import Mysql, { Connection, ConnectionConfig } from "mysql";
|
|
2
|
-
import { AbstractModel } from "../models/abstract-model";
|
|
3
|
-
import { SmartDb } from "../smart-db";
|
|
4
|
-
import { SmartDbSqlBuildData } from "../smart-db-sql-build-data";
|
|
5
|
-
import { GenericModelData, SmartDbRunResult, SmartDbTableInfo } from "../smart-db-interfaces";
|
|
6
|
-
export declare class SmartDbMysql2 extends SmartDb {
|
|
7
|
-
protected db: Mysql.Connection;
|
|
8
|
-
constructor(connectorOrDb: string | ConnectionConfig | Connection);
|
|
9
|
-
getDatabaseType(): string;
|
|
10
|
-
getDbConnector(): string | Mysql.ConnectionConfig;
|
|
11
|
-
getDbQuote(): string;
|
|
12
|
-
hasConcurrentTransactions(): boolean;
|
|
13
|
-
closeSync(): boolean;
|
|
14
|
-
exists<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): Promise<boolean>;
|
|
15
|
-
existsSync<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): boolean;
|
|
16
|
-
exec(script: string): Promise<void>;
|
|
17
|
-
execSync(script: string): boolean;
|
|
18
|
-
getTableInfo(table: string): Promise<SmartDbTableInfo>;
|
|
19
|
-
protected statementGet(buildData: SmartDbSqlBuildData): Promise<any>;
|
|
20
|
-
protected statementGetSync(buildData: SmartDbSqlBuildData): any;
|
|
21
|
-
protected statementGetAll(buildData: SmartDbSqlBuildData): Promise<any[]>;
|
|
22
|
-
protected statementGetAllSync(buildData: SmartDbSqlBuildData): any[];
|
|
23
|
-
protected statementRun(buildData: SmartDbSqlBuildData): Promise<SmartDbRunResult>;
|
|
24
|
-
protected statementRunSync(buildData: SmartDbSqlBuildData): SmartDbRunResult;
|
|
25
|
-
close(): Promise<void>;
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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,30 +0,0 @@
|
|
|
1
|
-
import Sqlite3 from "sqlite3";
|
|
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 SmartDbSqlite3Options {
|
|
7
|
-
mode?: number;
|
|
8
|
-
callback?: (this: Sqlite3.Database, err: Error | null) => void;
|
|
9
|
-
}
|
|
10
|
-
export declare class SmartDbSqlite3 extends SmartDb {
|
|
11
|
-
protected db: Sqlite3.Database;
|
|
12
|
-
constructor(connectorOrDb: string | Sqlite3.Database, options?: SmartDbSqlite3Options);
|
|
13
|
-
getDatabaseType(): string;
|
|
14
|
-
getDbConnector(): string | SmartDbConnector;
|
|
15
|
-
getDbQuote(): string;
|
|
16
|
-
hasConcurrentTransactions(): boolean;
|
|
17
|
-
exists<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): Promise<boolean>;
|
|
18
|
-
existsSync<T extends AbstractModel<T, D>, D extends GenericModelData>(modelClass: string | (new () => T), type?: "view" | "table" | "index", indexTableName?: string): boolean;
|
|
19
|
-
exec(script: string): Promise<void>;
|
|
20
|
-
execSync(script: string): Sqlite3.Database | false;
|
|
21
|
-
closeSync(): boolean;
|
|
22
|
-
getTableInfo(table: string): Promise<SmartDbTableInfo>;
|
|
23
|
-
protected statementRun(buildData: SmartDbSqlBuildData): Promise<SmartDbRunResult>;
|
|
24
|
-
protected statementRunSync(buildData: SmartDbSqlBuildData): SmartDbRunResult;
|
|
25
|
-
protected statementGet(buildData: SmartDbSqlBuildData): Promise<any>;
|
|
26
|
-
protected statementGetSync(buildData: SmartDbSqlBuildData): void;
|
|
27
|
-
protected statementGetAll(buildData: SmartDbSqlBuildData): Promise<any[]>;
|
|
28
|
-
protected statementGetAllSync(buildData: SmartDbSqlBuildData): any[];
|
|
29
|
-
close(): Promise<void>;
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
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 n=[];if(!e.includeCoreTables&&e.db.existsSync(SmartDbCoreTableModel)){const t=e.db.getAllSync(SmartDbCoreTableModel);if(!1===t)throw e.db.getLastError();t.forEach(e=>{n.push(e.name)})}const r=[];t.forEach(t=>{if(!n.includes(t.name)){const n=t.name[0].toUpperCase()+_.camelCase(t.name.substr(1))+"Model";r.push(n);const a=[];e.db.getTableInfo(t.name).then(r=>{const s=r.fields;let o=!1,i="",l="/* eslint-disable @typescript-eslint/member-ordering */\n";if(l+="// noinspection JSUnusedGlobalSymbols\n\n",s){l+=`import {AbstractModel, GenericModelData, ModelAttributeMap} from "${e.abstractModelModule}";\n`,i+=`export interface ${n}Data extends GenericModelData {\n`,"user"==t.name&&s.push({name:"hash",type:"string",virtual:!0},{name:"privileges",type:"string[]",virtual:!0});let r,c="",m="",b=!1;const p=[];s.forEach(e=>{const t=e.name.match(/([a-z0-9]{1,4})_/i);e.isPk&&(c=e.name,t&&(m=t[1])),t?p.includes(t[1])||p.push(t[1]):b=!0}),m||b||1!=p.length||(m=p[0]),m&&(r=new RegExp(`^${m}_(.*)$`));const d={};s.forEach(n=>{const s=getType(n.type);let c;o||"SqlValueType"!=s||(l+=`import {SqlValueType} from "${e.smartDbInterfaces}";\n`,o=!0);const m=r&&n.name.match(r);c=m?_.camelCase(m[1]):_.camelCase(n.name);let b=!0;c!=n.name&&(a.push({name:c,attribute:c,type:s,typeScriptStyle:b,alias:n.name}),b=!1),a.push({name:n.name,attribute:c,type:s,physical:void 0!==n.cid,typeScriptStyle:b}),d[c]=s,"user"==t.name&&"name"==c&&(i+=" // @ts-ignore"),i+=` ${c}?: ${s};\n`}),i+="}\n\n",i+=`export class ${n} extends AbstractModel<${n}, ${n}Data> {\n`,_.forEach(d,(e,t)=>{i+=` private _${t}?: ${e};\n`}),i+="\n",i+=" static readonly attributeMap: ModelAttributeMap = {\n",a.forEach((e,t)=>{t>0&&(i+=",\n"),i+=` ${e.name}: {\n`,e.physical&&(i+=" physical: true,\n"),e.alias&&(i+=` alias: "${e.alias}",\n`),e.virtual&&(i+=" virtual: true,\n"),e.typeScriptStyle&&(i+=" typeScriptStyle: true,\n"),i+=` type: "${e.type}",\n`,i+=` attribute: "_${e.attribute}"\n`,i+=" }"}),i+="\n",i+=" };\n",i+="\n",i+=" static getClassName(): string {\n",i+=` return "${n}";\n`,i+=" }\n",i+="\n",i+=" static getTableName(): string {\n",i+=` return "${t.name}";\n`,i+=" }\n",i+="\n",i+=" static getPrimaryKey(): string {\n",i+=` return "${c}";\n`,i+=" }\n",i+="\n",i+=` static from(other: ${n} | ${n}Data): ${n} {\n`,i+=` let value: ${n} = null;\n`,i+=" if (other) {\n",i+=` value = new ${n}();\n`,i+=` if (other instanceof ${n}) {\n`,i+=" Object.assign(value, other);\n",i+=" } else {\n",i+=" value.assign(other);\n",i+=" }\n",i+=" }\n",i+=" return value;\n",i+=" }\n",i+="\n",i+=` constructor(data?: ${n} | ${n}Data) {\n`,i+=" super();\n",i+=" if (data) {\n",i+=" this.assign(data);\n",i+=" }\n",i+=" }\n",i+="\n",i+=` public clone(): ${n} {\n`,i+=` return ${n}.from(this);\n`,i+=" }\n",i+="\n",i+=" public getClassName(): string {\n",i+=` return "${n}";\n`,i+=" }\n",i+="\n",i+=" public getTableName(): string {\n",i+=` return "${t.name}";\n`,i+=" }\n",i+="\n",i+=" public getPrimaryKey(): string {\n",i+=` return "${c}";\n`,i+=" }\n",i+="\n",i+=" public getAttributeMap(): ModelAttributeMap {\n",i+=` return ${n}.attributeMap;\n`,i+=" }\n",a.forEach(e=>{let t;i+="\n",t=e.name.length<3||e.name.match(/_/)?"FunctionNamingConventionJS":"",""!==t&&(i+=` // noinspection ${t}\n`),i+=` get ${e.name}(): ${e.type} {\n`,i+=` return this._${e.attribute};\n`,i+=" }\n\n",""!==t&&(i+=` // noinspection ${t}\n`),i+=` set ${e.name}(${e.attribute}: ${e.type}) {\n`,i+=` this._${e.attribute} = ${e.attribute};\n`,i+=" }\n"}),i+="}\n",i=l+"\n"+i;const u=t.name.replace(/[^[a-z0-9]/g,"-")+"-models.ts";fs.writeFileSync(`${e.modelDirectory}/${u}`,i)}else console.log("error: table has no fields")}).catch(e=>{console.error(e),process.abort()})}});let a=`import {AbstractModel} from "${e.abstractModelModule}";\n`;_.forEach(r,e=>{a+=`import {${e}} from "./${_.kebabCase(e)}";\n`}),a+="\n",a+="interface SmartDbDictionaryEntry {\n",a+=" cls: "+r.map(e=>"typeof "+e).join(" |\n "),a+=";\n",a+="}\n\n",a+="export class SmartDbDictionary {\n",a+=" static models: { [relation: string]: SmartDbDictionaryEntry; } = {\n",_.forEach(r,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()}(()=>{if(4==process.argv.length){extractDbApi({modelDirectory:process.argv[3],smartDbInterfaces:"@egi/smart-db/smart-db-api",abstractModelModule:"@egi/smart-db/smart-db-api",db:new SmartDbBetterSqlite3(process.argv[2],{verbose:(e,...t)=>{console.log("DB LOG",e,...t)}})})}else if(2==process.argv.length&&fs.existsSync("src/helpers/extract-db-api.ts")){const e=`/tmp/smart-db-core.${process.pid}.sqlite3`,t={includeCoreTables:!0,modelDirectory:"src/models",smartDbInterfaces:"../smart-db-interfaces",abstractModelModule:"./abstract-models",db:new SmartDbBetterSqlite3(e,{verbose:(e,...t)=>{console.log("DB LOG",e,...t)}})};t.db.initDb({module:"smart-db-core",sqlFilesDirectory:"assets/sqlite3"}).then(()=>{extractDbApi(t),fs.unlinkSync(e),t.db.closeSync()})}else console.log("usage: extract-db-api {db-connector|path-to-db} {target-models-directory}")})();
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { FieldNamingStyle, GenericModelData, ModelAttributeMap } from "../smart-db-interfaces";
|
|
2
|
-
export declare abstract class AbstractModel<T extends AbstractModel<T, D>, D extends GenericModelData> {
|
|
3
|
-
abstract clone(): T;
|
|
4
|
-
abstract getClassName(): string;
|
|
5
|
-
abstract getTableName(): string;
|
|
6
|
-
abstract getPrimaryKey(): string;
|
|
7
|
-
abstract getAttributeMap(): ModelAttributeMap;
|
|
8
|
-
static readonly attributeMap: ModelAttributeMap;
|
|
9
|
-
static getTableName(): string;
|
|
10
|
-
static from(other: any): any;
|
|
11
|
-
assign(other: T | D, options?: {
|
|
12
|
-
only?: string[];
|
|
13
|
-
exclude?: string[];
|
|
14
|
-
skipUndefined?: boolean;
|
|
15
|
-
}): void;
|
|
16
|
-
setValue(attribute: string, value: string | number | boolean | Date): void;
|
|
17
|
-
getValue(attribute: string): string | number | boolean;
|
|
18
|
-
hasAttribute(attribute: string): boolean;
|
|
19
|
-
clear(attributes: string | string[]): void;
|
|
20
|
-
getPlainObject(style: FieldNamingStyle, includeVirtuals?: boolean, fields?: string[]): D;
|
|
21
|
-
private toDbTimestamp;
|
|
22
|
-
}
|
package/models/abstract-model.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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){const s=this.getAttributeMap(),a=[];void 0===e&&(e=!0),_.forOwn(s,(s,r)=>{let l=t==FieldNamingStyle.All||e&&s.virtual;if(!l)if(t==FieldNamingStyle.Database)l=s.physical;else{if(t!=FieldNamingStyle.TypeScript)throw"unknown style "+t;l=s.typeScriptStyle}l&&(i&&!_.includes(i,r)||a.push(r))});const r={};return a.forEach(t=>{const e=s[t];if(e){const i=this[e.attribute];void 0!==i&&(r[t]=i)}}),r}toDbTimestamp(t){let e;return t&&(_.isNumber(t)&&(t=new Date(t)),e=t.toISOString().substr(0,23).replace("T"," ")),e}}AbstractModel.attributeMap={};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { GenericModelData, ModelAttributeMap } from "../smart-db-interfaces";
|
|
2
|
-
import { AbstractModel } from "./abstract-model";
|
|
3
|
-
export interface SmartDbCoreTableModelData extends GenericModelData {
|
|
4
|
-
id?: number;
|
|
5
|
-
name?: string;
|
|
6
|
-
type?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class SmartDbCoreTableModel extends AbstractModel<SmartDbCoreTableModel, SmartDbCoreTableModelData> {
|
|
9
|
-
private _id?;
|
|
10
|
-
private _name?;
|
|
11
|
-
private _type?;
|
|
12
|
-
static readonly attributeMap: ModelAttributeMap;
|
|
13
|
-
constructor(data?: SmartDbCoreTableModel | SmartDbCoreTableModelData);
|
|
14
|
-
static getClassName(): string;
|
|
15
|
-
static getTableName(): string;
|
|
16
|
-
static getPrimaryKey(): string;
|
|
17
|
-
static from(other: SmartDbCoreTableModel | SmartDbCoreTableModelData): SmartDbCoreTableModel;
|
|
18
|
-
clone(): SmartDbCoreTableModel;
|
|
19
|
-
getClassName(): string;
|
|
20
|
-
getTableName(): string;
|
|
21
|
-
getPrimaryKey(): string;
|
|
22
|
-
getAttributeMap(): ModelAttributeMap;
|
|
23
|
-
get ctb_id(): number;
|
|
24
|
-
set ctb_id(id: number);
|
|
25
|
-
get ctb_name(): string;
|
|
26
|
-
set ctb_name(name: string);
|
|
27
|
-
get ctb_type(): string;
|
|
28
|
-
set ctb_type(type: string);
|
|
29
|
-
get id(): number;
|
|
30
|
-
set id(id: number);
|
|
31
|
-
get name(): string;
|
|
32
|
-
set name(name: string);
|
|
33
|
-
get type(): string;
|
|
34
|
-
set type(type: string);
|
|
35
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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 ctb_id(){return this._id}set ctb_id(t){this._id=t}get ctb_name(){return this._name}set ctb_name(t){this._name=t}get ctb_type(){return this._type}set ctb_type(t){this._type=t}get id(){return this._id}set id(t){this._id=t}get name(){return this._name}set name(t){this._name=t}get type(){return this._type}set 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,13 +0,0 @@
|
|
|
1
|
-
import { SmartDbCoreTableModel } from "./smart-db-core-table-model";
|
|
2
|
-
import { SmartDbLogModel } from "./smart-db-log-model";
|
|
3
|
-
import { SmartDbVersionModel } from "./smart-db-version-model";
|
|
4
|
-
import { SmartDbVersionViewModel } from "./smart-db-version-view-model";
|
|
5
|
-
interface SmartDbDictionaryEntry {
|
|
6
|
-
cls: typeof SmartDbCoreTableModel | typeof SmartDbLogModel | typeof SmartDbVersionModel | typeof SmartDbVersionViewModel;
|
|
7
|
-
}
|
|
8
|
-
export declare class SmartDbDictionary {
|
|
9
|
-
static models: {
|
|
10
|
-
[relation: string]: SmartDbDictionaryEntry;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
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,65 +0,0 @@
|
|
|
1
|
-
import { GenericModelData, ModelAttributeMap } from "../smart-db-interfaces";
|
|
2
|
-
import { AbstractModel } from "./abstract-model";
|
|
3
|
-
export interface SmartDbLogModelData extends GenericModelData {
|
|
4
|
-
id?: number;
|
|
5
|
-
severity?: string;
|
|
6
|
-
type?: string;
|
|
7
|
-
location?: string;
|
|
8
|
-
info?: string;
|
|
9
|
-
data?: string;
|
|
10
|
-
user?: string;
|
|
11
|
-
timestamp?: Date;
|
|
12
|
-
}
|
|
13
|
-
export declare class SmartDbLogModel extends AbstractModel<SmartDbLogModel, SmartDbLogModelData> {
|
|
14
|
-
private _id?;
|
|
15
|
-
private _severity?;
|
|
16
|
-
private _type?;
|
|
17
|
-
private _location?;
|
|
18
|
-
private _info?;
|
|
19
|
-
private _data?;
|
|
20
|
-
private _user?;
|
|
21
|
-
private _timestamp?;
|
|
22
|
-
static readonly attributeMap: ModelAttributeMap;
|
|
23
|
-
constructor(data?: SmartDbLogModel | SmartDbLogModelData);
|
|
24
|
-
static getClassName(): string;
|
|
25
|
-
static getTableName(): string;
|
|
26
|
-
static getPrimaryKey(): string;
|
|
27
|
-
static from(other: SmartDbLogModel | SmartDbLogModelData): SmartDbLogModel;
|
|
28
|
-
clone(): SmartDbLogModel;
|
|
29
|
-
getClassName(): string;
|
|
30
|
-
getTableName(): string;
|
|
31
|
-
getPrimaryKey(): string;
|
|
32
|
-
getAttributeMap(): ModelAttributeMap;
|
|
33
|
-
get data(): string;
|
|
34
|
-
set data(data: string);
|
|
35
|
-
get id(): number;
|
|
36
|
-
set id(id: number);
|
|
37
|
-
get info(): string;
|
|
38
|
-
set info(info: string);
|
|
39
|
-
get location(): string;
|
|
40
|
-
set location(location: string);
|
|
41
|
-
get log_data(): string;
|
|
42
|
-
set log_data(data: string);
|
|
43
|
-
get log_id(): number;
|
|
44
|
-
set log_id(id: number);
|
|
45
|
-
get log_info(): string;
|
|
46
|
-
set log_info(info: string);
|
|
47
|
-
get log_location(): string;
|
|
48
|
-
set log_location(location: string);
|
|
49
|
-
get log_severity(): string;
|
|
50
|
-
set log_severity(severity: string);
|
|
51
|
-
get log_timestamp(): Date;
|
|
52
|
-
set log_timestamp(timestamp: Date);
|
|
53
|
-
get log_type(): string;
|
|
54
|
-
set log_type(type: string);
|
|
55
|
-
get log_user(): string;
|
|
56
|
-
set log_user(user: string);
|
|
57
|
-
get severity(): string;
|
|
58
|
-
set severity(severity: string);
|
|
59
|
-
get timestamp(): Date;
|
|
60
|
-
set timestamp(timestamp: Date);
|
|
61
|
-
get type(): string;
|
|
62
|
-
set type(type: string);
|
|
63
|
-
get user(): string;
|
|
64
|
-
set user(user: string);
|
|
65
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AbstractModel}from"./abstract-model";export class SmartDbLogModel extends AbstractModel{constructor(t){super(),t&&this.assign(t)}static getClassName(){return"SmartDbLogModel"}static getTableName(){return"smart_db_log"}static getPrimaryKey(){return"log_id"}static from(t){let e=null;return t&&(e=new SmartDbLogModel,t instanceof SmartDbLogModel?Object.assign(e,t):e.assign(t)),e}clone(){return SmartDbLogModel.from(this)}getClassName(){return"SmartDbLogModel"}getTableName(){return"smart_db_log"}getPrimaryKey(){return"log_id"}getAttributeMap(){return SmartDbLogModel.attributeMap}get data(){return this._data}set data(t){this._data=t}get id(){return this._id}set id(t){this._id=t}get info(){return this._info}set info(t){this._info=t}get location(){return this._location}set location(t){this._location=t}get log_data(){return this._data}set log_data(t){this._data=t}get log_id(){return this._id}set log_id(t){this._id=t}get log_info(){return this._info}set log_info(t){this._info=t}get log_location(){return this._location}set log_location(t){this._location=t}get log_severity(){return this._severity}set log_severity(t){this._severity=t}get log_timestamp(){return this._timestamp}set log_timestamp(t){this._timestamp=t}get log_type(){return this._type}set log_type(t){this._type=t}get log_user(){return this._user}set log_user(t){this._user=t}get severity(){return this._severity}set severity(t){this._severity=t}get timestamp(){return this._timestamp}set timestamp(t){this._timestamp=t}get type(){return this._type}set type(t){this._type=t}get user(){return this._user}set user(t){this._user=t}}SmartDbLogModel.attributeMap={id:{alias:"log_id",typeScriptStyle:!0,type:"number",attribute:"_id"},log_id:{physical:!0,type:"number",attribute:"_id"},severity:{alias:"log_severity",typeScriptStyle:!0,type:"string",attribute:"_severity"},log_severity:{physical:!0,type:"string",attribute:"_severity"},type:{alias:"log_type",typeScriptStyle:!0,type:"string",attribute:"_type"},log_type:{physical:!0,type:"string",attribute:"_type"},location:{alias:"log_location",typeScriptStyle:!0,type:"string",attribute:"_location"},log_location:{physical:!0,type:"string",attribute:"_location"},info:{alias:"log_info",typeScriptStyle:!0,type:"string",attribute:"_info"},log_info:{physical:!0,type:"string",attribute:"_info"},data:{alias:"log_data",typeScriptStyle:!0,type:"string",attribute:"_data"},log_data:{physical:!0,type:"string",attribute:"_data"},user:{alias:"log_user",typeScriptStyle:!0,type:"string",attribute:"_user"},log_user:{physical:!0,type:"string",attribute:"_user"},timestamp:{alias:"log_timestamp",typeScriptStyle:!0,type:"Date",attribute:"_timestamp"},log_timestamp:{physical:!0,type:"Date",attribute:"_timestamp"}};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { GenericModelData, ModelAttributeMap } from "../smart-db-interfaces";
|
|
2
|
-
import { AbstractModel } from "./abstract-model";
|
|
3
|
-
export interface SmartDbVersionModelData extends GenericModelData {
|
|
4
|
-
id?: number;
|
|
5
|
-
module?: string;
|
|
6
|
-
sequence?: number;
|
|
7
|
-
version?: string;
|
|
8
|
-
subVersion?: string;
|
|
9
|
-
revision?: string;
|
|
10
|
-
releaseType?: string;
|
|
11
|
-
installDate?: Date;
|
|
12
|
-
}
|
|
13
|
-
export declare class SmartDbVersionModel extends AbstractModel<SmartDbVersionModel, SmartDbVersionModelData> {
|
|
14
|
-
private _id?;
|
|
15
|
-
private _module?;
|
|
16
|
-
private _sequence?;
|
|
17
|
-
private _version?;
|
|
18
|
-
private _subVersion?;
|
|
19
|
-
private _revision?;
|
|
20
|
-
private _releaseType?;
|
|
21
|
-
private _installDate?;
|
|
22
|
-
static readonly attributeMap: ModelAttributeMap;
|
|
23
|
-
constructor(data?: SmartDbVersionModel | SmartDbVersionModelData);
|
|
24
|
-
static getClassName(): string;
|
|
25
|
-
static getTableName(): string;
|
|
26
|
-
static getPrimaryKey(): string;
|
|
27
|
-
static from(other: SmartDbVersionModel | SmartDbVersionModelData): SmartDbVersionModel;
|
|
28
|
-
clone(): SmartDbVersionModel;
|
|
29
|
-
getClassName(): string;
|
|
30
|
-
getTableName(): string;
|
|
31
|
-
getPrimaryKey(): string;
|
|
32
|
-
getAttributeMap(): ModelAttributeMap;
|
|
33
|
-
get id(): number;
|
|
34
|
-
set id(id: number);
|
|
35
|
-
get installDate(): Date;
|
|
36
|
-
set installDate(installDate: Date);
|
|
37
|
-
get module(): string;
|
|
38
|
-
set module(module: string);
|
|
39
|
-
get releaseType(): string;
|
|
40
|
-
set releaseType(releaseType: string);
|
|
41
|
-
get revision(): string;
|
|
42
|
-
set revision(revision: string);
|
|
43
|
-
get sequence(): number;
|
|
44
|
-
set sequence(sequence: number);
|
|
45
|
-
get subVersion(): string;
|
|
46
|
-
set subVersion(subVersion: string);
|
|
47
|
-
get ver_id(): number;
|
|
48
|
-
set ver_id(id: number);
|
|
49
|
-
get ver_install_date(): Date;
|
|
50
|
-
set ver_install_date(installDate: Date);
|
|
51
|
-
get ver_module(): string;
|
|
52
|
-
set ver_module(module: string);
|
|
53
|
-
get ver_release_type(): string;
|
|
54
|
-
set ver_release_type(releaseType: string);
|
|
55
|
-
get ver_revision(): string;
|
|
56
|
-
set ver_revision(revision: string);
|
|
57
|
-
get ver_sequence(): number;
|
|
58
|
-
set ver_sequence(sequence: number);
|
|
59
|
-
get ver_sub_version(): string;
|
|
60
|
-
set ver_sub_version(subVersion: string);
|
|
61
|
-
get ver_version(): string;
|
|
62
|
-
set ver_version(version: string);
|
|
63
|
-
get version(): string;
|
|
64
|
-
set version(version: string);
|
|
65
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AbstractModel}from"./abstract-model";export class SmartDbVersionModel extends AbstractModel{constructor(e){super(),e&&this.assign(e)}static getClassName(){return"SmartDbVersionModel"}static getTableName(){return"smart_db_version"}static getPrimaryKey(){return"ver_id"}static from(e){let t=null;return e&&(t=new SmartDbVersionModel,e instanceof SmartDbVersionModel?Object.assign(t,e):t.assign(e)),t}clone(){return SmartDbVersionModel.from(this)}getClassName(){return"SmartDbVersionModel"}getTableName(){return"smart_db_version"}getPrimaryKey(){return"ver_id"}getAttributeMap(){return SmartDbVersionModel.attributeMap}get id(){return this._id}set id(e){this._id=e}get installDate(){return this._installDate}set installDate(e){this._installDate=e}get module(){return this._module}set module(e){this._module=e}get releaseType(){return this._releaseType}set releaseType(e){this._releaseType=e}get revision(){return this._revision}set revision(e){this._revision=e}get sequence(){return this._sequence}set sequence(e){this._sequence=e}get subVersion(){return this._subVersion}set subVersion(e){this._subVersion=e}get ver_id(){return this._id}set ver_id(e){this._id=e}get ver_install_date(){return this._installDate}set ver_install_date(e){this._installDate=e}get ver_module(){return this._module}set ver_module(e){this._module=e}get ver_release_type(){return this._releaseType}set ver_release_type(e){this._releaseType=e}get ver_revision(){return this._revision}set ver_revision(e){this._revision=e}get ver_sequence(){return this._sequence}set ver_sequence(e){this._sequence=e}get ver_sub_version(){return this._subVersion}set ver_sub_version(e){this._subVersion=e}get ver_version(){return this._version}set ver_version(e){this._version=e}get version(){return this._version}set version(e){this._version=e}}SmartDbVersionModel.attributeMap={id:{alias:"ver_id",typeScriptStyle:!0,type:"number",attribute:"_id"},ver_id:{physical:!0,type:"number",attribute:"_id"},module:{alias:"ver_module",typeScriptStyle:!0,type:"string",attribute:"_module"},ver_module:{physical:!0,type:"string",attribute:"_module"},sequence:{alias:"ver_sequence",typeScriptStyle:!0,type:"number",attribute:"_sequence"},ver_sequence:{physical:!0,type:"number",attribute:"_sequence"},version:{alias:"ver_version",typeScriptStyle:!0,type:"string",attribute:"_version"},ver_version:{physical:!0,type:"string",attribute:"_version"},subVersion:{alias:"ver_sub_version",typeScriptStyle:!0,type:"string",attribute:"_subVersion"},ver_sub_version:{physical:!0,type:"string",attribute:"_subVersion"},revision:{alias:"ver_revision",typeScriptStyle:!0,type:"string",attribute:"_revision"},ver_revision:{physical:!0,type:"string",attribute:"_revision"},releaseType:{alias:"ver_release_type",typeScriptStyle:!0,type:"string",attribute:"_releaseType"},ver_release_type:{physical:!0,type:"string",attribute:"_releaseType"},installDate:{alias:"ver_install_date",typeScriptStyle:!0,type:"Date",attribute:"_installDate"},ver_install_date:{physical:!0,type:"Date",attribute:"_installDate"}};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { GenericModelData, ModelAttributeMap, SqlValueType } from "../smart-db-interfaces";
|
|
2
|
-
import { AbstractModel } from "./abstract-model";
|
|
3
|
-
export interface SmartDbVersionViewModelData extends GenericModelData {
|
|
4
|
-
id?: number;
|
|
5
|
-
module?: string;
|
|
6
|
-
sequence?: number;
|
|
7
|
-
version?: string;
|
|
8
|
-
subVersion?: string;
|
|
9
|
-
revision?: string;
|
|
10
|
-
releaseType?: string;
|
|
11
|
-
installDate?: Date;
|
|
12
|
-
versionString?: SqlValueType;
|
|
13
|
-
}
|
|
14
|
-
export declare class SmartDbVersionViewModel extends AbstractModel<SmartDbVersionViewModel, SmartDbVersionViewModelData> {
|
|
15
|
-
private _id?;
|
|
16
|
-
private _module?;
|
|
17
|
-
private _sequence?;
|
|
18
|
-
private _version?;
|
|
19
|
-
private _subVersion?;
|
|
20
|
-
private _revision?;
|
|
21
|
-
private _releaseType?;
|
|
22
|
-
private _installDate?;
|
|
23
|
-
private _versionString?;
|
|
24
|
-
static readonly attributeMap: ModelAttributeMap;
|
|
25
|
-
constructor(data?: SmartDbVersionViewModel | SmartDbVersionViewModelData);
|
|
26
|
-
static getClassName(): string;
|
|
27
|
-
static getTableName(): string;
|
|
28
|
-
static getPrimaryKey(): string;
|
|
29
|
-
static from(other: SmartDbVersionViewModel | SmartDbVersionViewModelData): SmartDbVersionViewModel;
|
|
30
|
-
clone(): SmartDbVersionViewModel;
|
|
31
|
-
getClassName(): string;
|
|
32
|
-
getTableName(): string;
|
|
33
|
-
getPrimaryKey(): string;
|
|
34
|
-
getAttributeMap(): ModelAttributeMap;
|
|
35
|
-
get id(): number;
|
|
36
|
-
set id(id: number);
|
|
37
|
-
get installDate(): Date;
|
|
38
|
-
set installDate(installDate: Date);
|
|
39
|
-
get module(): string;
|
|
40
|
-
set module(module: string);
|
|
41
|
-
get releaseType(): string;
|
|
42
|
-
set releaseType(releaseType: string);
|
|
43
|
-
get revision(): string;
|
|
44
|
-
set revision(revision: string);
|
|
45
|
-
get sequence(): number;
|
|
46
|
-
set sequence(sequence: number);
|
|
47
|
-
get subVersion(): string;
|
|
48
|
-
set subVersion(subVersion: string);
|
|
49
|
-
get ver_id(): number;
|
|
50
|
-
set ver_id(id: number);
|
|
51
|
-
get ver_install_date(): Date;
|
|
52
|
-
set ver_install_date(installDate: Date);
|
|
53
|
-
get ver_module(): string;
|
|
54
|
-
set ver_module(module: string);
|
|
55
|
-
get ver_release_type(): string;
|
|
56
|
-
set ver_release_type(releaseType: string);
|
|
57
|
-
get ver_revision(): string;
|
|
58
|
-
set ver_revision(revision: string);
|
|
59
|
-
get ver_sequence(): number;
|
|
60
|
-
set ver_sequence(sequence: number);
|
|
61
|
-
get ver_sub_version(): string;
|
|
62
|
-
set ver_sub_version(subVersion: string);
|
|
63
|
-
get ver_version(): string;
|
|
64
|
-
set ver_version(version: string);
|
|
65
|
-
get ver_version_string(): SqlValueType;
|
|
66
|
-
set ver_version_string(versionString: SqlValueType);
|
|
67
|
-
get version(): string;
|
|
68
|
-
set version(version: string);
|
|
69
|
-
get versionString(): SqlValueType;
|
|
70
|
-
set versionString(versionString: SqlValueType);
|
|
71
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AbstractModel}from"./abstract-model";export class SmartDbVersionViewModel extends AbstractModel{constructor(e){super(),e&&this.assign(e)}static getClassName(){return"SmartDbVersionViewModel"}static getTableName(){return"smart_db_version_view"}static getPrimaryKey(){return""}static from(e){let t=null;return e&&(t=new SmartDbVersionViewModel,e instanceof SmartDbVersionViewModel?Object.assign(t,e):t.assign(e)),t}clone(){return SmartDbVersionViewModel.from(this)}getClassName(){return"SmartDbVersionViewModel"}getTableName(){return"smart_db_version_view"}getPrimaryKey(){return""}getAttributeMap(){return SmartDbVersionViewModel.attributeMap}get id(){return this._id}set id(e){this._id=e}get installDate(){return this._installDate}set installDate(e){this._installDate=e}get module(){return this._module}set module(e){this._module=e}get releaseType(){return this._releaseType}set releaseType(e){this._releaseType=e}get revision(){return this._revision}set revision(e){this._revision=e}get sequence(){return this._sequence}set sequence(e){this._sequence=e}get subVersion(){return this._subVersion}set subVersion(e){this._subVersion=e}get ver_id(){return this._id}set ver_id(e){this._id=e}get ver_install_date(){return this._installDate}set ver_install_date(e){this._installDate=e}get ver_module(){return this._module}set ver_module(e){this._module=e}get ver_release_type(){return this._releaseType}set ver_release_type(e){this._releaseType=e}get ver_revision(){return this._revision}set ver_revision(e){this._revision=e}get ver_sequence(){return this._sequence}set ver_sequence(e){this._sequence=e}get ver_sub_version(){return this._subVersion}set ver_sub_version(e){this._subVersion=e}get ver_version(){return this._version}set ver_version(e){this._version=e}get ver_version_string(){return this._versionString}set ver_version_string(e){this._versionString=e}get version(){return this._version}set version(e){this._version=e}get versionString(){return this._versionString}set versionString(e){this._versionString=e}}SmartDbVersionViewModel.attributeMap={id:{alias:"ver_id",typeScriptStyle:!0,type:"number",attribute:"_id"},ver_id:{physical:!0,type:"number",attribute:"_id"},module:{alias:"ver_module",typeScriptStyle:!0,type:"string",attribute:"_module"},ver_module:{physical:!0,type:"string",attribute:"_module"},sequence:{alias:"ver_sequence",typeScriptStyle:!0,type:"number",attribute:"_sequence"},ver_sequence:{physical:!0,type:"number",attribute:"_sequence"},version:{alias:"ver_version",typeScriptStyle:!0,type:"string",attribute:"_version"},ver_version:{physical:!0,type:"string",attribute:"_version"},subVersion:{alias:"ver_sub_version",typeScriptStyle:!0,type:"string",attribute:"_subVersion"},ver_sub_version:{physical:!0,type:"string",attribute:"_subVersion"},revision:{alias:"ver_revision",typeScriptStyle:!0,type:"string",attribute:"_revision"},ver_revision:{physical:!0,type:"string",attribute:"_revision"},releaseType:{alias:"ver_release_type",typeScriptStyle:!0,type:"string",attribute:"_releaseType"},ver_release_type:{physical:!0,type:"string",attribute:"_releaseType"},installDate:{alias:"ver_install_date",typeScriptStyle:!0,type:"Date",attribute:"_installDate"},ver_install_date:{physical:!0,type:"Date",attribute:"_installDate"},versionString:{alias:"ver_version_string",typeScriptStyle:!0,type:"SqlValueType",attribute:"_versionString"},ver_version_string:{physical:!0,type:"SqlValueType",attribute:"_versionString"}};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ModelAttributeMap } from "../smart-db-interfaces";
|
|
2
|
-
import { AbstractModel } from "./abstract-model";
|
|
3
|
-
export interface SqliteMasterModelData extends Record<string, any> {
|
|
4
|
-
name?: string;
|
|
5
|
-
type?: string;
|
|
6
|
-
rootpage?: number;
|
|
7
|
-
sql?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class SqliteMasterModel extends AbstractModel<SqliteMasterModel, SqliteMasterModelData> {
|
|
10
|
-
private _type?;
|
|
11
|
-
private _name;
|
|
12
|
-
private _tbl_name?;
|
|
13
|
-
private _rootpage?;
|
|
14
|
-
private _sql?;
|
|
15
|
-
static readonly attributeMap: ModelAttributeMap;
|
|
16
|
-
static getClassName(): string;
|
|
17
|
-
static getTableName(): string;
|
|
18
|
-
static from(other: SqliteMasterModel): SqliteMasterModel;
|
|
19
|
-
clone(): SqliteMasterModel;
|
|
20
|
-
getClassName(): string;
|
|
21
|
-
getTableName(): string;
|
|
22
|
-
getAttributeMap(): ModelAttributeMap;
|
|
23
|
-
getPrimaryKey(): string;
|
|
24
|
-
get name(): string;
|
|
25
|
-
set name(name: string);
|
|
26
|
-
get rootpage(): number;
|
|
27
|
-
set rootpage(rootpage: number);
|
|
28
|
-
get sql(): string;
|
|
29
|
-
set sql(sql: string);
|
|
30
|
-
get tblName(): string;
|
|
31
|
-
set tblName(tblNname: string);
|
|
32
|
-
get tbl_name(): string;
|
|
33
|
-
set tbl_name(tblNname: string);
|
|
34
|
-
get type(): string;
|
|
35
|
-
set type(type: string);
|
|
36
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AbstractModel}from"./abstract-model";export class SqliteMasterModel extends AbstractModel{static getClassName(){return"SqliteMasterModel"}static getTableName(){return"sqlite_master"}static from(t){let e=null;return t&&(e=new SqliteMasterModel,t instanceof SqliteMasterModel?Object.assign(e,t):e.assign(t)),e}clone(){return SqliteMasterModel.from(this)}getClassName(){return"SqliteMasterModel"}getTableName(){return"sqlite_master"}getAttributeMap(){return SqliteMasterModel.attributeMap}getPrimaryKey(){return"name"}get name(){return this._name}set name(t){this._name=t}get rootpage(){return this._rootpage}set rootpage(t){this._rootpage=t}get sql(){return this._sql}set sql(t){this._sql=t}get tblName(){return this._tbl_name}set tblName(t){this._tbl_name=t}get tbl_name(){return this._tbl_name}set tbl_name(t){this._tbl_name=t}get type(){return this._type}set type(t){this._type=t}}SqliteMasterModel.attributeMap={type:{type:"string",attribute:"_type"},name:{type:"string",attribute:"_name"},tbl_name:{type:"string",attribute:"_tbl_name"},tblName:{alias:"tbl_name",type:"string",attribute:"_tbl_name"},rootpage:{type:"number",attribute:"_rootpage"},sql:{type:"string",attribute:"_sql"}};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { GenericModelData, ModelAttributeMap, SqlValueType } from "../smart-db-interfaces";
|
|
2
|
-
import { AbstractModel } from "./abstract-model";
|
|
3
|
-
export interface SqliteSequenceModelData extends Record<string, any> {
|
|
4
|
-
name?: SqlValueType;
|
|
5
|
-
seq?: SqlValueType;
|
|
6
|
-
}
|
|
7
|
-
export declare class SqliteSequenceModel extends AbstractModel<SqliteSequenceModel, SqliteSequenceModelData> {
|
|
8
|
-
private _name?;
|
|
9
|
-
private _seq?;
|
|
10
|
-
static readonly attributeMap: ModelAttributeMap;
|
|
11
|
-
static getClassName(): string;
|
|
12
|
-
static getTableName(): string;
|
|
13
|
-
static getPrimaryKey(): string;
|
|
14
|
-
static from(other: SqliteSequenceModel | GenericModelData): SqliteSequenceModel;
|
|
15
|
-
clone(): SqliteSequenceModel;
|
|
16
|
-
getClassName(): string;
|
|
17
|
-
getTableName(): string;
|
|
18
|
-
getPrimaryKey(): string;
|
|
19
|
-
getAttributeMap(): ModelAttributeMap;
|
|
20
|
-
get name(): SqlValueType;
|
|
21
|
-
set name(name: SqlValueType);
|
|
22
|
-
get seq(): SqlValueType;
|
|
23
|
-
set seq(seq: SqlValueType);
|
|
24
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AbstractModel}from"./abstract-model";export class SqliteSequenceModel extends AbstractModel{static getClassName(){return"SqliteSequenceModel"}static getTableName(){return"sqlite_sequence"}static getPrimaryKey(){return""}static from(e){let t=null;return e&&(t=new SqliteSequenceModel,e instanceof SqliteSequenceModel?Object.assign(t,e):t.assign(e)),t}clone(){return SqliteSequenceModel.from(this)}getClassName(){return"SqliteSequenceModel"}getTableName(){return"sqlite_sequence"}getPrimaryKey(){return""}getAttributeMap(){return SqliteSequenceModel.attributeMap}get name(){return this._name}set name(e){this._name=e}get seq(){return this._seq}set seq(e){this._seq=e}}SqliteSequenceModel.attributeMap={name:{physical:!0,typeScriptStyle:!0,type:"SqlValueType",attribute:"_name"},seq:{physical:!0,typeScriptStyle:!0,type:"SqlValueType",attribute:"_seq"}};
|
package/smart-db-api.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from"./smart-db";export*from"./models/abstract-model";export*from"./models/smart-db-core-table-model";export*from"./models/smart-db-dictionary";export*from"./models/smart-db-log-model";export*from"./models/smart-db-version-model";export*from"./models/smart-db-version-view-model";export*from"./models/sqlite-master-model";export*from"./models/sqlite-sequence-model";export*from"./smart-db-log";export*from"./smart-db-globals";export*from"./smart-db-interfaces";
|
package/smart-db-globals.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SqlFieldDescriptor, SqlOperation, SqlOperationType, SqlValueType } from "./smart-db-interfaces";
|
|
2
|
-
export declare const OP: (op: SqlOperationType, value?: SqlValueType | SqlValueType[], key?: string, literalOp?: SqlOperationType) => SqlOperation;
|
|
3
|
-
export declare const VALUE: (value: SqlValueType, alias?: string, literal?: boolean) => SqlFieldDescriptor;
|
|
4
|
-
export declare const FIELD: (value: string, alias?: string) => SqlFieldDescriptor;
|
|
5
|
-
export declare const COUNT: (value?: string, alias?: string) => SqlFieldDescriptor;
|
|
6
|
-
export declare const COALESCE: (values: (SqlFieldDescriptor | SqlValueType)[], alias?: string) => SqlFieldDescriptor;
|
|
7
|
-
export declare const NVL: (values: (SqlFieldDescriptor | SqlValueType)[], alias?: string) => SqlFieldDescriptor;
|
|
8
|
-
export declare const LITERAL: (key: string, value: SqlValueType, op?: SqlOperationType) => SqlOperation;
|
|
9
|
-
export declare const GT: (value: SqlValueType) => SqlOperation;
|
|
10
|
-
export declare const GE: (value: SqlValueType) => SqlOperation;
|
|
11
|
-
export declare const LT: (value: SqlValueType) => SqlOperation;
|
|
12
|
-
export declare const LE: (value: SqlValueType) => SqlOperation;
|
|
13
|
-
export declare const EQ: (value: SqlValueType) => SqlOperation;
|
|
14
|
-
export declare const NE: (value: any) => SqlOperation;
|
|
15
|
-
export declare const IN: (value: SqlValueType[]) => SqlOperation;
|
|
16
|
-
export declare const IS_NULL: () => SqlOperation;
|
|
17
|
-
export declare const IS_NOT_NULL: () => SqlOperation;
|
|
18
|
-
export declare const SmartDbDateRegexp: RegExp;
|
|
19
|
-
export declare const SmartDbTimestampRegexp: RegExp;
|
|
20
|
-
export declare function toSmartDbDate(d: Date | number): string;
|
|
21
|
-
export declare function toSmartDbTimestamp(d: Date | number): string;
|
|
22
|
-
export declare function smartDbToDate(d: Date | number | string): Date | null;
|
package/smart-db-globals.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import _ from"lodash";import{SqlFieldOperationType,SqlOperationType}from"./smart-db-interfaces";export const OP=(e,t,o,r)=>o?{operation:e,value:t,key:o,literalOperation:r}:{operation:e,value:t};export const VALUE=(e,t,o)=>({operation:SqlFieldOperationType.VALUE,value:e,alias:t,literal:o});export const FIELD=(e,t)=>({operation:SqlFieldOperationType.FIELD,value:e,alias:t});export const COUNT=(e,t)=>({operation:SqlFieldOperationType.COUNT,value:e,alias:t});export const COALESCE=(e,t)=>({operation:SqlFieldOperationType.COALESCE,value:e,alias:t});export const NVL=(e,t)=>COALESCE(e,t);export const LITERAL=(e,t,o)=>OP(SqlOperationType.LITERAL,t,e,o||SqlOperationType.EQ);export const GT=e=>OP(SqlOperationType.GT,e);export const GE=e=>OP(SqlOperationType.GE,e);export const LT=e=>OP(SqlOperationType.LT,e);export const LE=e=>OP(SqlOperationType.LE,e);export const EQ=e=>OP(SqlOperationType.EQ,e);export const NE=e=>OP(SqlOperationType.NE,e);export const IN=e=>OP(SqlOperationType.IN,e);export const IS_NULL=()=>OP(SqlOperationType.IS_NULL);export const IS_NOT_NULL=()=>OP(SqlOperationType.IS_NOT_NULL);export const SmartDbDateRegexp=/^(\d{4}-[01]\d-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d)(Z| GMT| GMT[-+]\d{1,2})?$/;export const SmartDbTimestampRegexp=/^(\d{4}-[01]\d-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d\.\d{3})(Z| GMT| GMT[-+]\d{1,2})?$/;export function toSmartDbDate(e){let t;return e&&(_.isNumber(e)&&(e=new Date(e)),t=e.toISOString().substr(0,19).replace("T"," ")),t}export function toSmartDbTimestamp(e){let t;return e&&(_.isNumber(e)&&(e=new Date(e)),t=e.toISOString().substr(0,23).replace("T"," ")),t}export function smartDbToDate(e){let t=null;return _.isDate(e)?t=e:(_.isNumber(e)||_.isString(e)&&(e.match(SmartDbDateRegexp)||e.match(SmartDbTimestampRegexp)))&&(t=new Date(e)),t}
|
package/smart-db-interfaces.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export var FieldNamingStyle;!function(e){e[e.Database=0]="Database",e[e.TypeScript=1]="TypeScript",e[e.All=2]="All"}(FieldNamingStyle||(FieldNamingStyle={}));export var SqlOperationType;!function(e){e.GT=">",e.GE=">=",e.LT="<",e.LE="<=",e.EQ="=",e.NE="!=",e.IN="IN",e.LIKE="LIKE",e.NOT_LIKE="NOT LIKE",e.IS_NULL="IS NULL",e.IS_NOT_NULL="IS NOT NULL",e.LITERAL="LITERAL",e.VALUE="VALUE"}(SqlOperationType||(SqlOperationType={}));export var SqlFieldOperationType;!function(e){e.VALUE="VALUE",e.FIELD="FIELD",e.COUNT="COUNT",e.COALESCE="COALESCE"}(SqlFieldOperationType||(SqlFieldOperationType={}));
|
package/smart-db-log.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { SmartDbApi } from "./smart-db-interfaces";
|
|
2
|
-
export declare const SmartDbLogLocation: {
|
|
3
|
-
Frontend: string;
|
|
4
|
-
Backend: string;
|
|
5
|
-
Database: string;
|
|
6
|
-
UpgradeManager: string;
|
|
7
|
-
Other: string;
|
|
8
|
-
};
|
|
9
|
-
export declare type SmartDbLogLocationType = typeof SmartDbLogLocation;
|
|
10
|
-
export declare type SmartDbLogLocationKey = keyof SmartDbLogLocationType;
|
|
11
|
-
export declare type SmartDbLogLocationValue = SmartDbLogLocationType[keyof SmartDbLogLocationType];
|
|
12
|
-
export declare const SeverityCode: {
|
|
13
|
-
readonly Fatal: "F";
|
|
14
|
-
readonly Error: "E";
|
|
15
|
-
readonly Warning: "W";
|
|
16
|
-
readonly Info: "I";
|
|
17
|
-
readonly Debug: "D";
|
|
18
|
-
readonly Local: "L";
|
|
19
|
-
};
|
|
20
|
-
export declare type SeverityCodeType = typeof SeverityCode;
|
|
21
|
-
export declare type SeverityCodeKey = keyof SeverityCodeType;
|
|
22
|
-
export declare type SeverityCodeValue = SeverityCodeType[keyof SeverityCodeType];
|
|
23
|
-
export declare const SeverityLevel: {
|
|
24
|
-
readonly None: 0;
|
|
25
|
-
readonly Fatal: 1;
|
|
26
|
-
readonly Error: 2;
|
|
27
|
-
readonly Warning: 3;
|
|
28
|
-
readonly Info: 4;
|
|
29
|
-
readonly Debug: 5;
|
|
30
|
-
readonly All: 9;
|
|
31
|
-
};
|
|
32
|
-
export declare type SeverityLevelType = typeof SeverityLevel;
|
|
33
|
-
export declare type SeverityLevelKey = keyof SeverityLevelType;
|
|
34
|
-
export declare type SeverityLevelValue = SeverityLevelType[keyof SeverityLevelType];
|
|
35
|
-
export declare class SmartDbLog {
|
|
36
|
-
private db;
|
|
37
|
-
private dbLogLevel;
|
|
38
|
-
private consoleLogLevel;
|
|
39
|
-
private userId;
|
|
40
|
-
private dbLogging;
|
|
41
|
-
private isLogging;
|
|
42
|
-
constructor(db?: SmartDbApi);
|
|
43
|
-
getConsoleLogLevel(): SeverityLevelValue;
|
|
44
|
-
setConsoleLogLevel(consoleLogLevel: SeverityLevelValue): void;
|
|
45
|
-
getDbLogLevel(): SeverityLevelValue;
|
|
46
|
-
setDbLogLevel(dbLogLevel: SeverityLevelValue): void;
|
|
47
|
-
setDb(db: SmartDbApi): void;
|
|
48
|
-
setUserId(userId: string | number): void;
|
|
49
|
-
setDbLogging(dbLogging: boolean): void;
|
|
50
|
-
getDbLogging(): boolean;
|
|
51
|
-
logFatal(type: SmartDbLogLocationValue, location: string, message: string | Error, data?: any): void;
|
|
52
|
-
logError(type: SmartDbLogLocationValue, location: string, message: string | Error, data?: any): void;
|
|
53
|
-
logWarning(type: SmartDbLogLocationValue, location: string, message: string | Error, data?: any): void;
|
|
54
|
-
logInfo(type: SmartDbLogLocationValue, location: string, message: string | Error, data?: any): void;
|
|
55
|
-
logDebug(type: SmartDbLogLocationValue, location: string, message: string | Error, data?: any): void;
|
|
56
|
-
writeLog(type: SmartDbLogLocationValue, location: string, severity: SeverityCodeValue, message: string | Error, data: unknown, timestamp?: Date | string | number): void;
|
|
57
|
-
}
|
|
58
|
-
export declare const smartDbLog: SmartDbLog;
|
package/smart-db-log.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import _ from"lodash";import{SmartDbLogModel}from"./models/smart-db-log-model";import{SmartDbDateRegexp,SmartDbTimestampRegexp,toSmartDbTimestamp}from"./smart-db-globals";export const SmartDbLogLocation={Frontend:"frontend",Backend:"backend",Database:"database",UpgradeManager:"upgrade-manager",Other:"other"};export const SeverityCode={Fatal:"F",Error:"E",Warning:"W",Info:"I",Debug:"D",Local:"L"};export const SeverityLevel={None:0,Fatal:1,Error:2,Warning:3,Info:4,Debug:5,All:9};export class SmartDbLog{constructor(e){this.userId=null,this.dbLogging=!0,this.isLogging=!1,this.db=e,this.dbLogLevel=SeverityLevel.Info,this.consoleLogLevel=SeverityLevel.Info}getConsoleLogLevel(){return this.consoleLogLevel}setConsoleLogLevel(e){this.consoleLogLevel=e}getDbLogLevel(){return this.dbLogLevel}setDbLogLevel(e){this.dbLogLevel=e}setDb(e){this.db=e,this.db?this.db.exists(SmartDbLogModel).then(e=>{this.dbLogging=e}).catch(e=>{throw e}):this.dbLogging=!1}setUserId(e){this.userId=e}setDbLogging(e){this.dbLogging=e}getDbLogging(){return this.dbLogging}logFatal(e,t,o,r){this.writeLog(e,t,SeverityCode.Fatal,o,r)}logError(e,t,o,r){this.writeLog(e,t,SeverityCode.Error,o,r)}logWarning(e,t,o,r){this.writeLog(e,t,SeverityCode.Warning,o,r)}logInfo(e,t,o,r){this.writeLog(e,t,SeverityCode.Info,o,r)}logDebug(e,t,o,r){this.writeLog(e,t,SeverityCode.Debug,o,r)}writeLog(e,t,o,r,i,s){try{if(this.isLogging)console.error("recursive logging error:",e,t,o,r,i);else{this.isLogging=!0;let a,g,n=SeverityLevel.None;switch(o){case SeverityCode.Fatal:a=console.error,n=SeverityLevel.Fatal;break;case SeverityCode.Error:a=console.error,n=SeverityLevel.Error;break;case SeverityCode.Warning:a=console.warn,n=SeverityLevel.Warning;break;case SeverityCode.Info:a=console.info,n=SeverityLevel.Info;break;case SeverityCode.Debug:a=console.debug,n=SeverityLevel.Debug}if(_.isString(s)){const e=s.match(SmartDbTimestampRegexp),t=e&&s.match(SmartDbDateRegexp);g=e?e[1]:t?t[1]+".000":toSmartDbTimestamp(new Date)}else g=_.isDate(s)?toSmartDbTimestamp(s):_.isNumber(s)?toSmartDbTimestamp(new Date(s)):toSmartDbTimestamp(new Date);if(_.isObjectLike(r))if(r instanceof Error)i||(i=r),r=r.message;else try{r=JSON.stringify(r)}catch(e){r=r.toString()}else"boolean"==typeof r&&(r=r?"<true>":"<false>");if(i){if(i instanceof Error)i=i.stack;else if(_.isObject(i))try{i=JSON.stringify(i)}catch(e){i=i.toString(),this.db&&this.dbLogLevel>=n&&console.error("unable to stringify log data",i)}else i.toString?i=i.toString():(i=null,this.db&&this.dbLogLevel>=n&&console.error("unable to store log data",i));i&&(r+=` (${i})`)}if(this.consoleLogLevel>=n){const s=e.substr(0,1).toUpperCase();if(e==SmartDbLogLocation.Database&&this.db&&a(`${o}-${s}-${g}: last statement:`,this.db.getLastBuildData()),a(`${o}-${s}-${g}: ${r}`),this.dbLogging)try{e==SmartDbLogLocation.Database&&(i||(i=JSON.stringify(this.db.getLastBuildData()))),this.db.insertSync(SmartDbLogModel,{severity:o,type:e,location:t,info:r||"<empty>",data:i,user:this.userId,timestamp:new Date(g)})}catch(e){console.error(`F-B-${g}: unable to write the log statement below to database`,e,e.code,e.name,e.message);try{a(`F-B-${g}: last statement:`,this.db.getLastBuildData())}catch{a(`F-B-${g}: last statement not available`)}}}}this.isLogging=!1}catch(e){this.isLogging=!1,console.error("fatal logging error",e)}}}export const smartDbLog=new SmartDbLog;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SmartDbSqlBuildDataResults, SqlValueType } from "./smart-db-interfaces";
|
|
2
|
-
export declare class SmartDbSqlBuildData {
|
|
3
|
-
sql: string;
|
|
4
|
-
values: SqlValueType[];
|
|
5
|
-
constructor(sql?: string, values?: SqlValueType[]);
|
|
6
|
-
append(data: SmartDbSqlBuildData): void;
|
|
7
|
-
toString(): string;
|
|
8
|
-
results(): SmartDbSqlBuildDataResults;
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import _ from"lodash";export class SmartDbSqlBuildData{constructor(s,t){this.sql=s||"",this.values=t||[]}append(s){this.sql=this.sql.trim()+" "+s.sql.trim(),this.values=_.concat(this.values,s.values)}toString(){return this.sql+" <= ("+this.values.join(", ")+")"}results(){return{sql:this.sql,values:this.values}}}
|