ztechno_core 0.0.30 → 0.0.33
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/LICENSE +1 -1
- package/README.md +81 -81
- package/lib/sql_service.d.ts +15 -4
- package/lib/sql_service.js +16 -5
- package/lib/translate_service.d.ts +9 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
MIT
|
|
1
|
+
MIT
|
package/README.md
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
# ztech_jquery_ext
|
|
2
|
-
#### Extends JQuery library for more compact code base
|
|
3
|
-
|
|
4
|
-
[](https://www.npmjs.com/package/ztech_jquery_ext)
|
|
5
|
-
|
|
6
|
-
Requirements
|
|
7
|
-
-----
|
|
8
|
-
+ [jQuery](http://jquery.com/)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Installation
|
|
12
|
-
-----
|
|
13
|
-
|
|
14
|
-
### [NPM](https://www.npmjs.com/package/ztech_jquery_ext)
|
|
15
|
-
```bash
|
|
16
|
-
npm install ztech_jquery_ext
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### [Yarn](https://yarn.pm/ztech_jquery_ext)
|
|
20
|
-
```bash
|
|
21
|
-
yarn add ztech_jquery_ext
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### [CDN - jsDelivr](https://www.jsdelivr.com/package/npm/ztech_jquery_ext)
|
|
25
|
-
```html
|
|
26
|
-
<link href="https://cdn.jsdelivr.net/npm/ztech_jquery_ext/dist/css/ztech_jquery_ext.min.css" rel="stylesheet" type="text/css" />
|
|
27
|
-
<script src="https://cdn.jsdelivr.net/npm/ztech_jquery_ext/dist/js/ztech_jquery_ext.min.js" type="text/javascript"></script>
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### [CDN - UNPKG](https://unpkg.com/browse/ztech_jquery_ext/)
|
|
31
|
-
```html
|
|
32
|
-
<link href="https://unpkg.com/ztech_jquery_ext/dist/css/ztech_jquery_ext.min.css" rel="stylesheet" type="text/css" />
|
|
33
|
-
<script src="https://unpkg.com/ztech_jquery_ext/dist/js/ztech_jquery_ext.min.js" type="text/javascript"></script>
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
TypeScript Support
|
|
37
|
-
-----
|
|
38
|
-
In order to include types add the following in tsconfig.json
|
|
39
|
-
```json
|
|
40
|
-
{
|
|
41
|
-
"compilerOptions": {
|
|
42
|
-
"types": ["ztech_jquery_ext"]
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Alternatively Add the following reference at the top of the javascript/typescript file
|
|
48
|
-
```js
|
|
49
|
-
/// <reference types="ztech_jquery_ext" />
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Usage
|
|
53
|
-
-----
|
|
54
|
-
|
|
55
|
-
Include jQuery
|
|
56
|
-
```html
|
|
57
|
-
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Include Plugin JS
|
|
61
|
-
```html
|
|
62
|
-
<script src="https://cdn.jsdelivr.net/npm/ztech_jquery_ext/dist/js/ztech_jquery_ext.min.js" type="text/javascript"></script>
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Usage
|
|
66
|
-
```js
|
|
67
|
-
// [JQuery, JQuery, JQuery, ...]
|
|
68
|
-
var rows = $('.row').$arr();
|
|
69
|
-
|
|
70
|
-
// [number, number, number, ...]
|
|
71
|
-
var userids = $('.user').$map(function ($ele) {
|
|
72
|
-
return $ele.attr('id');
|
|
73
|
-
});
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
License
|
|
77
|
-
----
|
|
78
|
-
MIT
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Created with :heart: [create-jquery-plugin](https://www.npmjs.com/package/create-jquery-plugin)
|
|
1
|
+
# ztech_jquery_ext
|
|
2
|
+
#### Extends JQuery library for more compact code base
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/ztech_jquery_ext)
|
|
5
|
+
|
|
6
|
+
Requirements
|
|
7
|
+
-----
|
|
8
|
+
+ [jQuery](http://jquery.com/)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Installation
|
|
12
|
+
-----
|
|
13
|
+
|
|
14
|
+
### [NPM](https://www.npmjs.com/package/ztech_jquery_ext)
|
|
15
|
+
```bash
|
|
16
|
+
npm install ztech_jquery_ext
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### [Yarn](https://yarn.pm/ztech_jquery_ext)
|
|
20
|
+
```bash
|
|
21
|
+
yarn add ztech_jquery_ext
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### [CDN - jsDelivr](https://www.jsdelivr.com/package/npm/ztech_jquery_ext)
|
|
25
|
+
```html
|
|
26
|
+
<link href="https://cdn.jsdelivr.net/npm/ztech_jquery_ext/dist/css/ztech_jquery_ext.min.css" rel="stylesheet" type="text/css" />
|
|
27
|
+
<script src="https://cdn.jsdelivr.net/npm/ztech_jquery_ext/dist/js/ztech_jquery_ext.min.js" type="text/javascript"></script>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### [CDN - UNPKG](https://unpkg.com/browse/ztech_jquery_ext/)
|
|
31
|
+
```html
|
|
32
|
+
<link href="https://unpkg.com/ztech_jquery_ext/dist/css/ztech_jquery_ext.min.css" rel="stylesheet" type="text/css" />
|
|
33
|
+
<script src="https://unpkg.com/ztech_jquery_ext/dist/js/ztech_jquery_ext.min.js" type="text/javascript"></script>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
TypeScript Support
|
|
37
|
+
-----
|
|
38
|
+
In order to include types add the following in tsconfig.json
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"compilerOptions": {
|
|
42
|
+
"types": ["ztech_jquery_ext"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Alternatively Add the following reference at the top of the javascript/typescript file
|
|
48
|
+
```js
|
|
49
|
+
/// <reference types="ztech_jquery_ext" />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Usage
|
|
53
|
+
-----
|
|
54
|
+
|
|
55
|
+
Include jQuery
|
|
56
|
+
```html
|
|
57
|
+
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Include Plugin JS
|
|
61
|
+
```html
|
|
62
|
+
<script src="https://cdn.jsdelivr.net/npm/ztech_jquery_ext/dist/js/ztech_jquery_ext.min.js" type="text/javascript"></script>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Usage
|
|
66
|
+
```js
|
|
67
|
+
// [JQuery, JQuery, JQuery, ...]
|
|
68
|
+
var rows = $('.row').$arr();
|
|
69
|
+
|
|
70
|
+
// [number, number, number, ...]
|
|
71
|
+
var userids = $('.user').$map(function ($ele) {
|
|
72
|
+
return $ele.attr('id');
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
License
|
|
77
|
+
----
|
|
78
|
+
MIT
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
Created with :heart: [create-jquery-plugin](https://www.npmjs.com/package/create-jquery-plugin)
|
package/lib/sql_service.d.ts
CHANGED
|
@@ -6,12 +6,23 @@ 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<
|
|
23
|
+
T[] & {
|
|
24
|
+
insertId?: number;
|
|
25
|
+
}
|
|
26
|
+
>;
|
|
16
27
|
}
|
|
17
28
|
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,15 @@ export declare class ZTranslateService {
|
|
|
37
37
|
},
|
|
38
38
|
): Promise<string>;
|
|
39
39
|
private translateHtmlRec;
|
|
40
|
-
update(
|
|
40
|
+
update(
|
|
41
|
+
key: string,
|
|
42
|
+
lang: string,
|
|
43
|
+
data: TranslateData,
|
|
44
|
+
): Promise<
|
|
45
|
+
any[] & {
|
|
46
|
+
insertId?: number;
|
|
47
|
+
}
|
|
48
|
+
>;
|
|
41
49
|
private checkLocalCache;
|
|
42
50
|
private insertLocalCache;
|
|
43
51
|
private clearLocalCache;
|