|
| 1 | +import { captureCommandDefinitions, captureCommandMetadata } from './capture/index.ts'; |
| 2 | +import { managementCommandDefinitions, managementCommandMetadata } from './management/index.ts'; |
| 3 | +import { metroCommandDefinition, metroCommandMetadata } from './metro/index.ts'; |
| 4 | +import { |
| 5 | + observabilityCommandDefinitions, |
| 6 | + observabilityCommandMetadata, |
| 7 | +} from './observability/index.ts'; |
| 8 | +import { reactNativeCommandDefinition, reactNativeCommandMetadata } from './react-native/index.ts'; |
| 9 | +import { recordingCommandDefinitions, recordingCommandMetadata } from './recording/index.ts'; |
| 10 | +import { replayCommandDefinitions, replayCommandMetadataList } from './replay/index.ts'; |
| 11 | +import { systemCommandDefinitions, systemCommandMetadata } from './system/index.ts'; |
| 12 | + |
| 13 | +const clientCommandFamilyFacets = [ |
| 14 | + { |
| 15 | + metadata: managementCommandMetadata, |
| 16 | + definitions: managementCommandDefinitions, |
| 17 | + }, |
| 18 | + { |
| 19 | + metadata: captureCommandMetadata, |
| 20 | + definitions: captureCommandDefinitions, |
| 21 | + }, |
| 22 | + { |
| 23 | + metadata: systemCommandMetadata, |
| 24 | + definitions: systemCommandDefinitions, |
| 25 | + }, |
| 26 | + { |
| 27 | + metadata: [reactNativeCommandMetadata], |
| 28 | + definitions: [reactNativeCommandDefinition], |
| 29 | + }, |
| 30 | + { |
| 31 | + metadata: replayCommandMetadataList, |
| 32 | + definitions: replayCommandDefinitions, |
| 33 | + }, |
| 34 | + { |
| 35 | + metadata: observabilityCommandMetadata, |
| 36 | + definitions: observabilityCommandDefinitions, |
| 37 | + }, |
| 38 | + { |
| 39 | + metadata: recordingCommandMetadata, |
| 40 | + definitions: recordingCommandDefinitions, |
| 41 | + }, |
| 42 | + { |
| 43 | + metadata: [metroCommandMetadata], |
| 44 | + definitions: [metroCommandDefinition], |
| 45 | + }, |
| 46 | +] as const; |
| 47 | + |
| 48 | +export const clientCommandMetadata = readClientCommandMetadata(clientCommandFamilyFacets); |
| 49 | + |
| 50 | +export const clientCommandDefinitions = readClientCommandDefinitions(clientCommandFamilyFacets); |
| 51 | + |
| 52 | +function readClientCommandMetadata< |
| 53 | + const TFacets extends readonly { metadata: readonly unknown[] }[], |
| 54 | +>(facets: TFacets): Array<TFacets[number]['metadata'][number]> { |
| 55 | + return facets.flatMap((family) => [...family.metadata]) as Array< |
| 56 | + TFacets[number]['metadata'][number] |
| 57 | + >; |
| 58 | +} |
| 59 | + |
| 60 | +function readClientCommandDefinitions< |
| 61 | + const TFacets extends readonly { definitions: readonly unknown[] }[], |
| 62 | +>(facets: TFacets): Array<TFacets[number]['definitions'][number]> { |
| 63 | + return facets.flatMap((family) => [...family.definitions]) as Array< |
| 64 | + TFacets[number]['definitions'][number] |
| 65 | + >; |
| 66 | +} |
0 commit comments