@orion-js/helpers 4.0.0-next.1 → 4.0.0-next.3

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/index.js CHANGED
@@ -1,718 +1,12 @@
1
- import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __toESM = (mod, isNodeMode, target) => {
8
- target = mod != null ? __create(__getProtoOf(mod)) : {};
9
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
- for (let key of __getOwnPropNames(mod))
11
- if (!__hasOwnProp.call(to, key))
12
- __defProp(to, key, {
13
- get: () => mod[key],
14
- enumerable: true
15
- });
16
- return to;
17
- };
18
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
-
21
- // ../../node_modules/object-hash/index.js
22
- var require_object_hash = __commonJS((exports, module) => {
23
- var crypto = __require("crypto");
24
- exports = module.exports = objectHash;
25
- function objectHash(object, options) {
26
- options = applyDefaults(object, options);
27
- return hash(object, options);
28
- }
29
- exports.sha1 = function(object) {
30
- return objectHash(object);
31
- };
32
- exports.keys = function(object) {
33
- return objectHash(object, { excludeValues: true, algorithm: "sha1", encoding: "hex" });
34
- };
35
- exports.MD5 = function(object) {
36
- return objectHash(object, { algorithm: "md5", encoding: "hex" });
37
- };
38
- exports.keysMD5 = function(object) {
39
- return objectHash(object, { algorithm: "md5", encoding: "hex", excludeValues: true });
40
- };
41
- var hashes = crypto.getHashes ? crypto.getHashes().slice() : ["sha1", "md5"];
42
- hashes.push("passthrough");
43
- var encodings = ["buffer", "hex", "binary", "base64"];
44
- function applyDefaults(object, sourceOptions) {
45
- sourceOptions = sourceOptions || {};
46
- var options = {};
47
- options.algorithm = sourceOptions.algorithm || "sha1";
48
- options.encoding = sourceOptions.encoding || "hex";
49
- options.excludeValues = sourceOptions.excludeValues ? true : false;
50
- options.algorithm = options.algorithm.toLowerCase();
51
- options.encoding = options.encoding.toLowerCase();
52
- options.ignoreUnknown = sourceOptions.ignoreUnknown !== true ? false : true;
53
- options.respectType = sourceOptions.respectType === false ? false : true;
54
- options.respectFunctionNames = sourceOptions.respectFunctionNames === false ? false : true;
55
- options.respectFunctionProperties = sourceOptions.respectFunctionProperties === false ? false : true;
56
- options.unorderedArrays = sourceOptions.unorderedArrays !== true ? false : true;
57
- options.unorderedSets = sourceOptions.unorderedSets === false ? false : true;
58
- options.unorderedObjects = sourceOptions.unorderedObjects === false ? false : true;
59
- options.replacer = sourceOptions.replacer || undefined;
60
- options.excludeKeys = sourceOptions.excludeKeys || undefined;
61
- if (typeof object === "undefined") {
62
- throw new Error("Object argument required.");
63
- }
64
- for (var i = 0;i < hashes.length; ++i) {
65
- if (hashes[i].toLowerCase() === options.algorithm.toLowerCase()) {
66
- options.algorithm = hashes[i];
67
- }
68
- }
69
- if (hashes.indexOf(options.algorithm) === -1) {
70
- throw new Error('Algorithm "' + options.algorithm + '" not supported. ' + "supported values: " + hashes.join(", "));
71
- }
72
- if (encodings.indexOf(options.encoding) === -1 && options.algorithm !== "passthrough") {
73
- throw new Error('Encoding "' + options.encoding + '" not supported. ' + "supported values: " + encodings.join(", "));
74
- }
75
- return options;
76
- }
77
- function isNativeFunction(f) {
78
- if (typeof f !== "function") {
79
- return false;
80
- }
81
- var exp = /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i;
82
- return exp.exec(Function.prototype.toString.call(f)) != null;
83
- }
84
- function hash(object, options) {
85
- var hashingStream;
86
- if (options.algorithm !== "passthrough") {
87
- hashingStream = crypto.createHash(options.algorithm);
88
- } else {
89
- hashingStream = new PassThrough;
90
- }
91
- if (typeof hashingStream.write === "undefined") {
92
- hashingStream.write = hashingStream.update;
93
- hashingStream.end = hashingStream.update;
94
- }
95
- var hasher = typeHasher(options, hashingStream);
96
- hasher.dispatch(object);
97
- if (!hashingStream.update) {
98
- hashingStream.end("");
99
- }
100
- if (hashingStream.digest) {
101
- return hashingStream.digest(options.encoding === "buffer" ? undefined : options.encoding);
102
- }
103
- var buf = hashingStream.read();
104
- if (options.encoding === "buffer") {
105
- return buf;
106
- }
107
- return buf.toString(options.encoding);
108
- }
109
- exports.writeToStream = function(object, options, stream) {
110
- if (typeof stream === "undefined") {
111
- stream = options;
112
- options = {};
113
- }
114
- options = applyDefaults(object, options);
115
- return typeHasher(options, stream).dispatch(object);
116
- };
117
- function typeHasher(options, writeTo, context) {
118
- context = context || [];
119
- var write = function(str) {
120
- if (writeTo.update) {
121
- return writeTo.update(str, "utf8");
122
- } else {
123
- return writeTo.write(str, "utf8");
124
- }
125
- };
126
- return {
127
- dispatch: function(value) {
128
- if (options.replacer) {
129
- value = options.replacer(value);
130
- }
131
- var type = typeof value;
132
- if (value === null) {
133
- type = "null";
134
- }
135
- return this["_" + type](value);
136
- },
137
- _object: function(object) {
138
- var pattern = /\[object (.*)\]/i;
139
- var objString = Object.prototype.toString.call(object);
140
- var objType = pattern.exec(objString);
141
- if (!objType) {
142
- objType = "unknown:[" + objString + "]";
143
- } else {
144
- objType = objType[1];
145
- }
146
- objType = objType.toLowerCase();
147
- var objectNumber = null;
148
- if ((objectNumber = context.indexOf(object)) >= 0) {
149
- return this.dispatch("[CIRCULAR:" + objectNumber + "]");
150
- } else {
151
- context.push(object);
152
- }
153
- if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
154
- write("buffer:");
155
- return write(object);
156
- }
157
- if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
158
- if (this["_" + objType]) {
159
- this["_" + objType](object);
160
- } else if (options.ignoreUnknown) {
161
- return write("[" + objType + "]");
162
- } else {
163
- throw new Error('Unknown object type "' + objType + '"');
164
- }
165
- } else {
166
- var keys = Object.keys(object);
167
- if (options.unorderedObjects) {
168
- keys = keys.sort();
169
- }
170
- if (options.respectType !== false && !isNativeFunction(object)) {
171
- keys.splice(0, 0, "prototype", "__proto__", "constructor");
172
- }
173
- if (options.excludeKeys) {
174
- keys = keys.filter(function(key) {
175
- return !options.excludeKeys(key);
176
- });
177
- }
178
- write("object:" + keys.length + ":");
179
- var self = this;
180
- return keys.forEach(function(key) {
181
- self.dispatch(key);
182
- write(":");
183
- if (!options.excludeValues) {
184
- self.dispatch(object[key]);
185
- }
186
- write(",");
187
- });
188
- }
189
- },
190
- _array: function(arr, unordered) {
191
- unordered = typeof unordered !== "undefined" ? unordered : options.unorderedArrays !== false;
192
- var self = this;
193
- write("array:" + arr.length + ":");
194
- if (!unordered || arr.length <= 1) {
195
- return arr.forEach(function(entry) {
196
- return self.dispatch(entry);
197
- });
198
- }
199
- var contextAdditions = [];
200
- var entries = arr.map(function(entry) {
201
- var strm = new PassThrough;
202
- var localContext = context.slice();
203
- var hasher = typeHasher(options, strm, localContext);
204
- hasher.dispatch(entry);
205
- contextAdditions = contextAdditions.concat(localContext.slice(context.length));
206
- return strm.read().toString();
207
- });
208
- context = context.concat(contextAdditions);
209
- entries.sort();
210
- return this._array(entries, false);
211
- },
212
- _date: function(date) {
213
- return write("date:" + date.toJSON());
214
- },
215
- _symbol: function(sym) {
216
- return write("symbol:" + sym.toString());
217
- },
218
- _error: function(err) {
219
- return write("error:" + err.toString());
220
- },
221
- _boolean: function(bool) {
222
- return write("bool:" + bool.toString());
223
- },
224
- _string: function(string) {
225
- write("string:" + string.length + ":");
226
- write(string.toString());
227
- },
228
- _function: function(fn) {
229
- write("fn:");
230
- if (isNativeFunction(fn)) {
231
- this.dispatch("[native]");
232
- } else {
233
- this.dispatch(fn.toString());
234
- }
235
- if (options.respectFunctionNames !== false) {
236
- this.dispatch("function-name:" + String(fn.name));
237
- }
238
- if (options.respectFunctionProperties) {
239
- this._object(fn);
240
- }
241
- },
242
- _number: function(number) {
243
- return write("number:" + number.toString());
244
- },
245
- _xml: function(xml) {
246
- return write("xml:" + xml.toString());
247
- },
248
- _null: function() {
249
- return write("Null");
250
- },
251
- _undefined: function() {
252
- return write("Undefined");
253
- },
254
- _regexp: function(regex) {
255
- return write("regex:" + regex.toString());
256
- },
257
- _uint8array: function(arr) {
258
- write("uint8array:");
259
- return this.dispatch(Array.prototype.slice.call(arr));
260
- },
261
- _uint8clampedarray: function(arr) {
262
- write("uint8clampedarray:");
263
- return this.dispatch(Array.prototype.slice.call(arr));
264
- },
265
- _int8array: function(arr) {
266
- write("uint8array:");
267
- return this.dispatch(Array.prototype.slice.call(arr));
268
- },
269
- _uint16array: function(arr) {
270
- write("uint16array:");
271
- return this.dispatch(Array.prototype.slice.call(arr));
272
- },
273
- _int16array: function(arr) {
274
- write("uint16array:");
275
- return this.dispatch(Array.prototype.slice.call(arr));
276
- },
277
- _uint32array: function(arr) {
278
- write("uint32array:");
279
- return this.dispatch(Array.prototype.slice.call(arr));
280
- },
281
- _int32array: function(arr) {
282
- write("uint32array:");
283
- return this.dispatch(Array.prototype.slice.call(arr));
284
- },
285
- _float32array: function(arr) {
286
- write("float32array:");
287
- return this.dispatch(Array.prototype.slice.call(arr));
288
- },
289
- _float64array: function(arr) {
290
- write("float64array:");
291
- return this.dispatch(Array.prototype.slice.call(arr));
292
- },
293
- _arraybuffer: function(arr) {
294
- write("arraybuffer:");
295
- return this.dispatch(new Uint8Array(arr));
296
- },
297
- _url: function(url) {
298
- return write("url:" + url.toString(), "utf8");
299
- },
300
- _map: function(map) {
301
- write("map:");
302
- var arr = Array.from(map);
303
- return this._array(arr, options.unorderedSets !== false);
304
- },
305
- _set: function(set) {
306
- write("set:");
307
- var arr = Array.from(set);
308
- return this._array(arr, options.unorderedSets !== false);
309
- },
310
- _file: function(file) {
311
- write("file:");
312
- return this.dispatch([file.name, file.size, file.type, file.lastModfied]);
313
- },
314
- _blob: function() {
315
- if (options.ignoreUnknown) {
316
- return write("[blob]");
317
- }
318
- throw Error(`Hashing Blob objects is currently not supported
319
- ` + `(see https://github.com/puleos/object-hash/issues/26)
320
- ` + `Use "options.replacer" or "options.ignoreUnknown"
321
- `);
322
- },
323
- _domwindow: function() {
324
- return write("domwindow");
325
- },
326
- _bigint: function(number) {
327
- return write("bigint:" + number.toString());
328
- },
329
- _process: function() {
330
- return write("process");
331
- },
332
- _timer: function() {
333
- return write("timer");
334
- },
335
- _pipe: function() {
336
- return write("pipe");
337
- },
338
- _tcp: function() {
339
- return write("tcp");
340
- },
341
- _udp: function() {
342
- return write("udp");
343
- },
344
- _tty: function() {
345
- return write("tty");
346
- },
347
- _statwatcher: function() {
348
- return write("statwatcher");
349
- },
350
- _securecontext: function() {
351
- return write("securecontext");
352
- },
353
- _connection: function() {
354
- return write("connection");
355
- },
356
- _zlib: function() {
357
- return write("zlib");
358
- },
359
- _context: function() {
360
- return write("context");
361
- },
362
- _nodescript: function() {
363
- return write("nodescript");
364
- },
365
- _httpparser: function() {
366
- return write("httpparser");
367
- },
368
- _dataview: function() {
369
- return write("dataview");
370
- },
371
- _signal: function() {
372
- return write("signal");
373
- },
374
- _fsevent: function() {
375
- return write("fsevent");
376
- },
377
- _tlswrap: function() {
378
- return write("tlswrap");
379
- }
380
- };
381
- }
382
- function PassThrough() {
383
- return {
384
- buf: "",
385
- write: function(b) {
386
- this.buf += b;
387
- },
388
- end: function(b) {
389
- this.buf += b;
390
- },
391
- read: function() {
392
- return this.buf;
393
- }
394
- };
395
- }
396
- });
397
-
398
- // ../../node_modules/uuid/dist/rng.js
399
- var require_rng = __commonJS((exports) => {
400
- Object.defineProperty(exports, "__esModule", {
401
- value: true
402
- });
403
- exports.default = rng;
404
- var _crypto = _interopRequireDefault(__require("crypto"));
405
- function _interopRequireDefault(obj) {
406
- return obj && obj.__esModule ? obj : { default: obj };
407
- }
408
- function rng() {
409
- return _crypto.default.randomBytes(16);
410
- }
411
- });
412
-
413
- // ../../node_modules/uuid/dist/bytesToUuid.js
414
- var require_bytesToUuid = __commonJS((exports) => {
415
- Object.defineProperty(exports, "__esModule", {
416
- value: true
417
- });
418
- exports.default = undefined;
419
- var byteToHex = [];
420
- for (i = 0;i < 256; ++i) {
421
- byteToHex[i] = (i + 256).toString(16).substr(1);
422
- }
423
- var i;
424
- function bytesToUuid(buf, offset) {
425
- var i2 = offset || 0;
426
- var bth = byteToHex;
427
- return [bth[buf[i2++]], bth[buf[i2++]], bth[buf[i2++]], bth[buf[i2++]], "-", bth[buf[i2++]], bth[buf[i2++]], "-", bth[buf[i2++]], bth[buf[i2++]], "-", bth[buf[i2++]], bth[buf[i2++]], "-", bth[buf[i2++]], bth[buf[i2++]], bth[buf[i2++]], bth[buf[i2++]], bth[buf[i2++]], bth[buf[i2++]]].join("");
428
- }
429
- var _default = bytesToUuid;
430
- exports.default = _default;
431
- });
432
-
433
- // ../../node_modules/uuid/dist/v1.js
434
- var require_v1 = __commonJS((exports) => {
435
- Object.defineProperty(exports, "__esModule", {
436
- value: true
437
- });
438
- exports.default = undefined;
439
- var _rng = _interopRequireDefault(require_rng());
440
- var _bytesToUuid = _interopRequireDefault(require_bytesToUuid());
441
- function _interopRequireDefault(obj) {
442
- return obj && obj.__esModule ? obj : { default: obj };
443
- }
444
- var _nodeId;
445
- var _clockseq;
446
- var _lastMSecs = 0;
447
- var _lastNSecs = 0;
448
- function v1(options, buf, offset) {
449
- var i = buf && offset || 0;
450
- var b = buf || [];
451
- options = options || {};
452
- var node = options.node || _nodeId;
453
- var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
454
- if (node == null || clockseq == null) {
455
- var seedBytes = options.random || (options.rng || _rng.default)();
456
- if (node == null) {
457
- node = _nodeId = [seedBytes[0] | 1, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
458
- }
459
- if (clockseq == null) {
460
- clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383;
461
- }
462
- }
463
- var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();
464
- var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
465
- var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4;
466
- if (dt < 0 && options.clockseq === undefined) {
467
- clockseq = clockseq + 1 & 16383;
468
- }
469
- if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
470
- nsecs = 0;
471
- }
472
- if (nsecs >= 1e4) {
473
- throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
474
- }
475
- _lastMSecs = msecs;
476
- _lastNSecs = nsecs;
477
- _clockseq = clockseq;
478
- msecs += 12219292800000;
479
- var tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
480
- b[i++] = tl >>> 24 & 255;
481
- b[i++] = tl >>> 16 & 255;
482
- b[i++] = tl >>> 8 & 255;
483
- b[i++] = tl & 255;
484
- var tmh = msecs / 4294967296 * 1e4 & 268435455;
485
- b[i++] = tmh >>> 8 & 255;
486
- b[i++] = tmh & 255;
487
- b[i++] = tmh >>> 24 & 15 | 16;
488
- b[i++] = tmh >>> 16 & 255;
489
- b[i++] = clockseq >>> 8 | 128;
490
- b[i++] = clockseq & 255;
491
- for (var n = 0;n < 6; ++n) {
492
- b[i + n] = node[n];
493
- }
494
- return buf ? buf : (0, _bytesToUuid.default)(b);
495
- }
496
- var _default = v1;
497
- exports.default = _default;
498
- });
499
-
500
- // ../../node_modules/uuid/dist/v35.js
501
- var require_v35 = __commonJS((exports) => {
502
- Object.defineProperty(exports, "__esModule", {
503
- value: true
504
- });
505
- exports.default = _default;
506
- exports.URL = exports.DNS = undefined;
507
- var _bytesToUuid = _interopRequireDefault(require_bytesToUuid());
508
- function _interopRequireDefault(obj) {
509
- return obj && obj.__esModule ? obj : { default: obj };
510
- }
511
- function uuidToBytes(uuid) {
512
- var bytes = [];
513
- uuid.replace(/[a-fA-F0-9]{2}/g, function(hex) {
514
- bytes.push(parseInt(hex, 16));
515
- });
516
- return bytes;
517
- }
518
- function stringToBytes(str) {
519
- str = unescape(encodeURIComponent(str));
520
- var bytes = new Array(str.length);
521
- for (var i = 0;i < str.length; i++) {
522
- bytes[i] = str.charCodeAt(i);
523
- }
524
- return bytes;
525
- }
526
- var DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
527
- exports.DNS = DNS;
528
- var URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
529
- exports.URL = URL;
530
- function _default(name, version, hashfunc) {
531
- var generateUUID = function(value, namespace, buf, offset) {
532
- var off = buf && offset || 0;
533
- if (typeof value == "string")
534
- value = stringToBytes(value);
535
- if (typeof namespace == "string")
536
- namespace = uuidToBytes(namespace);
537
- if (!Array.isArray(value))
538
- throw TypeError("value must be an array of bytes");
539
- if (!Array.isArray(namespace) || namespace.length !== 16)
540
- throw TypeError("namespace must be uuid string or an Array of 16 byte values");
541
- var bytes = hashfunc(namespace.concat(value));
542
- bytes[6] = bytes[6] & 15 | version;
543
- bytes[8] = bytes[8] & 63 | 128;
544
- if (buf) {
545
- for (var idx = 0;idx < 16; ++idx) {
546
- buf[off + idx] = bytes[idx];
547
- }
548
- }
549
- return buf || (0, _bytesToUuid.default)(bytes);
550
- };
551
- try {
552
- generateUUID.name = name;
553
- } catch (err) {
554
- }
555
- generateUUID.DNS = DNS;
556
- generateUUID.URL = URL;
557
- return generateUUID;
558
- }
559
- });
560
-
561
- // ../../node_modules/uuid/dist/md5.js
562
- var require_md5 = __commonJS((exports) => {
563
- Object.defineProperty(exports, "__esModule", {
564
- value: true
565
- });
566
- exports.default = undefined;
567
- var _crypto = _interopRequireDefault(__require("crypto"));
568
- function _interopRequireDefault(obj) {
569
- return obj && obj.__esModule ? obj : { default: obj };
570
- }
571
- function md5(bytes) {
572
- if (Array.isArray(bytes)) {
573
- bytes = Buffer.from(bytes);
574
- } else if (typeof bytes === "string") {
575
- bytes = Buffer.from(bytes, "utf8");
576
- }
577
- return _crypto.default.createHash("md5").update(bytes).digest();
578
- }
579
- var _default = md5;
580
- exports.default = _default;
581
- });
582
-
583
- // ../../node_modules/uuid/dist/v3.js
584
- var require_v3 = __commonJS((exports) => {
585
- Object.defineProperty(exports, "__esModule", {
586
- value: true
587
- });
588
- exports.default = undefined;
589
- var _v = _interopRequireDefault(require_v35());
590
- var _md = _interopRequireDefault(require_md5());
591
- function _interopRequireDefault(obj) {
592
- return obj && obj.__esModule ? obj : { default: obj };
593
- }
594
- var v3 = (0, _v.default)("v3", 48, _md.default);
595
- var _default = v3;
596
- exports.default = _default;
597
- });
598
-
599
- // ../../node_modules/uuid/dist/v4.js
600
- var require_v4 = __commonJS((exports) => {
601
- Object.defineProperty(exports, "__esModule", {
602
- value: true
603
- });
604
- exports.default = undefined;
605
- var _rng = _interopRequireDefault(require_rng());
606
- var _bytesToUuid = _interopRequireDefault(require_bytesToUuid());
607
- function _interopRequireDefault(obj) {
608
- return obj && obj.__esModule ? obj : { default: obj };
609
- }
610
- function v4(options, buf, offset) {
611
- var i = buf && offset || 0;
612
- if (typeof options == "string") {
613
- buf = options === "binary" ? new Array(16) : null;
614
- options = null;
615
- }
616
- options = options || {};
617
- var rnds = options.random || (options.rng || _rng.default)();
618
- rnds[6] = rnds[6] & 15 | 64;
619
- rnds[8] = rnds[8] & 63 | 128;
620
- if (buf) {
621
- for (var ii = 0;ii < 16; ++ii) {
622
- buf[i + ii] = rnds[ii];
623
- }
624
- }
625
- return buf || (0, _bytesToUuid.default)(rnds);
626
- }
627
- var _default = v4;
628
- exports.default = _default;
629
- });
630
-
631
- // ../../node_modules/uuid/dist/sha1.js
632
- var require_sha1 = __commonJS((exports) => {
633
- Object.defineProperty(exports, "__esModule", {
634
- value: true
635
- });
636
- exports.default = undefined;
637
- var _crypto = _interopRequireDefault(__require("crypto"));
638
- function _interopRequireDefault(obj) {
639
- return obj && obj.__esModule ? obj : { default: obj };
640
- }
641
- function sha1(bytes) {
642
- if (Array.isArray(bytes)) {
643
- bytes = Buffer.from(bytes);
644
- } else if (typeof bytes === "string") {
645
- bytes = Buffer.from(bytes, "utf8");
646
- }
647
- return _crypto.default.createHash("sha1").update(bytes).digest();
648
- }
649
- var _default = sha1;
650
- exports.default = _default;
651
- });
652
-
653
- // ../../node_modules/uuid/dist/v5.js
654
- var require_v5 = __commonJS((exports) => {
655
- Object.defineProperty(exports, "__esModule", {
656
- value: true
657
- });
658
- exports.default = undefined;
659
- var _v = _interopRequireDefault(require_v35());
660
- var _sha = _interopRequireDefault(require_sha1());
661
- function _interopRequireDefault(obj) {
662
- return obj && obj.__esModule ? obj : { default: obj };
663
- }
664
- var v5 = (0, _v.default)("v5", 80, _sha.default);
665
- var _default = v5;
666
- exports.default = _default;
667
- });
668
-
669
- // ../../node_modules/uuid/dist/index.js
670
- var require_dist = __commonJS((exports) => {
671
- Object.defineProperty(exports, "__esModule", {
672
- value: true
673
- });
674
- Object.defineProperty(exports, "v1", {
675
- enumerable: true,
676
- get: function() {
677
- return _v.default;
678
- }
679
- });
680
- Object.defineProperty(exports, "v3", {
681
- enumerable: true,
682
- get: function() {
683
- return _v2.default;
684
- }
685
- });
686
- Object.defineProperty(exports, "v4", {
687
- enumerable: true,
688
- get: function() {
689
- return _v3.default;
690
- }
691
- });
692
- Object.defineProperty(exports, "v5", {
693
- enumerable: true,
694
- get: function() {
695
- return _v4.default;
696
- }
697
- });
698
- var _v = _interopRequireDefault(require_v1());
699
- var _v2 = _interopRequireDefault(require_v3());
700
- var _v3 = _interopRequireDefault(require_v4());
701
- var _v4 = _interopRequireDefault(require_v5());
702
- function _interopRequireDefault(obj) {
703
- return obj && obj.__esModule ? obj : { default: obj };
704
- }
705
- });
706
-
707
1
  // src/sleep.ts
