Skip to content

Merging Master into Multi-Tab #1045

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 25 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
284a746
Add @davideast as a CODEOWNER (#996)
Jul 9, 2018
81cd260
Embed metadata directly into the RPC call (#979)
ryanpbrewster Jul 10, 2018
d7cc609
Added missing type for optional database url. (#1001)
CarlosACabrera Jul 11, 2018
a8e3b5a
RxFire Realtime Database (#997)
davideast Jul 12, 2018
ad69a21
Expose array transforms and array contains queries. (#1004)
mikelehen Jul 12, 2018
e125588
Move fieldFilter (free function) to Filter.create() (#988)
rsgowman Jul 13, 2018
f1a5e2e
Enable firestore sdk to talk to emulator (#1007)
tonymeng Jul 16, 2018
6905339
Setting GarbageSource in SyncEngine's constructor (#1010)
schmidt-sebastian Jul 16, 2018
5c338d1
b/72533250: Fix issue with limbo resolutions triggering incorrect man…
mikelehen Jul 18, 2018
49c81b1
Updating yarn.lock
jshcrowthe Jul 18, 2018
3d1a15c
Add @firebase/util as a dep of @firebase/testing
jshcrowthe Jul 18, 2018
6d66392
Allow remote updates from watch to heal a cache with synthesized dele…
wilhuff Jul 18, 2018
3d26806
Fix getRemoteKeysForTarget() method name in comment. (#1020)
mikelehen Jul 18, 2018
593cd20
Making sure we don't export 'experimental' (#1023)
schmidt-sebastian Jul 19, 2018
e6ab894
Add a schema migration that drops the query cache (#1019)
wilhuff Jul 19, 2018
4b51dee
Add a release note for the fix to #1548 (#1024)
wilhuff Jul 19, 2018
fffdb75
Ensure that we create an empty TargetGlobal row. (#1029)
mikelehen Jul 19, 2018
d60f659
Remove unnecessary `any` (#1030)
Jul 19, 2018
60a58d9
Publish [email protected]
jshcrowthe Jul 19, 2018
2d7a74c
Unify local.QueryData with the other platforms (#1027)
rsgowman Jul 20, 2018
5118935
Fix to #1027 to allow SnapshotVersion == 0 (#1033)
rsgowman Jul 20, 2018
86c8077
Add iat to fake access token payload (#1022)
ryanpbrewster Jul 20, 2018
8309eb3
catch server error RESET_PASSWORD_EXCEED_LIMIT (#1037)
wti806 Jul 23, 2018
56b15ff
Dirty Merge
schmidt-sebastian Jul 24, 2018
d300520
Merging Master into Multi-Tab (#1038)
schmidt-sebastian Jul 25, 2018
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
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ packages/auth-types @bojeil-google @wti806

# Testing Code
packages/testing @tonymeng @ryanpbrewster

# RxFire Code
packages/rxfire @davideast
2 changes: 1 addition & 1 deletion integration/browserify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "karma start --single-run"
},
"dependencies": {
"firebase": "5.2.0"
"firebase": "5.3.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.47",
Expand Down
2 changes: 1 addition & 1 deletion integration/firebase-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"test": "tsc index.ts --outDir dist"
},
"dependencies": {
"firebase": "5.2.0"
"firebase": "5.3.0"
},
"devDependencies": {
"typescript": "2.8.1"
Expand Down
2 changes: 1 addition & 1 deletion integration/messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"test:manual": "mocha --exit"
},
"dependencies": {
"firebase": "5.2.0"
"firebase": "5.3.0"
},
"devDependencies": {
"chai": "4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion integration/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"test": "karma start --single-run"
},
"dependencies": {
"firebase": "5.2.0"
"firebase": "5.3.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.47",
Expand Down
2 changes: 1 addition & 1 deletion integration/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "karma start --single-run"
},
"dependencies": {
"firebase": "5.2.0"
"firebase": "5.3.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.47",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebase/auth",
"version": "0.7.0",
"version": "0.7.1",
"main": "dist/auth.js",
"module": "dist/auth.esm.js",
"description": "Javascript library for Firebase Auth SDK",
Expand Down
3 changes: 3 additions & 0 deletions packages/auth/src/rpchandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ fireauth.RpcHandler.ServerError = {
OPERATION_NOT_ALLOWED: 'OPERATION_NOT_ALLOWED',
PASSWORD_LOGIN_DISABLED: 'PASSWORD_LOGIN_DISABLED',
QUOTA_EXCEEDED: 'QUOTA_EXCEEDED',
RESET_PASSWORD_EXCEED_LIMIT: 'RESET_PASSWORD_EXCEED_LIMIT',
SESSION_EXPIRED: 'SESSION_EXPIRED',
TOKEN_EXPIRED: 'TOKEN_EXPIRED',
TOO_MANY_ATTEMPTS_TRY_LATER: 'TOO_MANY_ATTEMPTS_TRY_LATER',
Expand Down Expand Up @@ -2231,6 +2232,8 @@ fireauth.RpcHandler.getDeveloperError_ =
// Send Password reset email errors:
errorMap[fireauth.RpcHandler.ServerError.EMAIL_NOT_FOUND] =
fireauth.authenum.Error.USER_DELETED;
errorMap[fireauth.RpcHandler.ServerError.RESET_PASSWORD_EXCEED_LIMIT] =
fireauth.authenum.Error.TOO_MANY_ATTEMPTS_TRY_LATER;

// Reset password errors:
errorMap[fireauth.RpcHandler.ServerError.EXPIRED_OOB_CODE] =
Expand Down
2 changes: 2 additions & 0 deletions packages/auth/test/rpchandler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3994,6 +3994,8 @@ function testSendPasswordResetEmail_caughtServerError() {
var errorMap = {};
errorMap[fireauth.RpcHandler.ServerError.EMAIL_NOT_FOUND] =
fireauth.authenum.Error.USER_DELETED;
errorMap[fireauth.RpcHandler.ServerError.RESET_PASSWORD_EXCEED_LIMIT] =
fireauth.authenum.Error.TOO_MANY_ATTEMPTS_TRY_LATER;
errorMap[fireauth.RpcHandler.ServerError.INVALID_RECIPIENT_EMAIL] =
fireauth.authenum.Error.INVALID_RECIPIENT_EMAIL;
errorMap[fireauth.RpcHandler.ServerError.INVALID_SENDER] =
Expand Down
13 changes: 5 additions & 8 deletions packages/firebase/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ declare namespace firebase {
declare namespace firebase.app {
interface App {
auth(): firebase.auth.Auth;
database(): firebase.database.Database;
database(url?: string): firebase.database.Database;
delete(): Promise<any>;
messaging(): firebase.messaging.Messaging;
name: string;
Expand Down Expand Up @@ -1559,10 +1559,9 @@ declare namespace firebase.firestore {

/**
* Filter conditions in a `Query.where()` clause are specified using the
* strings '<', '<=', '==', '>=', and '>'.
* strings '<', '<=', '==', '>=', '>', and 'array-contains'.
*/
// TODO(array-features): Add 'array-contains' once backend support lands.
export type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>';
export type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>' | 'array-contains';

/**
* A `Query` refers to a Query which you can read or listen to. You can also
Expand Down Expand Up @@ -1942,8 +1941,7 @@ declare namespace firebase.firestore {
* @param elements The elements to union into the array.
* @return The FieldValue sentinel for use in a call to set() or update().
*/
// TODO(array-features): Expose this once backend support lands.
//static arrayUnion(...elements: any[]): FieldValue;
static arrayUnion(...elements: any[]): FieldValue;

/**
* Returns a special value that can be used with set() or update() that tells
Expand All @@ -1955,8 +1953,7 @@ declare namespace firebase.firestore {
* @param elements The elements to remove from the array.
* @return The FieldValue sentinel for use in a call to set() or update().
*/
// TODO(array-features): Expose this once backend support lands.
//static arrayRemove(...elements: any[]): FieldValue;
static arrayRemove(...elements: any[]): FieldValue;

/**
* Returns true if this `FieldValue` is equal to the provided one.
Expand Down
6 changes: 3 additions & 3 deletions packages/firebase/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firebase",
"version": "5.2.0",
"version": "5.3.0",
"description": "Firebase JavaScript library for web and Node.js",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"license": "Apache-2.0",
Expand Down Expand Up @@ -36,9 +36,9 @@
"react-native": "dist/index.rn.cjs.js",
"dependencies": {
"@firebase/app": "0.3.3",
"@firebase/auth": "0.7.0",
"@firebase/auth": "0.7.1",
"@firebase/database": "0.3.4",
"@firebase/firestore": "0.5.6",
"@firebase/firestore": "0.6.0",
"@firebase/functions": "0.3.0",
"@firebase/messaging": "0.3.5",
"@firebase/polyfill": "0.3.3",
Expand Down
11 changes: 4 additions & 7 deletions packages/firestore-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -868,10 +868,9 @@ export type OrderByDirection = 'desc' | 'asc';

/**
* Filter conditions in a `Query.where()` clause are specified using the
* strings '<', '<=', '==', '>=', and '>'.
* strings '<', '<=', '==', '>=', '>', and 'array-contains'.
*/
// TODO(array-features): Add 'array-contains' once backend support lands.
export type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>';
export type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>' | 'array-contains';

/**
* A `Query` refers to a Query which you can read or listen to. You can also
Expand Down Expand Up @@ -1247,8 +1246,7 @@ export class FieldValue {
* @param elements The elements to union into the array.
* @return The FieldValue sentinel for use in a call to set() or update().
*/
// TODO(array-features): Expose this once backend support lands.
//static arrayUnion(...elements: any[]): FieldValue;
static arrayUnion(...elements: any[]): FieldValue;

/**
* Returns a special value that can be used with set() or update() that tells
Expand All @@ -1260,8 +1258,7 @@ export class FieldValue {
* @param elements The elements to remove from the array.
* @return The FieldValue sentinel for use in a call to set() or update().
*/
// TODO(array-features): Expose this once backend support lands.
//static arrayRemove(...elements: any[]): FieldValue;
static arrayRemove(...elements: any[]): FieldValue;

/**
* Returns true if this `FieldValue` is equal to the provided one.
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebase/firestore-types",
"version": "0.4.3",
"version": "0.5.0",
"description": "@firebase/firestore Types",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"license": "Apache-2.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Unreleased
- [fixed] Fixed an issue where documents could be cached as deleted when
they should not have been, leading to queries returning fewer results than
they should (firebase/firebase-ios-sdk#1548).
- [feature] Added `firebase.firestore.FieldValue.arrayUnion()` and
`firebase.firestore.FieldValue.arrayRemove()` to atomically add and remove
elements from an array field in a document.
- [feature] Added `'array-contains'` query operator for use with `.where()` to
find documents where an array field contains a specific element.

# 0.5.0
- [changed] Merged the `includeQueryMetadataChanges` and
Expand Down
4 changes: 2 additions & 2 deletions packages/firestore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebase/firestore",
"version": "0.5.6",
"version": "0.6.0",
"description": "",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"scripts": {
Expand All @@ -25,7 +25,7 @@
"dist"
],
"dependencies": {
"@firebase/firestore-types": "0.4.3",
"@firebase/firestore-types": "0.5.0",
"@firebase/logger": "0.1.1",
"@firebase/webchannel-wrapper": "0.2.8",
"grpc": "1.11.3",
Expand Down
3 changes: 1 addition & 2 deletions packages/firestore/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { FirestoreClient } from '../core/firestore_client';
import {
Bound,
Direction,
fieldFilter,
Filter,
OrderBy,
Query as InternalQuery,
Expand Down Expand Up @@ -1373,7 +1372,7 @@ export class Query implements firestore.Query {
value
);
}
const filter = fieldFilter(fieldPath, relationOp, fieldValue);
const filter = Filter.create(fieldPath, relationOp, fieldValue);
this.validateNewFilter(filter);
return new Query(this._query.addFilter(filter), this.firestore);
}
Expand Down
6 changes: 2 additions & 4 deletions packages/firestore/src/api/field_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ export abstract class FieldValueImpl implements firestore.FieldValue {
return ServerTimestampFieldValueImpl.instance;
}

// TODO(array-features): Expose this once backend support lands.
static _arrayUnion(...elements: AnyJs[]): FieldValueImpl {
static arrayUnion(...elements: AnyJs[]): FieldValueImpl {
validateAtLeastNumberOfArgs('FieldValue.arrayUnion', arguments, 1);
// NOTE: We don't actually parse the data until it's used in set() or
// update() since we need access to the Firestore instance.
return new ArrayUnionFieldValueImpl(elements);
}

// TODO(array-features): Expose this once backend support lands.
static _arrayRemove(...elements: AnyJs[]): FieldValueImpl {
static arrayRemove(...elements: AnyJs[]): FieldValueImpl {
validateAtLeastNumberOfArgs('FieldValue.arrayRemove', arguments, 1);
// NOTE: We don't actually parse the data until it's used in set() or
// update() since we need access to the Firestore instance.
Expand Down
80 changes: 41 additions & 39 deletions packages/firestore/src/core/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,35 @@ export class Query {
}
}

export interface Filter {
matches(doc: Document): boolean;
canonicalId(): string;
isEqual(filter: Filter): boolean;
export abstract class Filter {
abstract matches(doc: Document): boolean;
abstract canonicalId(): string;
abstract isEqual(filter: Filter): boolean;

/**
* Creates a filter based on the provided arguments.
*/
static create(field: FieldPath, op: RelationOp, value: FieldValue): Filter {
if (value.isEqual(NullValue.INSTANCE)) {
if (op !== RelationOp.EQUAL) {
throw new FirestoreError(
Code.INVALID_ARGUMENT,
'Invalid query. You can only perform equals comparisons on null.'
);
}
return new NullFilter(field);
} else if (value.isEqual(DoubleValue.NAN)) {
if (op !== RelationOp.EQUAL) {
throw new FirestoreError(
Code.INVALID_ARGUMENT,
'Invalid query. You can only perform equals comparisons on NaN.'
);
}
return new NanFilter(field);
} else {
return new RelationFilter(field, op, value);
}
}
}

export class RelationOp {
Expand Down Expand Up @@ -434,12 +459,14 @@ export class RelationOp {
}
}

export class RelationFilter implements Filter {
export class RelationFilter extends Filter {
constructor(
public field: FieldPath,
public op: RelationOp,
public value: FieldValue
) {}
) {
super();
}

matches(doc: Document): boolean {
if (this.field.isKeyField()) {
Expand Down Expand Up @@ -528,8 +555,10 @@ export class RelationFilter implements Filter {
/**
* Filter that matches 'null' values.
*/
export class NullFilter implements Filter {
constructor(public field: FieldPath) {}
export class NullFilter extends Filter {
constructor(public field: FieldPath) {
super();
}

matches(doc: Document): boolean {
const val = doc.field(this.field);
Expand All @@ -556,8 +585,10 @@ export class NullFilter implements Filter {
/**
* Filter that matches 'NaN' values.
*/
export class NanFilter implements Filter {
constructor(public field: FieldPath) {}
export class NanFilter extends Filter {
constructor(public field: FieldPath) {
super();
}

matches(doc: Document): boolean {
const val = doc.field(this.field).value();
Expand All @@ -581,35 +612,6 @@ export class NanFilter implements Filter {
}
}

/**
* Creates a filter based on the provided arguments.
*/
export function fieldFilter(
field: FieldPath,
op: RelationOp,
value: FieldValue
): Filter {
if (value.isEqual(NullValue.INSTANCE)) {
if (op !== RelationOp.EQUAL) {
throw new FirestoreError(
Code.INVALID_ARGUMENT,
'Invalid query. You can only perform equals ' + 'comparisons on null.'
);
}
return new NullFilter(field);
} else if (value.isEqual(DoubleValue.NAN)) {
if (op !== RelationOp.EQUAL) {
throw new FirestoreError(
Code.INVALID_ARGUMENT,
'Invalid query. You can only perform equals ' + 'comparisons on NaN.'
);
}
return new NanFilter(field);
} else {
return new RelationFilter(field, op, value);
}
}

/**
* The direction of sorting in an order by.
*/
Expand Down
Loading