@firebase/firestore-compat 0.3.39 → 0.3.40

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 (81) hide show
  1. package/dist/index.cjs.js +978 -978
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm2017.js +978 -978
  4. package/dist/index.esm2017.js.map +1 -1
  5. package/dist/index.node.cjs.js +978 -978
  6. package/dist/index.node.cjs.js.map +1 -1
  7. package/dist/index.rn.js +978 -978
  8. package/dist/index.rn.js.map +1 -1
  9. package/dist/node-esm/index.node.esm.js +978 -978
  10. package/dist/node-esm/index.node.esm.js.map +1 -1
  11. package/dist/node-esm/src/api/blob.d.ts +29 -29
  12. package/dist/node-esm/src/api/database.d.ts +228 -228
  13. package/dist/node-esm/src/api/field_path.d.ts +36 -36
  14. package/dist/node-esm/src/api/field_value.d.ts +29 -29
  15. package/dist/node-esm/src/api/geo_point.d.ts +17 -17
  16. package/dist/node-esm/src/api/observer.d.ts +29 -29
  17. package/dist/node-esm/src/api/timestamp.d.ts +17 -17
  18. package/dist/node-esm/src/config.d.ts +28 -28
  19. package/dist/node-esm/src/index.console.d.ts +48 -48
  20. package/dist/node-esm/src/index.d.ts +49 -49
  21. package/dist/node-esm/src/index.node.d.ts +22 -22
  22. package/dist/node-esm/src/index.rn.d.ts +22 -22
  23. package/dist/node-esm/src/register-module.d.ts +42 -42
  24. package/dist/node-esm/src/util/input_validation.d.ts +18 -18
  25. package/dist/node-esm/test/array_transforms.test.d.ts +17 -17
  26. package/dist/node-esm/test/batch_writes.test.d.ts +17 -17
  27. package/dist/node-esm/test/bootstrap.d.ts +17 -17
  28. package/dist/node-esm/test/bundle.test.d.ts +17 -17
  29. package/dist/node-esm/test/cursor.test.d.ts +17 -17
  30. package/dist/node-esm/test/database.test.d.ts +17 -17
  31. package/dist/node-esm/test/fields.test.d.ts +17 -17
  32. package/dist/node-esm/test/get_options.test.d.ts +17 -17
  33. package/dist/node-esm/test/numeric_transforms.test.d.ts +17 -17
  34. package/dist/node-esm/test/query.test.d.ts +17 -17
  35. package/dist/node-esm/test/server_timestamp.test.d.ts +17 -17
  36. package/dist/node-esm/test/smoke.test.d.ts +17 -17
  37. package/dist/node-esm/test/transactions.test.d.ts +17 -17
  38. package/dist/node-esm/test/type.test.d.ts +17 -17
  39. package/dist/node-esm/test/util/equality_matcher.d.ts +33 -33
  40. package/dist/node-esm/test/util/events_accumulator.d.ts +39 -39
  41. package/dist/node-esm/test/util/firebase_export.d.ts +29 -29
  42. package/dist/node-esm/test/util/helpers.d.ts +49 -49
  43. package/dist/node-esm/test/util/promise.d.ts +28 -28
  44. package/dist/node-esm/test/util/settings.d.ts +23 -23
  45. package/dist/node-esm/test/validation.test.d.ts +17 -17
  46. package/dist/src/api/blob.d.ts +29 -29
  47. package/dist/src/api/database.d.ts +228 -228
  48. package/dist/src/api/field_path.d.ts +36 -36
  49. package/dist/src/api/field_value.d.ts +29 -29
  50. package/dist/src/api/geo_point.d.ts +17 -17
  51. package/dist/src/api/observer.d.ts +29 -29
  52. package/dist/src/api/timestamp.d.ts +17 -17
  53. package/dist/src/config.d.ts +28 -28
  54. package/dist/src/index.console.d.ts +48 -48
  55. package/dist/src/index.d.ts +49 -49
  56. package/dist/src/index.node.d.ts +22 -22
  57. package/dist/src/index.rn.d.ts +22 -22
  58. package/dist/src/register-module.d.ts +42 -42
  59. package/dist/src/util/input_validation.d.ts +18 -18
  60. package/dist/test/array_transforms.test.d.ts +17 -17
  61. package/dist/test/batch_writes.test.d.ts +17 -17
  62. package/dist/test/bootstrap.d.ts +17 -17
  63. package/dist/test/bundle.test.d.ts +17 -17
  64. package/dist/test/cursor.test.d.ts +17 -17
  65. package/dist/test/database.test.d.ts +17 -17
  66. package/dist/test/fields.test.d.ts +17 -17
  67. package/dist/test/get_options.test.d.ts +17 -17
  68. package/dist/test/numeric_transforms.test.d.ts +17 -17
  69. package/dist/test/query.test.d.ts +17 -17
  70. package/dist/test/server_timestamp.test.d.ts +17 -17
  71. package/dist/test/smoke.test.d.ts +17 -17
  72. package/dist/test/transactions.test.d.ts +17 -17
  73. package/dist/test/type.test.d.ts +17 -17
  74. package/dist/test/util/equality_matcher.d.ts +33 -33
  75. package/dist/test/util/events_accumulator.d.ts +39 -39
  76. package/dist/test/util/firebase_export.d.ts +29 -29
  77. package/dist/test/util/helpers.d.ts +49 -49
  78. package/dist/test/util/promise.d.ts +28 -28
  79. package/dist/test/util/settings.d.ts +23 -23
  80. package/dist/test/validation.test.d.ts +17 -17
  81. package/package.json +8 -8
package/dist/index.cjs.js CHANGED
@@ -12,999 +12,999 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
12
12
  var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
13
13
 
14
14
  const name = "@firebase/firestore-compat";
15
- const version = "0.3.39";
15
+ const version = "0.3.40";
16
16
 
