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,257 +1,209 @@
1
- "use strict";
2
- // The MIT License (MIT)
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.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
- handler = (0, onInit_1.withInit)(handler !== null && handler !== void 0 ? handler : contextOnlyHandler);
39
- const cloudFunction = (data, context) => {
40
- if (legacyEventType && context.eventType === legacyEventType) {
41
- /*
42
- * v1beta1 event flow has different format for context, transform them to
43
- * new format.
44
- */
45
- context.eventType = provider + "." + eventType;
46
- context.resource = {
47
- service,
48
- name: context.resource,
49
- };
50
- }
51
- const event = {
52
- data,
53
- context,
54
- };
55
- if (provider === "google.firebase.database") {
56
- context.authType = _detectAuthType(event);
57
- if (context.authType !== "ADMIN") {
58
- context.auth = _makeAuth(event, context.authType);
59
- }
60
- else {
61
- delete context.auth;
62
- }
63
- }
64
- if (triggerResource() == null) {
65
- Object.defineProperty(context, "params", {
66
- get: () => {
67
- throw new Error("context.params is not available when using the handler namespace.");
68
- },
69
- });
70
- }
71
- else {
72
- context.params = context.params || _makeParams(context, triggerResource);
73
- }
74
- let promise;
75
- if (labels && labels["deployment-scheduled"]) {
76
- // Scheduled function do not have meaningful data, so exclude it
77
- promise = contextOnlyHandler(context);
78
- }
79
- else {
80
- const dataOrChange = dataConstructor(event);
81
- promise = handler(dataOrChange, context);
82
- }
83
- if (typeof promise === "undefined") {
84
- (0, logger_1.warn)("Function returned undefined, expected Promise or value");
85
- }
86
- return Promise.resolve(promise);
87
- };
88
- Object.defineProperty(cloudFunction, "__trigger", {
89
- get: () => {
90
- if (triggerResource() == null) {
91
- return {};
92
- }
93
- const trigger = {
94
- ...optionsToTrigger(options),
95
- eventTrigger: {
96
- resource: triggerResource(),
97
- eventType: legacyEventType || provider + "." + eventType,
98
- service,
99
- },
100
- };
101
- if (!!labels && Object.keys(labels).length) {
102
- trigger.labels = { ...trigger.labels, ...labels };
103
- }
104
- return trigger;
105
- },
106
- });
107
- Object.defineProperty(cloudFunction, "__endpoint", {
108
- get: () => {
109
- if (triggerResource() == null) {
110
- return undefined;
111
- }
112
- const endpoint = {
113
- platform: "gcfv1",
114
- ...(0, manifest_1.initV1Endpoint)(options),
115
- ...optionsToEndpoint(options),
116
- };
117
- if (options.schedule) {
118
- endpoint.scheduleTrigger = (0, manifest_1.initV1ScheduleTrigger)(options.schedule.schedule, options);
119
- (0, encoding_1.copyIfPresent)(endpoint.scheduleTrigger, options.schedule, "timeZone");
120
- (0, encoding_1.copyIfPresent)(endpoint.scheduleTrigger.retryConfig, options.schedule.retryConfig, "retryCount", "maxDoublings", "maxBackoffDuration", "maxRetryDuration", "minBackoffDuration");
121
- }
122
- else {
123
- endpoint.eventTrigger = {
124
- eventType: legacyEventType || provider + "." + eventType,
125
- eventFilters: {
126
- resource: triggerResource(),
127
- },
128
- retry: !!options.failurePolicy,
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
- var _a, _b, _c;
152
- if (context.params) {
153
- // In unit testing, user may directly provide `context.params`.
154
- return context.params;
155
- }
156
- if (!context.resource) {
157
- // In unit testing, `resource` may be unpopulated for a test event.
158
- return {};
159
- }
160
- const triggerResource = triggerResourceGetter();
161
- const wildcards = triggerResource.match(WILDCARD_REGEX);
162
- const params = {};
163
- // Note: some tests don't set context.resource.name
164
- const eventResourceParts = (_c = (_b = (_a = context === null || context === void 0 ? void 0 : context.resource) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.split) === null || _c === void 0 ? void 0 : _c.call(_b, "/");
165
- if (wildcards && eventResourceParts) {
166
- const triggerResourceParts = triggerResource.split("/");
167
- for (const wildcard of wildcards) {
168
- const wildcardNoBraces = wildcard.slice(1, -1);
169
- const position = triggerResourceParts.indexOf(wildcard);
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
- var _a, _b, _c, _d, _e, _f;
177
- if (authType === "UNAUTHENTICATED") {
178
- return null;
179
- }
180
- return {
181
- uid: (_c = (_b = (_a = event.context) === null || _a === void 0 ? void 0 : _a.auth) === null || _b === void 0 ? void 0 : _b.variable) === null || _c === void 0 ? void 0 : _c.uid,
182
- token: (_f = (_e = (_d = event.context) === null || _d === void 0 ? void 0 : _d.auth) === null || _e === void 0 ? void 0 : _e.variable) === null || _f === void 0 ? void 0 : _f.token,
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
- var _a, _b, _c, _d;
187
- if ((_b = (_a = event.context) === null || _a === void 0 ? void 0 : _a.auth) === null || _b === void 0 ? void 0 : _b.admin) {
188
- return "ADMIN";
189
- }
190
- if ((_d = (_c = event.context) === null || _c === void 0 ? void 0 : _c.auth) === null || _d === void 0 ? void 0 : _d.variable) {
191
- return "USER";
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
- const trigger = {};
198
- (0, encoding_1.copyIfPresent)(trigger, options, "regions", "schedule", "minInstances", "maxInstances", "ingressSettings", "vpcConnectorEgressSettings", "vpcConnector", "labels", "secrets");
199
- (0, encoding_1.convertIfPresent)(trigger, options, "failurePolicy", "failurePolicy", (policy) => {
200
- if (policy === false) {
201
- return undefined;
202
- }
203
- else if (policy === true) {
204
- return function_configuration_1.DEFAULT_FAILURE_POLICY;
205
- }
206
- else {
207
- return policy;
208
- }
209
- });
210
- (0, encoding_1.convertIfPresent)(trigger, options, "timeout", "timeoutSeconds", encoding_1.durationFromSeconds);
211
- (0, encoding_1.convertIfPresent)(trigger, options, "availableMemoryMb", "memory", (mem) => {
212
- const memoryLookup = {
213
- "128MB": 128,
214
- "256MB": 256,
215
- "512MB": 512,
216
- "1GB": 1024,
217
- "2GB": 2048,
218
- "4GB": 4096,
219
- "8GB": 8192,
220
- };
221
- return memoryLookup[mem];
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
- const endpoint = {};
229
- (0, encoding_1.copyIfPresent)(endpoint, options, "omit", "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds");
230
- (0, encoding_1.convertIfPresent)(endpoint, options, "region", "regions");
231
- (0, encoding_1.convertIfPresent)(endpoint, options, "serviceAccountEmail", "serviceAccount", (sa) => sa);
232
- (0, encoding_1.convertIfPresent)(endpoint, options, "secretEnvironmentVariables", "secrets", (secrets) => secrets.map((secret) => ({ key: secret instanceof types_1.SecretParam ? secret.name : secret })));
233
- if ((options === null || options === void 0 ? void 0 : options.vpcConnector) !== undefined) {
234
- if (options.vpcConnector === null || options.vpcConnector instanceof options_1.ResetValue) {
235
- endpoint.vpc = function_configuration_1.RESET_VALUE;
236
- }
237
- else {
238
- const vpc = { connector: options.vpcConnector };
239
- (0, encoding_1.convertIfPresent)(vpc, options, "egressSettings", "vpcConnectorEgressSettings");
240
- endpoint.vpc = vpc;
241
- }
242
- }
243
- (0, encoding_1.convertIfPresent)(endpoint, options, "availableMemoryMb", "memory", (mem) => {
244
- const memoryLookup = {
245
- "128MB": 128,
246
- "256MB": 256,
247
- "512MB": 512,
248
- "1GB": 1024,
249
- "2GB": 2048,
250
- "4GB": 4096,
251
- "8GB": 8192,
252
- };
253
- return typeof mem === "object" ? mem : memoryLookup[mem];
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;
@@ -1,10 +1,7 @@
1
1
  export { firebaseConfig } from "../common/config";
2
2
  /**
3
- * Store and retrieve project configuration data such as third-party API
4
- * keys or other settings. You can set configuration values using the
5
- * Firebase CLI as described in
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 function config(): Record<string, any>;
7
+ export declare const config: never;
package/lib/v1/config.js CHANGED
@@ -1,77 +1,15 @@
1
- "use strict";
2
- // The MIT License (MIT)
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
- * Store and retrieve project configuration data such as third-party API
36
- * keys or other settings. You can set configuration values using the
37
- * Firebase CLI as described in
38
- * https://firebase.google.com/docs/functions/config-env.
39
- *
40
- * @deprecated Using functions.config() is discouraged. See https://firebase.google.com/docs/functions/config-env.
41
- */
42
- function config() {
43
- // K_CONFIGURATION is only set in GCFv2
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
- function init() {
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;