@orion-js/helpers 4.3.1 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Orionjs Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Interface representing the standardized error information structure for Orion errors.
3
+ * This is used by the getInfo method to provide consistent error reporting.
4
+ */
5
+ export interface OrionErrorInformation {
6
+ /** The error code or identifier */
7
+ error: string;
8
+ /** Human-readable error message */
9
+ message: string;
10
+ /** Additional error metadata or context */
11
+ extra: any;
12
+ /** The sub-type of error. For example for permissions errors it could be 'read', 'write', 'admin' */
13
+ type?: string;
14
+ }
15
+ /**
16
+ * Base error class for all Orion-specific errors.
17
+ *
18
+ * This abstract class provides common properties and methods for all error types
19
+ * used in the Orion framework. It's extended by more specific error classes
20
+ * like UserError and PermissionsError.
21
+ *
22
+ * @property isOrionError - Flag indicating this is an Orion error (always true)
23
+ * @property isUserError - Flag indicating if this is a user-facing error
24
+ * @property isPermissionsError - Flag indicating if this is a permissions-related error
25
+ * @property code - Error code for identifying the error type
26
+ * @property extra - Additional error context or metadata
27
+ */
28
+ export declare class OrionError extends Error {
29
+ isOrionError: boolean;
30
+ isUserError: boolean;
31
+ isPermissionsError: boolean;
32
+ code: string;
33
+ extra: any;
34
+ /**
35
+ * Returns a standardized representation of the error information.
36
+ * @returns An object containing error details in a consistent format
37
+ */
38
+ getInfo: () => OrionErrorInformation;
39
+ }
@@ -0,0 +1,37 @@
1
+ import { OrionError } from './OrionError';
2
+ /**
3
+ * Error class for permission-related errors in the Orion framework.
4
+ *
5
+ * PermissionsError represents authorization failures where a user or client
6
+ * attempts to perform an action they don't have permission to execute.
7
+ * This is used to distinguish security/permissions errors from other types
8
+ * of errors for proper error handling and user feedback.
9
+ *
10
+ * @extends OrionError
11
+ */
12
+ export default class PermissionsError extends OrionError {
13
+ /**
14
+ * Creates a new PermissionsError instance.
15
+ *
16
+ * @param permissionErrorType - Identifies the specific permission that was violated
17
+ * (e.g., 'read', 'write', 'admin')
18
+ * @param extra - Additional error context or metadata. Can include a custom message
19
+ * via the message property.
20
+ *
21
+ * @example
22
+ * // Basic usage
23
+ * throw new PermissionsError('delete_document')
24
+ *
25
+ * @example
26
+ * // With custom message
27
+ * throw new PermissionsError('access_admin', { message: 'Admin access required' })
28
+ *
29
+ * @example
30
+ * // With additional context
31
+ * throw new PermissionsError('edit_user', {
32
+ * userId: 'user123',
33
+ * requiredRole: 'admin'
34
+ * })
35
+ */
36
+ constructor(permissionErrorType: any, extra?: any);
37
+ }
@@ -0,0 +1,33 @@
1
+ import { OrionError } from './OrionError';
2
+ /**
3
+ * Error class for user-facing errors in the Orion framework.
4
+ *
5
+ * UserError is designed to represent errors that should be displayed to end users,
6
+ * as opposed to system errors or unexpected failures. These errors typically represent
7
+ * validation issues, business rule violations, or other expected error conditions.
8
+ *
9
+ * @extends OrionError
10
+ */
11
+ export default class UserError extends OrionError {
12
+ /**
13
+ * Creates a new UserError instance.
14
+ *
15
+ * @param code - Error code identifier. If only one parameter is provided,
16
+ * this will be used as the message and code will default to 'error'.
17
+ * @param message - Human-readable error message. Optional if code is provided.
18
+ * @param extra - Additional error context or metadata.
19
+ *
20
+ * @example
21
+ * // Basic usage
22
+ * throw new UserError('invalid_input', 'The provided email is invalid')
23
+ *
24
+ * @example
25
+ * // Using only a message (code will be 'error')
26
+ * throw new UserError('Input validation failed')
27
+ *
28
+ * @example
29
+ * // With extra metadata
30
+ * throw new UserError('rate_limit', 'Too many requests', { maxRequests: 100 })
31
+ */
32
+ constructor(code: string, message?: string, extra?: any);
33
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @file Exports all error classes used in the Orion framework
3
+ */
4
+ import { OrionError } from './OrionError';
5
+ import type { OrionErrorInformation } from './OrionError';
6
+ import PermissionsError from './PermissionsError';
7
+ import UserError from './UserError';
8
+ /**
9
+ * Re-export all error types for convenient importing
10
+ */
11
+ export { OrionError, PermissionsError, UserError };
12
+ export type { OrionErrorInformation };
13
+ /**
14
+ * Type guard to check if an error is an OrionError
15
+ *
16
+ * @param error - Any error object to test
17
+ * @returns True if the error is an OrionError instance
18
+ *
19
+ * @example
20
+ * try {
21
+ * // some code that might throw
22
+ * } catch (error) {
23
+ * if (isOrionError(error)) {
24
+ * // Handle Orion-specific error
25
+ * console.log(error.code, error.getInfo())
26
+ * } else {
27
+ * // Handle general error
28
+ * }
29
+ * }
30
+ */
31
+ export declare function isOrionError(error: any): error is OrionError;
32
+ /**
33
+ * Type guard to check if an error is a UserError
34
+ *
35
+ * @param error - Any error object to test
36
+ * @returns True if the error is a UserError instance
37
+ */
38
+ export declare function isUserError(error: any): error is UserError;
39
+ /**
40
+ * Type guard to check if an error is a PermissionsError
41
+ *
42
+ * @param error - Any error object to test
43
+ * @returns True if the error is a PermissionsError instance
44
+ */
45
+ export declare function isPermissionsError(error: any): error is PermissionsError;
@@ -0,0 +1 @@
1
+ export declare function clone<T>(value: T): T;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Compose `middleware` returning
3
+ * a fully valid middleware comprised
4
+ * of all those which are passed.
5
+ */
6
+ export declare function composeMiddlewares(middleware: any): (context: any, next?: any) => Promise<any>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Creates a map (object) from an array of items, using a specified property as the key.
3
+ *
4
+ * This utility transforms an array of objects into a lookup object/dictionary where
5
+ * each item in the array becomes a value in the map, indexed by the specified property.
6
+ * If multiple items have the same key value, only the last one will be preserved.
7
+ *
8
+ * @template T The type of items in the input array
9
+ * @param array - The input array of items to transform into a map
10
+ * @param key - The property name to use as keys in the resulting map (defaults to '_id')
11
+ * @returns A record object where keys are values of the specified property and values are the original items
12
+ *
13
+ * @example
14
+ * // Returns { '1': { id: 1, name: 'Item 1' }, '2': { id: 2, name: 'Item 2' } }
15
+ * createMap([{ id: 1, name: 'Item 1' }, { id: 2, name: 'Item 2' }], 'id')
16
+ */
17
+ export default function createMap<T>(array: Array<T>, key?: string): Record<string, T>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Creates a grouped map from an array of items, using a specified property as the key.
3
+ *
4
+ * This utility transforms an array of objects into a lookup object/dictionary where
5
+ * each value is an array of items sharing the same key value. Unlike createMap,
6
+ * this function preserves all items with the same key by grouping them in arrays.
7
+ *
8
+ * @template T The type of items in the input array
9
+ * @param array - The input array of items to transform into a grouped map
10
+ * @param key - The property name to use as keys in the resulting map (defaults to '_id')
11
+ * @returns A record object where keys are values of the specified property and values are arrays of items
12
+ *
13
+ * @example
14
+ * // Returns { 'category1': [{ id: 1, category: 'category1' }, { id: 3, category: 'category1' }],
15
+ * // 'category2': [{ id: 2, category: 'category2' }] }
16
+ * createMapArray([
17
+ * { id: 1, category: 'category1' },
18
+ * { id: 2, category: 'category2' },
19
+ * { id: 3, category: 'category1' }
20
+ * ], 'category')
21
+ */
22
+ export default function createMapArray<T>(array: Array<T>, key?: string): Record<string, Array<T>>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns a random ID
3
+ * @param charsCount length of the ID
4
+ * @param chars characters used to generate the ID
5
+ */
6
+ export default function generateId(charsCount?: number, chars?: string): string;
@@ -0,0 +1,2 @@
1
+ export declare function generateUUID(): string;
2
+ export declare function generateUUIDWithPrefix(prefix: string): string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Receives any javascript object, string, number, boolean, array, or object and returns a hash of it.
3
+ */
4
+ export default function hashObject(object: any): string;
package/dist/index.d.ts CHANGED
@@ -1,378 +1,16 @@
1
- /**
2
- * Creates a timeout with a promise
3
- */
4
- declare const _default: (time: number) => Promise<void>;
5
-
6
- /**
7
- * Receives any javascript object, string, number, boolean, array, or object and returns a hash of it.
8
- */
9
- declare function hashObject(object: any): string;
10
-
11
- /**
12
- * Returns a random ID
13
- * @param charsCount length of the ID
14
- * @param chars characters used to generate the ID
15
- */
16
- declare function generateId(charsCount?: number, chars?: string): string;
17
-
18
- /**
19
- * Creates a map (object) from an array of items, using a specified property as the key.
20
- *
21
- * This utility transforms an array of objects into a lookup object/dictionary where
22
- * each item in the array becomes a value in the map, indexed by the specified property.
23
- * If multiple items have the same key value, only the last one will be preserved.
24
- *
25
- * @template T The type of items in the input array
26
- * @param array - The input array of items to transform into a map
27
- * @param key - The property name to use as keys in the resulting map (defaults to '_id')
28
- * @returns A record object where keys are values of the specified property and values are the original items
29
- *
30
- * @example
31
- * // Returns { '1': { id: 1, name: 'Item 1' }, '2': { id: 2, name: 'Item 2' } }
32
- * createMap([{ id: 1, name: 'Item 1' }, { id: 2, name: 'Item 2' }], 'id')
33
- */
34
- declare function createMap<T>(array: Array<T>, key?: string): Record<string, T>;
35
-
36
- /**
37
- * Creates a grouped map from an array of items, using a specified property as the key.
38
- *
39
- * This utility transforms an array of objects into a lookup object/dictionary where
40
- * each value is an array of items sharing the same key value. Unlike createMap,
41
- * this function preserves all items with the same key by grouping them in arrays.
42
- *
43
- * @template T The type of items in the input array
44
- * @param array - The input array of items to transform into a grouped map
45
- * @param key - The property name to use as keys in the resulting map (defaults to '_id')
46
- * @returns A record object where keys are values of the specified property and values are arrays of items
47
- *
48
- * @example
49
- * // Returns { 'category1': [{ id: 1, category: 'category1' }, { id: 3, category: 'category1' }],
50
- * // 'category2': [{ id: 2, category: 'category2' }] }
51
- * createMapArray([
52
- * { id: 1, category: 'category1' },
53
- * { id: 2, category: 'category2' },
54
- * { id: 3, category: 'category1' }
55
- * ], 'category')
56
- */
57
- declare function createMapArray<T>(array: Array<T>, key?: string): Record<string, Array<T>>;
58
-
59
- declare function clone<T>(value: T): T;
60
-
61
- /**
62
- * Interface representing the standardized error information structure for Orion errors.
63
- * This is used by the getInfo method to provide consistent error reporting.
64
- */
65
- interface OrionErrorInformation {
66
- /** The error code or identifier */
67
- error: string;
68
- /** Human-readable error message */
69
- message: string;
70
- /** Additional error metadata or context */
71
- extra: any;
72
- /** The sub-type of error. For example for permissions errors it could be 'read', 'write', 'admin' */
73
- type?: string;
74
- }
75
- /**
76
- * Base error class for all Orion-specific errors.
77
- *
78
- * This abstract class provides common properties and methods for all error types
79
- * used in the Orion framework. It's extended by more specific error classes
80
- * like UserError and PermissionsError.
81
- *
82
- * @property isOrionError - Flag indicating this is an Orion error (always true)
83
- * @property isUserError - Flag indicating if this is a user-facing error
84
- * @property isPermissionsError - Flag indicating if this is a permissions-related error
85
- * @property code - Error code for identifying the error type
86
- * @property extra - Additional error context or metadata
87
- */
88
- declare class OrionError extends Error {
89
- isOrionError: boolean;
90
- isUserError: boolean;
91
- isPermissionsError: boolean;
92
- code: string;
93
- extra: any;
94
- /**
95
- * Returns a standardized representation of the error information.
96
- * @returns An object containing error details in a consistent format
97
- */
98
- getInfo: () => OrionErrorInformation;
99
- }
100
-
101
- /**
102
- * Error class for permission-related errors in the Orion framework.
103
- *
104
- * PermissionsError represents authorization failures where a user or client
105
- * attempts to perform an action they don't have permission to execute.
106
- * This is used to distinguish security/permissions errors from other types
107
- * of errors for proper error handling and user feedback.
108
- *
109
- * @extends OrionError
110
- */
111
- declare class PermissionsError extends OrionError {
112
- /**
113
- * Creates a new PermissionsError instance.
114
- *
115
- * @param permissionErrorType - Identifies the specific permission that was violated
116
- * (e.g., 'read', 'write', 'admin')
117
- * @param extra - Additional error context or metadata. Can include a custom message
118
- * via the message property.
119
- *
120
- * @example
121
- * // Basic usage
122
- * throw new PermissionsError('delete_document')
123
- *
124
- * @example
125
- * // With custom message
126
- * throw new PermissionsError('access_admin', { message: 'Admin access required' })
127
- *
128
- * @example
129
- * // With additional context
130
- * throw new PermissionsError('edit_user', {
131
- * userId: 'user123',
132
- * requiredRole: 'admin'
133
- * })
134
- */
135
- constructor(permissionErrorType: any, extra?: any);
136
- }
137
-
138
- /**
139
- * Error class for user-facing errors in the Orion framework.
140
- *
141
- * UserError is designed to represent errors that should be displayed to end users,
142
- * as opposed to system errors or unexpected failures. These errors typically represent
143
- * validation issues, business rule violations, or other expected error conditions.
144
- *
145
- * @extends OrionError
146
- */
147
- declare class UserError extends OrionError {
148
- /**
149
- * Creates a new UserError instance.
150
- *
151
- * @param code - Error code identifier. If only one parameter is provided,
152
- * this will be used as the message and code will default to 'error'.
153
- * @param message - Human-readable error message. Optional if code is provided.
154
- * @param extra - Additional error context or metadata.
155
- *
156
- * @example
157
- * // Basic usage
158
- * throw new UserError('invalid_input', 'The provided email is invalid')
159
- *
160
- * @example
161
- * // Using only a message (code will be 'error')
162
- * throw new UserError('Input validation failed')
163
- *
164
- * @example
165
- * // With extra metadata
166
- * throw new UserError('rate_limit', 'Too many requests', { maxRequests: 100 })
167
- */
168
- constructor(code: string, message?: string, extra?: any);
169
- }
170
-
171
- /**
172
- * @file Exports all error classes used in the Orion framework
173
- */
174
-
175
- /**
176
- * Type guard to check if an error is an OrionError
177
- *
178
- * @param error - Any error object to test
179
- * @returns True if the error is an OrionError instance
180
- *
181
- * @example
182
- * try {
183
- * // some code that might throw
184
- * } catch (error) {
185
- * if (isOrionError(error)) {
186
- * // Handle Orion-specific error
187
- * console.log(error.code, error.getInfo())
188
- * } else {
189
- * // Handle general error
190
- * }
191
- * }
192
- */
193
- declare function isOrionError(error: any): error is OrionError;
194
- /**
195
- * Type guard to check if an error is a UserError
196
- *
197
- * @param error - Any error object to test
198
- * @returns True if the error is a UserError instance
199
- */
200
- declare function isUserError(error: any): error is UserError;
201
- /**
202
- * Type guard to check if an error is a PermissionsError
203
- *
204
- * @param error - Any error object to test
205
- * @returns True if the error is a PermissionsError instance
206
- */
207
- declare function isPermissionsError(error: any): error is PermissionsError;
208
-
209
- /**
210
- * Compose `middleware` returning
211
- * a fully valid middleware comprised
212
- * of all those which are passed.
213
- */
214
- declare function composeMiddlewares(middleware: any): (context: any, next?: any) => Promise<any>;
215
-
216
- /**
217
- * Executes an asynchronous function with automatic retries on failure.
218
- *
219
- * This utility attempts to execute the provided function and automatically
220
- * retries if it fails, with a specified delay between attempts. It will
221
- * continue retrying until either the function succeeds or the maximum
222
- * number of retries is reached.
223
- *
224
- * @template TFunc Type of the function to execute (must return a Promise)
225
- * @param fn - The asynchronous function to execute
226
- * @param retries - The maximum number of retry attempts after the initial attempt
227
- * @param timeout - The delay in milliseconds between retry attempts
228
- * @returns A promise that resolves with the result of the function or rejects with the last error
229
- *
230
- * @example
231
- * // Retry an API call up to 3 times with 1 second between attempts
232
- * const result = await executeWithRetries(
233
- * () => fetchDataFromApi(),
234
- * 3,
235
- * 1000
236
- * );
237
- */
238
- declare function executeWithRetries<TFunc extends () => Promise<any>>(fn: TFunc, retries: number, timeout: number): Promise<ReturnType<TFunc>>;
239
-
240
- declare function generateUUID(): string;
241
- declare function generateUUIDWithPrefix(prefix: string): string;
242
-
243
- /**
244
- * Removes diacritical marks (accents) from text without any other modifications.
245
- * This is the most basic normalization function that others build upon.
246
- *
247
- * @param text - The input string to process
248
- * @returns String with accents removed but otherwise unchanged
249
- */
250
- declare function removeAccentsOnly(text: string): string;
251
- /**
252
- * Normalizes text by removing diacritical marks (accents) and trimming whitespace.
253
- * Builds on removeAccentsOnly and adds whitespace trimming.
254
- *
255
- * @param text - The input string to normalize
256
- * @returns Normalized string with accents removed and whitespace trimmed
257
- */
258
- declare function removeAccentsAndTrim(text: string): string;
259
- /**
260
- * Normalizes text for search purposes by:
261
- * - Removing diacritical marks (accents)
262
- * - Converting to lowercase
263
- * - Trimming whitespace
264
- *
265
- * Builds on removeAccentsAndTrim and adds lowercase conversion.
266
- * Useful for case-insensitive and accent-insensitive text searching.
267
- *
268
- * @param text - The input string to normalize for search
269
- * @returns Search-optimized string in lowercase with accents removed
270
- */
271
- declare function normalizeForSearch(text: string): string;
272
- /**
273
- * Normalizes text for search purposes by:
274
- * - Removing diacritical marks (accents)
275
- * - Converting to lowercase
276
- * - Trimming whitespace
277
- * - Removing all spaces
278
- *
279
- * Builds on normalizeForSearch and removes all whitespace.
280
- * Useful for compact search indexes or when spaces should be ignored in searches.
281
- *
282
- * @param text - The input string to normalize for compact search
283
- * @returns Compact search-optimized string with no spaces
284
- */
285
- declare function normalizeForCompactSearch(text: string): string;
286
- /**
287
- * Normalizes text for search token processing by:
288
- * - Removing diacritical marks (accents)
289
- * - Converting to lowercase
290
- * - Trimming whitespace
291
- * - Replacing all non-alphanumeric characters with spaces
292
- *
293
- * Builds on normalizeForSearch and replaces non-alphanumeric characters with spaces.
294
- * Useful for tokenizing search terms where special characters should be treated as word separators.
295
- *
296
- * @param text - The input string to normalize for tokenized search
297
- * @returns Search token string with only alphanumeric characters and spaces
298
- */
299
- declare function normalizeForSearchToken(text: string): string;
300
- /**
301
- * Normalizes a string specifically for use as a file key (e.g., in S3 or other storage systems).
302
- * Performs the following transformations:
303
- * - Removes accents/diacritical marks
304
- * - Replaces special characters with hyphens
305
- * - Ensures only alphanumeric characters, hyphens, periods, and underscores remain
306
- * - Replaces multiple consecutive hyphens with a single hyphen
307
- * - Removes leading/trailing hyphens
308
- *
309
- * @param text - The input string to normalize for file key usage
310
- * @returns A storage-safe string suitable for use as a file key
311
- */
312
- declare function normalizeForFileKey(text: string): string;
313
-
314
- /**
315
- * Generates an array of search tokens from input text and optional metadata.
316
- *
317
- * This function processes text by:
318
- * 1. Converting it to an array of strings (if not already)
319
- * 2. Filtering out falsy values
320
- * 3. Normalizing each string (removing accents, special characters)
321
- * 4. Splitting by spaces to create individual tokens
322
- * 5. Optionally adding metadata tokens in the format "_key:value"
323
- *
324
- * @param text - String or array of strings to tokenize
325
- * @param meta - Optional metadata object where each key-value pair becomes a token
326
- * @returns Array of normalized search tokens
327
- *
328
- * @example
329
- * // Returns ['hello', 'world']
330
- * getSearchTokens('Hello, World!')
331
- *
332
- * @example
333
- * // Returns ['hello', 'world', '_id:123']
334
- * getSearchTokens('Hello, World!', { id: '123' })
335
- */
336
- declare function getSearchTokens(text: string[] | string, meta?: Record<string, string>): string[];
337
- /**
338
- * Interface for parameters used in generating search queries from tokens.
339
- *
340
- * @property filter - Optional string to filter search results
341
- * @property [key: string] - Additional key-value pairs for metadata filtering
342
- */
343
- interface SearchQueryForTokensParams {
344
- filter?: string;
345
- [key: string]: string;
346
- }
347
- /**
348
- * Options for customizing the search query generation behavior.
349
- * Currently empty but provided for future extensibility.
350
- */
351
- type SearchQueryForTokensOptions = {};
352
- /**
353
- * Generates a MongoDB-compatible query object based on the provided parameters.
354
- *
355
- * This function:
356
- * 1. Processes any filter text into RegExp tokens for prefix matching
357
- * 2. Adds metadata filters based on additional properties in the params object
358
- * 3. Returns a query object with the $all operator for MongoDB queries
359
- *
360
- * @param params - Parameters for generating the search query
361
- * @param _options - Options for customizing search behavior (reserved for future use)
362
- * @returns A MongoDB-compatible query object with format { $all: [...tokens] }
363
- *
364
- * @example
365
- * // Returns { $all: [/^hello/, /^world/] }
366
- * getSearchQueryForTokens({ filter: 'Hello World' })
367
- *
368
- * @example
369
- * // Returns { $all: [/^search/, '_category:books'] }
370
- * getSearchQueryForTokens({ filter: 'search', category: 'books' })
371
- */
372
- declare function getSearchQueryForTokens(params?: SearchQueryForTokensParams, _options?: SearchQueryForTokensOptions): {
373
- $all: (string | RegExp)[];
374
- };
375
-
376
- declare function shortenMongoId(string: string): string;
377
-
378
- export { OrionError, type OrionErrorInformation, PermissionsError, type SearchQueryForTokensOptions, type SearchQueryForTokensParams, UserError, clone, composeMiddlewares, createMap, createMapArray, executeWithRetries, generateId, generateUUID, generateUUIDWithPrefix, getSearchQueryForTokens, getSearchTokens, hashObject, isOrionError, isPermissionsError, isUserError, normalizeForCompactSearch, normalizeForFileKey, normalizeForSearch, normalizeForSearchToken, removeAccentsAndTrim, removeAccentsOnly, shortenMongoId, _default as sleep };
1
+ import sleep from './sleep';
2
+ import hashObject from './hashObject';
3
+ import generateId from './generateId';
4
+ import createMap from './createMap';
5
+ import createMapArray from './createMapArray';
6
+ export * from './clone';
7
+ import { OrionError, PermissionsError, UserError, isOrionError, isUserError, isPermissionsError } from './Errors';
8
+ import type { OrionErrorInformation } from './Errors';
9
+ export * from './composeMiddlewares';
10
+ export * from './retries';
11
+ export * from './generateUUID';
12
+ export * from './normalize';
13
+ export * from './searchTokens';
14
+ export * from './shortenMongoId';
15
+ export { createMap, createMapArray, generateId, hashObject, sleep, OrionError, PermissionsError, UserError, isOrionError, isUserError, isPermissionsError, };
16
+ export type { OrionErrorInformation };
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Removes diacritical marks (accents) from text without any other modifications.
3
+ * This is the most basic normalization function that others build upon.
4
+ *
5
+ * @param text - The input string to process
6
+ * @returns String with accents removed but otherwise unchanged
7
+ */
8
+ export declare function removeAccentsOnly(text: string): string;
9
+ /**
10
+ * Normalizes text by removing diacritical marks (accents) and trimming whitespace.
11
+ * Builds on removeAccentsOnly and adds whitespace trimming.
12
+ *
13
+ * @param text - The input string to normalize
14
+ * @returns Normalized string with accents removed and whitespace trimmed
15
+ */
16
+ export declare function removeAccentsAndTrim(text: string): string;
17
+ /**
18
+ * Normalizes text for search purposes by:
19
+ * - Removing diacritical marks (accents)
20
+ * - Converting to lowercase
21
+ * - Trimming whitespace
22
+ *
23
+ * Builds on removeAccentsAndTrim and adds lowercase conversion.
24
+ * Useful for case-insensitive and accent-insensitive text searching.
25
+ *
26
+ * @param text - The input string to normalize for search
27
+ * @returns Search-optimized string in lowercase with accents removed
28
+ */
29
+ export declare function normalizeForSearch(text: string): string;
30
+ /**
31
+ * Normalizes text for search purposes by:
32
+ * - Removing diacritical marks (accents)
33
+ * - Converting to lowercase
34
+ * - Trimming whitespace
35
+ * - Removing all spaces
36
+ *
37
+ * Builds on normalizeForSearch and removes all whitespace.
38
+ * Useful for compact search indexes or when spaces should be ignored in searches.
39
+ *
40
+ * @param text - The input string to normalize for compact search
41
+ * @returns Compact search-optimized string with no spaces
42
+ */
43
+ export declare function normalizeForCompactSearch(text: string): string;
44
+ /**
45
+ * Normalizes text for search token processing by:
46
+ * - Removing diacritical marks (accents)
47
+ * - Converting to lowercase
48
+ * - Trimming whitespace
49
+ * - Replacing all non-alphanumeric characters with spaces
50
+ *
51
+ * Builds on normalizeForSearch and replaces non-alphanumeric characters with spaces.
52
+ * Useful for tokenizing search terms where special characters should be treated as word separators.
53
+ *
54
+ * @param text - The input string to normalize for tokenized search
55
+ * @returns Search token string with only alphanumeric characters and spaces
56
+ */
57
+ export declare function normalizeForSearchToken(text: string): string;
58
+ /**
59
+ * Normalizes a string specifically for use as a file key (e.g., in S3 or other storage systems).
60
+ * Performs the following transformations:
61
+ * - Removes accents/diacritical marks
62
+ * - Replaces special characters with hyphens
63
+ * - Ensures only alphanumeric characters, hyphens, periods, and underscores remain
64
+ * - Replaces multiple consecutive hyphens with a single hyphen
65
+ * - Removes leading/trailing hyphens
66
+ *
67
+ * @param text - The input string to normalize for file key usage
68
+ * @returns A storage-safe string suitable for use as a file key
69
+ */
70
+ export declare function normalizeForFileKey(text: string): string;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Executes an asynchronous function with automatic retries on failure.
3
+ *
4
+ * This utility attempts to execute the provided function and automatically
5
+ * retries if it fails, with a specified delay between attempts. It will
6
+ * continue retrying until either the function succeeds or the maximum
7
+ * number of retries is reached.
8
+ *
9
+ * @template TFunc Type of the function to execute (must return a Promise)
10
+ * @param fn - The asynchronous function to execute
11
+ * @param retries - The maximum number of retry attempts after the initial attempt
12
+ * @param timeout - The delay in milliseconds between retry attempts
13
+ * @returns A promise that resolves with the result of the function or rejects with the last error
14
+ *
15
+ * @example
16
+ * // Retry an API call up to 3 times with 1 second between attempts
17
+ * const result = await executeWithRetries(
18
+ * () => fetchDataFromApi(),
19
+ * 3,
20
+ * 1000
21
+ * );
22
+ */
23
+ export declare function executeWithRetries<TFunc extends () => Promise<any>>(fn: TFunc, retries: number, timeout: number): Promise<ReturnType<TFunc>>;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Generates an array of search tokens from input text and optional metadata.
3
+ *
4
+ * This function processes text by:
5
+ * 1. Converting it to an array of strings (if not already)
6
+ * 2. Filtering out falsy values
7
+ * 3. Normalizing each string (removing accents, special characters)
8
+ * 4. Splitting by spaces to create individual tokens
9
+ * 5. Optionally adding metadata tokens in the format "_key:value"
10
+ *
11
+ * @param text - String or array of strings to tokenize
12
+ * @param meta - Optional metadata object where each key-value pair becomes a token
13
+ * @returns Array of normalized search tokens
14
+ *
15
+ * @example
16
+ * // Returns ['hello', 'world']
17
+ * getSearchTokens('Hello, World!')
18
+ *
19
+ * @example
20
+ * // Returns ['hello', 'world', '_id:123']
21
+ * getSearchTokens('Hello, World!', { id: '123' })
22
+ */
23
+ export declare function getSearchTokens(text: string[] | string, meta?: Record<string, string>): string[];
24
+ /**
25
+ * Interface for parameters used in generating search queries from tokens.
26
+ *
27
+ * @property filter - Optional string to filter search results
28
+ * @property [key: string] - Additional key-value pairs for metadata filtering
29
+ */
30
+ export interface SearchQueryForTokensParams {
31
+ filter?: string;
32
+ [key: string]: string;
33
+ }
34
+ /**
35
+ * Options for customizing the search query generation behavior.
36
+ * Currently empty but provided for future extensibility.
37
+ */
38
+ export type SearchQueryForTokensOptions = {};
39
+ /**
40
+ * Generates a MongoDB-compatible query object based on the provided parameters.
41
+ *
42
+ * This function:
43
+ * 1. Processes any filter text into RegExp tokens for prefix matching
44
+ * 2. Adds metadata filters based on additional properties in the params object
45
+ * 3. Returns a query object with the $all operator for MongoDB queries
46
+ *
47
+ * @param params - Parameters for generating the search query
48
+ * @param _options - Options for customizing search behavior (reserved for future use)
49
+ * @returns A MongoDB-compatible query object with format { $all: [...tokens] }
50
+ *
51
+ * @example
52
+ * // Returns { $all: [/^hello/, /^world/] }
53
+ * getSearchQueryForTokens({ filter: 'Hello World' })
54
+ *
55
+ * @example
56
+ * // Returns { $all: [/^search/, '_category:books'] }
57
+ * getSearchQueryForTokens({ filter: 'search', category: 'books' })
58
+ */
59
+ export declare function getSearchQueryForTokens(params?: SearchQueryForTokensParams, _options?: SearchQueryForTokensOptions): {
60
+ $all: (string | RegExp)[];
61
+ };
@@ -0,0 +1 @@
1
+ export declare function shortenMongoId(string: string): string;
@@ -0,0 +1,5 @@
1
+ export default _default;
2
+ /**
3
+ * Creates a timeout with a promise
4
+ */
5
+ declare function _default(time: number): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/helpers",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "main": "./dist/index.cjs",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -14,27 +14,26 @@
14
14
  ],
