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.
Files changed (157) hide show
  1. package/lib/_virtual/rolldown_runtime.js +34 -0
  2. package/lib/bin/firebase-functions.js +78 -103
  3. package/lib/common/app.js +35 -55
  4. package/lib/common/change.js +54 -75
  5. package/lib/common/config.js +41 -41
  6. package/lib/common/debug.js +23 -47
  7. package/lib/common/encoding.js +59 -82
  8. package/lib/common/onInit.js +26 -28
  9. package/lib/common/options.js +22 -42
  10. package/lib/common/params.d.ts +6 -6
  11. package/lib/common/params.js +0 -23
  12. package/lib/common/providers/database.js +270 -300
  13. package/lib/common/providers/firestore.js +66 -92
  14. package/lib/common/providers/https.d.ts +0 -1
  15. package/lib/common/providers/https.js +537 -539
  16. package/lib/common/providers/identity.js +393 -444
  17. package/lib/common/providers/tasks.js +64 -98
  18. package/lib/common/timezone.js +544 -542
  19. package/lib/common/trace.d.ts +0 -1
  20. package/lib/common/trace.js +63 -55
  21. package/lib/common/utilities/assertions.d.ts +11 -0
  22. package/lib/common/utilities/assertions.js +18 -0
  23. package/lib/common/utilities/encoder.js +20 -37
  24. package/lib/common/utilities/path-pattern.js +106 -132
  25. package/lib/common/utilities/path.js +28 -27
  26. package/lib/common/utilities/utils.js +23 -45
  27. package/lib/esm/_virtual/rolldown_runtime.mjs +16 -0
  28. package/lib/esm/bin/firebase-functions.mjs +91 -0
  29. package/lib/esm/common/app.mjs +39 -0
  30. package/lib/esm/common/change.mjs +57 -0
  31. package/lib/esm/common/config.mjs +45 -0
  32. package/lib/esm/common/debug.mjs +28 -0
  33. package/lib/esm/common/encoding.mjs +69 -0
  34. package/lib/esm/common/onInit.mjs +33 -0
  35. package/lib/esm/common/options.mjs +22 -0
  36. package/lib/esm/common/params.mjs +1 -0
  37. package/lib/esm/common/providers/database.mjs +269 -0
  38. package/lib/esm/common/providers/firestore.mjs +78 -0
  39. package/lib/esm/common/providers/https.mjs +573 -0
  40. package/lib/esm/common/providers/identity.mjs +428 -0
  41. package/lib/esm/common/providers/tasks.mjs +67 -0
  42. package/lib/esm/common/timezone.mjs +544 -0
  43. package/lib/esm/common/trace.mjs +73 -0
  44. package/lib/esm/common/utilities/assertions.mjs +17 -0
  45. package/lib/esm/common/utilities/encoder.mjs +21 -0
  46. package/lib/esm/common/utilities/path-pattern.mjs +116 -0
  47. package/lib/esm/common/utilities/path.mjs +35 -0
  48. package/lib/esm/common/utilities/utils.mjs +29 -0
  49. package/lib/esm/function-configuration.mjs +1 -0
  50. package/lib/esm/logger/common.mjs +23 -0
  51. package/lib/esm/logger/compat.mjs +25 -0
  52. package/lib/esm/logger/index.mjs +131 -0
  53. package/lib/esm/params/index.mjs +160 -0
  54. package/lib/esm/params/types.mjs +400 -0
  55. package/lib/esm/runtime/loader.mjs +132 -0
  56. package/lib/esm/runtime/manifest.mjs +134 -0
  57. package/lib/esm/types/global.d.mjs +1 -0
  58. package/lib/esm/v1/cloud-functions.mjs +206 -0
  59. package/lib/esm/v1/config.mjs +14 -0
  60. package/lib/esm/v1/function-builder.mjs +252 -0
  61. package/lib/esm/v1/function-configuration.mjs +72 -0
  62. package/lib/esm/v1/index.mjs +27 -0
  63. package/lib/esm/v1/providers/analytics.mjs +212 -0
  64. package/lib/esm/v1/providers/auth.mjs +156 -0
  65. package/lib/esm/v1/providers/database.mjs +243 -0
  66. package/lib/esm/v1/providers/firestore.mjs +131 -0
  67. package/lib/esm/v1/providers/https.mjs +82 -0
  68. package/lib/esm/v1/providers/pubsub.mjs +175 -0
  69. package/lib/esm/v1/providers/remoteConfig.mjs +64 -0
  70. package/lib/esm/v1/providers/storage.mjs +163 -0
  71. package/lib/esm/v1/providers/tasks.mjs +63 -0
  72. package/lib/esm/v1/providers/testLab.mjs +94 -0
  73. package/lib/esm/v2/core.mjs +4 -0
  74. package/lib/esm/v2/index.mjs +28 -0
  75. package/lib/esm/v2/options.mjs +102 -0
  76. package/lib/esm/v2/providers/alerts/alerts.mjs +85 -0
  77. package/lib/esm/v2/providers/alerts/appDistribution.mjs +75 -0
  78. package/lib/esm/v2/providers/alerts/billing.mjs +51 -0
  79. package/lib/esm/v2/providers/alerts/crashlytics.mjs +122 -0
  80. package/lib/esm/v2/providers/alerts/index.mjs +22 -0
  81. package/lib/esm/v2/providers/alerts/performance.mjs +66 -0
  82. package/lib/esm/v2/providers/database.mjs +197 -0
  83. package/lib/esm/v2/providers/dataconnect.mjs +130 -0
  84. package/lib/esm/v2/providers/eventarc.mjs +51 -0
  85. package/lib/esm/v2/providers/firestore.mjs +294 -0
  86. package/lib/esm/v2/providers/https.mjs +210 -0
  87. package/lib/esm/v2/providers/identity.mjs +103 -0
  88. package/lib/esm/v2/providers/pubsub.mjs +148 -0
  89. package/lib/esm/v2/providers/remoteConfig.mjs +52 -0
  90. package/lib/esm/v2/providers/scheduler.mjs +84 -0
  91. package/lib/esm/v2/providers/storage.mjs +155 -0
  92. package/lib/esm/v2/providers/tasks.mjs +65 -0
  93. package/lib/esm/v2/providers/testLab.mjs +53 -0
  94. package/lib/esm/v2/trace.mjs +20 -0
  95. package/lib/function-configuration.d.ts +0 -0
  96. package/lib/function-configuration.js +0 -0
  97. package/lib/logger/common.js +21 -41
  98. package/lib/logger/compat.js +18 -33
  99. package/lib/logger/index.js +119 -130
  100. package/lib/params/index.d.ts +19 -4
  101. package/lib/params/index.js +153 -129
  102. package/lib/params/types.d.ts +17 -0
  103. package/lib/params/types.js +390 -382
  104. package/lib/runtime/loader.js +114 -148
  105. package/lib/runtime/manifest.js +106 -126
  106. package/lib/types/global.d.js +0 -0
  107. package/lib/v1/cloud-functions.d.ts +2 -2
  108. package/lib/v1/cloud-functions.js +193 -241
  109. package/lib/v1/config.d.ts +4 -7
  110. package/lib/v1/config.js +13 -75
  111. package/lib/v1/function-builder.js +239 -368
  112. package/lib/v1/function-configuration.js +70 -63
  113. package/lib/v1/index.js +118 -73
  114. package/lib/v1/providers/analytics.js +189 -210
  115. package/lib/v1/providers/auth.d.ts +2 -1
  116. package/lib/v1/providers/auth.js +159 -164
  117. package/lib/v1/providers/database.js +237 -242
  118. package/lib/v1/providers/firestore.js +131 -130
  119. package/lib/v1/providers/https.d.ts +2 -1
  120. package/lib/v1/providers/https.js +79 -86
  121. package/lib/v1/providers/pubsub.js +175 -172
  122. package/lib/v1/providers/remoteConfig.js +64 -68
  123. package/lib/v1/providers/storage.js +161 -163
  124. package/lib/v1/providers/tasks.d.ts +1 -1
  125. package/lib/v1/providers/tasks.js +65 -80
  126. package/lib/v1/providers/testLab.js +94 -94
  127. package/lib/v2/core.d.ts +1 -1
  128. package/lib/v2/core.js +5 -32
  129. package/lib/v2/index.d.ts +6 -3
  130. package/lib/v2/index.js +123 -75
  131. package/lib/v2/options.js +88 -114
  132. package/lib/v2/providers/alerts/alerts.js +76 -95
  133. package/lib/v2/providers/alerts/appDistribution.js +73 -78
  134. package/lib/v2/providers/alerts/billing.js +49 -53
  135. package/lib/v2/providers/alerts/crashlytics.js +110 -102
  136. package/lib/v2/providers/alerts/index.js +56 -53
  137. package/lib/v2/providers/alerts/performance.js +64 -74
  138. package/lib/v2/providers/database.js +177 -180
  139. package/lib/v2/providers/dataconnect.d.ts +95 -0
  140. package/lib/v2/providers/dataconnect.js +137 -0
  141. package/lib/v2/providers/eventarc.js +55 -77
  142. package/lib/v2/providers/firestore.js +262 -260
  143. package/lib/v2/providers/https.d.ts +3 -2
  144. package/lib/v2/providers/https.js +210 -247
  145. package/lib/v2/providers/identity.d.ts +2 -1
  146. package/lib/v2/providers/identity.js +96 -105
  147. package/lib/v2/providers/pubsub.js +149 -167
  148. package/lib/v2/providers/remoteConfig.js +54 -63
  149. package/lib/v2/providers/scheduler.js +84 -96
  150. package/lib/v2/providers/storage.js +147 -162
  151. package/lib/v2/providers/tasks.d.ts +1 -1
  152. package/lib/v2/providers/tasks.js +68 -95
  153. package/lib/v2/providers/testLab.js +55 -64
  154. package/lib/v2/trace.js +18 -19
  155. package/package.json +290 -226
  156. package/protos/compiledFirestore.mjs +3512 -0
  157. package/protos/update.sh +28 -7
