@rootintf/json-msg 2.3.2 → 3.0.5

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.
@@ -47,7 +47,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
47
47
  }
48
48
  } validate18.errors = vErrors; return errors === 0; }
49
49
  validate18.evaluated = { "props": { "id": true, "dt": true }, "dynamicProps": false, "dynamicItems": false };
50
- const schema_MsgEffect = validate19;
50
+ const schema_Efkt = validate19;
51
51
  function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate19.evaluated; if (evaluated0.dynamicProps) {
52
52
  evaluated0.props = undefined;
53
53
  } if (evaluated0.dynamicItems) {
@@ -66,7 +66,7 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
66
66
  }
67
67
  } validate19.errors = vErrors; return errors === 0; }
68
68
  validate19.evaluated = { "dynamicProps": false, "dynamicItems": false };
69
- const schema_MsgAckEffect = validate20;
69
+ const schema_Ack = validate20;
70
70
  function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
71
71
  evaluated0.props = undefined;
72
72
  } if (evaluated0.dynamicItems) {
@@ -139,21 +139,17 @@ function unsafeStringify(arr, offset = 0) {
139
139
  byteToHex[arr[offset + 15]]).toLowerCase();
140
140
  }
141
141
 
142
- let getRandomValues;
143
142
  const rnds8 = new Uint8Array(16);
144
143
  function rng() {
145
- if (!getRandomValues) {
146
- if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
147
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
148
- }
149
- getRandomValues = crypto.getRandomValues.bind(crypto);
150
- }
151
- return getRandomValues(rnds8);
144
+ return crypto.getRandomValues(rnds8);
152
145
  }
153
146
 
154
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
155
- var native = { randomUUID };
156
-
147
+ function v4(options, buf, offset) {
148
+ if (crypto.randomUUID) {
149
+ return crypto.randomUUID();
150
+ }
151
+ return _v4(options);
152
+ }
157
153
  function _v4(options, buf, offset) {
158
154
  options = options || {};
159
155
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -164,16 +160,10 @@ function _v4(options, buf, offset) {
164
160
  rnds[8] = (rnds[8] & 0x3f) | 0x80;
165
161
  return unsafeStringify(rnds);
166
162
  }
167
- function v4(options, buf, offset) {
168
- if (native.randomUUID && true && !options) {
169
- return native.randomUUID();
170
- }
171
- return _v4(options);
172
- }
173
163
 
174
164
  //-------------------------------------------------------------------------------------------------
175
165
  const LOGR_ = bitlogr.LOGR.get_instance();
176
- const logr_ = LOGR_.create({ labels: bitlogr.l_array(['VALIDATION']) });
166
+ const logr_ = LOGR_.create({ name: "npm:json-msg", labels: bitlogr.l_array(['VALIDATION']) });
177
167
  const l_ = logr_.l;
178
168
  // TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
179
169
  // "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
@@ -200,7 +190,7 @@ var JSON_Msg = (function () {
200
190
  // }
201
191
  };
202
192
  })();
