@firebase/firestore 3.0.1 → 3.0.2-canary.07b88e6e8
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/CHANGELOG.md +12 -0
- package/dist/firestore/compat/api/blob.d.ts +29 -0
- package/dist/firestore/compat/api/database.d.ts +228 -0
- package/dist/firestore/compat/api/field_path.d.ts +36 -0
- package/dist/firestore/compat/api/field_value.d.ts +29 -0
- package/dist/firestore/compat/api/geo_point.d.ts +17 -0
- package/dist/firestore/compat/api/observer.d.ts +29 -0
- package/dist/firestore/compat/api/timestamp.d.ts +17 -0
- package/dist/firestore/compat/config.d.ts +28 -0
- package/dist/firestore/compat/index.console.d.ts +42 -0
- package/dist/firestore/compat/index.d.ts +49 -0
- package/dist/firestore/compat/index.node.d.ts +22 -0
- package/dist/firestore/compat/index.rn.d.ts +22 -0
- package/dist/firestore/compat/register-module.d.ts +42 -0
- package/dist/firestore/compat/util/input_validation.d.ts +18 -0
- package/dist/firestore/src/api/credentials.d.ts +4 -1
- package/dist/firestore/src/api.d.ts +1 -0
- package/dist/firestore/src/model/mutation.d.ts +4 -4
- package/dist/firestore/test/integration/api_internal/auth.test.d.ts +17 -0
- package/dist/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm2017.js +2617 -2615
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2721 -2738
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.esm2017.js +47 -41
- package/dist/index.node.cjs.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +75 -79
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.rn.js +2627 -2625
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +12 -1
- package/dist/lite/firestore/compat/api/blob.d.ts +29 -0
- package/dist/lite/firestore/compat/api/database.d.ts +228 -0
- package/dist/lite/firestore/compat/api/field_path.d.ts +36 -0
- package/dist/lite/firestore/compat/api/field_value.d.ts +29 -0
- package/dist/lite/firestore/compat/api/geo_point.d.ts +17 -0
- package/dist/lite/firestore/compat/api/observer.d.ts +29 -0
- package/dist/lite/firestore/compat/api/timestamp.d.ts +17 -0
- package/dist/lite/firestore/compat/config.d.ts +28 -0
- package/dist/lite/firestore/compat/index.console.d.ts +42 -0
- package/dist/lite/firestore/compat/index.d.ts +49 -0
- package/dist/lite/firestore/compat/index.node.d.ts +22 -0
- package/dist/lite/firestore/compat/index.rn.d.ts +22 -0
- package/dist/lite/firestore/compat/register-module.d.ts +42 -0
- package/dist/lite/firestore/compat/util/input_validation.d.ts +18 -0
- package/dist/lite/firestore/src/api/credentials.d.ts +4 -1
- package/dist/lite/firestore/src/api.d.ts +1 -0
- package/dist/lite/firestore/src/model/mutation.d.ts +4 -4
- package/dist/lite/firestore/test/integration/api_internal/auth.test.d.ts +17 -0
- package/dist/lite/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/lite/index.browser.esm2017.js +848 -845
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +815 -815
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +8 -5
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.esm2017.js +9 -6
- package/dist/lite/index.node.esm2017.js.map +1 -1
- package/dist/lite/index.rn.esm2017.js +832 -829
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +1 -1
- package/dist/lite/packages/firestore/compat/api/blob.d.ts +29 -0
- package/dist/lite/packages/firestore/compat/api/database.d.ts +228 -0
- package/dist/lite/packages/firestore/compat/api/field_path.d.ts +36 -0
- package/dist/lite/packages/firestore/compat/api/field_value.d.ts +29 -0
- package/dist/lite/packages/firestore/compat/api/geo_point.d.ts +17 -0
- package/dist/lite/packages/firestore/compat/api/observer.d.ts +29 -0
- package/dist/lite/packages/firestore/compat/api/timestamp.d.ts +17 -0
- package/dist/lite/packages/firestore/compat/config.d.ts +28 -0
- package/dist/lite/packages/firestore/compat/index.console.d.ts +42 -0
- package/dist/lite/packages/firestore/compat/index.d.ts +49 -0
- package/dist/lite/packages/firestore/compat/index.node.d.ts +22 -0
- package/dist/lite/packages/firestore/compat/index.rn.d.ts +22 -0
- package/dist/lite/packages/firestore/compat/register-module.d.ts +42 -0
- package/dist/lite/packages/firestore/compat/util/input_validation.d.ts +18 -0
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +112 -112
- package/dist/lite/packages/firestore/rollup.config.debug.d.ts +14 -0
- package/dist/lite/packages/firestore/rollup.shared.d.ts +4 -10
- package/dist/lite/packages/firestore/src/api/credentials.d.ts +4 -1
- package/dist/lite/packages/firestore/src/api.d.ts +1 -0
- package/dist/lite/packages/firestore/src/model/mutation.d.ts +4 -4
- package/dist/lite/packages/firestore/test/integration/api_internal/auth.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/lite/private.d.ts +1 -1
- package/dist/packages/firestore/compat/api/blob.d.ts +29 -0
- package/dist/packages/firestore/compat/api/database.d.ts +228 -0
- package/dist/packages/firestore/compat/api/field_path.d.ts +36 -0
- package/dist/packages/firestore/compat/api/field_value.d.ts +29 -0
- package/dist/packages/firestore/compat/api/geo_point.d.ts +17 -0
- package/dist/packages/firestore/compat/api/observer.d.ts +29 -0
- package/dist/packages/firestore/compat/api/timestamp.d.ts +17 -0
- package/dist/packages/firestore/compat/config.d.ts +28 -0
- package/dist/packages/firestore/compat/index.console.d.ts +42 -0
- package/dist/packages/firestore/compat/index.d.ts +49 -0
- package/dist/packages/firestore/compat/index.node.d.ts +22 -0
- package/dist/packages/firestore/compat/index.rn.d.ts +22 -0
- package/dist/packages/firestore/compat/register-module.d.ts +42 -0
- package/dist/packages/firestore/compat/util/input_validation.d.ts +18 -0
- package/dist/packages/firestore/dist/index.esm2017.d.ts +165 -156
- package/dist/packages/firestore/dist/index.node.cjs.esm2017.d.ts +11 -1
- package/dist/packages/firestore/rollup.config.debug.d.ts +14 -0
- package/dist/packages/firestore/rollup.shared.d.ts +4 -10
- package/dist/packages/firestore/src/api/credentials.d.ts +4 -1
- package/dist/packages/firestore/src/api.d.ts +1 -0
- package/dist/packages/firestore/src/model/mutation.d.ts +4 -4
- package/dist/packages/firestore/test/integration/api_internal/auth.test.d.ts +17 -0
- package/dist/packages/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/private.d.ts +3 -1
- package/package.json +20 -17
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
18
|
+
import { Provider } from '@firebase/component';
|
|
19
|
+
import { Firestore as FirestoreCompat, PersistenceProvider } from './api/database';
|
|
20
|
+
export { CollectionReference, DocumentReference, DocumentSnapshot, QuerySnapshot } from './api/database';
|
|
21
|
+
export { Blob } from './api/blob';
|
|
22
|
+
export { GeoPoint } from './api/geo_point';
|
|
23
|
+
export { FieldPath } from './api/field_path';
|
|
24
|
+
export { FieldValue } from './api/field_value';
|
|
25
|
+
export { Timestamp } from './api/timestamp';
|
|
26
|
+
export interface FirestoreDatabase {
|
|
27
|
+
projectId: string;
|
|
28
|
+
database?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The persistence provider included with the memory-only SDK. This provider
|
|
32
|
+
* errors for all attempts to access persistence.
|
|
33
|
+
*/
|
|
34
|
+
export declare class MemoryPersistenceProvider implements PersistenceProvider {
|
|
35
|
+
enableIndexedDbPersistence(firestore: FirestoreCompat, forceOwnership: boolean): Promise<void>;
|
|
36
|
+
enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise<void>;
|
|
37
|
+
clearIndexedDbPersistence(firestore: Firestore): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/** Firestore class that exposes the constructor expected by the Console. */
|
|
40
|
+
export declare class Firestore extends FirestoreCompat {
|
|
41
|
+
constructor(firestoreDatabase: FirestoreDatabase, authProvider: Provider<FirebaseAuthInternalName>);
|
|
42
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseNamespace } from '@firebase/app-types';
|
|
18
|
+
import * as types from '@firebase/firestore-types';
|
|
19
|
+
import './register-module';
|
|
20
|
+
/**
|
|
21
|
+
* Registers the main Firestore build with the components framework.
|
|
22
|
+
* Persistence can be enabled via `firebase.firestore().enablePersistence()`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function registerFirestore(instance: FirebaseNamespace): void;
|
|
25
|
+
declare module '@firebase/app-compat' {
|
|
26
|
+
interface FirebaseNamespace {
|
|
27
|
+
firestore: {
|
|
28
|
+
(app?: FirebaseApp): types.FirebaseFirestore;
|
|
29
|
+
Blob: typeof types.Blob;
|
|
30
|
+
CollectionReference: typeof types.CollectionReference;
|
|
31
|
+
DocumentReference: typeof types.DocumentReference;
|
|
32
|
+
DocumentSnapshot: typeof types.DocumentSnapshot;
|
|
33
|
+
FieldPath: typeof types.FieldPath;
|
|
34
|
+
FieldValue: typeof types.FieldValue;
|
|
35
|
+
Firestore: typeof types.FirebaseFirestore;
|
|
36
|
+
GeoPoint: typeof types.GeoPoint;
|
|
37
|
+
Query: typeof types.Query;
|
|
38
|
+
QueryDocumentSnapshot: typeof types.QueryDocumentSnapshot;
|
|
39
|
+
QuerySnapshot: typeof types.QuerySnapshot;
|
|
40
|
+
Timestamp: typeof types.Timestamp;
|
|
41
|
+
Transaction: typeof types.Transaction;
|
|
42
|
+
WriteBatch: typeof types.WriteBatch;
|
|
43
|
+
setLogLevel: typeof types.setLogLevel;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
interface FirebaseApp {
|
|
47
|
+
firestore?(): types.FirebaseFirestore;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseNamespace } from '@firebase/app-types';
|
|
18
|
+
/**
|
|
19
|
+
* Registers the main Firestore Node build with the components framework.
|
|
20
|
+
* Persistence can be enabled via `firebase.firestore().enablePersistence()`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function registerFirestore(instance: FirebaseNamespace): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseNamespace } from '@firebase/app-types';
|
|
18
|
+
/**
|
|
19
|
+
* Registers the main Firestore ReactNative build with the components framework.
|
|
20
|
+
* Persistence can be enabled via `firebase.firestore().enablePersistence()`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function registerFirestore(instance: FirebaseNamespace): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import * as types from '@firebase/firestore-types';
|
|
18
|
+
declare module '@firebase/app-compat' {
|
|
19
|
+
interface FirebaseNamespace {
|
|
20
|
+
firestore: {
|
|
21
|
+
(app?: FirebaseApp): types.FirebaseFirestore;
|
|
22
|
+
Blob: typeof types.Blob;
|
|
23
|
+
CollectionReference: typeof types.CollectionReference;
|
|
24
|
+
DocumentReference: typeof types.DocumentReference;
|
|
25
|
+
DocumentSnapshot: typeof types.DocumentSnapshot;
|
|
26
|
+
FieldPath: typeof types.FieldPath;
|
|
27
|
+
FieldValue: typeof types.FieldValue;
|
|
28
|
+
Firestore: typeof types.FirebaseFirestore;
|
|
29
|
+
GeoPoint: typeof types.GeoPoint;
|
|
30
|
+
Query: typeof types.Query;
|
|
31
|
+
QueryDocumentSnapshot: typeof types.QueryDocumentSnapshot;
|
|
32
|
+
QuerySnapshot: typeof types.QuerySnapshot;
|
|
33
|
+
Timestamp: typeof types.Timestamp;
|
|
34
|
+
Transaction: typeof types.Transaction;
|
|
35
|
+
WriteBatch: typeof types.WriteBatch;
|
|
36
|
+
setLogLevel: typeof types.setLogLevel;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
interface FirebaseApp {
|
|
40
|
+
firestore?(): types.FirebaseFirestore;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { SetOptions } from '@firebase/firestore-types';
|
|
18
|
+
export declare function validateSetOptions(methodName: string, options: SetOptions | undefined): SetOptions;
|
|
@@ -80,7 +80,10 @@ export interface CredentialsProvider {
|
|
|
80
80
|
invalidateToken(): void;
|
|
81
81
|
shutdown(): void;
|
|
82
82
|
}
|
|
83
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* A CredentialsProvider that always yields an empty token.
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
84
87
|
export declare class EmptyCredentialsProvider implements CredentialsProvider {
|
|
85
88
|
getToken(): Promise<Token | null>;
|
|
86
89
|
invalidateToken(): void;
|
|
@@ -47,3 +47,4 @@ export { FieldPath as _FieldPath } from './model/path';
|
|
|
47
47
|
export type { ResourcePath as _ResourcePath } from './model/path';
|
|
48
48
|
export type { ByteString as _ByteString } from './util/byte_string';
|
|
49
49
|
export { logWarn as _logWarn } from './util/log';
|
|
50
|
+
export { EmptyCredentialsProvider as _EmptyCredentialsProvider } from './api/credentials';
|
|
@@ -141,7 +141,7 @@ export declare function preconditionIsValidForDocument(precondition: Preconditio
|
|
|
141
141
|
*
|
|
142
142
|
* Every type of mutation needs to implement its own applyToRemoteDocument() and
|
|
143
143
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
144
|
-
* to some source document (see `
|
|
144
|
+
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
145
145
|
* example).
|
|
146
146
|
*/
|
|
147
147
|
export declare abstract class Mutation {
|
|
@@ -162,7 +162,7 @@ export declare abstract class Mutation {
|
|
|
162
162
|
* of the document.
|
|
163
163
|
* @param mutationResult - The result of applying the mutation from the backend.
|
|
164
164
|
*/
|
|
165
|
-
export declare function
|
|
165
|
+
export declare function mutationApplyToRemoteDocument(mutation: Mutation, document: MutableDocument, mutationResult: MutationResult): void;
|
|
166
166
|
/**
|
|
167
167
|
* Applies this mutation to the given document for the purposes of computing
|
|
168
168
|
* the new local view of a document. If the input document doesn't match the
|
|
@@ -175,7 +175,7 @@ export declare function applyMutationToRemoteDocument(mutation: Mutation, docume
|
|
|
175
175
|
* @param localWriteTime - A timestamp indicating the local write time of the
|
|
176
176
|
* batch this mutation is a part of.
|
|
177
177
|
*/
|
|
178
|
-
export declare function
|
|
178
|
+
export declare function mutationApplyToLocalView(mutation: Mutation, document: MutableDocument, localWriteTime: Timestamp): void;
|
|
179
179
|
/**
|
|
180
180
|
* If this mutation is not idempotent, returns the base value to persist with
|
|
181
181
|
* this mutation. If a base value is returned, the mutation is always applied
|
|
@@ -192,7 +192,7 @@ export declare function applyMutationToLocalView(mutation: Mutation, document: M
|
|
|
192
192
|
* @returns a base value to store along with the mutation, or null for
|
|
193
193
|
* idempotent mutations.
|
|
194
194
|
*/
|
|
195
|
-
export declare function
|
|
195
|
+
export declare function mutationExtractBaseValue(mutation: Mutation, document: Document): ObjectValue | null;
|
|
196
196
|
export declare function mutationEquals(left: Mutation, right: Mutation): boolean;
|
|
197
197
|
/**
|
|
198
198
|
* A mutation that creates or replaces the document at the given key with the
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
@@ -20,7 +20,7 @@ import { JsonObject } from '../../src/model/object_value';
|
|
|
20
20
|
/**
|
|
21
21
|
* A mock Firestore. Will not work for integration test.
|
|
22
22
|
*/
|
|
23
|
-
export declare const FIRESTORE:
|
|
23
|
+
export declare const FIRESTORE: Firestore;
|
|
24
24
|
export declare function firestore(): Firestore;
|
|
25
25
|
export declare function newTestFirestore(projectId?: string): Firestore;
|
|
26
26
|
export declare function collectionReference(path: string): CollectionReference;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { _getProvider
|
|
1
|
+
import { _getProvider, getApp as t, _removeServiceInstance as n, _registerComponent as e, registerVersion as r, SDK_VERSION as s } from "@firebase/app";
|
|
2
2
|
|
|
3
|
-
import { Component as
|
|
3
|
+
import { Component as i } from "@firebase/component";
|
|
4
4
|
|
|
5
|
-
import { Logger as
|
|
5
|
+
import { Logger as o, LogLevel as u } from "@firebase/logger";
|
|
6
6
|
|
|
7
|
-
import { createMockUserToken as
|
|
7
|
+
import { createMockUserToken as c, getModularInstance as a } from "@firebase/util";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -26,7 +26,7 @@ import { createMockUserToken as a, getModularInstance as h } from "@firebase/uti
|
|
|
26
26
|
* Simple wrapper around a nullable UID. Mostly exists to make code more
|
|
27
27
|
* readable.
|
|
28
28
|
*/
|
|
29
|
-
class
|
|
29
|
+
class h {
|
|
30
30
|
constructor(t) {
|
|
31
31
|
this.uid = t;
|
|
32
32
|
}
|
|
@@ -44,11 +44,11 @@ class l {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/** A user with a null UID. */
|
|
47
|
+
/** A user with a null UID. */ h.UNAUTHENTICATED = new h(null),
|
|
48
48
|
// TODO(mikelehen): Look into getting a proper uid-equivalent for
|
|
49
49
|
// non-FirebaseAuth providers.
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
h.GOOGLE_CREDENTIALS = new h("google-credentials-uid"), h.FIRST_PARTY = new h("first-party-uid"),
|
|
51
|
+
h.MOCK_USER = new h("mock-user");
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* @license
|
|
@@ -66,7 +66,7 @@ l.MOCK_USER = new l("mock-user");
|
|
|
66
66
|
* See the License for the specific language governing permissions and
|
|
67
67
|
* limitations under the License.
|
|
68
68
|
*/
|
|
69
|
-
let
|
|
69
|
+
let l = "9.0.2-canary.07b88e6e8";
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @license
|
|
@@ -84,7 +84,7 @@ let f = "9.0.1";
|
|
|
84
84
|
* See the License for the specific language governing permissions and
|
|
85
85
|
* limitations under the License.
|
|
86
86
|
*/
|
|
87
|
-
const
|
|
87
|
+
const f = new o("@firebase/firestore");
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
|
@@ -98,36 +98,36 @@ const d = new u("@firebase/firestore");
|
|
|
98
98
|
* <li>`error` to log errors only.</li>
|
|
99
99
|
* <li><code>`silent` to turn off logging.</li>
|
|
100
100
|
* </ul>
|
|
101
|
-
*/ function
|
|
102
|
-
|
|
101
|
+
*/ function d(t) {
|
|
102
|
+
f.setLogLevel(t);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function
|
|
106
|
-
if (
|
|
107
|
-
const e = n.map(
|
|
108
|
-
|
|
105
|
+
function w(t, ...n) {
|
|
106
|
+
if (f.logLevel <= u.DEBUG) {
|
|
107
|
+
const e = n.map(y);
|
|
108
|
+
f.debug(`Firestore (${l}): ${t}`, ...e);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function
|
|
113
|
-
if (
|
|
114
|
-
const e = n.map(
|
|
115
|
-
|
|
112
|
+
function m(t, ...n) {
|
|
113
|
+
if (f.logLevel <= u.ERROR) {
|
|
114
|
+
const e = n.map(y);
|
|
115
|
+
f.error(`Firestore (${l}): ${t}`, ...e);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* @internal
|
|
121
|
-
*/ function
|
|
122
|
-
if (
|
|
123
|
-
const e = n.map(
|
|
124
|
-
|
|
121
|
+
*/ function p(t, ...n) {
|
|
122
|
+
if (f.logLevel <= u.WARN) {
|
|
123
|
+
const e = n.map(y);
|
|
124
|
+
f.warn(`Firestore (${l}): ${t}`, ...e);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* Converts an additional log parameter to a string representation.
|
|
130
|
-
*/ function
|
|
130
|
+
*/ function y(t) {
|
|
131
131
|
if ("string" == typeof t) return t;
|
|
132
132
|
try {
|
|
133
133
|
return n = t, JSON.stringify(n);
|
|
@@ -178,14 +178,14 @@ function p(t, ...n) {
|
|
|
178
178
|
* Returns `never` and can be used in expressions:
|
|
179
179
|
* @example
|
|
180
180
|
* let futureVar = fail('not implemented yet');
|
|
181
|
-
*/ function
|
|
181
|
+
*/ function _(t = "Unexpected state") {
|
|
182
182
|
// Log the failure in addition to throw an exception, just in case the
|
|
183
183
|
// exception is swallowed.
|
|
184
|
-
const n = `FIRESTORE (${
|
|
184
|
+
const n = `FIRESTORE (${l}) INTERNAL ASSERTION FAILED: ` + t;
|
|
185
185
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
186
186
|
// that cannot be handled by the user. (Also it would create a circular
|
|
187
187
|
// dependency between the error and assert modules which doesn't work.)
|
|
188
|
-
throw
|
|
188
|
+
throw m(n), new Error(n);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -193,14 +193,14 @@ function p(t, ...n) {
|
|
|
193
193
|
* given message if it did.
|
|
194
194
|
*
|
|
195
195
|
* Messages are stripped in production builds.
|
|
196
|
-
*/ function
|
|
197
|
-
t ||
|
|
196
|
+
*/ function g(t, n) {
|
|
197
|
+
t || _();
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
* Casts `obj` to `T`. In non-production builds, verifies that `obj` is an
|
|
202
202
|
* instance of `T` before casting.
|
|
203
|
-
*/ function
|
|
203
|
+
*/ function b(t,
|
|
204
204
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
205
|
n) {
|
|
206
206
|
return t;
|
|
@@ -221,9 +221,9 @@ n) {
|
|
|
221
221
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
222
222
|
* See the License for the specific language governing permissions and
|
|
223
223
|
* limitations under the License.
|
|
224
|
-
*/ const
|
|
224
|
+
*/ const v = "ok", E = "cancelled", I = "unknown", T = "invalid-argument", A = "deadline-exceeded", P = "not-found", R = "already-exists", V = "permission-denied", N = "unauthenticated", D = "resource-exhausted", $ = "failed-precondition", F = "aborted", S = "out-of-range", q = "unimplemented", x = "internal", O = "unavailable", C = "data-loss";
|
|
225
225
|
|
|
226
|
-
/** An error returned by a Firestore operation. */ class
|
|
226
|
+
/** An error returned by a Firestore operation. */ class L extends Error {
|
|
227
227
|
/** @hideconstructor */
|
|
228
228
|
constructor(
|
|
229
229
|
/**
|
|
@@ -259,7 +259,7 @@ n) {
|
|
|
259
259
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
260
260
|
* See the License for the specific language governing permissions and
|
|
261
261
|
* limitations under the License.
|
|
262
|
-
*/ class
|
|
262
|
+
*/ class U {
|
|
263
263
|
constructor() {
|
|
264
264
|
this.promise = new Promise(((t, n) => {
|
|
265
265
|
this.resolve = t, this.reject = n;
|
|
@@ -282,7 +282,7 @@ n) {
|
|
|
282
282
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
283
283
|
* See the License for the specific language governing permissions and
|
|
284
284
|
* limitations under the License.
|
|
285
|
-
*/ class
|
|
285
|
+
*/ class j {
|
|
286
286
|
constructor(t, n) {
|
|
287
287
|
this.user = n, this.type = "OAuth", this.authHeaders = {},
|
|
288
288
|
// Set the headers using Object Literal notation to avoid minification
|
|
@@ -290,14 +290,17 @@ n) {
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* A CredentialsProvider that always yields an empty token.
|
|
295
|
+
* @internal
|
|
296
|
+
*/ class k {
|
|
294
297
|
getToken() {
|
|
295
298
|
return Promise.resolve(null);
|
|
296
299
|
}
|
|
297
300
|
invalidateToken() {}
|
|
298
301
|
start(t, n) {
|
|
299
302
|
// Fire with initial user.
|
|
300
|
-
t.enqueueRetryable((() => n(
|
|
303
|
+
t.enqueueRetryable((() => n(h.UNAUTHENTICATED)));
|
|
301
304
|
}
|
|
302
305
|
shutdown() {}
|
|
303
306
|
}
|
|
@@ -305,7 +308,7 @@ n) {
|
|
|
305
308
|
/**
|
|
306
309
|
* A CredentialsProvider that always returns a constant token. Used for
|
|
307
310
|
* emulator token mocking.
|
|
308
|
-
*/ class
|
|
311
|
+
*/ class M {
|
|
309
312
|
constructor(t) {
|
|
310
313
|
this.token = t,
|
|
311
314
|
/**
|
|
@@ -329,15 +332,15 @@ n) {
|
|
|
329
332
|
}
|
|
330
333
|
}
|
|
331
334
|
|
|
332
|
-
/** Credential provider for the Lite SDK. */ class
|
|
335
|
+
/** Credential provider for the Lite SDK. */ class B {
|
|
333
336
|
constructor(t) {
|
|
334
337
|
this.auth = null, t.onInit((t => {
|
|
335
338
|
this.auth = t;
|
|
336
339
|
}));
|
|
337
340
|
}
|
|
338
341
|
getToken() {
|
|
339
|
-
return this.auth ? this.auth.getToken().then((t => t ? (
|
|
340
|
-
new
|
|
342
|
+
return this.auth ? this.auth.getToken().then((t => t ? (g("string" == typeof t.accessToken),
|
|
343
|
+
new j(t.accessToken, new h(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
341
344
|
}
|
|
342
345
|
invalidateToken() {}
|
|
343
346
|
start(t, n) {}
|
|
@@ -350,9 +353,9 @@ n) {
|
|
|
350
353
|
* Technically this may no longer be necessary since the SDK should gracefully
|
|
351
354
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
352
355
|
* safer to keep the implementation as-is.
|
|
353
|
-
*/ class
|
|
356
|
+
*/ class Q {
|
|
354
357
|
constructor(t, n, e) {
|
|
355
|
-
this.t = t, this.i = n, this.o = e, this.type = "FirstParty", this.user =
|
|
358
|
+
this.t = t, this.i = n, this.o = e, this.type = "FirstParty", this.user = h.FIRST_PARTY;
|
|
356
359
|
}
|
|
357
360
|
get authHeaders() {
|
|
358
361
|
const t = {
|
|
@@ -368,16 +371,16 @@ n) {
|
|
|
368
371
|
* Provides user credentials required for the Firestore JavaScript SDK
|
|
369
372
|
* to authenticate the user, using technique that is only available
|
|
370
373
|
* to applications hosted by Google.
|
|
371
|
-
*/ class
|
|
374
|
+
*/ class z {
|
|
372
375
|
constructor(t, n, e) {
|
|
373
376
|
this.t = t, this.i = n, this.o = e;
|
|
374
377
|
}
|
|
375
378
|
getToken() {
|
|
376
|
-
return Promise.resolve(new
|
|
379
|
+
return Promise.resolve(new Q(this.t, this.i, this.o));
|
|
377
380
|
}
|
|
378
381
|
start(t, n) {
|
|
379
382
|
// Fire with initial uid.
|
|
380
|
-
t.enqueueRetryable((() => n(
|
|
383
|
+
t.enqueueRetryable((() => n(h.FIRST_PARTY)));
|
|
381
384
|
}
|
|
382
385
|
shutdown() {}
|
|
383
386
|
invalidateToken() {}
|
|
@@ -403,7 +406,7 @@ n) {
|
|
|
403
406
|
* See the License for the specific language governing permissions and
|
|
404
407
|
* limitations under the License.
|
|
405
408
|
*/
|
|
406
|
-
class
|
|
409
|
+
class W {
|
|
407
410
|
/**
|
|
408
411
|
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
409
412
|
* persistenceKey.
|
|
@@ -432,7 +435,7 @@ class G {
|
|
|
432
435
|
* Represents the database ID a Firestore client is associated with.
|
|
433
436
|
* @internal
|
|
434
437
|
*/
|
|
435
|
-
class
|
|
438
|
+
class G {
|
|
436
439
|
constructor(t, n) {
|
|
437
440
|
this.projectId = t, this.database = n || "(default)";
|
|
438
441
|
}
|
|
@@ -440,7 +443,7 @@ class H {
|
|
|
440
443
|
return "(default)" === this.database;
|
|
441
444
|
}
|
|
442
445
|
isEqual(t) {
|
|
443
|
-
return t instanceof
|
|
446
|
+
return t instanceof G && t.projectId === this.projectId && t.database === this.database;
|
|
444
447
|
}
|
|
445
448
|
}
|
|
446
449
|
|
|
@@ -463,20 +466,20 @@ class H {
|
|
|
463
466
|
/**
|
|
464
467
|
* Path represents an ordered sequence of string segments.
|
|
465
468
|
*/
|
|
466
|
-
class
|
|
469
|
+
class H {
|
|
467
470
|
constructor(t, n, e) {
|
|
468
|
-
void 0 === n ? n = 0 : n > t.length &&
|
|
471
|
+
void 0 === n ? n = 0 : n > t.length && _(), void 0 === e ? e = t.length - n : e > t.length - n && _(),
|
|
469
472
|
this.segments = t, this.offset = n, this.len = e;
|
|
470
473
|
}
|
|
471
474
|
get length() {
|
|
472
475
|
return this.len;
|
|
473
476
|
}
|
|
474
477
|
isEqual(t) {
|
|
475
|
-
return 0 ===
|
|
478
|
+
return 0 === H.comparator(this, t);
|
|
476
479
|
}
|
|
477
480
|
child(t) {
|
|
478
481
|
const n = this.segments.slice(this.offset, this.limit());
|
|
479
|
-
return t instanceof
|
|
482
|
+
return t instanceof H ? t.forEach((t => {
|
|
480
483
|
n.push(t);
|
|
481
484
|
})) : n.push(t), this.construct(n);
|
|
482
485
|
}
|
|
@@ -533,9 +536,9 @@ class Y {
|
|
|
533
536
|
* within Firestore.
|
|
534
537
|
*
|
|
535
538
|
* @internal
|
|
536
|
-
*/ class
|
|
539
|
+
*/ class Y extends H {
|
|
537
540
|
construct(t, n, e) {
|
|
538
|
-
return new
|
|
541
|
+
return new Y(t, n, e);
|
|
539
542
|
}
|
|
540
543
|
canonicalString() {
|
|
541
544
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -556,35 +559,35 @@ class Y {
|
|
|
556
559
|
// for legacy reasons and should not be used frequently).
|
|
557
560
|
const n = [];
|
|
558
561
|
for (const e of t) {
|
|
559
|
-
if (e.indexOf("//") >= 0) throw new
|
|
562
|
+
if (e.indexOf("//") >= 0) throw new L(T, `Invalid segment (${e}). Paths must not contain // in them.`);
|
|
560
563
|
// Strip leading and traling slashed.
|
|
561
564
|
n.push(...e.split("/").filter((t => t.length > 0)));
|
|
562
565
|
}
|
|
563
|
-
return new
|
|
566
|
+
return new Y(n);
|
|
564
567
|
}
|
|
565
568
|
static emptyPath() {
|
|
566
|
-
return new
|
|
569
|
+
return new Y([]);
|
|
567
570
|
}
|
|
568
571
|
}
|
|
569
572
|
|
|
570
|
-
const
|
|
573
|
+
const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
571
574
|
|
|
572
575
|
/**
|
|
573
576
|
* A dot-separated path for navigating sub-objects within a document.
|
|
574
577
|
* @internal
|
|
575
|
-
*/ class
|
|
578
|
+
*/ class J extends H {
|
|
576
579
|
construct(t, n, e) {
|
|
577
|
-
return new
|
|
580
|
+
return new J(t, n, e);
|
|
578
581
|
}
|
|
579
582
|
/**
|
|
580
583
|
* Returns true if the string could be used as a segment in a field path
|
|
581
584
|
* without escaping.
|
|
582
585
|
*/ static isValidIdentifier(t) {
|
|
583
|
-
return
|
|
586
|
+
return K.test(t);
|
|
584
587
|
}
|
|
585
588
|
canonicalString() {
|
|
586
589
|
return this.toArray().map((t => (t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"),
|
|
587
|
-
|
|
590
|
+
J.isValidIdentifier(t) || (t = "`" + t + "`"), t))).join(".");
|
|
588
591
|
}
|
|
589
592
|
toString() {
|
|
590
593
|
return this.canonicalString();
|
|
@@ -597,7 +600,7 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
597
600
|
/**
|
|
598
601
|
* The field designating the key of a document.
|
|
599
602
|
*/ static keyField() {
|
|
600
|
-
return new
|
|
603
|
+
return new J([ "__name__" ]);
|
|
601
604
|
}
|
|
602
605
|
/**
|
|
603
606
|
* Parses a field string from the given server-formatted string.
|
|
@@ -612,24 +615,24 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
612
615
|
const n = [];
|
|
613
616
|
let e = "", r = 0;
|
|
614
617
|
const s = () => {
|
|
615
|
-
if (0 === e.length) throw new
|
|
618
|
+
if (0 === e.length) throw new L(T, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
616
619
|
n.push(e), e = "";
|
|
617
620
|
};
|
|
618
621
|
let i = !1;
|
|
619
622
|
for (;r < t.length; ) {
|
|
620
623
|
const n = t[r];
|
|
621
624
|
if ("\\" === n) {
|
|
622
|
-
if (r + 1 === t.length) throw new
|
|
625
|
+
if (r + 1 === t.length) throw new L(T, "Path has trailing escape character: " + t);
|
|
623
626
|
const n = t[r + 1];
|
|
624
|
-
if ("\\" !== n && "." !== n && "`" !== n) throw new
|
|
627
|
+
if ("\\" !== n && "." !== n && "`" !== n) throw new L(T, "Path has invalid escape sequence: " + t);
|
|
625
628
|
e += n, r += 2;
|
|
626
629
|
} else "`" === n ? (i = !i, r++) : "." !== n || i ? (e += n, r++) : (s(), r++);
|
|
627
630
|
}
|
|
628
|
-
if (s(), i) throw new
|
|
629
|
-
return new
|
|
631
|
+
if (s(), i) throw new L(T, "Unterminated ` in path: " + t);
|
|
632
|
+
return new J(n);
|
|
630
633
|
}
|
|
631
634
|
static emptyPath() {
|
|
632
|
-
return new
|
|
635
|
+
return new J([]);
|
|
633
636
|
}
|
|
634
637
|
}
|
|
635
638
|
|
|
@@ -651,27 +654,27 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
651
654
|
*/
|
|
652
655
|
/**
|
|
653
656
|
* @internal
|
|
654
|
-
*/ class
|
|
657
|
+
*/ class Z {
|
|
655
658
|
constructor(t) {
|
|
656
659
|
this.path = t;
|
|
657
660
|
}
|
|
658
661
|
static fromPath(t) {
|
|
659
|
-
return new
|
|
662
|
+
return new Z(Y.fromString(t));
|
|
660
663
|
}
|
|
661
664
|
static fromName(t) {
|
|
662
|
-
return new
|
|
665
|
+
return new Z(Y.fromString(t).popFirst(5));
|
|
663
666
|
}
|
|
664
667
|
/** Returns true if the document is in the specified collectionId. */ hasCollectionId(t) {
|
|
665
668
|
return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;
|
|
666
669
|
}
|
|
667
670
|
isEqual(t) {
|
|
668
|
-
return null !== t && 0 ===
|
|
671
|
+
return null !== t && 0 === Y.comparator(this.path, t.path);
|
|
669
672
|
}
|
|
670
673
|
toString() {
|
|
671
674
|
return this.path.toString();
|
|
672
675
|
}
|
|
673
676
|
static comparator(t, n) {
|
|
674
|
-
return
|
|
677
|
+
return Y.comparator(t.path, n.path);
|
|
675
678
|
}
|
|
676
679
|
static isDocumentKey(t) {
|
|
677
680
|
return t.length % 2 == 0;
|
|
@@ -682,7 +685,7 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
682
685
|
* @param segments - The segments of the path to the document
|
|
683
686
|
* @returns A new instance of DocumentKey
|
|
684
687
|
*/ static fromSegments(t) {
|
|
685
|
-
return new
|
|
688
|
+
return new Z(new Y(t.slice()));
|
|
686
689
|
}
|
|
687
690
|
}
|
|
688
691
|
|
|
@@ -701,8 +704,8 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
701
704
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
702
705
|
* See the License for the specific language governing permissions and
|
|
703
706
|
* limitations under the License.
|
|
704
|
-
*/ function
|
|
705
|
-
if (!e) throw new
|
|
707
|
+
*/ function X(t, n, e) {
|
|
708
|
+
if (!e) throw new L(T, `Function ${t}() cannot be called with an empty ${n}.`);
|
|
706
709
|
}
|
|
707
710
|
|
|
708
711
|
/**
|
|
@@ -713,15 +716,15 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
713
716
|
* Validates that `path` refers to a document (indicated by the fact it contains
|
|
714
717
|
* an even numbers of segments).
|
|
715
718
|
*/
|
|
716
|
-
function
|
|
717
|
-
if (!
|
|
719
|
+
function tt(t) {
|
|
720
|
+
if (!Z.isDocumentKey(t)) throw new L(T, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
718
721
|
}
|
|
719
722
|
|
|
720
723
|
/**
|
|
721
724
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
722
725
|
* contains an odd numbers of segments).
|
|
723
|
-
*/ function
|
|
724
|
-
if (
|
|
726
|
+
*/ function nt(t) {
|
|
727
|
+
if (Z.isDocumentKey(t)) throw new L(T, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
725
728
|
}
|
|
726
729
|
|
|
727
730
|
/**
|
|
@@ -729,7 +732,7 @@ function nt(t) {
|
|
|
729
732
|
* (i.e. excludes Array, Date, etc.).
|
|
730
733
|
*/
|
|
731
734
|
/** Returns a string describing the type / value of the provided input. */
|
|
732
|
-
function
|
|
735
|
+
function et(t) {
|
|
733
736
|
if (void 0 === t) return "undefined";
|
|
734
737
|
if (null === t) return "null";
|
|
735
738
|
if ("string" == typeof t) return t.length > 20 && (t = `${t.substring(0, 20)}...`),
|
|
@@ -758,27 +761,27 @@ function rt(t) {
|
|
|
758
761
|
return n ? `a custom ${n} object` : "an object";
|
|
759
762
|
}
|
|
760
763
|
}
|
|
761
|
-
return "function" == typeof t ? "a function" :
|
|
764
|
+
return "function" == typeof t ? "a function" : _();
|
|
762
765
|
}
|
|
763
766
|
|
|
764
|
-
function
|
|
767
|
+
function rt(t,
|
|
765
768
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
766
769
|
n) {
|
|
767
770
|
if ("_delegate" in t && (
|
|
768
771
|
// Unwrap Compat types
|
|
769
772
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
770
773
|
t = t._delegate), !(t instanceof n)) {
|
|
771
|
-
if (n.name === t.constructor.name) throw new
|
|
774
|
+
if (n.name === t.constructor.name) throw new L(T, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
772
775
|
{
|
|
773
|
-
const e =
|
|
774
|
-
throw new
|
|
776
|
+
const e = et(t);
|
|
777
|
+
throw new L(T, `Expected type '${n.name}', but it was: ${e}`);
|
|
775
778
|
}
|
|
776
779
|
}
|
|
777
780
|
return t;
|
|
778
781
|
}
|
|
779
782
|
|
|
780
|
-
function
|
|
781
|
-
if (n <= 0) throw new
|
|
783
|
+
function st(t, n) {
|
|
784
|
+
if (n <= 0) throw new L(T, `Function ${t}() requires a positive number, but it was: ${n}.`);
|
|
782
785
|
}
|
|
783
786
|
|
|
784
787
|
/**
|
|
@@ -799,11 +802,11 @@ function it(t, n) {
|
|
|
799
802
|
*/
|
|
800
803
|
/**
|
|
801
804
|
* Returns whether a variable is either undefined or null.
|
|
802
|
-
*/ function
|
|
805
|
+
*/ function it(t) {
|
|
803
806
|
return null == t;
|
|
804
807
|
}
|
|
805
808
|
|
|
806
|
-
/** Returns whether the value represents -0. */ function
|
|
809
|
+
/** Returns whether the value represents -0. */ function ot(t) {
|
|
807
810
|
// Detect if the value is -0.0. Based on polyfill from
|
|
808
811
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
809
812
|
return 0 === t && 1 / t == -1 / 0;
|
|
@@ -829,7 +832,7 @@ function it(t, n) {
|
|
|
829
832
|
* See the License for the specific language governing permissions and
|
|
830
833
|
* limitations under the License.
|
|
831
834
|
*/
|
|
832
|
-
const
|
|
835
|
+
const ut = {
|
|
833
836
|
BatchGetDocuments: "batchGet",
|
|
834
837
|
Commit: "commit",
|
|
835
838
|
RunQuery: "runQuery"
|
|
@@ -866,7 +869,7 @@ const ct = {
|
|
|
866
869
|
* are used for reverse lookups from the webchannel stream. Do NOT change the
|
|
867
870
|
* names of these identifiers or change this into a const enum.
|
|
868
871
|
*/
|
|
869
|
-
var
|
|
872
|
+
var ct, at;
|
|
870
873
|
|
|
871
874
|
/**
|
|
872
875
|
* Converts an HTTP Status Code to the equivalent error code.
|
|
@@ -875,8 +878,8 @@ var at, ht;
|
|
|
875
878
|
* @returns The equivalent Code. Unknown status codes are mapped to
|
|
876
879
|
* Code.UNKNOWN.
|
|
877
880
|
*/
|
|
878
|
-
function
|
|
879
|
-
if (void 0 === t) return
|
|
881
|
+
function ht(t) {
|
|
882
|
+
if (void 0 === t) return m("RPC_ERROR", "HTTP error has no status"), I;
|
|
880
883
|
// The canonical error codes for Google APIs [1] specify mapping onto HTTP
|
|
881
884
|
// status codes but the mapping is not bijective. In each case of ambiguity
|
|
882
885
|
// this function chooses a primary error.
|
|
@@ -886,66 +889,66 @@ function lt(t) {
|
|
|
886
889
|
switch (t) {
|
|
887
890
|
case 200:
|
|
888
891
|
// OK
|
|
889
|
-
return
|
|
892
|
+
return v;
|
|
890
893
|
|
|
891
894
|
case 400:
|
|
892
895
|
// Bad Request
|
|
893
|
-
return
|
|
896
|
+
return $;
|
|
894
897
|
|
|
895
898
|
// Other possibilities based on the forward mapping
|
|
896
899
|
// return Code.INVALID_ARGUMENT;
|
|
897
900
|
// return Code.OUT_OF_RANGE;
|
|
898
901
|
case 401:
|
|
899
902
|
// Unauthorized
|
|
900
|
-
return
|
|
903
|
+
return N;
|
|
901
904
|
|
|
902
905
|
case 403:
|
|
903
906
|
// Forbidden
|
|
904
|
-
return
|
|
907
|
+
return V;
|
|
905
908
|
|
|
906
909
|
case 404:
|
|
907
910
|
// Not Found
|
|
908
|
-
return
|
|
911
|
+
return P;
|
|
909
912
|
|
|
910
913
|
case 409:
|
|
911
914
|
// Conflict
|
|
912
|
-
return
|
|
915
|
+
return F;
|
|
913
916
|
|
|
914
917
|
// Other possibilities:
|
|
915
918
|
// return Code.ALREADY_EXISTS;
|
|
916
919
|
case 416:
|
|
917
920
|
// Range Not Satisfiable
|
|
918
|
-
return
|
|
921
|
+
return S;
|
|
919
922
|
|
|
920
923
|
case 429:
|
|
921
924
|
// Too Many Requests
|
|
922
|
-
return
|
|
925
|
+
return D;
|
|
923
926
|
|
|
924
927
|
case 499:
|
|
925
928
|
// Client Closed Request
|
|
926
|
-
return
|
|
929
|
+
return E;
|
|
927
930
|
|
|
928
931
|
case 500:
|
|
929
932
|
// Internal Server Error
|
|
930
|
-
return
|
|
933
|
+
return I;
|
|
931
934
|
|
|
932
935
|
// Other possibilities:
|
|
933
936
|
// return Code.INTERNAL;
|
|
934
937
|
// return Code.DATA_LOSS;
|
|
935
938
|
case 501:
|
|
936
939
|
// Unimplemented
|
|
937
|
-
return
|
|
940
|
+
return q;
|
|
938
941
|
|
|
939
942
|
case 503:
|
|
940
943
|
// Service Unavailable
|
|
941
|
-
return
|
|
944
|
+
return O;
|
|
942
945
|
|
|
943
946
|
case 504:
|
|
944
947
|
// Gateway Timeout
|
|
945
|
-
return
|
|
948
|
+
return A;
|
|
946
949
|
|
|
947
950
|
default:
|
|
948
|
-
return t >= 200 && t < 300 ?
|
|
951
|
+
return t >= 200 && t < 300 ? v : t >= 400 && t < 500 ? $ : t >= 500 && t < 600 ? x : I;
|
|
949
952
|
}
|
|
950
953
|
}
|
|
951
954
|
|
|
@@ -968,16 +971,16 @@ function lt(t) {
|
|
|
968
971
|
/**
|
|
969
972
|
* A Rest-based connection that relies on the native HTTP stack
|
|
970
973
|
* (e.g. `fetch` or a polyfill).
|
|
971
|
-
*/ (
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
974
|
+
*/ (at = ct || (ct = {}))[at.OK = 0] = "OK", at[at.CANCELLED = 1] = "CANCELLED",
|
|
975
|
+
at[at.UNKNOWN = 2] = "UNKNOWN", at[at.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT",
|
|
976
|
+
at[at.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED", at[at.NOT_FOUND = 5] = "NOT_FOUND",
|
|
977
|
+
at[at.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", at[at.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
|
|
978
|
+
at[at.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", at[at.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
|
|
979
|
+
at[at.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", at[at.ABORTED = 10] = "ABORTED",
|
|
980
|
+
at[at.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", at[at.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
|
|
981
|
+
at[at.INTERNAL = 13] = "INTERNAL", at[at.UNAVAILABLE = 14] = "UNAVAILABLE", at[at.DATA_LOSS = 15] = "DATA_LOSS";
|
|
979
982
|
|
|
980
|
-
class
|
|
983
|
+
class lt extends
|
|
981
984
|
/**
|
|
982
985
|
* Base class for all Rest-based connections to the backend (WebChannel and
|
|
983
986
|
* HTTP).
|
|
@@ -990,11 +993,11 @@ class {
|
|
|
990
993
|
}
|
|
991
994
|
l(t, n, e, r) {
|
|
992
995
|
const s = this.m(t, n);
|
|
993
|
-
|
|
996
|
+
w("RestConnection", "Sending: ", s, e);
|
|
994
997
|
const i = {};
|
|
995
|
-
return this.p(i, r), this.g(t, s, i, e).then((t => (
|
|
998
|
+
return this.p(i, r), this.g(t, s, i, e).then((t => (w("RestConnection", "Received: ", t),
|
|
996
999
|
t)), (n => {
|
|
997
|
-
throw
|
|
1000
|
+
throw p("RestConnection", `${t} failed with error: `, n, "url: ", s, "request:", e),
|
|
998
1001
|
n;
|
|
999
1002
|
}));
|
|
1000
1003
|
}
|
|
@@ -1007,7 +1010,7 @@ class {
|
|
|
1007
1010
|
* Modifies the headers for a request, adding any authorization token if
|
|
1008
1011
|
* present and any additional headers for the request.
|
|
1009
1012
|
*/ p(t, n) {
|
|
1010
|
-
if (t["X-Goog-Api-Client"] = "gl-js/ fire/" +
|
|
1013
|
+
if (t["X-Goog-Api-Client"] = "gl-js/ fire/" + l,
|
|
1011
1014
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1012
1015
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1013
1016
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
@@ -1016,7 +1019,7 @@ class {
|
|
|
1016
1019
|
n) for (const e in n.authHeaders) n.authHeaders.hasOwnProperty(e) && (t[e] = n.authHeaders[e]);
|
|
1017
1020
|
}
|
|
1018
1021
|
m(t, n) {
|
|
1019
|
-
const e =
|
|
1022
|
+
const e = ut[t];
|
|
1020
1023
|
return `${this.u}/v1/${n}:${e}`;
|
|
1021
1024
|
}
|
|
1022
1025
|
} {
|
|
@@ -1040,9 +1043,9 @@ class {
|
|
|
1040
1043
|
body: s
|
|
1041
1044
|
});
|
|
1042
1045
|
} catch (t) {
|
|
1043
|
-
throw new
|
|
1046
|
+
throw new L(ht(t.status), "Request failed with error: " + t.statusText);
|
|
1044
1047
|
}
|
|
1045
|
-
if (!i.ok) throw new
|
|
1048
|
+
if (!i.ok) throw new L(ht(i.status), "Request failed with error: " + i.statusText);
|
|
1046
1049
|
return i.json();
|
|
1047
1050
|
}
|
|
1048
1051
|
}
|
|
@@ -1085,7 +1088,7 @@ class {
|
|
|
1085
1088
|
*
|
|
1086
1089
|
* If `nBytes < 0` , an error will be thrown.
|
|
1087
1090
|
*/
|
|
1088
|
-
function
|
|
1091
|
+
function ft(t) {
|
|
1089
1092
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1090
1093
|
const n =
|
|
1091
1094
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1111,14 +1114,14 @@ function dt(t) {
|
|
|
1111
1114
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1112
1115
|
* See the License for the specific language governing permissions and
|
|
1113
1116
|
* limitations under the License.
|
|
1114
|
-
*/ class
|
|
1117
|
+
*/ class dt {
|
|
1115
1118
|
static A() {
|
|
1116
1119
|
// Alphanumeric characters
|
|
1117
1120
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = Math.floor(256 / t.length) * t.length;
|
|
1118
1121
|
// The largest byte value that is a multiple of `char.length`.
|
|
1119
1122
|
let e = "";
|
|
1120
1123
|
for (;e.length < 20; ) {
|
|
1121
|
-
const r =
|
|
1124
|
+
const r = ft(40);
|
|
1122
1125
|
for (let s = 0; s < r.length; ++s)
|
|
1123
1126
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1124
1127
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
@@ -1128,11 +1131,11 @@ function dt(t) {
|
|
|
1128
1131
|
}
|
|
1129
1132
|
}
|
|
1130
1133
|
|
|
1131
|
-
function
|
|
1134
|
+
function wt(t, n) {
|
|
1132
1135
|
return t < n ? -1 : t > n ? 1 : 0;
|
|
1133
1136
|
}
|
|
1134
1137
|
|
|
1135
|
-
/** Helper to compare arrays using isEqual(). */ function
|
|
1138
|
+
/** Helper to compare arrays using isEqual(). */ function mt(t, n, e) {
|
|
1136
1139
|
return t.length === n.length && t.every(((t, r) => e(t, n[r])));
|
|
1137
1140
|
}
|
|
1138
1141
|
|
|
@@ -1167,7 +1170,7 @@ function mt(t, n) {
|
|
|
1167
1170
|
* For examples and further specifications, refer to the
|
|
1168
1171
|
* {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
|
|
1169
1172
|
*/
|
|
1170
|
-
class
|
|
1173
|
+
class pt {
|
|
1171
1174
|
/**
|
|
1172
1175
|
* Creates a new timestamp.
|
|
1173
1176
|
*
|
|
@@ -1188,18 +1191,18 @@ class yt {
|
|
|
1188
1191
|
* The fractions of a second at nanosecond resolution.*
|
|
1189
1192
|
*/
|
|
1190
1193
|
n) {
|
|
1191
|
-
if (this.seconds = t, this.nanoseconds = n, n < 0) throw new
|
|
1192
|
-
if (n >= 1e9) throw new
|
|
1193
|
-
if (t < -62135596800) throw new
|
|
1194
|
+
if (this.seconds = t, this.nanoseconds = n, n < 0) throw new L(T, "Timestamp nanoseconds out of range: " + n);
|
|
1195
|
+
if (n >= 1e9) throw new L(T, "Timestamp nanoseconds out of range: " + n);
|
|
1196
|
+
if (t < -62135596800) throw new L(T, "Timestamp seconds out of range: " + t);
|
|
1194
1197
|
// This will break in the year 10,000.
|
|
1195
|
-
if (t >= 253402300800) throw new
|
|
1198
|
+
if (t >= 253402300800) throw new L(T, "Timestamp seconds out of range: " + t);
|
|
1196
1199
|
}
|
|
1197
1200
|
/**
|
|
1198
1201
|
* Creates a new timestamp with the current date, with millisecond precision.
|
|
1199
1202
|
*
|
|
1200
1203
|
* @returns a new timestamp representing the current date.
|
|
1201
1204
|
*/ static now() {
|
|
1202
|
-
return
|
|
1205
|
+
return pt.fromMillis(Date.now());
|
|
1203
1206
|
}
|
|
1204
1207
|
/**
|
|
1205
1208
|
* Creates a new timestamp from the given date.
|
|
@@ -1208,7 +1211,7 @@ class yt {
|
|
|
1208
1211
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1209
1212
|
* date.
|
|
1210
1213
|
*/ static fromDate(t) {
|
|
1211
|
-
return
|
|
1214
|
+
return pt.fromMillis(t.getTime());
|
|
1212
1215
|
}
|
|
1213
1216
|
/**
|
|
1214
1217
|
* Creates a new timestamp from the given number of milliseconds.
|
|
@@ -1219,7 +1222,7 @@ class yt {
|
|
|
1219
1222
|
* number of milliseconds.
|
|
1220
1223
|
*/ static fromMillis(t) {
|
|
1221
1224
|
const n = Math.floor(t / 1e3), e = Math.floor(1e6 * (t - 1e3 * n));
|
|
1222
|
-
return new
|
|
1225
|
+
return new pt(n, e);
|
|
1223
1226
|
}
|
|
1224
1227
|
/**
|
|
1225
1228
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1241,7 +1244,7 @@ class yt {
|
|
|
1241
1244
|
return 1e3 * this.seconds + this.nanoseconds / 1e6;
|
|
1242
1245
|
}
|
|
1243
1246
|
_compareTo(t) {
|
|
1244
|
-
return this.seconds === t.seconds ?
|
|
1247
|
+
return this.seconds === t.seconds ? wt(this.nanoseconds, t.nanoseconds) : wt(this.seconds, t.seconds);
|
|
1245
1248
|
}
|
|
1246
1249
|
/**
|
|
1247
1250
|
* Returns true if this `Timestamp` is equal to the provided one.
|
|
@@ -1297,15 +1300,15 @@ class yt {
|
|
|
1297
1300
|
/**
|
|
1298
1301
|
* A version of a document in Firestore. This corresponds to the version
|
|
1299
1302
|
* timestamp, such as update_time or read_time.
|
|
1300
|
-
*/ class
|
|
1303
|
+
*/ class yt {
|
|
1301
1304
|
constructor(t) {
|
|
1302
1305
|
this.timestamp = t;
|
|
1303
1306
|
}
|
|
1304
1307
|
static fromTimestamp(t) {
|
|
1305
|
-
return new
|
|
1308
|
+
return new yt(t);
|
|
1306
1309
|
}
|
|
1307
1310
|
static min() {
|
|
1308
|
-
return new
|
|
1311
|
+
return new yt(new pt(0, 0));
|
|
1309
1312
|
}
|
|
1310
1313
|
compareTo(t) {
|
|
1311
1314
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1340,13 +1343,13 @@ class yt {
|
|
|
1340
1343
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1341
1344
|
* See the License for the specific language governing permissions and
|
|
1342
1345
|
* limitations under the License.
|
|
1343
|
-
*/ function
|
|
1346
|
+
*/ function _t(t) {
|
|
1344
1347
|
let n = 0;
|
|
1345
1348
|
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n++;
|
|
1346
1349
|
return n;
|
|
1347
1350
|
}
|
|
1348
1351
|
|
|
1349
|
-
function
|
|
1352
|
+
function gt(t, n) {
|
|
1350
1353
|
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n(e, t[e]);
|
|
1351
1354
|
}
|
|
1352
1355
|
|
|
@@ -1376,12 +1379,12 @@ function bt(t, n) {
|
|
|
1376
1379
|
* If foo is not an object, foo is replaced with an object
|
|
1377
1380
|
* containing foo
|
|
1378
1381
|
*/
|
|
1379
|
-
class
|
|
1382
|
+
class bt {
|
|
1380
1383
|
constructor(t) {
|
|
1381
1384
|
this.fields = t,
|
|
1382
1385
|
// TODO(dimond): validation of FieldMask
|
|
1383
1386
|
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
|
|
1384
|
-
t.sort(
|
|
1387
|
+
t.sort(J.comparator);
|
|
1385
1388
|
}
|
|
1386
1389
|
/**
|
|
1387
1390
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
@@ -1393,7 +1396,7 @@ class vt {
|
|
|
1393
1396
|
return !1;
|
|
1394
1397
|
}
|
|
1395
1398
|
isEqual(t) {
|
|
1396
|
-
return
|
|
1399
|
+
return mt(this.fields, t.fields, ((t, n) => t.isEqual(n)));
|
|
1397
1400
|
}
|
|
1398
1401
|
}
|
|
1399
1402
|
|
|
@@ -1439,13 +1442,13 @@ class vt {
|
|
|
1439
1442
|
* before being sent as a proto.
|
|
1440
1443
|
* @internal
|
|
1441
1444
|
*/
|
|
1442
|
-
class
|
|
1445
|
+
class vt {
|
|
1443
1446
|
constructor(t) {
|
|
1444
1447
|
this.binaryString = t;
|
|
1445
1448
|
}
|
|
1446
1449
|
static fromBase64String(t) {
|
|
1447
1450
|
const n = atob(t);
|
|
1448
|
-
return new
|
|
1451
|
+
return new vt(n);
|
|
1449
1452
|
}
|
|
1450
1453
|
static fromUint8Array(t) {
|
|
1451
1454
|
const n =
|
|
@@ -1460,7 +1463,7 @@ class Et {
|
|
|
1460
1463
|
/**
|
|
1461
1464
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1462
1465
|
*/ (t);
|
|
1463
|
-
return new
|
|
1466
|
+
return new vt(n);
|
|
1464
1467
|
}
|
|
1465
1468
|
toBase64() {
|
|
1466
1469
|
return t = this.binaryString, btoa(t);
|
|
@@ -1496,31 +1499,31 @@ class Et {
|
|
|
1496
1499
|
return 2 * this.binaryString.length;
|
|
1497
1500
|
}
|
|
1498
1501
|
compareTo(t) {
|
|
1499
|
-
return
|
|
1502
|
+
return wt(this.binaryString, t.binaryString);
|
|
1500
1503
|
}
|
|
1501
1504
|
isEqual(t) {
|
|
1502
1505
|
return this.binaryString === t.binaryString;
|
|
1503
1506
|
}
|
|
1504
1507
|
}
|
|
1505
1508
|
|
|
1506
|
-
|
|
1509
|
+
vt.EMPTY_BYTE_STRING = new vt("");
|
|
1507
1510
|
|
|
1508
|
-
const
|
|
1511
|
+
const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
1509
1512
|
|
|
1510
1513
|
/**
|
|
1511
1514
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
1512
1515
|
* nanos" representation.
|
|
1513
|
-
*/ function
|
|
1516
|
+
*/ function It(t) {
|
|
1514
1517
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1515
1518
|
// while the proto js library (for node) will return a
|
|
1516
1519
|
// google.protobuf.Timestamp instance.
|
|
1517
|
-
if (
|
|
1520
|
+
if (g(!!t), "string" == typeof t) {
|
|
1518
1521
|
// The date string can have higher precision (nanos) than the Date class
|
|
1519
1522
|
// (millis), so we do some custom parsing here.
|
|
1520
1523
|
// Parse the nanos right out of the string.
|
|
1521
1524
|
let n = 0;
|
|
1522
|
-
const e =
|
|
1523
|
-
if (
|
|
1525
|
+
const e = Et.exec(t);
|
|
1526
|
+
if (g(!!e), e[1]) {
|
|
1524
1527
|
// Pad the fraction out to 9 digits (nanos).
|
|
1525
1528
|
let t = e[1];
|
|
1526
1529
|
t = (t + "000000000").substr(0, 9), n = Number(t);
|
|
@@ -1533,21 +1536,21 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1533
1536
|
};
|
|
1534
1537
|
}
|
|
1535
1538
|
return {
|
|
1536
|
-
seconds:
|
|
1537
|
-
nanos:
|
|
1539
|
+
seconds: Tt(t.seconds),
|
|
1540
|
+
nanos: Tt(t.nanos)
|
|
1538
1541
|
};
|
|
1539
1542
|
}
|
|
1540
1543
|
|
|
1541
1544
|
/**
|
|
1542
1545
|
* Converts the possible Proto types for numbers into a JavaScript number.
|
|
1543
1546
|
* Returns 0 if the value is not numeric.
|
|
1544
|
-
*/ function
|
|
1547
|
+
*/ function Tt(t) {
|
|
1545
1548
|
// TODO(bjornick): Handle int64 greater than 53 bits.
|
|
1546
1549
|
return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
|
|
1547
1550
|
}
|
|
1548
1551
|
|
|
1549
|
-
/** Converts the possible Proto types for Blobs into a ByteString. */ function
|
|
1550
|
-
return "string" == typeof t ?
|
|
1552
|
+
/** Converts the possible Proto types for Blobs into a ByteString. */ function At(t) {
|
|
1553
|
+
return "string" == typeof t ? vt.fromBase64String(t) : vt.fromUint8Array(t);
|
|
1551
1554
|
}
|
|
1552
1555
|
|
|
1553
1556
|
/**
|
|
@@ -1583,7 +1586,7 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1583
1586
|
* FieldValueOptions to value().
|
|
1584
1587
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1585
1588
|
* localWriteTime.
|
|
1586
|
-
*/ function
|
|
1589
|
+
*/ function Pt(t) {
|
|
1587
1590
|
var n, e;
|
|
1588
1591
|
return "server_timestamp" === (null === (e = ((null === (n = null == t ? void 0 : t.mapValue) || void 0 === n ? void 0 : n.fields) || {}).__type__) || void 0 === e ? void 0 : e.stringValue);
|
|
1589
1592
|
}
|
|
@@ -1593,16 +1596,16 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1593
1596
|
*
|
|
1594
1597
|
* Preserving the previous values allows the user to display the last resoled
|
|
1595
1598
|
* value until the backend responds with the timestamp.
|
|
1596
|
-
*/ function
|
|
1599
|
+
*/ function Rt(t) {
|
|
1597
1600
|
const n = t.mapValue.fields.__previous_value__;
|
|
1598
|
-
return
|
|
1601
|
+
return Pt(n) ? Rt(n) : n;
|
|
1599
1602
|
}
|
|
1600
1603
|
|
|
1601
1604
|
/**
|
|
1602
1605
|
* Returns the local time at which this timestamp was first set.
|
|
1603
|
-
*/ function
|
|
1604
|
-
const n =
|
|
1605
|
-
return new
|
|
1606
|
+
*/ function Vt(t) {
|
|
1607
|
+
const n = It(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1608
|
+
return new pt(n.seconds, n.nanos);
|
|
1606
1609
|
}
|
|
1607
1610
|
|
|
1608
1611
|
/**
|
|
@@ -1621,13 +1624,13 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1621
1624
|
* See the License for the specific language governing permissions and
|
|
1622
1625
|
* limitations under the License.
|
|
1623
1626
|
*/
|
|
1624
|
-
/** Extracts the backend's type order for the provided value. */ function
|
|
1625
|
-
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ?
|
|
1627
|
+
/** Extracts the backend's type order for the provided value. */ function Nt(t) {
|
|
1628
|
+
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ? Pt(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : _();
|
|
1626
1629
|
}
|
|
1627
1630
|
|
|
1628
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function
|
|
1629
|
-
const e =
|
|
1630
|
-
if (e !==
|
|
1631
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Dt(t, n) {
|
|
1632
|
+
const e = Nt(t);
|
|
1633
|
+
if (e !== Nt(n)) return !1;
|
|
1631
1634
|
switch (e) {
|
|
1632
1635
|
case 0 /* NullValue */ :
|
|
1633
1636
|
return !0;
|
|
@@ -1636,14 +1639,14 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1636
1639
|
return t.booleanValue === n.booleanValue;
|
|
1637
1640
|
|
|
1638
1641
|
case 4 /* ServerTimestampValue */ :
|
|
1639
|
-
return
|
|
1642
|
+
return Vt(t).isEqual(Vt(n));
|
|
1640
1643
|
|
|
1641
1644
|
case 3 /* TimestampValue */ :
|
|
1642
1645
|
return function(t, n) {
|
|
1643
1646
|
if ("string" == typeof t.timestampValue && "string" == typeof n.timestampValue && t.timestampValue.length === n.timestampValue.length)
|
|
1644
1647
|
// Use string equality for ISO 8601 timestamps
|
|
1645
1648
|
return t.timestampValue === n.timestampValue;
|
|
1646
|
-
const e =
|
|
1649
|
+
const e = It(t.timestampValue), r = It(n.timestampValue);
|
|
1647
1650
|
return e.seconds === r.seconds && e.nanos === r.nanos;
|
|
1648
1651
|
}(t, n);
|
|
1649
1652
|
|
|
@@ -1652,7 +1655,7 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1652
1655
|
|
|
1653
1656
|
case 6 /* BlobValue */ :
|
|
1654
1657
|
return function(t, n) {
|
|
1655
|
-
return
|
|
1658
|
+
return At(t.bytesValue).isEqual(At(n.bytesValue));
|
|
1656
1659
|
}(t, n);
|
|
1657
1660
|
|
|
1658
1661
|
case 7 /* RefValue */ :
|
|
@@ -1660,70 +1663,70 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1660
1663
|
|
|
1661
1664
|
case 8 /* GeoPointValue */ :
|
|
1662
1665
|
return function(t, n) {
|
|
1663
|
-
return
|
|
1666
|
+
return Tt(t.geoPointValue.latitude) === Tt(n.geoPointValue.latitude) && Tt(t.geoPointValue.longitude) === Tt(n.geoPointValue.longitude);
|
|
1664
1667
|
}(t, n);
|
|
1665
1668
|
|
|
1666
1669
|
case 2 /* NumberValue */ :
|
|
1667
1670
|
return function(t, n) {
|
|
1668
|
-
if ("integerValue" in t && "integerValue" in n) return
|
|
1671
|
+
if ("integerValue" in t && "integerValue" in n) return Tt(t.integerValue) === Tt(n.integerValue);
|
|
1669
1672
|
if ("doubleValue" in t && "doubleValue" in n) {
|
|
1670
|
-
const e =
|
|
1671
|
-
return e === r ?
|
|
1673
|
+
const e = Tt(t.doubleValue), r = Tt(n.doubleValue);
|
|
1674
|
+
return e === r ? ot(e) === ot(r) : isNaN(e) && isNaN(r);
|
|
1672
1675
|
}
|
|
1673
1676
|
return !1;
|
|
1674
1677
|
}(t, n);
|
|
1675
1678
|
|
|
1676
1679
|
case 9 /* ArrayValue */ :
|
|
1677
|
-
return
|
|
1680
|
+
return mt(t.arrayValue.values || [], n.arrayValue.values || [], Dt);
|
|
1678
1681
|
|
|
1679
1682
|
case 10 /* ObjectValue */ :
|
|
1680
1683
|
return function(t, n) {
|
|
1681
1684
|
const e = t.mapValue.fields || {}, r = n.mapValue.fields || {};
|
|
1682
|
-
if (
|
|
1683
|
-
for (const t in e) if (e.hasOwnProperty(t) && (void 0 === r[t] ||
|
|
1685
|
+
if (_t(e) !== _t(r)) return !1;
|
|
1686
|
+
for (const t in e) if (e.hasOwnProperty(t) && (void 0 === r[t] || !Dt(e[t], r[t]))) return !1;
|
|
1684
1687
|
return !0;
|
|
1685
1688
|
}
|
|
1686
1689
|
/** Returns true if the ArrayValue contains the specified element. */ (t, n);
|
|
1687
1690
|
|
|
1688
1691
|
default:
|
|
1689
|
-
return
|
|
1692
|
+
return _();
|
|
1690
1693
|
}
|
|
1691
1694
|
}
|
|
1692
1695
|
|
|
1693
|
-
function
|
|
1694
|
-
return void 0 !== (t.values || []).find((t =>
|
|
1696
|
+
function $t(t, n) {
|
|
1697
|
+
return void 0 !== (t.values || []).find((t => Dt(t, n)));
|
|
1695
1698
|
}
|
|
1696
1699
|
|
|
1697
|
-
function
|
|
1698
|
-
const e =
|
|
1699
|
-
if (e !== r) return
|
|
1700
|
+
function Ft(t, n) {
|
|
1701
|
+
const e = Nt(t), r = Nt(n);
|
|
1702
|
+
if (e !== r) return wt(e, r);
|
|
1700
1703
|
switch (e) {
|
|
1701
1704
|
case 0 /* NullValue */ :
|
|
1702
1705
|
return 0;
|
|
1703
1706
|
|
|
1704
1707
|
case 1 /* BooleanValue */ :
|
|
1705
|
-
return
|
|
1708
|
+
return wt(t.booleanValue, n.booleanValue);
|
|
1706
1709
|
|
|
1707
1710
|
case 2 /* NumberValue */ :
|
|
1708
1711
|
return function(t, n) {
|
|
1709
|
-
const e =
|
|
1712
|
+
const e = Tt(t.integerValue || t.doubleValue), r = Tt(n.integerValue || n.doubleValue);
|
|
1710
1713
|
return e < r ? -1 : e > r ? 1 : e === r ? 0 :
|
|
1711
1714
|
// one or both are NaN.
|
|
1712
1715
|
isNaN(e) ? isNaN(r) ? 0 : -1 : 1;
|
|
1713
1716
|
}(t, n);
|
|
1714
1717
|
|
|
1715
1718
|
case 3 /* TimestampValue */ :
|
|
1716
|
-
return
|
|
1719
|
+
return St(t.timestampValue, n.timestampValue);
|
|
1717
1720
|
|
|
1718
1721
|
case 4 /* ServerTimestampValue */ :
|
|
1719
|
-
return
|
|
1722
|
+
return St(Vt(t), Vt(n));
|
|
1720
1723
|
|
|
1721
1724
|
case 5 /* StringValue */ :
|
|
1722
|
-
return
|
|
1725
|
+
return wt(t.stringValue, n.stringValue);
|
|
1723
1726
|
|
|
1724
1727
|
case 6 /* BlobValue */ :
|
|
1725
1728
|
return function(t, n) {
|
|
1726
|
-
const e =
|
|
1729
|
+
const e = At(t), r = At(n);
|
|
1727
1730
|
return e.compareTo(r);
|
|
1728
1731
|
}(t.bytesValue, n.bytesValue);
|
|
1729
1732
|
|
|
@@ -1731,27 +1734,27 @@ function St(t, n) {
|
|
|
1731
1734
|
return function(t, n) {
|
|
1732
1735
|
const e = t.split("/"), r = n.split("/");
|
|
1733
1736
|
for (let t = 0; t < e.length && t < r.length; t++) {
|
|
1734
|
-
const n =
|
|
1737
|
+
const n = wt(e[t], r[t]);
|
|
1735
1738
|
if (0 !== n) return n;
|
|
1736
1739
|
}
|
|
1737
|
-
return
|
|
1740
|
+
return wt(e.length, r.length);
|
|
1738
1741
|
}(t.referenceValue, n.referenceValue);
|
|
1739
1742
|
|
|
1740
1743
|
case 8 /* GeoPointValue */ :
|
|
1741
1744
|
return function(t, n) {
|
|
1742
|
-
const e =
|
|
1745
|
+
const e = wt(Tt(t.latitude), Tt(n.latitude));
|
|
1743
1746
|
if (0 !== e) return e;
|
|
1744
|
-
return
|
|
1747
|
+
return wt(Tt(t.longitude), Tt(n.longitude));
|
|
1745
1748
|
}(t.geoPointValue, n.geoPointValue);
|
|
1746
1749
|
|
|
1747
1750
|
case 9 /* ArrayValue */ :
|
|
1748
1751
|
return function(t, n) {
|
|
1749
1752
|
const e = t.values || [], r = n.values || [];
|
|
1750
1753
|
for (let t = 0; t < e.length && t < r.length; ++t) {
|
|
1751
|
-
const n =
|
|
1754
|
+
const n = Ft(e[t], r[t]);
|
|
1752
1755
|
if (n) return n;
|
|
1753
1756
|
}
|
|
1754
|
-
return
|
|
1757
|
+
return wt(e.length, r.length);
|
|
1755
1758
|
}(t.arrayValue, n.arrayValue);
|
|
1756
1759
|
|
|
1757
1760
|
case 10 /* ObjectValue */ :
|
|
@@ -1763,49 +1766,49 @@ function St(t, n) {
|
|
|
1763
1766
|
// canonical IDs are independent of insertion order.
|
|
1764
1767
|
r.sort(), i.sort();
|
|
1765
1768
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1766
|
-
const n =
|
|
1769
|
+
const n = wt(r[t], i[t]);
|
|
1767
1770
|
if (0 !== n) return n;
|
|
1768
|
-
const o =
|
|
1771
|
+
const o = Ft(e[r[t]], s[i[t]]);
|
|
1769
1772
|
if (0 !== o) return o;
|
|
1770
1773
|
}
|
|
1771
|
-
return
|
|
1774
|
+
return wt(r.length, i.length);
|
|
1772
1775
|
}
|
|
1773
1776
|
/** Returns a reference value for the provided database and key. */ (t.mapValue, n.mapValue);
|
|
1774
1777
|
|
|
1775
1778
|
default:
|
|
1776
|
-
throw
|
|
1779
|
+
throw _();
|
|
1777
1780
|
}
|
|
1778
1781
|
}
|
|
1779
1782
|
|
|
1780
|
-
function
|
|
1781
|
-
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return
|
|
1782
|
-
const e =
|
|
1783
|
-
return 0 !== s ? s :
|
|
1783
|
+
function St(t, n) {
|
|
1784
|
+
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return wt(t, n);
|
|
1785
|
+
const e = It(t), r = It(n), s = wt(e.seconds, r.seconds);
|
|
1786
|
+
return 0 !== s ? s : wt(e.nanos, r.nanos);
|
|
1784
1787
|
}
|
|
1785
1788
|
|
|
1786
|
-
function
|
|
1789
|
+
function qt(t, n) {
|
|
1787
1790
|
return {
|
|
1788
1791
|
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${n.path.canonicalString()}`
|
|
1789
1792
|
};
|
|
1790
1793
|
}
|
|
1791
1794
|
|
|
1792
|
-
/** Returns true if `value` is an ArrayValue. */ function
|
|
1795
|
+
/** Returns true if `value` is an ArrayValue. */ function xt(t) {
|
|
1793
1796
|
return !!t && "arrayValue" in t;
|
|
1794
1797
|
}
|
|
1795
1798
|
|
|
1796
|
-
/** Returns true if `value` is a NullValue. */ function
|
|
1799
|
+
/** Returns true if `value` is a NullValue. */ function Ot(t) {
|
|
1797
1800
|
return !!t && "nullValue" in t;
|
|
1798
1801
|
}
|
|
1799
1802
|
|
|
1800
|
-
/** Returns true if `value` is NaN. */ function
|
|
1803
|
+
/** Returns true if `value` is NaN. */ function Ct(t) {
|
|
1801
1804
|
return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
|
|
1802
1805
|
}
|
|
1803
1806
|
|
|
1804
|
-
/** Returns true if `value` is a MapValue. */ function
|
|
1807
|
+
/** Returns true if `value` is a MapValue. */ function Lt(t) {
|
|
1805
1808
|
return !!t && "mapValue" in t;
|
|
1806
1809
|
}
|
|
1807
1810
|
|
|
1808
|
-
/** Creates a deep copy of `source`. */ function
|
|
1811
|
+
/** Creates a deep copy of `source`. */ function Ut(t) {
|
|
1809
1812
|
if (t.geoPointValue) return {
|
|
1810
1813
|
geoPointValue: Object.assign({}, t.geoPointValue)
|
|
1811
1814
|
};
|
|
@@ -1818,7 +1821,7 @@ function xt(t, n) {
|
|
|
1818
1821
|
fields: {}
|
|
1819
1822
|
}
|
|
1820
1823
|
};
|
|
1821
|
-
return
|
|
1824
|
+
return gt(t.mapValue.fields, ((t, e) => n.mapValue.fields[t] = Ut(e))), n;
|
|
1822
1825
|
}
|
|
1823
1826
|
if (t.arrayValue) {
|
|
1824
1827
|
const n = {
|
|
@@ -1826,7 +1829,7 @@ function xt(t, n) {
|
|
|
1826
1829
|
values: []
|
|
1827
1830
|
}
|
|
1828
1831
|
};
|
|
1829
|
-
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] =
|
|
1832
|
+
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] = Ut(t.arrayValue.values[e]);
|
|
1830
1833
|
return n;
|
|
1831
1834
|
}
|
|
1832
1835
|
return Object.assign({}, t);
|
|
@@ -1851,12 +1854,12 @@ function xt(t, n) {
|
|
|
1851
1854
|
/**
|
|
1852
1855
|
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
1853
1856
|
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
1854
|
-
*/ class
|
|
1857
|
+
*/ class jt {
|
|
1855
1858
|
constructor(t) {
|
|
1856
1859
|
this.value = t;
|
|
1857
1860
|
}
|
|
1858
1861
|
static empty() {
|
|
1859
|
-
return new
|
|
1862
|
+
return new jt({
|
|
1860
1863
|
mapValue: {}
|
|
1861
1864
|
});
|
|
1862
1865
|
}
|
|
@@ -1870,7 +1873,7 @@ function xt(t, n) {
|
|
|
1870
1873
|
{
|
|
1871
1874
|
let n = this.value;
|
|
1872
1875
|
for (let e = 0; e < t.length - 1; ++e) if (n = (n.mapValue.fields || {})[t.get(e)],
|
|
1873
|
-
!
|
|
1876
|
+
!Lt(n)) return null;
|
|
1874
1877
|
return n = (n.mapValue.fields || {})[t.lastSegment()], n || null;
|
|
1875
1878
|
}
|
|
1876
1879
|
}
|
|
@@ -1880,21 +1883,21 @@ function xt(t, n) {
|
|
|
1880
1883
|
* @param path - The field path to set.
|
|
1881
1884
|
* @param value - The value to set.
|
|
1882
1885
|
*/ set(t, n) {
|
|
1883
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] =
|
|
1886
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Ut(n);
|
|
1884
1887
|
}
|
|
1885
1888
|
/**
|
|
1886
1889
|
* Sets the provided fields to the provided values.
|
|
1887
1890
|
*
|
|
1888
1891
|
* @param data - A map of fields to values (or null for deletes).
|
|
1889
1892
|
*/ setAll(t) {
|
|
1890
|
-
let n =
|
|
1893
|
+
let n = J.emptyPath(), e = {}, r = [];
|
|
1891
1894
|
t.forEach(((t, s) => {
|
|
1892
1895
|
if (!n.isImmediateParentOf(s)) {
|
|
1893
1896
|
// Insert the accumulated changes at this parent location
|
|
1894
1897
|
const t = this.getFieldsMap(n);
|
|
1895
1898
|
this.applyChanges(t, e, r), e = {}, r = [], n = s.popLast();
|
|
1896
1899
|
}
|
|
1897
|
-
t ? e[s.lastSegment()] =
|
|
1900
|
+
t ? e[s.lastSegment()] = Ut(t) : r.push(s.lastSegment());
|
|
1898
1901
|
}));
|
|
1899
1902
|
const s = this.getFieldsMap(n);
|
|
1900
1903
|
this.applyChanges(s, e, r);
|
|
@@ -1906,10 +1909,10 @@ function xt(t, n) {
|
|
|
1906
1909
|
* @param path - The field path to remove.
|
|
1907
1910
|
*/ delete(t) {
|
|
1908
1911
|
const n = this.field(t.popLast());
|
|
1909
|
-
|
|
1912
|
+
Lt(n) && n.mapValue.fields && delete n.mapValue.fields[t.lastSegment()];
|
|
1910
1913
|
}
|
|
1911
1914
|
isEqual(t) {
|
|
1912
|
-
return
|
|
1915
|
+
return Dt(this.value, t.value);
|
|
1913
1916
|
}
|
|
1914
1917
|
/**
|
|
1915
1918
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
@@ -1921,7 +1924,7 @@ function xt(t, n) {
|
|
|
1921
1924
|
});
|
|
1922
1925
|
for (let e = 0; e < t.length; ++e) {
|
|
1923
1926
|
let r = n.mapValue.fields[t.get(e)];
|
|
1924
|
-
|
|
1927
|
+
Lt(r) && r.mapValue.fields || (r = {
|
|
1925
1928
|
mapValue: {
|
|
1926
1929
|
fields: {}
|
|
1927
1930
|
}
|
|
@@ -1933,11 +1936,11 @@ function xt(t, n) {
|
|
|
1933
1936
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1934
1937
|
* entries.
|
|
1935
1938
|
*/ applyChanges(t, n, e) {
|
|
1936
|
-
|
|
1939
|
+
gt(n, ((n, e) => t[n] = e));
|
|
1937
1940
|
for (const n of e) delete t[n];
|
|
1938
1941
|
}
|
|
1939
1942
|
clone() {
|
|
1940
|
-
return new
|
|
1943
|
+
return new jt(Ut(this.value));
|
|
1941
1944
|
}
|
|
1942
1945
|
}
|
|
1943
1946
|
|
|
@@ -1966,7 +1969,7 @@ function xt(t, n) {
|
|
|
1966
1969
|
* not transition to one of these states even after all mutations have been
|
|
1967
1970
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1968
1971
|
* from all views.
|
|
1969
|
-
*/ class
|
|
1972
|
+
*/ class kt {
|
|
1970
1973
|
constructor(t, n, e, r, s) {
|
|
1971
1974
|
this.key = t, this.documentType = n, this.version = e, this.data = r, this.documentState = s;
|
|
1972
1975
|
}
|
|
@@ -1974,23 +1977,23 @@ function xt(t, n) {
|
|
|
1974
1977
|
* Creates a document with no known version or data, but which can serve as
|
|
1975
1978
|
* base document for mutations.
|
|
1976
1979
|
*/ static newInvalidDocument(t) {
|
|
1977
|
-
return new
|
|
1980
|
+
return new kt(t, 0 /* INVALID */ , yt.min(), jt.empty(), 0 /* SYNCED */);
|
|
1978
1981
|
}
|
|
1979
1982
|
/**
|
|
1980
1983
|
* Creates a new document that is known to exist with the given data at the
|
|
1981
1984
|
* given version.
|
|
1982
1985
|
*/ static newFoundDocument(t, n, e) {
|
|
1983
|
-
return new
|
|
1986
|
+
return new kt(t, 1 /* FOUND_DOCUMENT */ , n, e, 0 /* SYNCED */);
|
|
1984
1987
|
}
|
|
1985
1988
|
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, n) {
|
|
1986
|
-
return new
|
|
1989
|
+
return new kt(t, 2 /* NO_DOCUMENT */ , n, jt.empty(), 0 /* SYNCED */);
|
|
1987
1990
|
}
|
|
1988
1991
|
/**
|
|
1989
1992
|
* Creates a new document that is known to exist at the given version but
|
|
1990
1993
|
* whose data is not known (e.g. a document that was updated without a known
|
|
1991
1994
|
* base document).
|
|
1992
1995
|
*/ static newUnknownDocument(t, n) {
|
|
1993
|
-
return new
|
|
1996
|
+
return new kt(t, 3 /* UNKNOWN_DOCUMENT */ , n, jt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
1994
1997
|
}
|
|
1995
1998
|
/**
|
|
1996
1999
|
* Changes the document type to indicate that it exists and that its version
|
|
@@ -2003,7 +2006,7 @@ function xt(t, n) {
|
|
|
2003
2006
|
* Changes the document type to indicate that it doesn't exist at the given
|
|
2004
2007
|
* version.
|
|
2005
2008
|
*/ convertToNoDocument(t) {
|
|
2006
|
-
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data =
|
|
2009
|
+
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data = jt.empty(),
|
|
2007
2010
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2008
2011
|
}
|
|
2009
2012
|
/**
|
|
@@ -2011,7 +2014,7 @@ function xt(t, n) {
|
|
|
2011
2014
|
* that its data is not known (e.g. a document that was updated without a known
|
|
2012
2015
|
* base document).
|
|
2013
2016
|
*/ convertToUnknownDocument(t) {
|
|
2014
|
-
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data =
|
|
2017
|
+
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data = jt.empty(),
|
|
2015
2018
|
this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2016
2019
|
}
|
|
2017
2020
|
setHasCommittedMutations() {
|
|
@@ -2042,10 +2045,10 @@ function xt(t, n) {
|
|
|
2042
2045
|
return 3 /* UNKNOWN_DOCUMENT */ === this.documentType;
|
|
2043
2046
|
}
|
|
2044
2047
|
isEqual(t) {
|
|
2045
|
-
return t instanceof
|
|
2048
|
+
return t instanceof kt && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2046
2049
|
}
|
|
2047
2050
|
clone() {
|
|
2048
|
-
return new
|
|
2051
|
+
return new kt(this.key, this.documentType, this.version, this.data.clone(), this.documentState);
|
|
2049
2052
|
}
|
|
2050
2053
|
toString() {
|
|
2051
2054
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2069,7 +2072,7 @@ function xt(t, n) {
|
|
|
2069
2072
|
* limitations under the License.
|
|
2070
2073
|
*/
|
|
2071
2074
|
// Visible for testing
|
|
2072
|
-
class
|
|
2075
|
+
class Mt {
|
|
2073
2076
|
constructor(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2074
2077
|
this.path = t, this.collectionGroup = n, this.orderBy = e, this.filters = r, this.limit = s,
|
|
2075
2078
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
@@ -2083,26 +2086,26 @@ class Bt {
|
|
|
2083
2086
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2084
2087
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2085
2088
|
* property.
|
|
2086
|
-
*/ function
|
|
2087
|
-
return new
|
|
2089
|
+
*/ function Bt(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2090
|
+
return new Mt(t, n, e, r, s, i, o);
|
|
2088
2091
|
}
|
|
2089
2092
|
|
|
2090
|
-
class
|
|
2093
|
+
class Qt extends class {} {
|
|
2091
2094
|
constructor(t, n, e) {
|
|
2092
2095
|
super(), this.field = t, this.op = n, this.value = e;
|
|
2093
2096
|
}
|
|
2094
2097
|
/**
|
|
2095
2098
|
* Creates a filter based on the provided arguments.
|
|
2096
2099
|
*/ static create(t, n, e) {
|
|
2097
|
-
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.R(t, n, e) : new
|
|
2100
|
+
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.R(t, n, e) : new zt(t, n, e) : "array-contains" /* ARRAY_CONTAINS */ === n ? new Yt(t, e) : "in" /* IN */ === n ? new Kt(t, e) : "not-in" /* NOT_IN */ === n ? new Jt(t, e) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === n ? new Zt(t, e) : new Qt(t, n, e);
|
|
2098
2101
|
}
|
|
2099
2102
|
static R(t, n, e) {
|
|
2100
|
-
return "in" /* IN */ === n ? new
|
|
2103
|
+
return "in" /* IN */ === n ? new Wt(t, e) : new Gt(t, e);
|
|
2101
2104
|
}
|
|
2102
2105
|
matches(t) {
|
|
2103
2106
|
const n = t.data.field(this.field);
|
|
2104
2107
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2105
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.V(
|
|
2108
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.V(Ft(n, this.value)) : null !== n && Nt(this.value) === Nt(n) && this.V(Ft(n, this.value));
|
|
2106
2109
|
// Only compare types with matching backend order (such as double and int).
|
|
2107
2110
|
}
|
|
2108
2111
|
V(t) {
|
|
@@ -2126,7 +2129,7 @@ class zt extends class {} {
|
|
|
2126
2129
|
return t >= 0;
|
|
2127
2130
|
|
|
2128
2131
|
default:
|
|
2129
|
-
return
|
|
2132
|
+
return _();
|
|
2130
2133
|
}
|
|
2131
2134
|
}
|
|
2132
2135
|
N() {
|
|
@@ -2135,79 +2138,79 @@ class zt extends class {} {
|
|
|
2135
2138
|
}
|
|
2136
2139
|
|
|
2137
2140
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2138
|
-
class
|
|
2141
|
+
class zt extends Qt {
|
|
2139
2142
|
constructor(t, n, e) {
|
|
2140
|
-
super(t, n, e), this.key =
|
|
2143
|
+
super(t, n, e), this.key = Z.fromName(e.referenceValue);
|
|
2141
2144
|
}
|
|
2142
2145
|
matches(t) {
|
|
2143
|
-
const n =
|
|
2146
|
+
const n = Z.comparator(t.key, this.key);
|
|
2144
2147
|
return this.V(n);
|
|
2145
2148
|
}
|
|
2146
2149
|
}
|
|
2147
2150
|
|
|
2148
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2151
|
+
/** Filter that matches on key fields within an array. */ class Wt extends Qt {
|
|
2149
2152
|
constructor(t, n) {
|
|
2150
|
-
super(t, "in" /* IN */ , n), this.keys =
|
|
2153
|
+
super(t, "in" /* IN */ , n), this.keys = Ht("in" /* IN */ , n);
|
|
2151
2154
|
}
|
|
2152
2155
|
matches(t) {
|
|
2153
2156
|
return this.keys.some((n => n.isEqual(t.key)));
|
|
2154
2157
|
}
|
|
2155
2158
|
}
|
|
2156
2159
|
|
|
2157
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2160
|
+
/** Filter that matches on key fields not present within an array. */ class Gt extends Qt {
|
|
2158
2161
|
constructor(t, n) {
|
|
2159
|
-
super(t, "not-in" /* NOT_IN */ , n), this.keys =
|
|
2162
|
+
super(t, "not-in" /* NOT_IN */ , n), this.keys = Ht("not-in" /* NOT_IN */ , n);
|
|
2160
2163
|
}
|
|
2161
2164
|
matches(t) {
|
|
2162
2165
|
return !this.keys.some((n => n.isEqual(t.key)));
|
|
2163
2166
|
}
|
|
2164
2167
|
}
|
|
2165
2168
|
|
|
2166
|
-
function
|
|
2169
|
+
function Ht(t, n) {
|
|
2167
2170
|
var e;
|
|
2168
|
-
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t =>
|
|
2171
|
+
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t => Z.fromName(t.referenceValue)));
|
|
2169
2172
|
}
|
|
2170
2173
|
|
|
2171
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2174
|
+
/** A Filter that implements the array-contains operator. */ class Yt extends Qt {
|
|
2172
2175
|
constructor(t, n) {
|
|
2173
2176
|
super(t, "array-contains" /* ARRAY_CONTAINS */ , n);
|
|
2174
2177
|
}
|
|
2175
2178
|
matches(t) {
|
|
2176
2179
|
const n = t.data.field(this.field);
|
|
2177
|
-
return
|
|
2180
|
+
return xt(n) && $t(n.arrayValue, this.value);
|
|
2178
2181
|
}
|
|
2179
2182
|
}
|
|
2180
2183
|
|
|
2181
|
-
/** A Filter that implements the IN operator. */ class
|
|
2184
|
+
/** A Filter that implements the IN operator. */ class Kt extends Qt {
|
|
2182
2185
|
constructor(t, n) {
|
|
2183
2186
|
super(t, "in" /* IN */ , n);
|
|
2184
2187
|
}
|
|
2185
2188
|
matches(t) {
|
|
2186
2189
|
const n = t.data.field(this.field);
|
|
2187
|
-
return null !== n &&
|
|
2190
|
+
return null !== n && $t(this.value.arrayValue, n);
|
|
2188
2191
|
}
|
|
2189
2192
|
}
|
|
2190
2193
|
|
|
2191
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2194
|
+
/** A Filter that implements the not-in operator. */ class Jt extends Qt {
|
|
2192
2195
|
constructor(t, n) {
|
|
2193
2196
|
super(t, "not-in" /* NOT_IN */ , n);
|
|
2194
2197
|
}
|
|
2195
2198
|
matches(t) {
|
|
2196
|
-
if (
|
|
2199
|
+
if ($t(this.value.arrayValue, {
|
|
2197
2200
|
nullValue: "NULL_VALUE"
|
|
2198
2201
|
})) return !1;
|
|
2199
2202
|
const n = t.data.field(this.field);
|
|
2200
|
-
return null !== n &&
|
|
2203
|
+
return null !== n && !$t(this.value.arrayValue, n);
|
|
2201
2204
|
}
|
|
2202
2205
|
}
|
|
2203
2206
|
|
|
2204
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2207
|
+
/** A Filter that implements the array-contains-any operator. */ class Zt extends Qt {
|
|
2205
2208
|
constructor(t, n) {
|
|
2206
2209
|
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , n);
|
|
2207
2210
|
}
|
|
2208
2211
|
matches(t) {
|
|
2209
2212
|
const n = t.data.field(this.field);
|
|
2210
|
-
return !(!
|
|
2213
|
+
return !(!xt(n) || !n.arrayValue.values) && n.arrayValue.values.some((t => $t(this.value.arrayValue, t)));
|
|
2211
2214
|
}
|
|
2212
2215
|
}
|
|
2213
2216
|
|
|
@@ -2224,7 +2227,7 @@ function Yt(t, n) {
|
|
|
2224
2227
|
* Bound provides a function to determine whether a document comes before or
|
|
2225
2228
|
* after a bound. This is influenced by whether the position is just before or
|
|
2226
2229
|
* just after the provided values.
|
|
2227
|
-
*/ class
|
|
2230
|
+
*/ class Xt {
|
|
2228
2231
|
constructor(t, n) {
|
|
2229
2232
|
this.position = t, this.before = n;
|
|
2230
2233
|
}
|
|
@@ -2232,22 +2235,22 @@ function Yt(t, n) {
|
|
|
2232
2235
|
|
|
2233
2236
|
/**
|
|
2234
2237
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2235
|
-
*/ class
|
|
2238
|
+
*/ class tn {
|
|
2236
2239
|
constructor(t, n = "asc" /* ASCENDING */) {
|
|
2237
2240
|
this.field = t, this.dir = n;
|
|
2238
2241
|
}
|
|
2239
2242
|
}
|
|
2240
2243
|
|
|
2241
|
-
function
|
|
2244
|
+
function nn(t, n) {
|
|
2242
2245
|
return t.dir === n.dir && t.field.isEqual(n.field);
|
|
2243
2246
|
}
|
|
2244
2247
|
|
|
2245
|
-
function
|
|
2248
|
+
function en(t, n) {
|
|
2246
2249
|
if (null === t) return null === n;
|
|
2247
2250
|
if (null === n) return !1;
|
|
2248
2251
|
if (t.before !== n.before || t.position.length !== n.position.length) return !1;
|
|
2249
2252
|
for (let e = 0; e < t.position.length; e++) {
|
|
2250
|
-
if (
|
|
2253
|
+
if (!Dt(t.position[e], n.position[e])) return !1;
|
|
2251
2254
|
}
|
|
2252
2255
|
return !0;
|
|
2253
2256
|
}
|
|
@@ -2274,7 +2277,7 @@ function rn(t, n) {
|
|
|
2274
2277
|
* query the RemoteStore results.
|
|
2275
2278
|
*
|
|
2276
2279
|
* Visible for testing.
|
|
2277
|
-
*/ class
|
|
2280
|
+
*/ class rn {
|
|
2278
2281
|
/**
|
|
2279
2282
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2280
2283
|
* Path must currently be empty if this is a collection group query.
|
|
@@ -2287,15 +2290,15 @@ function rn(t, n) {
|
|
|
2287
2290
|
}
|
|
2288
2291
|
}
|
|
2289
2292
|
|
|
2290
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2291
|
-
return !
|
|
2293
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function sn(t) {
|
|
2294
|
+
return !it(t.limit) && "L" /* Last */ === t.limitType;
|
|
2292
2295
|
}
|
|
2293
2296
|
|
|
2294
|
-
function
|
|
2297
|
+
function on(t) {
|
|
2295
2298
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2296
2299
|
}
|
|
2297
2300
|
|
|
2298
|
-
function
|
|
2301
|
+
function un(t) {
|
|
2299
2302
|
for (const n of t.filters) if (n.N()) return n.field;
|
|
2300
2303
|
return null;
|
|
2301
2304
|
}
|
|
@@ -2308,7 +2311,7 @@ function cn(t) {
|
|
|
2308
2311
|
* Returns whether the query matches a collection group rather than a specific
|
|
2309
2312
|
* collection.
|
|
2310
2313
|
*/
|
|
2311
|
-
function
|
|
2314
|
+
function cn(t) {
|
|
2312
2315
|
return null !== t.collectionGroup;
|
|
2313
2316
|
}
|
|
2314
2317
|
|
|
@@ -2316,23 +2319,23 @@ function an(t) {
|
|
|
2316
2319
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2317
2320
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2318
2321
|
* the SDK and backend always orders by `__name__`).
|
|
2319
|
-
*/ function
|
|
2320
|
-
const n =
|
|
2322
|
+
*/ function an(t) {
|
|
2323
|
+
const n = b(t);
|
|
2321
2324
|
if (null === n.D) {
|
|
2322
2325
|
n.D = [];
|
|
2323
|
-
const t =
|
|
2326
|
+
const t = un(n), e = on(n);
|
|
2324
2327
|
if (null !== t && null === e)
|
|
2325
2328
|
// In order to implicitly add key ordering, we must also add the
|
|
2326
2329
|
// inequality filter field for it to be a valid query.
|
|
2327
2330
|
// Note that the default inequality field and key ordering is ascending.
|
|
2328
|
-
t.isKeyField() || n.D.push(new
|
|
2331
|
+
t.isKeyField() || n.D.push(new tn(t)), n.D.push(new tn(J.keyField(), "asc" /* ASCENDING */)); else {
|
|
2329
2332
|
let t = !1;
|
|
2330
2333
|
for (const e of n.explicitOrderBy) n.D.push(e), e.field.isKeyField() && (t = !0);
|
|
2331
2334
|
if (!t) {
|
|
2332
2335
|
// The order of the implicit key ordering always matches the last
|
|
2333
2336
|
// explicit order by
|
|
2334
2337
|
const t = n.explicitOrderBy.length > 0 ? n.explicitOrderBy[n.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2335
|
-
n.D.push(new
|
|
2338
|
+
n.D.push(new tn(J.keyField(), t));
|
|
2336
2339
|
}
|
|
2337
2340
|
}
|
|
2338
2341
|
}
|
|
@@ -2341,34 +2344,34 @@ function an(t) {
|
|
|
2341
2344
|
|
|
2342
2345
|
/**
|
|
2343
2346
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2344
|
-
*/ function
|
|
2345
|
-
const n =
|
|
2346
|
-
if (!n.$) if ("F" /* First */ === n.limitType) n.$ =
|
|
2347
|
+
*/ function hn(t) {
|
|
2348
|
+
const n = b(t);
|
|
2349
|
+
if (!n.$) if ("F" /* First */ === n.limitType) n.$ = Bt(n.path, n.collectionGroup, an(n), n.filters, n.limit, n.startAt, n.endAt); else {
|
|
2347
2350
|
// Flip the orderBy directions since we want the last results
|
|
2348
2351
|
const t = [];
|
|
2349
|
-
for (const e of
|
|
2352
|
+
for (const e of an(n)) {
|
|
2350
2353
|
const n = "desc" /* DESCENDING */ === e.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2351
|
-
t.push(new
|
|
2354
|
+
t.push(new tn(e.field, n));
|
|
2352
2355
|
}
|
|
2353
2356
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2354
|
-
const e = n.endAt ? new
|
|
2357
|
+
const e = n.endAt ? new Xt(n.endAt.position, !n.endAt.before) : null, r = n.startAt ? new Xt(n.startAt.position, !n.startAt.before) : null;
|
|
2355
2358
|
// Now return as a LimitType.First query.
|
|
2356
|
-
n.$ =
|
|
2359
|
+
n.$ = Bt(n.path, n.collectionGroup, t, n.filters, n.limit, e, r);
|
|
2357
2360
|
}
|
|
2358
2361
|
return n.$;
|
|
2359
2362
|
}
|
|
2360
2363
|
|
|
2361
|
-
function
|
|
2364
|
+
function ln(t, n) {
|
|
2362
2365
|
return function(t, n) {
|
|
2363
2366
|
if (t.limit !== n.limit) return !1;
|
|
2364
2367
|
if (t.orderBy.length !== n.orderBy.length) return !1;
|
|
2365
|
-
for (let e = 0; e < t.orderBy.length; e++) if (!
|
|
2368
|
+
for (let e = 0; e < t.orderBy.length; e++) if (!nn(t.orderBy[e], n.orderBy[e])) return !1;
|
|
2366
2369
|
if (t.filters.length !== n.filters.length) return !1;
|
|
2367
2370
|
for (let s = 0; s < t.filters.length; s++) if (e = t.filters[s], r = n.filters[s],
|
|
2368
|
-
e.op !== r.op || !e.field.isEqual(r.field) ||
|
|
2371
|
+
e.op !== r.op || !e.field.isEqual(r.field) || !Dt(e.value, r.value)) return !1;
|
|
2369
2372
|
var e, r;
|
|
2370
|
-
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!
|
|
2371
|
-
}(
|
|
2373
|
+
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!en(t.startAt, n.startAt) && en(t.endAt, n.endAt);
|
|
2374
|
+
}(hn(t), hn(n)) && t.limitType === n.limitType;
|
|
2372
2375
|
}
|
|
2373
2376
|
|
|
2374
2377
|
/**
|
|
@@ -2396,9 +2399,9 @@ function fn(t, n) {
|
|
|
2396
2399
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2397
2400
|
* otherwise a DoubleValue is returned.
|
|
2398
2401
|
*/
|
|
2399
|
-
function
|
|
2402
|
+
function fn(t, n) {
|
|
2400
2403
|
return function(t) {
|
|
2401
|
-
return "number" == typeof t && Number.isInteger(t) && !
|
|
2404
|
+
return "number" == typeof t && Number.isInteger(t) && !ot(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2402
2405
|
}(n) ?
|
|
2403
2406
|
/**
|
|
2404
2407
|
* Returns an IntegerValue for `value`.
|
|
@@ -2420,7 +2423,7 @@ function dn(t, n) {
|
|
|
2420
2423
|
};
|
|
2421
2424
|
}
|
|
2422
2425
|
return {
|
|
2423
|
-
doubleValue:
|
|
2426
|
+
doubleValue: ot(n) ? "-0" : n
|
|
2424
2427
|
};
|
|
2425
2428
|
}(t, n);
|
|
2426
2429
|
}
|
|
@@ -2441,7 +2444,7 @@ function dn(t, n) {
|
|
|
2441
2444
|
* See the License for the specific language governing permissions and
|
|
2442
2445
|
* limitations under the License.
|
|
2443
2446
|
*/
|
|
2444
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2447
|
+
/** Used to represent a field transform on a mutation. */ class dn {
|
|
2445
2448
|
constructor() {
|
|
2446
2449
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2447
2450
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2449,15 +2452,15 @@ function dn(t, n) {
|
|
|
2449
2452
|
}
|
|
2450
2453
|
}
|
|
2451
2454
|
|
|
2452
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2455
|
+
/** Transforms a value into a server-generated timestamp. */ class wn extends dn {}
|
|
2453
2456
|
|
|
2454
|
-
/** Transforms an array value via a union operation. */ class
|
|
2457
|
+
/** Transforms an array value via a union operation. */ class mn extends dn {
|
|
2455
2458
|
constructor(t) {
|
|
2456
2459
|
super(), this.elements = t;
|
|
2457
2460
|
}
|
|
2458
2461
|
}
|
|
2459
2462
|
|
|
2460
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2463
|
+
/** Transforms an array value via a remove operation. */ class pn extends dn {
|
|
2461
2464
|
constructor(t) {
|
|
2462
2465
|
super(), this.elements = t;
|
|
2463
2466
|
}
|
|
@@ -2468,7 +2471,7 @@ function dn(t, n) {
|
|
|
2468
2471
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2469
2472
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2470
2473
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2471
|
-
*/ class
|
|
2474
|
+
*/ class yn extends dn {
|
|
2472
2475
|
constructor(t, n) {
|
|
2473
2476
|
super(), this.S = t, this.q = n;
|
|
2474
2477
|
}
|
|
@@ -2490,7 +2493,7 @@ function dn(t, n) {
|
|
|
2490
2493
|
* See the License for the specific language governing permissions and
|
|
2491
2494
|
* limitations under the License.
|
|
2492
2495
|
*/
|
|
2493
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2496
|
+
/** A field path and the TransformOperation to perform upon it. */ class _n {
|
|
2494
2497
|
constructor(t, n) {
|
|
2495
2498
|
this.field = t, this.transform = n;
|
|
2496
2499
|
}
|
|
@@ -2500,18 +2503,18 @@ function dn(t, n) {
|
|
|
2500
2503
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2501
2504
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2502
2505
|
* (meaning no precondition).
|
|
2503
|
-
*/ class
|
|
2506
|
+
*/ class gn {
|
|
2504
2507
|
constructor(t, n) {
|
|
2505
2508
|
this.updateTime = t, this.exists = n;
|
|
2506
2509
|
}
|
|
2507
2510
|
/** Creates a new empty Precondition. */ static none() {
|
|
2508
|
-
return new
|
|
2511
|
+
return new gn;
|
|
2509
2512
|
}
|
|
2510
2513
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2511
|
-
return new
|
|
2514
|
+
return new gn(void 0, t);
|
|
2512
2515
|
}
|
|
2513
2516
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2514
|
-
return new
|
|
2517
|
+
return new gn(t);
|
|
2515
2518
|
}
|
|
2516
2519
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2517
2520
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2562,14 +2565,14 @@ function dn(t, n) {
|
|
|
2562
2565
|
*
|
|
2563
2566
|
* Every type of mutation needs to implement its own applyToRemoteDocument() and
|
|
2564
2567
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2565
|
-
* to some source document (see `
|
|
2568
|
+
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2566
2569
|
* example).
|
|
2567
|
-
*/ class
|
|
2570
|
+
*/ class bn {}
|
|
2568
2571
|
|
|
2569
2572
|
/**
|
|
2570
2573
|
* A mutation that creates or replaces the document at the given key with the
|
|
2571
2574
|
* object value contents.
|
|
2572
|
-
*/ class
|
|
2575
|
+
*/ class vn extends bn {
|
|
2573
2576
|
constructor(t, n, e, r = []) {
|
|
2574
2577
|
super(), this.key = t, this.value = n, this.precondition = e, this.fieldTransforms = r,
|
|
2575
2578
|
this.type = 0 /* Set */;
|
|
@@ -2588,14 +2591,14 @@ function dn(t, n) {
|
|
|
2588
2591
|
* is deleted.
|
|
2589
2592
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2590
2593
|
* ignored.
|
|
2591
|
-
*/ class
|
|
2594
|
+
*/ class En extends bn {
|
|
2592
2595
|
constructor(t, n, e, r, s = []) {
|
|
2593
2596
|
super(), this.key = t, this.data = n, this.fieldMask = e, this.precondition = r,
|
|
2594
2597
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2595
2598
|
}
|
|
2596
2599
|
}
|
|
2597
2600
|
|
|
2598
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2601
|
+
/** A mutation that deletes the document at the given key. */ class In extends bn {
|
|
2599
2602
|
constructor(t, n) {
|
|
2600
2603
|
super(), this.key = t, this.precondition = n, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2601
2604
|
}
|
|
@@ -2607,7 +2610,7 @@ function dn(t, n) {
|
|
|
2607
2610
|
*
|
|
2608
2611
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2609
2612
|
* primarily to facilitate serialization into protos.
|
|
2610
|
-
*/ class
|
|
2613
|
+
*/ class Tn extends bn {
|
|
2611
2614
|
constructor(t, n) {
|
|
2612
2615
|
super(), this.key = t, this.precondition = n, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2613
2616
|
}
|
|
@@ -2628,13 +2631,13 @@ function dn(t, n) {
|
|
|
2628
2631
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2629
2632
|
* See the License for the specific language governing permissions and
|
|
2630
2633
|
* limitations under the License.
|
|
2631
|
-
*/ const
|
|
2634
|
+
*/ const An = (() => {
|
|
2632
2635
|
const t = {
|
|
2633
2636
|
asc: "ASCENDING",
|
|
2634
2637
|
desc: "DESCENDING"
|
|
2635
2638
|
};
|
|
2636
2639
|
return t;
|
|
2637
|
-
})(),
|
|
2640
|
+
})(), Pn = (() => {
|
|
2638
2641
|
const t = {
|
|
2639
2642
|
"<": "LESS_THAN",
|
|
2640
2643
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2664,7 +2667,7 @@ function dn(t, n) {
|
|
|
2664
2667
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2665
2668
|
* resource name in documents.
|
|
2666
2669
|
*/
|
|
2667
|
-
class
|
|
2670
|
+
class Rn {
|
|
2668
2671
|
constructor(t, n) {
|
|
2669
2672
|
this.databaseId = t, this.F = n;
|
|
2670
2673
|
}
|
|
@@ -2681,7 +2684,7 @@ class Vn {
|
|
|
2681
2684
|
/**
|
|
2682
2685
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2683
2686
|
*/
|
|
2684
|
-
function
|
|
2687
|
+
function Vn(t, n) {
|
|
2685
2688
|
if (t.F) {
|
|
2686
2689
|
return `${new Date(1e3 * n.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + n.nanoseconds).slice(-9)}Z`;
|
|
2687
2690
|
}
|
|
@@ -2696,129 +2699,129 @@ function Nn(t, n) {
|
|
|
2696
2699
|
*
|
|
2697
2700
|
* Visible for testing.
|
|
2698
2701
|
*/
|
|
2699
|
-
function
|
|
2702
|
+
function Nn(t, n) {
|
|
2700
2703
|
return t.F ? n.toBase64() : n.toUint8Array();
|
|
2701
2704
|
}
|
|
2702
2705
|
|
|
2703
|
-
function
|
|
2704
|
-
return
|
|
2706
|
+
function Dn(t, n) {
|
|
2707
|
+
return Vn(t, n.toTimestamp());
|
|
2705
2708
|
}
|
|
2706
2709
|
|
|
2707
|
-
function
|
|
2708
|
-
return
|
|
2709
|
-
const n =
|
|
2710
|
-
return new
|
|
2710
|
+
function $n(t) {
|
|
2711
|
+
return g(!!t), yt.fromTimestamp(function(t) {
|
|
2712
|
+
const n = It(t);
|
|
2713
|
+
return new pt(n.seconds, n.nanos);
|
|
2711
2714
|
}(t));
|
|
2712
2715
|
}
|
|
2713
2716
|
|
|
2714
|
-
function
|
|
2717
|
+
function Fn(t, n) {
|
|
2715
2718
|
return function(t) {
|
|
2716
|
-
return new
|
|
2719
|
+
return new Y([ "projects", t.projectId, "databases", t.database ]);
|
|
2717
2720
|
}(t).child("documents").child(n).canonicalString();
|
|
2718
2721
|
}
|
|
2719
2722
|
|
|
2720
|
-
function
|
|
2721
|
-
return
|
|
2723
|
+
function Sn(t, n) {
|
|
2724
|
+
return Fn(t.databaseId, n.path);
|
|
2722
2725
|
}
|
|
2723
2726
|
|
|
2724
|
-
function
|
|
2727
|
+
function qn(t, n) {
|
|
2725
2728
|
const e = function(t) {
|
|
2726
|
-
const n =
|
|
2727
|
-
return
|
|
2729
|
+
const n = Y.fromString(t);
|
|
2730
|
+
return g(Wn(n)), n;
|
|
2728
2731
|
}(n);
|
|
2729
|
-
if (e.get(1) !== t.databaseId.projectId) throw new
|
|
2730
|
-
if (e.get(3) !== t.databaseId.database) throw new
|
|
2731
|
-
return new
|
|
2732
|
+
if (e.get(1) !== t.databaseId.projectId) throw new L(T, "Tried to deserialize key from different project: " + e.get(1) + " vs " + t.databaseId.projectId);
|
|
2733
|
+
if (e.get(3) !== t.databaseId.database) throw new L(T, "Tried to deserialize key from different database: " + e.get(3) + " vs " + t.databaseId.database);
|
|
2734
|
+
return new Z((g((r = e).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2732
2735
|
var r;
|
|
2733
2736
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2734
2737
|
|
|
2735
|
-
function
|
|
2736
|
-
return
|
|
2738
|
+
function xn(t, n) {
|
|
2739
|
+
return Fn(t.databaseId, n);
|
|
2737
2740
|
}
|
|
2738
2741
|
|
|
2739
|
-
function
|
|
2740
|
-
return new
|
|
2742
|
+
function On(t) {
|
|
2743
|
+
return new Y([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2741
2744
|
}
|
|
2742
2745
|
|
|
2743
|
-
function
|
|
2746
|
+
function Cn(t, n, e) {
|
|
2744
2747
|
return {
|
|
2745
|
-
name:
|
|
2748
|
+
name: Sn(t, n),
|
|
2746
2749
|
fields: e.value.mapValue.fields
|
|
2747
2750
|
};
|
|
2748
2751
|
}
|
|
2749
2752
|
|
|
2750
|
-
function
|
|
2753
|
+
function Ln(t, n) {
|
|
2751
2754
|
return "found" in n ? function(t, n) {
|
|
2752
|
-
|
|
2753
|
-
const e =
|
|
2755
|
+
g(!!n.found), n.found.name, n.found.updateTime;
|
|
2756
|
+
const e = qn(t, n.found.name), r = $n(n.found.updateTime), s = new jt({
|
|
2754
2757
|
mapValue: {
|
|
2755
2758
|
fields: n.found.fields
|
|
2756
2759
|
}
|
|
2757
2760
|
});
|
|
2758
|
-
return
|
|
2761
|
+
return kt.newFoundDocument(e, r, s);
|
|
2759
2762
|
}(t, n) : "missing" in n ? function(t, n) {
|
|
2760
|
-
|
|
2761
|
-
const e =
|
|
2762
|
-
return
|
|
2763
|
-
}(t, n) :
|
|
2763
|
+
g(!!n.missing), g(!!n.readTime);
|
|
2764
|
+
const e = qn(t, n.missing), r = $n(n.readTime);
|
|
2765
|
+
return kt.newNoDocument(e, r);
|
|
2766
|
+
}(t, n) : _();
|
|
2764
2767
|
}
|
|
2765
2768
|
|
|
2766
|
-
function
|
|
2769
|
+
function Un(t, n) {
|
|
2767
2770
|
let e;
|
|
2768
|
-
if (n instanceof
|
|
2769
|
-
update:
|
|
2770
|
-
}; else if (n instanceof Tn) e = {
|
|
2771
|
-
delete: qn(t, n.key)
|
|
2771
|
+
if (n instanceof vn) e = {
|
|
2772
|
+
update: Cn(t, n.key, n.value)
|
|
2772
2773
|
}; else if (n instanceof In) e = {
|
|
2773
|
-
|
|
2774
|
-
|
|
2774
|
+
delete: Sn(t, n.key)
|
|
2775
|
+
}; else if (n instanceof En) e = {
|
|
2776
|
+
update: Cn(t, n.key, n.data),
|
|
2777
|
+
updateMask: zn(n.fieldMask)
|
|
2775
2778
|
}; else {
|
|
2776
|
-
if (!(n instanceof
|
|
2779
|
+
if (!(n instanceof Tn)) return _();
|
|
2777
2780
|
e = {
|
|
2778
|
-
verify:
|
|
2781
|
+
verify: Sn(t, n.key)
|
|
2779
2782
|
};
|
|
2780
2783
|
}
|
|
2781
2784
|
return n.fieldTransforms.length > 0 && (e.updateTransforms = n.fieldTransforms.map((t => function(t, n) {
|
|
2782
2785
|
const e = n.transform;
|
|
2783
|
-
if (e instanceof
|
|
2786
|
+
if (e instanceof wn) return {
|
|
2784
2787
|
fieldPath: n.field.canonicalString(),
|
|
2785
2788
|
setToServerValue: "REQUEST_TIME"
|
|
2786
2789
|
};
|
|
2787
|
-
if (e instanceof
|
|
2790
|
+
if (e instanceof mn) return {
|
|
2788
2791
|
fieldPath: n.field.canonicalString(),
|
|
2789
2792
|
appendMissingElements: {
|
|
2790
2793
|
values: e.elements
|
|
2791
2794
|
}
|
|
2792
2795
|
};
|
|
2793
|
-
if (e instanceof
|
|
2796
|
+
if (e instanceof pn) return {
|
|
2794
2797
|
fieldPath: n.field.canonicalString(),
|
|
2795
2798
|
removeAllFromArray: {
|
|
2796
2799
|
values: e.elements
|
|
2797
2800
|
}
|
|
2798
2801
|
};
|
|
2799
|
-
if (e instanceof
|
|
2802
|
+
if (e instanceof yn) return {
|
|
2800
2803
|
fieldPath: n.field.canonicalString(),
|
|
2801
2804
|
increment: e.q
|
|
2802
2805
|
};
|
|
2803
|
-
throw
|
|
2806
|
+
throw _();
|
|
2804
2807
|
}(0, t)))), n.precondition.isNone || (e.currentDocument = function(t, n) {
|
|
2805
2808
|
return void 0 !== n.updateTime ? {
|
|
2806
|
-
updateTime:
|
|
2809
|
+
updateTime: Dn(t, n.updateTime)
|
|
2807
2810
|
} : void 0 !== n.exists ? {
|
|
2808
2811
|
exists: n.exists
|
|
2809
|
-
} :
|
|
2812
|
+
} : _();
|
|
2810
2813
|
}(t, n.precondition)), e;
|
|
2811
2814
|
}
|
|
2812
2815
|
|
|
2813
|
-
function
|
|
2816
|
+
function jn(t, n) {
|
|
2814
2817
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2815
2818
|
const e = {
|
|
2816
2819
|
structuredQuery: {}
|
|
2817
2820
|
}, r = n.path;
|
|
2818
|
-
null !== n.collectionGroup ? (e.parent =
|
|
2821
|
+
null !== n.collectionGroup ? (e.parent = xn(t, r), e.structuredQuery.from = [ {
|
|
2819
2822
|
collectionId: n.collectionGroup,
|
|
2820
2823
|
allDescendants: !0
|
|
2821
|
-
} ]) : (e.parent =
|
|
2824
|
+
} ]) : (e.parent = xn(t, r.popLast()), e.structuredQuery.from = [ {
|
|
2822
2825
|
collectionId: r.lastSegment()
|
|
2823
2826
|
} ]);
|
|
2824
2827
|
const s = function(t) {
|
|
@@ -2827,36 +2830,36 @@ function kn(t, n) {
|
|
|
2827
2830
|
// visible for testing
|
|
2828
2831
|
function(t) {
|
|
2829
2832
|
if ("==" /* EQUAL */ === t.op) {
|
|
2830
|
-
if (
|
|
2833
|
+
if (Ct(t.value)) return {
|
|
2831
2834
|
unaryFilter: {
|
|
2832
|
-
field:
|
|
2835
|
+
field: Qn(t.field),
|
|
2833
2836
|
op: "IS_NAN"
|
|
2834
2837
|
}
|
|
2835
2838
|
};
|
|
2836
|
-
if (
|
|
2839
|
+
if (Ot(t.value)) return {
|
|
2837
2840
|
unaryFilter: {
|
|
2838
|
-
field:
|
|
2841
|
+
field: Qn(t.field),
|
|
2839
2842
|
op: "IS_NULL"
|
|
2840
2843
|
}
|
|
2841
2844
|
};
|
|
2842
2845
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2843
|
-
if (
|
|
2846
|
+
if (Ct(t.value)) return {
|
|
2844
2847
|
unaryFilter: {
|
|
2845
|
-
field:
|
|
2848
|
+
field: Qn(t.field),
|
|
2846
2849
|
op: "IS_NOT_NAN"
|
|
2847
2850
|
}
|
|
2848
2851
|
};
|
|
2849
|
-
if (
|
|
2852
|
+
if (Ot(t.value)) return {
|
|
2850
2853
|
unaryFilter: {
|
|
2851
|
-
field:
|
|
2854
|
+
field: Qn(t.field),
|
|
2852
2855
|
op: "IS_NOT_NULL"
|
|
2853
2856
|
}
|
|
2854
2857
|
};
|
|
2855
2858
|
}
|
|
2856
2859
|
return {
|
|
2857
2860
|
fieldFilter: {
|
|
2858
|
-
field:
|
|
2859
|
-
op:
|
|
2861
|
+
field: Qn(t.field),
|
|
2862
|
+
op: Bn(t.op),
|
|
2860
2863
|
value: t.value
|
|
2861
2864
|
}
|
|
2862
2865
|
};
|
|
@@ -2876,22 +2879,22 @@ function kn(t, n) {
|
|
|
2876
2879
|
// visible for testing
|
|
2877
2880
|
function(t) {
|
|
2878
2881
|
return {
|
|
2879
|
-
field:
|
|
2880
|
-
direction:
|
|
2882
|
+
field: Qn(t.field),
|
|
2883
|
+
direction: Mn(t.dir)
|
|
2881
2884
|
};
|
|
2882
2885
|
}(t)));
|
|
2883
2886
|
}(n.orderBy);
|
|
2884
2887
|
i && (e.structuredQuery.orderBy = i);
|
|
2885
2888
|
const o = function(t, n) {
|
|
2886
|
-
return t.F ||
|
|
2889
|
+
return t.F || it(n) ? n : {
|
|
2887
2890
|
value: n
|
|
2888
2891
|
};
|
|
2889
2892
|
}(t, n.limit);
|
|
2890
|
-
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt =
|
|
2891
|
-
n.endAt && (e.structuredQuery.endAt =
|
|
2893
|
+
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt = kn(n.startAt)),
|
|
2894
|
+
n.endAt && (e.structuredQuery.endAt = kn(n.endAt)), e;
|
|
2892
2895
|
}
|
|
2893
2896
|
|
|
2894
|
-
function
|
|
2897
|
+
function kn(t) {
|
|
2895
2898
|
return {
|
|
2896
2899
|
before: t.before,
|
|
2897
2900
|
values: t.position
|
|
@@ -2899,29 +2902,29 @@ function Mn(t) {
|
|
|
2899
2902
|
}
|
|
2900
2903
|
|
|
2901
2904
|
// visible for testing
|
|
2902
|
-
function
|
|
2903
|
-
return
|
|
2905
|
+
function Mn(t) {
|
|
2906
|
+
return An[t];
|
|
2904
2907
|
}
|
|
2905
2908
|
|
|
2906
2909
|
// visible for testing
|
|
2907
|
-
function
|
|
2908
|
-
return
|
|
2910
|
+
function Bn(t) {
|
|
2911
|
+
return Pn[t];
|
|
2909
2912
|
}
|
|
2910
2913
|
|
|
2911
|
-
function
|
|
2914
|
+
function Qn(t) {
|
|
2912
2915
|
return {
|
|
2913
2916
|
fieldPath: t.canonicalString()
|
|
2914
2917
|
};
|
|
2915
2918
|
}
|
|
2916
2919
|
|
|
2917
|
-
function
|
|
2920
|
+
function zn(t) {
|
|
2918
2921
|
const n = [];
|
|
2919
2922
|
return t.fields.forEach((t => n.push(t.canonicalString()))), {
|
|
2920
2923
|
fieldPaths: n
|
|
2921
2924
|
};
|
|
2922
2925
|
}
|
|
2923
2926
|
|
|
2924
|
-
function
|
|
2927
|
+
function Wn(t) {
|
|
2925
2928
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2926
2929
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2927
2930
|
}
|
|
@@ -2941,8 +2944,8 @@ function Gn(t) {
|
|
|
2941
2944
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2942
2945
|
* See the License for the specific language governing permissions and
|
|
2943
2946
|
* limitations under the License.
|
|
2944
|
-
*/ function
|
|
2945
|
-
return new
|
|
2947
|
+
*/ function Gn(t) {
|
|
2948
|
+
return new Rn(t, /* useProto3Json= */ !0);
|
|
2946
2949
|
}
|
|
2947
2950
|
|
|
2948
2951
|
/**
|
|
@@ -2970,7 +2973,7 @@ function Gn(t) {
|
|
|
2970
2973
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
2971
2974
|
* delays causing spikes of load to the backend.
|
|
2972
2975
|
*/
|
|
2973
|
-
class
|
|
2976
|
+
class Hn {
|
|
2974
2977
|
constructor(
|
|
2975
2978
|
/**
|
|
2976
2979
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3025,7 +3028,7 @@ class Yn {
|
|
|
3025
3028
|
// honored as such).
|
|
3026
3029
|
const n = Math.floor(this.j + this.G()), e = Math.max(0, Date.now() - this.M), r = Math.max(0, n - e);
|
|
3027
3030
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3028
|
-
r > 0 &&
|
|
3031
|
+
r > 0 && w("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${n} ms, last attempt: ${e} ms ago)`),
|
|
3029
3032
|
this.k = this.O.enqueueAfterDelay(this.timerId, r, (() => (this.M = Date.now(),
|
|
3030
3033
|
t()))),
|
|
3031
3034
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3068,23 +3071,23 @@ class Yn {
|
|
|
3068
3071
|
* An implementation of Datastore that exposes additional state for internal
|
|
3069
3072
|
* consumption.
|
|
3070
3073
|
*/
|
|
3071
|
-
class
|
|
3074
|
+
class Yn extends class {} {
|
|
3072
3075
|
constructor(t, n, e) {
|
|
3073
3076
|
super(), this.credentials = t, this.Y = n, this.S = e, this.K = !1;
|
|
3074
3077
|
}
|
|
3075
3078
|
J() {
|
|
3076
|
-
if (this.K) throw new
|
|
3079
|
+
if (this.K) throw new L($, "The client has already been terminated.");
|
|
3077
3080
|
}
|
|
3078
3081
|
/** Gets an auth token and invokes the provided RPC. */ l(t, n, e) {
|
|
3079
3082
|
return this.J(), this.credentials.getToken().then((r => this.Y.l(t, n, e, r))).catch((t => {
|
|
3080
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3081
|
-
t) : new
|
|
3083
|
+
throw "FirebaseError" === t.name ? (t.code === N && this.credentials.invalidateToken(),
|
|
3084
|
+
t) : new L(I, t.toString());
|
|
3082
3085
|
}));
|
|
3083
3086
|
}
|
|
3084
3087
|
/** Gets an auth token and invokes the provided RPC with streamed results. */ v(t, n, e) {
|
|
3085
3088
|
return this.J(), this.credentials.getToken().then((r => this.Y.v(t, n, e, r))).catch((t => {
|
|
3086
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3087
|
-
t) : new
|
|
3089
|
+
throw "FirebaseError" === t.name ? (t.code === N && this.credentials.invalidateToken(),
|
|
3090
|
+
t) : new L(I, t.toString());
|
|
3088
3091
|
}));
|
|
3089
3092
|
}
|
|
3090
3093
|
terminate() {
|
|
@@ -3094,38 +3097,38 @@ class Kn extends class {} {
|
|
|
3094
3097
|
|
|
3095
3098
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3096
3099
|
// firestore-exp client.
|
|
3097
|
-
async function
|
|
3098
|
-
const e =
|
|
3099
|
-
writes: n.map((t =>
|
|
3100
|
+
async function Kn(t, n) {
|
|
3101
|
+
const e = b(t), r = On(e.S) + "/documents", s = {
|
|
3102
|
+
writes: n.map((t => Un(e.S, t)))
|
|
3100
3103
|
};
|
|
3101
3104
|
await e.l("Commit", r, s);
|
|
3102
3105
|
}
|
|
3103
3106
|
|
|
3104
|
-
async function
|
|
3105
|
-
const e =
|
|
3106
|
-
documents: n.map((t =>
|
|
3107
|
+
async function Jn(t, n) {
|
|
3108
|
+
const e = b(t), r = On(e.S) + "/documents", s = {
|
|
3109
|
+
documents: n.map((t => Sn(e.S, t)))
|
|
3107
3110
|
}, i = await e.v("BatchGetDocuments", r, s), o = new Map;
|
|
3108
3111
|
i.forEach((t => {
|
|
3109
|
-
const n =
|
|
3112
|
+
const n = Ln(e.S, t);
|
|
3110
3113
|
o.set(n.key.toString(), n);
|
|
3111
3114
|
}));
|
|
3112
3115
|
const u = [];
|
|
3113
3116
|
return n.forEach((t => {
|
|
3114
3117
|
const n = o.get(t.toString());
|
|
3115
|
-
|
|
3118
|
+
g(!!n), u.push(n);
|
|
3116
3119
|
})), u;
|
|
3117
3120
|
}
|
|
3118
3121
|
|
|
3119
|
-
async function
|
|
3120
|
-
const e =
|
|
3122
|
+
async function Zn(t, n) {
|
|
3123
|
+
const e = b(t), r = jn(e.S, hn(n));
|
|
3121
3124
|
return (await e.v("RunQuery", r.parent, {
|
|
3122
3125
|
structuredQuery: r.structuredQuery
|
|
3123
3126
|
})).filter((t => !!t.document)).map((t => function(t, n, e) {
|
|
3124
|
-
const r =
|
|
3127
|
+
const r = qn(t, n.name), s = $n(n.updateTime), i = new jt({
|
|
3125
3128
|
mapValue: {
|
|
3126
3129
|
fields: n.fields
|
|
3127
3130
|
}
|
|
3128
|
-
}), o =
|
|
3131
|
+
}), o = kt.newFoundDocument(r, s, i);
|
|
3129
3132
|
return e && o.setHasCommittedMutations(), e ? o.setHasCommittedMutations() : o;
|
|
3130
3133
|
}(e.S, t.document, void 0)));
|
|
3131
3134
|
}
|
|
@@ -3145,7 +3148,7 @@ async function Xn(t, n) {
|
|
|
3145
3148
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3146
3149
|
* See the License for the specific language governing permissions and
|
|
3147
3150
|
* limitations under the License.
|
|
3148
|
-
*/ const
|
|
3151
|
+
*/ const Xn = new Map;
|
|
3149
3152
|
|
|
3150
3153
|
/**
|
|
3151
3154
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3156,17 +3159,17 @@ async function Xn(t, n) {
|
|
|
3156
3159
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3157
3160
|
* instance is terminated.
|
|
3158
3161
|
*/
|
|
3159
|
-
function
|
|
3160
|
-
if (t._terminated) throw new
|
|
3161
|
-
if (!
|
|
3162
|
-
|
|
3162
|
+
function te(t) {
|
|
3163
|
+
if (t._terminated) throw new L($, "The client has already been terminated.");
|
|
3164
|
+
if (!Xn.has(t)) {
|
|
3165
|
+
w("ComponentProvider", "Initializing Datastore");
|
|
3163
3166
|
const i = function(t) {
|
|
3164
|
-
return new
|
|
3167
|
+
return new lt(t, fetch.bind(null));
|
|
3165
3168
|
}((n = t._databaseId, e = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3166
|
-
new
|
|
3167
|
-
return new
|
|
3169
|
+
new W(n, e, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Gn(t._databaseId), u = function(t, n, e) {
|
|
3170
|
+
return new Yn(t, n, e);
|
|
3168
3171
|
}(t._credentials, i, o);
|
|
3169
|
-
|
|
3172
|
+
Xn.set(t, u);
|
|
3170
3173
|
}
|
|
3171
3174
|
var n, e, r, s;
|
|
3172
3175
|
/**
|
|
@@ -3184,7 +3187,7 @@ function ne(t) {
|
|
|
3184
3187
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3185
3188
|
* See the License for the specific language governing permissions and
|
|
3186
3189
|
* limitations under the License.
|
|
3187
|
-
*/ return
|
|
3190
|
+
*/ return Xn.get(t);
|
|
3188
3191
|
}
|
|
3189
3192
|
|
|
3190
3193
|
/**
|
|
@@ -3196,21 +3199,21 @@ function ne(t) {
|
|
|
3196
3199
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3197
3200
|
* defaults can be supplied and the value can be checked for equality.
|
|
3198
3201
|
*/
|
|
3199
|
-
class
|
|
3202
|
+
class ne {
|
|
3200
3203
|
constructor(t) {
|
|
3201
3204
|
var n;
|
|
3202
3205
|
if (void 0 === t.host) {
|
|
3203
|
-
if (void 0 !== t.ssl) throw new
|
|
3206
|
+
if (void 0 !== t.ssl) throw new L(T, "Can't provide ssl option if host option is not set");
|
|
3204
3207
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3205
3208
|
} else this.host = t.host, this.ssl = null === (n = t.ssl) || void 0 === n || n;
|
|
3206
3209
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3207
3210
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3208
|
-
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new
|
|
3211
|
+
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new L(T, "cacheSizeBytes must be at least 1048576");
|
|
3209
3212
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3210
3213
|
}
|
|
3211
3214
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3212
3215
|
this.useFetchStreams = !!t.useFetchStreams, function(t, n, e, r) {
|
|
3213
|
-
if (!0 === n && !0 === r) throw new
|
|
3216
|
+
if (!0 === n && !0 === r) throw new L(T, `${t} and ${e} cannot be used together.`);
|
|
3214
3217
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3215
3218
|
}
|
|
3216
3219
|
isEqual(t) {
|
|
@@ -3238,18 +3241,18 @@ class ee {
|
|
|
3238
3241
|
* The Cloud Firestore service interface.
|
|
3239
3242
|
*
|
|
3240
3243
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3241
|
-
*/ class
|
|
3244
|
+
*/ class ee {
|
|
3242
3245
|
/** @hideconstructor */
|
|
3243
3246
|
constructor(t, n) {
|
|
3244
3247
|
this._credentials = n,
|
|
3245
3248
|
/**
|
|
3246
3249
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3247
3250
|
*/
|
|
3248
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3249
|
-
this._settingsFrozen = !1, t instanceof
|
|
3251
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new ne({}),
|
|
3252
|
+
this._settingsFrozen = !1, t instanceof G ? this._databaseId = t : (this._app = t,
|
|
3250
3253
|
this._databaseId = function(t) {
|
|
3251
|
-
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new
|
|
3252
|
-
return new
|
|
3254
|
+
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new L(T, '"projectId" not provided in firebase.initializeApp.');
|
|
3255
|
+
return new G(t.options.projectId);
|
|
3253
3256
|
}
|
|
3254
3257
|
/**
|
|
3255
3258
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
@@ -3267,7 +3270,7 @@ class ee {
|
|
|
3267
3270
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
3268
3271
|
* instance.
|
|
3269
3272
|
*/ get app() {
|
|
3270
|
-
if (!this._app) throw new
|
|
3273
|
+
if (!this._app) throw new L($, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
|
|
3271
3274
|
return this._app;
|
|
3272
3275
|
}
|
|
3273
3276
|
get _initialized() {
|
|
@@ -3277,21 +3280,21 @@ class ee {
|
|
|
3277
3280
|
return void 0 !== this._terminateTask;
|
|
3278
3281
|
}
|
|
3279
3282
|
_setSettings(t) {
|
|
3280
|
-
if (this._settingsFrozen) throw new
|
|
3281
|
-
this._settings = new
|
|
3282
|
-
if (!t) return new
|
|
3283
|
+
if (this._settingsFrozen) throw new L($, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3284
|
+
this._settings = new ne(t), void 0 !== t.credentials && (this._credentials = function(t) {
|
|
3285
|
+
if (!t) return new k;
|
|
3283
3286
|
switch (t.type) {
|
|
3284
3287
|
case "gapi":
|
|
3285
3288
|
const n = t.client;
|
|
3286
3289
|
// Make sure this really is a Gapi client.
|
|
3287
|
-
return
|
|
3288
|
-
new
|
|
3290
|
+
return g(!("object" != typeof n || null === n || !n.auth || !n.auth.getAuthHeaderValueForFirstParty)),
|
|
3291
|
+
new z(n, t.sessionIndex || "0", t.iamToken || null);
|
|
3289
3292
|
|
|
3290
3293
|
case "provider":
|
|
3291
3294
|
return t.client;
|
|
3292
3295
|
|
|
3293
3296
|
default:
|
|
3294
|
-
throw new
|
|
3297
|
+
throw new L(T, "makeCredentialsProvider failed due to invalid credential type");
|
|
3295
3298
|
}
|
|
3296
3299
|
}(t.credentials));
|
|
3297
3300
|
}
|
|
@@ -3319,17 +3322,17 @@ class ee {
|
|
|
3319
3322
|
* Only ever called once.
|
|
3320
3323
|
*/ _terminate() {
|
|
3321
3324
|
return function(t) {
|
|
3322
|
-
const n =
|
|
3323
|
-
n && (
|
|
3325
|
+
const n = Xn.get(t);
|
|
3326
|
+
n && (w("ComponentProvider", "Removing Datastore"), Xn.delete(t), n.terminate());
|
|
3324
3327
|
}(this), Promise.resolve();
|
|
3325
3328
|
}
|
|
3326
3329
|
}
|
|
3327
3330
|
|
|
3328
|
-
function
|
|
3329
|
-
const
|
|
3330
|
-
if (
|
|
3331
|
-
return
|
|
3332
|
-
options:
|
|
3331
|
+
function re(t, n) {
|
|
3332
|
+
const e = _getProvider(t, "firestore/lite");
|
|
3333
|
+
if (e.isInitialized()) throw new L($, "Firestore can only be initialized once per app.");
|
|
3334
|
+
return e.initialize({
|
|
3335
|
+
options: n
|
|
3333
3336
|
});
|
|
3334
3337
|
}
|
|
3335
3338
|
|
|
@@ -3341,8 +3344,8 @@ function se(n, e) {
|
|
|
3341
3344
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3342
3345
|
* instance is associated with.
|
|
3343
3346
|
* @returns The `Firestore` instance of the provided app.
|
|
3344
|
-
*/ function
|
|
3345
|
-
return
|
|
3347
|
+
*/ function se(n = t()) {
|
|
3348
|
+
return _getProvider(n, "firestore/lite").getImmediate();
|
|
3346
3349
|
}
|
|
3347
3350
|
|
|
3348
3351
|
/**
|
|
@@ -3357,24 +3360,24 @@ function se(n, e) {
|
|
|
3357
3360
|
* @param port - the emulator port (ex: 9000).
|
|
3358
3361
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3359
3362
|
* Security Rules.
|
|
3360
|
-
*/ function
|
|
3363
|
+
*/ function ie(t, n, e, r = {}) {
|
|
3361
3364
|
var s;
|
|
3362
|
-
const i = (t =
|
|
3363
|
-
if ("firestore.googleapis.com" !== i.host && i.host !== n &&
|
|
3365
|
+
const i = (t = rt(t, ee))._getSettings();
|
|
3366
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== n && p("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3364
3367
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3365
3368
|
host: `${n}:${e}`,
|
|
3366
3369
|
ssl: !1
|
|
3367
3370
|
})), r.mockUserToken) {
|
|
3368
3371
|
let n, e;
|
|
3369
|
-
if ("string" == typeof r.mockUserToken) n = r.mockUserToken, e =
|
|
3372
|
+
if ("string" == typeof r.mockUserToken) n = r.mockUserToken, e = h.MOCK_USER; else {
|
|
3370
3373
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3371
3374
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3372
|
-
n =
|
|
3375
|
+
n = c(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3373
3376
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3374
|
-
if (!i) throw new
|
|
3375
|
-
e = new
|
|
3377
|
+
if (!i) throw new L(T, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3378
|
+
e = new h(i);
|
|
3376
3379
|
}
|
|
3377
|
-
t._credentials = new
|
|
3380
|
+
t._credentials = new M(new j(n, e));
|
|
3378
3381
|
}
|
|
3379
3382
|
}
|
|
3380
3383
|
|
|
@@ -3397,8 +3400,8 @@ function se(n, e) {
|
|
|
3397
3400
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3398
3401
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3399
3402
|
* terminated.
|
|
3400
|
-
*/ function
|
|
3401
|
-
return t =
|
|
3403
|
+
*/ function oe(t) {
|
|
3404
|
+
return t = rt(t, ee), n(t.app, "firestore/lite"), t._delete();
|
|
3402
3405
|
}
|
|
3403
3406
|
|
|
3404
3407
|
/**
|
|
@@ -3438,7 +3441,7 @@ function se(n, e) {
|
|
|
3438
3441
|
* and can be used to write, read, or listen to the location. The document at
|
|
3439
3442
|
* the referenced location may or may not exist.
|
|
3440
3443
|
*/
|
|
3441
|
-
class
|
|
3444
|
+
class ue {
|
|
3442
3445
|
/** @hideconstructor */
|
|
3443
3446
|
constructor(t,
|
|
3444
3447
|
/**
|
|
@@ -3466,17 +3469,17 @@ class ce {
|
|
|
3466
3469
|
/**
|
|
3467
3470
|
* The collection this `DocumentReference` belongs to.
|
|
3468
3471
|
*/ get parent() {
|
|
3469
|
-
return new
|
|
3472
|
+
return new ae(this.firestore, this.converter, this._key.path.popLast());
|
|
3470
3473
|
}
|
|
3471
3474
|
withConverter(t) {
|
|
3472
|
-
return new
|
|
3475
|
+
return new ue(this.firestore, t, this._key);
|
|
3473
3476
|
}
|
|
3474
3477
|
}
|
|
3475
3478
|
|
|
3476
3479
|
/**
|
|
3477
3480
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3478
3481
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3479
|
-
*/ class
|
|
3482
|
+
*/ class ce {
|
|
3480
3483
|
// This is the lite version of the Query class in the main SDK.
|
|
3481
3484
|
/** @hideconstructor protected */
|
|
3482
3485
|
constructor(t,
|
|
@@ -3489,17 +3492,17 @@ class ce {
|
|
|
3489
3492
|
this.type = "query", this.firestore = t;
|
|
3490
3493
|
}
|
|
3491
3494
|
withConverter(t) {
|
|
3492
|
-
return new
|
|
3495
|
+
return new ce(this.firestore, t, this._query);
|
|
3493
3496
|
}
|
|
3494
3497
|
}
|
|
3495
3498
|
|
|
3496
3499
|
/**
|
|
3497
3500
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3498
3501
|
* document references, and querying for documents (using {@link query}).
|
|
3499
|
-
*/ class
|
|
3502
|
+
*/ class ae extends ce {
|
|
3500
3503
|
/** @hideconstructor */
|
|
3501
3504
|
constructor(t, n, e) {
|
|
3502
|
-
super(t, n, new
|
|
3505
|
+
super(t, n, new rn(e)), this._path = e,
|
|
3503
3506
|
/** The type of this Firestore reference. */
|
|
3504
3507
|
this.type = "collection";
|
|
3505
3508
|
}
|
|
@@ -3517,23 +3520,23 @@ class ce {
|
|
|
3517
3520
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3518
3521
|
*/ get parent() {
|
|
3519
3522
|
const t = this._path.popLast();
|
|
3520
|
-
return t.isEmpty() ? null : new
|
|
3521
|
-
/* converter= */ null, new
|
|
3523
|
+
return t.isEmpty() ? null : new ue(this.firestore,
|
|
3524
|
+
/* converter= */ null, new Z(t));
|
|
3522
3525
|
}
|
|
3523
3526
|
withConverter(t) {
|
|
3524
|
-
return new
|
|
3527
|
+
return new ae(this.firestore, t, this._path);
|
|
3525
3528
|
}
|
|
3526
3529
|
}
|
|
3527
3530
|
|
|
3528
|
-
function
|
|
3529
|
-
if (t =
|
|
3530
|
-
const r =
|
|
3531
|
-
return
|
|
3531
|
+
function he(t, n, ...e) {
|
|
3532
|
+
if (t = a(t), X("collection", "path", n), t instanceof ee) {
|
|
3533
|
+
const r = Y.fromString(n, ...e);
|
|
3534
|
+
return nt(r), new ae(t, /* converter= */ null, r);
|
|
3532
3535
|
}
|
|
3533
3536
|
{
|
|
3534
|
-
if (!(t instanceof
|
|
3535
|
-
const r =
|
|
3536
|
-
return
|
|
3537
|
+
if (!(t instanceof ue || t instanceof ae)) throw new L(T, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3538
|
+
const r = t._path.child(Y.fromString(n, ...e));
|
|
3539
|
+
return nt(r), new ae(t.firestore,
|
|
3537
3540
|
/* converter= */ null, r);
|
|
3538
3541
|
}
|
|
3539
3542
|
}
|
|
@@ -3550,32 +3553,32 @@ function le(t, n, ...e) {
|
|
|
3550
3553
|
* collection or subcollection with this ID as the last segment of its path
|
|
3551
3554
|
* will be included. Cannot contain a slash.
|
|
3552
3555
|
* @returns The created `Query`.
|
|
3553
|
-
*/ function
|
|
3554
|
-
if (t =
|
|
3555
|
-
return new
|
|
3556
|
+
*/ function le(t, n) {
|
|
3557
|
+
if (t = rt(t, ee), X("collectionGroup", "collection id", n), n.indexOf("/") >= 0) throw new L(T, `Invalid collection ID '${n}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3558
|
+
return new ce(t,
|
|
3556
3559
|
/* converter= */ null,
|
|
3557
3560
|
/**
|
|
3558
3561
|
* Creates a new Query for a collection group query that matches all documents
|
|
3559
3562
|
* within the provided collection group.
|
|
3560
3563
|
*/
|
|
3561
3564
|
function(t) {
|
|
3562
|
-
return new
|
|
3565
|
+
return new rn(Y.emptyPath(), t);
|
|
3563
3566
|
}(n));
|
|
3564
3567
|
}
|
|
3565
3568
|
|
|
3566
|
-
function
|
|
3567
|
-
if (t =
|
|
3569
|
+
function fe(t, n, ...e) {
|
|
3570
|
+
if (t = a(t),
|
|
3568
3571
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3569
3572
|
// 'undefined' and 'null'.
|
|
3570
|
-
1 === arguments.length && (n =
|
|
3571
|
-
const r =
|
|
3572
|
-
return
|
|
3573
|
-
/* converter= */ null, new
|
|
3573
|
+
1 === arguments.length && (n = dt.A()), X("doc", "path", n), t instanceof ee) {
|
|
3574
|
+
const r = Y.fromString(n, ...e);
|
|
3575
|
+
return tt(r), new ue(t,
|
|
3576
|
+
/* converter= */ null, new Z(r));
|
|
3574
3577
|
}
|
|
3575
3578
|
{
|
|
3576
|
-
if (!(t instanceof
|
|
3577
|
-
const r = t._path.child(
|
|
3578
|
-
return
|
|
3579
|
+
if (!(t instanceof ue || t instanceof ae)) throw new L(T, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3580
|
+
const r = t._path.child(Y.fromString(n, ...e));
|
|
3581
|
+
return tt(r), new ue(t.firestore, t instanceof ae ? t.converter : null, new Z(r));
|
|
3579
3582
|
}
|
|
3580
3583
|
}
|
|
3581
3584
|
|
|
@@ -3586,8 +3589,8 @@ function de(t, n, ...e) {
|
|
|
3586
3589
|
* @param right - A reference to compare.
|
|
3587
3590
|
* @returns true if the references point to the same location in the same
|
|
3588
3591
|
* Firestore database.
|
|
3589
|
-
*/ function
|
|
3590
|
-
return t =
|
|
3592
|
+
*/ function de(t, n) {
|
|
3593
|
+
return t = a(t), n = a(n), (t instanceof ue || t instanceof ae) && (n instanceof ue || n instanceof ae) && (t.firestore === n.firestore && t.path === n.path && t.converter === n.converter);
|
|
3591
3594
|
}
|
|
3592
3595
|
|
|
3593
3596
|
/**
|
|
@@ -3598,8 +3601,8 @@ function de(t, n, ...e) {
|
|
|
3598
3601
|
* @param right - A `Query` to compare.
|
|
3599
3602
|
* @returns true if the references point to the same location in the same
|
|
3600
3603
|
* Firestore database.
|
|
3601
|
-
*/ function
|
|
3602
|
-
return t =
|
|
3604
|
+
*/ function we(t, n) {
|
|
3605
|
+
return t = a(t), n = a(n), t instanceof ce && n instanceof ce && (t.firestore === n.firestore && ln(t._query, n._query) && t.converter === n.converter);
|
|
3603
3606
|
}
|
|
3604
3607
|
|
|
3605
3608
|
/**
|
|
@@ -3625,7 +3628,7 @@ function de(t, n, ...e) {
|
|
|
3625
3628
|
*
|
|
3626
3629
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3627
3630
|
* name is provided, the path will point to a nested field in a document.
|
|
3628
|
-
*/ class
|
|
3631
|
+
*/ class me {
|
|
3629
3632
|
/**
|
|
3630
3633
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3631
3634
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3633,8 +3636,8 @@ function de(t, n, ...e) {
|
|
|
3633
3636
|
* @param fieldNames - A list of field names.
|
|
3634
3637
|
*/
|
|
3635
3638
|
constructor(...t) {
|
|
3636
|
-
for (let n = 0; n < t.length; ++n) if (0 === t[n].length) throw new
|
|
3637
|
-
this._internalPath = new
|
|
3639
|
+
for (let n = 0; n < t.length; ++n) if (0 === t[n].length) throw new L(T, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3640
|
+
this._internalPath = new J(t);
|
|
3638
3641
|
}
|
|
3639
3642
|
/**
|
|
3640
3643
|
* Returns true if this `FieldPath` is equal to the provided one.
|
|
@@ -3649,8 +3652,8 @@ function de(t, n, ...e) {
|
|
|
3649
3652
|
/**
|
|
3650
3653
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3651
3654
|
* It can be used in queries to sort or filter by the document ID.
|
|
3652
|
-
*/ function
|
|
3653
|
-
return new
|
|
3655
|
+
*/ function pe() {
|
|
3656
|
+
return new me("__name__");
|
|
3654
3657
|
}
|
|
3655
3658
|
|
|
3656
3659
|
/**
|
|
@@ -3671,7 +3674,7 @@ function de(t, n, ...e) {
|
|
|
3671
3674
|
*/
|
|
3672
3675
|
/**
|
|
3673
3676
|
* An immutable object representing an array of bytes.
|
|
3674
|
-
*/ class
|
|
3677
|
+
*/ class ye {
|
|
3675
3678
|
/** @hideconstructor */
|
|
3676
3679
|
constructor(t) {
|
|
3677
3680
|
this._byteString = t;
|
|
@@ -3683,9 +3686,9 @@ function de(t, n, ...e) {
|
|
|
3683
3686
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3684
3687
|
*/ static fromBase64String(t) {
|
|
3685
3688
|
try {
|
|
3686
|
-
return new
|
|
3689
|
+
return new ye(vt.fromBase64String(t));
|
|
3687
3690
|
} catch (t) {
|
|
3688
|
-
throw new
|
|
3691
|
+
throw new L(T, "Failed to construct data from Base64 string: " + t);
|
|
3689
3692
|
}
|
|
3690
3693
|
}
|
|
3691
3694
|
/**
|
|
@@ -3693,7 +3696,7 @@ function de(t, n, ...e) {
|
|
|
3693
3696
|
*
|
|
3694
3697
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3695
3698
|
*/ static fromUint8Array(t) {
|
|
3696
|
-
return new
|
|
3699
|
+
return new ye(vt.fromUint8Array(t));
|
|
3697
3700
|
}
|
|
3698
3701
|
/**
|
|
3699
3702
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3745,7 +3748,7 @@ function de(t, n, ...e) {
|
|
|
3745
3748
|
/**
|
|
3746
3749
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3747
3750
|
* or `update()`.
|
|
3748
|
-
*/ class
|
|
3751
|
+
*/ class _e {
|
|
3749
3752
|
/**
|
|
3750
3753
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3751
3754
|
* @hideconstructor
|
|
@@ -3777,7 +3780,7 @@ function de(t, n, ...e) {
|
|
|
3777
3780
|
*
|
|
3778
3781
|
* Latitude values are in the range of [-90, 90].
|
|
3779
3782
|
* Longitude values are in the range of [-180, 180].
|
|
3780
|
-
*/ class
|
|
3783
|
+
*/ class ge {
|
|
3781
3784
|
/**
|
|
3782
3785
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3783
3786
|
* longitude values.
|
|
@@ -3785,8 +3788,8 @@ function de(t, n, ...e) {
|
|
|
3785
3788
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3786
3789
|
*/
|
|
3787
3790
|
constructor(t, n) {
|
|
3788
|
-
if (!isFinite(t) || t < -90 || t > 90) throw new
|
|
3789
|
-
if (!isFinite(n) || n < -180 || n > 180) throw new
|
|
3791
|
+
if (!isFinite(t) || t < -90 || t > 90) throw new L(T, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3792
|
+
if (!isFinite(n) || n < -180 || n > 180) throw new L(T, "Longitude must be a number between -180 and 180, but was: " + n);
|
|
3790
3793
|
this._lat = t, this._long = n;
|
|
3791
3794
|
}
|
|
3792
3795
|
/**
|
|
@@ -3817,7 +3820,7 @@ function de(t, n, ...e) {
|
|
|
3817
3820
|
* Actually private to JS consumers of our API, so this function is prefixed
|
|
3818
3821
|
* with an underscore.
|
|
3819
3822
|
*/ _compareTo(t) {
|
|
3820
|
-
return
|
|
3823
|
+
return wt(this._lat, t._lat) || wt(this._long, t._long);
|
|
3821
3824
|
}
|
|
3822
3825
|
}
|
|
3823
3826
|
|
|
@@ -3836,29 +3839,29 @@ function de(t, n, ...e) {
|
|
|
3836
3839
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3837
3840
|
* See the License for the specific language governing permissions and
|
|
3838
3841
|
* limitations under the License.
|
|
3839
|
-
*/ const
|
|
3842
|
+
*/ const be = /^__.*__$/;
|
|
3840
3843
|
|
|
3841
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3844
|
+
/** The result of parsing document data (e.g. for a setData call). */ class ve {
|
|
3842
3845
|
constructor(t, n, e) {
|
|
3843
3846
|
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3844
3847
|
}
|
|
3845
3848
|
toMutation(t, n) {
|
|
3846
|
-
return null !== this.fieldMask ? new
|
|
3849
|
+
return null !== this.fieldMask ? new En(t, this.data, this.fieldMask, n, this.fieldTransforms) : new vn(t, this.data, n, this.fieldTransforms);
|
|
3847
3850
|
}
|
|
3848
3851
|
}
|
|
3849
3852
|
|
|
3850
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3853
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Ee {
|
|
3851
3854
|
constructor(t,
|
|
3852
3855
|
// The fieldMask does not include document transforms.
|
|
3853
3856
|
n, e) {
|
|
3854
3857
|
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3855
3858
|
}
|
|
3856
3859
|
toMutation(t, n) {
|
|
3857
|
-
return new
|
|
3860
|
+
return new En(t, this.data, this.fieldMask, n, this.fieldTransforms);
|
|
3858
3861
|
}
|
|
3859
3862
|
}
|
|
3860
3863
|
|
|
3861
|
-
function
|
|
3864
|
+
function Ie(t) {
|
|
3862
3865
|
switch (t) {
|
|
3863
3866
|
case 0 /* Set */ :
|
|
3864
3867
|
// fall through
|
|
@@ -3872,11 +3875,11 @@ function Te(t) {
|
|
|
3872
3875
|
return !1;
|
|
3873
3876
|
|
|
3874
3877
|
default:
|
|
3875
|
-
throw
|
|
3878
|
+
throw _();
|
|
3876
3879
|
}
|
|
3877
3880
|
}
|
|
3878
3881
|
|
|
3879
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3882
|
+
/** A "context" object passed around while parsing user data. */ class Te {
|
|
3880
3883
|
/**
|
|
3881
3884
|
* Initializes a ParseContext with the given source and path.
|
|
3882
3885
|
*
|
|
@@ -3908,7 +3911,7 @@ function Te(t) {
|
|
|
3908
3911
|
return this.settings.X;
|
|
3909
3912
|
}
|
|
3910
3913
|
/** Returns a new context with the specified settings overwritten. */ tt(t) {
|
|
3911
|
-
return new
|
|
3914
|
+
return new Te(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.S, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3912
3915
|
}
|
|
3913
3916
|
nt(t) {
|
|
3914
3917
|
var n;
|
|
@@ -3935,7 +3938,7 @@ function Te(t) {
|
|
|
3935
3938
|
});
|
|
3936
3939
|
}
|
|
3937
3940
|
ot(t) {
|
|
3938
|
-
return
|
|
3941
|
+
return Qe(t, this.settings.methodName, this.settings.ut || !1, this.path, this.settings.ct);
|
|
3939
3942
|
}
|
|
3940
3943
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3941
3944
|
return void 0 !== this.fieldMask.find((n => t.isPrefixOf(n))) || void 0 !== this.fieldTransforms.find((n => t.isPrefixOf(n.field)));
|
|
@@ -3947,52 +3950,52 @@ function Te(t) {
|
|
|
3947
3950
|
}
|
|
3948
3951
|
rt(t) {
|
|
3949
3952
|
if (0 === t.length) throw this.ot("Document fields must not be empty");
|
|
3950
|
-
if (
|
|
3953
|
+
if (Ie(this.X) && be.test(t)) throw this.ot('Document fields cannot begin and end with "__"');
|
|
3951
3954
|
}
|
|
3952
3955
|
}
|
|
3953
3956
|
|
|
3954
3957
|
/**
|
|
3955
3958
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3956
3959
|
* classes.
|
|
3957
|
-
*/ class
|
|
3960
|
+
*/ class Ae {
|
|
3958
3961
|
constructor(t, n, e) {
|
|
3959
|
-
this.databaseId = t, this.ignoreUndefinedProperties = n, this.S = e ||
|
|
3962
|
+
this.databaseId = t, this.ignoreUndefinedProperties = n, this.S = e || Gn(t);
|
|
3960
3963
|
}
|
|
3961
3964
|
/** Creates a new top-level parse context. */ at(t, n, e, r = !1) {
|
|
3962
|
-
return new
|
|
3965
|
+
return new Te({
|
|
3963
3966
|
X: t,
|
|
3964
3967
|
methodName: n,
|
|
3965
3968
|
ct: e,
|
|
3966
|
-
path:
|
|
3969
|
+
path: J.emptyPath(),
|
|
3967
3970
|
et: !1,
|
|
3968
3971
|
ut: r
|
|
3969
3972
|
}, this.databaseId, this.S, this.ignoreUndefinedProperties);
|
|
3970
3973
|
}
|
|
3971
3974
|
}
|
|
3972
3975
|
|
|
3973
|
-
function
|
|
3974
|
-
const n = t._freezeSettings(), e =
|
|
3975
|
-
return new
|
|
3976
|
+
function Pe(t) {
|
|
3977
|
+
const n = t._freezeSettings(), e = Gn(t._databaseId);
|
|
3978
|
+
return new Ae(t._databaseId, !!n.ignoreUndefinedProperties, e);
|
|
3976
3979
|
}
|
|
3977
3980
|
|
|
3978
|
-
/** Parse document data from a set() call. */ function
|
|
3981
|
+
/** Parse document data from a set() call. */ function Re(t, n, e, r, s, i = {}) {
|
|
3979
3982
|
const o = t.at(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , n, e, s);
|
|
3980
|
-
|
|
3981
|
-
const u =
|
|
3983
|
+
je("Data must be an object, but it was:", o, r);
|
|
3984
|
+
const u = Le(r, o);
|
|
3982
3985
|
let c, a;
|
|
3983
|
-
if (i.merge) c = new
|
|
3986
|
+
if (i.merge) c = new bt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
3984
3987
|
const t = [];
|
|
3985
3988
|
for (const r of i.mergeFields) {
|
|
3986
|
-
const s =
|
|
3987
|
-
if (!o.contains(s)) throw new
|
|
3988
|
-
|
|
3989
|
+
const s = ke(n, r, e);
|
|
3990
|
+
if (!o.contains(s)) throw new L(T, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
3991
|
+
ze(t, s) || t.push(s);
|
|
3989
3992
|
}
|
|
3990
|
-
c = new
|
|
3993
|
+
c = new bt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
3991
3994
|
} else c = null, a = o.fieldTransforms;
|
|
3992
|
-
return new
|
|
3995
|
+
return new ve(new jt(u), c, a);
|
|
3993
3996
|
}
|
|
3994
3997
|
|
|
3995
|
-
class
|
|
3998
|
+
class Ve extends _e {
|
|
3996
3999
|
_toFieldTransform(t) {
|
|
3997
4000
|
if (2 /* MergeSet */ !== t.X) throw 1 /* Update */ === t.X ? t.ot(`${this._methodName}() can only appear at the top level of your update data`) : t.ot(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
3998
4001
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4000,7 +4003,7 @@ class Ne extends ge {
|
|
|
4000
4003
|
return t.fieldMask.push(t.path), null;
|
|
4001
4004
|
}
|
|
4002
4005
|
isEqual(t) {
|
|
4003
|
-
return t instanceof
|
|
4006
|
+
return t instanceof Ve;
|
|
4004
4007
|
}
|
|
4005
4008
|
}
|
|
4006
4009
|
|
|
@@ -4019,8 +4022,8 @@ class Ne extends ge {
|
|
|
4019
4022
|
* context.
|
|
4020
4023
|
* @param context - The parent context.
|
|
4021
4024
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4022
|
-
*/ function
|
|
4023
|
-
return new
|
|
4025
|
+
*/ function Ne(t, n, e) {
|
|
4026
|
+
return new Te({
|
|
4024
4027
|
X: 3 /* Argument */ ,
|
|
4025
4028
|
ct: n.settings.ct,
|
|
4026
4029
|
methodName: t._methodName,
|
|
@@ -4028,23 +4031,23 @@ class Ne extends ge {
|
|
|
4028
4031
|
}, n.databaseId, n.S, n.ignoreUndefinedProperties);
|
|
4029
4032
|
}
|
|
4030
4033
|
|
|
4031
|
-
class
|
|
4034
|
+
class De extends _e {
|
|
4032
4035
|
_toFieldTransform(t) {
|
|
4033
|
-
return new
|
|
4036
|
+
return new _n(t.path, new wn);
|
|
4034
4037
|
}
|
|
4035
4038
|
isEqual(t) {
|
|
4036
|
-
return t instanceof
|
|
4039
|
+
return t instanceof De;
|
|
4037
4040
|
}
|
|
4038
4041
|
}
|
|
4039
4042
|
|
|
4040
|
-
class
|
|
4043
|
+
class $e extends _e {
|
|
4041
4044
|
constructor(t, n) {
|
|
4042
4045
|
super(t), this.ht = n;
|
|
4043
4046
|
}
|
|
4044
4047
|
_toFieldTransform(t) {
|
|
4045
|
-
const n =
|
|
4046
|
-
/*array=*/ !0), e = this.ht.map((t =>
|
|
4047
|
-
return new
|
|
4048
|
+
const n = Ne(this, t,
|
|
4049
|
+
/*array=*/ !0), e = this.ht.map((t => Ce(t, n))), r = new mn(e);
|
|
4050
|
+
return new _n(t.path, r);
|
|
4048
4051
|
}
|
|
4049
4052
|
isEqual(t) {
|
|
4050
4053
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4052,14 +4055,14 @@ class Fe extends ge {
|
|
|
4052
4055
|
}
|
|
4053
4056
|
}
|
|
4054
4057
|
|
|
4055
|
-
class
|
|
4058
|
+
class Fe extends _e {
|
|
4056
4059
|
constructor(t, n) {
|
|
4057
4060
|
super(t), this.ht = n;
|
|
4058
4061
|
}
|
|
4059
4062
|
_toFieldTransform(t) {
|
|
4060
|
-
const n =
|
|
4061
|
-
/*array=*/ !0), e = this.ht.map((t =>
|
|
4062
|
-
return new
|
|
4063
|
+
const n = Ne(this, t,
|
|
4064
|
+
/*array=*/ !0), e = this.ht.map((t => Ce(t, n))), r = new pn(e);
|
|
4065
|
+
return new _n(t.path, r);
|
|
4063
4066
|
}
|
|
4064
4067
|
isEqual(t) {
|
|
4065
4068
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4067,13 +4070,13 @@ class Se extends ge {
|
|
|
4067
4070
|
}
|
|
4068
4071
|
}
|
|
4069
4072
|
|
|
4070
|
-
class
|
|
4073
|
+
class Se extends _e {
|
|
4071
4074
|
constructor(t, n) {
|
|
4072
4075
|
super(t), this.lt = n;
|
|
4073
4076
|
}
|
|
4074
4077
|
_toFieldTransform(t) {
|
|
4075
|
-
const n = new
|
|
4076
|
-
return new
|
|
4078
|
+
const n = new yn(t.S, fn(t.S, this.lt));
|
|
4079
|
+
return new _n(t.path, n);
|
|
4077
4080
|
}
|
|
4078
4081
|
isEqual(t) {
|
|
4079
4082
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4081,50 +4084,50 @@ class qe extends ge {
|
|
|
4081
4084
|
}
|
|
4082
4085
|
}
|
|
4083
4086
|
|
|
4084
|
-
/** Parse update data from an update() call. */ function
|
|
4087
|
+
/** Parse update data from an update() call. */ function qe(t, n, e, r) {
|
|
4085
4088
|
const s = t.at(1 /* Update */ , n, e);
|
|
4086
|
-
|
|
4087
|
-
const i = [], o =
|
|
4088
|
-
|
|
4089
|
-
const u =
|
|
4089
|
+
je("Data must be an object, but it was:", s, r);
|
|
4090
|
+
const i = [], o = jt.empty();
|
|
4091
|
+
gt(r, ((t, r) => {
|
|
4092
|
+
const u = Be(n, t, e);
|
|
4090
4093
|
// For Compat types, we have to "extract" the underlying types before
|
|
4091
4094
|
// performing validation.
|
|
4092
|
-
r =
|
|
4095
|
+
r = a(r);
|
|
4093
4096
|
const c = s.st(u);
|
|
4094
|
-
if (r instanceof
|
|
4097
|
+
if (r instanceof Ve)
|
|
4095
4098
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4096
4099
|
i.push(u); else {
|
|
4097
|
-
const t =
|
|
4100
|
+
const t = Ce(r, c);
|
|
4098
4101
|
null != t && (i.push(u), o.set(u, t));
|
|
4099
4102
|
}
|
|
4100
4103
|
}));
|
|
4101
|
-
const u = new
|
|
4102
|
-
return new
|
|
4104
|
+
const u = new bt(i);
|
|
4105
|
+
return new Ee(o, u, s.fieldTransforms);
|
|
4103
4106
|
}
|
|
4104
4107
|
|
|
4105
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4106
|
-
const o = t.at(1 /* Update */ , n, e), u = [
|
|
4107
|
-
if (i.length % 2 != 0) throw new
|
|
4108
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4109
|
-
const
|
|
4108
|
+
/** Parse update data from a list of field/value arguments. */ function xe(t, n, e, r, s, i) {
|
|
4109
|
+
const o = t.at(1 /* Update */ , n, e), u = [ ke(n, r, e) ], c = [ s ];
|
|
4110
|
+
if (i.length % 2 != 0) throw new L(T, `Function ${n}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4111
|
+
for (let t = 0; t < i.length; t += 2) u.push(ke(n, i[t])), c.push(i[t + 1]);
|
|
4112
|
+
const h = [], l = jt.empty();
|
|
4110
4113
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4111
4114
|
// user specified the field multiple times.
|
|
4112
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4115
|
+
for (let t = u.length - 1; t >= 0; --t) if (!ze(h, u[t])) {
|
|
4113
4116
|
const n = u[t];
|
|
4114
4117
|
let e = c[t];
|
|
4115
4118
|
// For Compat types, we have to "extract" the underlying types before
|
|
4116
4119
|
// performing validation.
|
|
4117
|
-
e =
|
|
4120
|
+
e = a(e);
|
|
4118
4121
|
const r = o.st(n);
|
|
4119
|
-
if (e instanceof
|
|
4122
|
+
if (e instanceof Ve)
|
|
4120
4123
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4121
|
-
|
|
4122
|
-
const t =
|
|
4123
|
-
null != t && (
|
|
4124
|
+
h.push(n); else {
|
|
4125
|
+
const t = Ce(e, r);
|
|
4126
|
+
null != t && (h.push(n), l.set(n, t));
|
|
4124
4127
|
}
|
|
4125
4128
|
}
|
|
4126
|
-
const f = new
|
|
4127
|
-
return new
|
|
4129
|
+
const f = new bt(h);
|
|
4130
|
+
return new Ee(l, f, o.fieldTransforms);
|
|
4128
4131
|
}
|
|
4129
4132
|
|
|
4130
4133
|
/**
|
|
@@ -4133,8 +4136,8 @@ class qe extends ge {
|
|
|
4133
4136
|
*
|
|
4134
4137
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4135
4138
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4136
|
-
*/ function
|
|
4137
|
-
return
|
|
4139
|
+
*/ function Oe(t, n, e, r = !1) {
|
|
4140
|
+
return Ce(e, t.at(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , n));
|
|
4138
4141
|
}
|
|
4139
4142
|
|
|
4140
4143
|
/**
|
|
@@ -4145,12 +4148,12 @@ class qe extends ge {
|
|
|
4145
4148
|
* the source of the data being parsed, etc.
|
|
4146
4149
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4147
4150
|
* that should not be included in the resulting parsed data.
|
|
4148
|
-
*/ function
|
|
4149
|
-
if (
|
|
4151
|
+
*/ function Ce(t, n) {
|
|
4152
|
+
if (Ue(
|
|
4150
4153
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4151
4154
|
// from firestore-exp.
|
|
4152
|
-
t =
|
|
4153
|
-
if (t instanceof
|
|
4155
|
+
t = a(t))) return je("Unsupported field value:", n, t), Le(t, n);
|
|
4156
|
+
if (t instanceof _e)
|
|
4154
4157
|
// FieldValues usually parse into transforms (except FieldValue.delete())
|
|
4155
4158
|
// in which case we do not want to include this field in our parsed data
|
|
4156
4159
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4162,7 +4165,7 @@ class qe extends ge {
|
|
|
4162
4165
|
*/
|
|
4163
4166
|
return function(t, n) {
|
|
4164
4167
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4165
|
-
if (!
|
|
4168
|
+
if (!Ie(n.X)) throw n.ot(`${t._methodName}() can only be used with update() and set()`);
|
|
4166
4169
|
if (!n.path) throw n.ot(`${t._methodName}() is not currently supported inside arrays`);
|
|
4167
4170
|
const e = t._toFieldTransform(n);
|
|
4168
4171
|
e && n.fieldTransforms.push(e);
|
|
@@ -4192,7 +4195,7 @@ class qe extends ge {
|
|
|
4192
4195
|
const e = [];
|
|
4193
4196
|
let r = 0;
|
|
4194
4197
|
for (const s of t) {
|
|
4195
|
-
let t =
|
|
4198
|
+
let t = Ce(s, n.it(r));
|
|
4196
4199
|
null == t && (
|
|
4197
4200
|
// Just include nulls in the array for fields being replaced with a
|
|
4198
4201
|
// sentinel.
|
|
@@ -4208,10 +4211,10 @@ class qe extends ge {
|
|
|
4208
4211
|
}(t, n);
|
|
4209
4212
|
}
|
|
4210
4213
|
return function(t, n) {
|
|
4211
|
-
if (null === (t =
|
|
4214
|
+
if (null === (t = a(t))) return {
|
|
4212
4215
|
nullValue: "NULL_VALUE"
|
|
4213
4216
|
};
|
|
4214
|
-
if ("number" == typeof t) return
|
|
4217
|
+
if ("number" == typeof t) return fn(n.S, t);
|
|
4215
4218
|
if ("boolean" == typeof t) return {
|
|
4216
4219
|
booleanValue: t
|
|
4217
4220
|
};
|
|
@@ -4219,37 +4222,37 @@ class qe extends ge {
|
|
|
4219
4222
|
stringValue: t
|
|
4220
4223
|
};
|
|
4221
4224
|
if (t instanceof Date) {
|
|
4222
|
-
const e =
|
|
4225
|
+
const e = pt.fromDate(t);
|
|
4223
4226
|
return {
|
|
4224
|
-
timestampValue:
|
|
4227
|
+
timestampValue: Vn(n.S, e)
|
|
4225
4228
|
};
|
|
4226
4229
|
}
|
|
4227
|
-
if (t instanceof
|
|
4230
|
+
if (t instanceof pt) {
|
|
4228
4231
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4229
4232
|
// offline mode works the same with regards to truncation, perform the
|
|
4230
4233
|
// truncation immediately without waiting for the backend to do that.
|
|
4231
|
-
const e = new
|
|
4234
|
+
const e = new pt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4232
4235
|
return {
|
|
4233
|
-
timestampValue:
|
|
4236
|
+
timestampValue: Vn(n.S, e)
|
|
4234
4237
|
};
|
|
4235
4238
|
}
|
|
4236
|
-
if (t instanceof
|
|
4239
|
+
if (t instanceof ge) return {
|
|
4237
4240
|
geoPointValue: {
|
|
4238
4241
|
latitude: t.latitude,
|
|
4239
4242
|
longitude: t.longitude
|
|
4240
4243
|
}
|
|
4241
4244
|
};
|
|
4242
|
-
if (t instanceof
|
|
4243
|
-
bytesValue:
|
|
4245
|
+
if (t instanceof ye) return {
|
|
4246
|
+
bytesValue: Nn(n.S, t._byteString)
|
|
4244
4247
|
};
|
|
4245
|
-
if (t instanceof
|
|
4248
|
+
if (t instanceof ue) {
|
|
4246
4249
|
const e = n.databaseId, r = t.firestore._databaseId;
|
|
4247
4250
|
if (!r.isEqual(e)) throw n.ot(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${e.projectId}/${e.database}`);
|
|
4248
4251
|
return {
|
|
4249
|
-
referenceValue:
|
|
4252
|
+
referenceValue: Fn(t.firestore._databaseId || n.databaseId, t._key.path)
|
|
4250
4253
|
};
|
|
4251
4254
|
}
|
|
4252
|
-
throw n.ot(`Unsupported field value: ${
|
|
4255
|
+
throw n.ot(`Unsupported field value: ${et(t)}`);
|
|
4253
4256
|
}
|
|
4254
4257
|
/**
|
|
4255
4258
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4260,13 +4263,13 @@ class qe extends ge {
|
|
|
4260
4263
|
*/ (t, n);
|
|
4261
4264
|
}
|
|
4262
4265
|
|
|
4263
|
-
function
|
|
4266
|
+
function Le(t, n) {
|
|
4264
4267
|
const e = {};
|
|
4265
4268
|
return !function(t) {
|
|
4266
4269
|
for (const n in t) if (Object.prototype.hasOwnProperty.call(t, n)) return !1;
|
|
4267
4270
|
return !0;
|
|
4268
|
-
}(t) ?
|
|
4269
|
-
const s =
|
|
4271
|
+
}(t) ? gt(t, ((t, r) => {
|
|
4272
|
+
const s = Ce(r, n.nt(t));
|
|
4270
4273
|
null != s && (e[t] = s);
|
|
4271
4274
|
})) :
|
|
4272
4275
|
// If we encounter an empty object, we explicitly add it to the update
|
|
@@ -4278,35 +4281,35 @@ function Ue(t, n) {
|
|
|
4278
4281
|
};
|
|
4279
4282
|
}
|
|
4280
4283
|
|
|
4281
|
-
function
|
|
4282
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof
|
|
4284
|
+
function Ue(t) {
|
|
4285
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof pt || t instanceof ge || t instanceof ye || t instanceof ue || t instanceof _e);
|
|
4283
4286
|
}
|
|
4284
4287
|
|
|
4285
|
-
function
|
|
4286
|
-
if (!
|
|
4288
|
+
function je(t, n, e) {
|
|
4289
|
+
if (!Ue(e) || !function(t) {
|
|
4287
4290
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4288
4291
|
}(e)) {
|
|
4289
|
-
const r =
|
|
4292
|
+
const r = et(e);
|
|
4290
4293
|
throw "an object" === r ? n.ot(t + " a custom object") : n.ot(t + " " + r);
|
|
4291
4294
|
}
|
|
4292
4295
|
}
|
|
4293
4296
|
|
|
4294
4297
|
/**
|
|
4295
4298
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4296
|
-
*/ function
|
|
4299
|
+
*/ function ke(t, n, e) {
|
|
4297
4300
|
if ((
|
|
4298
4301
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4299
4302
|
// FieldPath.
|
|
4300
|
-
n =
|
|
4301
|
-
if ("string" == typeof n) return
|
|
4302
|
-
throw
|
|
4303
|
+
n = a(n)) instanceof me) return n._internalPath;
|
|
4304
|
+
if ("string" == typeof n) return Be(t, n);
|
|
4305
|
+
throw Qe("Field path arguments must be of type string or FieldPath.", t,
|
|
4303
4306
|
/* hasConverter= */ !1,
|
|
4304
4307
|
/* path= */ void 0, e);
|
|
4305
4308
|
}
|
|
4306
4309
|
|
|
4307
4310
|
/**
|
|
4308
4311
|
* Matches any characters in a field path string that are reserved.
|
|
4309
|
-
*/ const
|
|
4312
|
+
*/ const Me = new RegExp("[~\\*/\\[\\]]");
|
|
4310
4313
|
|
|
4311
4314
|
/**
|
|
4312
4315
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4316,29 +4319,29 @@ function ke(t, n, e) {
|
|
|
4316
4319
|
* split on dots.
|
|
4317
4320
|
* @param targetDoc - The document against which the field path will be
|
|
4318
4321
|
* evaluated.
|
|
4319
|
-
*/ function
|
|
4320
|
-
if (n.search(
|
|
4322
|
+
*/ function Be(t, n, e) {
|
|
4323
|
+
if (n.search(Me) >= 0) throw Qe(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4321
4324
|
/* hasConverter= */ !1,
|
|
4322
4325
|
/* path= */ void 0, e);
|
|
4323
4326
|
try {
|
|
4324
|
-
return new
|
|
4327
|
+
return new me(...n.split("."))._internalPath;
|
|
4325
4328
|
} catch (r) {
|
|
4326
|
-
throw
|
|
4329
|
+
throw Qe(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4327
4330
|
/* hasConverter= */ !1,
|
|
4328
4331
|
/* path= */ void 0, e);
|
|
4329
4332
|
}
|
|
4330
4333
|
}
|
|
4331
4334
|
|
|
4332
|
-
function
|
|
4335
|
+
function Qe(t, n, e, r, s) {
|
|
4333
4336
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4334
4337
|
let u = `Function ${n}() called with invalid data`;
|
|
4335
4338
|
e && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4336
4339
|
let c = "";
|
|
4337
4340
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4338
|
-
c += ")"), new
|
|
4341
|
+
c += ")"), new L(T, u + t + c);
|
|
4339
4342
|
}
|
|
4340
4343
|
|
|
4341
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4344
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function ze(t, n) {
|
|
4342
4345
|
return t.some((t => t.isEqual(n)));
|
|
4343
4346
|
}
|
|
4344
4347
|
|
|
@@ -4366,7 +4369,7 @@ function ze(t, n, e, r, s) {
|
|
|
4366
4369
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4367
4370
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4368
4371
|
* explicitly verify a document's existence.
|
|
4369
|
-
*/ class
|
|
4372
|
+
*/ class We {
|
|
4370
4373
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4371
4374
|
// the legacy SDK. The changes are:
|
|
4372
4375
|
// - No support for SnapshotMetadata.
|
|
@@ -4382,7 +4385,7 @@ function ze(t, n, e, r, s) {
|
|
|
4382
4385
|
/**
|
|
4383
4386
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4384
4387
|
*/ get ref() {
|
|
4385
|
-
return new
|
|
4388
|
+
return new ue(this._firestore, this._converter, this._key);
|
|
4386
4389
|
}
|
|
4387
4390
|
/**
|
|
4388
4391
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4402,7 +4405,7 @@ function ze(t, n, e, r, s) {
|
|
|
4402
4405
|
if (this._converter) {
|
|
4403
4406
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4404
4407
|
// if a converter has been provided.
|
|
4405
|
-
const t = new
|
|
4408
|
+
const t = new Ge(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4406
4409
|
/* converter= */ null);
|
|
4407
4410
|
return this._converter.fromFirestore(t);
|
|
4408
4411
|
}
|
|
@@ -4422,7 +4425,7 @@ function ze(t, n, e, r, s) {
|
|
|
4422
4425
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4423
4426
|
get(t) {
|
|
4424
4427
|
if (this._document) {
|
|
4425
|
-
const n = this._document.data.field(
|
|
4428
|
+
const n = this._document.data.field(Ke("DocumentSnapshot.get", t));
|
|
4426
4429
|
if (null !== n) return this._userDataWriter.convertValue(n);
|
|
4427
4430
|
}
|
|
4428
4431
|
}
|
|
@@ -4438,7 +4441,7 @@ function ze(t, n, e, r, s) {
|
|
|
4438
4441
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4439
4442
|
* `exists` property will always be true and `data()` will never return
|
|
4440
4443
|
* 'undefined'.
|
|
4441
|
-
*/ class
|
|
4444
|
+
*/ class Ge extends We {
|
|
4442
4445
|
/**
|
|
4443
4446
|
* Retrieves all fields in the document as an `Object`.
|
|
4444
4447
|
*
|
|
@@ -4456,7 +4459,7 @@ function ze(t, n, e, r, s) {
|
|
|
4456
4459
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4457
4460
|
* number of documents can be determined via the `empty` and `size`
|
|
4458
4461
|
* properties.
|
|
4459
|
-
*/ class
|
|
4462
|
+
*/ class He {
|
|
4460
4463
|
/** @hideconstructor */
|
|
4461
4464
|
constructor(t, n) {
|
|
4462
4465
|
this._docs = n, this.query = t;
|
|
@@ -4487,14 +4490,14 @@ function ze(t, n, e, r, s) {
|
|
|
4487
4490
|
* @param left - A snapshot to compare.
|
|
4488
4491
|
* @param right - A snapshot to compare.
|
|
4489
4492
|
* @returns true if the snapshots are equal.
|
|
4490
|
-
*/ function
|
|
4491
|
-
return t =
|
|
4493
|
+
*/ function Ye(t, n) {
|
|
4494
|
+
return t = a(t), n = a(n), t instanceof We && n instanceof We ? t._firestore === n._firestore && t._key.isEqual(n._key) && (null === t._document ? null === n._document : t._document.isEqual(n._document)) && t._converter === n._converter : t instanceof He && n instanceof He && (we(t.query, n.query) && mt(t.docs, n.docs, Ye));
|
|
4492
4495
|
}
|
|
4493
4496
|
|
|
4494
4497
|
/**
|
|
4495
4498
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4496
|
-
*/ function
|
|
4497
|
-
return "string" == typeof n ?
|
|
4499
|
+
*/ function Ke(t, n) {
|
|
4500
|
+
return "string" == typeof n ? Be(t, n) : n instanceof me ? n._internalPath : n._delegate._internalPath;
|
|
4498
4501
|
}
|
|
4499
4502
|
|
|
4500
4503
|
/**
|
|
@@ -4521,7 +4524,7 @@ function ze(t, n, e, r, s) {
|
|
|
4521
4524
|
* can then be passed to {@link query} to create a new query instance that
|
|
4522
4525
|
* also contains this `QueryConstraint`.
|
|
4523
4526
|
*/
|
|
4524
|
-
class
|
|
4527
|
+
class Je {}
|
|
4525
4528
|
|
|
4526
4529
|
/**
|
|
4527
4530
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4531,40 +4534,40 @@ class Ze {}
|
|
|
4531
4534
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4532
4535
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4533
4536
|
* existing or new constraints.
|
|
4534
|
-
*/ function
|
|
4537
|
+
*/ function Ze(t, ...n) {
|
|
4535
4538
|
for (const e of n) t = e._apply(t);
|
|
4536
4539
|
return t;
|
|
4537
4540
|
}
|
|
4538
4541
|
|
|
4539
|
-
class
|
|
4542
|
+
class Xe extends Je {
|
|
4540
4543
|
constructor(t, n, e) {
|
|
4541
4544
|
super(), this.ft = t, this.dt = n, this.wt = e, this.type = "where";
|
|
4542
4545
|
}
|
|
4543
4546
|
_apply(t) {
|
|
4544
|
-
const n =
|
|
4547
|
+
const n = Pe(t.firestore), e = function(t, n, e, r, s, i, o) {
|
|
4545
4548
|
let u;
|
|
4546
4549
|
if (s.isKeyField()) {
|
|
4547
|
-
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new
|
|
4550
|
+
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new L(T, `Invalid Query. You can't perform '${i}' queries on FieldPath.documentId().`);
|
|
4548
4551
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4549
|
-
|
|
4552
|
+
wr(o, i);
|
|
4550
4553
|
const n = [];
|
|
4551
|
-
for (const e of o) n.push(
|
|
4554
|
+
for (const e of o) n.push(dr(r, t, e));
|
|
4552
4555
|
u = {
|
|
4553
4556
|
arrayValue: {
|
|
4554
4557
|
values: n
|
|
4555
4558
|
}
|
|
4556
4559
|
};
|
|
4557
|
-
} else u =
|
|
4558
|
-
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i ||
|
|
4559
|
-
u =
|
|
4560
|
+
} else u = dr(r, t, o);
|
|
4561
|
+
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || wr(o, i),
|
|
4562
|
+
u = Oe(e, n, o,
|
|
4560
4563
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4561
|
-
const c =
|
|
4564
|
+
const c = Qt.create(s, i, u);
|
|
4562
4565
|
return function(t, n) {
|
|
4563
4566
|
if (n.N()) {
|
|
4564
|
-
const e =
|
|
4565
|
-
if (null !== e && !e.isEqual(n.field)) throw new
|
|
4566
|
-
const r =
|
|
4567
|
-
null !== r &&
|
|
4567
|
+
const e = un(t);
|
|
4568
|
+
if (null !== e && !e.isEqual(n.field)) throw new L(T, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${e.toString()}' and '${n.field.toString()}'`);
|
|
4569
|
+
const r = on(t);
|
|
4570
|
+
null !== r && mr(t, n.field, r);
|
|
4568
4571
|
}
|
|
4569
4572
|
const e = function(t, n) {
|
|
4570
4573
|
for (const e of t.filters) if (n.indexOf(e.op) >= 0) return e.op;
|
|
@@ -4605,12 +4608,12 @@ class tr extends Ze {
|
|
|
4605
4608
|
}(n.op));
|
|
4606
4609
|
if (null !== e)
|
|
4607
4610
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4608
|
-
throw e === n.op ? new
|
|
4611
|
+
throw e === n.op ? new L(T, `Invalid query. You cannot use more than one '${n.op.toString()}' filter.`) : new L(T, `Invalid query. You cannot use '${n.op.toString()}' filters with '${e.toString()}' filters.`);
|
|
4609
4612
|
}(t, c), c;
|
|
4610
4613
|
}(t._query, "where", n, t.firestore._databaseId, this.ft, this.dt, this.wt);
|
|
4611
|
-
return new
|
|
4614
|
+
return new ce(t.firestore, t.converter, function(t, n) {
|
|
4612
4615
|
const e = t.filters.concat([ n ]);
|
|
4613
|
-
return new
|
|
4616
|
+
return new rn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), e, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4614
4617
|
}(t._query, e));
|
|
4615
4618
|
}
|
|
4616
4619
|
}
|
|
@@ -4625,25 +4628,25 @@ class tr extends Ze {
|
|
|
4625
4628
|
* "<=", "!=").
|
|
4626
4629
|
* @param value - The value for comparison
|
|
4627
4630
|
* @returns The created {@link Query}.
|
|
4628
|
-
*/ function
|
|
4629
|
-
const r = n, s =
|
|
4630
|
-
return new
|
|
4631
|
+
*/ function tr(t, n, e) {
|
|
4632
|
+
const r = n, s = Ke("where", t);
|
|
4633
|
+
return new Xe(s, r, e);
|
|
4631
4634
|
}
|
|
4632
4635
|
|
|
4633
|
-
class
|
|
4636
|
+
class nr extends Je {
|
|
4634
4637
|
constructor(t, n) {
|
|
4635
4638
|
super(), this.ft = t, this.yt = n, this.type = "orderBy";
|
|
4636
4639
|
}
|
|
4637
4640
|
_apply(t) {
|
|
4638
4641
|
const n = function(t, n, e) {
|
|
4639
|
-
if (null !== t.startAt) throw new
|
|
4640
|
-
if (null !== t.endAt) throw new
|
|
4641
|
-
const r = new
|
|
4642
|
+
if (null !== t.startAt) throw new L(T, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4643
|
+
if (null !== t.endAt) throw new L(T, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4644
|
+
const r = new tn(n, e);
|
|
4642
4645
|
return function(t, n) {
|
|
4643
|
-
if (null ===
|
|
4646
|
+
if (null === on(t)) {
|
|
4644
4647
|
// This is the first order by. It must match any inequality.
|
|
4645
|
-
const e =
|
|
4646
|
-
null !== e &&
|
|
4648
|
+
const e = un(t);
|
|
4649
|
+
null !== e && mr(t, e, n.field);
|
|
4647
4650
|
}
|
|
4648
4651
|
}(t, r), r;
|
|
4649
4652
|
}
|
|
@@ -4658,10 +4661,10 @@ class er extends Ze {
|
|
|
4658
4661
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4659
4662
|
* server timestamp.
|
|
4660
4663
|
*/ (t._query, this.ft, this.yt);
|
|
4661
|
-
return new
|
|
4664
|
+
return new ce(t.firestore, t.converter, function(t, n) {
|
|
4662
4665
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4663
4666
|
const e = t.explicitOrderBy.concat([ n ]);
|
|
4664
|
-
return new
|
|
4667
|
+
return new rn(t.path, t.collectionGroup, e, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4665
4668
|
}(t._query, n));
|
|
4666
4669
|
}
|
|
4667
4670
|
}
|
|
@@ -4674,18 +4677,18 @@ class er extends Ze {
|
|
|
4674
4677
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4675
4678
|
* not specified, order will be ascending.
|
|
4676
4679
|
* @returns The created {@link Query}.
|
|
4677
|
-
*/ function
|
|
4678
|
-
const e = n, r =
|
|
4679
|
-
return new
|
|
4680
|
+
*/ function er(t, n = "asc") {
|
|
4681
|
+
const e = n, r = Ke("orderBy", t);
|
|
4682
|
+
return new nr(r, e);
|
|
4680
4683
|
}
|
|
4681
4684
|
|
|
4682
|
-
class
|
|
4685
|
+
class rr extends Je {
|
|
4683
4686
|
constructor(t, n, e) {
|
|
4684
4687
|
super(), this.type = t, this._t = n, this.gt = e;
|
|
4685
4688
|
}
|
|
4686
4689
|
_apply(t) {
|
|
4687
|
-
return new
|
|
4688
|
-
return new
|
|
4690
|
+
return new ce(t.firestore, t.converter, function(t, n, e) {
|
|
4691
|
+
return new rn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), n, e, t.startAt, t.endAt);
|
|
4689
4692
|
}(t._query, this._t, this.gt));
|
|
4690
4693
|
}
|
|
4691
4694
|
}
|
|
@@ -4695,8 +4698,8 @@ class sr extends Ze {
|
|
|
4695
4698
|
*
|
|
4696
4699
|
* @param limit - The maximum number of items to return.
|
|
4697
4700
|
* @returns The created {@link Query}.
|
|
4698
|
-
*/ function
|
|
4699
|
-
return
|
|
4701
|
+
*/ function sr(t) {
|
|
4702
|
+
return st("limit", t), new rr("limit", t, "F" /* First */);
|
|
4700
4703
|
}
|
|
4701
4704
|
|
|
4702
4705
|
/**
|
|
@@ -4707,54 +4710,54 @@ class sr extends Ze {
|
|
|
4707
4710
|
*
|
|
4708
4711
|
* @param limit - The maximum number of items to return.
|
|
4709
4712
|
* @returns The created {@link Query}.
|
|
4710
|
-
*/ function
|
|
4711
|
-
return
|
|
4713
|
+
*/ function ir(t) {
|
|
4714
|
+
return st("limitToLast", t), new rr("limitToLast", t, "L" /* Last */);
|
|
4712
4715
|
}
|
|
4713
4716
|
|
|
4714
|
-
class
|
|
4717
|
+
class or extends Je {
|
|
4715
4718
|
constructor(t, n, e) {
|
|
4716
4719
|
super(), this.type = t, this.bt = n, this.vt = e;
|
|
4717
4720
|
}
|
|
4718
4721
|
_apply(t) {
|
|
4719
|
-
const n =
|
|
4720
|
-
return new
|
|
4721
|
-
return new
|
|
4722
|
+
const n = fr(t, this.type, this.bt, this.vt);
|
|
4723
|
+
return new ce(t.firestore, t.converter, function(t, n) {
|
|
4724
|
+
return new rn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, n, t.endAt);
|
|
4722
4725
|
}(t._query, n));
|
|
4723
4726
|
}
|
|
4724
4727
|
}
|
|
4725
4728
|
|
|
4726
|
-
function
|
|
4727
|
-
return new
|
|
4729
|
+
function ur(...t) {
|
|
4730
|
+
return new or("startAt", t, /*before=*/ !0);
|
|
4728
4731
|
}
|
|
4729
4732
|
|
|
4730
|
-
function
|
|
4731
|
-
return new
|
|
4733
|
+
function cr(...t) {
|
|
4734
|
+
return new or("startAfter", t,
|
|
4732
4735
|
/*before=*/ !1);
|
|
4733
4736
|
}
|
|
4734
4737
|
|
|
4735
|
-
class
|
|
4738
|
+
class ar extends Je {
|
|
4736
4739
|
constructor(t, n, e) {
|
|
4737
4740
|
super(), this.type = t, this.bt = n, this.vt = e;
|
|
4738
4741
|
}
|
|
4739
4742
|
_apply(t) {
|
|
4740
|
-
const n =
|
|
4741
|
-
return new
|
|
4742
|
-
return new
|
|
4743
|
+
const n = fr(t, this.type, this.bt, this.vt);
|
|
4744
|
+
return new ce(t.firestore, t.converter, function(t, n) {
|
|
4745
|
+
return new rn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, n);
|
|
4743
4746
|
}(t._query, n));
|
|
4744
4747
|
}
|
|
4745
4748
|
}
|
|
4746
4749
|
|
|
4747
|
-
function
|
|
4748
|
-
return new
|
|
4750
|
+
function hr(...t) {
|
|
4751
|
+
return new ar("endBefore", t, /*before=*/ !0);
|
|
4749
4752
|
}
|
|
4750
4753
|
|
|
4751
|
-
function
|
|
4752
|
-
return new
|
|
4754
|
+
function lr(...t) {
|
|
4755
|
+
return new ar("endAt", t, /*before=*/ !1);
|
|
4753
4756
|
}
|
|
4754
4757
|
|
|
4755
|
-
/** Helper function to create a bound from a document or fields */ function
|
|
4756
|
-
if (e[0] =
|
|
4757
|
-
if (!r) throw new
|
|
4758
|
+
/** Helper function to create a bound from a document or fields */ function fr(t, n, e, r) {
|
|
4759
|
+
if (e[0] = a(e[0]), e[0] instanceof We) return function(t, n, e, r, s) {
|
|
4760
|
+
if (!r) throw new L(P, `Can't use a DocumentSnapshot that doesn't exist for ${e}().`);
|
|
4758
4761
|
const i = [];
|
|
4759
4762
|
// Because people expect to continue/end a query at the exact document
|
|
4760
4763
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4763,42 +4766,42 @@ function fr(...t) {
|
|
|
4763
4766
|
// the provided document. Without the key (by using the explicit sort
|
|
4764
4767
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4765
4768
|
// results.
|
|
4766
|
-
for (const e of
|
|
4769
|
+
for (const e of an(t)) if (e.field.isKeyField()) i.push(qt(n, r.key)); else {
|
|
4767
4770
|
const t = r.data.field(e.field);
|
|
4768
|
-
if (
|
|
4771
|
+
if (Pt(t)) throw new L(T, 'Invalid query. You are trying to start or end a query using a document for which the field "' + e.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
4769
4772
|
if (null === t) {
|
|
4770
4773
|
const t = e.field.canonicalString();
|
|
4771
|
-
throw new
|
|
4774
|
+
throw new L(T, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
4772
4775
|
}
|
|
4773
4776
|
i.push(t);
|
|
4774
4777
|
}
|
|
4775
|
-
return new
|
|
4778
|
+
return new Xt(i, s);
|
|
4776
4779
|
}
|
|
4777
4780
|
/**
|
|
4778
4781
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4779
4782
|
*/ (t._query, t.firestore._databaseId, n, e[0]._document, r);
|
|
4780
4783
|
{
|
|
4781
|
-
const s =
|
|
4784
|
+
const s = Pe(t.firestore);
|
|
4782
4785
|
return function(t, n, e, r, s, i) {
|
|
4783
4786
|
// Use explicit order by's because it has to match the query the user made
|
|
4784
4787
|
const o = t.explicitOrderBy;
|
|
4785
|
-
if (s.length > o.length) throw new
|
|
4788
|
+
if (s.length > o.length) throw new L(T, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
4786
4789
|
const u = [];
|
|
4787
4790
|
for (let i = 0; i < s.length; i++) {
|
|
4788
4791
|
const c = s[i];
|
|
4789
4792
|
if (o[i].field.isKeyField()) {
|
|
4790
|
-
if ("string" != typeof c) throw new
|
|
4791
|
-
if (!
|
|
4792
|
-
const e = t.path.child(
|
|
4793
|
-
if (!
|
|
4794
|
-
const s = new
|
|
4795
|
-
u.push(
|
|
4793
|
+
if ("string" != typeof c) throw new L(T, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4794
|
+
if (!cn(t) && -1 !== c.indexOf("/")) throw new L(T, `Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);
|
|
4795
|
+
const e = t.path.child(Y.fromString(c));
|
|
4796
|
+
if (!Z.isDocumentKey(e)) throw new L(T, `Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to ${r}() must result in a valid document path, but '${e}' is not because it contains an odd number of segments.`);
|
|
4797
|
+
const s = new Z(e);
|
|
4798
|
+
u.push(qt(n, s));
|
|
4796
4799
|
} else {
|
|
4797
|
-
const t =
|
|
4800
|
+
const t = Oe(e, r, c);
|
|
4798
4801
|
u.push(t);
|
|
4799
4802
|
}
|
|
4800
4803
|
}
|
|
4801
|
-
return new
|
|
4804
|
+
return new Xt(u, i);
|
|
4802
4805
|
}
|
|
4803
4806
|
/**
|
|
4804
4807
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
@@ -4808,28 +4811,28 @@ function fr(...t) {
|
|
|
4808
4811
|
}
|
|
4809
4812
|
}
|
|
4810
4813
|
|
|
4811
|
-
function
|
|
4812
|
-
if ("string" == typeof (e =
|
|
4813
|
-
if ("" === e) throw new
|
|
4814
|
-
if (!
|
|
4815
|
-
const r = n.path.child(
|
|
4816
|
-
if (!
|
|
4817
|
-
return
|
|
4814
|
+
function dr(t, n, e) {
|
|
4815
|
+
if ("string" == typeof (e = a(e))) {
|
|
4816
|
+
if ("" === e) throw new L(T, "Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4817
|
+
if (!cn(n) && -1 !== e.indexOf("/")) throw new L(T, `Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);
|
|
4818
|
+
const r = n.path.child(Y.fromString(e));
|
|
4819
|
+
if (!Z.isDocumentKey(r)) throw new L(T, `Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);
|
|
4820
|
+
return qt(t, new Z(r));
|
|
4818
4821
|
}
|
|
4819
|
-
if (e instanceof
|
|
4820
|
-
throw new
|
|
4822
|
+
if (e instanceof ue) return qt(t, e._key);
|
|
4823
|
+
throw new L(T, `Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${et(e)}.`);
|
|
4821
4824
|
}
|
|
4822
4825
|
|
|
4823
4826
|
/**
|
|
4824
4827
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4825
4828
|
* array requirements.
|
|
4826
|
-
*/ function
|
|
4827
|
-
if (!Array.isArray(t) || 0 === t.length) throw new
|
|
4828
|
-
if (t.length > 10) throw new
|
|
4829
|
+
*/ function wr(t, n) {
|
|
4830
|
+
if (!Array.isArray(t) || 0 === t.length) throw new L(T, `Invalid Query. A non-empty array is required for '${n.toString()}' filters.`);
|
|
4831
|
+
if (t.length > 10) throw new L(T, `Invalid Query. '${n.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4829
4832
|
}
|
|
4830
4833
|
|
|
4831
|
-
function
|
|
4832
|
-
if (!e.isEqual(n)) throw new
|
|
4834
|
+
function mr(t, n, e) {
|
|
4835
|
+
if (!e.isEqual(n)) throw new L(T, `Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${n.toString()}' and so you must also use '${n.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${e.toString()}' instead.`);
|
|
4833
4836
|
}
|
|
4834
4837
|
|
|
4835
4838
|
/**
|
|
@@ -4879,7 +4882,7 @@ function pr(t, n, e) {
|
|
|
4879
4882
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4880
4883
|
* call.
|
|
4881
4884
|
*/
|
|
4882
|
-
function
|
|
4885
|
+
function pr(t, n, e) {
|
|
4883
4886
|
let r;
|
|
4884
4887
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4885
4888
|
// toFirestore().
|
|
@@ -4888,9 +4891,9 @@ function yr(t, n, e) {
|
|
|
4888
4891
|
r;
|
|
4889
4892
|
}
|
|
4890
4893
|
|
|
4891
|
-
class
|
|
4894
|
+
class yr extends class {
|
|
4892
4895
|
convertValue(t, n = "none") {
|
|
4893
|
-
switch (
|
|
4896
|
+
switch (Nt(t)) {
|
|
4894
4897
|
case 0 /* NullValue */ :
|
|
4895
4898
|
return null;
|
|
4896
4899
|
|
|
@@ -4898,7 +4901,7 @@ class _r extends class {
|
|
|
4898
4901
|
return t.booleanValue;
|
|
4899
4902
|
|
|
4900
4903
|
case 2 /* NumberValue */ :
|
|
4901
|
-
return
|
|
4904
|
+
return Tt(t.integerValue || t.doubleValue);
|
|
4902
4905
|
|
|
4903
4906
|
case 3 /* TimestampValue */ :
|
|
4904
4907
|
return this.convertTimestamp(t.timestampValue);
|
|
@@ -4910,7 +4913,7 @@ class _r extends class {
|
|
|
4910
4913
|
return t.stringValue;
|
|
4911
4914
|
|
|
4912
4915
|
case 6 /* BlobValue */ :
|
|
4913
|
-
return this.convertBytes(
|
|
4916
|
+
return this.convertBytes(At(t.bytesValue));
|
|
4914
4917
|
|
|
4915
4918
|
case 7 /* RefValue */ :
|
|
4916
4919
|
return this.convertReference(t.referenceValue);
|
|
@@ -4925,17 +4928,17 @@ class _r extends class {
|
|
|
4925
4928
|
return this.convertObject(t.mapValue, n);
|
|
4926
4929
|
|
|
4927
4930
|
default:
|
|
4928
|
-
throw
|
|
4931
|
+
throw _();
|
|
4929
4932
|
}
|
|
4930
4933
|
}
|
|
4931
4934
|
convertObject(t, n) {
|
|
4932
4935
|
const e = {};
|
|
4933
|
-
return
|
|
4936
|
+
return gt(t.fields, ((t, r) => {
|
|
4934
4937
|
e[t] = this.convertValue(r, n);
|
|
4935
4938
|
})), e;
|
|
4936
4939
|
}
|
|
4937
4940
|
convertGeoPoint(t) {
|
|
4938
|
-
return new
|
|
4941
|
+
return new ge(Tt(t.latitude), Tt(t.longitude));
|
|
4939
4942
|
}
|
|
4940
4943
|
convertArray(t, n) {
|
|
4941
4944
|
return (t.values || []).map((t => this.convertValue(t, n)));
|
|
@@ -4943,27 +4946,27 @@ class _r extends class {
|
|
|
4943
4946
|
convertServerTimestamp(t, n) {
|
|
4944
4947
|
switch (n) {
|
|
4945
4948
|
case "previous":
|
|
4946
|
-
const e =
|
|
4949
|
+
const e = Rt(t);
|
|
4947
4950
|
return null == e ? null : this.convertValue(e, n);
|
|
4948
4951
|
|
|
4949
4952
|
case "estimate":
|
|
4950
|
-
return this.convertTimestamp(
|
|
4953
|
+
return this.convertTimestamp(Vt(t));
|
|
4951
4954
|
|
|
4952
4955
|
default:
|
|
4953
4956
|
return null;
|
|
4954
4957
|
}
|
|
4955
4958
|
}
|
|
4956
4959
|
convertTimestamp(t) {
|
|
4957
|
-
const n =
|
|
4958
|
-
return new
|
|
4960
|
+
const n = It(t);
|
|
4961
|
+
return new pt(n.seconds, n.nanos);
|
|
4959
4962
|
}
|
|
4960
4963
|
convertDocumentKey(t, n) {
|
|
4961
|
-
const e =
|
|
4962
|
-
|
|
4963
|
-
const r = new
|
|
4964
|
+
const e = Y.fromString(t);
|
|
4965
|
+
g(Wn(e));
|
|
4966
|
+
const r = new G(e.get(1), e.get(3)), s = new Z(e.popFirst(5));
|
|
4964
4967
|
return r.isEqual(n) ||
|
|
4965
4968
|
// TODO(b/64130202): Somehow support foreign references.
|
|
4966
|
-
|
|
4969
|
+
m(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),
|
|
4967
4970
|
s;
|
|
4968
4971
|
}
|
|
4969
4972
|
} {
|
|
@@ -4971,11 +4974,11 @@ class _r extends class {
|
|
|
4971
4974
|
super(), this.firestore = t;
|
|
4972
4975
|
}
|
|
4973
4976
|
convertBytes(t) {
|
|
4974
|
-
return new
|
|
4977
|
+
return new ye(t);
|
|
4975
4978
|
}
|
|
4976
4979
|
convertReference(t) {
|
|
4977
4980
|
const n = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
4978
|
-
return new
|
|
4981
|
+
return new ue(this.firestore, /* converter= */ null, n);
|
|
4979
4982
|
}
|
|
4980
4983
|
}
|
|
4981
4984
|
|
|
@@ -4991,12 +4994,12 @@ class _r extends class {
|
|
|
4991
4994
|
* @param reference - The reference of the document to fetch.
|
|
4992
4995
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
4993
4996
|
* document contents.
|
|
4994
|
-
*/ function
|
|
4995
|
-
const n =
|
|
4996
|
-
return
|
|
4997
|
-
|
|
4997
|
+
*/ function _r(t) {
|
|
4998
|
+
const n = te((t = rt(t, ue)).firestore), e = new yr(t.firestore);
|
|
4999
|
+
return Jn(n, [ t._key ]).then((n => {
|
|
5000
|
+
g(1 === n.length);
|
|
4998
5001
|
const r = n[0];
|
|
4999
|
-
return new
|
|
5002
|
+
return new We(t.firestore, e, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5000
5003
|
}));
|
|
5001
5004
|
}
|
|
5002
5005
|
|
|
@@ -5011,33 +5014,33 @@ class _r extends class {
|
|
|
5011
5014
|
*
|
|
5012
5015
|
* @param query - The `Query` to execute.
|
|
5013
5016
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5014
|
-
*/ function
|
|
5017
|
+
*/ function gr(t) {
|
|
5015
5018
|
!function(t) {
|
|
5016
|
-
if (
|
|
5017
|
-
}((t =
|
|
5018
|
-
const n =
|
|
5019
|
-
return
|
|
5020
|
-
const r = n.map((n => new
|
|
5021
|
-
return
|
|
5019
|
+
if (sn(t) && 0 === t.explicitOrderBy.length) throw new L(q, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5020
|
+
}((t = rt(t, ce))._query);
|
|
5021
|
+
const n = te(t.firestore), e = new yr(t.firestore);
|
|
5022
|
+
return Zn(n, t._query).then((n => {
|
|
5023
|
+
const r = n.map((n => new Ge(t.firestore, e, n.key, n, t.converter)));
|
|
5024
|
+
return sn(t._query) &&
|
|
5022
5025
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5023
5026
|
// specified by the user. As such, we need to reverse the order of the
|
|
5024
5027
|
// results to return the documents in the expected order.
|
|
5025
|
-
r.reverse(), new
|
|
5028
|
+
r.reverse(), new He(t, r);
|
|
5026
5029
|
}));
|
|
5027
5030
|
}
|
|
5028
5031
|
|
|
5029
|
-
function
|
|
5030
|
-
const r =
|
|
5031
|
-
return
|
|
5032
|
+
function br(t, n, e) {
|
|
5033
|
+
const r = pr((t = rt(t, ue)).converter, n, e), s = Re(Pe(t.firestore), "setDoc", t._key, r, null !== t.converter, e);
|
|
5034
|
+
return Kn(te(t.firestore), [ s.toMutation(t._key, gn.none()) ]);
|
|
5032
5035
|
}
|
|
5033
5036
|
|
|
5034
|
-
function
|
|
5035
|
-
const s =
|
|
5037
|
+
function vr(t, n, e, ...r) {
|
|
5038
|
+
const s = Pe((t = rt(t, ue)).firestore);
|
|
5036
5039
|
// For Compat types, we have to "extract" the underlying types before
|
|
5037
5040
|
// performing validation.
|
|
5038
5041
|
let i;
|
|
5039
|
-
i = "string" == typeof (n =
|
|
5040
|
-
return
|
|
5042
|
+
i = "string" == typeof (n = a(n)) || n instanceof me ? xe(s, "updateDoc", t._key, n, e, r) : qe(s, "updateDoc", t._key, n);
|
|
5043
|
+
return Kn(te(t.firestore), [ i.toMutation(t._key, gn.exists(!0)) ]);
|
|
5041
5044
|
}
|
|
5042
5045
|
|
|
5043
5046
|
/**
|
|
@@ -5051,8 +5054,8 @@ function Er(t, n, e, ...r) {
|
|
|
5051
5054
|
* @param reference - A reference to the document to delete.
|
|
5052
5055
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5053
5056
|
* deleted from the backend.
|
|
5054
|
-
*/ function
|
|
5055
|
-
return
|
|
5057
|
+
*/ function Er(t) {
|
|
5058
|
+
return Kn(te((t = rt(t, ue)).firestore), [ new In(t._key, gn.none()) ]);
|
|
5056
5059
|
}
|
|
5057
5060
|
|
|
5058
5061
|
/**
|
|
@@ -5068,9 +5071,9 @@ function Er(t, n, e, ...r) {
|
|
|
5068
5071
|
* @param data - An Object containing the data for the new document.
|
|
5069
5072
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5070
5073
|
* newly created document after it has been written to the backend.
|
|
5071
|
-
*/ function
|
|
5072
|
-
const e =
|
|
5073
|
-
return
|
|
5074
|
+
*/ function Ir(t, n) {
|
|
5075
|
+
const e = fe(t = rt(t, ae)), r = pr(t.converter, n), s = Re(Pe(t.firestore), "addDoc", e._key, r, null !== e.converter, {});
|
|
5076
|
+
return Kn(te(t.firestore), [ s.toMutation(e._key, gn.exists(!1)) ]).then((() => e));
|
|
5074
5077
|
}
|
|
5075
5078
|
|
|
5076
5079
|
/**
|
|
@@ -5092,15 +5095,15 @@ function Er(t, n, e, ...r) {
|
|
|
5092
5095
|
/**
|
|
5093
5096
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5094
5097
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5095
|
-
*/ function
|
|
5096
|
-
return new
|
|
5098
|
+
*/ function Tr() {
|
|
5099
|
+
return new Ve("deleteField");
|
|
5097
5100
|
}
|
|
5098
5101
|
|
|
5099
5102
|
/**
|
|
5100
5103
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5101
5104
|
* include a server-generated timestamp in the written data.
|
|
5102
|
-
*/ function
|
|
5103
|
-
return new
|
|
5105
|
+
*/ function Ar() {
|
|
5106
|
+
return new De("serverTimestamp");
|
|
5104
5107
|
}
|
|
5105
5108
|
|
|
5106
5109
|
/**
|
|
@@ -5114,10 +5117,10 @@ function Er(t, n, e, ...r) {
|
|
|
5114
5117
|
* @param elements - The elements to union into the array.
|
|
5115
5118
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5116
5119
|
* `updateDoc()`.
|
|
5117
|
-
*/ function
|
|
5120
|
+
*/ function Pr(...t) {
|
|
5118
5121
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5119
5122
|
// update() since we'd need the Firestore instance to do this.
|
|
5120
|
-
return new
|
|
5123
|
+
return new $e("arrayUnion", t);
|
|
5121
5124
|
}
|
|
5122
5125
|
|
|
5123
5126
|
/**
|
|
@@ -5130,10 +5133,10 @@ function Er(t, n, e, ...r) {
|
|
|
5130
5133
|
* @param elements - The elements to remove from the array.
|
|
5131
5134
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5132
5135
|
* `updateDoc()`
|
|
5133
|
-
*/ function
|
|
5136
|
+
*/ function Rr(...t) {
|
|
5134
5137
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5135
5138
|
// update() since we'd need the Firestore instance to do this.
|
|
5136
|
-
return new
|
|
5139
|
+
return new Fe("arrayRemove", t);
|
|
5137
5140
|
}
|
|
5138
5141
|
|
|
5139
5142
|
/**
|
|
@@ -5154,8 +5157,8 @@ function Er(t, n, e, ...r) {
|
|
|
5154
5157
|
* @param n - The value to increment by.
|
|
5155
5158
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5156
5159
|
* `updateDoc()`
|
|
5157
|
-
*/ function
|
|
5158
|
-
return new
|
|
5160
|
+
*/ function Vr(t) {
|
|
5161
|
+
return new Se("increment", t);
|
|
5159
5162
|
}
|
|
5160
5163
|
|
|
5161
5164
|
/**
|
|
@@ -5181,25 +5184,25 @@ function Er(t, n, e, ...r) {
|
|
|
5181
5184
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5182
5185
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5183
5186
|
* called.
|
|
5184
|
-
*/ class
|
|
5187
|
+
*/ class Nr {
|
|
5185
5188
|
/** @hideconstructor */
|
|
5186
5189
|
constructor(t, n) {
|
|
5187
5190
|
this._firestore = t, this._commitHandler = n, this._mutations = [], this._committed = !1,
|
|
5188
|
-
this._dataReader =
|
|
5191
|
+
this._dataReader = Pe(t);
|
|
5189
5192
|
}
|
|
5190
5193
|
set(t, n, e) {
|
|
5191
5194
|
this._verifyNotCommitted();
|
|
5192
|
-
const r =
|
|
5193
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5195
|
+
const r = Dr(t, this._firestore), s = pr(r.converter, n, e), i = Re(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, e);
|
|
5196
|
+
return this._mutations.push(i.toMutation(r._key, gn.none())), this;
|
|
5194
5197
|
}
|
|
5195
5198
|
update(t, n, e, ...r) {
|
|
5196
5199
|
this._verifyNotCommitted();
|
|
5197
|
-
const s =
|
|
5200
|
+
const s = Dr(t, this._firestore);
|
|
5198
5201
|
// For Compat types, we have to "extract" the underlying types before
|
|
5199
5202
|
// performing validation.
|
|
5200
5203
|
let i;
|
|
5201
|
-
return i = "string" == typeof (n =
|
|
5202
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5204
|
+
return i = "string" == typeof (n = a(n)) || n instanceof me ? xe(this._dataReader, "WriteBatch.update", s._key, n, e, r) : qe(this._dataReader, "WriteBatch.update", s._key, n),
|
|
5205
|
+
this._mutations.push(i.toMutation(s._key, gn.exists(!0))), this;
|
|
5203
5206
|
}
|
|
5204
5207
|
/**
|
|
5205
5208
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5208,8 +5211,8 @@ function Er(t, n, e, ...r) {
|
|
|
5208
5211
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5209
5212
|
*/ delete(t) {
|
|
5210
5213
|
this._verifyNotCommitted();
|
|
5211
|
-
const n =
|
|
5212
|
-
return this._mutations = this._mutations.concat(new
|
|
5214
|
+
const n = Dr(t, this._firestore);
|
|
5215
|
+
return this._mutations = this._mutations.concat(new In(n._key, gn.none())), this;
|
|
5213
5216
|
}
|
|
5214
5217
|
/**
|
|
5215
5218
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5226,12 +5229,12 @@ function Er(t, n, e, ...r) {
|
|
|
5226
5229
|
return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
|
|
5227
5230
|
}
|
|
5228
5231
|
_verifyNotCommitted() {
|
|
5229
|
-
if (this._committed) throw new
|
|
5232
|
+
if (this._committed) throw new L($, "A write batch can no longer be used after commit() has been called.");
|
|
5230
5233
|
}
|
|
5231
5234
|
}
|
|
5232
5235
|
|
|
5233
|
-
function
|
|
5234
|
-
if ((t =
|
|
5236
|
+
function Dr(t, n) {
|
|
5237
|
+
if ((t = a(t)).firestore !== n) throw new L(T, "Provided document reference is from a different Firestore instance.");
|
|
5235
5238
|
return t;
|
|
5236
5239
|
}
|
|
5237
5240
|
|
|
@@ -5247,9 +5250,9 @@ function $r(t, n) {
|
|
|
5247
5250
|
*
|
|
5248
5251
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5249
5252
|
* writes.
|
|
5250
|
-
*/ function
|
|
5251
|
-
const n =
|
|
5252
|
-
return new
|
|
5253
|
+
*/ function $r(t) {
|
|
5254
|
+
const n = te(t = rt(t, ee));
|
|
5255
|
+
return new Nr(t, (t => Kn(n, t)));
|
|
5253
5256
|
}
|
|
5254
5257
|
|
|
5255
5258
|
/**
|
|
@@ -5271,7 +5274,7 @@ function $r(t, n) {
|
|
|
5271
5274
|
/**
|
|
5272
5275
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5273
5276
|
* perform and the base versions for any documents read.
|
|
5274
|
-
*/ class
|
|
5277
|
+
*/ class Fr {
|
|
5275
5278
|
constructor(t) {
|
|
5276
5279
|
this.datastore = t,
|
|
5277
5280
|
// The version of each document that was read during this transaction.
|
|
@@ -5290,8 +5293,8 @@ function $r(t, n) {
|
|
|
5290
5293
|
this.writtenDocs = new Set;
|
|
5291
5294
|
}
|
|
5292
5295
|
async lookup(t) {
|
|
5293
|
-
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new
|
|
5294
|
-
const n = await
|
|
5296
|
+
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new L(T, "Firestore transactions require all reads to be executed before all writes.");
|
|
5297
|
+
const n = await Jn(this.datastore, t);
|
|
5295
5298
|
return n.forEach((t => this.recordVersion(t))), n;
|
|
5296
5299
|
}
|
|
5297
5300
|
set(t, n) {
|
|
@@ -5306,7 +5309,7 @@ function $r(t, n) {
|
|
|
5306
5309
|
this.writtenDocs.add(t.toString());
|
|
5307
5310
|
}
|
|
5308
5311
|
delete(t) {
|
|
5309
|
-
this.write(new
|
|
5312
|
+
this.write(new In(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5310
5313
|
}
|
|
5311
5314
|
async commit() {
|
|
5312
5315
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
@@ -5318,22 +5321,22 @@ function $r(t, n) {
|
|
|
5318
5321
|
// For each document that was read but not written to, we want to perform
|
|
5319
5322
|
// a `verify` operation.
|
|
5320
5323
|
t.forEach(((t, n) => {
|
|
5321
|
-
const e =
|
|
5322
|
-
this.mutations.push(new
|
|
5323
|
-
})), await
|
|
5324
|
+
const e = Z.fromPath(n);
|
|
5325
|
+
this.mutations.push(new Tn(e, this.precondition(e)));
|
|
5326
|
+
})), await Kn(this.datastore, this.mutations), this.committed = !0;
|
|
5324
5327
|
}
|
|
5325
5328
|
recordVersion(t) {
|
|
5326
5329
|
let n;
|
|
5327
5330
|
if (t.isFoundDocument()) n = t.version; else {
|
|
5328
|
-
if (!t.isNoDocument()) throw
|
|
5331
|
+
if (!t.isNoDocument()) throw _();
|
|
5329
5332
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5330
|
-
n =
|
|
5333
|
+
n = yt.min();
|
|
5331
5334
|
}
|
|
5332
5335
|
const e = this.readVersions.get(t.key.toString());
|
|
5333
5336
|
if (e) {
|
|
5334
5337
|
if (!n.isEqual(e))
|
|
5335
5338
|
// This transaction will fail no matter what.
|
|
5336
|
-
throw new
|
|
5339
|
+
throw new L(F, "Document version changed between two reads.");
|
|
5337
5340
|
} else this.readVersions.set(t.key.toString(), n);
|
|
5338
5341
|
}
|
|
5339
5342
|
/**
|
|
@@ -5341,7 +5344,7 @@ function $r(t, n) {
|
|
|
5341
5344
|
* as a precondition, or no precondition if it was not read.
|
|
5342
5345
|
*/ precondition(t) {
|
|
5343
5346
|
const n = this.readVersions.get(t.toString());
|
|
5344
|
-
return !this.writtenDocs.has(t.toString()) && n ?
|
|
5347
|
+
return !this.writtenDocs.has(t.toString()) && n ? gn.updateTime(n) : gn.none();
|
|
5345
5348
|
}
|
|
5346
5349
|
/**
|
|
5347
5350
|
* Returns the precondition for a document if the operation is an update.
|
|
@@ -5350,7 +5353,7 @@ function $r(t, n) {
|
|
|
5350
5353
|
// The first time a document is written, we want to take into account the
|
|
5351
5354
|
// read time and existence
|
|
5352
5355
|
if (!this.writtenDocs.has(t.toString()) && n) {
|
|
5353
|
-
if (n.isEqual(
|
|
5356
|
+
if (n.isEqual(yt.min()))
|
|
5354
5357
|
// The document doesn't exist, so fail the transaction.
|
|
5355
5358
|
// This has to be validated locally because you can't send a
|
|
5356
5359
|
// precondition that a document does not exist without changing the
|
|
@@ -5360,13 +5363,13 @@ function $r(t, n) {
|
|
|
5360
5363
|
// express that to the backend, we have to validate locally.
|
|
5361
5364
|
// Note: this can change once we can send separate verify writes in the
|
|
5362
5365
|
// transaction.
|
|
5363
|
-
throw new
|
|
5366
|
+
throw new L(T, "Can't update a document that doesn't exist.");
|
|
5364
5367
|
// Document exists, base precondition on document update time.
|
|
5365
|
-
return
|
|
5368
|
+
return gn.updateTime(n);
|
|
5366
5369
|
}
|
|
5367
5370
|
// Document was not read, so we just use the preconditions for a blind
|
|
5368
5371
|
// update.
|
|
5369
|
-
return
|
|
5372
|
+
return gn.exists(!0);
|
|
5370
5373
|
}
|
|
5371
5374
|
write(t) {
|
|
5372
5375
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5394,17 +5397,17 @@ function $r(t, n) {
|
|
|
5394
5397
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
5395
5398
|
* with backoff.
|
|
5396
5399
|
*/
|
|
5397
|
-
class
|
|
5400
|
+
class Sr {
|
|
5398
5401
|
constructor(t, n, e, r) {
|
|
5399
5402
|
this.asyncQueue = t, this.datastore = n, this.updateFunction = e, this.deferred = r,
|
|
5400
|
-
this.Et = 5, this.It = new
|
|
5403
|
+
this.Et = 5, this.It = new Hn(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5401
5404
|
}
|
|
5402
5405
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5403
5406
|
this.Et -= 1, this.Tt();
|
|
5404
5407
|
}
|
|
5405
5408
|
Tt() {
|
|
5406
5409
|
this.It.W((async () => {
|
|
5407
|
-
const t = new
|
|
5410
|
+
const t = new Fr(this.datastore), n = this.At(t);
|
|
5408
5411
|
n && n.then((n => {
|
|
5409
5412
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5410
5413
|
this.deferred.resolve(n);
|
|
@@ -5419,7 +5422,7 @@ class qr {
|
|
|
5419
5422
|
At(t) {
|
|
5420
5423
|
try {
|
|
5421
5424
|
const n = this.updateFunction(t);
|
|
5422
|
-
return !
|
|
5425
|
+
return !it(n) && n.catch && n.then ? n : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5423
5426
|
null);
|
|
5424
5427
|
} catch (t) {
|
|
5425
5428
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5444,36 +5447,36 @@ class qr {
|
|
|
5444
5447
|
*/
|
|
5445
5448
|
function(t) {
|
|
5446
5449
|
switch (t) {
|
|
5447
|
-
case
|
|
5448
|
-
return
|
|
5450
|
+
case v:
|
|
5451
|
+
return _();
|
|
5449
5452
|
|
|
5453
|
+
case E:
|
|
5450
5454
|
case I:
|
|
5451
|
-
case
|
|
5452
|
-
case
|
|
5453
|
-
case
|
|
5455
|
+
case A:
|
|
5456
|
+
case D:
|
|
5457
|
+
case x:
|
|
5454
5458
|
case O:
|
|
5455
|
-
case C:
|
|
5456
5459
|
// Unauthenticated means something went wrong with our token and we need
|
|
5457
5460
|
// to retry with new credentials which will happen automatically.
|
|
5458
|
-
case
|
|
5461
|
+
case N:
|
|
5459
5462
|
return !1;
|
|
5460
5463
|
|
|
5461
|
-
case
|
|
5464
|
+
case T:
|
|
5465
|
+
case P:
|
|
5462
5466
|
case R:
|
|
5463
5467
|
case V:
|
|
5464
|
-
case
|
|
5465
|
-
case F:
|
|
5468
|
+
case $:
|
|
5466
5469
|
// Aborted might be retried in some scenarios, but that is dependant on
|
|
5467
5470
|
// the context and should handled individually by the calling code.
|
|
5468
5471
|
// See https://cloud.google.com/apis/design/errors.
|
|
5469
|
-
case
|
|
5472
|
+
case F:
|
|
5473
|
+
case S:
|
|
5470
5474
|
case q:
|
|
5471
|
-
case
|
|
5472
|
-
case L:
|
|
5475
|
+
case C:
|
|
5473
5476
|
return !0;
|
|
5474
5477
|
|
|
5475
5478
|
default:
|
|
5476
|
-
return
|
|
5479
|
+
return _();
|
|
5477
5480
|
}
|
|
5478
5481
|
}(n);
|
|
5479
5482
|
}
|
|
@@ -5497,7 +5500,7 @@ class qr {
|
|
|
5497
5500
|
* See the License for the specific language governing permissions and
|
|
5498
5501
|
* limitations under the License.
|
|
5499
5502
|
*/
|
|
5500
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
5503
|
+
/** The Platform's 'document' implementation or null if not available. */ function qr() {
|
|
5501
5504
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
5502
5505
|
// eslint-disable-next-line no-restricted-globals
|
|
5503
5506
|
return "undefined" != typeof document ? document : null;
|
|
@@ -5529,10 +5532,10 @@ class qr {
|
|
|
5529
5532
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
5530
5533
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5531
5534
|
* IE.
|
|
5532
|
-
*/ class
|
|
5535
|
+
*/ class xr {
|
|
5533
5536
|
constructor(t, n, e, r, s) {
|
|
5534
5537
|
this.asyncQueue = t, this.timerId = n, this.targetTimeMs = e, this.op = r, this.removalCallback = s,
|
|
5535
|
-
this.deferred = new
|
|
5538
|
+
this.deferred = new U, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5536
5539
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5537
5540
|
// and so we attach a dummy catch callback to avoid
|
|
5538
5541
|
// 'UnhandledPromiseRejectionWarning' log spam.
|
|
@@ -5552,7 +5555,7 @@ class qr {
|
|
|
5552
5555
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5553
5556
|
* the DelayedOperation class public.
|
|
5554
5557
|
*/ static createAndSchedule(t, n, e, r, s) {
|
|
5555
|
-
const i = Date.now() + e, o = new
|
|
5558
|
+
const i = Date.now() + e, o = new xr(t, n, i, r, s);
|
|
5556
5559
|
return o.start(e), o;
|
|
5557
5560
|
}
|
|
5558
5561
|
/**
|
|
@@ -5574,7 +5577,7 @@ class qr {
|
|
|
5574
5577
|
* As long as the operation has not yet been run, calling cancel() provides a
|
|
5575
5578
|
* guarantee that the operation will not be run.
|
|
5576
5579
|
*/ cancel(t) {
|
|
5577
|
-
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new
|
|
5580
|
+
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new L(E, "Operation cancelled" + (t ? ": " + t : ""))));
|
|
5578
5581
|
}
|
|
5579
5582
|
handleDelayElapsed() {
|
|
5580
5583
|
this.asyncQueue.enqueueAndForget((() => null !== this.timerHandle ? (this.clearTimeout(),
|
|
@@ -5601,7 +5604,7 @@ class qr {
|
|
|
5601
5604
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5602
5605
|
* See the License for the specific language governing permissions and
|
|
5603
5606
|
* limitations under the License.
|
|
5604
|
-
*/ class
|
|
5607
|
+
*/ class Or {
|
|
5605
5608
|
constructor() {
|
|
5606
5609
|
// The last promise in the queue.
|
|
5607
5610
|
this.Vt = Promise.resolve(),
|
|
@@ -5624,15 +5627,15 @@ class qr {
|
|
|
5624
5627
|
// List of TimerIds to fast-forward delays for.
|
|
5625
5628
|
this.xt = [],
|
|
5626
5629
|
// Backoff timer used to schedule retries for retryable operations
|
|
5627
|
-
this.It = new
|
|
5630
|
+
this.It = new Hn(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5628
5631
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5629
5632
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5630
5633
|
// after page comes into foreground.
|
|
5631
5634
|
this.Ot = () => {
|
|
5632
|
-
const t =
|
|
5633
|
-
t &&
|
|
5635
|
+
const t = qr();
|
|
5636
|
+
t && w("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.It.H();
|
|
5634
5637
|
};
|
|
5635
|
-
const t =
|
|
5638
|
+
const t = qr();
|
|
5636
5639
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ot);
|
|
5637
5640
|
}
|
|
5638
5641
|
get isShuttingDown() {
|
|
@@ -5653,7 +5656,7 @@ class qr {
|
|
|
5653
5656
|
enterRestrictedMode(t) {
|
|
5654
5657
|
if (!this.Dt) {
|
|
5655
5658
|
this.Dt = !0, this.qt = t || !1;
|
|
5656
|
-
const n =
|
|
5659
|
+
const n = qr();
|
|
5657
5660
|
n && "function" == typeof n.removeEventListener && n.removeEventListener("visibilitychange", this.Ot);
|
|
5658
5661
|
}
|
|
5659
5662
|
}
|
|
@@ -5664,7 +5667,7 @@ class qr {
|
|
|
5664
5667
|
// Create a deferred Promise that we can return to the callee. This
|
|
5665
5668
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5666
5669
|
// advance the queue even when the operation is not run.
|
|
5667
|
-
const n = new
|
|
5670
|
+
const n = new U;
|
|
5668
5671
|
return this.Lt((() => this.Dt && this.qt ? Promise.resolve() : (t().then(n.resolve, n.reject),
|
|
5669
5672
|
n.promise))).then((() => n.promise));
|
|
5670
5673
|
}
|
|
@@ -5719,7 +5722,7 @@ class qr {
|
|
|
5719
5722
|
* limitations under the License.
|
|
5720
5723
|
*/ (t)) throw t;
|
|
5721
5724
|
// Failure will be handled by AsyncQueue
|
|
5722
|
-
|
|
5725
|
+
w("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
5723
5726
|
}
|
|
5724
5727
|
this.Nt.length > 0 &&
|
|
5725
5728
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
@@ -5741,7 +5744,7 @@ class qr {
|
|
|
5741
5744
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5742
5745
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5743
5746
|
// and return the rejected Promise.
|
|
5744
|
-
throw
|
|
5747
|
+
throw m("INTERNAL UNHANDLED ERROR: ",
|
|
5745
5748
|
/**
|
|
5746
5749
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
5747
5750
|
* This returns expected output of message + stack when available.
|
|
@@ -5784,11 +5787,11 @@ class qr {
|
|
|
5784
5787
|
this.Ct(),
|
|
5785
5788
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5786
5789
|
this.xt.indexOf(t) > -1 && (n = 0);
|
|
5787
|
-
const r =
|
|
5790
|
+
const r = xr.createAndSchedule(this, t, n, e, (t => this.jt(t)));
|
|
5788
5791
|
return this.$t.push(r), r;
|
|
5789
5792
|
}
|
|
5790
5793
|
Ct() {
|
|
5791
|
-
this.Ft &&
|
|
5794
|
+
this.Ft && _();
|
|
5792
5795
|
}
|
|
5793
5796
|
verifyOperationInProgress() {}
|
|
5794
5797
|
/**
|
|
@@ -5838,10 +5841,10 @@ class qr {
|
|
|
5838
5841
|
}
|
|
5839
5842
|
}
|
|
5840
5843
|
|
|
5841
|
-
class
|
|
5844
|
+
class Cr {
|
|
5842
5845
|
/** @hideconstructor */
|
|
5843
5846
|
constructor(t, n) {
|
|
5844
|
-
this._firestore = t, this._transaction = n, this._dataReader =
|
|
5847
|
+
this._firestore = t, this._transaction = n, this._dataReader = Pe(t);
|
|
5845
5848
|
}
|
|
5846
5849
|
/**
|
|
5847
5850
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5849,25 +5852,25 @@ class Lr {
|
|
|
5849
5852
|
* @param documentRef - A reference to the document to be read.
|
|
5850
5853
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5851
5854
|
*/ get(t) {
|
|
5852
|
-
const n =
|
|
5855
|
+
const n = Dr(t, this._firestore), e = new yr(this._firestore);
|
|
5853
5856
|
return this._transaction.lookup([ n._key ]).then((t => {
|
|
5854
|
-
if (!t || 1 !== t.length) return
|
|
5857
|
+
if (!t || 1 !== t.length) return _();
|
|
5855
5858
|
const r = t[0];
|
|
5856
|
-
if (r.isFoundDocument()) return new
|
|
5857
|
-
if (r.isNoDocument()) return new
|
|
5858
|
-
throw
|
|
5859
|
+
if (r.isFoundDocument()) return new We(this._firestore, e, r.key, r, n.converter);
|
|
5860
|
+
if (r.isNoDocument()) return new We(this._firestore, e, n._key, null, n.converter);
|
|
5861
|
+
throw _();
|
|
5859
5862
|
}));
|
|
5860
5863
|
}
|
|
5861
5864
|
set(t, n, e) {
|
|
5862
|
-
const r =
|
|
5865
|
+
const r = Dr(t, this._firestore), s = pr(r.converter, n, e), i = Re(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, e);
|
|
5863
5866
|
return this._transaction.set(r._key, i), this;
|
|
5864
5867
|
}
|
|
5865
5868
|
update(t, n, e, ...r) {
|
|
5866
|
-
const s =
|
|
5869
|
+
const s = Dr(t, this._firestore);
|
|
5867
5870
|
// For Compat types, we have to "extract" the underlying types before
|
|
5868
5871
|
// performing validation.
|
|
5869
5872
|
let i;
|
|
5870
|
-
return i = "string" == typeof (n =
|
|
5873
|
+
return i = "string" == typeof (n = a(n)) || n instanceof me ? xe(this._dataReader, "Transaction.update", s._key, n, e, r) : qe(this._dataReader, "Transaction.update", s._key, n),
|
|
5871
5874
|
this._transaction.update(s._key, i), this;
|
|
5872
5875
|
}
|
|
5873
5876
|
/**
|
|
@@ -5876,7 +5879,7 @@ class Lr {
|
|
|
5876
5879
|
* @param documentRef - A reference to the document to be deleted.
|
|
5877
5880
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5878
5881
|
*/ delete(t) {
|
|
5879
|
-
const n =
|
|
5882
|
+
const n = Dr(t, this._firestore);
|
|
5880
5883
|
return this._transaction.delete(n._key), this;
|
|
5881
5884
|
}
|
|
5882
5885
|
}
|
|
@@ -5897,9 +5900,9 @@ class Lr {
|
|
|
5897
5900
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5898
5901
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5899
5902
|
* rejected promise with the corresponding failure error is returned.
|
|
5900
|
-
*/ function
|
|
5901
|
-
const e =
|
|
5902
|
-
return new
|
|
5903
|
+
*/ function Lr(t, n) {
|
|
5904
|
+
const e = te(t = rt(t, ee)), r = new U;
|
|
5905
|
+
return new Sr(new Or, e, (e => n(new Cr(t, e))), r).run(), r.promise;
|
|
5903
5906
|
}
|
|
5904
5907
|
|
|
5905
5908
|
/**
|
|
@@ -5910,11 +5913,11 @@ class Lr {
|
|
|
5910
5913
|
* directly to the backend, and `onSnapshot()` APIs are not supported.
|
|
5911
5914
|
* @packageDocumentation
|
|
5912
5915
|
*/ !function(t) {
|
|
5913
|
-
|
|
5914
|
-
}(`${
|
|
5915
|
-
const e = t.getProvider("app").getImmediate(), r = new
|
|
5916
|
+
l = t;
|
|
5917
|
+
}(`${s}_lite`), e(new i("firestore/lite", ((t, {options: n}) => {
|
|
5918
|
+
const e = t.getProvider("app").getImmediate(), r = new ee(e, new B(t.getProvider("auth-internal")));
|
|
5916
5919
|
return n && r._setSettings(n), r;
|
|
5917
|
-
}), "PUBLIC" /* PUBLIC */)),
|
|
5920
|
+
}), "PUBLIC" /* PUBLIC */)), r("firestore-lite", "3.0.2-canary.07b88e6e8", "node");
|
|
5918
5921
|
|
|
5919
|
-
export {
|
|
5922
|
+
export { ye as Bytes, ae as CollectionReference, ue as DocumentReference, We as DocumentSnapshot, me as FieldPath, _e as FieldValue, ee as Firestore, L as FirestoreError, ge as GeoPoint, ce as Query, Je as QueryConstraint, Ge as QueryDocumentSnapshot, He as QuerySnapshot, pt as Timestamp, Cr as Transaction, Nr as WriteBatch, Ir as addDoc, Rr as arrayRemove, Pr as arrayUnion, he as collection, le as collectionGroup, ie as connectFirestoreEmulator, Er as deleteDoc, Tr as deleteField, fe as doc, pe as documentId, lr as endAt, hr as endBefore, _r as getDoc, gr as getDocs, se as getFirestore, Vr as increment, re as initializeFirestore, sr as limit, ir as limitToLast, er as orderBy, Ze as query, we as queryEqual, de as refEqual, Lr as runTransaction, Ar as serverTimestamp, br as setDoc, d as setLogLevel, Ye as snapshotEqual, cr as startAfter, ur as startAt, oe as terminate, vr as updateDoc, tr as where, $r as writeBatch };
|
|
5920
5923
|
//# sourceMappingURL=index.browser.esm2017.js.map
|