Skip to content

Commit 5f3aade

Browse files
committed
Merge branch 'master' into launch.next
# Conflicts: # package-lock.json # src/common/providers/database.ts
2 parents 8241eb6 + 2990313 commit 5f3aade

File tree

6 files changed

+16
-139
lines changed

6 files changed

+16
-139
lines changed

CHANGELOG.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
- Adds RTDB Triggers for v2 functions (#1127)
2-
- Adds support for Firebase Admin SDK v11 (#1151)
3-
- Fixes bug where emulated task queue function required auth header (#1154)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firebase-functions",
3-
"version": "3.21.2",
3+
"version": "3.22.0",
44
"description": "Firebase SDK for Cloud Functions",
55
"keywords": [
66
"firebase",

spec/v1/providers/database.spec.ts

Lines changed: 9 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -569,52 +569,17 @@ describe('Database Functions', () => {
569569
expect(subject.val()).to.equal(0);
570570
populate({ myKey: 0 });
571571
expect(subject.val()).to.deep.equal({ myKey: 0 });
572+
573+
// Null values are still reported as null.
574+
populate({ myKey: null });
575+
expect(subject.val()).to.deep.equal({ myKey: null });
572576
});
573577

574578
// Regression test: .val() was returning array of nulls when there's a property called length (BUG#37683995)
575579
it('should return correct values when data has "length" property', () => {
576580
populate({ length: 3, foo: 'bar' });
577581
expect(subject.val()).to.deep.equal({ length: 3, foo: 'bar' });
578582
});
579-
580-
it('should deal with null-values appropriately', () => {
581-
populate(null);
582-
expect(subject.val()).to.be.null;
583-
584-
populate({ myKey: null });
585-
expect(subject.val()).to.be.null;
586-
});
587-
588-
it('should deal with empty object values appropriately', () => {
589-
populate({});
590-
expect(subject.val()).to.be.null;
591-
592-
populate({ myKey: {} });
593-
expect(subject.val()).to.be.null;
594-
595-
populate({ myKey: { child: null } });
596-
expect(subject.val()).to.be.null;
597-
});
598-
599-
it('should deal with empty array values appropriately', () => {
600-
populate([]);
601-
expect(subject.val()).to.be.null;
602-
603-
populate({ myKey: [] });
604-
expect(subject.val()).to.be.null;
605-
606-
populate({ myKey: [null] });
607-
expect(subject.val()).to.be.null;
608-
609-
populate({ myKey: [{}] });
610-
expect(subject.val()).to.be.null;
611-
612-
populate({ myKey: [{ myKey: null }] });
613-
expect(subject.val()).to.be.null;
614-
615-
populate({ myKey: [{ myKey: {} }] });
616-
expect(subject.val()).to.be.null;
617-
});
618583
});
619584

620585
describe('#child(): DataSnapshot', () => {
@@ -641,37 +606,14 @@ describe('Database Functions', () => {
641606
});
642607

643608
it('should be false for a non-existent value', () => {
644-
populate({ a: { b: 'c', nullChild: null } });
609+
populate({ a: { b: 'c' } });
645610
expect(subject.child('d').exists()).to.be.false;
646-
expect(subject.child('nullChild').exists()).to.be.false;
647611
});
648612

649613
it('should be false for a value pathed beyond a leaf', () => {
650614
populate({ a: { b: 'c' } });
651615
expect(subject.child('a/b/c').exists()).to.be.false;
652616
});
653-
654-
it('should be false for an empty object value', () => {
655-
populate({ a: {} });
656-
expect(subject.child('a').exists()).to.be.false;
657-
658-
populate({ a: { child: null } });
659-
expect(subject.child('a').exists()).to.be.false;
660-
661-
populate({ a: { child: {} } });
662-
expect(subject.child('a').exists()).to.be.false;
663-
});
664-
665-
it('should be false for an empty array value', () => {
666-
populate({ a: [] });
667-
expect(subject.child('a').exists()).to.be.false;
668-
669-
populate({ a: [null] });
670-
expect(subject.child('a').exists()).to.be.false;
671-
672-
populate({ a: [{}] });
673-
expect(subject.child('a').exists()).to.be.false;
674-
});
675617
});
676618

677619
describe('#forEach(action: (a: DataSnapshot) => boolean): boolean', () => {
@@ -700,17 +642,6 @@ describe('Database Functions', () => {
700642

701643
expect(subject.forEach(counter)).to.equal(false);
702644
expect(count).to.eq(0);
703-
704-
populate({
705-
a: 'foo',
706-
nullChild: null,
707-
emptyObjectChild: {},
708-
emptyArrayChild: [],
709-
});
710-
count = 0;
711-
712-
expect(subject.forEach(counter)).to.equal(false);
713-
expect(count).to.eq(1);
714645
});
715646

716647
it('should cancel further enumeration if callback returns true', () => {
@@ -750,51 +681,13 @@ describe('Database Functions', () => {
750681

751682
describe('#numChildren()', () => {
752683
it('should be key count for objects', () => {
753-
populate({
754-
a: 'b',
755-
c: 'd',
756-
nullChild: null,
757-
emptyObjectChild: {},
758-
emptyArrayChild: [],
759-
});
684+
populate({ a: 'b', c: 'd' });
760685
expect(subject.numChildren()).to.eq(2);
761686
});
762687

763688
it('should be 0 for non-objects', () => {
764689
populate(23);
765690
expect(subject.numChildren()).to.eq(0);
766-
767-
populate({
768-
nullChild: null,
769-
emptyObjectChild: {},
770-
emptyArrayChild: [],
771-
});
772-
expect(subject.numChildren()).to.eq(0);
773-
});
774-
});
775-
776-
describe('#hasChildren()', () => {
777-
it('should true for objects', () => {
778-
populate({
779-
a: 'b',
780-
c: 'd',
781-
nullChild: null,
782-
emptyObjectChild: {},
783-
emptyArrayChild: [],
784-
});
785-
expect(subject.hasChildren()).to.be.true;
786-
});
787-
788-
it('should be false for non-objects', () => {
789-
populate(23);
790-
expect(subject.hasChildren()).to.be.false;
791-
792-
populate({
793-
nullChild: null,
794-
emptyObjectChild: {},
795-
emptyArrayChild: [],
796-
});
797-
expect(subject.hasChildren()).to.be.false;
798691
});
799692
});
800693

@@ -806,17 +699,9 @@ describe('Database Functions', () => {
806699
});
807700

808701
it('should return false if a child is missing', () => {
809-
populate({
810-
a: 'b',
811-
nullChild: null,
812-
emptyObjectChild: {},
813-
emptyArrayChild: [],
814-
});
702+
populate({ a: 'b' });
815703
expect(subject.hasChild('c')).to.be.false;
816704
expect(subject.hasChild('a/b')).to.be.false;
817-
expect(subject.hasChild('nullChild')).to.be.false;
818-
expect(subject.hasChild('emptyObjectChild')).to.be.false;
819-
expect(subject.hasChild('emptyArrayChild')).to.be.false;
820705
});
821706
});
822707

@@ -846,21 +731,11 @@ describe('Database Functions', () => {
846731

847732
describe('#toJSON(): Object', () => {
848733
it('should return the current value', () => {
849-
populate({
850-
a: 'b',
851-
nullChild: null,
852-
emptyObjectChild: {},
853-
emptyArrayChild: [],
854-
});
734+
populate({ a: 'b' });
855735
expect(subject.toJSON()).to.deep.equal(subject.val());
856736
});
857737
it('should be stringifyable', () => {
858-
populate({
859-
a: 'b',
860-
nullChild: null,
861-
emptyObjectChild: {},
862-
emptyArrayChild: [],
863-
});
738+
populate({ a: 'b' });
864739
expect(JSON.stringify(subject)).to.deep.equal('{"a":"b"}');
865740
});
866741
});

src/v1/cloud-functions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export { Request, Response };
2727
import { convertIfPresent, copyIfPresent } from '../common/encoding';
2828
import { ManifestEndpoint, ManifestRequiredAPI } from '../runtime/manifest';
2929

30+
export { Change } from './common/change';
31+
3032
/** @hidden */
3133
const WILDCARD_REGEX = new RegExp('{[^/{}]*}', 'g');
3234

src/v2/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@ export {
6060
EventHandlerOptions,
6161
} from './options';
6262

63+
export { Change } from '../common/change';
64+
6365
export { CloudFunction, CloudEvent } from './core';

src/v2/providers/database.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ export interface ReferenceOptions extends options.EventHandlerOptions {
8888
/**
8989
* Specify the handler to trigger on a database instance(s).
9090
* If present, this value can either be a single instance or a pattern.
91-
* Examples: 'my-instance-1', '{instance}'
91+
* Examples: 'my-instance-1', 'my-instance-*'
92+
* Note: The capture syntax cannot be used for 'instance'.
9293
*/
9394
instance?: string;
9495

0 commit comments

Comments
 (0)