UNPKG

mongoose-management

Version:
150 lines (149 loc) 3.12 kB
import { Separator } from 'inquirer'; import Prompts from './prompts'; import Storage from './storage'; import Create from './template/create'; import * as mongoTypes from './mongo'; /** * */ export declare type objType<K extends string | number | symbol = string, T = any> = Record<K, T>; /** * */ export declare type levelOptionsType = { prompts: Prompts; storage: Storage; creater: Create; }; /** * */ export declare type schemaType = keyof typeof mongoTypes.schemaTypes; /** * */ export declare type schemaNormalType = keyof typeof mongoTypes.schemaTypesNormal; /** * */ export declare type schemaIndexType = keyof typeof mongoTypes.schemaIndexTypes; /** * */ export declare type dataType = { groups: dataGroupType[]; }; /** * */ export declare type dataGroupType = { path: string; collections: dataCollectionType[]; }; /** * */ export declare type dataCollectionType = { name: string; columns: dataColumnType[]; indexes: dataIndexType[]; }; /** * */ export declare type dataColumnType = { name: string; type: schemaType; required?: boolean; default?: string | number; lowercase?: boolean; uppercase?: boolean; trim?: boolean; match?: string; enum?: string; minLength?: number; maxLength?: number; min?: number; max?: number; } & dataColumnInternalValuesType; /** * */ export declare type dataColumnInternalValuesType = { populate?: string; subTypes?: schemaNormalType[]; subColumns?: dataColumnType[]; }; /** * */ export declare type dataIndexType = { name: string; columns: { [k: string]: dataIndexColumnValueType; }; properties: { unique?: boolean; sparse?: boolean; }; } & dataIndexInternalValuesType; /** * */ export declare type dataIndexInternalValuesType = { readonly?: boolean; }; /** * */ export declare type dataIndexColumnValueType = 1 | -1 | 'text' | 'hashed' | '2dsphere'; /** * */ export declare type choicesType<T> = choiceType<T> | InstanceType<typeof Separator>; /** * */ export declare type choiceType<T> = choiceListType<choiceValueType<T>>; /** * */ export declare type choiceListType<T> = { name: string; value: T; short: string; }; /** * */ export declare type choiceValueType<T> = { action?: 'create' | 'createColumn' | 'createIndex' | 'back' | 'backToCollection' | 'exit' | 'save' | 'edit' | 'remove' | 'write'; data?: T; }; /** * */ export declare type templateTypesType = 'index' | 'documents' | 'interfaces' | 'models' | 'repositories'; /** * */ export declare type templateCollectionNamesType = { collectionNameLower: string; collectionNameUpper: string; collectionNameRaw: string; }; /** * */ export declare type templateCollectionType = { interfaceName: string; schemaDefinitions: string; SchemaIndexes: string; schemaTypes: string; } & templateCollectionNamesType; export declare type Unpacked<T> = T extends Array<infer U> ? U : T; export declare type OptionalValues<T> = T extends { [K in keyof T]: any; } ? { [K in keyof T]?: T[K]; } : T;