@rootintf/protocol-2phw 0.6.10 → 0.7.1

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const validate_Msg2PhW = validate10$1;const pattern0 = new RegExp("0\\.6", "u");function validate10$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data["2PhW"] === undefined) && (missing0 = "2PhW")){validate10$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data["2PhW"] !== undefined){let data0 = data["2PhW"];{if(typeof data0 === "string"){if(!pattern0.test(data0)){validate10$1.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/pattern",keyword:"pattern",params:{pattern: "0\\.6"},message:"must match pattern \""+"0\\.6"+"\""}];return false;}}else {validate10$1.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}}}}else {validate10$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10$1.errors = vErrors;return errors === 0;}const validate_MsgOptions = validate11$1;function validate11$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.options === undefined) && (missing0 = "options")){validate11$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.options !== undefined){let data0 = data.options;if(!(data0 && typeof data0 == "object" && !Array.isArray(data0))){validate11$1.errors = [{instancePath:instancePath+"/options",schemaPath:"#/properties/options/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}else {validate11$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate11$1.errors = vErrors;return errors === 0;}const validate_Options_delay = validate12$1;function validate12$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ttl_msec_incr === undefined) && (missing0 = "ttl_msec_incr")){validate12$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ttl_msec !== undefined){if(!(Array.isArray(data.ttl_msec))){validate12$1.errors = [{instancePath:instancePath+"/ttl_msec",schemaPath:"#/properties/ttl_msec/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}}}else {validate12$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate12$1.errors = vErrors;return errors === 0;}const validate_MsgWarp = validate13;function validate13(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.warp === undefined) && (missing0 = "warp")){validate13.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.warp !== undefined){let data0 = data.warp;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ttl_msec !== undefined){let data1 = data0.ttl_msec;if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){validate13.errors = [{instancePath:instancePath+"/warp/ttl_msec",schemaPath:"#/properties/warp/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}}}}else {validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate13.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate13.errors = vErrors;return errors === 0;}const validate_MsgEngage = validate14;function validate14(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.engage === undefined) && (missing0 = "engage")){validate14.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.engage !== undefined){let data0 = data.engage;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}}else {validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate14.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate14.errors = vErrors;return errors === 0;}
5
+ const validate_Msg2PhW = validate10$1;const pattern0 = new RegExp("0\\.7", "u");function validate10$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data["2PhW"] === undefined) && (missing0 = "2PhW")){validate10$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data["2PhW"] !== undefined){let data0 = data["2PhW"];{if(typeof data0 === "string"){if(!pattern0.test(data0)){validate10$1.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/pattern",keyword:"pattern",params:{pattern: "0\\.7"},message:"must match pattern \""+"0\\.7"+"\""}];return false;}}else {validate10$1.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}}}}else {validate10$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10$1.errors = vErrors;return errors === 0;}const validate_MsgOptions = validate11$1;function validate11$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.options === undefined) && (missing0 = "options")){validate11$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.options !== undefined){let data0 = data.options;if(!(data0 && typeof data0 == "object" && !Array.isArray(data0))){validate11$1.errors = [{instancePath:instancePath+"/options",schemaPath:"#/properties/options/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}else {validate11$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate11$1.errors = vErrors;return errors === 0;}const validate_Options_delay = validate12$1;function validate12$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ttl_msec_incr === undefined) && (missing0 = "ttl_msec_incr")){validate12$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ttl_msec_incr !== undefined){let data0 = data.ttl_msec_incr;const _errs1 = errors;{if(Array.isArray(data0)){var valid1 = true;const len0 = data0.length;for(let i0=0; i0<len0; i0++){let data1 = data0[i0];const _errs3 = errors;if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){validate12$1.errors = [{instancePath:instancePath+"/ttl_msec_incr/" + i0,schemaPath:"#/properties/ttl_msec_incr/items/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs3 === errors;if(!valid1){break;}}}else {validate12$1.errors = [{instancePath:instancePath+"/ttl_msec_incr",schemaPath:"#/properties/ttl_msec_incr/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.reason !== undefined){const _errs5 = errors;if(typeof data.reason !== "string"){validate12$1.errors = [{instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs5 === errors;}else {var valid0 = true;}}}}else {validate12$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate12$1.errors = vErrors;return errors === 0;}const validate_MsgWarp = validate13;function validate13(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.warp === undefined) && (missing0 = "warp")){validate13.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.warp !== undefined){let data0 = data.warp;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ttl_msec !== undefined){let data1 = data0.ttl_msec;const _errs3 = errors;if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){validate13.errors = [{instancePath:instancePath+"/warp/ttl_msec",schemaPath:"#/properties/warp/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.instantaneous !== undefined){const _errs5 = errors;if(typeof data0.instantaneous !== "boolean"){validate13.errors = [{instancePath:instancePath+"/warp/instantaneous",schemaPath:"#/properties/warp/properties/instantaneous/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs5 === errors;}else {var valid1 = true;}}}}else {validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate13.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate13.errors = vErrors;return errors === 0;}const validate_MsgEngage = validate14;function validate14(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.engage === undefined) && (missing0 = "engage")){validate14.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.engage !== undefined){let data0 = data.engage;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}}else {validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate14.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate14.errors = vErrors;return errors === 0;}
6
6
 
7
7
  // console.log('OUT', __name({variableName}) );
8
8
 
@@ -389,7 +389,7 @@ class Config {
389
389
 
390
390
  //-------------------------------------------------------------------------------------------------
391
391
 
392
- let k_VERSION= "0.6";
392
+ let k_VERSION= "0.7";
393
393
 
394
394
  var JSON_MsgOptions = (function() {
395
395
  return {
@@ -479,6 +479,11 @@ var JSON_MsgAckWarp = (function() {
479
479
  // json_msgAckWarp._msg= _msg;
480
480
  // return json_msgAckWarp;
481
481
  // }
482
+ create_with_msgOk : function(json_msgWarp, b_ok= true) {
483
+ const json_msgAck= JSON_MsgAck_1.create_with_msgOk(json_msgWarp, b_ok);
484
+ json_msgAck["2PhW"]= k_VERSION;
485
+ return json_msgAck;
486
+ },
482
487
  create_with_msgExpired : function( json_msgWarp ) {
483
488
  const json_msgAck= JSON_MsgAck_1.create_with_msgExpired( json_msgWarp );
484
489
  json_msgAck["2PhW"]= k_VERSION;
@@ -505,6 +510,16 @@ var JSON_MsgAckEngage = (function() {
505
510
  // json_msgAckEngage._msg= _msg;
506
511
  // return json_msgAckEngage;
507
512
  // }
513
+ create_with_msgOk : function(json_msgEngage, b_ok= true) {
514
+ const json_msgAck= JSON_MsgAck_1.create_with_msgOk(json_msgEngage, b_ok);
515
+ json_msgAck["2PhW"]= k_VERSION;
516
+ return json_msgAck;
517
+ },
518
+ create_with_msgExpired : function( json_msgEngage ) {
519
+ const json_msgAck= JSON_MsgAck_1.create_with_msgExpired( json_msgEngage );
520
+ json_msgAck["2PhW"]= k_VERSION;
521
+ return json_msgAck;
522
+ },
508
523
  validate : function(json) {
509
524
  if (! validate_Msg2PhW(json)) {
510
525
  LOGR_.log(l_.VALIDATION, 'JSON_MsgAckEngage: validate_Msg2PhW_: ', validate_Msg2PhW.errors);
@@ -590,6 +605,8 @@ class StateWarp {
590
605
  changeState(newState) {
591
606
  if (newState instanceof StateAckWarp)
592
607
  return true;
608
+ if (newState instanceof StateComplete)
609
+ return true;
593
610
  return false;
594
611
  }
595
612
  }
@@ -598,19 +615,21 @@ class StateAckWarp {
598
615
  changeState(newState) {
599
616
  if (newState instanceof StateEngage)
600
617
  return true;
618
+ if (newState instanceof StateComplete)
619
+ return true;
601
620
  return false;
602
621
  }
603
622
  }
604
623
 
605
624
  class StateEngage {
606
625
  changeState(newState) {
607
- if (newState instanceof StateAckEngage)
626
+ if (newState instanceof StateComplete)
608
627
  return true;
609
628
  return false;
610
629
  }
611
630
  }
612
631
 
613
- class StateAckEngage {
632
+ class StateComplete {
614
633
  changeState(newState) {
615
634
  return false;
616
635
  }
@@ -674,6 +693,13 @@ function handler_msgAckWarp_(cfg, msg, json_msgAckWarp)
674
693
  if (! cfg._callback_msgAckWarp(msg, json_msgAckWarp))
675
694
  return false;
676
695
 
696
+ if (json_msgWarp.warp.instantaneous) {
697
+ const b_res= ctx.protocol.changeState( new StateComplete() );
698
+ console.assert(b_res);
699
+
700
+ return true;
701
+ }
702
+
677
703
  const b_res= ctx.protocol.changeState( new StateEngage() );
678
704
  console.assert(b_res);
679
705
 
@@ -721,6 +747,13 @@ function handler_msgWarp_(cfg, msg, json_msgWarp)
721
747
  if (! cfg._callback_msgWarp(msg, json_msgWarp))
722
748
  return false;
723
749
 
750
+ if (json_msgWarp.warp.instantaneous) {
751
+ const b_res= ctx.protocol.changeState( new StateComplete() );
752
+ console.assert(b_res);
753
+
754
+ return true;
755
+ }
756
+
724
757
  const b_res= ctx.protocol.changeState( new StateAckWarp() );
725
758
  console.assert(b_res);
726
759
 
@@ -740,7 +773,7 @@ function handler_msgEngage_(cfg, msg, json_msgEngage)
740
773
  if (! cfg._callback_msgEngage(msg, json_msgEngage))
741
774
  return false;
742
775
 
743
- const b_res= ctx.protocol.changeState( new StateAckEngage() );
776
+ const b_res= ctx.protocol.changeState( new StateComplete() );
744
777
  console.assert(b_res);
745
778
 
746
779
  return true;
@@ -758,7 +791,7 @@ class TwoPhW {
758
791
  }
759
792
 
760
793
  // this function need to be removed when a microservice db is used instead of a state machine
761
- create_MsgWarp_out(str_id, json_user, json_hyperport, nr_ttl_msec)
794
+ create_MsgWarp_out(str_id, json_user, json_hyperport, nr_ttl_msec, b_instantaneous)
762
795
  {
763
796
  if (nr_ttl_msec === undefined)
764
797
  nr_ttl_msec= k_TTL;
@@ -766,9 +799,13 @@ class TwoPhW {
766
799
  const json_msgWarp= JSON_MsgWarp.create_with_user_hyperport(json_user, json_hyperport, nr_ttl_msec);
767
800
  json_msgWarp.id= str_id;
768
801
 
802
+ if (b_instantaneous !== undefined)
803
+ json_msgWarp.warp.instantaneous= b_instantaneous;
804
+
769
805
  const ctx= set_ctx(json_msgWarp.id, { protocol: new ProtocolStateState() });
770
806
  const b_res= ctx.protocol.changeState( new StateWarp(), nr_ttl_msec, function() {
771
807
  const json_Nack= JSON_MsgAckWarp.create_with_msgExpired( json_msgWarp );
808
+ //TODO: the referer is NULL here !
772
809
  this._config._callback_msgAckWarp(json_Nack, json_Nack);
773
810
  }.bind(this) );
774
811
 
@@ -1,4 +1,4 @@
1
- const validate_Msg2PhW = validate10$1;const pattern0 = new RegExp("0\\.6", "u");function validate10$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data["2PhW"] === undefined) && (missing0 = "2PhW")){validate10$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data["2PhW"] !== undefined){let data0 = data["2PhW"];{if(typeof data0 === "string"){if(!pattern0.test(data0)){validate10$1.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/pattern",keyword:"pattern",params:{pattern: "0\\.6"},message:"must match pattern \""+"0\\.6"+"\""}];return false;}}else {validate10$1.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}}}}else {validate10$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10$1.errors = vErrors;return errors === 0;}const validate_MsgOptions = validate11$1;function validate11$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.options === undefined) && (missing0 = "options")){validate11$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.options !== undefined){let data0 = data.options;if(!(data0 && typeof data0 == "object" && !Array.isArray(data0))){validate11$1.errors = [{instancePath:instancePath+"/options",schemaPath:"#/properties/options/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}else {validate11$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate11$1.errors = vErrors;return errors === 0;}const validate_Options_delay = validate12$1;function validate12$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ttl_msec_incr === undefined) && (missing0 = "ttl_msec_incr")){validate12$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ttl_msec !== undefined){if(!(Array.isArray(data.ttl_msec))){validate12$1.errors = [{instancePath:instancePath+"/ttl_msec",schemaPath:"#/properties/ttl_msec/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}}}else {validate12$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate12$1.errors = vErrors;return errors === 0;}const validate_MsgWarp = validate13;function validate13(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.warp === undefined) && (missing0 = "warp")){validate13.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.warp !== undefined){let data0 = data.warp;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ttl_msec !== undefined){let data1 = data0.ttl_msec;if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){validate13.errors = [{instancePath:instancePath+"/warp/ttl_msec",schemaPath:"#/properties/warp/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}}}}else {validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate13.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate13.errors = vErrors;return errors === 0;}const validate_MsgEngage = validate14;function validate14(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.engage === undefined) && (missing0 = "engage")){validate14.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.engage !== undefined){let data0 = data.engage;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}}else {validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate14.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate14.errors = vErrors;return errors === 0;}
1
+ const validate_Msg2PhW = validate10$1;const pattern0 = new RegExp("0\\.7", "u");function validate10$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data["2PhW"] === undefined) && (missing0 = "2PhW")){validate10$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data["2PhW"] !== undefined){let data0 = data["2PhW"];{if(typeof data0 === "string"){if(!pattern0.test(data0)){validate10$1.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/pattern",keyword:"pattern",params:{pattern: "0\\.7"},message:"must match pattern \""+"0\\.7"+"\""}];return false;}}else {validate10$1.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}}}}else {validate10$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10$1.errors = vErrors;return errors === 0;}const validate_MsgOptions = validate11$1;function validate11$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.options === undefined) && (missing0 = "options")){validate11$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.options !== undefined){let data0 = data.options;if(!(data0 && typeof data0 == "object" && !Array.isArray(data0))){validate11$1.errors = [{instancePath:instancePath+"/options",schemaPath:"#/properties/options/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}else {validate11$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate11$1.errors = vErrors;return errors === 0;}const validate_Options_delay = validate12$1;function validate12$1(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ttl_msec_incr === undefined) && (missing0 = "ttl_msec_incr")){validate12$1.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ttl_msec_incr !== undefined){let data0 = data.ttl_msec_incr;const _errs1 = errors;{if(Array.isArray(data0)){var valid1 = true;const len0 = data0.length;for(let i0=0; i0<len0; i0++){let data1 = data0[i0];const _errs3 = errors;if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){validate12$1.errors = [{instancePath:instancePath+"/ttl_msec_incr/" + i0,schemaPath:"#/properties/ttl_msec_incr/items/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs3 === errors;if(!valid1){break;}}}else {validate12$1.errors = [{instancePath:instancePath+"/ttl_msec_incr",schemaPath:"#/properties/ttl_msec_incr/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.reason !== undefined){const _errs5 = errors;if(typeof data.reason !== "string"){validate12$1.errors = [{instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs5 === errors;}else {var valid0 = true;}}}}else {validate12$1.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate12$1.errors = vErrors;return errors === 0;}const validate_MsgWarp = validate13;function validate13(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.warp === undefined) && (missing0 = "warp")){validate13.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.warp !== undefined){let data0 = data.warp;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ttl_msec !== undefined){let data1 = data0.ttl_msec;const _errs3 = errors;if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){validate13.errors = [{instancePath:instancePath+"/warp/ttl_msec",schemaPath:"#/properties/warp/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.instantaneous !== undefined){const _errs5 = errors;if(typeof data0.instantaneous !== "boolean"){validate13.errors = [{instancePath:instancePath+"/warp/instantaneous",schemaPath:"#/properties/warp/properties/instantaneous/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs5 === errors;}else {var valid1 = true;}}}}else {validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate13.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate13.errors = vErrors;return errors === 0;}const validate_MsgEngage = validate14;function validate14(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.engage === undefined) && (missing0 = "engage")){validate14.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.engage !== undefined){let data0 = data.engage;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}}else {validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate14.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate14.errors = vErrors;return errors === 0;}
2
2
 
3
3
  // console.log('OUT', __name({variableName}) );
4
4
 
@@ -385,7 +385,7 @@ class Config {
385
385
 
386
386
  //-------------------------------------------------------------------------------------------------
387
387
 
388
- let k_VERSION= "0.6";
388
+ let k_VERSION= "0.7";
389
389
 
390
390
  var JSON_MsgOptions = (function() {
391
391
  return {
@@ -475,6 +475,11 @@ var JSON_MsgAckWarp = (function() {
475
475
  // json_msgAckWarp._msg= _msg;
476
476
  // return json_msgAckWarp;
477
477
  // }
478
+ create_with_msgOk : function(json_msgWarp, b_ok= true) {
479
+ const json_msgAck= JSON_MsgAck_1.create_with_msgOk(json_msgWarp, b_ok);
480
+ json_msgAck["2PhW"]= k_VERSION;
481
+ return json_msgAck;
482
+ },
478
483
  create_with_msgExpired : function( json_msgWarp ) {
479
484
  const json_msgAck= JSON_MsgAck_1.create_with_msgExpired( json_msgWarp );
480
485
  json_msgAck["2PhW"]= k_VERSION;
@@ -501,6 +506,16 @@ var JSON_MsgAckEngage = (function() {
501
506
  // json_msgAckEngage._msg= _msg;
502
507
  // return json_msgAckEngage;
503
508
  // }
509
+ create_with_msgOk : function(json_msgEngage, b_ok= true) {
510
+ const json_msgAck= JSON_MsgAck_1.create_with_msgOk(json_msgEngage, b_ok);
511
+ json_msgAck["2PhW"]= k_VERSION;
512
+ return json_msgAck;
513
+ },
514
+ create_with_msgExpired : function( json_msgEngage ) {
515
+ const json_msgAck= JSON_MsgAck_1.create_with_msgExpired( json_msgEngage );
516
+ json_msgAck["2PhW"]= k_VERSION;
517
+ return json_msgAck;
518
+ },
504
519
  validate : function(json) {
505
520
  if (! validate_Msg2PhW(json)) {
506
521
  LOGR_.log(l_.VALIDATION, 'JSON_MsgAckEngage: validate_Msg2PhW_: ', validate_Msg2PhW.errors);
@@ -586,6 +601,8 @@ class StateWarp {
586
601
  changeState(newState) {
587
602
  if (newState instanceof StateAckWarp)
588
603
  return true;
604
+ if (newState instanceof StateComplete)
605
+ return true;
589
606
  return false;
590
607
  }
591
608
  }
@@ -594,19 +611,21 @@ class StateAckWarp {
594
611
  changeState(newState) {
595
612
  if (newState instanceof StateEngage)
596
613
  return true;
614
+ if (newState instanceof StateComplete)
615
+ return true;
597
616
  return false;
598
617
  }
599
618
  }
600
619
 
601
620
  class StateEngage {
602
621
  changeState(newState) {
603
- if (newState instanceof StateAckEngage)
622
+ if (newState instanceof StateComplete)
604
623
  return true;
605
624
  return false;
606
625
  }
607
626
  }
608
627
 
609
- class StateAckEngage {
628
+ class StateComplete {
610
629
  changeState(newState) {
611
630
  return false;
612
631
  }
@@ -670,6 +689,13 @@ function handler_msgAckWarp_(cfg, msg, json_msgAckWarp)
670
689
  if (! cfg._callback_msgAckWarp(msg, json_msgAckWarp))
671
690
  return false;
672
691
 
692
+ if (json_msgWarp.warp.instantaneous) {
693
+ const b_res= ctx.protocol.changeState( new StateComplete() );
694
+ console.assert(b_res);
695
+
696
+ return true;
697
+ }
698
+
673
699
  const b_res= ctx.protocol.changeState( new StateEngage() );
674
700
  console.assert(b_res);
675
701
 
@@ -717,6 +743,13 @@ function handler_msgWarp_(cfg, msg, json_msgWarp)
717
743
  if (! cfg._callback_msgWarp(msg, json_msgWarp))
718
744
  return false;
719
745
 
746
+ if (json_msgWarp.warp.instantaneous) {
747
+ const b_res= ctx.protocol.changeState( new StateComplete() );
748
+ console.assert(b_res);
749
+
750
+ return true;
751
+ }
752
+
720
753
  const b_res= ctx.protocol.changeState( new StateAckWarp() );
721
754
  console.assert(b_res);
722
755
 
@@ -736,7 +769,7 @@ function handler_msgEngage_(cfg, msg, json_msgEngage)
736
769
  if (! cfg._callback_msgEngage(msg, json_msgEngage))
737
770
  return false;
738
771
 
739
- const b_res= ctx.protocol.changeState( new StateAckEngage() );
772
+ const b_res= ctx.protocol.changeState( new StateComplete() );
740
773
  console.assert(b_res);
741
774
 
742
775
  return true;
@@ -754,7 +787,7 @@ class TwoPhW {
754
787
  }
755
788
 
756
789
  // this function need to be removed when a microservice db is used instead of a state machine
757
- create_MsgWarp_out(str_id, json_user, json_hyperport, nr_ttl_msec)
790
+ create_MsgWarp_out(str_id, json_user, json_hyperport, nr_ttl_msec, b_instantaneous)
758
791
  {
759
792
  if (nr_ttl_msec === undefined)
760
793
  nr_ttl_msec= k_TTL;
@@ -762,9 +795,13 @@ class TwoPhW {
762
795
  const json_msgWarp= JSON_MsgWarp.create_with_user_hyperport(json_user, json_hyperport, nr_ttl_msec);
763
796
  json_msgWarp.id= str_id;
764
797
 
798
+ if (b_instantaneous !== undefined)
799
+ json_msgWarp.warp.instantaneous= b_instantaneous;
800
+
765
801
  const ctx= set_ctx(json_msgWarp.id, { protocol: new ProtocolStateState() });
766
802
  const b_res= ctx.protocol.changeState( new StateWarp(), nr_ttl_msec, function() {
767
803
  const json_Nack= JSON_MsgAckWarp.create_with_msgExpired( json_msgWarp );
804
+ //TODO: the referer is NULL here !
768
805
  this._config._callback_msgAckWarp(json_Nack, json_Nack);
769
806
  }.bind(this) );
770
807
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rootintf/protocol-2phw",
3
- "version": "0.6.10",
3
+ "version": "0.7.1",
4
4
  "description": "",
5
5
  "main": "dist/twoPhW.cjs.js",
6
6
  "browser": "dist/twoPhW.es.mjs",
@@ -6,7 +6,7 @@
6
6
  "properties" : {
7
7
  "2PhW" : {
8
8
  "type" : "string",
9
- "pattern": "0\\.6"
9
+ "pattern": "0\\.7"
10
10
  }
11
11
  }
12
12
  }
@@ -9,7 +9,11 @@
9
9
  "required" : ["user", "hyperport"],
10
10
  "properties": {
11
11
  "ttl_msec" : {
12
- "type" : "integer"}
12
+ "type" : "integer"
13
+ },
14
+ "instantaneous" : {
15
+ "type" : "boolean"
16
+ }
13
17
  }
14
18
  }
15
19
  }
@@ -4,8 +4,14 @@
4
4
  "type" : "object",
5
5
  "required" : ["ttl_msec_incr"],
6
6
  "properties" : {
7
- "ttl_msec" : {
8
- "type" : "array"
7
+ "ttl_msec_incr" : {
8
+ "type" : "array",
9
+ "items": {
10
+ "type" : "integer"
11
+ }
12
+ },
13
+ "reason" : {
14
+ "type" : "string"
9
15
  }
10
16
  }
11
17
  }
package/src/twoPhW.mjs CHANGED
@@ -80,7 +80,7 @@ class Config {
80
80
 
81
81
  //-------------------------------------------------------------------------------------------------
82
82
 
83
- let k_VERSION= "0.6";
83
+ let k_VERSION= "0.7";
84
84
 
85
85
  var JSON_MsgOptions = (function() {
86
86
  return {
@@ -170,6 +170,11 @@ var JSON_MsgAckWarp = (function() {
170
170
  // json_msgAckWarp._msg= _msg;
171
171
  // return json_msgAckWarp;
172
172
  // }
173
+ create_with_msgOk : function(json_msgWarp, b_ok= true) {
174
+ const json_msgAck= JSON_MsgAck.create_with_msgOk(json_msgWarp, b_ok);
175
+ json_msgAck["2PhW"]= k_VERSION;
176
+ return json_msgAck;
177
+ },
173
178
  create_with_msgExpired : function( json_msgWarp ) {
174
179
  const json_msgAck= JSON_MsgAck.create_with_msgExpired( json_msgWarp )
175
180
  json_msgAck["2PhW"]= k_VERSION;
@@ -196,6 +201,16 @@ var JSON_MsgAckEngage = (function() {
196
201
  // json_msgAckEngage._msg= _msg;
197
202
  // return json_msgAckEngage;
198
203
  // }
204
+ create_with_msgOk : function(json_msgEngage, b_ok= true) {
205
+ const json_msgAck= JSON_MsgAck.create_with_msgOk(json_msgEngage, b_ok);
206
+ json_msgAck["2PhW"]= k_VERSION;
207
+ return json_msgAck;
208
+ },
209
+ create_with_msgExpired : function( json_msgEngage ) {
210
+ const json_msgAck= JSON_MsgAck.create_with_msgExpired( json_msgEngage )
211
+ json_msgAck["2PhW"]= k_VERSION;
212
+ return json_msgAck;
213
+ },
199
214
  validate : function(json) {
200
215
  if (! validate_Msg2PhW_(json)) {
201
216
  LOGR_.log(l_.VALIDATION, 'JSON_MsgAckEngage: validate_Msg2PhW_: ', validate_Msg2PhW_.errors)
@@ -281,6 +296,8 @@ class StateWarp {
281
296
  changeState(newState) {
282
297
  if (newState instanceof StateAckWarp)
283
298
  return true;
299
+ if (newState instanceof StateComplete)
300
+ return true;
284
301
  return false;
285
302
  }
286
303
  }
@@ -289,24 +306,20 @@ class StateAckWarp {
289
306
  changeState(newState) {
290
307
  if (newState instanceof StateEngage)
291
308
  return true;
309
+ if (newState instanceof StateComplete)
310
+ return true;
292
311
  return false;
293
312
  }
294
313
  }
295
314
 
296
315
  class StateEngage {
297
316
  changeState(newState) {
298
- if (newState instanceof StateAckEngage)
317
+ if (newState instanceof StateComplete)
299
318
  return true;
300
319
  return false;
301
320
  }
302
321
  }
303
322
 
304
- class StateAckEngage {
305
- changeState(newState) {
306
- return false;
307
- }
308
- }
309
-
310
323
  class StateComplete {
311
324
  changeState(newState) {
312
325
  return false;
@@ -371,6 +384,13 @@ function handler_msgAckWarp_(cfg, msg, json_msgAckWarp)
371
384
  if (! cfg._callback_msgAckWarp(msg, json_msgAckWarp))
372
385
  return false;
373
386
 
387
+ if (json_msgWarp.warp.instantaneous) {
388
+ const b_res= ctx.protocol.changeState( new StateComplete() );
389
+ console.assert(b_res);
390
+
391
+ return true;
392
+ }
393
+
374
394
  const b_res= ctx.protocol.changeState( new StateEngage() );
375
395
  console.assert(b_res);
376
396
 
@@ -418,6 +438,13 @@ function handler_msgWarp_(cfg, msg, json_msgWarp)
418
438
  if (! cfg._callback_msgWarp(msg, json_msgWarp))
419
439
  return false;
420
440
 
441
+ if (json_msgWarp.warp.instantaneous) {
442
+ const b_res= ctx.protocol.changeState( new StateComplete() );
443
+ console.assert(b_res);
444
+
445
+ return true;
446
+ }
447
+
421
448
  const b_res= ctx.protocol.changeState( new StateAckWarp() );
422
449
  console.assert(b_res);
423
450
 
@@ -437,7 +464,7 @@ function handler_msgEngage_(cfg, msg, json_msgEngage)
437
464
  if (! cfg._callback_msgEngage(msg, json_msgEngage))
438
465
  return false;
439
466
 
440
- const b_res= ctx.protocol.changeState( new StateAckEngage() );
467
+ const b_res= ctx.protocol.changeState( new StateComplete() );
441
468
  console.assert(b_res);
442
469
 
443
470
  return true;
@@ -455,7 +482,7 @@ class TwoPhW {
455
482
  }
456
483
 
457
484
  // this function need to be removed when a microservice db is used instead of a state machine
458
- create_MsgWarp_out(str_id, json_user, json_hyperport, nr_ttl_msec)
485
+ create_MsgWarp_out(str_id, json_user, json_hyperport, nr_ttl_msec, b_instantaneous)
459
486
  {
460
487
  if (nr_ttl_msec === undefined)
461
488
  nr_ttl_msec= k_TTL;
@@ -463,9 +490,13 @@ class TwoPhW {
463
490
  const json_msgWarp= JSON_MsgWarp.create_with_user_hyperport(json_user, json_hyperport, nr_ttl_msec);
464
491
  json_msgWarp.id= str_id;
465
492
 
493
+ if (b_instantaneous !== undefined)
494
+ json_msgWarp.warp.instantaneous= b_instantaneous;
495
+
466
496
  const ctx= set_ctx(json_msgWarp.id, { protocol: new ProtocolStateState() });
467
497
  const b_res= ctx.protocol.changeState( new StateWarp(), nr_ttl_msec, function() {
468
498
  const json_Nack= JSON_MsgAckWarp.create_with_msgExpired( json_msgWarp );
499
+ //TODO: the referer is NULL here !
469
500
  this._config._callback_msgAckWarp(json_Nack, json_Nack);
470
501
  }.bind(this) );
471
502
 
@@ -1 +1 @@
1
- "use strict";export const validate_Msg2PhW = validate10;const schema11 = {"$id":"validate_Msg2PhW","$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["2PhW"],"properties":{"2PhW":{"type":"string","pattern":"0\\.6"}}};const pattern0 = new RegExp("0\\.6", "u");function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="validate_Msg2PhW" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data["2PhW"] === undefined) && (missing0 = "2PhW")){validate10.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data["2PhW"] !== undefined){let data0 = data["2PhW"];const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(!pattern0.test(data0)){validate10.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/pattern",keyword:"pattern",params:{pattern: "0\\.6"},message:"must match pattern \""+"0\\.6"+"\""}];return false;}}else {validate10.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}}}}else {validate10.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10.errors = vErrors;return errors === 0;}export const validate_MsgOptions = validate11;const schema12 = {"$id":"validate_MsgOptions","$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["options"],"properties":{"options":{"type":"object"}}};function validate11(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="validate_MsgOptions" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.options === undefined) && (missing0 = "options")){validate11.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.options !== undefined){let data0 = data.options;if(!(data0 && typeof data0 == "object" && !Array.isArray(data0))){validate11.errors = [{instancePath:instancePath+"/options",schemaPath:"#/properties/options/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}else {validate11.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate11.errors = vErrors;return errors === 0;}export const validate_Options_delay = validate12;const schema13 = {"$id":"validate_Options_delay","$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["ttl_msec_incr"],"properties":{"ttl_msec":{"type":"array"}}};function validate12(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="validate_Options_delay" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ttl_msec_incr === undefined) && (missing0 = "ttl_msec_incr")){validate12.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ttl_msec !== undefined){if(!(Array.isArray(data.ttl_msec))){validate12.errors = [{instancePath:instancePath+"/ttl_msec",schemaPath:"#/properties/ttl_msec/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}}}else {validate12.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate12.errors = vErrors;return errors === 0;}export const validate_MsgWarp = validate13;const schema14 = {"$id":"validate_MsgWarp","$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["warp"],"properties":{"warp":{"type":"object","required":["user","hyperport"],"properties":{"ttl_msec":{"type":"integer"}}}}};function validate13(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="validate_MsgWarp" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.warp === undefined) && (missing0 = "warp")){validate13.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.warp !== undefined){let data0 = data.warp;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ttl_msec !== undefined){let data1 = data0.ttl_msec;if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){validate13.errors = [{instancePath:instancePath+"/warp/ttl_msec",schemaPath:"#/properties/warp/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}}}}else {validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate13.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate13.errors = vErrors;return errors === 0;}export const validate_MsgEngage = validate14;const schema15 = {"$id":"validate_MsgEngage","$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["engage"],"properties":{"engage":{"type":"object","required":["user","hyperport"]}}};function validate14(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="validate_MsgEngage" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.engage === undefined) && (missing0 = "engage")){validate14.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.engage !== undefined){let data0 = data.engage;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}}else {validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate14.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate14.errors = vErrors;return errors === 0;}
1
+ "use strict";export const validate_Msg2PhW = validate10;const schema11 = {"$id":"validate_Msg2PhW","$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["2PhW"],"properties":{"2PhW":{"type":"string","pattern":"0\\.7"}}};const pattern0 = new RegExp("0\\.7", "u");function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="validate_Msg2PhW" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data["2PhW"] === undefined) && (missing0 = "2PhW")){validate10.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data["2PhW"] !== undefined){let data0 = data["2PhW"];const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(!pattern0.test(data0)){validate10.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/pattern",keyword:"pattern",params:{pattern: "0\\.7"},message:"must match pattern \""+"0\\.7"+"\""}];return false;}}else {validate10.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"#/properties/2PhW/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}}}}else {validate10.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10.errors = vErrors;return errors === 0;}export const validate_MsgOptions = validate11;const schema12 = {"$id":"validate_MsgOptions","$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["options"],"properties":{"options":{"type":"object"}}};function validate11(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="validate_MsgOptions" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.options === undefined) && (missing0 = "options")){validate11.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.options !== undefined){let data0 = data.options;if(!(data0 && typeof data0 == "object" && !Array.isArray(data0))){validate11.errors = [{instancePath:instancePath+"/options",schemaPath:"#/properties/options/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}else {validate11.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate11.errors = vErrors;return errors === 0;}export const validate_Options_delay = validate12;const schema13 = {"$id":"validate_Options_delay","$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["ttl_msec_incr"],"properties":{"ttl_msec_incr":{"type":"array","items":{"type":"integer"}},"reason":{"type":"string"}}};function validate12(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="validate_Options_delay" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ttl_msec_incr === undefined) && (missing0 = "ttl_msec_incr")){validate12.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ttl_msec_incr !== undefined){let data0 = data.ttl_msec_incr;const _errs1 = errors;if(errors === _errs1){if(Array.isArray(data0)){var valid1 = true;const len0 = data0.length;for(let i0=0; i0<len0; i0++){let data1 = data0[i0];const _errs3 = errors;if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){validate12.errors = [{instancePath:instancePath+"/ttl_msec_incr/" + i0,schemaPath:"#/properties/ttl_msec_incr/items/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs3 === errors;if(!valid1){break;}}}else {validate12.errors = [{instancePath:instancePath+"/ttl_msec_incr",schemaPath:"#/properties/ttl_msec_incr/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.reason !== undefined){const _errs5 = errors;if(typeof data.reason !== "string"){validate12.errors = [{instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs5 === errors;}else {var valid0 = true;}}}}else {validate12.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate12.errors = vErrors;return errors === 0;}export const validate_MsgWarp = validate13;const schema14 = {"$id":"validate_MsgWarp","$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["warp"],"properties":{"warp":{"type":"object","required":["user","hyperport"],"properties":{"ttl_msec":{"type":"integer"},"instantaneous":{"type":"boolean"}}}}};function validate13(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="validate_MsgWarp" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.warp === undefined) && (missing0 = "warp")){validate13.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.warp !== undefined){let data0 = data.warp;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ttl_msec !== undefined){let data1 = data0.ttl_msec;const _errs3 = errors;if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){validate13.errors = [{instancePath:instancePath+"/warp/ttl_msec",schemaPath:"#/properties/warp/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.instantaneous !== undefined){const _errs5 = errors;if(typeof data0.instantaneous !== "boolean"){validate13.errors = [{instancePath:instancePath+"/warp/instantaneous",schemaPath:"#/properties/warp/properties/instantaneous/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs5 === errors;}else {var valid1 = true;}}}}else {validate13.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate13.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate13.errors = vErrors;return errors === 0;}export const validate_MsgEngage = validate14;const schema15 = {"$id":"validate_MsgEngage","$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["engage"],"properties":{"engage":{"type":"object","required":["user","hyperport"]}}};function validate14(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="validate_MsgEngage" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.engage === undefined) && (missing0 = "engage")){validate14.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.engage !== undefined){let data0 = data.engage;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.user === undefined) && (missing1 = "user")) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))){validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}}else {validate14.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate14.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate14.errors = vErrors;return errors === 0;}
@@ -1,4 +1,12 @@
1
1
 
2
+ import {
3
+ validate_Msg2PhW as validate_Msg2PhW_,
4
+ validate_MsgOptions as validate_MsgOptions_,
5
+ validate_Options_delay as validate_Options_delay_,
6
+ validate_MsgWarp as validate_MsgWarp_,
7
+ validate_MsgEngage as validate_MsgEngage_
8
+ } from '../src/validate-esm.mjs';
9
+
2
10
  import { v4 as uuidv4 } from 'uuid';
3
11
  import { TwoPhW, JSON_MsgOptions, JSON_MsgWarp, JSON_MsgEngage, JSON_MsgAckWarp, JSON_MsgAckEngage, l as l_2PhW } from '../src/twoPhW.mjs';
4
12
  import { JSON_Msg, JSON_Msg_msg, JSON_MsgAck } from '@rootintf/json-msg'
@@ -69,11 +77,14 @@ const json_msgAckEngage_ = {
69
77
  "2PhW": k_VERSION
70
78
  }
71
79
 
80
+ //TODO: "required" : ["reason"],
72
81
  const json_msgOptions_ = {
73
82
  id: "f5d6c2b8-1481-49b2-882c-262bb1c9ef8c",
74
83
  referer: ["twoPhW", "af9447e3-4b36-424f-8d07-976a9216a298"],
75
84
  dt: "2022-10-28T06:26:19.692Z",
76
85
  options: {
86
+ ttl_msec_incr : [ 20000, 4000 ],
87
+ reason : "it is taking too long"
77
88
  },
78
89
  "_msg" : json_msgWarp_,
79
90
  "2PhW": k_VERSION
@@ -90,6 +101,9 @@ describe("Validation", function () {
90
101
  it("twoPhW.JSON_MsgOptions.validate(json_msgOptions_)", function () {
91
102
  expect( JSON_MsgOptions.validate(json_msgOptions_) ).toBe(true);
92
103
  });
104
+ it("validate_Options_delay_(json_msgOptions_.options)", function () {
105
+ expect( validate_Options_delay_(json_msgOptions_.options) ).toBe(true);
106
+ });
93
107
  });
94
108
 
95
109
  describe("Validation", function () {