@rootintf/json-msg 2.1.7 → 2.3.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.
- package/dist/json-msg.cjs.js +0 -2
- package/dist/json-msg.es.mjs +0 -2
- package/dist/json_msg+ack.d.ts +21 -7
- package/package.json +16 -2
- package/antora-docs/antora.yml +0 -5
- package/antora-docs/modules/ROOT/nav.adoc +0 -1
- package/antora-docs/modules/ROOT/pages/index.adoc +0 -76
- package/dist/ajv-gen-validate.d.cts +0 -1
- package/dist/validate-esm.d.mts +0 -47
- package/jasmine.json +0 -7
- package/rollup.config.mjs +0 -37
- package/schema/schema_JSON_Msg.json +0 -38
- package/src/ajv-gen-validate.cjs +0 -29
- package/src/declarations.d.ts +0 -1
- package/src/json_msg+ack.ts +0 -96
- package/src/validate-esm.mjs +0 -1
- package/tests/json_msg+ack.spec.mjs +0 -113
- package/tsconfig.json +0 -115
package/dist/json-msg.cjs.js
CHANGED
|
@@ -175,8 +175,6 @@ function v4(options, buf, offset) {
|
|
|
175
175
|
const LOGR_ = bitlogr.LOGR.get_instance();
|
|
176
176
|
const logr_ = LOGR_.create({ labels: bitlogr.l_array(['VALIDATION']) });
|
|
177
177
|
const l_ = logr_.l;
|
|
178
|
-
// console.log('File location:', import.meta.url, '[Implementation]');
|
|
179
|
-
//-------------------------------------------------------------------------------------------------
|
|
180
178
|
// TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
|
|
181
179
|
// "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
|
|
182
180
|
var JSON_Msg = (function () {
|
package/dist/json-msg.es.mjs
CHANGED
|
@@ -173,8 +173,6 @@ function v4(options, buf, offset) {
|
|
|
173
173
|
const LOGR_ = LOGR.get_instance();
|
|
174
174
|
const logr_ = LOGR_.create({ labels: l_array(['VALIDATION']) });
|
|
175
175
|
const l_ = logr_.l;
|
|
176
|
-
// console.log('File location:', import.meta.url, '[Implementation]');
|
|
177
|
-
//-------------------------------------------------------------------------------------------------
|
|
178
176
|
// TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
|
|
179
177
|
// "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
|
|
180
178
|
var JSON_Msg = (function () {
|
package/dist/json_msg+ack.d.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
declare const logr_: any;
|
|
2
|
+
interface JSON_Msg {
|
|
3
|
+
id: string;
|
|
4
|
+
referer: unknown;
|
|
5
|
+
dt: string;
|
|
6
|
+
}
|
|
7
|
+
interface JSON_MsgEffect extends JSON_Msg {
|
|
8
|
+
_cause: JSON_Msg;
|
|
9
|
+
}
|
|
10
|
+
interface JSON_MsgAck extends JSON_MsgEffect {
|
|
11
|
+
ack: {
|
|
12
|
+
ok: boolean;
|
|
13
|
+
expired?: boolean;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
2
16
|
declare var JSON_Msg: {
|
|
3
|
-
merge: (json:
|
|
4
|
-
validate: (json:
|
|
17
|
+
merge: <T extends object>(json: T) => JSON_Msg & T;
|
|
18
|
+
validate: (json: unknown) => json is JSON_Msg;
|
|
5
19
|
};
|
|
6
20
|
declare var JSON_MsgEffect: {
|
|
7
|
-
create_with_cause_merge: (msg_cause:
|
|
8
|
-
validate: (json:
|
|
21
|
+
create_with_cause_merge: <T extends object>(msg_cause: JSON_Msg, json: T) => JSON_MsgEffect & T;
|
|
22
|
+
validate: (json: unknown) => json is JSON_MsgEffect;
|
|
9
23
|
};
|
|
10
24
|
declare var JSON_MsgAck: {
|
|
11
|
-
create_with_cause_Ok: (msg_cause:
|
|
12
|
-
create_with_cause_Expired: (msg_cause:
|
|
13
|
-
validate: (json:
|
|
25
|
+
create_with_cause_Ok: (msg_cause: JSON_Msg, b_ok?: boolean) => JSON_MsgAck;
|
|
26
|
+
create_with_cause_Expired: (msg_cause: JSON_Msg) => JSON_MsgAck;
|
|
27
|
+
validate: (json: unknown) => json is JSON_MsgAck;
|
|
14
28
|
};
|
|
15
29
|
export { JSON_Msg, JSON_MsgEffect, JSON_MsgAck, logr_ as logr };
|
package/package.json
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rootintf/json-msg",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/json-msg.cjs.js",
|
|
6
|
-
"
|
|
6
|
+
"module": "dist/json-msg.es.mjs",
|
|
7
7
|
"browser": "dist/json-msg.es.mjs",
|
|
8
|
+
"types": "dist/json_msg+ack.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/json_msg+ack.d.ts",
|
|
12
|
+
"import": "./dist/json-msg.es.mjs",
|
|
13
|
+
"require": "./dist/json-msg.cjs.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/json-msg.cjs.js",
|
|
19
|
+
"dist/json-msg.es.mjs",
|
|
20
|
+
"dist/json_msg+ack.d.ts"
|
|
21
|
+
],
|
|
8
22
|
"scripts": {
|
|
9
23
|
"build": "node src/ajv-gen-validate.cjs && rollup --config",
|
|
10
24
|
"script": "node --experimental-json-modules tests/json-msg.test.mjs",
|
package/antora-docs/antora.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// * xref:index.adoc[]
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
= npm-json-msg
|
|
2
|
-
|
|
3
|
-
Protocols: xref:protocols::JSON_Msg.adoc[]
|
|
4
|
-
|
|
5
|
-
[cols="24h,~"]
|
|
6
|
-
|===
|
|
7
|
-
|npm-json-msg
|
|
8
|
-
|https://gitlab.com/interop-protocols/npm-json-msg.git[^]
|
|
9
|
-
|===
|
|
10
|
-
|
|
11
|
-
== `JSON_Msg`
|
|
12
|
-
|
|
13
|
-
.JSON Schema, Draft-07
|
|
14
|
-
https://json-schema.org/specification-links.html#draft-7[^]
|
|
15
|
-
[source,json-schema/draft-07]
|
|
16
|
-
----
|
|
17
|
-
{
|
|
18
|
-
"$id": "validate_Msg",
|
|
19
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
20
|
-
"type" : "object",
|
|
21
|
-
"required" : ["id", "referer", "dt"],
|
|
22
|
-
"properties" : {
|
|
23
|
-
"id" : { "type" : "string"},
|
|
24
|
-
"referer" : {
|
|
25
|
-
"type" : "array",
|
|
26
|
-
"minItems" : 2,
|
|
27
|
-
"maxItems": 2,
|
|
28
|
-
"items": { "type" : "string" }
|
|
29
|
-
},
|
|
30
|
-
"dt" : { "type" : "string" }
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
----
|
|
34
|
-
|
|
35
|
-
* *referer* [_sic_] --
|
|
36
|
-
** `[0]` -- package, product or service name.
|
|
37
|
-
** `[1]` -- instance specifier.
|
|
38
|
-
|
|
39
|
-
== `JSON_Msg_msg`
|
|
40
|
-
|
|
41
|
-
[source,json-schema/draft-07]
|
|
42
|
-
----
|
|
43
|
-
{
|
|
44
|
-
"$id": "validate_Msg_msg",
|
|
45
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
46
|
-
"type" : "object",
|
|
47
|
-
"required" : ["_msg"]
|
|
48
|
-
|
|
49
|
-
// ... JSON_Msg format
|
|
50
|
-
}
|
|
51
|
-
----
|
|
52
|
-
|
|
53
|
-
* *_msg* -- original message this message is in regards to.
|
|
54
|
-
|
|
55
|
-
== `JSON_MsgAck`
|
|
56
|
-
|
|
57
|
-
[source,json-schema/draft-07]
|
|
58
|
-
----
|
|
59
|
-
{
|
|
60
|
-
"$id": "validate_MsgAck",
|
|
61
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
62
|
-
"type" : "object",
|
|
63
|
-
"required" : ["ack"],
|
|
64
|
-
"properties" : {
|
|
65
|
-
"ack" : {
|
|
66
|
-
"type" : "object",
|
|
67
|
-
"required" : ["ok"],
|
|
68
|
-
"properties" : {
|
|
69
|
-
"ok" : { "type" : "boolean" }
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// ... JSON_Msg_msg format
|
|
75
|
-
}
|
|
76
|
-
----
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/validate-esm.d.mts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export function schema_Msg(data: any, { instancePath, parentData, parentDataProperty, rootData, dynamicAnchors }?: {
|
|
2
|
-
instancePath?: string;
|
|
3
|
-
rootData?: any;
|
|
4
|
-
dynamicAnchors?: {};
|
|
5
|
-
}): boolean;
|
|
6
|
-
export namespace schema_Msg {
|
|
7
|
-
namespace evaluated {
|
|
8
|
-
namespace props {
|
|
9
|
-
let id: boolean;
|
|
10
|
-
let dt: boolean;
|
|
11
|
-
}
|
|
12
|
-
let dynamicProps: boolean;
|
|
13
|
-
let dynamicItems: boolean;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export function schema_MsgEffect(data: any, { instancePath, parentData, parentDataProperty, rootData, dynamicAnchors }?: {
|
|
17
|
-
instancePath?: string;
|
|
18
|
-
rootData?: any;
|
|
19
|
-
dynamicAnchors?: {};
|
|
20
|
-
}): boolean;
|
|
21
|
-
export namespace schema_MsgEffect {
|
|
22
|
-
export namespace evaluated_1 {
|
|
23
|
-
let dynamicProps_1: boolean;
|
|
24
|
-
export { dynamicProps_1 as dynamicProps };
|
|
25
|
-
let dynamicItems_1: boolean;
|
|
26
|
-
export { dynamicItems_1 as dynamicItems };
|
|
27
|
-
}
|
|
28
|
-
export { evaluated_1 as evaluated };
|
|
29
|
-
}
|
|
30
|
-
export function schema_MsgAckEffect(data: any, { instancePath, parentData, parentDataProperty, rootData, dynamicAnchors }?: {
|
|
31
|
-
instancePath?: string;
|
|
32
|
-
rootData?: any;
|
|
33
|
-
dynamicAnchors?: {};
|
|
34
|
-
}): boolean;
|
|
35
|
-
export namespace schema_MsgAckEffect {
|
|
36
|
-
export namespace evaluated_2 {
|
|
37
|
-
export namespace props_1 {
|
|
38
|
-
let ack: boolean;
|
|
39
|
-
}
|
|
40
|
-
export { props_1 as props };
|
|
41
|
-
let dynamicProps_2: boolean;
|
|
42
|
-
export { dynamicProps_2 as dynamicProps };
|
|
43
|
-
let dynamicItems_2: boolean;
|
|
44
|
-
export { dynamicItems_2 as dynamicItems };
|
|
45
|
-
}
|
|
46
|
-
export { evaluated_2 as evaluated };
|
|
47
|
-
}
|
package/jasmine.json
DELETED
package/rollup.config.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
4
|
-
import json from '@rollup/plugin-json';
|
|
5
|
-
import typescript from '@rollup/plugin-typescript';
|
|
6
|
-
|
|
7
|
-
export default [
|
|
8
|
-
{
|
|
9
|
-
input: 'src/json_msg+ack.ts',
|
|
10
|
-
output: {
|
|
11
|
-
file: 'dist/json-msg.es.mjs',
|
|
12
|
-
format: 'es'
|
|
13
|
-
},
|
|
14
|
-
plugins: [
|
|
15
|
-
resolve(),
|
|
16
|
-
commonjs(),
|
|
17
|
-
json(),
|
|
18
|
-
typescript({ tsconfig: './tsconfig.json' })
|
|
19
|
-
],
|
|
20
|
-
external: ['@knev/bitlogr'], // Don't bundle these
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
input: 'src/json_msg+ack.ts',
|
|
24
|
-
output: {
|
|
25
|
-
file: 'dist/json-msg.cjs.js',
|
|
26
|
-
format: 'cjs'
|
|
27
|
-
},
|
|
28
|
-
plugins: [
|
|
29
|
-
resolve(),
|
|
30
|
-
commonjs(),
|
|
31
|
-
json(),
|
|
32
|
-
typescript({ tsconfig: './tsconfig.json' })
|
|
33
|
-
],
|
|
34
|
-
external: ['@knev/bitlogr'], // Don't bundle these
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
];
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{
|
|
3
|
-
"$id" : "https://root-interface.se/protocols/JSON_Msg",
|
|
4
|
-
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
5
|
-
"schemas": {
|
|
6
|
-
"https://root-interface.se/protocols/JSON_Msg/Msg" : {
|
|
7
|
-
"$id" : "https://root-interface.se/protocols/JSON_Msg/Msg",
|
|
8
|
-
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
9
|
-
"type" : "object",
|
|
10
|
-
"required" : ["id", "referer", "dt"],
|
|
11
|
-
"properties" : {
|
|
12
|
-
"id" : { "type" : "string"},
|
|
13
|
-
"dt" : { "type" : "string" }
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"https://root-interface.se/protocols/JSON_Msg/Msg_effect" : {
|
|
17
|
-
"$id" : "https://root-interface.se/protocols/JSON_Msg/MsgEffect",
|
|
18
|
-
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
19
|
-
"type" : "object",
|
|
20
|
-
"required" : ["_cause"]
|
|
21
|
-
},
|
|
22
|
-
"https://root-interface.se/protocols/JSON_Msg/MsgAck_effect" : {
|
|
23
|
-
"$id" : "https://root-interface.se/protocols/JSON_Msg/MsgAckEffect",
|
|
24
|
-
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
25
|
-
"type" : "object",
|
|
26
|
-
"required" : ["ack"],
|
|
27
|
-
"properties" : {
|
|
28
|
-
"ack" : {
|
|
29
|
-
"type" : "object",
|
|
30
|
-
"required" : ["ok"],
|
|
31
|
-
"properties" : {
|
|
32
|
-
"ok" : { "type" : "boolean" }
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/ajv-gen-validate.cjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// https://ajv.js.org/standalone.html
|
|
3
|
-
|
|
4
|
-
const fs = require("fs")
|
|
5
|
-
const path = require("path")
|
|
6
|
-
const Ajv2019 = require("ajv/dist/2019");
|
|
7
|
-
const standaloneCode = require("ajv/dist/standalone").default
|
|
8
|
-
|
|
9
|
-
// For ESM, the export name needs to be a valid export name, it can not be `export const #/definitions/Foo = ...;` so we
|
|
10
|
-
// need to provide a mapping between a valid name and the $id field. Below will generate
|
|
11
|
-
// `export const Foo = ...;export const Bar = ...;`
|
|
12
|
-
// This mapping would not have been needed if the `$ids` was just `Bar` and `Foo` instead of `#/definitions/Foo`
|
|
13
|
-
// and `#/definitions/Bar` respectfully
|
|
14
|
-
const ajv = new Ajv2019({
|
|
15
|
-
code: {source: true, esm: true}
|
|
16
|
-
});
|
|
17
|
-
var json_schema_JSON_Msg_= require('../schema/schema_JSON_Msg.json');
|
|
18
|
-
Object.values(json_schema_JSON_Msg_.schemas).forEach(schema => {
|
|
19
|
-
ajv.addSchema(schema);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
let moduleCode = standaloneCode(ajv, {
|
|
23
|
-
"schema_Msg": "https://root-interface.se/protocols/JSON_Msg/Msg",
|
|
24
|
-
"schema_MsgEffect" : "https://root-interface.se/protocols/JSON_Msg/MsgEffect",
|
|
25
|
-
"schema_MsgAckEffect" : "https://root-interface.se/protocols/JSON_Msg/MsgAckEffect"
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
// Now you can write the module code to file
|
|
29
|
-
fs.writeFileSync(path.join(__dirname, "./validate-esm.mjs"), moduleCode)
|
package/src/declarations.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare module '@knev/bitlogr';
|
package/src/json_msg+ack.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { schema_Msg, schema_MsgEffect, schema_MsgAckEffect } from './validate-esm.mjs';
|
|
3
|
-
|
|
4
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
-
import { LOGR, lRef, l_array, l_LL } from '@knev/bitlogr';
|
|
6
|
-
|
|
7
|
-
//-------------------------------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
const LOGR_= LOGR.get_instance();
|
|
10
|
-
const logr_= LOGR_.create({ labels: l_array(['VALIDATION']) });
|
|
11
|
-
const l_ = logr_.l;
|
|
12
|
-
|
|
13
|
-
// console.log('File location:', import.meta.url, '[Implementation]');
|
|
14
|
-
|
|
15
|
-
//-------------------------------------------------------------------------------------------------
|
|
16
|
-
|
|
17
|
-
// TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
|
|
18
|
-
|
|
19
|
-
// "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
|
|
20
|
-
var JSON_Msg = (function() {
|
|
21
|
-
return {
|
|
22
|
-
merge: function(json) {
|
|
23
|
-
return Object.assign({
|
|
24
|
-
id: uuidv4(),
|
|
25
|
-
referer: null,
|
|
26
|
-
dt: new Date().toISOString()
|
|
27
|
-
}, json || {});
|
|
28
|
-
},
|
|
29
|
-
validate : function (json) {
|
|
30
|
-
const b_valid = schema_Msg(json);
|
|
31
|
-
if (! b_valid)
|
|
32
|
-
logr_.log(l_.VALIDATION, () => ['JSON_Msg: validate: ', (schema_Msg as any).errors])
|
|
33
|
-
return b_valid;
|
|
34
|
-
},
|
|
35
|
-
// TODO: requires a separate ajv module require, and JTD specific schema
|
|
36
|
-
// https://ajv.js.org/guide/getting-started.html#parsing-and-serializing-json
|
|
37
|
-
// static #ajv_parse_= ajv.compileParser(this.#schema_json_Msg);
|
|
38
|
-
// static parse(json) {
|
|
39
|
-
// return this.#ajv_parse_(json);
|
|
40
|
-
// }
|
|
41
|
-
}
|
|
42
|
-
})();
|
|
43
|
-
|
|
44
|
-
var JSON_MsgEffect = (function() {
|
|
45
|
-
return {
|
|
46
|
-
create_with_cause_merge: function(msg_cause, json) {
|
|
47
|
-
const _cause= msg_cause;
|
|
48
|
-
return Object.assign(JSON_Msg.merge(json), { _cause });
|
|
49
|
-
},
|
|
50
|
-
validate : function(json) {
|
|
51
|
-
if (! JSON_Msg.validate(json))
|
|
52
|
-
return false;
|
|
53
|
-
const b_valid= schema_MsgEffect(json);
|
|
54
|
-
if (! b_valid)
|
|
55
|
-
logr_.log(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', (schema_MsgEffect as any).errors])
|
|
56
|
-
return b_valid;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
})();
|
|
60
|
-
|
|
61
|
-
var JSON_MsgAck = (function() {
|
|
62
|
-
return {
|
|
63
|
-
create_with_cause_Ok : function(msg_cause, b_ok= true) {
|
|
64
|
-
return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
|
|
65
|
-
ack : {
|
|
66
|
-
"ok" : b_ok,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
create_with_cause_Expired : function(msg_cause) {
|
|
71
|
-
return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
|
|
72
|
-
ack : {
|
|
73
|
-
"ok" : false,
|
|
74
|
-
"expired" : true
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
},
|
|
78
|
-
validate : function(json) {
|
|
79
|
-
if (! JSON_MsgEffect.validate(json))
|
|
80
|
-
return false;
|
|
81
|
-
const b_valid= schema_MsgAckEffect(json);
|
|
82
|
-
if (! b_valid)
|
|
83
|
-
logr_.log(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', (schema_MsgAckEffect as any).errors])
|
|
84
|
-
return b_valid;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
})();
|
|
88
|
-
|
|
89
|
-
//-------------------------------------------------------------------------------------------------
|
|
90
|
-
|
|
91
|
-
export {
|
|
92
|
-
JSON_Msg,
|
|
93
|
-
JSON_MsgEffect,
|
|
94
|
-
JSON_MsgAck,
|
|
95
|
-
logr_ as logr
|
|
96
|
-
}
|
package/src/validate-esm.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";export const schema_Msg = validate18;const schema21 = {"$id":"https://root-interface.se/protocols/JSON_Msg/Msg","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["id","referer","dt"],"properties":{"id":{"type":"string"},"dt":{"type":"string"}}};function validate18(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/JSON_Msg/Msg" */;let vErrors = null;let errors = 0;const evaluated0 = validate18.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.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))){validate18.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.id !== undefined){const _errs1 = errors;if(typeof data.id !== "string"){validate18.errors = [{instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.dt !== undefined){const _errs3 = errors;if(typeof data.dt !== "string"){validate18.errors = [{instancePath:instancePath+"/dt",schemaPath:"#/properties/dt/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}}}}else {validate18.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate18.errors = vErrors;return errors === 0;}validate18.evaluated = {"props":{"id":true,"dt":true},"dynamicProps":false,"dynamicItems":false};export const schema_MsgEffect = validate19;const schema22 = {"$id":"https://root-interface.se/protocols/JSON_Msg/MsgEffect","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["_cause"]};function validate19(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/JSON_Msg/MsgEffect" */;let vErrors = null;let errors = 0;const evaluated0 = validate19.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._cause === undefined) && (missing0 = "_cause")){validate19.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}}else {validate19.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate19.errors = vErrors;return errors === 0;}validate19.evaluated = {"dynamicProps":false,"dynamicItems":false};export const schema_MsgAckEffect = validate20;const schema23 = {"$id":"https://root-interface.se/protocols/JSON_Msg/MsgAckEffect","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["ack"],"properties":{"ack":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean"}}}}};function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/JSON_Msg/MsgAckEffect" */;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.ack === undefined) && (missing0 = "ack")){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ack !== undefined){let data0 = data.ack;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if((data0.ok === undefined) && (missing1 = "ok")){validate20.errors = [{instancePath:instancePath+"/ack",schemaPath:"#/properties/ack/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ok !== undefined){if(typeof data0.ok !== "boolean"){validate20.errors = [{instancePath:instancePath+"/ack/ok",schemaPath:"#/properties/ack/properties/ok/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/ack",schemaPath:"#/properties/ack/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}validate20.evaluated = {"props":{"ack":true},"dynamicProps":false,"dynamicItems":false};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { JSON_Msg, JSON_MsgEffect, JSON_MsgAck, logr as logr_ } from '../dist/json-msg.es.mjs';
|
|
3
|
-
import { LOGR, l_concat } from '@knev/bitlogr';
|
|
4
|
-
|
|
5
|
-
//-------------------------------------------------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
// const obj_labels_ = l_concat(l_json_msg, ['LOG_TEST']);
|
|
8
|
-
// const obj_labels_ = l_concat({}, ['LOG_TEST']);
|
|
9
|
-
|
|
10
|
-
const LOGR_= LOGR.get_instance();
|
|
11
|
-
// const logr_= LOGR_.create({ labels: obj_labels_ });
|
|
12
|
-
|
|
13
|
-
const l_= logr_.l;
|
|
14
|
-
|
|
15
|
-
LOGR_.toggle(l_, {
|
|
16
|
-
VALIDATION : true,
|
|
17
|
-
// LOG_TEST : true
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// // console.log('File location:', import.meta.url, '[Test]');
|
|
21
|
-
// logr_.log(l_.LOG_TEST, () => ['const l_ ', l_])
|
|
22
|
-
|
|
23
|
-
//-------------------------------------------------------------------------------------------------
|
|
24
|
-
|
|
25
|
-
const json_msgWarp_nomsg = {
|
|
26
|
-
"id" : "C995A2D2-49BB-4D41-B1D3-C12648652B47",
|
|
27
|
-
"referer": [ "ipsme.dev/js-blue/blue.html", "afab6b6b-2284-4abd-b71e-1e369b7e9220" ],
|
|
28
|
-
"dt": "2023-03-10T20:10:39.408Z",
|
|
29
|
-
"ack": {
|
|
30
|
-
"ok": true,
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const json_msgWarp_cause_null = {
|
|
35
|
-
"id" : "C995A2D2-49BB-4D41-B1D3-C12648652B47",
|
|
36
|
-
"referer": [ "ipsme.dev/js-blue/blue.html", "afab6b6b-2284-4abd-b71e-1e369b7e9220" ],
|
|
37
|
-
"dt": "2023-03-10T20:10:39.408Z",
|
|
38
|
-
"ack": {
|
|
39
|
-
"ok": true,
|
|
40
|
-
},
|
|
41
|
-
"_cause": null
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const json_msgAckWarp_effect = {
|
|
45
|
-
"id" : "C995A2D2-49BB-4D41-B1D3-C12648652B47",
|
|
46
|
-
"referer": [ "ipsme.dev/js-blue/blue.html", "afab6b6b-2284-4abd-b71e-1e369b7e9220" ],
|
|
47
|
-
"dt": "2023-03-10T20:10:39.408Z",
|
|
48
|
-
"ack": {
|
|
49
|
-
"ok": true,
|
|
50
|
-
},
|
|
51
|
-
"_cause": {}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
//-------------------------------------------------------------------------------------------------
|
|
55
|
-
// JSON_Msg
|
|
56
|
-
|
|
57
|
-
describe("JSON_Msg validation", function () {
|
|
58
|
-
it("JSON_Msg.validate({})", function () {
|
|
59
|
-
const merged_msg = JSON_Msg.merge({});
|
|
60
|
-
expect( JSON_Msg.validate(merged_msg) ).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("JSON_Msg.merge({ foo: \"bar\" })", function () {
|
|
64
|
-
const merged_msg = JSON_Msg.merge({ foo: "bar" });
|
|
65
|
-
|
|
66
|
-
expect( merged_msg.foo ).toBe('bar');
|
|
67
|
-
expect( JSON_Msg.validate(merged_msg) ).toBe(true);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("JSON_Msg.validate(json_msgAckWarp)", function () {
|
|
71
|
-
expect( JSON_Msg.validate(json_msgAckWarp_effect) ).toBe(true);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
//-------------------------------------------------------------------------------------------------
|
|
76
|
-
// JSON_Msg_effect
|
|
77
|
-
|
|
78
|
-
describe("JSON_Msg_effect validation", function () {
|
|
79
|
-
it("create_with_cause_merge", function () {
|
|
80
|
-
const json= JSON_MsgEffect.create_with_cause_merge(json_msgWarp_nomsg, {
|
|
81
|
-
"ack": {
|
|
82
|
-
"ok": true,
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
logr_.log(l_.VALIDATION, () => ['JSON_Msg_effect validation: LOGR test', LOGR.get_instance()._id]);
|
|
86
|
-
|
|
87
|
-
expect( json._cause !== undefined ).toBe(true);
|
|
88
|
-
expect( JSON_MsgEffect.validate(json) ).toBe(true);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("JSON_Msg_msg.validate(json_msgAckWarp)", function () {
|
|
92
|
-
expect( JSON_MsgEffect.validate(json_msgAckWarp_effect) ).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("JSON_Msg_effect.validate(json_msgWarp_nomsg)", function () {
|
|
96
|
-
expect( JSON_MsgEffect.validate(json_msgWarp_nomsg) ).toBe(false);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("JSON_Msg_effect.validate(json_msgWarp_msg_null)", function () {
|
|
100
|
-
expect( JSON_MsgEffect.validate(json_msgWarp_cause_null) ).toBe(true);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
//-------------------------------------------------------------------------------------------------
|
|
105
|
-
// JSON_MsgAck_effect
|
|
106
|
-
|
|
107
|
-
describe("JSON_MsgAck_effect validation", function () {
|
|
108
|
-
it("JSON_MsgAck_effect.validate(json_msgAckWarp)", function () {
|
|
109
|
-
expect( JSON_MsgAck.validate(json_msgAckWarp_effect) ).toBe(true);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
//-------------------------------------------------------------------------------------------------
|
package/tsconfig.json
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Projects */
|
|
6
|
-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
-
|
|
13
|
-
/* Language and Environment */
|
|
14
|
-
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
-
// "libReplacement": true, /* Enable lib replacement. */
|
|
18
|
-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
19
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
20
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
21
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
22
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
23
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
24
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
25
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
26
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
27
|
-
|
|
28
|
-
/* Modules */
|
|
29
|
-
"module": "ESNext", /* Specify what module code is generated. */
|
|
30
|
-
"rootDir": "./src", /* Specify the root folder within your source files. */
|
|
31
|
-
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
32
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
33
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
34
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
35
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
36
|
-
"types": [ "node" ], /* Specify type package names to be included without being referenced in a source file. */
|
|
37
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
38
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
39
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
40
|
-
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
|
|
41
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
42
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
43
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
44
|
-
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
|
45
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
46
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
47
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
48
|
-
|
|
49
|
-
/* JavaScript Support */
|
|
50
|
-
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
51
|
-
"checkJs": false, /* Enable error reporting in type-checked JavaScript files. */
|
|
52
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
53
|
-
|
|
54
|
-
/* Emit */
|
|
55
|
-
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
56
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
57
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
58
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
59
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
60
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
62
|
-
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
63
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
64
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
65
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
66
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
67
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
68
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
69
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
70
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
71
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
72
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
73
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
74
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
75
|
-
"declarationDir": "./dist", /* Specify the output directory for generated declaration files. */
|
|
76
|
-
|
|
77
|
-
/* Interop Constraints */
|
|
78
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
79
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
80
|
-
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
|
81
|
-
// "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
|
|
82
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
83
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
84
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
85
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
86
|
-
|
|
87
|
-
/* Type Checking */
|
|
88
|
-
"strict": false, /* Enable all strict type-checking options. */
|
|
89
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
90
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
91
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
92
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
93
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
94
|
-
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
|
95
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
96
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
97
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
98
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
99
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
100
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
101
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
102
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
103
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
104
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
105
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
106
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
107
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
108
|
-
|
|
109
|
-
/* Completeness */
|
|
110
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
111
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
112
|
-
},
|
|
113
|
-
"include": ["src/**/*"],
|
|
114
|
-
"exclude": ["node_modules", "dist"]
|
|
115
|
-
}
|