firebase-functions 6.6.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 (156) 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 +4 -2
  101. package/lib/params/index.js +150 -144
  102. package/lib/params/types.js +389 -423
  103. package/lib/runtime/loader.js +114 -148
  104. package/lib/runtime/manifest.js +106 -126
  105. package/lib/types/global.d.js +0 -0
  106. package/lib/v1/cloud-functions.d.ts +2 -2
  107. package/lib/v1/cloud-functions.js +193 -241
  108. package/lib/v1/config.d.ts +4 -7
  109. package/lib/v1/config.js +13 -75
  110. package/lib/v1/function-builder.js +239 -368
  111. package/lib/v1/function-configuration.js +70 -63
  112. package/lib/v1/index.js +118 -73
  113. package/lib/v1/providers/analytics.js +188 -235
  114. package/lib/v1/providers/auth.d.ts +2 -1
  115. package/lib/v1/providers/auth.js +159 -164
  116. package/lib/v1/providers/database.js +237 -242
  117. package/lib/v1/providers/firestore.js +131 -130
  118. package/lib/v1/providers/https.d.ts +2 -1
  119. package/lib/v1/providers/https.js +79 -86
  120. package/lib/v1/providers/pubsub.js +175 -172
  121. package/lib/v1/providers/remoteConfig.js +64 -68
  122. package/lib/v1/providers/storage.js +161 -163
  123. package/lib/v1/providers/tasks.d.ts +1 -1
  124. package/lib/v1/providers/tasks.js +65 -80
  125. package/lib/v1/providers/testLab.js +94 -94
  126. package/lib/v2/core.d.ts +1 -1
  127. package/lib/v2/core.js +5 -32
  128. package/lib/v2/index.d.ts +6 -3
  129. package/lib/v2/index.js +123 -75
  130. package/lib/v2/options.js +88 -114
  131. package/lib/v2/providers/alerts/alerts.js +76 -95
  132. package/lib/v2/providers/alerts/appDistribution.js +73 -78
  133. package/lib/v2/providers/alerts/billing.js +49 -53
  134. package/lib/v2/providers/alerts/crashlytics.js +110 -102
  135. package/lib/v2/providers/alerts/index.js +56 -53
  136. package/lib/v2/providers/alerts/performance.js +64 -74
  137. package/lib/v2/providers/database.js +177 -180
  138. package/lib/v2/providers/dataconnect.d.ts +95 -0
  139. package/lib/v2/providers/dataconnect.js +137 -0
  140. package/lib/v2/providers/eventarc.js +55 -77
  141. package/lib/v2/providers/firestore.js +262 -260
  142. package/lib/v2/providers/https.d.ts +3 -2
  143. package/lib/v2/providers/https.js +210 -247
  144. package/lib/v2/providers/identity.d.ts +2 -1
  145. package/lib/v2/providers/identity.js +96 -105
  146. package/lib/v2/providers/pubsub.js +149 -167
  147. package/lib/v2/providers/remoteConfig.js +54 -63
  148. package/lib/v2/providers/scheduler.js +84 -96
  149. package/lib/v2/providers/storage.js +147 -162
  150. package/lib/v2/providers/tasks.d.ts +1 -1
  151. package/lib/v2/providers/tasks.js +68 -95
  152. package/lib/v2/providers/testLab.js +55 -64
  153. package/lib/v2/trace.js +18 -19
  154. package/package.json +290 -226
  155. package/protos/compiledFirestore.mjs +3512 -0
  156. package/protos/update.sh +28 -7
package/lib/v2/options.js CHANGED
@@ -1,133 +1,107 @@
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.__getSpec = exports.optionsToEndpoint = exports.optionsToTriggerAnnotations = exports.getGlobalOptions = exports.setGlobalOptions = exports.RESET_VALUE = void 0;
25
- /**
26
- * Options to configure cloud functions.
27
- * @packageDocumentation
28
- */
29
- const encoding_1 = require("../common/encoding");
30
- const options_1 = require("../common/options");
31
- const params_1 = require("../params");
32
- const types_1 = require("../params/types");
33
- const logger = require("../logger");
34
- var options_2 = require("../common/options");
35
- Object.defineProperty(exports, "RESET_VALUE", { enumerable: true, get: function () { return options_2.RESET_VALUE; } });
1
+ const require_logger_index = require('../logger/index.js');
2
+ const require_params_types = require('../params/types.js');
3
+ const require_params_index = require('../params/index.js');
4
+ const require_common_options = require('../common/options.js');
5
+ const require_common_encoding = require('../common/encoding.js');
6
+
7
+ //#region src/v2/options.ts
36
8
  const MemoryOptionToMB = {
37
- "128MiB": 128,
38
- "256MiB": 256,
39
- "512MiB": 512,
40
- "1GiB": 1024,
41
- "2GiB": 2048,
42
- "4GiB": 4096,
43
- "8GiB": 8192,
44
- "16GiB": 16384,
45
- "32GiB": 32768,
9
+ "128MiB": 128,
10
+ "256MiB": 256,
11
+ "512MiB": 512,
12
+ "1GiB": 1024,
13
+ "2GiB": 2048,
14
+ "4GiB": 4096,
15
+ "8GiB": 8192,
16
+ "16GiB": 16384,
17
+ "32GiB": 32768
46
18
  };