15
15
  "author": "nicolaslopezj",
16
16
  "license": "MIT",
17
- "scripts": {
18
- "test": "bun test",
19
- "prepare": "bun run build",
20
- "clean": "rm -rf ./dist",
21
- "build": "tsup",
22
- "dev": "tsup --watch"
23
- },
24
17
  "dependencies": {
25
18
  "uuid": "^11.1.0"
26
19
  },
27
20
  "peerDependencies": {
28
- "@orion-js/logger": "4.3.1"
21
+ "@orion-js/logger": "4.4.0"
29
22
  },
30
23
  "devDependencies": {
31
24
  "@types/node": "^18.0.0",
32
25
  "tsup": "^8.0.1",
33
- "typescript": "^5.4.5"
26
+ "typescript": "^7.0.2"
34
27
  },
35
28
  "publishConfig": {
36
29
  "access": "public"
37
30
  },
38
31
  "gitHead": "a485b1fe6a1840ee6cb58fd69d6de62585f1ed10",
39
- "type": "module"
40
- }
32
+ "type": "module",
33
+ "scripts": {
34
+ "test": "bun test",
35
+ "clean": "rm -rf ./dist",
36
+ "build": "tsup && bun run ../../scripts/emit-declarations.ts",
37
+ "dev": "tsup --watch"
38
+ }
39
+ }
package/dist/index.d.cts DELETED
@@ -1,378 +0,0 @@
1
- /**
2
- * Creates a timeout with a promise
3
- */
4
- declare const _default: (time: number) => Promise<void>;
5
-
6
- /**
7
- * Receives any javascript object, string, number, boolean, array, or object and returns a hash of it.
8
- */
9
- declare function hashObject(object: any): string;
10
-
11
- /**
12
- * Returns a random ID
13
- * @param charsCount length of the ID
14
- * @param chars characters used to generate the ID
15
- */
16
- declare function generateId(charsCount?: number, chars?: string): string;
17
-
18
- /**
19
- * Creates a map (object) from an array of items, using a specified property as the key.
20
- *
21
- * This utility transforms an array of objects into a lookup object/dictionary where
22
- * each item in the array becomes a value in the map, indexed by the specified property.
23
- * If multiple items have the same key value, only the last one will be preserved.
24
- *
25
- * @template T The type of items in the input array
26
- * @param array - The input array of items to transform into a map
27
- * @param key - The property name to use as keys in the resulting map (defaults to '_id')
28
- * @returns A record object where keys are values of the specified property and values are the original items
29
- *
30
- * @example
31
- * // Returns { '1': { id: 1, name: 'Item 1' }, '2': { id: 2, name: 'Item 2' } }
32
- * createMap([{ id: 1, name: 'Item 1' }, { id: 2, name: 'Item 2' }], 'id')
33
- */
34
- declare function createMap<T>(array: Array<T>, key?: string): Record<string, T>;
35
-
36
- /**
37
- * Creates a grouped map from an array of items, using a specified property as the key.
38
- *
39
- * This utility transforms an array of objects into a lookup object/dictionary where
40
- * each value is an array of items sharing the same key value. Unlike createMap,
41
- * this function preserves all items with the same key by grouping them in arrays.
42
- *
43
- * @template T The type of items in the input array
44
- * @param array - The input array of items to transform into a grouped map
45
- * @param key - The property name to use as keys in the resulting map (defaults to '_id')
46
- * @returns A record object where keys are values of the specified property and values are arrays of items
47
- *
48
- * @example
49
- * // Returns { 'category1': [{ id: 1, category: 'category1' }, { id: 3, category: 'category1' }],
50
- * // 'category2': [{ id: 2, category: 'category2' }] }
51
- * createMapArray([
52
- * { id: 1, category: 'category1' },
53
- * { id: 2, category: 'category2' },
54
- * { id: 3, category: 'category1' }
55
- * ], 'category')
56
- */
57
- declare function createMapArray<T>(array: Array<T>, key?: string): Record<string, Array<T>>;
58
-
59
- declare function clone<T>(value: T): T;
60
-
61
- /**
62
- * Interface representing the standardized error information structure for Orion errors.
63
- * This is used by the getInfo method to provide consistent error reporting.
64
- */
65
- interface OrionErrorInformation {
66
- /** The error code or identifier */
67
- error: string;
68
- /** Human-readable error message */
69
- message: string;
70
- /** Additional error metadata or context */
71
- extra: any;
72
- /** The sub-type of error. For example for permissions errors it could be 'read', 'write', 'admin' */
73
- type?: string;
74
- }
75
- /**
76
- * Base error class for all Orion-specific errors.
77
- *
78
- * This abstract class provides common properties and methods for all error types
79
- * used in the Orion framework. It's extended by more specific error classes
80
- * like UserError and PermissionsError.
81
- *
82
- * @property isOrionError - Flag indicating this is an Orion error (always true)
83
- * @property isUserError - Flag indicating if this is a user-facing error
84
- * @property isPermissionsError - Flag indicating if this is a permissions-related error
85
- * @property code - Error code for identifying the error type
86
- * @property extra - Additional error context or metadata
87
- */
88
- declare class OrionError extends Error {
89
- isOrionError: boolean;
90
- isUserError: boolean;
91
- isPermissionsError: boolean;
92
- code: string;
93
- extra: any;
94
- /**
95
- * Returns a standardized representation of the error information.
96
- * @returns An object containing error details in a consistent format
97
- */
98
- getInfo: () => OrionErrorInformation;
99
- }
100
-
101
- /**
102
- * Error class for permission-related errors in the Orion framework.
103
- *
104
- * PermissionsError represents authorization failures where a user or client
105
- * attempts to perform an action they don't have permission to execute.
106
- * This is used to distinguish security/permissions errors from other types
107
- * of errors for proper error handling and user feedback.
108
- *
109
- * @extends OrionError
110
- */
111
- declare class PermissionsError extends OrionError {
112
- /**
113
- * Creates a new PermissionsError instance.
114
- *
115
- * @param permissionErrorType - Identifies the specific permission that was violated
116
- * (e.g., 'read', 'write', 'admin')
117
- * @param extra - Additional error context or metadata. Can include a custom message
118
- * via the message property.
119
- *
120
- * @example
121
- * // Basic usage
122
- * throw new PermissionsError('delete_document')
123
- *
124
- * @example
125
- * // With custom message
126
- * throw new PermissionsError('access_admin', { message: 'Admin access required' })
127
- *
128
- * @example
129
- * // With additional context
130
- * throw new PermissionsError('edit_user', {
131
- * userId: 'user123',
132
- * requiredRole: 'admin'
133
- * })
134
- */
135
- constructor(permissionErrorType: any, extra?: any);
136
- }
137
-
138
- /**
139
- * Error class for user-facing errors in the Orion framework.
140
- *
141
- * UserError is designed to represent errors that should be displayed to end users,
142
- * as opposed to system errors or unexpected failures. These errors typically represent
143
- * validation issues, business rule violations, or other expected error conditions.
144
- *
145
- * @extends OrionError
146
- */
147
- declare class UserError extends OrionError {
148
- /**
149
- * Creates a new UserError instance.
150
- *
151
- * @param code - Error code identifier. If only one parameter is provided,
152
- * this will be used as the message and code will default to 'error'.
153
- * @param message - Human-readable error message. Optional if code is provided.
154
- * @param extra - Additional error context or metadata.
155
- *
156
- * @example
157
- * // Basic usage
158
- * throw new UserError('invalid_input', 'The provided email is invalid')
159
- *
160
- * @example
161
- * // Using only a message (code will be 'error')
162
- * throw new UserError('Input validation failed')
163
- *
164
- * @example
165
- * // With extra metadata
166
- * throw new UserError('rate_limit', 'Too many requests', { maxRequests: 100 })
167
- */
168
- constructor(code: string, message?: string, extra?: any);
169
- }
170
-
171
- /**
172
- * @file Exports all error classes used in the Orion framework
173
- */
174
-
175
- /**
176
- * Type guard to check if an error is an OrionError
177
- *
178
- * @param error - Any error object to test
179
- * @returns True if the error is an OrionError instance
180
- *
181
- * @example
182
- * try {
183
- * // some code that might throw
184
- * } catch (error) {
185
- * if (isOrionError(error)) {
186
- * // Handle Orion-specific error
187
- * console.log(error.code, error.getInfo())
188
- * } else {
189
- * // Handle general error
190
- * }
191
- * }
192
- */
193
- declare function isOrionError(error: any): error is OrionError;
194
- /**
195
- * Type guard to check if an error is a UserError
196
- *
197
- * @param error - Any error object to test
198
- * @returns True if the error is a UserError instance
199
- */
200
- declare function isUserError(error: any): error is UserError;
201
- /**
202
- * Type guard to check if an error is a PermissionsError
203
- *
204
- * @param error - Any error object to test
205
- * @returns True if the error is a PermissionsError instance
206
- */
207
- declare function isPermissionsError(error: any): error is PermissionsError;
208
-
209
- /**
210
- * Compose `middleware` returning
211
- * a fully valid middleware comprised
212
- * of all those which are passed.
213
- */
214
- declare function composeMiddlewares(middleware: any): (context: any, next?: any) => Promise<any>;
215
-
216
- /**
217
- * Executes an asynchronous function with automatic retries on failure.
218
- *
219
- * This utility attempts to execute the provided function and automatically
220
- * retries if it fails, with a specified delay between attempts. It will
221
- * continue retrying until either the function succeeds or the maximum
222
- * number of retries is reached.
223
- *
224
- * @template TFunc Type of the function to execute (must return a Promise)
225
- * @param fn - The asynchronous function to execute
226
- * @param retries - The maximum number of retry attempts after the initial attempt
227
- * @param timeout - The delay in milliseconds between retry attempts
228
- * @returns A promise that resolves with the result of the function or rejects with the last error
229
- *
230
- * @example
231
- * // Retry an API call up to 3 times with 1 second between attempts
232
- * const result = await executeWithRetries(
233
- * () => fetchDataFromApi(),
234
- * 3,
235
- * 1000
236
- * );
237
- */
238
- declare function executeWithRetries<TFunc extends () => Promise<any>>(fn: TFunc, retries: number, timeout: number): Promise<ReturnType<TFunc>>;
239
-
240
- declare function generateUUID(): string;
241
- declare function generateUUIDWithPrefix(prefix: string): string;
242
-
243
- /**
244
- * Removes diacritical marks (accents) from text without any other modifications.
245
- * This is the most basic normalization function that others build upon.
246
- *
247
- * @param text - The input string to process
248
- * @returns String with accents removed but otherwise unchanged
249
- */
250
- declare function removeAccentsOnly(text: string): string;
251
- /**
252
- * Normalizes text by removing diacritical marks (accents) and trimming whitespace.
253
- * Builds on removeAccentsOnly and adds whitespace trimming.
254
- *
255
- * @param text - The input string to normalize
256
- * @returns Normalized string with accents removed and whitespace trimmed
257
- */
258
- declare function removeAccentsAndTrim(text: string): string;
259
- /**
260
- * Normalizes text for search purposes by:
261
- * - Removing diacritical marks (accents)
262
- * - Converting to lowercase
263
- * - Trimming whitespace
264
- *
265
- * Builds on removeAccentsAndTrim and adds lowercase conversion.
266
- * Useful for case-insensitive and accent-insensitive text searching.
267
- *
268
- * @param text - The input string to normalize for search
269
- * @returns Search-optimized string in lowercase with accents removed
270
- */
271
- declare function normalizeForSearch(text: string): string;
272
- /**
273
- * Normalizes text for search purposes by:
274
- * - Removing diacritical marks (accents)
275
- * - Converting to lowercase
276
- * - Trimming whitespace
277
- * - Removing all spaces
278
- *
279
- * Builds on normalizeForSearch and removes all whitespace.
280
- * Useful for compact search indexes or when spaces should be ignored in searches.
281
- *
282
- * @param text - The input string to normalize for compact search
283
- * @returns Compact search-optimized string with no spaces
284
- */
285
- declare function normalizeForCompactSearch(text: string): string;
286
- /**
287
- * Normalizes text for search token processing by:
288
- * - Removing diacritical marks (accents)
289
- * - Converting to lowercase
290
- * - Trimming whitespace
291
- * - Replacing all non-alphanumeric characters with spaces
292
- *
293
- * Builds on normalizeForSearch and replaces non-alphanumeric characters with spaces.
294
- * Useful for tokenizing search terms where special characters should be treated as word separators.
295
- *
296
- * @param text - The input string to normalize for tokenized search
297
- * @returns Search token string with only alphanumeric characters and spaces
298
- */
299
- declare function normalizeForSearchToken(text: string): string;
300
- /**
301
- * Normalizes a string specifically for use as a file key (e.g., in S3 or other storage systems).
302
- * Performs the following transformations:
303
- * - Removes accents/diacritical marks
304
- * - Replaces special characters with hyphens
305
- * - Ensures only alphanumeric characters, hyphens, periods, and underscores remain
306
- * - Replaces multiple consecutive hyphens with a single hyphen
307
- * - Removes leading/trailing hyphens
308
- *
309
- * @param text - The input string to normalize for file key usage
310
- * @returns A storage-safe string suitable for use as a file key
311
- */
312
- declare function normalizeForFileKey(text: string): string;
313
-
314
- /**
315
- * Generates an array of search tokens from input text and optional metadata.
316
- *
317
- * This function processes text by:
318
- * 1. Converting it to an array of strings (if not already)
319
- * 2. Filtering out falsy values
320
- * 3. Normalizing each string (removing accents, special characters)
321
- * 4. Splitting by spaces to create individual tokens
322
- * 5. Optionally adding metadata tokens in the format "_key:value"
323
- *
324
- * @param text - String or array of strings to tokenize
325
- * @param meta - Optional metadata object where each key-value pair becomes a token
326
- * @returns Array of normalized search tokens
327
- *
328
- * @example
329
- * // Returns ['hello', 'world']
330
- * getSearchTokens('Hello, World!')
331
- *
332
- * @example
333
- * // Returns ['hello', 'world', '_id:123']
334
- * getSearchTokens('Hello, World!', { id: '123' })
335
- */
336
- declare function getSearchTokens(text: string[] | string, meta?: Record<string, string>): string[];
337
- /**
338
- * Interface for parameters used in generating search queries from tokens.
339
- *
340
- * @property filter - Optional string to filter search results
341
- * @property [key: string] - Additional key-value pairs for metadata filtering
342
- */
343
- interface SearchQueryForTokensParams {
344
- filter?: string;
345
- [key: string]: string;
346
- }
347
- /**
348
- * Options for customizing the search query generation behavior.
349
- * Currently empty but provided for future extensibility.
350
- */
351
- type SearchQueryForTokensOptions = {};
352
- /**
353
- * Generates a MongoDB-compatible query object based on the provided parameters.
354
- *
355
- * This function:
356
- * 1. Processes any filter text into RegExp tokens for prefix matching
357
- * 2. Adds metadata filters based on additional properties in the params object
358
- * 3. Returns a query object with the $all operator for MongoDB queries
359
- *
360
- * @param params - Parameters for generating the search query
361
- * @param _options - Options for customizing search behavior (reserved for future use)
362
- * @returns A MongoDB-compatible query object with format { $all: [...tokens] }
363
- *
364
- * @example
365
- * // Returns { $all: [/^hello/, /^world/] }
366
- * getSearchQueryForTokens({ filter: 'Hello World' })
367
- *
368
- * @example
369
- * // Returns { $all: [/^search/, '_category:books'] }
370
- * getSearchQueryForTokens({ filter: 'search', category: 'books' })
371
- */
372
- declare function getSearchQueryForTokens(params?: SearchQueryForTokensParams, _options?: SearchQueryForTokensOptions): {
373
- $all: (string | RegExp)[];
374
- };
375
-
376
- declare function shortenMongoId(string: string): string;
377
-
378
- export { OrionError, type OrionErrorInformation, PermissionsError, type SearchQueryForTokensOptions, type SearchQueryForTokensParams, UserError, clone, composeMiddlewares, createMap, createMapArray, executeWithRetries, generateId, generateUUID, generateUUIDWithPrefix, getSearchQueryForTokens, getSearchTokens, hashObject, isOrionError, isPermissionsError, isUserError, normalizeForCompactSearch, normalizeForFileKey, normalizeForSearch, normalizeForSearchToken, removeAccentsAndTrim, removeAccentsOnly, shortenMongoId, _default as sleep };