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
@@ -1,273 +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
- }
105
- }
106
- exports.AnalyticsEvent = AnalyticsEvent;
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
+ };
107
92
  function isValidUserProperty(property) {
108
- if (property == null || typeof property !== "object" || !("value" in property)) {
109
- return false;
110
- }
111
- const { value } = property;
112
- if (value == null) {
113
- return false;
114
- }
115
- if (typeof value === "object" && Object.keys(value).length === 0) {
116
- return false;
117
- }
118
- return true;
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;
119
104
  }
120
105
  /**
121
- * Interface representing the user who triggered the events.
122
- */
123
- class UserDimensions {
124
- /** @hidden */
125
- constructor(wireFormat) {
126
- // These are interfaces or primitives, no transformation needed.
127
- copyFields(wireFormat, this, ["userId", "deviceInfo", "geoInfo", "appInfo"]);
128
- // The following fields do need transformations of some sort.
129
- copyTimestampToString(wireFormat, this, "firstOpenTimestampMicros", "firstOpenTime");
130
- this.userProperties = {}; // With no entries in the wire format, present an empty (as opposed to absent) map.
131
- copyField(wireFormat, this, "userProperties", (r) => {
132
- const entries = Object.entries(r)
133
- .filter(([, v]) => isValidUserProperty(v))
134
- .map(([k, v]) => [k, new UserPropertyValue(v)]);
135
- return Object.fromEntries(entries);
136
- });
137
- copyField(wireFormat, this, "bundleInfo", (r) => new ExportBundleInfo(r));
138
- // BUG(36000368) Remove when no longer necessary
139
- /* tslint:disable:no-string-literal */
140
- if (!this.userId && this.userProperties["user_id"]) {
141
- this.userId = this.userProperties["user_id"].value;
142
- }
143
- /* tslint:enable:no-string-literal */
144
- }
145
- }
146
- 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
+ };
147
129
  /** Predefined or custom properties stored on the client side. */
148
- class UserPropertyValue {
149
- /** @hidden */
150
- constructor(wireFormat) {
151
- copyField(wireFormat, this, "value", unwrapValueAsString);
152
- copyTimestampToString(wireFormat, this, "setTimestampUsec", "setTime");
153
- }
154
- }
155
- 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
+ };
156
137
  /** Interface representing the bundle these events were uploaded to. */
157
- class ExportBundleInfo {
158
- /** @hidden */
159
- constructor(wireFormat) {
160
- copyField(wireFormat, this, "bundleSequenceId");
161
- copyTimestampToMillis(wireFormat, this, "serverTimestampOffsetMicros", "serverTimestampOffset");
162
- }
163
- }
164
- 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
+ };
165
145
  /** @hidden */
166
146
  function copyFieldTo(from, to, fromField, toField, transform) {
167
- if (typeof from[fromField] === "undefined") {
168
- return;
169
- }
170
- if (transform) {
171
- to[toField] = transform(from[fromField]);
172
- return;
173
- }
174
- 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];
175
155
  }
176
156
  /** @hidden */
