firebase-functions 3.24.1 → 4.0.0-rc.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/README.md +7 -9
- package/lib/bin/firebase-functions.js +13 -15
- package/lib/common/app.d.ts +14 -0
- package/lib/common/app.js +62 -0
- package/lib/common/change.d.ts +0 -5
- package/lib/common/change.js +5 -7
- package/lib/common/config.d.ts +6 -0
- package/lib/common/config.js +49 -0
- package/lib/common/debug.js +2 -2
- package/lib/common/encoding.d.ts +0 -8
- package/lib/common/encoding.js +6 -29
- package/lib/common/options.d.ts +14 -0
- package/lib/common/options.js +44 -0
- package/lib/common/params.d.ts +32 -0
- package/lib/common/params.js +23 -0
- package/lib/common/providers/database.d.ts +17 -19
- package/lib/common/providers/database.js +68 -39
- package/lib/common/providers/https.d.ts +11 -52
- package/lib/common/providers/https.js +115 -110
- package/lib/common/providers/identity.d.ts +8 -8
- package/lib/common/providers/identity.js +71 -79
- package/lib/common/providers/tasks.d.ts +11 -10
- package/lib/common/providers/tasks.js +10 -9
- package/lib/common/timezone.js +538 -538
- package/lib/common/trace.d.ts +14 -0
- package/lib/common/trace.js +69 -0
- package/lib/{encoder.d.ts → common/utilities/encoder.d.ts} +0 -0
- package/lib/{encoder.js → common/utilities/encoder.js} +1 -1
- package/lib/{utilities → common/utilities}/path-pattern.d.ts +0 -0
- package/lib/{utilities → common/utilities}/path-pattern.js +17 -16
- package/lib/{utilities → common/utilities}/path.d.ts +0 -0
- package/lib/{utilities → common/utilities}/path.js +5 -7
- package/lib/{utils.d.ts → common/utilities/utils.d.ts} +1 -1
- package/lib/{utils.js → common/utilities/utils.js} +18 -12
- package/lib/logger/common.d.ts +1 -3
- package/lib/logger/common.js +9 -14
- package/lib/logger/compat.js +9 -9
- package/lib/logger/index.d.ts +1 -1
- package/lib/logger/index.js +24 -30
- package/lib/{v2/params → params}/index.d.ts +22 -9
- package/lib/{v2/params → params}/index.js +22 -14
- package/lib/params/types.d.ts +180 -0
- package/lib/params/types.js +289 -0
- package/lib/runtime/loader.js +12 -14
- package/lib/runtime/manifest.d.ts +56 -24
- package/lib/runtime/manifest.js +114 -4
- package/lib/v1/cloud-functions.d.ts +232 -0
- package/lib/v1/cloud-functions.js +205 -0
- package/lib/v1/config.d.ts +8 -0
- package/lib/v1/config.js +75 -0
- package/lib/{function-builder.d.ts → v1/function-builder.d.ts} +16 -16
- package/lib/{function-builder.js → v1/function-builder.js} +56 -46
- package/lib/v1/function-configuration.d.ts +197 -0
- package/lib/v1/function-configuration.js +70 -0
- package/lib/v1/index.d.ts +20 -0
- package/lib/{index.js → v1/index.js} +5 -10
- package/lib/{providers → v1/providers}/analytics.d.ts +5 -11
- package/lib/{providers → v1/providers}/analytics.js +49 -43
- package/lib/{providers → v1/providers}/auth.d.ts +28 -18
- package/lib/{providers → v1/providers}/auth.js +45 -34
- package/lib/{providers → v1/providers}/database.d.ts +25 -42
- package/lib/{providers → v1/providers}/database.js +46 -46
- package/lib/{providers → v1/providers}/firestore.d.ts +15 -33
- package/lib/{providers → v1/providers}/firestore.js +40 -44
- package/lib/{providers → v1/providers}/https.d.ts +3 -8
- package/lib/{providers → v1/providers}/https.js +14 -22
- package/lib/{providers → v1/providers}/pubsub.d.ts +8 -16
- package/lib/{providers → v1/providers}/pubsub.js +22 -26
- package/lib/{providers → v1/providers}/remoteConfig.d.ts +2 -11
- package/lib/{providers → v1/providers}/remoteConfig.js +9 -9
- package/lib/{providers → v1/providers}/storage.d.ts +11 -26
- package/lib/{providers → v1/providers}/storage.js +24 -29
- package/lib/{providers → v1/providers}/tasks.d.ts +6 -8
- package/lib/{providers → v1/providers}/tasks.js +12 -17
- package/lib/{providers → v1/providers}/testLab.d.ts +86 -46
- package/lib/{providers → v1/providers}/testLab.js +14 -14
- package/lib/v2/core.d.ts +4 -5
- package/lib/v2/index.d.ts +16 -14
- package/lib/v2/index.js +5 -1
- package/lib/v2/options.d.ts +52 -32
- package/lib/v2/options.js +32 -47
- package/lib/v2/providers/alerts/alerts.d.ts +20 -18
- package/lib/v2/providers/alerts/alerts.js +9 -6
- package/lib/v2/providers/alerts/appDistribution.d.ts +28 -26
- package/lib/v2/providers/alerts/appDistribution.js +8 -7
- package/lib/v2/providers/alerts/billing.d.ts +5 -5
- package/lib/v2/providers/alerts/billing.js +5 -4
- package/lib/v2/providers/alerts/crashlytics.d.ts +32 -30
- package/lib/v2/providers/alerts/crashlytics.js +10 -9
- package/lib/v2/providers/alerts/index.d.ts +5 -5
- package/lib/v2/providers/alerts/performance.d.ts +3 -3
- package/lib/v2/providers/alerts/performance.js +5 -7
- package/lib/v2/providers/database.d.ts +41 -38
- package/lib/v2/providers/database.js +22 -17
- package/lib/v2/providers/eventarc.d.ts +25 -23
- package/lib/v2/providers/eventarc.js +10 -7
- package/lib/v2/providers/https.d.ts +43 -33
- package/lib/v2/providers/https.js +18 -56
- package/lib/v2/providers/identity.d.ts +25 -23
- package/lib/v2/providers/identity.js +10 -7
- package/lib/v2/providers/pubsub.d.ts +25 -23
- package/lib/v2/providers/pubsub.js +11 -27
- package/lib/v2/providers/remoteConfig.d.ts +63 -0
- package/lib/v2/providers/remoteConfig.js +65 -0
- package/lib/v2/providers/scheduler.d.ts +14 -12
- package/lib/v2/providers/scheduler.js +16 -14
- package/lib/v2/providers/storage.d.ts +32 -30
- package/lib/v2/providers/storage.js +16 -32
- package/lib/v2/providers/tasks.d.ts +30 -26
- package/lib/v2/providers/tasks.js +14 -31
- package/lib/v2/providers/testLab.d.ts +110 -0
- package/lib/v2/providers/testLab.js +65 -0
- package/lib/v2/trace.d.ts +4 -0
- package/lib/v2/trace.js +21 -0
- package/package.json +61 -66
- package/lib/apps.d.ts +0 -35
- package/lib/apps.js +0 -112
- package/lib/cloud-functions.d.ts +0 -231
- package/lib/cloud-functions.js +0 -251
- package/lib/config.d.ts +0 -24
- package/lib/config.js +0 -117
- package/lib/function-configuration.d.ts +0 -108
- package/lib/function-configuration.js +0 -71
- package/lib/handler-builder.d.ts +0 -256
- package/lib/handler-builder.js +0 -349
- package/lib/index.d.ts +0 -19
- package/lib/setup.d.ts +0 -1
- package/lib/setup.js +0 -60
- package/lib/v2/params/types.d.ts +0 -118
- package/lib/v2/params/types.js +0 -196
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { CloudFunction, EventContext } from
|
|
2
|
-
import { DeploymentOptions, ScheduleRetryConfig } from
|
|
3
|
-
/** @hidden */
|
|
4
|
-
export declare const provider = "google.pubsub";
|
|
5
|
-
/** @hidden */
|
|
6
|
-
export declare const service = "pubsub.googleapis.com";
|
|
1
|
+
import { CloudFunction, EventContext } from "../cloud-functions";
|
|
2
|
+
import { DeploymentOptions, ScheduleRetryConfig } from "../function-configuration";
|
|
7
3
|
/**
|
|
8
4
|
* Registers a Cloud Function triggered when a Google Cloud Pub/Sub message
|
|
9
5
|
* is sent to a specified topic.
|
|
@@ -12,12 +8,10 @@ export declare const service = "pubsub.googleapis.com";
|
|
|
12
8
|
* @returns Pub/Sub topic builder interface.
|
|
13
9
|
*/
|
|
14
10
|
export declare function topic(topic: string): TopicBuilder;
|
|
15
|
-
/** @hidden */
|
|
16
|
-
export declare function _topicWithOptions(topic: string, options: DeploymentOptions): TopicBuilder;
|
|
17
11
|
/**
|
|
18
12
|
* The Google Cloud Pub/Sub topic builder.
|
|
19
13
|
*
|
|
20
|
-
* Access via
|
|
14
|
+
* Access via `functions.pubsub.topic()`.
|
|
21
15
|
*/
|
|
22
16
|
export declare class TopicBuilder {
|
|
23
17
|
private triggerResource;
|
|
@@ -30,7 +24,7 @@ export declare class TopicBuilder {
|
|
|
30
24
|
*
|
|
31
25
|
* @param handler - Event handler that runs every time a Cloud Pub/Sub message
|
|
32
26
|
* is published.
|
|
33
|
-
* @
|
|
27
|
+
* @returns A function that you can export and deploy.
|
|
34
28
|
*/
|
|
35
29
|
onPublish(handler: (message: Message, context: EventContext) => PromiseLike<any> | any): CloudFunction<Message>;
|
|
36
30
|
}
|
|
@@ -38,11 +32,9 @@ export declare class TopicBuilder {
|
|
|
38
32
|
* Registers a Cloud Function to run at specified times.
|
|
39
33
|
*
|
|
40
34
|
* @param schedule - The schedule, in Unix Crontab or AppEngine syntax.
|
|
41
|
-
* @
|
|
35
|
+
* @returns ScheduleBuilder interface.
|
|
42
36
|
*/
|
|
43
37
|
export declare function schedule(schedule: string): ScheduleBuilder;
|
|
44
|
-
/** @hidden */
|
|
45
|
-
export declare function _scheduleWithOptions(schedule: string, options: DeploymentOptions): ScheduleBuilder;
|
|
46
38
|
/**
|
|
47
39
|
* The builder for scheduled functions, which are powered by
|
|
48
40
|
* Google Pub/Sub and Cloud Scheduler. Describes the Cloud Scheduler
|
|
@@ -50,7 +42,7 @@ export declare function _scheduleWithOptions(schedule: string, options: Deployme
|
|
|
50
42
|
* frequency. For more information, see
|
|
51
43
|
* [Schedule functions](/docs/functions/schedule-functions).
|
|
52
44
|
*
|
|
53
|
-
* Access via
|
|
45
|
+
* Access via `functions.pubsub.schedule()`.
|
|
54
46
|
*/
|
|
55
47
|
export declare class ScheduleBuilder {
|
|
56
48
|
private triggerResource;
|
|
@@ -65,7 +57,7 @@ export declare class ScheduleBuilder {
|
|
|
65
57
|
*
|
|
66
58
|
* @param handler - Handler that fires whenever the associated
|
|
67
59
|
* scheduler job sends a Pub/Sub message.
|
|
68
|
-
* @
|
|
60
|
+
* @returns A function that you can export and deploy.
|
|
69
61
|
*/
|
|
70
62
|
onRun(handler: (context: EventContext) => PromiseLike<any> | any): CloudFunction<unknown>;
|
|
71
63
|
}
|
|
@@ -95,7 +87,7 @@ export declare class Message {
|
|
|
95
87
|
/**
|
|
96
88
|
* Returns a JSON-serializable representation of this object.
|
|
97
89
|
*
|
|
98
|
-
* @
|
|
90
|
+
* @returns A JSON-serializable representation of this object.
|
|
99
91
|
*/
|
|
100
92
|
toJSON(): any;
|
|
101
93
|
}
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.Message = exports.ScheduleBuilder = exports._scheduleWithOptions = exports.schedule = exports.TopicBuilder = exports._topicWithOptions = exports.topic = exports.service = exports.provider = void 0;
|
|
25
25
|
const cloud_functions_1 = require("../cloud-functions");
|
|
26
|
-
/** @
|
|
27
|
-
exports.provider =
|
|
28
|
-
/** @
|
|
29
|
-
exports.service =
|
|
26
|
+
/** @internal */
|
|
27
|
+
exports.provider = "google.pubsub";
|
|
28
|
+
/** @internal */
|
|
29
|
+
exports.service = "pubsub.googleapis.com";
|
|
30
30
|
/**
|
|
31
31
|
* Registers a Cloud Function triggered when a Google Cloud Pub/Sub message
|
|
32
32
|
* is sent to a specified topic.
|
|
@@ -38,14 +38,14 @@ function topic(topic) {
|
|
|
38
38
|
return _topicWithOptions(topic, {});
|
|
39
39
|
}
|
|
40
40
|
exports.topic = topic;
|
|
41
|
-
/** @
|
|
41
|
+
/** @internal */
|
|
42
42
|
function _topicWithOptions(topic, options) {
|
|
43
|
-
if (topic.indexOf(
|
|
44
|
-
throw new Error(
|
|
43
|
+
if (topic.indexOf("/") !== -1) {
|
|
44
|
+
throw new Error("Topic name may not have a /");
|
|
45
45
|
}
|
|
46
46
|
return new TopicBuilder(() => {
|
|
47
47
|
if (!process.env.GCLOUD_PROJECT) {
|
|
48
|
-
throw new Error(
|
|
48
|
+
throw new Error("process.env.GCLOUD_PROJECT is not set.");
|
|
49
49
|
}
|
|
50
50
|
return `projects/${process.env.GCLOUD_PROJECT}/topics/${topic}`;
|
|
51
51
|
}, options);
|
|
@@ -54,7 +54,7 @@ exports._topicWithOptions = _topicWithOptions;
|
|
|
54
54
|
/**
|
|
55
55
|
* The Google Cloud Pub/Sub topic builder.
|
|
56
56
|
*
|
|
57
|
-
* Access via
|
|
57
|
+
* Access via `functions.pubsub.topic()`.
|
|
58
58
|
*/
|
|
59
59
|
class TopicBuilder {
|
|
60
60
|
/** @hidden */
|
|
@@ -68,7 +68,7 @@ class TopicBuilder {
|
|
|
68
68
|
*
|
|
69
69
|
* @param handler - Event handler that runs every time a Cloud Pub/Sub message
|
|
70
70
|
* is published.
|
|
71
|
-
* @
|
|
71
|
+
* @returns A function that you can export and deploy.
|
|
72
72
|
*/
|
|
73
73
|
onPublish(handler) {
|
|
74
74
|
return (0, cloud_functions_1.makeCloudFunction)({
|
|
@@ -76,7 +76,7 @@ class TopicBuilder {
|
|
|
76
76
|
provider: exports.provider,
|
|
77
77
|
service: exports.service,
|
|
78
78
|
triggerResource: this.triggerResource,
|
|
79
|
-
eventType:
|
|
79
|
+
eventType: "topic.publish",
|
|
80
80
|
dataConstructor: (raw) => new Message(raw.data),
|
|
81
81
|
options: this.options,
|
|
82
82
|
});
|
|
@@ -87,17 +87,17 @@ exports.TopicBuilder = TopicBuilder;
|
|
|
87
87
|
* Registers a Cloud Function to run at specified times.
|
|
88
88
|
*
|
|
89
89
|
* @param schedule - The schedule, in Unix Crontab or AppEngine syntax.
|
|
90
|
-
* @
|
|
90
|
+
* @returns ScheduleBuilder interface.
|
|
91
91
|
*/
|
|
92
92
|
function schedule(schedule) {
|
|
93
93
|
return _scheduleWithOptions(schedule, {});
|
|
94
94
|
}
|
|
95
95
|
exports.schedule = schedule;
|
|
96
|
-
/** @
|
|
96
|
+
/** @internal */
|
|
97
97
|
function _scheduleWithOptions(schedule, options) {
|
|
98
98
|
const triggerResource = () => {
|
|
99
99
|
if (!process.env.GCLOUD_PROJECT) {
|
|
100
|
-
throw new Error(
|
|
100
|
+
throw new Error("process.env.GCLOUD_PROJECT is not set.");
|
|
101
101
|
}
|
|
102
102
|
// The CLI will append the correct topic name based on region and function name
|
|
103
103
|
return `projects/${process.env.GCLOUD_PROJECT}/topics`;
|
|
@@ -115,7 +115,7 @@ exports._scheduleWithOptions = _scheduleWithOptions;
|
|
|
115
115
|
* frequency. For more information, see
|
|
116
116
|
* [Schedule functions](/docs/functions/schedule-functions).
|
|
117
117
|
*
|
|
118
|
-
* Access via
|
|
118
|
+
* Access via `functions.pubsub.schedule()`.
|
|
119
119
|
*/
|
|
120
120
|
class ScheduleBuilder {
|
|
121
121
|
/** @hidden */
|
|
@@ -137,7 +137,7 @@ class ScheduleBuilder {
|
|
|
137
137
|
*
|
|
138
138
|
* @param handler - Handler that fires whenever the associated
|
|
139
139
|
* scheduler job sends a Pub/Sub message.
|
|
140
|
-
* @
|
|
140
|
+
* @returns A function that you can export and deploy.
|
|
141
141
|
*/
|
|
142
142
|
onRun(handler) {
|
|
143
143
|
const cloudFunction = (0, cloud_functions_1.makeCloudFunction)({
|
|
@@ -145,9 +145,9 @@ class ScheduleBuilder {
|
|
|
145
145
|
provider: exports.provider,
|
|
146
146
|
service: exports.service,
|
|
147
147
|
triggerResource: this.triggerResource,
|
|
148
|
-
eventType:
|
|
148
|
+
eventType: "topic.publish",
|
|
149
149
|
options: this.options,
|
|
150
|
-
labels: {
|
|
150
|
+
labels: { "deployment-scheduled": "true" },
|
|
151
151
|
});
|
|
152
152
|
return cloudFunction;
|
|
153
153
|
}
|
|
@@ -160,25 +160,21 @@ exports.ScheduleBuilder = ScheduleBuilder;
|
|
|
160
160
|
*/
|
|
161
161
|
class Message {
|
|
162
162
|
constructor(data) {
|
|
163
|
-
[this.data, this.attributes, this._json] = [
|
|
164
|
-
data.data,
|
|
165
|
-
data.attributes || {},
|
|
166
|
-
data.json,
|
|
167
|
-
];
|
|
163
|
+
[this.data, this.attributes, this._json] = [data.data, data.attributes || {}, data.json];
|
|
168
164
|
}
|
|
169
165
|
/**
|
|
170
166
|
* The JSON data payload of this message object, if any.
|
|
171
167
|
*/
|
|
172
168
|
get json() {
|
|
173
|
-
if (typeof this._json ===
|
|
174
|
-
this._json = JSON.parse(Buffer.from(this.data,
|
|
169
|
+
if (typeof this._json === "undefined") {
|
|
170
|
+
this._json = JSON.parse(Buffer.from(this.data, "base64").toString("utf8"));
|
|
175
171
|
}
|
|
176
172
|
return this._json;
|
|
177
173
|
}
|
|
178
174
|
/**
|
|
179
175
|
* Returns a JSON-serializable representation of this object.
|
|
180
176
|
*
|
|
181
|
-
* @
|
|
177
|
+
* @returns A JSON-serializable representation of this object.
|
|
182
178
|
*/
|
|
183
179
|
toJSON() {
|
|
184
180
|
return {
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { CloudFunction, EventContext } from
|
|
2
|
-
import { DeploymentOptions } from '../function-configuration';
|
|
3
|
-
/** @hidden */
|
|
4
|
-
export declare const provider = "google.firebase.remoteconfig";
|
|
5
|
-
/** @hidden */
|
|
6
|
-
export declare const service = "firebaseremoteconfig.googleapis.com";
|
|
1
|
+
import { CloudFunction, EventContext } from "../cloud-functions";
|
|
7
2
|
/**
|
|
8
3
|
* Registers a function that triggers on Firebase Remote Config template
|
|
9
4
|
* update events.
|
|
@@ -11,17 +6,13 @@ export declare const service = "firebaseremoteconfig.googleapis.com";
|
|
|
11
6
|
* @param handler A function that takes the updated Remote Config
|
|
12
7
|
* template version metadata as an argument.
|
|
13
8
|
*
|
|
14
|
-
* @
|
|
9
|
+
* @returns A function that you can export and deploy.
|
|
15
10
|
*/
|
|
16
11
|
export declare function onUpdate(handler: (version: TemplateVersion, context: EventContext) => PromiseLike<any> | any): CloudFunction<TemplateVersion>;
|
|
17
|
-
/** @hidden */
|
|
18
|
-
export declare function _onUpdateWithOptions(handler: (version: TemplateVersion, context: EventContext) => PromiseLike<any> | any, options: DeploymentOptions): CloudFunction<TemplateVersion>;
|
|
19
12
|
/** Builder used to create Cloud Functions for Remote Config. */
|
|
20
13
|
export declare class UpdateBuilder {
|
|
21
14
|
private triggerResource;
|
|
22
15
|
private options;
|
|
23
|
-
/** @hidden */
|
|
24
|
-
constructor(triggerResource: () => string, options: DeploymentOptions);
|
|
25
16
|
/**
|
|
26
17
|
* Handle all updates (including rollbacks) that affect a Remote Config
|
|
27
18
|
* project.
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.UpdateBuilder = exports._onUpdateWithOptions = exports.onUpdate = exports.service = exports.provider = void 0;
|
|
25
25
|
const cloud_functions_1 = require("../cloud-functions");
|
|
26
|
-
/** @
|
|
27
|
-
exports.provider =
|
|
28
|
-
/** @
|
|
29
|
-
exports.service =
|
|
26
|
+
/** @internal */
|
|
27
|
+
exports.provider = "google.firebase.remoteconfig";
|
|
28
|
+
/** @internal */
|
|
29
|
+
exports.service = "firebaseremoteconfig.googleapis.com";
|
|
30
30
|
/**
|
|
31
31
|
* Registers a function that triggers on Firebase Remote Config template
|
|
32
32
|
* update events.
|
|
@@ -34,17 +34,17 @@ exports.service = 'firebaseremoteconfig.googleapis.com';
|
|
|
34
34
|
* @param handler A function that takes the updated Remote Config
|
|
35
35
|
* template version metadata as an argument.
|
|
36
36
|
*
|
|
37
|
-
* @
|
|
37
|
+
* @returns A function that you can export and deploy.
|
|
38
38
|
*/
|
|
39
39
|
function onUpdate(handler) {
|
|
40
40
|
return _onUpdateWithOptions(handler, {});
|
|
41
41
|
}
|
|
42
42
|
exports.onUpdate = onUpdate;
|
|
43
|
-
/** @
|
|
43
|
+
/** @internal */
|
|
44
44
|
function _onUpdateWithOptions(handler, options) {
|
|
45
45
|
const triggerResource = () => {
|
|
46
46
|
if (!process.env.GCLOUD_PROJECT) {
|
|
47
|
-
throw new Error(
|
|
47
|
+
throw new Error("process.env.GCLOUD_PROJECT is not set.");
|
|
48
48
|
}
|
|
49
49
|
return `projects/${process.env.GCLOUD_PROJECT}`;
|
|
50
50
|
};
|
|
@@ -53,7 +53,7 @@ function _onUpdateWithOptions(handler, options) {
|
|
|
53
53
|
exports._onUpdateWithOptions = _onUpdateWithOptions;
|
|
54
54
|
/** Builder used to create Cloud Functions for Remote Config. */
|
|
55
55
|
class UpdateBuilder {
|
|
56
|
-
/** @
|
|
56
|
+
/** @internal */
|
|
57
57
|
constructor(triggerResource, options) {
|
|
58
58
|
this.triggerResource = triggerResource;
|
|
59
59
|
this.options = options;
|
|
@@ -70,7 +70,7 @@ class UpdateBuilder {
|
|
|
70
70
|
provider: exports.provider,
|
|
71
71
|
service: exports.service,
|
|
72
72
|
triggerResource: this.triggerResource,
|
|
73
|
-
eventType:
|
|
73
|
+
eventType: "update",
|
|
74
74
|
options: this.options,
|
|
75
75
|
});
|
|
76
76
|
}
|
|
@@ -1,43 +1,32 @@
|
|
|
1
|
-
import { CloudFunction, EventContext } from
|
|
2
|
-
import { DeploymentOptions } from '../function-configuration';
|
|
3
|
-
/** @hidden */
|
|
4
|
-
export declare const provider = "google.storage";
|
|
5
|
-
/** @hidden */
|
|
6
|
-
export declare const service = "storage.googleapis.com";
|
|
1
|
+
import { CloudFunction, EventContext } from "../cloud-functions";
|
|
7
2
|
/**
|
|
8
3
|
* Registers a Cloud Function scoped to a specific storage bucket.
|
|
9
4
|
*
|
|
10
5
|
* @param bucket Name of the bucket to which this Cloud Function is
|
|
11
6
|
* scoped.
|
|
12
7
|
*
|
|
13
|
-
* @
|
|
8
|
+
* @returns Storage bucket builder interface.
|
|
14
9
|
*/
|
|
15
10
|
export declare function bucket(bucket?: string): BucketBuilder;
|
|
16
11
|
/**
|
|
17
12
|
* Registers a Cloud Function scoped to the default storage bucket for the
|
|
18
13
|
* project.
|
|
19
14
|
*
|
|
20
|
-
* @
|
|
15
|
+
* @returns Storage object builder interface.
|
|
21
16
|
*/
|
|
22
17
|
export declare function object(): ObjectBuilder;
|
|
23
|
-
/** @hidden */
|
|
24
|
-
export declare function _bucketWithOptions(options: DeploymentOptions, bucket?: string): BucketBuilder;
|
|
25
|
-
/** @hidden */
|
|
26
|
-
export declare function _objectWithOptions(options: DeploymentOptions): ObjectBuilder;
|
|
27
18
|
/**
|
|
28
19
|
* The Google Cloud Storage bucket builder interface.
|
|
29
20
|
*
|
|
30
|
-
* Access via
|
|
21
|
+
* Access via `functions.storage.bucket()`.
|
|
31
22
|
*/
|
|
32
23
|
export declare class BucketBuilder {
|
|
33
24
|
private triggerResource;
|
|
34
25
|
private options;
|
|
35
|
-
/** @hidden */
|
|
36
|
-
constructor(triggerResource: () => string, options: DeploymentOptions);
|
|
37
26
|
/**
|
|
38
27
|
* Event handler which fires every time a Google Cloud Storage change occurs.
|
|
39
28
|
*
|
|
40
|
-
* @
|
|
29
|
+
* @returns Storage object builder interface scoped to the specified storage
|
|
41
30
|
* bucket.
|
|
42
31
|
*/
|
|
43
32
|
object(): ObjectBuilder;
|
|
@@ -45,15 +34,11 @@ export declare class BucketBuilder {
|
|
|
45
34
|
/**
|
|
46
35
|
* The Google Cloud Storage object builder interface.
|
|
47
36
|
*
|
|
48
|
-
* Access via
|
|
37
|
+
* Access via `functions.storage.object()`.
|
|
49
38
|
*/
|
|
50
39
|
export declare class ObjectBuilder {
|
|
51
40
|
private triggerResource;
|
|
52
41
|
private options;
|
|
53
|
-
/** @hidden */
|
|
54
|
-
constructor(triggerResource: () => string, options: DeploymentOptions);
|
|
55
|
-
/** @hidden */
|
|
56
|
-
onChange(handler: any): Error;
|
|
57
42
|
/**
|
|
58
43
|
* Event handler sent only when a bucket has enabled object versioning.
|
|
59
44
|
* This event indicates that the live version of an object has become an
|
|
@@ -63,7 +48,7 @@ export declare class ObjectBuilder {
|
|
|
63
48
|
* @param handler Event handler which is run every time a Google Cloud Storage
|
|
64
49
|
* archival occurs.
|
|
65
50
|
*
|
|
66
|
-
* @
|
|
51
|
+
* @returns A function which you can export and deploy.
|
|
67
52
|
*/
|
|
68
53
|
onArchive(handler: (object: ObjectMetadata, context: EventContext) => PromiseLike<any> | any): CloudFunction<ObjectMetadata>;
|
|
69
54
|
/**
|
|
@@ -78,7 +63,7 @@ export declare class ObjectBuilder {
|
|
|
78
63
|
* @param handler Event handler which is run every time a Google Cloud Storage
|
|
79
64
|
* deletion occurs.
|
|
80
65
|
*
|
|
81
|
-
* @
|
|
66
|
+
* @returns A function which you can export and deploy.
|
|
82
67
|
*/
|
|
83
68
|
onDelete(handler: (object: ObjectMetadata, context: EventContext) => PromiseLike<any> | any): CloudFunction<ObjectMetadata>;
|
|
84
69
|
/**
|
|
@@ -92,7 +77,7 @@ export declare class ObjectBuilder {
|
|
|
92
77
|
* @param handler Event handler which is run every time a Google Cloud Storage
|
|
93
78
|
* object creation occurs.
|
|
94
79
|
*
|
|
95
|
-
* @
|
|
80
|
+
* @returns A function which you can export and deploy.
|
|
96
81
|
*/
|
|
97
82
|
onFinalize(handler: (object: ObjectMetadata, context: EventContext) => PromiseLike<any> | any): CloudFunction<ObjectMetadata>;
|
|
98
83
|
/**
|
|
@@ -102,7 +87,7 @@ export declare class ObjectBuilder {
|
|
|
102
87
|
* @param handler Event handler which is run every time a Google Cloud Storage
|
|
103
88
|
* metadata update occurs.
|
|
104
89
|
*
|
|
105
|
-
* @
|
|
90
|
+
* @returns A function which you can export and deploy.
|
|
106
91
|
*/
|
|
107
92
|
onMetadataUpdate(handler: (object: ObjectMetadata, context: EventContext) => PromiseLike<any> | any): CloudFunction<ObjectMetadata>;
|
|
108
93
|
/** @hidden */
|
|
@@ -134,7 +119,7 @@ export interface ObjectMetadata {
|
|
|
134
119
|
updated: string;
|
|
135
120
|
/** Link to access the object, assuming you have sufficient permissions. */
|
|
136
121
|
selfLink?: string;
|
|
137
|
-
/**The object's name. */
|
|
122
|
+
/** The object's name. */
|
|
138
123
|
name?: string;
|
|
139
124
|
/**
|
|
140
125
|
* Generation version number that changes each time the object is
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.ObjectBuilder = exports.BucketBuilder = exports._objectWithOptions = exports._bucketWithOptions = exports.object = exports.bucket = exports.service = exports.provider = void 0;
|
|
25
|
+
const config_1 = require("../../common/config");
|
|
25
26
|
const cloud_functions_1 = require("../cloud-functions");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
exports.service = 'storage.googleapis.com';
|
|
27
|
+
/** @internal */
|
|
28
|
+
exports.provider = "google.storage";
|
|
29
|
+
/** @internal */
|
|
30
|
+
exports.service = "storage.googleapis.com";
|
|
31
31
|
/**
|
|
32
32
|
* Registers a Cloud Function scoped to a specific storage bucket.
|
|
33
33
|
*
|
|
34
34
|
* @param bucket Name of the bucket to which this Cloud Function is
|
|
35
35
|
* scoped.
|
|
36
36
|
*
|
|
37
|
-
* @
|
|
37
|
+
* @returns Storage bucket builder interface.
|
|
38
38
|
*/
|
|
39
39
|
function bucket(bucket) {
|
|
40
40
|
return _bucketWithOptions({}, bucket);
|
|
@@ -44,19 +44,19 @@ exports.bucket = bucket;
|
|
|
44
44
|
* Registers a Cloud Function scoped to the default storage bucket for the
|
|
45
45
|
* project.
|
|
46
46
|
*
|
|
47
|
-
* @
|
|
47
|
+
* @returns Storage object builder interface.
|
|
48
48
|
*/
|
|
49
49
|
function object() {
|
|
50
50
|
return _objectWithOptions({});
|
|
51
51
|
}
|
|
52
52
|
exports.object = object;
|
|
53
|
-
/** @
|
|
53
|
+
/** @internal */
|
|
54
54
|
function _bucketWithOptions(options, bucket) {
|
|
55
55
|
const resourceGetter = () => {
|
|
56
56
|
bucket = bucket || (0, config_1.firebaseConfig)().storageBucket;
|
|
57
57
|
if (!bucket) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
|
|
58
|
+
throw new Error("Missing bucket name. If you are unit testing, please provide a bucket name" +
|
|
59
|
+
" through `functions.storage.bucket(bucketName)`, or set process.env.FIREBASE_CONFIG.");
|
|
60
60
|
}
|
|
61
61
|
if (!/^[a-z\d][a-z\d\\._-]{1,230}[a-z\d]$/.test(bucket)) {
|
|
62
62
|
throw new Error(`Invalid bucket name ${bucket}`);
|
|
@@ -66,7 +66,7 @@ function _bucketWithOptions(options, bucket) {
|
|
|
66
66
|
return new BucketBuilder(resourceGetter, options);
|
|
67
67
|
}
|
|
68
68
|
exports._bucketWithOptions = _bucketWithOptions;
|
|
69
|
-
/** @
|
|
69
|
+
/** @internal */
|
|
70
70
|
function _objectWithOptions(options) {
|
|
71
71
|
return _bucketWithOptions(options).object();
|
|
72
72
|
}
|
|
@@ -74,10 +74,10 @@ exports._objectWithOptions = _objectWithOptions;
|
|
|
74
74
|
/**
|
|
75
75
|
* The Google Cloud Storage bucket builder interface.
|
|
76
76
|
*
|
|
77
|
-
* Access via
|
|
77
|
+
* Access via `functions.storage.bucket()`.
|
|
78
78
|
*/
|
|
79
79
|
class BucketBuilder {
|
|
80
|
-
/** @
|
|
80
|
+
/** @internal */
|
|
81
81
|
constructor(triggerResource, options) {
|
|
82
82
|
this.triggerResource = triggerResource;
|
|
83
83
|
this.options = options;
|
|
@@ -85,7 +85,7 @@ class BucketBuilder {
|
|
|
85
85
|
/**
|
|
86
86
|
* Event handler which fires every time a Google Cloud Storage change occurs.
|
|
87
87
|
*
|
|
88
|
-
* @
|
|
88
|
+
* @returns Storage object builder interface scoped to the specified storage
|
|
89
89
|
* bucket.
|
|
90
90
|
*/
|
|
91
91
|
object() {
|
|
@@ -96,19 +96,14 @@ exports.BucketBuilder = BucketBuilder;
|
|
|
96
96
|
/**
|
|
97
97
|
* The Google Cloud Storage object builder interface.
|
|
98
98
|
*
|
|
99
|
-
* Access via
|
|
99
|
+
* Access via `functions.storage.object()`.
|
|
100
100
|
*/
|
|
101
101
|
class ObjectBuilder {
|
|
102
|
-
/** @
|
|
102
|
+
/** @internal */
|
|
103
103
|
constructor(triggerResource, options) {
|
|
104
104
|
this.triggerResource = triggerResource;
|
|
105
105
|
this.options = options;
|
|
106
106
|
}
|
|
107
|
-
/** @hidden */
|
|
108
|
-
onChange(handler) {
|
|
109
|
-
throw new Error('"onChange" is now deprecated, please use "onArchive", "onDelete", ' +
|
|
110
|
-
'"onFinalize", or "onMetadataUpdate".');
|
|
111
|
-
}
|
|
112
107
|
/**
|
|
113
108
|
* Event handler sent only when a bucket has enabled object versioning.
|
|
114
109
|
* This event indicates that the live version of an object has become an
|
|
@@ -118,10 +113,10 @@ class ObjectBuilder {
|
|
|
118
113
|
* @param handler Event handler which is run every time a Google Cloud Storage
|
|
119
114
|
* archival occurs.
|
|
120
115
|
*
|
|
121
|
-
* @
|
|
116
|
+
* @returns A function which you can export and deploy.
|
|
122
117
|
*/
|
|
123
118
|
onArchive(handler) {
|
|
124
|
-
return this.onOperation(handler,
|
|
119
|
+
return this.onOperation(handler, "object.archive");
|
|
125
120
|
}
|
|
126
121
|
/**
|
|
127
122
|
* Event handler which fires every time a Google Cloud Storage deletion occurs.
|
|
@@ -135,10 +130,10 @@ class ObjectBuilder {
|
|
|
135
130
|
* @param handler Event handler which is run every time a Google Cloud Storage
|
|
136
131
|
* deletion occurs.
|
|
137
132
|
*
|
|
138
|
-
* @
|
|
133
|
+
* @returns A function which you can export and deploy.
|
|
139
134
|
*/
|
|
140
135
|
onDelete(handler) {
|
|
141
|
-
return this.onOperation(handler,
|
|
136
|
+
return this.onOperation(handler, "object.delete");
|
|
142
137
|
}
|
|
143
138
|
/**
|
|
144
139
|
* Event handler which fires every time a Google Cloud Storage object
|
|
@@ -151,10 +146,10 @@ class ObjectBuilder {
|
|
|
151
146
|
* @param handler Event handler which is run every time a Google Cloud Storage
|
|
152
147
|
* object creation occurs.
|
|
153
148
|
*
|
|
154
|
-
* @
|
|
149
|
+
* @returns A function which you can export and deploy.
|
|
155
150
|
*/
|
|
156
151
|
onFinalize(handler) {
|
|
157
|
-
return this.onOperation(handler,
|
|
152
|
+
return this.onOperation(handler, "object.finalize");
|
|
158
153
|
}
|
|
159
154
|
/**
|
|
160
155
|
* Event handler which fires every time the metadata of an existing object
|
|
@@ -163,10 +158,10 @@ class ObjectBuilder {
|
|
|
163
158
|
* @param handler Event handler which is run every time a Google Cloud Storage
|
|
164
159
|
* metadata update occurs.
|
|
165
160
|
*
|
|
166
|
-
* @
|
|
161
|
+
* @returns A function which you can export and deploy.
|
|
167
162
|
*/
|
|
168
163
|
onMetadataUpdate(handler) {
|
|
169
|
-
return this.onOperation(handler,
|
|
164
|
+
return this.onOperation(handler, "object.metadataUpdate");
|
|
170
165
|
}
|
|
171
166
|
/** @hidden */
|
|
172
167
|
onOperation(handler, eventType) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as express from
|
|
2
|
-
import { Request } from
|
|
3
|
-
import { RateLimits, RetryConfig, TaskContext } from
|
|
4
|
-
import { ManifestEndpoint, ManifestRequiredAPI } from
|
|
1
|
+
import * as express from "express";
|
|
2
|
+
import { Request } from "../../common/providers/https";
|
|
3
|
+
import { RateLimits, RetryConfig, TaskContext } from "../../common/providers/tasks";
|
|
4
|
+
import { ManifestEndpoint, ManifestRequiredAPI } from "../../runtime/manifest";
|
|
5
5
|
export { RetryConfig, RateLimits, TaskContext };
|
|
6
6
|
/**
|
|
7
7
|
* Options for configuring the task queue to listen to.
|
|
@@ -17,7 +17,7 @@ export interface TaskQueueOptions {
|
|
|
17
17
|
* `roles/cloudtasks.enqueuer` and `roles/cloudfunctions.invoker`
|
|
18
18
|
* will have permissions.
|
|
19
19
|
*/
|
|
20
|
-
invoker?:
|
|
20
|
+
invoker?: "private" | string | string[];
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* A handler for tasks.
|
|
@@ -25,8 +25,6 @@ export interface TaskQueueOptions {
|
|
|
25
25
|
export interface TaskQueueFunction {
|
|
26
26
|
(req: Request, res: express.Response): Promise<void>;
|
|
27
27
|
/** @alpha */
|
|
28
|
-
__trigger: unknown;
|
|
29
|
-
/** @alpha */
|
|
30
28
|
__endpoint: ManifestEndpoint;
|
|
31
29
|
/** @alpha */
|
|
32
30
|
__requiredAPIs?: ManifestRequiredAPI[];
|
|
@@ -49,7 +47,7 @@ export declare class TaskQueueBuilder {
|
|
|
49
47
|
/**
|
|
50
48
|
* Creates a handler for tasks sent to a Google Cloud Tasks queue.
|
|
51
49
|
* @param handler - A callback to handle task requests.
|
|
52
|
-
* @returns A
|
|
50
|
+
* @returns A function you can export and deploy.
|
|
53
51
|
*/
|
|
54
52
|
onDispatch(handler: (data: any, context: TaskContext) => void | Promise<void>): TaskQueueFunction;
|
|
55
53
|
}
|
|
@@ -22,9 +22,10 @@
|
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.taskQueue = exports.TaskQueueBuilder = void 0;
|
|
25
|
+
const encoding_1 = require("../../common/encoding");
|
|
26
|
+
const tasks_1 = require("../../common/providers/tasks");
|
|
27
|
+
const manifest_1 = require("../../runtime/manifest");
|
|
25
28
|
const cloud_functions_1 = require("../cloud-functions");
|
|
26
|
-
const encoding_1 = require("../common/encoding");
|
|
27
|
-
const tasks_1 = require("../common/providers/tasks");
|
|
28
29
|
/**
|
|
29
30
|
* Builder for creating a `TaskQueueFunction`.
|
|
30
31
|
*/
|
|
@@ -37,7 +38,7 @@ class TaskQueueBuilder {
|
|
|
37
38
|
/**
|
|
38
39
|
* Creates a handler for tasks sent to a Google Cloud Tasks queue.
|
|
39
40
|
* @param handler - A callback to handle task requests.
|
|
40
|
-
* @returns A
|
|
41
|
+
* @returns A function you can export and deploy.
|
|
41
42
|
*/
|
|
42
43
|
onDispatch(handler) {
|
|
43
44
|
// onEnqueueHandler sniffs the function length of the passed-in callback
|
|
@@ -45,25 +46,19 @@ class TaskQueueBuilder {
|
|
|
45
46
|
// in another handler to avoid accidentally triggering the v2 API
|
|
46
47
|
const fixedLen = (data, context) => handler(data, context);
|
|
47
48
|
const func = (0, tasks_1.onDispatchHandler)(fixedLen);
|
|
48
|
-
func.__trigger = {
|
|
49
|
-
...(0, cloud_functions_1.optionsToTrigger)(this.depOpts || {}),
|
|
50
|
-
taskQueueTrigger: {},
|
|
51
|
-
};
|
|
52
|
-
(0, encoding_1.copyIfPresent)(func.__trigger.taskQueueTrigger, this.tqOpts, 'retryConfig');
|
|
53
|
-
(0, encoding_1.copyIfPresent)(func.__trigger.taskQueueTrigger, this.tqOpts, 'rateLimits');
|
|
54
|
-
(0, encoding_1.convertIfPresent)(func.__trigger.taskQueueTrigger, this.tqOpts, 'invoker', 'invoker', encoding_1.convertInvoker);
|
|
55
49
|
func.__endpoint = {
|
|
56
|
-
platform:
|
|
50
|
+
platform: "gcfv1",
|
|
51
|
+
...(0, manifest_1.initV1Endpoint)(this.depOpts),
|
|
57
52
|
...(0, cloud_functions_1.optionsToEndpoint)(this.depOpts),
|
|
58
|
-
taskQueueTrigger:
|
|
53
|
+
taskQueueTrigger: (0, manifest_1.initTaskQueueTrigger)(this.depOpts),
|
|
59
54
|
};
|
|
60
|
-
(0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger, this.tqOpts,
|
|
61
|
-
(0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger, this.tqOpts,
|
|
62
|
-
(0, encoding_1.convertIfPresent)(func.__endpoint.taskQueueTrigger, this.tqOpts,
|
|
55
|
+
(0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger, this.tqOpts, "retryConfig");
|
|
56
|
+
(0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger, this.tqOpts, "rateLimits");
|
|
57
|
+
(0, encoding_1.convertIfPresent)(func.__endpoint.taskQueueTrigger, this.tqOpts, "invoker", "invoker", encoding_1.convertInvoker);
|
|
63
58
|
func.__requiredAPIs = [
|
|
64
59
|
{
|
|
65
|
-
api:
|
|
66
|
-
reason:
|
|
60
|
+
api: "cloudtasks.googleapis.com",
|
|
61
|
+
reason: "Needed for task queue functions",
|
|
67
62
|
},
|
|
68
63
|
];
|
|
69
64
|
func.run = handler;
|