203
- var JSON_MsgEffect = (function () {
193
+ var JSON_Efkt = (function () {
204
194
  return {
205
195
  create_with_cause_merge: function (msg_cause, json) {
206
196
  const _cause = msg_cause;
@@ -209,24 +199,24 @@ var JSON_MsgEffect = (function () {
209
199
  validate: function (json) {
210
200
  if (!JSON_Msg.validate(json))
211
201
  return false;
212
- const b_valid = schema_MsgEffect(json);
202
+ const b_valid = schema_Efkt(json);
213
203
  if (!b_valid)
214
- logr_.log(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
204
+ logr_.log(l_.VALIDATION, () => ['JSON_Efkt: validate: ', schema_Efkt.errors]);
215
205
  return b_valid;
216
206
  }
217
207
  };
218
208
  })();
219
- var JSON_MsgAck = (function () {
209
+ var JSON_Ack = (function () {
220
210
  return {
221
211
  create_with_cause_Ok: function (msg_cause, b_ok = true) {
222
- return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
212
+ return JSON_Efkt.create_with_cause_merge(msg_cause, {
223
213
  ack: {
224
214
  "ok": b_ok,
225
215
  },
226
216
  });
227
217
  },
228
218
  create_with_cause_Expired: function (msg_cause) {
229
- return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
219
+ return JSON_Efkt.create_with_cause_merge(msg_cause, {
230
220
  ack: {
231
221
  "ok": false,
232
222
  "expired": true
@@ -234,17 +224,17 @@ var JSON_MsgAck = (function () {
234
224
  });
235
225
  },
236
226
  validate: function (json) {
237
- if (!JSON_MsgEffect.validate(json))
227
+ if (!JSON_Efkt.validate(json))
238
228
  return false;
239
- const b_valid = schema_MsgAckEffect(json);
229
+ const b_valid = schema_Ack(json);
240
230
  if (!b_valid)
241
- logr_.log(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
231
+ logr_.log(l_.VALIDATION, () => ['JSON_Ack: validate: ', schema_Ack.errors]);
242
232
  return b_valid;
243
233
  }
244
234
  };
245
235
  })();
246
236
 
237
+ exports.JSON_Ack = JSON_Ack;
238
+ exports.JSON_Efkt = JSON_Efkt;
247
239
  exports.JSON_Msg = JSON_Msg;
248
- exports.JSON_MsgAck = JSON_MsgAck;
249
- exports.JSON_MsgEffect = JSON_MsgEffect;
250
240
  exports.logr = logr_;
@@ -45,7 +45,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
45
45
  }
46
46
  } validate18.errors = vErrors; return errors === 0; }
47
47
  validate18.evaluated = { "props": { "id": true, "dt": true }, "dynamicProps": false, "dynamicItems": false };
48
- const schema_MsgEffect = validate19;
48
+ const schema_Efkt = validate19;
49
49
  function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate19.evaluated; if (evaluated0.dynamicProps) {
50
50
  evaluated0.props = undefined;
51
51
  } if (evaluated0.dynamicItems) {
@@ -64,7 +64,7 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
64
64
  }
65
65
  } validate19.errors = vErrors; return errors === 0; }
66
66
  validate19.evaluated = { "dynamicProps": false, "dynamicItems": false };
67
- const schema_MsgAckEffect = validate20;
67
+ const schema_Ack = validate20;
68
68
  function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
69
69
  evaluated0.props = undefined;
70
70
  } if (evaluated0.dynamicItems) {
@@ -137,21 +137,17 @@ function unsafeStringify(arr, offset = 0) {
137
137
  byteToHex[arr[offset + 15]]).toLowerCase();
138
138
  }
139
139
 
140
- let getRandomValues;
141
140
  const rnds8 = new Uint8Array(16);
142
141
  function rng() {
143
- if (!getRandomValues) {
144
- if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
145
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
146
- }
147
- getRandomValues = crypto.getRandomValues.bind(crypto);
148
- }
149
- return getRandomValues(rnds8);
142
+ return crypto.getRandomValues(rnds8);
150
143
  }
151
144
 
152
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
153
- var native = { randomUUID };
154
-
145
+ function v4(options, buf, offset) {
146
+ if (crypto.randomUUID) {
147
+ return crypto.randomUUID();
148
+ }
149
+ return _v4(options);
150
+ }
155
151
  function _v4(options, buf, offset) {
156
152
  options = options || {};
157
153
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -162,16 +158,10 @@ function _v4(options, buf, offset) {
162
158
  rnds[8] = (rnds[8] & 0x3f) | 0x80;
163
159
  return unsafeStringify(rnds);
164
160
  }
165
- function v4(options, buf, offset) {
166
- if (native.randomUUID && true && !options) {
167
- return native.randomUUID();
168
- }
169
- return _v4(options);
170
- }
171
161
 
172
162
  //-------------------------------------------------------------------------------------------------
173
163
  const LOGR_ = LOGR.get_instance();
174
- const logr_ = LOGR_.create({ labels: l_array(['VALIDATION']) });
164
+ const logr_ = LOGR_.create({ name: "npm:json-msg", labels: l_array(['VALIDATION']) });
175
165
  const l_ = logr_.l;
176
166
  // TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
177
167
  // "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
@@ -198,7 +188,7 @@ var JSON_Msg = (function () {
198
188
  // }
199
189
  };
200
190
  })();
201
- var JSON_MsgEffect = (function () {
191
+ var JSON_Efkt = (function () {
202
192
  return {
203
193
  create_with_cause_merge: function (msg_cause, json) {
204
194
  const _cause = msg_cause;
@@ -207,24 +197,24 @@ var JSON_MsgEffect = (function () {
207
197
  validate: function (json) {
208
198
  if (!JSON_Msg.validate(json))
209
199
  return false;
210
- const b_valid = schema_MsgEffect(json);
200
+ const b_valid = schema_Efkt(json);
211
201
  if (!b_valid)
212
- logr_.log(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
202
+ logr_.log(l_.VALIDATION, () => ['JSON_Efkt: validate: ', schema_Efkt.errors]);
213
203
  return b_valid;
214
204
  }
215
205
  };
216
206
  })();
217
- var JSON_MsgAck = (function () {
207
+ var JSON_Ack = (function () {
218
208
  return {
219
209
  create_with_cause_Ok: function (msg_cause, b_ok = true) {
220
- return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
210
+ return JSON_Efkt.create_with_cause_merge(msg_cause, {
221
211
  ack: {
222
212
  "ok": b_ok,
223
213
  },
224
214
  });
225
215
  },
226
216
  create_with_cause_Expired: function (msg_cause) {
227
- return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
217
+ return JSON_Efkt.create_with_cause_merge(msg_cause, {
228
218
  ack: {
229
219
  "ok": false,
230
220
  "expired": true
@@ -232,14 +222,14 @@ var JSON_MsgAck = (function () {
232
222
  });
233
223
  },
234
224
  validate: function (json) {
235
- if (!JSON_MsgEffect.validate(json))
225
+ if (!JSON_Efkt.validate(json))
236
226
  return false;
237
- const b_valid = schema_MsgAckEffect(json);
227
+ const b_valid = schema_Ack(json);
238
228
  if (!b_valid)
239
- logr_.log(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
229
+ logr_.log(l_.VALIDATION, () => ['JSON_Ack: validate: ', schema_Ack.errors]);
240
230
  return b_valid;
241
231
  }
242
232
  };
243
233
  })();
244
234
 
245
- export { JSON_Msg, JSON_MsgAck, JSON_MsgEffect, logr_ as logr };
235
+ export { JSON_Ack, JSON_Efkt, JSON_Msg, logr_ as logr };
@@ -4,10 +4,10 @@ interface JSON_Msg {
4
4
  referer: unknown;
5
5
  dt: string;
6
6
  }
7
- interface JSON_MsgEffect extends JSON_Msg {
7
+ interface JSON_Efkt extends JSON_Msg {
8
8
  _cause: JSON_Msg;
9
9
  }
10
- interface JSON_MsgAck extends JSON_MsgEffect {
10
+ interface JSON_Ack extends JSON_Efkt {
11
11
  ack: {
12
12
  ok: boolean;
13
13
  expired?: boolean;
@@ -17,13 +17,13 @@ declare var JSON_Msg: {
17
17
  merge: <T extends object>(json: T) => JSON_Msg & T;
18
18
  validate: (json: unknown) => json is JSON_Msg;
19
19
  };
20
- declare var JSON_MsgEffect: {
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;
20
+ declare var JSON_Efkt: {
21
+ create_with_cause_merge: <T extends object>(msg_cause: JSON_Msg, json: T) => JSON_Efkt & T;
22
+ validate: (json: unknown) => json is JSON_Efkt;
23
23
  };
24
- declare var JSON_MsgAck: {
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;
24
+ declare var JSON_Ack: {
25
+ create_with_cause_Ok: (msg_cause: JSON_Msg, b_ok?: boolean) => JSON_Ack;
26
+ create_with_cause_Expired: (msg_cause: JSON_Msg) => JSON_Ack;
27
+ validate: (json: unknown) => json is JSON_Ack;
28
28
  };
29
- export { JSON_Msg, JSON_MsgEffect, JSON_MsgAck, logr_ as logr };
29
+ export { JSON_Msg, JSON_Efkt, JSON_Ack, logr_ as logr };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rootintf/json-msg",
3
- "version": "2.3.2",
3
+ "version": "3.0.5",
4
4
  "description": "",
5
5
  "main": "dist/json-msg.cjs.js",
6
6
  "module": "dist/json-msg.es.mjs",
@@ -39,20 +39,18 @@
39
39
  },
40
40
  "homepage": "https://gitlab.com/interface-x/npm-json-msg.git#readme",
41
41
  "dependencies": {
42
- "@knev/bitlogr": "^3.1.3",
42
+ "@knev/bitlogr": "^3.4.8",
43
43
  "ajv": "^8.17.1",
44
- "uuid": "^13.0.0"
44
+ "uuid": "^14.0.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@rollup/plugin-commonjs": "^29.0.0",
48
48
  "@rollup/plugin-json": "^6.1.0",
49
49
  "@rollup/plugin-node-resolve": "^16.0.3",
50
50
  "@rollup/plugin-typescript": "^12.3.0",
51
- "@types/ajv": "^1.0.4",
52
51
  "@types/node": "^24.10.1",
53
- "ajv-cli": "^5.0.0",
54
52
  "del-cli": "^7.0.0",
55
- "jasmine": "^5.13.0",
53
+ "jasmine": "^6.3.0",
56
54
  "rollup": "^4.53.3",
57
55
  "tslib": "^2.8.1",
58
56
  "typescript": "^5.9.3"