177
- function copyField(from, to, field, transform = (from) => from) {
178
- copyFieldTo(from, to, field, field, transform);
157
+ function copyField(from, to, field, transform = (from$1) => from$1) {
158
+ copyFieldTo(from, to, field, field, transform);
179
159
  }
180
160
  /** @hidden */
181
161
  function copyFields(from, to, fields) {
182
- for (const field of fields) {
183
- copyField(from, to, field);
184
- }
162
+ for (const field of fields) {
163
+ copyField(from, to, field);
164
+ }
185
165
  }
186
166
  function mapKeys(obj, transform) {
187
- const entries = Object.entries(obj).map(([k, v]) => [k, transform(v)]);
188
- return Object.fromEntries(entries);
167
+ const entries = Object.entries(obj).map(([k, v]) => [k, transform(v)]);
168
+ return Object.fromEntries(entries);
189
169
  }
190
- // The incoming payload will have fields like:
191
- // {
192
- // 'myInt': {
193
- // 'intValue': '123'
194
- // },
195
- // 'myDouble': {
196
- // 'doubleValue': 1.0
197
- // },
198
- // 'myFloat': {
199
- // 'floatValue': 1.1
200
- // },
201
- // 'myString': {
202
- // 'stringValue': 'hi!'
203
- // }
204
- // }
205
- //
206
- // The following method will remove these four types of 'xValue' fields, flattening them
207
- // to just their values, as a string:
208
- // {
209
- // 'myInt': '123',
210
- // 'myDouble': '1.0',
211
- // 'myFloat': '1.1',
212
- // 'myString': 'hi!'
213
- // }
214
- //
215
- // Note that while 'intValue' will have a quoted payload, 'doubleValue' and 'floatValue' will not. This
216
- // is due to the encoding library, which renders int64 values as strings to avoid loss of precision. This
217
- // method always returns a string, similarly to avoid loss of precision, unlike the less-conservative
218
- // 'unwrapValue' method just below.
219
170
  /** @hidden */
220
171
  function unwrapValueAsString(wrapped) {
221
- if (!wrapped || typeof wrapped !== "object") {
222
- return "";
223
- }
224
- const keys = Object.keys(wrapped);
225
- if (keys.length === 0) {
226
- return "";
227
- }
228
- const key = keys[0];
229
- const value = wrapped[key];
230
- if (value === null || value === undefined) {
231
- return "";
232
- }
233
- return value.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();
234
185
  }
235
- // Ditto as the method above, but returning the values in the idiomatic JavaScript type (string for strings,
236
- // number for numbers):
237
- // {
238
- // 'myInt': 123,
239
- // 'myDouble': 1.0,
240
- // 'myFloat': 1.1,
241
- // 'myString': 'hi!'
242
- // }
243
- //
244
- // The field names in the incoming xValue fields identify the type a value has, which for JavaScript's
245
- // purposes can be divided into 'number' versus 'string'. This method will render all the numbers as
246
- // JavaScript's 'number' type, since we prefer using idiomatic types. Note that this may lead to loss
247
- // in precision for int64 fields, so use with care.
248
186
  /** @hidden */
249
- const xValueNumberFields = ["intValue", "floatValue", "doubleValue"];
187
+ const xValueNumberFields = [
188
+ "intValue",
189
+ "floatValue",
190
+ "doubleValue"
191
+ ];
250
192
  /** @hidden */
251
193
  function unwrapValue(wrapped) {
252
- const key = Object.keys(wrapped)[0];
253
- const value = unwrapValueAsString(wrapped);
254
- 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;
255
197
  }
256
- // The JSON payload delivers timestamp fields as strings of timestamps denoted in microseconds.
257
- // The JavaScript convention is to use numbers denoted in milliseconds. This method
258
- // makes it easy to convert a field of one type into the other.
259
198
  /** @hidden */
260
199
  function copyTimestampToMillis(from, to, fromName, toName) {
261
- if (from[fromName] !== undefined) {
262
- to[toName] = Math.round(from[fromName] / 1000);
263
- }
200
+ if (from[fromName] !== undefined) {
201
+ to[toName] = Math.round(from[fromName] / 1e3);
202
+ }
264
203
  }
265
- // The JSON payload delivers timestamp fields as strings of timestamps denoted in microseconds.
266
- // In our SDK, we'd like to present timestamp as ISO-format strings. This method makes it easy
267
- // to convert a field of one type into the other.
268
204
  /** @hidden */
269
205
  function copyTimestampToString(from, to, fromName, toName) {
270
- if (from[fromName] !== undefined) {
271
- to[toName] = new Date(from[fromName] / 1000).toISOString();
272
- }
206
+ if (from[fromName] !== undefined) {
207
+ to[toName] = new Date(from[fromName] / 1e3).toISOString();
208
+ }
273
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.