generator-jhipster
Version:
Spring Boot + Angular/React/Vue in one handy generator
61 lines (60 loc) • 2.89 kB
TypeScript
/**
* 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 { ConfigAll } from '../../types/command-all.ts';
export type MatrixSample<T extends Record<string, any> = ConfigAll> = {
[P in keyof T]?: T[P];
};
export type Matrix<T extends Record<string, any> = ConfigAll> = Record<string, MatrixSample<T>>;
export type MatrixInput<T extends Record<string, any> = ConfigAll> = {
[P in keyof T]?: T[P][];
};
type AdditionalValue<T extends Record<string, any>, K extends keyof T> = {
value: T[K];
additional?: MatrixSample<T>;
} | T[K];
export type MatrixAdditionalInput<T extends Record<string, any> = ConfigAll> = {
[P in keyof T]?: AdditionalValue<T, P>[];
};
/**
* Create a matrix from options
* @example
* const matrix = fromMatrix({ a: [true, false], b: [true, false] });
* // {
* // 'a(true)-b(true)': { a: true, b: true },
* // 'a(true)-b(false)': { a: true, b: false },
* // 'a(false)-b(true)': { a: false, b: true },
* // 'a(false)-b(false)': { a: false, b: false },
* // }
*/
export declare const fromMatrix: <T extends Record<string, any> = ConfigAll>(configMatrix: MatrixInput<T>) => Matrix<T>;
/**
* Apply new matrix value to existing matrix
* @example
* const matrix = extendMatrix(fromMatrix({ initialMatrix: [true, false] }), { toBeMerged: [true, false] });
* // {
* // 'initialMatrix(true)-toBeMerged(true)': { initialMatrix: true, toBeMerged: true },
* // 'initialMatrix(false)-toBeMerged(false)': { initialMatrix: false, toBeMerged: false },
* // }
*/
export declare const extendMatrix: <M extends Record<string, any> = ConfigAll, A extends Record<string, any> = ConfigAll>(matrix: Matrix<M>, configMatrix: MatrixAdditionalInput<A>) => Matrix<M & A>;
export declare const extendFilteredMatrix: <M extends Record<string, any> = ConfigAll, A extends Record<string, any> = ConfigAll>(matrix: Matrix<M>, filter: (sample: MatrixSample<M>) => boolean, extendedConfig: MatrixAdditionalInput<A>) => Matrix<M & A>;
export declare const buildSamplesFromMatrix: (samples: Record<string, Record<string, unknown>>, { commonConfig }?: {
commonConfig?: Record<string, unknown>;
}) => Record<string, Record<string, unknown>>;
export {};