@rootintf/protocol-2phw 1.3.3-api.1 → 2.0.3-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.
@@ -77,8 +77,8 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
77
77
  if (valid0) {
78
78
  if (data["2PhW"] !== undefined) {
79
79
  const _errs10 = errors;
80
- if ("1" !== data["2PhW"]) {
81
- validate19.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/2PhW/const", keyword: "const", params: { allowedValue: "1" }, message: "must be equal to constant" }];
80
+ if ("2" !== data["2PhW"]) {
81
+ validate19.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/2PhW/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
82
82
  return false;
83
83
  }
84
84
  var valid0 = _errs10 === errors;
@@ -159,8 +159,8 @@ function validate20(data, { instancePath = "", parentData, parentDataProperty, r
159
159
  if (valid0) {
160
160
  if (data["2PhW"] !== undefined) {
161
161
  const _errs7 = errors;
162
- if ("1" !== data["2PhW"]) {
163
- validate20.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/2PhW/const", keyword: "const", params: { allowedValue: "1" }, message: "must be equal to constant" }];
162
+ if ("2" !== data["2PhW"]) {
163
+ validate20.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/2PhW/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
164
164
  return false;
165
165
  }
166
166
  var valid0 = _errs7 === errors;
@@ -370,7 +370,115 @@ function requireJsonMsg_cjs () {
370
370
  if (hasRequiredJsonMsg_cjs) return jsonMsg_cjs;
371
371
  hasRequiredJsonMsg_cjs = 1;
372
372
 
373
- const schema_Msg = validate18;function validate18(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate18.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((data.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))){validate18.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.id !== undefined){const _errs1 = errors;if(typeof data.id !== "string"){validate18.errors = [{instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.dt !== undefined){const _errs3 = errors;if(typeof data.dt !== "string"){validate18.errors = [{instancePath:instancePath+"/dt",schemaPath:"#/properties/dt/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}}}}else {validate18.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate18.errors = vErrors;return errors === 0;}validate18.evaluated = {"props":{"id":true,"dt":true},"dynamicProps":false,"dynamicItems":false};const schema_Msg_msg = validate19;function validate19(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate19.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data._msg === undefined) && (missing0 = "_msg")){validate19.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}}else {validate19.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate19.errors = vErrors;return errors === 0;}validate19.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema_MsgAck_msg = validate20;function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ack === undefined) && (missing0 = "ack")){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ack !== undefined){let data0 = data.ack;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if((data0.ok === undefined) && (missing1 = "ok")){validate20.errors = [{instancePath:instancePath+"/ack",schemaPath:"#/properties/ack/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ok !== undefined){if(typeof data0.ok !== "boolean"){validate20.errors = [{instancePath:instancePath+"/ack/ok",schemaPath:"#/properties/ack/properties/ok/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/ack",schemaPath:"#/properties/ack/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}validate20.evaluated = {"props":{"ack":true},"dynamicProps":false,"dynamicItems":false};
373
+ const schema_Msg = validate18;
374
+ function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate18.evaluated; if (evaluated0.dynamicProps) {
375
+ evaluated0.props = undefined;
376
+ } if (evaluated0.dynamicItems) {
377
+ evaluated0.items = undefined;
378
+ } {
379
+ if (data && typeof data == "object" && !Array.isArray(data)) {
380
+ let missing0;
381
+ if ((((data.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))) {
382
+ validate18.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
383
+ return false;
384
+ }
385
+ else {
386
+ if (data.id !== undefined) {
387
+ const _errs1 = errors;
388
+ if (typeof data.id !== "string") {
389
+ validate18.errors = [{ instancePath: instancePath + "/id", schemaPath: "#/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
390
+ return false;
391
+ }
392
+ var valid0 = _errs1 === errors;
393
+ }
394
+ else {
395
+ var valid0 = true;
396
+ }
397
+ if (valid0) {
398
+ if (data.dt !== undefined) {
399
+ const _errs3 = errors;
400
+ if (typeof data.dt !== "string") {
401
+ validate18.errors = [{ instancePath: instancePath + "/dt", schemaPath: "#/properties/dt/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
402
+ return false;
403
+ }
404
+ var valid0 = _errs3 === errors;
405
+ }
406
+ else {
407
+ var valid0 = true;
408
+ }
409
+ }
410
+ }
411
+ }
412
+ else {
413
+ validate18.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
414
+ return false;
415
+ }
416
+ } validate18.errors = vErrors; return errors === 0; }
417
+ validate18.evaluated = { "props": { "id": true, "dt": true }, "dynamicProps": false, "dynamicItems": false };
418
+ const schema_MsgEffect = validate19;
419
+ function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate19.evaluated; if (evaluated0.dynamicProps) {
420
+ evaluated0.props = undefined;
421
+ } if (evaluated0.dynamicItems) {
422
+ evaluated0.items = undefined;
423
+ } {
424
+ if (data && typeof data == "object" && !Array.isArray(data)) {
425
+ let missing0;
426
+ if ((data._cause === undefined) && (missing0 = "_cause")) {
427
+ validate19.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
428
+ return false;
429
+ }
430
+ }
431
+ else {
432
+ validate19.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
433
+ return false;
434
+ }
435
+ } validate19.errors = vErrors; return errors === 0; }
436
+ validate19.evaluated = { "dynamicProps": false, "dynamicItems": false };
437
+ const schema_MsgAckEffect = validate20;
438
+ function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
439
+ evaluated0.props = undefined;
440
+ } if (evaluated0.dynamicItems) {
441
+ evaluated0.items = undefined;
442
+ } {
443
+ if (data && typeof data == "object" && !Array.isArray(data)) {
444
+ let missing0;
445
+ if ((data.ack === undefined) && (missing0 = "ack")) {
446
+ validate20.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
447
+ return false;
448
+ }
449
+ else {
450
+ if (data.ack !== undefined) {
451
+ let data0 = data.ack;
452
+ {
453
+ if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
454
+ let missing1;
455
+ if ((data0.ok === undefined) && (missing1 = "ok")) {
456
+ validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
457
+ return false;
458
+ }
459
+ else {
460
+ if (data0.ok !== undefined) {
461
+ if (typeof data0.ok !== "boolean") {
462
+ validate20.errors = [{ instancePath: instancePath + "/ack/ok", schemaPath: "#/properties/ack/properties/ok/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
463
+ return false;
464
+ }
465
+ }
466
+ }
467
+ }
468
+ else {
469
+ validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
470
+ return false;
471
+ }
472
+ }
473
+ }
474
+ }
475
+ }
476
+ else {
477
+ validate20.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
478
+ return false;
479
+ }
480
+ } validate20.errors = vErrors; return errors === 0; }
481
+ validate20.evaluated = { "props": { "ack": true }, "dynamicProps": false, "dynamicItems": false };
374
482
 
375
483
  const byteToHex = [];
376
484
  for (let i = 0; i < 256; ++i) {
@@ -414,10 +522,7 @@ function requireJsonMsg_cjs () {
414
522
  const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
415
523
  var native = { randomUUID };
416
524
 
417
- function v4(options, buf, offset) {
418
- if (native.randomUUID && true && !options) {
419
- return native.randomUUID();
420
- }
525
+ function _v4(options, buf, offset) {
421
526
  options = options || {};
422
527
  const rnds = options.random ?? options.rng?.() ?? rng();
423
528
  if (rnds.length < 16) {
@@ -427,6 +532,12 @@ function requireJsonMsg_cjs () {
427
532
  rnds[8] = (rnds[8] & 0x3f) | 0x80;
428
533
  return unsafeStringify(rnds);
429
534
  }
535
+ function v4(options, buf, offset) {
536
+ if (native.randomUUID && true && !options) {
537
+ return native.randomUUID();
538
+ }
539
+ return _v4(options);
540
+ }
430
541
 
431
542
  // console.log('OUT', __name({variableName}) );
432
543
 
@@ -521,88 +632,84 @@ function requireJsonMsg_cjs () {
521
632
 
522
633
  })();
523
634
 
524
- let LOGR_= LOGR.get_instance();
525
- const log_= LOGR_.log;
526
-
527
- const l_= {
528
- VALIDATION : 0b1 << 0,
635
+ let LOGR_ = LOGR.get_instance();
636
+ const log_ = LOGR_.log;
637
+ const l_ = {
638
+ VALIDATION: 0b1 << 0,
529
639
  };
530
- LOGR_.labels= l_;
531
-
640
+ LOGR_.labels = l_;
532
641
  // TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
533
-
534
642
  // "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
535
- var JSON_Msg = (function() {
536
- return {
537
- merge: function(json) {
538
- return Object.assign({
539
- id: v4(),
540
- referer: null,
541
- dt: new Date().toISOString()
542
- }, json || {});
543
- },
544
- validate : function (json) {
545
- const b_valid = schema_Msg(json);
546
- if (!b_valid)
547
- log_(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
548
- return b_valid;
549
- },
550
- // TODO: requires a separate ajv module require, and JTD specific schema
551
- // https://ajv.js.org/guide/getting-started.html#parsing-and-serializing-json
552
- // static #ajv_parse_= ajv.compileParser(this.#schema_json_Msg);
553
- // static parse(json) {
554
- // return this.#ajv_parse_(json);
555
- // }
556
- }
643
+ var JSON_Msg = (function () {
644
+ return {
645
+ merge: function (json) {
646
+ return Object.assign({
647
+ id: v4(),
648
+ referer: null,
649
+ dt: new Date().toISOString()
650
+ }, json || {});
651
+ },
652
+ validate: function (json) {
653
+ const b_valid = schema_Msg(json);
654
+ if (!b_valid)
655
+ log_(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
656
+ return b_valid;
657
+ },
658
+ // TODO: requires a separate ajv module require, and JTD specific schema
659
+ // https://ajv.js.org/guide/getting-started.html#parsing-and-serializing-json
660
+ // static #ajv_parse_= ajv.compileParser(this.#schema_json_Msg);
661
+ // static parse(json) {
662
+ // return this.#ajv_parse_(json);
663
+ // }
664
+ };
557
665
  })();
558
-
559
- var JSON_Msg_msg = (function() {
560
- return {
561
- create_with_msg_merge: function(_msg, json) {
562
- return Object.assign(JSON_Msg.merge(json), { _msg });
563
- },
564
- validate : function(json) {
565
- if (! JSON_Msg.validate(json))
566
- return false;
567
- const b_valid= schema_Msg_msg(json);
568
- if (!b_valid)
569
- log_(l_.VALIDATION, () => ['JSON_Msg_msg: validate: ', schema_Msg_msg.errors]);
570
- return b_valid;
571
- }
572
- }
666
+ var JSON_MsgEffect = (function () {
667
+ return {
668
+ create_with_cause_merge: function (msg_cause, json) {
669
+ const _cause = msg_cause;
670
+ return Object.assign(JSON_Msg.merge(json), { _cause });
671
+ },
672
+ validate: function (json) {
673
+ if (!JSON_Msg.validate(json))
674
+ return false;
675
+ const b_valid = schema_MsgEffect(json);
676
+ if (!b_valid)
677
+ log_(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
678
+ return b_valid;
679
+ }
680
+ };
573
681
  })();
574
-
575
- var JSON_MsgAck_msg = (function() {
576
- return {
577
- create_with_msgOk : function(_msg, b_ok= true) {
578
- return JSON_Msg_msg.create_with_msg_merge(_msg, {
579
- ack : {
580
- "ok" : b_ok,
581
- },
582
- });
583
- },
584
- create_with_msgExpired : function(_msg) {
585
- return JSON_Msg_msg.create_with_msg_merge(_msg, {
586
- ack : {
587
- "ok" : false,
588
- "expired" : true
589
- },
590
- });
591
- },
592
- validate : function(json) {
593
- if (! JSON_Msg_msg.validate(json))
594
- return false;
595
- const b_valid= schema_MsgAck_msg(json);
596
- if (!b_valid)
597
- log_(l_.VALIDATION, () => ['JSON_MsgAck: validate: ', schema_MsgAck_msg.errors]);
598
- return b_valid;
599
- }
600
- }
682
+ var JSON_MsgAck = (function () {
683
+ return {
684
+ create_with_cause_Ok: function (msg_cause, b_ok = true) {
685
+ return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
686
+ ack: {
687
+ "ok": b_ok,
688
+ },
689
+ });
690
+ },
691
+ create_with_cause_Expired: function (msg_cause) {
692
+ return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
693
+ ack: {
694
+ "ok": false,
695
+ "expired": true
696
+ },
697
+ });
698
+ },
699
+ validate: function (json) {
700
+ if (!JSON_MsgEffect.validate(json))
701
+ return false;
702
+ const b_valid = schema_MsgAckEffect(json);
703
+ if (!b_valid)
704
+ log_(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
705
+ return b_valid;
706
+ }
707
+ };
601
708
  })();
602
709
 
603
710
  jsonMsg_cjs.JSON_Msg = JSON_Msg;
604
- jsonMsg_cjs.JSON_MsgAck_msg = JSON_MsgAck_msg;
605
- jsonMsg_cjs.JSON_Msg_msg = JSON_Msg_msg;
711
+ jsonMsg_cjs.JSON_MsgAck = JSON_MsgAck;
712
+ jsonMsg_cjs.JSON_MsgEffect = JSON_MsgEffect;
606
713
  jsonMsg_cjs.l = l_;
607
714
  return jsonMsg_cjs;
608
715
  }
@@ -794,7 +901,7 @@ class Config {
794
901
  // }
795
902
  // })();
796
903
  //-------------------------------------------------------------------------------------------------
797
- let k_VERSION = "1";
904
+ let k_VERSION = "2";
798
905
  // rtt_msec <= ttl_msec *2 => rtt_msec = ttl_msec *2
799
906
  // t_ttl_rtt_(TTL, RTT) = t_ttl_rtt_(TTL, TTL *2) = TTL *2 + TTL *2 = TTL *4 MAX
800
907
  function time_ttl_rtt_(ttl_msec, rtt_msec) {
@@ -807,8 +914,8 @@ function time_ttl_rtt_(ttl_msec, rtt_msec) {
807
914
  }
808
915
  var JSON_MsgOptions = (function () {
809
916
  return {
810
- create_with_msg_options: function (_msg, options) {
811
- return jsonMsg_cjsExports.JSON_Msg_msg.create_with_msg_merge(_msg, {
917
+ create_with_cause_options: function (msg_cause, options) {
918
+ return jsonMsg_cjsExports.JSON_MsgEffect.create_with_msg_merge(msg_cause, {
812
919
  options: options,
813
920
  "2PhW": k_VERSION
814
921
  });
@@ -861,9 +968,9 @@ var JSON_MsgWarp = (function () {
861
968
  })();
862
969
  var JSON_MsgEngage = (function () {
863
970
  return {
864
- create_with_MsgWarp: function (json_msgWarp) {
971
+ create_with_Warp: function (json_msgWarp) {
865
972
  console.assert(json_msgWarp.ack === undefined, "Engage with a Warp, not an Ack");
866
- return jsonMsg_cjsExports.JSON_Msg_msg.create_with_msg_merge(json_msgWarp, {
973
+ return jsonMsg_cjsExports.JSON_MsgEffect.create_with_cause_merge(json_msgWarp, {
867
974
  engage: {
868
975
  "ok": true,
869
976
  "rtt_msec": Date.now() - Date.parse(json_msgWarp.dt)
@@ -871,12 +978,12 @@ var JSON_MsgEngage = (function () {
871
978
  "2PhW": k_VERSION
872
979
  });
873
980
  },
874
- validate: function (json_msg_msg) {
981
+ validate: function (json_msgEffect) {
875
982
  // if (! JSON_Msg_msg.validate(json))
876
983
  // return false;
877
- if (!JSON_MsgWarp.validate(json_msg_msg._msg))
984
+ if (!JSON_MsgWarp.validate(json_msgEffect._cause))
878
985
  return false;
879
- if (!schema_MsgEngage(json_msg_msg)) {
986
+ if (!schema_MsgEngage(json_msgEffect)) {
880
987
  log_(l_.VALIDATION, () => ['JSON_MsgEngage: schema_MsgEngage_: ', schema_MsgEngage.errors]);
881
988
  return false;
882
989
  }
@@ -888,23 +995,23 @@ var JSON_MsgAckWarp = (function () {
888
995
  return {
889
996
  // createWith_msgAck_msg : function(json_msgAck, _msg) {
890
997
  // const json_msgAckWarp= structuredClone(json_msgAck);
891
- // json_msgAckWarp._msg= _msg;
998
+ // json_msgAckWarp._cause= _cause;
892
999
  // return json_msgAckWarp;
893
1000
  // }
894
- create_with_msgOk: function (json_msgWarp, b_ok = true) {
895
- const json_msgAck_msg = jsonMsg_cjsExports.JSON_MsgAck_msg.create_with_msgOk(json_msgWarp, b_ok);
896
- json_msgAck_msg["2PhW"] = k_VERSION;
897
- return json_msgAck_msg;
1001
+ create_with_Warp_Ok: function (json_msgWarp, b_ok = true) {
1002
+ const json_msgAck = jsonMsg_cjsExports.JSON_MsgAck.create_with_cause_Ok(json_msgWarp, b_ok);
1003
+ json_msgAck["2PhW"] = k_VERSION;
1004
+ return json_msgAck;
898
1005
  },
899
1006
  // create_with_msgExpired : function( json_msgWarp ) {
900
1007
  // const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgExpired( json_msgWarp )
901
1008
  // json_msgAck_msg["2PhW"]= k_VERSION;
902
1009
  // return json_msgAck_msg;
903
1010
  // },
904
- validate: function (json_msgAck_msg) {
1011
+ validate: function (json_msgAck) {
905
1012
  // if (! JSON_MsgAck_msg.validate(json))
906
1013
  // return false;
907
- if (!JSON_MsgWarp.validate(json_msgAck_msg._msg))
1014
+ if (!JSON_MsgWarp.validate(json_msgAck._cause))
908
1015
  return false;
909
1016
  return true;
910
1017
  }
@@ -914,23 +1021,23 @@ var JSON_MsgAckEngage = (function () {
914
1021
  return {
915
1022
  // createWith_msgAck_msg : function(json_msgAck, _msg) {
916
1023
  // const json_msgAckEngage= structuredClone(json_msgAck);
917
- // json_msgAckEngage._msg= _msg;
1024
+ // json_msgAckEngage._cause= _cause;
918
1025
  // return json_msgAckEngage;
919
1026
  // }
920
- create_with_msgOk: function (json_msgEngage, b_ok = true) {
921
- const json_msgAck_msg = jsonMsg_cjsExports.JSON_MsgAck_msg.create_with_msgOk(json_msgEngage, b_ok);
922
- json_msgAck_msg["2PhW"] = k_VERSION;
923
- return json_msgAck_msg;
1027
+ create_with_Engage_Ok: function (json_msgEngage, b_ok = true) {
1028
+ const json_msgAck = jsonMsg_cjsExports.JSON_MsgAck.create_with_cause_Ok(json_msgEngage, b_ok);
1029
+ json_msgAck["2PhW"] = k_VERSION;
1030
+ return json_msgAck;
924
1031
  },
925
1032
  // create_with_msgExpired : function( json_msgEngage ) {
926
1033
  // const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgExpired( json_msgEngage )
927
1034
  // json_msgAck_msg["2PhW"]= k_VERSION;
928
1035
  // return json_msgAck_msg;
929
1036
  // },
930
- validate: function (json_msgAck_msg) {
1037
+ validate: function (json_msgAck) {
931
1038
  // if (! JSON_MsgAck_msg.validate(json_msgAck_msg))
932
1039
  // return false;
933
- if (!JSON_MsgEngage.validate(json_msgAck_msg._msg))
1040
+ if (!JSON_MsgEngage.validate(json_msgAck._cause))
934
1041
  return false;
935
1042
  return true;
936
1043
  }
@@ -988,7 +1095,7 @@ class StateEngage extends StateState {
988
1095
  if (false === state_new instanceof StateAckEngage)
989
1096
  return false;
990
1097
  // The Engage gets to live for THE WARP'S creation time + TTL*2 + RTT
991
- const json_msgWarp = this.json_msgEngage._msg;
1098
+ const json_msgWarp = this.json_msgEngage._cause;
992
1099
  const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, this.json_msgEngage.engage.rtt_msec);
993
1100
  log_(l_.PROTOCOL_STATE, () => [`StateEngage: evt_AckEngage.dt@${state_new.evt_AckEngage.dt}, msgWarp.dt@${Date.parse(json_msgWarp.dt)} + ${timeout_ms}`]);
994
1101
  if (state_new.evt_AckEngage.dt >= Date.parse(json_msgWarp.dt) + timeout_ms)
@@ -1005,14 +1112,14 @@ class StateAckWarp extends StateState {
1005
1112
  return false;
1006
1113
  if (!this.json_msgAckWarp.ack.ok)
1007
1114
  return false;
1008
- if (this.json_msgAckWarp._msg.warp.instantaneous)
1115
+ if (this.json_msgAckWarp._cause.warp.instantaneous)
1009
1116
  return false;
1010
1117
  // The Ack gets to live for THE ACK'S creation time + TTL*2 + STT
1011
1118
  // +STT, so lines up with the Engage timeout
1012
1119
  // - Engage: T0 +2TTL +RTT; RTT= STT+STT
1013
1120
  // - AckWarp: TAckWarp +2TLL +STT; TAckWarp= T0 +STT;
1014
1121
  // - STT: Date of the Ack minus date of the Warp.
1015
- const timeout_ms = time_ttl_rtt_(this.json_msgAckWarp._msg.warp.ttl_msec) + Date.parse(this.json_msgAckWarp.dt) - Date.parse(this.json_msgAckWarp._msg.dt);
1122
+ const timeout_ms = time_ttl_rtt_(this.json_msgAckWarp._cause.warp.ttl_msec) + Date.parse(this.json_msgAckWarp.dt) - Date.parse(this.json_msgAckWarp._cause.dt);
1016
1123
  log_(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.json_msgAckWarp.dt)} + ${timeout_ms}`]);
1017
1124
  if (state_new.evt_Engage.dt >= Date.parse(this.json_msgAckWarp.dt) + timeout_ms)
1018
1125
  return false;
@@ -1084,7 +1191,7 @@ class TwoPhW_EventLog {
1084
1191
  }
1085
1192
  _warp(json_msg) {
1086
1193
  const b_Ack = json_msg.ack !== undefined;
1087
- const json = b_Ack ? json_msg["_msg"] : json_msg;
1194
+ const json = b_Ack ? json_msg["_cause"] : json_msg;
1088
1195
  if (json.warp) {
1089
1196
  return {
1090
1197
  str_type: `2PhW[JSON_Msg${b_Ack ? 'Ack' : ''}Warp]`,
@@ -1094,7 +1201,7 @@ class TwoPhW_EventLog {
1094
1201
  if (json.engage) {
1095
1202
  return {
1096
1203
  str_type: `2PhW[JSON_Msg${b_Ack ? 'Ack' : ''}Engage]`,
1097
- json_msgWarp: json["_msg"]
1204
+ json_msgWarp: json["_cause"]
1098
1205
  };
1099
1206
  }
1100
1207
  return { str_type: null, json_msgWarp: null }; // Explicit default for invalid cases
@@ -1168,8 +1275,8 @@ class TwoPhW {
1168
1275
  if (! validate_Options_delay_(json_msgOptions.options))
1169
1276
  return false;
1170
1277
 
1171
- if (JSON_MsgWarp.validate(json_msgOptions._msg)) {
1172
- const json_msgWarp= json_msgOptions._msg;
1278
+ if (JSON_MsgWarp.validate(json_msgOptions._cause)) {
1279
+ const json_msgWarp= json_msgOptions._cause;
1173
1280
 
1174
1281
  const ctx= get_ctx(json_msgWarp.id);
1175
1282
  if (!ctx )
@@ -1212,7 +1319,7 @@ class TwoPhW {
1212
1319
  }
1213
1320
  _handler_msgAckWarp(msg, json_msgAckWarp) {
1214
1321
  log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: ', json_msgAckWarp]);
1215
- const json_msgWarp = json_msgAckWarp._msg;
1322
+ const json_msgWarp = json_msgAckWarp._cause;
1216
1323
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1217
1324
  const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
1218
1325
  dt: Date.now(),
@@ -1227,7 +1334,7 @@ class TwoPhW {
1227
1334
  }
1228
1335
  register_msgEngage(msg, json_msgEngage) {
1229
1336
  log_(l_.SENDER, () => ['register_msgEngage: ', json_msgEngage]);
1230
- const json_msgWarp = json_msgEngage._msg;
1337
+ const json_msgWarp = json_msgEngage._cause;
1231
1338
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1232
1339
  const b_changeState = protocolState.canChangeState(new StateEngage(null, {
1233
1340
  dt: Date.now(),
@@ -1244,7 +1351,7 @@ class TwoPhW {
1244
1351
  }
1245
1352
  _handler_msgAckEngage(msg, json_msgAckEngage) {
1246
1353
  log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage: ', json_msgAckEngage]);
1247
- const json_msgWarp = json_msgAckEngage._msg._msg;
1354
+ const json_msgWarp = json_msgAckEngage._cause._cause;
1248
1355
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1249
1356
  const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
1250
1357
  dt: Date.now(),
@@ -1274,7 +1381,7 @@ class TwoPhW {
1274
1381
  }
1275
1382
  register_msgAckWarp(msg, json_msgAckWarp) {
1276
1383
  log_(l_.RECVER, () => ['register_msgAckWarp: ', json_msgAckWarp]);
1277
- const json_msgWarp = json_msgAckWarp._msg;
1384
+ const json_msgWarp = json_msgAckWarp._cause;
1278
1385
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1279
1386
  const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
1280
1387
  dt: Date.now(),
@@ -1291,7 +1398,7 @@ class TwoPhW {
1291
1398
  }
1292
1399
  _handler_msgEngage(msg, json_msgEngage) {
1293
1400
  log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: ', json_msgEngage]);
1294
- const json_msgWarp = json_msgEngage["_msg"];
1401
+ const json_msgWarp = json_msgEngage._cause;
1295
1402
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1296
1403
  const b_changeState = protocolState.canChangeState(new StateEngage(null, {
1297
1404
  dt: Date.now(),
@@ -1306,7 +1413,7 @@ class TwoPhW {
1306
1413
  }
1307
1414
  register_msgAckEngage(msg, json_msgAckEngage) {
1308
1415
  log_(l_.RECVER, () => ['register_msgAckEngage: ', json_msgAckEngage]);
1309
- const json_msgWarp = json_msgAckEngage._msg._msg;
1416
+ const json_msgWarp = json_msgAckEngage._cause._cause;
1310
1417
  const protocolState = this.eventLog.traverse_State(json_msgWarp);
1311
1418
  const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
1312
1419
  dt: Date.now(),
@@ -1318,19 +1425,19 @@ class TwoPhW {
1318
1425
  this.eventLog._addEvent(msg, json_msgAckEngage);
1319
1426
  }
1320
1427
  //-------------------------------------------------------------------------------------------------
1321
- handler_json_msgAck_msg(msg, json_msgAck_msg) {
1322
- log_(l_.HANDLERS, () => ['handler_json_msgAck_msg: ', json_msgAck_msg]);
1323
- if (JSON_MsgAckWarp.validate(json_msgAck_msg) && this._handler_msgAckWarp(msg, json_msgAck_msg))
1428
+ handler_json_msgAck(msg, json_msgAck) {
1429
+ log_(l_.HANDLERS, () => ['handler_json_msgAck: ', json_msgAck]);
1430
+ if (JSON_MsgAckWarp.validate(json_msgAck) && this._handler_msgAckWarp(msg, json_msgAck))
1324
1431
  return true;
1325
- if (JSON_MsgAckEngage.validate(json_msgAck_msg) && this._handler_msgAckEngage(msg, json_msgAck_msg))
1432
+ if (JSON_MsgAckEngage.validate(json_msgAck) && this._handler_msgAckEngage(msg, json_msgAck))
1326
1433
  return true;
1327
1434
  return false;
1328
1435
  }
1329
- handler_json_msg_msg(msg, json_msg_msg) {
1330
- log_(l_.HANDLERS, () => ['handler_json_msg_msg: ', json_msg_msg]);
1331
- if (jsonMsg_cjsExports.JSON_MsgAck_msg.validate(json_msg_msg) && this.handler_json_msgAck_msg(msg, json_msg_msg))
1436
+ handler_json_msgEffect(msg, json_msgEffect) {
1437
+ log_(l_.HANDLERS, () => ['handler_json_msgEffect: ', json_msgEffect]);
1438
+ if (jsonMsg_cjsExports.JSON_MsgAck.validate(json_msgEffect) && this.handler_json_msgAck(msg, json_msgEffect))
1332
1439
  return true;
1333
- if (JSON_MsgEngage.validate(json_msg_msg) && this._handler_msgEngage(msg, json_msg_msg))
1440
+ if (JSON_MsgEngage.validate(json_msgEffect) && this._handler_msgEngage(msg, json_msgEffect))
1334
1441
  return true;
1335
1442
  // if (JSON_MsgOptions.validate(json_msg) && this.handler_msgOptions_(this._config, msg, json_msg))
1336
1443
  // return true;
@@ -1352,7 +1459,7 @@ class TwoPhW {
1352
1459
  }
1353
1460
  handler_json(msg, json) {
1354
1461
  log_(l_.HANDLERS, () => ['handler_json: ', json]);
1355
- if (jsonMsg_cjsExports.JSON_Msg_msg.validate(json) && this.handler_json_msg_msg(msg, json))
1462
+ if (jsonMsg_cjsExports.JSON_MsgEffect.validate(json) && this.handler_json_msgEffect(msg, json))
1356
1463
  return true;
1357
1464
  if (jsonMsg_cjsExports.JSON_Msg.validate(json) && this.handler_json_msg(msg, json))
1358
1465
  return true;
package/dist/twoPhW.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { JSON_Msg, JSON_Msg_msg, JSON_MsgAck_msg } from '@rootintf/json-msg';
1
+ import { JSON_Msg, JSON_MsgEffect, JSON_MsgAck } from '@rootintf/json-msg';
2
2
  import { EventLog } from './EventLog-mem.mjs';
3
3
  type t_msg = string;
4
4
  interface EventMinimal {
@@ -25,7 +25,7 @@ declare class Config {
25
25
  }
26
26
  declare function time_ttl_rtt_(ttl_msec: number | undefined, rtt_msec?: number): number | undefined;
27
27
  declare var JSON_MsgOptions: {
28
- create_with_msg_options: (_msg: any, options: any) => any;
28
+ create_with_cause_options: (msg_cause: any, options: any) => any;
29
29
  validate: (json: any) => boolean;
30
30
  };
31
31
  declare var JSON_MsgWarp: {
@@ -34,16 +34,16 @@ declare var JSON_MsgWarp: {
34
34
  validate: (json_msg: any) => boolean;
35
35
  };
36
36
  declare var JSON_MsgEngage: {
37
- create_with_MsgWarp: (json_msgWarp: any) => any;
38
- validate: (json_msg_msg: any) => boolean;
37
+ create_with_Warp: (json_msgWarp: any) => any;
38
+ validate: (json_msgEffect: any) => boolean;
39
39
  };
40
40
  declare var JSON_MsgAckWarp: {
41
- create_with_msgOk: (json_msgWarp: any, b_ok?: boolean) => any;
42
- validate: (json_msgAck_msg: any) => boolean;
41
+ create_with_Warp_Ok: (json_msgWarp: any, b_ok?: boolean) => any;
42
+ validate: (json_msgAck: any) => boolean;
43
43
  };
44
44
  declare var JSON_MsgAckEngage: {
45
- create_with_msgOk: (json_msgEngage: any, b_ok?: boolean) => any;
46
- validate: (json_msgAck_msg: any) => boolean;
45
+ create_with_Engage_Ok: (json_msgEngage: any, b_ok?: boolean) => any;
46
+ validate: (json_msgAck: any) => boolean;
47
47
  };
48
48
  declare class StateState {
49
49
  private _idx_event;
@@ -117,15 +117,15 @@ declare class TwoPhW {
117
117
  get eventLog(): TwoPhW_EventLog;
118
118
  _handler_msgOptions(cfg: any, msg: any, json_msgOptions: any): boolean;
119
119
  register_msgWarp(msg: t_msg, json_msgWarp: JSON_Msg): boolean;
120
- _handler_msgAckWarp(msg: t_msg, json_msgAckWarp: JSON_MsgAck_msg): boolean;
121
- register_msgEngage(msg: t_msg, json_msgEngage: JSON_Msg_msg): boolean;
122
- _handler_msgAckEngage(msg: t_msg, json_msgAckEngage: JSON_MsgAck_msg): boolean;
120
+ _handler_msgAckWarp(msg: t_msg, json_msgAckWarp: JSON_MsgAck): boolean;
121
+ register_msgEngage(msg: t_msg, json_msgEngage: JSON_MsgEffect): boolean;
122
+ _handler_msgAckEngage(msg: t_msg, json_msgAckEngage: JSON_MsgAck): boolean;
123
123
  _handler_msgWarp(msg: t_msg, json_msgWarp: JSON_Msg): boolean;
124
- register_msgAckWarp(msg: t_msg, json_msgAckWarp: JSON_MsgAck_msg): boolean;
125
- _handler_msgEngage(msg: t_msg, json_msgEngage: JSON_Msg_msg): boolean;
126
- register_msgAckEngage(msg: t_msg, json_msgAckEngage: JSON_MsgAck_msg): boolean;
127
- handler_json_msgAck_msg(msg: t_msg, json_msgAck_msg: JSON_MsgAck_msg): boolean;
128
- handler_json_msg_msg(msg: t_msg, json_msg_msg: JSON_Msg_msg): boolean;
124
+ register_msgAckWarp(msg: t_msg, json_msgAckWarp: JSON_MsgAck): boolean;
125
+ _handler_msgEngage(msg: t_msg, json_msgEngage: JSON_MsgEffect): boolean;
126
+ register_msgAckEngage(msg: t_msg, json_msgAckEngage: JSON_MsgAck): boolean;
127
+ handler_json_msgAck(msg: t_msg, json_msgAck: JSON_MsgAck): boolean;
128
+ handler_json_msgEffect(msg: t_msg, json_msgEffect: JSON_MsgEffect): boolean;
129
129
  handler_json_msg(msg: t_msg, json_msg: JSON_Msg): boolean;
130
130
  handler_json(msg: t_msg, json: any): boolean;
131
131
  }