@apify/utilities 2.9.6 → 2.9.8

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.
@@ -0,0 +1,540 @@
1
+ import { Log, Exception } from '@apify/log';
2
+ import { Transform, TransformCallback, Readable, PassThrough } from 'stream';
3
+ import { KeyObject } from 'crypto';
4
+
5
+ /*!
6
+ * This module contains various server utility and helper functions.
7
+ * Note that it automatically exports functions from utilities.client.js
8
+ *
9
+ * Author: Jan Curn (jan@apify.com)
10
+ * Copyright(c) 2015 Apify. All rights reserved.
11
+ *
12
+ */
13
+
14
+ /**
15
+ * Generates a random cryptographically strong string consisting of 17 alphanumeric characters.
16
+ * This string is similar to MongoDB ObjectIds generated by Meteor.
17
+ */
18
+ declare function cryptoRandomObjectId(length?: number): string;
19
+ /**
20
+ * Generates unique, deterministic record ID from the provided key with given length (defaults to 17).
21
+ */
22
+ declare function deterministicUniqueId(key: string, length?: number): string;
23
+ /**
24
+ * Returns a random integer between 0 and max (excluded, unless it is also 0).
25
+ * @param {number} maxExcluded
26
+ * @returns {number}
27
+ */
28
+ declare function getRandomInt(maxExcluded: number): number;
29
+ /**
30
+ * If 'date' is a String, this function converts and returns it as a Date object.
31
+ * Otherwise, the function returns the original 'date' argument.
32
+ * This function is useful to convert dates transfered via JSON which doesn't natively support dates.
33
+ */
34
+ declare function parseDateFromJson(date: string | Date): Date;
35
+ /**
36
+ * Returns a Promise object that will wait a specific number of milliseconds.
37
+ * @param {number} millis Time to wait. If the value is not larger than zero, the promise resolves immediately.
38
+ */
39
+ declare function delayPromise(millis: number): Promise<void>;
40
+ /**
41
+ * Removes an element from an array.
42
+ */
43
+ declare function removeFromArray<T>(array: T[], element: T): boolean;
44
+ interface RequestLike {
45
+ url: string;
46
+ }
47
+ interface ResponseLike {
48
+ status: (code: number) => void;
49
+ send: (payload: string) => void;
50
+ headersSent?: boolean;
51
+ }
52
+ /**
53
+ * A default route for HTTP 404 error page for API endpoints.
54
+ */
55
+ declare function http404Route(req: RequestLike, res: ResponseLike): void;
56
+ /**
57
+ * Default error handler of Express API endpoints.
58
+ */
59
+ declare function expressErrorHandler(err: Error, req: RequestLike, res: ResponseLike, next: (...a: unknown[]) => unknown): unknown;
60
+ type BetterIntervalID = {
61
+ _betterClearInterval: () => void;
62
+ };
63
+ /**
64
+ * Similar to setInterval() but with two important differences:
65
+ * First, it assumes the function is asynchronous and only schedules its next invocation AFTER the asynchronous function finished.
66
+ * Second, it invokes the function immediately.
67
+ * @param func Asynchronous function to be periodically executed. It must take a single argument with a callback that
68
+ * the function must invoke after it's done.
69
+ * @param delay The number of milliseconds to wait to next invocation of the function.
70
+ * @returns Object that can be passed to betterClearInterval()
71
+ */
72
+ declare function betterSetInterval(func: (a: (...args: unknown[]) => unknown) => void, delay: number): BetterIntervalID;
73
+ declare function betterClearInterval(intervalID: BetterIntervalID): void;
74
+ /**
75
+ * Escapes a string so that it can be used in regular expression (e.g. converts "myfile.*" to "myfile\\.\\*").
76
+ */
77
+ declare function escapeRegExp(str: string): string;
78
+ /**
79
+ * String left pad
80
+ */
81
+ declare function leftpad(str: string, len: number, ch?: string | number): string;
82
+ /**
83
+ * Computes weighted average of 2 values.
84
+ */
85
+ declare function weightedAverage(val1: number, weight1: number, val2: number, weight2: number): number;
86
+ /**
87
+ * Checks whether username is listed in FORBIDDEN_USERNAMES
88
+ * or matches any root route path.
89
+ */
90
+ declare function isForbiddenUsername(username: string): boolean;
91
+ /**
92
+ * Executes array of promises in sequence and then returns array where Nth item is result of Nth promise.
93
+ */
94
+ declare function sequentializePromises<T>(promises: (Promise<T> | (() => Promise<T>))[]): Promise<T[]>;
95
+ /**
96
+ * Helper function for validation if parameter is an instance of given prototype or multiple prototypes.
97
+ */
98
+ declare function checkParamPrototypeOrThrow(paramVal: any, paramName: string, prototypes: any, prototypeName: string, isOptional?: boolean): void;
99
+ interface Server {
100
+ removeListener(event: string, cb: (...params: any[]) => any): unknown;
101
+ on(event: string, cb: (...params: any[]) => any): unknown;
102
+ listen(port: number): unknown;
103
+ }
104
+ /**
105
+ * Starts listening at a port specified in the constructor.
106
+ * Unfortunately server.listen() is not a normal function that fails on error, so we need this trickery.
107
+ * Returns a function that calls `server.listen(port)` and resolves once server starts listening.
108
+ *
109
+ * Usage: `promisifyServerListen(server)(1234)`;
110
+ */
111
+ declare function promisifyServerListen<T extends Server>(server: T): (port: number) => Promise<void>;
112
+ declare function configureLogger(givenLog: Log, isProduction?: boolean): void;
113
+ /**
114
+ * Wraps given promise with timeout.
115
+ */
116
+ declare function timeoutPromise<T>(promise: Promise<T>, timeoutMillis: number, errorMessage?: string): Promise<unknown>;
117
+
118
+ /*!
119
+ * This module contains various client-side utility and helper functions.
120
+ *
121
+ * Author: Jan Curn (jan@apify.com)
122
+ * Copyright(c) 2016 Apify. All rights reserved.
123
+ *
124
+ */
125
+ /**
126
+ * Returns true if object equals null or undefined, otherwise returns false.
127
+ */
128
+ declare function isNullOrUndefined(obj: unknown): boolean;
129
+ declare function isBuffer(obj: any): boolean;
130
+ /**
131
+ * Converts Date object to ISO string.
132
+ */
133
+ declare function dateToString(date: Date, middleT: boolean): string;
134
+ /**
135
+ * Ensures a string is shorter than a specified number of character, and truncates it if not,
136
+ * appending a specific suffix to it.
137
+ * @param str
138
+ * @param maxLength
139
+ * @param [suffix] Suffix to be appended to truncated string. Defaults to "...[truncated]".
140
+ */
141
+ declare function truncate(str: string, maxLength: number, suffix?: string): string;
142
+ /**
143
+ * Gets ordinal suffix for a number (e.g. "nd" for 2).
144
+ */
145
+ declare function getOrdinalSuffix(num: number): string;
146
+ interface Uri {
147
+ protocol?: string;
148
+ host?: string;
149
+ path?: string;
150
+ query?: string;
151
+ fragment?: string;
152
+ fragmentKey?: Record<string, unknown>;
153
+ }
154
+ /**
155
+ * @deprecated use `new URL()` instead
156
+ */
157
+ declare function parseUrl(str: string): Uri;
158
+ declare function normalizeUrl(url: string, keepFragment?: boolean): string | null;
159
+ declare function markedSetNofollowLinks(href: string, title: string, text: string): string;
160
+ declare function markedDecreaseHeadsLevel(text: string, level: number): string;
161
+ /**
162
+ * Converts integer version number previously generated by buildNumberToInt() or versionNumberToInt()
163
+ * to string in a form 'MAJOR.MINOR' or 'MAJOR.MINOR.BUILD' in case build number is non-zero.
164
+ */
165
+ declare function buildOrVersionNumberIntToStr(int: number): string | null;
166
+ /**
167
+ * If a property name is invalid for MongoDB or BSON, the function transforms
168
+ * it to a valid form, which can be (most of the time) reversed back using unescapePropertyName().
169
+ * For a detailed list of transformations, see escapeForBson().
170
+ * @private
171
+ */
172
+ declare function escapePropertyName(name: string): string;
173
+ /**
174
+ * Reverses a string transformed using escapePropertyName() back to its original form.
175
+ * Note that the reverse transformation might not be 100% correct for certain unlikely-to-occur strings
176
+ * (e.g. string contain null chars).
177
+ * @private
178
+ */
179
+ declare function unescapePropertyName(name: string): string;
180
+ /**
181
+ * Traverses an object, creates a deep clone if requested and transforms object keys and values using a provided function.
182
+ * The `traverseObject` is recursive, hence if the input object has circular references, the function will run into
183
+ * and infinite recursion and crash the Node.js process.
184
+ * @param obj Object to traverse, it must not contain circular references!
185
+ * @param clone If true, object is not modified but cloned.
186
+ * @param transformFunc Function used to transform the property names na value.
187
+ * It has the following signature: `(key, value) => [key, value]`.
188
+ * Beware that the transformed value is only set if it !== old value.
189
+ * @returns {*}
190
+ * @private
191
+ */
192
+ declare function traverseObject(obj: Record<string, any>, clone: boolean, transformFunc: (key: string, value: unknown) => [string, unknown]): any[] | Record<string, any>;
193
+ /**
194
+ * Transforms an object so that it can be stored to MongoDB or serialized to BSON.
195
+ * It does so by transforming prohibited property names (e.g. names starting with "$",
196
+ * containing "." or null char, equal to "toBSON" or "_bsontype") to equivalent full-width Unicode chars
197
+ * which are normally allowed. To revert this transformation, use unescapeFromBson().
198
+ * @param obj Object to be transformed. It must not contain circular references or any complex types (e.g. Maps, Promises etc.)!
199
+ * @param clone If true, the function transforms a deep clone of the object rather than the original object.
200
+ * @returns {*} Transformed object
201
+ */
202
+ declare function escapeForBson(obj: Record<string, any>, clone?: boolean): any[] | Record<string, any>;
203
+ /**
204
+ * Reverts a transformation of object property names performed by escapeForBson().
205
+ * Note that the reverse transformation might not be 100% equal to the original object
206
+ * for certain unlikely-to-occur property name (e.g. one contain null chars or full-width Unicode chars).
207
+ * @param obj Object to be transformed. It must not contain circular references or any complex types (e.g. Maps, Promises etc.)!
208
+ * @param clone If true, the function transforms a deep clone of the object rather than the original object.
209
+ * @returns {*} Transformed object.
210
+ */
211
+ declare function unescapeFromBson(obj: Record<string, any>, clone?: boolean): Record<string, any>;
212
+ /**
213
+ * Determines whether an object contains property names that cannot be stored to MongoDB.
214
+ * See escapeForBson() for more details.
215
+ * Note that this function only works with objects that are serializable to JSON!
216
+ * @param obj Object to be checked. It must not contain circular references or any complex types (e.g. Maps, Promises etc.)!
217
+ * @returns {boolean} Returns true if object is invalid, otherwise it returns false.
218
+ */
219
+ declare function isBadForMongo(obj: Record<string, any>): boolean;
220
+ declare class JsonVariable {
221
+ readonly name: string;
222
+ constructor(name: string);
223
+ getToken(): string;
224
+ }
225
+ /**
226
+ * Stringifies provided value to JSON with a difference that supports functions that
227
+ * are stringified using .toString() method.
228
+ *
229
+ * In addition to that supports instances of JsonVariable('my.token') that are replaced
230
+ * with a {{my.token}}.
231
+ */
232
+ declare function jsonStringifyExtended(value: Record<string, any>, replacer?: ((k: string, val: unknown) => unknown) | null, space?: number): string;
233
+ /**
234
+ * Splits a full name into the first name and last name, trimming all internal and external spaces.
235
+ * Returns an array with two elements or null if splitting is not possible.
236
+ */
237
+ declare function splitFullName(fullName: string): (string | null)[];
238
+ /**
239
+ * Perform a Regex test on a given URL to see if it is relative.
240
+ */
241
+ declare function isUrlRelative(url: string): boolean;
242
+
243
+ declare class RetryableError extends Error {
244
+ readonly error: Exception;
245
+ constructor(error: Error | Exception, ...args: unknown[]);
246
+ }
247
+ interface RetryableError extends Exception {
248
+ }
249
+ declare function retryWithExpBackoff<T>(params?: {
250
+ func?: (...args: unknown[]) => T;
251
+ expBackoffMillis?: number;
252
+ expBackoffMaxRepeats?: number;
253
+ }): Promise<T>;
254
+
255
+ declare enum CHECK_TYPES {
256
+ MONGODB_PING = "MONGODB_PING",
257
+ MONGODB_READ = "MONGODB_READ",
258
+ MONGODB_WRITE = "MONGODB_WRITE",
259
+ REDIS = "REDIS",
260
+ REDIS_PING = "REDIS_PING",
261
+ REDIS_WRITE = "REDIS_WRITE"
262
+ }
263
+ type CheckType<T extends Record<string, any> = Record<string, any>> = {
264
+ client: T;
265
+ type: CHECK_TYPES;
266
+ };
267
+ interface HealthCheckerOptions {
268
+ checks: CheckType[];
269
+ redisPrefix?: string;
270
+ redisTtlSecs?: number;
271
+ checkTimeoutMillis?: number;
272
+ mongoDbWriteTestCollection?: string;
273
+ mongoDbWriteTestRemoveOlderThanSecs?: number;
274
+ }
275
+ /**
276
+ * Provides health-checking functionality to ensure that connection to Redis and MongoDB is working.
277
+ *
278
+ * Example use:
279
+ *
280
+ * ```javascript
281
+ * const redis = new Redis();
282
+ * const mongo = await MongoClient.connect('mongodb://127.0.0.1:3001/my-db');
283
+ *
284
+ * const checks = [{
285
+ * client: redis,
286
+ * type: HealthChecker.CHECK_TYPES.REDIS,
287
+ * }, {
288
+ * client: mongo.db('my-db'),
289
+ * type: HealthChecker.CHECK_TYPES.MONGODB_READ,
290
+ * }];
291
+ *
292
+ * const checker = new HealthChecker({ checks });
293
+ * setInterval(() => checker.ensureIsHealthy().then(() => console.log('ok'), err => console.log(err)), 5000);
294
+ * ```
295
+ */
296
+ declare class HealthChecker {
297
+ private readonly options;
298
+ static readonly CHECK_TYPES: typeof CHECK_TYPES;
299
+ checks: CheckType[];
300
+ redisPrefix: string;
301
+ redisTtlSecs: number;
302
+ checkTimeoutMillis: number;
303
+ mongoDbWriteTestCollection: string;
304
+ mongoDbWriteTestRemoveOlderThanSecs: number;
305
+ constructor(options: HealthCheckerOptions);
306
+ ensureIsHealthy(): Promise<void>;
307
+ _validateCheck(check: CheckType): void;
308
+ _performCheck(check: CheckType): Promise<void>;
309
+ _testMongoDbPing({ client }: CheckType): Promise<void>;
310
+ _testMongoDbRead({ client }: CheckType): Promise<void>;
311
+ _testMongoDbWrite({ client }: CheckType): Promise<void>;
312
+ _testRedisPing({ client }: CheckType): Promise<void>;
313
+ _testRedisWrite({ client }: CheckType): Promise<void>;
314
+ }
315
+
316
+ /**
317
+ * A transforming stream which accepts string/Buffer data with JSON Lines objects on input
318
+ * and emits 'object' event for every parsed JavaScript objects.
319
+ * The stream passes through the original data.
320
+ * Each JSON object is expected to be on a separate line, some lines might be empty or contain whitespace.
321
+ * After each JSON object there needs to be '\n' or end of stream.
322
+ * This stream is especially useful for processing stream from Docker engine, such as:
323
+ *
324
+ * <pre>
325
+ * {"status":"Preparing","progressDetail":{},"id":"e0380bb6c0bb"}
326
+ * {"status":"Preparing","progressDetail":{},"id":"9f8566ee5135"}
327
+ * {"errorDetail":{"message":"no basic auth credentials"},"error":"no basic auth credentials"}
328
+ * </pre>
329
+ *
330
+ * **WARNING**: You still need to consume the `data` event from the transformed stream,
331
+ * otherwise the internal buffers will get full and the stream might be corked.
332
+ */
333
+ declare class ParseJsonlStream extends Transform {
334
+ private pendingChunk;
335
+ parseLineAndEmitObject(line: string): void;
336
+ _transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void;
337
+ _flush(callback: TransformCallback): void;
338
+ }
339
+
340
+ /**
341
+ * Concat data from stream to Buffer
342
+ */
343
+ declare function concatStreamToBuffer(stream: Readable | PassThrough): Promise<Buffer>;
344
+ /**
345
+ * Flushes the provided stream into a Buffer and transforms
346
+ * it to a String using the provided encoding or utf-8 as default.
347
+ */
348
+ declare function readStreamToString(stream: Readable | PassThrough, encoding?: BufferEncoding): Promise<string>;
349
+
350
+ declare class WebhookPayloadTemplateError extends Error {
351
+ constructor(message?: string);
352
+ }
353
+ declare class InvalidJsonError extends WebhookPayloadTemplateError {
354
+ constructor(originalError: Error);
355
+ }
356
+ declare class InvalidVariableError extends Error {
357
+ constructor(variable?: string);
358
+ }
359
+ /**
360
+ * WebhookPayloadTemplate enables creation and parsing of webhook payload template strings.
361
+ * Template strings are JSON that may include template variables enclosed in double
362
+ * curly brackets: `{{variable}}`. When the template is parsed, variables are replaced
363
+ * with values from a provided context.
364
+ *
365
+ * This is useful to create dynamic webhook payloads where a template is saved on webhook
366
+ * creation and then variables are dynamically added on webhook dispatch.
367
+ *
368
+ * **Example:**
369
+ * ```js
370
+ * const payloadTemplate = `{
371
+ * "id": "some-id",
372
+ * "createdAt": "2019-05-08T15:22:21.095Z",
373
+ * "dataToSend": {{data}}
374
+ * }`
375
+ *
376
+ * const data = {
377
+ * status: 200,
378
+ * body: 'hello world'
379
+ * }
380
+ *
381
+ * const payloadObject = WebhookPayloadTemplate.parse(payloadTemplate, null, { data })
382
+ * ```
383
+ *
384
+ * **Produces:**
385
+ * ```js
386
+ * {
387
+ * id: "some-id",
388
+ * createdAt: '2019-05-08T15:22:21.095Z',
389
+ * dataToSend: {
390
+ * status: 200,
391
+ * body: 'hello world'
392
+ * }
393
+ * }
394
+ * ```
395
+ * @hideconstructor
396
+ */
397
+ declare class WebhookPayloadTemplate {
398
+ private readonly template;
399
+ private readonly allowedVariables;
400
+ private readonly context;
401
+ private payload;
402
+ readonly replacedVariables: {
403
+ variableName: string;
404
+ replacement: string;
405
+ }[];
406
+ constructor(template: string, allowedVariables?: Set<string> | null, context?: Record<string, any>);
407
+ /**
408
+ * Parse existing webhook payload template string into an object, replacing
409
+ * template variables using the provided context.
410
+ *
411
+ * Parse also validates the template structure, so it can be used
412
+ * to check validity of the template JSON and usage of allowedVariables.
413
+ */
414
+ static parse(payloadTemplate: string, allowedVariables?: Set<string> | null, context?: Record<string, any>, options?: {
415
+ interpolateStrings?: boolean;
416
+ }): Record<string, any>;
417
+ /**
418
+ * Stringify an object into a webhook payload template.
419
+ * Values created using `getTemplateVariable('foo.bar')`
420
+ * will be stringified to `{{foo.bar}}` template variable.
421
+ */
422
+ static stringify(objectTemplate: Record<string, any>, replacer?: ((_: any) => string) | null, indent?: number): string;
423
+ /**
424
+ * Produces an instance of a template variable that can be used
425
+ * in objects and will be stringified into `{{variableName}}` syntax.
426
+ *
427
+ * **Example:**
428
+ * ```js
429
+ * const resourceVariable = WebhookPayloadTemplate.getVariable('resource');
430
+ * const objectTemplate = {
431
+ * foo: 'foo',
432
+ * bar: ['bar'],
433
+ * res: resourceVariable,
434
+ * }
435
+ *
436
+ * const payloadTemplate = WebhookPayloadTemplate.stringify(objectTemplate);
437
+ * ```
438
+ *
439
+ * **Produces:**
440
+ * ```json
441
+ * {
442
+ * "foo": "foo",
443
+ * "bar": ["bar"],
444
+ * "res": {{resource}},
445
+ * }
446
+ * ```
447
+ */
448
+ static getVariable(variableName: string): JsonVariable;
449
+ private _parse;
450
+ private _interpolate;
451
+ private _interpolateString;
452
+ private _interpolateObject;
453
+ private _interpolateArray;
454
+ private _findPositionOfNextVariable;
455
+ private _isVariableInsideString;
456
+ private _countUnescapedDoubleQuotesUpToIndex;
457
+ private _replaceVariable;
458
+ private _validateVariableName;
459
+ private _getVariableValue;
460
+ private _getVariableReplacement;
461
+ }
462
+
463
+ type DecryptOptions = {
464
+ privateKey: KeyObject;
465
+ encryptedPassword: string;
466
+ encryptedValue: string;
467
+ };
468
+ type EncryptOptions = {
469
+ publicKey: KeyObject;
470
+ value: string;
471
+ };
472
+ /**
473
+ * It encrypts the given value using AES cipher and the password for encryption using the public key.
474
+ * NOTE: The encryption password is a string of encryption key and initial vector used for cipher.
475
+ * It returns the encrypted password and encrypted value in BASE64 format.
476
+ *
477
+ * @param publicKey {KeyObject} Public key used for encryption
478
+ * @param value {string} Value to be encrypted
479
+ * @returns {Object<encryptedPassword, encryptedValue>}
480
+ */
481
+ declare function publicEncrypt({ publicKey, value }: EncryptOptions): {
482
+ encryptedPassword: string;
483
+ encryptedValue: string;
484
+ };
485
+ /**
486
+ * It decrypts encrypted password using private key
487
+ * and uses the password(consists of encrypted key and initial vector)
488
+ * to decrypt the encrypted value.
489
+ *
490
+ * @param privateKey {KeyObject} Private key used for decryption
491
+ * @param encryptedPassword {string} Password in Base64 encrypted using private key
492
+ * @param encryptedValue {string} Content in Base64 encrypted using AES cipher
493
+ * @returns {string}
494
+ */
495
+ declare function privateDecrypt({ privateKey, encryptedPassword, encryptedValue, }: DecryptOptions): string;
496
+
497
+ /**
498
+ * Extract import statements from the code.
499
+ */
500
+ declare function separateImports(code: string): {
501
+ code: string;
502
+ imports: string;
503
+ };
504
+
505
+ declare enum CodeHashMetaKey {
506
+ VERSION = "v",
507
+ USER = "u"
508
+ }
509
+ /**
510
+ * Allows hashing of an Actor input together with some metadata into a shareable link for the "Run on Apify" button.
511
+ * Uses a common secret for checking the signatures.
512
+ *
513
+ * The hash consists of 3 parts separated by a dot, as in `ABC.DEF.GHI`, each being a base64url encoded string:
514
+ * - `meta` object with the `version` and `user` properties.
515
+ * - `data` data object (the one that gets encoded)
516
+ * - `signature` used for verification of the URL hash, computed from the `meta` and `data` objects
517
+ */
518
+ declare class CodeHashManager {
519
+ private readonly secret;
520
+ static readonly SECTION_SEPARATOR = ".";
521
+ static readonly VERSION = 1;
522
+ constructor(secret: string);
523
+ /**
524
+ * Encodes object (e.g. input for actor) to a string hash and uses the `secret` to sign the hash.
525
+ */
526
+ encode<T extends object>(data: T, userId: string): string;
527
+ decode(urlHash: string): {
528
+ data: any;
529
+ meta: {
530
+ userId: any;
531
+ version: any;
532
+ isSignatureValid: boolean;
533
+ };
534
+ };
535
+ private toBase64;
536
+ private fromBase64;
537
+ private generateSignature;
538
+ }
539
+
540
+ export { type BetterIntervalID, CHECK_TYPES, CodeHashManager, CodeHashMetaKey, HealthChecker, InvalidJsonError, InvalidVariableError, JsonVariable, ParseJsonlStream, RetryableError, WebhookPayloadTemplate, betterClearInterval, betterSetInterval, buildOrVersionNumberIntToStr, checkParamPrototypeOrThrow, concatStreamToBuffer, configureLogger, cryptoRandomObjectId, dateToString, delayPromise, deterministicUniqueId, escapeForBson, escapePropertyName, escapeRegExp, expressErrorHandler, getOrdinalSuffix, getRandomInt, http404Route, isBadForMongo, isBuffer, isForbiddenUsername, isNullOrUndefined, isUrlRelative, jsonStringifyExtended, leftpad, markedDecreaseHeadsLevel, markedSetNofollowLinks, normalizeUrl, parseDateFromJson, parseUrl, privateDecrypt, promisifyServerListen, publicEncrypt, readStreamToString, removeFromArray, retryWithExpBackoff, separateImports, sequentializePromises, splitFullName, timeoutPromise, traverseObject, truncate, unescapeFromBson, unescapePropertyName, weightedAverage };