UNPKG

gen-jhipster

Version:

VHipster - Spring Boot + Angular/React/Vue in one handy generator

20 lines (19 loc) 1.7 kB
import type { Simplify } from 'type-fest'; import type { DerivedProperty, JHipsterChoices } from '../command/types.ts'; export declare const flatChoices: (choices: JHipsterChoices) => string[]; export declare const derivedPropertyName: <const P extends string, const V extends string, const S extends string = "">(property: P, value: V, suffix?: S) => `${DerivedProperty<P, V>}${S}`; export declare const applyDerivedProperty: <const Prop extends string>(data: any, property: Prop, possibleValues: JHipsterChoices, { addAny, addNo, defaultValue }?: { addAny?: boolean; addNo?: boolean; defaultValue?: string; }) => void; export declare const buildMutateDataForProperty: <const P extends string, const Values extends string[], const PropertyType = Values[number], const Prefix extends string = P, const S extends string = "", const IsAny extends boolean = false, const IsArray extends boolean = false, const Data extends Partial<Record<P, IsArray extends true ? PropertyType[] : IsAny extends true ? any : PropertyType | undefined>> = Simplify<Partial<Record<P, IsArray extends true ? PropertyType[] : IsAny extends true ? any : PropertyType | undefined>>>>(property: P, possibleValues: Values, { prefix, suffix, array, valCheck, }?: { prefix?: Prefix; suffix?: S; /** Property is an array, check if the property includes the value instead of matching the value */ array?: IsArray; /** Set callback argument as any to avoid type mismatch */ anyData?: IsAny; /** Callback logic */ valCheck?: (data: Data, value: any) => boolean; }) => Simplify<Data & { [K in Values[number] as ReturnType<typeof derivedPropertyName<Prefix, K, S>>]: (data: Data) => boolean; }>;