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,247 +1,226 @@
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.ExportBundleInfo = exports.UserPropertyValue = exports.UserDimensions = exports.AnalyticsEvent = exports.AnalyticsEventBuilder = exports._eventWithOptions = exports.event = exports.service = exports.provider = void 0;
25
- const cloud_functions_1 = require("../cloud-functions");
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
2
+ const require_v1_cloud_functions = require('../cloud-functions.js');
3
+
4
+ //#region src/v1/providers/analytics.ts
5
+ var analytics_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
6
+ AnalyticsEvent: () => AnalyticsEvent,
7
+ AnalyticsEventBuilder: () => AnalyticsEventBuilder,
8
+ ExportBundleInfo: () => ExportBundleInfo,
9
+ UserDimensions: () => UserDimensions,
10
+ UserPropertyValue: () => UserPropertyValue,
11
+ _eventWithOptions: () => _eventWithOptions,
12
+ event: () => event,
13
+ provider: () => provider,
14
+ service: () => service
15
+ });
26
16
  /** @internal */
27
- exports.provider = "google.analytics";
17
+ const provider = "google.analytics";
28
18
  /** @internal */
29
- exports.service = "app-measurement.com";
19
+ const service = "app-measurement.com";
30
20
  /**
31
- * Registers a function to handle analytics events.
32
- *
33
- * @param analyticsEventType Name of the analytics event type to which
34
- * this Cloud Function is scoped.
35
- *
36
- * @returns Analytics event builder interface.
37
- */
21
+ * Registers a function to handle analytics events.
22
+ *
23
+ * @param analyticsEventType Name of the analytics event type to which
24
+ * this Cloud Function is scoped.
25
+ *
26
+ * @returns Analytics event builder interface.
27
+ */
38
28
  function event(analyticsEventType) {
39
- return _eventWithOptions(analyticsEventType, {});
29
+ return _eventWithOptions(analyticsEventType, {});
40
30
  }
41
- exports.event = event;
42
31
  /** @internal */
43
32
  function _eventWithOptions(analyticsEventType, options) {
44
- return new AnalyticsEventBuilder(() => {
45
- if (!process.env.GCLOUD_PROJECT) {
46
- throw new Error("process.env.GCLOUD_PROJECT is not set.");
47
- }
48
- return "projects/" + process.env.GCLOUD_PROJECT + "/events/" + analyticsEventType;
49
- }, options);
33
+ return new AnalyticsEventBuilder(() => {
34
+ if (!process.env.GCLOUD_PROJECT) {
35
+ throw new Error("process.env.GCLOUD_PROJECT is not set.");
36
+ }
37
+ return "projects/" + process.env.GCLOUD_PROJECT + "/events/" + analyticsEventType;
38
+ }, options);
50
39
  }
51
- exports._eventWithOptions = _eventWithOptions;
52
40
  /**
53
- * The Firebase Analytics event builder interface.
54
- *
55
- * Access via `functions.analytics.event()`.
56
- */
57
- class AnalyticsEventBuilder {
58
- /** @hidden */
59
- constructor(triggerResource, options) {
60
- this.triggerResource = triggerResource;
61
- this.options = options;
62
- }
63
- /**
64
- * Event handler that fires every time a Firebase Analytics event occurs.
65
- *
66
- * @param handler Event handler that fires every time a Firebase Analytics event
67
- * occurs.
68
- *
69
- * @returns A function that you can export and deploy.
70
- */
71
- onLog(handler) {
72
- const dataConstructor = (raw) => {
73
- return new AnalyticsEvent(raw.data);
74
- };
75
- return (0, cloud_functions_1.makeCloudFunction)({
76
- handler,
77
- provider: exports.provider,
78
- eventType: "event.log",
79
- service: exports.service,
80
- legacyEventType: `providers/google.firebase.analytics/eventTypes/event.log`,
81
- triggerResource: this.triggerResource,
82
- dataConstructor,
83
- options: this.options,
84
- });
85
- }
86
- }
87
- exports.AnalyticsEventBuilder = AnalyticsEventBuilder;
41
+ * The Firebase Analytics event builder interface.
42
+ *
43
+ * Access via `functions.analytics.event()`.
44
+ */
45
+ var AnalyticsEventBuilder = class {
46
+ /** @hidden */
47
+ constructor(triggerResource, options) {
48
+ this.triggerResource = triggerResource;
49
+ this.options = options;
50
+ }
51
+ /**
52
+ * Event handler that fires every time a Firebase Analytics event occurs.
53
+ *
54
+ * @param handler Event handler that fires every time a Firebase Analytics event
55
+ * occurs.
56
+ *
57
+ * @returns A function that you can export and deploy.
58
+ */
59
+ onLog(handler) {
60
+ const dataConstructor = (raw) => {
61
+ return new AnalyticsEvent(raw.data);
62
+ };
63
+ return require_v1_cloud_functions.makeCloudFunction({
64
+ handler,
65
+ provider,
66
+ eventType: "event.log",
67
+ service,
68
+ legacyEventType: `providers/google.firebase.analytics/eventTypes/event.log`,
69
+ triggerResource: this.triggerResource,
70
+ dataConstructor,
71
+ options: this.options
72
+ });
73
+ }
74
+ };
88
75
  /** Interface representing a Firebase Analytics event that was logged for a specific user. */
