@lokalise/node-core 13.0.0 → 13.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +22 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -84,6 +84,7 @@ __export(src_exports, {
|
|
|
84
84
|
resolveMonorepoLogger: () => resolveMonorepoLogger,
|
|
85
85
|
resolveMonorepoLoggerConfiguration: () => resolveMonorepoLoggerConfiguration,
|
|
86
86
|
success: () => success,
|
|
87
|
+
transformToKebabCase: () => transformToKebabCase,
|
|
87
88
|
waitAndRetry: () => waitAndRetry
|
|
88
89
|
});
|
|
89
90
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -584,6 +585,26 @@ function deepClone(object) {
|
|
|
584
585
|
}
|
|
585
586
|
return structuredClone(object);
|
|
586
587
|
}
|
|
588
|
+
function transformKey(key) {
|
|
589
|
+
return key.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
|
|
590
|
+
}
|
|
591
|
+
function transformToKebabCase(object) {
|
|
592
|
+
if (Array.isArray(object)) {
|
|
593
|
+
return object.map(transformToKebabCase);
|
|
594
|
+
}
|
|
595
|
+
if (typeof object !== "object" || object === null || object === void 0) {
|
|
596
|
+
return object;
|
|
597
|
+
}
|
|
598
|
+
return Object.entries(object).reduce(
|
|
599
|
+
(result, [key, value]) => {
|
|
600
|
+
const transformedKey = transformKey(key);
|
|
601
|
+
const transformedValue = value && typeof value === "object" ? transformToKebabCase(value) : value;
|
|
602
|
+
result[transformedKey] = transformedValue;
|
|
603
|
+
return result;
|
|
604
|
+
},
|
|
605
|
+
{}
|
|
606
|
+
);
|
|
607
|
+
}
|
|
587
608
|
|
|
588
609
|
// src/utils/hashUtils.ts
|
|
589
610
|
var import_node_crypto = require("crypto");
|
|
@@ -980,6 +1001,7 @@ var FsReadableProvider = class _FsReadableProvider {
|
|
|
980
1001
|
resolveMonorepoLogger,
|
|
981
1002
|
resolveMonorepoLoggerConfiguration,
|
|
982
1003
|
success,
|
|
1004
|
+
transformToKebabCase,
|
|
983
1005
|
waitAndRetry
|
|
984
1006
|
});
|
|
985
1007
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/typeUtils.ts","../src/errors/PublicNonRecoverableError.ts","../src/errors/InternalError.ts","../src/errors/errorTypeGuards.ts","../src/config/ConfigScope.ts","../src/config/configTransformers.ts","../src/config/configValidators.ts","../src/errors/either.ts","../src/utils/encryptionUtility.ts","../src/utils/arrayUtils.ts","../src/utils/objectUtils.ts","../src/utils/hashUtils.ts","../src/logging/loggerConfigResolver.ts","../src/errors/globalErrorHandler.ts","../src/errors/publicErrors.ts","../src/utils/waitUtils.ts","../src/observability/MultiTransactionObservabilityManager.ts","../src/utils/checksumUtils.ts","../src/utils/streamUtils.ts"],"sourcesContent":["export type { ErrorDetails } from './errors/types'\n\nexport {\n PublicNonRecoverableError,\n isPublicNonRecoverableError,\n type PublicNonRecoverableErrorParams,\n} from './errors/PublicNonRecoverableError'\n\nexport {\n InternalError,\n isInternalError,\n type InternalErrorParams,\n} from './errors/InternalError'\nexport { isEntityGoneError } from './errors/errorTypeGuards'\n\nexport { ConfigScope } from './config/ConfigScope'\nexport { ensureClosingSlashTransformer } from './config/configTransformers'\nexport { createRangeValidator } from './config/configValidators'\nexport {\n type EnvValueValidator,\n type EnvValueTransformer,\n type AppConfig,\n type RedisConfig,\n} from './config/configTypes'\n\nexport {\n type Either,\n type DefiniteEither,\n success,\n failure,\n isSuccess,\n isFailure,\n} from './errors/either'\n\nexport { EncryptionUtility } from './utils/encryptionUtility'\n\nexport {\n chunk,\n callChunked,\n removeFalsy,\n removeNullish,\n removeDuplicates,\n} from './utils/arrayUtils'\nexport {\n groupBy,\n groupByPath,\n groupByUnique,\n pick,\n pickWithoutUndefined,\n copyWithoutUndefined,\n copyWithoutEmpty,\n isEmptyObject,\n convertDateFieldsToIsoString,\n deepClone,\n} from './utils/objectUtils'\n\nexport {\n isError,\n isStandardizedError,\n isObject,\n hasMessage,\n} from './utils/typeUtils'\nexport { type StandardizedError } from './utils/typeUtils'\n\nexport { generateHash, HashAlgorithm, HashEncoding } from './utils/hashUtils'\n\nexport {\n resolveLoggerConfiguration,\n resolveMonorepoLoggerConfiguration,\n resolveLogger,\n resolveMonorepoLogger,\n} from './logging/loggerConfigResolver'\nexport type { AppLoggerConfig, MonorepoAppLoggerConfig } from './logging/loggerConfigResolver'\nexport type { CommonLogger } from './logging/commonLogger'\n\nexport {\n type ErrorReport,\n type ErrorReporter,\n type ErrorResolver,\n} from './errors/errorReporterTypes'\nexport {\n executeAsyncAndHandleGlobalErrors,\n executeAndHandleGlobalErrors,\n executeSettleAllAndHandleGlobalErrors,\n globalLogger,\n resolveGlobalErrorLogObject,\n} from './errors/globalErrorHandler'\n\nexport { type MayOmit } from './common/may-omit'\nexport { type FreeformRecord } from './common/commonTypes'\nexport {\n type ValidationError,\n type CommonErrorParams,\n type OptionalMessageErrorParams,\n RequestValidationError,\n AccessDeniedError,\n EntityNotFoundError,\n EntityGoneError,\n AuthFailedError,\n} from './errors/publicErrors'\n\nexport { waitAndRetry } from './utils/waitUtils'\n\nexport type { TransactionObservabilityManager } from './observability/observabilityTypes'\nexport { MultiTransactionObservabilityManager } from './observability/MultiTransactionObservabilityManager'\n\nexport {\n generateChecksumForReadable,\n generateChecksumForObject,\n generateChecksumForBufferOrString,\n} from './utils/checksumUtils'\nexport { FsReadableProvider } from './utils/streamUtils'\nexport type {\n PersistToFsOptions,\n ReadableProvider,\n FsReadableProviderOptions,\n} from './utils/streamUtils'\n","// Error structure commonly used in libraries, e. g. fastify\nexport type StandardizedError = {\n code: string\n message: string\n}\n\nexport function hasMessage(maybe: unknown): maybe is { message: string } {\n return isObject(maybe) && typeof maybe.message === 'string'\n}\n\nexport function isObject(maybeObject: unknown): maybeObject is Record<PropertyKey, unknown> {\n return typeof maybeObject === 'object' && maybeObject !== null\n}\n\nexport function isStandardizedError(error: unknown): error is StandardizedError {\n return isObject(error) && typeof error.code === 'string' && typeof error.message === 'string'\n}\n\nexport function isError(maybeError: unknown): maybeError is Error {\n return (\n maybeError instanceof Error || Object.prototype.toString.call(maybeError) === '[object Error]'\n )\n}\n","import { isError } from '../utils/typeUtils'\nimport type { ErrorDetails } from './types'\n\nexport type PublicNonRecoverableErrorParams<T = ErrorDetails> = {\n message: string\n errorCode: string\n details?: T\n httpStatusCode?: number\n cause?: unknown\n}\n\nconst PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY = 'PUBLIC_NON_RECOVERABLE_ERROR_KEY'\nconst publicNonRecoverableErrorSymbol = Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)\n\n/**\n * This error is returned to the consumer of API\n */\nexport class PublicNonRecoverableError<T = ErrorDetails> extends Error {\n readonly [publicNonRecoverableErrorSymbol] = true\n public readonly details?: T\n public readonly errorCode: string\n public readonly httpStatusCode: number\n\n constructor(params: PublicNonRecoverableErrorParams<T>) {\n super(params.message, {\n cause: params.cause,\n })\n // set the name as the class name for every class that extends PublicNonRecoverableError\n this.name = this.constructor.name\n this.details = params.details\n this.errorCode = params.errorCode\n this.httpStatusCode = params.httpStatusCode ?? 500\n }\n}\n\nexport function isPublicNonRecoverableError(error: unknown): error is PublicNonRecoverableError {\n return (\n isError(error) &&\n // biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface\n ((error as any)[Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)] === true ||\n error.name === 'PublicNonRecoverableError')\n )\n}\n","import { isError } from '../utils/typeUtils'\nimport type { ErrorDetails } from './types'\n\nexport type InternalErrorParams<T = ErrorDetails> = {\n message: string\n errorCode: string\n details?: T\n cause?: unknown\n}\n\nconst INTERNAL_ERROR_SYMBOL_KEY = 'INTERNAL_ERROR_KEY'\nconst internalErrorSymbol = Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)\n\nexport class InternalError<T = ErrorDetails> extends Error {\n readonly [internalErrorSymbol] = true\n public readonly details?: T\n public readonly errorCode: string\n\n constructor(params: InternalErrorParams<T>) {\n super(params.message, {\n cause: params.cause,\n })\n // set the name as the class name for every class that extends InternalError\n this.name = this.constructor.name\n this.details = params.details\n this.errorCode = params.errorCode\n }\n}\n\nexport function isInternalError(error: unknown): error is InternalError {\n return (\n isError(error) &&\n // biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface\n ((error as any)[Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)] === true ||\n error.name === 'InternalError')\n )\n}\n","import { isPublicNonRecoverableError } from '../errors/PublicNonRecoverableError'\n\nimport type { EntityGoneError } from './publicErrors'\n\nexport function isEntityGoneError(entity: unknown): entity is EntityGoneError {\n return isPublicNonRecoverableError(entity) && entity.httpStatusCode === 410\n}\n","import type { ZodSchema } from 'zod'\n\nimport { InternalError } from '../errors/InternalError'\n\nimport type { EnvValueValidator } from './configTypes'\n\nexport type EnvType = {\n [key: string]: string | undefined\n}\n\nexport class ConfigScope {\n private env: EnvType\n\n constructor(envOverride?: EnvType) {\n this.env = envOverride ?? { ...process.env }\n }\n\n updateEnv() {\n // Accessing process.env values is slow, so we cache them\n this.env = { ...process.env }\n }\n\n getMandatoryInteger(param: string): number {\n const rawValue = this.env[param]\n if (!rawValue) {\n throw new InternalError({\n message: `Missing mandatory configuration parameter: ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getMandatory(param: string): string {\n const result = this.env[param]\n if (!result) {\n throw new InternalError({\n message: `Missing mandatory configuration parameter: ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return result\n }\n\n getMandatoryOneOf<const T>(param: string, supportedValues: T[]): T {\n const result = this.getMandatory(param)\n return validateOneOf(\n result,\n supportedValues,\n `Unsupported ${param}: ${result}. Supported values: ${supportedValues.toString()}`,\n )\n }\n\n getMandatoryValidatedInteger(param: string, validator: EnvValueValidator<number>): number {\n const value = this.getMandatoryInteger(param)\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return value\n }\n\n getOptionalNullable<T extends string | null | undefined>(\n param: string,\n defaultValue: T,\n ): T | string {\n return this.env[param] || defaultValue\n }\n\n getOptional(param: string, defaultValue: string): string {\n // Using the `||` operator instead of `??`, since '' is not a valid value, and 0 (number) is not expected here\n return this.env[param] || defaultValue\n }\n\n getOptionalInteger(param: string, defaultValue: number): number {\n const rawValue = this.env[param]\n if (!rawValue) {\n return defaultValue\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getOptionalNullableInteger<T extends number | null | undefined>(\n param: string,\n defaultValue: T,\n ): T | number {\n const rawValue = this.env[param]\n if (!rawValue) {\n return defaultValue\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getOptionalOneOf<const T extends string>(\n param: string,\n defaultValue: T,\n supportedValues: T[],\n ): T {\n const result = this.getOptional(param, defaultValue)\n return validateOneOf(\n result,\n supportedValues,\n `Unsupported ${param}: ${result}. Supported values: ${supportedValues.toString()}`,\n )\n }\n\n getOptionalValidated(\n param: string,\n defaultValue: string,\n validator: EnvValueValidator<string>,\n ): string {\n const value = this.env[param] || defaultValue\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return value\n }\n\n getOptionalValidatedInteger(\n param: string,\n defaultValue: number,\n validator: EnvValueValidator<number>,\n ): number {\n const value = this.getOptionalInteger(param, defaultValue)\n\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n\n return value\n }\n\n getOptionalTransformed(\n param: string,\n defaultValue: string,\n transformer: (value: string) => string,\n ): string {\n const value = this.env[param] || defaultValue\n return transformer(value)\n }\n\n getOptionalNullableTransformed<T extends string | undefined>(\n param: string,\n defaultValue: T,\n transformer: (value: T | string) => T | string,\n ): T | string {\n const value = this.env[param] || defaultValue\n return transformer(value as T)\n }\n\n getMandatoryTransformed(param: string, transformer: (value: string) => string) {\n const value = this.getMandatory(param)\n\n return transformer(value)\n }\n\n getOptionalBoolean(param: string, defaultValue: boolean): boolean {\n const rawValue = this.env[param]?.toLowerCase()\n if (rawValue === undefined || rawValue === '') {\n return defaultValue\n }\n\n validateOneOf(rawValue, ['true', 'false'])\n\n return rawValue === 'true'\n }\n\n getMandatoryJsonObject<T extends object>(param: string, schema: ZodSchema<T>): T {\n const rawValue = this.getMandatory(param)\n return this.validateSchema(\n JSON.parse(rawValue),\n schema,\n `Configuration parameter ${param} must be a valid JSON meeting the given schema, but was ${rawValue}`,\n )\n }\n\n getOptionalNullableJsonObject<T extends object, Z extends T | null | undefined>(\n param: string,\n schema: ZodSchema<T>,\n defaultValue: Z,\n ): Z {\n const rawValue = this.getOptionalNullable(param, undefined)\n if (!rawValue) {\n return defaultValue\n }\n\n return this.validateSchema(\n JSON.parse(rawValue),\n schema,\n `Configuration parameter ${param} must be a valid JSON meeting the given schema, but was ${rawValue}`,\n ) as Z\n }\n\n getOptionalJsonObject<T extends object>(param: string, schema: ZodSchema<T>, defaultValue: T): T {\n return this.getOptionalNullableJsonObject(param, schema, defaultValue)\n }\n\n isProduction(): boolean {\n return this.env.NODE_ENV === 'production'\n }\n\n isDevelopment(): boolean {\n return this.env.NODE_ENV !== 'production'\n }\n\n isTest(): boolean {\n return this.env.NODE_ENV === 'test'\n }\n\n private validateSchema<T extends object>(\n value: unknown,\n schema: ZodSchema<T>,\n errorMessage: string,\n ): T {\n const parsedValue = schema.safeParse(value)\n if (!parsedValue.success) {\n throw new InternalError({\n message: errorMessage,\n errorCode: 'CONFIGURATION_ERROR',\n details: parsedValue.error,\n })\n }\n\n return parsedValue.data\n }\n}\n\nexport function validateOneOf<const T>(\n validatedEntity: unknown,\n expectedOneOfEntities: T[],\n errorText?: string,\n): T {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n if (!expectedOneOfEntities.includes(validatedEntity as T)) {\n throw new InternalError({\n message:\n errorText ||\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Validated entity ${validatedEntity} is not one of: ${expectedOneOfEntities.toString()}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return validatedEntity as T\n}\n\nexport function validateNumber(validatedObject: unknown, errorText: string): number {\n if (!Number.isFinite(validatedObject)) {\n throw new InternalError({\n message: errorText,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return validatedObject as number\n}\n","import type { EnvValueTransformer } from './configTypes'\n\nexport const ensureClosingSlashTransformer: EnvValueTransformer<\n string | undefined | null,\n string\n> = (value) => {\n if (!value) {\n return ''\n }\n\n const lastChar = value.at(-1)\n if (lastChar !== '/') {\n return `${value}/`\n }\n return value\n}\n","import type { EnvValueValidator } from './configTypes'\n\nexport const createRangeValidator = (\n greaterOrEqualThan: number,\n lessOrEqualThan: number,\n): EnvValueValidator<number> => {\n return (value) => {\n return value >= greaterOrEqualThan && value <= lessOrEqualThan\n }\n}\n","type Left<T> = {\n error: T\n result?: never\n}\n\ntype Right<U> = {\n error?: never\n result: U\n}\n\n/**\n * Either is a functional programming type which is used to communicate errors happening in potentially recoverable scenarios.\n * It can return either an error (Left side) or a resolved result (Right side), but not both.\n * It is up to caller of the function to handle received error or throw (Public)NonRecoverableError if it cannot.\n *\n * @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}\n */\nexport type Either<T, U> = NonNullable<Left<T> | Right<U>>\n\n/***\n * Variation of Either, which may or may not have Error set, but always has Result\n */\nexport type DefiniteEither<T, U> = {\n error?: T\n result: U\n}\n\nexport const isFailure = <T, U>(e: Either<T, U>): e is Left<T> => {\n return e.error !== undefined\n}\n\nexport const isSuccess = <T, U>(e: Either<T, U>): e is Right<U> => {\n return e.result !== undefined\n}\n\nexport const failure = <T>(error: T): Left<T> => ({ error })\n\nexport const success = <U>(result: U): Right<U> => ({ result })\n","import * as crypto from 'node:crypto'\n\nconst algorithm = 'aes-256-gcm'\nconst ivLength = 16\nconst tagLength = 16\nconst defaultEncoding = 'hex'\nconst defaultSaltLength = 64\nconst defaultPbkdf2Iterations = 100000\n\nexport type Options = {\n saltLength?: number\n pbkdf2Iterations?: number\n encoding?: NodeJS.BufferEncoding\n}\n\n/**\n * Type-scripted version of https://github.com/MauriceButler/cryptr\n */\nexport class EncryptionUtility {\n private readonly secret: string\n private readonly saltLength: number\n private readonly encryptedPosition: number\n private readonly tagPosition: number\n private readonly pbkdf2Iterations: number\n private readonly encoding: NodeJS.BufferEncoding\n\n constructor(secret: string, options?: Options) {\n this.secret = secret\n\n this.encoding = options?.encoding ?? defaultEncoding\n this.pbkdf2Iterations = options?.pbkdf2Iterations ?? defaultPbkdf2Iterations\n this.saltLength = options?.saltLength ?? defaultSaltLength\n\n this.tagPosition = this.saltLength + ivLength\n this.encryptedPosition = this.tagPosition + tagLength\n }\n\n private getKey(salt: Buffer) {\n return crypto.pbkdf2Sync(this.secret, salt, this.pbkdf2Iterations, 32, 'sha512')\n }\n\n public encrypt(value: string) {\n const iv = crypto.randomBytes(ivLength)\n const salt = crypto.randomBytes(this.saltLength)\n\n const key = this.getKey(salt)\n\n const cipher = crypto.createCipheriv(algorithm, key, iv)\n const encrypted = Buffer.concat([cipher.update(String(value), 'utf8'), cipher.final()])\n\n const tag = cipher.getAuthTag()\n\n return Buffer.concat([salt, iv, tag, encrypted]).toString(this.encoding)\n }\n\n public decrypt(value: string) {\n const stringValue = Buffer.from(String(value), this.encoding)\n\n const salt = stringValue.subarray(0, this.saltLength)\n const iv = stringValue.subarray(this.saltLength, this.tagPosition)\n const tag = stringValue.subarray(this.tagPosition, this.encryptedPosition)\n const encrypted = stringValue.subarray(this.encryptedPosition)\n\n const key = this.getKey(salt)\n\n const decipher = crypto.createDecipheriv(algorithm, key, iv)\n\n decipher.setAuthTag(tag)\n\n return Buffer.concat([\n decipher.update(encrypted),\n Buffer.from(decipher.final('utf8')),\n ]).toString('utf8')\n }\n}\n","export function chunk<T>(array: T[], chunkSize: number): T[][] {\n const length = array.length\n if (!length || chunkSize < 1) {\n return []\n }\n let index = 0\n let resIndex = 0\n const result = new Array(Math.ceil(length / chunkSize))\n\n while (index < length) {\n // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>\n result[resIndex++] = array.slice(index, (index += chunkSize))\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return result\n}\n\nexport async function callChunked<Item>(\n chunkSize: number,\n array: readonly Item[],\n processFn: (arrayChunk: Item[]) => Promise<unknown>,\n): Promise<void> {\n for (let i = 0; i < array.length; i += chunkSize) {\n const arrayChunk = array.slice(i, i + chunkSize)\n await processFn(arrayChunk)\n }\n}\n\n/**\n * Return a copy of the given array without null or undefined values\n */\nexport function removeNullish<const T>(array: readonly (T | null | undefined)[]): T[] {\n return array.filter((e) => e !== undefined && e !== null) as T[]\n}\n\n/**\n * Return a copy of the given array without falsy values (eg: false, 0, '', null, undefined)\n */\nexport function removeFalsy<const T>(\n array: readonly (T | null | undefined | 0 | '' | false)[],\n): T[] {\n return array.filter((e) => e) as T[]\n}\n\n/**\n * Return a copy of the given array without duplicates.\n */\nexport function removeDuplicates<const T>(array: readonly T[]): T[] {\n return [...new Set(array)]\n}\n","import dotProp from 'dot-prop'\n\nimport { InternalError } from '../errors/InternalError'\n\ntype RecordKeyType = string | number | symbol\n\nexport function copyWithoutUndefined<\n T extends Record<RecordKeyType, unknown>,\n TargetRecordType = Pick<\n T,\n {\n [Prop in keyof T]: T[Prop] extends null | undefined ? never : Prop\n }[keyof T]\n >,\n>(originalValue: T): TargetRecordType {\n return Object.keys(originalValue).reduce(\n (acc, key) => {\n // @ts-ignore\n if (originalValue[key] !== undefined) {\n // @ts-ignore\n acc[key] = originalValue[key]\n }\n return acc\n },\n {} as Record<string, unknown>,\n ) as TargetRecordType\n}\n\nexport function copyWithoutEmpty<\n T extends Record<RecordKeyType, unknown>,\n TargetRecordType = Pick<\n T,\n {\n [Prop in keyof T]: T[Prop] extends null | undefined | '' ? never : Prop\n }[keyof T]\n >,\n>(originalValue: T): TargetRecordType {\n return Object.keys(originalValue).reduce(\n (acc, key) => {\n if (\n originalValue[key] !== undefined &&\n originalValue[key] !== null &&\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n (typeof originalValue[key] !== 'string' || originalValue[key].trim().length > 0)\n ) {\n // @ts-ignore\n acc[key] = originalValue[key]\n }\n return acc\n },\n {} as Record<string, unknown>,\n ) as TargetRecordType\n}\n\nexport function pick<T, K extends string | number | symbol>(\n source: T,\n propNames: readonly K[],\n): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>> {\n const result = {} as T\n let idx = 0\n while (idx < propNames.length) {\n // @ts-ignore\n if (propNames[idx] in source) {\n // @ts-ignore\n result[propNames[idx]] = source[propNames[idx]]\n }\n idx += 1\n }\n return result\n}\n\nexport function pickWithoutUndefined<T, K extends string | number | symbol>(\n source: T,\n propNames: readonly K[],\n): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>> {\n const result = {} as T\n let idx = 0\n while (idx < propNames.length) {\n // @ts-ignore\n if (propNames[idx] in source && source[propNames[idx]] !== undefined) {\n // @ts-ignore\n result[propNames[idx]] = source[propNames[idx]]\n }\n idx += 1\n }\n return result\n}\n\nexport function isEmptyObject(params: Record<string, unknown>): boolean {\n for (const key in params) {\n if (Object.hasOwn(params, key) && params[key] !== undefined) {\n return false\n }\n }\n return true\n}\n\ntype KeysMatching<T, V> = { [K in keyof T]: T[K] extends V ? K : never }[keyof T]\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects.\n * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.\n */\nexport function groupBy<\n T extends object,\n K extends KeysMatching<T, RecordKeyType | null | undefined>,\n>(array: T[], selector: K): Record<RecordKeyType, T[]> {\n return array.reduce(\n (acc, item) => {\n const key = item[selector] as RecordKeyType | null | undefined\n if (key === undefined || key === null) {\n return acc\n }\n if (!acc[key]) {\n acc[key] = []\n }\n acc[key].push(item)\n return acc\n },\n {} as Record<RecordKeyType, T[]>,\n )\n}\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects. Support nested keys.\n * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.\n */\nexport function groupByPath<T extends object>(array: T[], selector: string): Record<string, T[]> {\n return array.reduce(\n (acc, item) => {\n const key = dotProp.get(item, selector)\n if (key === undefined || key === null) {\n return acc\n }\n const strKeyPath = key as string\n\n if (!acc[strKeyPath]) {\n acc[strKeyPath] = []\n }\n acc[strKeyPath].push(item)\n return acc\n },\n {} as Record<RecordKeyType, T[]>,\n )\n}\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects.\n * @returns An object where the keys are unique values from the given selector and the value is the\n * corresponding object from the array.\n * @throws InternalError If a duplicated value is found for the given selector.\n */\nexport function groupByUnique<\n T extends object,\n K extends KeysMatching<T, RecordKeyType | null | undefined>,\n>(array: T[], selector: K): Record<RecordKeyType, T> {\n return array.reduce(\n (acc, item) => {\n const key = item[selector] as RecordKeyType | null | undefined\n if (key === undefined || key === null) {\n return acc\n }\n if (acc[key] !== undefined) {\n throw new InternalError({\n message: `Duplicated item for selector ${selector.toString()} with value ${key.toString()}`,\n errorCode: 'DUPLICATED_ITEM',\n details: { selector, value: key },\n })\n }\n acc[key] = item\n return acc\n },\n {} as Record<RecordKeyType, T>,\n )\n}\n\ntype DatesAsString<T> = T extends Date ? string : ExactlyLikeWithDateAsString<T>\n\ntype ExactlyLikeWithDateAsString<T> = T extends object ? { [K in keyof T]: DatesAsString<T[K]> } : T\n\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input,\n): ExactlyLikeWithDateAsString<Input>\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input[],\n): ExactlyLikeWithDateAsString<Input>[]\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input | Input[],\n): ExactlyLikeWithDateAsString<Input> | ExactlyLikeWithDateAsString<Input>[] {\n if (Array.isArray(object)) {\n // @ts-ignore\n return object.map(convertDateFieldsToIsoStringAux)\n }\n\n return Object.entries(object).reduce(\n (result, [key, value]) => {\n // @ts-ignore\n result[key] = convertDateFieldsToIsoStringAux(value)\n return result\n },\n {} as ExactlyLikeWithDateAsString<Input>,\n )\n}\n\nfunction convertDateFieldsToIsoStringAux<T>(item: T): DatesAsString<T> {\n if (item instanceof Date) {\n // @ts-ignore\n return item.toISOString()\n }\n\n if (item && typeof item === 'object') {\n // @ts-ignore\n return convertDateFieldsToIsoString(item)\n }\n\n // @ts-ignore\n return item\n}\n\n/**\n * Return a deep clone copy of an object.\n *\n * Please Note: This uses structuredClone, which has the limitations of these restricted Types: functions,\n * Error objects, WeakMap, WeakSet, DOM nodes, and certain other browser-specific objects like Window.\n */\nexport function deepClone<T extends object | undefined | null>(object: T): T {\n if (object === undefined || object === null) {\n return object\n }\n return structuredClone(object)\n}\n\nfunction transformKey(key: string): string {\n return key\n .replace(/([a-z])([A-Z])/g, '$1-$2') // transforms basic camelCase\n .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2') // transforms abbreviations\n .replace(/_/g, '-') // transforms snake_case\n .toLowerCase() // finally lowercase all\n}\n\ntype TransformToKebabCaseInputType = Record<string, unknown> | null | undefined\ntype TransformToKebabCaseReturnType<Input, Output> = Input extends Record<string, unknown>\n ? Output\n : Input\n/**\n * Transforms an object's keys from camelCase or snake_case to kebab-case.\n * @param object\n */\nexport function transformToKebabCase<\n Output extends Record<string, unknown>,\n Input extends TransformToKebabCaseInputType,\n>(object: Input): TransformToKebabCaseReturnType<Input, Output>\n\nexport function transformToKebabCase<\n Output extends Record<string, unknown>,\n Input extends TransformToKebabCaseInputType,\n>(object: Input[]): TransformToKebabCaseReturnType<Input, Output>[]\n\nexport function transformToKebabCase<Output, Input>(\n object: Input | Input[],\n): TransformToKebabCaseReturnType<Input, Output> | TransformToKebabCaseReturnType<Input, Output>[] {\n if (Array.isArray(object)) {\n // @ts-ignore\n return object.map(transformToKebabCase)\n }\n if (typeof object !== 'object' || object === null || object === undefined) {\n return object as TransformToKebabCaseReturnType<Input, Output>\n }\n\n return Object.entries(object as Record<string, unknown>).reduce(\n (result, [key, value]) => {\n const transformedKey = transformKey(key)\n const transformedValue =\n value && typeof value === 'object'\n ? transformToKebabCase(value as TransformToKebabCaseInputType)\n : value\n\n // Avoiding destructuring by directly assigning the new key-value pair\n result[transformedKey] = transformedValue\n return result\n },\n {} as Record<string, unknown>,\n ) as TransformToKebabCaseReturnType<Input, Output>\n}\n","import { createHash } from 'node:crypto'\n\nexport enum HashEncoding {\n HEX = 'hex',\n BASE64 = 'base64',\n}\n\nexport enum HashAlgorithm {\n SHA256 = 'sha256',\n SHA512 = 'sha512',\n}\n\nexport function generateHash(\n algorithm: HashAlgorithm,\n data: string,\n encoding: HashEncoding = HashEncoding.HEX,\n) {\n return createHash(algorithm).update(data).digest(encoding)\n}\n","import type { Level, Logger, LoggerOptions, redactOptions } from 'pino'\nimport { levels, pino } from 'pino'\nimport pretty from 'pino-pretty'\n\nexport type AppLoggerConfig = {\n logLevel: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n nodeEnv: 'production' | 'development' | 'test'\n base?: Record<string, unknown>\n redact?: redactOptions\n}\n\nexport type MonorepoAppLoggerConfig = AppLoggerConfig & {\n targetFile?: string\n append?: boolean\n}\n\n/* c8 ignore next 8 */\nexport function resolveMonorepoLogger(appConfig: MonorepoAppLoggerConfig): Logger {\n if (appConfig.nodeEnv !== 'development') {\n return resolveLogger(appConfig)\n }\n\n const configuration = resolveMonorepoLoggerConfiguration(appConfig) as LoggerOptions\n return pino(configuration)\n}\n\n// Note that transports do not work in vitest, likely because pino attempts to run them in a separate worker\n/* c8 ignore next 25 */\nexport function resolveMonorepoLoggerConfiguration(\n appConfig: MonorepoAppLoggerConfig,\n): LoggerOptions | Logger {\n if (appConfig.nodeEnv !== 'development') {\n return resolveLoggerConfiguration(appConfig)\n }\n\n return {\n level: appConfig.logLevel,\n formatters: {\n level: (label) => {\n return { level: label }\n },\n },\n redact: appConfig.redact,\n transport: {\n target: 'pino/file',\n options: {\n destination: appConfig.targetFile ?? './service.log',\n mkdir: true,\n append: appConfig.append ?? false,\n },\n },\n }\n}\n\nexport function resolveLogger(appConfig: AppLoggerConfig): Logger {\n if (appConfig.nodeEnv !== 'production') {\n return resolveLoggerConfiguration(appConfig) as Logger\n }\n\n const configuration = resolveLoggerConfiguration(appConfig) as LoggerOptions\n return pino(configuration)\n}\n\nexport function resolveLoggerConfiguration(appConfig: AppLoggerConfig): LoggerOptions | Logger {\n if (appConfig.nodeEnv !== 'production') {\n return pino(\n pretty({\n sync: true,\n minimumLevel: appConfig.logLevel as Level,\n colorize: true,\n translateTime: 'SYS:standard',\n ignore: 'hostname,pid',\n }),\n )\n }\n\n return {\n level: appConfig.logLevel,\n formatters: {\n level: (_label, numericLevel): { level: string } => {\n const level = levels.labels[numericLevel] || 'unknown'\n return { level }\n },\n },\n redact: appConfig.redact,\n } satisfies LoggerOptions\n}\n","import { types } from 'node:util'\n\nimport type { SerializedError } from 'pino'\nimport { levels, pino, stdSerializers } from 'pino'\n\nimport type { CommonLogger } from '../logging/commonLogger'\nimport { hasMessage } from '../utils/typeUtils'\n\ntype LogObject = {\n message: string\n 'x-request-id'?: string\n error?: SerializedError\n}\n\nexport const globalLogger: CommonLogger = pino({\n formatters: {\n level: (_label, numericLevel): { level: string } => {\n const level = levels.labels[numericLevel] || 'unknown'\n return { level }\n },\n },\n})\n\nexport function resolveGlobalErrorLogObject(err: unknown, correlationId?: string): LogObject {\n if (types.isNativeError(err)) {\n return {\n message: err.message,\n error: stdSerializers.err(err),\n 'x-request-id': correlationId,\n }\n }\n\n if (hasMessage(err)) {\n return {\n message: err.message,\n 'x-request-id': correlationId,\n }\n }\n\n return {\n message: 'Unknown error',\n 'x-request-id': correlationId,\n }\n}\n\nexport function executeAndHandleGlobalErrors<T>(operation: () => T) {\n try {\n const result = operation()\n return result\n } catch (err) {\n const logObject = resolveGlobalErrorLogObject(err)\n globalLogger.error(logObject, logObject.message)\n process.exit(1)\n }\n}\n\nexport async function executeAsyncAndHandleGlobalErrors<T>(\n operation: () => Promise<T>,\n stopOnError = true,\n) {\n try {\n const result = await operation()\n return result\n } catch (err) {\n const logObject = resolveGlobalErrorLogObject(err)\n globalLogger.error(logObject, logObject.message)\n if (stopOnError) {\n process.exit(1)\n }\n }\n}\n\nexport async function executeSettleAllAndHandleGlobalErrors(\n promises: Promise<unknown>[],\n stopOnError = true,\n) {\n const result = await Promise.allSettled(promises)\n\n let errorsHappened: boolean | undefined\n for (const entry of result) {\n if (entry.status === 'rejected') {\n const logObject = resolveGlobalErrorLogObject(entry.reason)\n globalLogger.error(logObject, logObject.message)\n errorsHappened = true\n }\n }\n\n if (stopOnError && errorsHappened) {\n process.exit(1)\n }\n\n return result\n}\n","import { constants as httpConstants } from 'node:http2'\n\nimport type { FreeformRecord } from '../common/commonTypes'\n\nimport { PublicNonRecoverableError } from './PublicNonRecoverableError'\n\nexport type CommonErrorParams = {\n message: string\n details?: FreeformRecord\n cause?: Error\n}\n\nexport type OptionalMessageErrorParams = Partial<CommonErrorParams>\n\nexport type ValidationError = {\n message: string\n path: string[]\n}\n\nexport class RequestValidationError extends PublicNonRecoverableError {\n constructor(errors: ValidationError[]) {\n super({\n message: 'Invalid params',\n errorCode: 'VALIDATION_ERROR',\n httpStatusCode: httpConstants.HTTP_STATUS_BAD_REQUEST,\n details: {\n error: errors,\n },\n })\n }\n}\n\nexport class AccessDeniedError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ACCESS_DENIED',\n httpStatusCode: httpConstants.HTTP_STATUS_FORBIDDEN,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n\nexport class EntityNotFoundError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ENTITY_NOT_FOUND',\n httpStatusCode: httpConstants.HTTP_STATUS_NOT_FOUND,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n\nexport class EntityGoneError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ENTITY_GONE',\n httpStatusCode: 410,\n details: params.details,\n })\n }\n}\n\nexport class AuthFailedError extends PublicNonRecoverableError {\n constructor(params: OptionalMessageErrorParams = {}) {\n super({\n message: params.message ?? 'Authentication failed',\n errorCode: 'AUTH_FAILED',\n httpStatusCode: httpConstants.HTTP_STATUS_UNAUTHORIZED,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n","export const waitAndRetry = async <T>(\n predicateFn: () => T,\n sleepTime = 20,\n maxRetryCount = 15,\n): Promise<T> => {\n return new Promise((resolve, reject) => {\n let retryCount = 0\n function performCheck() {\n // amount of retries exceeded\n if (maxRetryCount !== 0 && retryCount > maxRetryCount) {\n resolve(predicateFn())\n }\n\n // Try executing predicateFn\n Promise.resolve()\n .then(() => {\n return predicateFn()\n })\n .then((result) => {\n if (result) {\n resolve(result)\n } else {\n retryCount++\n setTimeout(performCheck, sleepTime)\n }\n })\n .catch((err) => {\n reject(err)\n })\n }\n\n performCheck()\n })\n}\n","import type { TransactionObservabilityManager } from './observabilityTypes'\n\n/**\n * Groups different TransactionObservabilityManager instances into one\n * to facilitate tracking transactions across multiple observability tools.\n */\nexport class MultiTransactionObservabilityManager implements TransactionObservabilityManager {\n private readonly managers: TransactionObservabilityManager[]\n\n constructor(managers: TransactionObservabilityManager[]) {\n this.managers = managers\n }\n\n start(transactionName: string, uniqueTransactionKey: string): void {\n for (const manager of this.managers) {\n manager.start(transactionName, uniqueTransactionKey)\n }\n }\n\n startWithGroup(\n transactionName: string,\n uniqueTransactionKey: string,\n transactionGroup: string,\n ): void {\n for (const manager of this.managers) {\n manager.startWithGroup(transactionName, uniqueTransactionKey, transactionGroup)\n }\n }\n\n stop(uniqueTransactionKey: string, wasSuccessful?: boolean): void {\n for (const manager of this.managers) {\n manager.stop(uniqueTransactionKey, wasSuccessful)\n }\n }\n}\n","import type { BinaryLike } from 'node:crypto'\nimport { createHash } from 'node:crypto'\nimport type { Readable } from 'node:stream'\n\nconst HASH_ALGORITHM = 'md5'\n\nexport function generateChecksumForBufferOrString(data: BinaryLike): string {\n return createHash(HASH_ALGORITHM).update(data).digest('hex')\n}\n\nexport function generateChecksumForObject(object: object): string {\n const objectAsString = JSON.stringify(object)\n return generateChecksumForBufferOrString(objectAsString)\n}\n\nexport function generateChecksumForReadable(readable: Readable): Promise<string> {\n return new Promise((resolve, reject) => {\n const hashCreator = createHash(HASH_ALGORITHM)\n readable.on('data', (data) => {\n if (Buffer.isBuffer(data)) {\n hashCreator.update(data)\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hashCreator.update(Buffer.from(data))\n }\n })\n\n readable.on('end', () => {\n const hash = hashCreator.digest('hex')\n resolve(hash)\n })\n readable.on('error', (err) => {\n /* c8 ignore next 1 */\n reject(err)\n })\n })\n}\n","import { F_OK } from 'node:constants'\nimport { access, createReadStream, createWriteStream } from 'node:fs'\nimport { stat, unlink } from 'node:fs/promises'\nimport type { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream'\n\nexport type ReadableProvider = {\n /**\n * Guarantees to provide a new stream every time this is called, before `destroy` is invoked.\n */\n createStream(): Promise<Readable>\n\n /**\n * Returns size of the persisted content\n */\n getContentLength(): Promise<number>\n\n /**\n * Remove the persisted value. No new streams can be created after this is called\n */\n destroy(): Promise<void>\n}\n\nexport type PersistToFsOptions = {\n targetFile: string\n sourceReadable: Readable\n}\n\nexport type FsReadableProviderOptions = {\n storageFile: string\n}\n\nexport class FsReadableProvider implements ReadableProvider {\n public readonly storageFile: string\n constructor(options: FsReadableProviderOptions) {\n this.storageFile = options.storageFile\n }\n\n fileExists(): Promise<boolean> {\n return new Promise((resolve) => {\n access(this.storageFile, F_OK, (err) => {\n return resolve(!err)\n })\n })\n }\n\n async getContentLength(): Promise<number> {\n if (!(await this.fileExists())) {\n throw new Error(`File ${this.storageFile} was already deleted.`)\n }\n const stats = await stat(this.storageFile)\n return stats.size\n }\n\n async createStream(): Promise<Readable> {\n if (!(await this.fileExists())) {\n throw new Error(`File ${this.storageFile} was already deleted.`)\n }\n\n return createReadStream(this.storageFile)\n }\n\n async destroy(): Promise<void> {\n if (!(await this.fileExists())) {\n // nothing to do here\n return\n }\n\n return unlink(this.storageFile)\n }\n\n protected async persist(sourceReadable: Readable): Promise<void> {\n const writable = createWriteStream(this.storageFile)\n return new Promise((resolve, reject) => {\n pipeline(sourceReadable, writable, (err) => {\n if (err) {\n /* c8 ignore next 1 */\n reject(err)\n } else {\n resolve()\n }\n })\n })\n }\n\n public static async persistReadableToFs(\n options: PersistToFsOptions,\n ): Promise<FsReadableProvider> {\n const provider = new FsReadableProvider({\n storageFile: options.targetFile,\n })\n await provider.persist(options.sourceReadable)\n return provider\n }\n}\n\n/**\n * Consumes the readable in order to calculate its length in bytes\n * @param readable\n */\nexport function getReadableContentLength(readable: Readable): Promise<number> {\n return new Promise((resolve, reject) => {\n let size = 0\n readable.on('data', (chunk) => {\n if (typeof chunk === 'string' || Buffer.isBuffer(chunk)) {\n size += Buffer.byteLength(chunk)\n }\n })\n readable.on('end',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C9B,YAAM,IAAI,MAAM,QAAQ,KAAK,WAAW,uBAAuB;AAAA,IACjE;AACA,UAAM,QAAQ,UAAM,sBAAK,KAAK,WAAW;AACzC,WAAO,MAAM;AAAA,EACf;AAAA,EAEA,MAAM,eAAkC;AACtC,QAAI,CAAE,MAAM,KAAK,WAAW,GAAI;AAC9B,YAAM,IAAI,MAAM,QAAQ,KAAK,WAAW,uBAAuB;AAAA,IACjE;AAEA,eAAO,iCAAiB,KAAK,WAAW;AAAA,EAC1C;AAAA,EAEA,MAAM,UAAyB;AAC7B,QAAI,CAAE,MAAM,KAAK,WAAW,GAAI;AAE9B;AAAA,IACF;AAEA,eAAO,wBAAO,KAAK,WAAW;AAAA,EAChC;AAAA,EAEA,MAAgB,QAAQ,gBAAyC;AAC/D,UAAM,eAAW,kCAAkB,KAAK,WAAW;AACnD,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,uCAAS,gBAAgB,UAAU,CAAC,QAAQ;AAC1C,YAAI,KAAK;AAEP,iBAAO,GAAG;AAAA,QACZ,OAAO;AACL,kBAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,aAAoB,oBAClB,SAC6B;AAC7B,UAAM,WAAW,IAAI,oBAAmB;AAAA,MACtC,aAAa,QAAQ;AAAA,IACvB,CAAC;AACD,UAAM,SAAS,QAAQ,QAAQ,cAAc;AAC7C,WAAO;AAAA,EACT;AACF;","names":["dotProp","HashEncoding","HashAlgorithm","algorithm","pretty","import_pino","httpConstants","import_node_crypto"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/typeUtils.ts","../src/errors/PublicNonRecoverableError.ts","../src/errors/InternalError.ts","../src/errors/errorTypeGuards.ts","../src/config/ConfigScope.ts","../src/config/configTransformers.ts","../src/config/configValidators.ts","../src/errors/either.ts","../src/utils/encryptionUtility.ts","../src/utils/arrayUtils.ts","../src/utils/objectUtils.ts","../src/utils/hashUtils.ts","../src/logging/loggerConfigResolver.ts","../src/errors/globalErrorHandler.ts","../src/errors/publicErrors.ts","../src/utils/waitUtils.ts","../src/observability/MultiTransactionObservabilityManager.ts","../src/utils/checksumUtils.ts","../src/utils/streamUtils.ts"],"sourcesContent":["export type { ErrorDetails } from './errors/types'\n\nexport {\n PublicNonRecoverableError,\n isPublicNonRecoverableError,\n type PublicNonRecoverableErrorParams,\n} from './errors/PublicNonRecoverableError'\n\nexport {\n InternalError,\n isInternalError,\n type InternalErrorParams,\n} from './errors/InternalError'\nexport { isEntityGoneError } from './errors/errorTypeGuards'\n\nexport { ConfigScope } from './config/ConfigScope'\nexport { ensureClosingSlashTransformer } from './config/configTransformers'\nexport { createRangeValidator } from './config/configValidators'\nexport {\n type EnvValueValidator,\n type EnvValueTransformer,\n type AppConfig,\n type RedisConfig,\n} from './config/configTypes'\n\nexport {\n type Either,\n type DefiniteEither,\n success,\n failure,\n isSuccess,\n isFailure,\n} from './errors/either'\n\nexport { EncryptionUtility } from './utils/encryptionUtility'\n\nexport {\n chunk,\n callChunked,\n removeFalsy,\n removeNullish,\n removeDuplicates,\n} from './utils/arrayUtils'\nexport {\n groupBy,\n groupByPath,\n groupByUnique,\n pick,\n pickWithoutUndefined,\n copyWithoutUndefined,\n copyWithoutEmpty,\n isEmptyObject,\n convertDateFieldsToIsoString,\n deepClone,\n transformToKebabCase,\n} from './utils/objectUtils'\n\nexport {\n isError,\n isStandardizedError,\n isObject,\n hasMessage,\n} from './utils/typeUtils'\nexport { type StandardizedError } from './utils/typeUtils'\n\nexport { generateHash, HashAlgorithm, HashEncoding } from './utils/hashUtils'\n\nexport {\n resolveLoggerConfiguration,\n resolveMonorepoLoggerConfiguration,\n resolveLogger,\n resolveMonorepoLogger,\n} from './logging/loggerConfigResolver'\nexport type { AppLoggerConfig, MonorepoAppLoggerConfig } from './logging/loggerConfigResolver'\nexport type { CommonLogger } from './logging/commonLogger'\n\nexport {\n type ErrorReport,\n type ErrorReporter,\n type ErrorResolver,\n} from './errors/errorReporterTypes'\nexport {\n executeAsyncAndHandleGlobalErrors,\n executeAndHandleGlobalErrors,\n executeSettleAllAndHandleGlobalErrors,\n globalLogger,\n resolveGlobalErrorLogObject,\n} from './errors/globalErrorHandler'\n\nexport { type MayOmit } from './common/may-omit'\nexport { type FreeformRecord } from './common/commonTypes'\nexport {\n type ValidationError,\n type CommonErrorParams,\n type OptionalMessageErrorParams,\n RequestValidationError,\n AccessDeniedError,\n EntityNotFoundError,\n EntityGoneError,\n AuthFailedError,\n} from './errors/publicErrors'\n\nexport { waitAndRetry } from './utils/waitUtils'\n\nexport type { TransactionObservabilityManager } from './observability/observabilityTypes'\nexport { MultiTransactionObservabilityManager } from './observability/MultiTransactionObservabilityManager'\n\nexport {\n generateChecksumForReadable,\n generateChecksumForObject,\n generateChecksumForBufferOrString,\n} from './utils/checksumUtils'\nexport { FsReadableProvider } from './utils/streamUtils'\nexport type {\n PersistToFsOptions,\n ReadableProvider,\n FsReadableProviderOptions,\n} from './utils/streamUtils'\n","// Error structure commonly used in libraries, e. g. fastify\nexport type StandardizedError = {\n code: string\n message: string\n}\n\nexport function hasMessage(maybe: unknown): maybe is { message: string } {\n return isObject(maybe) && typeof maybe.message === 'string'\n}\n\nexport function isObject(maybeObject: unknown): maybeObject is Record<PropertyKey, unknown> {\n return typeof maybeObject === 'object' && maybeObject !== null\n}\n\nexport function isStandardizedError(error: unknown): error is StandardizedError {\n return isObject(error) && typeof error.code === 'string' && typeof error.message === 'string'\n}\n\nexport function isError(maybeError: unknown): maybeError is Error {\n return (\n maybeError instanceof Error || Object.prototype.toString.call(maybeError) === '[object Error]'\n )\n}\n","import { isError } from '../utils/typeUtils'\nimport type { ErrorDetails } from './types'\n\nexport type PublicNonRecoverableErrorParams<T = ErrorDetails> = {\n message: string\n errorCode: string\n details?: T\n httpStatusCode?: number\n cause?: unknown\n}\n\nconst PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY = 'PUBLIC_NON_RECOVERABLE_ERROR_KEY'\nconst publicNonRecoverableErrorSymbol = Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)\n\n/**\n * This error is returned to the consumer of API\n */\nexport class PublicNonRecoverableError<T = ErrorDetails> extends Error {\n readonly [publicNonRecoverableErrorSymbol] = true\n public readonly details?: T\n public readonly errorCode: string\n public readonly httpStatusCode: number\n\n constructor(params: PublicNonRecoverableErrorParams<T>) {\n super(params.message, {\n cause: params.cause,\n })\n // set the name as the class name for every class that extends PublicNonRecoverableError\n this.name = this.constructor.name\n this.details = params.details\n this.errorCode = params.errorCode\n this.httpStatusCode = params.httpStatusCode ?? 500\n }\n}\n\nexport function isPublicNonRecoverableError(error: unknown): error is PublicNonRecoverableError {\n return (\n isError(error) &&\n // biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface\n ((error as any)[Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)] === true ||\n error.name === 'PublicNonRecoverableError')\n )\n}\n","import { isError } from '../utils/typeUtils'\nimport type { ErrorDetails } from './types'\n\nexport type InternalErrorParams<T = ErrorDetails> = {\n message: string\n errorCode: string\n details?: T\n cause?: unknown\n}\n\nconst INTERNAL_ERROR_SYMBOL_KEY = 'INTERNAL_ERROR_KEY'\nconst internalErrorSymbol = Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)\n\nexport class InternalError<T = ErrorDetails> extends Error {\n readonly [internalErrorSymbol] = true\n public readonly details?: T\n public readonly errorCode: string\n\n constructor(params: InternalErrorParams<T>) {\n super(params.message, {\n cause: params.cause,\n })\n // set the name as the class name for every class that extends InternalError\n this.name = this.constructor.name\n this.details = params.details\n this.errorCode = params.errorCode\n }\n}\n\nexport function isInternalError(error: unknown): error is InternalError {\n return (\n isError(error) &&\n // biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface\n ((error as any)[Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)] === true ||\n error.name === 'InternalError')\n )\n}\n","import { isPublicNonRecoverableError } from '../errors/PublicNonRecoverableError'\n\nimport type { EntityGoneError } from './publicErrors'\n\nexport function isEntityGoneError(entity: unknown): entity is EntityGoneError {\n return isPublicNonRecoverableError(entity) && entity.httpStatusCode === 410\n}\n","import type { ZodSchema } from 'zod'\n\nimport { InternalError } from '../errors/InternalError'\n\nimport type { EnvValueValidator } from './configTypes'\n\nexport type EnvType = {\n [key: string]: string | undefined\n}\n\nexport class ConfigScope {\n private env: EnvType\n\n constructor(envOverride?: EnvType) {\n this.env = envOverride ?? { ...process.env }\n }\n\n updateEnv() {\n // Accessing process.env values is slow, so we cache them\n this.env = { ...process.env }\n }\n\n getMandatoryInteger(param: string): number {\n const rawValue = this.env[param]\n if (!rawValue) {\n throw new InternalError({\n message: `Missing mandatory configuration parameter: ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getMandatory(param: string): string {\n const result = this.env[param]\n if (!result) {\n throw new InternalError({\n message: `Missing mandatory configuration parameter: ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return result\n }\n\n getMandatoryOneOf<const T>(param: string, supportedValues: T[]): T {\n const result = this.getMandatory(param)\n return validateOneOf(\n result,\n supportedValues,\n `Unsupported ${param}: ${result}. Supported values: ${supportedValues.toString()}`,\n )\n }\n\n getMandatoryValidatedInteger(param: string, validator: EnvValueValidator<number>): number {\n const value = this.getMandatoryInteger(param)\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return value\n }\n\n getOptionalNullable<T extends string | null | undefined>(\n param: string,\n defaultValue: T,\n ): T | string {\n return this.env[param] || defaultValue\n }\n\n getOptional(param: string, defaultValue: string): string {\n // Using the `||` operator instead of `??`, since '' is not a valid value, and 0 (number) is not expected here\n return this.env[param] || defaultValue\n }\n\n getOptionalInteger(param: string, defaultValue: number): number {\n const rawValue = this.env[param]\n if (!rawValue) {\n return defaultValue\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getOptionalNullableInteger<T extends number | null | undefined>(\n param: string,\n defaultValue: T,\n ): T | number {\n const rawValue = this.env[param]\n if (!rawValue) {\n return defaultValue\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getOptionalOneOf<const T extends string>(\n param: string,\n defaultValue: T,\n supportedValues: T[],\n ): T {\n const result = this.getOptional(param, defaultValue)\n return validateOneOf(\n result,\n supportedValues,\n `Unsupported ${param}: ${result}. Supported values: ${supportedValues.toString()}`,\n )\n }\n\n getOptionalValidated(\n param: string,\n defaultValue: string,\n validator: EnvValueValidator<string>,\n ): string {\n const value = this.env[param] || defaultValue\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return value\n }\n\n getOptionalValidatedInteger(\n param: string,\n defaultValue: number,\n validator: EnvValueValidator<number>,\n ): number {\n const value = this.getOptionalInteger(param, defaultValue)\n\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n\n return value\n }\n\n getOptionalTransformed(\n param: string,\n defaultValue: string,\n transformer: (value: string) => string,\n ): string {\n const value = this.env[param] || defaultValue\n return transformer(value)\n }\n\n getOptionalNullableTransformed<T extends string | undefined>(\n param: string,\n defaultValue: T,\n transformer: (value: T | string) => T | string,\n ): T | string {\n const value = this.env[param] || defaultValue\n return transformer(value as T)\n }\n\n getMandatoryTransformed(param: string, transformer: (value: string) => string) {\n const value = this.getMandatory(param)\n\n return transformer(value)\n }\n\n getOptionalBoolean(param: string, defaultValue: boolean): boolean {\n const rawValue = this.env[param]?.toLowerCase()\n if (rawValue === undefined || rawValue === '') {\n return defaultValue\n }\n\n validateOneOf(rawValue, ['true', 'false'])\n\n return rawValue === 'true'\n }\n\n getMandatoryJsonObject<T extends object>(param: string, schema: ZodSchema<T>): T {\n const rawValue = this.getMandatory(param)\n return this.validateSchema(\n JSON.parse(rawValue),\n schema,\n `Configuration parameter ${param} must be a valid JSON meeting the given schema, but was ${rawValue}`,\n )\n }\n\n getOptionalNullableJsonObject<T extends object, Z extends T | null | undefined>(\n param: string,\n schema: ZodSchema<T>,\n defaultValue: Z,\n ): Z {\n const rawValue = this.getOptionalNullable(param, undefined)\n if (!rawValue) {\n return defaultValue\n }\n\n return this.validateSchema(\n JSON.parse(rawValue),\n schema,\n `Configuration parameter ${param} must be a valid JSON meeting the given schema, but was ${rawValue}`,\n ) as Z\n }\n\n getOptionalJsonObject<T extends object>(param: string, schema: ZodSchema<T>, defaultValue: T): T {\n return this.getOptionalNullableJsonObject(param, schema, defaultValue)\n }\n\n isProduction(): boolean {\n return this.env.NODE_ENV === 'production'\n }\n\n isDevelopment(): boolean {\n return this.env.NODE_ENV !== 'production'\n }\n\n isTest(): boolean {\n return this.env.NODE_ENV === 'test'\n }\n\n private validateSchema<T extends object>(\n value: unknown,\n schema: ZodSchema<T>,\n errorMessage: string,\n ): T {\n const parsedValue = schema.safeParse(value)\n if (!parsedValue.success) {\n throw new InternalError({\n message: errorMessage,\n errorCode: 'CONFIGURATION_ERROR',\n details: parsedValue.error,\n })\n }\n\n return parsedValue.data\n }\n}\n\nexport function validateOneOf<const T>(\n validatedEntity: unknown,\n expectedOneOfEntities: T[],\n errorText?: string,\n): T {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n if (!expectedOneOfEntities.includes(validatedEntity as T)) {\n throw new InternalError({\n message:\n errorText ||\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Validated entity ${validatedEntity} is not one of: ${expectedOneOfEntities.toString()}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return validatedEntity as T\n}\n\nexport function validateNumber(validatedObject: unknown, errorText: string): number {\n if (!Number.isFinite(validatedObject)) {\n throw new InternalError({\n message: errorText,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return validatedObject as number\n}\n","import type { EnvValueTransformer } from './configTypes'\n\nexport const ensureClosingSlashTransformer: EnvValueTransformer<\n string | undefined | null,\n string\n> = (value) => {\n if (!value) {\n return ''\n }\n\n const lastChar = value.at(-1)\n if (lastChar !== '/') {\n return `${value}/`\n }\n return value\n}\n","import type { EnvValueValidator } from './configTypes'\n\nexport const createRangeValidator = (\n greaterOrEqualThan: number,\n lessOrEqualThan: number,\n): EnvValueValidator<number> => {\n return (value) => {\n return value >= greaterOrEqualThan && value <= lessOrEqualThan\n }\n}\n","type Left<T> = {\n error: T\n result?: never\n}\n\ntype Right<U> = {\n error?: never\n result: U\n}\n\n/**\n * Either is a functional programming type which is used to communicate errors happening in potentially recoverable scenarios.\n * It can return either an error (Left side) or a resolved result (Right side), but not both.\n * It is up to caller of the function to handle received error or throw (Public)NonRecoverableError if it cannot.\n *\n * @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}\n */\nexport type Either<T, U> = NonNullable<Left<T> | Right<U>>\n\n/***\n * Variation of Either, which may or may not have Error set, but always has Result\n */\nexport type DefiniteEither<T, U> = {\n error?: T\n result: U\n}\n\nexport const isFailure = <T, U>(e: Either<T, U>): e is Left<T> => {\n return e.error !== undefined\n}\n\nexport const isSuccess = <T, U>(e: Either<T, U>): e is Right<U> => {\n return e.result !== undefined\n}\n\nexport const failure = <T>(error: T): Left<T> => ({ error })\n\nexport const success = <U>(result: U): Right<U> => ({ result })\n","import * as crypto from 'node:crypto'\n\nconst algorithm = 'aes-256-gcm'\nconst ivLength = 16\nconst tagLength = 16\nconst defaultEncoding = 'hex'\nconst defaultSaltLength = 64\nconst defaultPbkdf2Iterations = 100000\n\nexport type Options = {\n saltLength?: number\n pbkdf2Iterations?: number\n encoding?: NodeJS.BufferEncoding\n}\n\n/**\n * Type-scripted version of https://github.com/MauriceButler/cryptr\n */\nexport class EncryptionUtility {\n private readonly secret: string\n private readonly saltLength: number\n private readonly encryptedPosition: number\n private readonly tagPosition: number\n private readonly pbkdf2Iterations: number\n private readonly encoding: NodeJS.BufferEncoding\n\n constructor(secret: string, options?: Options) {\n this.secret = secret\n\n this.encoding = options?.encoding ?? defaultEncoding\n this.pbkdf2Iterations = options?.pbkdf2Iterations ?? defaultPbkdf2Iterations\n this.saltLength = options?.saltLength ?? defaultSaltLength\n\n this.tagPosition = this.saltLength + ivLength\n this.encryptedPosition = this.tagPosition + tagLength\n }\n\n private getKey(salt: Buffer) {\n return crypto.pbkdf2Sync(this.secret, salt, this.pbkdf2Iterations, 32, 'sha512')\n }\n\n public encrypt(value: string) {\n const iv = crypto.randomBytes(ivLength)\n const salt = crypto.randomBytes(this.saltLength)\n\n const key = this.getKey(salt)\n\n const cipher = crypto.createCipheriv(algorithm, key, iv)\n const encrypted = Buffer.concat([cipher.update(String(value), 'utf8'), cipher.final()])\n\n const tag = cipher.getAuthTag()\n\n return Buffer.concat([salt, iv, tag, encrypted]).toString(this.encoding)\n }\n\n public decrypt(value: string) {\n const stringValue = Buffer.from(String(value), this.encoding)\n\n const salt = stringValue.subarray(0, this.saltLength)\n const iv = stringValue.subarray(this.saltLength, this.tagPosition)\n const tag = stringValue.subarray(this.tagPosition, this.encryptedPosition)\n const encrypted = stringValue.subarray(this.encryptedPosition)\n\n const key = this.getKey(salt)\n\n const decipher = crypto.createDecipheriv(algorithm, key, iv)\n\n decipher.setAuthTag(tag)\n\n return Buffer.concat([\n decipher.update(encrypted),\n Buffer.from(decipher.final('utf8')),\n ]).toString('utf8')\n }\n}\n","export function chunk<T>(array: T[], chunkSize: number): T[][] {\n const length = array.length\n if (!length || chunkSize < 1) {\n return []\n }\n let index = 0\n let resIndex = 0\n const result = new Array(Math.ceil(length / chunkSize))\n\n while (index < length) {\n // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>\n result[resIndex++] = array.slice(index, (index += chunkSize))\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return result\n}\n\nexport async function callChunked<Item>(\n chunkSize: number,\n array: readonly Item[],\n processFn: (arrayChunk: Item[]) => Promise<unknown>,\n): Promise<void> {\n for (let i = 0; i < array.length; i += chunkSize) {\n const arrayChunk = array.slice(i, i + chunkSize)\n await processFn(arrayChunk)\n }\n}\n\n/**\n * Return a copy of the given array without null or undefined values\n */\nexport function removeNullish<const T>(array: readonly (T | null | undefined)[]): T[] {\n return array.filter((e) => e !== undefined && e !== null) as T[]\n}\n\n/**\n * Return a copy of the given array without falsy values (eg: false, 0, '', null, undefined)\n */\nexport function removeFalsy<const T>(\n array: readonly (T | null | undefined | 0 | '' | false)[],\n): T[] {\n return array.filter((e) => e) as T[]\n}\n\n/**\n * Return a copy of the given array without duplicates.\n */\nexport function removeDuplicates<const T>(array: readonly T[]): T[] {\n return [...new Set(array)]\n}\n","import dotProp from 'dot-prop'\n\nimport { InternalError } from '../errors/InternalError'\n\ntype RecordKeyType = string | number | symbol\n\nexport function copyWithoutUndefined<\n T extends Record<RecordKeyType, unknown>,\n TargetRecordType = Pick<\n T,\n {\n [Prop in keyof T]: T[Prop] extends null | undefined ? never : Prop\n }[keyof T]\n >,\n>(originalValue: T): TargetRecordType {\n return Object.keys(originalValue).reduce(\n (acc, key) => {\n // @ts-ignore\n if (originalValue[key] !== undefined) {\n // @ts-ignore\n acc[key] = originalValue[key]\n }\n return acc\n },\n {} as Record<string, unknown>,\n ) as TargetRecordType\n}\n\nexport function copyWithoutEmpty<\n T extends Record<RecordKeyType, unknown>,\n TargetRecordType = Pick<\n T,\n {\n [Prop in keyof T]: T[Prop] extends null | undefined | '' ? never : Prop\n }[keyof T]\n >,\n>(originalValue: T): TargetRecordType {\n return Object.keys(originalValue).reduce(\n (acc, key) => {\n if (\n originalValue[key] !== undefined &&\n originalValue[key] !== null &&\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n (typeof originalValue[key] !== 'string' || originalValue[key].trim().length > 0)\n ) {\n // @ts-ignore\n acc[key] = originalValue[key]\n }\n return acc\n },\n {} as Record<string, unknown>,\n ) as TargetRecordType\n}\n\nexport function pick<T, K extends string | number | symbol>(\n source: T,\n propNames: readonly K[],\n): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>> {\n const result = {} as T\n let idx = 0\n while (idx < propNames.length) {\n // @ts-ignore\n if (propNames[idx] in source) {\n // @ts-ignore\n result[propNames[idx]] = source[propNames[idx]]\n }\n idx += 1\n }\n return result\n}\n\nexport function pickWithoutUndefined<T, K extends string | number | symbol>(\n source: T,\n propNames: readonly K[],\n): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>> {\n const result = {} as T\n let idx = 0\n while (idx < propNames.length) {\n // @ts-ignore\n if (propNames[idx] in source && source[propNames[idx]] !== undefined) {\n // @ts-ignore\n result[propNames[idx]] = source[propNames[idx]]\n }\n idx += 1\n }\n return result\n}\n\nexport function isEmptyObject(params: Record<string, unknown>): boolean {\n for (const key in params) {\n if (Object.hasOwn(params, key) && params[key] !== undefined) {\n return false\n }\n }\n return true\n}\n\ntype KeysMatching<T, V> = { [K in keyof T]: T[K] extends V ? K : never }[keyof T]\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects.\n * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.\n */\nexport function groupBy<\n T extends object,\n K extends KeysMatching<T, RecordKeyType | null | undefined>,\n>(array: T[], selector: K): Record<RecordKeyType, T[]> {\n return array.reduce(\n (acc, item) => {\n const key = item[selector] as RecordKeyType | null | undefined\n if (key === undefined || key === null) {\n return acc\n }\n if (!acc[key]) {\n acc[key] = []\n }\n acc[key].push(item)\n return acc\n },\n {} as Record<RecordKeyType, T[]>,\n )\n}\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects. Support nested keys.\n * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.\n */\nexport function groupByPath<T extends object>(array: T[], selector: string): Record<string, T[]> {\n return array.reduce(\n (acc, item) => {\n const key = dotProp.get(item, selector)\n if (key === undefined || key === null) {\n return acc\n }\n const strKeyPath = key as string\n\n if (!acc[strKeyPath]) {\n acc[strKeyPath] = []\n }\n acc[strKeyPath].push(item)\n return acc\n },\n {} as Record<RecordKeyType, T[]>,\n )\n}\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects.\n * @returns An object where the keys are unique values from the given selector and the value is the\n * corresponding object from the array.\n * @throws InternalError If a duplicated value is found for the given selector.\n */\nexport function groupByUnique<\n T extends object,\n K extends KeysMatching<T, RecordKeyType | null | undefined>,\n>(array: T[], selector: K): Record<RecordKeyType, T> {\n return array.reduce(\n (acc, item) => {\n const key = item[selector] as RecordKeyType | null | undefined\n if (key === undefined || key === null) {\n return acc\n }\n if (acc[key] !== undefined) {\n throw new InternalError({\n message: `Duplicated item for selector ${selector.toString()} with value ${key.toString()}`,\n errorCode: 'DUPLICATED_ITEM',\n details: { selector, value: key },\n })\n }\n acc[key] = item\n return acc\n },\n {} as Record<RecordKeyType, T>,\n )\n}\n\ntype DatesAsString<T> = T extends Date ? string : ExactlyLikeWithDateAsString<T>\n\ntype ExactlyLikeWithDateAsString<T> = T extends object ? { [K in keyof T]: DatesAsString<T[K]> } : T\n\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input,\n): ExactlyLikeWithDateAsString<Input>\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input[],\n): ExactlyLikeWithDateAsString<Input>[]\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input | Input[],\n): ExactlyLikeWithDateAsString<Input> | ExactlyLikeWithDateAsString<Input>[] {\n if (Array.isArray(object)) {\n // @ts-ignore\n return object.map(convertDateFieldsToIsoStringAux)\n }\n\n return Object.entries(object).reduce(\n (result, [key, value]) => {\n // @ts-ignore\n result[key] = convertDateFieldsToIsoStringAux(value)\n return result\n },\n {} as ExactlyLikeWithDateAsString<Input>,\n )\n}\n\nfunction convertDateFieldsToIsoStringAux<T>(item: T): DatesAsString<T> {\n if (item instanceof Date) {\n // @ts-ignore\n return item.toISOString()\n }\n\n if (item && typeof item === 'object') {\n // @ts-ignore\n return convertDateFieldsToIsoString(item)\n }\n\n // @ts-ignore\n return item\n}\n\n/**\n * Return a deep clone copy of an object.\n *\n * Please Note: This uses structuredClone, which has the limitations of these restricted Types: functions,\n * Error objects, WeakMap, WeakSet, DOM nodes, and certain other browser-specific objects like Window.\n */\nexport function deepClone<T extends object | undefined | null>(object: T): T {\n if (object === undefined || object === null) {\n return object\n }\n return structuredClone(object)\n}\n\nfunction transformKey(key: string): string {\n return key\n .replace(/([a-z])([A-Z])/g, '$1-$2') // transforms basic camelCase\n .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2') // transforms abbreviations\n .replace(/_/g, '-') // transforms snake_case\n .toLowerCase() // finally lowercase all\n}\n\ntype TransformToKebabCaseInputType = Record<string, unknown> | null | undefined\ntype TransformToKebabCaseReturnType<Input, Output> = Input extends Record<string, unknown>\n ? Output\n : Input\n/**\n * Transforms an object's keys from camelCase or snake_case to kebab-case.\n * @param object\n */\nexport function transformToKebabCase<\n Output extends Record<string, unknown>,\n Input extends TransformToKebabCaseInputType,\n>(object: Input): TransformToKebabCaseReturnType<Input, Output>\n\nexport function transformToKebabCase<\n Output extends Record<string, unknown>,\n Input extends TransformToKebabCaseInputType,\n>(object: Input[]): TransformToKebabCaseReturnType<Input, Output>[]\n\nexport function transformToKebabCase<Output, Input>(\n object: Input | Input[],\n): TransformToKebabCaseReturnType<Input, Output> | TransformToKebabCaseReturnType<Input, Output>[] {\n if (Array.isArray(object)) {\n // @ts-ignore\n return object.map(transformToKebabCase)\n }\n if (typeof object !== 'object' || object === null || object === undefined) {\n return object as TransformToKebabCaseReturnType<Input, Output>\n }\n\n return Object.entries(object as Record<string, unknown>).reduce(\n (result, [key, value]) => {\n const transformedKey = transformKey(key)\n const transformedValue =\n value && typeof value === 'object'\n ? transformToKebabCase(value as TransformToKebabCaseInputType)\n : value\n\n // Avoiding destructuring by directly assigning the new key-value pair\n result[transformedKey] = transformedValue\n return result\n },\n {} as Record<string, unknown>,\n ) as TransformToKebabCaseReturnType<Input, Output>\n}\n","import { createHash } from 'node:crypto'\n\nexport enum HashEncoding {\n HEX = 'hex',\n BASE64 = 'base64',\n}\n\nexport enum HashAlgorithm {\n SHA256 = 'sha256',\n SHA512 = 'sha512',\n}\n\nexport function generateHash(\n algorithm: HashAlgorithm,\n data: string,\n encoding: HashEncoding = HashEncoding.HEX,\n) {\n return createHash(algorithm).update(data).digest(encoding)\n}\n","import type { Level, Logger, LoggerOptions, redactOptions } from 'pino'\nimport { levels, pino } from 'pino'\nimport pretty from 'pino-pretty'\n\nexport type AppLoggerConfig = {\n logLevel: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n nodeEnv: 'production' | 'development' | 'test'\n base?: Record<string, unknown>\n redact?: redactOptions\n}\n\nexport type MonorepoAppLoggerConfig = AppLoggerConfig & {\n targetFile?: string\n append?: boolean\n}\n\n/* c8 ignore next 8 */\nexport function resolveMonorepoLogger(appConfig: MonorepoAppLoggerConfig): Logger {\n if (appConfig.nodeEnv !== 'development') {\n return resolveLogger(appConfig)\n }\n\n const configuration = resolveMonorepoLoggerConfiguration(appConfig) as LoggerOptions\n return pino(configuration)\n}\n\n// Note that transports do not work in vitest, likely because pino attempts to run them in a separate worker\n/* c8 ignore next 25 */\nexport function resolveMonorepoLoggerConfiguration(\n appConfig: MonorepoAppLoggerConfig,\n): LoggerOptions | Logger {\n if (appConfig.nodeEnv !== 'development') {\n return resolveLoggerConfiguration(appConfig)\n }\n\n return {\n level: appConfig.logLevel,\n formatters: {\n level: (label) => {\n return { level: label }\n },\n },\n redact: appConfig.redact,\n transport: {\n target: 'pino/file',\n options: {\n destination: appConfig.targetFile ?? './service.log',\n mkdir: true,\n append: appConfig.append ?? false,\n },\n },\n }\n}\n\nexport function resolveLogger(appConfig: AppLoggerConfig): Logger {\n if (appConfig.nodeEnv !== 'production') {\n return resolveLoggerConfiguration(appConfig) as Logger\n }\n\n const configuration = resolveLoggerConfiguration(appConfig) as LoggerOptions\n return pino(configuration)\n}\n\nexport function resolveLoggerConfiguration(appConfig: AppLoggerConfig): LoggerOptions | Logger {\n if (appConfig.nodeEnv !== 'production') {\n return pino(\n pretty({\n sync: true,\n minimumLevel: appConfig.logLevel as Level,\n colorize: true,\n translateTime: 'SYS:standard',\n ignore: 'hostname,pid',\n }),\n )\n }\n\n return {\n level: appConfig.logLevel,\n formatters: {\n level: (_label, numericLevel): { level: string } => {\n const level = levels.labels[numericLevel] || 'unknown'\n return { level }\n },\n },\n redact: appConfig.redact,\n } satisfies LoggerOptions\n}\n","import { types } from 'node:util'\n\nimport type { SerializedError } from 'pino'\nimport { levels, pino, stdSerializers } from 'pino'\n\nimport type { CommonLogger } from '../logging/commonLogger'\nimport { hasMessage } from '../utils/typeUtils'\n\ntype LogObject = {\n message: string\n 'x-request-id'?: string\n error?: SerializedError\n}\n\nexport const globalLogger: CommonLogger = pino({\n formatters: {\n level: (_label, numericLevel): { level: string } => {\n const level = levels.labels[numericLevel] || 'unknown'\n return { level }\n },\n },\n})\n\nexport function resolveGlobalErrorLogObject(err: unknown, correlationId?: string): LogObject {\n if (types.isNativeError(err)) {\n return {\n message: err.message,\n error: stdSerializers.err(err),\n 'x-request-id': correlationId,\n }\n }\n\n if (hasMessage(err)) {\n return {\n message: err.message,\n 'x-request-id': correlationId,\n }\n }\n\n return {\n message: 'Unknown error',\n 'x-request-id': correlationId,\n }\n}\n\nexport function executeAndHandleGlobalErrors<T>(operation: () => T) {\n try {\n const result = operation()\n return result\n } catch (err) {\n const logObject = resolveGlobalErrorLogObject(err)\n globalLogger.error(logObject, logObject.message)\n process.exit(1)\n }\n}\n\nexport async function executeAsyncAndHandleGlobalErrors<T>(\n operation: () => Promise<T>,\n stopOnError = true,\n) {\n try {\n const result = await operation()\n return result\n } catch (err) {\n const logObject = resolveGlobalErrorLogObject(err)\n globalLogger.error(logObject, logObject.message)\n if (stopOnError) {\n process.exit(1)\n }\n }\n}\n\nexport async function executeSettleAllAndHandleGlobalErrors(\n promises: Promise<unknown>[],\n stopOnError = true,\n) {\n const result = await Promise.allSettled(promises)\n\n let errorsHappened: boolean | undefined\n for (const entry of result) {\n if (entry.status === 'rejected') {\n const logObject = resolveGlobalErrorLogObject(entry.reason)\n globalLogger.error(logObject, logObject.message)\n errorsHappened = true\n }\n }\n\n if (stopOnError && errorsHappened) {\n process.exit(1)\n }\n\n return result\n}\n","import { constants as httpConstants } from 'node:http2'\n\nimport type { FreeformRecord } from '../common/commonTypes'\n\nimport { PublicNonRecoverableError } from './PublicNonRecoverableError'\n\nexport type CommonErrorParams = {\n message: string\n details?: FreeformRecord\n cause?: Error\n}\n\nexport type OptionalMessageErrorParams = Partial<CommonErrorParams>\n\nexport type ValidationError = {\n message: string\n path: string[]\n}\n\nexport class RequestValidationError extends PublicNonRecoverableError {\n constructor(errors: ValidationError[]) {\n super({\n message: 'Invalid params',\n errorCode: 'VALIDATION_ERROR',\n httpStatusCode: httpConstants.HTTP_STATUS_BAD_REQUEST,\n details: {\n error: errors,\n },\n })\n }\n}\n\nexport class AccessDeniedError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ACCESS_DENIED',\n httpStatusCode: httpConstants.HTTP_STATUS_FORBIDDEN,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n\nexport class EntityNotFoundError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ENTITY_NOT_FOUND',\n httpStatusCode: httpConstants.HTTP_STATUS_NOT_FOUND,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n\nexport class EntityGoneError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ENTITY_GONE',\n httpStatusCode: 410,\n details: params.details,\n })\n }\n}\n\nexport class AuthFailedError extends PublicNonRecoverableError {\n constructor(params: OptionalMessageErrorParams = {}) {\n super({\n message: params.message ?? 'Authentication failed',\n errorCode: 'AUTH_FAILED',\n httpStatusCode: httpConstants.HTTP_STATUS_UNAUTHORIZED,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n","export const waitAndRetry = async <T>(\n predicateFn: () => T,\n sleepTime = 20,\n maxRetryCount = 15,\n): Promise<T> => {\n return new Promise((resolve, reject) => {\n let retryCount = 0\n function performCheck() {\n // amount of retries exceeded\n if (maxRetryCount !== 0 && retryCount > maxRetryCount) {\n resolve(predicateFn())\n }\n\n // Try executing predicateFn\n Promise.resolve()\n .then(() => {\n return predicateFn()\n })\n .then((result) => {\n if (result) {\n resolve(result)\n } else {\n retryCount++\n setTimeout(performCheck, sleepTime)\n }\n })\n .catch((err) => {\n reject(err)\n })\n }\n\n performCheck()\n })\n}\n","import type { TransactionObservabilityManager } from './observabilityTypes'\n\n/**\n * Groups different TransactionObservabilityManager instances into one\n * to facilitate tracking transactions across multiple observability tools.\n */\nexport class MultiTransactionObservabilityManager implements TransactionObservabilityManager {\n private readonly managers: TransactionObservabilityManager[]\n\n constructor(managers: TransactionObservabilityManager[]) {\n this.managers = managers\n }\n\n start(transactionName: string, uniqueTransactionKey: string): void {\n for (const manager of this.managers) {\n manager.start(transactionName, uniqueTransactionKey)\n }\n }\n\n startWithGroup(\n transactionName: string,\n uniqueTransactionKey: string,\n transactionGroup: string,\n ): void {\n for (const manager of this.managers) {\n manager.startWithGroup(transactionName, uniqueTransactionKey, transactionGroup)\n }\n }\n\n stop(uniqueTransactionKey: string, wasSuccessful?: boolean): void {\n for (const manager of this.managers) {\n manager.stop(uniqueTransactionKey, wasSuccessful)\n }\n }\n}\n","import type { BinaryLike } from 'node:crypto'\nimport { createHash } from 'node:crypto'\nimport type { Readable } from 'node:stream'\n\nconst HASH_ALGORITHM = 'md5'\n\nexport function generateChecksumForBufferOrString(data: BinaryLike): string {\n return createHash(HASH_ALGORITHM).update(data).digest('hex')\n}\n\nexport function generateChecksumForObject(object: object): string {\n const objectAsString = JSON.stringify(object)\n return generateChecksumForBufferOrString(objectAsString)\n}\n\nexport function generateChecksumForReadable(readable: Readable): Promise<string> {\n return new Promise((resolve, reject) => {\n const hashCreator = createHash(HASH_ALGORITHM)\n readable.on('data', (data) => {\n if (Buffer.isBuffer(data)) {\n hashCreator.update(data)\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hashCreator.update(Buffer.from(data))\n }\n })\n\n readable.on('end', () => {\n const hash = hashCreator.digest('hex')\n resolve(hash)\n })\n readable.on('error', (err) => {\n /* c8 ignore next 1 */\n reject(err)\n })\n })\n}\n","import { F_OK } from 'node:constants'\nimport { access, createReadStream, createWriteStream } from 'node:fs'\nimport { stat, unlink } from 'node:fs/promises'\nimport type { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream'\n\nexport type ReadableProvider = {\n /**\n * Guarantees to provide a new stream every time this is called, before `destroy` is invoked.\n */\n createStream(): Promise<Readable>\n\n /**\n * Returns size of the persisted content\n */\n getContentLength(): Promise<number>\n\n /**\n * Remove the persisted value. No new streams can be created after this is called\n */\n destroy(): Promise<void>\n}\n\nexport type PersistToFsOptions = {\n targetFile: string\n sourceReadable: Readable\n}\n\nexport type FsReadableProviderOptions = {\n storageFile: string\n}\n\nexport class FsReadableProvider implements ReadableProvider {\n public readonly storageFile: string\n constructor(options: FsReadableProviderOptions) {\n this.storageFile = options.storageFile\n }\n\n fileExists(): Promise<boolean> {\n return new Promise((resolve) => {\n access(this.storageFile, F_OK, (err) => {\n return resolve(!err)\n })\n })\n }\n\n async getContentLength(): Promise<number> {\n if (!(await this.fileExists())) {\n throw new Error(`File ${this.storageFile} was already deleted.`)\n }\n const stats = await stat(this.storageFile)\n return stats.size\n }\n\n async createStream(): Promise<Readable> {\n if (!(await this.fileExists())) {\n throw new Error(`File ${this.storageFile} was already deleted.`)\n }\n\n return createReadStream(this.storageFile)\n }\n\n async destroy(): Promise<void> {\n if (!(await this.fileExists())) {\n // nothing to do here\n return\n }\n\n return unlink(this.storageFile)\n }\n\n protected async persist(sourceReadable: Readable): Promise<void> {\n const writable = createWriteStream(this.storageFile)\n return new Promise((resolve, reject) => {\n pipeline(sourceReadable, writable, (err) => {\n if (err) {\n /* c8 ignore next 1 */\n reject(err)\n } else {\n resolve()\n }\n })\n })\n }\n\n public static async persistReadableToFs(\n options: PersistToFsOptions,\n ): Promise<FsReadableProvider> {\n const provider = new FsReadableProvider({\n storageFile: options.targetFile,\n })\n await provider.persist(options.sourceReadable)\n return provider\n }\n}\n\n/**\n * Consumes the readable in order to calculate its length in bytes\n * @param readable\n */\nexport function getReadableContentLength(readable: Readable): Promise<number> {\n return new Promise((resolve, reject) => {\n let size = 0\n readable.on('data', (chunk) => {\n if (typeof chunk === 'string' || Buffer.isBuffer(chunk)) {\n size += Buffer.byteLength(chunk)\n }\n })\n readable.on('end', () => {\n resolve(size)\n })\n readable.on('error', (error) => {\n /* c8 ignore next 1 */\n reject(error)\n })\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,SAAS,WAAW,OAA8C;AACvE,SAAO,SAAS,KAAK,KAAK,OAAO,MAAM,YAAY;AACrD;AAEO,SAAS,SAA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K,WAAW,GAAI;AAC9B,YAAM,IAAI,MAAM,QAAQ,KAAK,WAAW,uBAAuB;AAAA,IACjE;AACA,UAAM,QAAQ,UAAM,sBAAK,KAAK,WAAW;AACzC,WAAO,MAAM;AAAA,EACf;AAAA,EAEA,MAAM,eAAkC;AACtC,QAAI,CAAE,MAAM,KAAK,WAAW,GAAI;AAC9B,YAAM,IAAI,MAAM,QAAQ,KAAK,WAAW,uBAAuB;AAAA,IACjE;AAEA,eAAO,iCAAiB,KAAK,WAAW;AAAA,EAC1C;AAAA,EAEA,MAAM,UAAyB;AAC7B,QAAI,CAAE,MAAM,KAAK,WAAW,GAAI;AAE9B;AAAA,IACF;AAEA,eAAO,wBAAO,KAAK,WAAW;AAAA,EAChC;AAAA,EAEA,MAAgB,QAAQ,gBAAyC;AAC/D,UAAM,eAAW,kCAAkB,KAAK,WAAW;AACnD,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,uCAAS,gBAAgB,UAAU,CAAC,QAAQ;AAC1C,YAAI,KAAK;AAEP,iBAAO,GAAG;AAAA,QACZ,OAAO;AACL,kBAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,aAAoB,oBAClB,SAC6B;AAC7B,UAAM,WAAW,IAAI,oBAAmB;AAAA,MACtC,aAAa,QAAQ;AAAA,IACvB,CAAC;AACD,UAAM,SAAS,QAAQ,QAAQ,cAAc;AAC7C,WAAO;AAAA,EACT;AACF;","names":["dotProp","HashEncoding","HashAlgorithm","algorithm","pretty","import_pino","httpConstants","import_node_crypto"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -246,6 +246,14 @@ declare function convertDateFieldsToIsoString<Input extends object>(object: Inpu
|
|
|
246
246
|
* Error objects, WeakMap, WeakSet, DOM nodes, and certain other browser-specific objects like Window.
|
|
247
247
|
*/
|
|
248
248
|
declare function deepClone<T extends object | undefined | null>(object: T): T;
|
|
249
|
+
type TransformToKebabCaseInputType = Record<string, unknown> | null | undefined;
|
|
250
|
+
type TransformToKebabCaseReturnType<Input, Output> = Input extends Record<string, unknown> ? Output : Input;
|
|
251
|
+
/**
|
|
252
|
+
* Transforms an object's keys from camelCase or snake_case to kebab-case.
|
|
253
|
+
* @param object
|
|
254
|
+
*/
|
|
255
|
+
declare function transformToKebabCase<Output extends Record<string, unknown>, Input extends TransformToKebabCaseInputType>(object: Input): TransformToKebabCaseReturnType<Input, Output>;
|
|
256
|
+
declare function transformToKebabCase<Output extends Record<string, unknown>, Input extends TransformToKebabCaseInputType>(object: Input[]): TransformToKebabCaseReturnType<Input, Output>[];
|
|
249
257
|
|
|
250
258
|
type StandardizedError = {
|
|
251
259
|
code: string;
|
|
@@ -401,4 +409,4 @@ declare class FsReadableProvider implements ReadableProvider {
|
|
|
401
409
|
static persistReadableToFs(options: PersistToFsOptions): Promise<FsReadableProvider>;
|
|
402
410
|
}
|
|
403
411
|
|
|
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 };
|
|
412
|
+
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, transformToKebabCase, waitAndRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -246,6 +246,14 @@ declare function convertDateFieldsToIsoString<Input extends object>(object: Inpu
|
|
|
246
246
|
* Error objects, WeakMap, WeakSet, DOM nodes, and certain other browser-specific objects like Window.
|
|
247
247
|
*/
|
|
248
248
|
declare function deepClone<T extends object | undefined | null>(object: T): T;
|
|
249
|
+
type TransformToKebabCaseInputType = Record<string, unknown> | null | undefined;
|
|
250
|
+
type TransformToKebabCaseReturnType<Input, Output> = Input extends Record<string, unknown> ? Output : Input;
|
|
251
|
+
/**
|
|
252
|
+
* Transforms an object's keys from camelCase or snake_case to kebab-case.
|
|
253
|
+
* @param object
|
|
254
|
+
*/
|
|
255
|
+
declare function transformToKebabCase<Output extends Record<string, unknown>, Input extends TransformToKebabCaseInputType>(object: Input): TransformToKebabCaseReturnType<Input, Output>;
|
|
256
|
+
declare function transformToKebabCase<Output extends Record<string, unknown>, Input extends TransformToKebabCaseInputType>(object: Input[]): TransformToKebabCaseReturnType<Input, Output>[];
|
|
249
257
|
|
|
250
258
|
type StandardizedError = {
|
|
251
259
|
code: string;
|
|
@@ -401,4 +409,4 @@ declare class FsReadableProvider implements ReadableProvider {
|
|
|
401
409
|
static persistReadableToFs(options: PersistToFsOptions): Promise<FsReadableProvider>;
|
|
402
410
|
}
|
|
403
411
|
|
|
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 };
|
|
412
|
+
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, transformToKebabCase, waitAndRetry };
|
package/dist/index.js
CHANGED
|
@@ -494,6 +494,26 @@ function deepClone(object) {
|
|
|
494
494
|
}
|
|
495
495
|
return structuredClone(object);
|
|
496
496
|
}
|
|
497
|
+
function transformKey(key) {
|
|
498
|
+
return key.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
|
|
499
|
+
}
|
|
500
|
+
function transformToKebabCase(object) {
|
|
501
|
+
if (Array.isArray(object)) {
|
|
502
|
+
return object.map(transformToKebabCase);
|
|
503
|
+
}
|
|
504
|
+
if (typeof object !== "object" || object === null || object === void 0) {
|
|
505
|
+
return object;
|
|
506
|
+
}
|
|
507
|
+
return Object.entries(object).reduce(
|
|
508
|
+
(result, [key, value]) => {
|
|
509
|
+
const transformedKey = transformKey(key);
|
|
510
|
+
const transformedValue = value && typeof value === "object" ? transformToKebabCase(value) : value;
|
|
511
|
+
result[transformedKey] = transformedValue;
|
|
512
|
+
return result;
|
|
513
|
+
},
|
|
514
|
+
{}
|
|
515
|
+
);
|
|
516
|
+
}
|
|
497
517
|
|
|
498
518
|
// src/utils/hashUtils.ts
|
|
499
519
|
import { createHash } from "node:crypto";
|
|
@@ -889,6 +909,7 @@ export {
|
|
|
889
909
|
resolveMonorepoLogger,
|
|
890
910
|
resolveMonorepoLoggerConfiguration,
|
|
891
911
|
success,
|
|
912
|
+
transformToKebabCase,
|
|
892
913
|
waitAndRetry
|
|
893
914
|
};
|
|
894
915
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/typeUtils.ts","../src/errors/PublicNonRecoverableError.ts","../src/errors/InternalError.ts","../src/errors/errorTypeGuards.ts","../src/config/ConfigScope.ts","../src/config/configTransformers.ts","../src/config/configValidators.ts","../src/errors/either.ts","../src/utils/encryptionUtility.ts","../src/utils/arrayUtils.ts","../src/utils/objectUtils.ts","../src/utils/hashUtils.ts","../src/logging/loggerConfigResolver.ts","../src/errors/globalErrorHandler.ts","../src/errors/publicErrors.ts","../src/utils/waitUtils.ts","../src/observability/MultiTransactionObservabilityManager.ts","../src/utils/checksumUtils.ts","../src/utils/streamUtils.ts"],"sourcesContent":["// Error structure commonly used in libraries, e. g. fastify\nexport type StandardizedError = {\n code: string\n message: string\n}\n\nexport function hasMessage(maybe: unknown): maybe is { message: string } {\n return isObject(maybe) && typeof maybe.message === 'string'\n}\n\nexport function isObject(maybeObject: unknown): maybeObject is Record<PropertyKey, unknown> {\n return typeof maybeObject === 'object' && maybeObject !== null\n}\n\nexport function isStandardizedError(error: unknown): error is StandardizedError {\n return isObject(error) && typeof error.code === 'string' && typeof error.message === 'string'\n}\n\nexport function isError(maybeError: unknown): maybeError is Error {\n return (\n maybeError instanceof Error || Object.prototype.toString.call(maybeError) === '[object Error]'\n )\n}\n","import { isError } from '../utils/typeUtils'\nimport type { ErrorDetails } from './types'\n\nexport type PublicNonRecoverableErrorParams<T = ErrorDetails> = {\n message: string\n errorCode: string\n details?: T\n httpStatusCode?: number\n cause?: unknown\n}\n\nconst PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY = 'PUBLIC_NON_RECOVERABLE_ERROR_KEY'\nconst publicNonRecoverableErrorSymbol = Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)\n\n/**\n * This error is returned to the consumer of API\n */\nexport class PublicNonRecoverableError<T = ErrorDetails> extends Error {\n readonly [publicNonRecoverableErrorSymbol] = true\n public readonly details?: T\n public readonly errorCode: string\n public readonly httpStatusCode: number\n\n constructor(params: PublicNonRecoverableErrorParams<T>) {\n super(params.message, {\n cause: params.cause,\n })\n // set the name as the class name for every class that extends PublicNonRecoverableError\n this.name = this.constructor.name\n this.details = params.details\n this.errorCode = params.errorCode\n this.httpStatusCode = params.httpStatusCode ?? 500\n }\n}\n\nexport function isPublicNonRecoverableError(error: unknown): error is PublicNonRecoverableError {\n return (\n isError(error) &&\n // biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface\n ((error as any)[Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)] === true ||\n error.name === 'PublicNonRecoverableError')\n )\n}\n","import { isError } from '../utils/typeUtils'\nimport type { ErrorDetails } from './types'\n\nexport type InternalErrorParams<T = ErrorDetails> = {\n message: string\n errorCode: string\n details?: T\n cause?: unknown\n}\n\nconst INTERNAL_ERROR_SYMBOL_KEY = 'INTERNAL_ERROR_KEY'\nconst internalErrorSymbol = Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)\n\nexport class InternalError<T = ErrorDetails> extends Error {\n readonly [internalErrorSymbol] = true\n public readonly details?: T\n public readonly errorCode: string\n\n constructor(params: InternalErrorParams<T>) {\n super(params.message, {\n cause: params.cause,\n })\n // set the name as the class name for every class that extends InternalError\n this.name = this.constructor.name\n this.details = params.details\n this.errorCode = params.errorCode\n }\n}\n\nexport function isInternalError(error: unknown): error is InternalError {\n return (\n isError(error) &&\n // biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface\n ((error as any)[Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)] === true ||\n error.name === 'InternalError')\n )\n}\n","import { isPublicNonRecoverableError } from '../errors/PublicNonRecoverableError'\n\nimport type { EntityGoneError } from './publicErrors'\n\nexport function isEntityGoneError(entity: unknown): entity is EntityGoneError {\n return isPublicNonRecoverableError(entity) && entity.httpStatusCode === 410\n}\n","import type { ZodSchema } from 'zod'\n\nimport { InternalError } from '../errors/InternalError'\n\nimport type { EnvValueValidator } from './configTypes'\n\nexport type EnvType = {\n [key: string]: string | undefined\n}\n\nexport class ConfigScope {\n private env: EnvType\n\n constructor(envOverride?: EnvType) {\n this.env = envOverride ?? { ...process.env }\n }\n\n updateEnv() {\n // Accessing process.env values is slow, so we cache them\n this.env = { ...process.env }\n }\n\n getMandatoryInteger(param: string): number {\n const rawValue = this.env[param]\n if (!rawValue) {\n throw new InternalError({\n message: `Missing mandatory configuration parameter: ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getMandatory(param: string): string {\n const result = this.env[param]\n if (!result) {\n throw new InternalError({\n message: `Missing mandatory configuration parameter: ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return result\n }\n\n getMandatoryOneOf<const T>(param: string, supportedValues: T[]): T {\n const result = this.getMandatory(param)\n return validateOneOf(\n result,\n supportedValues,\n `Unsupported ${param}: ${result}. Supported values: ${supportedValues.toString()}`,\n )\n }\n\n getMandatoryValidatedInteger(param: string, validator: EnvValueValidator<number>): number {\n const value = this.getMandatoryInteger(param)\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return value\n }\n\n getOptionalNullable<T extends string | null | undefined>(\n param: string,\n defaultValue: T,\n ): T | string {\n return this.env[param] || defaultValue\n }\n\n getOptional(param: string, defaultValue: string): string {\n // Using the `||` operator instead of `??`, since '' is not a valid value, and 0 (number) is not expected here\n return this.env[param] || defaultValue\n }\n\n getOptionalInteger(param: string, defaultValue: number): number {\n const rawValue = this.env[param]\n if (!rawValue) {\n return defaultValue\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getOptionalNullableInteger<T extends number | null | undefined>(\n param: string,\n defaultValue: T,\n ): T | number {\n const rawValue = this.env[param]\n if (!rawValue) {\n return defaultValue\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getOptionalOneOf<const T extends string>(\n param: string,\n defaultValue: T,\n supportedValues: T[],\n ): T {\n const result = this.getOptional(param, defaultValue)\n return validateOneOf(\n result,\n supportedValues,\n `Unsupported ${param}: ${result}. Supported values: ${supportedValues.toString()}`,\n )\n }\n\n getOptionalValidated(\n param: string,\n defaultValue: string,\n validator: EnvValueValidator<string>,\n ): string {\n const value = this.env[param] || defaultValue\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return value\n }\n\n getOptionalValidatedInteger(\n param: string,\n defaultValue: number,\n validator: EnvValueValidator<number>,\n ): number {\n const value = this.getOptionalInteger(param, defaultValue)\n\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n\n return value\n }\n\n getOptionalTransformed(\n param: string,\n defaultValue: string,\n transformer: (value: string) => string,\n ): string {\n const value = this.env[param] || defaultValue\n return transformer(value)\n }\n\n getOptionalNullableTransformed<T extends string | undefined>(\n param: string,\n defaultValue: T,\n transformer: (value: T | string) => T | string,\n ): T | string {\n const value = this.env[param] || defaultValue\n return transformer(value as T)\n }\n\n getMandatoryTransformed(param: string, transformer: (value: string) => string) {\n const value = this.getMandatory(param)\n\n return transformer(value)\n }\n\n getOptionalBoolean(param: string, defaultValue: boolean): boolean {\n const rawValue = this.env[param]?.toLowerCase()\n if (rawValue === undefined || rawValue === '') {\n return defaultValue\n }\n\n validateOneOf(rawValue, ['true', 'false'])\n\n return rawValue === 'true'\n }\n\n getMandatoryJsonObject<T extends object>(param: string, schema: ZodSchema<T>): T {\n const rawValue = this.getMandatory(param)\n return this.validateSchema(\n JSON.parse(rawValue),\n schema,\n `Configuration parameter ${param} must be a valid JSON meeting the given schema, but was ${rawValue}`,\n )\n }\n\n getOptionalNullableJsonObject<T extends object, Z extends T | null | undefined>(\n param: string,\n schema: ZodSchema<T>,\n defaultValue: Z,\n ): Z {\n const rawValue = this.getOptionalNullable(param, undefined)\n if (!rawValue) {\n return defaultValue\n }\n\n return this.validateSchema(\n JSON.parse(rawValue),\n schema,\n `Configuration parameter ${param} must be a valid JSON meeting the given schema, but was ${rawValue}`,\n ) as Z\n }\n\n getOptionalJsonObject<T extends object>(param: string, schema: ZodSchema<T>, defaultValue: T): T {\n return this.getOptionalNullableJsonObject(param, schema, defaultValue)\n }\n\n isProduction(): boolean {\n return this.env.NODE_ENV === 'production'\n }\n\n isDevelopment(): boolean {\n return this.env.NODE_ENV !== 'production'\n }\n\n isTest(): boolean {\n return this.env.NODE_ENV === 'test'\n }\n\n private validateSchema<T extends object>(\n value: unknown,\n schema: ZodSchema<T>,\n errorMessage: string,\n ): T {\n const parsedValue = schema.safeParse(value)\n if (!parsedValue.success) {\n throw new InternalError({\n message: errorMessage,\n errorCode: 'CONFIGURATION_ERROR',\n details: parsedValue.error,\n })\n }\n\n return parsedValue.data\n }\n}\n\nexport function validateOneOf<const T>(\n validatedEntity: unknown,\n expectedOneOfEntities: T[],\n errorText?: string,\n): T {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n if (!expectedOneOfEntities.includes(validatedEntity as T)) {\n throw new InternalError({\n message:\n errorText ||\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Validated entity ${validatedEntity} is not one of: ${expectedOneOfEntities.toString()}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return validatedEntity as T\n}\n\nexport function validateNumber(validatedObject: unknown, errorText: string): number {\n if (!Number.isFinite(validatedObject)) {\n throw new InternalError({\n message: errorText,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return validatedObject as number\n}\n","import type { EnvValueTransformer } from './configTypes'\n\nexport const ensureClosingSlashTransformer: EnvValueTransformer<\n string | undefined | null,\n string\n> = (value) => {\n if (!value) {\n return ''\n }\n\n const lastChar = value.at(-1)\n if (lastChar !== '/') {\n return `${value}/`\n }\n return value\n}\n","import type { EnvValueValidator } from './configTypes'\n\nexport const createRangeValidator = (\n greaterOrEqualThan: number,\n lessOrEqualThan: number,\n): EnvValueValidator<number> => {\n return (value) => {\n return value >= greaterOrEqualThan && value <= lessOrEqualThan\n }\n}\n","type Left<T> = {\n error: T\n result?: never\n}\n\ntype Right<U> = {\n error?: never\n result: U\n}\n\n/**\n * Either is a functional programming type which is used to communicate errors happening in potentially recoverable scenarios.\n * It can return either an error (Left side) or a resolved result (Right side), but not both.\n * It is up to caller of the function to handle received error or throw (Public)NonRecoverableError if it cannot.\n *\n * @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}\n */\nexport type Either<T, U> = NonNullable<Left<T> | Right<U>>\n\n/***\n * Variation of Either, which may or may not have Error set, but always has Result\n */\nexport type DefiniteEither<T, U> = {\n error?: T\n result: U\n}\n\nexport const isFailure = <T, U>(e: Either<T, U>): e is Left<T> => {\n return e.error !== undefined\n}\n\nexport const isSuccess = <T, U>(e: Either<T, U>): e is Right<U> => {\n return e.result !== undefined\n}\n\nexport const failure = <T>(error: T): Left<T> => ({ error })\n\nexport const success = <U>(result: U): Right<U> => ({ result })\n","import * as crypto from 'node:crypto'\n\nconst algorithm = 'aes-256-gcm'\nconst ivLength = 16\nconst tagLength = 16\nconst defaultEncoding = 'hex'\nconst defaultSaltLength = 64\nconst defaultPbkdf2Iterations = 100000\n\nexport type Options = {\n saltLength?: number\n pbkdf2Iterations?: number\n encoding?: NodeJS.BufferEncoding\n}\n\n/**\n * Type-scripted version of https://github.com/MauriceButler/cryptr\n */\nexport class EncryptionUtility {\n private readonly secret: string\n private readonly saltLength: number\n private readonly encryptedPosition: number\n private readonly tagPosition: number\n private readonly pbkdf2Iterations: number\n private readonly encoding: NodeJS.BufferEncoding\n\n constructor(secret: string, options?: Options) {\n this.secret = secret\n\n this.encoding = options?.encoding ?? defaultEncoding\n this.pbkdf2Iterations = options?.pbkdf2Iterations ?? defaultPbkdf2Iterations\n this.saltLength = options?.saltLength ?? defaultSaltLength\n\n this.tagPosition = this.saltLength + ivLength\n this.encryptedPosition = this.tagPosition + tagLength\n }\n\n private getKey(salt: Buffer) {\n return crypto.pbkdf2Sync(this.secret, salt, this.pbkdf2Iterations, 32, 'sha512')\n }\n\n public encrypt(value: string) {\n const iv = crypto.randomBytes(ivLength)\n const salt = crypto.randomBytes(this.saltLength)\n\n const key = this.getKey(salt)\n\n const cipher = crypto.createCipheriv(algorithm, key, iv)\n const encrypted = Buffer.concat([cipher.update(String(value), 'utf8'), cipher.final()])\n\n const tag = cipher.getAuthTag()\n\n return Buffer.concat([salt, iv, tag, encrypted]).toString(this.encoding)\n }\n\n public decrypt(value: string) {\n const stringValue = Buffer.from(String(value), this.encoding)\n\n const salt = stringValue.subarray(0, this.saltLength)\n const iv = stringValue.subarray(this.saltLength, this.tagPosition)\n const tag = stringValue.subarray(this.tagPosition, this.encryptedPosition)\n const encrypted = stringValue.subarray(this.encryptedPosition)\n\n const key = this.getKey(salt)\n\n const decipher = crypto.createDecipheriv(algorithm, key, iv)\n\n decipher.setAuthTag(tag)\n\n return Buffer.concat([\n decipher.update(encrypted),\n Buffer.from(decipher.final('utf8')),\n ]).toString('utf8')\n }\n}\n","export function chunk<T>(array: T[], chunkSize: number): T[][] {\n const length = array.length\n if (!length || chunkSize < 1) {\n return []\n }\n let index = 0\n let resIndex = 0\n const result = new Array(Math.ceil(length / chunkSize))\n\n while (index < length) {\n // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>\n result[resIndex++] = array.slice(index, (index += chunkSize))\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return result\n}\n\nexport async function callChunked<Item>(\n chunkSize: number,\n array: readonly Item[],\n processFn: (arrayChunk: Item[]) => Promise<unknown>,\n): Promise<void> {\n for (let i = 0; i < array.length; i += chunkSize) {\n const arrayChunk = array.slice(i, i + chunkSize)\n await processFn(arrayChunk)\n }\n}\n\n/**\n * Return a copy of the given array without null or undefined values\n */\nexport function removeNullish<const T>(array: readonly (T | null | undefined)[]): T[] {\n return array.filter((e) => e !== undefined && e !== null) as T[]\n}\n\n/**\n * Return a copy of the given array without falsy values (eg: false, 0, '', null, undefined)\n */\nexport function removeFalsy<const T>(\n array: readonly (T | null | undefined | 0 | '' | false)[],\n): T[] {\n return array.filter((e) => e) as T[]\n}\n\n/**\n * Return a copy of the given array without duplicates.\n */\nexport function removeDuplicates<const T>(array: readonly T[]): T[] {\n return [...new Set(array)]\n}\n","import dotProp from 'dot-prop'\n\nimport { InternalError } from '../errors/InternalError'\n\ntype RecordKeyType = string | number | symbol\n\nexport function copyWithoutUndefined<\n T extends Record<RecordKeyType, unknown>,\n TargetRecordType = Pick<\n T,\n {\n [Prop in keyof T]: T[Prop] extends null | undefined ? never : Prop\n }[keyof T]\n >,\n>(originalValue: T): TargetRecordType {\n return Object.keys(originalValue).reduce(\n (acc, key) => {\n // @ts-ignore\n if (originalValue[key] !== undefined) {\n // @ts-ignore\n acc[key] = originalValue[key]\n }\n return acc\n },\n {} as Record<string, unknown>,\n ) as TargetRecordType\n}\n\nexport function copyWithoutEmpty<\n T extends Record<RecordKeyType, unknown>,\n TargetRecordType = Pick<\n T,\n {\n [Prop in keyof T]: T[Prop] extends null | undefined | '' ? never : Prop\n }[keyof T]\n >,\n>(originalValue: T): TargetRecordType {\n return Object.keys(originalValue).reduce(\n (acc, key) => {\n if (\n originalValue[key] !== undefined &&\n originalValue[key] !== null &&\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n (typeof originalValue[key] !== 'string' || originalValue[key].trim().length > 0)\n ) {\n // @ts-ignore\n acc[key] = originalValue[key]\n }\n return acc\n },\n {} as Record<string, unknown>,\n ) as TargetRecordType\n}\n\nexport function pick<T, K extends string | number | symbol>(\n source: T,\n propNames: readonly K[],\n): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>> {\n const result = {} as T\n let idx = 0\n while (idx < propNames.length) {\n // @ts-ignore\n if (propNames[idx] in source) {\n // @ts-ignore\n result[propNames[idx]] = source[propNames[idx]]\n }\n idx += 1\n }\n return result\n}\n\nexport function pickWithoutUndefined<T, K extends string | number | symbol>(\n source: T,\n propNames: readonly K[],\n): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>> {\n const result = {} as T\n let idx = 0\n while (idx < propNames.length) {\n // @ts-ignore\n if (propNames[idx] in source && source[propNames[idx]] !== undefined) {\n // @ts-ignore\n result[propNames[idx]] = source[propNames[idx]]\n }\n idx += 1\n }\n return result\n}\n\nexport function isEmptyObject(params: Record<string, unknown>): boolean {\n for (const key in params) {\n if (Object.hasOwn(params, key) && params[key] !== undefined) {\n return false\n }\n }\n return true\n}\n\ntype KeysMatching<T, V> = { [K in keyof T]: T[K] extends V ? K : never }[keyof T]\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects.\n * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.\n */\nexport function groupBy<\n T extends object,\n K extends KeysMatching<T, RecordKeyType | null | undefined>,\n>(array: T[], selector: K): Record<RecordKeyType, T[]> {\n return array.reduce(\n (acc, item) => {\n const key = item[selector] as RecordKeyType | null | undefined\n if (key === undefined || key === null) {\n return acc\n }\n if (!acc[key]) {\n acc[key] = []\n }\n acc[key].push(item)\n return acc\n },\n {} as Record<RecordKeyType, T[]>,\n )\n}\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects. Support nested keys.\n * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.\n */\nexport function groupByPath<T extends object>(array: T[], selector: string): Record<string, T[]> {\n return array.reduce(\n (acc, item) => {\n const key = dotProp.get(item, selector)\n if (key === undefined || key === null) {\n return acc\n }\n const strKeyPath = key as string\n\n if (!acc[strKeyPath]) {\n acc[strKeyPath] = []\n }\n acc[strKeyPath].push(item)\n return acc\n },\n {} as Record<RecordKeyType, T[]>,\n )\n}\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects.\n * @returns An object where the keys are unique values from the given selector and the value is the\n * corresponding object from the array.\n * @throws InternalError If a duplicated value is found for the given selector.\n */\nexport function groupByUnique<\n T extends object,\n K extends KeysMatching<T, RecordKeyType | null | undefined>,\n>(array: T[], selector: K): Record<RecordKeyType, T> {\n return array.reduce(\n (acc, item) => {\n const key = item[selector] as RecordKeyType | null | undefined\n if (key === undefined || key === null) {\n return acc\n }\n if (acc[key] !== undefined) {\n throw new InternalError({\n message: `Duplicated item for selector ${selector.toString()} with value ${key.toString()}`,\n errorCode: 'DUPLICATED_ITEM',\n details: { selector, value: key },\n })\n }\n acc[key] = item\n return acc\n },\n {} as Record<RecordKeyType, T>,\n )\n}\n\ntype DatesAsString<T> = T extends Date ? string : ExactlyLikeWithDateAsString<T>\n\ntype ExactlyLikeWithDateAsString<T> = T extends object ? { [K in keyof T]: DatesAsString<T[K]> } : T\n\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input,\n): ExactlyLikeWithDateAsString<Input>\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input[],\n): ExactlyLikeWithDateAsString<Input>[]\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input | Input[],\n): ExactlyLikeWithDateAsString<Input> | ExactlyLikeWithDateAsString<Input>[] {\n if (Array.isArray(object)) {\n // @ts-ignore\n return object.map(convertDateFieldsToIsoStringAux)\n }\n\n return Object.entries(object).reduce(\n (result, [key, value]) => {\n // @ts-ignore\n result[key] = convertDateFieldsToIsoStringAux(value)\n return result\n },\n {} as ExactlyLikeWithDateAsString<Input>,\n )\n}\n\nfunction convertDateFieldsToIsoStringAux<T>(item: T): DatesAsString<T> {\n if (item instanceof Date) {\n // @ts-ignore\n return item.toISOString()\n }\n\n if (item && typeof item === 'object') {\n // @ts-ignore\n return convertDateFieldsToIsoString(item)\n }\n\n // @ts-ignore\n return item\n}\n\n/**\n * Return a deep clone copy of an object.\n *\n * Please Note: This uses structuredClone, which has the limitations of these restricted Types: functions,\n * Error objects, WeakMap, WeakSet, DOM nodes, and certain other browser-specific objects like Window.\n */\nexport function deepClone<T extends object | undefined | null>(object: T): T {\n if (object === undefined || object === null) {\n return object\n }\n return structuredClone(object)\n}\n\nfunction transformKey(key: string): string {\n return key\n .replace(/([a-z])([A-Z])/g, '$1-$2') // transforms basic camelCase\n .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2') // transforms abbreviations\n .replace(/_/g, '-') // transforms snake_case\n .toLowerCase() // finally lowercase all\n}\n\ntype TransformToKebabCaseInputType = Record<string, unknown> | null | undefined\ntype TransformToKebabCaseReturnType<Input, Output> = Input extends Record<string, unknown>\n ? Output\n : Input\n/**\n * Transforms an object's keys from camelCase or snake_case to kebab-case.\n * @param object\n */\nexport function transformToKebabCase<\n Output extends Record<string, unknown>,\n Input extends TransformToKebabCaseInputType,\n>(object: Input): TransformToKebabCaseReturnType<Input, Output>\n\nexport function transformToKebabCase<\n Output extends Record<string, unknown>,\n Input extends TransformToKebabCaseInputType,\n>(object: Input[]): TransformToKebabCaseReturnType<Input, Output>[]\n\nexport function transformToKebabCase<Output, Input>(\n object: Input | Input[],\n): TransformToKebabCaseReturnType<Input, Output> | TransformToKebabCaseReturnType<Input, Output>[] {\n if (Array.isArray(object)) {\n // @ts-ignore\n return object.map(transformToKebabCase)\n }\n if (typeof object !== 'object' || object === null || object === undefined) {\n return object as TransformToKebabCaseReturnType<Input, Output>\n }\n\n return Object.entries(object as Record<string, unknown>).reduce(\n (result, [key, value]) => {\n const transformedKey = transformKey(key)\n const transformedValue =\n value && typeof value === 'object'\n ? transformToKebabCase(value as TransformToKebabCaseInputType)\n : value\n\n // Avoiding destructuring by directly assigning the new key-value pair\n result[transformedKey] = transformedValue\n return result\n },\n {} as Record<string, unknown>,\n ) as TransformToKebabCaseReturnType<Input, Output>\n}\n","import { createHash } from 'node:crypto'\n\nexport enum HashEncoding {\n HEX = 'hex',\n BASE64 = 'base64',\n}\n\nexport enum HashAlgorithm {\n SHA256 = 'sha256',\n SHA512 = 'sha512',\n}\n\nexport function generateHash(\n algorithm: HashAlgorithm,\n data: string,\n encoding: HashEncoding = HashEncoding.HEX,\n) {\n return createHash(algorithm).update(data).digest(encoding)\n}\n","import type { Level, Logger, LoggerOptions, redactOptions } from 'pino'\nimport { levels, pino } from 'pino'\nimport pretty from 'pino-pretty'\n\nexport type AppLoggerConfig = {\n logLevel: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n nodeEnv: 'production' | 'development' | 'test'\n base?: Record<string, unknown>\n redact?: redactOptions\n}\n\nexport type MonorepoAppLoggerConfig = AppLoggerConfig & {\n targetFile?: string\n append?: boolean\n}\n\n/* c8 ignore next 8 */\nexport function resolveMonorepoLogger(appConfig: MonorepoAppLoggerConfig): Logger {\n if (appConfig.nodeEnv !== 'development') {\n return resolveLogger(appConfig)\n }\n\n const configuration = resolveMonorepoLoggerConfiguration(appConfig) as LoggerOptions\n return pino(configuration)\n}\n\n// Note that transports do not work in vitest, likely because pino attempts to run them in a separate worker\n/* c8 ignore next 25 */\nexport function resolveMonorepoLoggerConfiguration(\n appConfig: MonorepoAppLoggerConfig,\n): LoggerOptions | Logger {\n if (appConfig.nodeEnv !== 'development') {\n return resolveLoggerConfiguration(appConfig)\n }\n\n return {\n level: appConfig.logLevel,\n formatters: {\n level: (label) => {\n return { level: label }\n },\n },\n redact: appConfig.redact,\n transport: {\n target: 'pino/file',\n options: {\n destination: appConfig.targetFile ?? './service.log',\n mkdir: true,\n append: appConfig.append ?? false,\n },\n },\n }\n}\n\nexport function resolveLogger(appConfig: AppLoggerConfig): Logger {\n if (appConfig.nodeEnv !== 'production') {\n return resolveLoggerConfiguration(appConfig) as Logger\n }\n\n const configuration = resolveLoggerConfiguration(appConfig) as LoggerOptions\n return pino(configuration)\n}\n\nexport function resolveLoggerConfiguration(appConfig: AppLoggerConfig): LoggerOptions | Logger {\n if (appConfig.nodeEnv !== 'production') {\n return pino(\n pretty({\n sync: true,\n minimumLevel: appConfig.logLevel as Level,\n colorize: true,\n translateTime: 'SYS:standard',\n ignore: 'hostname,pid',\n }),\n )\n }\n\n return {\n level: appConfig.logLevel,\n formatters: {\n level: (_label, numericLevel): { level: string } => {\n const level = levels.labels[numericLevel] || 'unknown'\n return { level }\n },\n },\n redact: appConfig.redact,\n } satisfies LoggerOptions\n}\n","import { types } from 'node:util'\n\nimport type { SerializedError } from 'pino'\nimport { levels, pino, stdSerializers } from 'pino'\n\nimport type { CommonLogger } from '../logging/commonLogger'\nimport { hasMessage } from '../utils/typeUtils'\n\ntype LogObject = {\n message: string\n 'x-request-id'?: string\n error?: SerializedError\n}\n\nexport const globalLogger: CommonLogger = pino({\n formatters: {\n level: (_label, numericLevel): { level: string } => {\n const level = levels.labels[numericLevel] || 'unknown'\n return { level }\n },\n },\n})\n\nexport function resolveGlobalErrorLogObject(err: unknown, correlationId?: string): LogObject {\n if (types.isNativeError(err)) {\n return {\n message: err.message,\n error: stdSerializers.err(err),\n 'x-request-id': correlationId,\n }\n }\n\n if (hasMessage(err)) {\n return {\n message: err.message,\n 'x-request-id': correlationId,\n }\n }\n\n return {\n message: 'Unknown error',\n 'x-request-id': correlationId,\n }\n}\n\nexport function executeAndHandleGlobalErrors<T>(operation: () => T) {\n try {\n const result = operation()\n return result\n } catch (err) {\n const logObject = resolveGlobalErrorLogObject(err)\n globalLogger.error(logObject, logObject.message)\n process.exit(1)\n }\n}\n\nexport async function executeAsyncAndHandleGlobalErrors<T>(\n operation: () => Promise<T>,\n stopOnError = true,\n) {\n try {\n const result = await operation()\n return result\n } catch (err) {\n const logObject = resolveGlobalErrorLogObject(err)\n globalLogger.error(logObject, logObject.message)\n if (stopOnError) {\n process.exit(1)\n }\n }\n}\n\nexport async function executeSettleAllAndHandleGlobalErrors(\n promises: Promise<unknown>[],\n stopOnError = true,\n) {\n const result = await Promise.allSettled(promises)\n\n let errorsHappened: boolean | undefined\n for (const entry of result) {\n if (entry.status === 'rejected') {\n const logObject = resolveGlobalErrorLogObject(entry.reason)\n globalLogger.error(logObject, logObject.message)\n errorsHappened = true\n }\n }\n\n if (stopOnError && errorsHappened) {\n process.exit(1)\n }\n\n return result\n}\n","import { constants as httpConstants } from 'node:http2'\n\nimport type { FreeformRecord } from '../common/commonTypes'\n\nimport { PublicNonRecoverableError } from './PublicNonRecoverableError'\n\nexport type CommonErrorParams = {\n message: string\n details?: FreeformRecord\n cause?: Error\n}\n\nexport type OptionalMessageErrorParams = Partial<CommonErrorParams>\n\nexport type ValidationError = {\n message: string\n path: string[]\n}\n\nexport class RequestValidationError extends PublicNonRecoverableError {\n constructor(errors: ValidationError[]) {\n super({\n message: 'Invalid params',\n errorCode: 'VALIDATION_ERROR',\n httpStatusCode: httpConstants.HTTP_STATUS_BAD_REQUEST,\n details: {\n error: errors,\n },\n })\n }\n}\n\nexport class AccessDeniedError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ACCESS_DENIED',\n httpStatusCode: httpConstants.HTTP_STATUS_FORBIDDEN,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n\nexport class EntityNotFoundError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ENTITY_NOT_FOUND',\n httpStatusCode: httpConstants.HTTP_STATUS_NOT_FOUND,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n\nexport class EntityGoneError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ENTITY_GONE',\n httpStatusCode: 410,\n details: params.details,\n })\n }\n}\n\nexport class AuthFailedError extends PublicNonRecoverableError {\n constructor(params: OptionalMessageErrorParams = {}) {\n super({\n message: params.message ?? 'Authentication failed',\n errorCode: 'AUTH_FAILED',\n httpStatusCode: httpConstants.HTTP_STATUS_UNAUTHORIZED,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n","export const waitAndRetry = async <T>(\n predicateFn: () => T,\n sleepTime = 20,\n maxRetryCount = 15,\n): Promise<T> => {\n return new Promise((resolve, reject) => {\n let retryCount = 0\n function performCheck() {\n // amount of retries exceeded\n if (maxRetryCount !== 0 && retryCount > maxRetryCount) {\n resolve(predicateFn())\n }\n\n // Try executing predicateFn\n Promise.resolve()\n .then(() => {\n return predicateFn()\n })\n .then((result) => {\n if (result) {\n resolve(result)\n } else {\n retryCount++\n setTimeout(performCheck, sleepTime)\n }\n })\n .catch((err) => {\n reject(err)\n })\n }\n\n performCheck()\n })\n}\n","import type { TransactionObservabilityManager } from './observabilityTypes'\n\n/**\n * Groups different TransactionObservabilityManager instances into one\n * to facilitate tracking transactions across multiple observability tools.\n */\nexport class MultiTransactionObservabilityManager implements TransactionObservabilityManager {\n private readonly managers: TransactionObservabilityManager[]\n\n constructor(managers: TransactionObservabilityManager[]) {\n this.managers = managers\n }\n\n start(transactionName: string, uniqueTransactionKey: string): void {\n for (const manager of this.managers) {\n manager.start(transactionName, uniqueTransactionKey)\n }\n }\n\n startWithGroup(\n transactionName: string,\n uniqueTransactionKey: string,\n transactionGroup: string,\n ): void {\n for (const manager of this.managers) {\n manager.startWithGroup(transactionName, uniqueTransactionKey, transactionGroup)\n }\n }\n\n stop(uniqueTransactionKey: string, wasSuccessful?: boolean): void {\n for (const manager of this.managers) {\n manager.stop(uniqueTransactionKey, wasSuccessful)\n }\n }\n}\n","import type { BinaryLike } from 'node:crypto'\nimport { createHash } from 'node:crypto'\nimport type { Readable } from 'node:stream'\n\nconst HASH_ALGORITHM = 'md5'\n\nexport function generateChecksumForBufferOrString(data: BinaryLike): string {\n return createHash(HASH_ALGORITHM).update(data).digest('hex')\n}\n\nexport function generateChecksumForObject(object: object): string {\n const objectAsString = JSON.stringify(object)\n return generateChecksumForBufferOrString(objectAsString)\n}\n\nexport function generateChecksumForReadable(readable: Readable): Promise<string> {\n return new Promise((resolve, reject) => {\n const hashCreator = createHash(HASH_ALGORITHM)\n readable.on('data', (data) => {\n if (Buffer.isBuffer(data)) {\n hashCreator.update(data)\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hashCreator.update(Buffer.from(data))\n }\n })\n\n readable.on('end', () => {\n const hash = hashCreator.digest('hex')\n resolve(hash)\n })\n readable.on('error', (err) => {\n /* c8 ignore next 1 */\n reject(err)\n })\n })\n}\n","import { F_OK } from 'node:constants'\nimport { access, createReadStream, createWriteStream } from 'node:fs'\nimport { stat, unlink } from 'node:fs/promises'\nimport type { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream'\n\nexport type ReadableProvider = {\n /**\n * Guarantees to provide a new stream every time this is called, before `destroy` is invoked.\n */\n createStream(): Promise<Readable>\n\n /**\n * Returns size of the persisted content\n */\n getContentLength(): Promise<number>\n\n /**\n * Remove the persisted value. No new streams can be created after this is called\n */\n destroy(): Promise<void>\n}\n\nexport type PersistToFsOptions = {\n targetFile: string\n sourceReadable: Readable\n}\n\nexport type FsReadableProviderOptions = {\n storageFile: string\n}\n\nexport class FsReadableProvider implements ReadableProvider {\n public readonly storageFile: string\n constructor(options: FsReadableProviderOptions) {\n this.storageFile = options.storageFile\n }\n\n fileExists(): Promise<boolean> {\n return new Promise((resolve) => {\n access(this.storageFile, F_OK, (err) => {\n return resolve(!err)\n })\n })\n }\n\n async getContentLength(): Promise<number> {\n if (!(await this.fileExists())) {\n throw new Error(`File ${this.storageFile} was already deleted.`)\n }\n const stats = await stat(this.storageFile)\n return stats.size\n }\n\n async createStream(): Promise<Readable> {\n if (!(await this.fileExists())) {\n throw new Error(`File ${this.storageFile} was already deleted.`)\n }\n\n return createReadStream(this.storageFile)\n }\n\n async destroy(): Promise<void> {\n if (!(await this.fileExists())) {\n // nothing to do here\n return\n }\n\n return unlink(this.storageFile)\n }\n\n protected async persist(sourceReadable: Readable): Promise<void> {\n const writable = createWriteStream(this.storageFile)\n return new Promise((resolve, reject) => {\n pipeline(sourceReadable, writable, (err) => {\n if (err) {\n /* c8 ignore next 1 */\n reject(err)\n } else {\n resolve()\n }\n })\n })\n }\n\n public static async persistReadableToFs(\n options: PersistToFsOptions,\n ): Promise<FsReadableProvider> {\n const provider = new FsReadableProvider({\n storageFile: options.targetFile,\n })\n await provider.persist(options.sourceReadable)\n return provider\n }\n}\n\n/**\n * Consumes the readable in order to calculate its length in bytes\n * @param readable\n */\nexport function getReadableContentLength(readable: Readable): Promise<number> {\n return new Promise((resolve, reject) => {\n let size = 0\n readable.on('data', (chunk) => {\n if (typeof chunk === 'string' || Buffer.isBuffer(chunk)) {\n size += Buffer.byteLength(chunk)\n }\n })\n readable.on('end', () => {\n resolve(size)\n })\n readable.on('error', (error) => {\n /* c8 ignore next 1 */\n reject(error)\n })\n })\n}\n"],"mappings":";AAMO,SAAS,WAAW,OAA8C;AACvE,SAAO,SAAS,KAAK,KAAK,OAAO,MAAM,YAAY;AACrD;AAEO,SAAS,SAAS,aAAmE;AAC1F,SAAO,OAAO,gBAAgB,YAAY,gBAAgB;AAC5D;AAEO,SAAS,oBAAoB,OAA4C;AAC9E,SAAO,SAAS,KAAK,KAAK,OAAO,MAAM,SAAS,YAAY,OAAO,MAAM,YAAY;AACvF;AAEO,SAAS,QAAQ,YAA0C;AAChE,SACE,sBAAsB,SAAS,OAAO,UAAU,SAAS,KAAK,UAAU,MAAM;AAElF;;;ACXA,IAAM,0CAA0C;AAChD,IAAM,kCAAkC,OAAO,IAAI,uCAAuC;AAKnF,IAAM,4BAAN,cAA0D,MAAM;AAAA,EACrE,CAAU,+BAA+B,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,YAAY,QAA4C;AACtD,UAAM,OAAO,SAAS;AAAA,MACpB,OAAO,OAAO;AAAA,IAChB,CAAC;AAED,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,UAAU,OAAO;AACtB,SAAK,YAAY,OAAO;AACxB,SAAK,iBAAiB,OAAO,kBAAkB;AAAA,EACjD;AACF;AAEO,SAAS,4BAA4B,OAAoD;AAC9F,SACE,QAAQ,KAAK;AAAA,GAEX,MAAc,OAAO,IAAI,uCAAuC,CAAC,MAAM,QACvE,MAAM,SAAS;AAErB;;;AChCA,IAAM,4BAA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Q,MAAM,KAAK,KAAK,WAAW;AACzC,WAAO,MAAM;AAAA,EACf;AAAA,EAEA,MAAM,eAAkC;AACtC,QAAI,CAAE,MAAM,KAAK,WAAW,GAAI;AAC9B,YAAM,IAAI,MAAM,QAAQ,KAAK,WAAW,uBAAuB;AAAA,IACjE;AAEA,WAAO,iBAAiB,KAAK,WAAW;AAAA,EAC1C;AAAA,EAEA,MAAM,UAAyB;AAC7B,QAAI,CAAE,MAAM,KAAK,WAAW,GAAI;AAE9B;AAAA,IACF;AAEA,WAAO,OAAO,KAAK,WAAW;AAAA,EAChC;AAAA,EAEA,MAAgB,QAAQ,gBAAyC;AAC/D,UAAM,WAAW,kBAAkB,KAAK,WAAW;AACnD,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,eAAS,gBAAgB,UAAU,CAAC,QAAQ;AAC1C,YAAI,KAAK;AAEP,iBAAO,GAAG;AAAA,QACZ,OAAO;AACL,kBAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,aAAoB,oBAClB,SAC6B;AAC7B,UAAM,WAAW,IAAI,oBAAmB;AAAA,MACtC,aAAa,QAAQ;AAAA,IACvB,CAAC;AACD,UAAM,SAAS,QAAQ,QAAQ,cAAc;AAC7C,WAAO;AAAA,EACT;AACF;","names":["HashEncoding","HashAlgorithm","algorithm","levels","pino","pino","levels","createHash"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/typeUtils.ts","../src/errors/PublicNonRecoverableError.ts","../src/errors/InternalError.ts","../src/errors/errorTypeGuards.ts","../src/config/ConfigScope.ts","../src/config/configTransformers.ts","../src/config/configValidators.ts","../src/errors/either.ts","../src/utils/encryptionUtility.ts","../src/utils/arrayUtils.ts","../src/utils/objectUtils.ts","../src/utils/hashUtils.ts","../src/logging/loggerConfigResolver.ts","../src/errors/globalErrorHandler.ts","../src/errors/publicErrors.ts","../src/utils/waitUtils.ts","../src/observability/MultiTransactionObservabilityManager.ts","../src/utils/checksumUtils.ts","../src/utils/streamUtils.ts"],"sourcesContent":["// Error structure commonly used in libraries, e. g. fastify\nexport type StandardizedError = {\n code: string\n message: string\n}\n\nexport function hasMessage(maybe: unknown): maybe is { message: string } {\n return isObject(maybe) && typeof maybe.message === 'string'\n}\n\nexport function isObject(maybeObject: unknown): maybeObject is Record<PropertyKey, unknown> {\n return typeof maybeObject === 'object' && maybeObject !== null\n}\n\nexport function isStandardizedError(error: unknown): error is StandardizedError {\n return isObject(error) && typeof error.code === 'string' && typeof error.message === 'string'\n}\n\nexport function isError(maybeError: unknown): maybeError is Error {\n return (\n maybeError instanceof Error || Object.prototype.toString.call(maybeError) === '[object Error]'\n )\n}\n","import { isError } from '../utils/typeUtils'\nimport type { ErrorDetails } from './types'\n\nexport type PublicNonRecoverableErrorParams<T = ErrorDetails> = {\n message: string\n errorCode: string\n details?: T\n httpStatusCode?: number\n cause?: unknown\n}\n\nconst PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY = 'PUBLIC_NON_RECOVERABLE_ERROR_KEY'\nconst publicNonRecoverableErrorSymbol = Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)\n\n/**\n * This error is returned to the consumer of API\n */\nexport class PublicNonRecoverableError<T = ErrorDetails> extends Error {\n readonly [publicNonRecoverableErrorSymbol] = true\n public readonly details?: T\n public readonly errorCode: string\n public readonly httpStatusCode: number\n\n constructor(params: PublicNonRecoverableErrorParams<T>) {\n super(params.message, {\n cause: params.cause,\n })\n // set the name as the class name for every class that extends PublicNonRecoverableError\n this.name = this.constructor.name\n this.details = params.details\n this.errorCode = params.errorCode\n this.httpStatusCode = params.httpStatusCode ?? 500\n }\n}\n\nexport function isPublicNonRecoverableError(error: unknown): error is PublicNonRecoverableError {\n return (\n isError(error) &&\n // biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface\n ((error as any)[Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)] === true ||\n error.name === 'PublicNonRecoverableError')\n )\n}\n","import { isError } from '../utils/typeUtils'\nimport type { ErrorDetails } from './types'\n\nexport type InternalErrorParams<T = ErrorDetails> = {\n message: string\n errorCode: string\n details?: T\n cause?: unknown\n}\n\nconst INTERNAL_ERROR_SYMBOL_KEY = 'INTERNAL_ERROR_KEY'\nconst internalErrorSymbol = Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)\n\nexport class InternalError<T = ErrorDetails> extends Error {\n readonly [internalErrorSymbol] = true\n public readonly details?: T\n public readonly errorCode: string\n\n constructor(params: InternalErrorParams<T>) {\n super(params.message, {\n cause: params.cause,\n })\n // set the name as the class name for every class that extends InternalError\n this.name = this.constructor.name\n this.details = params.details\n this.errorCode = params.errorCode\n }\n}\n\nexport function isInternalError(error: unknown): error is InternalError {\n return (\n isError(error) &&\n // biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface\n ((error as any)[Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)] === true ||\n error.name === 'InternalError')\n )\n}\n","import { isPublicNonRecoverableError } from '../errors/PublicNonRecoverableError'\n\nimport type { EntityGoneError } from './publicErrors'\n\nexport function isEntityGoneError(entity: unknown): entity is EntityGoneError {\n return isPublicNonRecoverableError(entity) && entity.httpStatusCode === 410\n}\n","import type { ZodSchema } from 'zod'\n\nimport { InternalError } from '../errors/InternalError'\n\nimport type { EnvValueValidator } from './configTypes'\n\nexport type EnvType = {\n [key: string]: string | undefined\n}\n\nexport class ConfigScope {\n private env: EnvType\n\n constructor(envOverride?: EnvType) {\n this.env = envOverride ?? { ...process.env }\n }\n\n updateEnv() {\n // Accessing process.env values is slow, so we cache them\n this.env = { ...process.env }\n }\n\n getMandatoryInteger(param: string): number {\n const rawValue = this.env[param]\n if (!rawValue) {\n throw new InternalError({\n message: `Missing mandatory configuration parameter: ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getMandatory(param: string): string {\n const result = this.env[param]\n if (!result) {\n throw new InternalError({\n message: `Missing mandatory configuration parameter: ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return result\n }\n\n getMandatoryOneOf<const T>(param: string, supportedValues: T[]): T {\n const result = this.getMandatory(param)\n return validateOneOf(\n result,\n supportedValues,\n `Unsupported ${param}: ${result}. Supported values: ${supportedValues.toString()}`,\n )\n }\n\n getMandatoryValidatedInteger(param: string, validator: EnvValueValidator<number>): number {\n const value = this.getMandatoryInteger(param)\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return value\n }\n\n getOptionalNullable<T extends string | null | undefined>(\n param: string,\n defaultValue: T,\n ): T | string {\n return this.env[param] || defaultValue\n }\n\n getOptional(param: string, defaultValue: string): string {\n // Using the `||` operator instead of `??`, since '' is not a valid value, and 0 (number) is not expected here\n return this.env[param] || defaultValue\n }\n\n getOptionalInteger(param: string, defaultValue: number): number {\n const rawValue = this.env[param]\n if (!rawValue) {\n return defaultValue\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getOptionalNullableInteger<T extends number | null | undefined>(\n param: string,\n defaultValue: T,\n ): T | number {\n const rawValue = this.env[param]\n if (!rawValue) {\n return defaultValue\n }\n return validateNumber(\n Number.parseInt(rawValue),\n `Configuration parameter ${param}\\` must be a number, but was ${rawValue}`,\n )\n }\n\n getOptionalOneOf<const T extends string>(\n param: string,\n defaultValue: T,\n supportedValues: T[],\n ): T {\n const result = this.getOptional(param, defaultValue)\n return validateOneOf(\n result,\n supportedValues,\n `Unsupported ${param}: ${result}. Supported values: ${supportedValues.toString()}`,\n )\n }\n\n getOptionalValidated(\n param: string,\n defaultValue: string,\n validator: EnvValueValidator<string>,\n ): string {\n const value = this.env[param] || defaultValue\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return value\n }\n\n getOptionalValidatedInteger(\n param: string,\n defaultValue: number,\n validator: EnvValueValidator<number>,\n ): number {\n const value = this.getOptionalInteger(param, defaultValue)\n\n if (!validator(value)) {\n throw new InternalError({\n message: `Value ${value} is invalid for parameter ${param}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n\n return value\n }\n\n getOptionalTransformed(\n param: string,\n defaultValue: string,\n transformer: (value: string) => string,\n ): string {\n const value = this.env[param] || defaultValue\n return transformer(value)\n }\n\n getOptionalNullableTransformed<T extends string | undefined>(\n param: string,\n defaultValue: T,\n transformer: (value: T | string) => T | string,\n ): T | string {\n const value = this.env[param] || defaultValue\n return transformer(value as T)\n }\n\n getMandatoryTransformed(param: string, transformer: (value: string) => string) {\n const value = this.getMandatory(param)\n\n return transformer(value)\n }\n\n getOptionalBoolean(param: string, defaultValue: boolean): boolean {\n const rawValue = this.env[param]?.toLowerCase()\n if (rawValue === undefined || rawValue === '') {\n return defaultValue\n }\n\n validateOneOf(rawValue, ['true', 'false'])\n\n return rawValue === 'true'\n }\n\n getMandatoryJsonObject<T extends object>(param: string, schema: ZodSchema<T>): T {\n const rawValue = this.getMandatory(param)\n return this.validateSchema(\n JSON.parse(rawValue),\n schema,\n `Configuration parameter ${param} must be a valid JSON meeting the given schema, but was ${rawValue}`,\n )\n }\n\n getOptionalNullableJsonObject<T extends object, Z extends T | null | undefined>(\n param: string,\n schema: ZodSchema<T>,\n defaultValue: Z,\n ): Z {\n const rawValue = this.getOptionalNullable(param, undefined)\n if (!rawValue) {\n return defaultValue\n }\n\n return this.validateSchema(\n JSON.parse(rawValue),\n schema,\n `Configuration parameter ${param} must be a valid JSON meeting the given schema, but was ${rawValue}`,\n ) as Z\n }\n\n getOptionalJsonObject<T extends object>(param: string, schema: ZodSchema<T>, defaultValue: T): T {\n return this.getOptionalNullableJsonObject(param, schema, defaultValue)\n }\n\n isProduction(): boolean {\n return this.env.NODE_ENV === 'production'\n }\n\n isDevelopment(): boolean {\n return this.env.NODE_ENV !== 'production'\n }\n\n isTest(): boolean {\n return this.env.NODE_ENV === 'test'\n }\n\n private validateSchema<T extends object>(\n value: unknown,\n schema: ZodSchema<T>,\n errorMessage: string,\n ): T {\n const parsedValue = schema.safeParse(value)\n if (!parsedValue.success) {\n throw new InternalError({\n message: errorMessage,\n errorCode: 'CONFIGURATION_ERROR',\n details: parsedValue.error,\n })\n }\n\n return parsedValue.data\n }\n}\n\nexport function validateOneOf<const T>(\n validatedEntity: unknown,\n expectedOneOfEntities: T[],\n errorText?: string,\n): T {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n if (!expectedOneOfEntities.includes(validatedEntity as T)) {\n throw new InternalError({\n message:\n errorText ||\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Validated entity ${validatedEntity} is not one of: ${expectedOneOfEntities.toString()}`,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return validatedEntity as T\n}\n\nexport function validateNumber(validatedObject: unknown, errorText: string): number {\n if (!Number.isFinite(validatedObject)) {\n throw new InternalError({\n message: errorText,\n errorCode: 'CONFIGURATION_ERROR',\n })\n }\n return validatedObject as number\n}\n","import type { EnvValueTransformer } from './configTypes'\n\nexport const ensureClosingSlashTransformer: EnvValueTransformer<\n string | undefined | null,\n string\n> = (value) => {\n if (!value) {\n return ''\n }\n\n const lastChar = value.at(-1)\n if (lastChar !== '/') {\n return `${value}/`\n }\n return value\n}\n","import type { EnvValueValidator } from './configTypes'\n\nexport const createRangeValidator = (\n greaterOrEqualThan: number,\n lessOrEqualThan: number,\n): EnvValueValidator<number> => {\n return (value) => {\n return value >= greaterOrEqualThan && value <= lessOrEqualThan\n }\n}\n","type Left<T> = {\n error: T\n result?: never\n}\n\ntype Right<U> = {\n error?: never\n result: U\n}\n\n/**\n * Either is a functional programming type which is used to communicate errors happening in potentially recoverable scenarios.\n * It can return either an error (Left side) or a resolved result (Right side), but not both.\n * It is up to caller of the function to handle received error or throw (Public)NonRecoverableError if it cannot.\n *\n * @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}\n */\nexport type Either<T, U> = NonNullable<Left<T> | Right<U>>\n\n/***\n * Variation of Either, which may or may not have Error set, but always has Result\n */\nexport type DefiniteEither<T, U> = {\n error?: T\n result: U\n}\n\nexport const isFailure = <T, U>(e: Either<T, U>): e is Left<T> => {\n return e.error !== undefined\n}\n\nexport const isSuccess = <T, U>(e: Either<T, U>): e is Right<U> => {\n return e.result !== undefined\n}\n\nexport const failure = <T>(error: T): Left<T> => ({ error })\n\nexport const success = <U>(result: U): Right<U> => ({ result })\n","import * as crypto from 'node:crypto'\n\nconst algorithm = 'aes-256-gcm'\nconst ivLength = 16\nconst tagLength = 16\nconst defaultEncoding = 'hex'\nconst defaultSaltLength = 64\nconst defaultPbkdf2Iterations = 100000\n\nexport type Options = {\n saltLength?: number\n pbkdf2Iterations?: number\n encoding?: NodeJS.BufferEncoding\n}\n\n/**\n * Type-scripted version of https://github.com/MauriceButler/cryptr\n */\nexport class EncryptionUtility {\n private readonly secret: string\n private readonly saltLength: number\n private readonly encryptedPosition: number\n private readonly tagPosition: number\n private readonly pbkdf2Iterations: number\n private readonly encoding: NodeJS.BufferEncoding\n\n constructor(secret: string, options?: Options) {\n this.secret = secret\n\n this.encoding = options?.encoding ?? defaultEncoding\n this.pbkdf2Iterations = options?.pbkdf2Iterations ?? defaultPbkdf2Iterations\n this.saltLength = options?.saltLength ?? defaultSaltLength\n\n this.tagPosition = this.saltLength + ivLength\n this.encryptedPosition = this.tagPosition + tagLength\n }\n\n private getKey(salt: Buffer) {\n return crypto.pbkdf2Sync(this.secret, salt, this.pbkdf2Iterations, 32, 'sha512')\n }\n\n public encrypt(value: string) {\n const iv = crypto.randomBytes(ivLength)\n const salt = crypto.randomBytes(this.saltLength)\n\n const key = this.getKey(salt)\n\n const cipher = crypto.createCipheriv(algorithm, key, iv)\n const encrypted = Buffer.concat([cipher.update(String(value), 'utf8'), cipher.final()])\n\n const tag = cipher.getAuthTag()\n\n return Buffer.concat([salt, iv, tag, encrypted]).toString(this.encoding)\n }\n\n public decrypt(value: string) {\n const stringValue = Buffer.from(String(value), this.encoding)\n\n const salt = stringValue.subarray(0, this.saltLength)\n const iv = stringValue.subarray(this.saltLength, this.tagPosition)\n const tag = stringValue.subarray(this.tagPosition, this.encryptedPosition)\n const encrypted = stringValue.subarray(this.encryptedPosition)\n\n const key = this.getKey(salt)\n\n const decipher = crypto.createDecipheriv(algorithm, key, iv)\n\n decipher.setAuthTag(tag)\n\n return Buffer.concat([\n decipher.update(encrypted),\n Buffer.from(decipher.final('utf8')),\n ]).toString('utf8')\n }\n}\n","export function chunk<T>(array: T[], chunkSize: number): T[][] {\n const length = array.length\n if (!length || chunkSize < 1) {\n return []\n }\n let index = 0\n let resIndex = 0\n const result = new Array(Math.ceil(length / chunkSize))\n\n while (index < length) {\n // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>\n result[resIndex++] = array.slice(index, (index += chunkSize))\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return result\n}\n\nexport async function callChunked<Item>(\n chunkSize: number,\n array: readonly Item[],\n processFn: (arrayChunk: Item[]) => Promise<unknown>,\n): Promise<void> {\n for (let i = 0; i < array.length; i += chunkSize) {\n const arrayChunk = array.slice(i, i + chunkSize)\n await processFn(arrayChunk)\n }\n}\n\n/**\n * Return a copy of the given array without null or undefined values\n */\nexport function removeNullish<const T>(array: readonly (T | null | undefined)[]): T[] {\n return array.filter((e) => e !== undefined && e !== null) as T[]\n}\n\n/**\n * Return a copy of the given array without falsy values (eg: false, 0, '', null, undefined)\n */\nexport function removeFalsy<const T>(\n array: readonly (T | null | undefined | 0 | '' | false)[],\n): T[] {\n return array.filter((e) => e) as T[]\n}\n\n/**\n * Return a copy of the given array without duplicates.\n */\nexport function removeDuplicates<const T>(array: readonly T[]): T[] {\n return [...new Set(array)]\n}\n","import dotProp from 'dot-prop'\n\nimport { InternalError } from '../errors/InternalError'\n\ntype RecordKeyType = string | number | symbol\n\nexport function copyWithoutUndefined<\n T extends Record<RecordKeyType, unknown>,\n TargetRecordType = Pick<\n T,\n {\n [Prop in keyof T]: T[Prop] extends null | undefined ? never : Prop\n }[keyof T]\n >,\n>(originalValue: T): TargetRecordType {\n return Object.keys(originalValue).reduce(\n (acc, key) => {\n // @ts-ignore\n if (originalValue[key] !== undefined) {\n // @ts-ignore\n acc[key] = originalValue[key]\n }\n return acc\n },\n {} as Record<string, unknown>,\n ) as TargetRecordType\n}\n\nexport function copyWithoutEmpty<\n T extends Record<RecordKeyType, unknown>,\n TargetRecordType = Pick<\n T,\n {\n [Prop in keyof T]: T[Prop] extends null | undefined | '' ? never : Prop\n }[keyof T]\n >,\n>(originalValue: T): TargetRecordType {\n return Object.keys(originalValue).reduce(\n (acc, key) => {\n if (\n originalValue[key] !== undefined &&\n originalValue[key] !== null &&\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n (typeof originalValue[key] !== 'string' || originalValue[key].trim().length > 0)\n ) {\n // @ts-ignore\n acc[key] = originalValue[key]\n }\n return acc\n },\n {} as Record<string, unknown>,\n ) as TargetRecordType\n}\n\nexport function pick<T, K extends string | number | symbol>(\n source: T,\n propNames: readonly K[],\n): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>> {\n const result = {} as T\n let idx = 0\n while (idx < propNames.length) {\n // @ts-ignore\n if (propNames[idx] in source) {\n // @ts-ignore\n result[propNames[idx]] = source[propNames[idx]]\n }\n idx += 1\n }\n return result\n}\n\nexport function pickWithoutUndefined<T, K extends string | number | symbol>(\n source: T,\n propNames: readonly K[],\n): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>> {\n const result = {} as T\n let idx = 0\n while (idx < propNames.length) {\n // @ts-ignore\n if (propNames[idx] in source && source[propNames[idx]] !== undefined) {\n // @ts-ignore\n result[propNames[idx]] = source[propNames[idx]]\n }\n idx += 1\n }\n return result\n}\n\nexport function isEmptyObject(params: Record<string, unknown>): boolean {\n for (const key in params) {\n if (Object.hasOwn(params, key) && params[key] !== undefined) {\n return false\n }\n }\n return true\n}\n\ntype KeysMatching<T, V> = { [K in keyof T]: T[K] extends V ? K : never }[keyof T]\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects.\n * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.\n */\nexport function groupBy<\n T extends object,\n K extends KeysMatching<T, RecordKeyType | null | undefined>,\n>(array: T[], selector: K): Record<RecordKeyType, T[]> {\n return array.reduce(\n (acc, item) => {\n const key = item[selector] as RecordKeyType | null | undefined\n if (key === undefined || key === null) {\n return acc\n }\n if (!acc[key]) {\n acc[key] = []\n }\n acc[key].push(item)\n return acc\n },\n {} as Record<RecordKeyType, T[]>,\n )\n}\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects. Support nested keys.\n * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.\n */\nexport function groupByPath<T extends object>(array: T[], selector: string): Record<string, T[]> {\n return array.reduce(\n (acc, item) => {\n const key = dotProp.get(item, selector)\n if (key === undefined || key === null) {\n return acc\n }\n const strKeyPath = key as string\n\n if (!acc[strKeyPath]) {\n acc[strKeyPath] = []\n }\n acc[strKeyPath].push(item)\n return acc\n },\n {} as Record<RecordKeyType, T[]>,\n )\n}\n\n/**\n * @param array The array of objects to be grouped.\n * @param selector The key used for grouping the objects.\n * @returns An object where the keys are unique values from the given selector and the value is the\n * corresponding object from the array.\n * @throws InternalError If a duplicated value is found for the given selector.\n */\nexport function groupByUnique<\n T extends object,\n K extends KeysMatching<T, RecordKeyType | null | undefined>,\n>(array: T[], selector: K): Record<RecordKeyType, T> {\n return array.reduce(\n (acc, item) => {\n const key = item[selector] as RecordKeyType | null | undefined\n if (key === undefined || key === null) {\n return acc\n }\n if (acc[key] !== undefined) {\n throw new InternalError({\n message: `Duplicated item for selector ${selector.toString()} with value ${key.toString()}`,\n errorCode: 'DUPLICATED_ITEM',\n details: { selector, value: key },\n })\n }\n acc[key] = item\n return acc\n },\n {} as Record<RecordKeyType, T>,\n )\n}\n\ntype DatesAsString<T> = T extends Date ? string : ExactlyLikeWithDateAsString<T>\n\ntype ExactlyLikeWithDateAsString<T> = T extends object ? { [K in keyof T]: DatesAsString<T[K]> } : T\n\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input,\n): ExactlyLikeWithDateAsString<Input>\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input[],\n): ExactlyLikeWithDateAsString<Input>[]\nexport function convertDateFieldsToIsoString<Input extends object>(\n object: Input | Input[],\n): ExactlyLikeWithDateAsString<Input> | ExactlyLikeWithDateAsString<Input>[] {\n if (Array.isArray(object)) {\n // @ts-ignore\n return object.map(convertDateFieldsToIsoStringAux)\n }\n\n return Object.entries(object).reduce(\n (result, [key, value]) => {\n // @ts-ignore\n result[key] = convertDateFieldsToIsoStringAux(value)\n return result\n },\n {} as ExactlyLikeWithDateAsString<Input>,\n )\n}\n\nfunction convertDateFieldsToIsoStringAux<T>(item: T): DatesAsString<T> {\n if (item instanceof Date) {\n // @ts-ignore\n return item.toISOString()\n }\n\n if (item && typeof item === 'object') {\n // @ts-ignore\n return convertDateFieldsToIsoString(item)\n }\n\n // @ts-ignore\n return item\n}\n\n/**\n * Return a deep clone copy of an object.\n *\n * Please Note: This uses structuredClone, which has the limitations of these restricted Types: functions,\n * Error objects, WeakMap, WeakSet, DOM nodes, and certain other browser-specific objects like Window.\n */\nexport function deepClone<T extends object | undefined | null>(object: T): T {\n if (object === undefined || object === null) {\n return object\n }\n return structuredClone(object)\n}\n\nfunction transformKey(key: string): string {\n return key\n .replace(/([a-z])([A-Z])/g, '$1-$2') // transforms basic camelCase\n .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2') // transforms abbreviations\n .replace(/_/g, '-') // transforms snake_case\n .toLowerCase() // finally lowercase all\n}\n\ntype TransformToKebabCaseInputType = Record<string, unknown> | null | undefined\ntype TransformToKebabCaseReturnType<Input, Output> = Input extends Record<string, unknown>\n ? Output\n : Input\n/**\n * Transforms an object's keys from camelCase or snake_case to kebab-case.\n * @param object\n */\nexport function transformToKebabCase<\n Output extends Record<string, unknown>,\n Input extends TransformToKebabCaseInputType,\n>(object: Input): TransformToKebabCaseReturnType<Input, Output>\n\nexport function transformToKebabCase<\n Output extends Record<string, unknown>,\n Input extends TransformToKebabCaseInputType,\n>(object: Input[]): TransformToKebabCaseReturnType<Input, Output>[]\n\nexport function transformToKebabCase<Output, Input>(\n object: Input | Input[],\n): TransformToKebabCaseReturnType<Input, Output> | TransformToKebabCaseReturnType<Input, Output>[] {\n if (Array.isArray(object)) {\n // @ts-ignore\n return object.map(transformToKebabCase)\n }\n if (typeof object !== 'object' || object === null || object === undefined) {\n return object as TransformToKebabCaseReturnType<Input, Output>\n }\n\n return Object.entries(object as Record<string, unknown>).reduce(\n (result, [key, value]) => {\n const transformedKey = transformKey(key)\n const transformedValue =\n value && typeof value === 'object'\n ? transformToKebabCase(value as TransformToKebabCaseInputType)\n : value\n\n // Avoiding destructuring by directly assigning the new key-value pair\n result[transformedKey] = transformedValue\n return result\n },\n {} as Record<string, unknown>,\n ) as TransformToKebabCaseReturnType<Input, Output>\n}\n","import { createHash } from 'node:crypto'\n\nexport enum HashEncoding {\n HEX = 'hex',\n BASE64 = 'base64',\n}\n\nexport enum HashAlgorithm {\n SHA256 = 'sha256',\n SHA512 = 'sha512',\n}\n\nexport function generateHash(\n algorithm: HashAlgorithm,\n data: string,\n encoding: HashEncoding = HashEncoding.HEX,\n) {\n return createHash(algorithm).update(data).digest(encoding)\n}\n","import type { Level, Logger, LoggerOptions, redactOptions } from 'pino'\nimport { levels, pino } from 'pino'\nimport pretty from 'pino-pretty'\n\nexport type AppLoggerConfig = {\n logLevel: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n nodeEnv: 'production' | 'development' | 'test'\n base?: Record<string, unknown>\n redact?: redactOptions\n}\n\nexport type MonorepoAppLoggerConfig = AppLoggerConfig & {\n targetFile?: string\n append?: boolean\n}\n\n/* c8 ignore next 8 */\nexport function resolveMonorepoLogger(appConfig: MonorepoAppLoggerConfig): Logger {\n if (appConfig.nodeEnv !== 'development') {\n return resolveLogger(appConfig)\n }\n\n const configuration = resolveMonorepoLoggerConfiguration(appConfig) as LoggerOptions\n return pino(configuration)\n}\n\n// Note that transports do not work in vitest, likely because pino attempts to run them in a separate worker\n/* c8 ignore next 25 */\nexport function resolveMonorepoLoggerConfiguration(\n appConfig: MonorepoAppLoggerConfig,\n): LoggerOptions | Logger {\n if (appConfig.nodeEnv !== 'development') {\n return resolveLoggerConfiguration(appConfig)\n }\n\n return {\n level: appConfig.logLevel,\n formatters: {\n level: (label) => {\n return { level: label }\n },\n },\n redact: appConfig.redact,\n transport: {\n target: 'pino/file',\n options: {\n destination: appConfig.targetFile ?? './service.log',\n mkdir: true,\n append: appConfig.append ?? false,\n },\n },\n }\n}\n\nexport function resolveLogger(appConfig: AppLoggerConfig): Logger {\n if (appConfig.nodeEnv !== 'production') {\n return resolveLoggerConfiguration(appConfig) as Logger\n }\n\n const configuration = resolveLoggerConfiguration(appConfig) as LoggerOptions\n return pino(configuration)\n}\n\nexport function resolveLoggerConfiguration(appConfig: AppLoggerConfig): LoggerOptions | Logger {\n if (appConfig.nodeEnv !== 'production') {\n return pino(\n pretty({\n sync: true,\n minimumLevel: appConfig.logLevel as Level,\n colorize: true,\n translateTime: 'SYS:standard',\n ignore: 'hostname,pid',\n }),\n )\n }\n\n return {\n level: appConfig.logLevel,\n formatters: {\n level: (_label, numericLevel): { level: string } => {\n const level = levels.labels[numericLevel] || 'unknown'\n return { level }\n },\n },\n redact: appConfig.redact,\n } satisfies LoggerOptions\n}\n","import { types } from 'node:util'\n\nimport type { SerializedError } from 'pino'\nimport { levels, pino, stdSerializers } from 'pino'\n\nimport type { CommonLogger } from '../logging/commonLogger'\nimport { hasMessage } from '../utils/typeUtils'\n\ntype LogObject = {\n message: string\n 'x-request-id'?: string\n error?: SerializedError\n}\n\nexport const globalLogger: CommonLogger = pino({\n formatters: {\n level: (_label, numericLevel): { level: string } => {\n const level = levels.labels[numericLevel] || 'unknown'\n return { level }\n },\n },\n})\n\nexport function resolveGlobalErrorLogObject(err: unknown, correlationId?: string): LogObject {\n if (types.isNativeError(err)) {\n return {\n message: err.message,\n error: stdSerializers.err(err),\n 'x-request-id': correlationId,\n }\n }\n\n if (hasMessage(err)) {\n return {\n message: err.message,\n 'x-request-id': correlationId,\n }\n }\n\n return {\n message: 'Unknown error',\n 'x-request-id': correlationId,\n }\n}\n\nexport function executeAndHandleGlobalErrors<T>(operation: () => T) {\n try {\n const result = operation()\n return result\n } catch (err) {\n const logObject = resolveGlobalErrorLogObject(err)\n globalLogger.error(logObject, logObject.message)\n process.exit(1)\n }\n}\n\nexport async function executeAsyncAndHandleGlobalErrors<T>(\n operation: () => Promise<T>,\n stopOnError = true,\n) {\n try {\n const result = await operation()\n return result\n } catch (err) {\n const logObject = resolveGlobalErrorLogObject(err)\n globalLogger.error(logObject, logObject.message)\n if (stopOnError) {\n process.exit(1)\n }\n }\n}\n\nexport async function executeSettleAllAndHandleGlobalErrors(\n promises: Promise<unknown>[],\n stopOnError = true,\n) {\n const result = await Promise.allSettled(promises)\n\n let errorsHappened: boolean | undefined\n for (const entry of result) {\n if (entry.status === 'rejected') {\n const logObject = resolveGlobalErrorLogObject(entry.reason)\n globalLogger.error(logObject, logObject.message)\n errorsHappened = true\n }\n }\n\n if (stopOnError && errorsHappened) {\n process.exit(1)\n }\n\n return result\n}\n","import { constants as httpConstants } from 'node:http2'\n\nimport type { FreeformRecord } from '../common/commonTypes'\n\nimport { PublicNonRecoverableError } from './PublicNonRecoverableError'\n\nexport type CommonErrorParams = {\n message: string\n details?: FreeformRecord\n cause?: Error\n}\n\nexport type OptionalMessageErrorParams = Partial<CommonErrorParams>\n\nexport type ValidationError = {\n message: string\n path: string[]\n}\n\nexport class RequestValidationError extends PublicNonRecoverableError {\n constructor(errors: ValidationError[]) {\n super({\n message: 'Invalid params',\n errorCode: 'VALIDATION_ERROR',\n httpStatusCode: httpConstants.HTTP_STATUS_BAD_REQUEST,\n details: {\n error: errors,\n },\n })\n }\n}\n\nexport class AccessDeniedError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ACCESS_DENIED',\n httpStatusCode: httpConstants.HTTP_STATUS_FORBIDDEN,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n\nexport class EntityNotFoundError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ENTITY_NOT_FOUND',\n httpStatusCode: httpConstants.HTTP_STATUS_NOT_FOUND,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n\nexport class EntityGoneError extends PublicNonRecoverableError {\n constructor(params: CommonErrorParams) {\n super({\n message: params.message,\n errorCode: 'ENTITY_GONE',\n httpStatusCode: 410,\n details: params.details,\n })\n }\n}\n\nexport class AuthFailedError extends PublicNonRecoverableError {\n constructor(params: OptionalMessageErrorParams = {}) {\n super({\n message: params.message ?? 'Authentication failed',\n errorCode: 'AUTH_FAILED',\n httpStatusCode: httpConstants.HTTP_STATUS_UNAUTHORIZED,\n details: params.details,\n cause: params.cause,\n })\n }\n}\n","export const waitAndRetry = async <T>(\n predicateFn: () => T,\n sleepTime = 20,\n maxRetryCount = 15,\n): Promise<T> => {\n return new Promise((resolve, reject) => {\n let retryCount = 0\n function performCheck() {\n // amount of retries exceeded\n if (maxRetryCount !== 0 && retryCount > maxRetryCount) {\n resolve(predicateFn())\n }\n\n // Try executing predicateFn\n Promise.resolve()\n .then(() => {\n return predicateFn()\n })\n .then((result) => {\n if (result) {\n resolve(result)\n } else {\n retryCount++\n setTimeout(performCheck, sleepTime)\n }\n })\n .catch((err) => {\n reject(err)\n })\n }\n\n performCheck()\n })\n}\n","import type { TransactionObservabilityManager } from './observabilityTypes'\n\n/**\n * Groups different TransactionObservabilityManager instances into one\n * to facilitate tracking transactions across multiple observability tools.\n */\nexport class MultiTransactionObservabilityManager implements TransactionObservabilityManager {\n private readonly managers: TransactionObservabilityManager[]\n\n constructor(managers: TransactionObservabilityManager[]) {\n this.managers = managers\n }\n\n start(transactionName: string, uniqueTransactionKey: string): void {\n for (const manager of this.managers) {\n manager.start(transactionName, uniqueTransactionKey)\n }\n }\n\n startWithGroup(\n transactionName: string,\n uniqueTransactionKey: string,\n transactionGroup: string,\n ): void {\n for (const manager of this.managers) {\n manager.startWithGroup(transactionName, uniqueTransactionKey, transactionGroup)\n }\n }\n\n stop(uniqueTransactionKey: string, wasSuccessful?: boolean): void {\n for (const manager of this.managers) {\n manager.stop(uniqueTransactionKey, wasSuccessful)\n }\n }\n}\n","import type { BinaryLike } from 'node:crypto'\nimport { createHash } from 'node:crypto'\nimport type { Readable } from 'node:stream'\n\nconst HASH_ALGORITHM = 'md5'\n\nexport function generateChecksumForBufferOrString(data: BinaryLike): string {\n return createHash(HASH_ALGORITHM).update(data).digest('hex')\n}\n\nexport function generateChecksumForObject(object: object): string {\n const objectAsString = JSON.stringify(object)\n return generateChecksumForBufferOrString(objectAsString)\n}\n\nexport function generateChecksumForReadable(readable: Readable): Promise<string> {\n return new Promise((resolve, reject) => {\n const hashCreator = createHash(HASH_ALGORITHM)\n readable.on('data', (data) => {\n if (Buffer.isBuffer(data)) {\n hashCreator.update(data)\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hashCreator.update(Buffer.from(data))\n }\n })\n\n readable.on('end', () => {\n const hash = hashCreator.digest('hex')\n resolve(hash)\n })\n readable.on('error', (err) => {\n /* c8 ignore next 1 */\n reject(err)\n })\n })\n}\n","import { F_OK } from 'node:constants'\nimport { access, createReadStream, createWriteStream } from 'node:fs'\nimport { stat, unlink } from 'node:fs/promises'\nimport type { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream'\n\nexport type ReadableProvider = {\n /**\n * Guarantees to provide a new stream every time this is called, before `destroy` is invoked.\n */\n createStream(): Promise<Readable>\n\n /**\n * Returns size of the persisted content\n */\n getContentLength(): Promise<number>\n\n /**\n * Remove the persisted value. No new streams can be created after this is called\n */\n destroy(): Promise<void>\n}\n\nexport type PersistToFsOptions = {\n targetFile: string\n sourceReadable: Readable\n}\n\nexport type FsReadableProviderOptions = {\n storageFile: string\n}\n\nexport class FsReadableProvider implements ReadableProvider {\n public readonly storageFile: string\n constructor(options: FsReadableProviderOptions) {\n this.storageFile = options.storageFile\n }\n\n fileExists(): Promise<boolean> {\n return new Promise((resolve) => {\n access(this.storageFile, F_OK, (err) => {\n return resolve(!err)\n })\n })\n }\n\n async getContentLength(): Promise<number> {\n if (!(await this.fileExists())) {\n throw new Error(`File ${this.storageFile} was already deleted.`)\n }\n const stats = await stat(this.storageFile)\n return stats.size\n }\n\n async createStream(): Promise<Readable> {\n if (!(await this.fileExists())) {\n throw new Error(`File ${this.storageFile} was already deleted.`)\n }\n\n return createReadStream(this.storageFile)\n }\n\n async destroy(): Promise<void> {\n if (!(await this.fileExists())) {\n // nothing to do here\n return\n }\n\n return unlink(this.storageFile)\n }\n\n protected async persist(sourceReadable: Readable): Promise<void> {\n const writable = createWriteStream(this.storageFile)\n return new Promise((resolve, reject) => {\n pipeline(sourceReadable, writable, (err) => {\n if (err) {\n /* c8 ignore next 1 */\n reject(err)\n } else {\n resolve()\n }\n })\n })\n }\n\n public static async persistReadableToFs(\n options: PersistToFsOptions,\n ): Promise<FsReadableProvider> {\n const provider = new FsReadableProvider({\n storageFile: options.targetFile,\n })\n await provider.persist(options.sourceReadable)\n return provider\n }\n}\n\n/**\n * Consumes the readable in order to calculate its length in bytes\n * @param readable\n */\nexport function getReadableContentLength(readable: Readable): Promise<number> {\n return new Promise((resolve, reject) => {\n let size = 0\n readable.on('data', (chunk) => {\n if (typeof chunk === 'string' || Buffer.isBuffer(chunk)) {\n size += Buffer.byteLength(chunk)\n }\n })\n readable.on('end', () => {\n resolve(size)\n })\n readable.on('error', (error) => {\n /* c8 ignore next 1 */\n reject(error)\n })\n })\n}\n"],"mappings":";AAMO,SAAS,WAAW,OAA8C;AACvE,SAAO,SAAS,KAAK,KAAK,OAAO,MAAM,YAAY;AACrD;AAEO,SAAS,SAAS,aAAmE;AAC1F,SAAO,OAAO,gBAAgB,YAAY,gBAAgB;AAC5D;AAEO,SAAS,oBAAoB,OAA4C;AAC9E,SAAO,SAAS,KAAK,KAAK,OAAO,MAAM,SAAS,YAAY,OAAO,MAAM,YAAY;AACvF;AAEO,SAAS,QAAQ,YAA0C;AAChE,SACE,sBAAsB,SAAS,OAAO,UAAU,SAAS,KAAK,UAAU,MAAM;AAElF;;;ACXA,IAAM,0CAA0C;AAChD,IAAM,kCAAkC,OAAO,IAAI,uCAAuC;AAKnF,IAAM,4BAAN,cAA0D,MAAM;AAAA,EACrE,CAAU,+BAA+B,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,YAAY,QAA4C;AACtD,UAAM,OAAO,SAAS;AAAA,MACpB,OAAO,OAAO;AAAA,IAChB,CAAC;AAED,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,UAAU,OAAO;AACtB,SAAK,YAAY,OAAO;AACxB,SAAK,iBAAiB,OAAO,kBAAkB;AAAA,EACjD;AACF;AAEO,SAAS,4BAA4B,OAAoD;AAC9F,SACE,QAAQ,KAAK;AAAA,GAEX,MAAc,OAAO,IAAI,uCAAuC,CAAC,MAAM,QACvE,MAAM,SAAS;AAErB;;;AChCA,IAAM,4BAA4B;AAClC,IAAM,sBAAsB,OAAO,IAAI,yBAAyB;AAEzD,IAAM,gBAAN,cAA8C,MAAM;AAAA,EACzD,CAAU,mBAAmB,IAAI;AAAA,EACjB;AAAA,EACA;AAAA,EAEhB,YAAY,QAAgC;AAC1C,UAAM,OAAO,S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":["HashEncoding","HashAlgorithm","algorithm","levels","pino","pino","levels","createHash"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokalise/node-core",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.2",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Lokalise",
|
|
6
6
|
"url": "https://lokalise.com/"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"files": ["dist"],
|
|
15
15
|
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
16
17
|
"exports": {
|
|
17
18
|
"./package.json": "./package.json",
|
|
18
19
|
".": {
|