@firebase/firestore-compat 0.4.0-20230301000120 → 0.4.0-20250716004940

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