import { EnumValueStatic } from '../../enum-values'; import { KeyValuePair, KeyValueType } from './kv.entities'; import { KVModelFormatType } from './kv.isolated.entities'; export interface KVField { name: string; type: 'number' | 'string' | 'stringArray' | 'text' | 'json' | 'image' | 'color' | 'wxSubscribeData' | 'wxTmplData' | 'emailTmplData' | 'boolean'; help?: string; required?: boolean; defaultValue?: boolean | number | string; } export interface KVFields { [key: string]: { name: string; field: KVField; }; } export interface KVGroupFields { [groupKey: string]: { name?: string; fields: { /** * name 在整个 KVGroupFields 中必须唯一 */ name: string; field: KVField; }[]; }; } export interface KVListFieldsValue { type: string; fields: { name?: string; field: KVField; }[]; values: V[]; } export interface KVFieldsValue { fields: Record; values: any; } export interface KVGroupFieldsValue { form?: KVGroupFields; values: any; } export declare function recognizeTypeValue(type: KeyValueType, value: any): [KeyValueType, string]; export declare enum AsunaCollectionPrefix { SYSTEM = "SYSTEM", APP = "APP" } export declare const AsunaCollections: { SYSTEM_MIGRATIONS: string; SYSTEM_EMAIL: string; SYSTEM_SERVER: string; SYSTEM_WECHAT: string; SYSTEM_DYNAMIC_ROUTER: string; SYSTEM_TENANT: string; APP_SETTINGS: string; THIRD_SETTINGS: string; }; export declare class KvDef { collection: string; key: string; constructor(o: KvDef); } export declare class KvDefIdentifierHelper { static parse: (identifier: string) => KvDef; static stringify: (payload: KvDef) => string; } export declare type ConstantsKeys = 'WXMessageIds'; export declare class KvHelper { private static initializers; static constantKvDef: KvDef; private static constantMapsPair; private static enumValueConstantMapsPair; /** * call syncMergedConstants to sync constants * @param key * @param constantMap */ static mergeConstantMaps(key: ConstantsKeys | string, constantMap: { [name: string]: string; }): Promise; /** * call syncMergedConstants to sync constants * @param enumValue */ static mergeConstantMapsForEnumValue(enumValue: EnumValueStatic): Promise; static syncMergedConstants(): Promise; static reInitInitializer(kvDef: KvDef): Promise; static regInitializer(kvDef: KvDef, opts: { name?: string; type?: KeyValueType; value?: V; extra?: any; }, config: { formatType?: KVModelFormatType; noUpdate?: boolean; merge?: boolean; }): void; static set(opts: { collection?: string; key: string; name?: string; type?: KeyValueType; value?: V; extra?: any; }, { formatType, merge, noUpdate, }?: { formatType?: KVModelFormatType; noUpdate?: boolean; merge?: boolean; }): Promise; static update(id: number, name: any, type: any, value: any): Promise; static delete(kvDef: KvDef): Promise; static get(kvDef: KvDef, defaultPair?: { name: string; type: KeyValueType; value: any; }): Promise; static find(collection?: string, key?: string): Promise; static getConfigsByEnumKeys(kvDef: KvDef, keyValues: KeyValues): Promise<{ [key in keyof KeyValues]: any; }>; static getValueByGroupFieldKV(kvDef: KvDef, fieldKey: string): Promise; /** * @deprecated * @param kvDef * @param identifier */ static checkPermission(kvDef: Partial, identifier: string): Promise; static auth({ req, res }: { req: any; res: any; }, { collection }: { collection: string; }): Promise; static preload(kvDef: KvDef): Promise; private static getGroupFieldsValueByFieldKV; }