@lokalise/node-core 12.5.1 → 13.0.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.
Files changed (85) hide show
  1. package/dist/index.cjs +985 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +404 -0
  4. package/dist/index.d.ts +404 -29
  5. package/dist/index.js +893 -78
  6. package/dist/index.js.map +1 -1
  7. package/package.json +13 -7
  8. package/dist/src/common/commonTypes.d.ts +0 -1
  9. package/dist/src/common/commonTypes.js +0 -3
  10. package/dist/src/common/commonTypes.js.map +0 -1
  11. package/dist/src/common/may-omit.d.ts +0 -1
  12. package/dist/src/common/may-omit.js +0 -3
  13. package/dist/src/common/may-omit.js.map +0 -1
  14. package/dist/src/config/ConfigScope.d.ts +0 -34
  15. package/dist/src/config/ConfigScope.js +0 -173
  16. package/dist/src/config/ConfigScope.js.map +0 -1
  17. package/dist/src/config/configTransformers.d.ts +0 -2
  18. package/dist/src/config/configTransformers.js +0 -15
  19. package/dist/src/config/configTransformers.js.map +0 -1
  20. package/dist/src/config/configTypes.d.ts +0 -30
  21. package/dist/src/config/configTypes.js +0 -3
  22. package/dist/src/config/configTypes.js.map +0 -1
  23. package/dist/src/config/configValidators.d.ts +0 -2
  24. package/dist/src/config/configValidators.js +0 -10
  25. package/dist/src/config/configValidators.js.map +0 -1
  26. package/dist/src/errors/InternalError.d.ts +0 -16
  27. package/dist/src/errors/InternalError.js +0 -29
  28. package/dist/src/errors/InternalError.js.map +0 -1
  29. package/dist/src/errors/PublicNonRecoverableError.d.ts +0 -21
  30. package/dist/src/errors/PublicNonRecoverableError.js +0 -34
  31. package/dist/src/errors/PublicNonRecoverableError.js.map +0 -1
  32. package/dist/src/errors/either.d.ts +0 -28
  33. package/dist/src/errors/either.js +0 -16
  34. package/dist/src/errors/either.js.map +0 -1
  35. package/dist/src/errors/errorReporterTypes.d.ts +0 -14
  36. package/dist/src/errors/errorReporterTypes.js +0 -3
  37. package/dist/src/errors/errorReporterTypes.js.map +0 -1
  38. package/dist/src/errors/errorTypeGuards.d.ts +0 -2
  39. package/dist/src/errors/errorTypeGuards.js +0 -8
  40. package/dist/src/errors/errorTypeGuards.js.map +0 -1
  41. package/dist/src/errors/globalErrorHandler.d.ts +0 -13
  42. package/dist/src/errors/globalErrorHandler.js +0 -77
  43. package/dist/src/errors/globalErrorHandler.js.map +0 -1
  44. package/dist/src/errors/publicErrors.d.ts +0 -27
  45. package/dist/src/errors/publicErrors.js +0 -66
  46. package/dist/src/errors/publicErrors.js.map +0 -1
  47. package/dist/src/errors/types.d.ts +0 -1
  48. package/dist/src/errors/types.js +0 -3
  49. package/dist/src/errors/types.js.map +0 -1
  50. package/dist/src/logging/commonLogger.d.ts +0 -17
  51. package/dist/src/logging/commonLogger.js +0 -3
  52. package/dist/src/logging/commonLogger.js.map +0 -1
  53. package/dist/src/logging/loggerConfigResolver.d.ts +0 -15
  54. package/dist/src/logging/loggerConfigResolver.js +0 -70
  55. package/dist/src/logging/loggerConfigResolver.js.map +0 -1
  56. package/dist/src/observability/MultiTransactionObservabilityManager.d.ts +0 -12
  57. package/dist/src/observability/MultiTransactionObservabilityManager.js +0 -30
  58. package/dist/src/observability/MultiTransactionObservabilityManager.js.map +0 -1
  59. package/dist/src/observability/observabilityTypes.d.ts +0 -23
  60. package/dist/src/observability/observabilityTypes.js +0 -3
  61. package/dist/src/observability/observabilityTypes.js.map +0 -1
  62. package/dist/src/utils/arrayUtils.d.ts +0 -14
  63. package/dist/src/utils/arrayUtils.js +0 -47
  64. package/dist/src/utils/arrayUtils.js.map +0 -1
  65. package/dist/src/utils/checksumUtils.d.ts +0 -5
  66. package/dist/src/utils/checksumUtils.js +0 -37
  67. package/dist/src/utils/checksumUtils.js.map +0 -1
  68. package/dist/src/utils/encryptionUtility.d.ts +0 -20
  69. package/dist/src/utils/encryptionUtility.js +0 -58
  70. package/dist/src/utils/encryptionUtility.js.map +0 -1
  71. package/dist/src/utils/hashUtils.d.ts +0 -9
  72. package/dist/src/utils/hashUtils.js +0 -19
  73. package/dist/src/utils/hashUtils.js.map +0 -1
  74. package/dist/src/utils/objectUtils.d.ts +0 -55
  75. package/dist/src/utils/objectUtils.js +0 -195
  76. package/dist/src/utils/objectUtils.js.map +0 -1
  77. package/dist/src/utils/streamUtils.d.ts +0 -37
  78. package/dist/src/utils/streamUtils.js +0 -85
  79. package/dist/src/utils/streamUtils.js.map +0 -1
  80. package/dist/src/utils/typeUtils.d.ts +0 -10
  81. package/dist/src/utils/typeUtils.js +0 -19
  82. package/dist/src/utils/typeUtils.js.map +0 -1
  83. package/dist/src/utils/waitUtils.d.ts +0 -1
  84. package/dist/src/utils/waitUtils.js +0 -34
  85. package/dist/src/utils/waitUtils.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,29 +1,404 @@
