mind-client-js 0.20.0
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/.gitattributes +3 -0
- package/LICENSE +674 -0
- package/README.md +1 -0
- package/js/dynamic-pool.js +145 -0
- package/js/errors.js +84 -0
- package/js/extends/global.js +134 -0
- package/js/extends/glvn.js +940 -0
- package/js/extends/glvnManagement.js +76 -0
- package/js/index.js +811 -0
- package/js/login.js +215 -0
- package/js/namespaces/RESP3.js +211 -0
- package/js/namespaces/_staticPool.js +156 -0
- package/js/namespaces/db.js +23 -0
- package/js/namespaces/dbms.js +18 -0
- package/js/namespaces/fs.js +708 -0
- package/js/namespaces/globals.js +35 -0
- package/js/namespaces/process.js +451 -0
- package/js/namespaces/server.js +438 -0
- package/js/namespaces/session.js +622 -0
- package/js/namespaces/uApi.js +157 -0
- package/js/namespaces/vars.js +51 -0
- package/js/static-pool.js +789 -0
- package/js/uapi.js +270 -0
- package/js/utils.js +174 -0
- package/package.json +34 -0
- package/sketch.txt +22 -0
package/js/login.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/*###############################################################
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (c) 2025-2026 DnaSoft BV and/or its subsidiaries. #
|
|
4
|
+
# All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# This source code contains the intellectual property #
|
|
7
|
+
# of its copyright holder(s), and is made available #
|
|
8
|
+
# under a license. If you do not know the terms of #
|
|
9
|
+
# the license, please stop and do not read further. #
|
|
10
|
+
# #
|
|
11
|
+
###############################################################*/
|
|
12
|
+
|
|
13
|
+
const uapi = require("./uapi")
|
|
14
|
+
const fs = require("fs");
|
|
15
|
+
const errors = require("./errors");
|
|
16
|
+
|
|
17
|
+
let driverName
|
|
18
|
+
let driverDescription
|
|
19
|
+
let driverVersion
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
pack = JSON.parse(fs.readFileSync(__dirname.substring(0, __dirname.lastIndexOf('\\')) + '/package.json', 'utf8'))
|
|
23
|
+
driverVersion = pack.version
|
|
24
|
+
driverDescription = pack.description
|
|
25
|
+
driverName = pack.name
|
|
26
|
+
|
|
27
|
+
} catch (err) {
|
|
28
|
+
driverVersion = "test-mode"
|
|
29
|
+
driverDescription = "test-mode"
|
|
30
|
+
driverName = "test-mode"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = async function (that, writer, reader, resolve, reject, username, password, options) {
|
|
34
|
+
const opCode = 'server.login'
|
|
35
|
+
const credentials = username + ':' + password
|
|
36
|
+
|
|
37
|
+
that.RESP3._init(that)
|
|
38
|
+
const RESP3 = that.RESP3
|
|
39
|
+
|
|
40
|
+
// send command
|
|
41
|
+
writer(
|
|
42
|
+
"*6" + RESP3.CRLF +
|
|
43
|
+
RESP3.build.blob(opCode) +
|
|
44
|
+
RESP3.build.blob(credentials) +
|
|
45
|
+
RESP3.build.blob(driverName) +
|
|
46
|
+
RESP3.build.blob(driverVersion) +
|
|
47
|
+
RESP3.build.blob(driverDescription) +
|
|
48
|
+
RESP3.build.blob((options.uApi && options.uApi.appName) || '')
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// process response
|
|
52
|
+
reader(data => {
|
|
53
|
+
if (data.charAt(0) === '-') {
|
|
54
|
+
reject(new Error(RESP3.parse.simpleError(data)))
|
|
55
|
+
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const dataA = data.split(RESP3.CRLF)
|
|
60
|
+
let ix = 0
|
|
61
|
+
let iy = 0
|
|
62
|
+
|
|
63
|
+
// check header
|
|
64
|
+
if (dataA[ix].charAt(0) === '-') {
|
|
65
|
+
reject(new Error(dataA[0].slice(1)))
|
|
66
|
+
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// proceed with the server array
|
|
71
|
+
ix += 2
|
|
72
|
+
const serverLength = parseInt(dataA[ix].slice(1))
|
|
73
|
+
|
|
74
|
+
iy = ix
|
|
75
|
+
for (ix = ix + 1; ix < iy + serverLength * 2; ix += 2) {
|
|
76
|
+
Object.defineProperties(that.server, {
|
|
77
|
+
[RESP3.parse.simpleString(dataA[ix])]: {
|
|
78
|
+
value: RESP3.parse.simpleString(dataA[ix + 1]),
|
|
79
|
+
enumerable: true,
|
|
80
|
+
configurable: true
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const mindVersion = that.server.mindVersion
|
|
86
|
+
if (mindVersion < that.requiresMind) {
|
|
87
|
+
reject(new Error(errors.BAD_SERVER_VERSION + 'invalid mind server version, expected ' + that.requiresMind + ' or higher, but found ' + mindVersion))
|
|
88
|
+
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const sessionLength = parseInt(dataA[ix].slice(1))
|
|
93
|
+
|
|
94
|
+
// continue with session
|
|
95
|
+
iy = ix
|
|
96
|
+
for (ix = ix + 1; ix < iy + sessionLength * 3; ix += 2) {
|
|
97
|
+
const name = RESP3.parse.simpleString(dataA[ix])
|
|
98
|
+
const strValue = RESP3.parse.simpleString(dataA[ix + 1])
|
|
99
|
+
|
|
100
|
+
if (RESP3.parse.simpleString(dataA[ix]) === "pid") {
|
|
101
|
+
Object.defineProperties(that.process, {
|
|
102
|
+
[RESP3.parse.simpleString(dataA[ix])]: {
|
|
103
|
+
value: isNaN(parseInt(strValue)) ? strValue : parseInt(strValue),
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: false
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
} else {
|
|
111
|
+
Object.defineProperties(that.session, {
|
|
112
|
+
[RESP3.parse.simpleString(dataA[ix])]: {
|
|
113
|
+
value: isNaN(parseInt(strValue)) ? strValue : parseInt(strValue),
|
|
114
|
+
enumerable: true,
|
|
115
|
+
configurable: true,
|
|
116
|
+
writable: false
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// finally the user api
|
|
123
|
+
const uApiJson = RESP3.parse.blob(data.slice(data.indexOf('\r\n$') + 2))
|
|
124
|
+
const uApi = JSON.parse(uApiJson === '' ? '{}' : uApiJson)
|
|
125
|
+
|
|
126
|
+
Object.defineProperties(that, {
|
|
127
|
+
uApi: {
|
|
128
|
+
value: uApi.client === undefined ? null : uApi.client,
|
|
129
|
+
enumerable: false,
|
|
130
|
+
configurable: true,
|
|
131
|
+
writable: false
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
// append reader, writer and root to make them available to deeper levels
|
|
136
|
+
appendToObject(that.fs, that)
|
|
137
|
+
appendToObject(that.process, that)
|
|
138
|
+
appendToObject(that.server, that)
|
|
139
|
+
appendToObject(that.session, that)
|
|
140
|
+
appendToObject(that.db, that)
|
|
141
|
+
appendToObject(that._staticPool, that)
|
|
142
|
+
appendToObject(that.db.vars, that)
|
|
143
|
+
appendToObject(that.db.globals, that)
|
|
144
|
+
|
|
145
|
+
// and initialize some classes
|
|
146
|
+
that.server._init(that.server)
|
|
147
|
+
that.process._init(that.process)
|
|
148
|
+
that.session._init(that.session)
|
|
149
|
+
that.db.globals._init(that.db.globals)
|
|
150
|
+
that.db.vars._init(that.db.vars)
|
|
151
|
+
|
|
152
|
+
// make RESP3 and _staticPool not enumerable
|
|
153
|
+
Object.defineProperties(that, {
|
|
154
|
+
RESP3: {
|
|
155
|
+
enumerable: false,
|
|
156
|
+
configurable: false
|
|
157
|
+
},
|
|
158
|
+
_staticPool: {
|
|
159
|
+
enumerable: false,
|
|
160
|
+
configurable: true
|
|
161
|
+
},
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
// now we can add vars and globals names, if any, from the options object
|
|
165
|
+
if (uApi && uApi.server && uApi.server.vars && uApi.server.vars.length > 0) {
|
|
166
|
+
uApi.server.vars.forEach(_var => {
|
|
167
|
+
try {
|
|
168
|
+
that.db.vars.addName(_var)
|
|
169
|
+
|
|
170
|
+
} catch (err) {
|
|
171
|
+
reject(new Error(errors.ERROR_ADDING_NAME + 'Error occurred adding var name: ' + _var + ': ' + err.message))
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (options && options.db && options.db.globals) {
|
|
177
|
+
options.db.globals.forEach(_var => {
|
|
178
|
+
try {
|
|
179
|
+
that.db.globals.addName(_var)
|
|
180
|
+
|
|
181
|
+
} catch (err) {
|
|
182
|
+
reject(new Error(errors.ERROR_ADDING_NAME + 'Error occurred adding global name: ' + _var + ': ' + err.message))
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// and add, if present, the user API
|
|
188
|
+
if (that.uApi !== null) {
|
|
189
|
+
uapi.parse(that, writer, reader)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// resolve the promise
|
|
193
|
+
resolve()
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
const appendToObject = (namespace, that) => {
|
|
197
|
+
Object.defineProperties(namespace, {
|
|
198
|
+
objRoot: {
|
|
199
|
+
value: that,
|
|
200
|
+
enumerable: false,
|
|
201
|
+
configurable: false
|
|
202
|
+
},
|
|
203
|
+
writer: {
|
|
204
|
+
value: writer,
|
|
205
|
+
enumerable: false,
|
|
206
|
+
configurable: false
|
|
207
|
+
},
|
|
208
|
+
reader: {
|
|
209
|
+
value: reader,
|
|
210
|
+
enumerable: false,
|
|
211
|
+
configurable: false
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/*###############################################################
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (c) 2026 DnaSoft BV and/or its subsidiaries. #
|
|
4
|
+
# All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# This source code contains the intellectual property #
|
|
7
|
+
# of its copyright holder(s), and is made available #
|
|
8
|
+
# under a license. If you do not know the terms of #
|
|
9
|
+
# the license, please stop and do not read further. #
|
|
10
|
+
# #
|
|
11
|
+
###############################################################*/
|
|
12
|
+
|
|
13
|
+
class RESP3 {
|
|
14
|
+
|
|
15
|
+
build = {
|
|
16
|
+
blobError: str => '!' + str.length.toString() + '\r\n' + str + '\r\n',
|
|
17
|
+
simpleError: str => '-' + str + '\r\n',
|
|
18
|
+
|
|
19
|
+
simpleString: str => '+' + str + '\r\n',
|
|
20
|
+
blob: str => '$' + str.toString().length.toString() + '\r\n' + str.toString() + '\r\n',
|
|
21
|
+
verbatimString: (str, type) => {
|
|
22
|
+
if (type.length !== 3) {
|
|
23
|
+
throw new Error(errors.VERBATIM_TYPE_NOT_3_CHARS + 'Verbatim type MUST be 3 chars length!')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return '=' + (str.length + 4).toString() + '\r\n' + type + ':' + str + '\r\n'
|
|
27
|
+
},
|
|
28
|
+
streamedString: () => '',
|
|
29
|
+
|
|
30
|
+
_null: () => '_\r\n',
|
|
31
|
+
_true: () => '#t\r\n',
|
|
32
|
+
_false: () => '#f\r\n',
|
|
33
|
+
|
|
34
|
+
int: val => '#f' + val.toString() + '\r\n',
|
|
35
|
+
double: val => ',' + val.toString() + '\r\n',
|
|
36
|
+
bigNumber: val => '(' + val.toString() + '\r\n'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
parse = {
|
|
40
|
+
extractToken: str => str.slice(1, str.slice(-2) === '\r\n' ? -2 : str.length),
|
|
41
|
+
|
|
42
|
+
map: str => str,
|
|
43
|
+
|
|
44
|
+
blob: str => str.slice(2 + str.indexOf('\r\n'), -2),
|
|
45
|
+
|
|
46
|
+
simpleString: function (str) {
|
|
47
|
+
return this.extractToken(str)
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
simpleError: function (str) {
|
|
51
|
+
return this.extractToken(str)
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
boolean: function (str) {
|
|
55
|
+
return this.extractToken(str) === 't'
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
null: function (str) {
|
|
59
|
+
return this.extractToken(str)
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
int: function (str) {
|
|
63
|
+
return parseInt(this.extractToken(str))
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
double: function (str) {
|
|
67
|
+
return parseFloat(this.extractToken(str))
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
bigNumber: function (str) {
|
|
71
|
+
return this.extractToken(str)
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
returns: function (str, returnDatatype) {
|
|
75
|
+
let type = str.charAt(0)
|
|
76
|
+
|
|
77
|
+
if (type === '') {
|
|
78
|
+
type = '|'
|
|
79
|
+
str = '\r\n' + str.slice(str.indexOf('\n') + 1)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
switch (type) {
|
|
83
|
+
case '+':
|
|
84
|
+
return this.simpleString(str)
|
|
85
|
+
|
|
86
|
+
case '$':
|
|
87
|
+
return this.blob(str)
|
|
88
|
+
|
|
89
|
+
case ':':
|
|
90
|
+
return this.int(str)
|
|
91
|
+
|
|
92
|
+
case '_':
|
|
93
|
+
return null
|
|
94
|
+
|
|
95
|
+
case ',':
|
|
96
|
+
return this.double(str)
|
|
97
|
+
|
|
98
|
+
case '#':
|
|
99
|
+
return this.boolean(str)
|
|
100
|
+
|
|
101
|
+
case '|':
|
|
102
|
+
if (returnDatatype === 'object') {
|
|
103
|
+
return JSON.parse(str.slice(6 + str.indexOf('\r\n'), -2))
|
|
104
|
+
|
|
105
|
+
} else {
|
|
106
|
+
return str.slice(6 + str.indexOf('\r\n'), -2)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
default :
|
|
110
|
+
return this.simpleError('+INVALID RESP3 datatype')
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
convert = {
|
|
116
|
+
jsArrayToRESP3: array => {
|
|
117
|
+
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
jsObjectToRESP3: object => {
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
_init = that => {
|
|
126
|
+
Object.defineProperties(that.RESP3, {
|
|
127
|
+
extractToken: {
|
|
128
|
+
value: str => str.slice(1, str.slice(-2) === '\r\n' ? -2 : str.length),
|
|
129
|
+
enumerable: false,
|
|
130
|
+
configurable: true,
|
|
131
|
+
writable: false
|
|
132
|
+
},
|
|
133
|
+
CRLF: {
|
|
134
|
+
value: '\r\n',
|
|
135
|
+
enumerable: true,
|
|
136
|
+
configurable: true,
|
|
137
|
+
writable: false
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
LF: {
|
|
141
|
+
value: '\n',
|
|
142
|
+
enumerable: true,
|
|
143
|
+
configurable: true,
|
|
144
|
+
writable: false
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
null: {
|
|
148
|
+
value: '_',
|
|
149
|
+
enumerable: true,
|
|
150
|
+
configurable: true,
|
|
151
|
+
writable: false
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
boolean: {
|
|
155
|
+
value: '#',
|
|
156
|
+
enumerable: true,
|
|
157
|
+
configurable: true,
|
|
158
|
+
writable: false
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
true: {
|
|
162
|
+
value: '#t',
|
|
163
|
+
enumerable: true,
|
|
164
|
+
configurable: true,
|
|
165
|
+
writable: false
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
false: {
|
|
169
|
+
value: '#f',
|
|
170
|
+
enumerable: true,
|
|
171
|
+
configurable: true,
|
|
172
|
+
writable: false
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
int: {
|
|
176
|
+
value: ':',
|
|
177
|
+
enumerable: true,
|
|
178
|
+
configurable: true,
|
|
179
|
+
writable: false
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
double: {
|
|
183
|
+
value: ',',
|
|
184
|
+
enumerable: true,
|
|
185
|
+
configurable: true,
|
|
186
|
+
writable: false
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
bigNumber: {
|
|
190
|
+
value: '(',
|
|
191
|
+
enumerable: true,
|
|
192
|
+
configurable: true,
|
|
193
|
+
writable: false
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
_init: {
|
|
197
|
+
enumerable: false,
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
Object.defineProperties(that.RESP3.parse, {
|
|
202
|
+
extractToken: {
|
|
203
|
+
enumerable: false,
|
|
204
|
+
configurable: true,
|
|
205
|
+
writable: false
|
|
206
|
+
},
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
module.exports = RESP3
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/*###############################################################
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (c) 2026 DnaSoft BV and/or its subsidiaries. #
|
|
4
|
+
# All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# This source code contains the intellectual property #
|
|
7
|
+
# of its copyright holder(s), and is made available #
|
|
8
|
+
# under a license. If you do not know the terms of #
|
|
9
|
+
# the license, please stop and do not read further. #
|
|
10
|
+
# #
|
|
11
|
+
###############################################################*/
|
|
12
|
+
|
|
13
|
+
const utils = require("../utils");
|
|
14
|
+
const errors = require('../errors.js')
|
|
15
|
+
|
|
16
|
+
class _staticPool {
|
|
17
|
+
_register = function (pool) {
|
|
18
|
+
const that = this
|
|
19
|
+
const RESP3 = that.objRoot.RESP3
|
|
20
|
+
const pids = []
|
|
21
|
+
|
|
22
|
+
pool.sessions.forEach(session => {
|
|
23
|
+
pids.push(session.session.process.pid)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return new Promise(function (resolve, reject) {
|
|
27
|
+
if (that.objRoot.connected === false || that.objRoot.loggedIn === false) {
|
|
28
|
+
reject(new Error(errors.POOL_NOT_INITIALIZED + 'pool not initialized'))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// send command
|
|
32
|
+
const opCode = 'pool.register'
|
|
33
|
+
|
|
34
|
+
that.writer("*2" + RESP3.CRLF +
|
|
35
|
+
RESP3.build.blob(opCode) +
|
|
36
|
+
RESP3.build.blob(JSON.stringify(pids))
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
that.reader(data => {
|
|
40
|
+
if (data.charAt(0) === '-') {
|
|
41
|
+
reject(new Error(RESP3.parse.simpleError(data)))
|
|
42
|
+
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
resolve(RESP3.parse.simpleString(data))
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_getPoolStats = function () {
|
|
52
|
+
const that = this
|
|
53
|
+
const RESP3 = that.objRoot.RESP3
|
|
54
|
+
|
|
55
|
+
return new Promise(function (resolve, reject) {
|
|
56
|
+
if (that.objRoot.connected === false || that.objRoot.loggedIn === false) {
|
|
57
|
+
reject(new Error(errors.POOL_NOT_INITIALIZED + 'Pool not initialized'))
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// send command
|
|
61
|
+
const opCode = 'pool.getPoolStats'
|
|
62
|
+
|
|
63
|
+
that.writer("*1" + RESP3.CRLF +
|
|
64
|
+
RESP3.build.blob(opCode)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
that.reader(data => {
|
|
68
|
+
if (data.charAt(0) === '-') {
|
|
69
|
+
reject(new Error(RESP3.parse.simpleError(data)))
|
|
70
|
+
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
resolve(JSON.parse(RESP3.parse.blob(data)))
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_changeServerSetting = function (name, value) {
|
|
80
|
+
const that = this
|
|
81
|
+
const RESP3 = that.objRoot.RESP3
|
|
82
|
+
|
|
83
|
+
return new Promise(function (resolve, reject) {
|
|
84
|
+
if (that.objRoot.connected === false || that.objRoot.loggedIn === false) {
|
|
85
|
+
reject(new Error(errors.POOL_NOT_INITIALIZED + 'pool not initialized'))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (typeof name !== 'string') {
|
|
89
|
+
reject(new Error(errors.PARAM_NOT_STRING + 'name must be a string'))
|
|
90
|
+
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (name === '') {
|
|
95
|
+
reject(new Error(errors.PARAM_NOT_STRING_OR_EMPTY + 'name must be a string longer than 0 chars'))
|
|
96
|
+
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (typeof value !== 'number') {
|
|
101
|
+
reject(new Error(errors.PARAM_NOT_NUMBER + 'value must be a number'))
|
|
102
|
+
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// send command
|
|
107
|
+
const opCode = 'pool.changeServerSetting'
|
|
108
|
+
|
|
109
|
+
that.writer("*3" + RESP3.CRLF +
|
|
110
|
+
RESP3.build.blob(opCode) +
|
|
111
|
+
RESP3.build.blob(name) +
|
|
112
|
+
RESP3.build.blob(value)
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
that.reader(data => {
|
|
116
|
+
if (data.charAt(0) === '-') {
|
|
117
|
+
reject(new Error(RESP3.parse.simpleError(data)))
|
|
118
|
+
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
resolve()
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
_rundown = function () {
|
|
128
|
+
const that = this
|
|
129
|
+
const RESP3 = that.objRoot.RESP3
|
|
130
|
+
|
|
131
|
+
return new Promise(function (resolve, reject) {
|
|
132
|
+
if (that.objRoot.connected === false || that.objRoot.loggedIn === false) {
|
|
133
|
+
reject(new Error(errors.POOL_NOT_INITIALIZED + 'Pool not initialized'))
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// send command
|
|
137
|
+
const opCode = 'pool.rundown'
|
|
138
|
+
|
|
139
|
+
that.writer("*1" + RESP3.CRLF +
|
|
140
|
+
RESP3.build.blob(opCode)
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
that.reader(data => {
|
|
144
|
+
if (data.charAt(0) === '-') {
|
|
145
|
+
reject(new Error(RESP3.parse.simpleError(data)))
|
|
146
|
+
|
|
147
|
+
return
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
resolve()
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = _staticPool
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*###############################################################
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (c) 2026 DnaSoft BV and/or its subsidiaries. #
|
|
4
|
+
# All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# This source code contains the intellectual property #
|
|
7
|
+
# of its copyright holder(s), and is made available #
|
|
8
|
+
# under a license. If you do not know the terms of #
|
|
9
|
+
# the license, please stop and do not read further. #
|
|
10
|
+
# #
|
|
11
|
+
###############################################################*/
|
|
12
|
+
|
|
13
|
+
const Vars = require('./vars')
|
|
14
|
+
const Globals = require('./globals')
|
|
15
|
+
|
|
16
|
+
class Db {
|
|
17
|
+
vars = new Vars
|
|
18
|
+
globals = new Globals
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
module.exports = Db
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*###############################################################
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (c) 2026 DnaSoft BV and/or its subsidiaries. #
|
|
4
|
+
# All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# This source code contains the intellectual property #
|
|
7
|
+
# of its copyright holder(s), and is made available #
|
|
8
|
+
# under a license. If you do not know the terms of #
|
|
9
|
+
# the license, please stop and do not read further. #
|
|
10
|
+
# #
|
|
11
|
+
###############################################################*/
|
|
12
|
+
|
|
13
|
+
class Dbms {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
module.exports = Dbms
|