@alba-cars/common-modules
Version:
A package containing DTOs, validation classes and common modules and interfaces for Alba Cars
54 lines (53 loc) • 2.3 kB
TypeScript
import { ValidationOptions } from "class-validator";
export type Numeric = number | `${number}`;
export type Booleanish = boolean | "true" | "1" | "false" | "0";
export type Optional<T> = T | undefined;
export type Nullable<T> = T | null;
export type Maybe<T> = T | null | undefined;
export type NestedKeyOf<ObjectType extends object> = {
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
}[keyof ObjectType & (string | number)];
export declare const createFieldPath: <T extends Record<string, any>>(path: NestedKeyOf<T>) => NestedKeyOf<T>;
export type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
export declare function IsDateOrConvertible(validationOptions?: ValidationOptions): (object: Record<string, unknown>, propertyName: string) => void;
export declare class PaginationOptions {
limit?: number;
page?: number;
}
export declare class DateFilter {
from?: Date | string | number;
to?: Date | string | number;
}
export declare class NumberRange {
min?: number;
max?: number;
}
export declare class BaseFilter {
id?: string | string[];
createdBy?: string | string[];
updatedBy?: string | string[];
deletedBy?: string | string[];
isDeleted?: boolean;
isActive?: boolean;
createdAt?: DateFilter;
updatedAt?: DateFilter;
deletedAt?: DateFilter;
}
export type TypedSort<T> = Partial<Record<keyof T, "asc" | "desc">>;
export type PrefixedKeys<T extends Record<string, any>, Prefix extends string> = `${Prefix}.${keyof T & string}`;
export type TypedSelect<T, Nested extends Record<string, any>> = keyof T | {
[K in keyof Nested]: PrefixedKeys<Nested[K], K & string>;
}[keyof Nested];
export declare class TypedFilter extends BaseFilter {
[key: string]: unknown;
}
export declare class TypedOptions<T extends Record<string, any>> extends PaginationOptions {
sort?: TypedSort<T>;
select?: string | string[];
validate(): string[];
static fromPlain(plain: Record<string, unknown>): TypedOptions<Record<string, any>>;
static toPlain(entity: any): Record<string, unknown>;
}
export declare function formatImageUrl(src: string | null | undefined): string | null;