UNPKG

@itwin/presentation-common

Version:

Common pieces for iModel.js presentation packages

84 lines 2.54 kB
/** @packageDocumentation * @module Core */ import { KeySet } from "./KeySet.js"; /** * Create a type with `T` properties excluding properties listed in `K`. * * Usage example: `Omit<SomeType, "exclude_prop1" | "exclude_prop2">` * * @public */ export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; /** * Create a type with `T` properties excluding all properties in type `K`. * * Usage example: `Subtract<SomeType, ExcludePropertiesInThisType>` * * @public */ export type Subtract<T, K> = Omit<T, keyof K>; /** * Create a type from given type `T` and make specified properties optional. * @public */ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; /** * A dictionary data structure. * @public */ export interface ValuesDictionary<T> { [key: string]: T; } /** * A structure for paged responses * @public */ export interface PagedResponse<T> { /** Total number of items */ total: number; /** Items for the requested page */ items: T[]; } /** * Get total number of instances included in the supplied key set. The * count is calculated by adding all of the following: * - `keys.instanceKeysCount` * - number of `keys.nodeKeys` which are *ECInstance* keys * - for every grouping node key in `keys.nodeKeys`, number of grouped instances * * E.g. if `keys` contains one instance key, one *ECInstance* node key * and one grouping node key which groups 3 instances, the result is 5. * * @public */ export declare const getInstancesCount: (keys: Readonly<KeySet>) => number; /** * Default (recommended) keyset batch size for cases when it needs to be sent * over HTTP. Sending keys in batches helps avoid HTTP413 error. * * @public */ export declare const DEFAULT_KEYS_BATCH_SIZE = 5000; /** * Removes all `undefined` properties from given `obj` object and returns * the same (mutated) object. * * Example: `omitUndefined({ a: 1, b: undefined })` will return `{ a: 1 }` * * @internal */ export declare function omitUndefined<T extends object>(obj: T): T; /** @internal */ type NullToUndefined<T> = T extends null ? undefined : T extends Array<infer U> ? Array<NullToUndefined<U>> : T extends object ? { [K in keyof T]: NullToUndefined<T[K]>; } : T; /** @internal */ export declare function deepReplaceNullsToUndefined<T>(obj: T): NullToUndefined<T>; /** @internal */ export declare function createCancellableTimeoutPromise(timeoutMs: number): { promise: Promise<void>; cancel: () => void; }; export {}; //# sourceMappingURL=Utils.d.ts.map