@bazariodev/docket 0.0.0-stage → 0.0.0

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +443 -2
  4. package/dist/browser/constants.d.cts +14 -0
  5. package/dist/browser/constants.d.ts +14 -0
  6. package/dist/browser/index.cjs +192 -0
  7. package/dist/browser/index.cjs.map +1 -0
  8. package/dist/browser/index.d.cts +29 -0
  9. package/dist/browser/index.d.ts +29 -0
  10. package/dist/browser/index.js +187 -0
  11. package/dist/browser/index.js.map +1 -0
  12. package/dist/chunk-7ld72rnl.js +376 -0
  13. package/dist/chunk-7ld72rnl.js.map +1 -0
  14. package/dist/chunk-B-SP8Od_.js +437 -0
  15. package/dist/chunk-B-SP8Od_.js.map +1 -0
  16. package/dist/chunk-BLf-eCDO.cjs +53 -0
  17. package/dist/chunk-BLf-eCDO.cjs.map +1 -0
  18. package/dist/chunk-Bvq4tF_F.cjs +440 -0
  19. package/dist/chunk-Bvq4tF_F.cjs.map +1 -0
  20. package/dist/chunk-CEhpwtwJ.cjs +379 -0
  21. package/dist/chunk-CEhpwtwJ.cjs.map +1 -0
  22. package/dist/chunk-CSS3f4_M.js +46 -0
  23. package/dist/chunk-CSS3f4_M.js.map +1 -0
  24. package/dist/chunk-CXZYNALm.cjs +124 -0
  25. package/dist/chunk-CXZYNALm.cjs.map +1 -0
  26. package/dist/chunk-DYcNnkOV.js +50 -0
  27. package/dist/chunk-DYcNnkOV.js.map +1 -0
  28. package/dist/chunk-DqK_3eFr.cjs +53 -0
  29. package/dist/chunk-DqK_3eFr.cjs.map +1 -0
  30. package/dist/chunk-LRCHwVuE.js +110 -0
  31. package/dist/chunk-LRCHwVuE.js.map +1 -0
  32. package/dist/constants.d.cts +6 -0
  33. package/dist/constants.d.ts +6 -0
  34. package/dist/core/constants.d.cts +43 -0
  35. package/dist/core/constants.d.ts +43 -0
  36. package/dist/core/errors.d.cts +8 -0
  37. package/dist/core/errors.d.ts +8 -0
  38. package/dist/devtools/index.cjs +37 -0
  39. package/dist/devtools/index.cjs.map +1 -0
  40. package/dist/devtools/index.d.cts +11 -0
  41. package/dist/devtools/index.d.ts +11 -0
  42. package/dist/devtools/index.js +35 -0
  43. package/dist/devtools/index.js.map +1 -0
  44. package/dist/export/index.cjs +111 -0
  45. package/dist/export/index.cjs.map +1 -0
  46. package/dist/export/index.d.cts +49 -0
  47. package/dist/export/index.d.ts +49 -0
  48. package/dist/export/index.js +109 -0
  49. package/dist/export/index.js.map +1 -0
  50. package/dist/history/constants.d.cts +35 -0
  51. package/dist/history/constants.d.ts +35 -0
  52. package/dist/history/index.cjs +1196 -0
  53. package/dist/history/index.cjs.map +1 -0
  54. package/dist/history/index.d.cts +113 -0
  55. package/dist/history/index.d.ts +113 -0
  56. package/dist/history/index.js +1194 -0
  57. package/dist/history/index.js.map +1 -0
  58. package/dist/index.cjs +14 -0
  59. package/dist/index.cjs.map +1 -0
  60. package/dist/index.d.cts +158 -0
  61. package/dist/index.d.ts +158 -0
  62. package/dist/index.js +6 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/indexeddb/index.cjs +15 -0
  65. package/dist/indexeddb/index.cjs.map +1 -0
  66. package/dist/indexeddb/index.d.cts +46 -0
  67. package/dist/indexeddb/index.d.ts +46 -0
  68. package/dist/indexeddb/index.js +13 -0
  69. package/dist/indexeddb/index.js.map +1 -0
  70. package/dist/redaction/index.cjs +154 -0
  71. package/dist/redaction/index.cjs.map +1 -0
  72. package/dist/redaction/index.d.cts +70 -0
  73. package/dist/redaction/index.d.ts +70 -0
  74. package/dist/redaction/index.js +152 -0
  75. package/dist/redaction/index.js.map +1 -0
  76. package/dist/sip/constants.d.cts +5 -0
  77. package/dist/sip/constants.d.ts +5 -0
  78. package/dist/sip/index.cjs +336 -0
  79. package/dist/sip/index.cjs.map +1 -0
  80. package/dist/sip/index.d.cts +34 -0
  81. package/dist/sip/index.d.ts +34 -0
  82. package/dist/sip/index.js +333 -0
  83. package/dist/sip/index.js.map +1 -0
  84. package/dist/storage/constants.d.cts +11 -0
  85. package/dist/storage/constants.d.ts +11 -0
  86. package/dist/storage/contracts.d.cts +35 -0
  87. package/dist/storage/contracts.d.ts +35 -0
  88. package/package.json +127 -3
