MCPcopy Create free account
hub / github.com/firebase/firebase-tools / askForAllowedEventTypes

Function askForAllowedEventTypes

src/extensions/askUserForEventsConfig.ts:92–115  ·  view source on GitHub ↗
(
  eventDescriptors: EventDescriptor[],
  preselectedTypes?: string[],
)

Source from the content-addressed store, hash-verified

90 * @return A list of strings indicating the event types
91 */
92export 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

Callers 2

askForEventsConfigFunction · 0.85

Calls 2

checkboxFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…