@rootintf/protocol-subverseinfo 0.0.4-api-0.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.
@@ -0,0 +1,379 @@
1
+ const schema_SubverseInfo_discovery = 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.discovery === undefined) && (missing0 = "discovery")) || ((data.subverse_info === undefined) && (missing0 = "subverse_info"))){validate19.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.discovery !== undefined){let data0 = data.discovery;const _errs1 = errors;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if((((data0.name === undefined) && (missing1 = "name")) || ((data0.graphql === undefined) && (missing1 = "graphql"))) || ((data0.ttl_msec === undefined) && (missing1 = "ttl_msec"))){validate19.errors = [{instancePath:instancePath+"/discovery",schemaPath:"#/properties/discovery/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.name !== undefined){const _errs3 = errors;if(typeof data0.name !== "string"){validate19.errors = [{instancePath:instancePath+"/discovery/name",schemaPath:"#/properties/discovery/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.graphql !== undefined){const _errs5 = errors;if(typeof data0.graphql !== "string"){validate19.errors = [{instancePath:instancePath+"/discovery/graphql",schemaPath:"#/properties/discovery/properties/graphql/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs5 === errors;}else {var valid1 = true;}if(valid1){if(data0.ttl_msec !== undefined){let data3 = data0.ttl_msec;const _errs7 = errors;if(!(((typeof data3 == "number") && (!(data3 % 1) && !isNaN(data3))) && (isFinite(data3)))){validate19.errors = [{instancePath:instancePath+"/discovery/ttl_msec",schemaPath:"#/properties/discovery/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs7 === errors;}else {var valid1 = true;}}}}}else {validate19.errors = [{instancePath:instancePath+"/discovery",schemaPath:"#/properties/discovery/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.subverse_info !== undefined){const _errs9 = errors;if("0.1" !== data.subverse_info){validate19.errors = [{instancePath:instancePath+"/subverse_info",schemaPath:"definitions_SubverseInfo#/definitions/_v/const",keyword:"const",params:{allowedValue: "0.1"},message:"must be equal to constant"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}}}}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 = {"props":{"discovery":true,"subverse_info":true},"dynamicProps":false,"dynamicItems":false};const schema_SubverseInfo_expanse = validate20;function validate21(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate21.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.name === undefined) && (missing0 = "name")) || ((data.uri === undefined) && (missing0 = "uri"))){validate21.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.name !== undefined){const _errs1 = errors;if(typeof data.name !== "string"){validate21.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.uri !== undefined){const _errs3 = errors;if(typeof data.uri !== "string"){validate21.errors = [{instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.favicon !== undefined){const _errs5 = errors;if(typeof data.favicon !== "string"){validate21.errors = [{instancePath:instancePath+"/favicon",schemaPath:"#/properties/favicon/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.info !== undefined){let data3 = data.info;const _errs7 = errors;if(!(data3 && typeof data3 == "object" && !Array.isArray(data3))){validate21.errors = [{instancePath:instancePath+"/info",schemaPath:"definitions_SubverseInfo#/definitions/info/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}}}}}}else {validate21.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate21.errors = vErrors;return errors === 0;}validate21.evaluated = {"props":{"name":true,"uri":true,"favicon":true,"info":true},"dynamicProps":false,"dynamicItems":false};function validate24(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate24.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.name === undefined) && (missing0 = "name")) || ((data.uri === undefined) && (missing0 = "uri"))){validate24.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.name !== undefined){const _errs1 = errors;if(typeof data.name !== "string"){validate24.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.uri !== undefined){const _errs3 = errors;if(typeof data.uri !== "string"){validate24.errors = [{instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.favicon !== undefined){const _errs5 = errors;if(typeof data.favicon !== "string"){validate24.errors = [{instancePath:instancePath+"/favicon",schemaPath:"#/properties/favicon/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.info !== undefined){let data3 = data.info;const _errs7 = errors;if(!(data3 && typeof data3 == "object" && !Array.isArray(data3))){validate24.errors = [{instancePath:instancePath+"/info",schemaPath:"definitions_SubverseInfo#/definitions/info/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}}}}}}else {validate24.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate24.errors = vErrors;return errors === 0;}validate24.evaluated = {"props":{"name":true,"uri":true,"favicon":true,"info":true},"dynamicProps":false,"dynamicItems":false};function validate23(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate23.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(Array.isArray(data)){var valid0 = true;const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];const _errs1 = errors;if(!(validate24(data0, {instancePath:instancePath+"/" + i0,parentData:data,parentDataProperty:i0,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate24.errors : vErrors.concat(validate24.errors);errors = vErrors.length;}if(errors === _errs1){if(!(data0 && typeof data0 == "object" && !Array.isArray(data0))){validate23.errors = [{instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;if(!valid0){break;}}}else {validate23.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}validate23.errors = vErrors;return errors === 0;}validate23.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};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(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if(((data.expanse === undefined) && (missing0 = "expanse")) || ((data.subverse_info === undefined) && (missing0 = "subverse_info"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.expanse !== undefined){let data0 = data.expanse;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.subverse === undefined) && (missing1 = "subverse")) || ((data0.protocols === undefined) && (missing1 = "protocols"))){validate20.errors = [{instancePath:instancePath+"/expanse",schemaPath:"#/properties/expanse/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.subverse !== undefined){let data1 = data0.subverse;const _errs3 = errors;if(!(validate21(data1, {instancePath:instancePath+"/expanse/subverse",parentData:data0,parentDataProperty:"subverse",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate21.errors : vErrors.concat(validate21.errors);errors = vErrors.length;}if(errors === _errs3){if(data1 && typeof data1 == "object" && !Array.isArray(data1)){let missing2;if((data1.map_url === undefined) && (missing2 = "map_url")){validate20.errors = [{instancePath:instancePath+"/expanse/subverse",schemaPath:"#/properties/expanse/properties/subverse/required",keyword:"required",params:{missingProperty: missing2},message:"must have required property '"+missing2+"'"}];return false;}else {if(data1.map_url !== undefined){if(typeof data1.map_url !== "string"){validate20.errors = [{instancePath:instancePath+"/expanse/subverse/map_url",schemaPath:"#/properties/expanse/properties/subverse/properties/map_url/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/expanse/subverse",schemaPath:"#/properties/expanse/properties/subverse/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.instances !== undefined){const _errs8 = errors;if(!(validate23(data0.instances, {instancePath:instancePath+"/expanse/instances",parentData:data0,parentDataProperty:"instances",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate23.errors : vErrors.concat(validate23.errors);errors = vErrors.length;}var valid1 = _errs8 === errors;}else {var valid1 = true;}if(valid1){if(data0.platforms !== undefined){let data4 = data0.platforms;const _errs9 = errors;const _errs10 = errors;if(errors === _errs10){if(Array.isArray(data4)){var valid5 = true;const len0 = data4.length;for(let i0=0; i0<len0; i0++){let data5 = data4[i0];const _errs12 = errors;if(errors === _errs12){if(data5 && typeof data5 == "object" && !Array.isArray(data5)){let missing3;if((data5.name === undefined) && (missing3 = "name")){validate20.errors = [{instancePath:instancePath+"/expanse/platforms/" + i0,schemaPath:"definitions_SubverseInfo#/definitions/platforms/items/required",keyword:"required",params:{missingProperty: missing3},message:"must have required property '"+missing3+"'"}];return false;}else {if(data5.name !== undefined){const _errs14 = errors;if(typeof data5.name !== "string"){validate20.errors = [{instancePath:instancePath+"/expanse/platforms/" + i0+"/name",schemaPath:"definitions_SubverseInfo#/definitions/platforms/items/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid6 = _errs14 === errors;}else {var valid6 = true;}if(valid6){if(data5.archs !== undefined){let data7 = data5.archs;const _errs16 = errors;if(errors === _errs16){if(Array.isArray(data7)){var valid7 = true;const len1 = data7.length;for(let i1=0; i1<len1; i1++){const _errs18 = errors;if(typeof data7[i1] !== "string"){validate20.errors = [{instancePath:instancePath+"/expanse/platforms/" + i0+"/archs/" + i1,schemaPath:"definitions_SubverseInfo#/definitions/platforms/items/properties/archs/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid7 = _errs18 === errors;if(!valid7){break;}}}else {validate20.errors = [{instancePath:instancePath+"/expanse/platforms/" + i0+"/archs",schemaPath:"definitions_SubverseInfo#/definitions/platforms/items/properties/archs/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid6 = _errs16 === errors;}else {var valid6 = true;}if(valid6){if(data5.agents !== undefined){let data9 = data5.agents;const _errs20 = errors;if(errors === _errs20){if(Array.isArray(data9)){var valid8 = true;const len2 = data9.length;for(let i2=0; i2<len2; i2++){const _errs22 = errors;if(typeof data9[i2] !== "string"){validate20.errors = [{instancePath:instancePath+"/expanse/platforms/" + i0+"/agents/" + i2,schemaPath:"definitions_SubverseInfo#/definitions/platforms/items/properties/agents/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid8 = _errs22 === errors;if(!valid8){break;}}}else {validate20.errors = [{instancePath:instancePath+"/expanse/platforms/" + i0+"/agents",schemaPath:"definitions_SubverseInfo#/definitions/platforms/items/properties/agents/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid6 = _errs20 === errors;}else {var valid6 = true;}}}}}else {validate20.errors = [{instancePath:instancePath+"/expanse/platforms/" + i0,schemaPath:"definitions_SubverseInfo#/definitions/platforms/items/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid5 = _errs12 === errors;if(!valid5){break;}}}else {validate20.errors = [{instancePath:instancePath+"/expanse/platforms",schemaPath:"definitions_SubverseInfo#/definitions/platforms/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid1 = _errs9 === errors;}else {var valid1 = true;}if(valid1){if(data0.protocols !== undefined){let data11 = data0.protocols;const _errs24 = errors;const _errs25 = errors;if(errors === _errs25){if(Array.isArray(data11)){var valid10 = true;const len3 = data11.length;for(let i3=0; i3<len3; i3++){let data12 = data11[i3];const _errs27 = errors;if(errors === _errs27){if(data12 && typeof data12 == "object" && !Array.isArray(data12)){let missing4;if(((data12.name === undefined) && (missing4 = "name")) || ((data12.attr === undefined) && (missing4 = "attr"))){validate20.errors = [{instancePath:instancePath+"/expanse/protocols/" + i3,schemaPath:"definitions_SubverseInfo#/definitions/protocols/items/required",keyword:"required",params:{missingProperty: missing4},message:"must have required property '"+missing4+"'"}];return false;}else {if(data12.name !== undefined){const _errs29 = errors;if(typeof data12.name !== "string"){validate20.errors = [{instancePath:instancePath+"/expanse/protocols/" + i3+"/name",schemaPath:"definitions_SubverseInfo#/definitions/protocols/items/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid11 = _errs29 === errors;}else {var valid11 = true;}if(valid11){if(data12.attr !== undefined){const _errs31 = errors;if(typeof data12.attr !== "string"){validate20.errors = [{instancePath:instancePath+"/expanse/protocols/" + i3+"/attr",schemaPath:"definitions_SubverseInfo#/definitions/protocols/items/properties/attr/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid11 = _errs31 === errors;}else {var valid11 = true;}if(valid11){if(data12.url !== undefined){const _errs33 = errors;if(typeof data12.url !== "string"){validate20.errors = [{instancePath:instancePath+"/expanse/protocols/" + i3+"/url",schemaPath:"definitions_SubverseInfo#/definitions/protocols/items/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid11 = _errs33 === errors;}else {var valid11 = true;}}}}}else {validate20.errors = [{instancePath:instancePath+"/expanse/protocols/" + i3,schemaPath:"definitions_SubverseInfo#/definitions/protocols/items/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid10 = _errs27 === errors;if(!valid10){break;}}}else {validate20.errors = [{instancePath:instancePath+"/expanse/protocols",schemaPath:"definitions_SubverseInfo#/definitions/protocols/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid1 = _errs24 === errors;}else {var valid1 = true;}}}}}}else {validate20.errors = [{instancePath:instancePath+"/expanse",schemaPath:"#/properties/expanse/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.subverse_info !== undefined){const _errs35 = errors;if("0.1" !== data.subverse_info){validate20.errors = [{instancePath:instancePath+"/subverse_info",schemaPath:"definitions_SubverseInfo#/definitions/_v/const",keyword:"const",params:{allowedValue: "0.1"},message:"must be equal to constant"}];return false;}var valid0 = _errs35 === errors;}else {var valid0 = true;}}}}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":{"expanse":true,"subverse_info":true},"dynamicProps":false,"dynamicItems":false};
2
+
3
+ // console.log('OUT', __name({variableName}) );
4
+
5
+ function l_toBigInt_(ref, obj, ignore= false) {
6
+ console.assert(ref !== BigInt(0), 'no labels initialized');
7
+ let bigInt = BigInt(0);
8
+ for (const [k,v] of Object.entries(obj)) {
9
+ if ( ( ignore || v ) && ref[k])
10
+ bigInt|= BigInt( ref[k] );
11
+ // console.log('0b'+ bigInt.toString(2) );
12
+ }
13
+ return bigInt;
14
+ }
15
+
16
+ //-------------------------------------------------------------------------------------------------
17
+
18
+ function handler_default_( /* ... */ ) {
19
+ // https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
20
+ var args = Array.prototype.slice.call(arguments);
21
+ console.log.apply(console, args);
22
+ }
23
+
24
+ //-------------------------------------------------------------------------------------------------
25
+
26
+ class BitLogr {
27
+ constructor() {
28
+ this._handler_log= handler_default_;
29
+ this._Bint_labels= BigInt(0);
30
+ this._Bint_toggled= BigInt(0);
31
+
32
+ BitLogr.prototype['log']= function (nr_logged, /* ... */ ) {
33
+ // console.log('NOP')
34
+ };
35
+ }
36
+
37
+ set handler(fx) {
38
+ this._handler_log= fx;
39
+ }
40
+
41
+ get labels() { return this._Bint_labels; }
42
+ set labels(obj) {
43
+ this._Bint_labels= obj;
44
+ this._Bint_toggled= BigInt(0);
45
+ }
46
+
47
+ // put= function(label, abbrv) {
48
+ // let name= __name(label);
49
+ // _labels[name]= label[name];
50
+ // console.log(_labels);
51
+ // }
52
+
53
+ get toggled() { return this._Bint_toggled; }
54
+ set toggled(obj) {
55
+ this._Bint_toggled= l_toBigInt_(this._Bint_labels, obj);
56
+
57
+ if (this._Bint_toggled === BigInt(0)) {
58
+ console.log('adlkjasdlfk');
59
+ return;
60
+ }
61
+
62
+ BitLogr.prototype['log']= function (nr_logged, /* ... */ ) {
63
+ if ( (BigInt(nr_logged) & this._Bint_toggled) === BigInt(0))
64
+ return false;
65
+
66
+ var args = Array.prototype.slice.call(arguments);
67
+ args.shift(); // remove first arg: nr_logged
68
+ this._handler_log.apply(this, args);
69
+
70
+ return true;
71
+ };
72
+ }
73
+
74
+ // log= function (nr_logged, /* ... */ ) {}
75
+ }
76
+
77
+ var jsonMsg_cjs = {};
78
+
79
+ var hasRequiredJsonMsg_cjs;
80
+
81
+ function requireJsonMsg_cjs () {
82
+ if (hasRequiredJsonMsg_cjs) return jsonMsg_cjs;
83
+ hasRequiredJsonMsg_cjs = 1;
84
+
85
+ Object.defineProperty(jsonMsg_cjs, '__esModule', { value: true });
86
+
87
+ const validate_Msg = validate10;function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{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"))){validate10.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"){validate10.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.referer !== undefined){let data1 = data.referer;const _errs3 = errors;{if(Array.isArray(data1)){if(data1.length > 2){validate10.errors = [{instancePath:instancePath+"/referer",schemaPath:"#/properties/referer/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"}];return false;}else {if(data1.length < 2){validate10.errors = [{instancePath:instancePath+"/referer",schemaPath:"#/properties/referer/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"}];return false;}else {var valid1 = true;const len0 = data1.length;for(let i0=0; i0<len0; i0++){const _errs5 = errors;if(typeof data1[i0] !== "string"){validate10.errors = [{instancePath:instancePath+"/referer/" + i0,schemaPath:"#/properties/referer/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs5 === errors;if(!valid1){break;}}}}}else {validate10.errors = [{instancePath:instancePath+"/referer",schemaPath:"#/properties/referer/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.dt !== undefined){const _errs7 = errors;if(typeof data.dt !== "string"){validate10.errors = [{instancePath:instancePath+"/dt",schemaPath:"#/properties/dt/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}}}}}else {validate10.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10.errors = vErrors;return errors === 0;}const validate_Msg_msg = validate11;function validate11(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data._msg === undefined) && (missing0 = "_msg")){validate11.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];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;}const validate_MsgAck = validate12;function validate12(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ack === undefined) && (missing0 = "ack")){validate12.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")){validate12.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"){validate12.errors = [{instancePath:instancePath+"/ack/ok",schemaPath:"#/properties/ack/properties/ok/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}}}}else {validate12.errors = [{instancePath:instancePath+"/ack",schemaPath:"#/properties/ack/type",keyword:"type",params:{type: "object"},message:"must be object"}];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;}
88
+
89
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
90
+ // require the crypto API and do not support built-in fallback to lower quality random number
91
+ // generators (like Math.random()).
92
+ let getRandomValues;
93
+ const rnds8 = new Uint8Array(16);
94
+ function rng() {
95
+ // lazy load so that environments that need to polyfill have a chance to do so
96
+ if (!getRandomValues) {
97
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
98
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
99
+
100
+ if (!getRandomValues) {
101
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
102
+ }
103
+ }
104
+
105
+ return getRandomValues(rnds8);
106
+ }
107
+
108
+ /**
109
+ * Convert array of 16 byte values to UUID string format of the form:
110
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
111
+ */
112
+
113
+ const byteToHex = [];
114
+
115
+ for (let i = 0; i < 256; ++i) {
116
+ byteToHex.push((i + 0x100).toString(16).slice(1));
117
+ }
118
+
119
+ function unsafeStringify(arr, offset = 0) {
120
+ // Note: Be careful editing this code! It's been tuned for performance
121
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
122
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
123
+ }
124
+
125
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
126
+ var native = {
127
+ randomUUID
128
+ };
129
+
130
+ function v4(options, buf, offset) {
131
+ if (native.randomUUID && !buf && !options) {
132
+ return native.randomUUID();
133
+ }
134
+
135
+ options = options || {};
136
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
137
+
138
+ rnds[6] = rnds[6] & 0x0f | 0x40;
139
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
140
+
141
+ return unsafeStringify(rnds);
142
+ }
143
+
144
+ // console.log('OUT', __name({variableName}) );
145
+
146
+ function l_toBigInt_(ref, obj, ignore= false) {
147
+ console.assert(ref !== BigInt(0), 'no labels initialized');
148
+ let bigInt = BigInt(0);
149
+ for (const [k,v] of Object.entries(obj)) {
150
+ if ( ( ignore || v ) && ref[k])
151
+ bigInt|= BigInt( ref[k] );
152
+ // console.log('0b'+ bigInt.toString(2) );
153
+ }
154
+ return bigInt;
155
+ }
156
+
157
+ //-------------------------------------------------------------------------------------------------
158
+
159
+ function handler_default_( /* ... */ ) {
160
+ // https://stackoverflow.com/questions/18746440/passing-multiple-arguments-to-console-log
161
+ var args = Array.prototype.slice.call(arguments);
162
+ console.log.apply(console, args);
163
+ }
164
+
165
+ //-------------------------------------------------------------------------------------------------
166
+
167
+ class BitLogr {
168
+ constructor() {
169
+ this._handler_log= handler_default_;
170
+ this._Bint_labels= BigInt(0);
171
+ this._Bint_toggled= BigInt(0);
172
+
173
+ BitLogr.prototype['log']= function (nr_logged, /* ... */ ) {
174
+ // console.log('NOP')
175
+ };
176
+ }
177
+
178
+ set handler(fx) {
179
+ this._handler_log= fx;
180
+ }
181
+
182
+ get labels() { return this._Bint_labels; }
183
+ set labels(obj) {
184
+ this._Bint_labels= obj;
185
+ this._Bint_toggled= BigInt(0);
186
+ }
187
+
188
+ // put= function(label, abbrv) {
189
+ // let name= __name(label);
190
+ // _labels[name]= label[name];
191
+ // console.log(_labels);
192
+ // }
193
+
194
+ get toggled() { return this._Bint_toggled; }
195
+ set toggled(obj) {
196
+ this._Bint_toggled= l_toBigInt_(this._Bint_labels, obj);
197
+
198
+ if (this._Bint_toggled === BigInt(0)) {
199
+ console.log('adlkjasdlfk');
200
+ return;
201
+ }
202
+
203
+ BitLogr.prototype['log']= function (nr_logged, /* ... */ ) {
204
+ if ( (BigInt(nr_logged) & this._Bint_toggled) === BigInt(0))
205
+ return false;
206
+
207
+ var args = Array.prototype.slice.call(arguments);
208
+ args.shift(); // remove first arg: nr_logged
209
+ this._handler_log.apply(this, args);
210
+
211
+ return true;
212
+ };
213
+ }
214
+
215
+ // log= function (nr_logged, /* ... */ ) {}
216
+ }
217
+
218
+ let LOGR_= new BitLogr();
219
+
220
+ const l_= {
221
+ VALIDATION : 0b1 << 0,
222
+ };
223
+
224
+ // TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
225
+
226
+ // "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
227
+ var JSON_Msg = (function() {
228
+ return {
229
+ merge : function(json) {
230
+ const dt_Msg= new Date();
231
+ let json_msg= {
232
+ id : v4(),
233
+ referer : null,
234
+ dt : dt_Msg.toISOString(),
235
+ };
236
+ // https://stackoverflow.com/questions/684672/how-do-i-loop-through-or-enumerate-a-javascript-object
237
+ for (var key of Object.keys(json)) {
238
+ json_msg[key]= json[key];
239
+ }
240
+ return json_msg;
241
+ },
242
+ validate : function(json) {
243
+ const b_valid= validate_Msg(json);
244
+ if (!b_valid)
245
+ LOGR_.log(l_.VALIDATION, 'JSON_Msg: validate: ', validate_Msg.errors);
246
+ return b_valid;
247
+ }
248
+ // TODO: requires a separate ajv module require, and JTD specific schema
249
+ // https://ajv.js.org/guide/getting-started.html#parsing-and-serializing-json
250
+ // static #ajv_parse_= ajv.compileParser(this.#schema_json_Msg);
251
+ // static parse(json) {
252
+ // return this.#ajv_parse_(json);
253
+ // }
254
+ }
255
+ })();
256
+
257
+ var JSON_Msg_msg = (function() {
258
+ return {
259
+ create_with_msg_merge : function(_msg, json) {
260
+ let json_msg= JSON_Msg.merge(json);
261
+ json_msg._msg= _msg;
262
+ return json_msg;
263
+ },
264
+ validate : function(json) {
265
+ if (! JSON_Msg.validate(json))
266
+ return false;
267
+ const b_valid= validate_Msg_msg(json);
268
+ if (!b_valid)
269
+ LOGR_.log(l_.VALIDATION, 'JSON_Msg_msg: validate: ', validate_Msg_msg.errors);
270
+ return b_valid;
271
+ }
272
+ }
273
+ })();
274
+
275
+ var JSON_MsgAck = (function() {
276
+ return {
277
+ create_with_msgOk : function(_msg, b_ok= true) {
278
+ return JSON_Msg_msg.create_with_msg_merge(_msg, {
279
+ ack : {
280
+ "ok" : b_ok,
281
+ },
282
+ });
283
+ },
284
+ create_with_msgExpired : function(_msg) {
285
+ return JSON_Msg_msg.create_with_msg_merge(_msg, {
286
+ ack : {
287
+ "ok" : false,
288
+ "expired" : true
289
+ },
290
+ });
291
+ },
292
+ validate : function(json) {
293
+ if (! JSON_Msg_msg.validate(json))
294
+ return false;
295
+ const b_valid= validate_MsgAck(json);
296
+ if (!b_valid)
297
+ LOGR_.log(l_.VALIDATION, 'JSON_MsgAck: validate: ', validate_MsgAck.errors);
298
+ return b_valid;
299
+ }
300
+ }
301
+ })();
302
+
303
+ jsonMsg_cjs.JSON_Msg = JSON_Msg;
304
+ jsonMsg_cjs.JSON_MsgAck = JSON_MsgAck;
305
+ jsonMsg_cjs.JSON_Msg_msg = JSON_Msg_msg;
306
+ return jsonMsg_cjs;
307
+ }
308
+
309
+ var jsonMsg_cjsExports = requireJsonMsg_cjs();
310
+
311
+ let LOGR_= new BitLogr();
312
+
313
+ const l_= {
314
+ VALIDATION : 0b1 << 0,
315
+ };
316
+ LOGR_.labels= l_;
317
+
318
+ LOGR_.toggled= {
319
+ // VALIDATION : 1
320
+ };
321
+
322
+ const kstr_VERSION= "0.1";
323
+
324
+ // TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
325
+
326
+ // const regex_IOI= new RegExp('\\bquery\\s*\\{\\s*IOI\\s*\\(\\s*pkg\\s*:\\s*"([^"]*)"\\s*\\)\\s*\\{.*heartbeat\\s*\\}\\s*\\}');
327
+
328
+ var JSON_MsgSubverseInfo_discovery = (function() {
329
+ return {
330
+ merge : function(json) {
331
+ let json_msg= jsonMsg_cjsExports.JSON_Msg.merge(json);
332
+ json_msg["subverse_info"]= kstr_VERSION;
333
+
334
+ return json_msg;
335
+ },
336
+ validate : function(json, _pkg) {
337
+ if (! jsonMsg_cjsExports.JSON_Msg.validate(json))
338
+ return false;
339
+
340
+ if (! schema_SubverseInfo_discovery(json)) {
341
+ LOGR_.log(l_.VALIDATION, 'schema_SubverseInfo_discovery: validate: ', schema_SubverseInfo_discovery.errors);
342
+ return false;
343
+ }
344
+
345
+ // const str_graphql = json["discovery"]["graphql"];
346
+
347
+ // const regex_match= str_graphql.match(regex_IOI);
348
+ // if (regex_match === null || regex_match.length !== 2)
349
+ // return false;
350
+
351
+ // if (pkg !== regex_match[1])
352
+ // return false;
353
+
354
+ return true;
355
+ }
356
+ }
357
+ })();
358
+
359
+ var JSON_MsgSubverseInfo_expanse = (function() {
360
+ return {
361
+ create_with_msg_merge : function(_msg, json) {
362
+ let json_msg_msg= jsonMsg_cjsExports.JSON_Msg_msg.create_with_msg_merge(_msg, json);
363
+ json_msg_msg["subverse_info"]= kstr_VERSION;
364
+
365
+ return json_msg_msg;
366
+ },
367
+ validate : function(json) {
368
+ if (! jsonMsg_cjsExports.JSON_Msg_msg.validate(json))
369
+ return false;
370
+ if (! schema_SubverseInfo_expanse(json)) {
371
+ LOGR_.log(l_.VALIDATION, 'JSON_SubverseInfo_expanse: validate: ', schema_SubverseInfo_expanse.errors);
372
+ return false;
373
+ }
374
+ return true;
375
+ }
376
+ }
377
+ })();
378
+
379
+ export { JSON_MsgSubverseInfo_discovery, JSON_MsgSubverseInfo_expanse };
package/jasmine.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "spec_dir": "tests",
3
+ "spec_files": [
4
+ "**/*[sS]pec.?(m)js",
5
+ "!**/*nospec.js"
6
+ ]
7
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@rootintf/protocol-subverseinfo",
3
+ "version": "0.0.4-api-0.1",
4
+ "description": "",
5
+ "main": "dist/subverseinfo.cjs.js",
6
+ "browser": "dist/subverseinfo.es.mjs",
7
+ "scripts": {
8
+ "build": "node src/ajv-gen-validate.cjs && rollup --config",
9
+ "test": "jasmine --config=jasmine.json",
10
+ "clean": "del-cli dist && del-cli src/validate-esm.mjs && echo OK"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://gitlab.com/interface-x/npm-protocol-subverseinfo.git"
15
+ },
16
+ "keywords": [
17
+ "json"
18
+ ],
19
+ "author": "K.Nevelsteen, PhD",
20
+ "license": "ISC",
21
+ "bugs": {
22
+ "url": "https://gitlab.com/interface-x/npm-protocol-subverseinfo.git/-/issues"
23
+ },
24
+ "homepage": "https://gitlab.com/interface-x/npm-protocol-subverseinfo.git#readme",
25
+ "dependencies": {
26
+ "@knev/bitlogr": "^0.2.12",
27
+ "@rootintf/json-msg": "^0.2.1",
28
+ "ajv": "^8.17.1",
29
+ "uuid": "^11.0.3"
30
+ },
31
+ "devDependencies": {
32
+ "@rollup/plugin-commonjs": "^28.0.1",
33
+ "@rollup/plugin-json": "^6.1.0",
34
+ "@rollup/plugin-node-resolve": "^15.3.0",
35
+ "ajv-cli": "^5.0.0",
36
+ "del-cli": "^6.0.0",
37
+ "jasmine": "^5.5.0",
38
+ "rollup": "^4.28.1"
39
+ }
40
+ }
@@ -0,0 +1,24 @@
1
+
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+ import json from '@rollup/plugin-json';
5
+
6
+ export default [
7
+ {
8
+ input: 'src/subverseinfo.mjs',
9
+ output: {
10
+ file: 'dist/subverseinfo.es.mjs',
11
+ format: 'es'
12
+ },
13
+ plugins: [resolve(), commonjs(), json()]
14
+ },
15
+ {
16
+ input: 'src/subverseinfo.mjs',
17
+ output: {
18
+ file: 'dist/subverseinfo.cjs.js',
19
+ format: 'cjs'
20
+ },
21
+ plugins: [resolve(), commonjs(), json()]
22
+ }
23
+
24
+ ];
@@ -0,0 +1,61 @@
1
+ {
2
+ "$id" : "https://root-interface.se/schemas/definitions_SubverseInfo",
3
+ "$schema" : "https://json-schema.org/draft/2019-09/schema",
4
+ "definitions" : {
5
+ "_v" : {
6
+ "const": "0.1"
7
+ },
8
+ "info" : {
9
+ "type" : "object"
10
+ },
11
+ "unique-id" : {
12
+ "type" : "object",
13
+ "required": [ "name", "uri" ],
14
+ "properties": {
15
+ "name": { "type" : "string" },
16
+ "uri": { "type" : "string" },
17
+ "favicon" : { "type" : "string" },
18
+ "info" : { "$ref": "definitions_SubverseInfo#/definitions/info" }
19
+ }
20
+ },
21
+ "instances" : {
22
+ "type" : "array",
23
+ "items": {
24
+ "type" : "object",
25
+ "allOf": [{ "$ref": "definitions_SubverseInfo#/definitions/unique-id" }],
26
+ "properties": {
27
+ }
28
+ }
29
+ },
30
+ "platforms" : {
31
+ "type": "array",
32
+ "items": {
33
+ "type" : "object",
34
+ "required": [ "name" ],
35
+ "properties": {
36
+ "name": { "type": "string" },
37
+ "archs": {
38
+ "type": "array",
39
+ "items": { "type" : "string" }
40
+ },
41
+ "agents": {
42
+ "type": "array",
43
+ "items": { "type" : "string" }
44
+ }
45
+ }
46
+ }
47
+ },
48
+ "protocols" : {
49
+ "type" : "array",
50
+ "items" : {
51
+ "type" : "object",
52
+ "required": [ "name", "attr" ],
53
+ "properties" : {
54
+ "name": { "type" : "string" },
55
+ "attr": { "type" : "string" },
56
+ "url": { "type" : "string" }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$id": "https://root-interface.se/schemas/schema_SubverseInfo_discovery",
3
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4
+ "type" : "object",
5
+ "required" : [ "discovery", "subverse_info" ],
6
+ "properties" : {
7
+ "discovery" : {
8
+ "type" : "object",
9
+ "required": [ "name", "graphql", "ttl_msec" ],
10
+ "properties": {
11
+ "name" : {
12
+ "type" : "string"
13
+ },
14
+ "graphql" : {
15
+ "type" : "string"
16
+ },
17
+ "ttl_msec" : {
18
+ "type" : "integer"
19
+ }
20
+ }
21
+ },
22
+ "subverse_info": { "$ref": "definitions_SubverseInfo#/definitions/_v" }
23
+ }
24
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "$id": "https://root-interface.se/schemas/schema_SubverseInfo_expanse",
3
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4
+ "type" : "object",
5
+ "required" : [ "expanse", "subverse_info" ],
6
+ "properties" : {
7
+ "expanse" : {
8
+ "type" : "object",
9
+ "required" : [ "subverse", "protocols" ],
10
+ "properties" : {
11
+ "subverse" : {
12
+ "type" : "object",
13
+ "allOf": [{ "$ref": "definitions_SubverseInfo#/definitions/unique-id" }],
14
+ "required" : [ "map_url" ],
15
+ "properties" : {
16
+ "map_url" : { "type" : "string" }
17
+ }
18
+ },
19
+ "instances" : { "$ref": "definitions_SubverseInfo#/definitions/instances" },
20
+ "platforms" : { "$ref": "definitions_SubverseInfo#/definitions/platforms" },
21
+ "protocols": { "$ref": "definitions_SubverseInfo#/definitions/protocols" }
22
+ }
23
+ },
24
+ "subverse_info": { "$ref": "definitions_SubverseInfo#/definitions/_v" }
25
+ }
26
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$id": "https://root-interface.se/schemas/schema_expanse_instances",
3
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
4
+ "type" : "object",
5
+ "required" : ["instances"],
6
+ "properties" : {
7
+ "instances" : { "$ref": "definitions_SubverseInfo#/definitions/instances" },
8
+ "subverse" : {
9
+ "type" : "object",
10
+ "required": [ "name", "uri" ],
11
+ "properties": {
12
+ "name": { "type" : "string" },
13
+ "uri": { "type" : "string" }
14
+ },
15
+ "additionalProperties": false
16
+ },
17
+ "platforms" : { "$ref": "definitions_SubverseInfo#/definitions/platforms" },
18
+ "protocols": { "$ref": "definitions_SubverseInfo#/definitions/protocols" }
19
+
20
+ }
21
+ }