@firebase/firestore 3.5.0-canary.e35db6f95 → 3.5.0-canary.ee871fc0b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/firestore/lite/index.d.ts +2 -0
- package/dist/firestore/src/api/aggregate.d.ts +19 -5
- package/dist/firestore/src/api/database.d.ts +6 -6
- package/dist/firestore/src/api.d.ts +2 -0
- package/dist/firestore/src/core/count_query_runner.d.ts +32 -0
- package/dist/firestore/src/core/firestore_client.d.ts +2 -2
- package/dist/firestore/src/lite-api/aggregate.d.ts +17 -61
- package/dist/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/firestore/src/lite-api/database.d.ts +6 -6
- package/dist/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/index.d.ts +189 -7
- package/dist/index.esm2017.js +3167 -2981
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +3477 -3276
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +3893 -3670
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +3890 -3671
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +3231 -3045
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +103 -7
- package/dist/lite/firestore/lite/index.d.ts +2 -0
- package/dist/lite/firestore/src/api/aggregate.d.ts +19 -5
- package/dist/lite/firestore/src/api/database.d.ts +6 -6
- package/dist/lite/firestore/src/api.d.ts +2 -0
- package/dist/lite/firestore/src/core/count_query_runner.d.ts +32 -0
- package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -2
- package/dist/lite/firestore/src/lite-api/aggregate.d.ts +17 -61
- package/dist/lite/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/lite/firestore/src/lite-api/database.d.ts +6 -6
- package/dist/lite/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/lite/index.browser.esm2017.js +1068 -917
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +1183 -1037
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +84 -4
- package/dist/lite/index.node.cjs.js +240 -62
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +238 -64
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1059 -908
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +95 -6
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +213 -128
- package/dist/lite/packages/firestore/lite/index.d.ts +2 -0
- package/dist/lite/packages/firestore/src/api/aggregate.d.ts +19 -5
- package/dist/lite/packages/firestore/src/api/database.d.ts +6 -6
- package/dist/lite/packages/firestore/src/api.d.ts +2 -0
- package/dist/lite/packages/firestore/src/core/count_query_runner.d.ts +32 -0
- package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -2
- package/dist/lite/packages/firestore/src/lite-api/aggregate.d.ts +17 -61
- package/dist/lite/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/lite/packages/firestore/src/lite-api/database.d.ts +6 -6
- package/dist/lite/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/lite/private.d.ts +93 -4
- package/dist/packages/firestore/dist/index.esm2017.d.ts +295 -186
- package/dist/packages/firestore/lite/index.d.ts +2 -0
- package/dist/packages/firestore/src/api/aggregate.d.ts +19 -5
- package/dist/packages/firestore/src/api/database.d.ts +6 -6
- package/dist/packages/firestore/src/api.d.ts +2 -0
- package/dist/packages/firestore/src/core/count_query_runner.d.ts +32 -0
- package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -2
- package/dist/packages/firestore/src/lite-api/aggregate.d.ts +17 -61
- package/dist/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
- package/dist/packages/firestore/src/lite-api/database.d.ts +6 -6
- package/dist/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
- package/dist/private.d.ts +200 -11
- package/package.json +9 -9
package/dist/lite/index.d.ts
CHANGED
|
@@ -35,6 +35,69 @@ export declare function addDoc<T>(reference: CollectionReference<T>, data: WithF
|
|
|
35
35
|
export declare type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
|
|
36
36
|
[K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Represents an aggregation that can be performed by Firestore.
|
|
40
|
+
*/
|
|
41
|
+
export declare class AggregateField<T> {
|
|
42
|
+
/** A type string to uniquely identify instances of this class. */
|
|
43
|
+
type: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The union of all `AggregateField` types that are supported by Firestore.
|
|
47
|
+
*/
|
|
48
|
+
export declare type AggregateFieldType = AggregateField<number>;
|
|
49
|
+
/**
|
|
50
|
+
* The results of executing an aggregation query.
|
|
51
|
+
*/
|
|
52
|
+
export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
|
|
53
|
+
/** A type string to uniquely identify instances of this class. */
|
|
54
|
+
readonly type = "AggregateQuerySnapshot";
|
|
55
|
+
/**
|
|
56
|
+
* The underlying query over which the aggregations recorded in this
|
|
57
|
+
* `AggregateQuerySnapshot` were performed.
|
|
58
|
+
*/
|
|
59
|
+
readonly query: Query<unknown>;
|
|
60
|
+
private constructor();
|
|
61
|
+
/**
|
|
62
|
+
* Returns the results of the aggregations performed over the underlying
|
|
63
|
+
* query.
|
|
64
|
+
*
|
|
65
|
+
* The keys of the returned object will be the same as those of the
|
|
66
|
+
* `AggregateSpec` object specified to the aggregation method, and the values
|
|
67
|
+
* will be the corresponding aggregation result.
|
|
68
|
+
*
|
|
69
|
+
* @returns The results of the aggregations performed over the underlying
|
|
70
|
+
* query.
|
|
71
|
+
*/
|
|
72
|
+
data(): AggregateSpecData<T>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Compares two `AggregateQuerySnapshot` instances for equality.
|
|
76
|
+
*
|
|
77
|
+
* Two `AggregateQuerySnapshot` instances are considered "equal" if they have
|
|
78
|
+
* underlying queries that compare equal, and the same data.
|
|
79
|
+
*
|
|
80
|
+
* @param left - The first `AggregateQuerySnapshot` to compare.
|
|
81
|
+
* @param right - The second `AggregateQuerySnapshot` to compare.
|
|
82
|
+
*
|
|
83
|
+
* @returns `true` if the objects are "equal", as defined above, or `false`
|
|
84
|
+
* otherwise.
|
|
85
|
+
*/
|
|
86
|
+
export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* A type whose property values are all `AggregateField` objects.
|
|
89
|
+
*/
|
|
90
|
+
export declare interface AggregateSpec {
|
|
91
|
+
[field: string]: AggregateFieldType;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A type whose keys are taken from an `AggregateSpec`, and whose values are the
|
|
95
|
+
* result of the aggregation performed by the corresponding `AggregateField`
|
|
96
|
+
* from the input `AggregateSpec`.
|
|
97
|
+
*/
|
|
98
|
+
export declare type AggregateSpecData<T extends AggregateSpec> = {
|
|
99
|
+
[P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
|
|
100
|
+
};
|
|
38
101
|
/**
|
|
39
102
|
* Returns a special value that can be used with {@link (setDoc:1)} or {@link
|
|
40
103
|
* updateDoc:1} that tells the server to remove the given elements from any
|
|
@@ -466,7 +529,7 @@ export declare abstract class FieldValue {
|
|
|
466
529
|
/**
|
|
467
530
|
* The Cloud Firestore service interface.
|
|
468
531
|
*
|
|
469
|
-
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
532
|
+
* Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
|
|
470
533
|
*/
|
|
471
534
|
export declare class Firestore {
|
|
472
535
|
/**
|
|
@@ -659,6 +722,23 @@ export declare class GeoPoint {
|
|
|
659
722
|
longitude: number;
|
|
660
723
|
};
|
|
661
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* Calculates the number of documents in the result set of the given query,
|
|
727
|
+
* without actually downloading the documents.
|
|
728
|
+
*
|
|
729
|
+
* Using this function to count the documents is efficient because only the
|
|
730
|
+
* final count, not the documents' data, is downloaded. This function can even
|
|
731
|
+
* count the documents if the result set would be prohibitively large to
|
|
732
|
+
* download entirely (e.g. thousands of documents).
|
|
733
|
+
*
|
|
734
|
+
* @param query - The query whose result set size to calculate.
|
|
735
|
+
* @returns A Promise that will be resolved with the count; the count can be
|
|
736
|
+
* retrieved from `snapshot.data().count`, where `snapshot` is the
|
|
737
|
+
* `AggregateQuerySnapshot` to which the returned Promise resolves.
|
|
738
|
+
*/
|
|
739
|
+
export declare function getCount(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
|
|
740
|
+
count: AggregateField<number>;
|
|
741
|
+
}>>;
|
|
662
742
|
/**
|
|
663
743
|
* Reads the document referred to by the specified document reference.
|
|
664
744
|
*
|
|
@@ -729,8 +809,8 @@ export declare function increment(n: number): FieldValue;
|
|
|
729
809
|
/**
|
|
730
810
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
731
811
|
* Can only be called before any other functions, including
|
|
732
|
-
* {@link getFirestore}. If the custom settings are empty, this function is
|
|
733
|
-
* equivalent to calling {@link getFirestore}.
|
|
812
|
+
* {@link (getFirestore:1)}. If the custom settings are empty, this function is
|
|
813
|
+
* equivalent to calling {@link (getFirestore:1)}.
|
|
734
814
|
*
|
|
735
815
|
* @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
|
|
736
816
|
* be associated.
|
|
@@ -1089,7 +1169,7 @@ export declare function startAt(...fieldValues: unknown[]): QueryConstraint;
|
|
|
1089
1169
|
* response from the server will not be resolved.
|
|
1090
1170
|
*
|
|
1091
1171
|
* To restart after termination, create a new instance of `Firestore` with
|
|
1092
|
-
* {@link getFirestore}.
|
|
1172
|
+
* {@link (getFirestore:1)}.
|
|
1093
1173
|
*
|
|
1094
1174
|
* Note: Under normal circumstances, calling `terminate()` is not required. This
|
|
1095
1175
|
* function is useful only when you want to force this instance to release all of
|
|
@@ -14,7 +14,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
14
14
|
|
|
15
15
|
var nodeFetch__default = /*#__PURE__*/_interopDefaultLegacy(nodeFetch);
|
|
16
16
|
|
|
17
|
-
const version$1 = "3.5.0-canary.
|
|
17
|
+
const version$1 = "3.5.0-canary.ee871fc0b";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @license
|
|
@@ -67,7 +67,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
67
67
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
68
68
|
User.MOCK_USER = new User('mock-user');
|
|
69
69
|
|
|
70
|
-
const version = "9.10.0-canary.
|
|
70
|
+
const version = "9.10.0-canary.ee871fc0b";
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* @license
|
|
@@ -4575,6 +4575,21 @@ function toQueryTarget(serializer, target) {
|
|
|
4575
4575
|
}
|
|
4576
4576
|
return result;
|
|
4577
4577
|
}
|
|
4578
|
+
function toRunAggregationQueryRequest(serializer, target) {
|
|
4579
|
+
const queryTarget = toQueryTarget(serializer, target);
|
|
4580
|
+
return {
|
|
4581
|
+
structuredAggregationQuery: {
|
|
4582
|
+
aggregations: [
|
|
4583
|
+
{
|
|
4584
|
+
count: {},
|
|
4585
|
+
alias: 'count_alias'
|
|
4586
|
+
}
|
|
4587
|
+
],
|
|
4588
|
+
structuredQuery: queryTarget.structuredQuery
|
|
4589
|
+
},
|
|
4590
|
+
parent: queryTarget.parent
|
|
4591
|
+
};
|
|
4592
|
+
}
|
|
4578
4593
|
function toFilter(filters) {
|
|
4579
4594
|
if (filters.length === 0) {
|
|
4580
4595
|
return;
|
|
@@ -4977,6 +4992,19 @@ async function invokeRunQueryRpc(datastore, query) {
|
|
|
4977
4992
|
// Omit RunQueryResponses that only contain readTimes.
|
|
4978
4993
|
.filter(proto => !!proto.document)
|
|
4979
4994
|
.map(proto => fromDocument(datastoreImpl.serializer, proto.document, undefined)));
|
|
4995
|
+
}
|
|
4996
|
+
async function invokeRunAggregationQueryRpc(datastore, query) {
|
|
4997
|
+
const datastoreImpl = debugCast(datastore);
|
|
4998
|
+
const request = toRunAggregationQueryRequest(datastoreImpl.serializer, queryToTarget(query));
|
|
4999
|
+
const parent = request.parent;
|
|
5000
|
+
if (!datastoreImpl.connection.shouldResourcePathBeIncludedInRequest) {
|
|
5001
|
+
delete request.parent;
|
|
5002
|
+
}
|
|
5003
|
+
const response = await datastoreImpl.invokeStreamingRPC('RunAggregationQuery', parent, request, /*expectedResponseCount=*/ 1);
|
|
5004
|
+
return (response
|
|
5005
|
+
// Omit RunAggregationQueryResponse that only contain readTimes.
|
|
5006
|
+
.filter(proto => !!proto.result)
|
|
5007
|
+
.map(proto => proto.result.aggregateFields));
|
|
4980
5008
|
}
|
|
4981
5009
|
|
|
4982
5010
|
/**
|
|
@@ -5187,7 +5215,7 @@ class FirestoreSettingsImpl {
|
|
|
5187
5215
|
/**
|
|
5188
5216
|
* The Cloud Firestore service interface.
|
|
5189
5217
|
*
|
|
5190
|
-
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
5218
|
+
* Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
|
|
5191
5219
|
*/
|
|
5192
5220
|
class Firestore {
|
|
5193
5221
|
/** @hideconstructor */
|
|
@@ -5338,7 +5366,7 @@ function connectFirestoreEmulator(firestore, host, port, options = {}) {
|
|
|
5338
5366
|
* response from the server will not be resolved.
|
|
5339
5367
|
*
|
|
5340
5368
|
* To restart after termination, create a new instance of `Firestore` with
|
|
5341
|
-
* {@link getFirestore}.
|
|
5369
|
+
* {@link (getFirestore:1)}.
|
|
5342
5370
|
*
|
|
5343
5371
|
* Note: Under normal circumstances, calling `terminate()` is not required. This
|
|
5344
5372
|
* function is useful only when you want to force this instance to release all of
|
|
@@ -5386,6 +5414,100 @@ function registerFirestore() {
|
|
|
5386
5414
|
app.registerVersion('firestore-lite', version$1, 'cjs5');
|
|
5387
5415
|
}
|
|
5388
5416
|
|
|
5417
|
+
/**
|
|
5418
|
+
* @license
|
|
5419
|
+
* Copyright 2022 Google LLC
|
|
5420
|
+
*
|
|
5421
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5422
|
+
* you may not use this file except in compliance with the License.
|
|
5423
|
+
* You may obtain a copy of the License at
|
|
5424
|
+
*
|
|
5425
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5426
|
+
*
|
|
5427
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
5428
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5429
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5430
|
+
* See the License for the specific language governing permissions and
|
|
5431
|
+
* limitations under the License.
|
|
5432
|
+
*/
|
|
5433
|
+
/**
|
|
5434
|
+
* Represents an aggregation that can be performed by Firestore.
|
|
5435
|
+
*/
|
|
5436
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5437
|
+
class AggregateField {
|
|
5438
|
+
constructor() {
|
|
5439
|
+
/** A type string to uniquely identify instances of this class. */
|
|
5440
|
+
this.type = 'AggregateField';
|
|
5441
|
+
}
|
|
5442
|
+
}
|
|
5443
|
+
/**
|
|
5444
|
+
* The results of executing an aggregation query.
|
|
5445
|
+
*/
|
|
5446
|
+
class AggregateQuerySnapshot {
|
|
5447
|
+
/** @hideconstructor */
|
|
5448
|
+
constructor(query, _data) {
|
|
5449
|
+
this._data = _data;
|
|
5450
|
+
/** A type string to uniquely identify instances of this class. */
|
|
5451
|
+
this.type = 'AggregateQuerySnapshot';
|
|
5452
|
+
this.query = query;
|
|
5453
|
+
}
|
|
5454
|
+
/**
|
|
5455
|
+
* Returns the results of the aggregations performed over the underlying
|
|
5456
|
+
* query.
|
|
5457
|
+
*
|
|
5458
|
+
* The keys of the returned object will be the same as those of the
|
|
5459
|
+
* `AggregateSpec` object specified to the aggregation method, and the values
|
|
5460
|
+
* will be the corresponding aggregation result.
|
|
5461
|
+
*
|
|
5462
|
+
* @returns The results of the aggregations performed over the underlying
|
|
5463
|
+
* query.
|
|
5464
|
+
*/
|
|
5465
|
+
data() {
|
|
5466
|
+
return this._data;
|
|
5467
|
+
}
|
|
5468
|
+
}
|
|
5469
|
+
|
|
5470
|
+
/**
|
|
5471
|
+
* @license
|
|
5472
|
+
* Copyright 2022 Google LLC
|
|
5473
|
+
*
|
|
5474
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5475
|
+
* you may not use this file except in compliance with the License.
|
|
5476
|
+
* You may obtain a copy of the License at
|
|
5477
|
+
*
|
|
5478
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5479
|
+
*
|
|
5480
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
5481
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5482
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5483
|
+
* See the License for the specific language governing permissions and
|
|
5484
|
+
* limitations under the License.
|
|
5485
|
+
*/
|
|
5486
|
+
/**
|
|
5487
|
+
* CountQueryRunner encapsulates the logic needed to run the count aggregation
|
|
5488
|
+
* queries.
|
|
5489
|
+
*/
|
|
5490
|
+
class CountQueryRunner {
|
|
5491
|
+
constructor(query, datastore, userDataWriter) {
|
|
5492
|
+
this.query = query;
|
|
5493
|
+
this.datastore = datastore;
|
|
5494
|
+
this.userDataWriter = userDataWriter;
|
|
5495
|
+
}
|
|
5496
|
+
run() {
|
|
5497
|
+
return invokeRunAggregationQueryRpc(this.datastore, this.query._query).then(result => {
|
|
5498
|
+
hardAssert(result[0] !== undefined);
|
|
5499
|
+
const counts = Object.entries(result[0])
|
|
5500
|
+
.filter(([key, value]) => key === 'count_alias')
|
|
5501
|
+
.map(([key, value]) => this.userDataWriter.convertValue(value));
|
|
5502
|
+
const countValue = counts[0];
|
|
5503
|
+
hardAssert(typeof countValue === 'number');
|
|
5504
|
+
return Promise.resolve(new AggregateQuerySnapshot(this.query, {
|
|
5505
|
+
count: countValue
|
|
5506
|
+
}));
|
|
5507
|
+
});
|
|
5508
|
+
}
|
|
5509
|
+
}
|
|
5510
|
+
|
|
5389
5511
|
/**
|
|
5390
5512
|
* @license
|
|
5391
5513
|
* Copyright 2020 Google LLC
|
|
@@ -5617,64 +5739,6 @@ function queryEqual(left, right) {
|
|
|
5617
5739
|
return false;
|
|
5618
5740
|
}
|
|
5619
5741
|
|
|
5620
|
-
/**
|
|
5621
|
-
* @license
|
|
5622
|
-
* Copyright 2020 Google LLC
|
|
5623
|
-
*
|
|
5624
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5625
|
-
* you may not use this file except in compliance with the License.
|
|
5626
|
-
* You may obtain a copy of the License at
|
|
5627
|
-
*
|
|
5628
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5629
|
-
*
|
|
5630
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
5631
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5632
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5633
|
-
* See the License for the specific language governing permissions and
|
|
5634
|
-
* limitations under the License.
|
|
5635
|
-
*/
|
|
5636
|
-
/**
|
|
5637
|
-
* A `FieldPath` refers to a field in a document. The path may consist of a
|
|
5638
|
-
* single field name (referring to a top-level field in the document), or a
|
|
5639
|
-
* list of field names (referring to a nested field in the document).
|
|
5640
|
-
*
|
|
5641
|
-
* Create a `FieldPath` by providing field names. If more than one field
|
|
5642
|
-
* name is provided, the path will point to a nested field in a document.
|
|
5643
|
-
*/
|
|
5644
|
-
class FieldPath {
|
|
5645
|
-
/**
|
|
5646
|
-
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
5647
|
-
* name is provided, the path will point to a nested field in a document.
|
|
5648
|
-
*
|
|
5649
|
-
* @param fieldNames - A list of field names.
|
|
5650
|
-
*/
|
|
5651
|
-
constructor(...fieldNames) {
|
|
5652
|
-
for (let i = 0; i < fieldNames.length; ++i) {
|
|
5653
|
-
if (fieldNames[i].length === 0) {
|
|
5654
|
-
throw new FirestoreError(Code.INVALID_ARGUMENT, `Invalid field name at argument $(i + 1). ` +
|
|
5655
|
-
'Field names must not be empty.');
|
|
5656
|
-
}
|
|
5657
|
-
}
|
|
5658
|
-
this._internalPath = new FieldPath$1(fieldNames);
|
|
5659
|
-
}
|
|
5660
|
-
/**
|
|
5661
|
-
* Returns true if this `FieldPath` is equal to the provided one.
|
|
5662
|
-
*
|
|
5663
|
-
* @param other - The `FieldPath` to compare against.
|
|
5664
|
-
* @returns true if this `FieldPath` is equal to the provided one.
|
|
5665
|
-
*/
|
|
5666
|
-
isEqual(other) {
|
|
5667
|
-
return this._internalPath.isEqual(other._internalPath);
|
|
5668
|
-
}
|
|
5669
|
-
}
|
|
5670
|
-
/**
|
|
5671
|
-
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
5672
|
-
* It can be used in queries to sort or filter by the document ID.
|
|
5673
|
-
*/
|
|
5674
|
-
function documentId() {
|
|
5675
|
-
return new FieldPath(DOCUMENT_KEY_NAME);
|
|
5676
|
-
}
|
|
5677
|
-
|
|
5678
5742
|
/**
|
|
5679
5743
|
* @license
|
|
5680
5744
|
* Copyright 2020 Google LLC
|
|
@@ -5756,6 +5820,64 @@ class Bytes {
|
|
|
5756
5820
|
}
|
|
5757
5821
|
}
|
|
5758
5822
|
|
|
5823
|
+
/**
|
|
5824
|
+
* @license
|
|
5825
|
+
* Copyright 2020 Google LLC
|
|
5826
|
+
*
|
|
5827
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5828
|
+
* you may not use this file except in compliance with the License.
|
|
5829
|
+
* You may obtain a copy of the License at
|
|
5830
|
+
*
|
|
5831
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5832
|
+
*
|
|
5833
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
5834
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5835
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5836
|
+
* See the License for the specific language governing permissions and
|
|
5837
|
+
* limitations under the License.
|
|
5838
|
+
*/
|
|
5839
|
+
/**
|
|
5840
|
+
* A `FieldPath` refers to a field in a document. The path may consist of a
|
|
5841
|
+
* single field name (referring to a top-level field in the document), or a
|
|
5842
|
+
* list of field names (referring to a nested field in the document).
|
|
5843
|
+
*
|
|
5844
|
+
* Create a `FieldPath` by providing field names. If more than one field
|
|
5845
|
+
* name is provided, the path will point to a nested field in a document.
|
|
5846
|
+
*/
|
|
5847
|
+
class FieldPath {
|
|
5848
|
+
/**
|
|
5849
|
+
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
5850
|
+
* name is provided, the path will point to a nested field in a document.
|
|
5851
|
+
*
|
|
5852
|
+
* @param fieldNames - A list of field names.
|
|
5853
|
+
*/
|
|
5854
|
+
constructor(...fieldNames) {
|
|
5855
|
+
for (let i = 0; i < fieldNames.length; ++i) {
|
|
5856
|
+
if (fieldNames[i].length === 0) {
|
|
5857
|
+
throw new FirestoreError(Code.INVALID_ARGUMENT, `Invalid field name at argument $(i + 1). ` +
|
|
5858
|
+
'Field names must not be empty.');
|
|
5859
|
+
}
|
|
5860
|
+
}
|
|
5861
|
+
this._internalPath = new FieldPath$1(fieldNames);
|
|
5862
|
+
}
|
|
5863
|
+
/**
|
|
5864
|
+
* Returns true if this `FieldPath` is equal to the provided one.
|
|
5865
|
+
*
|
|
5866
|
+
* @param other - The `FieldPath` to compare against.
|
|
5867
|
+
* @returns true if this `FieldPath` is equal to the provided one.
|
|
5868
|
+
*/
|
|
5869
|
+
isEqual(other) {
|
|
5870
|
+
return this._internalPath.isEqual(other._internalPath);
|
|
5871
|
+
}
|
|
5872
|
+
}
|
|
5873
|
+
/**
|
|
5874
|
+
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
5875
|
+
* It can be used in queries to sort or filter by the document ID.
|
|
5876
|
+
*/
|
|
5877
|
+
function documentId() {
|
|
5878
|
+
return new FieldPath(DOCUMENT_KEY_NAME);
|
|
5879
|
+
}
|
|
5880
|
+
|
|
5759
5881
|
/**
|
|
5760
5882
|
* @license
|
|
5761
5883
|
* Copyright 2020 Google LLC
|
|
@@ -7464,6 +7586,58 @@ function addDoc(reference, data) {
|
|
|
7464
7586
|
]).then(() => docRef);
|
|
7465
7587
|
}
|
|
7466
7588
|
|
|
7589
|
+
/**
|
|
7590
|
+
* @license
|
|
7591
|
+
* Copyright 2022 Google LLC
|
|
7592
|
+
*
|
|
7593
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7594
|
+
* you may not use this file except in compliance with the License.
|
|
7595
|
+
* You may obtain a copy of the License at
|
|
7596
|
+
*
|
|
7597
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7598
|
+
*
|
|
7599
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7600
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
7601
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
7602
|
+
* See the License for the specific language governing permissions and
|
|
7603
|
+
* limitations under the License.
|
|
7604
|
+
*/
|
|
7605
|
+
/**
|
|
7606
|
+
* Calculates the number of documents in the result set of the given query,
|
|
7607
|
+
* without actually downloading the documents.
|
|
7608
|
+
*
|
|
7609
|
+
* Using this function to count the documents is efficient because only the
|
|
7610
|
+
* final count, not the documents' data, is downloaded. This function can even
|
|
7611
|
+
* count the documents if the result set would be prohibitively large to
|
|
7612
|
+
* download entirely (e.g. thousands of documents).
|
|
7613
|
+
*
|
|
7614
|
+
* @param query - The query whose result set size to calculate.
|
|
7615
|
+
* @returns A Promise that will be resolved with the count; the count can be
|
|
7616
|
+
* retrieved from `snapshot.data().count`, where `snapshot` is the
|
|
7617
|
+
* `AggregateQuerySnapshot` to which the returned Promise resolves.
|
|
7618
|
+
*/
|
|
7619
|
+
function getCount(query) {
|
|
7620
|
+
const firestore = cast(query.firestore, Firestore);
|
|
7621
|
+
const datastore = getDatastore(firestore);
|
|
7622
|
+
const userDataWriter = new LiteUserDataWriter(firestore);
|
|
7623
|
+
return new CountQueryRunner(query, datastore, userDataWriter).run();
|
|
7624
|
+
}
|
|
7625
|
+
/**
|
|
7626
|
+
* Compares two `AggregateQuerySnapshot` instances for equality.
|
|
7627
|
+
*
|
|
7628
|
+
* Two `AggregateQuerySnapshot` instances are considered "equal" if they have
|
|
7629
|
+
* underlying queries that compare equal, and the same data.
|
|
7630
|
+
*
|
|
7631
|
+
* @param left - The first `AggregateQuerySnapshot` to compare.
|
|
7632
|
+
* @param right - The second `AggregateQuerySnapshot` to compare.
|
|
7633
|
+
*
|
|
7634
|
+
* @returns `true` if the objects are "equal", as defined above, or `false`
|
|
7635
|
+
* otherwise.
|
|
7636
|
+
*/
|
|
7637
|
+
function aggregateQuerySnapshotEqual(left, right) {
|
|
7638
|
+
return (queryEqual(left.query, right.query) && util.deepEqual(left.data(), right.data()));
|
|
7639
|
+
}
|
|
7640
|
+
|
|
7467
7641
|
/**
|
|
7468
7642
|
* @license
|
|
7469
7643
|
* Copyright 2020 Google LLC
|
|
@@ -8456,6 +8630,8 @@ function runTransaction(firestore, updateFunction, options) {
|
|
|
8456
8630
|
*/
|
|
8457
8631
|
registerFirestore();
|
|
8458
8632
|
|
|
8633
|
+
exports.AggregateField = AggregateField;
|
|
8634
|
+
exports.AggregateQuerySnapshot = AggregateQuerySnapshot;
|
|
8459
8635
|
exports.Bytes = Bytes;
|
|
8460
8636
|
exports.CollectionReference = CollectionReference;
|
|
8461
8637
|
exports.DocumentReference = DocumentReference;
|
|
@@ -8473,6 +8649,7 @@ exports.Timestamp = Timestamp;
|
|
|
8473
8649
|
exports.Transaction = Transaction;
|
|
8474
8650
|
exports.WriteBatch = WriteBatch;
|
|
8475
8651
|
exports.addDoc = addDoc;
|
|
8652
|
+
exports.aggregateQuerySnapshotEqual = aggregateQuerySnapshotEqual;
|
|
8476
8653
|
exports.arrayRemove = arrayRemove;
|
|
8477
8654
|
exports.arrayUnion = arrayUnion;
|
|
8478
8655
|
exports.collection = collection;
|
|
@@ -8484,6 +8661,7 @@ exports.doc = doc;
|
|
|
8484
8661
|
exports.documentId = documentId;
|
|
8485
8662
|
exports.endAt = endAt;
|
|
8486
8663
|
exports.endBefore = endBefore;
|
|
8664
|
+
exports.getCount = getCount;
|
|
8487
8665
|
exports.getDoc = getDoc;
|
|
8488
8666
|
exports.getDocs = getDocs;
|
|
8489
8667
|
exports.getFirestore = getFirestore;
|