UNPKG

denwa-nest-shared

Version:

Shared NestJS module for DTO validation, RBAC, TypeORM query building, and OpenAPI client

109 lines (108 loc) • 5 kB
import { FindOptionsSelect } from 'typeorm'; import { GraphQLResolveInfo } from 'graphql'; import { ICursorPagination, IPaginate, IPreparedFile, IPreparedImage, QueryDataType } from './types'; import { AllFilesDto, AllImagesDto, FileDto, ImageFileDto, TempFilesDto, TempImagesDto } from './dto'; import { ExecutionContext } from '@nestjs/common'; export declare const getError: ({ error, message }: { error?: unknown; message?: string; }) => void; export declare const createPaginate: (page: number, count: number, limit: number, modelsNumber?: number, options?: { cursor?: string; hasNextPage?: boolean; }) => IPaginate; export declare const encodeCursor: (data: ICursorPagination) => string; export declare const decodeCursor: (cursor: string) => ICursorPagination | null; export declare const getPaginateSkip: (page: number, limit: number) => number; export declare const formatPhone: (phone: string) => string; export declare const concatenateTwo32BitNumbers: (low: number, high: number) => number; export declare const prepareTokenExp: (accessExp: number | { low: number; high: number; }, refreshExp: number | { low: number; high: number; }) => { access: number; refresh: number; }; export declare const checkPageAndLimit: (page: number, limit: number, maxLimit?: number, maxPage?: number) => { checkedPage: number; checkedLimit: number; }; export declare const isCorrectOrder: (order: string) => boolean; export declare const createQueryData: <Entity>({ page, limit, sortField, sortFields, sortOrder, filterType, searchType, filter, filters, search, fromToFields, oneEntryArrayFields, fields, relationsMap, searchFields, cursor, select, extraRow, maxPage, }: { page: number; limit: number; sortField?: string; sortOrder?: string; sortFields?: { field: string; order: string; }[]; filterType?: string; searchType?: string; filter?: object; filters?: object[]; search?: object | string; fromToFields?: { fromFieldName: string; toFieldName: string; originalFieldName: string; }[]; oneEntryArrayFields?: { key: string; originalKey: string; }[]; fields?: string[]; relationsMap?: Record<string, string | string[]>; searchFields?: string[]; cursor?: string | ICursorPagination; select?: (keyof Entity)[] | FindOptionsSelect<Entity>; extraRow?: boolean; maxPage?: number; }) => QueryDataType<Entity>; export declare const extractGraphqlFields: (info: GraphQLResolveInfo) => string[]; export declare const prepareTempImages: (files: ImageFileDto[], tempImages: TempImagesDto[]) => IPreparedImage[]; export declare const getTempImagesInAllImages: (allImages: AllImagesDto[] | undefined) => TempImagesDto[]; export declare const getTempFilesInAllFiles: (allFiles: AllFilesDto[] | undefined) => TempFilesDto[]; export declare const prepareImages: (images: string) => IPreparedImage[]; export declare const updateEntityImages: (entityImages: string | null, allImages: AllImagesDto[] | undefined, preparedTempImages: IPreparedImage[]) => { newImages: IPreparedImage[] | null; deletedImages: ImageFileDto[] | null; }; export declare const updateEntityFiles: (entityFiles: string | null, allFiles: AllFilesDto[] | undefined, preparedTempFiles: IPreparedFile[]) => { newFiles: IPreparedFile[] | null; deletedFiles: FileDto[] | null; }; export declare const translit: (word: string, isTrim?: boolean) => string; export declare const checkTranslit: (string: string) => boolean; export declare const prepareRequestContext: (context: ExecutionContext) => any; export declare const getGuardAuthContext: (context: ExecutionContext) => { request: Record<string, unknown>; authHeader?: string; }; export declare const getRandomNumber: (min: number, max: number) => number; export declare const getUniqueNumber: () => string; export declare const createValue: (name: string, parameters: string[], initialValue?: string, isDateTime?: boolean) => string; export declare const compareRolesPriority: ({ userRoles, comparedUserRoles, rolePriority, }: { userRoles: string[]; comparedUserRoles: string[]; rolePriority: Record<string, number>; }) => { maxUserRolePriority: number; maxComparedUserRolePriority: number; isPriorityHigher: boolean; isPriorityEqual: boolean; isPriorityLower: boolean; }; export declare const htmlToSlateString: (html: string) => string; export declare const escapeHtml: (string: string) => string; export declare const serializeContentToHtml: ({ content, contentImages, uploadUrl, bucketFolder, }: { content: string; contentImages: IPreparedImage[]; uploadUrl: string; bucketFolder: string; }) => string; export declare const extractImageUrlsFromContent: (contentJson: string) => string[]; export declare const cleanContentImages: (contentJson: string | null | undefined, contentImages: string | null | undefined) => string | null;