Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @tezos-dappetizer/utils

Index

Dappetizer Config

Other

Other

AllProperties<T>: { [ P in keyof Required<T>]: Pick<T, P> extends Required<Pick<T, P>> ? T[P] : T[P] | undefined }

Type parameters

  • T

ChildProcessAbstraction: { exec: typeof exec; spawn: typeof spawn }

Type declaration

  • Readonly exec: typeof exec
  • Readonly spawn: typeof spawn
Constructor<T>: new (...args: any[]) => T

Type parameters

Type declaration

    • new (...args: any[]): T
    • Parameters

      • Rest ...args: any[]

      Returns T

DeepReadonly<T>: T extends Builtin ? T : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends WeakMap<infer K, infer V> ? WeakMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends WeakSet<infer U> ? WeakSet<DeepReadonly<U>> : T extends Promise<infer U> ? Promise<DeepReadonly<U>> : T extends AnyArray<infer U> ? readonly DeepReadonly<U>[] : T extends object ? { readonly [ K in keyof T]: DeepReadonly<T[K]> } : Readonly<T>

Type parameters

  • T

DefaultConstructor<T>: new () => T

Type parameters

Type declaration

    • new (): T
    • Returns T

FSAbstraction: { existsSync: typeof existsSync; mkdirSync: typeof mkdirSync; promises: FSPromisesAbstraction; readFileSync: typeof readFileSync; statSync: typeof statSync; writeFileSync: typeof writeFileSync }

Type declaration

  • Readonly existsSync: typeof existsSync
  • Readonly mkdirSync: typeof mkdirSync
  • Readonly promises: FSPromisesAbstraction
  • Readonly readFileSync: typeof readFileSync
  • Readonly statSync: typeof statSync
  • Readonly writeFileSync: typeof writeFileSync
FSPromisesAbstraction: typeof promises
KeyOfType<TObject, TProperty>: { [ P in keyof TObject]: TObject[P] extends TProperty ? P : never }[keyof TObject]

Type parameters

  • TObject

  • TProperty

LogData: {}

Type declaration

  • [key: string]: unknown
LoggerCategory: string | Constructor
NonEmptyArray<T>: [T, ...T[]]

Type parameters

  • T

NonEmptyReadonlyArray<T>: readonly [T, ...T[]]
deprecated

Use Readonly<NonEmptyArray<T>> instead.

Type parameters

  • T

Nullish<T>: T | null | undefined

Type parameters

  • T

OneOrReadonlyArray<T>: T | readonly T[]

Type parameters

  • T

RecordToDump: {}

Type declaration

StringKeyOfType<TObject, TProperty>: Extract<KeyOfType<TObject, TProperty>, string>

Type parameters

  • TObject

  • TProperty