89
- class AnalyticsEvent {
90
- /** @hidden */
91
- constructor(wireFormat) {
92
- this.params = {}; // In case of absent field, show empty (not absent) map.
93
- if (wireFormat.eventDim && wireFormat.eventDim.length > 0) {
94
- // If there's an eventDim, there'll always be exactly one.
95
- const eventDim = wireFormat.eventDim[0];
96
- copyField(eventDim, this, "name");
97
- copyField(eventDim, this, "params", (p) => mapKeys(p, unwrapValue));
98
- copyFieldTo(eventDim, this, "valueInUsd", "valueInUSD");
99
- copyFieldTo(eventDim, this, "date", "reportingDate");
100
- copyTimestampToString(eventDim, this, "timestampMicros", "logTime");
101
- copyTimestampToString(eventDim, this, "previousTimestampMicros", "previousLogTime");
102
- }
103
- copyFieldTo(wireFormat, this, "userDim", "user", (dim) => new UserDimensions(dim));
104
- }
76
+ var AnalyticsEvent = class {
77
+ /** @hidden */
78
+ constructor(wireFormat) {
79
+ this.params = {};
80
+ if (wireFormat.eventDim && wireFormat.eventDim.length > 0) {
81
+ const eventDim = wireFormat.eventDim[0];
82
+ copyField(eventDim, this, "name");
83
+ copyField(eventDim, this, "params", (p) => mapKeys(p, unwrapValue));
84
+ copyFieldTo(eventDim, this, "valueInUsd", "valueInUSD");
85
+ copyFieldTo(eventDim, this, "date", "reportingDate");
86
+ copyTimestampToString(eventDim, this, "timestampMicros", "logTime");
87
+ copyTimestampToString(eventDim, this, "previousTimestampMicros", "previousLogTime");
88
+ }
89
+ copyFieldTo(wireFormat, this, "userDim", "user", (dim) => new UserDimensions(dim));
90
+ }
91
+ };
92
+ function isValidUserProperty(property) {
93
+ if (property == null || typeof property !== "object" || !("value" in property)) {
94
+ return false;
95
+ }
96
+ const { value } = property;
97
+ if (value == null) {
98
+ return false;
99
+ }
100
+ if (typeof value === "object" && Object.keys(value).length === 0) {
101
+ return false;
102
+ }
103
+ return true;
105
104
  }
106
- exports.AnalyticsEvent = AnalyticsEvent;
107
105
  /**
108
- * Interface representing the user who triggered the events.
109
- */
110
- class UserDimensions {
111
- /** @hidden */
112
- constructor(wireFormat) {
113
- // These are interfaces or primitives, no transformation needed.
114
- copyFields(wireFormat, this, ["userId", "deviceInfo", "geoInfo", "appInfo"]);
115
- // The following fields do need transformations of some sort.
116
- copyTimestampToString(wireFormat, this, "firstOpenTimestampMicros", "firstOpenTime");
117
- this.userProperties = {}; // With no entries in the wire format, present an empty (as opposed to absent) map.
118
- copyField(wireFormat, this, "userProperties", (r) => {
119
- const entries = Object.entries(r).map(([k, v]) => [k, new UserPropertyValue(v)]);
120
- return Object.fromEntries(entries);
121
- });
122
- copyField(wireFormat, this, "bundleInfo", (r) => new ExportBundleInfo(r));
123
- // BUG(36000368) Remove when no longer necessary
124
- /* tslint:disable:no-string-literal */
125
- if (!this.userId && this.userProperties["user_id"]) {
126
- this.userId = this.userProperties["user_id"].value;
127
- }
128
- /* tslint:enable:no-string-literal */
129
- }
130
- }
131
- exports.UserDimensions = UserDimensions;
106
+ * Interface representing the user who triggered the events.
107
+ */
108
+ var UserDimensions = class {
109
+ /** @hidden */
110
+ constructor(wireFormat) {
111
+ copyFields(wireFormat, this, [
112
+ "userId",
113
+ "deviceInfo",
114
+ "geoInfo",
115
+ "appInfo"
116
+ ]);
117
+ copyTimestampToString(wireFormat, this, "firstOpenTimestampMicros", "firstOpenTime");
118
+ this.userProperties = {};
119
+ copyField(wireFormat, this, "userProperties", (r) => {
120
+ const entries = Object.entries(r).filter(([, v]) => isValidUserProperty(v)).map(([k, v]) => [k, new UserPropertyValue(v)]);
121
+ return Object.fromEntries(entries);
122
+ });
123
+ copyField(wireFormat, this, "bundleInfo", (r) => new ExportBundleInfo(r));
124
+ if (!this.userId && this.userProperties["user_id"]) {
125
+ this.userId = this.userProperties["user_id"].value;
126
+ }
127
+ }
128
+ };
132
129
  /** Predefined or custom properties stored on the client side. */
133
- class UserPropertyValue {
134
- /** @hidden */
135
- constructor(wireFormat) {
136
- copyField(wireFormat, this, "value", unwrapValueAsString);
137
- copyTimestampToString(wireFormat, this, "setTimestampUsec", "setTime");
138
- }
139
- }
140
- exports.UserPropertyValue = UserPropertyValue;
130
+ var UserPropertyValue = class {
131
+ /** @hidden */
132
+ constructor(wireFormat) {
133
+ copyField(wireFormat, this, "value", unwrapValueAsString);
134
+ copyTimestampToString(wireFormat, this, "setTimestampUsec", "setTime");
135
+ }
136
+ };
141
137
  /** Interface representing the bundle these events were uploaded to. */
142
- class ExportBundleInfo {
143
- /** @hidden */
144
- constructor(wireFormat) {
145
- copyField(wireFormat, this, "bundleSequenceId");
146
- copyTimestampToMillis(wireFormat, this, "serverTimestampOffsetMicros", "serverTimestampOffset");
147
- }
148
- }
149
- exports.ExportBundleInfo = ExportBundleInfo;
138
+ var ExportBundleInfo = class {
139
+ /** @hidden */
140
+ constructor(wireFormat) {
141
+ copyField(wireFormat, this, "bundleSequenceId");
142
+ copyTimestampToMillis(wireFormat, this, "serverTimestampOffsetMicros", "serverTimestampOffset");
143
+ }
144
+ };
150
145
  /** @hidden */
151
146
  function copyFieldTo(from, to, fromField, toField, transform) {
152
- if (typeof from[fromField] === "undefined") {
153
- return;
154
- }
155
- if (transform) {
156
- to[toField] = transform(from[fromField]);
157
- return;
158
- }
159
- to[toField] = from[fromField];
147
+ if (typeof from[fromField] === "undefined") {
148
+ return;
149
+ }
150
+ if (transform) {
151
+ to[toField] = transform(from[fromField]);
152
+ return;
153
+ }
154
+ to[toField] = from[fromField];
160
155
  }
161
156
  /** @hidden */
162
- function copyField(from, to, field, transform = (from) => from) {
163
- copyFieldTo(from, to, field, field, transform);
157
+ function copyField(from, to, field, transform = (from$1) => from$1) {
158
+ copyFieldTo(from, to, field, field, transform);
164
159
  }
165
160
  /** @hidden */
166
161
  function copyFields(from, to, fields) {
167
- for (const field of fields) {
168
- copyField(from, to, field);
169
- }
162
+ for (const field of fields) {
163
+ copyField(from, to, field);
164
+ }
170
165
  }
171
166
  function mapKeys(obj, transform) {
172
- const entries = Object.entries(obj).map(([k, v]) => [k, transform(v)]);
173
- return Object.fromEntries(entries);
167
+ const entries = Object.entries(obj).map(([k, v]) => [k, transform(v)]);
168
+ return Object.fromEntries(entries);
174
169
  }
175
- // The incoming payload will have fields like:
176
- // {
177
- // 'myInt': {
178
- // 'intValue': '123'
179
- // },
180
- // 'myDouble': {
181
- // 'doubleValue': 1.0
182
- // },
183
- // 'myFloat': {
184
- // 'floatValue': 1.1
185
- // },
186
- // 'myString': {
187
- // 'stringValue': 'hi!'
188
- // }
189
- // }
190
- //
191
- // The following method will remove these four types of 'xValue' fields, flattening them
192
- // to just their values, as a string:
193
- // {
194
- // 'myInt': '123',
195
- // 'myDouble': '1.0',
196
- // 'myFloat': '1.1',
197
- // 'myString': 'hi!'
198
- // }
199
- //
200
- // Note that while 'intValue' will have a quoted payload, 'doubleValue' and 'floatValue' will not. This
201
- // is due to the encoding library, which renders int64 values as strings to avoid loss of precision. This
202
- // method always returns a string, similarly to avoid loss of precision, unlike the less-conservative
203
- // 'unwrapValue' method just below.
204
170
  /** @hidden */
205
171
  function unwrapValueAsString(wrapped) {
206
- const key = Object.keys(wrapped)[0];
207
- return wrapped[key].toString();
172
+ if (!wrapped || typeof wrapped !== "object") {
173
+ return "";
174
+ }
175
+ const keys = Object.keys(wrapped);
176
+ if (keys.length === 0) {
177
+ return "";
178
+ }
179
+ const key = keys[0];
180
+ const value = wrapped[key];
181
+ if (value === null || value === undefined) {
182
+ return "";
183
+ }
184
+ return value.toString();
208
185
  }
209
- // Ditto as the method above, but returning the values in the idiomatic JavaScript type (string for strings,
210
- // number for numbers):
211
- // {
212
- // 'myInt': 123,
213
- // 'myDouble': 1.0,
214
- // 'myFloat': 1.1,
215
- // 'myString': 'hi!'
216
- // }
217
- //
218
- // The field names in the incoming xValue fields identify the type a value has, which for JavaScript's
219
- // purposes can be divided into 'number' versus 'string'. This method will render all the numbers as
220
- // JavaScript's 'number' type, since we prefer using idiomatic types. Note that this may lead to loss
221
- // in precision for int64 fields, so use with care.
222
186
  /** @hidden */
223
- const xValueNumberFields = ["intValue", "floatValue", "doubleValue"];
187
+ const xValueNumberFields = [
188
+ "intValue",
189
+ "floatValue",
190
+ "doubleValue"
191
+ ];
224
192
  /** @hidden */
225
193
  function unwrapValue(wrapped) {
226
- const key = Object.keys(wrapped)[0];
227
- const value = unwrapValueAsString(wrapped);
228
- return xValueNumberFields.includes(key) ? Number(value) : value;
194
+ const key = Object.keys(wrapped)[0];
195
+ const value = unwrapValueAsString(wrapped);
196
+ return xValueNumberFields.includes(key) ? Number(value) : value;
229
197
  }
230
- // The JSON payload delivers timestamp fields as strings of timestamps denoted in microseconds.
231
- // The JavaScript convention is to use numbers denoted in milliseconds. This method
232
- // makes it easy to convert a field of one type into the other.
233
198
  /** @hidden */
234
199
  function copyTimestampToMillis(from, to, fromName, toName) {
235
- if (from[fromName] !== undefined) {
236
- to[toName] = Math.round(from[fromName] / 1000);
237
- }
200
+ if (from[fromName] !== undefined) {
201
+ to[toName] = Math.round(from[fromName] / 1e3);
202
+ }
238
203
  }
239
- // The JSON payload delivers timestamp fields as strings of timestamps denoted in microseconds.
240
- // In our SDK, we'd like to present timestamp as ISO-format strings. This method makes it easy
241
- // to convert a field of one type into the other.
242
204
  /** @hidden */
243
205
  function copyTimestampToString(from, to, fromName, toName) {
244
- if (from[fromName] !== undefined) {
245
- to[toName] = new Date(from[fromName] / 1000).toISOString();
246
- }
206
+ if (from[fromName] !== undefined) {
207
+ to[toName] = new Date(from[fromName] / 1e3).toISOString();
208
+ }
247
209
  }
210
+
211
+ //#endregion
212
+ exports.AnalyticsEvent = AnalyticsEvent;
213
+ exports.AnalyticsEventBuilder = AnalyticsEventBuilder;
214
+ exports.ExportBundleInfo = ExportBundleInfo;
215
+ exports.UserDimensions = UserDimensions;
216
+ exports.UserPropertyValue = UserPropertyValue;
217
+ exports._eventWithOptions = _eventWithOptions;
218
+ Object.defineProperty(exports, 'analytics_exports', {
219
+ enumerable: true,
220
+ get: function () {
221
+ return analytics_exports;
222
+ }
223
+ });
224
+ exports.event = event;
225
+ exports.provider = provider;
226
+ exports.service = service;
@@ -1,6 +1,7 @@
1
1
  import { AuthEventContext, AuthUserRecord, BeforeCreateResponse, BeforeEmailResponse, BeforeSignInResponse, BeforeSmsResponse, HttpsError, MaybeAsync, UserInfo, UserRecord, userRecordConstructor, UserRecordMetadata } from "../../common/providers/identity";
2
2
  import { BlockingFunction, CloudFunction, EventContext } from "../cloud-functions";
3
- export { UserRecord, UserInfo, UserRecordMetadata, userRecordConstructor };
3
+ export { UserRecordMetadata, userRecordConstructor };
4
+ export type { UserRecord, UserInfo };
4
5
  export { HttpsError };
5
6
  /**
6
7
  * Options for Auth blocking function.