gen-jhipster
Version:
VHipster - Spring Boot + Angular/React/Vue in one handy generator
43 lines (42 loc) • 2.14 kB
TypeScript
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 a 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 {};