47
19
  let globalOptions;
48
20
  /**
49
- * Sets default options for all functions written using the 2nd gen SDK.
50
- * @param options Options to set as default
51
- */
21
+ * Sets default options for all functions written using the 2nd gen SDK.
22
+ * @param options Options to set as default
23
+ */
52
24
  function setGlobalOptions(options) {
53
- if (globalOptions) {
54
- logger.warn("Calling setGlobalOptions twice leads to undefined behavior");
55
- }
56
- globalOptions = options;
25
+ if (globalOptions) {
26
+ require_logger_index.warn("Calling setGlobalOptions twice leads to undefined behavior");
27
+ }
28
+ globalOptions = options;
57
29
  }
58
- exports.setGlobalOptions = setGlobalOptions;
59
30
  /**
60
- * Get the currently set default options.
61
- * Used only for trigger generation.
62
- * @internal
63
- */
31
+ * Get the currently set default options.
32
+ * Used only for trigger generation.
33
+ * @internal
34
+ */
64
35
  function getGlobalOptions() {
65
- return globalOptions || {};
36
+ return globalOptions || {};
66
37
  }
67
- exports.getGlobalOptions = getGlobalOptions;
68
38
  /**
69
- * Apply GlobalOptions to trigger definitions.
70
- * @internal
71
- */
39
+ * Apply GlobalOptions to trigger definitions.
40
+ * @internal
41
+ */
72
42
  function optionsToTriggerAnnotations(opts) {
73
- const annotation = {};
74
- (0, encoding_1.copyIfPresent)(annotation, opts, "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "vpcConnector", "vpcConnectorEgressSettings", "secrets");
75
- (0, encoding_1.convertIfPresent)(annotation, opts, "availableMemoryMb", "memory", (mem) => {
76
- return MemoryOptionToMB[mem];
77
- });
78
- (0, encoding_1.convertIfPresent)(annotation, opts, "regions", "region", (region) => {
79
- if (typeof region === "string") {
80
- return [region];
81
- }
82
- return region;
83
- });
84
- (0, encoding_1.convertIfPresent)(annotation, opts, "serviceAccountEmail", "serviceAccount", encoding_1.serviceAccountFromShorthand);
85
- (0, encoding_1.convertIfPresent)(annotation, opts, "timeout", "timeoutSeconds", encoding_1.durationFromSeconds);
86
- (0, encoding_1.convertIfPresent)(annotation, opts, "failurePolicy", "retry", (retry) => {
87
- return retry ? { retry: true } : null;
88
- });
89
- return annotation;
43
+ const annotation = {};
44
+ require_common_encoding.copyIfPresent(annotation, opts, "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "vpcConnector", "vpcConnectorEgressSettings", "secrets");
45
+ require_common_encoding.convertIfPresent(annotation, opts, "availableMemoryMb", "memory", (mem) => {
46
+ return MemoryOptionToMB[mem];
47
+ });
48
+ require_common_encoding.convertIfPresent(annotation, opts, "regions", "region", (region) => {
49
+ if (typeof region === "string") {
50
+ return [region];
51
+ }
52
+ return region;
53
+ });
54
+ require_common_encoding.convertIfPresent(annotation, opts, "serviceAccountEmail", "serviceAccount", require_common_encoding.serviceAccountFromShorthand);
55
+ require_common_encoding.convertIfPresent(annotation, opts, "timeout", "timeoutSeconds", require_common_encoding.durationFromSeconds);
56
+ require_common_encoding.convertIfPresent(annotation, opts, "failurePolicy", "retry", (retry) => {
57
+ return retry ? { retry: true } : null;
58
+ });
59
+ return annotation;
90
60
  }
91
- exports.optionsToTriggerAnnotations = optionsToTriggerAnnotations;
92
61
  /**
93
- * Apply GlobalOptions to endpoint manifest.
94
- * @internal
95
- */
62
+ * Apply GlobalOptions to endpoint manifest.
63
+ * @internal
64
+ */
96
65
  function optionsToEndpoint(opts) {
97
- const endpoint = {};
98
- (0, encoding_1.copyIfPresent)(endpoint, opts, "omit", "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds", "cpu");
99
- (0, encoding_1.convertIfPresent)(endpoint, opts, "serviceAccountEmail", "serviceAccount");
100
- if (opts.vpcConnector !== undefined) {
101
- if (opts.vpcConnector === null || opts.vpcConnector instanceof options_1.ResetValue) {
102
- endpoint.vpc = options_1.RESET_VALUE;
103
- }
104
- else {
105
- const vpc = { connector: opts.vpcConnector };
106
- (0, encoding_1.convertIfPresent)(vpc, opts, "egressSettings", "vpcConnectorEgressSettings");
107
- endpoint.vpc = vpc;
108
- }
109
- }
110
- (0, encoding_1.convertIfPresent)(endpoint, opts, "availableMemoryMb", "memory", (mem) => {
111
- return typeof mem === "object" ? mem : MemoryOptionToMB[mem];
112
- });
113
- (0, encoding_1.convertIfPresent)(endpoint, opts, "region", "region", (region) => {
114
- if (typeof region === "string") {
115
- return [region];
116
- }
117
- return region;
118
- });
119
- (0, encoding_1.convertIfPresent)(endpoint, opts, "secretEnvironmentVariables", "secrets", (secrets) => secrets.map((secret) => ({ key: secret instanceof types_1.SecretParam ? secret.name : secret })));
120
- return endpoint;
66
+ const endpoint = {};
67
+ require_common_encoding.copyIfPresent(endpoint, opts, "omit", "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds", "cpu");
68
+ require_common_encoding.convertIfPresent(endpoint, opts, "serviceAccountEmail", "serviceAccount");
69
+ if (opts.vpcConnector !== undefined) {
70
+ if (opts.vpcConnector === null || opts.vpcConnector instanceof require_common_options.ResetValue) {
71
+ endpoint.vpc = require_common_options.RESET_VALUE;
72
+ } else {
73
+ const vpc = { connector: opts.vpcConnector };
74
+ require_common_encoding.convertIfPresent(vpc, opts, "egressSettings", "vpcConnectorEgressSettings");
75
+ endpoint.vpc = vpc;
76
+ }
77
+ }
78
+ require_common_encoding.convertIfPresent(endpoint, opts, "availableMemoryMb", "memory", (mem) => {
79
+ return typeof mem === "object" ? mem : MemoryOptionToMB[mem];
80
+ });
81
+ require_common_encoding.convertIfPresent(endpoint, opts, "region", "region", (region) => {
82
+ if (typeof region === "string") {
83
+ return [region];
84
+ }
85
+ return region;
86
+ });
87
+ require_common_encoding.convertIfPresent(endpoint, opts, "secretEnvironmentVariables", "secrets", (secrets) => secrets.map((secret) => ({ key: secret instanceof require_params_types.SecretParam ? secret.name : secret })));
88
+ return endpoint;
121
89
  }
122
- exports.optionsToEndpoint = optionsToEndpoint;
123
90
  /**
124
- * @hidden
125
- * @alpha
126
- */
91
+ * @hidden
92
+ * @alpha
93
+ */
127
94
  function __getSpec() {
128
- return {
129
- globalOptions: getGlobalOptions(),
130
- params: params_1.declaredParams.map((p) => p.toSpec()),
131
- };
95
+ return {
96
+ globalOptions: getGlobalOptions(),
97
+ params: require_params_index.declaredParams.map((p) => p.toSpec())
98
+ };
132
99
  }
100
+
101
+ //#endregion
102
+ exports.RESET_VALUE = require_common_options.RESET_VALUE;
133
103
  exports.__getSpec = __getSpec;
104
+ exports.getGlobalOptions = getGlobalOptions;
105
+ exports.optionsToEndpoint = optionsToEndpoint;
106
+ exports.optionsToTriggerAnnotations = optionsToTriggerAnnotations;
107
+ exports.setGlobalOptions = setGlobalOptions;
@@ -1,108 +1,89 @@
1
- "use strict";
2
- // The MIT License (MIT)
3
- //
4
- // Copyright (c) 2022 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.convertAlertAndApp = exports.getOptsAndAlertTypeAndApp = exports.getEndpointAnnotation = exports.onAlertPublished = exports.eventType = void 0;
25
- const manifest_1 = require("../../../runtime/manifest");
26
- const trace_1 = require("../../trace");
27
- const options = require("../../options");
28
- const onInit_1 = require("../../../common/onInit");
1
+ const require_runtime_manifest = require('../../../runtime/manifest.js');
2
+ const require_common_onInit = require('../../../common/onInit.js');
3
+ const require_v2_trace = require('../../trace.js');
4
+ const require_v2_options = require('../../options.js');
5
+
6
+ //#region src/v2/providers/alerts/alerts.ts
29
7
  /** @internal */
30
- exports.eventType = "google.firebase.firebasealerts.alerts.v1.published";
8
+ const eventType = "google.firebase.firebasealerts.alerts.v1.published";
31
9
  function onAlertPublished(alertTypeOrOpts, handler) {
32
- const [opts, alertType, appId] = getOptsAndAlertTypeAndApp(alertTypeOrOpts);
33
- const func = (raw) => {
34
- return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(convertAlertAndApp(raw));
35
- };
36
- func.run = handler;
37
- func.__endpoint = getEndpointAnnotation(opts, alertType, appId);
38
- return func;
10
+ const [opts, alertType, appId] = getOptsAndAlertTypeAndApp(alertTypeOrOpts);
11
+ const func = (raw) => {
12
+ return require_v2_trace.wrapTraceContext(require_common_onInit.withInit(handler))(convertAlertAndApp(raw));
13
+ };
14
+ func.run = handler;
15
+ func.__endpoint = getEndpointAnnotation(opts, alertType, appId);
16
+ return func;
39
17
  }
40
- exports.onAlertPublished = onAlertPublished;
41
18
  /**
42
- * Helper function for getting the endpoint annotation used in alert handling functions.
43
- * @internal
44
- */
19
+ * Helper function for getting the endpoint annotation used in alert handling functions.
20
+ * @internal
21
+ */
45
22
  function getEndpointAnnotation(opts, alertType, appId) {
46
- var _a;
47
- const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
48
- const specificOpts = options.optionsToEndpoint(opts);
49
- const endpoint = {
50
- ...(0, manifest_1.initV2Endpoint)(options.getGlobalOptions(), opts),
51
- platform: "gcfv2",
52
- ...baseOpts,
53
- ...specificOpts,
54
- labels: {
55
- ...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
56
- ...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
57
- },
58
- eventTrigger: {
59
- eventType: exports.eventType,
60
- eventFilters: {
61
- alerttype: alertType,
62
- },
63
- retry: (_a = opts.retry) !== null && _a !== void 0 ? _a : false,
64
- },
65
- };
66
- if (appId) {
67
- endpoint.eventTrigger.eventFilters.appid = appId;
68
- }
69
- return endpoint;
23
+ const baseOpts = require_v2_options.optionsToEndpoint(require_v2_options.getGlobalOptions());
24
+ const specificOpts = require_v2_options.optionsToEndpoint(opts);
25
+ const endpoint = {
26
+ ...require_runtime_manifest.initV2Endpoint(require_v2_options.getGlobalOptions(), opts),
27
+ platform: "gcfv2",
28
+ ...baseOpts,
29
+ ...specificOpts,
30
+ labels: {
31
+ ...baseOpts?.labels,
32
+ ...specificOpts?.labels
33
+ },
34
+ eventTrigger: {
35
+ eventType,
36
+ eventFilters: { alerttype: alertType },
37
+ retry: opts.retry ?? false
38
+ }
39
+ };
40
+ if (appId) {
41
+ endpoint.eventTrigger.eventFilters.appid = appId;
42
+ }
43
+ return endpoint;
70
44
  }
71
- exports.getEndpointAnnotation = getEndpointAnnotation;
72
45
  /**
73
- * Helper function to parse the function opts, alert type, and appId.
74
- * @internal
75
- */
46
+ * Helper function to parse the function opts, alert type, and appId.
47
+ * @internal
48
+ */
76
49
  function getOptsAndAlertTypeAndApp(alertTypeOrOpts) {
77
- let opts;
78
- let alertType;
79
- let appId;
80
- if (typeof alertTypeOrOpts === "string") {
81
- alertType = alertTypeOrOpts;
82
- opts = {};
83
- }
84
- else {
85
- alertType = alertTypeOrOpts.alertType;
86
- appId = alertTypeOrOpts.appId;
87
- opts = { ...alertTypeOrOpts };
88
- delete opts.alertType;
89
- delete opts.appId;
90
- }
91
- return [opts, alertType, appId];
50
+ let opts;
51
+ let alertType;
52
+ let appId;
53
+ if (typeof alertTypeOrOpts === "string") {
54
+ alertType = alertTypeOrOpts;
55
+ opts = {};
56
+ } else {
57
+ alertType = alertTypeOrOpts.alertType;
58
+ appId = alertTypeOrOpts.appId;
59
+ opts = { ...alertTypeOrOpts };
60
+ delete opts.alertType;
61
+ delete opts.appId;
62
+ }
63
+ return [
64
+ opts,
65
+ alertType,
66
+ appId
67
+ ];
92
68
  }
93
- exports.getOptsAndAlertTypeAndApp = getOptsAndAlertTypeAndApp;
94
69
  /**
95
- * Helper function to covert alert type & app id in the CloudEvent to camel case.
96
- * @internal
97
- */
70
+ * Helper function to covert alert type & app id in the CloudEvent to camel case.
71
+ * @internal
72
+ */
98
73
  function convertAlertAndApp(raw) {
99
- const event = { ...raw };
100
- if ("alerttype" in event) {
101
- event.alertType = event.alerttype;
102
- }
103
- if ("appid" in event) {
104
- event.appId = event.appid;
105
- }
106
- return event;
74
+ const event = { ...raw };
75
+ if ("alerttype" in event) {
76
+ event.alertType = event.alerttype;
77
+ }
78
+ if ("appid" in event) {
79
+ event.appId = event.appid;
80
+ }
81
+ return event;
107
82
  }
83
+
84
+ //#endregion
108
85
  exports.convertAlertAndApp = convertAlertAndApp;
86
+ exports.eventType = eventType;
87
+ exports.getEndpointAnnotation = getEndpointAnnotation;
88
+ exports.getOptsAndAlertTypeAndApp = getOptsAndAlertTypeAndApp;
89
+ exports.onAlertPublished = onAlertPublished;
@@ -1,90 +1,85 @@
1
- "use strict";
2
- // The MIT License (MIT)
3
- //
4
- // Copyright (c) 2022 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.getOptsAndApp = exports.onInAppFeedbackPublished = exports.onNewTesterIosDevicePublished = exports.inAppFeedbackAlert = exports.newTesterIosDeviceAlert = void 0;
25
- const trace_1 = require("../../trace");
26
- const alerts_1 = require("./alerts");
27
- const onInit_1 = require("../../../common/onInit");
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.js');
2
+ const require_common_onInit = require('../../../common/onInit.js');
3
+ const require_v2_trace = require('../../trace.js');
4
+ const require_v2_providers_alerts_alerts = require('./alerts.js');
5
+
6
+ //#region src/v2/providers/alerts/appDistribution.ts
7
+ var appDistribution_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
8
+ getOptsAndApp: () => getOptsAndApp,
9
+ inAppFeedbackAlert: () => inAppFeedbackAlert,
10
+ newTesterIosDeviceAlert: () => newTesterIosDeviceAlert,
11
+ onInAppFeedbackPublished: () => onInAppFeedbackPublished,
12
+ onNewTesterIosDevicePublished: () => onNewTesterIosDevicePublished
13
+ });
28
14
  /** @internal */