TypeOfName: typeof unknownDummy
ValueToDump: undefined | boolean | number | string | null | BigNumber | Date | readonly ValueToDump[] | RecordToDump
APP_SHUTDOWN_MANAGER_DI_TOKEN: InjectionToken<AppShutdownManager> = ...
BACKGROUND_WORKERS_DI_TOKEN: InjectionToken<BackgroundWorker> = ...
CHILD_PROCESS_DI_TOKEN: InjectionToken<ChildProcessAbstraction> = ...
CLOCK_DI_TOKEN: InjectionToken<Clock> = ...
CONFIGS_WITH_DIAGNOSTIC_DI_TOKEN: InjectionToken<ConfigWithDiagnostics> = ...
CONFIG_NETWORK_DI_TOKEN: InjectionToken<string> = ...
DI_CONTAINER_DI_TOKEN: InjectionToken<default> = ...
EXPLICIT_CONFIG_FILE_PATH_DI_TOKEN: InjectionToken<string> = ...
EXPRESS_APP_DI_TOKEN: InjectionToken<Application> = ...
FS_DI_TOKEN: InjectionToken<FSAbstraction> = ...
FS_PROMISES_DI_TOKEN: InjectionToken<__module> = ...
HEALTH_CHECKS_DI_TOKEN: InjectionToken<HealthCheck> = 'HealthChecks'
HTTP_FETCHER_DI_TOKEN: InjectionToken<HttpFetcher> = ...
HTTP_HANDLERS_DI_TOKEN: InjectionToken<HttpHandler> = 'HttpHandlers'
LOGGER_FACTORY_DI_TOKEN: InjectionToken<LoggerFactory> = ...
LONG_EXECUTION_HELPER_DI_TOKEN: InjectionToken<LongExecutionHelper> = ...
MAINNET: "mainnet" = 'mainnet'
METRICS_UPDATERS_DI_TOKEN: InjectionToken<MetricsUpdater> = ...
NETWORK_SPECIFIC_CONFIG_ELEMENT_DI_TOKEN: InjectionToken<ConfigObjectElement<string>> = ...
PACKAGE_JSON_LOADER_DI_TOKEN: InjectionToken<PackageJsonLoader> = ...
PROCESS_DI_TOKEN: InjectionToken<Process> = ...
REQUIRE_DI_TOKEN: InjectionToken<RequireAbstraction> = ...
ROOT_CONFIG_ELEMENT_DI_TOKEN: InjectionToken<ConfigObjectElement<string>> = ...
ROOT_LOGGER_DI_TOKEN: InjectionToken<RootLogger> = ...
ROOT_LOGGER_FACTORY_DI_TOKEN: InjectionToken<RootLoggerFactory> = ...
RPC_BLOCK_MONITOR_DI_TOKEN: InjectionToken<RpcBlockMonitor> = ...
RPC_MEMPOOL_MONITOR_DI_TOKEN: InjectionToken<RpcMempoolMonitor> = ...
SLEEP_HELPER_DI_TOKEN: InjectionToken<SleepHelper> = ...
TAQUITO_HTTP_BACKEND_DI_TOKEN: InjectionToken<HttpBackend> = ...
TAQUITO_RPC_CLIENT_DI_TOKEN: InjectionToken<RpcClient> = ...
TIMER_HELPER_DI_TOKEN: InjectionToken<TimerHelper> = ...
VERSION_INFOS_DI_TOKEN: InjectionToken<VersionInfo> = ...
candidateConfigFileNames: readonly ["dappetizer.config.ts", "dappetizer.config.js", "dappetizer.config.json"] = ...

If config file path is not expecified explicitly, then these candidates are checked.

contentTypes: Readonly<{ JSON: string }> = ...
emptyStringSanitizer: StringSanitizer = ...
httpHeaders: Readonly<{ ACCEPT: string; CONTENT_TYPE: string }> = ...
httpMethods: Readonly<{ DELETE: string; GET: string; HEAD: string; OPTIONS: string; PATCH: string; POST: string; PUT: string }> = ...
httpStatusCodes: Readonly<{ INTERNAL_SERVER_ERROR: number; OK: number }> = ...
npmModules: { BIGNUMBER: "bignumber.js"; TYPEORM: "typeorm"; dappetizer: { CLI: "@tezos-dappetizer/cli"; DATABASE: "@tezos-dappetizer/database"; DECORATORS: "@tezos-dappetizer/decorators"; INDEXER: "@tezos-dappetizer/indexer"; UTILS: "@tezos-dappetizer/utils" }; taquito: { MICHELSON_ENCODER: "@taquito/michelson-encoder"; TAQUITO: "@taquito/taquito" } } = ...

Type declaration

  • BIGNUMBER: "bignumber.js"
  • TYPEORM: "typeorm"
  • dappetizer: { CLI: "@tezos-dappetizer/cli"; DATABASE: "@tezos-dappetizer/database"; DECORATORS: "@tezos-dappetizer/decorators"; INDEXER: "@tezos-dappetizer/indexer"; UTILS: "@tezos-dappetizer/utils" }
    • CLI: "@tezos-dappetizer/cli"
    • DATABASE: "@tezos-dappetizer/database"
    • DECORATORS: "@tezos-dappetizer/decorators"
    • INDEXER: "@tezos-dappetizer/indexer"
    • UTILS: "@tezos-dappetizer/utils"
  • taquito: { MICHELSON_ENCODER: "@taquito/michelson-encoder"; TAQUITO: "@taquito/taquito" }
    • MICHELSON_ENCODER: "@taquito/michelson-encoder"
    • TAQUITO: "@taquito/taquito"
