@rootintf/json-msg 2.3.2 → 4.0.2-api.4
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/dist/json-msg.cjs.js +21 -31
- package/dist/json-msg.es.mjs +20 -30
- package/dist/json_msg+ack.d.ts +10 -10
- package/package.json +58 -60
package/dist/json-msg.cjs.js
CHANGED
|
@@ -47,7 +47,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
47
47
|
}
|
|
48
48
|
} validate18.errors = vErrors; return errors === 0; }
|
|
49
49
|
validate18.evaluated = { "props": { "id": true, "dt": true }, "dynamicProps": false, "dynamicItems": false };
|
|
50
|
-
const
|
|
50
|
+
const schema_Eff = validate19;
|
|
51
51
|
function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate19.evaluated; if (evaluated0.dynamicProps) {
|
|
52
52
|
evaluated0.props = undefined;
|
|
53
53
|
} if (evaluated0.dynamicItems) {
|
|
@@ -66,7 +66,7 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
66
66
|
}
|
|
67
67
|
} validate19.errors = vErrors; return errors === 0; }
|
|
68
68
|
validate19.evaluated = { "dynamicProps": false, "dynamicItems": false };
|
|
69
|
-
const
|
|
69
|
+
const schema_Ack = validate20;
|
|
70
70
|
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
|
|
71
71
|
evaluated0.props = undefined;
|
|
72
72
|
} if (evaluated0.dynamicItems) {
|
|
@@ -139,21 +139,17 @@ function unsafeStringify(arr, offset = 0) {
|
|
|
139
139
|
byteToHex[arr[offset + 15]]).toLowerCase();
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
let getRandomValues;
|
|
143
142
|
const rnds8 = new Uint8Array(16);
|
|
144
143
|
function rng() {
|
|
145
|
-
|
|
146
|
-
if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
|
|
147
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
148
|
-
}
|
|
149
|
-
getRandomValues = crypto.getRandomValues.bind(crypto);
|
|
150
|
-
}
|
|
151
|
-
return getRandomValues(rnds8);
|
|
144
|
+
return crypto.getRandomValues(rnds8);
|
|
152
145
|
}
|
|
153
146
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
147
|
+
function v4(options, buf, offset) {
|
|
148
|
+
if (crypto.randomUUID) {
|
|
149
|
+
return crypto.randomUUID();
|
|
150
|
+
}
|
|
151
|
+
return _v4(options);
|
|
152
|
+
}
|
|
157
153
|
function _v4(options, buf, offset) {
|
|
158
154
|
options = options || {};
|
|
159
155
|
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
@@ -164,16 +160,10 @@ function _v4(options, buf, offset) {
|
|
|
164
160
|
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
165
161
|
return unsafeStringify(rnds);
|
|
166
162
|
}
|
|
167
|
-
function v4(options, buf, offset) {
|
|
168
|
-
if (native.randomUUID && true && !options) {
|
|
169
|
-
return native.randomUUID();
|
|
170
|
-
}
|
|
171
|
-
return _v4(options);
|
|
172
|
-
}
|
|
173
163
|
|
|
174
164
|
//-------------------------------------------------------------------------------------------------
|
|
175
165
|
const LOGR_ = bitlogr.LOGR.get_instance();
|
|
176
|
-
const logr_ = LOGR_.create({ labels: bitlogr.l_array(['VALIDATION']) });
|
|
166
|
+
const logr_ = LOGR_.create({ name: "npm:json-msg", labels: bitlogr.l_array(['VALIDATION']) });
|
|
177
167
|
const l_ = logr_.l;
|
|
178
168
|
// TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
|
|
179
169
|
// "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
|
|
@@ -200,7 +190,7 @@ var JSON_Msg = (function () {
|
|
|
200
190
|
// }
|
|
201
191
|
};
|
|
202
192
|
})();
|
|
203
|
-
var
|
|
193
|
+
var JSON_Eff = (function () {
|
|
204
194
|
return {
|
|
205
195
|
create_with_cause_merge: function (msg_cause, json) {
|
|
206
196
|
const _cause = msg_cause;
|
|
@@ -209,24 +199,24 @@ var JSON_MsgEffect = (function () {
|
|
|
209
199
|
validate: function (json) {
|
|
210
200
|
if (!JSON_Msg.validate(json))
|
|
211
201
|
return false;
|
|
212
|
-
const b_valid =
|
|
202
|
+
const b_valid = schema_Eff(json);
|
|
213
203
|
if (!b_valid)
|
|
214
|
-
logr_.log(l_.VALIDATION, () => ['
|
|
204
|
+
logr_.log(l_.VALIDATION, () => ['JSON_Eff: validate: ', schema_Eff.errors]);
|
|
215
205
|
return b_valid;
|
|
216
206
|
}
|
|
217
207
|
};
|
|
218
208
|
})();
|
|
219
|
-
var
|
|
209
|
+
var JSON_Ack = (function () {
|
|
220
210
|
return {
|
|
221
211
|
create_with_cause_Ok: function (msg_cause, b_ok = true) {
|
|
222
|
-
return
|
|
212
|
+
return JSON_Eff.create_with_cause_merge(msg_cause, {
|
|
223
213
|
ack: {
|
|
224
214
|
"ok": b_ok,
|
|
225
215
|
},
|
|
226
216
|
});
|
|
227
217
|
},
|
|
228
218
|
create_with_cause_Expired: function (msg_cause) {
|
|
229
|
-
return
|
|
219
|
+
return JSON_Eff.create_with_cause_merge(msg_cause, {
|
|
230
220
|
ack: {
|
|
231
221
|
"ok": false,
|
|
232
222
|
"expired": true
|
|
@@ -234,17 +224,17 @@ var JSON_MsgAck = (function () {
|
|
|
234
224
|
});
|
|
235
225
|
},
|
|
236
226
|
validate: function (json) {
|
|
237
|
-
if (!
|
|
227
|
+
if (!JSON_Eff.validate(json))
|
|
238
228
|
return false;
|
|
239
|
-
const b_valid =
|
|
229
|
+
const b_valid = schema_Ack(json);
|
|
240
230
|
if (!b_valid)
|
|
241
|
-
logr_.log(l_.VALIDATION, () => ['
|
|
231
|
+
logr_.log(l_.VALIDATION, () => ['JSON_Ack: validate: ', schema_Ack.errors]);
|
|
242
232
|
return b_valid;
|
|
243
233
|
}
|
|
244
234
|
};
|
|
245
235
|
})();
|
|
246
236
|
|
|
237
|
+
exports.JSON_Ack = JSON_Ack;
|
|
238
|
+
exports.JSON_Eff = JSON_Eff;
|
|
247
239
|
exports.JSON_Msg = JSON_Msg;
|
|
248
|
-
exports.JSON_MsgAck = JSON_MsgAck;
|
|
249
|
-
exports.JSON_MsgEffect = JSON_MsgEffect;
|
|
250
240
|
exports.logr = logr_;
|
package/dist/json-msg.es.mjs
CHANGED
|
@@ -45,7 +45,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
45
45
|
}
|
|
46
46
|
} validate18.errors = vErrors; return errors === 0; }
|
|
47
47
|
validate18.evaluated = { "props": { "id": true, "dt": true }, "dynamicProps": false, "dynamicItems": false };
|
|
48
|
-
const
|
|
48
|
+
const schema_Eff = validate19;
|
|
49
49
|
function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate19.evaluated; if (evaluated0.dynamicProps) {
|
|
50
50
|
evaluated0.props = undefined;
|
|
51
51
|
} if (evaluated0.dynamicItems) {
|
|
@@ -64,7 +64,7 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
64
64
|
}
|
|
65
65
|
} validate19.errors = vErrors; return errors === 0; }
|
|
66
66
|
validate19.evaluated = { "dynamicProps": false, "dynamicItems": false };
|
|
67
|
-
const
|
|
67
|
+
const schema_Ack = validate20;
|
|
68
68
|
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
|
|
69
69
|
evaluated0.props = undefined;
|
|
70
70
|
} if (evaluated0.dynamicItems) {
|
|
@@ -137,21 +137,17 @@ function unsafeStringify(arr, offset = 0) {
|
|
|
137
137
|
byteToHex[arr[offset + 15]]).toLowerCase();
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
let getRandomValues;
|
|
141
140
|
const rnds8 = new Uint8Array(16);
|
|
142
141
|
function rng() {
|
|
143
|
-
|
|
144
|
-
if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
|
|
145
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
146
|
-
}
|
|
147
|
-
getRandomValues = crypto.getRandomValues.bind(crypto);
|
|
148
|
-
}
|
|
149
|
-
return getRandomValues(rnds8);
|
|
142
|
+
return crypto.getRandomValues(rnds8);
|
|
150
143
|
}
|
|
151
144
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
145
|
+
function v4(options, buf, offset) {
|
|
146
|
+
if (crypto.randomUUID) {
|
|
147
|
+
return crypto.randomUUID();
|
|
148
|
+
}
|
|
149
|
+
return _v4(options);
|
|
150
|
+
}
|
|
155
151
|
function _v4(options, buf, offset) {
|
|
156
152
|
options = options || {};
|
|
157
153
|
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
@@ -162,16 +158,10 @@ function _v4(options, buf, offset) {
|
|
|
162
158
|
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
163
159
|
return unsafeStringify(rnds);
|
|
164
160
|
}
|
|
165
|
-
function v4(options, buf, offset) {
|
|
166
|
-
if (native.randomUUID && true && !options) {
|
|
167
|
-
return native.randomUUID();
|
|
168
|
-
}
|
|
169
|
-
return _v4(options);
|
|
170
|
-
}
|
|
171
161
|
|
|
172
162
|
//-------------------------------------------------------------------------------------------------
|
|
173
163
|
const LOGR_ = LOGR.get_instance();
|
|
174
|
-
const logr_ = LOGR_.create({ labels: l_array(['VALIDATION']) });
|
|
164
|
+
const logr_ = LOGR_.create({ name: "npm:json-msg", labels: l_array(['VALIDATION']) });
|
|
175
165
|
const l_ = logr_.l;
|
|
176
166
|
// TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
|
|
177
167
|
// "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
|
|
@@ -198,7 +188,7 @@ var JSON_Msg = (function () {
|
|
|
198
188
|
// }
|
|
199
189
|
};
|
|
200
190
|
})();
|
|
201
|
-
var
|
|
191
|
+
var JSON_Eff = (function () {
|
|
202
192
|
return {
|
|
203
193
|
create_with_cause_merge: function (msg_cause, json) {
|
|
204
194
|
const _cause = msg_cause;
|
|
@@ -207,24 +197,24 @@ var JSON_MsgEffect = (function () {
|
|
|
207
197
|
validate: function (json) {
|
|
208
198
|
if (!JSON_Msg.validate(json))
|
|
209
199
|
return false;
|
|
210
|
-
const b_valid =
|
|
200
|
+
const b_valid = schema_Eff(json);
|
|
211
201
|
if (!b_valid)
|
|
212
|
-
logr_.log(l_.VALIDATION, () => ['
|
|
202
|
+
logr_.log(l_.VALIDATION, () => ['JSON_Eff: validate: ', schema_Eff.errors]);
|
|
213
203
|
return b_valid;
|
|
214
204
|
}
|
|
215
205
|
};
|
|
216
206
|
})();
|
|
217
|
-
var
|
|
207
|
+
var JSON_Ack = (function () {
|
|
218
208
|
return {
|
|
219
209
|
create_with_cause_Ok: function (msg_cause, b_ok = true) {
|
|
220
|
-
return
|
|
210
|
+
return JSON_Eff.create_with_cause_merge(msg_cause, {
|
|
221
211
|
ack: {
|
|
222
212
|
"ok": b_ok,
|
|
223
213
|
},
|
|
224
214
|
});
|
|
225
215
|
},
|
|
226
216
|
create_with_cause_Expired: function (msg_cause) {
|
|
227
|
-
return
|
|
217
|
+
return JSON_Eff.create_with_cause_merge(msg_cause, {
|
|
228
218
|
ack: {
|
|
229
219
|
"ok": false,
|
|
230
220
|
"expired": true
|
|
@@ -232,14 +222,14 @@ var JSON_MsgAck = (function () {
|
|
|
232
222
|
});
|
|
233
223
|
},
|
|
234
224
|
validate: function (json) {
|
|
235
|
-
if (!
|
|
225
|
+
if (!JSON_Eff.validate(json))
|
|
236
226
|
return false;
|
|
237
|
-
const b_valid =
|
|
227
|
+
const b_valid = schema_Ack(json);
|
|
238
228
|
if (!b_valid)
|
|
239
|
-
logr_.log(l_.VALIDATION, () => ['
|
|
229
|
+
logr_.log(l_.VALIDATION, () => ['JSON_Ack: validate: ', schema_Ack.errors]);
|
|
240
230
|
return b_valid;
|
|
241
231
|
}
|
|
242
232
|
};
|
|
243
233
|
})();
|
|
244
234
|
|
|
245
|
-
export {
|
|
235
|
+
export { JSON_Ack, JSON_Eff, JSON_Msg, logr_ as logr };
|
package/dist/json_msg+ack.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ interface JSON_Msg {
|
|
|
4
4
|
referer: unknown;
|
|
5
5
|
dt: string;
|
|
6
6
|
}
|
|
7
|
-
interface
|
|
7
|
+
interface JSON_Eff extends JSON_Msg {
|
|
8
8
|
_cause: JSON_Msg;
|
|
9
9
|
}
|
|
10
|
-
interface
|
|
10
|
+
interface JSON_Ack extends JSON_Eff {
|
|
11
11
|
ack: {
|
|
12
12
|
ok: boolean;
|
|
13
13
|
expired?: boolean;
|
|
@@ -17,13 +17,13 @@ declare var JSON_Msg: {
|
|
|
17
17
|
merge: <T extends object>(json: T) => JSON_Msg & T;
|
|
18
18
|
validate: (json: unknown) => json is JSON_Msg;
|
|
19
19
|
};
|
|
20
|
-
declare var
|
|
21
|
-
create_with_cause_merge: <T extends object>(msg_cause: JSON_Msg, json: T) =>
|
|
22
|
-
validate: (json: unknown) => json is
|
|
20
|
+
declare var JSON_Eff: {
|
|
21
|
+
create_with_cause_merge: <T extends object>(msg_cause: JSON_Msg, json: T) => JSON_Eff & T;
|
|
22
|
+
validate: (json: unknown) => json is JSON_Eff;
|
|
23
23
|
};
|
|
24
|
-
declare var
|
|
25
|
-
create_with_cause_Ok: (msg_cause: JSON_Msg, b_ok?: boolean) =>
|
|
26
|
-
create_with_cause_Expired: (msg_cause: JSON_Msg) =>
|
|
27
|
-
validate: (json: unknown) => json is
|
|
24
|
+
declare var JSON_Ack: {
|
|
25
|
+
create_with_cause_Ok: (msg_cause: JSON_Msg, b_ok?: boolean) => JSON_Ack;
|
|
26
|
+
create_with_cause_Expired: (msg_cause: JSON_Msg) => JSON_Ack;
|
|
27
|
+
validate: (json: unknown) => json is JSON_Ack;
|
|
28
28
|
};
|
|
29
|
-
export { JSON_Msg,
|
|
29
|
+
export { JSON_Msg, JSON_Eff, JSON_Ack, logr_ as logr };
|
package/package.json
CHANGED
|
@@ -1,60 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@rootintf/json-msg",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/json-msg.cjs.js",
|
|
6
|
-
"module": "dist/json-msg.es.mjs",
|
|
7
|
-
"browser": "dist/json-msg.es.mjs",
|
|
8
|
-
"types": "dist/json_msg+ack.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/json_msg+ack.d.ts",
|
|
12
|
-
"import": "./dist/json-msg.es.mjs",
|
|
13
|
-
"require": "./dist/json-msg.cjs.js"
|
|
14
|
-
},
|
|
15
|
-
"./package.json": "./package.json"
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist/json-msg.cjs.js",
|
|
19
|
-
"dist/json-msg.es.mjs",
|
|
20
|
-
"dist/json_msg+ack.d.ts"
|
|
21
|
-
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "node src/ajv-gen-validate.cjs && rollup --config",
|
|
24
|
-
"script": "node --experimental-json-modules tests/json-msg.test.mjs",
|
|
25
|
-
"test": "jasmine --config=jasmine.json",
|
|
26
|
-
"clean": "del-cli dist && del-cli src/validate-esm.mjs && echo OK"
|
|
27
|
-
},
|
|
28
|
-
"repository": {
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "git+https://gitlab.com/interface-x/npm-json-msg.git"
|
|
31
|
-
},
|
|
32
|
-
"keywords": [
|
|
33
|
-
"json"
|
|
34
|
-
],
|
|
35
|
-
"author": "K.Nevelsteen, PhD",
|
|
36
|
-
"license": "ISC",
|
|
37
|
-
"bugs": {
|
|
38
|
-
"url": "https://gitlab.com/interface-x/npm-json-msg.git/-/issues"
|
|
39
|
-
},
|
|
40
|
-
"homepage": "https://gitlab.com/interface-x/npm-json-msg.git#readme",
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"@knev/bitlogr": "^3.
|
|
43
|
-
"ajv": "^8.17.1",
|
|
44
|
-
"uuid": "^
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@rollup/plugin-commonjs": "^29.0.0",
|
|
48
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
49
|
-
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
50
|
-
"@rollup/plugin-typescript": "^12.3.0",
|
|
51
|
-
"@types/
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@rootintf/json-msg",
|
|
3
|
+
"version": "4.0.2-api.4",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/json-msg.cjs.js",
|
|
6
|
+
"module": "dist/json-msg.es.mjs",
|
|
7
|
+
"browser": "dist/json-msg.es.mjs",
|
|
8
|
+
"types": "dist/json_msg+ack.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/json_msg+ack.d.ts",
|
|
12
|
+
"import": "./dist/json-msg.es.mjs",
|
|
13
|
+
"require": "./dist/json-msg.cjs.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/json-msg.cjs.js",
|
|
19
|
+
"dist/json-msg.es.mjs",
|
|
20
|
+
"dist/json_msg+ack.d.ts"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "node src/ajv-gen-validate.cjs && rollup --config",
|
|
24
|
+
"script": "node --experimental-json-modules tests/json-msg.test.mjs",
|
|
25
|
+
"test": "jasmine --config=jasmine.json",
|
|
26
|
+
"clean": "del-cli dist && del-cli src/validate-esm.mjs && echo OK"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://gitlab.com/interface-x/npm-json-msg.git"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"json"
|
|
34
|
+
],
|
|
35
|
+
"author": "K.Nevelsteen, PhD",
|
|
36
|
+
"license": "ISC",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://gitlab.com/interface-x/npm-json-msg.git/-/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://gitlab.com/interface-x/npm-json-msg.git#readme",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@knev/bitlogr": "^3.4.8",
|
|
43
|
+
"ajv": "^8.17.1",
|
|
44
|
+
"uuid": "^14.0.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
48
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
49
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
50
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
51
|
+
"@types/node": "^24.10.1",
|
|
52
|
+
"del-cli": "^7.0.0",
|
|
53
|
+
"jasmine": "^6.3.0",
|
|
54
|
+
"rollup": "^4.53.3",
|
|
55
|
+
"tslib": "^2.8.1",
|
|
56
|
+
"typescript": "^5.9.3"
|
|
57
|
+
}
|
|
58
|
+
}
|