29
- exports.newTesterIosDeviceAlert = "appDistribution.newTesterIosDevice";
15
+ const newTesterIosDeviceAlert = "appDistribution.newTesterIosDevice";
30
16
  /** @internal */
31
- exports.inAppFeedbackAlert = "appDistribution.inAppFeedback";
17
+ const inAppFeedbackAlert = "appDistribution.inAppFeedback";
32
18
  /**
33
- * Declares a function that can handle adding a new tester iOS device.
34
- * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
35
- * @param handler - Event handler which is run every time a new tester iOS device is added.
36
- * @returns A function that you can export and deploy.
37
- */
19
+ * Declares a function that can handle adding a new tester iOS device.
20
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
21
+ * @param handler - Event handler which is run every time a new tester iOS device is added.
22
+ * @returns A function that you can export and deploy.
23
+ */
38
24
  function onNewTesterIosDevicePublished(appIdOrOptsOrHandler, handler) {
39
- if (typeof appIdOrOptsOrHandler === "function") {
40
- handler = appIdOrOptsOrHandler;
41
- appIdOrOptsOrHandler = {};
42
- }
43
- const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
44
- const func = (raw) => {
45
- return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))((0, alerts_1.convertAlertAndApp)(raw));
46
- };
47
- func.run = handler;
48
- func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, exports.newTesterIosDeviceAlert, appId);
49
- return func;
25
+ if (typeof appIdOrOptsOrHandler === "function") {
26
+ handler = appIdOrOptsOrHandler;
27
+ appIdOrOptsOrHandler = {};
28
+ }
29
+ const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
30
+ const func = (raw) => {
31
+ return require_v2_trace.wrapTraceContext(require_common_onInit.withInit(handler))(require_v2_providers_alerts_alerts.convertAlertAndApp(raw));
32
+ };
33
+ func.run = handler;
34
+ func.__endpoint = require_v2_providers_alerts_alerts.getEndpointAnnotation(opts, newTesterIosDeviceAlert, appId);
35
+ return func;
50
36
  }