unknownDummy: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" = ...
versionInfo: Readonly<{ COMMIT_HASH: ""; VERSION: string }> = ...
  • addAbortListener(signal: AbortSignal, listener: () => void): () => void
  • Parameters

    • signal: AbortSignal
    • listener: () => void
        • (): void
        • Returns void

    Returns () => void

      • (): void
      • Returns void

  • addMillis(date: Date, millis: number): Date
  • Parameters

    • date: Date
    • millis: number

    Returns Date

  • appendUrl(baseUrl: string, relativeUrl: string): string
  • Resolves trailing/leading/missing slashes.

    Parameters

    • baseUrl: string
    • relativeUrl: string

    Returns string

  • asReadonly<T>(items: T[]): readonly T[]
  • asReadonly<T>(obj: T): Readonly<T>
  • Type parameters

    • T

    Parameters

    • items: T[]

    Returns readonly T[]

  • Type parameters

    • T

    Parameters

    • obj: T

    Returns Readonly<T>

  • bindNameofFunc<T>(): (key: keyof T) => string
  • deprecated

    Create a helper function on your own.

    Type parameters

    • T

    Returns (key: keyof T) => string

      • (key: keyof T): string
      • deprecated

        Create a helper function on your own.

        Parameters

        • key: keyof T

        Returns string

  • cacheFuncResult<T>(factory: () => T): () => T
  • Helper for lazy initialization of a singleton value.

    Type parameters

    • T

    Parameters

    • factory: () => T
        • (): T
        • Returns T

    Returns () => T

      • (): T
      • Helper for lazy initialization of a singleton value.

        Returns T

  • Creates a new object of given type and assigns its specified properties. Useful when properties are read-only. Compared to Object.assign(), this method makes sure that only existing properties are being assigned.

    Type parameters

    • T

    Parameters

    Returns T

  • createDIToken<T>(uniqueName: string): InjectionToken<T>
  • Makes sure that DI token is not treated as a string.

    Type parameters

    • T

    Parameters

    • uniqueName: string

    Returns InjectionToken<T>

  • deduplicate<T>(getKey: (value: T) => string): (source: Wrappable<T>) => IterableIterator<T>
  • deduplicate<T>(getKey: (value: T) => string, source: Wrappable<T>): IterableIterator<T>
  • Gets a function which deduplicates items of an iterable by specified key. It can be chained using a pipe().

    Type parameters

    • T

    Parameters

    • getKey: (value: T) => string
        • (value: T): string
        • Parameters

          • value: T

          Returns string

    Returns (source: Wrappable<T>) => IterableIterator<T>

      • (source: Wrappable<T>): IterableIterator<T>
      • Gets a function which deduplicates items of an iterable by specified key. It can be chained using a pipe().

        Parameters

        • source: Wrappable<T>

        Returns IterableIterator<T>

  • Deduplicates items of specified source iterable by specified key.

    Type parameters

    • T

    Parameters

    • getKey: (value: T) => string
        • (value: T): string
        • Parameters

          • value: T

          Returns string

    • source: Wrappable<T>

    Returns IterableIterator<T>

  • Deeply freezes an object even if it has circular references.

    Type parameters

    • T

    Parameters

    • obj: T

    Returns DeepReadonly<T>

  • Produces debug friendly dump of the given value, not a valid JSON.

    Parameters

    Returns string

  • dumpType(value: unknown): string
  • Parameters

    • value: unknown

    Returns string

  • equalsIgnoreCase(str1: string, str2: string): boolean
  • Parameters

    • str1: string
    • str2: string

    Returns boolean

  • errorObjToString(error: Error): string
  • Parameters

    • error: Error

    Returns string

  • errorToString(error: unknown, options?: { onlyMessage?: boolean }): string
  • Parameters

    • error: unknown
    • Optional options: { onlyMessage?: boolean }
      • Optional onlyMessage?: boolean

    Returns string

  • freezeResult(): MethodDecorator
  • Returns MethodDecorator

  • Safely gets a constructor name - returns Object if an object is created without a prototype.

    Parameters

    Returns string

  • getEnumTypeName(enumWrapper: Record<string, Record<string, string>>): string
  • deprecated

    Use getVariableName instead.

    Parameters

    • enumWrapper: Record<string, Record<string, string>>

    Returns string

  • getEnumValues<T>(enumType: Record<string, T>): T[]
  • Type parameters

    • T: string

    Parameters

    • enumType: Record<string, T>

    Returns T[]

  • getVariableName(variableWrapper: Record<string, unknown>): string
  • Parameters

    • variableWrapper: Record<string, unknown>

    Returns string

  • hasConstructor<T>(value: unknown, type: Constructor<T>): value is T
  • Checks actual constructor, does NOT honor inheritance chain. Compared to instanceof, works if type comes from multiple NPM modules.

    Type parameters

    Parameters

    Returns value is T

  • hasLength<T>(array: Nullish<readonly T[]>, lengthToCheck: 1): array is [T]
  • hasLength<T>(array: Nullish<readonly T[]>, lengthToCheck: 2): array is [T, T]
  • hasLength<T>(array: Nullish<readonly T[]>, lengthToCheck: 3): array is [T, T, T]
  • Type parameters

    • T

    Parameters

    • array: Nullish<readonly T[]>
    • lengthToCheck: 1

    Returns array is [T]

  • Type parameters

    • T

    Parameters

    • array: Nullish<readonly T[]>
    • lengthToCheck: 2

    Returns array is [T, T]

  • Type parameters

    • T

    Parameters

    • array: Nullish<readonly T[]>
    • lengthToCheck: 3

    Returns array is [T, T, T]

  • hasToJSON<T>(value: T): value is T & ToJSON
  • humanReadable(str: string): string
  • Parameters

    • str: string

    Returns string

  • injectAllOptional<T>(token: InjectionToken<T>): ReturnType<typeof injectWithTransform>
  • Fixes @injectAll() which fails if nothing is registered. This injects empty array instead.

    Type parameters

    • T

    Parameters

    • token: InjectionToken<T>

    Returns ReturnType<typeof injectWithTransform>

  • injectExplicit(argIndex?: number): ReturnType<typeof inject>
  • Parameters

    • argIndex: number = 0

    Returns ReturnType<typeof inject>

  • injectLogger(category: LoggerCategory): ReturnType<typeof injectWithTransform>
  • Used on constructor parameter for dependency injection of a logger for the specified category.

    Parameters

    Returns ReturnType<typeof injectWithTransform>

  • injectOptional<T>(token: InjectionToken<T>): ReturnType<typeof injectWithTransform>
  • Fixes @inject() which fails if nothing is registered. This injects undefined instead.

    Type parameters

    • T

    Parameters

    • token: InjectionToken<T>

    Returns ReturnType<typeof injectWithTransform>

  • isAbortError(error: unknown): boolean
  • Parameters

    • error: unknown

    Returns boolean

  • Type parameters

    • T

    Parameters

    Returns array is NonEmptyArray<T>

  • Type parameters

    • T

    Parameters

    Returns array is readonly [T, T]

  • isNotNullish<TValue>(value: Nullish<TValue>): value is TValue
  • Type parameters

    • TValue

    Parameters

    Returns value is TValue

  • isNullish<TValue>(value: Nullish<TValue>): value is undefined | null
  • Type parameters

    • TValue

    Parameters

    Returns value is undefined | null

  • isNullishOrEmpty<T>(array: Nullish<readonly T[]>): array is undefined | null
  • Type parameters

    • T

    Parameters

    Returns array is undefined | null

  • isObject(value: unknown): value is Record<string, unknown>
  • Parameters

    • value: unknown

    Returns value is Record<string, unknown>

  • isObjectLiteral(value: unknown): value is Record<string, unknown>
  • Parameters

    • value: unknown

    Returns value is Record<string, unknown>

  • isReadOnlyArray(value: unknown): value is readonly unknown[]
  • Parameters

    • value: unknown

    Returns value is readonly unknown[]

  • isWhiteSpace(str: Nullish<string>): str is undefined | null | ""
  • Parameters

    Returns str is undefined | null | ""

  • keyof<T>(key: keyof T & string): keyof T & string
  • Type parameters

    • T

    Parameters

    • key: keyof T & string

    Returns keyof T & string

  • last<T>(list: readonly [T, T]): T
  • last<T>(list: readonly T[]): T | undefined
  • Type parameters

    • T

    Parameters

    • list: readonly [T, T]

    Returns T

  • Type parameters

    • T

    Parameters

    • list: readonly T[]

    Returns T | undefined

  • listAllPropertyNames<T>(obj: T): (keyof T & string)[]
  • Lists both own and inherited properties including non-enumerable ones.

    Type parameters

    • T: object

    Parameters

    • obj: T

    Returns (keyof T & string)[]

  • locatePackageJsonInCurrentPackage(pathWithinPackage: string): string
  • Parameters

    • pathWithinPackage: string

    Returns string

  • nameof<T>(key: keyof T): string
  • deprecated

    Use [[keyOf]] instead.

    Type parameters

    • T

    Parameters

    • key: keyof T

    Returns string

  • pascalCase(str: string): string
  • Parameters

    • str: string

    Returns string

  • registerCachedHealthCheck(diContainer: default, resolveOptions: (diContainer: default) => { cacheTimeMillis: number; healthCheckToCache: HealthCheck }): void
  • Parameters

    • diContainer: default
    • resolveOptions: (diContainer: default) => { cacheTimeMillis: number; healthCheckToCache: HealthCheck }
        • (diContainer: default): { cacheTimeMillis: number; healthCheckToCache: HealthCheck }
        • Parameters

          • diContainer: default

          Returns { cacheTimeMillis: number; healthCheckToCache: HealthCheck }

    Returns void

  • registerDappetizerUtils(diContainer?: default): void
  • Parameters

    • diContainer: default = globalDIContainer

    Returns void

  • registerHttpServer(diContainer?: default): void
  • Parameters

    • diContainer: default = globalDIContainer

    Returns void

  • registerOnce(diContainer: default, name: string, registerFunc: () => void): void
  • Parameters

    • diContainer: default
    • name: string
    • registerFunc: () => void
        • (): void
        • Returns void

    Returns void

  • registerSingleton<T>(diContainer: default, token: InjectionToken<T>, factory: (c: default) => T): void
  • Type parameters

    • T

    Parameters

    • diContainer: default
    • token: InjectionToken<T>
    • factory: (c: default) => T
        • (c: default): T
        • Parameters

          • c: default

          Returns T

    Returns void

  • removeRequiredPrefix(str: string, prefixToRemove: string): string
  • Parameters

    • str: string
    • prefixToRemove: string

    Returns string

  • removeRequiredSuffix(str: string, suffixToRemove: string): string
  • Parameters

    • str: string
    • suffixToRemove: string

    Returns string

  • replaceAll(str: string, search: string, replacement: string): string
  • Parameters

    • str: string
    • search: string
    • replacement: string

    Returns string

  • resolveAllOptional<T>(diContainer: default, token: InjectionToken<T>): T[]
  • Type parameters

    Parameters

    • diContainer: default
    • token: InjectionToken<T>

    Returns T[]

  • resolveOptional<T>(diContainer: default, token: InjectionToken<T>): T | undefined
  • Type parameters

    Parameters

    • diContainer: default
    • token: InjectionToken<T>

    Returns T | undefined

  • resolveWithExplicitArgs<TResult, TExplicitArgs>(diContainer: default, resultType: new (...args: [...TExplicitArgs[], ...any[]]) => TResult, explicitArgs: [...TExplicitArgs[]]): TResult
  • Type parameters

    • TResult

    • TExplicitArgs: unknown[]

    Parameters

    • diContainer: default
    • resultType: new (...args: [...TExplicitArgs[], ...any[]]) => TResult
        • new (...args: [...TExplicitArgs[], ...any[]]): TResult
        • Parameters

          • Rest ...args: [...TExplicitArgs[], ...any[]]

          Returns TResult

    • explicitArgs: [...TExplicitArgs[]]

    Returns TResult

  • runApp(diContainer?: default): Promise<void>
  • Parameters

    • diContainer: default = globalDIContainer

    Returns Promise<void>

  • runInPerformanceSection<TResult>(logger: Logger, scopeFunc: () => TResult, performanceSection?: string): TResult
  • Type parameters

    • TResult

    Parameters

    • logger: Logger
    • scopeFunc: () => TResult
        • (): TResult
        • Returns TResult

    • Optional performanceSection: string

    Returns TResult

  • safeJsonStringify(value: unknown, options?: { indent?: string | number }): string
  • Parameters

    • value: unknown
    • Optional options: { indent?: string | number }
      • Optional indent?: string | number

    Returns string

  • sanitizeForJson(value: unknown, stringSanitizer?: StringSanitizer): unknown
  • Parameters

    Returns unknown

  • throwIfAborted(signal: AbortSignal): void
  • Parameters

    • signal: AbortSignal

    Returns void

  • typed<T>(value: T): T
  • Helper for strongly typed literal values on return statements e.g. return typed({ ... }).

    Type parameters

    • T

    Parameters

    • value: T

    Returns T

  • withIndex<T>(iterable: Iterable<T>): Iterable<[T, number]>
  • Type parameters

    • T

    Parameters

    • iterable: Iterable<T>

    Returns Iterable<[T, number]>

Generated using TypeDoc