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