ztechno_core 0.0.28 → 0.0.31
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/lib/sql_service.d.ts +11 -4
- package/lib/sql_service.js +16 -5
- package/lib/translate_service.d.ts +1 -1
- package/lib/user_service.js +3 -0
- package/package.json +45 -45
package/lib/sql_service.d.ts
CHANGED
|
@@ -6,12 +6,19 @@ export declare class ZSqlService {
|
|
|
6
6
|
private defaultPoolconfig;
|
|
7
7
|
private listeners;
|
|
8
8
|
private databaseName;
|
|
9
|
-
constructor(options: mysql.PoolConfig);
|
|
10
9
|
get database(): string;
|
|
11
|
-
|
|
12
|
-
on(eventName: '
|
|
10
|
+
constructor(options: mysql.PoolConfig);
|
|
11
|
+
on(eventName: 'err', listener: ZOnErrorCallback): void;
|
|
12
|
+
on(eventName: 'log', listener: ZOnLogCallback): void;
|
|
13
13
|
private triggerEvent;
|
|
14
14
|
private getPoolConnection;
|
|
15
|
-
query
|
|
15
|
+
query<T = any>(
|
|
16
|
+
sql: string,
|
|
17
|
+
params?:
|
|
18
|
+
| any[]
|
|
19
|
+
| {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
},
|
|
22
|
+
): Promise<T[]>;
|
|
16
23
|
}
|
|
17
24
|
export {};
|
package/lib/sql_service.js
CHANGED
|
@@ -43,6 +43,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
43
43
|
exports.ZSqlService = void 0;
|
|
44
44
|
const mysql = __importStar(require('mysql'));
|
|
45
45
|
class ZSqlService {
|
|
46
|
+
get database() {
|
|
47
|
+
return this.databaseName;
|
|
48
|
+
}
|
|
46
49
|
constructor(options) {
|
|
47
50
|
this.defaultPoolconfig = {
|
|
48
51
|
connectionLimit: 10,
|
|
@@ -54,6 +57,17 @@ class ZSqlService {
|
|
|
54
57
|
this.databaseName = options.database;
|
|
55
58
|
this.pool = mysql.createPool(Object.assign({}, this.defaultPoolconfig, options));
|
|
56
59
|
this.pool.on('connection', (connection) => {
|
|
60
|
+
connection.config.queryFormat = function (query, values) {
|
|
61
|
+
if (!values) {
|
|
62
|
+
return query;
|
|
63
|
+
}
|
|
64
|
+
return query.replace(
|
|
65
|
+
/\:(\w+)/g,
|
|
66
|
+
function (txt, key) {
|
|
67
|
+
return values.hasOwnProperty(key) ? this.escape(values[key]) : txt;
|
|
68
|
+
}.bind(this),
|
|
69
|
+
);
|
|
70
|
+
};
|
|
57
71
|
connection.on('error', (err) => {
|
|
58
72
|
this.triggerEvent('err', err);
|
|
59
73
|
});
|
|
@@ -62,9 +76,6 @@ class ZSqlService {
|
|
|
62
76
|
});
|
|
63
77
|
});
|
|
64
78
|
}
|
|
65
|
-
get database() {
|
|
66
|
-
return this.databaseName;
|
|
67
|
-
}
|
|
68
79
|
on(eventName, listener) {
|
|
69
80
|
if (!this.listeners.hasOwnProperty(eventName))
|
|
70
81
|
throw new Error(`EventName not supported for ZSqlService.on(${eventName}, ...)`);
|
|
@@ -80,12 +91,12 @@ class ZSqlService {
|
|
|
80
91
|
this.pool.getConnection((err, con) => (err ? reject(err) : resolve(con)));
|
|
81
92
|
});
|
|
82
93
|
}
|
|
83
|
-
async query(sql,
|
|
94
|
+
async query(sql, params) {
|
|
84
95
|
try {
|
|
85
96
|
const con = await this.getPoolConnection();
|
|
86
97
|
try {
|
|
87
98
|
const output = await new Promise((resolve, reject) => {
|
|
88
|
-
con.query(sql,
|
|
99
|
+
con.query(sql, params, (err, result) => (err ? reject(err) : resolve(result)));
|
|
89
100
|
});
|
|
90
101
|
con.release();
|
|
91
102
|
return output;
|
|
@@ -37,7 +37,7 @@ export declare class ZTranslateService {
|
|
|
37
37
|
},
|
|
38
38
|
): Promise<string>;
|
|
39
39
|
private translateHtmlRec;
|
|
40
|
-
update(key: string, lang: string, data: TranslateData): Promise<any>;
|
|
40
|
+
update(key: string, lang: string, data: TranslateData): Promise<any[]>;
|
|
41
41
|
private checkLocalCache;
|
|
42
42
|
private insertLocalCache;
|
|
43
43
|
private clearLocalCache;
|
package/lib/user_service.js
CHANGED
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ztechno_core",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Core files for ztechno framework",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"types": "lib/index.d.ts",
|
|
7
|
-
"typings": "lib/index.d.ts",
|
|
8
|
-
"license": "MIT",
|
|
9
|
-
"author": "Ivan Auda (ZTechnologies International)",
|
|
10
|
-
"files": [
|
|
11
|
-
"lib/**/*"
|
|
12
|
-
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"test": "jest --config jestconfig.json",
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"format": "prettier --write \"lib/**/*.ts\" \"lib/**/*.js\"",
|
|
17
|
-
"lint": "tslint -p tsconfig.json",
|
|
18
|
-
"preversion": "npm run lint",
|
|
19
|
-
"version": "npm run format && git add -A src",
|
|
20
|
-
"postversion": "git push && git push --tags",
|
|
21
|
-
"update": "npm run build && npm version patch && npm publish"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"ztechno",
|
|
25
|
-
"core",
|
|
26
|
-
"utils",
|
|
27
|
-
"service"
|
|
28
|
-
],
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@types/jest": "^29.2.3",
|
|
31
|
-
"@types/mysql": "^2.15.21",
|
|
32
|
-
"jest": "^29.3.1",
|
|
33
|
-
"prettier": "^2.7.1",
|
|
34
|
-
"ts-jest": "^29.0.3",
|
|
35
|
-
"tslint": "^6.1.3",
|
|
36
|
-
"tslint-config-prettier": "^1.18.0",
|
|
37
|
-
"typescript": "^4.9.3"
|
|
38
|
-
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"dom-parser": "^0.1.6",
|
|
41
|
-
"mysql": "^2.18.1",
|
|
42
|
-
"nodemailer": "^6.8.0",
|
|
43
|
-
"translate": "^1.4.1"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ztechno_core",
|
|
3
|
+
"version": "0.0.31",
|
|
4
|
+
"description": "Core files for ztechno framework",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"typings": "lib/index.d.ts",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "Ivan Auda (ZTechnologies International)",
|
|
10
|
+
"files": [
|
|
11
|
+
"lib/**/*"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "jest --config jestconfig.json",
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"format": "prettier --write \"lib/**/*.ts\" \"lib/**/*.js\"",
|
|
17
|
+
"lint": "tslint -p tsconfig.json",
|
|
18
|
+
"preversion": "npm run lint",
|
|
19
|
+
"version": "npm run format && git add -A src",
|
|
20
|
+
"postversion": "git push && git push --tags",
|
|
21
|
+
"update": "npm run build && npm version patch && npm publish"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"ztechno",
|
|
25
|
+
"core",
|
|
26
|
+
"utils",
|
|
27
|
+
"service"
|
|
28
|
+
],
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/jest": "^29.2.3",
|
|
31
|
+
"@types/mysql": "^2.15.21",
|
|
32
|
+
"jest": "^29.3.1",
|
|
33
|
+
"prettier": "^2.7.1",
|
|
34
|
+
"ts-jest": "^29.0.3",
|
|
35
|
+
"tslint": "^6.1.3",
|
|
36
|
+
"tslint-config-prettier": "^1.18.0",
|
|
37
|
+
"typescript": "^4.9.3"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"dom-parser": "^0.1.6",
|
|
41
|
+
"mysql": "^2.18.1",
|
|
42
|
+
"nodemailer": "^6.8.0",
|
|
43
|
+
"translate": "^1.4.1"
|
|
44
|
+
}
|
|
45
|
+
}
|