import { LogDefinitionName, RepeatingFieldsDefinitions, RepeatingFieldsTypes, } from '../resources/netlog_defs'; import { NetFields } from './net_fields'; type ArrayIndexes = Exclude['length'], T['length']>; type RepeatingFieldsExtract< TKey extends RepeatingFieldsTypes, > = { // This syntax is a bit weird to make typescript compiler happy [ label in RepeatingFieldsDefinitions[TKey]['repeatingFields'][ 'label' ] ]?: { [name in RepeatingFieldsDefinitions[TKey]['repeatingFields']['names'][number]]: | string | string[]; }[]; }; type RepeatingFieldsParams< type extends LogDefinitionName, repeatingType extends RepeatingFieldsTypes = type extends RepeatingFieldsTypes ? type : never, > = repeatingType extends RepeatingFieldsTypes ? RepeatingFieldsExtract : never; type Params = Partial< & Record, string | readonly string[]> & { 'timestamp': string; 'capture': boolean } >; type RepeatingFieldsParamsExtract< type extends LogDefinitionName, > = type extends RepeatingFieldsTypes ? RepeatingFieldsParams & Params : never; export type NetProps = { [type in keyof NetFields]: keyof NetFields[type]; }; export type NetParams = { [type in keyof NetProps]: RepeatingFieldsParamsExtract | Params; };