Skip to content

Export the compat implementation for FieldPath and FieldValue #4656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/firestore/compat/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ import { Component, ComponentType } from '@firebase/component';
import {
FirebaseFirestore,
CACHE_SIZE_UNLIMITED,
FieldPath,
GeoPoint,
Timestamp,
FieldValue
Timestamp
} from '../exp/index'; // import from the exp public API
import { Blob } from '../src/api/blob';
import {
Expand All @@ -42,6 +40,8 @@ import {
WriteBatch,
setLogLevel
} from '../src/api/database';
import { FieldPath } from '../src/api/field_path';
import { FieldValue } from '../src/api/field_value';

const firestoreNamespace = {
Firestore,
Expand Down
2 changes: 2 additions & 0 deletions packages/firestore/exp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,5 @@ export { CACHE_SIZE_UNLIMITED } from '../src/exp/database';
export { FirestoreErrorCode, FirestoreError } from '../src/util/error';

export { AbstractUserDataWriter } from '../src/lite/user_data_writer';

export { Compat } from '../src/lite/compat';
4 changes: 1 addition & 3 deletions packages/firestore/src/api/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
* limitations under the License.
*/

import { Bytes } from '../../exp/index';
import { Bytes, Compat } from '../../exp/index';
import { isBase64Available } from '../platform/base64';
import { Code, FirestoreError } from '../util/error';

import { Compat } from './compat';

/** Helper function to assert Uint8Array is available at runtime. */
function assertUint8ArrayAvailable(): void {
if (typeof Uint8Array === 'undefined') {
Expand Down
4 changes: 2 additions & 2 deletions packages/firestore/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ import {
runTransaction,
Transaction as ExpTransaction,
WriteBatch as ExpWriteBatch,
AbstractUserDataWriter
AbstractUserDataWriter,
Compat
} from '../../exp/index'; // import from the exp public API
import { DatabaseId } from '../core/database_info';
import { UntypedFirestoreDataConverter } from '../lite/user_data_reader';
Expand All @@ -115,7 +116,6 @@ import {
import { setLogLevel as setClientLogLevel } from '../util/log';

import { Blob } from './blob';
import { Compat } from './compat';
import {
CompleteFn,
ErrorFn,
Expand Down
4 changes: 1 addition & 3 deletions packages/firestore/src/api/field_path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

import { FieldPath as PublicFieldPath } from '@firebase/firestore-types';

import { FieldPath as ExpFieldPath } from '../../exp/index';
import { FieldPath as ExpFieldPath, Compat } from '../../exp/index';
import { FieldPath as InternalFieldPath } from '../model/path';

import { Compat } from './compat';

// The objects that are a part of this API are exposed to third-parties as
// compiled javascript so we want to flag our private members with a leading
// underscore to discourage their use.
Expand Down
5 changes: 2 additions & 3 deletions packages/firestore/src/api/field_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ import {
deleteField,
FieldValue as FieldValue1,
increment,
serverTimestamp
serverTimestamp,
Compat
} from '../../exp/index';

import { Compat } from './compat';

export class FieldValue
extends Compat<FieldValue1>
implements PublicFieldValue {
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/exp/reference_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import { Compat } from '../api/compat';
import {
CompleteFn,
ErrorFn,
Expand All @@ -35,6 +34,7 @@ import {
import { newQueryForPath, Query as InternalQuery } from '../core/query';
import { ViewSnapshot } from '../core/view_snapshot';
import { Bytes } from '../lite/bytes';
import { Compat } from '../lite/compat';
import { FieldPath } from '../lite/field_path';
import { validateHasExplicitOrderByForLimitToLast } from '../lite/query';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* contains a reference to the API type in the firestore-exp API. All internal
* code unwraps these references, which allows us to only use firestore-exp
* types in the SDK.
*
* @internal
*/
export abstract class Compat<T> {
constructor(readonly _delegate: T) {}
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/lite/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import { Compat } from '../api/compat';
import { DatabaseId } from '../core/database_info';
import {
findFilterOperator,
Expand Down Expand Up @@ -53,6 +52,7 @@ import {
valueDescription
} from '../util/input_validation';

import { Compat } from './compat';
import { FieldPath } from './field_path';
import { DocumentReference, Query } from './reference';
import { DocumentSnapshot, fieldPathFromArgument } from './snapshot';
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/lite/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import { Compat } from '../api/compat';
import {
newQueryForCollectionGroup,
newQueryForPath,
Expand All @@ -33,6 +32,7 @@ import {
} from '../util/input_validation';
import { AutoId } from '../util/misc';

import { Compat } from './compat';
import { FirebaseFirestore } from './database';
import { FieldPath } from './field_path';
import { FirestoreDataConverter } from './snapshot';
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/lite/reference_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
SetOptions as PublicSetOptions
} from '@firebase/firestore-types';

import { Compat } from '../api/compat';
import { hasLimitToLast } from '../core/query';
import { Document } from '../model/document';
import { DeleteMutation, Precondition } from '../model/mutation';
Expand All @@ -34,6 +33,7 @@ import { ByteString } from '../util/byte_string';
import { cast } from '../util/input_validation';

import { Bytes } from './bytes';
import { Compat } from './compat';
import { getDatastore } from './components';
import { FirebaseFirestore } from './database';
import { FieldPath } from './field_path';
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/lite/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

import { Compat } from '../api/compat';
import { Document } from '../model/document';
import { DocumentKey } from '../model/document_key';
import { FieldPath as InternalFieldPath } from '../model/path';
import { arrayEquals } from '../util/misc';

import { Compat } from './compat';
import { FirebaseFirestore } from './database';
import { FieldPath } from './field_path';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/lite/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import { Compat } from '../api/compat';
import { Transaction as InternalTransaction } from '../core/transaction';
import { TransactionRunner } from '../core/transaction_runner';
import { Document, MaybeDocument, NoDocument } from '../model/document';
Expand All @@ -24,6 +23,7 @@ import { newAsyncQueue } from '../util/async_queue_impl';
import { cast } from '../util/input_validation';
import { Deferred } from '../util/promise';

import { Compat } from './compat';
import { getDatastore } from './components';
import { FirebaseFirestore } from './database';
import { FieldPath } from './field_path';
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/lite/user_data_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
SetOptions
} from '@firebase/firestore-types';

import { Compat } from '../api/compat';
import { ParseContext } from '../api/parse_context';
import { DatabaseId } from '../core/database_info';
import { DocumentKey } from '../model/document_key';
Expand Down Expand Up @@ -59,6 +58,7 @@ import { isPlainObject, valueDescription } from '../util/input_validation';
import { Dict, forEach, isEmpty } from '../util/obj';

import { Bytes } from './bytes';
import { Compat } from './compat';
import { FirebaseFirestore } from './database';
import { FieldPath } from './field_path';
import { FieldValue } from './field_value';
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/lite/write_batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

import { Compat } from '../api/compat';
import { DeleteMutation, Mutation, Precondition } from '../model/mutation';
import { invokeCommitRpc } from '../remote/datastore';
import { Code, FirestoreError } from '../util/error';
import { cast } from '../util/input_validation';

import { Compat } from './compat';
import { getDatastore } from './components';
import { FirebaseFirestore } from './database';
import { FieldPath } from './field_path';
Expand Down