firebase-functions 6.6.0 → 7.0.0-rc.1

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 +321 -88
  155. package/protos/compiledFirestore.mjs +3512 -0
  156. package/protos/update.sh +28 -7
@@ -0,0 +1,155 @@
1
+ import { __export } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { initV2Endpoint } from "../../runtime/manifest.mjs";
3
+ import { firebaseConfig } from "../../common/config.mjs";
4
+ import { copyIfPresent } from "../../common/encoding.mjs";
5
+ import { withInit } from "../../common/onInit.mjs";
6
+ import { wrapTraceContext } from "../trace.mjs";
7
+ import { getGlobalOptions, optionsToEndpoint, optionsToTriggerAnnotations } from "../options.mjs";
8
+
9
+ //#region src/v2/providers/storage.ts
10
+ var storage_exports = /* @__PURE__ */ __export({
11
+ archivedEvent: () => archivedEvent,
12
+ deletedEvent: () => deletedEvent,
13
+ finalizedEvent: () => finalizedEvent,
14
+ getOptsAndBucket: () => getOptsAndBucket,
15
+ metadataUpdatedEvent: () => metadataUpdatedEvent,
16
+ onObjectArchived: () => onObjectArchived,
17
+ onObjectDeleted: () => onObjectDeleted,
18
+ onObjectFinalized: () => onObjectFinalized,
19
+ onObjectMetadataUpdated: () => onObjectMetadataUpdated,
20
+ onOperation: () => onOperation
21
+ });
22
+ /** @internal */
23
+ const archivedEvent = "google.cloud.storage.object.v1.archived";
24
+ /** @internal */
25
+ const finalizedEvent = "google.cloud.storage.object.v1.finalized";
26
+ /** @internal */
27
+ const deletedEvent = "google.cloud.storage.object.v1.deleted";
28
+ /** @internal */
29
+ const metadataUpdatedEvent = "google.cloud.storage.object.v1.metadataUpdated";
30
+ /**
31
+ * Event handler sent only when a bucket has enabled object versioning.
32
+ * This event indicates that the live version of an object has become an
33
+ * archived version, either because it was archived or because it was
34
+ * overwritten by the upload of an object of the same name.
35
+ *
36
+ * @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
37
+ * @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
38
+ */
39
+ function onObjectArchived(bucketOrOptsOrHandler, handler) {
40
+ return onOperation(archivedEvent, bucketOrOptsOrHandler, handler);
41
+ }
42
+ /**
43
+ * Event handler which fires every time a Google Cloud Storage object
44
+ * creation occurs.
45
+ *
46
+ * Sent when a new object (or a new generation of an existing object)
47
+ * is successfully created in the bucket. This includes copying or rewriting
48
+ * an existing object. A failed upload does not trigger this event.
49
+ *
50
+ * @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
51
+ * @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
52
+ */
53
+ function onObjectFinalized(bucketOrOptsOrHandler, handler) {
54
+ return onOperation(finalizedEvent, bucketOrOptsOrHandler, handler);
55
+ }
56
+ /**
57
+ * Event handler which fires every time a Google Cloud Storage deletion occurs.
58
+ *
59
+ * Sent when an object has been permanently deleted. This includes objects
60
+ * that are overwritten or are deleted as part of the bucket's lifecycle
61
+ * configuration. For buckets with object versioning enabled, this is not
62
+ * sent when an object is archived, even if archival occurs
63
+ * via the `storage.objects.delete` method.
64
+ *
65
+ * @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
66
+ * @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
67
+ */
68
+ function onObjectDeleted(bucketOrOptsOrHandler, handler) {
69
+ return onOperation(deletedEvent, bucketOrOptsOrHandler, handler);
70
+ }
71
+ /**
72
+ * Event handler which fires every time the metadata of an existing object
73
+ * changes.
74
+ *
75
+ * @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
76
+ * @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
77
+ */
78
+ function onObjectMetadataUpdated(bucketOrOptsOrHandler, handler) {
79
+ return onOperation(metadataUpdatedEvent, bucketOrOptsOrHandler, handler);
80
+ }
81
+ /** @internal */
82
+ function onOperation(eventType, bucketOrOptsOrHandler, handler) {
83
+ if (typeof bucketOrOptsOrHandler === "function") {
84
+ handler = bucketOrOptsOrHandler;
85
+ bucketOrOptsOrHandler = {};
86
+ }
87
+ const [opts, bucket] = getOptsAndBucket(bucketOrOptsOrHandler);
88
+ const func = (raw) => {
89
+ return wrapTraceContext(withInit(handler))(raw);
90
+ };
91
+ func.run = handler;
92
+ Object.defineProperty(func, "__trigger", { get: () => {
93
+ const baseOpts = optionsToTriggerAnnotations(getGlobalOptions());
94
+ const specificOpts = optionsToTriggerAnnotations(opts);
95
+ return {
96
+ platform: "gcfv2",
97
+ ...baseOpts,
98
+ ...specificOpts,
99
+ labels: {
100
+ ...baseOpts?.labels,
101
+ ...specificOpts?.labels
102
+ },
103
+ eventTrigger: {
104
+ eventType,
105
+ resource: bucket
106
+ }
107
+ };
108
+ } });
109
+ func.__endpoint = {};
110
+ Object.defineProperty(func, "__endpoint", { get: () => {
111
+ const baseOpts = optionsToEndpoint(getGlobalOptions());
112
+ const specificOpts = optionsToEndpoint(opts);
113
+ const endpoint = {
114
+ platform: "gcfv2",
115
+ ...initV2Endpoint(getGlobalOptions(), opts),
116
+ ...baseOpts,
117
+ ...specificOpts,
118
+ labels: {
119
+ ...baseOpts?.labels,
120
+ ...specificOpts?.labels
121
+ },
122
+ eventTrigger: {
123
+ eventType,
124
+ eventFilters: { bucket },
125
+ retry: opts.retry ?? false
126
+ }
127
+ };
128
+ copyIfPresent(endpoint.eventTrigger, opts, "retry", "retry");
129
+ return endpoint;
130
+ } });
131
+ return func;
132
+ }
133
+ /** @internal */
134
+ function getOptsAndBucket(bucketOrOpts) {
135
+ let bucket;
136
+ let opts;
137
+ if (typeof bucketOrOpts === "string" || "value" in bucketOrOpts) {
138
+ bucket = bucketOrOpts;
139
+ opts = {};
140
+ } else {
141
+ bucket = bucketOrOpts.bucket || firebaseConfig()?.storageBucket;
142
+ opts = { ...bucketOrOpts };
143
+ delete opts.bucket;
144
+ }
145
+ if (!bucket) {
146
+ throw new Error("Missing bucket name. If you are unit testing, please provide a bucket name" + " by providing bucket name directly in the event handler or by setting process.env.FIREBASE_CONFIG.");
147
+ }
148
+ if (typeof bucket === "string" && !/^[a-z\d][a-z\d\\._-]{1,230}[a-z\d]$/.test(bucket)) {
149
+ throw new Error(`Invalid bucket name ${bucket}`);
150
+ }
151
+ return [opts, bucket];
152
+ }
153
+
154
+ //#endregion
155
+ export { archivedEvent, deletedEvent, finalizedEvent, getOptsAndBucket, metadataUpdatedEvent, onObjectArchived, onObjectDeleted, onObjectFinalized, onObjectMetadataUpdated, onOperation, storage_exports };
@@ -0,0 +1,65 @@
1
+ import { __export } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { initTaskQueueTrigger, initV2Endpoint } from "../../runtime/manifest.mjs";
3
+ import { convertIfPresent, convertInvoker, copyIfPresent } from "../../common/encoding.mjs";
4
+ import { withInit } from "../../common/onInit.mjs";
5
+ import { wrapTraceContext } from "../trace.mjs";
6
+ import { onDispatchHandler } from "../../common/providers/tasks.mjs";
7
+ import { getGlobalOptions, optionsToEndpoint, optionsToTriggerAnnotations } from "../options.mjs";
8
+
9
+ //#region src/v2/providers/tasks.ts
10
+ var tasks_exports = /* @__PURE__ */ __export({ onTaskDispatched: () => onTaskDispatched });
11
+ function onTaskDispatched(optsOrHandler, handler) {
12
+ let opts;
13
+ if (arguments.length === 1) {
14
+ opts = {};
15
+ handler = optsOrHandler;
16
+ } else {
17
+ opts = optsOrHandler;
18
+ }
19
+ const fixedLen = (req) => handler(req);
20
+ const func = wrapTraceContext(withInit(onDispatchHandler(fixedLen)));
21
+ Object.defineProperty(func, "__trigger", { get: () => {
22
+ const baseOpts$1 = optionsToTriggerAnnotations(getGlobalOptions());
23
+ const specificOpts$1 = optionsToTriggerAnnotations(opts);
24
+ const taskQueueTrigger = {};
25
+ copyIfPresent(taskQueueTrigger, opts, "retryConfig", "rateLimits");
26
+ convertIfPresent(taskQueueTrigger, getGlobalOptions(), "invoker", "invoker", convertInvoker);
27
+ convertIfPresent(taskQueueTrigger, opts, "invoker", "invoker", convertInvoker);
28
+ return {
29
+ platform: "gcfv2",
30
+ ...baseOpts$1,
31
+ ...specificOpts$1,
32
+ labels: {
33
+ ...baseOpts$1?.labels,
34
+ ...specificOpts$1?.labels
35
+ },
36
+ taskQueueTrigger
37
+ };
38
+ } });
39
+ const baseOpts = optionsToEndpoint(getGlobalOptions());
40
+ const specificOpts = optionsToEndpoint(opts);
41
+ func.__endpoint = {
42
+ platform: "gcfv2",
43
+ ...initV2Endpoint(getGlobalOptions(), opts),
44
+ ...baseOpts,
45
+ ...specificOpts,
46
+ labels: {
47
+ ...baseOpts?.labels,
48
+ ...specificOpts?.labels
49
+ },
50
+ taskQueueTrigger: initTaskQueueTrigger(getGlobalOptions(), opts)
51
+ };
52
+ copyIfPresent(func.__endpoint.taskQueueTrigger.retryConfig, opts.retryConfig, "maxAttempts", "maxBackoffSeconds", "maxDoublings", "maxRetrySeconds", "minBackoffSeconds");
53
+ copyIfPresent(func.__endpoint.taskQueueTrigger.rateLimits, opts.rateLimits, "maxConcurrentDispatches", "maxDispatchesPerSecond");
54
+ convertIfPresent(func.__endpoint.taskQueueTrigger, getGlobalOptions(), "invoker", "invoker", convertInvoker);
55
+ convertIfPresent(func.__endpoint.taskQueueTrigger, opts, "invoker", "invoker", convertInvoker);
56
+ func.__requiredAPIs = [{
57
+ api: "cloudtasks.googleapis.com",
58
+ reason: "Needed for task queue functions"
59
+ }];
60
+ func.run = handler;
61
+ return func;
62
+ }
63
+
64
+ //#endregion
65
+ export { onTaskDispatched, tasks_exports };
@@ -0,0 +1,53 @@
1
+ import { __export } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { initV2Endpoint } from "../../runtime/manifest.mjs";
3
+ import { withInit } from "../../common/onInit.mjs";
4
+ import { wrapTraceContext } from "../trace.mjs";
5
+ import { getGlobalOptions, optionsToEndpoint } from "../options.mjs";
6
+
7
+ //#region src/v2/providers/testLab.ts
8
+ var testLab_exports = /* @__PURE__ */ __export({
9
+ eventType: () => eventType,
10
+ onTestMatrixCompleted: () => onTestMatrixCompleted
11
+ });
12
+ /** @internal */
13
+ const eventType = "google.firebase.testlab.testMatrix.v1.completed";
14
+ /**
15
+ * Event handler which triggers when a Firebase test matrix completes.
16
+ *
17
+ * @param optsOrHandler - Options or an event handler.
18
+ * @param handler - Event handler which is run every time a Firebase test matrix completes.
19
+ * @returns A Cloud Function that you can export and deploy.
20
+ * @alpha
21
+ */
22
+ function onTestMatrixCompleted(optsOrHandler, handler) {
23
+ if (typeof optsOrHandler === "function") {
24
+ handler = optsOrHandler;
25
+ optsOrHandler = {};
26
+ }
27
+ const baseOpts = optionsToEndpoint(getGlobalOptions());
28
+ const specificOpts = optionsToEndpoint(optsOrHandler);
29
+ const func = (raw) => {
30
+ return wrapTraceContext(withInit(handler))(raw);
31
+ };
32
+ func.run = handler;
33
+ const ep = {
34
+ ...initV2Endpoint(getGlobalOptions(), optsOrHandler),
35
+ platform: "gcfv2",
36
+ ...baseOpts,
37
+ ...specificOpts,
38
+ labels: {
39
+ ...baseOpts?.labels,
40
+ ...specificOpts?.labels
41
+ },
42
+ eventTrigger: {
43
+ eventType,
44
+ eventFilters: {},
45
+ retry: optsOrHandler.retry ?? false
46
+ }
47
+ };
48
+ func.__endpoint = ep;
49
+ return func;
50
+ }
51
+
52
+ //#endregion
53
+ export { eventType, onTestMatrixCompleted, testLab_exports };
@@ -0,0 +1,20 @@
1
+ import { extractTraceContext, traceContext } from "../common/trace.mjs";
2
+
3
+ //#region src/v2/trace.ts
4
+ function wrapTraceContext(handler) {
5
+ return (...args) => {
6
+ let traceParent;
7
+ if (args.length === 1) {
8
+ traceParent = extractTraceContext(args[0]);
9
+ } else {
10
+ traceParent = extractTraceContext(args[0].headers);
11
+ }
12
+ if (!traceParent) {
13
+ return handler.apply(null, args);
14
+ }
15
+ return traceContext.run(traceParent, handler, ...args);
16
+ };
17
+ }
18
+
19
+ //#endregion
20
+ export { wrapTraceContext };
File without changes
File without changes
@@ -1,45 +1,25 @@
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.UNPATCHED_CONSOLE = exports.CONSOLE_SEVERITY = void 0;
25
- // Map LogSeverity types to their equivalent `console.*` method.
1
+
2
+ //#region src/logger/common.ts
26
3
  /** @hidden */
