firebase-functions 6.5.0 → 7.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/lib/_virtual/rolldown_runtime.js +34 -0
- package/lib/bin/firebase-functions.js +78 -103
- package/lib/common/app.js +35 -55
- package/lib/common/change.js +54 -75
- package/lib/common/config.js +41 -41
- package/lib/common/debug.js +23 -47
- package/lib/common/encoding.js +59 -82
- package/lib/common/onInit.js +26 -28
- package/lib/common/options.js +22 -42
- package/lib/common/params.d.ts +6 -6
- package/lib/common/params.js +0 -23
- package/lib/common/providers/database.js +270 -300
- package/lib/common/providers/firestore.js +66 -92
- package/lib/common/providers/https.d.ts +0 -1
- package/lib/common/providers/https.js +537 -539
- package/lib/common/providers/identity.js +393 -444
- package/lib/common/providers/tasks.js +64 -98
- package/lib/common/timezone.js +544 -542
- package/lib/common/trace.d.ts +0 -1
- package/lib/common/trace.js +63 -55
- package/lib/common/utilities/assertions.d.ts +11 -0
- package/lib/common/utilities/assertions.js +18 -0
- package/lib/common/utilities/encoder.js +20 -37
- package/lib/common/utilities/path-pattern.js +106 -132
- package/lib/common/utilities/path.js +28 -27
- package/lib/common/utilities/utils.js +23 -45
- package/lib/esm/_virtual/rolldown_runtime.mjs +16 -0
- package/lib/esm/bin/firebase-functions.mjs +91 -0
- package/lib/esm/common/app.mjs +39 -0
- package/lib/esm/common/change.mjs +57 -0
- package/lib/esm/common/config.mjs +45 -0
- package/lib/esm/common/debug.mjs +28 -0
- package/lib/esm/common/encoding.mjs +69 -0
- package/lib/esm/common/onInit.mjs +33 -0
- package/lib/esm/common/options.mjs +22 -0
- package/lib/esm/common/params.mjs +1 -0
- package/lib/esm/common/providers/database.mjs +269 -0
- package/lib/esm/common/providers/firestore.mjs +78 -0
- package/lib/esm/common/providers/https.mjs +573 -0
- package/lib/esm/common/providers/identity.mjs +428 -0
- package/lib/esm/common/providers/tasks.mjs +67 -0
- package/lib/esm/common/timezone.mjs +544 -0
- package/lib/esm/common/trace.mjs +73 -0
- package/lib/esm/common/utilities/assertions.mjs +17 -0
- package/lib/esm/common/utilities/encoder.mjs +21 -0
- package/lib/esm/common/utilities/path-pattern.mjs +116 -0
- package/lib/esm/common/utilities/path.mjs +35 -0
- package/lib/esm/common/utilities/utils.mjs +29 -0
- package/lib/esm/function-configuration.mjs +1 -0
- package/lib/esm/logger/common.mjs +23 -0
- package/lib/esm/logger/compat.mjs +25 -0
- package/lib/esm/logger/index.mjs +131 -0
- package/lib/esm/params/index.mjs +160 -0
- package/lib/esm/params/types.mjs +400 -0
- package/lib/esm/runtime/loader.mjs +132 -0
- package/lib/esm/runtime/manifest.mjs +134 -0
- package/lib/esm/types/global.d.mjs +1 -0
- package/lib/esm/v1/cloud-functions.mjs +206 -0
- package/lib/esm/v1/config.mjs +14 -0
- package/lib/esm/v1/function-builder.mjs +252 -0
- package/lib/esm/v1/function-configuration.mjs +72 -0
- package/lib/esm/v1/index.mjs +27 -0
- package/lib/esm/v1/providers/analytics.mjs +212 -0
- package/lib/esm/v1/providers/auth.mjs +156 -0
- package/lib/esm/v1/providers/database.mjs +243 -0
- package/lib/esm/v1/providers/firestore.mjs +131 -0
- package/lib/esm/v1/providers/https.mjs +82 -0
- package/lib/esm/v1/providers/pubsub.mjs +175 -0
- package/lib/esm/v1/providers/remoteConfig.mjs +64 -0
- package/lib/esm/v1/providers/storage.mjs +163 -0
- package/lib/esm/v1/providers/tasks.mjs +63 -0
- package/lib/esm/v1/providers/testLab.mjs +94 -0
- package/lib/esm/v2/core.mjs +4 -0
- package/lib/esm/v2/index.mjs +28 -0
- package/lib/esm/v2/options.mjs +102 -0
- package/lib/esm/v2/providers/alerts/alerts.mjs +85 -0
- package/lib/esm/v2/providers/alerts/appDistribution.mjs +75 -0
- package/lib/esm/v2/providers/alerts/billing.mjs +51 -0
- package/lib/esm/v2/providers/alerts/crashlytics.mjs +122 -0
- package/lib/esm/v2/providers/alerts/index.mjs +22 -0
- package/lib/esm/v2/providers/alerts/performance.mjs +66 -0
- package/lib/esm/v2/providers/database.mjs +197 -0
- package/lib/esm/v2/providers/dataconnect.mjs +130 -0
- package/lib/esm/v2/providers/eventarc.mjs +51 -0
- package/lib/esm/v2/providers/firestore.mjs +294 -0
- package/lib/esm/v2/providers/https.mjs +210 -0
- package/lib/esm/v2/providers/identity.mjs +103 -0
- package/lib/esm/v2/providers/pubsub.mjs +148 -0
- package/lib/esm/v2/providers/remoteConfig.mjs +52 -0
- package/lib/esm/v2/providers/scheduler.mjs +84 -0
- package/lib/esm/v2/providers/storage.mjs +155 -0
- package/lib/esm/v2/providers/tasks.mjs +65 -0
- package/lib/esm/v2/providers/testLab.mjs +53 -0
- package/lib/esm/v2/trace.mjs +20 -0
- package/lib/function-configuration.d.ts +0 -0
- package/lib/function-configuration.js +0 -0
- package/lib/logger/common.js +21 -41
- package/lib/logger/compat.js +18 -33
- package/lib/logger/index.js +119 -130
- package/lib/params/index.d.ts +19 -4
- package/lib/params/index.js +153 -129
- package/lib/params/types.d.ts +17 -0
- package/lib/params/types.js +390 -382
- package/lib/runtime/loader.js +114 -148
- package/lib/runtime/manifest.js +106 -126
- package/lib/types/global.d.js +0 -0
- package/lib/v1/cloud-functions.d.ts +2 -2
- package/lib/v1/cloud-functions.js +193 -241
- package/lib/v1/config.d.ts +4 -7
- package/lib/v1/config.js +13 -75
- package/lib/v1/function-builder.js +239 -368
- package/lib/v1/function-configuration.js +70 -63
- package/lib/v1/index.js +118 -73
- package/lib/v1/providers/analytics.js +189 -210
- package/lib/v1/providers/auth.d.ts +2 -1
- package/lib/v1/providers/auth.js +159 -164
- package/lib/v1/providers/database.js +237 -242
- package/lib/v1/providers/firestore.js +131 -130
- package/lib/v1/providers/https.d.ts +2 -1
- package/lib/v1/providers/https.js +79 -86
- package/lib/v1/providers/pubsub.js +175 -172
- package/lib/v1/providers/remoteConfig.js +64 -68
- package/lib/v1/providers/storage.js +161 -163
- package/lib/v1/providers/tasks.d.ts +1 -1
- package/lib/v1/providers/tasks.js +65 -80
- package/lib/v1/providers/testLab.js +94 -94
- package/lib/v2/core.d.ts +1 -1
- package/lib/v2/core.js +5 -32
- package/lib/v2/index.d.ts +6 -3
- package/lib/v2/index.js +123 -75
- package/lib/v2/options.js +88 -114
- package/lib/v2/providers/alerts/alerts.js +76 -95
- package/lib/v2/providers/alerts/appDistribution.js +73 -78
- package/lib/v2/providers/alerts/billing.js +49 -53
- package/lib/v2/providers/alerts/crashlytics.js +110 -102
- package/lib/v2/providers/alerts/index.js +56 -53
- package/lib/v2/providers/alerts/performance.js +64 -74
- package/lib/v2/providers/database.js +177 -180
- package/lib/v2/providers/dataconnect.d.ts +95 -0
- package/lib/v2/providers/dataconnect.js +137 -0
- package/lib/v2/providers/eventarc.js +55 -77
- package/lib/v2/providers/firestore.js +262 -260
- package/lib/v2/providers/https.d.ts +3 -2
- package/lib/v2/providers/https.js +210 -247
- package/lib/v2/providers/identity.d.ts +2 -1
- package/lib/v2/providers/identity.js +96 -105
- package/lib/v2/providers/pubsub.js +149 -167
- package/lib/v2/providers/remoteConfig.js +54 -63
- package/lib/v2/providers/scheduler.js +84 -96
- package/lib/v2/providers/storage.js +147 -162
- package/lib/v2/providers/tasks.d.ts +1 -1
- package/lib/v2/providers/tasks.js +68 -95
- package/lib/v2/providers/testLab.js +55 -64
- package/lib/v2/trace.js +18 -19
- package/package.json +290 -226
- package/protos/compiledFirestore.mjs +3512 -0
- package/protos/update.sh +28 -7
|
@@ -1,257 +1,209 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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.optionsToEndpoint = exports.optionsToTrigger = exports.makeCloudFunction = exports.Change = void 0;
|
|
25
|
-
const logger_1 = require("../logger");
|
|
26
|
-
const function_configuration_1 = require("./function-configuration");
|
|
27
|
-
const encoding_1 = require("../common/encoding");
|
|
28
|
-
const manifest_1 = require("../runtime/manifest");
|
|
29
|
-
const options_1 = require("../common/options");
|
|
30
|
-
const types_1 = require("../params/types");
|
|
31
|
-
const onInit_1 = require("../common/onInit");
|
|
32
|
-
var change_1 = require("../common/change");
|
|
33
|
-
Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return change_1.Change; } });
|
|
1
|
+
const require_logger_index = require('../logger/index.js');
|
|
2
|
+
const require_params_types = require('../params/types.js');
|
|
3
|
+
const require_common_options = require('../common/options.js');
|
|
4
|
+
const require_runtime_manifest = require('../runtime/manifest.js');
|
|
5
|
+
const require_common_change = require('../common/change.js');
|
|
6
|
+
const require_common_encoding = require('../common/encoding.js');
|
|
7
|
+
const require_common_onInit = require('../common/onInit.js');
|
|
8
|
+
const require_v1_function_configuration = require('./function-configuration.js');
|
|
9
|
+
|
|
10
|
+
//#region src/v1/cloud-functions.ts
|
|
34
11
|
/** @internal */
|
|
35
12
|
const WILDCARD_REGEX = new RegExp("{[^/{}]*}", "g");
|
|
36
13
|
/** @internal */
|
|
37
|
-
function makeCloudFunction({ contextOnlyHandler, dataConstructor = (raw) => raw.data, eventType, handler, labels = {}, legacyEventType, options = {}, provider, service, triggerResource
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
// Note: We intentionally don't make use of labels args here.
|
|
132
|
-
// labels is used to pass SDK-defined labels to the trigger, which isn't
|
|
133
|
-
// something we will do in the container contract world.
|
|
134
|
-
endpoint.labels = { ...endpoint.labels };
|
|
135
|
-
return endpoint;
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
if (options.schedule) {
|
|
139
|
-
cloudFunction.__requiredAPIs = [
|
|
140
|
-
{
|
|
141
|
-
api: "cloudscheduler.googleapis.com",
|
|
142
|
-
reason: "Needed for scheduled functions.",
|
|
143
|
-
},
|
|
144
|
-
];
|
|
145
|
-
}
|
|
146
|
-
cloudFunction.run = handler || contextOnlyHandler;
|
|
147
|
-
return cloudFunction;
|
|
14
|
+
function makeCloudFunction({ contextOnlyHandler, dataConstructor = (raw) => raw.data, eventType, handler, labels = {}, legacyEventType, options = {}, provider, service, triggerResource }) {
|
|
15
|
+
handler = require_common_onInit.withInit(handler ?? contextOnlyHandler);
|
|
16
|
+
const cloudFunction = (data, context) => {
|
|
17
|
+
if (legacyEventType && context.eventType === legacyEventType) {
|
|
18
|
+
context.eventType = provider + "." + eventType;
|
|
19
|
+
context.resource = {
|
|
20
|
+
service,
|
|
21
|
+
name: context.resource
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const event = {
|
|
25
|
+
data,
|
|
26
|
+
context
|
|
27
|
+
};
|
|
28
|
+
if (provider === "google.firebase.database") {
|
|
29
|
+
context.authType = _detectAuthType(event);
|
|
30
|
+
if (context.authType !== "ADMIN") {
|
|
31
|
+
context.auth = _makeAuth(event, context.authType);
|
|
32
|
+
} else {
|
|
33
|
+
delete context.auth;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (triggerResource() == null) {
|
|
37
|
+
Object.defineProperty(context, "params", { get: () => {
|
|
38
|
+
throw new Error("context.params is not available when using the handler namespace.");
|
|
39
|
+
} });
|
|
40
|
+
} else {
|
|
41
|
+
context.params = context.params || _makeParams(context, triggerResource);
|
|
42
|
+
}
|
|
43
|
+
let promise;
|
|
44
|
+
if (labels && labels["deployment-scheduled"]) {
|
|
45
|
+
promise = contextOnlyHandler(context);
|
|
46
|
+
} else {
|
|
47
|
+
const dataOrChange = dataConstructor(event);
|
|
48
|
+
promise = handler(dataOrChange, context);
|
|
49
|
+
}
|
|
50
|
+
if (typeof promise === "undefined") {
|
|
51
|
+
require_logger_index.warn("Function returned undefined, expected Promise or value");
|
|
52
|
+
}
|
|
53
|
+
return Promise.resolve(promise);
|
|
54
|
+
};
|
|
55
|
+
Object.defineProperty(cloudFunction, "__trigger", { get: () => {
|
|
56
|
+
if (triggerResource() == null) {
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
const trigger = {
|
|
60
|
+
...optionsToTrigger(options),
|
|
61
|
+
eventTrigger: {
|
|
62
|
+
resource: triggerResource(),
|
|
63
|
+
eventType: legacyEventType || provider + "." + eventType,
|
|
64
|
+
service
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
if (!!labels && Object.keys(labels).length) {
|
|
68
|
+
trigger.labels = {
|
|
69
|
+
...trigger.labels,
|
|
70
|
+
...labels
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return trigger;
|
|
74
|
+
} });
|
|
75
|
+
Object.defineProperty(cloudFunction, "__endpoint", { get: () => {
|
|
76
|
+
if (triggerResource() == null) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
const endpoint = {
|
|
80
|
+
platform: "gcfv1",
|
|
81
|
+
...require_runtime_manifest.initV1Endpoint(options),
|
|
82
|
+
...optionsToEndpoint(options)
|
|
83
|
+
};
|
|
84
|
+
if (options.schedule) {
|
|
85
|
+
endpoint.scheduleTrigger = require_runtime_manifest.initV1ScheduleTrigger(options.schedule.schedule, options);
|
|
86
|
+
require_common_encoding.copyIfPresent(endpoint.scheduleTrigger, options.schedule, "timeZone");
|
|
87
|
+
require_common_encoding.copyIfPresent(endpoint.scheduleTrigger.retryConfig, options.schedule.retryConfig, "retryCount", "maxDoublings", "maxBackoffDuration", "maxRetryDuration", "minBackoffDuration");
|
|
88
|
+
} else {
|
|
89
|
+
endpoint.eventTrigger = {
|
|
90
|
+
eventType: legacyEventType || provider + "." + eventType,
|
|
91
|
+
eventFilters: { resource: triggerResource() },
|
|
92
|
+
retry: !!options.failurePolicy
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
endpoint.labels = { ...endpoint.labels };
|
|
96
|
+
return endpoint;
|
|
97
|
+
} });
|
|
98
|
+
if (options.schedule) {
|
|
99
|
+
cloudFunction.__requiredAPIs = [{
|
|
100
|
+
api: "cloudscheduler.googleapis.com",
|
|
101
|
+
reason: "Needed for scheduled functions."
|
|
102
|
+
}];
|
|
103
|
+
}
|
|
104
|
+
cloudFunction.run = handler || contextOnlyHandler;
|
|
105
|
+
return cloudFunction;
|
|
148
106
|
}
|
|
149
|
-
exports.makeCloudFunction = makeCloudFunction;
|
|
150
107
|
function _makeParams(context, triggerResourceGetter) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
params[wildcardNoBraces] = eventResourceParts[position];
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return params;
|
|
108
|
+
if (context.params) {
|
|
109
|
+
return context.params;
|
|
110
|
+
}
|
|
111
|
+
if (!context.resource) {
|
|
112
|
+
return {};
|
|
113
|
+
}
|
|
114
|
+
const triggerResource = triggerResourceGetter();
|
|
115
|
+
const wildcards = triggerResource.match(WILDCARD_REGEX);
|
|
116
|
+
const params = {};
|
|
117
|
+
const eventResourceParts = context?.resource?.name?.split?.("/");
|
|
118
|
+
if (wildcards && eventResourceParts) {
|
|
119
|
+
const triggerResourceParts = triggerResource.split("/");
|
|
120
|
+
for (const wildcard of wildcards) {
|
|
121
|
+
const wildcardNoBraces = wildcard.slice(1, -1);
|
|
122
|
+
const position = triggerResourceParts.indexOf(wildcard);
|
|
123
|
+
params[wildcardNoBraces] = eventResourceParts[position];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return params;
|
|
174
127
|
}
|
|
175
128
|
function _makeAuth(event, authType) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
};
|
|
129
|
+
if (authType === "UNAUTHENTICATED") {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
uid: event.context?.auth?.variable?.uid,
|
|
134
|
+
token: event.context?.auth?.variable?.token
|
|
135
|
+
};
|
|
184
136
|
}
|
|
185
137
|
function _detectAuthType(event) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return "UNAUTHENTICATED";
|
|
138
|
+
if (event.context?.auth?.admin) {
|
|
139
|
+
return "ADMIN";
|
|
140
|
+
}
|
|
141
|
+
if (event.context?.auth?.variable) {
|
|
142
|
+
return "USER";
|
|
143
|
+
}
|
|
144
|
+
return "UNAUTHENTICATED";
|
|
194
145
|
}
|
|
195
146
|
/** @hidden */
|
|
196
147
|
function optionsToTrigger(options) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
(0, encoding_1.convertIfPresent)(trigger, options, "serviceAccountEmail", "serviceAccount", encoding_1.serviceAccountFromShorthand);
|
|
224
|
-
return trigger;
|
|
148
|
+
const trigger = {};
|
|
149
|
+
require_common_encoding.copyIfPresent(trigger, options, "regions", "schedule", "minInstances", "maxInstances", "ingressSettings", "vpcConnectorEgressSettings", "vpcConnector", "labels", "secrets");
|
|
150
|
+
require_common_encoding.convertIfPresent(trigger, options, "failurePolicy", "failurePolicy", (policy) => {
|
|
151
|
+
if (policy === false) {
|
|
152
|
+
return undefined;
|
|
153
|
+
} else if (policy === true) {
|
|
154
|
+
return require_v1_function_configuration.DEFAULT_FAILURE_POLICY;
|
|
155
|
+
} else {
|
|
156
|
+
return policy;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
require_common_encoding.convertIfPresent(trigger, options, "timeout", "timeoutSeconds", require_common_encoding.durationFromSeconds);
|
|
160
|
+
require_common_encoding.convertIfPresent(trigger, options, "availableMemoryMb", "memory", (mem) => {
|
|
161
|
+
const memoryLookup = {
|
|
162
|
+
"128MB": 128,
|
|
163
|
+
"256MB": 256,
|
|
164
|
+
"512MB": 512,
|
|
165
|
+
"1GB": 1024,
|
|
166
|
+
"2GB": 2048,
|
|
167
|
+
"4GB": 4096,
|
|
168
|
+
"8GB": 8192
|
|
169
|
+
};
|
|
170
|
+
return memoryLookup[mem];
|
|
171
|
+
});
|
|
172
|
+
require_common_encoding.convertIfPresent(trigger, options, "serviceAccountEmail", "serviceAccount", require_common_encoding.serviceAccountFromShorthand);
|
|
173
|
+
return trigger;
|
|
225
174
|
}
|
|
226
|
-
exports.optionsToTrigger = optionsToTrigger;
|
|
227
175
|
function optionsToEndpoint(options) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
return endpoint;
|
|
176
|
+
const endpoint = {};
|
|
177
|
+
require_common_encoding.copyIfPresent(endpoint, options, "omit", "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds");
|
|
178
|
+
require_common_encoding.convertIfPresent(endpoint, options, "region", "regions");
|
|
179
|
+
require_common_encoding.convertIfPresent(endpoint, options, "serviceAccountEmail", "serviceAccount", (sa) => sa);
|
|
180
|
+
require_common_encoding.convertIfPresent(endpoint, options, "secretEnvironmentVariables", "secrets", (secrets) => secrets.map((secret) => ({ key: secret instanceof require_params_types.SecretParam ? secret.name : secret })));
|
|
181
|
+
if (options?.vpcConnector !== undefined) {
|
|
182
|
+
if (options.vpcConnector === null || options.vpcConnector instanceof require_common_options.ResetValue) {
|
|
183
|
+
endpoint.vpc = require_common_options.RESET_VALUE;
|
|
184
|
+
} else {
|
|
185
|
+
const vpc = { connector: options.vpcConnector };
|
|
186
|
+
require_common_encoding.convertIfPresent(vpc, options, "egressSettings", "vpcConnectorEgressSettings");
|
|
187
|
+
endpoint.vpc = vpc;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
require_common_encoding.convertIfPresent(endpoint, options, "availableMemoryMb", "memory", (mem) => {
|
|
191
|
+
const memoryLookup = {
|
|
192
|
+
"128MB": 128,
|
|
193
|
+
"256MB": 256,
|
|
194
|
+
"512MB": 512,
|
|
195
|
+
"1GB": 1024,
|
|
196
|
+
"2GB": 2048,
|
|
197
|
+
"4GB": 4096,
|
|
198
|
+
"8GB": 8192
|
|
199
|
+
};
|
|
200
|
+
return typeof mem === "object" ? mem : memoryLookup[mem];
|
|
201
|
+
});
|
|
202
|
+
return endpoint;
|
|
256
203
|
}
|
|
204
|
+
|
|
205
|
+
//#endregion
|
|
206
|
+
exports.Change = require_common_change.Change;
|
|
207
|
+
exports.makeCloudFunction = makeCloudFunction;
|
|
257
208
|
exports.optionsToEndpoint = optionsToEndpoint;
|
|
209
|
+
exports.optionsToTrigger = optionsToTrigger;
|
package/lib/v1/config.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
export { firebaseConfig } from "../common/config";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* https://firebase.google.com/docs/functions/config-env.
|
|
7
|
-
*
|
|
8
|
-
* @deprecated Using functions.config() is discouraged. See https://firebase.google.com/docs/functions/config-env.
|
|
3
|
+
* @deprecated `functions.config()` has been removed in firebase-functions v7.
|
|
4
|
+
* Migrate to environment parameters using the `params` module immediately.
|
|
5
|
+
* Migration guide: https://firebase.google.com/docs/functions/config-env#migrate-config
|
|
9
6
|
*/
|
|
10
|
-
export declare
|
|
7
|
+
export declare const config: never;
|
package/lib/v1/config.js
CHANGED
|
@@ -1,77 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// Copyright (c) 2017 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.config = exports.resetCache = exports.singleton = exports.firebaseConfig = void 0;
|
|
25
|
-
const fs = require("fs");
|
|
26
|
-
const path = require("path");
|
|
27
|
-
var config_1 = require("../common/config");
|
|
28
|
-
Object.defineProperty(exports, "firebaseConfig", { enumerable: true, get: function () { return config_1.firebaseConfig; } });
|
|
29
|
-
/** @internal */
|
|
30
|
-
function resetCache() {
|
|
31
|
-
exports.singleton = undefined;
|
|
32
|
-
}
|
|
33
|
-
exports.resetCache = resetCache;
|
|
1
|
+
const require_common_config = require('../common/config.js');
|
|
2
|
+
|
|
3
|
+
//#region src/v1/config.ts
|
|
34
4
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (process.env.K_CONFIGURATION) {
|
|
45
|
-
throw new Error("functions.config() is no longer available in Cloud Functions for " +
|
|
46
|
-
"Firebase v2. Please see the latest documentation for information " +
|
|
47
|
-
"on how to transition to using environment variables");
|
|
48
|
-
}
|
|
49
|
-
if (typeof exports.singleton === "undefined") {
|
|
50
|
-
init();
|
|
51
|
-
}
|
|
52
|
-
return exports.singleton;
|
|
53
|
-
}
|
|
5
|
+
* @deprecated `functions.config()` has been removed in firebase-functions v7.
|
|
6
|
+
* Migrate to environment parameters using the `params` module immediately.
|
|
7
|
+
* Migration guide: https://firebase.google.com/docs/functions/config-env#migrate-config
|
|
8
|
+
*/
|
|
9
|
+
const config = (() => {
|
|
10
|
+
throw new Error("functions.config() has been removed in firebase-functions v7. " + "Migrate to environment parameters using the params module. " + "Migration guide: https://firebase.google.com/docs/functions/config-env#migrate-config");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
54
14
|
exports.config = config;
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
const parsed = JSON.parse(process.env.CLOUD_RUNTIME_CONFIG);
|
|
58
|
-
delete parsed.firebase;
|
|
59
|
-
exports.singleton = parsed;
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
// Do nothing
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
const configPath = process.env.CLOUD_RUNTIME_CONFIG || path.join(process.cwd(), ".runtimeconfig.json");
|
|
67
|
-
const contents = fs.readFileSync(configPath);
|
|
68
|
-
const parsed = JSON.parse(contents.toString("utf8"));
|
|
69
|
-
delete parsed.firebase;
|
|
70
|
-
exports.singleton = parsed;
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
// Do nothing
|
|
75
|
-
}
|
|
76
|
-
exports.singleton = {};
|
|
77
|
-
}
|
|
15
|
+
exports.firebaseConfig = require_common_config.firebaseConfig;
|