( eventDescriptors: EventDescriptor[], preselectedTypes?: string[], )
| 90 | * @return A list of strings indicating the event types |
| 91 | */ |
| 92 | export async function askForAllowedEventTypes( |
| 93 | eventDescriptors: EventDescriptor[], |
| 94 | preselectedTypes?: string[], |
| 95 | ): Promise<string[]> { |
| 96 | let valid = false; |
| 97 | let response: string[] = []; |
| 98 | const eventTypes = eventDescriptors.map((e, index) => ({ |
| 99 | checked: false, |
| 100 | name: `${index + 1}. ${e.type}\n ${e.description}`, |
| 101 | value: e.type, |
| 102 | })); |
| 103 | while (!valid) { |
| 104 | response = await checkbox({ |
| 105 | default: preselectedTypes ?? [], |
| 106 | message: |
| 107 | `Please select the events [${eventTypes.length} types total] that this extension is permitted to emit. ` + |
| 108 | "You can implement your own handlers that trigger when these events are emitted to customize the extension's behavior. ", |
| 109 | choices: eventTypes, |
| 110 | pageSize: 20, |
| 111 | }); |
| 112 | valid = checkAllowedEventTypesResponse(response, eventDescriptors); |
| 113 | } |
| 114 | return response.filter((e) => e !== ""); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Asks the user if they want to enable events |
no test coverage detected
searching dependent graphs…