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