@@ -0,0 +1,379 @@
1
+ 'use strict';
2
+
3
+ var common = require('./chunk-CXZYNALm.cjs');
4
+ var constants = require('./chunk-BLf-eCDO.cjs');
5
+
6
+ const errorKeys = ['name', 'message', 'stack', 'cause', 'errors', 'fields'];
7
+ const recordKeys = [
8
+ 'runId',
9
+ 'seq',
10
+ 'at',
11
+ 'level',
12
+ 'area',
13
+ 'scope',
14
+ 'message',
15
+ 'redactionVersion',
16
+ 'fields',
17
+ 'context',
18
+ 'error',
19
+ 'truncated',
20
+ ];
21
+
22
+ function errorShape(keys, descriptors) {
23
+ return (
24
+ keys.every((key) => errorKeys.includes(key)) &&
25
+ typeof descriptors.get('name')?.value === 'string' &&
26
+ typeof descriptors.get('message')?.value === 'string' &&
27
+ (!descriptors.has('stack') ||
28
+ typeof descriptors.get('stack').value === 'string')
29
+ );
30
+ }
31
+
32
+ function errorMarker({ array, keys, descriptors }) {
33
+ return (
34
+ !array &&
35
+ keys.length === 2 &&
36
+ descriptors.get('name')?.value === 'Error' &&
37
+ descriptors.get('message')?.value === constants.MARKERS.LIMIT
38
+ );
39
+ }
40
+
41
+ function arrayIndex(key, length) {
42
+ const index = typeof key === 'string' ? Number(key) : -1;
43
+ return (
44
+ Number.isSafeInteger(index) &&
45
+ index >= 0 &&
46
+ index < length &&
47
+ String(index) === key
48
+ );
49
+ }
50
+
51
+ function ownJson(value, limits, { record = false } = {}) {
52
+ let nodes = 0;
53
+ let classifiedNodes = 0;
54
+ const ancestors = new Set();
55
+ const snapshots = new WeakMap();
56
+ const classifications = new WeakMap();
57
+ const classifying = new Set();
58
+
59
+ function inspect(value, kind = '') {
60
+ const cached = snapshots.get(value);
61
+ if (cached) return cached;
62
+ const array = Array.isArray(value);
63
+ const length = array ? common.own(value, 'length') : 0;
64
+ if (
65
+ array &&
66
+ (!Number.isSafeInteger(length) ||
67
+ length < 0 ||
68
+ length > limits.maxArrayLength + 1)
69
+ )
70
+ throw new TypeError('Invalid redactor bounds');
71
+ const keys = Reflect.ownKeys(value).filter(
72
+ (key) => !(array && key === 'length'),
73
+ );
74
+ const ceiling =
75
+ kind === 'marker'
76
+ ? 2
77
+ : kind === 'record'
78
+ ? recordKeys.length
79
+ : Math.max(limits.maxKeys + 1, errorKeys.length);
80
+ if (
81
+ (array && keys.length > limits.maxArrayLength + 1) ||
82
+ (!array && keys.length > ceiling)
83
+ )
84
+ throw new TypeError('Invalid redactor bounds');
85
+ const descriptors = new Map();
86
+ for (const key of keys) {
87
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
88
+ if (!descriptor || !Object.hasOwn(descriptor, 'value'))
89
+ throw new TypeError('Invalid redactor property');
90
+ descriptors.set(key, descriptor);
91
+ }
92
+ const snapshot = { array, length, keys, descriptors };
93
+ snapshots.set(value, snapshot);
94
+ return snapshot;
95
+ }
96
+
97
+ function errorRelationships({ descriptors }, depth) {
98
+ const fields = descriptors.get('fields');
99
+ if (
100
+ fields &&
101
+ (!fields.value ||
102
+ typeof fields.value !== 'object' ||
103
+ Array.isArray(fields.value))
104
+ )
105
+ return false;
106
+ const cause = descriptors.get('cause');
107
+ if (cause && !canonicalError(cause.value, depth + 1)) return false;
108
+ const errors = descriptors.get('errors');
109
+ if (!errors) return true;
110
+ if (!Array.isArray(errors.value)) return false;
111
+ const { length, keys, descriptors: children } = inspect(errors.value);
112
+ if (length !== keys.length || !keys.every((key) => arrayIndex(key, length)))
113
+ return false;
114
+ for (const key of keys)
115
+ if (!canonicalError(children.get(key).value, depth + 1)) return false;
116
+ return (
117
+ length <= limits.maxArrayLength ||
118
+ errorMarker(inspect(children.get(String(length - 1)).value))
119
+ );
120
+ }
121
+
122
+ function canonicalError(value, depth) {
123
+ if (!value || typeof value !== 'object' || Array.isArray(value))
124
+ return false;
125
+ const cached = classifications.get(value);
126
+ if (cached !== undefined) return cached;
127
+ if (classifying.has(value)) return false;
128
+ const snapshot = inspect(
129
+ value,
130
+ depth > limits.maxDepth || classifiedNodes >= limits.maxNodes
131
+ ? 'marker'
132
+ : '',
133
+ );
134
+ if (!errorShape(snapshot.keys, snapshot.descriptors)) {
135
+ classifications.set(value, false);
136
+ return false;
137
+ }
138
+ if (errorMarker(snapshot)) {
139
+ classifications.set(value, true);
140
+ return true;
141
+ }
142
+ if (depth > limits.maxDepth) return false;
143
+ if (++classifiedNodes > limits.maxNodes)
144
+ throw new TypeError('Invalid redactor bounds');
145
+ classifying.add(value);
146
+ const valid = errorRelationships(snapshot, depth);
147
+ classifying.delete(value);
148
+ classifications.set(value, valid);
149
+ return valid;
150
+ }
151
+
152
+ function charge(kind, marker) {
153
+ if (
154
+ !marker &&
155
+ ![
156
+ 'record',
157
+ 'header',
158
+ 'fixed',
159
+ 'error-name',
160
+ 'error-text',
161
+ 'errors',
162
+ 'error-fields',
163
+ 'boxed-fields',
164
+ ].includes(kind) &&
165
+ ++nodes > limits.maxNodes
166
+ )
167
+ throw new TypeError('Invalid redactor bounds');
168
+ }
169
+
170
+ function copy(value, depth, kind = '', overflow = false) {
171
+ const compound = value && typeof value === 'object';
172
+ const marker = overflow && value === constants.MARKERS.LIMIT;
173
+ if (!compound) {
174
+ if (
175
+ [
176
+ 'error',
177
+ 'errors',
178
+ 'error-fields',
179
+ 'record',
180
+ 'fields',
181
+ 'context',
182
+ ].includes(kind)
183
+ )
184
+ throw new TypeError('Invalid redactor JSON');
185
+ charge(kind, marker);
186
+ if (depth > limits.maxDepth && value !== constants.MARKERS.LIMIT)
187
+ throw new TypeError('Invalid redactor bounds');
188
+ if (
189
+ value === null ||
190
+ typeof value === 'boolean' ||
191
+ (typeof value === 'number' && Number.isFinite(value))
192
+ )
193
+ return value;
194
+ if (
195
+ typeof value === 'string' &&
196
+ (value.length <= limits.maxStringLength ||
197
+ Object.values(constants.MARKERS).includes(value) ||
198
+ (kind === 'fixed' && value.length <= 64) ||
199
+ (kind === 'error-name' && value === 'Error'))
200
+ )
201
+ return value;
202
+ throw new TypeError('Invalid redactor JSON');
203
+ }
204
+ if (ancestors.has(value)) throw new TypeError('Invalid redactor JSON');
205
+ if (
206
+ depth > limits.maxDepth &&
207
+ kind !== 'errors' &&
208
+ !(overflow && kind === 'error')
209
+ )
210
+ throw new TypeError('Invalid redactor bounds');
211
+ const { array, length, keys, descriptors } = inspect(
212
+ value,
213
+ depth > limits.maxDepth && kind === 'error' ? 'marker' : kind,
214
+ );
215
+ if (
216
+ (kind === 'errors' && !array) ||
217
+ (['record', 'error', 'error-fields', 'fields', 'context'].includes(
218
+ kind,
219
+ ) &&
220
+ array)
221
+ )
222
+ throw new TypeError('Invalid redactor JSON');
223
+ const shapedError = !array && errorShape(keys, descriptors);
224
+ if (kind === 'error' && !shapedError)
225
+ throw new TypeError('Invalid serialized error');
226
+ if (!kind && shapedError && canonicalError(value, depth)) kind = 'error';
227
+ if (kind === 'fields' && keys.length === 1 && keys[0] === 'value')
228
+ kind = 'boxed-fields';
229
+ const overflowMarker =
230
+ overflow && kind === 'error' && errorMarker({ array, keys, descriptors });
231
+ if (overflowMarker)
232
+ return Object.freeze({ name: 'Error', message: constants.MARKERS.LIMIT });
233
+ if (depth > limits.maxDepth && kind !== 'errors')
234
+ throw new TypeError('Invalid redactor bounds');
235
+ charge(kind, false);
236
+ const schema = kind === 'record' || kind === 'error';
237
+ const keyLimit = schema
238
+ ? kind === 'record'
239
+ ? recordKeys.length
240
+ : errorKeys.length
241
+ : array
242
+ ? limits.maxArrayLength
243
+ : limits.maxKeys;
244
+ const lastKey = array && length ? String(length - 1) : '';
245
+ const last = descriptors.get(lastKey)?.value;
246
+ const markerCount = array
247
+ ? Number(
248
+ last === constants.MARKERS.LIMIT ||
249
+ (kind === 'errors' && last && typeof last === 'object'),
250
+ )
251
+ : Number(descriptors.get(constants.MARKERS.LIMIT)?.value === constants.MARKERS.LIMIT);
252
+ if (
253
+ keys.length > keyLimit + markerCount ||
254
+ (array &&
255
+ (length !== keys.length ||
256
+ length > limits.maxArrayLength + markerCount))
257
+ )
258
+ throw new TypeError('Invalid redactor bounds');
259
+ if (kind === 'record' && keys.some((key) => !recordKeys.includes(key)))
260
+ throw new TypeError('Invalid record property');
261
+ const result = array ? [] : {};
262
+ ancestors.add(value);
263
+ for (const key of keys) {
264
+ if (array && !arrayIndex(key, length))
265
+ throw new TypeError('Invalid redactor index');
266
+ const descriptor = descriptors.get(key);
267
+ if (
268
+ typeof key !== 'string' ||
269
+ (!schema &&
270
+ !array &&
271
+ kind !== 'boxed-fields' &&
272
+ key.length > limits.maxStringLength &&
273
+ !Object.values(constants.MARKERS).includes(key)) ||
274
+ !Object.hasOwn(descriptor, 'value')
275
+ )
276
+ throw new TypeError('Invalid redactor property');
277
+ let childKind = '';
278
+ let childDepth = depth + 1;
279
+ let childOverflow =
280
+ (array &&
281
+ key === lastKey &&
282
+ (last === constants.MARKERS.LIMIT || (kind === 'errors' && markerCount))) ||
283
+ (key === constants.MARKERS.LIMIT && descriptor.value === constants.MARKERS.LIMIT);
284
+ if (kind === 'record') {
285
+ childDepth = 0;
286
+ childKind = 'header';
287
+ if (key === 'context') childKind = 'context';
288
+ if (key === 'fields') childKind = 'fields';
289
+ if (key === 'error') {
290
+ childKind = 'error';
291
+ childOverflow = true;
292
+ }
293
+ if (['runId', 'level', 'redactionVersion'].includes(key))
294
+ childKind = 'fixed';
295
+ } else if (kind === 'error') {
296
+ switch (key) {
297
+ case 'cause':
298
+ childKind = 'error';
299
+ childOverflow = true;
300
+ break;
301
+ case 'errors':
302
+ childKind = 'errors';
303
+ break;
304
+ case 'fields':
305
+ childKind = 'error-fields';
306
+ childDepth = depth;
307
+ break;
308
+ default:
309
+ childKind = key === 'name' ? 'error-name' : 'error-text';
310
+ childDepth = depth;
311
+ }
312
+ } else if (kind === 'errors') {
313
+ childKind = 'error';
314
+ childDepth = depth;
315
+ if (depth > limits.maxDepth) childOverflow = true;
316
+ } else if (kind === 'boxed-fields') {
317
+ childDepth = depth;
318
+ childOverflow = descriptor.value === constants.MARKERS.LIMIT;
319
+ }
320
+ common.define(
321
+ result,
322
+ key,
323
+ copy(descriptor.value, childDepth, childKind, childOverflow),
324
+ );
325
+ }
326
+
327
+ if (array && length > limits.maxArrayLength) {
328
+ const end = result[length - 1];
329
+ if (
330
+ end !== constants.MARKERS.LIMIT &&
331
+ !(
332
+ kind === 'errors' &&
333
+ end &&
334
+ typeof end === 'object' &&
335
+ Object.keys(end).length === 2 &&
336
+ end.name === 'Error' &&
337
+ end.message === constants.MARKERS.LIMIT
338
+ )
339
+ )
340
+ throw new TypeError('Invalid redactor bounds');
341
+ }
342
+
343
+ ancestors.delete(value);
344
+ return Object.freeze(result);
345
+ }
346
+ const result = copy(value, 0, record ? 'record' : '');
347
+ if (JSON.stringify(result).length > limits.maxRecordSize)
348
+ throw new TypeError('Invalid record size');
349
+ return result;
350
+ }
351
+
352
+ function ownRecord(record, limits) {
353
+ const result = ownJson(record, limits, { record: true });
354
+ for (const key of ['runId', 'area', 'scope', 'message', 'redactionVersion'])
355
+ if (typeof result[key] !== 'string')
356
+ throw new TypeError('Invalid record header');
357
+ if (
358
+ !Number.isSafeInteger(result.seq) ||
359
+ result.seq < 1 ||
360
+ !Number.isFinite(result.at) ||
361
+ !Object.values(constants.LEVELS).includes(result.level)
362
+ )
363
+ throw new TypeError('Invalid record header');
364
+ if (
365
+ result.context !== undefined &&
366
+ Object.values(result.context).some(
367
+ (value) => typeof value !== 'string' && typeof value !== 'number',
368
+ )
369
+ )
370
+ throw new TypeError('Invalid record context');
371
+
372
+ if (result.truncated !== undefined && result.truncated !== true)
373
+ throw new TypeError('Invalid truncation flag');
374
+ return result;
375
+ }
376
+
377
+ exports.ownJson = ownJson;
378
+ exports.ownRecord = ownRecord;
379
+ //# sourceMappingURL=chunk-CEhpwtwJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-CEhpwtwJ.cjs","sources":["../src/core/conversion.js"],"sourcesContent":["import { define, own } from './common.js';\nimport { LEVELS, MARKERS } from './constants.js';\n\nconst errorKeys = ['name', 'message', 'stack', 'cause', 'errors', 'fields'];\nconst recordKeys = [\n 'runId',\n 'seq',\n 'at',\n 'level',\n 'area',\n 'scope',\n 'message',\n 'redactionVersion',\n 'fields',\n 'context',\n 'error',\n 'truncated',\n];\n\nfunction errorShape(keys, descriptors) {\n return (\n keys.every((key) => errorKeys.includes(key)) &&\n typeof descriptors.get('name')?.value === 'string' &&\n typeof descriptors.get('message')?.value === 'string' &&\n (!descriptors.has('stack') ||\n typeof descriptors.get('stack').value === 'string')\n );\n}\n\nfunction errorMarker({ array, keys, descriptors }) {\n return (\n !array &&\n keys.length === 2 &&\n descriptors.get('name')?.value === 'Error' &&\n descriptors.get('message')?.value === MARKERS.LIMIT\n );\n}\n\nfunction arrayIndex(key, length) {\n const index = typeof key === 'string' ? Number(key) : -1;\n return (\n Number.isSafeInteger(index) &&\n index >= 0 &&\n index < length &&\n String(index) === key\n );\n}\n\nexport function ownJson(value, limits, { record = false } = {}) {\n let nodes = 0;\n let classifiedNodes = 0;\n const ancestors = new Set();\n const snapshots = new WeakMap();\n const classifications = new WeakMap();\n const classifying = new Set();\n\n function inspect(value, kind = '') {\n const cached = snapshots.get(value);\n if (cached) return cached;\n const array = Array.isArray(value);\n const length = array ? own(value, 'length') : 0;\n if (\n array &&\n (!Number.isSafeInteger(length) ||\n length < 0 ||\n length > limits.maxArrayLength + 1)\n )\n throw new TypeError('Invalid redactor bounds');\n const keys = Reflect.ownKeys(value).filter(\n (key) => !(array && key === 'length'),\n );\n const ceiling =\n kind === 'marker'\n ? 2\n : kind === 'record'\n ? recordKeys.length\n : Math.max(limits.maxKeys + 1, errorKeys.length);\n if (\n (array && keys.length > limits.maxArrayLength + 1) ||\n (!array && keys.length > ceiling)\n )\n throw new TypeError('Invalid redactor bounds');\n const descriptors = new Map();\n for (const key of keys) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (!descriptor || !Object.hasOwn(descriptor, 'value'))\n throw new TypeError('Invalid redactor property');\n descriptors.set(key, descriptor);\n }\n const snapshot = { array, length, keys, descriptors };\n snapshots.set(value, snapshot);\n return snapshot;\n }\n\n function errorRelationships({ descriptors }, depth) {\n const fields = descriptors.get('fields');\n if (\n fields &&\n (!fields.value ||\n typeof fields.value !== 'object' ||\n Array.isArray(fields.value))\n )\n return false;\n const cause = descriptors.get('cause');\n if (cause && !canonicalError(cause.value, depth + 1)) return false;\n const errors = descriptors.get('errors');\n if (!errors) return true;\n if (!Array.isArray(errors.value)) return false;\n const { length, keys, descriptors: children } = inspect(errors.value);\n if (length !== keys.length || !keys.every((key) => arrayIndex(key, length)))\n return false;\n for (const key of keys)\n if (!canonicalError(children.get(key).value, depth + 1)) return false;\n return (\n length <= limits.maxArrayLength ||\n errorMarker(inspect(children.get(String(length - 1)).value))\n );\n }\n\n function canonicalError(value, depth) {\n if (!value || typeof value !== 'object' || Array.isArray(value))\n return false;\n const cached = classifications.get(value);\n if (cached !== undefined) return cached;\n if (classifying.has(value)) return false;\n const snapshot = inspect(\n value,\n depth > limits.maxDepth || classifiedNodes >= limits.maxNodes\n ? 'marker'\n : '',\n );\n if (!errorShape(snapshot.keys, snapshot.descriptors)) {\n classifications.set(value, false);\n return false;\n }\n if (errorMarker(snapshot)) {\n classifications.set(value, true);\n return true;\n }\n if (depth > limits.maxDepth) return false;\n if (++classifiedNodes > limits.maxNodes)\n throw new TypeError('Invalid redactor bounds');\n classifying.add(value);\n const valid = errorRelationships(snapshot, depth);\n classifying.delete(value);\n classifications.set(value, valid);\n return valid;\n }\n\n function charge(kind, marker) {\n if (\n !marker &&\n ![\n 'record',\n 'header',\n 'fixed',\n 'error-name',\n 'error-text',\n 'errors',\n 'error-fields',\n 'boxed-fields',\n ].includes(kind) &&\n ++nodes > limits.maxNodes\n )\n throw new TypeError('Invalid redactor bounds');\n }\n\n function copy(value, depth, kind = '', overflow = false) {\n const compound = value && typeof value === 'object';\n const marker = overflow && value === MARKERS.LIMIT;\n if (!compound) {\n if (\n [\n 'error',\n 'errors',\n 'error-fields',\n 'record',\n 'fields',\n 'context',\n ].includes(kind)\n )\n throw new TypeError('Invalid redactor JSON');\n charge(kind, marker);\n if (depth > limits.maxDepth && value !== MARKERS.LIMIT)\n throw new TypeError('Invalid redactor bounds');\n if (\n value === null ||\n typeof value === 'boolean' ||\n (typeof value === 'number' && Number.isFinite(value))\n )\n return value;\n if (\n typeof value === 'string' &&\n (value.length <= limits.maxStringLength ||\n Object.values(MARKERS).includes(value) ||\n (kind === 'fixed' && value.length <= 64) ||\n (kind === 'error-name' && value === 'Error'))\n )\n return value;\n throw new TypeError('Invalid redactor JSON');\n }\n if (ancestors.has(value)) throw new TypeError('Invalid redactor JSON');\n if (\n depth > limits.maxDepth &&\n kind !== 'errors' &&\n !(overflow && kind === 'error')\n )\n throw new TypeError('Invalid redactor bounds');\n const { array, length, keys, descriptors } = inspect(\n value,\n depth > limits.maxDepth && kind === 'error' ? 'marker' : kind,\n );\n if (\n (kind === 'errors' && !array) ||\n (['record', 'error', 'error-fields', 'fields', 'context'].includes(\n kind,\n ) &&\n array)\n )\n throw new TypeError('Invalid redactor JSON');\n const shapedError = !array && errorShape(keys, descriptors);\n if (kind === 'error' && !shapedError)\n throw new TypeError('Invalid serialized error');\n if (!kind && shapedError && canonicalError(value, depth)) kind = 'error';\n if (kind === 'fields' && keys.length === 1 && keys[0] === 'value')\n kind = 'boxed-fields';\n const overflowMarker =\n overflow && kind === 'error' && errorMarker({ array, keys, descriptors });\n if (overflowMarker)\n return Object.freeze({ name: 'Error', message: MARKERS.LIMIT });\n if (depth > limits.maxDepth && kind !== 'errors')\n throw new TypeError('Invalid redactor bounds');\n charge(kind, false);\n const schema = kind === 'record' || kind === 'error';\n const keyLimit = schema\n ? kind === 'record'\n ? recordKeys.length\n : errorKeys.length\n : array\n ? limits.maxArrayLength\n : limits.maxKeys;\n const lastKey = array && length ? String(length - 1) : '';\n const last = descriptors.get(lastKey)?.value;\n const markerCount = array\n ? Number(\n last === MARKERS.LIMIT ||\n (kind === 'errors' && last && typeof last === 'object'),\n )\n : Number(descriptors.get(MARKERS.LIMIT)?.value === MARKERS.LIMIT);\n if (\n keys.length > keyLimit + markerCount ||\n (array &&\n (length !== keys.length ||\n length > limits.maxArrayLength + markerCount))\n )\n throw new TypeError('Invalid redactor bounds');\n if (kind === 'record' && keys.some((key) => !recordKeys.includes(key)))\n throw new TypeError('Invalid record property');\n const result = array ? [] : {};\n ancestors.add(value);\n for (const key of keys) {\n if (array && !arrayIndex(key, length))\n throw new TypeError('Invalid redactor index');\n const descriptor = descriptors.get(key);\n if (\n typeof key !== 'string' ||\n (!schema &&\n !array &&\n kind !== 'boxed-fields' &&\n key.length > limits.maxStringLength &&\n !Object.values(MARKERS).includes(key)) ||\n !Object.hasOwn(descriptor, 'value')\n )\n throw new TypeError('Invalid redactor property');\n let childKind = '';\n let childDepth = depth + 1;\n let childOverflow =\n (array &&\n key === lastKey &&\n (last === MARKERS.LIMIT || (kind === 'errors' && markerCount))) ||\n (key === MARKERS.LIMIT && descriptor.value === MARKERS.LIMIT);\n if (kind === 'record') {\n childDepth = 0;\n childKind = 'header';\n if (key === 'context') childKind = 'context';\n if (key === 'fields') childKind = 'fields';\n if (key === 'error') {\n childKind = 'error';\n childOverflow = true;\n }\n if (['runId', 'level', 'redactionVersion'].includes(key))\n childKind = 'fixed';\n } else if (kind === 'error') {\n switch (key) {\n case 'cause':\n childKind = 'error';\n childOverflow = true;\n break;\n case 'errors':\n childKind = 'errors';\n break;\n case 'fields':\n childKind = 'error-fields';\n childDepth = depth;\n break;\n default:\n childKind = key === 'name' ? 'error-name' : 'error-text';\n childDepth = depth;\n }\n } else if (kind === 'errors') {\n childKind = 'error';\n childDepth = depth;\n if (depth > limits.maxDepth) childOverflow = true;\n } else if (kind === 'boxed-fields') {\n childDepth = depth;\n childOverflow = descriptor.value === MARKERS.LIMIT;\n }\n define(\n result,\n key,\n copy(descriptor.value, childDepth, childKind, childOverflow),\n );\n }\n\n if (array && length > limits.maxArrayLength) {\n const end = result[length - 1];\n if (\n end !== MARKERS.LIMIT &&\n !(\n kind === 'errors' &&\n end &&\n typeof end === 'object' &&\n Object.keys(end).length === 2 &&\n end.name === 'Error' &&\n end.message === MARKERS.LIMIT\n )\n )\n throw new TypeError('Invalid redactor bounds');\n }\n\n ancestors.delete(value);\n return Object.freeze(result);\n }\n const result = copy(value, 0, record ? 'record' : '');\n if (JSON.stringify(result).length > limits.maxRecordSize)\n throw new TypeError('Invalid record size');\n return result;\n}\n\nexport function ownRecord(record, limits) {\n const result = ownJson(record, limits, { record: true });\n for (const key of ['runId', 'area', 'scope', 'message', 'redactionVersion'])\n if (typeof result[key] !== 'string')\n throw new TypeError('Invalid record header');\n if (\n !Number.isSafeInteger(result.seq) ||\n result.seq < 1 ||\n !Number.isFinite(result.at) ||\n !Object.values(LEVELS).includes(result.level)\n )\n throw new TypeError('Invalid record header');\n if (\n result.context !== undefined &&\n Object.values(result.context).some(\n (value) => typeof value !== 'string' && typeof value !== 'number',\n )\n )\n throw new TypeError('Invalid record context');\n\n if (result.truncated !== undefined && result.truncated !== true)\n throw new TypeError('Invalid truncation flag');\n return result;\n}\n"],"names":["MARKERS","own","define","LEVELS"],"mappings":";;;;;AAGA,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC;AAC3E,MAAM,UAAU,GAAG;AACnB,EAAE,OAAO;AACT,EAAE,KAAK;AACP,EAAE,IAAI;AACN,EAAE,OAAO;AACT,EAAE,MAAM;AACR,EAAE,OAAO;AACT,EAAE,SAAS;AACX,EAAE,kBAAkB;AACpB,EAAE,QAAQ;AACV,EAAE,SAAS;AACX,EAAE,OAAO;AACT,EAAE,WAAW;AACb,CAAC;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OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ;AACvE;AACA;AACA,IAAI,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC;;AAEjD,EAAE,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,KAAK,IAAI;AACjE,IAAI,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC;AAClD,EAAE,OAAO,MAAM;AACf;;;"}
@@ -0,0 +1,46 @@
1
+ const LEVELS = /* @__PURE__ */ Object.freeze({
2
+ DEBUG: 'debug',
3
+ INFO: 'info',
4
+ WARN: 'warn',
5
+ ERROR: 'error',
6
+ });
7
+ const LOGGING_LIMITS = /* @__PURE__ */ Object.freeze({
8
+ ROOT_LOGGER_CACHE_PAIRS: 1000,
9
+ STORM_SCOPE_PAIRS: 1000,
10
+ STORM_WINDOW_MS: 1000,
11
+ STORM_SUMMARY_DELAY_MS: 1000,
12
+ DEFAULT_LEVEL_OVERRIDE_MS: 86_400_000,
13
+ MAX_TIMER_DELAY_MS: 2_147_483_647,
14
+ DEFAULT_STORM_LIMIT: 100,
15
+ });
16
+ const LOGGING_ERROR_CODES = /* @__PURE__ */ Object.freeze({
17
+ RECURSIVE_LOGGING: 'recursive-logging',
18
+ ROOT_LOGGER_CACHE_LIMIT: 'root-logger-cache-limit',
19
+ STOPPED: 'stopped',
20
+ });
21
+ const LOGGING_ERROR_SOURCES = /* @__PURE__ */ Object.freeze({
22
+ DATA: 'data',
23
+ REDACTOR: 'redactor',
24
+ SINK: 'sink',
25
+ STORAGE: 'storage',
26
+ SCOPE: 'scope',
27
+ REENTRY: 'reentry',
28
+ });
29
+ const LIMITS = /* @__PURE__ */ Object.freeze({
30
+ maxDepth: 6,
31
+ maxStringLength: 16_384,
32
+ maxArrayLength: 100,
33
+ maxKeys: 100,
34
+ maxNodes: 1000,
35
+ maxRecordSize: 65_536,
36
+ });
37
+ const MARKERS = /* @__PURE__ */ Object.freeze({
38
+ LIMIT: '[truncated]',
39
+ CYCLE: '[circular]',
40
+ ACCESSOR: '[accessor]',
41
+ UNSUPPORTED: '[unsupported]',
42
+ MASK: '[redacted]',
43
+ });
44
+
45
+ export { LEVELS as L, MARKERS as M, LIMITS as a, LOGGING_ERROR_CODES as b, LOGGING_LIMITS as c, LOGGING_ERROR_SOURCES as d };
46
+ //# sourceMappingURL=chunk-CSS3f4_M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-CSS3f4_M.js","sources":["../src/core/constants.js"],"sourcesContent":["export const LEVELS = /* @__PURE__ */ Object.freeze({\n DEBUG: 'debug',\n INFO: 'info',\n WARN: 'warn',\n ERROR: 'error',\n});\nexport const LOGGING_LIMITS = /* @__PURE__ */ Object.freeze({\n ROOT_LOGGER_CACHE_PAIRS: 1000,\n STORM_SCOPE_PAIRS: 1000,\n STORM_WINDOW_MS: 1000,\n STORM_SUMMARY_DELAY_MS: 1000,\n DEFAULT_LEVEL_OVERRIDE_MS: 86_400_000,\n MAX_TIMER_DELAY_MS: 2_147_483_647,\n DEFAULT_STORM_LIMIT: 100,\n});\nexport const LOGGING_ERROR_CODES = /* @__PURE__ */ Object.freeze({\n RECURSIVE_LOGGING: 'recursive-logging',\n ROOT_LOGGER_CACHE_LIMIT: 'root-logger-cache-limit',\n STOPPED: 'stopped',\n});\nexport const LOGGING_ERROR_SOURCES = /* @__PURE__ */ Object.freeze({\n DATA: 'data',\n REDACTOR: 'redactor',\n SINK: 'sink',\n STORAGE: 'storage',\n SCOPE: 'scope',\n REENTRY: 'reentry',\n});\nexport const LIMITS = /* @__PURE__ */ Object.freeze({\n maxDepth: 6,\n maxStringLength: 16_384,\n maxArrayLength: 100,\n maxKeys: 100,\n maxNodes: 1000,\n maxRecordSize: 65_536,\n});\nexport const MARKERS = /* @__PURE__ */ Object.freeze({\n LIMIT: '[truncated]',\n CYCLE: '[circular]',\n ACCESSOR: '[accessor]',\n UNSUPPORTED: '[unsupported]',\n MASK: '[redacted]',\n});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AK,EAAE,YAAY;AACrB,EAAE,QAAQ,EAAE,YAAY;AACxB,EAAE,WAAW,EAAE,eAAe;AAC9B,EAAE,IAAI,EAAE,YAAY;AACpB,CAAC;;"}
@@ -0,0 +1,124 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./chunk-BLf-eCDO.cjs');
4
+
5
+ const levelOrder = Object.values(constants.LEVELS);
6
+
7
+ const scheduler = Object.freeze({
8
+ setTimeout: (callback, delay) => globalThis.setTimeout(callback, delay),
9
+ clearTimeout: (handle) => globalThis.clearTimeout(handle),
10
+ });
11
+ const levelRank = (level) => levelOrder.indexOf(level);
12
+
13
+ function assertLevel(level) {
14
+ if (levelRank(level) < 0) throw new TypeError('Invalid log level');
15
+ }
16
+
17
+ function assertStormLimit(value) {
18
+ if (
19
+ value !== undefined &&
20
+ value !== false &&
21
+ (!Number.isSafeInteger(value) || value < 1)
22
+ )
23
+ throw new TypeError('Invalid storm limit');
24
+ }
25
+
26
+ function positive(value, name) {
27
+ if (!Number.isSafeInteger(value) || value < 1)
28
+ throw new TypeError(`${name} must be a positive safe integer`);
29
+ return value;
30
+ }
31
+
32
+ function resolveLimits(limits = {}) {
33
+ const result = {};
34
+ for (const [key, fallback] of Object.entries(constants.LIMITS))
35
+ result[key] = positive(limits[key] ?? fallback, key);
36
+ return Object.freeze(result);
37
+ }
38
+
39
+ function report(callback, ...args) {
40
+ try {
41
+ const result = callback?.(...args);
42
+ if (result) Promise.resolve(result).catch(() => {});
43
+ } catch {
44
+ /* The reporter cannot interrupt cleanup. */
45
+ }
46
+ }
47
+
48
+ function define(target, key, value) {
49
+ Object.defineProperty(target, key, {
50
+ value,
51
+ enumerable: true,
52
+ configurable: true,
53
+ writable: true,
54
+ });
55
+ }
56
+
57
+ function own(value, key) {
58
+ return Object.getOwnPropertyDescriptor(value, key)?.value;
59
+ }
60
+
61
+ function isError(value) {
62
+ try {
63
+ return Error.isError?.(value) || value instanceof Error;
64
+ } catch {
65
+ return false;
66
+ }
67
+ }
68
+
69
+ function randomHex(length) {
70
+ if (!globalThis.crypto?.getRandomValues)
71
+ throw new Error('Cryptographic randomness is unavailable');
72
+ return Array.from(
73
+ globalThis.crypto.getRandomValues(new Uint8Array(length)),
74
+ (byte) => byte.toString(16).padStart(2, '0'),
75
+ ).join('');
76
+ }
77
+
78
+ function copyBindings(value = {}) {
79
+ const result = {};
80
+ for (const key of Reflect.ownKeys(value)) {
81
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
82
+ if (
83
+ typeof key === 'string' &&
84
+ descriptor?.enumerable &&
85
+ Object.hasOwn(descriptor, 'value')
86
+ )
87
+ Object.defineProperty(result, key, descriptor);
88
+ }
89
+ return result;
90
+ }
91
+
92
+ function validateQuery(query = {}) {
93
+ const { from, to, areas } = query;
94
+ if (
95
+ (from !== undefined && !Number.isFinite(from)) ||
96
+ (to !== undefined && !Number.isFinite(to)) ||
97
+ (from ?? -Infinity) > (to ?? Infinity)
98
+ )
99
+ throw new TypeError('Invalid record time range');
100
+ if (
101
+ areas !== undefined &&
102
+ (!Array.isArray(areas) || areas.some((area) => typeof area !== 'string'))
103
+ )
104
+ throw new TypeError('Invalid record areas');
105
+ return (record) =>
106
+ (!areas || areas.includes(record.area)) &&
107
+ record.at >= (from ?? -Infinity) &&
108
+ record.at <= (to ?? Infinity);
109
+ }
110
+
111
+ exports.assertLevel = assertLevel;
112
+ exports.assertStormLimit = assertStormLimit;
113
+ exports.copyBindings = copyBindings;
114
+ exports.define = define;
115
+ exports.isError = isError;
116
+ exports.levelRank = levelRank;
117
+ exports.own = own;
118
+ exports.positive = positive;
119
+ exports.randomHex = randomHex;
120
+ exports.report = report;
121
+ exports.resolveLimits = resolveLimits;
122
+ exports.scheduler = scheduler;
123
+ exports.validateQuery = validateQuery;
124
+ //# sourceMappingURL=chunk-CXZYNALm.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-CXZYNALm.cjs","sources":["../src/core/common.js"],"sourcesContent":["import { LEVELS, LIMITS } from './constants.js';\n\nconst levelOrder = Object.values(LEVELS);\n\nexport const scheduler = Object.freeze({\n setTimeout: (callback, delay) => globalThis.setTimeout(callback, delay),\n clearTimeout: (handle) => globalThis.clearTimeout(handle),\n});\nexport const levelRank = (level) => levelOrder.indexOf(level);\n\nexport function assertLevel(level) {\n if (levelRank(level) < 0) throw new TypeError('Invalid log level');\n}\n\nexport function assertStormLimit(value) {\n if (\n value !== undefined &&\n value !== false &&\n (!Number.isSafeInteger(value) || value < 1)\n )\n throw new TypeError('Invalid storm limit');\n}\n\nexport function positive(value, name) {\n if (!Number.isSafeInteger(value) || value < 1)\n throw new TypeError(`${name} must be a positive safe integer`);\n return value;\n}\n\nexport function resolveLimits(limits = {}) {\n const result = {};\n for (const [key, fallback] of Object.entries(LIMITS))\n result[key] = positive(limits[key] ?? fallback, key);\n return Object.freeze(result);\n}\n\nexport function report(callback, ...args) {\n try {\n const result = callback?.(...args);\n if (result) Promise.resolve(result).catch(() => {});\n } catch {\n /* The reporter cannot interrupt cleanup. */\n }\n}\n\nexport function define(target, key, value) {\n Object.defineProperty(target, key, {\n value,\n enumerable: true,\n configurable: true,\n writable: true,\n });\n}\n\nexport function own(value, key) {\n return Object.getOwnPropertyDescriptor(value, key)?.value;\n}\n\nexport function isError(value) {\n try {\n return Error.isError?.(value) || value instanceof Error;\n } catch {\n return false;\n }\n}\n\nexport function randomHex(length) {\n if (!globalThis.crypto?.getRandomValues)\n throw new Error('Cryptographic randomness is unavailable');\n return Array.from(\n globalThis.crypto.getRandomValues(new Uint8Array(length)),\n (byte) => byte.toString(16).padStart(2, '0'),\n ).join('');\n}\n\nexport function copyBindings(value = {}) {\n const result = {};\n for (const key of Reflect.ownKeys(value)) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (\n typeof key === 'string' &&\n descriptor?.enumerable &&\n Object.hasOwn(descriptor, 'value')\n )\n Object.defineProperty(result, key, descriptor);\n }\n return result;\n}\n\nexport function validateQuery(query = {}) {\n const { from, to, areas } = query;\n if (\n (from !== undefined && !Number.isFinite(from)) ||\n (to !== undefined && !Number.isFinite(to)) ||\n (from ?? -Infinity) > (to ?? Infinity)\n )\n throw new TypeError('Invalid record time range');\n if (\n areas !== undefined &&\n (!Array.isArray(areas) || areas.some((area) => typeof area !== 'string'))\n )\n throw new TypeError('Invalid record areas');\n return (record) =>\n (!areas || areas.includes(record.area)) &&\n record.at >= (from ?? -Infinity) &&\n record.at <= (to ?? Infinity);\n}\n"],"names":["LEVELS","LIMITS"],"mappings":";;;;AAEA,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAACA,gBAAM,CAAC;;AAE5B,MAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;AACvC,EAAE,UAAU,EAAE,CAAC,QAAQ,EAAE,KAAK,KAAK,UAAU,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC;AACzE,EAAE,YAAY,EAAE,CAAC,MAAM,KAAK,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC;AAC3D,CAAC;AACW,MAAC,SAAS,GAAG,CAAC,KAAK,KAAK,UAAU,CAAC,OAAO,CAAC,KAAK;;AAErD,SAAS,WAAW,CAAC,KAAK,EAAE;AACnC,EAAE,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,SAAS,CAAC,mBAAmB,CAAC;AACpE;;AAEO,SAAS,gBAAgB,CAAC,KAAK,EAAE;AACxC,EAAE;AACF,IAAI,KAAK,KAAK,SAAS;AACvB,IAAI,KAAK,KAAK,KAAK;AACnB,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;AAC9C;AACA,IAAI,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC;AAC9C;;AAEO,SAAS,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE;AACtC,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;AAC/C,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