Skip to content

Commit

Permalink
Remove makeConstructorPrivate (#3309)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Jun 26, 2020
1 parent c38fc71 commit e90304c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 274 deletions.
6 changes: 6 additions & 0 deletions .changeset/small-ghosts-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"firebase": patch
"@firebase/firestore": patch
---

Removed internal wrapper around our public API that was meant to prevent incorrect SDK usage for JavaScript users, but caused our SDK to stop working in IE11.
4 changes: 4 additions & 0 deletions packages/firestore/src/api/field_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ export class NumericIncrementFieldValueImpl extends SerializableFieldValue {
/** The public FieldValue class of the lite API. */
export abstract class FieldValue extends SerializableFieldValue
implements firestore.FieldValue {
protected constructor() {
super();
}

static delete(): firestore.FieldValue {
validateNoArgs('FieldValue.delete', arguments);
return new FieldValueDelegate(
Expand Down
62 changes: 12 additions & 50 deletions packages/firestore/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,75 +21,37 @@ import { _FirebaseNamespace } from '@firebase/app-types/private';
import { Component, ComponentType, Provider } from '@firebase/component';
import {
CACHE_SIZE_UNLIMITED,
Firestore,
CollectionReference,
DocumentReference,
DocumentSnapshot,
QueryDocumentSnapshot,
Firestore,
Query,
QueryDocumentSnapshot,
QuerySnapshot,
CollectionReference,
Transaction,
WriteBatch
} from './api/database';
import { Blob } from './api/blob';
import { FieldPath } from './api/field_path';
import { GeoPoint } from './api/geo_point';
import { Timestamp } from './api/timestamp';
import { makeConstructorPrivate } from './util/api';
import { FieldValue } from './api/field_value';

// Public instance that disallows construction at runtime. Note that this still
// allows instanceof checks.
export const PublicFirestore = makeConstructorPrivate(
const firestoreNamespace = {
Firestore,
'Use firebase.firestore() instead.'
);
export const PublicTransaction = makeConstructorPrivate(
GeoPoint,
Timestamp,
Blob,
Transaction,
'Use firebase.firestore().runTransaction() instead.'
);
export const PublicWriteBatch = makeConstructorPrivate(
WriteBatch,
'Use firebase.firestore().batch() instead.'
);
export const PublicDocumentReference = makeConstructorPrivate(
DocumentReference,
'Use firebase.firestore().doc() instead.'
);
export const PublicDocumentSnapshot = makeConstructorPrivate(DocumentSnapshot);
export const PublicQueryDocumentSnapshot = makeConstructorPrivate(
QueryDocumentSnapshot
);
export const PublicQuery = makeConstructorPrivate(Query);
export const PublicQuerySnapshot = makeConstructorPrivate(QuerySnapshot);
export const PublicCollectionReference = makeConstructorPrivate(
DocumentSnapshot,
Query,
QueryDocumentSnapshot,
QuerySnapshot,
CollectionReference,
'Use firebase.firestore().collection() instead.'
);
export const PublicFieldValue = makeConstructorPrivate(
FieldValue,
'Use FieldValue.<field>() instead.'
);
export const PublicBlob = makeConstructorPrivate(
Blob,
'Use Blob.fromUint8Array() or Blob.fromBase64String() instead.'
);

const firestoreNamespace = {
Firestore: PublicFirestore,
GeoPoint,
Timestamp,
Blob: PublicBlob,
Transaction: PublicTransaction,
WriteBatch: PublicWriteBatch,
DocumentReference: PublicDocumentReference,
DocumentSnapshot: PublicDocumentSnapshot,
Query: PublicQuery,
QueryDocumentSnapshot: PublicQueryDocumentSnapshot,
QuerySnapshot: PublicQuerySnapshot,
CollectionReference: PublicCollectionReference,
FieldPath,
FieldValue: PublicFieldValue,
FieldValue,
setLogLevel: Firestore.setLogLevel,
CACHE_SIZE_UNLIMITED
};
Expand Down
57 changes: 0 additions & 57 deletions packages/firestore/src/util/api.ts

This file was deleted.

This file was deleted.

72 changes: 0 additions & 72 deletions packages/firestore/test/unit/util/api.test.ts

This file was deleted.

0 comments on commit e90304c

Please sign in to comment.