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
@@ -1,150 +1,151 @@
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.DocumentBuilder = exports.beforeSnapshotConstructor = exports.snapshotConstructor = exports.NamespaceBuilder = exports.DatabaseBuilder = exports._documentWithOptions = exports._namespaceWithOptions = exports._databaseWithOptions = exports.database = exports.namespace = exports.document = exports.defaultDatabase = exports.service = exports.provider = void 0;
25
- const path_1 = require("path");
26
- const change_1 = require("../../common/change");
27
- const firestore_1 = require("../../common/providers/firestore");
28
- const cloud_functions_1 = require("../cloud-functions");
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
2
+ const require_common_change = require('../../common/change.js');
3
+ const require_v1_cloud_functions = require('../cloud-functions.js');
4
+ const require_common_providers_firestore = require('../../common/providers/firestore.js');
5
+ let path = require("path");
6
+ path = require_rolldown_runtime.__toESM(path);
7
+
8
+ //#region src/v1/providers/firestore.ts
9
+ var firestore_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
10
+ DatabaseBuilder: () => DatabaseBuilder,
11
+ DocumentBuilder: () => DocumentBuilder,
12
+ NamespaceBuilder: () => NamespaceBuilder,
13
+ _databaseWithOptions: () => _databaseWithOptions,
14
+ _documentWithOptions: () => _documentWithOptions,
15
+ _namespaceWithOptions: () => _namespaceWithOptions,
16
+ beforeSnapshotConstructor: () => beforeSnapshotConstructor,
17
+ database: () => database,
18
+ defaultDatabase: () => defaultDatabase,
19
+ document: () => document,
20
+ namespace: () => namespace,
21
+ provider: () => provider,
22
+ service: () => service,
23
+ snapshotConstructor: () => snapshotConstructor
24
+ });
29
25
  /** @internal */
30
- exports.provider = "google.firestore";
26
+ const provider = "google.firestore";
31
27
  /** @internal */
32
- exports.service = "firestore.googleapis.com";
28
+ const service = "firestore.googleapis.com";
33
29
  /** @internal */
