Skip to content

Commit 56b15ff

Browse files
Dirty Merge
2 parents 23adc0e + 8309eb3 commit 56b15ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2408
-937
lines changed

.github/CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ packages/auth-types @bojeil-google @wti806
2929

3030
# Testing Code
3131
packages/testing @tonymeng @ryanpbrewster
32+
33+
# RxFire Code
34+
packages/rxfire @davideast

integration/browserify/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "karma start --single-run"
88
},
99
"dependencies": {
10-
"firebase": "5.2.0"
10+
"firebase": "5.3.0"
1111
},
1212
"devDependencies": {
1313
"@babel/core": "7.0.0-beta.47",

integration/firebase-typings/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"test": "tsc index.ts --outDir dist"
77
},
88
"dependencies": {
9-
"firebase": "5.2.0"
9+
"firebase": "5.3.0"
1010
},
1111
"devDependencies": {
1212
"typescript": "2.8.1"

integration/messaging/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:manual": "mocha --exit"
99
},
1010
"dependencies": {
11-
"firebase": "5.2.0"
11+
"firebase": "5.3.0"
1212
},
1313
"devDependencies": {
1414
"chai": "4.1.2",

integration/typescript/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"test": "karma start --single-run"
77
},
88
"dependencies": {
9-
"firebase": "5.2.0"
9+
"firebase": "5.3.0"
1010
},
1111
"devDependencies": {
1212
"@babel/core": "7.0.0-beta.47",

integration/webpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "karma start --single-run"
88
},
99
"dependencies": {
10-
"firebase": "5.2.0"
10+
"firebase": "5.3.0"
1111
},
1212
"devDependencies": {
1313
"@babel/core": "7.0.0-beta.47",

packages/auth/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/auth",
3-
"version": "0.7.0",
3+
"version": "0.7.1",
44
"main": "dist/auth.js",
55
"module": "dist/auth.esm.js",
66
"description": "Javascript library for Firebase Auth SDK",

packages/auth/src/rpchandler.js

+3
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ fireauth.RpcHandler.ServerError = {
224224
OPERATION_NOT_ALLOWED: 'OPERATION_NOT_ALLOWED',
225225
PASSWORD_LOGIN_DISABLED: 'PASSWORD_LOGIN_DISABLED',
226226
QUOTA_EXCEEDED: 'QUOTA_EXCEEDED',
227+
RESET_PASSWORD_EXCEED_LIMIT: 'RESET_PASSWORD_EXCEED_LIMIT',
227228
SESSION_EXPIRED: 'SESSION_EXPIRED',
228229
TOKEN_EXPIRED: 'TOKEN_EXPIRED',
229230
TOO_MANY_ATTEMPTS_TRY_LATER: 'TOO_MANY_ATTEMPTS_TRY_LATER',
@@ -2231,6 +2232,8 @@ fireauth.RpcHandler.getDeveloperError_ =
22312232
// Send Password reset email errors:
22322233
errorMap[fireauth.RpcHandler.ServerError.EMAIL_NOT_FOUND] =
22332234
fireauth.authenum.Error.USER_DELETED;
2235+
errorMap[fireauth.RpcHandler.ServerError.RESET_PASSWORD_EXCEED_LIMIT] =
2236+
fireauth.authenum.Error.TOO_MANY_ATTEMPTS_TRY_LATER;
22342237

22352238
// Reset password errors:
22362239
errorMap[fireauth.RpcHandler.ServerError.EXPIRED_OOB_CODE] =

packages/auth/test/rpchandler_test.js

+2
Original file line numberDiff line numberDiff line change
@@ -3994,6 +3994,8 @@ function testSendPasswordResetEmail_caughtServerError() {
39943994
var errorMap = {};
39953995
errorMap[fireauth.RpcHandler.ServerError.EMAIL_NOT_FOUND] =
39963996
fireauth.authenum.Error.USER_DELETED;
3997+
errorMap[fireauth.RpcHandler.ServerError.RESET_PASSWORD_EXCEED_LIMIT] =
3998+
fireauth.authenum.Error.TOO_MANY_ATTEMPTS_TRY_LATER;
39973999
errorMap[fireauth.RpcHandler.ServerError.INVALID_RECIPIENT_EMAIL] =
39984000
fireauth.authenum.Error.INVALID_RECIPIENT_EMAIL;
39994001
errorMap[fireauth.RpcHandler.ServerError.INVALID_SENDER] =

packages/firebase/index.d.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ declare namespace firebase {
125125
declare namespace firebase.app {
126126
interface App {
127127
auth(): firebase.auth.Auth;
128-
database(): firebase.database.Database;
128+
database(url?: string): firebase.database.Database;
129129
delete(): Promise<any>;
130130
messaging(): firebase.messaging.Messaging;
131131
name: string;
@@ -1559,10 +1559,9 @@ declare namespace firebase.firestore {
15591559

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

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

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

19611958
/**
19621959
* Returns true if this `FieldValue` is equal to the provided one.

packages/firebase/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firebase",
3-
"version": "5.2.0",
3+
"version": "5.3.0",
44
"description": "Firebase JavaScript library for web and Node.js",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"license": "Apache-2.0",
@@ -36,9 +36,9 @@
3636
"react-native": "dist/index.rn.cjs.js",
3737
"dependencies": {
3838
"@firebase/app": "0.3.3",
39-
"@firebase/auth": "0.7.0",
39+
"@firebase/auth": "0.7.1",
4040
"@firebase/database": "0.3.4",
41-
"@firebase/firestore": "0.5.6",
41+
"@firebase/firestore": "0.6.0",
4242
"@firebase/functions": "0.3.0",
4343
"@firebase/messaging": "0.3.5",
4444
"@firebase/polyfill": "0.3.3",

packages/firestore-types/index.d.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -868,10 +868,9 @@ export type OrderByDirection = 'desc' | 'asc';
868868

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

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

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

12661263
/**
12671264
* Returns true if this `FieldValue` is equal to the provided one.

packages/firestore-types/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/firestore-types",
3-
"version": "0.4.3",
3+
"version": "0.5.0",
44
"description": "@firebase/firestore Types",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"license": "Apache-2.0",

packages/firestore/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# Unreleased
2+
- [fixed] Fixed an issue where documents could be cached as deleted when
3+
they should not have been, leading to queries returning fewer results than
4+
they should (firebase/firebase-ios-sdk#1548).
5+
- [feature] Added `firebase.firestore.FieldValue.arrayUnion()` and
6+
`firebase.firestore.FieldValue.arrayRemove()` to atomically add and remove
7+
elements from an array field in a document.
8+
- [feature] Added `'array-contains'` query operator for use with `.where()` to
9+
find documents where an array field contains a specific element.
210

311
# 0.5.0
412
- [changed] Merged the `includeQueryMetadataChanges` and

packages/firestore/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/firestore",
3-
"version": "0.5.6",
3+
"version": "0.6.0",
44
"description": "",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"scripts": {
@@ -25,7 +25,7 @@
2525
"dist"
2626
],
2727
"dependencies": {
28-
"@firebase/firestore-types": "0.4.3",
28+
"@firebase/firestore-types": "0.5.0",
2929
"@firebase/logger": "0.1.1",
3030
"@firebase/webchannel-wrapper": "0.2.8",
3131
"grpc": "1.11.3",

packages/firestore/src/api/database.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { FirestoreClient } from '../core/firestore_client';
2525
import {
2626
Bound,
2727
Direction,
28-
fieldFilter,
2928
Filter,
3029
OrderBy,
3130
Query as InternalQuery,
@@ -1373,7 +1372,7 @@ export class Query implements firestore.Query {
13731372
value
13741373
);
13751374
}
1376-
const filter = fieldFilter(fieldPath, relationOp, fieldValue);
1375+
const filter = Filter.create(fieldPath, relationOp, fieldValue);
13771376
this.validateNewFilter(filter);
13781377
return new Query(this._query.addFilter(filter), this.firestore);
13791378
}

packages/firestore/src/api/field_value.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,14 @@ export abstract class FieldValueImpl implements firestore.FieldValue {
3636
return ServerTimestampFieldValueImpl.instance;
3737
}
3838

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

47-
// TODO(array-features): Expose this once backend support lands.
48-
static _arrayRemove(...elements: AnyJs[]): FieldValueImpl {
46+
static arrayRemove(...elements: AnyJs[]): FieldValueImpl {
4947
validateAtLeastNumberOfArgs('FieldValue.arrayRemove', arguments, 1);
5048
// NOTE: We don't actually parse the data until it's used in set() or
5149
// update() since we need access to the Firestore instance.

packages/firestore/src/core/query.ts

+41-39
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,35 @@ export class Query {
390390
}
391391
}
392392

393-
export interface Filter {
394-
matches(doc: Document): boolean;
395-
canonicalId(): string;
396-
isEqual(filter: Filter): boolean;
393+
export abstract class Filter {
394+
abstract matches(doc: Document): boolean;
395+
abstract canonicalId(): string;
396+
abstract isEqual(filter: Filter): boolean;
397+
398+
/**
399+
* Creates a filter based on the provided arguments.
400+
*/
401+
static create(field: FieldPath, op: RelationOp, value: FieldValue): Filter {
402+
if (value.isEqual(NullValue.INSTANCE)) {
403+
if (op !== RelationOp.EQUAL) {
404+
throw new FirestoreError(
405+
Code.INVALID_ARGUMENT,
406+
'Invalid query. You can only perform equals comparisons on null.'
407+
);
408+
}
409+
return new NullFilter(field);
410+
} else if (value.isEqual(DoubleValue.NAN)) {
411+
if (op !== RelationOp.EQUAL) {
412+
throw new FirestoreError(
413+
Code.INVALID_ARGUMENT,
414+
'Invalid query. You can only perform equals comparisons on NaN.'
415+
);
416+
}
417+
return new NanFilter(field);
418+
} else {
419+
return new RelationFilter(field, op, value);
420+
}
421+
}
397422
}
398423

399424
export class RelationOp {
@@ -434,12 +459,14 @@ export class RelationOp {
434459
}
435460
}
436461

437-
export class RelationFilter implements Filter {
462+
export class RelationFilter extends Filter {
438463
constructor(
439464
public field: FieldPath,
440465
public op: RelationOp,
441466
public value: FieldValue
442-
) {}
467+
) {
468+
super();
469+
}
443470

444471
matches(doc: Document): boolean {
445472
if (this.field.isKeyField()) {
@@ -528,8 +555,10 @@ export class RelationFilter implements Filter {
528555
/**
529556
* Filter that matches 'null' values.
530557
*/
531-
export class NullFilter implements Filter {
532-
constructor(public field: FieldPath) {}
558+
export class NullFilter extends Filter {
559+
constructor(public field: FieldPath) {
560+
super();
561+
}
533562

534563
matches(doc: Document): boolean {
535564
const val = doc.field(this.field);
@@ -556,8 +585,10 @@ export class NullFilter implements Filter {
556585
/**
557586
* Filter that matches 'NaN' values.
558587
*/
559-
export class NanFilter implements Filter {
560-
constructor(public field: FieldPath) {}
588+
export class NanFilter extends Filter {
589+
constructor(public field: FieldPath) {
590+
super();
591+
}
561592

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

584-
/**
585-
* Creates a filter based on the provided arguments.
586-
*/
587-
export function fieldFilter(
588-
field: FieldPath,
589-
op: RelationOp,
590-
value: FieldValue
591-
): Filter {
592-
if (value.isEqual(NullValue.INSTANCE)) {
593-
if (op !== RelationOp.EQUAL) {
594-
throw new FirestoreError(
595-
Code.INVALID_ARGUMENT,
596-
'Invalid query. You can only perform equals ' + 'comparisons on null.'
597-
);
598-
}
599-
return new NullFilter(field);
600-
} else if (value.isEqual(DoubleValue.NAN)) {
601-
if (op !== RelationOp.EQUAL) {
602-
throw new FirestoreError(
603-
Code.INVALID_ARGUMENT,
604-
'Invalid query. You can only perform equals ' + 'comparisons on NaN.'
605-
);
606-
}
607-
return new NanFilter(field);
608-
} else {
609-
return new RelationFilter(field, op, value);
610-
}
611-
}
612-
613615
/**
614616
* The direction of sorting in an order by.
615617
*/

0 commit comments

Comments
 (0)