Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: firebase/firebase-functions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.0.0
Choose a base ref
...
head repository: firebase/firebase-functions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.0.1
Choose a head ref
  • 3 commits
  • 7 files changed
  • 2 contributors

Commits on Oct 17, 2022

  1. Copy the full SHA
    879c5c2 View commit details

Commits on Oct 18, 2022

  1. Fix params API to match agreed spec (#1268)

    * Fix params API to match agreed spec
    
    * Fixes & changelog
    inlined authored Oct 18, 2022
    Copy the full SHA
    7dbda7d View commit details
  2. 4.0.1

    google-oss-bot committed Oct 18, 2022
    Copy the full SHA
    ab8c33e View commit details
Showing with 21 additions and 50 deletions.
  1. +1 −32 CHANGELOG.md
  2. +2 −2 package-lock.json
  3. +1 −1 package.json
  4. +2 −2 spec/fixtures/sources/commonjs-params/index.js
  5. +12 −10 spec/params/params.spec.ts
  6. +2 −2 spec/runtime/manifest.spec.ts
  7. +1 −1 src/params/types.ts
33 changes: 1 addition & 32 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
### Breaking Changes

- Deprecated `allowInvalidAppCheckToken` option. Instead use
`enforceAppCheck`.

> App Check enforcement on callable functions is disabled by default in v4.
> Requests containing invalid App Check tokens won't be denied unless you
> explicitly enable App Check enforcement using the new `enforceAppCheck` option.
> Furthermore, when enforcement is enabled, callable functions will deny
> all requests without App Check tokens.
- Dropped support for Node.js versions 8, 10, and 12.
- Dropped support for Admin SDK versions 8 and 9.
- Removed the `functions.handler` namespace.
- `DataSnapshot` passed to the Firebase Realtime Database trigger now
matches the `DataSnapshot` returned by the Admin SDK, with null values
removed.
- Removed `__trigger` object on function handlers.
- Reorganized source code location. This affects only apps that directly import files instead of using the recommend entry points specified in the
- Reworked the `apps` library and removed `lodash` as a runtime dependency.

### Enhancements

- Logs created with the `functions.logger` package in v2 functions
are now annotated with each request's trace ID, making it easy to correlate
log entries with the incoming request. Trace IDs are especially useful for
cases where 2nd gen's concurrency feature permits a function
to handle multiple requests at any given time. See
[Correlate log entries](https://cloud.google.com/logging/docs/view/correlate-logs) to learn more.
- `functions.logger.error` now always outputs an error object and is included in Google Cloud Error Reporting.
- The logging severity of Auth/App Check token validation has changed from `info` to `debug` level.
- Event parameters for 2nd generation functions are now strongly typed, permitting stronger TypeScript types for matched parameters.
Correct the function BooleanExpression#then to BooleanExpression#thenElse (#1268)
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firebase-functions",
"version": "4.0.0",
"version": "4.0.1",
"description": "Firebase SDK for Cloud Functions",
"keywords": [
"firebase",
4 changes: 2 additions & 2 deletions spec/fixtures/sources/commonjs-params/index.js
Original file line number Diff line number Diff line change
@@ -4,10 +4,10 @@ const params = require("../../../../src/params");

params.defineString("BORING");
const foo = params.defineString("FOO", { input: { text: { validationRegex: "w+" } } });
const bar = params.defineString("BAR", { default: foo , label: "asdf" });
const bar = params.defineString("BAR", { default: foo, label: "asdf" });
params.defineString("BAZ", { input: { select: { options: [{ value: "a" }, { value: "b" }] } } });

params.defineInt("AN_INT", { default: bar.equals("qux").then(0, 1) });
params.defineInt("AN_INT", { default: bar.equals("qux").thenElse(0, 1) });
params.defineInt("ANOTHER_INT", {
input: {
select: {
22 changes: 12 additions & 10 deletions spec/params/params.spec.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ describe("Params spec extraction", () => {
it("converts Expressions in the param default to strings", () => {
const bar = params.defineInt("BAR");
expect(
params.defineString("FOO", { default: bar.notEquals(22).then("asdf", "jkl;") }).toSpec()
params.defineString("FOO", { default: bar.notEquals(22).thenElse("asdf", "jkl;") }).toSpec()
.default
).to.equal(`{{ params.BAR != 22 ? "asdf" : "jkl;" }}`);
});
@@ -174,13 +174,13 @@ describe("Params value extraction", () => {

it("can select the output of a ternary expression based on the comparison", () => {
const trueExpr = params.defineString("A_STRING").equals(params.defineString("SAME_STRING"));
expect(trueExpr.then(1, 0).value()).to.equal(1);
expect(trueExpr.thenElse(1, 0).value()).to.equal(1);
const falseExpr = params.defineInt("AN_INT").equals(params.defineInt("DIFF_INT"));
expect(falseExpr.then(1, 0).value()).to.equal(0);
expect(falseExpr.thenElse(1, 0).value()).to.equal(0);

const twentytwo = params.defineInt("DIFF_INT");
expect(trueExpr.then(twentytwo, 0).value()).to.equal(22);
expect(falseExpr.then(1, twentytwo).value()).to.equal(22);
expect(trueExpr.thenElse(twentytwo, 0).value()).to.equal(22);
expect(falseExpr.thenElse(1, twentytwo).value()).to.equal(22);
});
});

@@ -280,13 +280,15 @@ describe("Params as CEL", () => {
expect(
booleanExpr.then(params.defineString("FOO"), params.defineString("BAR")).toCEL()
).to.equal("{{ params.BOOL ? params.FOO : params.BAR }}");
expect(cmpExpr.then("asdf", "jkl;").toCEL()).to.equal(
expect(cmpExpr.thenElse("asdf", "jkl;").toCEL()).to.equal(
'{{ params.A != params.B ? "asdf" : "jkl;" }}'
);
expect(cmpExpr.then(-11, 22).toCEL()).to.equal("{{ params.A != params.B ? -11 : 22 }}");
expect(cmpExpr.then(false, true).toCEL()).to.equal("{{ params.A != params.B ? false : true }}");
expect(cmpExpr.then(params.defineString("FOO"), params.defineString("BAR")).toCEL()).to.equal(
"{{ params.A != params.B ? params.FOO : params.BAR }}"
expect(cmpExpr.thenElse(-11, 22).toCEL()).to.equal("{{ params.A != params.B ? -11 : 22 }}");
expect(cmpExpr.thenElse(false, true).toCEL()).to.equal(
"{{ params.A != params.B ? false : true }}"
);
expect(
cmpExpr.thenElse(params.defineString("FOO"), params.defineString("BAR")).toCEL()
).to.equal("{{ params.A != params.B ? params.FOO : params.BAR }}");
});
});
4 changes: 2 additions & 2 deletions spec/runtime/manifest.spec.ts
Original file line number Diff line number Diff line change
@@ -127,14 +127,14 @@ describe("stackToWire", () => {
labels: {},
httpsTrigger: {},
concurrency: intParam,
maxInstances: intParam.equals(24).then(-1, 1),
maxInstances: intParam.equals(24).thenElse(-1, 1),
},
v2schedule: {
platform: "gcfv2",
entryPoint: "v2callable",
labels: {},
scheduleTrigger: {
schedule: stringParam.equals("America/Mexico_City").then("mexico", "usa"),
schedule: stringParam.equals("America/Mexico_City").thenElse("mexico", "usa"),
timeZone: stringParam,
},
},
2 changes: 1 addition & 1 deletion src/params/types.ts
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ export class CompareExpression<
}

/** Returns a TernaryExpression which can resolve to one of two values, based on the resolution of this comparison. */
then<retT extends string | number | boolean | string[]>(
thenElse<retT extends string | number | boolean | string[]>(
ifTrue: retT | Expression<retT>,
ifFalse: retT | Expression<retT>
) {