UNPKG

generator-jhipster

Version:

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

39 lines (38 loc) 2.53 kB
/** * Copyright 2013-2026 the original author or authors from the JHipster project. * * This file is part of the JHipster project, see https://www.jhipster.tech/ * for more information. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ 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 readonly 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, anyCheck, 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; anyCheck?: (value: any, choices: Values) => boolean; /** Callback logic */ valCheck?: (data: Data, value: any) => boolean; }) => Simplify<Data & { [K in Values[number] as ReturnType<typeof derivedPropertyName<Prefix, K, S>>]: (data: Data) => boolean; }>;