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,259 +1,222 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
exports.onCallGenkit = exports.onCall = exports.onRequest = exports.hasClaim = exports.isSignedIn = exports.HttpsError = void 0;
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_logger_index = require('../../logger/index.js');
|
|
3
|
+
const require_params_types = require('../../params/types.js');
|
|
4
|
+
require('../../params/index.js');
|
|
5
|
+
const require_runtime_manifest = require('../../runtime/manifest.js');
|
|
6
|
+
const require_common_debug = require('../../common/debug.js');
|
|
7
|
+
const require_common_encoding = require('../../common/encoding.js');
|
|
8
|
+
const require_common_onInit = require('../../common/onInit.js');
|
|
9
|
+
const require_common_providers_https = require('../../common/providers/https.js');
|
|
10
|
+
const require_v2_trace = require('../trace.js');
|
|
11
|
+
const require_v2_options = require('../options.js');
|
|
12
|
+
let cors = require("cors");
|
|
13
|
+
cors = require_rolldown_runtime.__toESM(cors);
|
|
14
|
+
|
|
15
|
+
//#region src/v2/providers/https.ts
|
|
16
|
+
var https_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
17
|
+
HttpsError: () => require_common_providers_https.HttpsError,
|
|
18
|
+
hasClaim: () => hasClaim,
|
|
19
|
+
isSignedIn: () => isSignedIn,
|
|
20
|
+
onCall: () => onCall,
|
|
21
|
+
onCallGenkit: () => onCallGenkit,
|
|
22
|
+
onRequest: () => onRequest
|
|
23
|
+
});
|
|
25
24
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const encoding_1 = require("../../common/encoding");
|
|
31
|
-
const trace_1 = require("../trace");
|
|
32
|
-
const debug_1 = require("../../common/debug");
|
|
33
|
-
const https_1 = require("../../common/providers/https");
|
|
34
|
-
Object.defineProperty(exports, "HttpsError", { enumerable: true, get: function () { return https_1.HttpsError; } });
|
|
35
|
-
const manifest_1 = require("../../runtime/manifest");
|
|
36
|
-
const params_1 = require("../../params");
|
|
37
|
-
const options = require("../options");
|
|
38
|
-
const onInit_1 = require("../../common/onInit");
|
|
39
|
-
const logger = require("../../logger");
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated
|
|
42
|
-
*
|
|
43
|
-
* An auth policy that requires a user to be signed in.
|
|
44
|
-
*/
|
|
25
|
+
* @deprecated
|
|
26
|
+
*
|
|
27
|
+
* An auth policy that requires a user to be signed in.
|
|
28
|
+
*/
|
|
45
29
|
const isSignedIn = () => (auth) => !!auth;
|
|
46
|
-
exports.isSignedIn = isSignedIn;
|
|
47
30
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
31
|
+
* @deprecated
|
|
32
|
+
*
|
|
33
|
+
* An auth policy that requires a user to be both signed in and have a specific claim (optionally with a specific value)
|
|
34
|
+
*/
|
|
52
35
|
const hasClaim = (claim, value) => (auth) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
36
|
+
if (!auth) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (!(claim in auth.token)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return !value || auth.token[claim] === value;
|
|
60
43
|
};
|
|
61
|
-
exports.hasClaim = hasClaim;
|
|
62
44
|
function onRequest(optsOrHandler, handler) {
|
|
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
|
-
...baseOpts,
|
|
127
|
-
...specificOpts,
|
|
128
|
-
labels: {
|
|
129
|
-
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
|
130
|
-
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
|
131
|
-
},
|
|
132
|
-
httpsTrigger: {},
|
|
133
|
-
};
|
|
134
|
-
(0, encoding_1.convertIfPresent)(endpoint.httpsTrigger, globalOpts, "invoker", "invoker", encoding_1.convertInvoker);
|
|
135
|
-
(0, encoding_1.convertIfPresent)(endpoint.httpsTrigger, opts, "invoker", "invoker", encoding_1.convertInvoker);
|
|
136
|
-
handler.__endpoint = endpoint;
|
|
137
|
-
return handler;
|
|
45
|
+
let opts;
|
|
46
|
+
if (arguments.length === 1) {
|
|
47
|
+
opts = {};
|
|
48
|
+
handler = optsOrHandler;
|
|
49
|
+
} else {
|
|
50
|
+
opts = optsOrHandler;
|
|
51
|
+
}
|
|
52
|
+
handler = require_common_providers_https.withErrorHandler(handler);
|
|
53
|
+
if (require_common_debug.isDebugFeatureEnabled("enableCors") || "cors" in opts) {
|
|
54
|
+
let origin = opts.cors instanceof require_params_types.Expression ? opts.cors.value() : opts.cors;
|
|
55
|
+
if (require_common_debug.isDebugFeatureEnabled("enableCors")) {
|
|
56
|
+
origin = opts.cors === false ? false : true;
|
|
57
|
+
}
|
|
58
|
+
if (Array.isArray(origin) && origin.length === 1) {
|
|
59
|
+
origin = origin[0];
|
|
60
|
+
}
|
|
61
|
+
const middleware = (0, cors.default)({ origin });
|
|
62
|
+
const userProvidedHandler = handler;
|
|
63
|
+
handler = (req, res) => {
|
|
64
|
+
return new Promise((resolve) => {
|
|
65
|
+
res.on("finish", resolve);
|
|
66
|
+
middleware(req, res, () => {
|
|
67
|
+
resolve(userProvidedHandler(req, res));
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
handler = require_v2_trace.wrapTraceContext(require_common_onInit.withInit(handler));
|
|
73
|
+
Object.defineProperty(handler, "__trigger", { get: () => {
|
|
74
|
+
const baseOpts$1 = require_v2_options.optionsToTriggerAnnotations(require_v2_options.getGlobalOptions());
|
|
75
|
+
const specificOpts$1 = require_v2_options.optionsToTriggerAnnotations(opts);
|
|
76
|
+
const trigger = {
|
|
77
|
+
platform: "gcfv2",
|
|
78
|
+
...baseOpts$1,
|
|
79
|
+
...specificOpts$1,
|
|
80
|
+
labels: {
|
|
81
|
+
...baseOpts$1?.labels,
|
|
82
|
+
...specificOpts$1?.labels
|
|
83
|
+
},
|
|
84
|
+
httpsTrigger: { allowInsecure: false }
|
|
85
|
+
};
|
|
86
|
+
require_common_encoding.convertIfPresent(trigger.httpsTrigger, require_v2_options.getGlobalOptions(), "invoker", "invoker", require_common_encoding.convertInvoker);
|
|
87
|
+
require_common_encoding.convertIfPresent(trigger.httpsTrigger, opts, "invoker", "invoker", require_common_encoding.convertInvoker);
|
|
88
|
+
return trigger;
|
|
89
|
+
} });
|
|
90
|
+
const globalOpts = require_v2_options.getGlobalOptions();
|
|
91
|
+
const baseOpts = require_v2_options.optionsToEndpoint(globalOpts);
|
|
92
|
+
const specificOpts = require_v2_options.optionsToEndpoint(opts);
|
|
93
|
+
const endpoint = {
|
|
94
|
+
...require_runtime_manifest.initV2Endpoint(globalOpts, opts),
|
|
95
|
+
platform: "gcfv2",
|
|
96
|
+
...baseOpts,
|
|
97
|
+
...specificOpts,
|
|
98
|
+
labels: {
|
|
99
|
+
...baseOpts?.labels,
|
|
100
|
+
...specificOpts?.labels
|
|
101
|
+
},
|
|
102
|
+
httpsTrigger: {}
|
|
103
|
+
};
|
|
104
|
+
require_common_encoding.convertIfPresent(endpoint.httpsTrigger, globalOpts, "invoker", "invoker", require_common_encoding.convertInvoker);
|
|
105
|
+
require_common_encoding.convertIfPresent(endpoint.httpsTrigger, opts, "invoker", "invoker", require_common_encoding.convertInvoker);
|
|
106
|
+
handler.__endpoint = endpoint;
|
|
107
|
+
return handler;
|
|
138
108
|
}
|
|
139
|
-
exports.onRequest = onRequest;
|
|
140
109
|
function onCall(optsOrHandler, handler) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
},
|
|
213
|
-
callableTrigger: {},
|
|
214
|
-
};
|
|
215
|
-
// TODO: in the next major version, do auth/appcheck in these helper methods too.
|
|
216
|
-
func.run = (0, onInit_1.withInit)(handler);
|
|
217
|
-
func.stream = () => {
|
|
218
|
-
return {
|
|
219
|
-
stream: {
|
|
220
|
-
next() {
|
|
221
|
-
return Promise.reject("Coming soon");
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
output: Promise.reject("Coming soon"),
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
return func;
|
|
110
|
+
let opts;
|
|
111
|
+
if (arguments.length === 1) {
|
|
112
|
+
opts = {};
|
|
113
|
+
handler = optsOrHandler;
|
|
114
|
+
} else {
|
|
115
|
+
opts = optsOrHandler;
|
|
116
|
+
}
|
|
117
|
+
let cors$2;
|
|
118
|
+
if ("cors" in opts) {
|
|
119
|
+
if (opts.cors instanceof require_params_types.Expression) {
|
|
120
|
+
cors$2 = opts.cors.value();
|
|
121
|
+
} else {
|
|
122
|
+
cors$2 = opts.cors;
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
cors$2 = true;
|
|
126
|
+
}
|
|
127
|
+
let origin = require_common_debug.isDebugFeatureEnabled("enableCors") ? true : cors$2;
|
|
128
|
+
if (Array.isArray(origin) && origin.length === 1) {
|
|
129
|
+
origin = origin[0];
|
|
130
|
+
}
|
|
131
|
+
const fixedLen = (req, resp) => handler(req, resp);
|
|
132
|
+
let func = require_common_providers_https.onCallHandler({
|
|
133
|
+
cors: {
|
|
134
|
+
origin,
|
|
135
|
+
methods: "POST"
|
|
136
|
+
},
|
|
137
|
+
enforceAppCheck: opts.enforceAppCheck ?? require_v2_options.getGlobalOptions().enforceAppCheck,
|
|
138
|
+
consumeAppCheckToken: opts.consumeAppCheckToken,
|
|
139
|
+
heartbeatSeconds: opts.heartbeatSeconds,
|
|
140
|
+
authPolicy: opts.authPolicy
|
|
141
|
+
}, fixedLen, "gcfv2");
|
|
142
|
+
func = require_v2_trace.wrapTraceContext(require_common_onInit.withInit(func));
|
|
143
|
+
Object.defineProperty(func, "__trigger", { get: () => {
|
|
144
|
+
const baseOpts$1 = require_v2_options.optionsToTriggerAnnotations(require_v2_options.getGlobalOptions());
|
|
145
|
+
const specificOpts$1 = require_v2_options.optionsToTriggerAnnotations(opts);
|
|
146
|
+
return {
|
|
147
|
+
platform: "gcfv2",
|
|
148
|
+
...baseOpts$1,
|
|
149
|
+
...specificOpts$1,
|
|
150
|
+
labels: {
|
|
151
|
+
...baseOpts$1?.labels,
|
|
152
|
+
...specificOpts$1?.labels,
|
|
153
|
+
"deployment-callable": "true"
|
|
154
|
+
},
|
|
155
|
+
httpsTrigger: { allowInsecure: false }
|
|
156
|
+
};
|
|
157
|
+
} });
|
|
158
|
+
const baseOpts = require_v2_options.optionsToEndpoint(require_v2_options.getGlobalOptions());
|
|
159
|
+
const specificOpts = require_v2_options.optionsToEndpoint(opts);
|
|
160
|
+
func.__endpoint = {
|
|
161
|
+
...require_runtime_manifest.initV2Endpoint(require_v2_options.getGlobalOptions(), opts),
|
|
162
|
+
platform: "gcfv2",
|
|
163
|
+
...baseOpts,
|
|
164
|
+
...specificOpts,
|
|
165
|
+
labels: {
|
|
166
|
+
...baseOpts?.labels,
|
|
167
|
+
...specificOpts?.labels
|
|
168
|
+
},
|
|
169
|
+
callableTrigger: {}
|
|
170
|
+
};
|
|
171
|
+
func.run = require_common_onInit.withInit(handler);
|
|
172
|
+
func.stream = () => {
|
|
173
|
+
return {
|
|
174
|
+
stream: { next() {
|
|
175
|
+
return Promise.reject("Coming soon");
|
|
176
|
+
} },
|
|
177
|
+
output: Promise.reject("Coming soon")
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
return func;
|
|
228
181
|
}
|
|
229
|
-
exports.onCall = onCall;
|
|
230
182
|
function onCallGenkit(optsOrAction, action) {
|
|
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
|
-
|
|
256
|
-
cloudFunction.__endpoint.callableTrigger.genkitAction = action.__action.name;
|
|
257
|
-
return cloudFunction;
|
|
183
|
+
let opts;
|
|
184
|
+
if (arguments.length === 2) {
|
|
185
|
+
opts = optsOrAction;
|
|
186
|
+
} else {
|
|
187
|
+
opts = {};
|
|
188
|
+
action = optsOrAction;
|
|
189
|
+
}
|
|
190
|
+
if (!opts.secrets?.length) {
|
|
191
|
+
require_logger_index.debug(`Genkit function for ${action.__action.name} is not bound to any secret. This may mean that you are not storing API keys as a secret or that you are not binding your secret to this function. See https://firebase.google.com/docs/functions/config-env?gen=2nd#secret_parameters for more information.`);
|
|
192
|
+
}
|
|
193
|
+
const cloudFunction = onCall(opts, async (req, res) => {
|
|
194
|
+
const context = {};
|
|
195
|
+
require_common_encoding.copyIfPresent(context, req, "auth", "app", "instanceIdToken");
|
|
196
|
+
if (!req.acceptsStreaming) {
|
|
197
|
+
const { result } = await action.run(req.data, { context });
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
const { stream, output } = action.stream(req.data, { context });
|
|
201
|
+
for await (const chunk of stream) {
|
|
202
|
+
await res.sendChunk(chunk);
|
|
203
|
+
}
|
|
204
|
+
return output;
|
|
205
|
+
});
|
|
206
|
+
cloudFunction.__endpoint.callableTrigger.genkitAction = action.__action.name;
|
|
207
|
+
return cloudFunction;
|
|
258
208
|
}
|
|
209
|
+
|
|
210
|
+
//#endregion
|
|
211
|
+
exports.HttpsError = require_common_providers_https.HttpsError;
|
|
212
|
+
exports.hasClaim = hasClaim;
|
|
213
|
+
Object.defineProperty(exports, 'https_exports', {
|
|
214
|
+
enumerable: true,
|
|
215
|
+
get: function () {
|
|
216
|
+
return https_exports;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
exports.isSignedIn = isSignedIn;
|
|
220
|
+
exports.onCall = onCall;
|
|
259
221
|
exports.onCallGenkit = onCallGenkit;
|
|
222
|
+
exports.onRequest = onRequest;
|
|
@@ -8,7 +8,8 @@ import { BlockingFunction } from "../../v1/cloud-functions";
|
|
|
8
8
|
import { Expression } from "../../params";
|
|
9
9
|
import * as options from "../options";
|
|
10
10
|
import { SecretParam } from "../../params/types";
|
|
11
|
-
export {
|
|
11
|
+
export { HttpsError };
|
|
12
|
+
export type { AuthUserRecord, AuthBlockingEvent };
|
|
12
13
|
/** @hidden Internally used when parsing the options. */
|
|
13
14
|
interface InternalOptions {
|
|
14
15
|
opts: options.GlobalOptions;
|