17
- /**
18
- * @license
19
- * Copyright 2021 Google LLC
20
- *
21
- * Licensed under the Apache License, Version 2.0 (the "License");
22
- * you may not use this file except in compliance with the License.
23
- * You may obtain a copy of the License at
24
- *
25
- * http://www.apache.org/licenses/LICENSE-2.0
26
- *
27
- * Unless required by applicable law or agreed to in writing, software
28
- * distributed under the License is distributed on an "AS IS" BASIS,
29
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
- * See the License for the specific language governing permissions and
31
- * limitations under the License.
32
- */
33
- function validateSetOptions(methodName, options) {
34
- if (options === undefined) {
35
- return {
36
- merge: false
37
- };
38
- }
39
- if (options.mergeFields !== undefined && options.merge !== undefined) {
40
- throw new firestore.FirestoreError('invalid-argument', `Invalid options passed to function ${methodName}(): You cannot ` +
41
- 'specify both "merge" and "mergeFields".');
42
- }
43
- return options;
17
+ /**
18
+ * @license
19
+ * Copyright 2021 Google LLC
20
+ *
21
+ * Licensed under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License.
23
+ * You may obtain a copy of the License at
24
+ *
25
+ * http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software
28
+ * distributed under the License is distributed on an "AS IS" BASIS,
29
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
+ * See the License for the specific language governing permissions and
31
+ * limitations under the License.
32
+ */
33
+ function validateSetOptions(methodName, options) {
34
+ if (options === undefined) {
35
+ return {
36
+ merge: false
37
+ };
38
+ }
39
+ if (options.mergeFields !== undefined && options.merge !== undefined) {
40
+ throw new firestore.FirestoreError('invalid-argument', `Invalid options passed to function ${methodName}(): You cannot ` +
41
+ 'specify both "merge" and "mergeFields".');
42
+ }
43
+ return options;
44
44
  }
45
45
 
46
- /**
47
- * @license
48
- * Copyright 2017 Google LLC
49
- *
50
- * Licensed under the Apache License, Version 2.0 (the "License");
51
- * you may not use this file except in compliance with the License.
52
- * You may obtain a copy of the License at
53
- *
54
- * http://www.apache.org/licenses/LICENSE-2.0
55
- *
56
- * Unless required by applicable law or agreed to in writing, software
57
- * distributed under the License is distributed on an "AS IS" BASIS,
58
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
59
- * See the License for the specific language governing permissions and
60
- * limitations under the License.
61
- */
62
- /** Helper function to assert Uint8Array is available at runtime. */
63
- function assertUint8ArrayAvailable() {
64
- if (typeof Uint8Array === 'undefined') {
65
- throw new firestore.FirestoreError('unimplemented', 'Uint8Arrays are not available in this environment.');
66
- }
67
- }
68
- /** Helper function to assert Base64 functions are available at runtime. */
69
- function assertBase64Available() {
70
- if (!firestore._isBase64Available()) {
71
- throw new firestore.FirestoreError('unimplemented', 'Blobs are unavailable in Firestore in this environment.');
72
- }
73
- }
74
- /** Immutable class holding a blob (binary data) */
75
- class Blob {
76
- constructor(_delegate) {
77
- this._delegate = _delegate;
78
- }
79
- static fromBase64String(base64) {
80
- assertBase64Available();
81
- return new Blob(firestore.Bytes.fromBase64String(base64));
82
- }
83
- static fromUint8Array(array) {
84
- assertUint8ArrayAvailable();
85
- return new Blob(firestore.Bytes.fromUint8Array(array));
86
- }
87
- toBase64() {
88
- assertBase64Available();
89
- return this._delegate.toBase64();
90
- }
91
- toUint8Array() {
92
- assertUint8ArrayAvailable();
93
- return this._delegate.toUint8Array();
94
- }
95
- isEqual(other) {
96
- return this._delegate.isEqual(other._delegate);
97
- }
98
- toString() {
99
- return 'Blob(base64: ' + this.toBase64() + ')';
100
- }
46
+ /**
47
+ * @license
48
+ * Copyright 2017 Google LLC
49
+ *
50
+ * Licensed under the Apache License, Version 2.0 (the "License");
51
+ * you may not use this file except in compliance with the License.
52
+ * You may obtain a copy of the License at
53
+ *
54
+ * http://www.apache.org/licenses/LICENSE-2.0
55
+ *
56
+ * Unless required by applicable law or agreed to in writing, software
57
+ * distributed under the License is distributed on an "AS IS" BASIS,
58
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
59
+ * See the License for the specific language governing permissions and
60
+ * limitations under the License.
61
+ */
62
+ /** Helper function to assert Uint8Array is available at runtime. */
63
+ function assertUint8ArrayAvailable() {
64
+ if (typeof Uint8Array === 'undefined') {
65
+ throw new firestore.FirestoreError('unimplemented', 'Uint8Arrays are not available in this environment.');
66
+ }
67
+ }
68
+ /** Helper function to assert Base64 functions are available at runtime. */
69
+ function assertBase64Available() {
70
+ if (!firestore._isBase64Available()) {
71
+ throw new firestore.FirestoreError('unimplemented', 'Blobs are unavailable in Firestore in this environment.');
72
+ }
73
+ }
74
+ /** Immutable class holding a blob (binary data) */
75
+ class Blob {
76
+ constructor(_delegate) {
77
+ this._delegate = _delegate;
78
+ }
79
+ static fromBase64String(base64) {
80
+ assertBase64Available();
81
+ return new Blob(firestore.Bytes.fromBase64String(base64));
82
+ }
83
+ static fromUint8Array(array) {
84
+ assertUint8ArrayAvailable();
85
+ return new Blob(firestore.Bytes.fromUint8Array(array));
86
+ }
87
+ toBase64() {
88
+ assertBase64Available();
89
+ return this._delegate.toBase64();
90
+ }
91
+ toUint8Array() {
92
+ assertUint8ArrayAvailable();
93
+ return this._delegate.toUint8Array();
94
+ }
95
+ isEqual(other) {
96
+ return this._delegate.isEqual(other._delegate);
97
+ }
98
+ toString() {
99
+ return 'Blob(base64: ' + this.toBase64() + ')';
100
+ }
101
101
  }
102
102
 
103
- /**
104
- * @license
105
- * Copyright 2017 Google LLC
106
- *
107
- * Licensed under the Apache License, Version 2.0 (the "License");
108
- * you may not use this file except in compliance with the License.
109
- * You may obtain a copy of the License at
110
- *
111
- * http://www.apache.org/licenses/LICENSE-2.0
112
- *
113
- * Unless required by applicable law or agreed to in writing, software
114
- * distributed under the License is distributed on an "AS IS" BASIS,
115
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116
- * See the License for the specific language governing permissions and
117
- * limitations under the License.
118
- */
119
- function isPartialObserver(obj) {
120
- return implementsAnyMethods(obj, ['next', 'error', 'complete']);
121
- }
122
- /**
123
- * Returns true if obj is an object and contains at least one of the specified
124
- * methods.
125
- */
126
- function implementsAnyMethods(obj, methods) {
127
- if (typeof obj !== 'object' || obj === null) {
128
- return false;
129
- }
130
- const object = obj;
131
- for (const method of methods) {
132
- if (method in object && typeof object[method] === 'function') {
133
- return true;
134
- }
135
- }
136
- return false;
103
+ /**
104
+ * @license
105
+ * Copyright 2017 Google LLC
106
+ *
107
+ * Licensed under the Apache License, Version 2.0 (the "License");
108
+ * you may not use this file except in compliance with the License.
109
+ * You may obtain a copy of the License at
110
+ *
111
+ * http://www.apache.org/licenses/LICENSE-2.0
112
+ *
113
+ * Unless required by applicable law or agreed to in writing, software
114
+ * distributed under the License is distributed on an "AS IS" BASIS,
115
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116
+ * See the License for the specific language governing permissions and
117
+ * limitations under the License.
118
+ */
119
+ function isPartialObserver(obj) {
120
+ return implementsAnyMethods(obj, ['next', 'error', 'complete']);
121
+ }
122
+ /**
123
+ * Returns true if obj is an object and contains at least one of the specified
124
+ * methods.
125
+ */
126
+ function implementsAnyMethods(obj, methods) {
127
+ if (typeof obj !== 'object' || obj === null) {
128
+ return false;
129
+ }
130
+ const object = obj;
131
+ for (const method of methods) {
132
+ if (method in object && typeof object[method] === 'function') {
133
+ return true;
134
+ }
135
+ }
136
+ return false;
137
137
  }
138
138
 
139
- /**
140
- * @license
141
- * Copyright 2017 Google LLC
142
- *
143
- * Licensed under the Apache License, Version 2.0 (the "License");
144
- * you may not use this file except in compliance with the License.
145
- * You may obtain a copy of the License at
146
- *
147
- * http://www.apache.org/licenses/LICENSE-2.0
148
- *
149
- * Unless required by applicable law or agreed to in writing, software
150
- * distributed under the License is distributed on an "AS IS" BASIS,
151
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
152
- * See the License for the specific language governing permissions and
153
- * limitations under the License.
154
- */
155
- /**
156
- * The persistence provider included with the full Firestore SDK.
157
- */
158
- class IndexedDbPersistenceProvider {
159
- enableIndexedDbPersistence(firestore$1, forceOwnership) {
160
- return firestore.enableIndexedDbPersistence(firestore$1._delegate, { forceOwnership });
161
- }
162
- enableMultiTabIndexedDbPersistence(firestore$1) {
163
- return firestore.enableMultiTabIndexedDbPersistence(firestore$1._delegate);
164
- }
165
- clearIndexedDbPersistence(firestore$1) {
166
- return firestore.clearIndexedDbPersistence(firestore$1._delegate);
167
- }
168
- }
169
- /**
170
- * Compat class for Firestore. Exposes Firestore Legacy API, but delegates
171
- * to the functional API of firestore-exp.
172
- */
173
- class Firestore {
174
- constructor(databaseIdOrApp, _delegate, _persistenceProvider) {
175
- this._delegate = _delegate;
176
- this._persistenceProvider = _persistenceProvider;
177
- this.INTERNAL = {
178
- delete: () => this.terminate()
179
- };
180
- if (!(databaseIdOrApp instanceof firestore._DatabaseId)) {
181
- this._appCompat = databaseIdOrApp;
182
- }
183
- }
184
- get _databaseId() {
185
- return this._delegate._databaseId;
186
- }
187
- settings(settingsLiteral) {
188
- const currentSettings = this._delegate._getSettings();
189
- if (!settingsLiteral.merge &&
190
- currentSettings.host !== settingsLiteral.host) {
191
- firestore._logWarn('You are overriding the original host. If you did not intend ' +
192
- 'to override your settings, use {merge: true}.');
193
- }
194
- if (settingsLiteral.merge) {
195
- settingsLiteral = Object.assign(Object.assign({}, currentSettings), settingsLiteral);
196
- // Remove the property from the settings once the merge is completed
197
- delete settingsLiteral.merge;
198
- }
199
- this._delegate._setSettings(settingsLiteral);
200
- }
201
- useEmulator(host, port, options = {}) {
202
- firestore.connectFirestoreEmulator(this._delegate, host, port, options);
203
- }
204
- enableNetwork() {
205
- return firestore.enableNetwork(this._delegate);
206
- }
207
- disableNetwork() {
208
- return firestore.disableNetwork(this._delegate);
209
- }
210
- enablePersistence(settings) {
211
- let synchronizeTabs = false;
212
- let experimentalForceOwningTab = false;
213
- if (settings) {
214
- synchronizeTabs = !!settings.synchronizeTabs;
215
- experimentalForceOwningTab = !!settings.experimentalForceOwningTab;
216
- firestore._validateIsNotUsedTogether('synchronizeTabs', synchronizeTabs, 'experimentalForceOwningTab', experimentalForceOwningTab);
217
- }
218
- return synchronizeTabs
219
- ? this._persistenceProvider.enableMultiTabIndexedDbPersistence(this)
220
- : this._persistenceProvider.enableIndexedDbPersistence(this, experimentalForceOwningTab);
221
- }
222
- clearPersistence() {
223
- return this._persistenceProvider.clearIndexedDbPersistence(this);
224
- }
225
- terminate() {
226
- if (this._appCompat) {
227
- this._appCompat._removeServiceInstance('firestore-compat');
228
- this._appCompat._removeServiceInstance('firestore');
229
- }
230
- return this._delegate._delete();
231
- }
232
- waitForPendingWrites() {
233
- return firestore.waitForPendingWrites(this._delegate);
234
- }
235
- onSnapshotsInSync(arg) {
236
- return firestore.onSnapshotsInSync(this._delegate, arg);
237
- }
238
- get app() {
239
- if (!this._appCompat) {
240
- throw new firestore.FirestoreError('failed-precondition', "Firestore was not initialized using the Firebase SDK. 'app' is " +
241
- 'not available');
242
- }
243
- return this._appCompat;
244
- }
245
- collection(pathString) {
246
- try {
247
- return new CollectionReference(this, firestore.collection(this._delegate, pathString));
248
- }
249
- catch (e) {
250
- throw replaceFunctionName(e, 'collection()', 'Firestore.collection()');
251
- }
252
- }
253
- doc(pathString) {
254
- try {
255
- return new DocumentReference(this, firestore.doc(this._delegate, pathString));
256
- }
257
- catch (e) {
258
- throw replaceFunctionName(e, 'doc()', 'Firestore.doc()');
259
- }
260
- }
261
- collectionGroup(collectionId) {
262
- try {
263
- return new Query(this, firestore.collectionGroup(this._delegate, collectionId));
264
- }
265
- catch (e) {
266
- throw replaceFunctionName(e, 'collectionGroup()', 'Firestore.collectionGroup()');
267
- }
268
- }
269
- runTransaction(updateFunction) {
270
- return firestore.runTransaction(this._delegate, transaction => updateFunction(new Transaction(this, transaction)));
271
- }
272
- batch() {
273
- firestore.ensureFirestoreConfigured(this._delegate);
274
- return new WriteBatch(new firestore.WriteBatch(this._delegate, mutations => firestore.executeWrite(this._delegate, mutations)));
275
- }
276
- loadBundle(bundleData) {
277
- return firestore.loadBundle(this._delegate, bundleData);
278
- }
279
- namedQuery(name) {
280
- return firestore.namedQuery(this._delegate, name).then(expQuery => {
281
- if (!expQuery) {
282
- return null;
283
- }
284
- return new Query(this,
285
- // We can pass `expQuery` here directly since named queries don't have a UserDataConverter.
286
- // Otherwise, we would have to create a new ExpQuery and pass the old UserDataConverter.
287
- expQuery);
288
- });
289
- }
290
- }
291
- class UserDataWriter extends firestore.AbstractUserDataWriter {
292
- constructor(firestore) {
293
- super();
294
- this.firestore = firestore;
295
- }
296
- convertBytes(bytes) {
297
- return new Blob(new firestore.Bytes(bytes));
298
- }
299
- convertReference(name) {
300
- const key = this.convertDocumentKey(name, this.firestore._databaseId);
301
- return DocumentReference.forKey(key, this.firestore, /* converter= */ null);
302
- }
303
- }
304
- function setLogLevel(level) {
305
- firestore.setLogLevel(level);
306
- }
307
- /**
308
- * A reference to a transaction.
309
- */
310
- class Transaction {
311
- constructor(_firestore, _delegate) {
312
- this._firestore = _firestore;
313
- this._delegate = _delegate;
314
- this._userDataWriter = new UserDataWriter(_firestore);
315
- }
316
- get(documentRef) {
317
- const ref = castReference(documentRef);
318
- return this._delegate
319
- .get(ref)
320
- .then(result => new DocumentSnapshot(this._firestore, new firestore.DocumentSnapshot(this._firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, ref.converter)));
321
- }
322
- set(documentRef, data, options) {
323
- const ref = castReference(documentRef);
324
- if (options) {
325
- validateSetOptions('Transaction.set', options);
326
- this._delegate.set(ref, data, options);
327
- }
328
- else {
329
- this._delegate.set(ref, data);
330
- }
331
- return this;
332
- }
333
- update(documentRef, dataOrField, value, ...moreFieldsAndValues) {
334
- const ref = castReference(documentRef);
335
- if (arguments.length === 2) {
336
- this._delegate.update(ref, dataOrField);
337
- }
338
- else {
339
- this._delegate.update(ref, dataOrField, value, ...moreFieldsAndValues);
340
- }
341
- return this;
342
- }
343
- delete(documentRef) {
344
- const ref = castReference(documentRef);
345
- this._delegate.delete(ref);
346
- return this;
347
- }
348
- }
349
- class WriteBatch {
350
- constructor(_delegate) {
351
- this._delegate = _delegate;
352
- }
353
- set(documentRef, data, options) {
354
- const ref = castReference(documentRef);
355
- if (options) {
356
- validateSetOptions('WriteBatch.set', options);
357
- this._delegate.set(ref, data, options);
358
- }
359
- else {
360
- this._delegate.set(ref, data);
361
- }
362
- return this;
363
- }
364
- update(documentRef, dataOrField, value, ...moreFieldsAndValues) {
365
- const ref = castReference(documentRef);
366
- if (arguments.length === 2) {
367
- this._delegate.update(ref, dataOrField);
368
- }
369
- else {
370
- this._delegate.update(ref, dataOrField, value, ...moreFieldsAndValues);
371
- }
372
- return this;
373
- }
374
- delete(documentRef) {
375
- const ref = castReference(documentRef);
376
- this._delegate.delete(ref);
377
- return this;
378
- }
379
- commit() {
380
- return this._delegate.commit();
381
- }
382
- }
383
- /**
384
- * Wraps a `PublicFirestoreDataConverter` translating the types from the
385
- * experimental SDK into corresponding types from the Classic SDK before passing
386
- * them to the wrapped converter.
387
- */
388
- class FirestoreDataConverter {
389
- constructor(_firestore, _userDataWriter, _delegate) {
390
- this._firestore = _firestore;
391
- this._userDataWriter = _userDataWriter;
392
- this._delegate = _delegate;
393
- }
394
- fromFirestore(snapshot, options) {
395
- const expSnapshot = new firestore.QueryDocumentSnapshot(this._firestore._delegate, this._userDataWriter, snapshot._key, snapshot._document, snapshot.metadata,
396
- /* converter= */ null);
397
- return this._delegate.fromFirestore(new QueryDocumentSnapshot(this._firestore, expSnapshot), options !== null && options !== void 0 ? options : {});
398
- }
399
- toFirestore(modelObject, options) {
400
- if (!options) {
401
- return this._delegate.toFirestore(modelObject);
402
- }
403
- else {
404
- return this._delegate.toFirestore(modelObject, options);
405
- }
406
- }
407
- // Use the same instance of `FirestoreDataConverter` for the given instances
408
- // of `Firestore` and `PublicFirestoreDataConverter` so that isEqual() will
409
- // compare equal for two objects created with the same converter instance.
410
- static getInstance(firestore, converter) {
411
- const converterMapByFirestore = FirestoreDataConverter.INSTANCES;
412
- let untypedConverterByConverter = converterMapByFirestore.get(firestore);
413
- if (!untypedConverterByConverter) {
414
- untypedConverterByConverter = new WeakMap();
415
- converterMapByFirestore.set(firestore, untypedConverterByConverter);
416
- }
417
- let instance = untypedConverterByConverter.get(converter);
418
- if (!instance) {
419
- instance = new FirestoreDataConverter(firestore, new UserDataWriter(firestore), converter);
420
- untypedConverterByConverter.set(converter, instance);
421
- }
422
- return instance;
423
- }
424
- }
425
- FirestoreDataConverter.INSTANCES = new WeakMap();
426
- /**
427
- * A reference to a particular document in a collection in the database.
428
- */
429
- class DocumentReference {
430
- constructor(firestore, _delegate) {
431
- this.firestore = firestore;
432
- this._delegate = _delegate;
433
- this._userDataWriter = new UserDataWriter(firestore);
434
- }
435
- static forPath(path, firestore$1, converter) {
436
- if (path.length % 2 !== 0) {
437
- throw new firestore.FirestoreError('invalid-argument', 'Invalid document reference. Document ' +
438
- 'references must have an even number of segments, but ' +
439
- `${path.canonicalString()} has ${path.length}`);
440
- }
441
- return new DocumentReference(firestore$1, new firestore.DocumentReference(firestore$1._delegate, converter, new firestore._DocumentKey(path)));
442
- }
443
- static forKey(key, firestore$1, converter) {
444
- return new DocumentReference(firestore$1, new firestore.DocumentReference(firestore$1._delegate, converter, key));
445
- }
446
- get id() {
447
- return this._delegate.id;
448
- }
449
- get parent() {
450
- return new CollectionReference(this.firestore, this._delegate.parent);
451
- }
452
- get path() {
453
- return this._delegate.path;
454
- }
455
- collection(pathString) {
456
- try {
457
- return new CollectionReference(this.firestore, firestore.collection(this._delegate, pathString));
458
- }
459
- catch (e) {
460
- throw replaceFunctionName(e, 'collection()', 'DocumentReference.collection()');
461
- }
462
- }
463
- isEqual(other) {
464
- other = util.getModularInstance(other);
465
- if (!(other instanceof firestore.DocumentReference)) {
466
- return false;
467
- }
468
- return firestore.refEqual(this._delegate, other);
469
- }
470
- set(value, options) {
471
- options = validateSetOptions('DocumentReference.set', options);
472
- try {
473
- if (options) {
474
- return firestore.setDoc(this._delegate, value, options);
475
- }
476
- else {
477
- return firestore.setDoc(this._delegate, value);
478
- }
479
- }
480
- catch (e) {
481
- throw replaceFunctionName(e, 'setDoc()', 'DocumentReference.set()');
482
- }
483
- }
484
- update(fieldOrUpdateData, value, ...moreFieldsAndValues) {
485
- try {
486
- if (arguments.length === 1) {
487
- return firestore.updateDoc(this._delegate, fieldOrUpdateData);
488
- }
489
- else {
490
- return firestore.updateDoc(this._delegate, fieldOrUpdateData, value, ...moreFieldsAndValues);
491
- }
492
- }
493
- catch (e) {
494
- throw replaceFunctionName(e, 'updateDoc()', 'DocumentReference.update()');
495
- }
496
- }
497
- delete() {
498
- return firestore.deleteDoc(this._delegate);
499
- }
500
- onSnapshot(...args) {
501
- const options = extractSnapshotOptions(args);
502
- const observer = wrapObserver(args, result => new DocumentSnapshot(this.firestore, new firestore.DocumentSnapshot(this.firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, this._delegate.converter)));
503
- return firestore.onSnapshot(this._delegate, options, observer);
504
- }
505
- get(options) {
506
- let snap;
507
- if ((options === null || options === void 0 ? void 0 : options.source) === 'cache') {
508
- snap = firestore.getDocFromCache(this._delegate);
509
- }
510
- else if ((options === null || options === void 0 ? void 0 : options.source) === 'server') {
511
- snap = firestore.getDocFromServer(this._delegate);
512
- }
513
- else {
514
- snap = firestore.getDoc(this._delegate);
515
- }
516
- return snap.then(result => new DocumentSnapshot(this.firestore, new firestore.DocumentSnapshot(this.firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, this._delegate.converter)));
517
- }
518
- withConverter(converter) {
519
- return new DocumentReference(this.firestore, converter
520
- ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
521
- : this._delegate.withConverter(null));
522
- }
523
- }
524
- /**
525
- * Replaces the function name in an error thrown by the firestore-exp API
526
- * with the function names used in the classic API.
527
- */
528
- function replaceFunctionName(e, original, updated) {
529
- e.message = e.message.replace(original, updated);
530
- return e;
531
- }
532
- /**
533
- * Iterates the list of arguments from an `onSnapshot` call and returns the
534
- * first argument that may be an `SnapshotListenOptions` object. Returns an
535
- * empty object if none is found.
536
- */
537
- function extractSnapshotOptions(args) {
538
- for (const arg of args) {
539
- if (typeof arg === 'object' && !isPartialObserver(arg)) {
540
- return arg;
541
- }
542
- }
543
- return {};
544
- }
545
- /**
546
- * Creates an observer that can be passed to the firestore-exp SDK. The
547
- * observer converts all observed values into the format expected by the classic
548
- * SDK.
549
- *
550
- * @param args - The list of arguments from an `onSnapshot` call.
551
- * @param wrapper - The function that converts the firestore-exp type into the
552
- * type used by this shim.
553
- */
554
- function wrapObserver(args, wrapper) {
555
- var _a, _b;
556
- let userObserver;
557
- if (isPartialObserver(args[0])) {
558
- userObserver = args[0];
559
- }
560
- else if (isPartialObserver(args[1])) {
561
- userObserver = args[1];
562
- }
563
- else if (typeof args[0] === 'function') {
564
- userObserver = {
565
- next: args[0],
566
- error: args[1],
567
- complete: args[2]
568
- };
569
- }
570
- else {
571
- userObserver = {
572
- next: args[1],
573
- error: args[2],
574
- complete: args[3]
575
- };
576
- }
577
- return {
578
- next: val => {
579
- if (userObserver.next) {
580
- userObserver.next(wrapper(val));
581
- }
582
- },
583
- error: (_a = userObserver.error) === null || _a === void 0 ? void 0 : _a.bind(userObserver),
584
- complete: (_b = userObserver.complete) === null || _b === void 0 ? void 0 : _b.bind(userObserver)
585
- };
586
- }
587
- class DocumentSnapshot {
588
- constructor(_firestore, _delegate) {
589
- this._firestore = _firestore;
590
- this._delegate = _delegate;
591
- }
592
- get ref() {
593
- return new DocumentReference(this._firestore, this._delegate.ref);
594
- }
595
- get id() {
596
- return this._delegate.id;
597
- }
598
- get metadata() {
599
- return this._delegate.metadata;
600
- }
601
- get exists() {
602
- return this._delegate.exists();
603
- }
604
- data(options) {
605
- return this._delegate.data(options);
606
- }
607
- get(fieldPath, options
608
- // We are using `any` here to avoid an explicit cast by our users.
609
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
610
- ) {
611
- return this._delegate.get(fieldPath, options);
612
- }
613
- isEqual(other) {
614
- return firestore.snapshotEqual(this._delegate, other._delegate);
615
- }
616
- }
617
- class QueryDocumentSnapshot extends DocumentSnapshot {
618
- data(options) {
619
- const data = this._delegate.data(options);
620
- if (this._delegate._converter) {
621
- // Undefined is a possible valid value from converter.
622
- return data;
623
- }
624
- else {
625
- firestore._debugAssert(data !== undefined, 'Document in a QueryDocumentSnapshot should exist');
626
- return data;
627
- }
628
- }
629
- }
630
- class Query {
631
- constructor(firestore, _delegate) {
632
- this.firestore = firestore;
633
- this._delegate = _delegate;
634
- this._userDataWriter = new UserDataWriter(firestore);
635
- }
636
- where(fieldPath, opStr, value) {
637
- try {
638
- // The "as string" cast is a little bit of a hack. `where` accepts the
639
- // FieldPath Compat type as input, but is not typed as such in order to
640
- // not expose this via our public typings file.
641
- return new Query(this.firestore, firestore.query(this._delegate, firestore.where(fieldPath, opStr, value)));
642
- }
643
- catch (e) {
644
- throw replaceFunctionName(e, /(orderBy|where)\(\)/, 'Query.$1()');
645
- }
646
- }
647
- orderBy(fieldPath, directionStr) {
648
- try {
649
- // The "as string" cast is a little bit of a hack. `orderBy` accepts the
650
- // FieldPath Compat type as input, but is not typed as such in order to
651
- // not expose this via our public typings file.
652
- return new Query(this.firestore, firestore.query(this._delegate, firestore.orderBy(fieldPath, directionStr)));
653
- }
654
- catch (e) {
655
- throw replaceFunctionName(e, /(orderBy|where)\(\)/, 'Query.$1()');
656
- }
657
- }
658
- limit(n) {
659
- try {
660
- return new Query(this.firestore, firestore.query(this._delegate, firestore.limit(n)));
661
- }
662
- catch (e) {
663
- throw replaceFunctionName(e, 'limit()', 'Query.limit()');
664
- }
665
- }
666
- limitToLast(n) {
667
- try {
668
- return new Query(this.firestore, firestore.query(this._delegate, firestore.limitToLast(n)));
669
- }
670
- catch (e) {
671
- throw replaceFunctionName(e, 'limitToLast()', 'Query.limitToLast()');
672
- }
673
- }
674
- startAt(...args) {
675
- try {
676
- return new Query(this.firestore, firestore.query(this._delegate, firestore.startAt(...args)));
677
- }
678
- catch (e) {
679
- throw replaceFunctionName(e, 'startAt()', 'Query.startAt()');
680
- }
681
- }
682
- startAfter(...args) {
683
- try {
684
- return new Query(this.firestore, firestore.query(this._delegate, firestore.startAfter(...args)));
685
- }
686
- catch (e) {
687
- throw replaceFunctionName(e, 'startAfter()', 'Query.startAfter()');
688
- }
689
- }
690
- endBefore(...args) {
691
- try {
692
- return new Query(this.firestore, firestore.query(this._delegate, firestore.endBefore(...args)));
693
- }
694
- catch (e) {
695
- throw replaceFunctionName(e, 'endBefore()', 'Query.endBefore()');
696
- }
697
- }
698
- endAt(...args) {
699
- try {
700
- return new Query(this.firestore, firestore.query(this._delegate, firestore.endAt(...args)));
701
- }
702
- catch (e) {
703
- throw replaceFunctionName(e, 'endAt()', 'Query.endAt()');
704
- }
705
- }
706
- isEqual(other) {
707
- return firestore.queryEqual(this._delegate, other._delegate);
708
- }
709
- get(options) {
710
- let query;
711
- if ((options === null || options === void 0 ? void 0 : options.source) === 'cache') {
712
- query = firestore.getDocsFromCache(this._delegate);
713
- }
714
- else if ((options === null || options === void 0 ? void 0 : options.source) === 'server') {
715
- query = firestore.getDocsFromServer(this._delegate);
716
- }
717
- else {
718
- query = firestore.getDocs(this._delegate);
719
- }
720
- return query.then(result => new QuerySnapshot(this.firestore, new firestore.QuerySnapshot(this.firestore._delegate, this._userDataWriter, this._delegate, result._snapshot)));
721
- }
722
- onSnapshot(...args) {
723
- const options = extractSnapshotOptions(args);
724
- const observer = wrapObserver(args, snap => new QuerySnapshot(this.firestore, new firestore.QuerySnapshot(this.firestore._delegate, this._userDataWriter, this._delegate, snap._snapshot)));
725
- return firestore.onSnapshot(this._delegate, options, observer);
726
- }
727
- withConverter(converter) {
728
- return new Query(this.firestore, converter
729
- ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
730
- : this._delegate.withConverter(null));
731
- }
732
- }
733
- class DocumentChange {
734
- constructor(_firestore, _delegate) {
735
- this._firestore = _firestore;
736
- this._delegate = _delegate;
737
- }
738
- get type() {
739
- return this._delegate.type;
740
- }
741
- get doc() {
742
- return new QueryDocumentSnapshot(this._firestore, this._delegate.doc);
743
- }
744
- get oldIndex() {
745
- return this._delegate.oldIndex;
746
- }
747
- get newIndex() {
748
- return this._delegate.newIndex;
749
- }
750
- }
751
- class QuerySnapshot {
752
- constructor(_firestore, _delegate) {
753
- this._firestore = _firestore;
754
- this._delegate = _delegate;
755
- }
756
- get query() {
757
- return new Query(this._firestore, this._delegate.query);
758
- }
759
- get metadata() {
760
- return this._delegate.metadata;
761
- }
762
- get size() {
763
- return this._delegate.size;
764
- }
765
- get empty() {
766
- return this._delegate.empty;
767
- }
768
- get docs() {
769
- return this._delegate.docs.map(doc => new QueryDocumentSnapshot(this._firestore, doc));
770
- }
771
- docChanges(options) {
772
- return this._delegate
773
- .docChanges(options)
774
- .map(docChange => new DocumentChange(this._firestore, docChange));
775
- }
776
- forEach(callback, thisArg) {
777
- this._delegate.forEach(snapshot => {
778
- callback.call(thisArg, new QueryDocumentSnapshot(this._firestore, snapshot));
779
- });
780
- }
781
- isEqual(other) {
782
- return firestore.snapshotEqual(this._delegate, other._delegate);
783
- }
784
- }
785
- class CollectionReference extends Query {
786
- constructor(firestore, _delegate) {
787
- super(firestore, _delegate);
788
- this.firestore = firestore;
789
- this._delegate = _delegate;
790
- }
791
- get id() {
792
- return this._delegate.id;
793
- }
794
- get path() {
795
- return this._delegate.path;
796
- }
797
- get parent() {
798
- const docRef = this._delegate.parent;
799
- return docRef ? new DocumentReference(this.firestore, docRef) : null;
800
- }
801
- doc(documentPath) {
802
- try {
803
- if (documentPath === undefined) {
804
- // Call `doc` without `documentPath` if `documentPath` is `undefined`
805
- // as `doc` validates the number of arguments to prevent users from
806
- // accidentally passing `undefined`.
807
- return new DocumentReference(this.firestore, firestore.doc(this._delegate));
808
- }
809
- else {
810
- return new DocumentReference(this.firestore, firestore.doc(this._delegate, documentPath));
811
- }
812
- }
813
- catch (e) {
814
- throw replaceFunctionName(e, 'doc()', 'CollectionReference.doc()');
815
- }
816
- }
817
- add(data) {
818
- return firestore.addDoc(this._delegate, data).then(docRef => new DocumentReference(this.firestore, docRef));
819
- }
820
- isEqual(other) {
821
- return firestore.refEqual(this._delegate, other._delegate);
822
- }
823
- withConverter(converter) {
824
- return new CollectionReference(this.firestore, converter
825
- ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
826
- : this._delegate.withConverter(null));
827
- }
828
- }
829
- function castReference(documentRef) {
830
- return firestore._cast(documentRef, firestore.DocumentReference);
139
+ /**
140
+ * @license
141
+ * Copyright 2017 Google LLC
142
+ *
143
+ * Licensed under the Apache License, Version 2.0 (the "License");
144
+ * you may not use this file except in compliance with the License.
145
+ * You may obtain a copy of the License at
146
+ *
147
+ * http://www.apache.org/licenses/LICENSE-2.0
148
+ *
149
+ * Unless required by applicable law or agreed to in writing, software
150
+ * distributed under the License is distributed on an "AS IS" BASIS,
151
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
152
+ * See the License for the specific language governing permissions and
153
+ * limitations under the License.
154
+ */
155
+ /**
156
+ * The persistence provider included with the full Firestore SDK.
157
+ */
158
+ class IndexedDbPersistenceProvider {
159
+ enableIndexedDbPersistence(firestore$1, forceOwnership) {
160
+ return firestore.enableIndexedDbPersistence(firestore$1._delegate, { forceOwnership });
161
+ }
162
+ enableMultiTabIndexedDbPersistence(firestore$1) {
163
+ return firestore.enableMultiTabIndexedDbPersistence(firestore$1._delegate);
164
+ }
165
+ clearIndexedDbPersistence(firestore$1) {
166
+ return firestore.clearIndexedDbPersistence(firestore$1._delegate);
167
+ }
168
+ }
169
+ /**
170
+ * Compat class for Firestore. Exposes Firestore Legacy API, but delegates
171
+ * to the functional API of firestore-exp.
172
+ */
173
+ class Firestore {
174
+ constructor(databaseIdOrApp, _delegate, _persistenceProvider) {
175
+ this._delegate = _delegate;
176
+ this._persistenceProvider = _persistenceProvider;
177
+ this.INTERNAL = {
178
+ delete: () => this.terminate()
179
+ };
180
+ if (!(databaseIdOrApp instanceof firestore._DatabaseId)) {
181
+ this._appCompat = databaseIdOrApp;
182
+ }
183
+ }
184
+ get _databaseId() {
185
+ return this._delegate._databaseId;
186
+ }
187
+ settings(settingsLiteral) {
188
+ const currentSettings = this._delegate._getSettings();
189
+ if (!settingsLiteral.merge &&
190
+ currentSettings.host !== settingsLiteral.host) {
191
+ firestore._logWarn('You are overriding the original host. If you did not intend ' +
192
+ 'to override your settings, use {merge: true}.');
193
+ }
194
+ if (settingsLiteral.merge) {
195
+ settingsLiteral = Object.assign(Object.assign({}, currentSettings), settingsLiteral);
196
+ // Remove the property from the settings once the merge is completed
197
+ delete settingsLiteral.merge;
198
+ }
199
+ this._delegate._setSettings(settingsLiteral);
200
+ }
201
+ useEmulator(host, port, options = {}) {
202
+ firestore.connectFirestoreEmulator(this._delegate, host, port, options);
203
+ }
204
+ enableNetwork() {
205
+ return firestore.enableNetwork(this._delegate);
206
+ }
207
+ disableNetwork() {
208
+ return firestore.disableNetwork(this._delegate);
209
+ }
210
+ enablePersistence(settings) {
211
+ let synchronizeTabs = false;
212
+ let experimentalForceOwningTab = false;
213
+ if (settings) {
214
+ synchronizeTabs = !!settings.synchronizeTabs;
215
+ experimentalForceOwningTab = !!settings.experimentalForceOwningTab;
216
+ firestore._validateIsNotUsedTogether('synchronizeTabs', synchronizeTabs, 'experimentalForceOwningTab', experimentalForceOwningTab);
217
+ }
218
+ return synchronizeTabs
219
+ ? this._persistenceProvider.enableMultiTabIndexedDbPersistence(this)
220
+ : this._persistenceProvider.enableIndexedDbPersistence(this, experimentalForceOwningTab);
221
+ }
222
+ clearPersistence() {
223
+ return this._persistenceProvider.clearIndexedDbPersistence(this);
224
+ }
225
+ terminate() {
226
+ if (this._appCompat) {
227
+ this._appCompat._removeServiceInstance('firestore-compat');
228
+ this._appCompat._removeServiceInstance('firestore');
229
+ }
230
+ return this._delegate._delete();
231
+ }
232
+ waitForPendingWrites() {
233
+ return firestore.waitForPendingWrites(this._delegate);
234
+ }
235
+ onSnapshotsInSync(arg) {
236
+ return firestore.onSnapshotsInSync(this._delegate, arg);
237
+ }
238
+ get app() {
239
+ if (!this._appCompat) {
240
+ throw new firestore.FirestoreError('failed-precondition', "Firestore was not initialized using the Firebase SDK. 'app' is " +
241
+ 'not available');
242
+ }
243
+ return this._appCompat;
244
+ }
245
+ collection(pathString) {
246
+ try {
247
+ return new CollectionReference(this, firestore.collection(this._delegate, pathString));
248
+ }
249
+ catch (e) {
250
+ throw replaceFunctionName(e, 'collection()', 'Firestore.collection()');
251
+ }
252
+ }
253
+ doc(pathString) {
254
+ try {
255
+ return new DocumentReference(this, firestore.doc(this._delegate, pathString));
256
+ }
257
+ catch (e) {
258
+ throw replaceFunctionName(e, 'doc()', 'Firestore.doc()');
259
+ }
260
+ }
261
+ collectionGroup(collectionId) {
262
+ try {
263
+ return new Query(this, firestore.collectionGroup(this._delegate, collectionId));
264
+ }
265
+ catch (e) {
266
+ throw replaceFunctionName(e, 'collectionGroup()', 'Firestore.collectionGroup()');
267
+ }
268
+ }
269
+ runTransaction(updateFunction) {
270
+ return firestore.runTransaction(this._delegate, transaction => updateFunction(new Transaction(this, transaction)));
271
+ }
272
+ batch() {
273
+ firestore.ensureFirestoreConfigured(this._delegate);
274
+ return new WriteBatch(new firestore.WriteBatch(this._delegate, mutations => firestore.executeWrite(this._delegate, mutations)));
275
+ }
276
+ loadBundle(bundleData) {
277
+ return firestore.loadBundle(this._delegate, bundleData);
278
+ }
279
+ namedQuery(name) {
280
+ return firestore.namedQuery(this._delegate, name).then(expQuery => {
281
+ if (!expQuery) {
282
+ return null;
283
+ }
284
+ return new Query(this,
285
+ // We can pass `expQuery` here directly since named queries don't have a UserDataConverter.
286
+ // Otherwise, we would have to create a new ExpQuery and pass the old UserDataConverter.
287
+ expQuery);
288
+ });
289
+ }
290
+ }
291
+ class UserDataWriter extends firestore.AbstractUserDataWriter {
292
+ constructor(firestore) {
293
+ super();
294
+ this.firestore = firestore;
295
+ }
296
+ convertBytes(bytes) {
297
+ return new Blob(new firestore.Bytes(bytes));
298
+ }
299
+ convertReference(name) {
300
+ const key = this.convertDocumentKey(name, this.firestore._databaseId);
301
+ return DocumentReference.forKey(key, this.firestore, /* converter= */ null);
302
+ }
303
+ }
304
+ function setLogLevel(level) {
305
+ firestore.setLogLevel(level);
306
+ }
307
+ /**
308
+ * A reference to a transaction.
309
+ */
310
+ class Transaction {
311
+ constructor(_firestore, _delegate) {
312
+ this._firestore = _firestore;
313
+ this._delegate = _delegate;
314
+ this._userDataWriter = new UserDataWriter(_firestore);
315
+ }
316
+ get(documentRef) {
317
+ const ref = castReference(documentRef);
318
+ return this._delegate
319
+ .get(ref)
320
+ .then(result => new DocumentSnapshot(this._firestore, new firestore.DocumentSnapshot(this._firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, ref.converter)));
321
+ }
322
+ set(documentRef, data, options) {
323
+ const ref = castReference(documentRef);
324
+ if (options) {
325
+ validateSetOptions('Transaction.set', options);
326
+ this._delegate.set(ref, data, options);
327
+ }
328
+ else {
329
+ this._delegate.set(ref, data);
330
+ }
331
+ return this;
332
+ }
333
+ update(documentRef, dataOrField, value, ...moreFieldsAndValues) {
334
+ const ref = castReference(documentRef);
335
+ if (arguments.length === 2) {
336
+ this._delegate.update(ref, dataOrField);
337
+ }
338
+ else {
339
+ this._delegate.update(ref, dataOrField, value, ...moreFieldsAndValues);
340
+ }
341
+ return this;
342
+ }
343
+ delete(documentRef) {
344
+ const ref = castReference(documentRef);
345
+ this._delegate.delete(ref);
346
+ return this;
347
+ }
348
+ }
349
+ class WriteBatch {
350
+ constructor(_delegate) {
351
+ this._delegate = _delegate;
352
+ }
353
+ set(documentRef, data, options) {
354
+ const ref = castReference(documentRef);
355
+ if (options) {
356
+ validateSetOptions('WriteBatch.set', options);
357
+ this._delegate.set(ref, data, options);
358
+ }
359
+ else {
360
+ this._delegate.set(ref, data);
361
+ }
362
+ return this;
363
+ }
364
+ update(documentRef, dataOrField, value, ...moreFieldsAndValues) {
365
+ const ref = castReference(documentRef);
366
+ if (arguments.length === 2) {
367
+ this._delegate.update(ref, dataOrField);
368
+ }
369
+ else {
370
+ this._delegate.update(ref, dataOrField, value, ...moreFieldsAndValues);
371
+ }
372
+ return this;
373
+ }
374
+ delete(documentRef) {
375
+ const ref = castReference(documentRef);
376
+ this._delegate.delete(ref);
377
+ return this;
378
+ }
379
+ commit() {
380
+ return this._delegate.commit();
381
+ }
382
+ }
383
+ /**
384
+ * Wraps a `PublicFirestoreDataConverter` translating the types from the
385
+ * experimental SDK into corresponding types from the Classic SDK before passing
386
+ * them to the wrapped converter.
387
+ */
388
+ class FirestoreDataConverter {
389
+ constructor(_firestore, _userDataWriter, _delegate) {
390
+ this._firestore = _firestore;
391
+ this._userDataWriter = _userDataWriter;
392
+ this._delegate = _delegate;
393
+ }
394
+ fromFirestore(snapshot, options) {
395
+ const expSnapshot = new firestore.QueryDocumentSnapshot(this._firestore._delegate, this._userDataWriter, snapshot._key, snapshot._document, snapshot.metadata,
396
+ /* converter= */ null);
397
+ return this._delegate.fromFirestore(new QueryDocumentSnapshot(this._firestore, expSnapshot), options !== null && options !== void 0 ? options : {});
398
+ }
399
+ toFirestore(modelObject, options) {
400
+ if (!options) {
401
+ return this._delegate.toFirestore(modelObject);
402
+ }
403
+ else {
404
+ return this._delegate.toFirestore(modelObject, options);
405
+ }
406
+ }
407
+ // Use the same instance of `FirestoreDataConverter` for the given instances
408
+ // of `Firestore` and `PublicFirestoreDataConverter` so that isEqual() will
409
+ // compare equal for two objects created with the same converter instance.
410
+ static getInstance(firestore, converter) {
411
+ const converterMapByFirestore = FirestoreDataConverter.INSTANCES;
412
+ let untypedConverterByConverter = converterMapByFirestore.get(firestore);
413
+ if (!untypedConverterByConverter) {
414
+ untypedConverterByConverter = new WeakMap();
415
+ converterMapByFirestore.set(firestore, untypedConverterByConverter);
416
+ }
417
+ let instance = untypedConverterByConverter.get(converter);
418
+ if (!instance) {
419
+ instance = new FirestoreDataConverter(firestore, new UserDataWriter(firestore), converter);
420
+ untypedConverterByConverter.set(converter, instance);
421
+ }
422
+ return instance;
423
+ }
424
+ }
425
+ FirestoreDataConverter.INSTANCES = new WeakMap();
426
+ /**
427
+ * A reference to a particular document in a collection in the database.
428
+ */
429
+ class DocumentReference {
430
+ constructor(firestore, _delegate) {
431
+ this.firestore = firestore;
432
+ this._delegate = _delegate;
433
+ this._userDataWriter = new UserDataWriter(firestore);
434
+ }
435
+ static forPath(path, firestore$1, converter) {
436
+ if (path.length % 2 !== 0) {
437
+ throw new firestore.FirestoreError('invalid-argument', 'Invalid document reference. Document ' +
438
+ 'references must have an even number of segments, but ' +
439
+ `${path.canonicalString()} has ${path.length}`);
440
+ }
441
+ return new DocumentReference(firestore$1, new firestore.DocumentReference(firestore$1._delegate, converter, new firestore._DocumentKey(path)));
442
+ }
443
+ static forKey(key, firestore$1, converter) {
444
+ return new DocumentReference(firestore$1, new firestore.DocumentReference(firestore$1._delegate, converter, key));
445
+ }
446
+ get id() {
447
+ return this._delegate.id;
448
+ }
449
+ get parent() {
450
+ return new CollectionReference(this.firestore, this._delegate.parent);
451
+ }
452
+ get path() {
453
+ return this._delegate.path;
454
+ }
455
+ collection(pathString) {
456
+ try {
457
+ return new CollectionReference(this.firestore, firestore.collection(this._delegate, pathString));
458
+ }
459
+ catch (e) {
460
+ throw replaceFunctionName(e, 'collection()', 'DocumentReference.collection()');
461
+ }
462
+ }
463
+ isEqual(other) {
464
+ other = util.getModularInstance(other);
465
+ if (!(other instanceof firestore.DocumentReference)) {
466
+ return false;
467
+ }
468
+ return firestore.refEqual(this._delegate, other);
469
+ }
470
+ set(value, options) {
471
+ options = validateSetOptions('DocumentReference.set', options);
472
+ try {
473
+ if (options) {
474
+ return firestore.setDoc(this._delegate, value, options);
475
+ }
476
+ else {
477
+ return firestore.setDoc(this._delegate, value);
478
+ }
479
+ }
480
+ catch (e) {
481
+ throw replaceFunctionName(e, 'setDoc()', 'DocumentReference.set()');
482
+ }
483
+ }
484
+ update(fieldOrUpdateData, value, ...moreFieldsAndValues) {
485
+ try {
486
+ if (arguments.length === 1) {
487
+ return firestore.updateDoc(this._delegate, fieldOrUpdateData);
488
+ }
489
+ else {
490
+ return firestore.updateDoc(this._delegate, fieldOrUpdateData, value, ...moreFieldsAndValues);
491
+ }
492
+ }
493
+ catch (e) {
494
+ throw replaceFunctionName(e, 'updateDoc()', 'DocumentReference.update()');
495
+ }
496
+ }
497
+ delete() {
498
+ return firestore.deleteDoc(this._delegate);
499
+ }
500
+ onSnapshot(...args) {
501
+ const options = extractSnapshotOptions(args);
502
+ const observer = wrapObserver(args, result => new DocumentSnapshot(this.firestore, new firestore.DocumentSnapshot(this.firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, this._delegate.converter)));
503
+ return firestore.onSnapshot(this._delegate, options, observer);
504
+ }
505
+ get(options) {
506
+ let snap;
507
+ if ((options === null || options === void 0 ? void 0 : options.source) === 'cache') {
508
+ snap = firestore.getDocFromCache(this._delegate);
509
+ }
510
+ else if ((options === null || options === void 0 ? void 0 : options.source) === 'server') {
511
+ snap = firestore.getDocFromServer(this._delegate);
512
+ }
513
+ else {
514
+ snap = firestore.getDoc(this._delegate);
515
+ }
516
+ return snap.then(result => new DocumentSnapshot(this.firestore, new firestore.DocumentSnapshot(this.firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, this._delegate.converter)));
517
+ }
518
+ withConverter(converter) {
519
+ return new DocumentReference(this.firestore, converter
520
+ ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
521
+ : this._delegate.withConverter(null));
522
+ }
523
+ }
524
+ /**
525
+ * Replaces the function name in an error thrown by the firestore-exp API
526
+ * with the function names used in the classic API.
527
+ */
528
+ function replaceFunctionName(e, original, updated) {
529
+ e.message = e.message.replace(original, updated);
530
+ return e;
531
+ }
532
+ /**
533
+ * Iterates the list of arguments from an `onSnapshot` call and returns the
534
+ * first argument that may be an `SnapshotListenOptions` object. Returns an
535
+ * empty object if none is found.
536
+ */
537
+ function extractSnapshotOptions(args) {
538
+ for (const arg of args) {
539
+ if (typeof arg === 'object' && !isPartialObserver(arg)) {
540
+ return arg;
541
+ }
542
+ }
543
+ return {};
544
+ }
545
+ /**
546
+ * Creates an observer that can be passed to the firestore-exp SDK. The
547
+ * observer converts all observed values into the format expected by the classic
548
+ * SDK.
549
+ *
550
+ * @param args - The list of arguments from an `onSnapshot` call.
551
+ * @param wrapper - The function that converts the firestore-exp type into the
552
+ * type used by this shim.
553
+ */
554
+ function wrapObserver(args, wrapper) {
555
+ var _a, _b;
556
+ let userObserver;
557
+ if (isPartialObserver(args[0])) {
558
+ userObserver = args[0];
559
+ }
560
+ else if (isPartialObserver(args[1])) {
561
+ userObserver = args[1];
562
+ }
563
+ else if (typeof args[0] === 'function') {
564
+ userObserver = {
565
+ next: args[0],
566
+ error: args[1],
567
+ complete: args[2]
568
+ };
569
+ }
570
+ else {
571
+ userObserver = {
572
+ next: args[1],
573
+ error: args[2],
574
+ complete: args[3]
575
+ };
576
+ }
577
+ return {
578
+ next: val => {
579
+ if (userObserver.next) {
580
+ userObserver.next(wrapper(val));
581
+ }
582
+ },
583
+ error: (_a = userObserver.error) === null || _a === void 0 ? void 0 : _a.bind(userObserver),
584
+ complete: (_b = userObserver.complete) === null || _b === void 0 ? void 0 : _b.bind(userObserver)
585
+ };
586
+ }
587
+ class DocumentSnapshot {
588
+ constructor(_firestore, _delegate) {
589
+ this._firestore = _firestore;
590
+ this._delegate = _delegate;
591
+ }
592
+ get ref() {
593
+ return new DocumentReference(this._firestore, this._delegate.ref);
594
+ }
595
+ get id() {
596
+ return this._delegate.id;
597
+ }
598
+ get metadata() {
599
+ return this._delegate.metadata;
600
+ }
601
+ get exists() {
602
+ return this._delegate.exists();
603
+ }
604
+ data(options) {
605
+ return this._delegate.data(options);
606
+ }
607
+ get(fieldPath, options
608
+ // We are using `any` here to avoid an explicit cast by our users.
609
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
610
+ ) {
611
+ return this._delegate.get(fieldPath, options);
612
+ }
613
+ isEqual(other) {
614
+ return firestore.snapshotEqual(this._delegate, other._delegate);
615
+ }
616
+ }
617
+ class QueryDocumentSnapshot extends DocumentSnapshot {
618
+ data(options) {
619
+ const data = this._delegate.data(options);
620
+ if (this._delegate._converter) {
621
+ // Undefined is a possible valid value from converter.
622
+ return data;
623
+ }
624
+ else {
625
+ firestore._debugAssert(data !== undefined, 'Document in a QueryDocumentSnapshot should exist');
626
+ return data;
627
+ }
628
+ }
629
+ }
630
+ class Query {
631
+ constructor(firestore, _delegate) {
632
+ this.firestore = firestore;
633
+ this._delegate = _delegate;
634
+ this._userDataWriter = new UserDataWriter(firestore);
635
+ }
636
+ where(fieldPath, opStr, value) {
637
+ try {
638
+ // The "as string" cast is a little bit of a hack. `where` accepts the
639
+ // FieldPath Compat type as input, but is not typed as such in order to
640
+ // not expose this via our public typings file.
641
+ return new Query(this.firestore, firestore.query(this._delegate, firestore.where(fieldPath, opStr, value)));
642
+ }
643
+ catch (e) {
644
+ throw replaceFunctionName(e, /(orderBy|where)\(\)/, 'Query.$1()');
645
+ }
646
+ }
647
+ orderBy(fieldPath, directionStr) {
648
+ try {
649
+ // The "as string" cast is a little bit of a hack. `orderBy` accepts the
650
+ // FieldPath Compat type as input, but is not typed as such in order to
651
+ // not expose this via our public typings file.
652
+ return new Query(this.firestore, firestore.query(this._delegate, firestore.orderBy(fieldPath, directionStr)));
653
+ }
654
+ catch (e) {
655
+ throw replaceFunctionName(e, /(orderBy|where)\(\)/, 'Query.$1()');
656
+ }
657
+ }
658
+ limit(n) {
659
+ try {
660
+ return new Query(this.firestore, firestore.query(this._delegate, firestore.limit(n)));
661
+ }
662
+ catch (e) {
663
+ throw replaceFunctionName(e, 'limit()', 'Query.limit()');
664
+ }
665
+ }
666
+ limitToLast(n) {
667
+ try {
668
+ return new Query(this.firestore, firestore.query(this._delegate, firestore.limitToLast(n)));
669
+ }
670
+ catch (e) {
671
+ throw replaceFunctionName(e, 'limitToLast()', 'Query.limitToLast()');
672
+ }
673
+ }
674
+ startAt(...args) {
675
+ try {
676
+ return new Query(this.firestore, firestore.query(this._delegate, firestore.startAt(...args)));
677
+ }
678
+ catch (e) {
679
+ throw replaceFunctionName(e, 'startAt()', 'Query.startAt()');
680
+ }
681
+ }
682
+ startAfter(...args) {
683
+ try {
684
+ return new Query(this.firestore, firestore.query(this._delegate, firestore.startAfter(...args)));
685
+ }
686
+ catch (e) {
687
+ throw replaceFunctionName(e, 'startAfter()', 'Query.startAfter()');
688
+ }
689
+ }
690
+ endBefore(...args) {
691
+ try {
692
+ return new Query(this.firestore, firestore.query(this._delegate, firestore.endBefore(...args)));
693
+ }
694
+ catch (e) {
695
+ throw replaceFunctionName(e, 'endBefore()', 'Query.endBefore()');
696
+ }
697
+ }
698
+ endAt(...args) {
699
+ try {
700
+ return new Query(this.firestore, firestore.query(this._delegate, firestore.endAt(...args)));
701
+ }
702
+ catch (e) {
703
+ throw replaceFunctionName(e, 'endAt()', 'Query.endAt()');
704
+ }
705
+ }
706
+ isEqual(other) {
707
+ return firestore.queryEqual(this._delegate, other._delegate);
708
+ }
709
+ get(options) {
710
+ let query;
711
+ if ((options === null || options === void 0 ? void 0 : options.source) === 'cache') {
712
+ query = firestore.getDocsFromCache(this._delegate);
713
+ }
714
+ else if ((options === null || options === void 0 ? void 0 : options.source) === 'server') {
715
+ query = firestore.getDocsFromServer(this._delegate);
716
+ }
717
+ else {
718
+ query = firestore.getDocs(this._delegate);
719
+ }
720
+ return query.then(result => new QuerySnapshot(this.firestore, new firestore.QuerySnapshot(this.firestore._delegate, this._userDataWriter, this._delegate, result._snapshot)));
721
+ }
722
+ onSnapshot(...args) {
723
+ const options = extractSnapshotOptions(args);
724
+ const observer = wrapObserver(args, snap => new QuerySnapshot(this.firestore, new firestore.QuerySnapshot(this.firestore._delegate, this._userDataWriter, this._delegate, snap._snapshot)));
725
+ return firestore.onSnapshot(this._delegate, options, observer);
726
+ }
727
+ withConverter(converter) {
728
+ return new Query(this.firestore, converter
729
+ ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
730
+ : this._delegate.withConverter(null));
731
+ }
732
+ }
733
+ class DocumentChange {
734
+ constructor(_firestore, _delegate) {
735
+ this._firestore = _firestore;
736
+ this._delegate = _delegate;
737
+ }
738
+ get type() {
739
+ return this._delegate.type;
740
+ }
741
+ get doc() {
742
+ return new QueryDocumentSnapshot(this._firestore, this._delegate.doc);
743
+ }
744
+ get oldIndex() {
745
+ return this._delegate.oldIndex;
746
+ }
747
+ get newIndex() {
748
+ return this._delegate.newIndex;
749
+ }
750
+ }
751
+ class QuerySnapshot {
752
+ constructor(_firestore, _delegate) {
753
+ this._firestore = _firestore;
754
+ this._delegate = _delegate;
755
+ }
756
+ get query() {
757
+ return new Query(this._firestore, this._delegate.query);
758
+ }
759
+ get metadata() {
760
+ return this._delegate.metadata;
761
+ }
762
+ get size() {
763
+ return this._delegate.size;
764
+ }
765
+ get empty() {
766
+ return this._delegate.empty;
767
+ }
768
+ get docs() {
769
+ return this._delegate.docs.map(doc => new QueryDocumentSnapshot(this._firestore, doc));
770
+ }
771
+ docChanges(options) {
772
+ return this._delegate
773
+ .docChanges(options)
774
+ .map(docChange => new DocumentChange(this._firestore, docChange));
775
+ }
776
+ forEach(callback, thisArg) {
777
+ this._delegate.forEach(snapshot => {
778
+ callback.call(thisArg, new QueryDocumentSnapshot(this._firestore, snapshot));
779
+ });
780
+ }
781
+ isEqual(other) {
782
+ return firestore.snapshotEqual(this._delegate, other._delegate);
783
+ }
784
+ }
785
+ class CollectionReference extends Query {
786
+ constructor(firestore, _delegate) {
787
+ super(firestore, _delegate);
788
+ this.firestore = firestore;
789
+ this._delegate = _delegate;
790
+ }
791
+ get id() {
792
+ return this._delegate.id;
793
+ }
794
+ get path() {
795
+ return this._delegate.path;
796
+ }
797
+ get parent() {
798
+ const docRef = this._delegate.parent;
799
+ return docRef ? new DocumentReference(this.firestore, docRef) : null;
800
+ }
801
+ doc(documentPath) {
802
+ try {
803
+ if (documentPath === undefined) {
804
+ // Call `doc` without `documentPath` if `documentPath` is `undefined`
805
+ // as `doc` validates the number of arguments to prevent users from
806
+ // accidentally passing `undefined`.
807
+ return new DocumentReference(this.firestore, firestore.doc(this._delegate));
808
+ }
809
+ else {
810
+ return new DocumentReference(this.firestore, firestore.doc(this._delegate, documentPath));
811
+ }
812
+ }
813
+ catch (e) {
814
+ throw replaceFunctionName(e, 'doc()', 'CollectionReference.doc()');
815
+ }
816
+ }
817
+ add(data) {
818
+ return firestore.addDoc(this._delegate, data).then(docRef => new DocumentReference(this.firestore, docRef));
819
+ }
820
+ isEqual(other) {
821
+ return firestore.refEqual(this._delegate, other._delegate);
822
+ }
823
+ withConverter(converter) {
824
+ return new CollectionReference(this.firestore, converter
825
+ ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
826
+ : this._delegate.withConverter(null));
827
+ }
828
+ }
829
+ function castReference(documentRef) {
830
+ return firestore._cast(documentRef, firestore.DocumentReference);
831
831
  }
832
832
 
833
- /**
834
- * @license
835
- * Copyright 2017 Google LLC
836
- *
837
- * Licensed under the Apache License, Version 2.0 (the "License");
838
- * you may not use this file except in compliance with the License.
839
- * You may obtain a copy of the License at
840
- *
841
- * http://www.apache.org/licenses/LICENSE-2.0
842
- *
843
- * Unless required by applicable law or agreed to in writing, software
844
- * distributed under the License is distributed on an "AS IS" BASIS,
845
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
846
- * See the License for the specific language governing permissions and
847
- * limitations under the License.
848
- */
849
- // The objects that are a part of this API are exposed to third-parties as
850
- // compiled javascript so we want to flag our private members with a leading
851
- // underscore to discourage their use.
852
- /**
853
- * A `FieldPath` refers to a field in a document. The path may consist of a
854
- * single field name (referring to a top-level field in the document), or a list
855
- * of field names (referring to a nested field in the document).
856
- */
857
- class FieldPath {
858
- /**
859
- * Creates a FieldPath from the provided field names. If more than one field
860
- * name is provided, the path will point to a nested field in a document.
861
- *
862
- * @param fieldNames - A list of field names.
863
- */
864
- constructor(...fieldNames) {
865
- this._delegate = new firestore.FieldPath(...fieldNames);
866
- }
867
- static documentId() {
868
- /**
869
- * Internal Note: The backend doesn't technically support querying by
870
- * document ID. Instead it queries by the entire document name (full path
871
- * included), but in the cases we currently support documentId(), the net
872
- * effect is the same.
873
- */
874
- return new FieldPath(firestore._FieldPath.keyField().canonicalString());
875
- }
876
- isEqual(other) {
877
- other = util.getModularInstance(other);
878
- if (!(other instanceof firestore.FieldPath)) {
879
- return false;
880
- }
881
- return this._delegate._internalPath.isEqual(other._internalPath);
882
- }
833
+ /**
834
+ * @license
835
+ * Copyright 2017 Google LLC
836
+ *
837
+ * Licensed under the Apache License, Version 2.0 (the "License");
838
+ * you may not use this file except in compliance with the License.
839
+ * You may obtain a copy of the License at
840
+ *
841
+ * http://www.apache.org/licenses/LICENSE-2.0
842
+ *
843
+ * Unless required by applicable law or agreed to in writing, software
844
+ * distributed under the License is distributed on an "AS IS" BASIS,
845
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
846
+ * See the License for the specific language governing permissions and
847
+ * limitations under the License.
848
+ */
849
+ // The objects that are a part of this API are exposed to third-parties as
850
+ // compiled javascript so we want to flag our private members with a leading
851
+ // underscore to discourage their use.
852
+ /**
853
+ * A `FieldPath` refers to a field in a document. The path may consist of a
854
+ * single field name (referring to a top-level field in the document), or a list
855
+ * of field names (referring to a nested field in the document).
856
+ */
857
+ class FieldPath {
858
+ /**
859
+ * Creates a FieldPath from the provided field names. If more than one field
860
+ * name is provided, the path will point to a nested field in a document.
861
+ *
862
+ * @param fieldNames - A list of field names.
863
+ */
864
+ constructor(...fieldNames) {
865
+ this._delegate = new firestore.FieldPath(...fieldNames);
866
+ }
867
+ static documentId() {
868
+ /**
869
+ * Internal Note: The backend doesn't technically support querying by
870
+ * document ID. Instead it queries by the entire document name (full path
871
+ * included), but in the cases we currently support documentId(), the net
872
+ * effect is the same.
873
+ */
874
+ return new FieldPath(firestore._FieldPath.keyField().canonicalString());
875
+ }
876
+ isEqual(other) {
877
+ other = util.getModularInstance(other);
878
+ if (!(other instanceof firestore.FieldPath)) {
879
+ return false;
880
+ }
881
+ return this._delegate._internalPath.isEqual(other._internalPath);
882
+ }
883
883
  }
884
884
 
885
- /**
886
- * @license
887
- * Copyright 2017 Google LLC
888
- *
889
- * Licensed under the Apache License, Version 2.0 (the "License");
890
- * you may not use this file except in compliance with the License.
891
- * You may obtain a copy of the License at
892
- *
893
- * http://www.apache.org/licenses/LICENSE-2.0
894
- *
895
- * Unless required by applicable law or agreed to in writing, software
896
- * distributed under the License is distributed on an "AS IS" BASIS,
897
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
898
- * See the License for the specific language governing permissions and
899
- * limitations under the License.
900
- */
901
- class FieldValue {
902
- constructor(_delegate) {
903
- this._delegate = _delegate;
904
- }
905
- static serverTimestamp() {
906
- const delegate = firestore.serverTimestamp();
907
- delegate._methodName = 'FieldValue.serverTimestamp';
908
- return new FieldValue(delegate);
909
- }
910
- static delete() {
911
- const delegate = firestore.deleteField();
912
- delegate._methodName = 'FieldValue.delete';
913
- return new FieldValue(delegate);
914
- }
915
- static arrayUnion(...elements) {
916
- const delegate = firestore.arrayUnion(...elements);
917
- delegate._methodName = 'FieldValue.arrayUnion';
918
- return new FieldValue(delegate);
919
- }
920
- static arrayRemove(...elements) {
921
- const delegate = firestore.arrayRemove(...elements);
922
- delegate._methodName = 'FieldValue.arrayRemove';
923
- return new FieldValue(delegate);
924
- }
925
- static increment(n) {
926
- const delegate = firestore.increment(n);
927
- delegate._methodName = 'FieldValue.increment';
928
- return new FieldValue(delegate);
929
- }
930
- isEqual(other) {
931
- return this._delegate.isEqual(other._delegate);
932
- }
885
+ /**
886
+ * @license
887
+ * Copyright 2017 Google LLC
888
+ *
889
+ * Licensed under the Apache License, Version 2.0 (the "License");
890
+ * you may not use this file except in compliance with the License.
891
+ * You may obtain a copy of the License at
892
+ *
893
+ * http://www.apache.org/licenses/LICENSE-2.0
894
+ *
895
+ * Unless required by applicable law or agreed to in writing, software
896
+ * distributed under the License is distributed on an "AS IS" BASIS,
897
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
898
+ * See the License for the specific language governing permissions and
899
+ * limitations under the License.
900
+ */
901
+ class FieldValue {
902
+ static serverTimestamp() {
903
+ const delegate = firestore.serverTimestamp();
904
+ delegate._methodName = 'FieldValue.serverTimestamp';
905
+ return new FieldValue(delegate);
906
+ }
907
+ static delete() {
908
+ const delegate = firestore.deleteField();
909
+ delegate._methodName = 'FieldValue.delete';
910
+ return new FieldValue(delegate);
911
+ }
912
+ static arrayUnion(...elements) {
913
+ const delegate = firestore.arrayUnion(...elements);
914
+ delegate._methodName = 'FieldValue.arrayUnion';
915
+ return new FieldValue(delegate);
916
+ }
917
+ static arrayRemove(...elements) {
918
+ const delegate = firestore.arrayRemove(...elements);
919
+ delegate._methodName = 'FieldValue.arrayRemove';
920
+ return new FieldValue(delegate);
921
+ }
922
+ static increment(n) {
923
+ const delegate = firestore.increment(n);
924
+ delegate._methodName = 'FieldValue.increment';
925
+ return new FieldValue(delegate);
926
+ }
927
+ constructor(_delegate) {
928
+ this._delegate = _delegate;
929
+ }
930
+ isEqual(other) {
931
+ return this._delegate.isEqual(other._delegate);
932
+ }
933
933
  }
934
934
 
935
- /**
936
- * @license
937
- * Copyright 2021 Google LLC
938
- *
939
- * Licensed under the Apache License, Version 2.0 (the "License");
940
- * you may not use this file except in compliance with the License.
941
- * You may obtain a copy of the License at
942
- *
943
- * http://www.apache.org/licenses/LICENSE-2.0
944
- *
945
- * Unless required by applicable law or agreed to in writing, software
946
- * distributed under the License is distributed on an "AS IS" BASIS,
947
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
948
- * See the License for the specific language governing permissions and
949
- * limitations under the License.
950
- */
951
- const firestoreNamespace = {
952
- Firestore,
953
- GeoPoint: firestore.GeoPoint,
954
- Timestamp: firestore.Timestamp,
955
- Blob,
956
- Transaction,
957
- WriteBatch,
958
- DocumentReference,
959
- DocumentSnapshot,
960
- Query,
961
- QueryDocumentSnapshot,
962
- QuerySnapshot,
963
- CollectionReference,
964
- FieldPath,
965
- FieldValue,
966
- setLogLevel,
967
- CACHE_SIZE_UNLIMITED: firestore.CACHE_SIZE_UNLIMITED
968
- };
969
- /**
970
- * Configures Firestore as part of the Firebase SDK by calling registerComponent.
971
- *
972
- * @param firebase - The FirebaseNamespace to register Firestore with
973
- * @param firestoreFactory - A factory function that returns a new Firestore
974
- * instance.
975
- */
976
- function configureForFirebase(firebase, firestoreFactory) {
977
- firebase.INTERNAL.registerComponent(new component.Component('firestore-compat', container => {
978
- const app = container.getProvider('app-compat').getImmediate();
979
- const firestoreExp = container.getProvider('firestore').getImmediate();
980
- return firestoreFactory(app, firestoreExp);
981
- }, 'PUBLIC').setServiceProps(Object.assign({}, firestoreNamespace)));
935
+ /**
936
+ * @license
937
+ * Copyright 2021 Google LLC
938
+ *
939
+ * Licensed under the Apache License, Version 2.0 (the "License");
940
+ * you may not use this file except in compliance with the License.
941
+ * You may obtain a copy of the License at
942
+ *
943
+ * http://www.apache.org/licenses/LICENSE-2.0
944
+ *
945
+ * Unless required by applicable law or agreed to in writing, software
946
+ * distributed under the License is distributed on an "AS IS" BASIS,
947
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
948
+ * See the License for the specific language governing permissions and
949
+ * limitations under the License.
950
+ */
951
+ const firestoreNamespace = {
952
+ Firestore,
953
+ GeoPoint: firestore.GeoPoint,
954
+ Timestamp: firestore.Timestamp,
955
+ Blob,
956
+ Transaction,
957
+ WriteBatch,
958
+ DocumentReference,
959
+ DocumentSnapshot,
960
+ Query,
961
+ QueryDocumentSnapshot,
962
+ QuerySnapshot,
963
+ CollectionReference,
964
+ FieldPath,
965
+ FieldValue,
966
+ setLogLevel,
967
+ CACHE_SIZE_UNLIMITED: firestore.CACHE_SIZE_UNLIMITED
968
+ };
969
+ /**
970
+ * Configures Firestore as part of the Firebase SDK by calling registerComponent.
971
+ *
972
+ * @param firebase - The FirebaseNamespace to register Firestore with
973
+ * @param firestoreFactory - A factory function that returns a new Firestore
974
+ * instance.
975
+ */
976
+ function configureForFirebase(firebase, firestoreFactory) {
977
+ firebase.INTERNAL.registerComponent(new component.Component('firestore-compat', container => {
978
+ const app = container.getProvider('app-compat').getImmediate();
979
+ const firestoreExp = container.getProvider('firestore').getImmediate();
980
+ return firestoreFactory(app, firestoreExp);
981
+ }, 'PUBLIC').setServiceProps(Object.assign({}, firestoreNamespace)));
982
982
  }
983
983
 
984
- /**
985
- * @license
986
- * Copyright 2020 Google LLC
987
- *
988
- * Licensed under the Apache License, Version 2.0 (the "License");
989
- * you may not use this file except in compliance with the License.
990
- * You may obtain a copy of the License at
991
- *
992
- * http://www.apache.org/licenses/LICENSE-2.0
993
- *
994
- * Unless required by applicable law or agreed to in writing, software
995
- * distributed under the License is distributed on an "AS IS" BASIS,
996
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
997
- * See the License for the specific language governing permissions and
998
- * limitations under the License.
999
- */
1000
- /**
1001
- * Registers the main Firestore build with the components framework.
1002
- * Persistence can be enabled via `firebase.firestore().enablePersistence()`.
1003
- */
1004
- function registerFirestore(instance) {
1005
- configureForFirebase(instance, (app, firestoreExp) => new Firestore(app, firestoreExp, new IndexedDbPersistenceProvider()));
1006
- instance.registerVersion(name, version);
1007
- }
984
+ /**
985
+ * @license
986
+ * Copyright 2020 Google LLC
987
+ *
988
+ * Licensed under the Apache License, Version 2.0 (the "License");
989
+ * you may not use this file except in compliance with the License.
990
+ * You may obtain a copy of the License at
991
+ *
992
+ * http://www.apache.org/licenses/LICENSE-2.0
993
+ *
994
+ * Unless required by applicable law or agreed to in writing, software
995
+ * distributed under the License is distributed on an "AS IS" BASIS,
996
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
997
+ * See the License for the specific language governing permissions and
998
+ * limitations under the License.
999
+ */
1000
+ /**
1001
+ * Registers the main Firestore build with the components framework.
1002
+ * Persistence can be enabled via `firebase.firestore().enablePersistence()`.
1003
+ */
1004
+ function registerFirestore(instance) {
1005
+ configureForFirebase(instance, (app, firestoreExp) => new Firestore(app, firestoreExp, new IndexedDbPersistenceProvider()));
1006
+ instance.registerVersion(name, version);
1007
+ }
1008
1008
  registerFirestore(firebase__default["default"]);
1009
1009
 
1010
1010
  exports.registerFirestore = registerFirestore;