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
|
@@ -1,18 +1,49 @@
|
|
|
1
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.
|
|
2
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
24
|
exports.getOpts = exports.beforeOperation = exports.beforeUserSignedIn = exports.beforeUserCreated = exports.HttpsError = void 0;
|
|
4
25
|
const identity_1 = require("../../common/providers/identity");
|
|
5
26
|
Object.defineProperty(exports, "HttpsError", { enumerable: true, get: function () { return identity_1.HttpsError; } });
|
|
6
27
|
const options = require("../options");
|
|
28
|
+
/**
|
|
29
|
+
* Handles an event that is triggered before a user is created
|
|
30
|
+
* @param optsOrHandler - Either an object containing function options, or an event handler (run before user creation)
|
|
31
|
+
* @param handler? - If defined, an event handler which is run every time before a user is created
|
|
32
|
+
*/
|
|
7
33
|
function beforeUserCreated(optsOrHandler, handler) {
|
|
8
34
|
return beforeOperation('beforeCreate', optsOrHandler, handler);
|
|
9
35
|
}
|
|
10
36
|
exports.beforeUserCreated = beforeUserCreated;
|
|
37
|
+
/**
|
|
38
|
+
* Handles an event that is triggered before a user is signed in.
|
|
39
|
+
* @param optsOrHandler - Either an object containing function options, or an event handler (run before user signin)
|
|
40
|
+
* @param handler - Event handler which is run every time before a user is signed in
|
|
41
|
+
*/
|
|
11
42
|
function beforeUserSignedIn(optsOrHandler, handler) {
|
|
12
43
|
return beforeOperation('beforeSignIn', optsOrHandler, handler);
|
|
13
44
|
}
|
|
14
45
|
exports.beforeUserSignedIn = beforeUserSignedIn;
|
|
15
|
-
/** @
|
|
46
|
+
/** @hidden */
|
|
16
47
|
function beforeOperation(eventType, optsOrHandler, handler) {
|
|
17
48
|
if (!handler || typeof optsOrHandler === 'function') {
|
|
18
49
|
handler = optsOrHandler;
|
|
@@ -54,7 +85,7 @@ function beforeOperation(eventType, optsOrHandler, handler) {
|
|
|
54
85
|
return func;
|
|
55
86
|
}
|
|
56
87
|
exports.beforeOperation = beforeOperation;
|
|
57
|
-
/** @
|
|
88
|
+
/** @hidden */
|
|
58
89
|
function getOpts(blockingOptions) {
|
|
59
90
|
const accessToken = blockingOptions.accessToken || false;
|
|
60
91
|
const idToken = blockingOptions.idToken || false;
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import { CloudEvent, CloudFunction } from '../core';
|
|
2
2
|
import * as options from '../options';
|
|
3
|
+
/**
|
|
4
|
+
* Google Cloud Pub/Sub is a globally distributed message bus that automatically scales as you need it.
|
|
5
|
+
* You can create a function ({@link onMessagePublished}) that handles pub/sub events by using functions.pubsub.
|
|
6
|
+
*
|
|
7
|
+
* This function triggers whenever a new pub/sub message is sent to a specific topic.
|
|
8
|
+
* You must specify the Pub/Sub topic name that you want to trigger your function, and set the event within the
|
|
9
|
+
* onPublish() event handler.
|
|
10
|
+
*
|
|
11
|
+
* PubSub Topic:
|
|
12
|
+
* <ul>
|
|
13
|
+
* <li>A resource that you can publish messages to and then consume those messages via subscriptions.
|
|
14
|
+
* <li>An isolated data stream for pub/sub messages.
|
|
15
|
+
* <li>Messages are published to a topic.
|
|
16
|
+
* <li>Messages are listened to via a subscription.
|
|
17
|
+
* <li>Each subscription listens to the messages published to exactly one topic.
|
|
18
|
+
*
|
|
19
|
+
* Subscriptions - Resource that listens to the messages published by exactly one topic.
|
|
20
|
+
*
|
|
21
|
+
* [More info here](https://firebase.google.com/docs/functions/pubsub-events)
|
|
22
|
+
*/
|
|
3
23
|
/**
|
|
4
24
|
* Interface representing a Google Cloud Pub/Sub message.
|
|
5
25
|
*
|
|
6
|
-
* @param data Payload of a Pub/Sub message.
|
|
26
|
+
* @param data - Payload of a Pub/Sub message.
|
|
27
|
+
* @typeParam T - Type representing `Message.data`'s JSON format
|
|
7
28
|
*/
|
|
8
29
|
export declare class Message<T> {
|
|
9
30
|
/**
|
|
@@ -30,6 +51,10 @@ export declare class Message<T> {
|
|
|
30
51
|
readonly orderingKey: string;
|
|
31
52
|
/** @hidden */
|
|
32
53
|
private _json;
|
|
54
|
+
/**
|
|
55
|
+
* @hidden
|
|
56
|
+
* @alpha
|
|
57
|
+
*/
|
|
33
58
|
constructor(data: any);
|
|
34
59
|
/**
|
|
35
60
|
* The JSON data payload of this message object, if any.
|
|
@@ -38,20 +63,112 @@ export declare class Message<T> {
|
|
|
38
63
|
/**
|
|
39
64
|
* Returns a JSON-serializable representation of this object.
|
|
40
65
|
*
|
|
41
|
-
* @
|
|
66
|
+
* @returns A JSON-serializable representation of this object.
|
|
42
67
|
*/
|
|
43
68
|
toJSON(): any;
|
|
44
69
|
}
|
|
45
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* The interface published in a Pub/Sub publish subscription.
|
|
72
|
+
* @typeParam T - Type representing `Message.data`'s JSON format
|
|
73
|
+
*/
|
|
46
74
|
export interface MessagePublishedData<T = any> {
|
|
75
|
+
/** Google Cloud Pub/Sub message. */
|
|
47
76
|
readonly message: Message<T>;
|
|
77
|
+
/** A subscription resource. */
|
|
48
78
|
readonly subscription: string;
|
|
49
79
|
}
|
|
50
80
|
/** PubSubOptions extend EventHandlerOptions but must include a topic. */
|
|
51
81
|
export interface PubSubOptions extends options.EventHandlerOptions {
|
|
82
|
+
/** The Pub/Sub topic to watch for message events */
|
|
52
83
|
topic: string;
|
|
84
|
+
/**
|
|
85
|
+
* Region where functions should be deployed.
|
|
86
|
+
*/
|
|
87
|
+
region?: options.SupportedRegion | string;
|
|
88
|
+
/**
|
|
89
|
+
* Amount of memory to allocate to a function.
|
|
90
|
+
* A value of null restores the defaults of 256MB.
|
|
91
|
+
*/
|
|
92
|
+
memory?: options.MemoryOption | null;
|
|
93
|
+
/**
|
|
94
|
+
* Timeout for the function in sections, possible values are 0 to 540.
|
|
95
|
+
* HTTPS functions can specify a higher timeout.
|
|
96
|
+
* A value of null restores the default of 60s
|
|
97
|
+
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
|
98
|
+
* function depends on the type of function: Event handling functions have a
|
|
99
|
+
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
|
100
|
+
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
101
|
+
* timeout of 1,800s (30 minutes)
|
|
102
|
+
*/
|
|
103
|
+
timeoutSeconds?: number | null;
|
|
104
|
+
/**
|
|
105
|
+
* Min number of actual instances to be running at a given time.
|
|
106
|
+
* Instances will be billed for memory allocation and 10% of CPU allocation
|
|
107
|
+
* while idle.
|
|
108
|
+
* A value of null restores the default min instances.
|
|
109
|
+
*/
|
|
110
|
+
minInstances?: number | null;
|
|
111
|
+
/**
|
|
112
|
+
* Max number of instances to be running in parallel.
|
|
113
|
+
* A value of null restores the default max instances.
|
|
114
|
+
*/
|
|
115
|
+
maxInstances?: number | null;
|
|
116
|
+
/**
|
|
117
|
+
* Number of requests a function can serve at once.
|
|
118
|
+
* Can only be applied to functions running on Cloud Functions v2.
|
|
119
|
+
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
|
120
|
+
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
121
|
+
* The maximum value for concurrency is 1,000.
|
|
122
|
+
*/
|
|
123
|
+
concurrency?: number | null;
|
|
124
|
+
/**
|
|
125
|
+
* Fractional number of CPUs to allocate to a function.
|
|
126
|
+
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
|
127
|
+
* This is different from the defaults when using the gcloud utility and is different from
|
|
128
|
+
* the fixed amount assigned in Google Cloud Functions generation 1.
|
|
129
|
+
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
|
130
|
+
* to the value "gcf_gen1"
|
|
131
|
+
*/
|
|
132
|
+
cpu?: number | 'gcf_gen1';
|
|
133
|
+
/**
|
|
134
|
+
* Connect cloud function to specified VPC connector.
|
|
135
|
+
* A value of null removes the VPC connector
|
|
136
|
+
*/
|
|
137
|
+
vpcConnector?: string | null;
|
|
138
|
+
/**
|
|
139
|
+
* Egress settings for VPC connector.
|
|
140
|
+
* A value of null turns off VPC connector egress settings
|
|
141
|
+
*/
|
|
142
|
+
vpcConnectorEgressSettings?: options.VpcEgressSetting | null;
|
|
143
|
+
/**
|
|
144
|
+
* Specific service account for the function to run as.
|
|
145
|
+
* A value of null restores the default service account.
|
|
146
|
+
*/
|
|
147
|
+
serviceAccount?: string | null;
|
|
148
|
+
/**
|
|
149
|
+
* Ingress settings which control where this function can be called from.
|
|
150
|
+
* A value of null turns off ingress settings.
|
|
151
|
+
*/
|
|
152
|
+
ingressSettings?: options.IngressSetting | null;
|
|
153
|
+
/**
|
|
154
|
+
* User labels to set on the function.
|
|
155
|
+
*/
|
|
156
|
+
labels?: Record<string, string>;
|
|
157
|
+
secrets?: string[];
|
|
158
|
+
/** Whether failed executions should be delivered again. */
|
|
159
|
+
retry?: boolean;
|
|
53
160
|
}
|
|
54
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Handle a message being published to a Pub/Sub topic.
|
|
163
|
+
* @param topic - The Pub/Sub topic to watch for message events.
|
|
164
|
+
* @param handler - runs every time a Cloud Pub/Sub message is published
|
|
165
|
+
* @typeParam T - Type representing `Message.data`'s JSON format
|
|
166
|
+
*/
|
|
55
167
|
export declare function onMessagePublished<T = any>(topic: string, handler: (event: CloudEvent<MessagePublishedData<T>>) => any | Promise<any>): CloudFunction<CloudEvent<MessagePublishedData<T>>>;
|
|
56
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Handle a message being published to a Pub/Sub topic.
|
|
170
|
+
* @param options - Option containing information (topic) for event
|
|
171
|
+
* @param handler - runs every time a Cloud Pub/Sub message is published
|
|
172
|
+
* @typeParam T - Type representing `Message.data`'s JSON format
|
|
173
|
+
*/
|
|
57
174
|
export declare function onMessagePublished<T = any>(options: PubSubOptions, handler: (event: CloudEvent<MessagePublishedData<T>>) => any | Promise<any>): CloudFunction<CloudEvent<MessagePublishedData<T>>>;
|
|
@@ -1,14 +1,64 @@
|
|
|
1
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.
|
|
2
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
24
|
exports.onMessagePublished = exports.Message = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* Cloud functions to handle events from Google Cloud Pub/Sub.
|
|
27
|
+
* @packageDocumentation
|
|
28
|
+
*/
|
|
4
29
|
const encoding_1 = require("../../common/encoding");
|
|
5
30
|
const options = require("../options");
|
|
31
|
+
/**
|
|
32
|
+
* Google Cloud Pub/Sub is a globally distributed message bus that automatically scales as you need it.
|
|
33
|
+
* You can create a function ({@link onMessagePublished}) that handles pub/sub events by using functions.pubsub.
|
|
34
|
+
*
|
|
35
|
+
* This function triggers whenever a new pub/sub message is sent to a specific topic.
|
|
36
|
+
* You must specify the Pub/Sub topic name that you want to trigger your function, and set the event within the
|
|
37
|
+
* onPublish() event handler.
|
|
38
|
+
*
|
|
39
|
+
* PubSub Topic:
|
|
40
|
+
* <ul>
|
|
41
|
+
* <li>A resource that you can publish messages to and then consume those messages via subscriptions.
|
|
42
|
+
* <li>An isolated data stream for pub/sub messages.
|
|
43
|
+
* <li>Messages are published to a topic.
|
|
44
|
+
* <li>Messages are listened to via a subscription.
|
|
45
|
+
* <li>Each subscription listens to the messages published to exactly one topic.
|
|
46
|
+
*
|
|
47
|
+
* Subscriptions - Resource that listens to the messages published by exactly one topic.
|
|
48
|
+
*
|
|
49
|
+
* [More info here](https://firebase.google.com/docs/functions/pubsub-events)
|
|
50
|
+
*/
|
|
6
51
|
/**
|
|
7
52
|
* Interface representing a Google Cloud Pub/Sub message.
|
|
8
53
|
*
|
|
9
|
-
* @param data Payload of a Pub/Sub message.
|
|
54
|
+
* @param data - Payload of a Pub/Sub message.
|
|
55
|
+
* @typeParam T - Type representing `Message.data`'s JSON format
|
|
10
56
|
*/
|
|
11
57
|
class Message {
|
|
58
|
+
/**
|
|
59
|
+
* @hidden
|
|
60
|
+
* @alpha
|
|
61
|
+
*/
|
|
12
62
|
constructor(data) {
|
|
13
63
|
this.messageId = data.messageId;
|
|
14
64
|
this.data = data.data;
|
|
@@ -34,7 +84,7 @@ class Message {
|
|
|
34
84
|
/**
|
|
35
85
|
* Returns a JSON-serializable representation of this object.
|
|
36
86
|
*
|
|
37
|
-
* @
|
|
87
|
+
* @returns A JSON-serializable representation of this object.
|
|
38
88
|
*/
|
|
39
89
|
toJSON() {
|
|
40
90
|
const json = {
|
|
@@ -52,6 +102,12 @@ class Message {
|
|
|
52
102
|
}
|
|
53
103
|
}
|
|
54
104
|
exports.Message = Message;
|
|
105
|
+
/**
|
|
106
|
+
* Handle a message being published to a Pub/Sub topic.
|
|
107
|
+
* @param topicOrOptions - A string representing the PubSub topic or an option (which contains the topic)
|
|
108
|
+
* @param handler - runs every time a Cloud Pub/Sub message is published
|
|
109
|
+
* @typeParam T - Type representing `Message.data`'s JSON format
|
|
110
|
+
*/
|
|
55
111
|
function onMessagePublished(topicOrOptions, handler) {
|
|
56
112
|
let topic;
|
|
57
113
|
let opts;
|
|
@@ -148,27 +148,215 @@ export interface CustomerEncryption {
|
|
|
148
148
|
*/
|
|
149
149
|
keySha256?: string;
|
|
150
150
|
}
|
|
151
|
+
/** A CloudEvent that contains StorageObjectData */
|
|
151
152
|
export interface StorageEvent extends CloudEvent<StorageObjectData> {
|
|
152
153
|
/** The name of the bucket containing this object. */
|
|
153
154
|
bucket: string;
|
|
154
155
|
}
|
|
155
156
|
/** StorageOptions extend EventHandlerOptions with a bucket name */
|
|
156
157
|
export interface StorageOptions extends options.EventHandlerOptions {
|
|
158
|
+
/** The name of the bucket containing this object. */
|
|
157
159
|
bucket?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Region where functions should be deployed.
|
|
162
|
+
*/
|
|
163
|
+
region?: options.SupportedRegion | string;
|
|
164
|
+
/**
|
|
165
|
+
* Amount of memory to allocate to a function.
|
|
166
|
+
* A value of null restores the defaults of 256MB.
|
|
167
|
+
*/
|
|
168
|
+
memory?: options.MemoryOption | null;
|
|
169
|
+
/**
|
|
170
|
+
* Timeout for the function in sections, possible values are 0 to 540.
|
|
171
|
+
* HTTPS functions can specify a higher timeout.
|
|
172
|
+
* A value of null restores the default of 60s
|
|
173
|
+
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
|
174
|
+
* function depends on the type of function: Event handling functions have a
|
|
175
|
+
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
|
176
|
+
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
177
|
+
* timeout of 1,800s (30 minutes)
|
|
178
|
+
*/
|
|
179
|
+
timeoutSeconds?: number | null;
|
|
180
|
+
/**
|
|
181
|
+
* Min number of actual instances to be running at a given time.
|
|
182
|
+
* Instances will be billed for memory allocation and 10% of CPU allocation
|
|
183
|
+
* while idle.
|
|
184
|
+
* A value of null restores the default min instances.
|
|
185
|
+
*/
|
|
186
|
+
minInstances?: number | null;
|
|
187
|
+
/**
|
|
188
|
+
* Max number of instances to be running in parallel.
|
|
189
|
+
* A value of null restores the default max instances.
|
|
190
|
+
*/
|
|
191
|
+
maxInstances?: number | null;
|
|
192
|
+
/**
|
|
193
|
+
* Number of requests a function can serve at once.
|
|
194
|
+
* Can only be applied to functions running on Cloud Functions v2.
|
|
195
|
+
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
|
196
|
+
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
197
|
+
* The maximum value for concurrency is 1,000.
|
|
198
|
+
*/
|
|
199
|
+
concurrency?: number | null;
|
|
200
|
+
/**
|
|
201
|
+
* Fractional number of CPUs to allocate to a function.
|
|
202
|
+
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
|
203
|
+
* This is different from the defaults when using the gcloud utility and is different from
|
|
204
|
+
* the fixed amount assigned in Google Cloud Functions generation 1.
|
|
205
|
+
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
|
206
|
+
* to the value "gcf_gen1"
|
|
207
|
+
*/
|
|
208
|
+
cpu?: number | 'gcf_gen1';
|
|
209
|
+
/**
|
|
210
|
+
* Connect cloud function to specified VPC connector.
|
|
211
|
+
* A value of null removes the VPC connector
|
|
212
|
+
*/
|
|
213
|
+
vpcConnector?: string | null;
|
|
214
|
+
/**
|
|
215
|
+
* Egress settings for VPC connector.
|
|
216
|
+
* A value of null turns off VPC connector egress settings
|
|
217
|
+
*/
|
|
218
|
+
vpcConnectorEgressSettings?: options.VpcEgressSetting | null;
|
|
219
|
+
/**
|
|
220
|
+
* Specific service account for the function to run as.
|
|
221
|
+
* A value of null restores the default service account.
|
|
222
|
+
*/
|
|
223
|
+
serviceAccount?: string | null;
|
|
224
|
+
/**
|
|
225
|
+
* Ingress settings which control where this function can be called from.
|
|
226
|
+
* A value of null turns off ingress settings.
|
|
227
|
+
*/
|
|
228
|
+
ingressSettings?: options.IngressSetting | null;
|
|
229
|
+
/**
|
|
230
|
+
* User labels to set on the function.
|
|
231
|
+
*/
|
|
232
|
+
labels?: Record<string, string>;
|
|
233
|
+
secrets?: string[];
|
|
234
|
+
/** Whether failed executions should be delivered again. */
|
|
235
|
+
retry?: boolean;
|
|
158
236
|
}
|
|
159
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* Event handler sent only when a bucket has enabled object versioning.
|
|
239
|
+
* This event indicates that the live version of an object has become an
|
|
240
|
+
* archived version, either because it was archived or because it was
|
|
241
|
+
* overwritten by the upload of an object of the same name.
|
|
242
|
+
*
|
|
243
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
|
|
244
|
+
*/
|
|
160
245
|
export declare function onObjectArchived(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
246
|
+
/**
|
|
247
|
+
* Event handler sent only when a bucket has enabled object versioning.
|
|
248
|
+
* This event indicates that the live version of an object has become an
|
|
249
|
+
* archived version, either because it was archived or because it was
|
|
250
|
+
* overwritten by the upload of an object of the same name.
|
|
251
|
+
*
|
|
252
|
+
* @param bucket - The name of the bucket containing this object.
|
|
253
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
|
|
254
|
+
*/
|
|
161
255
|
export declare function onObjectArchived(bucket: string, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
256
|
+
/**
|
|
257
|
+
* Event handler sent only when a bucket has enabled object versioning.
|
|
258
|
+
* This event indicates that the live version of an object has become an
|
|
259
|
+
* archived version, either because it was archived or because it was
|
|
260
|
+
* overwritten by the upload of an object of the same name.
|
|
261
|
+
*
|
|
262
|
+
* @param opts - Options that can be set on an individual event-handling function.
|
|
263
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
|
|
264
|
+
*/
|
|
162
265
|
export declare function onObjectArchived(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
163
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* Event handler which fires every time a Google Cloud Storage object
|
|
268
|
+
* creation occurs.
|
|
269
|
+
*
|
|
270
|
+
* Sent when a new object (or a new generation of an existing object)
|
|
271
|
+
* is successfully created in the bucket. This includes copying or rewriting
|
|
272
|
+
* an existing object. A failed upload does not trigger this event.
|
|
273
|
+
*
|
|
274
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
|
|
275
|
+
*/
|
|
164
276
|
export declare function onObjectFinalized(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
277
|
+
/**
|
|
278
|
+
* Event handler which fires every time a Google Cloud Storage object
|
|
279
|
+
* creation occurs.
|
|
280
|
+
*
|
|
281
|
+
* Sent when a new object (or a new generation of an existing object)
|
|
282
|
+
* is successfully created in the bucket. This includes copying or rewriting
|
|
283
|
+
* an existing object. A failed upload does not trigger this event.
|
|
284
|
+
*
|
|
285
|
+
* @param bucket - The name of the bucket containing this object.
|
|
286
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
|
|
287
|
+
*/
|
|
165
288
|
export declare function onObjectFinalized(bucket: string, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
289
|
+
/**
|
|
290
|
+
* Event handler which fires every time a Google Cloud Storage object
|
|
291
|
+
* creation occurs.
|
|
292
|
+
*
|
|
293
|
+
* Sent when a new object (or a new generation of an existing object)
|
|
294
|
+
* is successfully created in the bucket. This includes copying or rewriting
|
|
295
|
+
* an existing object. A failed upload does not trigger this event.
|
|
296
|
+
*
|
|
297
|
+
* @param opts - Options that can be set on an individual event-handling function.
|
|
298
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
|
|
299
|
+
*/
|
|
166
300
|
export declare function onObjectFinalized(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
167
|
-
/**
|
|
301
|
+
/**
|
|
302
|
+
* Event handler which fires every time a Google Cloud Storage deletion occurs.
|
|
303
|
+
*
|
|
304
|
+
* Sent when an object has been permanently deleted. This includes objects
|
|
305
|
+
* that are overwritten or are deleted as part of the bucket's lifecycle
|
|
306
|
+
* configuration. For buckets with object versioning enabled, this is not
|
|
307
|
+
* sent when an object is archived, even if archival occurs
|
|
308
|
+
* via the `storage.objects.delete` method.
|
|
309
|
+
*
|
|
310
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
|
|
311
|
+
*/
|
|
168
312
|
export declare function onObjectDeleted(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
313
|
+
/**
|
|
314
|
+
* Event handler which fires every time a Google Cloud Storage deletion occurs.
|
|
315
|
+
*
|
|
316
|
+
* Sent when an object has been permanently deleted. This includes objects
|
|
317
|
+
* that are overwritten or are deleted as part of the bucket's lifecycle
|
|
318
|
+
* configuration. For buckets with object versioning enabled, this is not
|
|
319
|
+
* sent when an object is archived, even if archival occurs
|
|
320
|
+
* via the `storage.objects.delete` method.
|
|
321
|
+
*
|
|
322
|
+
* @param bucket - The name of the bucket containing this object.
|
|
323
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
|
|
324
|
+
*/
|
|
169
325
|
export declare function onObjectDeleted(bucket: string, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
326
|
+
/**
|
|
327
|
+
* Event handler which fires every time a Google Cloud Storage deletion occurs.
|
|
328
|
+
*
|
|
329
|
+
* Sent when an object has been permanently deleted. This includes objects
|
|
330
|
+
* that are overwritten or are deleted as part of the bucket's lifecycle
|
|
331
|
+
* configuration. For buckets with object versioning enabled, this is not
|
|
332
|
+
* sent when an object is archived, even if archival occurs
|
|
333
|
+
* via the `storage.objects.delete` method.
|
|
334
|
+
*
|
|
335
|
+
* @param opts - Options that can be set on an individual event-handling function.
|
|
336
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
|
|
337
|
+
*/
|
|
170
338
|
export declare function onObjectDeleted(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
171
|
-
/**
|
|
339
|
+
/**
|
|
340
|
+
* Event handler which fires every time the metadata of an existing object
|
|
341
|
+
* changes.
|
|
342
|
+
*
|
|
343
|
+
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
|
|
344
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
|
|
345
|
+
*/
|
|
172
346
|
export declare function onObjectMetadataUpdated(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
347
|
+
/**
|
|
348
|
+
* Event handler which fires every time the metadata of an existing object
|
|
349
|
+
* changes.
|
|
350
|
+
*
|
|
351
|
+
* @param bucket - The name of the bucket containing this object.
|
|
352
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
|
|
353
|
+
*/
|
|
173
354
|
export declare function onObjectMetadataUpdated(bucket: string, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
355
|
+
/**
|
|
356
|
+
* Event handler which fires every time the metadata of an existing object
|
|
357
|
+
* changes.
|
|
358
|
+
*
|
|
359
|
+
* @param opts - Options that can be set on an individual event-handling function.
|
|
360
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
|
|
361
|
+
*/
|
|
174
362
|
export declare function onObjectMetadataUpdated(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// The MIT License (MIT)
|
|
3
3
|
//
|
|
4
|
-
// Copyright (c)
|
|
4
|
+
// Copyright (c) 2022 Firebase
|
|
5
5
|
//
|
|
6
6
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
// of this software and associated documentation files (the "Software"), to deal
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.getOptsAndBucket = exports.onOperation = exports.onObjectMetadataUpdated = exports.onObjectDeleted = exports.onObjectFinalized = exports.onObjectArchived = exports.metadataUpdatedEvent = exports.deletedEvent = exports.finalizedEvent = exports.archivedEvent = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* Cloud functions to handle events from Google Cloud Storage.
|
|
27
|
+
* @packageDocumentation
|
|
28
|
+
*/
|
|
25
29
|
const encoding_1 = require("../../common/encoding");
|
|
26
30
|
const config_1 = require("../../config");
|
|
27
31
|
const options = require("../options");
|
|
@@ -33,20 +37,59 @@ exports.finalizedEvent = 'google.cloud.storage.object.v1.finalized';
|
|
|
33
37
|
exports.deletedEvent = 'google.cloud.storage.object.v1.deleted';
|
|
34
38
|
/** @internal */
|
|
35
39
|
exports.metadataUpdatedEvent = 'google.cloud.storage.object.v1.metadataUpdated';
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Event handler sent only when a bucket has enabled object versioning.
|
|
42
|
+
* This event indicates that the live version of an object has become an
|
|
43
|
+
* archived version, either because it was archived or because it was
|
|
44
|
+
* overwritten by the upload of an object of the same name.
|
|
45
|
+
*
|
|
46
|
+
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
|
|
47
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
|
|
48
|
+
*/
|
|
49
|
+
function onObjectArchived(bucketOrOptsOrHandler, handler) {
|
|
50
|
+
return onOperation(exports.archivedEvent, bucketOrOptsOrHandler, handler);
|
|
38
51
|
}
|
|
39
52
|
exports.onObjectArchived = onObjectArchived;
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Event handler which fires every time a Google Cloud Storage object
|
|
55
|
+
* creation occurs.
|
|
56
|
+
*
|
|
57
|
+
* Sent when a new object (or a new generation of an existing object)
|
|
58
|
+
* is successfully created in the bucket. This includes copying or rewriting
|
|
59
|
+
* an existing object. A failed upload does not trigger this event.
|
|
60
|
+
*
|
|
61
|
+
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
|
|
62
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
|
|
63
|
+
*/
|
|
64
|
+
function onObjectFinalized(bucketOrOptsOrHandler, handler) {
|
|
65
|
+
return onOperation(exports.finalizedEvent, bucketOrOptsOrHandler, handler);
|
|
42
66
|
}
|
|
43
67
|
exports.onObjectFinalized = onObjectFinalized;
|
|
44
|
-
|
|
45
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Event handler which fires every time a Google Cloud Storage deletion occurs.
|
|
70
|
+
*
|
|
71
|
+
* Sent when an object has been permanently deleted. This includes objects
|
|
72
|
+
* that are overwritten or are deleted as part of the bucket's lifecycle
|
|
73
|
+
* configuration. For buckets with object versioning enabled, this is not
|
|
74
|
+
* sent when an object is archived, even if archival occurs
|
|
75
|
+
* via the `storage.objects.delete` method.
|
|
76
|
+
*
|
|
77
|
+
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
|
|
78
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
|
|
79
|
+
*/
|
|
80
|
+
function onObjectDeleted(bucketOrOptsOrHandler, handler) {
|
|
81
|
+
return onOperation(exports.deletedEvent, bucketOrOptsOrHandler, handler);
|
|
46
82
|
}
|
|
47
83
|
exports.onObjectDeleted = onObjectDeleted;
|
|
48
|
-
|
|
49
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Event handler which fires every time the metadata of an existing object
|
|
86
|
+
* changes.
|
|
87
|
+
*
|
|
88
|
+
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
|
|
89
|
+
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
|
|
90
|
+
*/
|
|
91
|
+
function onObjectMetadataUpdated(bucketOrOptsOrHandler, handler) {
|
|
92
|
+
return onOperation(exports.metadataUpdatedEvent, bucketOrOptsOrHandler, handler);
|
|
50
93
|
}
|
|
51
94
|
exports.onObjectMetadataUpdated = onObjectMetadataUpdated;
|
|
52
95
|
/** @internal */
|