708
2
  var sleep_default = (time) => {
709
3
  return new Promise((resolve) => setTimeout(resolve, time));
710
4
  };
711
5
 
712
6
  // src/hashObject.ts
713
- var import_object_hash = __toESM(require_object_hash(), 1);
7
+ import hash from "object-hash";
714
8
  function hashObject_default(object) {
715
- return import_object_hash.default(object);
9
+ return hash(object);
716
10
  }
717
11
 
718
12
  // src/generateId.ts
@@ -731,18 +25,16 @@ var hexString = function(digits) {
731
25
  };
732
26
  var fraction = function() {
733
27
  var numerator = parseInt(hexString(8), 16);
734
- return numerator * 0.00000000023283064365386963;
28
+ return numerator * 23283064365386963e-26;
735
29
  };
736
30
  var choice = function(arrayOrString) {
737
31
  var index = Math.floor(fraction() * arrayOrString.length);
738
- if (typeof arrayOrString === "string")
739
- return arrayOrString.substr(index, 1);
740
- else
741
- return arrayOrString[index];
32
+ if (typeof arrayOrString === "string") return arrayOrString.substr(index, 1);
33
+ else return arrayOrString[index];
742
34
  };
743
35
  var randomString = function(charsCount, alphabet) {
744
36
  var digits = [];
745
- for (var i = 0;i < charsCount; i++) {
37
+ for (var i = 0; i < charsCount; i++) {
746
38
  digits[i] = choice(alphabet);
747
39
  }
748
40
  return digits.join("");
@@ -774,17 +66,44 @@ function createMapArray(array, key = "_id") {
774
66
  }
775
67
 
776
68
  // src/Errors/OrionError.ts
777
- class OrionError extends Error {
69
+ var OrionError = class extends Error {
778
70
  isOrionError = true;
779
71
  isUserError;
780
72
  isPermissionsError;
781
73
  code;
782
74
  extra;
75
+ /**
76
+ * Returns a standardized representation of the error information.
77
+ * @returns An object containing error details in a consistent format
78
+ */
783
79
  getInfo;
784
- }
80
+ };
785
81
 
786
82
  // src/Errors/PermissionsError.ts
787
- class PermissionsError extends OrionError {
83
+ var PermissionsError = class extends OrionError {
84
+ /**
85
+ * Creates a new PermissionsError instance.
86
+ *
87
+ * @param permissionErrorType - Identifies the specific permission that was violated
88
+ * (e.g., 'read', 'write', 'admin')
89
+ * @param extra - Additional error context or metadata. Can include a custom message
90
+ * via the message property.
91
+ *
92
+ * @example
93
+ * // Basic usage
94
+ * throw new PermissionsError('delete_document')
95
+ *
96
+ * @example
97
+ * // With custom message
98
+ * throw new PermissionsError('access_admin', { message: 'Admin access required' })
99
+ *
100
+ * @example
101
+ * // With additional context
102
+ * throw new PermissionsError('edit_user', {
103
+ * userId: 'user123',
104
+ * requiredRole: 'admin'
105
+ * })
106
+ */
788
107
  constructor(permissionErrorType, extra = {}) {
789
108
  const message = extra.message || `Client is not allowed to perform this action [${permissionErrorType}]`;
790
109
  super(message);
@@ -802,10 +121,30 @@ class PermissionsError extends OrionError {
802
121
  };
803
122
  };
804
123
  }
805
- }
124
+ };
806
125
 
807
126
  // src/Errors/UserError.ts
808
- class UserError extends OrionError {
127
+ var UserError = class extends OrionError {
128
+ /**
129
+ * Creates a new UserError instance.
130
+ *
131
+ * @param code - Error code identifier. If only one parameter is provided,
132
+ * this will be used as the message and code will default to 'error'.
133
+ * @param message - Human-readable error message. Optional if code is provided.
134
+ * @param extra - Additional error context or metadata.
135
+ *
136
+ * @example
137
+ * // Basic usage
138
+ * throw new UserError('invalid_input', 'The provided email is invalid')
139
+ *
140
+ * @example
141
+ * // Using only a message (code will be 'error')
142
+ * throw new UserError('Input validation failed')
143
+ *
144
+ * @example
145
+ * // With extra metadata
146
+ * throw new UserError('rate_limit', 'Too many requests', { maxRequests: 100 })
147
+ */
809
148
  constructor(code, message, extra) {
810
149
  if (!message && code) {
811
150
  message = code;
@@ -825,39 +164,38 @@ class UserError extends OrionError {
825
164
  };
826
165
  };
827
166
  }
828
- }
167
+ };
829
168
 
830
169
  // src/Errors/index.ts
831
170
  function isOrionError(error) {
832
171
  return Boolean(error && typeof error === "object" && error.isOrionError === true);
833
172
  }
834
173
  function isUserError(error) {
835
- return Boolean(error && typeof error === "object" && error.isOrionError === true && error.isUserError === true);
174
+ return Boolean(
175
+ error && typeof error === "object" && error.isOrionError === true && error.isUserError === true
176
+ );
836
177
  }
837
178
  function isPermissionsError(error) {
838
- return Boolean(error && typeof error === "object" && error.isOrionError === true && error.isPermissionsError === true);
179
+ return Boolean(
180
+ error && typeof error === "object" && error.isOrionError === true && error.isPermissionsError === true
181
+ );
839
182
  }
840
183
 
841
184
  // src/composeMiddlewares.ts
842
185
  function composeMiddlewares(middleware) {
843
- if (!Array.isArray(middleware))
844
- throw new TypeError("Middleware stack must be an array!");
186
+ if (!Array.isArray(middleware)) throw new TypeError("Middleware stack must be an array!");
845
187
  for (const fn of middleware) {
846
- if (typeof fn !== "function")
847
- throw new TypeError("Middleware must be composed of functions!");
188
+ if (typeof fn !== "function") throw new TypeError("Middleware must be composed of functions!");
848
189
  }
849
190
  return function(context, next) {
850
191
  let index = -1;
851
192
  return dispatch(0);
852
193
  function dispatch(i) {
853
- if (i <= index)
854
- return Promise.reject(new Error("next() called multiple times"));
194
+ if (i <= index) return Promise.reject(new Error("next() called multiple times"));
855
195
  index = i;
856
196
  let fn = middleware[i];
857
- if (i === middleware.length)
858
- fn = next;
859
- if (!fn)
860
- return Promise.resolve();
197
+ if (i === middleware.length) fn = next;
198
+ if (!fn) return Promise.resolve();
861
199
  try {
862
200
  return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
863
201
  } catch (err) {
@@ -866,6 +204,7 @@ function composeMiddlewares(middleware) {
866
204
  }
867
205
  };
868
206
  }
207
+
869
208
  // src/retries.ts
870
209
  function executeWithRetries(fn, retries, timeout) {
871
210
  return new Promise((resolve, reject) => {
@@ -884,51 +223,93 @@ function executeWithRetries(fn, retries, timeout) {
884
223
  retry(retries);
885
224
  });
886
225
  }
887
- // ../../node_modules/uuid/wrapper.mjs
888
- var import_dist = __toESM(require_dist(), 1);
889
- var v1 = import_dist.default.v1;
890
- var v3 = import_dist.default.v3;
891
- var v4 = import_dist.default.v4;
892
- var v5 = import_dist.default.v5;
226
+
227
+ // ../../node_modules/uuid/dist/esm-node/rng.js
228
+ import crypto2 from "crypto";
229
+ var rnds8Pool = new Uint8Array(256);
230
+ var poolPtr = rnds8Pool.length;
231
+ function rng() {
232
+ if (poolPtr > rnds8Pool.length - 16) {
233
+ crypto2.randomFillSync(rnds8Pool);
234
+ poolPtr = 0;
235
+ }
236
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
237
+ }
238
+
239
+ // ../../node_modules/uuid/dist/esm-node/regex.js
240
+ var regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
241
+
242
+ // ../../node_modules/uuid/dist/esm-node/validate.js
243
+ function validate(uuid) {
244
+ return typeof uuid === "string" && regex_default.test(uuid);
245
+ }
246
+ var validate_default = validate;
247
+
248
+ // ../../node_modules/uuid/dist/esm-node/stringify.js
249
+ var byteToHex = [];
250
+ for (let i = 0; i < 256; ++i) {
251
+ byteToHex.push((i + 256).toString(16).substr(1));
252
+ }
253
+ function stringify(arr, offset = 0) {
254
+ const uuid = (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();
255
+ if (!validate_default(uuid)) {
256
+ throw TypeError("Stringified UUID is invalid");
257
+ }
258
+ return uuid;
259
+ }
260
+ var stringify_default = stringify;
261
+
262
+ // ../../node_modules/uuid/dist/esm-node/v4.js
263
+ function v4(options, buf, offset) {
264
+ options = options || {};
265
+ const rnds = options.random || (options.rng || rng)();
266
+ rnds[6] = rnds[6] & 15 | 64;
267
+ rnds[8] = rnds[8] & 63 | 128;
268
+ if (buf) {
269
+ offset = offset || 0;
270
+ for (let i = 0; i < 16; ++i) {
271
+ buf[offset + i] = rnds[i];
272
+ }
273
+ return buf;
274
+ }
275
+ return stringify_default(rnds);
276
+ }
277
+ var v4_default = v4;
893
278
 
894
279
  // src/generateUUID.ts
895
280
  function generateUUID() {
896
- return v4();
281
+ return v4_default();
897
282
  }
898
283
  function generateUUIDWithPrefix(prefix) {
899
284
  return `${prefix}-${generateUUID()}`;
900
285
  }
286
+
901
287
  // src/normalize.ts
902
288
  function removeAccentsOnly(text) {
903
- if (!text)
904
- return "";
289
+ if (!text) return "";
905
290
  return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
906
291
  }
907
292
  function removeAccentsAndTrim(text) {
908
- if (!text)
909
- return "";
293
+ if (!text) return "";
910
294
  return removeAccentsOnly(text).trim();
911
295
  }
912
296
  function normalizeForSearch(text) {
913
- if (!text)
914
- return "";
297
+ if (!text) return "";
915
298
  return removeAccentsAndTrim(text).toLowerCase();
916
299
  }
917
300
  function normalizeForCompactSearch(text) {
918
- if (!text)
919
- return "";
301
+ if (!text) return "";
920
302
  return normalizeForSearch(text).replace(/\s/g, "");
921
303
  }
922
304
  function normalizeForSearchToken(text) {
923
- if (!text)
924
- return "";
305
+ if (!text) return "";
925
306
  return normalizeForSearch(text).replace(/[^0-9a-z]/gi, " ");
926
307
  }
927
308
  function normalizeForFileKey(text) {
928
- if (!text)
929
- return "";
309
+ if (!text) return "";
930
310
  return removeAccentsOnly(text).replace(/[^a-zA-Z0-9-._]/g, "-").replace(/-+/g, "-").trim().replace(/^-+|-+$/g, "");
931
311
  }
312
+
932
313
  // src/searchTokens.ts
933
314
  function getSearchTokens(text, meta) {
934
315
  const stringArray = Array.isArray(text) ? text : [text];
@@ -949,14 +330,13 @@ function getSearchQueryForTokens(params = {}, _options = {}) {
949
330
  searchTokens.push(...filterTokens);
950
331
  }
951
332
  for (const key in params) {
952
- if (key === "filter")
953
- continue;
954
- if (!params[key])
955
- continue;
333
+ if (key === "filter") continue;
334
+ if (!params[key]) continue;
956
335
  searchTokens.push(`_${key}:${params[key]}`);
957
336
  }
958
337
  return { $all: searchTokens };
959
338
  }
339
+
960
340
  // src/shortenMongoId.ts
961
341
  function lastOfString(string, last) {
962
342
  return string.substring(string.length - last, string.length);
@@ -965,28 +345,29 @@ function shortenMongoId(string) {
965
345
  return lastOfString(string, 5).toUpperCase();
966
346
  }
967
347
  export {
968
- sleep_default as sleep,
969
- shortenMongoId,
970
- removeAccentsOnly,
971
- removeAccentsAndTrim,
972
- normalizeForSearchToken,
973
- normalizeForSearch,
974
- normalizeForFileKey,
975
- normalizeForCompactSearch,
976
- isUserError,
977
- isPermissionsError,
978
- isOrionError,
979
- hashObject_default as hashObject,
980
- getSearchTokens,
981
- getSearchQueryForTokens,
982
- generateUUIDWithPrefix,
983
- generateUUID,
984
- generateId,
985
- executeWithRetries,
986
- createMapArray,
987
- createMap,
988
- composeMiddlewares,
989
- UserError,
348
+ OrionError,
990
349
  PermissionsError,
991
- OrionError
350
+ UserError,
351
+ composeMiddlewares,
352
+ createMap,
353
+ createMapArray,
354
+ executeWithRetries,
355
+ generateId,
356
+ generateUUID,
357
+ generateUUIDWithPrefix,
358
+ getSearchQueryForTokens,
359
+ getSearchTokens,
360
+ hashObject_default as hashObject,
361
+ isOrionError,
362
+ isPermissionsError,
363
+ isUserError,
364
+ normalizeForCompactSearch,
365
+ normalizeForFileKey,
366
+ normalizeForSearch,
367
+ normalizeForSearchToken,
368
+ removeAccentsAndTrim,
369
+ removeAccentsOnly,
370
+ shortenMongoId,
371
+ sleep_default as sleep
992
372
  };
373
+ //# sourceMappingURL=index.js.map