@rootintf/protocol-2phw 2.3.4-api.2 → 3.0.13-api.2
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 +384 -1
- package/dist/generated/iface-TwoPhW/index.d.mts +25 -0
- package/dist/generated/iface-TwoPhW/validate.d.cts +76 -0
- package/dist/generated/iface-TwoPhW/validate.d.mts +75 -0
- package/dist/twoPhW.cjs.js +419 -974
- package/dist/twoPhW.d.ts +51 -36
- package/dist/twoPhW.es.mjs +403 -970
- package/package.json +31 -17
- package/src/generated/.gitattributes +4 -0
- package/src/generated/iface-TwoPhW/index.cjs +26 -0
- package/src/generated/iface-TwoPhW/index.d.cts +25 -0
- package/src/generated/iface-TwoPhW/index.d.mts +25 -0
- package/src/generated/iface-TwoPhW/index.d.ts +25 -0
- package/src/generated/iface-TwoPhW/index.mjs +23 -0
- package/src/generated/iface-TwoPhW/package.json +36 -0
- package/src/generated/iface-TwoPhW/schema/schema_TwoPhW.json +131 -0
- package/src/generated/iface-TwoPhW/validate.cjs +1 -0
- package/src/generated/iface-TwoPhW/validate.mjs +1 -0
- package/src/generated/iface-introspection/index.cjs +13 -0
- package/src/generated/iface-introspection/index.d.cts +6 -0
- package/src/generated/iface-introspection/index.d.mts +6 -0
- package/src/generated/iface-introspection/index.d.ts +6 -0
- package/src/generated/iface-introspection/index.mjs +10 -0
- package/src/generated/iface-introspection/package.json +30 -0
- package/src/schema-cache/.gitattributes +4 -0
- package/src/schema-cache/5fdbd096ad99962b7e3d77cde8bd355fe180c859f35a61cfd07ee36b96c6700a.json +131 -0
- package/src/twoPhW.ts +770 -833
- package/.claude/scheduled_tasks.lock +0 -1
- package/antora-docs/antora.yml +0 -2
- package/antora-docs/modules/npm/pages/index.adoc +0 -7
- package/dev.txt +0 -23
- package/dist/ajv-gen-validate.d.cts +0 -1
- package/dist/validate-esm.d.mts +0 -48
- package/jasmine.json +0 -7
- package/rollup.config.mjs +0 -40
- package/schema/schema_2PhW.json +0 -61
- package/src/ajv-gen-validate.cjs +0 -40
- package/src/validate-esm.mjs +0 -1
- package/tests/twoPhW-new.spec.mjs +0 -850
- package/tsconfig.json +0 -115
package/dist/twoPhW.cjs.js
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var jsonMsg = require('@rootintf/json-msg');
|
|
4
|
+
var bitlogr = require('@knev/bitlogr');
|
|
3
5
|
var eventlog = require('@rootintf/eventlog');
|
|
4
6
|
|
|
5
|
-
const
|
|
6
|
-
function
|
|
7
|
+
const _v_JSON_MsgWarp = validate18;
|
|
8
|
+
function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate18.evaluated; if (evaluated0.dynamicProps) {
|
|
7
9
|
evaluated0.props = undefined;
|
|
8
10
|
} if (evaluated0.dynamicItems) {
|
|
9
11
|
evaluated0.items = undefined;
|
|
10
12
|
} {
|
|
11
13
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
12
14
|
let missing0;
|
|
13
|
-
if ((data.warp === undefined) && (missing0 = "warp")) {
|
|
14
|
-
|
|
15
|
+
if (((data.warp === undefined) && (missing0 = "warp")) || ((data["2PhW"] === undefined) && (missing0 = "2PhW"))) {
|
|
16
|
+
validate18.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
15
17
|
return false;
|
|
16
18
|
}
|
|
17
19
|
else {
|
|
18
20
|
if (data.warp !== undefined) {
|
|
19
21
|
let data0 = data.warp;
|
|
20
|
-
const
|
|
22
|
+
const _errs3 = errors;
|
|
21
23
|
{
|
|
22
24
|
if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
|
|
23
25
|
let missing1;
|
|
24
26
|
if (((((data0.id === undefined) && (missing1 = "id")) || ((data0.user === undefined) && (missing1 = "user"))) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))) || ((data0.ttl_msec === undefined) && (missing1 = "ttl_msec"))) {
|
|
25
|
-
|
|
27
|
+
validate18.errors = [{ instancePath: instancePath + "/warp", schemaPath: "#/properties/warp/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
26
28
|
return false;
|
|
27
29
|
}
|
|
28
30
|
else {
|
|
29
31
|
if (data0.id !== undefined) {
|
|
30
|
-
const
|
|
32
|
+
const _errs5 = errors;
|
|
31
33
|
if (typeof data0.id !== "string") {
|
|
32
|
-
|
|
34
|
+
validate18.errors = [{ instancePath: instancePath + "/warp/id", schemaPath: "#/properties/warp/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
33
35
|
return false;
|
|
34
36
|
}
|
|
35
|
-
var valid1 =
|
|
37
|
+
var valid1 = _errs5 === errors;
|
|
36
38
|
}
|
|
37
39
|
else {
|
|
38
40
|
var valid1 = true;
|
|
@@ -40,24 +42,32 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
40
42
|
if (valid1) {
|
|
41
43
|
if (data0.ttl_msec !== undefined) {
|
|
42
44
|
let data2 = data0.ttl_msec;
|
|
43
|
-
const
|
|
45
|
+
const _errs7 = errors;
|
|
44
46
|
if (!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))) {
|
|
45
|
-
|
|
47
|
+
validate18.errors = [{ instancePath: instancePath + "/warp/ttl_msec", schemaPath: "#/properties/warp/properties/ttl_msec/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
|
|
46
48
|
return false;
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
{
|
|
51
|
+
if ((typeof data2 == "number") && (isFinite(data2))) {
|
|
52
|
+
if (data2 <= 0 || isNaN(data2)) {
|
|
53
|
+
validate18.errors = [{ instancePath: instancePath + "/warp/ttl_msec", schemaPath: "#/properties/warp/properties/ttl_msec/exclusiveMinimum", keyword: "exclusiveMinimum", params: { comparison: ">", limit: 0 }, message: "must be > 0" }];
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
var valid1 = _errs7 === errors;
|
|
49
59
|
}
|
|
50
60
|
else {
|
|
51
61
|
var valid1 = true;
|
|
52
62
|
}
|
|
53
63
|
if (valid1) {
|
|
54
64
|
if (data0.instantaneous !== undefined) {
|
|
55
|
-
const
|
|
65
|
+
const _errs9 = errors;
|
|
56
66
|
if (typeof data0.instantaneous !== "boolean") {
|
|
57
|
-
|
|
67
|
+
validate18.errors = [{ instancePath: instancePath + "/warp/instantaneous", schemaPath: "#/properties/warp/properties/instantaneous/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
|
|
58
68
|
return false;
|
|
59
69
|
}
|
|
60
|
-
var valid1 =
|
|
70
|
+
var valid1 = _errs9 === errors;
|
|
61
71
|
}
|
|
62
72
|
else {
|
|
63
73
|
var valid1 = true;
|
|
@@ -67,23 +77,23 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
67
77
|
}
|
|
68
78
|
}
|
|
69
79
|
else {
|
|
70
|
-
|
|
80
|
+
validate18.errors = [{ instancePath: instancePath + "/warp", schemaPath: "#/properties/warp/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
71
81
|
return false;
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
|
-
var valid0 =
|
|
84
|
+
var valid0 = _errs3 === errors;
|
|
75
85
|
}
|
|
76
86
|
else {
|
|
77
87
|
var valid0 = true;
|
|
78
88
|
}
|
|
79
89
|
if (valid0) {
|
|
80
90
|
if (data["2PhW"] !== undefined) {
|
|
81
|
-
const
|
|
91
|
+
const _errs11 = errors;
|
|
82
92
|
if ("2" !== data["2PhW"]) {
|
|
83
|
-
|
|
93
|
+
validate18.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
|
|
84
94
|
return false;
|
|
85
95
|
}
|
|
86
|
-
var valid0 =
|
|
96
|
+
var valid0 = _errs11 === errors;
|
|
87
97
|
}
|
|
88
98
|
else {
|
|
89
99
|
var valid0 = true;
|
|
@@ -92,84 +102,61 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
104
|
else {
|
|
95
|
-
|
|
105
|
+
validate18.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
96
106
|
return false;
|
|
97
107
|
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const
|
|
108
|
+
} validate18.errors = vErrors; return errors === 0; }
|
|
109
|
+
validate18.evaluated = { "props": { "warp": true, "2PhW": true }, "dynamicProps": false, "dynamicItems": false };
|
|
110
|
+
const _v_JSON_AckWarp = validate20;
|
|
101
111
|
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
|
|
102
112
|
evaluated0.props = undefined;
|
|
103
113
|
} if (evaluated0.dynamicItems) {
|
|
104
114
|
evaluated0.items = undefined;
|
|
105
|
-
} {
|
|
115
|
+
} if (errors === 0) {
|
|
106
116
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
107
117
|
let missing0;
|
|
108
|
-
if ((data.
|
|
118
|
+
if (((data.ack === undefined) && (missing0 = "ack")) || ((data["2PhW"] === undefined) && (missing0 = "2PhW"))) {
|
|
109
119
|
validate20.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
110
120
|
return false;
|
|
111
121
|
}
|
|
112
122
|
else {
|
|
113
|
-
if (data.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
let missing1;
|
|
119
|
-
if (((data0.ok === undefined) && (missing1 = "ok")) || ((data0.rtt_msec === undefined) && (missing1 = "rtt_msec"))) {
|
|
120
|
-
validate20.errors = [{ instancePath: instancePath + "/engage", schemaPath: "#/properties/engage/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
if (data0.ok !== undefined) {
|
|
125
|
-
const _errs3 = errors;
|
|
126
|
-
if (typeof data0.ok !== "boolean") {
|
|
127
|
-
validate20.errors = [{ instancePath: instancePath + "/engage/ok", schemaPath: "#/properties/engage/properties/ok/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
var valid1 = _errs3 === errors;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
var valid1 = true;
|
|
134
|
-
}
|
|
135
|
-
if (valid1) {
|
|
136
|
-
if (data0.rtt_msec !== undefined) {
|
|
137
|
-
let data2 = data0.rtt_msec;
|
|
138
|
-
const _errs5 = errors;
|
|
139
|
-
if (!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))) {
|
|
140
|
-
validate20.errors = [{ instancePath: instancePath + "/engage/rtt_msec", schemaPath: "#/properties/engage/properties/rtt_msec/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
var valid1 = _errs5 === errors;
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
var valid1 = true;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
validate20.errors = [{ instancePath: instancePath + "/engage", schemaPath: "#/properties/engage/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
123
|
+
if (data._cause !== undefined) {
|
|
124
|
+
const _errs3 = errors;
|
|
125
|
+
if (!(validate18(data._cause, { instancePath: instancePath + "/_cause", parentData: data, parentDataProperty: "_cause", rootData, dynamicAnchors }))) {
|
|
126
|
+
vErrors = vErrors === null ? validate18.errors : vErrors.concat(validate18.errors);
|
|
127
|
+
errors = vErrors.length;
|
|
155
128
|
}
|
|
156
|
-
var valid0 =
|
|
129
|
+
var valid0 = _errs3 === errors;
|
|
157
130
|
}
|
|
158
131
|
else {
|
|
159
132
|
var valid0 = true;
|
|
160
133
|
}
|
|
161
134
|
if (valid0) {
|
|
162
|
-
if (data
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
135
|
+
if (data.ack !== undefined) {
|
|
136
|
+
let data1 = data.ack;
|
|
137
|
+
const _errs4 = errors;
|
|
138
|
+
if (!(data1 && typeof data1 == "object" && !Array.isArray(data1))) {
|
|
139
|
+
validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
166
140
|
return false;
|
|
167
141
|
}
|
|
168
|
-
var valid0 =
|
|
142
|
+
var valid0 = _errs4 === errors;
|
|
169
143
|
}
|
|
170
144
|
else {
|
|
171
145
|
var valid0 = true;
|
|
172
146
|
}
|
|
147
|
+
if (valid0) {
|
|
148
|
+
if (data["2PhW"] !== undefined) {
|
|
149
|
+
const _errs6 = errors;
|
|
150
|
+
if ("2" !== data["2PhW"]) {
|
|
151
|
+
validate20.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
var valid0 = _errs6 === errors;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
var valid0 = true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
173
160
|
}
|
|
174
161
|
}
|
|
175
162
|
}
|
|
@@ -178,757 +165,242 @@ function validate20(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
178
165
|
return false;
|
|
179
166
|
}
|
|
180
167
|
} validate20.errors = vErrors; return errors === 0; }
|
|
181
|
-
validate20.evaluated = { "props": { "
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (labels.length === 0)
|
|
194
|
-
return 1; // Empty object case, start at 1
|
|
195
|
-
const value_max = Math.max(...labels);
|
|
196
|
-
if (value_max <= 0)
|
|
197
|
-
return 1;
|
|
198
|
-
const bit_highest = Math.floor(Math.log2(value_max));
|
|
199
|
-
return 1 << (bit_highest + 1);
|
|
200
|
-
}
|
|
201
|
-
function l_array_(arr_labels, start = 1) {
|
|
202
|
-
if (!Array.isArray(arr_labels))
|
|
203
|
-
throw new Error('arr_labels must be an array');
|
|
204
|
-
if (!Number.isSafeInteger(start) || start < 0)
|
|
205
|
-
throw new Error('start must be a safe, non-negative integer');
|
|
206
|
-
return Object.freeze(arr_labels.reduce((acc, key, index) => {
|
|
207
|
-
acc[key] = start << index;
|
|
208
|
-
return acc;
|
|
209
|
-
}, {}));
|
|
210
|
-
}
|
|
211
|
-
function l_concat_(obj_labels, arg) {
|
|
212
|
-
if (!obj_labels || typeof obj_labels !== 'object')
|
|
213
|
-
throw new Error('obj_labels must be an object');
|
|
214
|
-
const obj_1label = Object.values(obj_labels);
|
|
215
|
-
if (!obj_1label.every(v => typeof v === 'number' && Number.isFinite(v)))
|
|
216
|
-
throw new Error('All values must be finite numbers');
|
|
217
|
-
if (!arg || (typeof arg !== 'object' && !Array.isArray(arg)))
|
|
218
|
-
throw new Error('arg must be an object or array');
|
|
219
|
-
if (Array.isArray(arg)) {
|
|
220
|
-
const len = l_length_(obj_labels);
|
|
221
|
-
const arr_labels_new = l_array_(arg, len);
|
|
222
|
-
return l_concat_(obj_labels, arr_labels_new);
|
|
223
|
-
}
|
|
224
|
-
const next_pos = l_length_(obj_labels);
|
|
225
|
-
const arg_entries = Object.entries(arg);
|
|
226
|
-
const result = Object.create(null);
|
|
227
|
-
Object.entries(obj_labels).forEach(([k, v]) => {
|
|
228
|
-
if (k !== '__proto__' && k !== 'constructor')
|
|
229
|
-
result[k] = v;
|
|
230
|
-
});
|
|
231
|
-
let min_arg = Infinity;
|
|
232
|
-
for (const [, value] of arg_entries) {
|
|
233
|
-
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
234
|
-
continue; // Skip non-numeric
|
|
235
|
-
if (value > 0 && value < min_arg)
|
|
236
|
-
min_arg = value;
|
|
237
|
-
}
|
|
238
|
-
// Shift only if min_arg is less than next_pos
|
|
239
|
-
const shift = min_arg === Infinity || min_arg >= next_pos
|
|
240
|
-
? 0
|
|
241
|
-
: Math.floor(Math.log2(next_pos / min_arg));
|
|
242
|
-
for (const [key, value] of arg_entries) {
|
|
243
|
-
if (!(key in result)) {
|
|
244
|
-
result[key] = value === 0 ? 0 : value << shift;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return Object.freeze(result);
|
|
248
|
-
}
|
|
249
|
-
function l_merge_(obj_labels1, obj_labels2) {
|
|
250
|
-
if (!obj_labels1 || typeof obj_labels1 !== 'object')
|
|
251
|
-
throw new Error('obj_labels must be an object');
|
|
252
|
-
const obj_1label1 = Object.values(obj_labels1);
|
|
253
|
-
if (!obj_1label1.every(v => typeof v === 'number' && Number.isFinite(v)))
|
|
254
|
-
throw new Error('All values must be finite numbers');
|
|
255
|
-
if (!obj_labels2 || typeof obj_labels2 !== 'object')
|
|
256
|
-
throw new Error('obj_labels must be an object');
|
|
257
|
-
const obj_1label2 = Object.values(obj_labels2);
|
|
258
|
-
if (!obj_1label2.every(v => typeof v === 'number' && Number.isFinite(v)))
|
|
259
|
-
throw new Error('All values must be finite numbers');
|
|
260
|
-
const result = Object.create(null);
|
|
261
|
-
Object.entries(obj_labels1).forEach(([k, v]) => {
|
|
262
|
-
if (k !== '__proto__' && k !== 'constructor')
|
|
263
|
-
result[k] = v;
|
|
264
|
-
});
|
|
265
|
-
const set_values = new Set(Object.values(obj_labels1)); // Track all used bit values
|
|
266
|
-
// Find the highest bit position to start shifting from if needed
|
|
267
|
-
const value_highest = Math.max(0, ...Array.from(set_values));
|
|
268
|
-
let next_shift = value_highest ? Math.floor(Math.log2(value_highest)) + 1 : 0;
|
|
269
|
-
// Process second set
|
|
270
|
-
for (const [key, value] of Object.entries(obj_labels2)) {
|
|
271
|
-
if (key in result) {
|
|
272
|
-
// Same key: Values must match
|
|
273
|
-
if (result[key] !== value) {
|
|
274
|
-
throw new Error(`Key '${key}' has conflicting values: ${result[key]} (obj_labels1) vs ${value} (obj_labels2)`);
|
|
275
|
-
}
|
|
276
|
-
// No action needed if values match, already in result
|
|
168
|
+
validate20.evaluated = { "props": { "_cause": true, "ack": true, "2PhW": true }, "dynamicProps": false, "dynamicItems": false };
|
|
169
|
+
const _v_JSON_EffEngage = validate22;
|
|
170
|
+
function validate22(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate22.evaluated; if (evaluated0.dynamicProps) {
|
|
171
|
+
evaluated0.props = undefined;
|
|
172
|
+
} if (evaluated0.dynamicItems) {
|
|
173
|
+
evaluated0.items = undefined;
|
|
174
|
+
} if (errors === 0) {
|
|
175
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
176
|
+
let missing0;
|
|
177
|
+
if (((data.engage === undefined) && (missing0 = "engage")) || ((data["2PhW"] === undefined) && (missing0 = "2PhW"))) {
|
|
178
|
+
validate22.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
179
|
+
return false;
|
|
277
180
|
}
|
|
278
181
|
else {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
182
|
+
if (data._cause !== undefined) {
|
|
183
|
+
const _errs3 = errors;
|
|
184
|
+
if (!(validate18(data._cause, { instancePath: instancePath + "/_cause", parentData: data, parentDataProperty: "_cause", rootData, dynamicAnchors }))) {
|
|
185
|
+
vErrors = vErrors === null ? validate18.errors : vErrors.concat(validate18.errors);
|
|
186
|
+
errors = vErrors.length;
|
|
187
|
+
}
|
|
188
|
+
var valid0 = _errs3 === errors;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
var valid0 = true;
|
|
192
|
+
}
|
|
193
|
+
if (valid0) {
|
|
194
|
+
if (data.engage !== undefined) {
|
|
195
|
+
let data1 = data.engage;
|
|
196
|
+
const _errs4 = errors;
|
|
197
|
+
if (errors === _errs4) {
|
|
198
|
+
if (data1 && typeof data1 == "object" && !Array.isArray(data1)) {
|
|
199
|
+
let missing1;
|
|
200
|
+
if (((data1.ok === undefined) && (missing1 = "ok")) || ((data1.rtt_msec === undefined) && (missing1 = "rtt_msec"))) {
|
|
201
|
+
validate22.errors = [{ instancePath: instancePath + "/engage", schemaPath: "#/properties/engage/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
if (data1.ok !== undefined) {
|
|
206
|
+
const _errs6 = errors;
|
|
207
|
+
if (typeof data1.ok !== "boolean") {
|
|
208
|
+
validate22.errors = [{ instancePath: instancePath + "/engage/ok", schemaPath: "#/properties/engage/properties/ok/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
var valid1 = _errs6 === errors;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
var valid1 = true;
|
|
215
|
+
}
|
|
216
|
+
if (valid1) {
|
|
217
|
+
if (data1.rtt_msec !== undefined) {
|
|
218
|
+
let data3 = data1.rtt_msec;
|
|
219
|
+
const _errs8 = errors;
|
|
220
|
+
if (!(((typeof data3 == "number") && (!(data3 % 1) && !isNaN(data3))) && (isFinite(data3)))) {
|
|
221
|
+
validate22.errors = [{ instancePath: instancePath + "/engage/rtt_msec", schemaPath: "#/properties/engage/properties/rtt_msec/type", keyword: "type", params: { type: "integer" }, message: "must be integer" }];
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
if (errors === _errs8) {
|
|
225
|
+
if ((typeof data3 == "number") && (isFinite(data3))) {
|
|
226
|
+
if (data3 < 0 || isNaN(data3)) {
|
|
227
|
+
validate22.errors = [{ instancePath: instancePath + "/engage/rtt_msec", schemaPath: "#/properties/engage/properties/rtt_msec/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" }];
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
var valid1 = _errs8 === errors;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
var valid1 = true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
validate22.errors = [{ instancePath: instancePath + "/engage", schemaPath: "#/properties/engage/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
var valid0 = _errs4 === errors;
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
var valid0 = true;
|
|
249
|
+
}
|
|
250
|
+
if (valid0) {
|
|
251
|
+
if (data["2PhW"] !== undefined) {
|
|
252
|
+
const _errs10 = errors;
|
|
253
|
+
if ("2" !== data["2PhW"]) {
|
|
254
|
+
validate22.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
var valid0 = _errs10 === errors;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
var valid0 = true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
284
263
|
}
|
|
285
|
-
if (maxIterations <= 0)
|
|
286
|
-
throw new Error('Too many collisions in l_merge_');
|
|
287
|
-
result[key] = value_new;
|
|
288
|
-
set_values.add(value_new);
|
|
289
264
|
}
|
|
290
265
|
}
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
function l_LL_(obj, x) {
|
|
294
|
-
if (!obj || typeof obj !== 'object')
|
|
295
|
-
throw new Error('obj must be an object');
|
|
296
|
-
if (!Number.isSafeInteger(x) || x < 0)
|
|
297
|
-
throw new Error('Shift value must be a safe, non-negative integer');
|
|
298
|
-
const obj_new = {};
|
|
299
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
300
|
-
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
301
|
-
continue; // Skip non-numeric
|
|
302
|
-
obj_new[k] = v << x;
|
|
303
|
-
}
|
|
304
|
-
return Object.freeze(obj_new);
|
|
305
|
-
}
|
|
306
|
-
function l_RR_(obj, x) {
|
|
307
|
-
if (!obj || typeof obj !== 'object')
|
|
308
|
-
throw new Error('obj must be an object');
|
|
309
|
-
if (!Number.isSafeInteger(x) || x < 0)
|
|
310
|
-
throw new Error('Shift value must be a safe, non-negative integer');
|
|
311
|
-
const obj_new = {};
|
|
312
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
313
|
-
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
314
|
-
continue; // Skip non-numeric
|
|
315
|
-
obj_new[k] = v >> x;
|
|
316
|
-
}
|
|
317
|
-
return Object.freeze(obj_new);
|
|
318
|
-
}
|
|
319
|
-
function l_assert_(actual, required) {
|
|
320
|
-
if (!actual || typeof actual !== 'object')
|
|
321
|
-
return false;
|
|
322
|
-
if (!required || typeof required !== 'object')
|
|
266
|
+
else {
|
|
267
|
+
validate22.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
323
268
|
return false;
|
|
324
|
-
const actualEntries = Object.entries(actual);
|
|
325
|
-
const requiredEntries = Object.entries(required);
|
|
326
|
-
// if (actualEntries.length === 0 && expectedEntries.length > 0)
|
|
327
|
-
// return false;
|
|
328
|
-
const actualValues = new Set();
|
|
329
|
-
for (const [, v] of actualEntries) {
|
|
330
|
-
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
331
|
-
return false;
|
|
332
|
-
actualValues.add(v);
|
|
333
269
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
270
|
+
} validate22.errors = vErrors; return errors === 0; }
|
|
271
|
+
validate22.evaluated = { "props": { "_cause": true, "engage": true, "2PhW": true }, "dynamicProps": false, "dynamicItems": false };
|
|
272
|
+
const _v_JSON_AckEngage = validate24;
|
|
273
|
+
function validate24(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate24.evaluated; if (evaluated0.dynamicProps) {
|
|
274
|
+
evaluated0.props = undefined;
|
|
275
|
+
} if (evaluated0.dynamicItems) {
|
|
276
|
+
evaluated0.items = undefined;
|
|
277
|
+
} if (errors === 0) {
|
|
278
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
279
|
+
let missing0;
|
|
280
|
+
if (((data.ack === undefined) && (missing0 = "ack")) || ((data["2PhW"] === undefined) && (missing0 = "2PhW"))) {
|
|
281
|
+
validate24.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
337
282
|
return false;
|
|
338
|
-
if (k in actual) {
|
|
339
|
-
if (actual[k] !== v)
|
|
340
|
-
return false;
|
|
341
283
|
}
|
|
342
284
|
else {
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
return true;
|
|
351
|
-
}
|
|
352
|
-
//-------------------------------------------------------------------------------------------------
|
|
353
|
-
function handler_default_( /* ... */) {
|
|
354
|
-
// https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
|
|
355
|
-
var args = Array.prototype.slice.call(arguments);
|
|
356
|
-
console.log.apply(console, args);
|
|
357
|
-
}
|
|
358
|
-
function l_toBigInt_(obj_labels, obj, ignore = false) {
|
|
359
|
-
if (!obj_labels || typeof obj_labels !== 'object')
|
|
360
|
-
throw new Error('obj_labels must be an object');
|
|
361
|
-
if (!obj || typeof obj !== 'object')
|
|
362
|
-
throw new Error('obj must be an object');
|
|
363
|
-
let bigint_l = BigInt(0);
|
|
364
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
365
|
-
if ((ignore || v) && obj_labels[k] !== undefined && typeof obj_labels[k] === 'number')
|
|
366
|
-
bigint_l |= BigInt(obj_labels[k]);
|
|
367
|
-
// console.log('0b'+ bigInt.toString(2) );
|
|
368
|
-
}
|
|
369
|
-
return bigint_l;
|
|
370
|
-
}
|
|
371
|
-
function lRef(initial) {
|
|
372
|
-
if (arguments.length === 0 || initial === undefined) {
|
|
373
|
-
return undefined;
|
|
374
|
-
}
|
|
375
|
-
let value = initial;
|
|
376
|
-
return {
|
|
377
|
-
get: () => value,
|
|
378
|
-
set: (newVal) => { value = newVal; }
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
/*
|
|
382
|
-
const l_ = {
|
|
383
|
-
get VALIDATION() { return logr_.lref.get().VALIDATION; }
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function createBitFlags(ref) {
|
|
387
|
-
// Create a proxy so that any property access computes the current bit
|
|
388
|
-
return new Proxy({}, {
|
|
389
|
-
get(target, prop, receiver) {
|
|
390
|
-
const positions = ref.get(); // get current { VALIDATION: n, ... }
|
|
391
|
-
const position = positions[prop]; // e.g., positions['VALIDATION']
|
|
392
|
-
|
|
393
|
-
if (position === undefined) {
|
|
394
|
-
// Optional: warn or return 0 for unknown keys
|
|
395
|
-
console.warn(`Unknown bitflag key: ${String(prop)}`);
|
|
396
|
-
return 0;
|
|
285
|
+
if (data._cause !== undefined) {
|
|
286
|
+
const _errs3 = errors;
|
|
287
|
+
if (!(validate22(data._cause, { instancePath: instancePath + "/_cause", parentData: data, parentDataProperty: "_cause", rootData, dynamicAnchors }))) {
|
|
288
|
+
vErrors = vErrors === null ? validate22.errors : vErrors.concat(validate22.errors);
|
|
289
|
+
errors = vErrors.length;
|
|
290
|
+
}
|
|
291
|
+
var valid0 = _errs3 === errors;
|
|
397
292
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
type BitPositions = Record<string, number>;
|
|
417
|
-
|
|
418
|
-
function createBitFlags<T extends BitPositions>(ref: { get: () => T }) {
|
|
419
|
-
return new Proxy({} as { [K in keyof T]: number }, {
|
|
420
|
-
get(target, prop: string | symbol) {
|
|
421
|
-
if (typeof prop !== 'string') return undefined;
|
|
422
|
-
const positions = ref.get();
|
|
423
|
-
const position = positions[prop as keyof T];
|
|
424
|
-
if (position === undefined) return 0;
|
|
425
|
-
return 1 << position;
|
|
426
|
-
},
|
|
427
|
-
ownKeys() {
|
|
428
|
-
return Object.keys(ref.get());
|
|
429
|
-
},
|
|
430
|
-
getOwnPropertyDescriptor() {
|
|
431
|
-
return { enumerable: true, configurable: true };
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
*/
|
|
436
|
-
function create_Referenced_l_(ref) {
|
|
437
|
-
return new Proxy({}, {
|
|
438
|
-
get(target, prop) {
|
|
439
|
-
if (typeof prop !== 'string')
|
|
440
|
-
return undefined;
|
|
441
|
-
// if (prop === 'get') {
|
|
442
|
-
// return () => {
|
|
443
|
-
// const positions = ref.get();
|
|
444
|
-
// const result: Partial<Record<keyof T, number>> = {};
|
|
445
|
-
// for (const key in positions) {
|
|
446
|
-
// result[key as keyof T] = positions[key];
|
|
447
|
-
// }
|
|
448
|
-
// return result as Record<keyof T, number>;
|
|
449
|
-
// };
|
|
450
|
-
// }
|
|
451
|
-
if (prop === 'get')
|
|
452
|
-
return () => ref.get();
|
|
453
|
-
const positions = ref.get();
|
|
454
|
-
const value = positions[prop];
|
|
455
|
-
if (value === undefined)
|
|
456
|
-
return 0;
|
|
457
|
-
return value;
|
|
458
|
-
},
|
|
459
|
-
ownKeys() {
|
|
460
|
-
return Object.keys(ref.get());
|
|
461
|
-
},
|
|
462
|
-
getOwnPropertyDescriptor() {
|
|
463
|
-
return { enumerable: true, configurable: true };
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
const LOGR = (function () {
|
|
468
|
-
let _instance; // Private variable to hold the single instance
|
|
469
|
-
// Module-level state would work - but only when the module is loaded once.
|
|
470
|
-
// Your bundler is currently bundling @knev/bitlogr into your distribution file,
|
|
471
|
-
// creating a second copy. The Global Symbol approach would work around this,
|
|
472
|
-
// but it's treating the symptom, not the cause.
|
|
473
|
-
const GLOBAL_KEY = Symbol.for('@knev/bitlogr/LOGR');
|
|
474
|
-
// The real issue is your build configuration bundling dependencies that should remain external.
|
|
475
|
-
// rollup.config.mjs: external: ['@knev/bitlogr', 'uuid'], // Don't bundle these
|
|
476
|
-
function _create_instance() {
|
|
477
|
-
const _id = Math.random();
|
|
478
|
-
if (globalThis.LOGR_ENABLED ?? true)
|
|
479
|
-
console.log('creating LOGR instance:', _id);
|
|
480
|
-
// Private state (replacing constructor properties)
|
|
481
|
-
let _Bint_toggled = BigInt(0);
|
|
482
|
-
let _handler_log = handler_default_;
|
|
483
|
-
function _log_fxn(nr_logged, argsFn /* args */) {
|
|
484
|
-
// console.log('_log_fxn: ', BigInt(nr_logged), _Bint_toggled, (BigInt(nr_logged) & _Bint_toggled));
|
|
485
|
-
if ((BigInt(nr_logged) & _Bint_toggled) === BigInt(0))
|
|
486
|
-
return;
|
|
487
|
-
const args = argsFn();
|
|
488
|
-
_handler_log.apply(this, args);
|
|
489
|
-
}
|
|
490
|
-
return {
|
|
491
|
-
_id, // for testing
|
|
492
|
-
get handler() { return _handler_log; },
|
|
493
|
-
set handler(fx) {
|
|
494
|
-
_handler_log = fx;
|
|
495
|
-
},
|
|
496
|
-
get toggled() { return _Bint_toggled; },
|
|
497
|
-
// toggle(obj_labels, obj_toggled) {
|
|
498
|
-
// _Bint_toggled= l_toBigInt_(obj_labels, obj_toggled);
|
|
499
|
-
// },
|
|
500
|
-
toggle(labels, obj_toggled) {
|
|
501
|
-
const obj_labels = typeof labels?.get === 'function'
|
|
502
|
-
? labels.get()
|
|
503
|
-
: labels;
|
|
504
|
-
// console.log('obj_labels', obj_labels)
|
|
505
|
-
_Bint_toggled = l_toBigInt_(obj_labels, obj_toggled);
|
|
506
|
-
},
|
|
507
|
-
// Core internal log function (exposed only to created loggers)
|
|
508
|
-
_log_fxn,
|
|
509
|
-
create(options = {}) {
|
|
510
|
-
// This constant will be replaced at build time
|
|
511
|
-
if (!(globalThis.LOGR_ENABLED ?? true)) {
|
|
512
|
-
return {
|
|
513
|
-
_obj_labels: undefined, // optional: keep shape compatible if needed
|
|
514
|
-
log: () => { }, // does nothing
|
|
515
|
-
raw: () => { }, // does nothing
|
|
516
|
-
};
|
|
293
|
+
else {
|
|
294
|
+
var valid0 = true;
|
|
295
|
+
}
|
|
296
|
+
if (valid0) {
|
|
297
|
+
if (data.ack !== undefined) {
|
|
298
|
+
let data1 = data.ack;
|
|
299
|
+
const _errs4 = errors;
|
|
300
|
+
if (!(data1 && typeof data1 == "object" && !Array.isArray(data1))) {
|
|
301
|
+
validate24.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
var valid0 = _errs4 === errors;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
var valid0 = true;
|
|
517
308
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
get: () => this._lref_labels?.get() || {}
|
|
527
|
-
});
|
|
528
|
-
},
|
|
529
|
-
get lref() { return this._lref_labels; },
|
|
530
|
-
set lref(lref_labels_new) {
|
|
531
|
-
this._lref_labels = lref_labels_new;
|
|
532
|
-
},
|
|
533
|
-
log(nr_logged, argsFn) {
|
|
534
|
-
// This constant will be replaced at build time
|
|
535
|
-
if (!(globalThis.LOGR_ENABLED ?? true))
|
|
536
|
-
return;
|
|
537
|
-
_log_fxn.call(this, nr_logged, argsFn);
|
|
538
|
-
},
|
|
539
|
-
// Optional shorthand for common cases
|
|
540
|
-
raw(...args) {
|
|
541
|
-
_handler_log.apply(this, args);
|
|
309
|
+
if (valid0) {
|
|
310
|
+
if (data["2PhW"] !== undefined) {
|
|
311
|
+
const _errs6 = errors;
|
|
312
|
+
if ("2" !== data["2PhW"]) {
|
|
313
|
+
validate24.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/_v/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
var valid0 = _errs6 === errors;
|
|
542
317
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
// Public interface
|
|
549
|
-
return {
|
|
550
|
-
get_instance() {
|
|
551
|
-
if (!(globalThis.LOGR_USE_GLOBAL_KEY ?? true)) {
|
|
552
|
-
if (!_instance)
|
|
553
|
-
_instance = _create_instance(); // Lazy initialization
|
|
554
|
-
return _instance;
|
|
318
|
+
else {
|
|
319
|
+
var valid0 = true;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
555
322
|
}
|
|
556
|
-
if (!globalThis[GLOBAL_KEY])
|
|
557
|
-
globalThis[GLOBAL_KEY] = _create_instance();
|
|
558
|
-
return globalThis[GLOBAL_KEY];
|
|
559
|
-
},
|
|
560
|
-
// For testing only - reset the singleton
|
|
561
|
-
_reset_for_testing() {
|
|
562
|
-
delete globalThis[GLOBAL_KEY];
|
|
563
323
|
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
lRef: lRef,
|
|
572
|
-
l_LL: l_LL_,
|
|
573
|
-
l_RR: l_RR_,
|
|
574
|
-
l_array: l_array_,
|
|
575
|
-
l_assert: l_assert_,
|
|
576
|
-
l_concat: l_concat_,
|
|
577
|
-
l_length: l_length_,
|
|
578
|
-
l_merge: l_merge_
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
function getAugmentedNamespace(n) {
|
|
582
|
-
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
|
|
583
|
-
var f = n.default;
|
|
584
|
-
if (typeof f == "function") {
|
|
585
|
-
var a = function a () {
|
|
586
|
-
var isInstance = false;
|
|
587
|
-
try {
|
|
588
|
-
isInstance = this instanceof a;
|
|
589
|
-
} catch {}
|
|
590
|
-
if (isInstance) {
|
|
591
|
-
return Reflect.construct(f, arguments, this.constructor);
|
|
592
|
-
}
|
|
593
|
-
return f.apply(this, arguments);
|
|
594
|
-
};
|
|
595
|
-
a.prototype = f.prototype;
|
|
596
|
-
} else a = {};
|
|
597
|
-
Object.defineProperty(a, '__esModule', {value: true});
|
|
598
|
-
Object.keys(n).forEach(function (k) {
|
|
599
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
600
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
601
|
-
enumerable: true,
|
|
602
|
-
get: function () {
|
|
603
|
-
return n[k];
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
});
|
|
607
|
-
return a;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
var jsonMsg_cjs = {};
|
|
611
|
-
|
|
612
|
-
var require$$0 = /*@__PURE__*/getAugmentedNamespace(logr_es);
|
|
613
|
-
|
|
614
|
-
var hasRequiredJsonMsg_cjs;
|
|
615
|
-
|
|
616
|
-
function requireJsonMsg_cjs () {
|
|
617
|
-
if (hasRequiredJsonMsg_cjs) return jsonMsg_cjs;
|
|
618
|
-
hasRequiredJsonMsg_cjs = 1;
|
|
619
|
-
|
|
620
|
-
var bitlogr = require$$0;
|
|
621
|
-
|
|
622
|
-
const schema_Msg = validate18;
|
|
623
|
-
function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate18.evaluated; if (evaluated0.dynamicProps) {
|
|
624
|
-
evaluated0.props = undefined;
|
|
625
|
-
} if (evaluated0.dynamicItems) {
|
|
626
|
-
evaluated0.items = undefined;
|
|
627
|
-
} {
|
|
628
|
-
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
629
|
-
let missing0;
|
|
630
|
-
if ((((data.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))) {
|
|
631
|
-
validate18.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
632
|
-
return false;
|
|
633
|
-
}
|
|
634
|
-
else {
|
|
635
|
-
if (data.id !== undefined) {
|
|
636
|
-
const _errs1 = errors;
|
|
637
|
-
if (typeof data.id !== "string") {
|
|
638
|
-
validate18.errors = [{ instancePath: instancePath + "/id", schemaPath: "#/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
639
|
-
return false;
|
|
640
|
-
}
|
|
641
|
-
var valid0 = _errs1 === errors;
|
|
642
|
-
}
|
|
643
|
-
else {
|
|
644
|
-
var valid0 = true;
|
|
645
|
-
}
|
|
646
|
-
if (valid0) {
|
|
647
|
-
if (data.dt !== undefined) {
|
|
648
|
-
const _errs3 = errors;
|
|
649
|
-
if (typeof data.dt !== "string") {
|
|
650
|
-
validate18.errors = [{ instancePath: instancePath + "/dt", schemaPath: "#/properties/dt/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
651
|
-
return false;
|
|
652
|
-
}
|
|
653
|
-
var valid0 = _errs3 === errors;
|
|
654
|
-
}
|
|
655
|
-
else {
|
|
656
|
-
var valid0 = true;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
662
|
-
validate18.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
663
|
-
return false;
|
|
664
|
-
}
|
|
665
|
-
} validate18.errors = vErrors; return errors === 0; }
|
|
666
|
-
validate18.evaluated = { "props": { "id": true, "dt": true }, "dynamicProps": false, "dynamicItems": false };
|
|
667
|
-
const schema_MsgEffect = validate19;
|
|
668
|
-
function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate19.evaluated; if (evaluated0.dynamicProps) {
|
|
669
|
-
evaluated0.props = undefined;
|
|
670
|
-
} if (evaluated0.dynamicItems) {
|
|
671
|
-
evaluated0.items = undefined;
|
|
672
|
-
} {
|
|
673
|
-
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
674
|
-
let missing0;
|
|
675
|
-
if ((data._cause === undefined) && (missing0 = "_cause")) {
|
|
676
|
-
validate19.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
677
|
-
return false;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
else {
|
|
681
|
-
validate19.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
682
|
-
return false;
|
|
683
|
-
}
|
|
684
|
-
} validate19.errors = vErrors; return errors === 0; }
|
|
685
|
-
validate19.evaluated = { "dynamicProps": false, "dynamicItems": false };
|
|
686
|
-
const schema_MsgAckEffect = validate20;
|
|
687
|
-
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
|
|
688
|
-
evaluated0.props = undefined;
|
|
689
|
-
} if (evaluated0.dynamicItems) {
|
|
690
|
-
evaluated0.items = undefined;
|
|
691
|
-
} {
|
|
692
|
-
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
693
|
-
let missing0;
|
|
694
|
-
if ((data.ack === undefined) && (missing0 = "ack")) {
|
|
695
|
-
validate20.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
696
|
-
return false;
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
699
|
-
if (data.ack !== undefined) {
|
|
700
|
-
let data0 = data.ack;
|
|
701
|
-
{
|
|
702
|
-
if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
|
|
703
|
-
let missing1;
|
|
704
|
-
if ((data0.ok === undefined) && (missing1 = "ok")) {
|
|
705
|
-
validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
706
|
-
return false;
|
|
707
|
-
}
|
|
708
|
-
else {
|
|
709
|
-
if (data0.ok !== undefined) {
|
|
710
|
-
if (typeof data0.ok !== "boolean") {
|
|
711
|
-
validate20.errors = [{ instancePath: instancePath + "/ack/ok", schemaPath: "#/properties/ack/properties/ok/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
|
|
712
|
-
return false;
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
else {
|
|
718
|
-
validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
719
|
-
return false;
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
else {
|
|
726
|
-
validate20.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
727
|
-
return false;
|
|
728
|
-
}
|
|
729
|
-
} validate20.errors = vErrors; return errors === 0; }
|
|
730
|
-
validate20.evaluated = { "props": { "ack": true }, "dynamicProps": false, "dynamicItems": false };
|
|
731
|
-
|
|
732
|
-
const byteToHex = [];
|
|
733
|
-
for (let i = 0; i < 256; ++i) {
|
|
734
|
-
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
735
|
-
}
|
|
736
|
-
function unsafeStringify(arr, offset = 0) {
|
|
737
|
-
return (byteToHex[arr[offset + 0]] +
|
|
738
|
-
byteToHex[arr[offset + 1]] +
|
|
739
|
-
byteToHex[arr[offset + 2]] +
|
|
740
|
-
byteToHex[arr[offset + 3]] +
|
|
741
|
-
'-' +
|
|
742
|
-
byteToHex[arr[offset + 4]] +
|
|
743
|
-
byteToHex[arr[offset + 5]] +
|
|
744
|
-
'-' +
|
|
745
|
-
byteToHex[arr[offset + 6]] +
|
|
746
|
-
byteToHex[arr[offset + 7]] +
|
|
747
|
-
'-' +
|
|
748
|
-
byteToHex[arr[offset + 8]] +
|
|
749
|
-
byteToHex[arr[offset + 9]] +
|
|
750
|
-
'-' +
|
|
751
|
-
byteToHex[arr[offset + 10]] +
|
|
752
|
-
byteToHex[arr[offset + 11]] +
|
|
753
|
-
byteToHex[arr[offset + 12]] +
|
|
754
|
-
byteToHex[arr[offset + 13]] +
|
|
755
|
-
byteToHex[arr[offset + 14]] +
|
|
756
|
-
byteToHex[arr[offset + 15]]).toLowerCase();
|
|
757
|
-
}
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
validate24.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
} validate24.errors = vErrors; return errors === 0; }
|
|
330
|
+
validate24.evaluated = { "props": { "_cause": true, "ack": true, "2PhW": true }, "dynamicProps": false, "dynamicItems": false };
|
|
758
331
|
|
|
759
|
-
|
|
760
|
-
const rnds8 = new Uint8Array(16);
|
|
761
|
-
function rng() {
|
|
762
|
-
if (!getRandomValues) {
|
|
763
|
-
if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
|
|
764
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
765
|
-
}
|
|
766
|
-
getRandomValues = crypto.getRandomValues.bind(crypto);
|
|
767
|
-
}
|
|
768
|
-
return getRandomValues(rnds8);
|
|
769
|
-
}
|
|
332
|
+
// GENERATED by iface-gen from schema_TwoPhW.json — DO NOT EDIT
|
|
770
333
|
|
|
771
|
-
|
|
772
|
-
var native = { randomUUID };
|
|
334
|
+
const VERSION = "2";
|
|
773
335
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
throw new Error('Random bytes length must be >= 16');
|
|
779
|
-
}
|
|
780
|
-
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
781
|
-
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
782
|
-
return unsafeStringify(rnds);
|
|
783
|
-
}
|
|
784
|
-
function v4(options, buf, offset) {
|
|
785
|
-
if (native.randomUUID && true && !options) {
|
|
786
|
-
return native.randomUUID();
|
|
787
|
-
}
|
|
788
|
-
return _v4(options);
|
|
789
|
-
}
|
|
336
|
+
const JSON_MsgWarp$1 = {
|
|
337
|
+
validate: _v_JSON_MsgWarp,
|
|
338
|
+
merge: (body) => jsonMsg.JSON_Msg.merge({ "warp": body, "2PhW": VERSION }),
|
|
339
|
+
};
|
|
790
340
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
const l_ = logr_.l;
|
|
795
|
-
// console.log('File location:', import.meta.url, '[Implementation]');
|
|
796
|
-
//-------------------------------------------------------------------------------------------------
|
|
797
|
-
// TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
|
|
798
|
-
// "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
|
|
799
|
-
var JSON_Msg = (function () {
|
|
800
|
-
return {
|
|
801
|
-
merge: function (json) {
|
|
802
|
-
return Object.assign({
|
|
803
|
-
id: v4(),
|
|
804
|
-
referer: null,
|
|
805
|
-
dt: new Date().toISOString()
|
|
806
|
-
}, json || {});
|
|
807
|
-
},
|
|
808
|
-
validate: function (json) {
|
|
809
|
-
const b_valid = schema_Msg(json);
|
|
810
|
-
if (!b_valid)
|
|
811
|
-
logr_.log(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
|
|
812
|
-
return b_valid;
|
|
813
|
-
},
|
|
814
|
-
// TODO: requires a separate ajv module require, and JTD specific schema
|
|
815
|
-
// https://ajv.js.org/guide/getting-started.html#parsing-and-serializing-json
|
|
816
|
-
// static #ajv_parse_= ajv.compileParser(this.#schema_json_Msg);
|
|
817
|
-
// static parse(json) {
|
|
818
|
-
// return this.#ajv_parse_(json);
|
|
819
|
-
// }
|
|
820
|
-
};
|
|
821
|
-
})();
|
|
822
|
-
var JSON_MsgEffect = (function () {
|
|
823
|
-
return {
|
|
824
|
-
create_with_cause_merge: function (msg_cause, json) {
|
|
825
|
-
const _cause = msg_cause;
|
|
826
|
-
return Object.assign(JSON_Msg.merge(json), { _cause });
|
|
827
|
-
},
|
|
828
|
-
validate: function (json) {
|
|
829
|
-
if (!JSON_Msg.validate(json))
|
|
830
|
-
return false;
|
|
831
|
-
const b_valid = schema_MsgEffect(json);
|
|
832
|
-
if (!b_valid)
|
|
833
|
-
logr_.log(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
|
|
834
|
-
return b_valid;
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
})();
|
|
838
|
-
var JSON_MsgAck = (function () {
|
|
839
|
-
return {
|
|
840
|
-
create_with_cause_Ok: function (msg_cause, b_ok = true) {
|
|
841
|
-
return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
|
|
842
|
-
ack: {
|
|
843
|
-
"ok": b_ok,
|
|
844
|
-
},
|
|
845
|
-
});
|
|
846
|
-
},
|
|
847
|
-
create_with_cause_Expired: function (msg_cause) {
|
|
848
|
-
return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
|
|
849
|
-
ack: {
|
|
850
|
-
"ok": false,
|
|
851
|
-
"expired": true
|
|
852
|
-
},
|
|
853
|
-
});
|
|
854
|
-
},
|
|
855
|
-
validate: function (json) {
|
|
856
|
-
if (!JSON_MsgEffect.validate(json))
|
|
857
|
-
return false;
|
|
858
|
-
const b_valid = schema_MsgAckEffect(json);
|
|
859
|
-
if (!b_valid)
|
|
860
|
-
logr_.log(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
|
|
861
|
-
return b_valid;
|
|
862
|
-
}
|
|
863
|
-
};
|
|
864
|
-
})();
|
|
341
|
+
const JSON_AckWarp$1 = {
|
|
342
|
+
validate: _v_JSON_AckWarp,
|
|
343
|
+
};
|
|
865
344
|
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
return jsonMsg_cjs;
|
|
871
|
-
}
|
|
345
|
+
const JSON_EffEngage$1 = {
|
|
346
|
+
validate: _v_JSON_EffEngage,
|
|
347
|
+
create_with_cause_merge: (cause, body) => jsonMsg.JSON_Eff.create_with_cause_merge(cause, { "engage": body, "2PhW": VERSION }),
|
|
348
|
+
};
|
|
872
349
|
|
|
873
|
-
|
|
350
|
+
const JSON_AckEngage$1 = {
|
|
351
|
+
validate: _v_JSON_AckEngage,
|
|
352
|
+
};
|
|
874
353
|
|
|
354
|
+
// The wire interface (validators, constructors, VERSION) is GENERATED by iface-gen from the pinned
|
|
355
|
+
// schema_TwoPhW.json (see ifacegenconfig.json; `npm run gen`) -- never hand-written here.
|
|
875
356
|
// interface Event extends Required<EventMinimal> {
|
|
876
357
|
// type : string;
|
|
877
358
|
// id : string | number;
|
|
878
359
|
// timeout_id : NodeJS.Timeout | null;
|
|
879
360
|
// };
|
|
880
|
-
const k_TTL = 20000;
|
|
881
361
|
//-------------------------------------------------------------------------------------------------
|
|
882
|
-
const obj_labels_merge_ =
|
|
883
|
-
const obj_labels_concat_ =
|
|
884
|
-
const lref_ = lRef(obj_labels_concat_);
|
|
885
|
-
|
|
362
|
+
const obj_labels_merge_ = bitlogr.l_merge(eventlog.logr.lref.get(), jsonMsg.logr.lref.get()); // VALIDATION : 4
|
|
363
|
+
const obj_labels_concat_ = bitlogr.l_concat(obj_labels_merge_, bitlogr.l_array(['HANDLERS', 'DROPS', 'PROTOCOL_STATE', 'RECVER', 'SENDER']));
|
|
364
|
+
const lref_ = bitlogr.lRef(obj_labels_concat_);
|
|
365
|
+
jsonMsg.logr.lref = lref_;
|
|
886
366
|
eventlog.logr.lref = lref_;
|
|
887
|
-
const LOGR_ = LOGR.get_instance();
|
|
367
|
+
const LOGR_ = bitlogr.LOGR.get_instance();
|
|
888
368
|
const logr_ = LOGR_.create(); // don't let create() make a new ref, assign lref_ from here
|
|
889
369
|
logr_.lref = lref_;
|
|
890
370
|
const l_ = logr_.l;
|
|
891
371
|
class Config {
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
372
|
+
// A step's callback is what makes the step this participant's to handle: with no callback set,
|
|
373
|
+
// the step's handler refuses it (returns false) before anything is logged. Every participant on
|
|
374
|
+
// the ME hears every exchange, so "no callback" is the normal case for a role it does not play.
|
|
375
|
+
_callback_msgWarp = null;
|
|
376
|
+
_callback_effEngage = null;
|
|
377
|
+
_callback_ackWarp = null;
|
|
378
|
+
_callback_ackEngage = null;
|
|
379
|
+
// "a step I sent was never answered inside its window", one per role: the sender's fires for its
|
|
380
|
+
// Warp / Engage, the receiver's for its AckWarp. A participant playing both roles keeps both.
|
|
381
|
+
_callback_sender_sent_expired;
|
|
382
|
+
_callback_receiver_sent_expired;
|
|
897
383
|
_callback_msgOptions;
|
|
898
384
|
constructor() {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
console.assert(false, 'callback_msgWarp uninitialized');
|
|
902
|
-
return false;
|
|
903
|
-
};
|
|
904
|
-
this._callback_msgEngage = (_msg, _json_msg) => {
|
|
905
|
-
console.assert(false, 'callback_msgEngage uninitialized');
|
|
906
|
-
return false;
|
|
385
|
+
this._callback_sender_sent_expired = (_msg, _json_msg) => {
|
|
386
|
+
console.assert(false, '_callback_sender_sent_expired uninitialized');
|
|
907
387
|
};
|
|
908
|
-
this.
|
|
909
|
-
console.assert(false, '
|
|
910
|
-
return false;
|
|
911
|
-
};
|
|
912
|
-
this._callback_msgAckEngage = (_msg, _json_msg) => {
|
|
913
|
-
console.assert(false, 'callback_msgAckEngage uninitialized');
|
|
914
|
-
return false;
|
|
915
|
-
};
|
|
916
|
-
this._callback_msg_sent_expired = (_msg, _json_msg) => {
|
|
917
|
-
console.assert(false, '_callback_msg_sent_expired uninitialized');
|
|
388
|
+
this._callback_receiver_sent_expired = (_msg, _json_msg) => {
|
|
389
|
+
console.assert(false, '_callback_receiver_sent_expired uninitialized');
|
|
918
390
|
};
|
|
919
391
|
this._callback_msgOptions = () => {
|
|
920
392
|
console.assert(false, 'callback_msgOptions uninitialized');
|
|
921
393
|
};
|
|
922
394
|
}
|
|
923
|
-
receiver(callback_msgWarp,
|
|
395
|
+
receiver(callback_msgWarp, callback_effEngage, callback_msg_sent_expired) {
|
|
924
396
|
this._callback_msgWarp = callback_msgWarp;
|
|
925
|
-
this.
|
|
926
|
-
this.
|
|
397
|
+
this._callback_effEngage = callback_effEngage;
|
|
398
|
+
this._callback_receiver_sent_expired = callback_msg_sent_expired;
|
|
927
399
|
}
|
|
928
|
-
sender(
|
|
929
|
-
this.
|
|
930
|
-
this.
|
|
931
|
-
this.
|
|
400
|
+
sender(callback_ackWarp, callback_ackEngage, callback_msg_sent_expired) {
|
|
401
|
+
this._callback_ackWarp = callback_ackWarp;
|
|
402
|
+
this._callback_ackEngage = callback_ackEngage;
|
|
403
|
+
this._callback_sender_sent_expired = callback_msg_sent_expired;
|
|
932
404
|
}
|
|
933
405
|
set callback_msgOptions(callback) {
|
|
934
406
|
this._callback_msgOptions = callback;
|
|
@@ -946,7 +418,7 @@ class Config {
|
|
|
946
418
|
// }
|
|
947
419
|
// })();
|
|
948
420
|
//-------------------------------------------------------------------------------------------------
|
|
949
|
-
|
|
421
|
+
const k_VERSION = VERSION;
|
|
950
422
|
// rtt_msec <= ttl_msec *2 => rtt_msec = ttl_msec *2
|
|
951
423
|
// t_ttl_rtt_(TTL, RTT) = t_ttl_rtt_(TTL, TTL *2) = TTL *2 + TTL *2 = TTL *4 MAX
|
|
952
424
|
function time_ttl_rtt_(ttl_msec, rtt_msec) {
|
|
@@ -957,10 +429,11 @@ function time_ttl_rtt_(ttl_msec, rtt_msec) {
|
|
|
957
429
|
console.assert(rtt_msec <= ttl_msec * 2, `t_ttl_rtt_: INVALID rtt_msec ttl_msec[${ttl_msec}] rtt_msec[${rtt_msec}]`);
|
|
958
430
|
return (ttl_msec * 2) + rtt_msec;
|
|
959
431
|
}
|
|
432
|
+
// not part of the generated interface (no schema yet)
|
|
960
433
|
var JSON_MsgOptions = (function () {
|
|
961
434
|
return {
|
|
962
435
|
create_with_cause_options: function (msg_cause, options) {
|
|
963
|
-
return
|
|
436
|
+
return jsonMsg.JSON_Eff.create_with_cause_merge(msg_cause, {
|
|
964
437
|
options: options,
|
|
965
438
|
"2PhW": k_VERSION
|
|
966
439
|
});
|
|
@@ -976,17 +449,18 @@ var JSON_MsgOptions = (function () {
|
|
|
976
449
|
}
|
|
977
450
|
};
|
|
978
451
|
})();
|
|
452
|
+
// Each JSON_* below is the generated namespace (validate + merge / create_with_cause_merge; the
|
|
453
|
+
// validators are delta-only: the base is validated upstream, in the responder chain) extended with
|
|
454
|
+
// what the schema cannot express: the protocol's own constructors.
|
|
979
455
|
var JSON_MsgWarp = (function () {
|
|
980
456
|
return {
|
|
457
|
+
...JSON_MsgWarp$1,
|
|
981
458
|
create_with_id_user_hyperport: function (json_warp_id, json_user, json_hyperport, nr_ttl_msec) {
|
|
982
|
-
return
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
ttl_msec: nr_ttl_msec
|
|
988
|
-
},
|
|
989
|
-
"2PhW": k_VERSION
|
|
459
|
+
return JSON_MsgWarp$1.merge({
|
|
460
|
+
id: json_warp_id,
|
|
461
|
+
user: json_user,
|
|
462
|
+
hyperport: json_hyperport,
|
|
463
|
+
ttl_msec: nr_ttl_msec
|
|
990
464
|
});
|
|
991
465
|
},
|
|
992
466
|
compare: function (json_L, json_R) {
|
|
@@ -999,92 +473,39 @@ var JSON_MsgWarp = (function () {
|
|
|
999
473
|
if (json_L.referer[1] !== json_R.referer[1])
|
|
1000
474
|
return false;
|
|
1001
475
|
return true;
|
|
1002
|
-
},
|
|
1003
|
-
validate: function (json_msg) {
|
|
1004
|
-
// if (! JSON_Msg.validate(json))
|
|
1005
|
-
// return false;
|
|
1006
|
-
if (!schema_MsgWarp(json_msg)) {
|
|
1007
|
-
logr_.log(l_.VALIDATION, () => ['JSON_MsgWarp: schema_MsgWarp_: ', schema_MsgWarp.errors]);
|
|
1008
|
-
return false;
|
|
1009
|
-
}
|
|
1010
|
-
return true;
|
|
1011
476
|
}
|
|
1012
477
|
};
|
|
1013
478
|
})();
|
|
1014
|
-
var
|
|
479
|
+
var JSON_EffEngage = (function () {
|
|
1015
480
|
return {
|
|
481
|
+
...JSON_EffEngage$1,
|
|
1016
482
|
create_with_Warp: function (json_msgWarp) {
|
|
1017
483
|
console.assert(json_msgWarp.ack === undefined, "Engage with a Warp, not an Ack");
|
|
1018
|
-
return
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
"rtt_msec": Date.now() - Date.parse(json_msgWarp.dt)
|
|
1022
|
-
},
|
|
1023
|
-
"2PhW": k_VERSION
|
|
484
|
+
return JSON_EffEngage$1.create_with_cause_merge(json_msgWarp, {
|
|
485
|
+
"ok": true,
|
|
486
|
+
"rtt_msec": Date.now() - Date.parse(json_msgWarp.dt)
|
|
1024
487
|
});
|
|
1025
|
-
},
|
|
1026
|
-
validate: function (json_msgEffect) {
|
|
1027
|
-
// if (! JSON_Msg_msg.validate(json))
|
|
1028
|
-
// return false;
|
|
1029
|
-
if (!JSON_MsgWarp.validate(json_msgEffect._cause))
|
|
1030
|
-
return false;
|
|
1031
|
-
if (!schema_MsgEngage(json_msgEffect)) {
|
|
1032
|
-
logr_.log(l_.VALIDATION, () => ['JSON_MsgEngage: schema_MsgEngage_: ', schema_MsgEngage.errors]);
|
|
1033
|
-
return false;
|
|
1034
|
-
}
|
|
1035
|
-
return true;
|
|
1036
488
|
}
|
|
1037
489
|
};
|
|
1038
490
|
})();
|
|
1039
|
-
|
|
491
|
+
// iface-gen emits no constructor for a JSON_Ack: build the base ack, stamp the protocol marker
|
|
492
|
+
var JSON_AckWarp = (function () {
|
|
1040
493
|
return {
|
|
1041
|
-
|
|
1042
|
-
// const json_msgAckWarp= structuredClone(json_msgAck);
|
|
1043
|
-
// json_msgAckWarp._cause= _cause;
|
|
1044
|
-
// return json_msgAckWarp;
|
|
1045
|
-
// }
|
|
494
|
+
...JSON_AckWarp$1,
|
|
1046
495
|
create_with_Warp_Ok: function (json_msgWarp, b_ok = true) {
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
return
|
|
1050
|
-
},
|
|
1051
|
-
// create_with_msgExpired : function( json_msgWarp ) {
|
|
1052
|
-
// const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgExpired( json_msgWarp )
|
|
1053
|
-
// json_msgAck_msg["2PhW"]= k_VERSION;
|
|
1054
|
-
// return json_msgAck_msg;
|
|
1055
|
-
// },
|
|
1056
|
-
validate: function (json_msgAck) {
|
|
1057
|
-
// if (! JSON_MsgAck_msg.validate(json))
|
|
1058
|
-
// return false;
|
|
1059
|
-
if (!JSON_MsgWarp.validate(json_msgAck._cause))
|
|
1060
|
-
return false;
|
|
1061
|
-
return true;
|
|
496
|
+
const json_ack = jsonMsg.JSON_Ack.create_with_cause_Ok(json_msgWarp, b_ok);
|
|
497
|
+
json_ack["2PhW"] = k_VERSION;
|
|
498
|
+
return json_ack;
|
|
1062
499
|
}
|
|
1063
500
|
};
|
|
1064
501
|
})();
|
|
1065
|
-
var
|
|
502
|
+
var JSON_AckEngage = (function () {
|
|
1066
503
|
return {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
create_with_Engage_Ok: function (json_msgEngage, b_ok = true) {
|
|
1073
|
-
const json_msgAck = jsonMsg_cjsExports.JSON_MsgAck.create_with_cause_Ok(json_msgEngage, b_ok);
|
|
1074
|
-
json_msgAck["2PhW"] = k_VERSION;
|
|
1075
|
-
return json_msgAck;
|
|
1076
|
-
},
|
|
1077
|
-
// create_with_msgExpired : function( json_msgEngage ) {
|
|
1078
|
-
// const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgExpired( json_msgEngage )
|
|
1079
|
-
// json_msgAck_msg["2PhW"]= k_VERSION;
|
|
1080
|
-
// return json_msgAck_msg;
|
|
1081
|
-
// },
|
|
1082
|
-
validate: function (json_msgAck) {
|
|
1083
|
-
// if (! JSON_MsgAck_msg.validate(json_msgAck_msg))
|
|
1084
|
-
// return false;
|
|
1085
|
-
if (!JSON_MsgEngage.validate(json_msgAck._cause))
|
|
1086
|
-
return false;
|
|
1087
|
-
return true;
|
|
504
|
+
...JSON_AckEngage$1,
|
|
505
|
+
create_with_Engage_Ok: function (json_effEngage, b_ok = true) {
|
|
506
|
+
const json_ack = jsonMsg.JSON_Ack.create_with_cause_Ok(json_effEngage, b_ok);
|
|
507
|
+
json_ack["2PhW"] = k_VERSION;
|
|
508
|
+
return json_ack;
|
|
1088
509
|
}
|
|
1089
510
|
};
|
|
1090
511
|
})();
|
|
@@ -1127,7 +548,7 @@ class StateState {
|
|
|
1127
548
|
class StateAckEngage extends StateState {
|
|
1128
549
|
constructor(idx_event, event) { super(idx_event, event); }
|
|
1129
550
|
get evt_AckEngage() { return this.event; }
|
|
1130
|
-
get
|
|
551
|
+
get json_ackEngage() { return this.json_msg; }
|
|
1131
552
|
canChangeState(_state_new) {
|
|
1132
553
|
return false;
|
|
1133
554
|
}
|
|
@@ -1135,38 +556,44 @@ class StateAckEngage extends StateState {
|
|
|
1135
556
|
class StateEngage extends StateState {
|
|
1136
557
|
constructor(idx_event, event) { super(idx_event, event); }
|
|
1137
558
|
get evt_Engage() { return this.event; }
|
|
1138
|
-
get
|
|
559
|
+
get json_effEngage() { return this.json_msg; }
|
|
1139
560
|
canChangeState(state_new) {
|
|
1140
561
|
if (false === state_new instanceof StateAckEngage)
|
|
1141
562
|
return false;
|
|
1142
563
|
// The Engage gets to live for THE WARP'S creation time + TTL*2 + RTT
|
|
1143
|
-
const json_msgWarp = this.
|
|
1144
|
-
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, this.
|
|
564
|
+
const json_msgWarp = this.json_effEngage._cause;
|
|
565
|
+
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, this.json_effEngage.engage.rtt_msec);
|
|
1145
566
|
logr_.log(l_.PROTOCOL_STATE, () => [`StateEngage: evt_AckEngage.dt@${state_new.evt_AckEngage.dt}, msgWarp.dt@${Date.parse(json_msgWarp.dt)} + ${timeout_ms}`]);
|
|
1146
567
|
if (state_new.evt_AckEngage.dt >= Date.parse(json_msgWarp.dt) + timeout_ms)
|
|
1147
568
|
return false;
|
|
1148
569
|
return true;
|
|
1149
570
|
}
|
|
1150
571
|
}
|
|
572
|
+
// Can a JSON_EffEngage follow this JSON_AckWarp? Not after a nack (it ends the exchange), and not
|
|
573
|
+
// after the ack of an instantaneous warp (single phase: the ack concludes it).
|
|
574
|
+
function isEngageAwaited_(json_ackWarp) {
|
|
575
|
+
return !!json_ackWarp.ack.ok && !json_ackWarp._cause.warp.instantaneous;
|
|
576
|
+
}
|
|
1151
577
|
class StateAckWarp extends StateState {
|
|
1152
578
|
constructor(idx_event, event) { super(idx_event, event); }
|
|
1153
579
|
get evt_AckWarp() { return this.event; }
|
|
1154
|
-
get
|
|
580
|
+
get json_ackWarp() { return this.json_msg; }
|
|
1155
581
|
canChangeState(state_new) {
|
|
1156
582
|
if (false === state_new instanceof StateEngage)
|
|
1157
583
|
return false;
|
|
1158
|
-
if (!this.
|
|
584
|
+
if (!isEngageAwaited_(this.json_ackWarp))
|
|
1159
585
|
return false;
|
|
1160
|
-
|
|
586
|
+
// RTT <= TTL*2: the cap that bounds the whole exchange at TTL*4 (see traverse_State's lookback)
|
|
587
|
+
if (state_new.json_effEngage.engage.rtt_msec > this.json_ackWarp._cause.warp.ttl_msec * 2)
|
|
1161
588
|
return false;
|
|
1162
589
|
// The Ack gets to live for THE ACK'S creation time + TTL*2 + STT
|
|
1163
590
|
// +STT, so lines up with the Engage timeout
|
|
1164
591
|
// - Engage: T0 +2TTL +RTT; RTT= STT+STT
|
|
1165
592
|
// - AckWarp: TAckWarp +2TLL +STT; TAckWarp= T0 +STT;
|
|
1166
593
|
// - STT: Date of the Ack minus date of the Warp.
|
|
1167
|
-
const timeout_ms = time_ttl_rtt_(this.
|
|
1168
|
-
logr_.log(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.
|
|
1169
|
-
if (state_new.evt_Engage.dt >= Date.parse(this.
|
|
594
|
+
const timeout_ms = time_ttl_rtt_(this.json_ackWarp._cause.warp.ttl_msec) + Date.parse(this.json_ackWarp.dt) - Date.parse(this.json_ackWarp._cause.dt);
|
|
595
|
+
logr_.log(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.json_ackWarp.dt)} + ${timeout_ms}`]);
|
|
596
|
+
if (state_new.evt_Engage.dt >= Date.parse(this.json_ackWarp.dt) + timeout_ms)
|
|
1170
597
|
return false;
|
|
1171
598
|
return true;
|
|
1172
599
|
}
|
|
@@ -1225,10 +652,16 @@ class ProtocolStateState {
|
|
|
1225
652
|
return this._state;
|
|
1226
653
|
}
|
|
1227
654
|
canChangeState(state_new) {
|
|
655
|
+
// An exchange is a dialogue: a step we RECEIVE is only legal after a step we SENT, and vice
|
|
656
|
+
// versa. Every participant on the ME hears every exchange, so without this a warp we merely
|
|
657
|
+
// heard would be "answered" by the ack its real receiver sent, and we could answer our own step.
|
|
658
|
+
if (!(this._state instanceof StateInitialState) && this._state.event.data.b_sent === state_new.event.data.b_sent)
|
|
659
|
+
return false;
|
|
1228
660
|
return this._state.canChangeState(state_new);
|
|
1229
661
|
}
|
|
1230
662
|
}
|
|
1231
663
|
//-------------------------------------------------------------------------------------------------
|
|
664
|
+
const kstr_EVT_DROPPED_ = '2PhW[DROPPED!]';
|
|
1232
665
|
class TwoPhW_EventLog {
|
|
1233
666
|
_eventLog;
|
|
1234
667
|
constructor(eventLog) {
|
|
@@ -1239,29 +672,31 @@ class TwoPhW_EventLog {
|
|
|
1239
672
|
const json = b_Ack ? json_msg["_cause"] : json_msg;
|
|
1240
673
|
if (json.warp) {
|
|
1241
674
|
return {
|
|
1242
|
-
str_type:
|
|
675
|
+
str_type: b_Ack ? '2PhW[JSON_AckWarp]' : '2PhW[JSON_MsgWarp]',
|
|
1243
676
|
json_msgWarp: json
|
|
1244
677
|
};
|
|
1245
678
|
}
|
|
1246
679
|
if (json.engage) {
|
|
1247
680
|
return {
|
|
1248
|
-
str_type:
|
|
681
|
+
str_type: b_Ack ? '2PhW[JSON_AckEngage]' : '2PhW[JSON_EffEngage]',
|
|
1249
682
|
json_msgWarp: json["_cause"]
|
|
1250
683
|
};
|
|
1251
684
|
}
|
|
1252
685
|
return { str_type: null, json_msgWarp: null }; // Explicit default for invalid cases
|
|
1253
686
|
}
|
|
1254
687
|
// _addEvent(msg: t_msg, json_msg : JSON_Msg, timeout_ms? : number, timeout_callback? : ( args? : {idx_event : number, event : EventMinimal} ) => {}) {
|
|
1255
|
-
_addEvent(msg, json_msg, timeout_ms, timeout_callback) {
|
|
688
|
+
_addEvent(msg, json_msg, b_sent, timeout_ms, timeout_callback) {
|
|
1256
689
|
const { str_type, json_msgWarp } = this._warp(json_msg);
|
|
1257
|
-
const { idx } = this._eventLog.add_Event(str_type, json_msgWarp.warp.id, { msg, json_msg }, timeout_ms, timeout_callback);
|
|
690
|
+
const { idx } = this._eventLog.add_Event(str_type, json_msgWarp.warp.id, { msg, json_msg, b_sent }, timeout_ms, timeout_callback);
|
|
1258
691
|
logr_.log(l_.PROTOCOL_STATE, () => [`_addEvent: [${idx}] timeout:${Date.now()}+${timeout_ms} `, json_msg]);
|
|
1259
692
|
}
|
|
1260
|
-
|
|
693
|
+
// Record a message we refused, for forensics: under its exchange and in the shape of every other
|
|
694
|
+
// 2PhW event, but never a step -- traverse_State skips it.
|
|
695
|
+
_dropEvent(msg, json_msg) {
|
|
1261
696
|
const { json_msgWarp } = this._warp(json_msg);
|
|
1262
697
|
if (!json_msgWarp)
|
|
1263
698
|
return;
|
|
1264
|
-
this._eventLog.add_Event(
|
|
699
|
+
this._eventLog.add_Event(kstr_EVT_DROPPED_, json_msgWarp.warp.id, { msg, json_msg, b_sent: false });
|
|
1265
700
|
}
|
|
1266
701
|
_cancelTimeout(idx_event) {
|
|
1267
702
|
logr_.log(l_.PROTOCOL_STATE, () => [`_cancelTimeout: [${idx_event}] timeout cancelled`]);
|
|
@@ -1269,11 +704,18 @@ class TwoPhW_EventLog {
|
|
|
1269
704
|
}
|
|
1270
705
|
traverse_State(json_msgWarp) {
|
|
1271
706
|
const protocolState = new ProtocolStateState();
|
|
1272
|
-
|
|
707
|
+
// Look back over the WHOLE exchange. Its longest window is the Warp's dt + TTL*2 + RTT (the
|
|
708
|
+
// AckEngage), and RTT <= TTL*2 (StateAckWarp refuses an Engage that claims more), so no step is
|
|
709
|
+
// legal more than TTL*4 after the Warp: the oldest event is never older than that.
|
|
710
|
+
const lookback_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, json_msgWarp.warp.ttl_msec * 2);
|
|
711
|
+
const arr_evts = this._eventLog.get_Events_by_id(json_msgWarp.warp.id, lookback_ms);
|
|
1273
712
|
logr_.log(l_.EVENTS, () => ['traverse_State: arr_evts: ', arr_evts]);
|
|
1274
|
-
//TODO: what is the right TTL? should it be a constant or calculated
|
|
1275
713
|
for (let i = arr_evts.length - 1; i >= 0; i--) {
|
|
1276
714
|
const { idx, evt } = arr_evts[i];
|
|
715
|
+
// a dropped message is not a step: not of this exchange, and it must not poison it either
|
|
716
|
+
// (it may well belong to ANOTHER exchange that reused the warp id -- that is why it was dropped)
|
|
717
|
+
if (evt.type === kstr_EVT_DROPPED_)
|
|
718
|
+
continue;
|
|
1277
719
|
const json_msg = evt.data.json_msg;
|
|
1278
720
|
if (!JSON_MsgWarp.compare(json_msgWarp, this._warp(json_msg).json_msgWarp))
|
|
1279
721
|
protocolState.state.changeState(new StateINVALID(idx, evt));
|
|
@@ -1281,13 +723,13 @@ class TwoPhW_EventLog {
|
|
|
1281
723
|
case '2PhW[JSON_MsgWarp]':
|
|
1282
724
|
protocolState.state.changeState(new StateWarp(idx, evt));
|
|
1283
725
|
break;
|
|
1284
|
-
case '2PhW[
|
|
726
|
+
case '2PhW[JSON_AckWarp]':
|
|
1285
727
|
protocolState.state.changeState(new StateAckWarp(idx, evt));
|
|
1286
728
|
break;
|
|
1287
|
-
case '2PhW[
|
|
729
|
+
case '2PhW[JSON_EffEngage]':
|
|
1288
730
|
protocolState.state.changeState(new StateEngage(idx, evt));
|
|
1289
731
|
break;
|
|
1290
|
-
case '2PhW[
|
|
732
|
+
case '2PhW[JSON_AckEngage]':
|
|
1291
733
|
protocolState.state.changeState(new StateAckEngage(idx, evt));
|
|
1292
734
|
break;
|
|
1293
735
|
}
|
|
@@ -1345,171 +787,173 @@ class TwoPhW {
|
|
|
1345
787
|
return false;
|
|
1346
788
|
}
|
|
1347
789
|
//-------------------------------------------------------------------------------------------------
|
|
790
|
+
// The typed handlers (handler_json_<message>) are what the responder's base dispatch calls AFTER it
|
|
791
|
+
// validated the message as that type (generated: `JSON_AckWarp.validate(json_ack) &&
|
|
792
|
+
// this.handler_json_ackWarp(msg, json_ack)`). They do not validate again.
|
|
793
|
+
//-------------------------------------------------------------------------------------------------
|
|
1348
794
|
// sender Source (src)
|
|
1349
795
|
register_msgWarp(msg, json_msgWarp) {
|
|
1350
796
|
logr_.log(l_.SENDER, () => ['register_msgWarp: ', json_msgWarp]);
|
|
1351
797
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1352
798
|
const b_changeState = protocolState.canChangeState(new StateWarp(null, {
|
|
1353
799
|
dt: Date.now(),
|
|
1354
|
-
data: { msg, json_msg: json_msgWarp }
|
|
800
|
+
data: { msg, json_msg: json_msgWarp, b_sent: true }
|
|
1355
801
|
}));
|
|
1356
802
|
logr_.log(l_.HANDLERS | l_.SENDER, () => ['register_msgWarp: protocolState.canChangeState ', b_changeState]);
|
|
1357
803
|
if (!b_changeState)
|
|
1358
804
|
return false;
|
|
1359
805
|
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec);
|
|
1360
806
|
const elapsed_ms = Date.now() - Date.parse(json_msgWarp.dt);
|
|
1361
|
-
this.eventLog._addEvent(msg, json_msgWarp, timeout_ms - elapsed_ms, () => {
|
|
1362
|
-
this.config.
|
|
807
|
+
this.eventLog._addEvent(msg, json_msgWarp, true, timeout_ms - elapsed_ms, () => {
|
|
808
|
+
this.config._callback_sender_sent_expired(msg, json_msgWarp);
|
|
1363
809
|
});
|
|
810
|
+
return true;
|
|
1364
811
|
}
|
|
1365
|
-
|
|
1366
|
-
logr_.log(l_.HANDLERS | l_.SENDER, () => ['
|
|
1367
|
-
|
|
812
|
+
handler_json_ackWarp(msg, json_ackWarp) {
|
|
813
|
+
logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_json_ackWarp: ', json_ackWarp]);
|
|
814
|
+
// no callback for this step: not ours -- before anything is logged
|
|
815
|
+
if (!this.config._callback_ackWarp)
|
|
816
|
+
return false;
|
|
817
|
+
const json_msgWarp = json_ackWarp._cause;
|
|
1368
818
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1369
819
|
const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
|
|
1370
820
|
dt: Date.now(),
|
|
1371
|
-
data: { msg, json_msg:
|
|
821
|
+
data: { msg, json_msg: json_ackWarp, b_sent: false }
|
|
1372
822
|
}));
|
|
1373
|
-
logr_.log(l_.HANDLERS | l_.SENDER, () => ['
|
|
823
|
+
logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_json_ackWarp: protocolState.canChangeState ', b_changeState]);
|
|
1374
824
|
if (!b_changeState)
|
|
1375
825
|
return false;
|
|
1376
826
|
this.eventLog._cancelTimeout(protocolState.state.idx_event);
|
|
1377
|
-
this.eventLog._addEvent(msg,
|
|
1378
|
-
return this.config.
|
|
827
|
+
this.eventLog._addEvent(msg, json_ackWarp, false);
|
|
828
|
+
return this.config._callback_ackWarp(msg, json_ackWarp);
|
|
1379
829
|
}
|
|
1380
|
-
|
|
1381
|
-
logr_.log(l_.SENDER, () => ['
|
|
1382
|
-
const json_msgWarp =
|
|
830
|
+
register_effEngage(msg, json_effEngage) {
|
|
831
|
+
logr_.log(l_.SENDER, () => ['register_effEngage: ', json_effEngage]);
|
|
832
|
+
const json_msgWarp = json_effEngage._cause;
|
|
1383
833
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1384
834
|
const b_changeState = protocolState.canChangeState(new StateEngage(null, {
|
|
1385
835
|
dt: Date.now(),
|
|
1386
|
-
data: { msg, json_msg:
|
|
836
|
+
data: { msg, json_msg: json_effEngage, b_sent: true }
|
|
1387
837
|
}));
|
|
1388
|
-
logr_.log(l_.HANDLERS | l_.SENDER, () => ['
|
|
838
|
+
logr_.log(l_.HANDLERS | l_.SENDER, () => ['register_effEngage: protocolState.canChangeState ', b_changeState]);
|
|
1389
839
|
if (!b_changeState)
|
|
1390
840
|
return false;
|
|
1391
|
-
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec,
|
|
841
|
+
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, json_effEngage.engage.rtt_msec);
|
|
1392
842
|
const elapsed_ms = Date.now() - Date.parse(json_msgWarp.dt);
|
|
1393
|
-
this.eventLog._addEvent(msg,
|
|
1394
|
-
this.config.
|
|
843
|
+
this.eventLog._addEvent(msg, json_effEngage, true, timeout_ms - elapsed_ms, () => {
|
|
844
|
+
this.config._callback_sender_sent_expired(msg, json_effEngage);
|
|
1395
845
|
});
|
|
846
|
+
return true;
|
|
1396
847
|
}
|
|
1397
|
-
|
|
1398
|
-
logr_.log(l_.HANDLERS | l_.SENDER, () => ['
|
|
1399
|
-
|
|
848
|
+
handler_json_ackEngage(msg, json_ackEngage) {
|
|
849
|
+
logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_json_ackEngage: ', json_ackEngage]);
|
|
850
|
+
// no callback for this step: not ours -- before anything is logged
|
|
851
|
+
if (!this.config._callback_ackEngage)
|
|
852
|
+
return false;
|
|
853
|
+
const json_msgWarp = json_ackEngage._cause._cause;
|
|
1400
854
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1401
855
|
const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
|
|
1402
856
|
dt: Date.now(),
|
|
1403
|
-
data: { msg, json_msg:
|
|
857
|
+
data: { msg, json_msg: json_ackEngage, b_sent: false }
|
|
1404
858
|
}));
|
|
1405
|
-
logr_.log(l_.HANDLERS | l_.SENDER, () => ['
|
|
859
|
+
logr_.log(l_.HANDLERS | l_.SENDER, () => ['handler_json_ackEngage: protocolState.canChangeState ', b_changeState]);
|
|
1406
860
|
if (!b_changeState)
|
|
1407
861
|
return false;
|
|
1408
862
|
this.eventLog._cancelTimeout(protocolState.state.idx_event);
|
|
1409
|
-
this.eventLog._addEvent(msg,
|
|
1410
|
-
return this.config.
|
|
863
|
+
this.eventLog._addEvent(msg, json_ackEngage, false);
|
|
864
|
+
return this.config._callback_ackEngage(msg, json_ackEngage);
|
|
1411
865
|
}
|
|
1412
866
|
//-------------------------------------------------------------------------------------------------
|
|
1413
867
|
// receiver Destination (dst)
|
|
1414
|
-
|
|
1415
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
868
|
+
handler_json_msgWarp(msg, json_msgWarp) {
|
|
869
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_json_msgWarp: ', json_msgWarp]);
|
|
870
|
+
// no callback for this step: not ours -- before anything is logged
|
|
871
|
+
if (!this.config._callback_msgWarp)
|
|
872
|
+
return false;
|
|
1416
873
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1417
874
|
const b_changeState = protocolState.canChangeState(new StateWarp(null, {
|
|
1418
875
|
dt: Date.now(),
|
|
1419
|
-
data: { msg, json_msg: json_msgWarp }
|
|
876
|
+
data: { msg, json_msg: json_msgWarp, b_sent: false }
|
|
1420
877
|
}));
|
|
1421
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
878
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_json_msgWarp: protocolState.canChangeState: ', b_changeState]);
|
|
1422
879
|
if (!b_changeState)
|
|
1423
880
|
return false;
|
|
1424
|
-
this.eventLog._addEvent(msg, json_msgWarp);
|
|
881
|
+
this.eventLog._addEvent(msg, json_msgWarp, false);
|
|
1425
882
|
return this.config._callback_msgWarp(msg, json_msgWarp);
|
|
1426
883
|
}
|
|
1427
|
-
|
|
1428
|
-
logr_.log(l_.RECVER, () => ['
|
|
1429
|
-
const json_msgWarp =
|
|
884
|
+
register_ackWarp(msg, json_ackWarp) {
|
|
885
|
+
logr_.log(l_.RECVER, () => ['register_ackWarp: ', json_ackWarp]);
|
|
886
|
+
const json_msgWarp = json_ackWarp._cause;
|
|
1430
887
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1431
888
|
const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
|
|
1432
889
|
dt: Date.now(),
|
|
1433
|
-
data: { msg, json_msg:
|
|
890
|
+
data: { msg, json_msg: json_ackWarp, b_sent: true }
|
|
1434
891
|
}));
|
|
1435
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
892
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['register_ackWarp: protocolState.canChangeState: ', b_changeState]);
|
|
1436
893
|
if (!b_changeState)
|
|
1437
894
|
return false;
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
this.
|
|
895
|
+
// The expiry means "the Engage I was waiting for never came". An ack no Engage can follow
|
|
896
|
+
// concludes the exchange and awaits nothing: logged, with no timer.
|
|
897
|
+
if (!isEngageAwaited_(json_ackWarp)) {
|
|
898
|
+
this.eventLog._addEvent(msg, json_ackWarp, true);
|
|
899
|
+
return true;
|
|
900
|
+
}
|
|
901
|
+
const elapsed_ms = Date.now() - Date.parse(json_ackWarp.dt);
|
|
902
|
+
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec) + Date.parse(json_ackWarp.dt) - Date.parse(json_msgWarp.dt);
|
|
903
|
+
this.eventLog._addEvent(msg, json_ackWarp, true, timeout_ms - elapsed_ms, () => {
|
|
904
|
+
this.config._callback_receiver_sent_expired(msg, json_ackWarp);
|
|
1442
905
|
});
|
|
906
|
+
return true;
|
|
1443
907
|
}
|
|
1444
|
-
|
|
1445
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
1446
|
-
|
|
908
|
+
handler_json_effEngage(msg, json_effEngage) {
|
|
909
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_json_effEngage: ', json_effEngage]);
|
|
910
|
+
// no callback for this step: not ours -- before anything is logged
|
|
911
|
+
if (!this.config._callback_effEngage)
|
|
912
|
+
return false;
|
|
913
|
+
const json_msgWarp = json_effEngage._cause;
|
|
1447
914
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1448
915
|
const b_changeState = protocolState.canChangeState(new StateEngage(null, {
|
|
1449
916
|
dt: Date.now(),
|
|
1450
|
-
data: { msg, json_msg:
|
|
917
|
+
data: { msg, json_msg: json_effEngage, b_sent: false }
|
|
1451
918
|
}));
|
|
1452
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
919
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['handler_json_effEngage: protocolState.canChangeState: ', b_changeState]);
|
|
1453
920
|
if (!b_changeState)
|
|
1454
921
|
return false;
|
|
1455
922
|
this.eventLog._cancelTimeout(protocolState.state.idx_event);
|
|
1456
|
-
this.eventLog._addEvent(msg,
|
|
1457
|
-
return this.config.
|
|
923
|
+
this.eventLog._addEvent(msg, json_effEngage, false);
|
|
924
|
+
return this.config._callback_effEngage(msg, json_effEngage);
|
|
1458
925
|
}
|
|
1459
|
-
|
|
1460
|
-
logr_.log(l_.RECVER, () => ['
|
|
1461
|
-
const json_msgWarp =
|
|
926
|
+
register_ackEngage(msg, json_ackEngage) {
|
|
927
|
+
logr_.log(l_.RECVER, () => ['register_ackEngage: ', json_ackEngage]);
|
|
928
|
+
const json_msgWarp = json_ackEngage._cause._cause;
|
|
1462
929
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1463
930
|
const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
|
|
1464
931
|
dt: Date.now(),
|
|
1465
|
-
data: { msg, json_msg:
|
|
932
|
+
data: { msg, json_msg: json_ackEngage, b_sent: true }
|
|
1466
933
|
}));
|
|
1467
|
-
logr_.log(l_.HANDLERS | l_.RECVER, () => ['
|
|
934
|
+
logr_.log(l_.HANDLERS | l_.RECVER, () => ['register_ackEngage: protocolState.canChangeState: ', b_changeState]);
|
|
1468
935
|
if (!b_changeState)
|
|
1469
936
|
return false;
|
|
1470
|
-
this.eventLog._addEvent(msg,
|
|
1471
|
-
|
|
1472
|
-
//-------------------------------------------------------------------------------------------------
|
|
1473
|
-
handler_json_msgAck(msg, json_msgAck) {
|
|
1474
|
-
logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msgAck: ', json_msgAck]);
|
|
1475
|
-
if (JSON_MsgAckWarp.validate(json_msgAck) && this._handler_msgAckWarp(msg, json_msgAck))
|
|
1476
|
-
return true;
|
|
1477
|
-
if (JSON_MsgAckEngage.validate(json_msgAck) && this._handler_msgAckEngage(msg, json_msgAck))
|
|
1478
|
-
return true;
|
|
1479
|
-
return false;
|
|
1480
|
-
}
|
|
1481
|
-
handler_json_msgEffect(msg, json_msgEffect) {
|
|
1482
|
-
logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msgEffect: ', json_msgEffect]);
|
|
1483
|
-
// if (JSON_MsgAck.validate(json_msgEffect) && this.handler_json_msgAck(msg, json_msgEffect) )
|
|
1484
|
-
// return true;
|
|
1485
|
-
if (JSON_MsgEngage.validate(json_msgEffect) && this._handler_msgEngage(msg, json_msgEffect))
|
|
1486
|
-
return true;
|
|
1487
|
-
// if (JSON_MsgOptions.validate(json_msg) && this.handler_msgOptions_(this._config, msg, json_msg))
|
|
1488
|
-
// return true;
|
|
1489
|
-
return false;
|
|
1490
|
-
}
|
|
1491
|
-
handler_json_msg(msg, json_msg) {
|
|
1492
|
-
logr_.log(l_.HANDLERS, () => ['TwoPhW: handler_json_msg: ', json_msg]);
|
|
1493
|
-
if (JSON_MsgWarp.validate(json_msg) && this._handler_msgWarp(msg, json_msg))
|
|
1494
|
-
return true;
|
|
1495
|
-
// https://attacomsian.com/blog/javascript-iterate-objects
|
|
1496
|
-
// Object.keys(json_msg).forEach((key, index) => {
|
|
1497
|
-
// if (key == 'dt')
|
|
1498
|
-
// return;
|
|
1499
|
-
// if (key == 'referer')
|
|
1500
|
-
// return;
|
|
1501
|
-
// console.log(`${key}: ${json_msg[key]}`);
|
|
1502
|
-
// });
|
|
1503
|
-
return false;
|
|
937
|
+
this.eventLog._addEvent(msg, json_ackEngage, true);
|
|
938
|
+
return true;
|
|
1504
939
|
}
|
|
1505
940
|
}
|
|
1506
941
|
|
|
1507
|
-
exports
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
exports
|
|
1512
|
-
|
|
942
|
+
Object.defineProperty(exports, "JSON_Ack", {
|
|
943
|
+
enumerable: true,
|
|
944
|
+
get: function () { return jsonMsg.JSON_Ack; }
|
|
945
|
+
});
|
|
946
|
+
Object.defineProperty(exports, "JSON_Eff", {
|
|
947
|
+
enumerable: true,
|
|
948
|
+
get: function () { return jsonMsg.JSON_Eff; }
|
|
949
|
+
});
|
|
950
|
+
Object.defineProperty(exports, "JSON_Msg", {
|
|
951
|
+
enumerable: true,
|
|
952
|
+
get: function () { return jsonMsg.JSON_Msg; }
|
|
953
|
+
});
|
|
954
|
+
exports.JSON_AckEngage = JSON_AckEngage;
|
|
955
|
+
exports.JSON_AckWarp = JSON_AckWarp;
|
|
956
|
+
exports.JSON_EffEngage = JSON_EffEngage;
|
|
1513
957
|
exports.JSON_MsgOptions = JSON_MsgOptions;
|
|
1514
958
|
exports.JSON_MsgWarp = JSON_MsgWarp;
|
|
1515
959
|
exports.StateAckEngage = StateAckEngage;
|
|
@@ -1519,5 +963,6 @@ exports.StateINVALID = StateINVALID;
|
|
|
1519
963
|
exports.StateInitialState = StateInitialState;
|
|
1520
964
|
exports.StateWarp = StateWarp;
|
|
1521
965
|
exports.TwoPhW = TwoPhW;
|
|
966
|
+
exports.VERSION = k_VERSION;
|
|
1522
967
|
exports.logr = logr_;
|
|
1523
968
|
exports.t_ttl_rtt = time_ttl_rtt_;
|