1
- export type { ErrorDetails } from './src/errors/types';
2
- export { PublicNonRecoverableError, isPublicNonRecoverableError, type PublicNonRecoverableErrorParams, } from './src/errors/PublicNonRecoverableError';
3
- export { InternalError, isInternalError, type InternalErrorParams, } from './src/errors/InternalError';
4
- export { isEntityGoneError } from './src/errors/errorTypeGuards';
5
- export { ConfigScope } from './src/config/ConfigScope';
6
- export { ensureClosingSlashTransformer } from './src/config/configTransformers';
7
- export { createRangeValidator } from './src/config/configValidators';
8
- export { type EnvValueValidator, type EnvValueTransformer, type AppConfig, type RedisConfig, } from './src/config/configTypes';
9
- export { type Either, type DefiniteEither, success, failure, isSuccess, isFailure, } from './src/errors/either';
10
- export { EncryptionUtility } from './src/utils/encryptionUtility';
11
- export { chunk, callChunked, removeFalsy, removeNullish, removeDuplicates, } from './src/utils/arrayUtils';
12
- export { groupBy, groupByPath, groupByUnique, pick, pickWithoutUndefined, copyWithoutUndefined, copyWithoutEmpty, isEmptyObject, convertDateFieldsToIsoString, deepClone, } from './src/utils/objectUtils';
13
- export { isError, isStandardizedError, isObject, hasMessage, } from './src/utils/typeUtils';
14
- export { type StandardizedError } from './src/utils/typeUtils';
15
- export { generateHash, HashAlgorithm, HashEncoding } from './src/utils/hashUtils';
16
- export { resolveLoggerConfiguration, resolveMonorepoLoggerConfiguration, resolveLogger, resolveMonorepoLogger, } from './src/logging/loggerConfigResolver';
17
- export type { AppLoggerConfig, MonorepoAppLoggerConfig } from './src/logging/loggerConfigResolver';
18
- export type { CommonLogger } from './src/logging/commonLogger';
19
- export { type ErrorReport, type ErrorReporter, type ErrorResolver, } from './src/errors/errorReporterTypes';
20
- export { executeAsyncAndHandleGlobalErrors, executeAndHandleGlobalErrors, executeSettleAllAndHandleGlobalErrors, globalLogger, resolveGlobalErrorLogObject, } from './src/errors/globalErrorHandler';
21
- export { type MayOmit } from './src/common/may-omit';
22
- export { type FreeformRecord } from './src/common/commonTypes';
23
- export { type ValidationError, type CommonErrorParams, type OptionalMessageErrorParams, RequestValidationError, AccessDeniedError, EntityNotFoundError, EntityGoneError, AuthFailedError, } from './src/errors/publicErrors';
24
- export { waitAndRetry } from './src/utils/waitUtils';
25
- export type { TransactionObservabilityManager } from './src/observability/observabilityTypes';
26
- export { MultiTransactionObservabilityManager } from './src/observability/MultiTransactionObservabilityManager';
27
- export { generateChecksumForReadable, generateChecksumForObject, generateChecksumForBufferOrString, } from './src/utils/checksumUtils';
28
- export { FsReadableProvider } from './src/utils/streamUtils';
29
- export type { PersistToFsOptions, ReadableProvider, FsReadableProviderOptions, } from './src/utils/streamUtils';
1
+ import { ZodSchema } from 'zod';
2
+ import { redactOptions, Logger, LoggerOptions, BaseLogger, Bindings, ChildLoggerOptions, SerializedError } from 'pino';
3
+ import { BinaryLike } from 'node:crypto';
4
+ import { Readable } from 'node:stream';
5
+
6
+ type ErrorDetails = Record<string, unknown>;
7
+
8
+ type PublicNonRecoverableErrorParams<T = ErrorDetails> = {
9
+ message: string;
10
+ errorCode: string;
11
+ details?: T;
12
+ httpStatusCode?: number;
13
+ cause?: unknown;
14
+ };
15
+ declare const publicNonRecoverableErrorSymbol: unique symbol;
16
+ /**
17
+ * This error is returned to the consumer of API
18
+ */
19
+ declare class PublicNonRecoverableError<T = ErrorDetails> extends Error {
20
+ readonly [publicNonRecoverableErrorSymbol] = true;
21
+ readonly details?: T;
22
+ readonly errorCode: string;
23
+ readonly httpStatusCode: number;
24
+ constructor(params: PublicNonRecoverableErrorParams<T>);
25
+ }
26
+ declare function isPublicNonRecoverableError(error: unknown): error is PublicNonRecoverableError;
27
+
28
+ type InternalErrorParams<T = ErrorDetails> = {
29
+ message: string;
30
+ errorCode: string;
31
+ details?: T;
32
+ cause?: unknown;
33
+ };
34
+ declare const internalErrorSymbol: unique symbol;
35
+ declare class InternalError<T = ErrorDetails> extends Error {
36
+ readonly [internalErrorSymbol] = true;
37
+ readonly details?: T;
38
+ readonly errorCode: string;
39
+ constructor(params: InternalErrorParams<T>);
40
+ }
41
+ declare function isInternalError(error: unknown): error is InternalError;
42
+
43
+ type FreeformRecord = Record<string, any>;
44
+
45
+ type CommonErrorParams = {
46
+ message: string;
47
+ details?: FreeformRecord;
48
+ cause?: Error;
49
+ };
50
+ type OptionalMessageErrorParams = Partial<CommonErrorParams>;
51
+ type ValidationError = {
52
+ message: string;
53
+ path: string[];
54
+ };
55
+ declare class RequestValidationError extends PublicNonRecoverableError {
56
+ constructor(errors: ValidationError[]);
57
+ }
58
+ declare class AccessDeniedError extends PublicNonRecoverableError {
59
+ constructor(params: CommonErrorParams);
60
+ }
61
+ declare class EntityNotFoundError extends PublicNonRecoverableError {
62
+ constructor(params: CommonErrorParams);
63
+ }
64
+ declare class EntityGoneError extends PublicNonRecoverableError {
65
+ constructor(params: CommonErrorParams);
66
+ }
67
+ declare class AuthFailedError extends PublicNonRecoverableError {
68
+ constructor(params?: OptionalMessageErrorParams);
69
+ }
70
+
71
+ declare function isEntityGoneError(entity: unknown): entity is EntityGoneError;
72
+
73
+ type EnvValueValidator<InputType> = (value: InputType) => boolean;
74
+ type EnvValueTransformer<InputType, OutputType> = (value: InputType) => OutputType;
75
+ type RedisConfig = {
76
+ host: string;
77
+ /**
78
+ * An integer from 0 to 15, inclusive
79
+ */
80
+ db?: number;
81
+ keyPrefix?: string;
82
+ port: number;
83
+ username?: string;
84
+ password?: string;
85
+ commandTimeout?: number;
86
+ connectTimeout?: number;
87
+ /**
88
+ * Set this option explicitly to null for infinite retries
89
+ * By default (for undefined) there are 20 retries, see: https://redis.github.io/ioredis/interfaces/CommonRedisOptions.html#maxRetriesPerRequest
90
+ */
91
+ maxRetriesPerRequest?: number | null;
92
+ enableReadyCheck?: boolean;
93
+ lazyConnect?: boolean;
94
+ useTls: boolean;
95
+ };
96
+ type AppConfig = {
97
+ port: number;
98
+ bindAddress: string;
99
+ logLevel: string;
100
+ nodeEnv: 'production' | 'development' | 'test';
101
+ appEnv: 'production' | 'development' | 'staging';
102
+ };
103
+
104
+ type EnvType = {
105
+ [key: string]: string | undefined;
106
+ };
107
+ declare class ConfigScope {
108
+ private env;
109
+ constructor(envOverride?: EnvType);
110
+ updateEnv(): void;
111
+ getMandatoryInteger(param: string): number;
112
+ getMandatory(param: string): string;
113
+ getMandatoryOneOf<const T>(param: string, supportedValues: T[]): T;
114
+ getMandatoryValidatedInteger(param: string, validator: EnvValueValidator<number>): number;
115
+ getOptionalNullable<T extends string | null | undefined>(param: string, defaultValue: T): T | string;
116
+ getOptional(param: string, defaultValue: string): string;
117
+ getOptionalInteger(param: string, defaultValue: number): number;
118
+ getOptionalNullableInteger<T extends number | null | undefined>(param: string, defaultValue: T): T | number;
119
+ getOptionalOneOf<const T extends string>(param: string, defaultValue: T, supportedValues: T[]): T;
120
+ getOptionalValidated(param: string, defaultValue: string, validator: EnvValueValidator<string>): string;
121
+ getOptionalValidatedInteger(param: string, defaultValue: number, validator: EnvValueValidator<number>): number;
122
+ getOptionalTransformed(param: string, defaultValue: string, transformer: (value: string) => string): string;
123
+ getOptionalNullableTransformed<T extends string | undefined>(param: string, defaultValue: T, transformer: (value: T | string) => T | string): T | string;
124
+ getMandatoryTransformed(param: string, transformer: (value: string) => string): string;
125
+ getOptionalBoolean(param: string, defaultValue: boolean): boolean;
126
+ getMandatoryJsonObject<T extends object>(param: string, schema: ZodSchema<T>): T;
127
+ getOptionalNullableJsonObject<T extends object, Z extends T | null | undefined>(param: string, schema: ZodSchema<T>, defaultValue: Z): Z;
128
+ getOptionalJsonObject<T extends object>(param: string, schema: ZodSchema<T>, defaultValue: T): T;
129
+ isProduction(): boolean;
130
+ isDevelopment(): boolean;
131
+ isTest(): boolean;
132
+ private validateSchema;
133
+ }
134
+
135
+ declare const ensureClosingSlashTransformer: EnvValueTransformer<string | undefined | null, string>;
136
+
137
+ declare const createRangeValidator: (greaterOrEqualThan: number, lessOrEqualThan: number) => EnvValueValidator<number>;
138
+
139
+ type Left<T> = {
140
+ error: T;
141
+ result?: never;
142
+ };
143
+ type Right<U> = {
144
+ error?: never;
145
+ result: U;
146
+ };
147
+ /**
148
+ * Either is a functional programming type which is used to communicate errors happening in potentially recoverable scenarios.
149
+ * It can return either an error (Left side) or a resolved result (Right side), but not both.
150
+ * It is up to caller of the function to handle received error or throw (Public)NonRecoverableError if it cannot.
151
+ *
152
+ * @see {@link https://antman-does-software.com/stop-catching-errors-in-typescript-use-the-either-type-to-make-your-code-predictable Further reading on motivation for Either type}
153
+ */
154
+ type Either<T, U> = NonNullable<Left<T> | Right<U>>;
155
+ /***
156
+ * Variation of Either, which may or may not have Error set, but always has Result
157
+ */
158
+ type DefiniteEither<T, U> = {
159
+ error?: T;
160
+ result: U;
161
+ };
162
+ declare const isFailure: <T, U>(e: Either<T, U>) => e is Left<T>;
163
+ declare const isSuccess: <T, U>(e: Either<T, U>) => e is Right<U>;
164
+ declare const failure: <T>(error: T) => Left<T>;
165
+ declare const success: <U>(result: U) => Right<U>;
166
+
167
+ type Options = {
168
+ saltLength?: number;
169
+ pbkdf2Iterations?: number;
170
+ encoding?: NodeJS.BufferEncoding;
171
+ };
172
+ /**
173
+ * Type-scripted version of https://github.com/MauriceButler/cryptr
174
+ */
175
+ declare class EncryptionUtility {
176
+ private readonly secret;
177
+ private readonly saltLength;
178
+ private readonly encryptedPosition;
179
+ private readonly tagPosition;
180
+ private readonly pbkdf2Iterations;
181
+ private readonly encoding;
182
+ constructor(secret: string, options?: Options);
183
+ private getKey;
184
+ encrypt(value: string): string;
185
+ decrypt(value: string): string;
186
+ }
187
+
188
+ declare function chunk<T>(array: T[], chunkSize: number): T[][];
189
+ declare function callChunked<Item>(chunkSize: number, array: readonly Item[], processFn: (arrayChunk: Item[]) => Promise<unknown>): Promise<void>;
190
+ /**
191
+ * Return a copy of the given array without null or undefined values
192
+ */
193
+ declare function removeNullish<const T>(array: readonly (T | null | undefined)[]): T[];
194
+ /**
195
+ * Return a copy of the given array without falsy values (eg: false, 0, '', null, undefined)
196
+ */
197
+ declare function removeFalsy<const T>(array: readonly (T | null | undefined | 0 | '' | false)[]): T[];
198
+ /**
199
+ * Return a copy of the given array without duplicates.
200
+ */
201
+ declare function removeDuplicates<const T>(array: readonly T[]): T[];
202
+
203
+ type RecordKeyType = string | number | symbol;
204
+ declare function copyWithoutUndefined<T extends Record<RecordKeyType, unknown>, TargetRecordType = Pick<T, {
205
+ [Prop in keyof T]: T[Prop] extends null | undefined ? never : Prop;
206
+ }[keyof T]>>(originalValue: T): TargetRecordType;
207
+ declare function copyWithoutEmpty<T extends Record<RecordKeyType, unknown>, TargetRecordType = Pick<T, {
208
+ [Prop in keyof T]: T[Prop] extends null | undefined | '' ? never : Prop;
209
+ }[keyof T]>>(originalValue: T): TargetRecordType;
210
+ declare function pick<T, K extends string | number | symbol>(source: T, propNames: readonly K[]): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
211
+ declare function pickWithoutUndefined<T, K extends string | number | symbol>(source: T, propNames: readonly K[]): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
212
+ declare function isEmptyObject(params: Record<string, unknown>): boolean;
213
+ type KeysMatching<T, V> = {
214
+ [K in keyof T]: T[K] extends V ? K : never;
215
+ }[keyof T];
216
+ /**
217
+ * @param array The array of objects to be grouped.
218
+ * @param selector The key used for grouping the objects.
219
+ * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.
220
+ */
221
+ declare function groupBy<T extends object, K extends KeysMatching<T, RecordKeyType | null | undefined>>(array: T[], selector: K): Record<RecordKeyType, T[]>;
222
+ /**
223
+ * @param array The array of objects to be grouped.
224
+ * @param selector The key used for grouping the objects. Support nested keys.
225
+ * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.
226
+ */
227
+ declare function groupByPath<T extends object>(array: T[], selector: string): Record<string, T[]>;
228
+ /**
229
+ * @param array The array of objects to be grouped.
230
+ * @param selector The key used for grouping the objects.
231
+ * @returns An object where the keys are unique values from the given selector and the value is the
232
+ * corresponding object from the array.
233
+ * @throws InternalError If a duplicated value is found for the given selector.
234
+ */
235
+ declare function groupByUnique<T extends object, K extends KeysMatching<T, RecordKeyType | null | undefined>>(array: T[], selector: K): Record<RecordKeyType, T>;
236
+ type DatesAsString<T> = T extends Date ? string : ExactlyLikeWithDateAsString<T>;
237
+ type ExactlyLikeWithDateAsString<T> = T extends object ? {
238
+ [K in keyof T]: DatesAsString<T[K]>;
239
+ } : T;
240
+ declare function convertDateFieldsToIsoString<Input extends object>(object: Input): ExactlyLikeWithDateAsString<Input>;
241
+ declare function convertDateFieldsToIsoString<Input extends object>(object: Input[]): ExactlyLikeWithDateAsString<Input>[];
242
+ /**
243
+ * Return a deep clone copy of an object.
244
+ *
245
+ * Please Note: This uses structuredClone, which has the limitations of these restricted Types: functions,
246
+ * Error objects, WeakMap, WeakSet, DOM nodes, and certain other browser-specific objects like Window.
247
+ */
248
+ declare function deepClone<T extends object | undefined | null>(object: T): T;
249
+
250
+ type StandardizedError = {
251
+ code: string;
252
+ message: string;
253
+ };
254
+ declare function hasMessage(maybe: unknown): maybe is {
255
+ message: string;
256
+ };
257
+ declare function isObject(maybeObject: unknown): maybeObject is Record<PropertyKey, unknown>;
258
+ declare function isStandardizedError(error: unknown): error is StandardizedError;
259
+ declare function isError(maybeError: unknown): maybeError is Error;
260
+
261
+ declare enum HashEncoding {
262
+ HEX = "hex",
263
+ BASE64 = "base64"
264
+ }
265
+ declare enum HashAlgorithm {
266
+ SHA256 = "sha256",
267
+ SHA512 = "sha512"
268
+ }
269
+ declare function generateHash(algorithm: HashAlgorithm, data: string, encoding?: HashEncoding): string;
270
+
271
+ type AppLoggerConfig = {
272
+ logLevel: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
273
+ nodeEnv: 'production' | 'development' | 'test';
274
+ base?: Record<string, unknown>;
275
+ redact?: redactOptions;
276
+ };
277
+ type MonorepoAppLoggerConfig = AppLoggerConfig & {
278
+ targetFile?: string;
279
+ append?: boolean;
280
+ };
281
+ declare function resolveMonorepoLogger(appConfig: MonorepoAppLoggerConfig): Logger;
282
+ declare function resolveMonorepoLoggerConfiguration(appConfig: MonorepoAppLoggerConfig): LoggerOptions | Logger;
283
+ declare function resolveLogger(appConfig: AppLoggerConfig): Logger;
284
+ declare function resolveLoggerConfiguration(appConfig: AppLoggerConfig): LoggerOptions | Logger;
285
+
286
+ type CommonLogger = BaseLogger & {
287
+ /**
288
+ * Creates a child logger, setting all key-value pairs in `bindings` as properties in the log lines. All serializers will be applied to the given pair.
289
+ * Child loggers use the same output stream as the parent and inherit the current log level of the parent at the time they are spawned.
290
+ * If a `level` property is present in the object passed to `child` it will override the child logger level.
291
+ *
292
+ * @param bindings: an object of key-value pairs to include in log lines as properties.
293
+ * @param options: an options object that will override child logger inherited options.
294
+ * @returns a child logger instance.
295
+ */
296
+ child(bindings: Bindings, options?: ChildLoggerOptions): CommonLogger;
297
+ /**
298
+ * A utility method for determining if a given log level will write to the destination.
299
+ */
300
+ isLevelEnabled(level: string): boolean;
301
+ };
302
+
303
+ /**
304
+ * Generic interface for resolving specific kind of errors based on something that was thrown during execution
305
+ */
306
+ type ErrorResolver = {
307
+ processError: (thrownError: unknown) => InternalError;
308
+ };
309
+ interface ErrorReport {
310
+ error: Error;
311
+ context?: Record<string, unknown>;
312
+ }
313
+ type ErrorReporter = {
314
+ report: (errorReport: ErrorReport) => void;
315
+ };
316
+
317
+ type LogObject = {
318
+ message: string;
319
+ 'x-request-id'?: string;
320
+ error?: SerializedError;
321
+ };
322
+ declare const globalLogger: CommonLogger;
323
+ declare function resolveGlobalErrorLogObject(err: unknown, correlationId?: string): LogObject;
324
+ declare function executeAndHandleGlobalErrors<T>(operation: () => T): T;
325
+ declare function executeAsyncAndHandleGlobalErrors<T>(operation: () => Promise<T>, stopOnError?: boolean): Promise<T | undefined>;
326
+ declare function executeSettleAllAndHandleGlobalErrors(promises: Promise<unknown>[], stopOnError?: boolean): Promise<PromiseSettledResult<unknown>[]>;
327
+
328
+ type MayOmit<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
329
+
330
+ declare const waitAndRetry: <T>(predicateFn: () => T, sleepTime?: number, maxRetryCount?: number) => Promise<T>;
331
+
332
+ type TransactionObservabilityManager = {
333
+ /**
334
+ * Creates and starts a background transaction to record work done
335
+ *
336
+ * @param transactionName - used for grouping similar transactions together
337
+ * @param uniqueTransactionKey - used for identifying specific ongoing transaction. Must be reasonably unique to reduce possibility of collisions
338
+ */
339
+ start: (transactionName: string, uniqueTransactionKey: string) => unknown;
340
+ /**
341
+ * Creates and starts a background transaction to record work done, and relates it to a specified group
342
+ *
343
+ * @param transactionName - used for grouping similar transactions together
344
+ * @param uniqueTransactionKey - used for identifying specific ongoing transaction. Must be reasonably unique to reduce possibility of collisions *
345
+ * @param transactionGroup - group is used for grouping related transactions with different names
346
+ */
347
+ startWithGroup: (transactionName: string, uniqueTransactionKey: string, transactionGroup: string) => void;
348
+ /**
349
+ * Ends the transaction
350
+ * @param uniqueTransactionKey - used for identifying specific ongoing transaction. Must be reasonably unique to reduce possibility of collisions
351
+ * @param wasSuccessful - indicates if the transaction was successful or not
352
+ */
353
+ stop: (uniqueTransactionKey: string, wasSuccessful?: boolean) => unknown;
354
+ };
355
+
356
+ /**
357
+ * Groups different TransactionObservabilityManager instances into one
358
+ * to facilitate tracking transactions across multiple observability tools.
359
+ */
360
+ declare class MultiTransactionObservabilityManager implements TransactionObservabilityManager {
361
+ private readonly managers;
362
+ constructor(managers: TransactionObservabilityManager[]);
363
+ start(transactionName: string, uniqueTransactionKey: string): void;
364
+ startWithGroup(transactionName: string, uniqueTransactionKey: string, transactionGroup: string): void;
365
+ stop(uniqueTransactionKey: string, wasSuccessful?: boolean): void;
366
+ }
367
+
368
+ declare function generateChecksumForBufferOrString(data: BinaryLike): string;
369
+ declare function generateChecksumForObject(object: object): string;
370
+ declare function generateChecksumForReadable(readable: Readable): Promise<string>;
371
+
372
+ type ReadableProvider = {
373
+ /**
374
+ * Guarantees to provide a new stream every time this is called, before `destroy` is invoked.
375
+ */
376
+ createStream(): Promise<Readable>;
377
+ /**
378
+ * Returns size of the persisted content
379
+ */
380
+ getContentLength(): Promise<number>;
381
+ /**
382
+ * Remove the persisted value. No new streams can be created after this is called
383
+ */
384
+ destroy(): Promise<void>;
385
+ };
386
+ type PersistToFsOptions = {
387
+ targetFile: string;
388
+ sourceReadable: Readable;
389
+ };
390
+ type FsReadableProviderOptions = {
391
+ storageFile: string;
392
+ };
393
+ declare class FsReadableProvider implements ReadableProvider {
394
+ readonly storageFile: string;
395
+ constructor(options: FsReadableProviderOptions);
396
+ fileExists(): Promise<boolean>;
397
+ getContentLength(): Promise<number>;
398
+ createStream(): Promise<Readable>;
399
+ destroy(): Promise<void>;
400
+ protected persist(sourceReadable: Readable): Promise<void>;
401
+ static persistReadableToFs(options: PersistToFsOptions): Promise<FsReadableProvider>;
402
+ }
403
+
404
+ export { AccessDeniedError, type AppConfig, type AppLoggerConfig, AuthFailedError, type CommonErrorParams, type CommonLogger, ConfigScope, type DefiniteEither, type Either, EncryptionUtility, EntityGoneError, EntityNotFoundError, type EnvValueTransformer, type EnvValueValidator, type ErrorDetails, type ErrorReport, type ErrorReporter, type ErrorResolver, type FreeformRecord, FsReadableProvider, type FsReadableProviderOptions, HashAlgorithm, HashEncoding, InternalError, type InternalErrorParams, type MayOmit, type MonorepoAppLoggerConfig, MultiTransactionObservabilityManager, type OptionalMessageErrorParams, type PersistToFsOptions, PublicNonRecoverableError, type PublicNonRecoverableErrorParams, type ReadableProvider, type RedisConfig, RequestValidationError, type StandardizedError, type TransactionObservabilityManager, type ValidationError, callChunked, chunk, convertDateFieldsToIsoString, copyWithoutEmpty, copyWithoutUndefined, createRangeValidator, deepClone, ensureClosingSlashTransformer, executeAndHandleGlobalErrors, executeAsyncAndHandleGlobalErrors, executeSettleAllAndHandleGlobalErrors, failure, generateChecksumForBufferOrString, generateChecksumForObject, generateChecksumForReadable, generateHash, globalLogger, groupBy, groupByPath, groupByUnique, hasMessage, isEmptyObject, isEntityGoneError, isError, isFailure, isInternalError, isObject, isPublicNonRecoverableError, isStandardizedError, isSuccess, pick, pickWithoutUndefined, removeDuplicates, removeFalsy, removeNullish, resolveGlobalErrorLogObject, resolveLogger, resolveLoggerConfiguration, resolveMonorepoLogger, resolveMonorepoLoggerConfiguration, success, waitAndRetry };