-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathavailability.ts
More file actions
38 lines (36 loc) · 1.89 KB
/
availability.ts
File metadata and controls
38 lines (36 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { McpContext, ServerFeature } from "../types";
import { checkFeatureActive } from "../util";
import { isCrashlyticsAvailable } from "./crashlytics/availability";
import { isAppTestingAvailable } from "./apptesting/availability";
const DEFAULT_AVAILABILITY_CHECKS: Record<ServerFeature, (ctx: McpContext) => Promise<boolean>> = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
core: async (ctx: McpContext): Promise<boolean> => true,
firestore: (ctx: McpContext): Promise<boolean> =>
checkFeatureActive("firestore", ctx.projectId, { config: ctx.config }),
storage: (ctx: McpContext): Promise<boolean> =>
checkFeatureActive("storage", ctx.projectId, { config: ctx.config }),
dataconnect: (ctx: McpContext): Promise<boolean> =>
checkFeatureActive("dataconnect", ctx.projectId, { config: ctx.config }),
auth: (ctx: McpContext): Promise<boolean> =>
checkFeatureActive("auth", ctx.projectId, { config: ctx.config }),
messaging: (ctx: McpContext): Promise<boolean> =>
checkFeatureActive("messaging", ctx.projectId, { config: ctx.config }),
functions: (ctx: McpContext): Promise<boolean> =>
checkFeatureActive("functions", ctx.projectId, { config: ctx.config }),
remoteconfig: (ctx: McpContext): Promise<boolean> =>
checkFeatureActive("remoteconfig", ctx.projectId, { config: ctx.config }),
crashlytics: isCrashlyticsAvailable,
apphosting: (ctx: McpContext): Promise<boolean> =>
checkFeatureActive("apphosting", ctx.projectId, { config: ctx.config }),
apptesting: isAppTestingAvailable,
database: (ctx: McpContext): Promise<boolean> =>
checkFeatureActive("database", ctx.projectId, { config: ctx.config }),
};
/**
* Returns the default availability function for a ServerFeature.
*/
export function getDefaultFeatureAvailabilityCheck(
feature: ServerFeature,
): (ctx: McpContext) => Promise<boolean> {
return DEFAULT_AVAILABILITY_CHECKS[feature];
}