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