firebase-functions 3.21.0 → 3.22.0
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 +54 -88
- package/lib/cloud-functions.js +2 -59
- package/lib/common/change.d.ts +46 -0
- package/lib/common/change.js +82 -0
- package/lib/common/encoding.js +21 -1
- package/lib/common/providers/database.d.ts +145 -0
- package/lib/common/providers/database.js +271 -0
- 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/identity.js +12 -4
- package/lib/common/providers/tasks.d.ts +9 -0
- package/lib/common/providers/tasks.js +13 -12
- package/lib/function-builder.d.ts +3 -3
- package/lib/function-builder.js +2 -2
- 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/database.d.ts +4 -146
- package/lib/providers/database.js +7 -251
- package/lib/providers/firestore.d.ts +2 -1
- package/lib/providers/firestore.js +2 -1
- 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/utilities/path-pattern.d.ts +1 -0
- package/lib/utilities/path-pattern.js +142 -0
- package/lib/v2/core.d.ts +25 -1
- package/lib/v2/core.js +7 -0
- package/lib/v2/index.d.ts +11 -3
- package/lib/v2/index.js +12 -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/database.d.ts +182 -0
- package/lib/v2/providers/database.js +204 -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 +12 -6
|
@@ -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);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The MIT License (MIT)
|
|
3
|
+
//
|
|
4
|
+
// Copyright (c) 2022 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.
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.PathPattern = exports.trimParam = void 0;
|
|
25
|
+
const path_1 = require("./path");
|
|
26
|
+
/** https://cloud.google.com/eventarc/docs/path-patterns */
|
|
27
|
+
/** @hidden */
|
|
28
|
+
const WILDCARD_CAPTURE_REGEX = new RegExp('{[^/{}]+}', 'g');
|
|
29
|
+
/** @internal */
|
|
30
|
+
function trimParam(param) {
|
|
31
|
+
const paramNoBraces = param.slice(1, -1);
|
|
32
|
+
if (paramNoBraces.includes('=')) {
|
|
33
|
+
return paramNoBraces.slice(0, paramNoBraces.indexOf('='));
|
|
34
|
+
}
|
|
35
|
+
return paramNoBraces;
|
|
36
|
+
}
|
|
37
|
+
exports.trimParam = trimParam;
|
|
38
|
+
/** @hidden */
|
|
39
|
+
class Segment {
|
|
40
|
+
constructor(value) {
|
|
41
|
+
this.value = value;
|
|
42
|
+
this.name = 'segment';
|
|
43
|
+
this.trimmed = value;
|
|
44
|
+
}
|
|
45
|
+
isSingleSegmentWildcard() {
|
|
46
|
+
return this.value.includes('*') && !this.isMultiSegmentWildcard();
|
|
47
|
+
}
|
|
48
|
+
isMultiSegmentWildcard() {
|
|
49
|
+
return this.value.includes('**');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** @hidden */
|
|
53
|
+
class SingleCaptureSegment {
|
|
54
|
+
constructor(value) {
|
|
55
|
+
this.value = value;
|
|
56
|
+
this.name = 'single-capture';
|
|
57
|
+
this.trimmed = trimParam(value);
|
|
58
|
+
}
|
|
59
|
+
isSingleSegmentWildcard() {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
isMultiSegmentWildcard() {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** @hidden */
|
|
67
|
+
class MultiCaptureSegment {
|
|
68
|
+
constructor(value) {
|
|
69
|
+
this.value = value;
|
|
70
|
+
this.name = 'multi-capture';
|
|
71
|
+
this.trimmed = trimParam(value);
|
|
72
|
+
}
|
|
73
|
+
isSingleSegmentWildcard() {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
isMultiSegmentWildcard() {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Implements Eventarc's path pattern from the spec https://cloud.google.com/eventarc/docs/path-patterns
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
class PathPattern {
|
|
85
|
+
constructor(raw) {
|
|
86
|
+
this.raw = raw;
|
|
87
|
+
this.segments = [];
|
|
88
|
+
this.initPathSegments(raw);
|
|
89
|
+
}
|
|
90
|
+
/** @throws on validation error */
|
|
91
|
+
static compile(rawPath) { }
|
|
92
|
+
getValue() {
|
|
93
|
+
return this.raw;
|
|
94
|
+
}
|
|
95
|
+
// If false, we don't need to use pathPattern as our eventarc match type.
|
|
96
|
+
hasWildcards() {
|
|
97
|
+
return this.segments.some((segment) => segment.isSingleSegmentWildcard() || segment.isMultiSegmentWildcard());
|
|
98
|
+
}
|
|
99
|
+
hasCaptures() {
|
|
100
|
+
return this.segments.some((segment) => segment.name == 'single-capture' || segment.name === 'multi-capture');
|
|
101
|
+
}
|
|
102
|
+
extractMatches(path) {
|
|
103
|
+
const matches = {};
|
|
104
|
+
if (!this.hasCaptures()) {
|
|
105
|
+
return matches;
|
|
106
|
+
}
|
|
107
|
+
const pathSegments = (0, path_1.pathParts)(path);
|
|
108
|
+
let pathNdx = 0;
|
|
109
|
+
for (let segmentNdx = 0; segmentNdx < this.segments.length && pathNdx < pathSegments.length; segmentNdx++) {
|
|
110
|
+
const segment = this.segments[segmentNdx];
|
|
111
|
+
const remainingSegments = this.segments.length - 1 - segmentNdx;
|
|
112
|
+
const nextPathNdx = pathSegments.length - remainingSegments;
|
|
113
|
+
if (segment.name === 'single-capture') {
|
|
114
|
+
matches[segment.trimmed] = pathSegments[pathNdx];
|
|
115
|
+
}
|
|
116
|
+
else if (segment.name === 'multi-capture') {
|
|
117
|
+
matches[segment.trimmed] = pathSegments
|
|
118
|
+
.slice(pathNdx, nextPathNdx)
|
|
119
|
+
.join('/');
|
|
120
|
+
}
|
|
121
|
+
pathNdx = segment.isMultiSegmentWildcard() ? nextPathNdx : pathNdx + 1;
|
|
122
|
+
}
|
|
123
|
+
return matches;
|
|
124
|
+
}
|
|
125
|
+
initPathSegments(raw) {
|
|
126
|
+
const parts = (0, path_1.pathParts)(raw);
|
|
127
|
+
for (const part of parts) {
|
|
128
|
+
let segment;
|
|
129
|
+
const capture = part.match(WILDCARD_CAPTURE_REGEX);
|
|
130
|
+
if (capture && capture.length === 1) {
|
|
131
|
+
segment = part.includes('**')
|
|
132
|
+
? new MultiCaptureSegment(part)
|
|
133
|
+
: new SingleCaptureSegment(part);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
segment = new Segment(part);
|
|
137
|
+
}
|
|
138
|
+
this.segments.push(segment);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.PathPattern = PathPattern;
|
package/lib/v2/core.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core functionality of the Firebase Functions v2 SDK.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
import { Change } from '../common/change';
|
|
1
6
|
import { ManifestEndpoint } from '../runtime/manifest';
|
|
7
|
+
export { Change };
|
|
2
8
|
/**
|
|
3
9
|
* A CloudEventBase is the base of a cross-platform format for encoding a serverless event.
|
|
4
10
|
* More information can be found in https://github.com/cloudevents/spec
|
|
11
|
+
* @typeParam T - The type of the event data.
|
|
12
|
+
* @beta
|
|
5
13
|
*/
|
|
6
14
|
export interface CloudEvent<T> {
|
|
7
15
|
/** Version of the CloudEvents spec for this event. */
|
|
@@ -19,10 +27,26 @@ export interface CloudEvent<T> {
|
|
|
19
27
|
/** Information about this specific event. */
|
|
20
28
|
data: T;
|
|
21
29
|
}
|
|
22
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* A handler for CloudEvents.
|
|
32
|
+
* @typeParam EventType - The kind of event this function handles.
|
|
33
|
+
* Always a subclass of CloudEvent<>
|
|
34
|
+
* @beta
|
|
35
|
+
*/
|
|
23
36
|
export interface CloudFunction<EventType extends CloudEvent<unknown>> {
|
|
24
37
|
(raw: CloudEvent<unknown>): any | Promise<any>;
|
|
38
|
+
/** @alpha */
|
|
25
39
|
__trigger?: unknown;
|
|
40
|
+
/** @alpha */
|
|
26
41
|
__endpoint: ManifestEndpoint;
|
|
42
|
+
/**
|
|
43
|
+
* The callback passed to the CloudFunction constructor.
|
|
44
|
+
* Use run to test a CloudFunction
|
|
45
|
+
* @param event - The parsed event to handle.
|
|
46
|
+
* @returns Any return value. Google Cloud Functions awaits any promise
|
|
47
|
+
* before shutting down your function. Resolved return values
|
|
48
|
+
* are only used for unit testing purposes.
|
|
49
|
+
* @beta
|
|
50
|
+
*/
|
|
27
51
|
run(event: EventType): any | Promise<any>;
|
|
28
52
|
}
|
package/lib/v2/core.js
CHANGED
|
@@ -21,3 +21,10 @@
|
|
|
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.Change = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* Core functionality of the Firebase Functions v2 SDK.
|
|
27
|
+
* @packageDocumentation
|
|
28
|
+
*/
|
|
29
|
+
const change_1 = require("../common/change");
|
|
30
|
+
Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return change_1.Change; } });
|
package/lib/v2/index.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
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';
|
|
10
|
+
import * as database from './providers/database';
|
|
4
11
|
import * as eventarc from './providers/eventarc';
|
|
5
12
|
import * as https from './providers/https';
|
|
6
13
|
import * as identity from './providers/identity';
|
|
7
14
|
import * as pubsub from './providers/pubsub';
|
|
8
15
|
import * as storage from './providers/storage';
|
|
9
16
|
import * as tasks from './providers/tasks';
|
|
10
|
-
export { alerts, https, identity, pubsub,
|
|
11
|
-
export { setGlobalOptions, GlobalOptions } from './options';
|
|
17
|
+
export { alerts, database, storage, https, identity, pubsub, logger, tasks, eventarc, };
|
|
18
|
+
export { setGlobalOptions, GlobalOptions, SupportedRegion, MemoryOption, VpcEgressSetting, IngressSetting, EventHandlerOptions, } from './options';
|
|
19
|
+
export { Change } from '../common/change';
|
|
12
20
|
export { CloudFunction, CloudEvent } from './core';
|
package/lib/v2/index.js
CHANGED
|
@@ -21,13 +21,20 @@
|
|
|
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.Change = exports.setGlobalOptions = exports.eventarc = exports.tasks = exports.logger = exports.pubsub = exports.identity = exports.https = exports.storage = exports.database = 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;
|
|
36
|
+
const database = require("./providers/database");
|
|
37
|
+
exports.database = database;
|
|
31
38
|
const eventarc = require("./providers/eventarc");
|
|
32
39
|
exports.eventarc = eventarc;
|
|
33
40
|
const https = require("./providers/https");
|
|
@@ -42,3 +49,5 @@ const tasks = require("./providers/tasks");
|
|
|
42
49
|
exports.tasks = tasks;
|
|
43
50
|
var options_1 = require("./options");
|
|
44
51
|
Object.defineProperty(exports, "setGlobalOptions", { enumerable: true, get: function () { return options_1.setGlobalOptions; } });
|
|
52
|
+
var change_1 = require("../common/change");
|
|
53
|
+
Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return change_1.Change; } });
|
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