UNPKG

9.04 kBTypeScriptView Raw
1import { Expression } from "../params";
2import { ResetValue } from "../common/options";
3import { SecretParam } from "../params/types";
4export { RESET_VALUE } from "../common/options";
5/**
6 * List of all regions supported by Cloud Functions.
7 */
8export declare const SUPPORTED_REGIONS: readonly ["us-central1", "us-east1", "us-east4", "us-west2", "us-west3", "us-west4", "europe-central2", "europe-west1", "europe-west2", "europe-west3", "europe-west6", "asia-east1", "asia-east2", "asia-northeast1", "asia-northeast2", "asia-northeast3", "asia-south1", "asia-southeast1", "asia-southeast2", "northamerica-northeast1", "southamerica-east1", "australia-southeast1"];
9/**
10 * Cloud Functions min timeout value.
11 */
12export declare const MIN_TIMEOUT_SECONDS = 0;
13/**
14 * Cloud Functions max timeout value.
15 */
16export declare const MAX_TIMEOUT_SECONDS = 540;
17/**
18 * List of available memory options supported by Cloud Functions.
19 */
20export declare const VALID_MEMORY_OPTIONS: readonly ["128MB", "256MB", "512MB", "1GB", "2GB", "4GB", "8GB"];
21/**
22 * List of available options for VpcConnectorEgressSettings.
23 */
24export declare const VPC_EGRESS_SETTINGS_OPTIONS: readonly ["VPC_CONNECTOR_EGRESS_SETTINGS_UNSPECIFIED", "PRIVATE_RANGES_ONLY", "ALL_TRAFFIC"];
25/**
26 * List of available options for IngressSettings.
27 */
28export declare const INGRESS_SETTINGS_OPTIONS: readonly ["INGRESS_SETTINGS_UNSPECIFIED", "ALLOW_ALL", "ALLOW_INTERNAL_ONLY", "ALLOW_INTERNAL_AND_GCLB"];
29/**
30 * Scheduler retry options. Applies only to scheduled functions.
31 */
32export interface ScheduleRetryConfig {
33 /**
34 * The number of attempts that the system will make to run a job using the exponential backoff procedure described by {@link ScheduleRetryConfig.maxDoublings}.
35 *
36 * @defaultValue 0 (infinite retry)
37 */
38 retryCount?: number | Expression<number> | ResetValue;
39 /**
40 * The time limit for retrying a failed job, measured from time when an execution was first attempted.
41 *
42 * If specified with {@link ScheduleRetryConfig.retryCount}, the job will be retried until both limits are reached.
43 *
44 * @defaultValue 0
45 */
46 maxRetryDuration?: string | Expression<string> | ResetValue;
47 /**
48 * The minimum amount of time to wait before retrying a job after it fails.
49 *
50 * @defaultValue 5 seconds
51 */
52 minBackoffDuration?: string | Expression<string> | ResetValue;
53 /**
54 * The maximum amount of time to wait before retrying a job after it fails.
55 *
56 * @defaultValue 1 hour
57 */
58 maxBackoffDuration?: string | Expression<string> | ResetValue;
59 /**
60 * The max number of backoff doubling applied at each retry.
61 *
62 * @defaultValue 5
63 */
64 maxDoublings?: number | Expression<number> | ResetValue;
65}
66/**
67 * Configuration options for scheduled functions.
68 */
69export interface Schedule {
70 /**
71 * Describes the schedule on which the job will be executed.
72 *
73 * The schedule can be either of the following types:
74 *
75 * 1. {@link https://en.wikipedia.org/wiki/Cron#Overview | Crontab}
76 *
77 * 2. English-like {@link https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules | schedule}
78 *
79 * @example
80 * ```
81 * // Crontab schedule
82 * schedule: "0 9 * * 1"` // Every Monday at 09:00 AM
83 *
84 * // English-like schedule
85 * schedule: "every 5 minutes"
86 * ```
87 */
88 schedule: string;
89 /**
90 * Specifies the time zone to be used in interpreting {@link Schedule.schedule}.
91 *
92 * The value of this field must be a time zone name from the tz database.
93 */
94 timeZone?: string | ResetValue;
95 /**
96 * Settings that determine the retry behavior.
97 */
98 retryConfig?: ScheduleRetryConfig;
99}
100/**
101 * Configuration option for failure policy on background functions.
102 */
103export interface FailurePolicy {
104 /**
105 * Retry configuration. Must be an empty object.
106 *
107 */
108 retry: Record<string, never>;
109}
110export declare const DEFAULT_FAILURE_POLICY: FailurePolicy;
111export declare const MAX_NUMBER_USER_LABELS = 58;
112/**
113 * Configuration options for a function that applicable at runtime.
114 */
115export interface RuntimeOptions {
116 /**
117 * Failure policy of the function, with boolean `true` being equivalent to
118 * providing an empty retry object.
119 */
120 failurePolicy?: FailurePolicy | boolean;
121 /**
122 * Amount of memory to allocate to the function.
123 */
124 memory?: (typeof VALID_MEMORY_OPTIONS)[number] | Expression<number> | ResetValue;
125 /**
126 * Timeout for the function in seconds, possible values are 0 to 540.
127 */
128 timeoutSeconds?: number | Expression<number> | ResetValue;
129 /**
130 * Min number of actual instances to be running at a given time.
131 *
132 * @remarks
133 * Instances will be billed for memory allocation and 10% of CPU allocation
134 * while idle.
135 */
136 minInstances?: number | Expression<number> | ResetValue;
137 /**
138 * Max number of actual instances allowed to be running in parallel.
139 */
140 maxInstances?: number | Expression<number> | ResetValue;
141 /**
142 * Connect cloud function to specified VPC connector.
143 */
144 vpcConnector?: string | Expression<string> | ResetValue;
145 /**
146 * Egress settings for VPC connector.
147 */
148 vpcConnectorEgressSettings?: (typeof VPC_EGRESS_SETTINGS_OPTIONS)[number] | ResetValue;
149 /**
150 * Specific service account for the function to run as.
151 */
152 serviceAccount?: "default" | string | Expression<string> | ResetValue;
153 /**
154 * Ingress settings which control where this function can be called from.
155 */
156 ingressSettings?: (typeof INGRESS_SETTINGS_OPTIONS)[number] | ResetValue;
157 /**
158 * User labels to set on the function.
159 */
160 labels?: Record<string, string>;
161 /**
162 * Invoker to set access control on https functions.
163 */
164 invoker?: "public" | "private" | string | string[];
165 secrets?: (string | SecretParam)[];
166 /**
167 * Determines whether Firebase AppCheck is enforced.
168 *
169 * @remarks
170 * When true, requests with invalid tokens autorespond with a 401
171 * (Unauthorized) error.
172 * When false, requests with invalid tokens set context.app to undefiend.
173 */
174 enforceAppCheck?: boolean;
175 /**
176 * Determines whether Firebase App Check token is consumed on request. Defaults to false.
177 *
178 * @remarks
179 * Set this to true to enable the App Check replay protection feature by consuming the App Check token on callable
180 * request. Tokens that are found to be already consumed will have the `request.app.alreadyConsumed` property set
181 * to true.
182 *
183 *
184 * Tokens are only considered to be consumed if it is sent to the App Check service by setting this option to true.
185 * Other uses of the token do not consume it.
186 *
187 * This replay protection feature requires an additional network call to the App Check backend and forces the clients
188 * to obtain a fresh attestation from the chosen attestation providers. This can therefore negatively impact
189 * performance and can potentially deplete your attestation providers' quotas faster. Use this feature only for
190 * protecting low volume, security critical, or expensive operations.
191 *
192 * This option does not affect the `enforceAppCheck` option. Setting the latter to true will cause the callable function
193 * to automatically respond with a 401 Unauthorized status code when the request includes an invalid App Check token.
194 * When the request includes valid but consumed App Check tokens, requests will not be automatically rejected. Instead,
195 * the `request.app.alreadyConsumed` property will be set to true and pass the execution to the handler code for making
196 * further decisions, such as requiring additional security checks or rejecting the request.
197 */
198 consumeAppCheckToken?: boolean;
199 /**
200 * Controls whether function configuration modified outside of function source is preserved. Defaults to false.
201 *
202 * @remarks
203 * When setting configuration available in the underlying platform that is not yet available in the Firebase Functions
204 * SDK, we highly recommend setting `preserveExternalChanges` to `true`. Otherwise, when the Firebase Functions SDK releases
205 * a new version of the SDK with support for the missing configuration, your function's manually configured setting
206 * may inadvertently be wiped out.
207 */
208 preserveExternalChanges?: boolean;
209}
210/**
211 * Configuration options for a function that applies during function deployment.
212 */
213export interface DeploymentOptions extends RuntimeOptions {
214 /**
215 * If true, do not deploy or emulate this function.
216 */
217 omit?: boolean | Expression<boolean>;
218 /**
219 * Regions where function should be deployed.
220 */
221 regions?: Array<(typeof SUPPORTED_REGIONS)[number] | string | Expression<string> | ResetValue>;
222 /**
223 * Schedule for the scheduled function.
224 */
225 schedule?: Schedule;
226}