firebase-functions 3.18.0 → 3.20.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/apps.js +1 -1
- package/lib/bin/firebase-functions.js +16 -14
- package/lib/cloud-functions.js +12 -12
- package/lib/common/providers/https.d.ts +20 -49
- package/lib/common/providers/https.js +10 -50
- package/lib/common/providers/identity.d.ts +187 -4
- package/lib/common/providers/identity.js +553 -27
- package/lib/common/providers/tasks.d.ts +58 -0
- package/lib/common/providers/tasks.js +68 -0
- package/lib/function-builder.d.ts +4 -1
- package/lib/function-builder.js +6 -1
- package/lib/handler-builder.d.ts +13 -2
- package/lib/handler-builder.js +18 -5
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -2
- package/lib/logger/compat.js +1 -1
- package/lib/providers/analytics.js +1 -1
- package/lib/providers/auth.js +2 -2
- package/lib/providers/database.js +12 -12
- package/lib/providers/firestore.js +7 -7
- package/lib/providers/https.d.ts +2 -44
- package/lib/providers/https.js +8 -56
- package/lib/providers/pubsub.js +2 -2
- package/lib/providers/remoteConfig.js +1 -1
- package/lib/providers/storage.js +2 -2
- package/lib/providers/tasks.d.ts +46 -0
- package/lib/providers/tasks.js +75 -0
- package/lib/providers/testLab.js +1 -1
- package/lib/runtime/loader.js +1 -2
- package/lib/runtime/manifest.d.ts +5 -3
- package/lib/runtime/manifest.js +21 -0
- package/lib/setup.js +3 -3
- package/lib/v2/index.d.ts +2 -1
- package/lib/v2/index.js +3 -1
- package/lib/v2/options.d.ts +2 -2
- package/lib/v2/options.js +23 -14
- package/lib/v2/providers/alerts/alerts.js +2 -2
- package/lib/v2/providers/alerts/appDistribution.js +1 -1
- package/lib/v2/providers/alerts/billing.d.ts +2 -2
- package/lib/v2/providers/alerts/billing.js +6 -6
- package/lib/v2/providers/alerts/crashlytics.js +1 -1
- package/lib/v2/providers/https.d.ts +2 -20
- package/lib/v2/providers/https.js +4 -43
- package/lib/v2/providers/pubsub.js +1 -1
- package/lib/v2/providers/storage.js +3 -5
- package/lib/v2/providers/tasks.d.ts +22 -0
- package/lib/v2/providers/tasks.js +89 -0
- package/package.json +24 -14
|
@@ -0,0 +1,89 @@
|
|
|
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.onTaskDispatched = void 0;
|
|
25
|
+
const options = require("../options");
|
|
26
|
+
const encoding_1 = require("../../common/encoding");
|
|
27
|
+
const tasks_1 = require("../../common/providers/tasks");
|
|
28
|
+
function onTaskDispatched(optsOrHandler, handler) {
|
|
29
|
+
let opts;
|
|
30
|
+
if (arguments.length == 1) {
|
|
31
|
+
opts = {};
|
|
32
|
+
handler = optsOrHandler;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
opts = optsOrHandler;
|
|
36
|
+
}
|
|
37
|
+
// onDispatchHandler sniffs the function length to determine which API to present.
|
|
38
|
+
// fix the length to prevent api versions from being mismatched.
|
|
39
|
+
const fixedLen = (req) => handler(req);
|
|
40
|
+
const func = tasks_1.onDispatchHandler(fixedLen);
|
|
41
|
+
Object.defineProperty(func, '__trigger', {
|
|
42
|
+
get: () => {
|
|
43
|
+
const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
|
|
44
|
+
// global options calls region a scalar and https allows it to be an array,
|
|
45
|
+
// but optionsToTriggerAnnotations handles both cases.
|
|
46
|
+
const specificOpts = options.optionsToTriggerAnnotations(opts);
|
|
47
|
+
const taskQueueTrigger = {};
|
|
48
|
+
encoding_1.copyIfPresent(taskQueueTrigger, opts, 'retryConfig', 'rateLimits');
|
|
49
|
+
encoding_1.convertIfPresent(taskQueueTrigger, opts, 'invoker', 'invoker', encoding_1.convertInvoker);
|
|
50
|
+
return {
|
|
51
|
+
apiVersion: 2,
|
|
52
|
+
platform: 'gcfv2',
|
|
53
|
+
...baseOpts,
|
|
54
|
+
...specificOpts,
|
|
55
|
+
labels: {
|
|
56
|
+
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
|
57
|
+
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
|
58
|
+
},
|
|
59
|
+
taskQueueTrigger,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
|
|
64
|
+
// global options calls region a scalar and https allows it to be an array,
|
|
65
|
+
// but optionsToManifestEndpoint handles both cases.
|
|
66
|
+
const specificOpts = options.optionsToEndpoint(opts);
|
|
67
|
+
func.__endpoint = {
|
|
68
|
+
platform: 'gcfv2',
|
|
69
|
+
...baseOpts,
|
|
70
|
+
...specificOpts,
|
|
71
|
+
labels: {
|
|
72
|
+
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
|
73
|
+
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
|
74
|
+
},
|
|
75
|
+
taskQueueTrigger: {},
|
|
76
|
+
};
|
|
77
|
+
encoding_1.copyIfPresent(func.__endpoint.taskQueueTrigger, opts, 'retryConfig');
|
|
78
|
+
encoding_1.copyIfPresent(func.__endpoint.taskQueueTrigger, opts, 'rateLimits');
|
|
79
|
+
encoding_1.convertIfPresent(func.__endpoint.taskQueueTrigger, opts, 'invoker', 'invoker', encoding_1.convertInvoker);
|
|
80
|
+
func.__requiredAPIs = [
|
|
81
|
+
{
|
|
82
|
+
api: 'cloudtasks.googleapis.com',
|
|
83
|
+
reason: 'Needed for task queue functions',
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
func.run = handler;
|
|
87
|
+
return func;
|
|
88
|
+
}
|
|
89
|
+
exports.onTaskDispatched = onTaskDispatched;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-functions",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"description": "Firebase SDK for Cloud Functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"firebase",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"./lib/providers/pubsub": "./lib/providers/pubsub.js",
|
|
41
41
|
"./lib/providers/remoteConfig": "./lib/providers/remoteConfig.js",
|
|
42
42
|
"./lib/providers/storage": "./lib/providers/storage.js",
|
|
43
|
+
"./lib/providers/tasks": "./lib/providers/tasks.js",
|
|
43
44
|
"./lib/providers/testLab": "./lib/providers/testLab.js",
|
|
44
45
|
"./v1": "./lib/index.js",
|
|
45
46
|
"./v1/analytics": "./lib/providers/analytics.js",
|
|
@@ -58,6 +59,7 @@
|
|
|
58
59
|
"./v2/params": "./lib/v2/params/index.js",
|
|
59
60
|
"./v2/pubsub": "./lib/v2/providers/pubsub.js",
|
|
60
61
|
"./v2/storage": "./lib/v2/providers/storage.js",
|
|
62
|
+
"./v2/tasks": "./lib/v2/providers/tasks.js",
|
|
61
63
|
"./v2/alerts": "./lib/v2/providers/alerts/index.js",
|
|
62
64
|
"./v2/alerts/appDistribution": "./lib/v2/providers/alerts/appDistribution.js",
|
|
63
65
|
"./v2/alerts/billing": "./lib/v2/providers/alerts/billing.js",
|
|
@@ -98,12 +100,27 @@
|
|
|
98
100
|
"v1/storage": [
|
|
99
101
|
"lib/providers/storage"
|
|
100
102
|
],
|
|
103
|
+
"v1/tasks": [
|
|
104
|
+
"lib/providers/tasks"
|
|
105
|
+
],
|
|
101
106
|
"v1/testLab": [
|
|
102
107
|
"lib/providers/testLab"
|
|
103
108
|
],
|
|
104
109
|
"v2": [
|
|
105
110
|
"lib/v2"
|
|
106
111
|
],
|
|
112
|
+
"v2/alerts": [
|
|
113
|
+
"lib/v2/providers/alerts"
|
|
114
|
+
],
|
|
115
|
+
"v2/alerts/appDistribution": [
|
|
116
|
+
"lib/v2/providers/alerts/appDistribution"
|
|
117
|
+
],
|
|
118
|
+
"v2/alerts/billing": [
|
|
119
|
+
"lib/v2/providers/alerts/billing"
|
|
120
|
+
],
|
|
121
|
+
"v2/alerts/crashlytics": [
|
|
122
|
+
"lib/v2/providers/alerts/crashlytics"
|
|
123
|
+
],
|
|
107
124
|
"v2/base": [
|
|
108
125
|
"lib/v2/base"
|
|
109
126
|
],
|
|
@@ -122,17 +139,8 @@
|
|
|
122
139
|
"v2/storage": [
|
|
123
140
|
"lib/v2/providers/storage"
|
|
124
141
|
],
|
|
125
|
-
"v2/
|
|
126
|
-
"lib/v2/providers/
|
|
127
|
-
],
|
|
128
|
-
"v2/alerts/appDistribution": [
|
|
129
|
-
"lib/v2/providers/alerts/appDistribution"
|
|
130
|
-
],
|
|
131
|
-
"v2/alerts/billing": [
|
|
132
|
-
"lib/v2/providers/alerts/billing"
|
|
133
|
-
],
|
|
134
|
-
"v2/alerts/crashlytics": [
|
|
135
|
-
"lib/v2/providers/alerts/crashlytics"
|
|
142
|
+
"v2/tasks": [
|
|
143
|
+
"lib/v2/providers/tasks"
|
|
136
144
|
]
|
|
137
145
|
}
|
|
138
146
|
},
|
|
@@ -149,7 +157,7 @@
|
|
|
149
157
|
"format:fix": "prettier --write '**/*.{json,md,ts,yml,yaml}'",
|
|
150
158
|
"lint": "tslint --config tslint.json --project tsconfig.json ",
|
|
151
159
|
"lint:fix": "tslint --config tslint.json --fix --project tsconfig.json",
|
|
152
|
-
"test": "mocha --file ./mocha/setup.ts spec/**/*.spec.ts
|
|
160
|
+
"test": "mocha --file ./mocha/setup.ts \"spec/**/*.spec.ts\"",
|
|
153
161
|
"test:bin": "./scripts/bin-test/run.sh"
|
|
154
162
|
},
|
|
155
163
|
"dependencies": {
|
|
@@ -157,7 +165,8 @@
|
|
|
157
165
|
"@types/express": "4.17.3",
|
|
158
166
|
"cors": "^2.8.5",
|
|
159
167
|
"express": "^4.17.1",
|
|
160
|
-
"lodash": "^4.17.14"
|
|
168
|
+
"lodash": "^4.17.14",
|
|
169
|
+
"node-fetch": "^2.6.7"
|
|
161
170
|
},
|
|
162
171
|
"devDependencies": {
|
|
163
172
|
"@types/chai": "^4.1.7",
|
|
@@ -168,6 +177,7 @@
|
|
|
168
177
|
"@types/mock-require": "^2.0.0",
|
|
169
178
|
"@types/nock": "^10.0.3",
|
|
170
179
|
"@types/node": "^8.10.50",
|
|
180
|
+
"@types/node-fetch": "^3.0.3",
|
|
171
181
|
"@types/sinon": "^7.0.13",
|
|
172
182
|
"chai": "^4.2.0",
|
|
173
183
|
"chai-as-promised": "^7.1.1",
|