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