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,4 +1,4 @@
|
|
|
1
|
-
import { CloudFunction, EventContext } from
|
|
1
|
+
import { CloudFunction, EventContext } from "../cloud-functions";
|
|
2
2
|
/** Handle events related to Test Lab test matrices. */
|
|
3
3
|
export declare function testMatrix(): TestMatrixBuilder;
|
|
4
4
|
/** Builder used to create Cloud Functions for Test Lab test matrices events. */
|
|
@@ -54,91 +54,131 @@ export declare class ResultStorage {
|
|
|
54
54
|
/**
|
|
55
55
|
* The detailed reason that a Matrix was deemed INVALID.
|
|
56
56
|
*
|
|
57
|
+
* @remarks
|
|
57
58
|
* Possible values:
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* -
|
|
62
|
-
*
|
|
63
|
-
* -
|
|
64
|
-
*
|
|
65
|
-
* -
|
|
66
|
-
*
|
|
67
|
-
* -
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* -
|
|
59
|
+
*
|
|
60
|
+
* - `DETAILS_UNAVAILABLE`: The matrix is INVALID, but there are no further details available.
|
|
61
|
+
*
|
|
62
|
+
* - `MALFORMED_APK`: The input app APK could not be parsed.
|
|
63
|
+
*
|
|
64
|
+
* - `MALFORMED_TEST_APK`: The input test APK could not be parsed.
|
|
65
|
+
*
|
|
66
|
+
* - `NO_MANIFEST`: The AndroidManifest.xml could not be found.
|
|
67
|
+
*
|
|
68
|
+
* - `NO_PACKAGE_NAME`: The APK manifest does not declare a package name.
|
|
69
|
+
*
|
|
70
|
+
* - `INVALID_PACKAGE_NAME`: The APK application ID is invalid.
|
|
71
|
+
*
|
|
72
|
+
* - `TEST_SAME_AS_APP`: The test package and app package are the same.
|
|
73
|
+
*
|
|
74
|
+
* - `NO_INSTRUMENTATION`: The test apk does not declare an instrumentation.
|
|
75
|
+
*
|
|
76
|
+
* - `NO_SIGNATURE`: The input app apk does not have a signature.
|
|
77
|
+
*
|
|
78
|
+
* - `INSTRUMENTATION_ORCHESTRATOR_INCOMPATIBLE`: The test runner class specified by
|
|
79
|
+
* user or in the test APK`s manifest file is not compatible with Android Test Orchestrator.
|
|
80
|
+
*
|
|
81
|
+
* - `NO_TEST_RUNNER_CLASS`: The test APK does not contain the test runner class
|
|
72
82
|
* specified by user or in the manifest file.
|
|
73
|
-
*
|
|
74
|
-
* -
|
|
83
|
+
*
|
|
84
|
+
* - `NO_LAUNCHER_ACTIVITY`: A main launcher activity could not be found.
|
|
85
|
+
*
|
|
86
|
+
* - `FORBIDDEN_PERMISSIONS`: The app declares one or more permissions that are
|
|
75
87
|
* not allowed.
|
|
76
|
-
*
|
|
88
|
+
*
|
|
89
|
+
* - `INVALID_ROBO_DIRECTIVES`: There is a conflict in the provided
|
|
77
90
|
* robo_directives.
|
|
78
|
-
*
|
|
91
|
+
*
|
|
92
|
+
* - `INVALID_RESOURCE_NAME`: There is at least one invalid resource name in the
|
|
79
93
|
* provided robo directives.
|
|
80
|
-
*
|
|
94
|
+
*
|
|
95
|
+
* - `INVALID_DIRECTIVE_ACTION`: Invalid definition of action in the robo
|
|
81
96
|
* directives, e.g. a click or ignore action includes an input text field.
|
|
82
|
-
*
|
|
97
|
+
*
|
|
98
|
+
* - `TEST_LOOP_INTENT_FILTER_NOT_FOUND`: There is no test loop intent filter,
|
|
83
99
|
* or the one that is given is not formatted correctly.
|
|
84
|
-
*
|
|
100
|
+
*
|
|
101
|
+
* - `SCENARIO_LABEL_NOT_DECLARED`: The request contains a scenario label that
|
|
85
102
|
* was not declared in the manifest.
|
|
86
|
-
*
|
|
87
|
-
* -
|
|
103
|
+
*
|
|
104
|
+
* - `SCENARIO_LABEL_MALFORMED`: There was an error when parsing a label value.
|
|
105
|
+
*
|
|
106
|
+
* - `SCENARIO_NOT_DECLARED`: The request contains a scenario number that was
|
|
88
107
|
* not declared in the manifest.
|
|
89
|
-
*
|
|
90
|
-
* -
|
|
108
|
+
*
|
|
109
|
+
* - `DEVICE_ADMIN_RECEIVER`: Device administrator applications are not allowed.
|
|
110
|
+
*
|
|
111
|
+
* - `MALFORMED_XC_TEST_ZIP`: The zipped XCTest was malformed. The zip did not ]
|
|
91
112
|
* contain a single .xctestrun file and the contents of the
|
|
92
113
|
* DerivedData/Build/Products directory.
|
|
93
|
-
*
|
|
114
|
+
*
|
|
115
|
+
* - `BUILT_FOR_IOS_SIMULATOR`: The zipped XCTest was built for the iOS
|
|
94
116
|
* simulator rather than for a physical device.
|
|
95
|
-
*
|
|
117
|
+
*
|
|
118
|
+
* - `NO_TESTS_IN_XC_TEST_ZIP`: The .xctestrun file did not specify any test
|
|
96
119
|
* targets.
|
|
97
|
-
*
|
|
120
|
+
*
|
|
121
|
+
* - `USE_DESTINATION_ARTIFACTS`: One or more of the test targets defined in the
|
|
98
122
|
* .xctestrun file specifies "UseDestinationArtifacts", which is disallowed.
|
|
99
|
-
*
|
|
123
|
+
*
|
|
124
|
+
* - `TEST_NON_APP_HOSTED`: XC tests which run on physical devices must have
|
|
100
125
|
* "IsAppHostedTestBundle" == "true" in the xctestrun file.
|
|
101
|
-
*
|
|
126
|
+
*
|
|
127
|
+
* - `PLIST_CANNOT_BE_PARSED`: An Info.plist file in the XCTest zip could not be
|
|
102
128
|
* parsed.
|
|
103
|
-
*
|
|
104
|
-
* -
|
|
129
|
+
*
|
|
130
|
+
* - `NO_CODE_APK`: APK contains no code.
|
|
131
|
+
*
|
|
132
|
+
* - `INVALID_INPUT_APK`: Either the provided input APK path was malformed, the
|
|
105
133
|
* APK file does not exist, or the user does not have permission to access the
|
|
106
134
|
* APK file.
|
|
107
|
-
*
|
|
135
|
+
*
|
|
136
|
+
* - `INVALID_APK_PREVIEW_SDK`: APK is built for a preview SDK which is
|
|
108
137
|
* unsupported.
|
|
109
138
|
*/
|
|
110
|
-
export declare type InvalidMatrixDetails =
|
|
139
|
+
export declare type InvalidMatrixDetails = "DETAILS_UNAVAILABLE" | "MALFORMED_APK" | "MALFORMED_TEST_APK" | "NO_MANIFEST" | "NO_PACKAGE_NAME" | "INVALID_PACKAGE_NAME" | "TEST_SAME_AS_APP" | "NO_INSTRUMENTATION" | "NO_SIGNATURE" | "INSTRUMENTATION_ORCHESTRATOR_INCOMPATIBLE" | "NO_TEST_RUNNER_CLASS" | "NO_LAUNCHER_ACTIVITY" | "FORBIDDEN_PERMISSIONS" | "INVALID_ROBO_DIRECTIVES" | "INVALID_RESOURCE_NAME" | "INVALID_DIRECTIVE_ACTION" | "TEST_LOOP_INTENT_FILTER_NOT_FOUND" | "SCENARIO_LABEL_NOT_DECLARED" | "SCENARIO_LABEL_MALFORMED" | "SCENARIO_NOT_DECLARED" | "DEVICE_ADMIN_RECEIVER" | "MALFORMED_XC_TEST_ZIP" | "BUILT_FOR_IOS_SIMULATOR" | "NO_TESTS_IN_XC_TEST_ZIP" | "USE_DESTINATION_ARTIFACTS" | "TEST_NOT_APP_HOSTED" | "PLIST_CANNOT_BE_PARSED" | "NO_CODE_APK" | "INVALID_INPUT_APK" | "INVALID_APK_PREVIEW_SDK";
|
|
111
140
|
/**
|
|
112
141
|
* The state (i.e. progress) of a TestMatrix.
|
|
113
142
|
*
|
|
143
|
+
* @remarks
|
|
114
144
|
* Possible values:
|
|
115
|
-
*
|
|
116
|
-
* -
|
|
117
|
-
*
|
|
145
|
+
*
|
|
146
|
+
* - `VALIDATING`: The matrix is being validated.
|
|
147
|
+
*
|
|
148
|
+
* - `PENDING`: The matrix is waiting for resources to become available.
|
|
149
|
+
*
|
|
150
|
+
* - `FINISHED`: The matrix has terminated normally. This means that the matrix
|
|
118
151
|
* level processing completed normally, but individual executions may be in an
|
|
119
152
|
* ERROR state.
|
|
120
|
-
*
|
|
153
|
+
*
|
|
154
|
+
* - `ERROR`: The matrix has stopped because it encountered an infrastructure
|
|
121
155
|
* failure.
|
|
122
|
-
*
|
|
156
|
+
*
|
|
157
|
+
* - `INVALID`: The matrix was not run because the provided inputs are not
|
|
123
158
|
* valid. E.g. the input file is not of the expected type, or is
|
|
124
159
|
* malformed/corrupt.
|
|
125
160
|
*/
|
|
126
|
-
export declare type TestState =
|
|
161
|
+
export declare type TestState = "VALIDATING" | "PENDING" | "FINISHED" | "ERROR" | "INVALID";
|
|
127
162
|
/**
|
|
128
163
|
* Outcome summary for a finished TestMatrix.
|
|
129
164
|
*
|
|
165
|
+
* @remarks
|
|
130
166
|
* Possible values:
|
|
131
|
-
*
|
|
167
|
+
*
|
|
168
|
+
* - `SUCCESS`: The test matrix run was successful, for instance:
|
|
132
169
|
* - All the test cases passed.
|
|
133
170
|
* - Robo did not detect a crash of the application under test.
|
|
134
|
-
*
|
|
171
|
+
*
|
|
172
|
+
* - `FAILURE`: The test run failed, for instance:
|
|
135
173
|
* - One or more test cases failed.
|
|
136
174
|
* - A test timed out.
|
|
137
175
|
* - The application under test crashed.
|
|
138
|
-
*
|
|
176
|
+
*
|
|
177
|
+
* - `INCONCLUSIVE`: Something unexpected happened. The run should still be
|
|
139
178
|
* considered unsuccessful but this is likely a transient problem and
|
|
140
179
|
* re-running the test might be successful.
|
|
141
|
-
*
|
|
180
|
+
*
|
|
181
|
+
* - `SKIPPED`: All tests were skipped, for instance:
|
|
142
182
|
* - All device configurations were incompatible.
|
|
143
183
|
*/
|
|
144
|
-
export declare type OutcomeSummary =
|
|
184
|
+
export declare type OutcomeSummary = "SUCCESS" | "FAILURE" | "INCONCLUSIVE" | "SKIPPED";
|
|
@@ -22,14 +22,13 @@
|
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.ResultStorage = exports.ClientInfo = exports.TestMatrix = exports.TestMatrixBuilder = exports._testMatrixWithOpts = exports.testMatrix = exports.TEST_MATRIX_COMPLETE_EVENT_TYPE = exports.SERVICE = exports.PROVIDER = void 0;
|
|
25
|
-
const _ = require("lodash");
|
|
26
25
|
const cloud_functions_1 = require("../cloud-functions");
|
|
27
26
|
/** @internal */
|
|
28
|
-
exports.PROVIDER =
|
|
27
|
+
exports.PROVIDER = "google.testing";
|
|
29
28
|
/** @internal */
|
|
30
|
-
exports.SERVICE =
|
|
29
|
+
exports.SERVICE = "testing.googleapis.com";
|
|
31
30
|
/** @internal */
|
|
32
|
-
exports.TEST_MATRIX_COMPLETE_EVENT_TYPE =
|
|
31
|
+
exports.TEST_MATRIX_COMPLETE_EVENT_TYPE = "testMatrix.complete";
|
|
33
32
|
/** Handle events related to Test Lab test matrices. */
|
|
34
33
|
function testMatrix() {
|
|
35
34
|
return _testMatrixWithOpts({});
|
|
@@ -39,9 +38,9 @@ exports.testMatrix = testMatrix;
|
|
|
39
38
|
function _testMatrixWithOpts(opts) {
|
|
40
39
|
return new TestMatrixBuilder(() => {
|
|
41
40
|
if (!process.env.GCLOUD_PROJECT) {
|
|
42
|
-
throw new Error(
|
|
41
|
+
throw new Error("process.env.GCLOUD_PROJECT is not set.");
|
|
43
42
|
}
|
|
44
|
-
return
|
|
43
|
+
return "projects/" + process.env.GCLOUD_PROJECT + "/testMatrices/{matrix}";
|
|
45
44
|
}, opts);
|
|
46
45
|
}
|
|
47
46
|
exports._testMatrixWithOpts = _testMatrixWithOpts;
|
|
@@ -87,11 +86,11 @@ exports.TestMatrix = TestMatrix;
|
|
|
87
86
|
class ClientInfo {
|
|
88
87
|
/** @internal */
|
|
89
88
|
constructor(data) {
|
|
90
|
-
this.name =
|
|
89
|
+
this.name = (data === null || data === void 0 ? void 0 : data.name) || "";
|
|
91
90
|
this.details = {};
|
|
92
|
-
|
|
93
|
-
this.details[detail.key] = detail.value ||
|
|
94
|
-
}
|
|
91
|
+
for (const detail of (data === null || data === void 0 ? void 0 : data.clientInfoDetails) || []) {
|
|
92
|
+
this.details[detail.key] = detail.value || "";
|
|
93
|
+
}
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
exports.ClientInfo = ClientInfo;
|
|
@@ -99,10 +98,11 @@ exports.ClientInfo = ClientInfo;
|
|
|
99
98
|
class ResultStorage {
|
|
100
99
|
/** @internal */
|
|
101
100
|
constructor(data) {
|
|
102
|
-
|
|
103
|
-
this.
|
|
104
|
-
this.
|
|
105
|
-
this.
|
|
101
|
+
var _a, _b, _c;
|
|
102
|
+
this.gcsPath = (_a = data === null || data === void 0 ? void 0 : data.googleCloudStorage) === null || _a === void 0 ? void 0 : _a.gcsPath;
|
|
103
|
+
this.toolResultsHistoryId = (_b = data === null || data === void 0 ? void 0 : data.toolResultsHistory) === null || _b === void 0 ? void 0 : _b.historyId;
|
|
104
|
+
this.toolResultsExecutionId = (_c = data === null || data === void 0 ? void 0 : data.toolResultsExecution) === null || _c === void 0 ? void 0 : _c.executionId;
|
|
105
|
+
this.resultsUrl = data === null || data === void 0 ? void 0 : data.resultsUrl;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
exports.ResultStorage = ResultStorage;
|
package/lib/v2/core.d.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Core functionality of the Firebase Functions v2 SDK.
|
|
3
3
|
* @packageDocumentation
|
|
4
4
|
*/
|
|
5
|
-
import { Change } from
|
|
6
|
-
import { ManifestEndpoint } from
|
|
5
|
+
import { Change } from "../common/change";
|
|
6
|
+
import { ManifestEndpoint } from "../runtime/manifest";
|
|
7
7
|
export { Change };
|
|
8
|
+
export { ParamsOf } from "../common/params";
|
|
8
9
|
/**
|
|
9
10
|
* A CloudEventBase is the base of a cross-platform format for encoding a serverless event.
|
|
10
11
|
* More information can be found in https://github.com/cloudevents/spec
|
|
@@ -13,7 +14,7 @@ export { Change };
|
|
|
13
14
|
*/
|
|
14
15
|
export interface CloudEvent<T> {
|
|
15
16
|
/** Version of the CloudEvents spec for this event. */
|
|
16
|
-
readonly specversion:
|
|
17
|
+
readonly specversion: "1.0";
|
|
17
18
|
/** A globally unique ID for this event. */
|
|
18
19
|
id: string;
|
|
19
20
|
/** The resource which published this event. */
|
|
@@ -36,8 +37,6 @@ export interface CloudEvent<T> {
|
|
|
36
37
|
export interface CloudFunction<EventType extends CloudEvent<unknown>> {
|
|
37
38
|
(raw: CloudEvent<unknown>): any | Promise<any>;
|
|
38
39
|
/** @alpha */
|
|
39
|
-
__trigger?: unknown;
|
|
40
|
-
/** @alpha */
|
|
41
40
|
__endpoint: ManifestEndpoint;
|
|
42
41
|
/**
|
|
43
42
|
* The callback passed to the CloudFunction constructor.
|
package/lib/v2/index.d.ts
CHANGED
|
@@ -5,17 +5,19 @@
|
|
|
5
5
|
* from 'firebase-functions/v2/pubsub'.
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
|
-
import * as logger from
|
|
9
|
-
import * as alerts from
|
|
10
|
-
import * as database from
|
|
11
|
-
import * as eventarc from
|
|
12
|
-
import * as https from
|
|
13
|
-
import * as identity from
|
|
14
|
-
import * as pubsub from
|
|
15
|
-
import * as scheduler from
|
|
16
|
-
import * as storage from
|
|
17
|
-
import * as tasks from
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
8
|
+
import * as logger from "../logger";
|
|
9
|
+
import * as alerts from "./providers/alerts";
|
|
10
|
+
import * as database from "./providers/database";
|
|
11
|
+
import * as eventarc from "./providers/eventarc";
|
|
12
|
+
import * as https from "./providers/https";
|
|
13
|
+
import * as identity from "./providers/identity";
|
|
14
|
+
import * as pubsub from "./providers/pubsub";
|
|
15
|
+
import * as scheduler from "./providers/scheduler";
|
|
16
|
+
import * as storage from "./providers/storage";
|
|
17
|
+
import * as tasks from "./providers/tasks";
|
|
18
|
+
import * as remoteConfig from "./providers/remoteConfig";
|
|
19
|
+
import * as testLab from "./providers/testLab";
|
|
20
|
+
export { alerts, database, storage, https, identity, pubsub, logger, tasks, eventarc, scheduler, remoteConfig, testLab, };
|
|
21
|
+
export { setGlobalOptions, GlobalOptions, SupportedRegion, MemoryOption, VpcEgressSetting, IngressSetting, EventHandlerOptions, } from "./options";
|
|
22
|
+
export { CloudFunction, CloudEvent, ParamsOf } from "./core";
|
|
23
|
+
export { Change } from "../common/change";
|
package/lib/v2/index.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
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 = exports.setGlobalOptions = exports.scheduler = exports.eventarc = exports.tasks = exports.logger = exports.pubsub = exports.identity = exports.https = exports.storage = exports.database = exports.alerts = void 0;
|
|
24
|
+
exports.Change = exports.setGlobalOptions = exports.testLab = exports.remoteConfig = exports.scheduler = exports.eventarc = exports.tasks = exports.logger = exports.pubsub = exports.identity = exports.https = exports.storage = exports.database = exports.alerts = void 0;
|
|
25
25
|
/**
|
|
26
26
|
* The V2 API for Cloud Functions for Firebase.
|
|
27
27
|
* This SDK also supports deep imports. For example, the namespace
|
|
@@ -49,6 +49,10 @@ const storage = require("./providers/storage");
|
|
|
49
49
|
exports.storage = storage;
|
|
50
50
|
const tasks = require("./providers/tasks");
|
|
51
51
|
exports.tasks = tasks;
|
|
52
|
+
const remoteConfig = require("./providers/remoteConfig");
|
|
53
|
+
exports.remoteConfig = remoteConfig;
|
|
54
|
+
const testLab = require("./providers/testLab");
|
|
55
|
+
exports.testLab = testLab;
|
|
52
56
|
var options_1 = require("./options");
|
|
53
57
|
Object.defineProperty(exports, "setGlobalOptions", { enumerable: true, get: function () { return options_1.setGlobalOptions; } });
|
|
54
58
|
var change_1 = require("../common/change");
|
package/lib/v2/options.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ResetValue } from "../common/options";
|
|
2
|
+
import { Expression } from "../params";
|
|
3
|
+
import { ParamSpec, SecretParam } from "../params/types";
|
|
4
|
+
export { RESET_VALUE } from "../common/options";
|
|
3
5
|
/**
|
|
4
6
|
* List of all regions supported by Cloud Functions v2
|
|
5
7
|
*/
|
|
6
|
-
export declare type SupportedRegion =
|
|
8
|
+
export declare type SupportedRegion = "asia-northeast1" | "europe-north1" | "europe-west1" | "europe-west4" | "us-central1" | "us-east1" | "us-west1";
|
|
7
9
|
/**
|
|
8
10
|
* List of available memory options supported by Cloud Functions.
|
|
9
11
|
*/
|
|
10
|
-
export declare type MemoryOption =
|
|
12
|
+
export declare type MemoryOption = "128MiB" | "256MiB" | "512MiB" | "1GiB" | "2GiB" | "4GiB" | "8GiB" | "16GiB" | "32GiB";
|
|
11
13
|
/**
|
|
12
14
|
* List of available options for VpcConnectorEgressSettings.
|
|
13
15
|
*/
|
|
14
|
-
export declare type VpcEgressSetting =
|
|
16
|
+
export declare type VpcEgressSetting = "PRIVATE_RANGES_ONLY" | "ALL_TRAFFIC";
|
|
15
17
|
/**
|
|
16
18
|
* List of available options for IngressSettings.
|
|
17
19
|
*/
|
|
18
|
-
export declare type IngressSetting =
|
|
20
|
+
export declare type IngressSetting = "ALLOW_ALL" | "ALLOW_INTERNAL_ONLY" | "ALLOW_INTERNAL_AND_GCLB";
|
|
19
21
|
/**
|
|
20
22
|
* GlobalOptions are options that can be set across an entire project.
|
|
21
23
|
* These options are common to HTTPS and Event handling functions.
|
|
@@ -23,83 +25,101 @@ export declare type IngressSetting = 'ALLOW_ALL' | 'ALLOW_INTERNAL_ONLY' | 'ALLO
|
|
|
23
25
|
export interface GlobalOptions {
|
|
24
26
|
/**
|
|
25
27
|
* Region where functions should be deployed.
|
|
26
|
-
* HTTP functions can override and specify more than one region.
|
|
27
28
|
*/
|
|
28
29
|
region?: SupportedRegion | string;
|
|
29
30
|
/**
|
|
30
31
|
* Amount of memory to allocate to a function.
|
|
31
|
-
* A value of null restores the defaults of 256MB.
|
|
32
32
|
*/
|
|
33
|
-
memory?: MemoryOption | Expression<number> |
|
|
33
|
+
memory?: MemoryOption | Expression<number> | ResetValue;
|
|
34
34
|
/**
|
|
35
35
|
* Timeout for the function in sections, possible values are 0 to 540.
|
|
36
36
|
* HTTPS functions can specify a higher timeout.
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
38
39
|
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
|
39
40
|
* function depends on the type of function: Event handling functions have a
|
|
40
41
|
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
|
41
42
|
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
42
43
|
* timeout of 1,800s (30 minutes)
|
|
43
44
|
*/
|
|
44
|
-
timeoutSeconds?: number | Expression<number> |
|
|
45
|
+
timeoutSeconds?: number | Expression<number> | ResetValue;
|
|
45
46
|
/**
|
|
46
47
|
* Min number of actual instances to be running at a given time.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
47
50
|
* Instances will be billed for memory allocation and 10% of CPU allocation
|
|
48
51
|
* while idle.
|
|
49
|
-
* A value of null restores the default min instances.
|
|
50
52
|
*/
|
|
51
|
-
minInstances?: number | Expression<number> |
|
|
53
|
+
minInstances?: number | Expression<number> | ResetValue;
|
|
52
54
|
/**
|
|
53
55
|
* Max number of instances to be running in parallel.
|
|
54
|
-
* A value of null restores the default max instances.
|
|
55
56
|
*/
|
|
56
|
-
maxInstances?: number | Expression<number> |
|
|
57
|
+
maxInstances?: number | Expression<number> | ResetValue;
|
|
57
58
|
/**
|
|
58
59
|
* Number of requests a function can serve at once.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
59
62
|
* Can only be applied to functions running on Cloud Functions v2.
|
|
60
63
|
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
|
61
64
|
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
62
65
|
* The maximum value for concurrency is 1,000.
|
|
63
66
|
*/
|
|
64
|
-
concurrency?: number | Expression<number> |
|
|
67
|
+
concurrency?: number | Expression<number> | ResetValue;
|
|
65
68
|
/**
|
|
66
69
|
* Fractional number of CPUs to allocate to a function.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
67
72
|
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
|
68
73
|
* This is different from the defaults when using the gcloud utility and is different from
|
|
69
74
|
* the fixed amount assigned in Google Cloud Functions generation 1.
|
|
70
75
|
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
|
71
76
|
* to the value "gcf_gen1"
|
|
72
77
|
*/
|
|
73
|
-
cpu?: number |
|
|
78
|
+
cpu?: number | "gcf_gen1";
|
|
74
79
|
/**
|
|
75
80
|
* Connect cloud function to specified VPC connector.
|
|
76
|
-
* A value of null removes the VPC connector
|
|
77
81
|
*/
|
|
78
|
-
vpcConnector?: string |
|
|
82
|
+
vpcConnector?: string | ResetValue;
|
|
79
83
|
/**
|
|
80
84
|
* Egress settings for VPC connector.
|
|
81
|
-
* A value of null turns off VPC connector egress settings
|
|
82
85
|
*/
|
|
83
|
-
vpcConnectorEgressSettings?: VpcEgressSetting |
|
|
86
|
+
vpcConnectorEgressSettings?: VpcEgressSetting | ResetValue;
|
|
84
87
|
/**
|
|
85
88
|
* Specific service account for the function to run as.
|
|
86
|
-
* A value of null restores the default service account.
|
|
87
89
|
*/
|
|
88
|
-
serviceAccount?: string |
|
|
90
|
+
serviceAccount?: string | ResetValue;
|
|
89
91
|
/**
|
|
90
92
|
* Ingress settings which control where this function can be called from.
|
|
91
|
-
* A value of null turns off ingress settings.
|
|
92
93
|
*/
|
|
93
|
-
ingressSettings?: IngressSetting |
|
|
94
|
+
ingressSettings?: IngressSetting | ResetValue;
|
|
95
|
+
/**
|
|
96
|
+
* Invoker to set access control on https functions.
|
|
97
|
+
*/
|
|
98
|
+
invoker?: "public" | "private" | string | string[];
|
|
94
99
|
/**
|
|
95
100
|
* User labels to set on the function.
|
|
96
101
|
*/
|
|
97
102
|
labels?: Record<string, string>;
|
|
103
|
+
secrets?: (string | SecretParam)[];
|
|
98
104
|
/**
|
|
99
|
-
*
|
|
105
|
+
* Determines whether Firebase AppCheck is enforced. Defaults to false.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* When true, requests with invalid tokens autorespond with a 401
|
|
109
|
+
* (Unauthorized) error.
|
|
110
|
+
* When false, requests with invalid tokens set event.app to undefiend.
|
|
111
|
+
*/
|
|
112
|
+
enforceAppCheck?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Controls whether function configuration modified outside of function source is preserved. Defaults to false.
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* When setting configuration available in the underlying platform that is not yet available in the Firebase Functions
|
|
118
|
+
* SDK, we highly recommend setting `preserveExternalChanges` to `true`. Otherwise, when the Firebase Functions SDK releases
|
|
119
|
+
* a new version of the SDK with support for the missing configuration, your function's manually configured setting
|
|
120
|
+
* may inadvertently be wiped out.
|
|
100
121
|
*/
|
|
101
|
-
|
|
102
|
-
secrets?: string[];
|
|
122
|
+
preserveExternalChanges?: boolean;
|
|
103
123
|
}
|
|
104
124
|
/**
|
|
105
125
|
* Sets default options for all functions written using the v2 SDK.
|
|
@@ -109,16 +129,16 @@ export declare function setGlobalOptions(options: GlobalOptions): void;
|
|
|
109
129
|
/**
|
|
110
130
|
* Additional fields that can be set on any event-handling Cloud Function.
|
|
111
131
|
*/
|
|
112
|
-
export interface EventHandlerOptions extends GlobalOptions {
|
|
132
|
+
export interface EventHandlerOptions extends Omit<GlobalOptions, "enforceAppCheck"> {
|
|
113
133
|
eventType?: string;
|
|
114
134
|
eventFilters?: Record<string, string | Expression<string>>;
|
|
115
135
|
eventFilterPathPatterns?: Record<string, string | Expression<string>>;
|
|
116
136
|
/** Whether failed executions should be delivered again. */
|
|
117
|
-
retry?: boolean | Expression<boolean> |
|
|
137
|
+
retry?: boolean | Expression<boolean> | ResetValue;
|
|
118
138
|
/** Region of the EventArc trigger. */
|
|
119
139
|
region?: string;
|
|
120
140
|
/** The service account that EventArc should use to invoke this function. Requires the P4SA to have ActAs permission on this service account. */
|
|
121
|
-
serviceAccount?: string |
|
|
141
|
+
serviceAccount?: string | ResetValue;
|
|
122
142
|
/** The name of the channel where the function receives events. */
|
|
123
143
|
channel?: string;
|
|
124
144
|
}
|
|
@@ -128,5 +148,5 @@ export interface EventHandlerOptions extends GlobalOptions {
|
|
|
128
148
|
*/
|
|
129
149
|
export declare function __getSpec(): {
|
|
130
150
|
globalOptions: GlobalOptions;
|
|
131
|
-
params: ParamSpec[];
|
|
151
|
+
params: ParamSpec<any>[];
|
|
132
152
|
};
|
package/lib/v2/options.js
CHANGED
|
@@ -21,24 +21,28 @@
|
|
|
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.
|
|
24
|
+
exports.__getSpec = exports.optionsToEndpoint = exports.getGlobalOptions = exports.setGlobalOptions = exports.RESET_VALUE = void 0;
|
|
25
25
|
/**
|
|
26
26
|
* Options to configure cloud functions.
|
|
27
27
|
* @packageDocumentation
|
|
28
28
|
*/
|
|
29
29
|
const encoding_1 = require("../common/encoding");
|
|
30
|
+
const options_1 = require("../common/options");
|
|
31
|
+
const params_1 = require("../params");
|
|
32
|
+
const types_1 = require("../params/types");
|
|
30
33
|
const logger = require("../logger");
|
|
31
|
-
|
|
34
|
+
var options_2 = require("../common/options");
|
|
35
|
+
Object.defineProperty(exports, "RESET_VALUE", { enumerable: true, get: function () { return options_2.RESET_VALUE; } });
|
|
32
36
|
const MemoryOptionToMB = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
"128MiB": 128,
|
|
38
|
+
"256MiB": 256,
|
|
39
|
+
"512MiB": 512,
|
|
40
|
+
"1GiB": 1024,
|
|
41
|
+
"2GiB": 2048,
|
|
42
|
+
"4GiB": 4096,
|
|
43
|
+
"8GiB": 8192,
|
|
44
|
+
"16GiB": 16384,
|
|
45
|
+
"32GiB": 32768,
|
|
42
46
|
};
|
|
43
47
|
let globalOptions;
|
|
44
48
|
/**
|
|
@@ -47,7 +51,7 @@ let globalOptions;
|
|
|
47
51
|
*/
|
|
48
52
|
function setGlobalOptions(options) {
|
|
49
53
|
if (globalOptions) {
|
|
50
|
-
logger.warn(
|
|
54
|
+
logger.warn("Calling setGlobalOptions twice leads to undefined behavior");
|
|
51
55
|
}
|
|
52
56
|
globalOptions = options;
|
|
53
57
|
}
|
|
@@ -61,53 +65,34 @@ function getGlobalOptions() {
|
|
|
61
65
|
return globalOptions || {};
|
|
62
66
|
}
|
|
63
67
|
exports.getGlobalOptions = getGlobalOptions;
|
|
64
|
-
/**
|
|
65
|
-
* Apply GlobalOptions to trigger definitions.
|
|
66
|
-
* @internal
|
|
67
|
-
*/
|
|
68
|
-
function optionsToTriggerAnnotations(opts) {
|
|
69
|
-
const annotation = {};
|
|
70
|
-
(0, encoding_1.copyIfPresent)(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings', 'secrets');
|
|
71
|
-
(0, encoding_1.convertIfPresent)(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
|
|
72
|
-
return typeof mem === 'object' ? mem : MemoryOptionToMB[mem];
|
|
73
|
-
});
|
|
74
|
-
(0, encoding_1.convertIfPresent)(annotation, opts, 'regions', 'region', (region) => {
|
|
75
|
-
if (typeof region === 'string') {
|
|
76
|
-
return [region];
|
|
77
|
-
}
|
|
78
|
-
return region;
|
|
79
|
-
});
|
|
80
|
-
(0, encoding_1.convertIfPresent)(annotation, opts, 'serviceAccountEmail', 'serviceAccount', encoding_1.serviceAccountFromShorthand);
|
|
81
|
-
(0, encoding_1.convertIfPresent)(annotation, opts, 'timeout', 'timeoutSeconds', encoding_1.durationFromSeconds);
|
|
82
|
-
(0, encoding_1.convertIfPresent)(annotation, opts, 'failurePolicy', 'retry', (retry) => {
|
|
83
|
-
return retry ? { retry: true } : null;
|
|
84
|
-
});
|
|
85
|
-
return annotation;
|
|
86
|
-
}
|
|
87
|
-
exports.optionsToTriggerAnnotations = optionsToTriggerAnnotations;
|
|
88
68
|
/**
|
|
89
69
|
* Apply GlobalOptions to endpoint manifest.
|
|
90
70
|
* @internal
|
|
91
71
|
*/
|
|
92
72
|
function optionsToEndpoint(opts) {
|
|
93
73
|
const endpoint = {};
|
|
94
|
-
(0, encoding_1.copyIfPresent)(endpoint, opts,
|
|
95
|
-
(0, encoding_1.convertIfPresent)(endpoint, opts,
|
|
96
|
-
if (opts.vpcConnector) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
74
|
+
(0, encoding_1.copyIfPresent)(endpoint, opts, "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds", "cpu");
|
|
75
|
+
(0, encoding_1.convertIfPresent)(endpoint, opts, "serviceAccountEmail", "serviceAccount");
|
|
76
|
+
if (opts.vpcConnector !== undefined) {
|
|
77
|
+
if (opts.vpcConnector === null || opts.vpcConnector instanceof options_1.ResetValue) {
|
|
78
|
+
endpoint.vpc = options_1.RESET_VALUE;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const vpc = { connector: opts.vpcConnector };
|
|
82
|
+
(0, encoding_1.convertIfPresent)(vpc, opts, "egressSettings", "vpcConnectorEgressSettings");
|
|
83
|
+
endpoint.vpc = vpc;
|
|
84
|
+
}
|
|
100
85
|
}
|
|
101
|
-
(0, encoding_1.convertIfPresent)(endpoint, opts,
|
|
102
|
-
return typeof mem ===
|
|
86
|
+
(0, encoding_1.convertIfPresent)(endpoint, opts, "availableMemoryMb", "memory", (mem) => {
|
|
87
|
+
return typeof mem === "object" ? mem : MemoryOptionToMB[mem];
|
|
103
88
|
});
|
|
104
|
-
(0, encoding_1.convertIfPresent)(endpoint, opts,
|
|
105
|
-
if (typeof region ===
|
|
89
|
+
(0, encoding_1.convertIfPresent)(endpoint, opts, "region", "region", (region) => {
|
|
90
|
+
if (typeof region === "string") {
|
|
106
91
|
return [region];
|
|
107
92
|
}
|
|
108
93
|
return region;
|
|
109
94
|
});
|
|
110
|
-
(0, encoding_1.convertIfPresent)(endpoint, opts,
|
|
95
|
+
(0, encoding_1.convertIfPresent)(endpoint, opts, "secretEnvironmentVariables", "secrets", (secrets) => secrets.map((secret) => ({ key: secret instanceof types_1.SecretParam ? secret.name : secret })));
|
|
111
96
|
return endpoint;
|
|
112
97
|
}
|
|
113
98
|
exports.optionsToEndpoint = optionsToEndpoint;
|