@rootintf/json-msg 1.1.5 → 2.1.6
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/README.md +43 -43
- package/antora-docs/antora.yml +5 -5
- package/antora-docs/modules/ROOT/pages/index.adoc +76 -76
- package/dist/ajv-gen-validate.d.cts +1 -0
- package/dist/json-msg.cjs.js +188 -172
- package/dist/json-msg.es.mjs +186 -170
- package/dist/json_msg+ack.d.ts +15 -0
- package/dist/validate-esm.d.mts +47 -0
- package/jasmine.json +6 -6
- package/package.json +14 -8
- package/rollup.config.mjs +36 -23
- package/schema/schema_JSON_Msg.json +38 -0
- package/src/ajv-gen-validate.cjs +28 -31
- package/src/declarations.d.ts +1 -0
- package/src/json_msg+ack.ts +96 -0
- package/src/validate-esm.mjs +1 -1
- package/tests/json_msg+ack.spec.mjs +113 -80
- package/tsconfig.json +115 -0
- package/schema/schema_Msg.json +0 -10
- package/schema/schema_MsgAck_msg.json +0 -15
- package/schema/schema_Msg_msg.json +0 -6
- package/src/json_msg+ack.mjs +0 -93
package/dist/json-msg.es.mjs
CHANGED
|
@@ -1,4 +1,114 @@
|
|
|
1
|
-
|
|
1
|
+
import { LOGR, l_array } from '@knev/bitlogr';
|
|
2
|
+
|
|
3
|
+
const schema_Msg = validate18;
|
|
4
|
+
function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate18.evaluated; if (evaluated0.dynamicProps) {
|
|
5
|
+
evaluated0.props = undefined;
|
|
6
|
+
} if (evaluated0.dynamicItems) {
|
|
7
|
+
evaluated0.items = undefined;
|
|
8
|
+
} {
|
|
9
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
10
|
+
let missing0;
|
|
11
|
+
if ((((data.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))) {
|
|
12
|
+
validate18.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (data.id !== undefined) {
|
|
17
|
+
const _errs1 = errors;
|
|
18
|
+
if (typeof data.id !== "string") {
|
|
19
|
+
validate18.errors = [{ instancePath: instancePath + "/id", schemaPath: "#/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
var valid0 = _errs1 === errors;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
var valid0 = true;
|
|
26
|
+
}
|
|
27
|
+
if (valid0) {
|
|
28
|
+
if (data.dt !== undefined) {
|
|
29
|
+
const _errs3 = errors;
|
|
30
|
+
if (typeof data.dt !== "string") {
|
|
31
|
+
validate18.errors = [{ instancePath: instancePath + "/dt", schemaPath: "#/properties/dt/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
var valid0 = _errs3 === errors;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
var valid0 = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
validate18.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
} validate18.errors = vErrors; return errors === 0; }
|
|
47
|
+
validate18.evaluated = { "props": { "id": true, "dt": true }, "dynamicProps": false, "dynamicItems": false };
|
|
48
|
+
const schema_MsgEffect = validate19;
|
|
49
|
+
function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate19.evaluated; if (evaluated0.dynamicProps) {
|
|
50
|
+
evaluated0.props = undefined;
|
|
51
|
+
} if (evaluated0.dynamicItems) {
|
|
52
|
+
evaluated0.items = undefined;
|
|
53
|
+
} {
|
|
54
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
55
|
+
let missing0;
|
|
56
|
+
if ((data._cause === undefined) && (missing0 = "_cause")) {
|
|
57
|
+
validate19.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
validate19.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
} validate19.errors = vErrors; return errors === 0; }
|
|
66
|
+
validate19.evaluated = { "dynamicProps": false, "dynamicItems": false };
|
|
67
|
+
const schema_MsgAckEffect = validate20;
|
|
68
|
+
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
|
|
69
|
+
evaluated0.props = undefined;
|
|
70
|
+
} if (evaluated0.dynamicItems) {
|
|
71
|
+
evaluated0.items = undefined;
|
|
72
|
+
} {
|
|
73
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
74
|
+
let missing0;
|
|
75
|
+
if ((data.ack === undefined) && (missing0 = "ack")) {
|
|
76
|
+
validate20.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
if (data.ack !== undefined) {
|
|
81
|
+
let data0 = data.ack;
|
|
82
|
+
{
|
|
83
|
+
if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
|
|
84
|
+
let missing1;
|
|
85
|
+
if ((data0.ok === undefined) && (missing1 = "ok")) {
|
|
86
|
+
validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
if (data0.ok !== undefined) {
|
|
91
|
+
if (typeof data0.ok !== "boolean") {
|
|
92
|
+
validate20.errors = [{ instancePath: instancePath + "/ack/ok", schemaPath: "#/properties/ack/properties/ok/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
validate20.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
} validate20.errors = vErrors; return errors === 0; }
|
|
111
|
+
validate20.evaluated = { "props": { "ack": true }, "dynamicProps": false, "dynamicItems": false };
|
|
2
112
|
|
|
3
113
|
const byteToHex = [];
|
|
4
114
|
for (let i = 0; i < 256; ++i) {
|
|
@@ -42,10 +152,7 @@ function rng() {
|
|
|
42
152
|
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
43
153
|
var native = { randomUUID };
|
|
44
154
|
|
|
45
|
-
function
|
|
46
|
-
if (native.randomUUID && true && !options) {
|
|
47
|
-
return native.randomUUID();
|
|
48
|
-
}
|
|
155
|
+
function _v4(options, buf, offset) {
|
|
49
156
|
options = options || {};
|
|
50
157
|
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
51
158
|
if (rnds.length < 16) {
|
|
@@ -55,177 +162,86 @@ function v4(options, buf, offset) {
|
|
|
55
162
|
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
56
163
|
return unsafeStringify(rnds);
|
|
57
164
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
function handler_default_( /* ... */ ) {
|
|
65
|
-
// https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
|
|
66
|
-
var args = Array.prototype.slice.call(arguments);
|
|
67
|
-
console.log.apply(console, args);
|
|
165
|
+
function v4(options, buf, offset) {
|
|
166
|
+
if (native.randomUUID && true && !options) {
|
|
167
|
+
return native.randomUUID();
|
|
168
|
+
}
|
|
169
|
+
return _v4(options);
|
|
68
170
|
}
|
|
69
171
|
|
|
70
172
|
//-------------------------------------------------------------------------------------------------
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
throw new Error('obj must be an object');
|
|
77
|
-
|
|
78
|
-
let bigInt = BigInt(0);
|
|
79
|
-
for (const [k,v] of Object.entries(obj)) {
|
|
80
|
-
if ( ( ignore || v ) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
|
|
81
|
-
bigInt|= BigInt( obj_labels[k] );
|
|
82
|
-
// console.log('0b'+ bigInt.toString(2) );
|
|
83
|
-
}
|
|
84
|
-
return bigInt;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// console.log(l_toBigInt_({},{}))
|
|
88
|
-
|
|
89
|
-
const LOGR = (function () {
|
|
90
|
-
let _instance; // Private variable to hold the single instance
|
|
91
|
-
|
|
92
|
-
function _create_instance() {
|
|
93
|
-
// Private state (replacing constructor properties)
|
|
94
|
-
let _handler_log = handler_default_;
|
|
95
|
-
let _obj_labels = undefined;
|
|
96
|
-
let _Bint_toggled = BigInt(0);
|
|
97
|
-
|
|
98
|
-
function _log_fxn(nr_logged, argsFn /* args */) {
|
|
99
|
-
if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
|
|
100
|
-
return false;
|
|
101
|
-
|
|
102
|
-
const args = argsFn();
|
|
103
|
-
_handler_log.apply(this, args);
|
|
104
|
-
// _handler_log.apply(this, args);
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
set handler(fx) {
|
|
110
|
-
_handler_log = fx;
|
|
111
|
-
},
|
|
112
|
-
get handler() {
|
|
113
|
-
return _handler_log;
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
get labels() { return _obj_labels; },
|
|
117
|
-
set labels(obj) {
|
|
118
|
-
_obj_labels = obj;
|
|
119
|
-
_Bint_toggled = BigInt(0);
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
// put= function(label, abbrv) {
|
|
123
|
-
// let name= __name(label);
|
|
124
|
-
// _labels[name]= label[name];
|
|
125
|
-
// console.log(_labels);
|
|
126
|
-
// }
|
|
127
|
-
|
|
128
|
-
get toggled() { return _Bint_toggled; },
|
|
129
|
-
set toggled(obj_toggled) {
|
|
130
|
-
_Bint_toggled= l_toBigInt_(_obj_labels, obj_toggled);
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
log(nr_logged, argsFn) {
|
|
134
|
-
|
|
135
|
-
return _log_fxn.call(this, nr_logged, argsFn); // Pass the thunk
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Public interface
|
|
141
|
-
return {
|
|
142
|
-
get_instance() {
|
|
143
|
-
if (!_instance) {
|
|
144
|
-
_instance = _create_instance(); // Lazy initialization
|
|
145
|
-
}
|
|
146
|
-
return _instance;
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
})();
|
|
151
|
-
|
|
152
|
-
let LOGR_= LOGR.get_instance();
|
|
153
|
-
const log_= LOGR_.log;
|
|
154
|
-
|
|
155
|
-
const l_= {
|
|
156
|
-
VALIDATION : 0b1 << 0,
|
|
157
|
-
};
|
|
158
|
-
LOGR_.labels= l_;
|
|
159
|
-
|
|
173
|
+
const LOGR_ = LOGR.get_instance();
|
|
174
|
+
const logr_ = LOGR_.create({ labels: l_array(['VALIDATION', 'DROPS', 'HANDLERS']) });
|
|
175
|
+
const l_ = logr_.l;
|
|
176
|
+
// console.log('File location:', import.meta.url, '[Implementation]');
|
|
177
|
+
//-------------------------------------------------------------------------------------------------
|
|
160
178
|
// TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
|
|
161
|
-
|
|
162
179
|
// "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
|
|
163
|
-
var JSON_Msg = (function() {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
var JSON_Msg = (function () {
|
|
181
|
+
return {
|
|
182
|
+
merge: function (json) {
|
|
183
|
+
return Object.assign({
|
|
184
|
+
id: v4(),
|
|
185
|
+
referer: null,
|
|
186
|
+
dt: new Date().toISOString()
|
|
187
|
+
}, json || {});
|
|
188
|
+
},
|
|
189
|
+
validate: function (json) {
|
|
190
|
+
const b_valid = schema_Msg(json);
|
|
191
|
+
if (!b_valid)
|
|
192
|
+
logr_.log(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
|
|
193
|
+
return b_valid;
|
|
194
|
+
},
|
|
195
|
+
// TODO: requires a separate ajv module require, and JTD specific schema
|
|
196
|
+
// https://ajv.js.org/guide/getting-started.html#parsing-and-serializing-json
|
|
197
|
+
// static #ajv_parse_= ajv.compileParser(this.#schema_json_Msg);
|
|
198
|
+
// static parse(json) {
|
|
199
|
+
// return this.#ajv_parse_(json);
|
|
200
|
+
// }
|
|
201
|
+
};
|
|
185
202
|
})();
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
203
|
+
var JSON_MsgEffect = (function () {
|
|
204
|
+
return {
|
|
205
|
+
create_with_cause_merge: function (msg_cause, json) {
|
|
206
|
+
const _cause = msg_cause;
|
|
207
|
+
return Object.assign(JSON_Msg.merge(json), { _cause });
|
|
208
|
+
},
|
|
209
|
+
validate: function (json) {
|
|
210
|
+
if (!JSON_Msg.validate(json))
|
|
211
|
+
return false;
|
|
212
|
+
const b_valid = schema_MsgEffect(json);
|
|
213
|
+
if (!b_valid)
|
|
214
|
+
logr_.log(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
|
|
215
|
+
return b_valid;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
201
218
|
})();
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
219
|
+
var JSON_MsgAck = (function () {
|
|
220
|
+
return {
|
|
221
|
+
create_with_cause_Ok: function (msg_cause, b_ok = true) {
|
|
222
|
+
return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
|
|
223
|
+
ack: {
|
|
224
|
+
"ok": b_ok,
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
create_with_cause_Expired: function (msg_cause) {
|
|
229
|
+
return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
|
|
230
|
+
ack: {
|
|
231
|
+
"ok": false,
|
|
232
|
+
"expired": true
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
validate: function (json) {
|
|
237
|
+
if (!JSON_MsgEffect.validate(json))
|
|
238
|
+
return false;
|
|
239
|
+
const b_valid = schema_MsgAckEffect(json);
|
|
240
|
+
if (!b_valid)
|
|
241
|
+
logr_.log(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
|
|
242
|
+
return b_valid;
|
|
243
|
+
}
|
|
244
|
+
};
|
|
229
245
|
})();
|
|
230
246
|
|
|
231
|
-
export { JSON_Msg,
|
|
247
|
+
export { JSON_Msg, JSON_MsgAck, JSON_MsgEffect, logr_ as logr };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const logr_: any;
|
|
2
|
+
declare var JSON_Msg: {
|
|
3
|
+
merge: (json: any) => any;
|
|
4
|
+
validate: (json: any) => boolean;
|
|
5
|
+
};
|
|
6
|
+
declare var JSON_MsgEffect: {
|
|
7
|
+
create_with_cause_merge: (msg_cause: any, json: any) => any;
|
|
8
|
+
validate: (json: any) => boolean;
|
|
9
|
+
};
|
|
10
|
+
declare var JSON_MsgAck: {
|
|
11
|
+
create_with_cause_Ok: (msg_cause: any, b_ok?: boolean) => any;
|
|
12
|
+
create_with_cause_Expired: (msg_cause: any) => any;
|
|
13
|
+
validate: (json: any) => boolean;
|
|
14
|
+
};
|
|
15
|
+
export { JSON_Msg, JSON_MsgEffect, JSON_MsgAck, logr_ as logr };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function schema_Msg(data: any, { instancePath, parentData, parentDataProperty, rootData, dynamicAnchors }?: {
|
|
2
|
+
instancePath?: string;
|
|
3
|
+
rootData?: any;
|
|
4
|
+
dynamicAnchors?: {};
|
|
5
|
+
}): boolean;
|
|
6
|
+
export namespace schema_Msg {
|
|
7
|
+
namespace evaluated {
|
|
8
|
+
namespace props {
|
|
9
|
+
let id: boolean;
|
|
10
|
+
let dt: boolean;
|
|
11
|
+
}
|
|
12
|
+
let dynamicProps: boolean;
|
|
13
|
+
let dynamicItems: boolean;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function schema_MsgEffect(data: any, { instancePath, parentData, parentDataProperty, rootData, dynamicAnchors }?: {
|
|
17
|
+
instancePath?: string;
|
|
18
|
+
rootData?: any;
|
|
19
|
+
dynamicAnchors?: {};
|
|
20
|
+
}): boolean;
|
|
21
|
+
export namespace schema_MsgEffect {
|
|
22
|
+
export namespace evaluated_1 {
|
|
23
|
+
let dynamicProps_1: boolean;
|
|
24
|
+
export { dynamicProps_1 as dynamicProps };
|
|
25
|
+
let dynamicItems_1: boolean;
|
|
26
|
+
export { dynamicItems_1 as dynamicItems };
|
|
27
|
+
}
|
|
28
|
+
export { evaluated_1 as evaluated };
|
|
29
|
+
}
|
|
30
|
+
export function schema_MsgAckEffect(data: any, { instancePath, parentData, parentDataProperty, rootData, dynamicAnchors }?: {
|
|
31
|
+
instancePath?: string;
|
|
32
|
+
rootData?: any;
|
|
33
|
+
dynamicAnchors?: {};
|
|
34
|
+
}): boolean;
|
|
35
|
+
export namespace schema_MsgAckEffect {
|
|
36
|
+
export namespace evaluated_2 {
|
|
37
|
+
export namespace props_1 {
|
|
38
|
+
let ack: boolean;
|
|
39
|
+
}
|
|
40
|
+
export { props_1 as props };
|
|
41
|
+
let dynamicProps_2: boolean;
|
|
42
|
+
export { dynamicProps_2 as dynamicProps };
|
|
43
|
+
let dynamicItems_2: boolean;
|
|
44
|
+
export { dynamicItems_2 as dynamicItems };
|
|
45
|
+
}
|
|
46
|
+
export { evaluated_2 as evaluated };
|
|
47
|
+
}
|
package/jasmine.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"spec_dir": "tests",
|
|
3
|
-
"spec_files": [
|
|
4
|
-
"**/*[sS]pec.?(m)js",
|
|
5
|
-
"!**/*nospec.js"
|
|
6
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"spec_dir": "tests",
|
|
3
|
+
"spec_files": [
|
|
4
|
+
"**/*[sS]pec.?(m)js",
|
|
5
|
+
"!**/*nospec.js"
|
|
6
|
+
]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rootintf/json-msg",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.1.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/json-msg.cjs.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
6
7
|
"browser": "dist/json-msg.es.mjs",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"build": "node src/ajv-gen-validate.cjs && rollup --config",
|
|
@@ -24,17 +25,22 @@
|
|
|
24
25
|
},
|
|
25
26
|
"homepage": "https://gitlab.com/interface-x/npm-json-msg.git#readme",
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@knev/bitlogr": "^
|
|
28
|
+
"@knev/bitlogr": "^3.1.3",
|
|
28
29
|
"ajv": "^8.17.1",
|
|
29
|
-
"uuid": "^
|
|
30
|
+
"uuid": "^13.0.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@rollup/plugin-commonjs": "^
|
|
33
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
33
34
|
"@rollup/plugin-json": "^6.1.0",
|
|
34
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
35
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
36
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
37
|
+
"@types/ajv": "^1.0.4",
|
|
38
|
+
"@types/node": "^24.10.1",
|
|
35
39
|
"ajv-cli": "^5.0.0",
|
|
36
|
-
"del-cli": "^
|
|
37
|
-
"jasmine": "^5.
|
|
38
|
-
"rollup": "^4.
|
|
40
|
+
"del-cli": "^7.0.0",
|
|
41
|
+
"jasmine": "^5.13.0",
|
|
42
|
+
"rollup": "^4.53.3",
|
|
43
|
+
"tslib": "^2.8.1",
|
|
44
|
+
"typescript": "^5.9.3"
|
|
39
45
|
}
|
|
40
46
|
}
|
package/rollup.config.mjs
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
4
|
-
import json from '@rollup/plugin-json';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
|
|
2
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
4
|
+
import json from '@rollup/plugin-json';
|
|
5
|
+
import typescript from '@rollup/plugin-typescript';
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
input: 'src/json_msg+ack.ts',
|
|
10
|
+
output: {
|
|
11
|
+
file: 'dist/json-msg.es.mjs',
|
|
12
|
+
format: 'es'
|
|
13
|
+
},
|
|
14
|
+
plugins: [
|
|
15
|
+
resolve(),
|
|
16
|
+
commonjs(),
|
|
17
|
+
json(),
|
|
18
|
+
typescript({ tsconfig: './tsconfig.json' })
|
|
19
|
+
],
|
|
20
|
+
external: ['@knev/bitlogr'], // Don't bundle these
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
input: 'src/json_msg+ack.ts',
|
|
24
|
+
output: {
|
|
25
|
+
file: 'dist/json-msg.cjs.js',
|
|
26
|
+
format: 'cjs'
|
|
27
|
+
},
|
|
28
|
+
plugins: [
|
|
29
|
+
resolve(),
|
|
30
|
+
commonjs(),
|
|
31
|
+
json(),
|
|
32
|
+
typescript({ tsconfig: './tsconfig.json' })
|
|
33
|
+
],
|
|
34
|
+
external: ['@knev/bitlogr'], // Don't bundle these
|
|
35
|
+
}
|
|
36
|
+
|
|
24
37
|
];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
{
|
|
3
|
+
"$id" : "https://root-interface.se/protocols/JSON_Msg",
|
|
4
|
+
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
5
|
+
"schemas": {
|
|
6
|
+
"https://root-interface.se/protocols/JSON_Msg/Msg" : {
|
|
7
|
+
"$id" : "https://root-interface.se/protocols/JSON_Msg/Msg",
|
|
8
|
+
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
9
|
+
"type" : "object",
|
|
10
|
+
"required" : ["id", "referer", "dt"],
|
|
11
|
+
"properties" : {
|
|
12
|
+
"id" : { "type" : "string"},
|
|
13
|
+
"dt" : { "type" : "string" }
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"https://root-interface.se/protocols/JSON_Msg/Msg_effect" : {
|
|
17
|
+
"$id" : "https://root-interface.se/protocols/JSON_Msg/MsgEffect",
|
|
18
|
+
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
19
|
+
"type" : "object",
|
|
20
|
+
"required" : ["_cause"]
|
|
21
|
+
},
|
|
22
|
+
"https://root-interface.se/protocols/JSON_Msg/MsgAck_effect" : {
|
|
23
|
+
"$id" : "https://root-interface.se/protocols/JSON_Msg/MsgAckEffect",
|
|
24
|
+
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
25
|
+
"type" : "object",
|
|
26
|
+
"required" : ["ack"],
|
|
27
|
+
"properties" : {
|
|
28
|
+
"ack" : {
|
|
29
|
+
"type" : "object",
|
|
30
|
+
"required" : ["ok"],
|
|
31
|
+
"properties" : {
|
|
32
|
+
"ok" : { "type" : "boolean" }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|