51
- exports.onNewTesterIosDevicePublished = onNewTesterIosDevicePublished;
52
37
  /**
53
- * Declares a function that can handle receiving new in-app feedback from a tester.
54
- * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
55
- * @param handler - Event handler which is run every time new feedback is received.
56
- * @returns A function that you can export and deploy.
57
- */
38
+ * Declares a function that can handle receiving new in-app feedback from a tester.
39
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
40
+ * @param handler - Event handler which is run every time new feedback is received.
41
+ * @returns A function that you can export and deploy.
42
+ */
58
43
  function onInAppFeedbackPublished(appIdOrOptsOrHandler, handler) {
59
- if (typeof appIdOrOptsOrHandler === "function") {
60
- handler = appIdOrOptsOrHandler;
61
- appIdOrOptsOrHandler = {};
62
- }
63
- const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
64
- const func = (raw) => {
65
- return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))((0, alerts_1.convertAlertAndApp)(raw));
66
- };
67
- func.run = handler;
68
- func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, exports.inAppFeedbackAlert, appId);
69
- return func;
44
+ if (typeof appIdOrOptsOrHandler === "function") {
45
+ handler = appIdOrOptsOrHandler;
46
+ appIdOrOptsOrHandler = {};
47
+ }
48
+ const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
49
+ const func = (raw) => {
50
+ return require_v2_trace.wrapTraceContext(require_common_onInit.withInit(handler))(require_v2_providers_alerts_alerts.convertAlertAndApp(raw));
51
+ };
52
+ func.run = handler;
53
+ func.__endpoint = require_v2_providers_alerts_alerts.getEndpointAnnotation(opts, inAppFeedbackAlert, appId);
54
+ return func;
70
55
  }
