UNPKG

6.73 kBTypeScriptView Raw
1import { ResetValue } from "../common/options";
2import { Expression } from "../params";
3import { ParamSpec, SecretParam } from "../params/types";
4export { RESET_VALUE } from "../common/options";
5/**
6 * List of all regions supported by Cloud Functions (2nd gen).
7 */
8export type SupportedRegion = "asia-east1" | "asia-northeast1" | "asia-northeast2" | "europe-north1" | "europe-west1" | "europe-west4" | "us-central1" | "us-east1" | "us-east4" | "us-west1" | "asia-east2" | "asia-northeast3" | "asia-southeast1" | "asia-southeast2" | "asia-south1" | "australia-southeast1" | "europe-central2" | "europe-west2" | "europe-west3" | "europe-west6" | "northamerica-northeast1" | "southamerica-east1" | "us-west2" | "us-west3" | "us-west4";
9/**
10 * List of available memory options supported by Cloud Functions.
11 */
12export type MemoryOption = "128MiB" | "256MiB" | "512MiB" | "1GiB" | "2GiB" | "4GiB" | "8GiB" | "16GiB" | "32GiB";
13/**
14 * List of available options for `VpcConnectorEgressSettings`.
15 */
16export type VpcEgressSetting = "PRIVATE_RANGES_ONLY" | "ALL_TRAFFIC";
17/**
18 * List of available options for `IngressSettings`.
19 */
20export type IngressSetting = "ALLOW_ALL" | "ALLOW_INTERNAL_ONLY" | "ALLOW_INTERNAL_AND_GCLB";
21/**
22 * `GlobalOptions` are options that can be set across an entire project.
23 * These options are common to HTTPS and event handling functions.
24 */
25export interface GlobalOptions {
26 /**
27 * If true, do not deploy or emulate this function.
28 */
29 omit?: boolean | Expression<boolean>;
30 /**
31 * Region where functions should be deployed.
32 */
33 region?: SupportedRegion | string | Expression<string> | ResetValue;
34 /**
35 * Amount of memory to allocate to a function.
36 */
37 memory?: MemoryOption | Expression<number> | ResetValue;
38 /**
39 * Timeout for the function in seconds, possible values are 0 to 540.
40 * HTTPS functions can specify a higher timeout.
41 *
42 * @remarks
43 * The minimum timeout for a 2nd gen function is 1s. The maximum timeout for a
44 * function depends on the type of function: Event handling functions have a
45 * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
46 * maximum timeout of 3,600s (1 hour). Task queue functions have a maximum
47 * timeout of 1,800s (30 minutes).
48 */
49 timeoutSeconds?: number | Expression<number> | ResetValue;
50 /**
51 * Minimum number of actual instances to be running at a given time.
52 *
53 * @remarks
54 * Instances are billed for memory allocation and 10% of CPU allocation
55 * while idle.
56 */
57 minInstances?: number | Expression<number> | ResetValue;
58 /**
59 * Max number of instances that can be running in parallel.
60 */
61 maxInstances?: number | Expression<number> | ResetValue;
62 /**
63 * Number of requests a function can serve at once.
64 *
65 * @remarks
66 * Can be applied only to functions running on Cloud Functions (2nd gen)).
67 * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
68 * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
69 * The maximum value for concurrency is 1,000.
70 */
71 concurrency?: number | Expression<number> | ResetValue;
72 /**
73 * Fractional number of CPUs to allocate to a function.
74 *
75 * @remarks
76 * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
77 * This is different from the defaults when using the gcloud utility and is different from
78 * the fixed amount assigned in Cloud Functions (1st gen).
79 * To revert to the CPU amounts used in gcloud or in Cloud Functions (1st gen), set this
80 * to the value "gcf_gen1"
81 */
82 cpu?: number | "gcf_gen1";
83 /**
84 * Connect a function to a specified VPC connector.
85 */
86 vpcConnector?: string | Expression<string> | ResetValue;
87 /**
88 * Egress settings for VPC connector.
89 */
90 vpcConnectorEgressSettings?: VpcEgressSetting | ResetValue;
91 /**
92 * Specific service account for the function to run as.
93 */
94 serviceAccount?: string | Expression<string> | ResetValue;
95 /**
96 * Ingress settings which control where this function can be called from.
97 */
98 ingressSettings?: IngressSetting | ResetValue;
99 /**
100 * Invoker to set access control on HTTPS functions.
101 */
102 invoker?: "public" | "private" | string | string[];
103 /**
104 * User labels to set on the function.
105 */
106 labels?: Record<string, string>;
107 secrets?: (string | SecretParam)[];
108 /**
109 * Determines whether Firebase App Check is enforced. Defaults to false.
110 *
111 * @remarks
112 * When true, requests with invalid tokens autorespond with a 401
113 * (Unauthorized) error.
114 * When false, requests with invalid tokens set `event.app` to `undefined`.
115 */
116 enforceAppCheck?: boolean;
117 /**
118 * Controls whether function configuration modified outside of function source is preserved. Defaults to false.
119 *
120 * @remarks
121 * When setting configuration available in an underlying platform that is not yet available in the Firebase SDK
122 * for Cloud Functions, we recommend setting `preserveExternalChanges` to `true`. Otherwise, when Google releases
123 * a new version of the SDK with support for the missing configuration, your function's manually configured setting
124 * may inadvertently be wiped out.
125 */
126 preserveExternalChanges?: boolean;
127}
128/**
129 * Sets default options for all functions written using the 2nd gen SDK.
130 * @param options Options to set as default
131 */
132export declare function setGlobalOptions(options: GlobalOptions): void;
133/**
134 * Additional fields that can be set on any event-handling function.
135 */
136export interface EventHandlerOptions extends Omit<GlobalOptions, "enforceAppCheck"> {
137 /** Type of the event. Valid values are TODO */
138 eventType?: string;
139 /** TODO */
140 eventFilters?: Record<string, string | Expression<string>>;
141 /** TODO */
142 eventFilterPathPatterns?: Record<string, string | Expression<string>>;
143 /** Whether failed executions should be delivered again. */
144 retry?: boolean | Expression<boolean> | ResetValue;
145 /** Region of the EventArc trigger. */
146 region?: string | Expression<string> | ResetValue;
147 /** The service account that EventArc should use to invoke this function. Requires the P4SA to have ActAs permission on this service account. */
148 serviceAccount?: string | Expression<string> | ResetValue;
149 /** The name of the channel where the function receives events. */
150 channel?: string;
151}
152/**
153 * @hidden
154 * @alpha
155 */
156export declare function __getSpec(): {
157 globalOptions: GlobalOptions;
158 params: ParamSpec<any>[];
159};