firebase-functions 3.21.0 → 3.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bin/firebase-functions.js +21 -0
- package/lib/cloud-functions.d.ts +53 -40
- package/lib/common/encoding.js +21 -1
- package/lib/common/providers/https.d.ts +37 -17
- package/lib/common/providers/https.js +3 -0
- package/lib/common/providers/identity.d.ts +5 -1
- package/lib/common/providers/tasks.d.ts +9 -0
- package/lib/function-builder.d.ts +1 -1
- package/lib/logger/common.js +21 -0
- package/lib/logger/compat.js +21 -0
- package/lib/logger/index.d.ts +14 -6
- package/lib/logger/index.js +33 -6
- package/lib/providers/auth.d.ts +26 -5
- package/lib/providers/auth.js +18 -4
- package/lib/providers/pubsub.d.ts +6 -6
- package/lib/providers/pubsub.js +6 -6
- package/lib/providers/tasks.d.ts +29 -14
- package/lib/providers/tasks.js +10 -3
- package/lib/v2/core.d.ts +23 -1
- package/lib/v2/index.d.ts +9 -3
- package/lib/v2/index.js +8 -3
- package/lib/v2/options.d.ts +13 -34
- package/lib/v2/options.js +6 -58
- package/lib/v2/params/index.d.ts +4 -1
- package/lib/v2/params/index.js +25 -1
- package/lib/v2/params/types.js +21 -0
- package/lib/v2/providers/alerts/alerts.d.ts +94 -3
- package/lib/v2/providers/alerts/alerts.js +23 -7
- package/lib/v2/providers/alerts/appDistribution.d.ts +101 -1
- package/lib/v2/providers/alerts/appDistribution.js +28 -1
- package/lib/v2/providers/alerts/billing.d.ts +23 -2
- package/lib/v2/providers/alerts/billing.js +37 -0
- package/lib/v2/providers/alerts/crashlytics.d.ts +193 -18
- package/lib/v2/providers/alerts/crashlytics.js +62 -1
- package/lib/v2/providers/alerts/index.d.ts +6 -0
- package/lib/v2/providers/alerts/index.js +27 -0
- package/lib/v2/providers/eventarc.d.ts +89 -5
- package/lib/v2/providers/eventarc.js +4 -0
- package/lib/v2/providers/https.d.ts +123 -2
- package/lib/v2/providers/https.js +13 -3
- package/lib/v2/providers/identity.d.ts +108 -4
- package/lib/v2/providers/identity.js +33 -2
- package/lib/v2/providers/pubsub.d.ts +122 -5
- package/lib/v2/providers/pubsub.js +58 -2
- package/lib/v2/providers/storage.d.ts +192 -4
- package/lib/v2/providers/storage.js +52 -9
- package/lib/v2/providers/tasks.d.ts +106 -6
- package/lib/v2/providers/tasks.js +4 -0
- package/package.json +6 -4
|
@@ -8,8 +8,8 @@ export declare const service = "pubsub.googleapis.com";
|
|
|
8
8
|
* Registers a Cloud Function triggered when a Google Cloud Pub/Sub message
|
|
9
9
|
* is sent to a specified topic.
|
|
10
10
|
*
|
|
11
|
-
* @param topic The Pub/Sub topic to watch for message events.
|
|
12
|
-
* @
|
|
11
|
+
* @param topic - The Pub/Sub topic to watch for message events.
|
|
12
|
+
* @returns Pub/Sub topic builder interface.
|
|
13
13
|
*/
|
|
14
14
|
export declare function topic(topic: string): TopicBuilder;
|
|
15
15
|
/** @hidden */
|
|
@@ -28,7 +28,7 @@ export declare class TopicBuilder {
|
|
|
28
28
|
* Event handler that fires every time a Cloud Pub/Sub message is
|
|
29
29
|
* published.
|
|
30
30
|
*
|
|
31
|
-
* @param handler Event handler that runs every time a Cloud Pub/Sub message
|
|
31
|
+
* @param handler - Event handler that runs every time a Cloud Pub/Sub message
|
|
32
32
|
* is published.
|
|
33
33
|
* @return A Cloud Function that you can export and deploy.
|
|
34
34
|
*/
|
|
@@ -37,7 +37,7 @@ export declare class TopicBuilder {
|
|
|
37
37
|
/**
|
|
38
38
|
* Registers a Cloud Function to run at specified times.
|
|
39
39
|
*
|
|
40
|
-
* @param schedule The schedule, in Unix Crontab or AppEngine syntax.
|
|
40
|
+
* @param schedule - The schedule, in Unix Crontab or AppEngine syntax.
|
|
41
41
|
* @return ScheduleBuilder interface.
|
|
42
42
|
*/
|
|
43
43
|
export declare function schedule(schedule: string): ScheduleBuilder;
|
|
@@ -63,7 +63,7 @@ export declare class ScheduleBuilder {
|
|
|
63
63
|
* Event handler for scheduled functions. Triggered whenever the associated
|
|
64
64
|
* scheduler job sends a Pub/Sub message.
|
|
65
65
|
*
|
|
66
|
-
* @param handler Handler that fires whenever the associated
|
|
66
|
+
* @param handler - Handler that fires whenever the associated
|
|
67
67
|
* scheduler job sends a Pub/Sub message.
|
|
68
68
|
* @return A Cloud Function that you can export and deploy.
|
|
69
69
|
*/
|
|
@@ -72,7 +72,7 @@ export declare class ScheduleBuilder {
|
|
|
72
72
|
/**
|
|
73
73
|
* Interface representing a Google Cloud Pub/Sub message.
|
|
74
74
|
*
|
|
75
|
-
* @param data Payload of a Pub/Sub message.
|
|
75
|
+
* @param data - Payload of a Pub/Sub message.
|
|
76
76
|
*/
|
|
77
77
|
export declare class Message {
|
|
78
78
|
/**
|
package/lib/providers/pubsub.js
CHANGED
|
@@ -31,8 +31,8 @@ exports.service = 'pubsub.googleapis.com';
|
|
|
31
31
|
* Registers a Cloud Function triggered when a Google Cloud Pub/Sub message
|
|
32
32
|
* is sent to a specified topic.
|
|
33
33
|
*
|
|
34
|
-
* @param topic The Pub/Sub topic to watch for message events.
|
|
35
|
-
* @
|
|
34
|
+
* @param topic - The Pub/Sub topic to watch for message events.
|
|
35
|
+
* @returns Pub/Sub topic builder interface.
|
|
36
36
|
*/
|
|
37
37
|
function topic(topic) {
|
|
38
38
|
return _topicWithOptions(topic, {});
|
|
@@ -66,7 +66,7 @@ class TopicBuilder {
|
|
|
66
66
|
* Event handler that fires every time a Cloud Pub/Sub message is
|
|
67
67
|
* published.
|
|
68
68
|
*
|
|
69
|
-
* @param handler Event handler that runs every time a Cloud Pub/Sub message
|
|
69
|
+
* @param handler - Event handler that runs every time a Cloud Pub/Sub message
|
|
70
70
|
* is published.
|
|
71
71
|
* @return A Cloud Function that you can export and deploy.
|
|
72
72
|
*/
|
|
@@ -86,7 +86,7 @@ exports.TopicBuilder = TopicBuilder;
|
|
|
86
86
|
/**
|
|
87
87
|
* Registers a Cloud Function to run at specified times.
|
|
88
88
|
*
|
|
89
|
-
* @param schedule The schedule, in Unix Crontab or AppEngine syntax.
|
|
89
|
+
* @param schedule - The schedule, in Unix Crontab or AppEngine syntax.
|
|
90
90
|
* @return ScheduleBuilder interface.
|
|
91
91
|
*/
|
|
92
92
|
function schedule(schedule) {
|
|
@@ -135,7 +135,7 @@ class ScheduleBuilder {
|
|
|
135
135
|
* Event handler for scheduled functions. Triggered whenever the associated
|
|
136
136
|
* scheduler job sends a Pub/Sub message.
|
|
137
137
|
*
|
|
138
|
-
* @param handler Handler that fires whenever the associated
|
|
138
|
+
* @param handler - Handler that fires whenever the associated
|
|
139
139
|
* scheduler job sends a Pub/Sub message.
|
|
140
140
|
* @return A Cloud Function that you can export and deploy.
|
|
141
141
|
*/
|
|
@@ -156,7 +156,7 @@ exports.ScheduleBuilder = ScheduleBuilder;
|
|
|
156
156
|
/**
|
|
157
157
|
* Interface representing a Google Cloud Pub/Sub message.
|
|
158
158
|
*
|
|
159
|
-
* @param data Payload of a Pub/Sub message.
|
|
159
|
+
* @param data - Payload of a Pub/Sub message.
|
|
160
160
|
*/
|
|
161
161
|
class Message {
|
|
162
162
|
constructor(data) {
|
package/lib/providers/tasks.d.ts
CHANGED
|
@@ -2,45 +2,60 @@ import * as express from 'express';
|
|
|
2
2
|
import { Request } from '../common/providers/https';
|
|
3
3
|
import { RateLimits, RetryConfig, TaskContext } from '../common/providers/tasks';
|
|
4
4
|
import { ManifestEndpoint, ManifestRequiredAPI } from '../runtime/manifest';
|
|
5
|
-
export {
|
|
6
|
-
/** @hidden */
|
|
7
|
-
RetryConfig as RetryPolicy,
|
|
8
|
-
/** @hidden */
|
|
9
|
-
RateLimits,
|
|
10
|
-
/** @hidden */
|
|
11
|
-
TaskContext, };
|
|
5
|
+
export { RetryConfig, RateLimits, TaskContext };
|
|
12
6
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @hidden
|
|
7
|
+
* Options for configuring the task queue to listen to.
|
|
15
8
|
*/
|
|
16
9
|
export interface TaskQueueOptions {
|
|
10
|
+
/** How a task should be retried in the event of a non-2xx return. */
|
|
17
11
|
retryConfig?: RetryConfig;
|
|
12
|
+
/** How congestion control should be applied to the function. */
|
|
18
13
|
rateLimits?: RateLimits;
|
|
19
14
|
/**
|
|
20
15
|
* Who can enqueue tasks for this function.
|
|
21
16
|
* If left unspecified, only service accounts which have
|
|
22
|
-
* roles/cloudtasks.enqueuer and roles/cloudfunctions.invoker
|
|
17
|
+
* `roles/cloudtasks.enqueuer` and `roles/cloudfunctions.invoker`
|
|
23
18
|
* will have permissions.
|
|
24
19
|
*/
|
|
25
20
|
invoker?: 'private' | string | string[];
|
|
26
21
|
}
|
|
27
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* A handler for tasks.
|
|
24
|
+
*/
|
|
28
25
|
export interface TaskQueueFunction {
|
|
29
26
|
(req: Request, res: express.Response): Promise<void>;
|
|
27
|
+
/** @alpha */
|
|
30
28
|
__trigger: unknown;
|
|
29
|
+
/** @alpha */
|
|
31
30
|
__endpoint: ManifestEndpoint;
|
|
31
|
+
/** @alpha */
|
|
32
32
|
__requiredAPIs?: ManifestRequiredAPI[];
|
|
33
|
+
/**
|
|
34
|
+
* The callback passed to the `TaskQueueFunction` constructor.
|
|
35
|
+
* @param data - The body enqueued into a task queue.
|
|
36
|
+
* @param context - The request context of the enqueued task
|
|
37
|
+
* @returns Any return value. Google Cloud Functions will await any promise
|
|
38
|
+
* before shutting down your function. Resolved return values
|
|
39
|
+
* are only used for unit testing purposes.
|
|
40
|
+
*/
|
|
33
41
|
run(data: any, context: TaskContext): void | Promise<void>;
|
|
34
42
|
}
|
|
35
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Builder for creating a `TaskQueueFunction`.
|
|
45
|
+
*/
|
|
36
46
|
export declare class TaskQueueBuilder {
|
|
37
47
|
private readonly tqOpts?;
|
|
38
48
|
private readonly depOpts?;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a handler for tasks sent to a Google Cloud Tasks queue.
|
|
51
|
+
* @param handler - A callback to handle task requests.
|
|
52
|
+
* @returns A Cloud Function you can export and deploy.
|
|
53
|
+
*/
|
|
39
54
|
onDispatch(handler: (data: any, context: TaskContext) => void | Promise<void>): TaskQueueFunction;
|
|
40
55
|
}
|
|
41
56
|
/**
|
|
42
57
|
* Declares a function that can handle tasks enqueued using the Firebase Admin SDK.
|
|
43
|
-
* @param options Configuration for the Task Queue that feeds into this function.
|
|
44
|
-
*
|
|
58
|
+
* @param options - Configuration for the Task Queue that feeds into this function.
|
|
59
|
+
* Omitting options will configure a Task Queue with default settings.
|
|
45
60
|
*/
|
|
46
61
|
export declare function taskQueue(options?: TaskQueueOptions): TaskQueueBuilder;
|
package/lib/providers/tasks.js
CHANGED
|
@@ -25,13 +25,20 @@ exports.taskQueue = exports.TaskQueueBuilder = void 0;
|
|
|
25
25
|
const cloud_functions_1 = require("../cloud-functions");
|
|
26
26
|
const encoding_1 = require("../common/encoding");
|
|
27
27
|
const tasks_1 = require("../common/providers/tasks");
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Builder for creating a `TaskQueueFunction`.
|
|
30
|
+
*/
|
|
29
31
|
class TaskQueueBuilder {
|
|
30
32
|
/** @internal */
|
|
31
33
|
constructor(tqOpts, depOpts) {
|
|
32
34
|
this.tqOpts = tqOpts;
|
|
33
35
|
this.depOpts = depOpts;
|
|
34
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a handler for tasks sent to a Google Cloud Tasks queue.
|
|
39
|
+
* @param handler - A callback to handle task requests.
|
|
40
|
+
* @returns A Cloud Function you can export and deploy.
|
|
41
|
+
*/
|
|
35
42
|
onDispatch(handler) {
|
|
36
43
|
// onEnqueueHandler sniffs the function length of the passed-in callback
|
|
37
44
|
// and the user could have only tried to listen to data. Wrap their handler
|
|
@@ -66,8 +73,8 @@ class TaskQueueBuilder {
|
|
|
66
73
|
exports.TaskQueueBuilder = TaskQueueBuilder;
|
|
67
74
|
/**
|
|
68
75
|
* Declares a function that can handle tasks enqueued using the Firebase Admin SDK.
|
|
69
|
-
* @param options Configuration for the Task Queue that feeds into this function.
|
|
70
|
-
*
|
|
76
|
+
* @param options - Configuration for the Task Queue that feeds into this function.
|
|
77
|
+
* Omitting options will configure a Task Queue with default settings.
|
|
71
78
|
*/
|
|
72
79
|
function taskQueue(options) {
|
|
73
80
|
return new TaskQueueBuilder(options);
|
package/lib/v2/core.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core functionality of the Firebase Functions v2 SDK.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { ManifestEndpoint } from '../runtime/manifest';
|
|
2
6
|
/**
|
|
3
7
|
* A CloudEventBase is the base of a cross-platform format for encoding a serverless event.
|
|
4
8
|
* More information can be found in https://github.com/cloudevents/spec
|
|
9
|
+
* @typeParam T - The type of the event data.
|
|
10
|
+
* @beta
|
|
5
11
|
*/
|
|
6
12
|
export interface CloudEvent<T> {
|
|
7
13
|
/** Version of the CloudEvents spec for this event. */
|
|
@@ -19,10 +25,26 @@ export interface CloudEvent<T> {
|
|
|
19
25
|
/** Information about this specific event. */
|
|
20
26
|
data: T;
|
|
21
27
|
}
|
|
22
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* A handler for CloudEvents.
|
|
30
|
+
* @typeParam EventType - The kind of event this function handles.
|
|
31
|
+
* Always a subclass of CloudEvent<>
|
|
32
|
+
* @beta
|
|
33
|
+
*/
|
|
23
34
|
export interface CloudFunction<EventType extends CloudEvent<unknown>> {
|
|
24
35
|
(raw: CloudEvent<unknown>): any | Promise<any>;
|
|
36
|
+
/** @alpha */
|
|
25
37
|
__trigger?: unknown;
|
|
38
|
+
/** @alpha */
|
|
26
39
|
__endpoint: ManifestEndpoint;
|
|
40
|
+
/**
|
|
41
|
+
* The callback passed to the CloudFunction constructor.
|
|
42
|
+
* Use run to test a CloudFunction
|
|
43
|
+
* @param event - The parsed event to handle.
|
|
44
|
+
* @returns Any return value. Google Cloud Functions awaits any promise
|
|
45
|
+
* before shutting down your function. Resolved return values
|
|
46
|
+
* are only used for unit testing purposes.
|
|
47
|
+
* @beta
|
|
48
|
+
*/
|
|
27
49
|
run(event: EventType): any | Promise<any>;
|
|
28
50
|
}
|
package/lib/v2/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The V2 API for Cloud Functions for Firebase.
|
|
3
|
+
* This SDK also supports deep imports. For example, the namespace
|
|
4
|
+
* 'pubsub' is available at 'firebase-functions/v2' or is directly importable
|
|
5
|
+
* from 'firebase-functions/v2/pubsub'.
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
1
8
|
import * as logger from '../logger';
|
|
2
|
-
import * as params from './params';
|
|
3
9
|
import * as alerts from './providers/alerts';
|
|
4
10
|
import * as eventarc from './providers/eventarc';
|
|
5
11
|
import * as https from './providers/https';
|
|
@@ -7,6 +13,6 @@ import * as identity from './providers/identity';
|
|
|
7
13
|
import * as pubsub from './providers/pubsub';
|
|
8
14
|
import * as storage from './providers/storage';
|
|
9
15
|
import * as tasks from './providers/tasks';
|
|
10
|
-
export { alerts, https, identity, pubsub,
|
|
11
|
-
export { setGlobalOptions, GlobalOptions } from './options';
|
|
16
|
+
export { alerts, storage, https, identity, pubsub, logger, tasks, eventarc };
|
|
17
|
+
export { setGlobalOptions, GlobalOptions, SupportedRegion, MemoryOption, VpcEgressSetting, IngressSetting, EventHandlerOptions, } from './options';
|
|
12
18
|
export { CloudFunction, CloudEvent } from './core';
|
package/lib/v2/index.js
CHANGED
|
@@ -21,11 +21,16 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.setGlobalOptions = exports.eventarc = exports.tasks = exports.
|
|
24
|
+
exports.setGlobalOptions = exports.eventarc = exports.tasks = exports.logger = exports.pubsub = exports.identity = exports.https = exports.storage = exports.alerts = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* The V2 API for Cloud Functions for Firebase.
|
|
27
|
+
* This SDK also supports deep imports. For example, the namespace
|
|
28
|
+
* 'pubsub' is available at 'firebase-functions/v2' or is directly importable
|
|
29
|
+
* from 'firebase-functions/v2/pubsub'.
|
|
30
|
+
* @packageDocumentation
|
|
31
|
+
*/
|
|
25
32
|
const logger = require("../logger");
|
|
26
33
|
exports.logger = logger;
|
|
27
|
-
const params = require("./params");
|
|
28
|
-
exports.params = params;
|
|
29
34
|
const alerts = require("./providers/alerts");
|
|
30
35
|
exports.alerts = alerts;
|
|
31
36
|
const eventarc = require("./providers/eventarc");
|
package/lib/v2/options.d.ts
CHANGED
|
@@ -2,48 +2,19 @@ import { ParamSpec } from './params/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* List of all regions supported by Cloud Functions v2
|
|
4
4
|
*/
|
|
5
|
-
export declare
|
|
6
|
-
/**
|
|
7
|
-
* A region known to be supported by CloudFunctions v2
|
|
8
|
-
*/
|
|
9
|
-
export declare type SupportedRegion = typeof SUPPORTED_REGIONS[number];
|
|
10
|
-
/**
|
|
11
|
-
* Cloud Functions v2 min timeout value.
|
|
12
|
-
*/
|
|
13
|
-
export declare const MIN_TIMEOUT_SECONDS = 1;
|
|
14
|
-
/**
|
|
15
|
-
* Cloud Functions v2 max timeout value for event handlers.
|
|
16
|
-
*/
|
|
17
|
-
export declare const MAX_EVENT_TIMEOUT_SECONDS = 540;
|
|
18
|
-
/**
|
|
19
|
-
* Cloud Functions v2 max timeout for HTTPS functions.
|
|
20
|
-
*/
|
|
21
|
-
export declare const MAX_HTTPS_TIMEOUT_SECONDS = 36000;
|
|
22
|
-
/**
|
|
23
|
-
* Maximum number of requests to serve on a single instance.
|
|
24
|
-
*/
|
|
25
|
-
export declare const MAX_CONCURRENCY = 1000;
|
|
5
|
+
export declare type SupportedRegion = 'asia-northeast1' | 'europe-north1' | 'europe-west1' | 'europe-west4' | 'us-central1' | 'us-east1' | 'us-west1';
|
|
26
6
|
/**
|
|
27
7
|
* List of available memory options supported by Cloud Functions.
|
|
28
8
|
*/
|
|
29
|
-
export declare
|
|
30
|
-
/**
|
|
31
|
-
* A supported memory option.
|
|
32
|
-
*/
|
|
33
|
-
export declare type MemoryOption = typeof SUPPORTED_MEMORY_OPTIONS[number];
|
|
9
|
+
export declare type MemoryOption = '128MiB' | '256MiB' | '512MiB' | '1GiB' | '2GiB' | '4GiB' | '8GiB' | '16GiB' | '32GiB';
|
|
34
10
|
/**
|
|
35
11
|
* List of available options for VpcConnectorEgressSettings.
|
|
36
12
|
*/
|
|
37
|
-
export declare
|
|
38
|
-
/**
|
|
39
|
-
* A valid VPC Egress setting.
|
|
40
|
-
*/
|
|
41
|
-
export declare type VpcEgressSetting = typeof SUPPORTED_VPC_EGRESS_SETTINGS[number];
|
|
13
|
+
export declare type VpcEgressSetting = 'PRIVATE_RANGES_ONLY' | 'ALL_TRAFFIC';
|
|
42
14
|
/**
|
|
43
15
|
* List of available options for IngressSettings.
|
|
44
16
|
*/
|
|
45
|
-
export declare
|
|
46
|
-
export declare type IngressSetting = typeof SUPPORTED_INGRESS_SETTINGS[number];
|
|
17
|
+
export declare type IngressSetting = 'ALLOW_ALL' | 'ALLOW_INTERNAL_ONLY' | 'ALLOW_INTERNAL_AND_GCLB';
|
|
47
18
|
/**
|
|
48
19
|
* GlobalOptions are options that can be set across an entire project.
|
|
49
20
|
* These options are common to HTTPS and Event handling functions.
|
|
@@ -63,6 +34,11 @@ export interface GlobalOptions {
|
|
|
63
34
|
* Timeout for the function in sections, possible values are 0 to 540.
|
|
64
35
|
* HTTPS functions can specify a higher timeout.
|
|
65
36
|
* A value of null restores the default of 60s
|
|
37
|
+
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
|
38
|
+
* function depends on the type of function: Event handling functions have a
|
|
39
|
+
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
|
40
|
+
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
41
|
+
* timeout of 1,800s (30 minutes)
|
|
66
42
|
*/
|
|
67
43
|
timeoutSeconds?: number | null;
|
|
68
44
|
/**
|
|
@@ -82,6 +58,7 @@ export interface GlobalOptions {
|
|
|
82
58
|
* Can only be applied to functions running on Cloud Functions v2.
|
|
83
59
|
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
|
84
60
|
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
61
|
+
* The maximum value for concurrency is 1,000.
|
|
85
62
|
*/
|
|
86
63
|
concurrency?: number | null;
|
|
87
64
|
/**
|
|
@@ -129,13 +106,15 @@ export interface GlobalOptions {
|
|
|
129
106
|
*/
|
|
130
107
|
export declare function setGlobalOptions(options: GlobalOptions): void;
|
|
131
108
|
/**
|
|
132
|
-
*
|
|
109
|
+
* Additional fields that can be set on any event-handling Cloud Function.
|
|
133
110
|
*/
|
|
134
111
|
export interface EventHandlerOptions extends GlobalOptions {
|
|
112
|
+
/** Whether failed executions should be delivered again. */
|
|
135
113
|
retry?: boolean;
|
|
136
114
|
}
|
|
137
115
|
/**
|
|
138
116
|
* @hidden
|
|
117
|
+
* @alpha
|
|
139
118
|
*/
|
|
140
119
|
export declare function __getSpec(): {
|
|
141
120
|
globalOptions: GlobalOptions;
|
package/lib/v2/options.js
CHANGED
|
@@ -21,52 +21,14 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.__getSpec = exports.optionsToEndpoint = exports.optionsToTriggerAnnotations = exports.getGlobalOptions = exports.setGlobalOptions =
|
|
24
|
+
exports.__getSpec = exports.optionsToEndpoint = exports.optionsToTriggerAnnotations = exports.getGlobalOptions = exports.setGlobalOptions = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* Options to configure cloud functions.
|
|
27
|
+
* @packageDocumentation
|
|
28
|
+
*/
|
|
25
29
|
const encoding_1 = require("../common/encoding");
|
|
26
30
|
const logger = require("../logger");
|
|
27
31
|
const params_1 = require("./params");
|
|
28
|
-
/**
|
|
29
|
-
* List of all regions supported by Cloud Functions v2
|
|
30
|
-
*/
|
|
31
|
-
exports.SUPPORTED_REGIONS = [
|
|
32
|
-
'asia-northeast1',
|
|
33
|
-
'europe-north1',
|
|
34
|
-
'europe-west1',
|
|
35
|
-
'europe-west4',
|
|
36
|
-
'us-central1',
|
|
37
|
-
'us-east1',
|
|
38
|
-
'us-west1',
|
|
39
|
-
];
|
|
40
|
-
/**
|
|
41
|
-
* Cloud Functions v2 min timeout value.
|
|
42
|
-
*/
|
|
43
|
-
exports.MIN_TIMEOUT_SECONDS = 1;
|
|
44
|
-
/**
|
|
45
|
-
* Cloud Functions v2 max timeout value for event handlers.
|
|
46
|
-
*/
|
|
47
|
-
exports.MAX_EVENT_TIMEOUT_SECONDS = 540;
|
|
48
|
-
/**
|
|
49
|
-
* Cloud Functions v2 max timeout for HTTPS functions.
|
|
50
|
-
*/
|
|
51
|
-
exports.MAX_HTTPS_TIMEOUT_SECONDS = 36000;
|
|
52
|
-
/**
|
|
53
|
-
* Maximum number of requests to serve on a single instance.
|
|
54
|
-
*/
|
|
55
|
-
exports.MAX_CONCURRENCY = 1000;
|
|
56
|
-
/**
|
|
57
|
-
* List of available memory options supported by Cloud Functions.
|
|
58
|
-
*/
|
|
59
|
-
exports.SUPPORTED_MEMORY_OPTIONS = [
|
|
60
|
-
'128MiB',
|
|
61
|
-
'256MiB',
|
|
62
|
-
'512MiB',
|
|
63
|
-
'1GiB',
|
|
64
|
-
'2GiB',
|
|
65
|
-
'4GiB',
|
|
66
|
-
'8GiB',
|
|
67
|
-
'16GiB',
|
|
68
|
-
'32GiB',
|
|
69
|
-
];
|
|
70
32
|
const MemoryOptionToMB = {
|
|
71
33
|
'128MiB': 128,
|
|
72
34
|
'256MiB': 256,
|
|
@@ -78,21 +40,6 @@ const MemoryOptionToMB = {
|
|
|
78
40
|
'16GiB': 16384,
|
|
79
41
|
'32GiB': 32768,
|
|
80
42
|
};
|
|
81
|
-
/**
|
|
82
|
-
* List of available options for VpcConnectorEgressSettings.
|
|
83
|
-
*/
|
|
84
|
-
exports.SUPPORTED_VPC_EGRESS_SETTINGS = [
|
|
85
|
-
'PRIVATE_RANGES_ONLY',
|
|
86
|
-
'ALL_TRAFFIC',
|
|
87
|
-
];
|
|
88
|
-
/**
|
|
89
|
-
* List of available options for IngressSettings.
|
|
90
|
-
*/
|
|
91
|
-
exports.SUPPORTED_INGRESS_SETTINGS = [
|
|
92
|
-
'ALLOW_ALL',
|
|
93
|
-
'ALLOW_INTERNAL_ONLY',
|
|
94
|
-
'ALLOW_INTERNAL_AND_GCLB',
|
|
95
|
-
];
|
|
96
43
|
let globalOptions;
|
|
97
44
|
/**
|
|
98
45
|
* Sets default options for all functions written using the v2 SDK.
|
|
@@ -166,6 +113,7 @@ function optionsToEndpoint(opts) {
|
|
|
166
113
|
exports.optionsToEndpoint = optionsToEndpoint;
|
|
167
114
|
/**
|
|
168
115
|
* @hidden
|
|
116
|
+
* @alpha
|
|
169
117
|
*/
|
|
170
118
|
function __getSpec() {
|
|
171
119
|
return {
|
package/lib/v2/params/index.d.ts
CHANGED
package/lib/v2/params/index.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// The MIT License (MIT)
|
|
3
|
+
//
|
|
4
|
+
// Copyright (c) 2021 Firebase
|
|
5
|
+
//
|
|
6
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
// in the Software without restriction, including without limitation the rights
|
|
9
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
// furnished to do so, subject to the following conditions:
|
|
12
|
+
//
|
|
13
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
// copies or substantial portions of the Software.
|
|
15
|
+
//
|
|
16
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
// SOFTWARE.
|
|
2
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
24
|
exports.defineJSON = exports.defineList = exports.defineFloat = exports.defineInt = exports.defineBoolean = exports.defineString = exports.declaredParams = void 0;
|
|
4
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* @hidden
|
|
27
|
+
* @alpha
|
|
28
|
+
*/
|
|
5
29
|
const types_1 = require("./types");
|
|
6
30
|
exports.declaredParams = [];
|
|
7
31
|
/**
|
package/lib/v2/params/types.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// The MIT License (MIT)
|
|
3
|
+
//
|
|
4
|
+
// Copyright (c) 2021 Firebase
|
|
5
|
+
//
|
|
6
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
// in the Software without restriction, including without limitation the rights
|
|
9
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
// furnished to do so, subject to the following conditions:
|
|
12
|
+
//
|
|
13
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
// copies or substantial portions of the Software.
|
|
15
|
+
//
|
|
16
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
// SOFTWARE.
|
|
2
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
24
|
exports.JSONParam = exports.ListParam = exports.BooleanParam = exports.FloatParam = exports.IntParam = exports.StringParam = exports.Param = void 0;
|
|
4
25
|
class Param {
|
|
@@ -2,6 +2,7 @@ import { CloudEvent, CloudFunction } from '../../core';
|
|
|
2
2
|
import * as options from '../../options';
|
|
3
3
|
/**
|
|
4
4
|
* The CloudEvent data emitted by Firebase Alerts.
|
|
5
|
+
* @typeParam T - the payload type that is expected for this alert.
|
|
5
6
|
*/
|
|
6
7
|
export interface FirebaseAlertData<T = any> {
|
|
7
8
|
/** Time that the event has created. */
|
|
@@ -13,6 +14,7 @@ export interface FirebaseAlertData<T = any> {
|
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* A custom CloudEvent for Firebase Alerts (with custom extension attributes).
|
|
17
|
+
* @typeParam T - the data type for this alert that is wrapped in a `FirebaseAlertData` object.
|
|
16
18
|
*/
|
|
17
19
|
export interface AlertEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
|
|
18
20
|
/** The type of the alerts that got triggered. */
|
|
@@ -22,7 +24,7 @@ export interface AlertEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
|
|
|
22
24
|
* and only present when the alert is targeting at a specific Firebase App.
|
|
23
25
|
*/
|
|
24
26
|
appId?: string;
|
|
25
|
-
/** Data for an AlertEvent is a FirebaseAlertData with a given payload. */
|
|
27
|
+
/** Data for an `AlertEvent` is a `FirebaseAlertData` object with a given payload. */
|
|
26
28
|
data: FirebaseAlertData<T>;
|
|
27
29
|
}
|
|
28
30
|
/** The underlying alert type of the Firebase Alerts provider. */
|
|
@@ -31,14 +33,103 @@ export declare type AlertType = 'crashlytics.newFatalIssue' | 'crashlytics.newNo
|
|
|
31
33
|
* Configuration for Firebase Alert functions.
|
|
32
34
|
*/
|
|
33
35
|
export interface FirebaseAlertOptions extends options.EventHandlerOptions {
|
|
36
|
+
/** Scope the handler to trigger on an alert type. */
|
|
34
37
|
alertType: AlertType;
|
|
38
|
+
/** Scope the function to trigger on a specific application. */
|
|
35
39
|
appId?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Region where functions should be deployed.
|
|
42
|
+
*/
|
|
43
|
+
region?: options.SupportedRegion | string;
|
|
44
|
+
/**
|
|
45
|
+
* Amount of memory to allocate to a function.
|
|
46
|
+
* A value of null restores the defaults of 256MB.
|
|
47
|
+
*/
|
|
48
|
+
memory?: options.MemoryOption | null;
|
|
49
|
+
/**
|
|
50
|
+
* Timeout for the function in sections, possible values are 0 to 540.
|
|
51
|
+
* HTTPS functions can specify a higher timeout.
|
|
52
|
+
* A value of null restores the default of 60s
|
|
53
|
+
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
|
54
|
+
* function depends on the type of function: Event handling functions have a
|
|
55
|
+
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
|
56
|
+
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
57
|
+
* timeout of 1,800s (30 minutes)
|
|
58
|
+
*/
|
|
59
|
+
timeoutSeconds?: number | null;
|
|
60
|
+
/**
|
|
61
|
+
* Min number of actual instances to be running at a given time.
|
|
62
|
+
* Instances will be billed for memory allocation and 10% of CPU allocation
|
|
63
|
+
* while idle.
|
|
64
|
+
* A value of null restores the default min instances.
|
|
65
|
+
*/
|
|
66
|
+
minInstances?: number | null;
|
|
67
|
+
/**
|
|
68
|
+
* Max number of instances to be running in parallel.
|
|
69
|
+
* A value of null restores the default max instances.
|
|
70
|
+
*/
|
|
71
|
+
maxInstances?: number | null;
|
|
72
|
+
/**
|
|
73
|
+
* Number of requests a function can serve at once.
|
|
74
|
+
* Can only be applied to functions running on Cloud Functions v2.
|
|
75
|
+
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
|
76
|
+
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
77
|
+
* The maximum value for concurrency is 1,000.
|
|
78
|
+
*/
|
|
79
|
+
concurrency?: number | null;
|
|
80
|
+
/**
|
|
81
|
+
* Fractional number of CPUs to allocate to a function.
|
|
82
|
+
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
|
83
|
+
* This is different from the defaults when using the gcloud utility and is different from
|
|
84
|
+
* the fixed amount assigned in Google Cloud Functions generation 1.
|
|
85
|
+
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
|
86
|
+
* to the value "gcf_gen1"
|
|
87
|
+
*/
|
|
88
|
+
cpu?: number | 'gcf_gen1';
|
|
89
|
+
/**
|
|
90
|
+
* Connect cloud function to specified VPC connector.
|
|
91
|
+
* A value of null removes the VPC connector
|
|
92
|
+
*/
|
|
93
|
+
vpcConnector?: string | null;
|
|
94
|
+
/**
|
|
95
|
+
* Egress settings for VPC connector.
|
|
96
|
+
* A value of null turns off VPC connector egress settings
|
|
97
|
+
*/
|
|
98
|
+
vpcConnectorEgressSettings?: options.VpcEgressSetting | null;
|
|
99
|
+
/**
|
|
100
|
+
* Specific service account for the function to run as.
|
|
101
|
+
* A value of null restores the default service account.
|
|
102
|
+
*/
|
|
103
|
+
serviceAccount?: string | null;
|
|
104
|
+
/**
|
|
105
|
+
* Ingress settings which control where this function can be called from.
|
|
106
|
+
* A value of null turns off ingress settings.
|
|
107
|
+
*/
|
|
108
|
+
ingressSettings?: options.IngressSetting | null;
|
|
109
|
+
/**
|
|
110
|
+
* User labels to set on the function.
|
|
111
|
+
*/
|
|
112
|
+
labels?: Record<string, string>;
|
|
113
|
+
secrets?: string[];
|
|
114
|
+
/** Whether failed executions should be delivered again. */
|
|
115
|
+
retry?: boolean;
|
|
36
116
|
}
|
|
37
117
|
/**
|
|
38
118
|
* Declares a function that can handle Firebase Alerts from CloudEvents.
|
|
39
|
-
* @
|
|
119
|
+
* @typeParam T - the type of event.data.payload.
|
|
120
|
+
* @param alertType - the alert type or Firebase Alert function configuration.
|
|
121
|
+
* @param handler a function that can handle the Firebase Alert inside a CloudEvent.
|
|
122
|
+
* @returns A function that you can export and deploy.
|
|
123
|
+
*/
|
|
124
|
+
export declare function onAlertPublished<T extends {
|
|
125
|
+
['@type']: string;
|
|
126
|
+
} = any>(alertType: AlertType, handler: (event: AlertEvent<T>) => any | Promise<any>): CloudFunction<AlertEvent<T>>;
|
|
127
|
+
/**
|
|
128
|
+
* Declares a function that can handle Firebase Alerts from CloudEvents.
|
|
129
|
+
* @typeParam T - the type of event.data.payload.
|
|
130
|
+
* @param options - the alert type and other options for this cloud function.
|
|
40
131
|
* @param handler a function that can handle the Firebase Alert inside a CloudEvent.
|
|
41
132
|
*/
|
|
42
133
|
export declare function onAlertPublished<T extends {
|
|
43
134
|
['@type']: string;
|
|
44
|
-
} = any>(
|
|
135
|
+
} = any>(options: FirebaseAlertOptions, handler: (event: AlertEvent<T>) => any | Promise<any>): CloudFunction<AlertEvent<T>>;
|