34
- exports.defaultDatabase = "(default)";
30
+ const defaultDatabase = "(default)";
35
31
  /**
36
- * Select the Firestore document to listen to for events.
37
- * @param path Full database path to listen to. This includes the name of
38
- * the collection that the document is a part of. For example, if the
39
- * collection is named "users" and the document is named "Ada", then the
40
- * path is "/users/Ada".
41
- */
42
- function document(path) {
43
- return _documentWithOptions(path, {});
32
+ * Select the Firestore document to listen to for events.
33
+ * @param path Full database path to listen to. This includes the name of
34
+ * the collection that the document is a part of. For example, if the
35
+ * collection is named "users" and the document is named "Ada", then the
36
+ * path is "/users/Ada".
37
+ */
38
+ function document(path$1) {
39
+ return _documentWithOptions(path$1, {});
44
40
  }
45
- exports.document = document;
46
- // Multiple namespaces are not yet supported by Firestore.
47
- function namespace(namespace) {
48
- return _namespaceWithOptions(namespace, {});
41
+ function namespace(namespace$1) {
42
+ return _namespaceWithOptions(namespace$1, {});
49
43
  }
50
- exports.namespace = namespace;
51
- // Multiple databases are not yet supported by Firestore.
52
- function database(database) {
53
- return _databaseWithOptions(database, {});
44
+ function database(database$1) {
45
+ return _databaseWithOptions(database$1, {});
54
46
  }
55
- exports.database = database;
56
47
  /** @internal */
57
- function _databaseWithOptions(database = exports.defaultDatabase, options) {
58
- return new DatabaseBuilder(database, options);
48
+ function _databaseWithOptions(database$1 = defaultDatabase, options) {
49
+ return new DatabaseBuilder(database$1, options);
59
50
  }
60
- exports._databaseWithOptions = _databaseWithOptions;
61
51
  /** @internal */
62
- function _namespaceWithOptions(namespace, options) {
63
- return _databaseWithOptions(exports.defaultDatabase, options).namespace(namespace);
52
+ function _namespaceWithOptions(namespace$1, options) {
53
+ return _databaseWithOptions(defaultDatabase, options).namespace(namespace$1);
64
54
  }
65
- exports._namespaceWithOptions = _namespaceWithOptions;
66
55
  /** @internal */
67
- function _documentWithOptions(path, options) {
68
- return _databaseWithOptions(exports.defaultDatabase, options).document(path);
56
+ function _documentWithOptions(path$1, options) {
57
+ return _databaseWithOptions(defaultDatabase, options).document(path$1);
69
58
  }
70
- exports._documentWithOptions = _documentWithOptions;
71
- class DatabaseBuilder {
72
- constructor(database, options) {
73
- this.database = database;
74
- this.options = options;
75
- }
76
- namespace(namespace) {
77
- return new NamespaceBuilder(this.database, this.options, namespace);
78
- }
79
- document(path) {
80
- return new NamespaceBuilder(this.database, this.options).document(path);
81
- }
82
- }
83
- exports.DatabaseBuilder = DatabaseBuilder;
84
- class NamespaceBuilder {
85
- constructor(database, options, namespace) {
86
- this.database = database;
87
- this.options = options;
88
- this.namespace = namespace;
89
- }
90
- document(path) {
91
- return new DocumentBuilder(() => {
92
- if (!process.env.GCLOUD_PROJECT) {
93
- throw new Error("process.env.GCLOUD_PROJECT is not set.");
94
- }
95
- const database = path_1.posix.join("projects", process.env.GCLOUD_PROJECT, "databases", this.database);
96
- return path_1.posix.join(database, this.namespace ? `documents@${this.namespace}` : "documents", path);
97
- }, this.options);
98
- }
99
- }
100
- exports.NamespaceBuilder = NamespaceBuilder;
59
+ var DatabaseBuilder = class {
60
+ constructor(database$1, options) {
61
+ this.database = database$1;
62
+ this.options = options;
63
+ }
64
+ namespace(namespace$1) {
65
+ return new NamespaceBuilder(this.database, this.options, namespace$1);
66
+ }
67
+ document(path$1) {
68
+ return new NamespaceBuilder(this.database, this.options).document(path$1);
69
+ }
70
+ };
71
+ var NamespaceBuilder = class {
72
+ constructor(database$1, options, namespace$1) {
73
+ this.database = database$1;
74
+ this.options = options;
75
+ this.namespace = namespace$1;
76
+ }
77
+ document(path$1) {
78
+ return new DocumentBuilder(() => {
79
+ if (!process.env.GCLOUD_PROJECT) {
80
+ throw new Error("process.env.GCLOUD_PROJECT is not set.");
81
+ }
82
+ const database$1 = path.posix.join("projects", process.env.GCLOUD_PROJECT, "databases", this.database);
83
+ return path.posix.join(database$1, this.namespace ? `documents@${this.namespace}` : "documents", path$1);
84
+ }, this.options);
85
+ }
86
+ };
101
87
  function snapshotConstructor(event) {
102
- var _a, _b, _c, _d;
103
- return (0, firestore_1.createSnapshotFromJson)(event.data, event.context.resource.name, (_b = (_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.readTime, (_d = (_c = event === null || event === void 0 ? void 0 : event.data) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.updateTime);
88
+ return require_common_providers_firestore.createSnapshotFromJson(event.data, event.context.resource.name, event?.data?.value?.readTime, event?.data?.value?.updateTime);
104
89
  }
105
- exports.snapshotConstructor = snapshotConstructor;
106
- // TODO remove this function when wire format changes to new format
107
90
  function beforeSnapshotConstructor(event) {
108
- var _a, _b;
109
- return (0, firestore_1.createBeforeSnapshotFromJson)(event.data, event.context.resource.name, (_b = (_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.oldValue) === null || _b === void 0 ? void 0 : _b.readTime, undefined);
91
+ return require_common_providers_firestore.createBeforeSnapshotFromJson(event.data, event.context.resource.name, event?.data?.oldValue?.readTime, undefined);
110
92
  }
111
- exports.beforeSnapshotConstructor = beforeSnapshotConstructor;
112
93
  function changeConstructor(raw) {
113
- return change_1.Change.fromObjects(beforeSnapshotConstructor(raw), snapshotConstructor(raw));
114
- }
115
- class DocumentBuilder {
116
- constructor(triggerResource, options) {
117
- this.triggerResource = triggerResource;
118
- this.options = options;
119
- // TODO what validation do we want to do here?
120
- }
121
- /** Respond to all document writes (creates, updates, or deletes). */
122
- onWrite(handler) {
123
- return this.onOperation(handler, "document.write", changeConstructor);
124
- }
125
- /** Respond only to document updates. */
126
- onUpdate(handler) {
127
- return this.onOperation(handler, "document.update", changeConstructor);
128
- }
129
- /** Respond only to document creations. */
130
- onCreate(handler) {
131
- return this.onOperation(handler, "document.create", snapshotConstructor);
132
- }
133
- /** Respond only to document deletions. */
134
- onDelete(handler) {
135
- return this.onOperation(handler, "document.delete", beforeSnapshotConstructor);
136
- }
137
- onOperation(handler, eventType, dataConstructor) {
138
- return (0, cloud_functions_1.makeCloudFunction)({
139
- handler,
140
- provider: exports.provider,
141
- eventType,
142
- service: exports.service,
143
- triggerResource: this.triggerResource,
144
- legacyEventType: `providers/cloud.firestore/eventTypes/${eventType}`,
145
- dataConstructor,
146
- options: this.options,
147
- });
148
- }
94
+ return require_common_change.Change.fromObjects(beforeSnapshotConstructor(raw), snapshotConstructor(raw));
149
95
  }
96
+ var DocumentBuilder = class {
97
+ constructor(triggerResource, options) {
98
+ this.triggerResource = triggerResource;
99
+ this.options = options;
100
+ }
101
+ /** Respond to all document writes (creates, updates, or deletes). */
102
+ onWrite(handler) {
103
+ return this.onOperation(handler, "document.write", changeConstructor);
104
+ }
105
+ /** Respond only to document updates. */
106
+ onUpdate(handler) {
107
+ return this.onOperation(handler, "document.update", changeConstructor);
108
+ }
109
+ /** Respond only to document creations. */
110
+ onCreate(handler) {
111
+ return this.onOperation(handler, "document.create", snapshotConstructor);
112
+ }
113
+ /** Respond only to document deletions. */
114
+ onDelete(handler) {
115
+ return this.onOperation(handler, "document.delete", beforeSnapshotConstructor);
116
+ }
117
+ onOperation(handler, eventType, dataConstructor) {
118
+ return require_v1_cloud_functions.makeCloudFunction({
119
+ handler,
120
+ provider,
121
+ eventType,
122
+ service,
123
+ triggerResource: this.triggerResource,
124
+ legacyEventType: `providers/cloud.firestore/eventTypes/${eventType}`,
125
+ dataConstructor,
126
+ options: this.options
127
+ });
128
+ }
129
+ };
130
+
131
+ //#endregion
132
+ exports.DatabaseBuilder = DatabaseBuilder;
150
133
  exports.DocumentBuilder = DocumentBuilder;
134
+ exports.NamespaceBuilder = NamespaceBuilder;
135
+ exports._databaseWithOptions = _databaseWithOptions;
136
+ exports._documentWithOptions = _documentWithOptions;
137
+ exports._namespaceWithOptions = _namespaceWithOptions;
138
+ exports.beforeSnapshotConstructor = beforeSnapshotConstructor;
139
+ exports.database = database;
140
+ exports.defaultDatabase = defaultDatabase;
141
+ exports.document = document;
142
+ Object.defineProperty(exports, 'firestore_exports', {
143
+ enumerable: true,
144
+ get: function () {
145
+ return firestore_exports;
146
+ }
147
+ });
148
+ exports.namespace = namespace;
149
+ exports.provider = provider;
150
+ exports.service = service;
151
+ exports.snapshotConstructor = snapshotConstructor;
@@ -1,7 +1,8 @@
1
1
  import * as express from "express";
2
2
  import { CallableContext, FunctionsErrorCode, HttpsError, Request } from "../../common/providers/https";
3
3
  import { HttpsFunction, Runnable } from "../cloud-functions";
4
- export { Request, CallableContext, FunctionsErrorCode, HttpsError };
4
+ export { HttpsError };
5
+ export type { Request, CallableContext, FunctionsErrorCode };
5
6
  /**
6
7
  * Handle HTTP requests.
7
8
  * @param handler A function that takes a request and response object,
@@ -1,99 +1,92 @@
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._onCallWithOptions = exports._onRequestWithOptions = exports.onCall = exports.onRequest = exports.HttpsError = void 0;
25
- const encoding_1 = require("../../common/encoding");
26
- const https_1 = require("../../common/providers/https");
27
- Object.defineProperty(exports, "HttpsError", { enumerable: true, get: function () { return https_1.HttpsError; } });
28
- const cloud_functions_1 = require("../cloud-functions");
29
- const manifest_1 = require("../../runtime/manifest");
30
- const onInit_1 = require("../../common/onInit");
31
- const trace_1 = require("../../v2/trace");
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_common_onInit = require('../../common/onInit.js');
5
+ const require_v1_cloud_functions = require('../cloud-functions.js');
6
+ const require_common_providers_https = require('../../common/providers/https.js');
7
+ const require_v2_trace = require('../../v2/trace.js');
8
+
9
+ //#region src/v1/providers/https.ts
10
+ var https_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
11
+ HttpsError: () => require_common_providers_https.HttpsError,
12
+ _onCallWithOptions: () => _onCallWithOptions,
13
+ _onRequestWithOptions: () => _onRequestWithOptions,
14
+ onCall: () => onCall,
15
+ onRequest: () => onRequest
16
+ });
32
17
  /**
33
- * Handle HTTP requests.
34
- * @param handler A function that takes a request and response object,
35
- * same signature as an Express app.
36
- */
18
+ * Handle HTTP requests.
19
+ * @param handler A function that takes a request and response object,
20
+ * same signature as an Express app.
21
+ */
37
22
  function onRequest(handler) {
38
- return _onRequestWithOptions(handler, {});
23
+ return _onRequestWithOptions(handler, {});
39
24
  }
40
- exports.onRequest = onRequest;
41
25
  /**
42
- * Declares a callable method for clients to call using a Firebase SDK.
43
- * @param handler A method that takes a data and context and returns a value.
44
- */
26
+ * Declares a callable method for clients to call using a Firebase SDK.
27
+ * @param handler A method that takes a data and context and returns a value.
28
+ */
45
29
  function onCall(handler) {
46
- return _onCallWithOptions(handler, {});
30
+ return _onCallWithOptions(handler, {});
47
31
  }
48
- exports.onCall = onCall;
49
32
  /** @internal */
50
33
  function _onRequestWithOptions(handler, options) {
51
- // lets us add __endpoint without altering handler:
52
- const cloudFunction = (req, res) => {
53
- return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(req, res);
54
- };
55
- cloudFunction.__trigger = {
56
- ...(0, cloud_functions_1.optionsToTrigger)(options),
57
- httpsTrigger: {},
58
- };
59
- (0, encoding_1.convertIfPresent)(cloudFunction.__trigger.httpsTrigger, options, "invoker", "invoker", encoding_1.convertInvoker);
60
- // TODO parse the options
61
- cloudFunction.__endpoint = {
62
- platform: "gcfv1",
63
- ...(0, manifest_1.initV1Endpoint)(options),
64
- ...(0, cloud_functions_1.optionsToEndpoint)(options),
65
- httpsTrigger: {},
66
- };
67
- (0, encoding_1.convertIfPresent)(cloudFunction.__endpoint.httpsTrigger, options, "invoker", "invoker", encoding_1.convertInvoker);
68
- return cloudFunction;
34
+ const cloudFunction = (req, res) => {
35
+ return require_v2_trace.wrapTraceContext(require_common_onInit.withInit(require_common_providers_https.withErrorHandler(handler)))(req, res);
36
+ };
37
+ cloudFunction.__trigger = {
38
+ ...require_v1_cloud_functions.optionsToTrigger(options),
39
+ httpsTrigger: {}
40
+ };
41
+ require_common_encoding.convertIfPresent(cloudFunction.__trigger.httpsTrigger, options, "invoker", "invoker", require_common_encoding.convertInvoker);
42
+ cloudFunction.__endpoint = {
43
+ platform: "gcfv1",
44
+ ...require_runtime_manifest.initV1Endpoint(options),
45
+ ...require_v1_cloud_functions.optionsToEndpoint(options),
46
+ httpsTrigger: {}
47
+ };
48
+ require_common_encoding.convertIfPresent(cloudFunction.__endpoint.httpsTrigger, options, "invoker", "invoker", require_common_encoding.convertInvoker);
49
+ return cloudFunction;
69
50
  }
70
- exports._onRequestWithOptions = _onRequestWithOptions;
71
51
  /** @internal */
72
52
  function _onCallWithOptions(handler, options) {
73
- // fix the length of handler to make the call to handler consistent
74
- // in the onCallHandler
75
- const fixedLen = (data, context) => {
76
- return (0, onInit_1.withInit)(handler)(data, context);
77
- };
78
- const func = (0, trace_1.wrapTraceContext)((0, https_1.onCallHandler)({
79
- enforceAppCheck: options.enforceAppCheck,
80
- consumeAppCheckToken: options.consumeAppCheckToken,
81
- cors: { origin: true, methods: "POST" },
82
- }, fixedLen, "gcfv1"));
83
- func.__trigger = {
84
- labels: {},
85
- ...(0, cloud_functions_1.optionsToTrigger)(options),
86
- httpsTrigger: {},
87
- };
88
- func.__trigger.labels["deployment-callable"] = "true";
89
- func.__endpoint = {
90
- platform: "gcfv1",
91
- labels: {},
92
- ...(0, manifest_1.initV1Endpoint)(options),
93
- ...(0, cloud_functions_1.optionsToEndpoint)(options),
94
- callableTrigger: {},
95
- };
96
- func.run = fixedLen;
97
- return func;
53
+ const fixedLen = (data, context) => {
54
+ return require_common_onInit.withInit(handler)(data, context);
55
+ };
56
+ const func = require_v2_trace.wrapTraceContext(require_common_providers_https.onCallHandler({
57
+ enforceAppCheck: options.enforceAppCheck,
58
+ consumeAppCheckToken: options.consumeAppCheckToken,
59
+ cors: {
60
+ origin: true,
61
+ methods: "POST"
62
+ }
63
+ }, fixedLen, "gcfv1"));
64
+ func.__trigger = {
65
+ labels: {},
66
+ ...require_v1_cloud_functions.optionsToTrigger(options),
67
+ httpsTrigger: {}
68
+ };
69
+ func.__trigger.labels["deployment-callable"] = "true";
70
+ func.__endpoint = {
71
+ platform: "gcfv1",
72
+ labels: {},
73
+ ...require_runtime_manifest.initV1Endpoint(options),
74
+ ...require_v1_cloud_functions.optionsToEndpoint(options),
75
+ callableTrigger: {}
76
+ };
77
+ func.run = fixedLen;
78
+ return func;
98
79
  }
80
+
81
+ //#endregion
82
+ exports.HttpsError = require_common_providers_https.HttpsError;
99
83
  exports._onCallWithOptions = _onCallWithOptions;
84
+ exports._onRequestWithOptions = _onRequestWithOptions;
85
+ Object.defineProperty(exports, 'https_exports', {
86
+ enumerable: true,
87
+ get: function () {
88
+ return https_exports;
89
+ }
90
+ });
91
+ exports.onCall = onCall;
92
+ exports.onRequest = onRequest;