27
- exports.CONSOLE_SEVERITY = {
28
- DEBUG: "debug",
29
- INFO: "info",
30
- NOTICE: "info",
31
- WARNING: "warn",
32
- ERROR: "error",
33
- CRITICAL: "error",
34
- ALERT: "error",
35
- EMERGENCY: "error",
4
+ const CONSOLE_SEVERITY = {
5
+ DEBUG: "debug",
6
+ INFO: "info",
7
+ NOTICE: "info",
8
+ WARNING: "warn",
9
+ ERROR: "error",
10
+ CRITICAL: "error",
11
+ ALERT: "error",
12
+ EMERGENCY: "error"
36
13
  };
37
- // safely preserve unpatched console.* methods in case of compat require
38
14
  /** @hidden */
39
- exports.UNPATCHED_CONSOLE = {
40
- debug: console.debug,
41
- info: console.info,
42
- log: console.log,
43
- warn: console.warn,
44
- error: console.error,
15
+ const UNPATCHED_CONSOLE = {
16
+ debug: console.debug,
17
+ info: console.info,
18
+ log: console.log,
19
+ warn: console.warn,
20
+ error: console.error
45
21
  };
22
+
23
+ //#endregion
24
+ exports.CONSOLE_SEVERITY = CONSOLE_SEVERITY;
25
+ exports.UNPATCHED_CONSOLE = UNPATCHED_CONSOLE;
@@ -1,41 +1,26 @@
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
- const util_1 = require("util");
25
- const common_1 = require("./common");
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const require_logger_common = require('./common.js');
3
+ let util = require("util");
4
+ util = require_rolldown_runtime.__toESM(util);
5
+
6
+ //#region src/logger/compat.ts
26
7
  /** @hidden */
27
8
  function patchedConsole(severity) {
28
- return function (data, ...args) {
29
- let message = (0, util_1.format)(data, ...args);
30
- if (severity === "ERROR") {
31
- message = new Error(message).stack || message;
32
- }
33
- common_1.UNPATCHED_CONSOLE[common_1.CONSOLE_SEVERITY[severity]](JSON.stringify({ severity, message }));
34
- };
9
+ return function(data, ...args) {
10
+ let message = (0, util.format)(data, ...args);
11
+ if (severity === "ERROR") {
12
+ message = new Error(message).stack || message;
13
+ }
14
+ require_logger_common.UNPATCHED_CONSOLE[require_logger_common.CONSOLE_SEVERITY[severity]](JSON.stringify({
15
+ severity,
16
+ message
17
+ }));
18
+ };
35
19
  }
36
- // IMPORTANT -- "../logger" must be imported before monkeypatching!
37
20
  console.debug = patchedConsole("DEBUG");
38
21
  console.info = patchedConsole("INFO");
39
22
  console.log = patchedConsole("INFO");
40
23
  console.warn = patchedConsole("WARNING");
41
24
  console.error = patchedConsole("ERROR");
25
+
26
+ //#endregion