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

Function askForEventsConfig

src/extensions/askUserForEventsConfig.ts:47–74  ·  view source on GitHub ↗
(
  events: EventDescriptor[],
  projectId: string,
  instanceId: string,
)

Source from the content-addressed store, hash-verified

45 * @return The instance events config or undefined if the user doesn't want events
46 */
47export async function askForEventsConfig(
48 events: EventDescriptor[],
49 projectId: string,
50 instanceId: string,
51): Promise<InstanceEventsConfig | undefined> {
52 logger.info(
53 `\n${clc.bold("Enable Events")}: ${await marked(
54 "If you enable events, you can write custom event handlers ([https://firebase.google.com/docs/extensions/install-extensions#eventarc](https://firebase.google.com/docs/extensions/install-extensions#eventarc)) that respond to these events.\n\nYou can always enable or disable events later. Events will be emitted via Eventarc. Fees apply ([https://cloud.google.com/eventarc/pricing](https://cloud.google.com/eventarc/pricing)).",
55 )}`,
56 );
57 if (!(await askShouldCollectEventsConfig())) {
58 return undefined;
59 }
60 let existingInstance: ExtensionInstance | undefined;
61 try {
62 existingInstance = instanceId
63 ? await extensionsApi.getInstance(projectId, instanceId)
64 : undefined;
65 } catch {
66 /* If instance was not found, then this is an instance ID for a new instance. Don't preselect any values when displaying prompts to the user. */
67 }
68 const preselectedTypes = existingInstance?.config.allowedEventTypes ?? [];
69 const oldLocation = existingInstance?.config.eventarcChannel?.split("/")[3];
70 const location = await askForEventArcLocation(oldLocation);
71 const channel = getEventArcChannel(projectId, location);
72 const allowedEventTypes = await askForAllowedEventTypes(events, preselectedTypes);
73 return { channel, allowedEventTypes };
74}
75
76/**
77 * Creates an EventArc channel resource name

Callers

nothing calls this directly

Calls 5

markedFunction · 0.90
askForEventArcLocationFunction · 0.85
getEventArcChannelFunction · 0.85
askForAllowedEventTypesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…