71
- exports.onInAppFeedbackPublished = onInAppFeedbackPublished;
72
56
  /**
73
- * Helper function to parse the function opts and appId.
74
- * @internal
75
- */
57
+ * Helper function to parse the function opts and appId.
58
+ * @internal
59
+ */
76
60
  function getOptsAndApp(appIdOrOpts) {
77
- let opts;
78
- let appId;
79
- if (typeof appIdOrOpts === "string") {
80
- opts = {};
81
- appId = appIdOrOpts;
82
- }
83
- else {
84
- appId = appIdOrOpts.appId;
85
- opts = { ...appIdOrOpts };
86
- delete opts.appId;
87
- }
88
- return [opts, appId];
61
+ let opts;
62
+ let appId;
63
+ if (typeof appIdOrOpts === "string") {
64
+ opts = {};
65
+ appId = appIdOrOpts;
66
+ } else {
67
+ appId = appIdOrOpts.appId;
68
+ opts = { ...appIdOrOpts };
69
+ delete opts.appId;
70
+ }
71
+ return [opts, appId];
89
72
  }
73
+
74
+ //#endregion
75
+ Object.defineProperty(exports, 'appDistribution_exports', {
76
+ enumerable: true,
77
+ get: function () {
78
+ return appDistribution_exports;
79
+ }
80
+ });
90
81
  exports.getOptsAndApp = getOptsAndApp;
82
+ exports.inAppFeedbackAlert = inAppFeedbackAlert;
83
+ exports.newTesterIosDeviceAlert = newTesterIosDeviceAlert;
84
+ exports.onInAppFeedbackPublished = onInAppFeedbackPublished;
85
+ exports.onNewTesterIosDevicePublished = onNewTesterIosDevicePublished;