@orion-js/helpers 4.0.0-next.0 → 4.0.0-next.2

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,724 +1,22 @@
1
- import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
1
  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
- });
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
706
3
 
707
4
  // src/sleep.ts
708
- var sleep_default = (time) => {
5
+ var sleep_default = /* @__PURE__ */ __name((time) => {
709
6
  return new Promise((resolve) => setTimeout(resolve, time));
710
- };
7
+ }, "default");
711
8
 
712
9
  // src/hashObject.ts
713
- var import_object_hash = __toESM(require_object_hash(), 1);
10
+ import hash from "object-hash";
714
11
  function hashObject_default(object) {
715
- return import_object_hash.default(object);
12
+ return hash(object);
716
13
  }
14
+ __name(hashObject_default, "default");
717
15
 
718
16
  // src/generateId.ts
719
17
  import crypto from "crypto";
720
18
  var UNMISTAKABLE_CHARS = "23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghjkmnopqrstuvwxyz";
721
- var hexString = function(digits) {
19
+ var hexString = /* @__PURE__ */ __name(function(digits) {
722
20
  var numBytes = Math.ceil(digits / 2);
723
21
  var bytes;
724
22
  try {
@@ -728,31 +26,30 @@ var hexString = function(digits) {
728
26
  }
729
27
  var result = bytes.toString("hex");
730
28
  return result.substring(0, digits);
731
- };
732
- var fraction = function() {
29
+ }, "hexString");
30
+ var fraction = /* @__PURE__ */ __name(function() {
733
31
  var numerator = parseInt(hexString(8), 16);
734
- return numerator * 0.00000000023283064365386963;
735
- };
736
- var choice = function(arrayOrString) {
32
+ return numerator * 23283064365386963e-26;
33
+ }, "fraction");
34
+ var choice = /* @__PURE__ */ __name(function(arrayOrString) {
737
35
  var index = Math.floor(fraction() * arrayOrString.length);
738
- if (typeof arrayOrString === "string")
739
- return arrayOrString.substr(index, 1);
740
- else
741
- return arrayOrString[index];
742
- };
743
- var randomString = function(charsCount, alphabet) {
36
+ if (typeof arrayOrString === "string") return arrayOrString.substr(index, 1);
37
+ else return arrayOrString[index];
38
+ }, "choice");
39
+ var randomString = /* @__PURE__ */ __name(function(charsCount, alphabet) {
744
40
  var digits = [];
745
- for (var i = 0;i < charsCount; i++) {
41
+ for (var i = 0; i < charsCount; i++) {
746
42
  digits[i] = choice(alphabet);
747
43
  }
748
44
  return digits.join("");
749
- };
45
+ }, "randomString");
750
46
  function generateId(charsCount, chars = UNMISTAKABLE_CHARS) {
751
47
  if (!charsCount) {
752
48
  charsCount = 17;
753
49
  }
754
50
  return randomString(charsCount, chars);
755
51
  }
52
+ __name(generateId, "generateId");
756
53
 
757
54
  // src/createMap.ts
758
55
  function createMap(array, key = "_id") {
@@ -762,6 +59,7 @@ function createMap(array, key = "_id") {
762
59
  }
763
60
  return map;
764
61
  }
62
+ __name(createMap, "createMap");
765
63
 
766
64
  // src/createMapArray.ts
767
65
  function createMapArray(array, key = "_id") {
@@ -772,19 +70,49 @@ function createMapArray(array, key = "_id") {
772
70
  }
773
71
  return map;
774
72
  }
73
+ __name(createMapArray, "createMapArray");
775
74
 
776
75
  // src/Errors/OrionError.ts
777
- class OrionError extends Error {
76
+ var _OrionError = class _OrionError extends Error {
778
77
  isOrionError = true;
779
78
  isUserError;
780
79
  isPermissionsError;
781
80
  code;
782
81
  extra;
82
+ /**
83
+ * Returns a standardized representation of the error information.
84
+ * @returns An object containing error details in a consistent format
85
+ */
783
86
  getInfo;
784
- }
87
+ };
88
+ __name(_OrionError, "OrionError");
89
+ var OrionError = _OrionError;
785
90
 
786
91
  // src/Errors/PermissionsError.ts
787
- class PermissionsError extends OrionError {
92
+ var _PermissionsError = class _PermissionsError extends OrionError {
93
+ /**
94
+ * Creates a new PermissionsError instance.
95
+ *
96
+ * @param permissionErrorType - Identifies the specific permission that was violated
97
+ * (e.g., 'read', 'write', 'admin')
98
+ * @param extra - Additional error context or metadata. Can include a custom message
99
+ * via the message property.
100
+ *
101
+ * @example
102
+ * // Basic usage
103
+ * throw new PermissionsError('delete_document')
104
+ *
105
+ * @example
106
+ * // With custom message
107
+ * throw new PermissionsError('access_admin', { message: 'Admin access required' })
108
+ *
109
+ * @example
110
+ * // With additional context
111
+ * throw new PermissionsError('edit_user', {
112
+ * userId: 'user123',
113
+ * requiredRole: 'admin'
114
+ * })
115
+ */
788
116
  constructor(permissionErrorType, extra = {}) {
789
117
  const message = extra.message || `Client is not allowed to perform this action [${permissionErrorType}]`;
790
118
  super(message);
@@ -802,10 +130,32 @@ class PermissionsError extends OrionError {
802
130
  };
803
131
  };
804
132
  }
805
- }
133
+ };
134
+ __name(_PermissionsError, "PermissionsError");
135
+ var PermissionsError = _PermissionsError;
806
136
 
807
137
  // src/Errors/UserError.ts
808
- class UserError extends OrionError {
138
+ var _UserError = class _UserError extends OrionError {
139
+ /**
140
+ * Creates a new UserError instance.
141
+ *
142
+ * @param code - Error code identifier. If only one parameter is provided,
143
+ * this will be used as the message and code will default to 'error'.
144
+ * @param message - Human-readable error message. Optional if code is provided.
145
+ * @param extra - Additional error context or metadata.
146
+ *
147
+ * @example
148
+ * // Basic usage
149
+ * throw new UserError('invalid_input', 'The provided email is invalid')
150
+ *
151
+ * @example
152
+ * // Using only a message (code will be 'error')
153
+ * throw new UserError('Input validation failed')
154
+ *
155
+ * @example
156
+ * // With extra metadata
157
+ * throw new UserError('rate_limit', 'Too many requests', { maxRequests: 100 })
158
+ */
809
159
  constructor(code, message, extra) {
810
160
  if (!message && code) {
811
161
  message = code;
@@ -825,51 +175,54 @@ class UserError extends OrionError {
825
175
  };
826
176
  };
827
177
  }
828
- }
178
+ };
179
+ __name(_UserError, "UserError");
180
+ var UserError = _UserError;
829
181
 
830
182
  // src/Errors/index.ts
831
183
  function isOrionError(error) {
832
184
  return Boolean(error && typeof error === "object" && error.isOrionError === true);
833
185
  }
186
+ __name(isOrionError, "isOrionError");
834
187
  function isUserError(error) {
835
188
  return Boolean(error && typeof error === "object" && error.isOrionError === true && error.isUserError === true);
836
189
  }
190
+ __name(isUserError, "isUserError");
837
191
  function isPermissionsError(error) {
838
192
  return Boolean(error && typeof error === "object" && error.isOrionError === true && error.isPermissionsError === true);
839
193
  }
194
+ __name(isPermissionsError, "isPermissionsError");
840
195
 
841
196
  // src/composeMiddlewares.ts
842
197
  function composeMiddlewares(middleware) {
843
- if (!Array.isArray(middleware))
844
- throw new TypeError("Middleware stack must be an array!");
198
+ if (!Array.isArray(middleware)) throw new TypeError("Middleware stack must be an array!");
845
199
  for (const fn of middleware) {
846
- if (typeof fn !== "function")
847
- throw new TypeError("Middleware must be composed of functions!");
200
+ if (typeof fn !== "function") throw new TypeError("Middleware must be composed of functions!");
848
201
  }
849
202
  return function(context, next) {
850
203
  let index = -1;
851
204
  return dispatch(0);
852
205
  function dispatch(i) {
853
- if (i <= index)
854
- return Promise.reject(new Error("next() called multiple times"));
206
+ if (i <= index) return Promise.reject(new Error("next() called multiple times"));
855
207
  index = i;
856
208
  let fn = middleware[i];
857
- if (i === middleware.length)
858
- fn = next;
859
- if (!fn)
860
- return Promise.resolve();
209
+ if (i === middleware.length) fn = next;
210
+ if (!fn) return Promise.resolve();
861
211
  try {
862
212
  return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
863
213
  } catch (err) {
864
214
  return Promise.reject(err);
865
215
  }
866
216
  }
217
+ __name(dispatch, "dispatch");
867
218
  };
868
219
  }
220
+ __name(composeMiddlewares, "composeMiddlewares");
221
+
869
222
  // src/retries.ts
870
223
  function executeWithRetries(fn, retries, timeout) {
871
224
  return new Promise((resolve, reject) => {
872
- const retry = async (retries2) => {
225
+ const retry = /* @__PURE__ */ __name(async (retries2) => {
873
226
  try {
874
227
  const result = await fn();
875
228
  resolve(result);
@@ -880,58 +233,115 @@ function executeWithRetries(fn, retries, timeout) {
880
233
  reject(error);
881
234
  }
882
235
  }
883
- };
236
+ }, "retry");
884
237
  retry(retries);
885
238
  });
886
239
  }
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;
240
+ __name(executeWithRetries, "executeWithRetries");
241
+
242
+ // ../../node_modules/uuid/dist/esm-node/rng.js
243
+ import crypto2 from "crypto";
244
+ var rnds8Pool = new Uint8Array(256);
245
+ var poolPtr = rnds8Pool.length;
246
+ function rng() {
247
+ if (poolPtr > rnds8Pool.length - 16) {
248
+ crypto2.randomFillSync(rnds8Pool);
249
+ poolPtr = 0;
250
+ }
251
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
252
+ }
253
+ __name(rng, "rng");
254
+
255
+ // ../../node_modules/uuid/dist/esm-node/regex.js
256
+ 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;
257
+
258
+ // ../../node_modules/uuid/dist/esm-node/validate.js
259
+ function validate(uuid) {
260
+ return typeof uuid === "string" && regex_default.test(uuid);
261
+ }
262
+ __name(validate, "validate");
263
+ var validate_default = validate;
264
+
265
+ // ../../node_modules/uuid/dist/esm-node/stringify.js
266
+ var byteToHex = [];
267
+ for (let i = 0; i < 256; ++i) {
268
+ byteToHex.push((i + 256).toString(16).substr(1));
269
+ }
270
+ function stringify(arr, offset = 0) {
271
+ 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();
272
+ if (!validate_default(uuid)) {
273
+ throw TypeError("Stringified UUID is invalid");
274
+ }
275
+ return uuid;
276
+ }
277
+ __name(stringify, "stringify");
278
+ var stringify_default = stringify;
279
+
280
+ // ../../node_modules/uuid/dist/esm-node/v4.js
281
+ function v4(options, buf, offset) {
282
+ options = options || {};
283
+ const rnds = options.random || (options.rng || rng)();
284
+ rnds[6] = rnds[6] & 15 | 64;
285
+ rnds[8] = rnds[8] & 63 | 128;
286
+ if (buf) {
287
+ offset = offset || 0;
288
+ for (let i = 0; i < 16; ++i) {
289
+ buf[offset + i] = rnds[i];
290
+ }
291
+ return buf;
292
+ }
293
+ return stringify_default(rnds);
294
+ }
295
+ __name(v4, "v4");
296
+ var v4_default = v4;
893
297
 
894
298
  // src/generateUUID.ts
895
299
  function generateUUID() {
896
- return v4();
300
+ return v4_default();
897
301
  }
302
+ __name(generateUUID, "generateUUID");
898
303
  function generateUUIDWithPrefix(prefix) {
899
304
  return `${prefix}-${generateUUID()}`;
900
305
  }
306
+ __name(generateUUIDWithPrefix, "generateUUIDWithPrefix");
307
+
901
308
  // src/normalize.ts
902
309
  function removeAccentsOnly(text) {
903
- if (!text)
904
- return "";
310
+ if (!text) return "";
905
311
  return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
906
312
  }
313
+ __name(removeAccentsOnly, "removeAccentsOnly");
907
314
  function removeAccentsAndTrim(text) {
908
- if (!text)
909
- return "";
315
+ if (!text) return "";
910
316
  return removeAccentsOnly(text).trim();
911
317
  }
318
+ __name(removeAccentsAndTrim, "removeAccentsAndTrim");
912
319
  function normalizeForSearch(text) {
913
- if (!text)
914
- return "";
320
+ if (!text) return "";
915
321
  return removeAccentsAndTrim(text).toLowerCase();
916
322
  }
323
+ __name(normalizeForSearch, "normalizeForSearch");
917
324
  function normalizeForCompactSearch(text) {
918
- if (!text)
919
- return "";
325
+ if (!text) return "";
920
326
  return normalizeForSearch(text).replace(/\s/g, "");
921
327
  }
328
+ __name(normalizeForCompactSearch, "normalizeForCompactSearch");
922
329
  function normalizeForSearchToken(text) {
923
- if (!text)
924
- return "";
330
+ if (!text) return "";
925
331
  return normalizeForSearch(text).replace(/[^0-9a-z]/gi, " ");
926
332
  }
333
+ __name(normalizeForSearchToken, "normalizeForSearchToken");
927
334
  function normalizeForFileKey(text) {
928
- if (!text)
929
- return "";
335
+ if (!text) return "";
930
336
  return removeAccentsOnly(text).replace(/[^a-zA-Z0-9-._]/g, "-").replace(/-+/g, "-").trim().replace(/^-+|-+$/g, "");
931
337
  }
338
+ __name(normalizeForFileKey, "normalizeForFileKey");
339
+
932
340
  // src/searchTokens.ts
933
341
  function getSearchTokens(text, meta) {
934
- const stringArray = Array.isArray(text) ? text : [text];
342
+ const stringArray = Array.isArray(text) ? text : [
343
+ text
344
+ ];
935
345
  const tokens = stringArray.filter(Boolean).map((text2) => String(text2)).flatMap((word) => {
936
346
  return normalizeForSearchToken(word).split(" ").filter(Boolean);
937
347
  });
@@ -942,6 +352,7 @@ function getSearchTokens(text, meta) {
942
352
  }
943
353
  return tokens;
944
354
  }
355
+ __name(getSearchTokens, "getSearchTokens");
945
356
  function getSearchQueryForTokens(params = {}, _options = {}) {
946
357
  const searchTokens = [];
947
358
  if (params.filter) {
@@ -949,44 +360,49 @@ function getSearchQueryForTokens(params = {}, _options = {}) {
949
360
  searchTokens.push(...filterTokens);
950
361
  }
951
362
  for (const key in params) {
952
- if (key === "filter")
953
- continue;
954
- if (!params[key])
955
- continue;
363
+ if (key === "filter") continue;
364
+ if (!params[key]) continue;
956
365
  searchTokens.push(`_${key}:${params[key]}`);
957
366
  }
958
- return { $all: searchTokens };
367
+ return {
368
+ $all: searchTokens
369
+ };
959
370
  }
371
+ __name(getSearchQueryForTokens, "getSearchQueryForTokens");
372
+
960
373
  // src/shortenMongoId.ts
961
374
  function lastOfString(string, last) {
962
375
  return string.substring(string.length - last, string.length);
963
376
  }
377
+ __name(lastOfString, "lastOfString");
964
378
  function shortenMongoId(string) {
965
379
  return lastOfString(string, 5).toUpperCase();
966
380
  }
381
+ __name(shortenMongoId, "shortenMongoId");
967
382
  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,
383
+ OrionError,
990
384
  PermissionsError,
991
- OrionError
385
+ UserError,
386
+ composeMiddlewares,
387
+ createMap,
388
+ createMapArray,
389
+ executeWithRetries,
390
+ generateId,
391
+ generateUUID,
392
+ generateUUIDWithPrefix,
393
+ getSearchQueryForTokens,
394
+ getSearchTokens,
395
+ hashObject_default as hashObject,
396
+ isOrionError,
397
+ isPermissionsError,
398
+ isUserError,
399
+ normalizeForCompactSearch,
400
+ normalizeForFileKey,
401
+ normalizeForSearch,
402
+ normalizeForSearchToken,
403
+ removeAccentsAndTrim,
404
+ removeAccentsOnly,
405
+ shortenMongoId,
406
+ sleep_default as sleep
992
407
  };
408
+ //# sourceMappingURL=index.js.map