@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.cjs.js
CHANGED
|
@@ -33,7 +33,7 @@ var grpc__namespace = /*#__PURE__*/_interopNamespace(grpc);
|
|
|
33
33
|
var protoLoader__namespace = /*#__PURE__*/_interopNamespace(protoLoader);
|
|
34
34
|
|
|
35
35
|
const name = "@firebase/firestore";
|
|
36
|
-
const version$1 = "3.4.
|
|
36
|
+
const version$1 = "3.4.15-20220831174748";
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @license
|
|
@@ -86,7 +86,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
86
86
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
87
87
|
User.MOCK_USER = new User('mock-user');
|
|
88
88
|
|
|
89
|
-
const version = "9.9.
|
|
89
|
+
const version = "9.9.4-20220831174748";
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* @license
|
|
@@ -641,19 +641,41 @@ class FirebaseAuthCredentialsProvider {
|
|
|
641
641
|
* safer to keep the implementation as-is.
|
|
642
642
|
*/
|
|
643
643
|
class FirstPartyToken {
|
|
644
|
-
constructor(gapi, sessionIndex, iamToken) {
|
|
644
|
+
constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
|
|
645
|
+
this.gapi = gapi;
|
|
646
|
+
this.sessionIndex = sessionIndex;
|
|
647
|
+
this.iamToken = iamToken;
|
|
648
|
+
this.authTokenFactory = authTokenFactory;
|
|
645
649
|
this.type = 'FirstParty';
|
|
646
650
|
this.user = User.FIRST_PARTY;
|
|
647
|
-
this.
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
651
|
+
this._headers = new Map();
|
|
652
|
+
}
|
|
653
|
+
/** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */
|
|
654
|
+
getAuthToken() {
|
|
655
|
+
if (this.authTokenFactory) {
|
|
656
|
+
return this.authTokenFactory();
|
|
652
657
|
}
|
|
653
|
-
|
|
654
|
-
this.
|
|
658
|
+
else {
|
|
659
|
+
// Make sure this really is a Gapi client.
|
|
660
|
+
hardAssert(!!(typeof this.gapi === 'object' &&
|
|
661
|
+
this.gapi !== null &&
|
|
662
|
+
this.gapi['auth'] &&
|
|
663
|
+
this.gapi['auth']['getAuthHeaderValueForFirstParty']));
|
|
664
|
+
return this.gapi['auth']['getAuthHeaderValueForFirstParty']([]);
|
|
655
665
|
}
|
|
656
666
|
}
|
|
667
|
+
get headers() {
|
|
668
|
+
this._headers.set('X-Goog-AuthUser', this.sessionIndex);
|
|
669
|
+
// Use array notation to prevent minification
|
|
670
|
+
const authHeaderTokenValue = this.getAuthToken();
|
|
671
|
+
if (authHeaderTokenValue) {
|
|
672
|
+
this._headers.set('Authorization', authHeaderTokenValue);
|
|
673
|
+
}
|
|
674
|
+
if (this.iamToken) {
|
|
675
|
+
this._headers.set('X-Goog-Iam-Authorization-Token', this.iamToken);
|
|
676
|
+
}
|
|
677
|
+
return this._headers;
|
|
678
|
+
}
|
|
657
679
|
}
|
|
658
680
|
/*
|
|
659
681
|
* Provides user credentials required for the Firestore JavaScript SDK
|
|
@@ -661,13 +683,14 @@ class FirstPartyToken {
|
|
|
661
683
|
* to applications hosted by Google.
|
|
662
684
|
*/
|
|
663
685
|
class FirstPartyAuthCredentialsProvider {
|
|
664
|
-
constructor(gapi, sessionIndex, iamToken) {
|
|
686
|
+
constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
|
|
665
687
|
this.gapi = gapi;
|
|
666
688
|
this.sessionIndex = sessionIndex;
|
|
667
689
|
this.iamToken = iamToken;
|
|
690
|
+
this.authTokenFactory = authTokenFactory;
|
|
668
691
|
}
|
|
669
692
|
getToken() {
|
|
670
|
-
return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken));
|
|
693
|
+
return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken, this.authTokenFactory));
|
|
671
694
|
}
|
|
672
695
|
start(asyncQueue, changeListener) {
|
|
673
696
|
// Fire with initial uid.
|
|
@@ -778,12 +801,7 @@ function makeAuthCredentialsProvider(credentials) {
|
|
|
778
801
|
switch (credentials['type']) {
|
|
779
802
|
case 'gapi':
|
|
780
803
|
const client = credentials['client'];
|
|
781
|
-
|
|
782
|
-
hardAssert(!!(typeof client === 'object' &&
|
|
783
|
-
client !== null &&
|
|
784
|
-
client['auth'] &&
|
|
785
|
-
client['auth']['getAuthHeaderValueForFirstParty']));
|
|
786
|
-
return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null);
|
|
804
|
+
return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null, credentials['authTokenFactory'] || null);
|
|
787
805
|
case 'provider':
|
|
788
806
|
return credentials['client'];
|
|
789
807
|
default:
|
|
@@ -4350,6 +4368,12 @@ class DatabaseId {
|
|
|
4350
4368
|
other.projectId === this.projectId &&
|
|
4351
4369
|
other.database === this.database);
|
|
4352
4370
|
}
|
|
4371
|
+
}
|
|
4372
|
+
function databaseIdFromApp(app, database) {
|
|
4373
|
+
if (!Object.prototype.hasOwnProperty.apply(app.options, ['projectId'])) {
|
|
4374
|
+
throw new FirestoreError(Code.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
|
|
4375
|
+
}
|
|
4376
|
+
return new DatabaseId(app.options.projectId, database);
|
|
4353
4377
|
}
|
|
4354
4378
|
|
|
4355
4379
|
/**
|
|
@@ -24765,7 +24789,7 @@ class Transaction$2 {
|
|
|
24765
24789
|
docVersion = doc.version;
|
|
24766
24790
|
}
|
|
24767
24791
|
else if (doc.isNoDocument()) {
|
|
24768
|
-
//
|
|
24792
|
+
// Represent a deleted doc using SnapshotVersion.min().
|
|
24769
24793
|
docVersion = SnapshotVersion.min();
|
|
24770
24794
|
}
|
|
24771
24795
|
else {
|
|
@@ -24789,7 +24813,12 @@ class Transaction$2 {
|
|
|
24789
24813
|
precondition(key) {
|
|
24790
24814
|
const version = this.readVersions.get(key.toString());
|
|
24791
24815
|
if (!this.writtenDocs.has(key.toString()) && version) {
|
|
24792
|
-
|
|
24816
|
+
if (version.isEqual(SnapshotVersion.min())) {
|
|
24817
|
+
return Precondition.exists(false);
|
|
24818
|
+
}
|
|
24819
|
+
else {
|
|
24820
|
+
return Precondition.updateTime(version);
|
|
24821
|
+
}
|
|
24793
24822
|
}
|
|
24794
24823
|
else {
|
|
24795
24824
|
return Precondition.none();
|
|
@@ -25484,9 +25513,11 @@ class FirestoreSettingsImpl {
|
|
|
25484
25513
|
*/
|
|
25485
25514
|
class Firestore$1 {
|
|
25486
25515
|
/** @hideconstructor */
|
|
25487
|
-
constructor(
|
|
25516
|
+
constructor(_authCredentials, _appCheckCredentials, _databaseId, _app) {
|
|
25488
25517
|
this._authCredentials = _authCredentials;
|
|
25489
25518
|
this._appCheckCredentials = _appCheckCredentials;
|
|
25519
|
+
this._databaseId = _databaseId;
|
|
25520
|
+
this._app = _app;
|
|
25490
25521
|
/**
|
|
25491
25522
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
25492
25523
|
*/
|
|
@@ -25494,13 +25525,6 @@ class Firestore$1 {
|
|
|
25494
25525
|
this._persistenceKey = '(lite)';
|
|
25495
25526
|
this._settings = new FirestoreSettingsImpl({});
|
|
25496
25527
|
this._settingsFrozen = false;
|
|
25497
|
-
if (databaseIdOrApp instanceof DatabaseId) {
|
|
25498
|
-
this._databaseId = databaseIdOrApp;
|
|
25499
|
-
}
|
|
25500
|
-
else {
|
|
25501
|
-
this._app = databaseIdOrApp;
|
|
25502
|
-
this._databaseId = databaseIdFromApp(databaseIdOrApp);
|
|
25503
|
-
}
|
|
25504
25528
|
}
|
|
25505
25529
|
/**
|
|
25506
25530
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
@@ -25563,12 +25587,6 @@ class Firestore$1 {
|
|
|
25563
25587
|
return Promise.resolve();
|
|
25564
25588
|
}
|
|
25565
25589
|
}
|
|
25566
|
-
function databaseIdFromApp(app) {
|
|
25567
|
-
if (!Object.prototype.hasOwnProperty.apply(app.options, ['projectId'])) {
|
|
25568
|
-
throw new FirestoreError(Code.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
|
|
25569
|
-
}
|
|
25570
|
-
return new DatabaseId(app.options.projectId);
|
|
25571
|
-
}
|
|
25572
25590
|
/**
|
|
25573
25591
|
* Modify this instance to communicate with the Cloud Firestore emulator.
|
|
25574
25592
|
*
|
|
@@ -26237,15 +26255,14 @@ const CACHE_SIZE_UNLIMITED = LRU_COLLECTION_DISABLED;
|
|
|
26237
26255
|
*/
|
|
26238
26256
|
class Firestore extends Firestore$1 {
|
|
26239
26257
|
/** @hideconstructor */
|
|
26240
|
-
constructor(
|
|
26241
|
-
super(
|
|
26258
|
+
constructor(authCredentialsProvider, appCheckCredentialsProvider, databaseId, app) {
|
|
26259
|
+
super(authCredentialsProvider, appCheckCredentialsProvider, databaseId, app);
|
|
26242
26260
|
/**
|
|
26243
26261
|
* Whether it's a {@link Firestore} or Firestore Lite instance.
|
|
26244
26262
|
*/
|
|
26245
26263
|
this.type = 'firestore';
|
|
26246
26264
|
this._queue = newAsyncQueue();
|
|
26247
|
-
this._persistenceKey =
|
|
26248
|
-
'name' in databaseIdOrApp ? databaseIdOrApp.name : '[DEFAULT]';
|
|
26265
|
+
this._persistenceKey = (app === null || app === void 0 ? void 0 : app.name) || '[DEFAULT]';
|
|
26249
26266
|
}
|
|
26250
26267
|
_terminate() {
|
|
26251
26268
|
if (!this._firestoreClient) {
|
|
@@ -26265,13 +26282,19 @@ class Firestore extends Firestore$1 {
|
|
|
26265
26282
|
* @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
|
|
26266
26283
|
* be associated.
|
|
26267
26284
|
* @param settings - A settings object to configure the {@link Firestore} instance.
|
|
26285
|
+
* @param databaseId - The name of database.
|
|
26268
26286
|
* @returns A newly initialized {@link Firestore} instance.
|
|
26269
26287
|
*/
|
|
26270
|
-
function initializeFirestore(app$1, settings) {
|
|
26288
|
+
function initializeFirestore(app$1, settings, databaseId) {
|
|
26289
|
+
if (!databaseId) {
|
|
26290
|
+
databaseId = DEFAULT_DATABASE_NAME;
|
|
26291
|
+
}
|
|
26271
26292
|
const provider = app._getProvider(app$1, 'firestore');
|
|
26272
|
-
if (provider.isInitialized()) {
|
|
26273
|
-
const existingInstance = provider.getImmediate(
|
|
26274
|
-
|
|
26293
|
+
if (provider.isInitialized(databaseId)) {
|
|
26294
|
+
const existingInstance = provider.getImmediate({
|
|
26295
|
+
identifier: databaseId
|
|
26296
|
+
});
|
|
26297
|
+
const initialSettings = provider.getOptions(databaseId);
|
|
26275
26298
|
if (util$1.deepEqual(initialSettings, settings)) {
|
|
26276
26299
|
return existingInstance;
|
|
26277
26300
|
}
|
|
@@ -26287,19 +26310,19 @@ function initializeFirestore(app$1, settings) {
|
|
|
26287
26310
|
settings.cacheSizeBytes < LRU_MINIMUM_CACHE_SIZE_BYTES) {
|
|
26288
26311
|
throw new FirestoreError(Code.INVALID_ARGUMENT, `cacheSizeBytes must be at least ${LRU_MINIMUM_CACHE_SIZE_BYTES}`);
|
|
26289
26312
|
}
|
|
26290
|
-
return provider.initialize({
|
|
26313
|
+
return provider.initialize({
|
|
26314
|
+
options: settings,
|
|
26315
|
+
instanceIdentifier: databaseId
|
|
26316
|
+
});
|
|
26291
26317
|
}
|
|
26292
|
-
|
|
26293
|
-
|
|
26294
|
-
|
|
26295
|
-
|
|
26296
|
-
|
|
26297
|
-
|
|
26298
|
-
|
|
26299
|
-
|
|
26300
|
-
*/
|
|
26301
|
-
function getFirestore(app$1 = app.getApp()) {
|
|
26302
|
-
return app._getProvider(app$1, 'firestore').getImmediate();
|
|
26318
|
+
function getFirestore(appOrDatabaseId, optionalDatabaseId) {
|
|
26319
|
+
const app$1 = typeof appOrDatabaseId === 'object' ? appOrDatabaseId : app.getApp();
|
|
26320
|
+
const databaseId = typeof appOrDatabaseId === 'string'
|
|
26321
|
+
? appOrDatabaseId
|
|
26322
|
+
: optionalDatabaseId || DEFAULT_DATABASE_NAME;
|
|
26323
|
+
return app._getProvider(app$1, 'firestore').getImmediate({
|
|
26324
|
+
identifier: databaseId
|
|
26325
|
+
});
|
|
26303
26326
|
}
|
|
26304
26327
|
/**
|
|
26305
26328
|
* @internal
|
|
@@ -26545,7 +26568,7 @@ function disableNetwork(firestore) {
|
|
|
26545
26568
|
* terminated.
|
|
26546
26569
|
*/
|
|
26547
26570
|
function terminate(firestore) {
|
|
26548
|
-
app._removeServiceInstance(firestore.app, 'firestore');
|
|
26571
|
+
app._removeServiceInstance(firestore.app, 'firestore', firestore._databaseId.database);
|
|
26549
26572
|
return firestore._delete();
|
|
26550
26573
|
}
|
|
26551
26574
|
/**
|
|
@@ -26614,13 +26637,13 @@ function verifyNotInitialized(firestore) {
|
|
|
26614
26637
|
*/
|
|
26615
26638
|
function registerFirestore(variant, useFetchStreams = true) {
|
|
26616
26639
|
setSDKVersion(app.SDK_VERSION);
|
|
26617
|
-
app._registerComponent(new component.Component('firestore', (container, { options: settings }) => {
|
|
26640
|
+
app._registerComponent(new component.Component('firestore', (container, { instanceIdentifier: databaseId, options: settings }) => {
|
|
26618
26641
|
const app = container.getProvider('app').getImmediate();
|
|
26619
|
-
const firestoreInstance = new Firestore(
|
|
26642
|
+
const firestoreInstance = new Firestore(new FirebaseAuthCredentialsProvider(container.getProvider('auth-internal')), new FirebaseAppCheckTokenProvider(container.getProvider('app-check-internal')), databaseIdFromApp(app, databaseId), app);
|
|
26620
26643
|
settings = Object.assign({ useFetchStreams }, settings);
|
|
26621
26644
|
firestoreInstance._setSettings(settings);
|
|
26622
26645
|
return firestoreInstance;
|
|
26623
|
-
}, 'PUBLIC'));
|
|
26646
|
+
}, 'PUBLIC').setMultipleInstances(true));
|
|
26624
26647
|
app.registerVersion(name, version$1, variant);
|
|
26625
26648
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
26626
26649
|
app.registerVersion(name, version$1, 'cjs2017');
|