@blazedpath/commons 0.0.8 → 0.0.9
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/blz-base/index.js +895 -893
- package/blz-cache/index.js +14 -25
- package/blz-core/index.js +349 -347
- package/blz-cryptography/index.js +49 -47
- package/blz-datetimes/index.js +350 -348
- package/blz-file/index.js +88 -83
- package/blz-hazelcast/index.js +103 -100
- package/blz-iterable/index.js +406 -404
- package/blz-json-schema/index.js +8 -6
- package/blz-jwt/index.js +92 -89
- package/blz-kafka/index.js +107 -105
- package/blz-math/index.js +129 -127
- package/blz-mongodb/index.js +35 -33
- package/blz-rds/index.js +46 -44
- package/blz-rds-mysql/index.js +23 -21
- package/blz-rds-mysqlx/index.js +22 -20
- package/blz-rds-oracle/index.js +204 -199
- package/blz-rds-postgres/index.js +22 -20
- package/blz-redis/index.js +125 -123
- package/blz-regex/index.js +24 -22
- package/blz-strings/index.js +167 -165
- package/blz-uuid/index.js +4 -2
- package/blz-yaml/index.js +19 -16
- package/package.json +1 -1
package/blz-file/index.js
CHANGED
|
@@ -1,94 +1,99 @@
|
|
|
1
|
+
const { Backend } = require('../blz-cryptography/index.js');
|
|
1
2
|
const fileService = require('./fileService.js')
|
|
2
|
-
const path =
|
|
3
|
+
const path = require('path')
|
|
3
4
|
module.exports = typeof module.exports === "undefined" ? {} : module.exports;
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
6
|
+
module.exports = {
|
|
7
|
+
Backend: {
|
|
8
|
+
/**
|
|
9
|
+
* Join parts of path
|
|
10
|
+
* @param {list(string)} paths - parts of path
|
|
11
|
+
* @return {string} - Path joined
|
|
12
|
+
*/
|
|
13
|
+
pathJoin: async function (paths) {
|
|
14
|
+
if (!paths) {
|
|
15
|
+
throw new Error("paths is required");
|
|
16
|
+
}
|
|
17
|
+
return path.join(...paths)
|
|
18
|
+
},
|
|
16
19
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* Append data to File
|
|
22
|
+
* @param {string} path - path of file
|
|
23
|
+
* @param {string} content - content of file
|
|
24
|
+
* @return {any}
|
|
25
|
+
*/
|
|
26
|
+
fileAppend: async function (path, content) {
|
|
27
|
+
await fileService.append(path, content)
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Read file request
|
|
31
|
+
* @param {string} path - Path of file
|
|
32
|
+
* @return {FileReadResponse}
|
|
33
|
+
*/
|
|
34
|
+
fileRead: async function (path) {
|
|
35
|
+
return fileService.read(path)
|
|
36
|
+
},
|
|
34
37
|
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
38
|
+
/**
|
|
39
|
+
* Append lines to file
|
|
40
|
+
* @param {string} path - Path of file
|
|
41
|
+
* @param {list(string)} lines - lines to append
|
|
42
|
+
* @param {integer} [start] - position to start append
|
|
43
|
+
* @return {any}
|
|
44
|
+
*/
|
|
45
|
+
fileAppendLines: async function (path, lines, start) {
|
|
46
|
+
await fileService.appendLines(path, lines, start)
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Read lines form file
|
|
50
|
+
* @param {string} path - Path of file
|
|
51
|
+
* @param {integer} [start] - Start position to read
|
|
52
|
+
* @param {integer} [count] - Count lines to read
|
|
53
|
+
* @return {any}
|
|
54
|
+
*/
|
|
55
|
+
fileReadLines: async function (path, start, count) {
|
|
56
|
+
return fileService.readLines(path, start, count)
|
|
57
|
+
},
|
|
55
58
|
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
59
|
+
/**
|
|
60
|
+
* Create iterable to read lines from file
|
|
61
|
+
* @param {string} path - Path of file
|
|
62
|
+
* @return {any}
|
|
63
|
+
*/
|
|
64
|
+
fileCreateLineIterable: async function (path) {
|
|
65
|
+
return fileService.createLineIterable(path)
|
|
66
|
+
},
|
|
64
67
|
|
|
65
68
|
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
69
|
+
/**
|
|
70
|
+
* File exists
|
|
71
|
+
* @param {string} path - path of file
|
|
72
|
+
* @return {boolean}
|
|
73
|
+
*/
|
|
74
|
+
fileExists: async function (path) {
|
|
75
|
+
return fileService.exists(path)
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Lines of file
|
|
79
|
+
* @param {string} path - path of file
|
|
80
|
+
* @return {integer}
|
|
81
|
+
*/
|
|
82
|
+
fileLines: async function (path) {
|
|
83
|
+
return fileService.lines(path)
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* File Size
|
|
87
|
+
* @param {string} path - path of file
|
|
88
|
+
* @return {integer}
|
|
89
|
+
*/
|
|
90
|
+
fileSize: async function (path) {
|
|
91
|
+
return fileService.size(path)
|
|
92
|
+
},
|
|
90
93
|
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
fileRemove: async function (path) {
|
|
95
|
+
return fileService.remove(path)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
93
98
|
}
|
|
94
99
|
|
package/blz-hazelcast/index.js
CHANGED
|
@@ -2,6 +2,7 @@ const hazelcastCache = require('./lib/hazelcastCache.js');
|
|
|
2
2
|
const { UsernamePasswordCredentials } = require('./lib/credentials.js');
|
|
3
3
|
const { usernamePasswordCredentialsFactory } = require('./lib/credentialsFactory.js');
|
|
4
4
|
const fs = require('fs-extra');
|
|
5
|
+
const { Backend } = require('../blz-cryptography/index.js');
|
|
5
6
|
|
|
6
7
|
// Hazelcast Client cache
|
|
7
8
|
let hazelcastClients = {};
|
|
@@ -67,7 +68,7 @@ function getOrCreateHazelcastClient(connection) {
|
|
|
67
68
|
1: usernamePasswordCredentialsFactory
|
|
68
69
|
}
|
|
69
70
|
},
|
|
70
|
-
|
|
71
|
+
options.connectionOptions.customCredentials = new UsernamePasswordCredentials(connection.user, connection.password, connection.endpoint);
|
|
71
72
|
}
|
|
72
73
|
hazelcastClient = hazelcastCache.createHazelcastClient(options);
|
|
73
74
|
hazelcastClients[connection.name] = hazelcastClient;
|
|
@@ -86,104 +87,106 @@ function ensureMembers(members) {
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
module.exports = {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
90
|
+
Backend: {
|
|
91
|
+
hazelcastMapGet: function (connection, name, key) {
|
|
92
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
93
|
+
return hazelcastClient.mapGet(name, key);
|
|
94
|
+
},
|
|
95
|
+
hazelcastMapGetAll: function (connection, name, keys) {
|
|
96
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
97
|
+
return hazelcastClient.mapGetAll(name, keys);
|
|
98
|
+
},
|
|
99
|
+
hazelcastMapSet: function (connection, name, key, value, ttl) {
|
|
100
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
101
|
+
return hazelcastClient.mapSet(name, key, value, ttl);
|
|
102
|
+
},
|
|
103
|
+
hazelcastMapSetAll: function (connection, name, data) {
|
|
104
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
105
|
+
return hazelcastClient.mapSetAll(name, data);
|
|
106
|
+
},
|
|
107
|
+
hazelcastMapDelete: function (connection, name, key) {
|
|
108
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
109
|
+
return hazelcastClient.mapDelete(name, key);
|
|
110
|
+
},
|
|
111
|
+
hazelcastMapSetTtl: function (connection, name, key, ttl) {
|
|
112
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
113
|
+
return hazelcastClient.mapSetTtl(name, key, ttl);
|
|
114
|
+
},
|
|
115
|
+
hazelcastMapGetEntryView: function (connection, name, key) {
|
|
116
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
117
|
+
return hazelcastClient.mapGetEntryView(name, key);
|
|
118
|
+
},
|
|
119
|
+
hazelcastMapContainsKey: function (connection, name, key) {
|
|
120
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
121
|
+
return hazelcastClient.mapContainsKey(name, key);
|
|
122
|
+
},
|
|
123
|
+
hazelcastMapKeySet: function (connection, name) {
|
|
124
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
125
|
+
return hazelcastClient.mapKeySet(name);
|
|
126
|
+
},
|
|
127
|
+
hazelcastMapValues: function (connection, name) {
|
|
128
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
129
|
+
return hazelcastClient.mapValues(name);
|
|
130
|
+
},
|
|
131
|
+
hazelcastMapEntrySet: function (connection, name) {
|
|
132
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
133
|
+
return hazelcastClient.mapEntrySet(name);
|
|
134
|
+
},
|
|
135
|
+
hazelcastMapSize: function (connection, name) {
|
|
136
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
137
|
+
return hazelcastClient.mapSize(name);
|
|
138
|
+
},
|
|
139
|
+
hazelcastMapClear: function (connection, name) {
|
|
140
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
141
|
+
return hazelcastClient.mapClear(name);
|
|
142
|
+
},
|
|
143
|
+
hazelcastMapDestroy: function (connection, name) {
|
|
144
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
145
|
+
return hazelcastClient.mapDestroy(name);
|
|
146
|
+
},
|
|
147
|
+
hazelcastListGet: function (connection, name, index) {
|
|
148
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
149
|
+
return hazelcastClient.listGet(name, index);
|
|
150
|
+
},
|
|
151
|
+
hazelcastListAdd: function (connection, name, element) {
|
|
152
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
153
|
+
return hazelcastClient.listAdd(name, element);
|
|
154
|
+
},
|
|
155
|
+
hazelcastListAddAt: function (connection, name, index, element) {
|
|
156
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
157
|
+
return hazelcastClient.listAddAt(name, index, element);
|
|
158
|
+
},
|
|
159
|
+
hazelcastListAddAll: function (connection, name, elements) {
|
|
160
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
161
|
+
return hazelcastClient.listAddAll(name, elements);
|
|
162
|
+
},
|
|
163
|
+
hazelcastListRemove: function (connection, name, element) {
|
|
164
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
165
|
+
return hazelcastClient.listRemove(name, element);
|
|
166
|
+
},
|
|
167
|
+
hazelcastListRemoveAt: function (connection, name, index) {
|
|
168
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
169
|
+
return hazelcastClient.listRemoveAt(name, index);
|
|
170
|
+
},
|
|
171
|
+
hazelcastListContains: function (connection, name, element) {
|
|
172
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
173
|
+
return hazelcastClient.listContains(name, element);
|
|
174
|
+
},
|
|
175
|
+
hazelcastListIndexOf: function (connection, name, element) {
|
|
176
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
177
|
+
return hazelcastClient.listIndexOf(name, element);
|
|
178
|
+
},
|
|
179
|
+
hazelcastListSize: function (connection, name) {
|
|
180
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
181
|
+
return hazelcastClient.listSize(name);
|
|
182
|
+
},
|
|
183
|
+
hazelcastListClear: function (connection, name) {
|
|
184
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
185
|
+
return hazelcastClient.listClear(name);
|
|
186
|
+
},
|
|
187
|
+
hazelcastListDestroy: function (connection, name) {
|
|
188
|
+
let hazelcastClient = getOrCreateHazelcastClient(connection);
|
|
189
|
+
return hazelcastClient.listDestroy(name);
|
|
190
|
+
}
|
|
188
191
|
}
|
|
189
192
|
};
|