@firebase/firestore 3.4.14 → 3.4.15-20220831174748
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 +6 -0
- package/dist/firestore/src/api/credentials.d.ts +13 -3
- package/dist/firestore/src/api/database.d.ts +34 -3
- package/dist/firestore/src/api/index_configuration.d.ts +5 -0
- package/dist/firestore/src/core/database_info.d.ts +4 -0
- package/dist/firestore/src/lite-api/database.d.ts +51 -7
- package/dist/firestore/test/integration/api/provider.test.d.ts +17 -0
- package/dist/firestore/test/integration/util/firebase_export.d.ts +2 -1
- package/dist/firestore/test/integration/util/helpers.d.ts +1 -0
- package/dist/index.d.ts +15 -94
- package/dist/index.esm2017.js +1713 -1704
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2343 -2330
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +81 -58
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +81 -58
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +1713 -1704
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +48 -6
- package/dist/lite/firestore/src/api/credentials.d.ts +13 -3
- package/dist/lite/firestore/src/api/database.d.ts +34 -3
- package/dist/lite/firestore/src/api/index_configuration.d.ts +5 -0
- package/dist/lite/firestore/src/core/database_info.d.ts +4 -0
- package/dist/lite/firestore/src/lite-api/database.d.ts +51 -7
- package/dist/lite/firestore/test/integration/api/provider.test.d.ts +17 -0
- package/dist/lite/firestore/test/integration/util/firebase_export.d.ts +2 -1
- package/dist/lite/firestore/test/integration/util/helpers.d.ts +1 -0
- package/dist/lite/index.browser.esm2017.js +273 -277
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +621 -608
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +15 -4
- package/dist/lite/index.node.cjs.js +71 -61
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +71 -61
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +273 -277
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +58 -7
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +29 -66
- package/dist/lite/packages/firestore/src/api/credentials.d.ts +13 -3
- package/dist/lite/packages/firestore/src/api/database.d.ts +34 -3
- package/dist/lite/packages/firestore/src/api/index_configuration.d.ts +5 -0
- package/dist/lite/packages/firestore/src/core/database_info.d.ts +4 -0
- package/dist/lite/packages/firestore/src/lite-api/database.d.ts +51 -7
- package/dist/lite/packages/firestore/test/integration/api/provider.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/integration/util/firebase_export.d.ts +2 -1
- package/dist/lite/packages/firestore/test/integration/util/helpers.d.ts +1 -0
- package/dist/lite/private.d.ts +25 -7
- package/dist/packages/firestore/dist/index.esm2017.d.ts +70 -65
- package/dist/packages/firestore/src/api/credentials.d.ts +13 -3
- package/dist/packages/firestore/src/api/database.d.ts +34 -3
- package/dist/packages/firestore/src/api/index_configuration.d.ts +5 -0
- package/dist/packages/firestore/src/core/database_info.d.ts +4 -0
- package/dist/packages/firestore/src/lite-api/database.d.ts +51 -7
- package/dist/packages/firestore/test/integration/api/provider.test.d.ts +17 -0
- package/dist/packages/firestore/test/integration/util/firebase_export.d.ts +2 -1
- package/dist/packages/firestore/test/integration/util/helpers.d.ts +1 -0
- package/dist/private.d.ts +28 -99
- package/package.json +5 -4
package/dist/index.node.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import * as grpc from '@grpc/grpc-js';
|
|
|
8
8
|
import * as protoLoader from '@grpc/proto-loader';
|
|
9
9
|
|
|
10
10
|
const name = "@firebase/firestore";
|
|
11
|
-
const version$1 = "3.4.
|
|
11
|
+
const version$1 = "3.4.15-20220831174748";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
@@ -61,7 +61,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
61
61
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
62
62
|
User.MOCK_USER = new User('mock-user');
|
|
63
63
|
|
|
64
|
-
const version = "9.9.
|
|
64
|
+
const version = "9.9.4-20220831174748";
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* @license
|
|
@@ -616,19 +616,41 @@ class FirebaseAuthCredentialsProvider {
|
|
|
616
616
|
* safer to keep the implementation as-is.
|
|
617
617
|
*/
|
|
618
618
|
class FirstPartyToken {
|
|
619
|
-
constructor(gapi, sessionIndex, iamToken) {
|
|
619
|
+
constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
|
|
620
|
+
this.gapi = gapi;
|
|
621
|
+
this.sessionIndex = sessionIndex;
|
|
622
|
+
this.iamToken = iamToken;
|
|
623
|
+
this.authTokenFactory = authTokenFactory;
|
|
620
624
|
this.type = 'FirstParty';
|
|
621
625
|
this.user = User.FIRST_PARTY;
|
|
622
|
-
this.
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
626
|
+
this._headers = new Map();
|
|
627
|
+
}
|
|
628
|
+
/** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */
|
|
629
|
+
getAuthToken() {
|
|
630
|
+
if (this.authTokenFactory) {
|
|
631
|
+
return this.authTokenFactory();
|
|
627
632
|
}
|
|
628
|
-
|
|
629
|
-
this.
|
|
633
|
+
else {
|
|
634
|
+
// Make sure this really is a Gapi client.
|
|
635
|
+
hardAssert(!!(typeof this.gapi === 'object' &&
|
|
636
|
+
this.gapi !== null &&
|
|
637
|
+
this.gapi['auth'] &&
|
|
638
|
+
this.gapi['auth']['getAuthHeaderValueForFirstParty']));
|
|
639
|
+
return this.gapi['auth']['getAuthHeaderValueForFirstParty']([]);
|
|
630
640
|
}
|
|
631
641
|
}
|
|
642
|
+
get headers() {
|
|
643
|
+
this._headers.set('X-Goog-AuthUser', this.sessionIndex);
|
|
644
|
+
// Use array notation to prevent minification
|
|
645
|
+
const authHeaderTokenValue = this.getAuthToken();
|
|
646
|
+
if (authHeaderTokenValue) {
|
|
647
|
+
this._headers.set('Authorization', authHeaderTokenValue);
|
|
648
|
+
}
|
|
649
|
+
if (this.iamToken) {
|
|
650
|
+
this._headers.set('X-Goog-Iam-Authorization-Token', this.iamToken);
|
|
651
|
+
}
|
|
652
|
+
return this._headers;
|
|
653
|
+
}
|
|
632
654
|
}
|
|
633
655
|
/*
|
|
634
656
|
* Provides user credentials required for the Firestore JavaScript SDK
|
|
@@ -636,13 +658,14 @@ class FirstPartyToken {
|
|
|
636
658
|
* to applications hosted by Google.
|
|
637
659
|
*/
|
|
638
660
|
class FirstPartyAuthCredentialsProvider {
|
|
639
|
-
constructor(gapi, sessionIndex, iamToken) {
|
|
661
|
+
constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
|
|
640
662
|
this.gapi = gapi;
|
|
641
663
|
this.sessionIndex = sessionIndex;
|
|
642
664
|
this.iamToken = iamToken;
|
|
665
|
+
this.authTokenFactory = authTokenFactory;
|
|
643
666
|
}
|
|
644
667
|
getToken() {
|
|
645
|
-
return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken));
|
|
668
|
+
return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken, this.authTokenFactory));
|
|
646
669
|
}
|
|
647
670
|
start(asyncQueue, changeListener) {
|
|
648
671
|
// Fire with initial uid.
|
|
@@ -753,12 +776,7 @@ function makeAuthCredentialsProvider(credentials) {
|
|
|
753
776
|
switch (credentials['type']) {
|
|
754
777
|
case 'gapi':
|
|
755
778
|
const client = credentials['client'];
|
|
756
|
-
|
|
757
|
-
hardAssert(!!(typeof client === 'object' &&
|
|
758
|
-
client !== null &&
|
|
759
|
-
client['auth'] &&
|
|
760
|
-
client['auth']['getAuthHeaderValueForFirstParty']));
|
|
761
|
-
return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null);
|
|
779
|
+
return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null, credentials['authTokenFactory'] || null);
|
|
762
780
|
case 'provider':
|
|
763
781
|
return credentials['client'];
|
|
764
782
|
default:
|
|
@@ -4325,6 +4343,12 @@ class DatabaseId {
|
|
|
4325
4343
|
other.projectId === this.projectId &&
|
|
4326
4344
|
other.database === this.database);
|
|
4327
4345
|
}
|
|
4346
|
+
}
|
|
4347
|
+
function databaseIdFromApp(app, database) {
|
|
4348
|
+
if (!Object.prototype.hasOwnProperty.apply(app.options, ['projectId'])) {
|
|
4349
|
+
throw new FirestoreError(Code.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
|
|
4350
|
+
}
|
|
4351
|
+
return new DatabaseId(app.options.projectId, database);
|
|
4328
4352
|
}
|
|
4329
4353
|
|
|
4330
4354
|
/**
|
|
@@ -24740,7 +24764,7 @@ class Transaction$2 {
|
|
|
24740
24764
|
docVersion = doc.version;
|
|
24741
24765
|
}
|
|
24742
24766
|
else if (doc.isNoDocument()) {
|
|
24743
|
-
//
|
|
24767
|
+
// Represent a deleted doc using SnapshotVersion.min().
|
|
24744
24768
|
docVersion = SnapshotVersion.min();
|
|
24745
24769
|
}
|
|
24746
24770
|
else {
|
|
@@ -24764,7 +24788,12 @@ class Transaction$2 {
|
|
|
24764
24788
|
precondition(key) {
|
|
24765
24789
|
const version = this.readVersions.get(key.toString());
|
|
24766
24790
|
if (!this.writtenDocs.has(key.toString()) && version) {
|
|
24767
|
-
|
|
24791
|
+
if (version.isEqual(SnapshotVersion.min())) {
|
|
24792
|
+
return Precondition.exists(false);
|
|
24793
|
+
}
|
|
24794
|
+
else {
|
|
24795
|
+
return Precondition.updateTime(version);
|
|
24796
|
+
}
|
|
24768
24797
|
}
|
|
24769
24798
|
else {
|
|
24770
24799
|
return Precondition.none();
|
|
@@ -25459,9 +25488,11 @@ class FirestoreSettingsImpl {
|
|
|
25459
25488
|
*/
|
|
25460
25489
|
class Firestore$1 {
|
|
25461
25490
|
/** @hideconstructor */
|
|
25462
|
-
constructor(
|
|
25491
|
+
constructor(_authCredentials, _appCheckCredentials, _databaseId, _app) {
|
|
25463
25492
|
this._authCredentials = _authCredentials;
|
|
25464
25493
|
this._appCheckCredentials = _appCheckCredentials;
|
|
25494
|
+
this._databaseId = _databaseId;
|
|
25495
|
+
this._app = _app;
|
|
25465
25496
|
/**
|
|
25466
25497
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
25467
25498
|
*/
|
|
@@ -25469,13 +25500,6 @@ class Firestore$1 {
|
|
|
25469
25500
|
this._persistenceKey = '(lite)';
|
|
25470
25501
|
this._settings = new FirestoreSettingsImpl({});
|
|
25471
25502
|
this._settingsFrozen = false;
|
|
25472
|
-
if (databaseIdOrApp instanceof DatabaseId) {
|
|
25473
|
-
this._databaseId = databaseIdOrApp;
|
|
25474
|
-
}
|
|
25475
|
-
else {
|
|
25476
|
-
this._app = databaseIdOrApp;
|
|
25477
|
-
this._databaseId = databaseIdFromApp(databaseIdOrApp);
|
|
25478
|
-
}
|
|
25479
25503
|
}
|
|
25480
25504
|
/**
|
|
25481
25505
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
@@ -25538,12 +25562,6 @@ class Firestore$1 {
|
|
|
25538
25562
|
return Promise.resolve();
|
|
25539
25563
|
}
|
|
25540
25564
|
}
|
|
25541
|
-
function databaseIdFromApp(app) {
|
|
25542
|
-
if (!Object.prototype.hasOwnProperty.apply(app.options, ['projectId'])) {
|
|
25543
|
-
throw new FirestoreError(Code.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
|
|
25544
|
-
}
|
|
25545
|
-
return new DatabaseId(app.options.projectId);
|
|
25546
|
-
}
|
|
25547
25565
|
/**
|
|
25548
25566
|
* Modify this instance to communicate with the Cloud Firestore emulator.
|
|
25549
25567
|
*
|
|
@@ -26212,15 +26230,14 @@ const CACHE_SIZE_UNLIMITED = LRU_COLLECTION_DISABLED;
|
|
|
26212
26230
|
*/
|
|
26213
26231
|
class Firestore extends Firestore$1 {
|
|
26214
26232
|
/** @hideconstructor */
|
|
26215
|
-
constructor(
|
|
26216
|
-
super(
|
|
26233
|
+
constructor(authCredentialsProvider, appCheckCredentialsProvider, databaseId, app) {
|
|
26234
|
+
super(authCredentialsProvider, appCheckCredentialsProvider, databaseId, app);
|
|
26217
26235
|
/**
|
|
26218
26236
|
* Whether it's a {@link Firestore} or Firestore Lite instance.
|
|
26219
26237
|
*/
|
|
26220
26238
|
this.type = 'firestore';
|
|
26221
26239
|
this._queue = newAsyncQueue();
|
|
26222
|
-
this._persistenceKey =
|
|
26223
|
-
'name' in databaseIdOrApp ? databaseIdOrApp.name : '[DEFAULT]';
|
|
26240
|
+
this._persistenceKey = (app === null || app === void 0 ? void 0 : app.name) || '[DEFAULT]';
|
|
26224
26241
|
}
|
|
26225
26242
|
_terminate() {
|
|
26226
26243
|
if (!this._firestoreClient) {
|
|
@@ -26240,13 +26257,19 @@ class Firestore extends Firestore$1 {
|
|
|
26240
26257
|
* @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
|
|
26241
26258
|
* be associated.
|
|
26242
26259
|
* @param settings - A settings object to configure the {@link Firestore} instance.
|
|
26260
|
+
* @param databaseId - The name of database.
|
|
26243
26261
|
* @returns A newly initialized {@link Firestore} instance.
|
|
26244
26262
|
*/
|
|
26245
|
-
function initializeFirestore(app, settings) {
|
|
26263
|
+
function initializeFirestore(app, settings, databaseId) {
|
|
26264
|
+
if (!databaseId) {
|
|
26265
|
+
databaseId = DEFAULT_DATABASE_NAME;
|
|
26266
|
+
}
|
|
26246
26267
|
const provider = _getProvider(app, 'firestore');
|
|
26247
|
-
if (provider.isInitialized()) {
|
|
26248
|
-
const existingInstance = provider.getImmediate(
|
|
26249
|
-
|
|
26268
|
+
if (provider.isInitialized(databaseId)) {
|
|
26269
|
+
const existingInstance = provider.getImmediate({
|
|
26270
|
+
identifier: databaseId
|
|
26271
|
+
});
|
|
26272
|
+
const initialSettings = provider.getOptions(databaseId);
|
|
26250
26273
|
if (deepEqual(initialSettings, settings)) {
|
|
26251
26274
|
return existingInstance;
|
|
26252
26275
|
}
|
|
@@ -26262,19 +26285,19 @@ function initializeFirestore(app, settings) {
|
|
|
26262
26285
|
settings.cacheSizeBytes < LRU_MINIMUM_CACHE_SIZE_BYTES) {
|
|
26263
26286
|
throw new FirestoreError(Code.INVALID_ARGUMENT, `cacheSizeBytes must be at least ${LRU_MINIMUM_CACHE_SIZE_BYTES}`);
|
|
26264
26287
|
}
|
|
26265
|
-
return provider.initialize({
|
|
26288
|
+
return provider.initialize({
|
|
26289
|
+
options: settings,
|
|
26290
|
+
instanceIdentifier: databaseId
|
|
26291
|
+
});
|
|
26266
26292
|
}
|
|
26267
|
-
|
|
26268
|
-
|
|
26269
|
-
|
|
26270
|
-
|
|
26271
|
-
|
|
26272
|
-
|
|
26273
|
-
|
|
26274
|
-
|
|
26275
|
-
*/
|
|
26276
|
-
function getFirestore(app = getApp()) {
|
|
26277
|
-
return _getProvider(app, 'firestore').getImmediate();
|
|
26293
|
+
function getFirestore(appOrDatabaseId, optionalDatabaseId) {
|
|
26294
|
+
const app = typeof appOrDatabaseId === 'object' ? appOrDatabaseId : getApp();
|
|
26295
|
+
const databaseId = typeof appOrDatabaseId === 'string'
|
|
26296
|
+
? appOrDatabaseId
|
|
26297
|
+
: optionalDatabaseId || DEFAULT_DATABASE_NAME;
|
|
26298
|
+
return _getProvider(app, 'firestore').getImmediate({
|
|
26299
|
+
identifier: databaseId
|
|
26300
|
+
});
|
|
26278
26301
|
}
|
|
26279
26302
|
/**
|
|
26280
26303
|
* @internal
|
|
@@ -26520,7 +26543,7 @@ function disableNetwork(firestore) {
|
|
|
26520
26543
|
* terminated.
|
|
26521
26544
|
*/
|
|
26522
26545
|
function terminate(firestore) {
|
|
26523
|
-
_removeServiceInstance(firestore.app, 'firestore');
|
|
26546
|
+
_removeServiceInstance(firestore.app, 'firestore', firestore._databaseId.database);
|
|
26524
26547
|
return firestore._delete();
|
|
26525
26548
|
}
|
|
26526
26549
|
/**
|
|
@@ -26589,13 +26612,13 @@ function verifyNotInitialized(firestore) {
|
|
|
26589
26612
|
*/
|
|
26590
26613
|
function registerFirestore(variant, useFetchStreams = true) {
|
|
26591
26614
|
setSDKVersion(SDK_VERSION$1);
|
|
26592
|
-
_registerComponent(new Component('firestore', (container, { options: settings }) => {
|
|
26615
|
+
_registerComponent(new Component('firestore', (container, { instanceIdentifier: databaseId, options: settings }) => {
|
|
26593
26616
|
const app = container.getProvider('app').getImmediate();
|
|
26594
|
-
const firestoreInstance = new Firestore(
|
|
26617
|
+
const firestoreInstance = new Firestore(new FirebaseAuthCredentialsProvider(container.getProvider('auth-internal')), new FirebaseAppCheckTokenProvider(container.getProvider('app-check-internal')), databaseIdFromApp(app, databaseId), app);
|
|
26595
26618
|
settings = Object.assign({ useFetchStreams }, settings);
|
|
26596
26619
|
firestoreInstance._setSettings(settings);
|
|
26597
26620
|
return firestoreInstance;
|
|
26598
|
-
}, 'PUBLIC'));
|
|
26621
|
+
}, 'PUBLIC').setMultipleInstances(true));
|
|
26599
26622
|
registerVersion(name, version$1, variant);
|
|
26600
26623
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
26601
26624
|
registerVersion(name, version$1, 'esm2017');
|