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,178 +1,176 @@
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.ObjectBuilder = exports.BucketBuilder = exports._objectWithOptions = exports._bucketWithOptions = exports.object = exports.bucket = exports.service = exports.provider = void 0;
25
- const config_1 = require("../../common/config");
26
- const cloud_functions_1 = require("../cloud-functions");
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
2
+ const require_common_config = require('../../common/config.js');
3
+ const require_v1_cloud_functions = require('../cloud-functions.js');
4
+
5
+ //#region src/v1/providers/storage.ts
6
+ var storage_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
7
+ BucketBuilder: () => BucketBuilder,
8
+ ObjectBuilder: () => ObjectBuilder,
9
+ _bucketWithOptions: () => _bucketWithOptions,
10
+ _objectWithOptions: () => _objectWithOptions,
11
+ bucket: () => bucket,
12
+ object: () => object,
13
+ provider: () => provider,
14
+ service: () => service
15
+ });
27
16
  /** @internal */
28
- exports.provider = "google.storage";
17
+ const provider = "google.storage";
29
18
  /** @internal */
30
- exports.service = "storage.googleapis.com";
19
+ const service = "storage.googleapis.com";
31
20
  /**
32
- * Registers a Cloud Function scoped to a specific storage bucket.
33
- *
34
- * @param bucket Name of the bucket to which this Cloud Function is
35
- * scoped.
36
- *
37
- * @returns Storage bucket builder interface.
38
- */
39
- function bucket(bucket) {
40
- return _bucketWithOptions({}, bucket);
21
+ * Registers a Cloud Function scoped to a specific storage bucket.
22
+ *
23
+ * @param bucket Name of the bucket to which this Cloud Function is
24
+ * scoped.
25
+ *
26
+ * @returns Storage bucket builder interface.
27
+ */
28
+ function bucket(bucket$1) {
29
+ return _bucketWithOptions({}, bucket$1);
41
30
  }
42
- exports.bucket = bucket;
43
31
  /**
44
- * Registers a Cloud Function scoped to the default storage bucket for the
45
- * project.
46
- *
47
- * @returns Storage object builder interface.
48
- */
32
+ * Registers a Cloud Function scoped to the default storage bucket for the
33
+ * project.
34
+ *
35
+ * @returns Storage object builder interface.
36
+ */
49
37
  function object() {
50
- return _objectWithOptions({});
38
+ return _objectWithOptions({});
51
39
  }
52
- exports.object = object;
53
40
  /** @internal */
54
- function _bucketWithOptions(options, bucket) {
55
- const resourceGetter = () => {
56
- bucket = bucket || (0, config_1.firebaseConfig)().storageBucket;
57
- if (!bucket) {
58
- throw new Error("Missing bucket name. If you are unit testing, please provide a bucket name" +
59
- " through `functions.storage.bucket(bucketName)`, or set process.env.FIREBASE_CONFIG.");
60
- }
61
- if (!/^[a-z\d][a-z\d\\._-]{1,230}[a-z\d]$/.test(bucket)) {
62
- throw new Error(`Invalid bucket name ${bucket}`);
63
- }
64
- return `projects/_/buckets/${bucket}`;
65
- };
66
- return new BucketBuilder(resourceGetter, options);
41
+ function _bucketWithOptions(options, bucket$1) {
42
+ const resourceGetter = () => {
43
+ bucket$1 = bucket$1 || require_common_config.firebaseConfig().storageBucket;
44
+ if (!bucket$1) {
45
+ throw new Error("Missing bucket name. If you are unit testing, please provide a bucket name" + " through `functions.storage.bucket(bucketName)`, or set process.env.FIREBASE_CONFIG.");
46
+ }
47
+ if (!/^[a-z\d][a-z\d\\._-]{1,230}[a-z\d]$/.test(bucket$1)) {
48
+ throw new Error(`Invalid bucket name ${bucket$1}`);
49
+ }
50
+ return `projects/_/buckets/${bucket$1}`;
51
+ };
52
+ return new BucketBuilder(resourceGetter, options);
67
53
  }
68
- exports._bucketWithOptions = _bucketWithOptions;
69
54
  /** @internal */
70
55
  function _objectWithOptions(options) {
71
- return _bucketWithOptions(options).object();
56
+ return _bucketWithOptions(options).object();
72
57
  }
73
- exports._objectWithOptions = _objectWithOptions;
74
58
  /**
75
- * The Google Cloud Storage bucket builder interface.
76
- *
77
- * Access via `functions.storage.bucket()`.
78
- */
79
- class BucketBuilder {
80
- /** @internal */
81
- constructor(triggerResource, options) {
82
- this.triggerResource = triggerResource;
83
- this.options = options;
84
- }
85
- /**
86
- * Event handler which fires every time a Google Cloud Storage change occurs.
87
- *
88
- * @returns Storage object builder interface scoped to the specified storage
89
- * bucket.
90
- */
91
- object() {
92
- return new ObjectBuilder(this.triggerResource, this.options);
93
- }
94
- }
95
- exports.BucketBuilder = BucketBuilder;
59
+ * The Google Cloud Storage bucket builder interface.
60
+ *
61
+ * Access via `functions.storage.bucket()`.
62
+ */
63
+ var BucketBuilder = class {
64
+ /** @internal */
65
+ constructor(triggerResource, options) {
66
+ this.triggerResource = triggerResource;
67
+ this.options = options;
68
+ }
69
+ /**
70
+ * Event handler which fires every time a Google Cloud Storage change occurs.
71
+ *
72
+ * @returns Storage object builder interface scoped to the specified storage
73
+ * bucket.
74
+ */
75
+ object() {
76
+ return new ObjectBuilder(this.triggerResource, this.options);
77
+ }
78
+ };
96
79
  /**
97
- * The Google Cloud Storage object builder interface.
98
- *
99
- * Access via `functions.storage.object()`.
100
- */
101
- class ObjectBuilder {
102
- /** @internal */
103
- constructor(triggerResource, options) {
104
- this.triggerResource = triggerResource;
105
- this.options = options;
106
- }
107
- /**
108
- * Event handler sent only when a bucket has enabled object versioning.
109
- * This event indicates that the live version of an object has become an
110
- * archived version, either because it was archived or because it was
111
- * overwritten by the upload of an object of the same name.
112
- *
113
- * @param handler Event handler which is run every time a Google Cloud Storage
114
- * archival occurs.
115
- *
116
- * @returns A function which you can export and deploy.
117
- */
118
- onArchive(handler) {
119
- return this.onOperation(handler, "object.archive");
120
- }
121
- /**
122
- * Event handler which fires every time a Google Cloud Storage deletion occurs.
123
- *
124
- * Sent when an object has been permanently deleted. This includes objects
125
- * that are overwritten or are deleted as part of the bucket's lifecycle
126
- * configuration. For buckets with object versioning enabled, this is not
127
- * sent when an object is archived, even if archival occurs
128
- * via the `storage.objects.delete` method.
129
- *
130
- * @param handler Event handler which is run every time a Google Cloud Storage
131
- * deletion occurs.
132
- *
133
- * @returns A function which you can export and deploy.
134
- */
135
- onDelete(handler) {
136
- return this.onOperation(handler, "object.delete");
137
- }
138
- /**
139
- * Event handler which fires every time a Google Cloud Storage object
140
- * creation occurs.
141
- *
142
- * Sent when a new object (or a new generation of an existing object)
143
- * is successfully created in the bucket. This includes copying or rewriting
144
- * an existing object. A failed upload does not trigger this event.
145
- *
146
- * @param handler Event handler which is run every time a Google Cloud Storage
147
- * object creation occurs.
148
- *
149
- * @returns A function which you can export and deploy.
150
- */
151
- onFinalize(handler) {
152
- return this.onOperation(handler, "object.finalize");
153
- }
154
- /**
155
- * Event handler which fires every time the metadata of an existing object
156
- * changes.
157
- *
158
- * @param handler Event handler which is run every time a Google Cloud Storage
159
- * metadata update occurs.
160
- *
161
- * @returns A function which you can export and deploy.
162
- */
163
- onMetadataUpdate(handler) {
164
- return this.onOperation(handler, "object.metadataUpdate");
165
- }
166
- /** @hidden */
167
- onOperation(handler, eventType) {
168
- return (0, cloud_functions_1.makeCloudFunction)({
169
- handler,
170
- provider: exports.provider,
171
- service: exports.service,
172
- eventType,
173
- triggerResource: this.triggerResource,
174
- options: this.options,
175
- });
176
- }
177
- }
80
+ * The Google Cloud Storage object builder interface.
81
+ *
82
+ * Access via `functions.storage.object()`.
83
+ */
84
+ var ObjectBuilder = class {
85
+ /** @internal */
86
+ constructor(triggerResource, options) {
87
+ this.triggerResource = triggerResource;
88
+ this.options = options;
89
+ }
90
+ /**
91
+ * Event handler sent only when a bucket has enabled object versioning.
92
+ * This event indicates that the live version of an object has become an
93
+ * archived version, either because it was archived or because it was
94
+ * overwritten by the upload of an object of the same name.
95
+ *
96
+ * @param handler Event handler which is run every time a Google Cloud Storage
97
+ * archival occurs.
98
+ *
99
+ * @returns A function which you can export and deploy.
100
+ */
101
+ onArchive(handler) {
102
+ return this.onOperation(handler, "object.archive");
103
+ }
104
+ /**
105
+ * Event handler which fires every time a Google Cloud Storage deletion occurs.
106
+ *
107
+ * Sent when an object has been permanently deleted. This includes objects
108
+ * that are overwritten or are deleted as part of the bucket's lifecycle
109
+ * configuration. For buckets with object versioning enabled, this is not
110
+ * sent when an object is archived, even if archival occurs
111
+ * via the `storage.objects.delete` method.
112
+ *
113
+ * @param handler Event handler which is run every time a Google Cloud Storage
114
+ * deletion occurs.
115
+ *
116
+ * @returns A function which you can export and deploy.
117
+ */
118
+ onDelete(handler) {
119
+ return this.onOperation(handler, "object.delete");
120
+ }
121
+ /**
122
+ * Event handler which fires every time a Google Cloud Storage object
123
+ * creation occurs.
124
+ *
125
+ * Sent when a new object (or a new generation of an existing object)
126
+ * is successfully created in the bucket. This includes copying or rewriting
127
+ * an existing object. A failed upload does not trigger this event.
128
+ *
129
+ * @param handler Event handler which is run every time a Google Cloud Storage
130
+ * object creation occurs.
131
+ *
132
+ * @returns A function which you can export and deploy.
133
+ */
134
+ onFinalize(handler) {
135
+ return this.onOperation(handler, "object.finalize");
136
+ }
137
+ /**
138
+ * Event handler which fires every time the metadata of an existing object
139
+ * changes.
140
+ *
141
+ * @param handler Event handler which is run every time a Google Cloud Storage
142
+ * metadata update occurs.
143
+ *
144
+ * @returns A function which you can export and deploy.
145
+ */
146
+ onMetadataUpdate(handler) {
147
+ return this.onOperation(handler, "object.metadataUpdate");
148
+ }
149
+ /** @hidden */
150
+ onOperation(handler, eventType) {
151
+ return require_v1_cloud_functions.makeCloudFunction({
152
+ handler,
153
+ provider,
154
+ service,
155
+ eventType,
156
+ triggerResource: this.triggerResource,
157
+ options: this.options
158
+ });
159
+ }
160
+ };
161
+
162
+ //#endregion
163
+ exports.BucketBuilder = BucketBuilder;
178
164
  exports.ObjectBuilder = ObjectBuilder;
165
+ exports._bucketWithOptions = _bucketWithOptions;
166
+ exports._objectWithOptions = _objectWithOptions;
167
+ exports.bucket = bucket;
168
+ exports.object = object;
169
+ exports.provider = provider;
170
+ exports.service = service;
171
+ Object.defineProperty(exports, 'storage_exports', {
172
+ enumerable: true,
173
+ get: function () {
174
+ return storage_exports;
175
+ }
176
+ });
@@ -2,7 +2,7 @@ import * as express from "express";
2
2
  import { Request } from "../../common/providers/https";
3
3
  import { RateLimits, RetryConfig, TaskContext } from "../../common/providers/tasks";
4
4
  import { ManifestEndpoint, ManifestRequiredAPI } from "../../runtime/manifest";
5
- export { RetryConfig, RateLimits, TaskContext };
5
+ export type { RetryConfig, RateLimits, TaskContext };
6
6
  /**
7
7
  * Options for configuring the task queue to listen to.
8
8
  */
@@ -1,85 +1,70 @@
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.taskQueue = exports.TaskQueueBuilder = void 0;
25
- const encoding_1 = require("../../common/encoding");
26
- const tasks_1 = require("../../common/providers/tasks");
27
- const manifest_1 = require("../../runtime/manifest");
28
- const cloud_functions_1 = require("../cloud-functions");
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
2
+ const require_runtime_manifest = require('../../runtime/manifest.js');
3
+ const require_common_encoding = require('../../common/encoding.js');
4
+ const require_v1_cloud_functions = require('../cloud-functions.js');
5
+ const require_common_providers_tasks = require('../../common/providers/tasks.js');
6
+
7
+ //#region src/v1/providers/tasks.ts
8
+ var tasks_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
9
+ TaskQueueBuilder: () => TaskQueueBuilder,
10
+ taskQueue: () => taskQueue
11
+ });
29
12
  /**
30
- * Builder for creating a `TaskQueueFunction`.
31
- */
32
- class TaskQueueBuilder {
33
- /** @internal */
34
- constructor(tqOpts, depOpts) {
35
- this.tqOpts = tqOpts;
36
- this.depOpts = depOpts;
37
- }
38
- /**
39
- * Creates a handler for tasks sent to a Google Cloud Tasks queue.
40
- * @param handler - A callback to handle task requests.
41
- * @returns A function you can export and deploy.
42
- */
43
- onDispatch(handler) {
44
- var _a, _b;
45
- // onEnqueueHandler sniffs the function length of the passed-in callback
46
- // and the user could have only tried to listen to data. Wrap their handler
47
- // in another handler to avoid accidentally triggering the v2 API
48
- const fixedLen = (data, context) => handler(data, context);
49
- const func = (0, tasks_1.onDispatchHandler)(fixedLen);
50
- func.__trigger = {
51
- ...(0, cloud_functions_1.optionsToTrigger)(this.depOpts || {}),
52
- taskQueueTrigger: {},
53
- };
54
- (0, encoding_1.copyIfPresent)(func.__trigger.taskQueueTrigger, this.tqOpts, "retryConfig");
55
- (0, encoding_1.copyIfPresent)(func.__trigger.taskQueueTrigger, this.tqOpts, "rateLimits");
56
- (0, encoding_1.convertIfPresent)(func.__trigger.taskQueueTrigger, this.tqOpts, "invoker", "invoker", encoding_1.convertInvoker);
57
- func.__endpoint = {
58
- platform: "gcfv1",
59
- ...(0, manifest_1.initV1Endpoint)(this.depOpts),
60
- ...(0, cloud_functions_1.optionsToEndpoint)(this.depOpts),
61
- taskQueueTrigger: (0, manifest_1.initTaskQueueTrigger)(this.depOpts),
62
- };
63
- (0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger.retryConfig, ((_a = this.tqOpts) === null || _a === void 0 ? void 0 : _a.retryConfig) || {}, "maxAttempts", "maxBackoffSeconds", "maxDoublings", "maxRetrySeconds", "minBackoffSeconds");
64
- (0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger.rateLimits, ((_b = this.tqOpts) === null || _b === void 0 ? void 0 : _b.rateLimits) || {}, "maxConcurrentDispatches", "maxDispatchesPerSecond");
65
- (0, encoding_1.convertIfPresent)(func.__endpoint.taskQueueTrigger, this.tqOpts, "invoker", "invoker", encoding_1.convertInvoker);
66
- func.__requiredAPIs = [
67
- {
68
- api: "cloudtasks.googleapis.com",
69
- reason: "Needed for task queue functions",
70
- },
71
- ];
72
- func.run = handler;
73
- return func;
74
- }
75
- }
76
- exports.TaskQueueBuilder = TaskQueueBuilder;
13
+ * Builder for creating a `TaskQueueFunction`.
14
+ */
15
+ var TaskQueueBuilder = class {
16
+ /** @internal */
17
+ constructor(tqOpts, depOpts) {
18
+ this.tqOpts = tqOpts;
19
+ this.depOpts = depOpts;
20
+ }
21
+ /**
22
+ * Creates a handler for tasks sent to a Google Cloud Tasks queue.
23
+ * @param handler - A callback to handle task requests.
24
+ * @returns A function you can export and deploy.
25
+ */
26
+ onDispatch(handler) {
27
+ const fixedLen = (data, context) => handler(data, context);
28
+ const func = require_common_providers_tasks.onDispatchHandler(fixedLen);
29
+ func.__trigger = {
30
+ ...require_v1_cloud_functions.optionsToTrigger(this.depOpts || {}),
31
+ taskQueueTrigger: {}
32
+ };
33
+ require_common_encoding.copyIfPresent(func.__trigger.taskQueueTrigger, this.tqOpts, "retryConfig");
34
+ require_common_encoding.copyIfPresent(func.__trigger.taskQueueTrigger, this.tqOpts, "rateLimits");
35
+ require_common_encoding.convertIfPresent(func.__trigger.taskQueueTrigger, this.tqOpts, "invoker", "invoker", require_common_encoding.convertInvoker);
36
+ func.__endpoint = {
37
+ platform: "gcfv1",
38
+ ...require_runtime_manifest.initV1Endpoint(this.depOpts),
39
+ ...require_v1_cloud_functions.optionsToEndpoint(this.depOpts),
40
+ taskQueueTrigger: require_runtime_manifest.initTaskQueueTrigger(this.depOpts)
41
+ };
42
+ require_common_encoding.copyIfPresent(func.__endpoint.taskQueueTrigger.retryConfig, this.tqOpts?.retryConfig || {}, "maxAttempts", "maxBackoffSeconds", "maxDoublings", "maxRetrySeconds", "minBackoffSeconds");
43
+ require_common_encoding.copyIfPresent(func.__endpoint.taskQueueTrigger.rateLimits, this.tqOpts?.rateLimits || {}, "maxConcurrentDispatches", "maxDispatchesPerSecond");
44
+ require_common_encoding.convertIfPresent(func.__endpoint.taskQueueTrigger, this.tqOpts, "invoker", "invoker", require_common_encoding.convertInvoker);
45
+ func.__requiredAPIs = [{
46
+ api: "cloudtasks.googleapis.com",
47
+ reason: "Needed for task queue functions"
48
+ }];
49
+ func.run = handler;
50
+ return func;
51
+ }
52
+ };
77
53
  /**
78
- * Declares a function that can handle tasks enqueued using the Firebase Admin SDK.
79
- * @param options - Configuration for the Task Queue that feeds into this function.
80
- * Omitting options will configure a Task Queue with default settings.
81
- */
54
+ * Declares a function that can handle tasks enqueued using the Firebase Admin SDK.
55
+ * @param options - Configuration for the Task Queue that feeds into this function.
56
+ * Omitting options will configure a Task Queue with default settings.
57
+ */
82
58
  function taskQueue(options) {
83
- return new TaskQueueBuilder(options);
59
+ return new TaskQueueBuilder(options);
84
60
  }
61
+
62
+ //#endregion
63
+ exports.TaskQueueBuilder = TaskQueueBuilder;
85
64
  exports.taskQueue = taskQueue;
65
+ Object.defineProperty(exports, 'tasks_exports', {
66
+ enumerable: true,
67
+ get: function () {
68
+ return tasks_exports;
69
+ }
70
+ });