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