@@ -1,259 +1,222 @@
1
- "use strict";
2
- // The MIT License (MIT)
3
- //
4
- // Copyright (c) 2021 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.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
- * Cloud functions to handle HTTPS request or callable RPCs.
27
- * @packageDocumentation
28
- */
29
- const cors = require("cors");
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
- * @deprecated
49
- *
50
- * An auth policy that requires a user to be both signed in and have a specific claim (optionally with a specific value)
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
- if (!auth) {
54
- return false;
55
- }
56
- if (!(claim in auth.token)) {
57
- return false;
58
- }
59
- return !value || auth.token[claim] === value;
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
- let opts;
64
- if (arguments.length === 1) {
65
- opts = {};
66
- handler = optsOrHandler;
67
- }
68
- else {
69
- opts = optsOrHandler;
70
- }
71
- if ((0, debug_1.isDebugFeatureEnabled)("enableCors") || "cors" in opts) {
72
- let origin = opts.cors instanceof params_1.Expression ? opts.cors.value() : opts.cors;
73
- if ((0, debug_1.isDebugFeatureEnabled)("enableCors")) {
74
- // Respect `cors: false` to turn off cors even if debug feature is enabled.
75
- origin = opts.cors === false ? false : true;
76
- }
77
- // Arrays cause the access-control-allow-origin header to be dynamic based
78
- // on the origin header of the request. If there is only one element in the
79
- // array, this is unnecessary.
80
- if (Array.isArray(origin) && origin.length === 1) {
81
- origin = origin[0];
82
- }
83
- const middleware = cors({ origin });
84
- const userProvidedHandler = handler;
85
- handler = (req, res) => {
86
- return new Promise((resolve) => {
87
- res.on("finish", resolve);
88
- middleware(req, res, () => {
89
- resolve(userProvidedHandler(req, res));
90
- });
91
- });
92
- };
93
- }
94
- handler = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler));
95
- Object.defineProperty(handler, "__trigger", {
96
- get: () => {
97
- const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
98
- // global options calls region a scalar and https allows it to be an array,
99
- // but optionsToTriggerAnnotations handles both cases.
100
- const specificOpts = options.optionsToTriggerAnnotations(opts);
101
- const trigger = {
102
- platform: "gcfv2",
103
- ...baseOpts,
104
- ...specificOpts,
105
- labels: {
106
- ...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
107
- ...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
108
- },
109
- httpsTrigger: {
110
- allowInsecure: false,
111
- },
112
- };
113
- (0, encoding_1.convertIfPresent)(trigger.httpsTrigger, options.getGlobalOptions(), "invoker", "invoker", encoding_1.convertInvoker);
114
- (0, encoding_1.convertIfPresent)(trigger.httpsTrigger, opts, "invoker", "invoker", encoding_1.convertInvoker);
115
- return trigger;
116
- },
117
- });
118
- const globalOpts = options.getGlobalOptions();
119
- const baseOpts = options.optionsToEndpoint(globalOpts);
120
- // global options calls region a scalar and https allows it to be an array,
121
- // but optionsToTriggerAnnotations handles both cases.
122
- const specificOpts = options.optionsToEndpoint(opts);
123
- const endpoint = {
124
- ...(0, manifest_1.initV2Endpoint)(globalOpts, opts),
125
- platform: "gcfv2",
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
- var _a;
142
- let opts;
143
- if (arguments.length === 1) {
144
- opts = {};
145
- handler = optsOrHandler;
146
- }
147
- else {
148
- opts = optsOrHandler;
149
- }
150
- let cors;
151
- if ("cors" in opts) {
152
- if (opts.cors instanceof params_1.Expression) {
153
- cors = opts.cors.value();
154
- }
155
- else {
156
- cors = opts.cors;
157
- }
158
- }
159
- else {
160
- cors = true;
161
- }
162
- let origin = (0, debug_1.isDebugFeatureEnabled)("enableCors") ? true : cors;
163
- // Arrays cause the access-control-allow-origin header to be dynamic based
164
- // on the origin header of the request. If there is only one element in the
165
- // array, this is unnecessary.
166
- if (Array.isArray(origin) && origin.length === 1) {
167
- origin = origin[0];
168
- }
169
- // fix the length of handler to make the call to handler consistent
170
- const fixedLen = (req, resp) => handler(req, resp);
171
- let func = (0, https_1.onCallHandler)({
172
- cors: { origin, methods: "POST" },
173
- enforceAppCheck: (_a = opts.enforceAppCheck) !== null && _a !== void 0 ? _a : options.getGlobalOptions().enforceAppCheck,
174
- consumeAppCheckToken: opts.consumeAppCheckToken,
175
- heartbeatSeconds: opts.heartbeatSeconds,
176
- authPolicy: opts.authPolicy,
177
- }, fixedLen, "gcfv2");
178
- func = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(func));
179
- Object.defineProperty(func, "__trigger", {
180
- get: () => {
181
- const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
182
- // global options calls region a scalar and https allows it to be an array,
183
- // but optionsToTriggerAnnotations handles both cases.
184
- const specificOpts = options.optionsToTriggerAnnotations(opts);
185
- return {
186
- platform: "gcfv2",
187
- ...baseOpts,
188
- ...specificOpts,
189
- labels: {
190
- ...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
191
- ...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
192
- "deployment-callable": "true",
193
- },
194
- httpsTrigger: {
195
- allowInsecure: false,
196
- },
197
- };
198
- },
199
- });
200
- const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
201
- // global options calls region a scalar and https allows it to be an array,
202
- // but optionsToEndpoint handles both cases.
203
- const specificOpts = options.optionsToEndpoint(opts);
204
- func.__endpoint = {
205
- ...(0, manifest_1.initV2Endpoint)(options.getGlobalOptions(), opts),
206
- platform: "gcfv2",
207
- ...baseOpts,
208
- ...specificOpts,
209
- labels: {
210
- ...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
211
- ...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
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
- var _a;
232
- let opts;
233
- if (arguments.length === 2) {
234
- opts = optsOrAction;
235
- }
236
- else {
237
- opts = {};
238
- action = optsOrAction;
239
- }
240
- if (!((_a = opts.secrets) === null || _a === void 0 ? void 0 : _a.length)) {
241
- logger.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.`);
242
- }
243
- const cloudFunction = onCall(opts, async (req, res) => {
244
- const context = {};
245
- (0, encoding_1.copyIfPresent)(context, req, "auth", "app", "instanceIdToken");
246
- if (!req.acceptsStreaming) {
247
- const { result } = await action.run(req.data, { context });
248
- return result;
249
- }
250
- const { stream, output } = action.stream(req.data, { context });
251
- for await (const chunk of stream) {
252
- await res.sendChunk(chunk);
253
- }
254
- return output;
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 { AuthUserRecord, AuthBlockingEvent, HttpsError };
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;