Skip to content

Functions SDK v4 #1161

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 72 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
8c96c81
Change logging severity for passing callable auth validation (#1138)
inlined Jun 15, 2022
c06b4fe
Bump admin SDK version. Remove vendored APIs + sniffing (#1139)
inlined Jun 16, 2022
ea5edf9
Error logs always show up in Cloud Error Reporting (#1141)
inlined Jun 17, 2022
0b47d40
Move to enforceAppCheck option (#1145)
inlined Jun 24, 2022
e844387
Put tests in a codebase (#1148)
inlined Jun 26, 2022
bebb398
Rework apps, update admin, remove lodash (#1144)
inlined Jun 27, 2022
7ff3abe
Divide everything into v1, v2, and common (unexported). (#1149)
inlined Jun 27, 2022
151eda9
add firebase@11.0.0 to peerDependencies (#1152)
Manokii Jun 28, 2022
8241eb6
Merge remote-tracking branch 'origin/master' into launch.next
inlined Jun 28, 2022
5f3aade
Merge branch 'master' into launch.next
taeold Jun 30, 2022
35a1632
Fix bad import path.
taeold Jun 30, 2022
94fd1c6
Unrevert revert DataSnapshot changes.
taeold Jun 30, 2022
a215d8e
Update prettier. Run prettier (#1160)
inlined Jul 13, 2022
ee7d43f
Merge remote-tracking branch 'origin/master' into launch.next
taeold Aug 18, 2022
620af0b
Fix broken branch (#1193)
taeold Aug 22, 2022
0e1f688
Fix bug where callable function skipped unrecognized auth headers (#…
taeold Aug 22, 2022
87d27ef
Migrate from prettier to eslint to match firebase/firebase-tools styl…
taeold Aug 22, 2022
87ca228
Make event params strongly typed (#1155)
inlined Aug 22, 2022
c303eab
More ESLint Migration (#1197)
taeold Aug 23, 2022
5e08c42
Fix integration tests (#1198)
taeold Aug 23, 2022
51e50c6
Update docgen scripts for v1/v2 (#1195)
taeold Aug 23, 2022
e19414d
Remove handler namespace (#1196)
taeold Aug 23, 2022
960f094
Prefer @returns over @return to match api-documenter style.
taeold Aug 24, 2022
d7cc2e5
Update documentation for src/common/change.ts (#1201)
TheIronDev Aug 24, 2022
d12b1d1
Fix namespace v1 docs (#1204)
colerogers Aug 24, 2022
637b191
Minor fixes for v1/auth docs. (#1200)
taeold Aug 24, 2022
922295d
Minor fixes for v1/database docs. (#1202)
taeold Aug 24, 2022
93d5b73
Fix tags on remote config. (#1205)
taeold Aug 24, 2022
1ed0cf7
Fix doc on v1 schedule configs (#1206)
taeold Aug 24, 2022
a58d06b
Fix docs on v1/testLab (#1207)
taeold Aug 24, 2022
3eea412
Doc fixes on cloud-functions.ts and functions-configuration.ts (#1203)
taeold Aug 24, 2022
b268efb
Update Documentation for v1 Resource (#1210)
TheIronDev Aug 25, 2022
c8912d6
Use `-o` instead of `-e`. (#1212)
kaibolay Aug 26, 2022
304344e
Merge branch 'master' of https://github.com/firebase/firebase-functio…
taeold Aug 26, 2022
1f6e566
More merge.
taeold Aug 26, 2022
3eee7ed
Update firestore docs (#1208)
TheIronDev Aug 26, 2022
f313ae3
Merge branch 'master' into launch.next
taeold Aug 31, 2022
c19a65f
Merge origin/master
taeold Aug 31, 2022
9eb8be5
Automatically add trace property to v2 function logs (#1192)
taeold Sep 1, 2022
0cb4457
Move params as top level import (#1218)
taeold Sep 2, 2022
9969a26
remove onChange (#1220)
colerogers Sep 6, 2022
0c97377
add changelog entry
colerogers Sep 6, 2022
7aea400
ternary expressions were always returning the if_true case (#1224)
Berlioz Sep 7, 2022
a3e9278
Merge branch 'master' of https://github.com/firebase/firebase-functio…
taeold Sep 7, 2022
28469c0
Inject trace context to v2 scheduled fns. (#1225)
taeold Sep 7, 2022
5adeed5
Update toc gen script.
taeold Sep 7, 2022
0dbc14d
Fill in more blanks for v1 ref docs (#1226)
taeold Sep 8, 2022
6faeccc
change req to event (#1228)
colerogers Sep 8, 2022
3b04088
Add changelog.
taeold Sep 8, 2022
a54cd0b
Add v2 Remote Config Triggers (#1216)
colerogers Sep 9, 2022
77f905e
Bring SDK Expression types into alignment with CLI + unit tests for E…
Berlioz Sep 13, 2022
d26a2c8
Merge branch 'master' of https://github.com/firebase/firebase-functio…
taeold Sep 22, 2022
5c3c3b7
Fix combination of params and captures (#1242)
inlined Sep 27, 2022
cea9ebe
Merge branch 'master' into launch.next
taeold Sep 30, 2022
ed62824
Adds v2 test lab triggers (#1241)
colerogers Sep 30, 2022
f22dfcf
Change @returns statement to use function instead of Cloud Function (…
colerogers Oct 3, 2022
54b5c6c
Make some storage fields required (#1251)
inlined Oct 3, 2022
9332ea0
allow Expressions in the top-level configuration of v1 functions (#1249)
Berlioz Oct 4, 2022
4193029
Revert "allow Expressions in the top-level configuration of v1 functi…
Berlioz Oct 4, 2022
0cd8b9d
Create an InternalExpression type which allows precanned access field…
Berlioz Oct 5, 2022
8a2c826
Add RESET_VALUE configuration value as sentinel value to reset a conf…
taeold Oct 5, 2022
4298cc8
Remove unusable list param definition function (#1233)
Berlioz Oct 5, 2022
5f924bc
Add new option to preserveExternalChanges. (#1253)
taeold Oct 5, 2022
8e71eca
Allow SecretParams to be directly registered in v1/v2 options (#1256)
Berlioz Oct 6, 2022
abb547f
Allow Expressions in the top-level configuration of v1 functions (#1255)
Berlioz Oct 6, 2022
9a7b280
Allow actual RegExp objects in the regex field of a textInput (#1247)
Berlioz Oct 6, 2022
b0acea3
Add jsdoc comments to the params types and fields (#1258)
Berlioz Oct 12, 2022
9941668
Print a warning when Expression.value() is invoked during discovery (…
Berlioz Oct 12, 2022
16e7b2b
Remove manifest types from API. (#1259)
taeold Oct 12, 2022
a322b2e
Re-export singleton object for internal-override.
taeold Oct 12, 2022
8a1ffdc
Re-export manifest types for use by internal packages. (#1260)
taeold Oct 13, 2022
32ac192
Merge branch 'master' into launch.next
taeold Oct 13, 2022
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
11 changes: 11 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
lib
dev
node_modules
/coverage/
/docgen/
/v1/
/v2/
/logger/
/dist/
/spec/fixtures
/scripts/**/*.js
70 changes: 70 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module.exports = {
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:jsdoc/recommended",
"google",
"prettier",
],
rules: {
"jsdoc/newline-after-description": "off",
"jsdoc/require-jsdoc": ["warn", { publicOnly: true }],
"no-restricted-globals": ["error", "name", "length"],
"prefer-arrow-callback": "error",
"prettier/prettier": "error",
"require-atomic-updates": "off", // This rule is so noisy and isn't useful: https://github.com/eslint/eslint/issues/11899
"require-jsdoc": "off", // This rule is deprecated and superseded by jsdoc/require-jsdoc.
"valid-jsdoc": "off", // This is deprecated but included in recommended configs.

"no-prototype-builtins": "warn",
"no-useless-escape": "warn",
"prefer-promise-reject-errors": "warn",
},
overrides: [
{
files: ["*.ts"],
rules: {
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",

// Google style guide allows us to omit trivial parameters and returns
"jsdoc/require-param": "off",
"jsdoc/require-returns": "off",

"@typescript-eslint/no-invalid-this": "error",
"@typescript-eslint/no-unused-vars": "error", // Unused vars should not exist.
"@typescript-eslint/no-misused-promises": "warn", // rule does not work with async handlers for express.
"no-invalid-this": "off", // Turned off in favor of @typescript-eslint/no-invalid-this.
"no-unused-vars": "off", // Off in favor of @typescript-eslint/no-unused-vars.
eqeqeq: ["error", "always", { null: "ignore" }],
camelcase: ["error", { properties: "never" }], // snake_case allowed in properties iif to satisfy an external contract / style

// Ideally, all these warning should be error - let's fix them in the future.
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/restrict-template-expressions": "warn",
},
},
{
files: ["*.spec.*"],
env: {
mocha: true,
},
rules: {},
},
],
globals: {},
parserOptions: {
project: "tsconfig.json",
},
plugins: ["prettier", "@typescript-eslint", "jsdoc"],
parser: "@typescript-eslint/parser",
};
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/---report-a-bug.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: '⚠️ Report a Bug'
name: "⚠️ Report a Bug"
about: Think you found a bug in the firebase-functions SDK? Report it here. Please do not use this form if your function is deployed successfully but not working as you expected.
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---

<!-- DO NOT DELETE
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/postmerge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ name: Post-merge tests
on:
workflow_dispatch:
workflow_run:
workflows: ['CI Tests']
workflows: ["CI Tests"]
types: [completed]
branches: [master]

Expand All @@ -38,16 +38,16 @@ jobs:

- uses: google-github-actions/auth@v0
with:
credentials_json: '${{ secrets.CF3_INTEGRATION_TEST_GOOGLE_CREDENTIALS }}'
credentials_json: "${{ secrets.CF3_INTEGRATION_TEST_GOOGLE_CREDENTIALS }}"
create_credentials_file: true

- name: 'Set up Cloud SDK'
- name: "Set up Cloud SDK"
uses: google-github-actions/setup-gcloud@v0

- name: 'Setup Firebase CLI'
- name: "Setup Firebase CLI"
run: npm i -g firebase-tools

- name: 'Run integration test'
- name: "Run integration test"
run: npm run test:postmerge

- name: Print debug logs
Expand Down
29 changes: 19 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,59 @@ env:
CI: true

jobs:
lint:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
strategy:
matrix:
node-version:
- "16"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm run lint
unit:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 10.x
- 12.x
- 14.x
- 16.x
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Cache npm
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

- run: npm ci
- run: npm run lint
- run: npm run format
- run: npm run test
integration:
needs: "unit"
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 12.x
- 14.x
- 16.x
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Cache npm
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

- run: npm install
- run: npm ci
- run: npm run test:bin
4 changes: 2 additions & 2 deletions .mocharc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ extension:
package: ./package.json
reporter: spec
require:
- 'ts-node/register'
- 'source-map-support/register'
- "ts-node/register"
- "source-map-support/register"
7 changes: 4 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lib
package.json
spec/fixtures/credential/unparsable.key.json
/node_modules
/lib/**/*
/CONTRIBUTING.md
/docgen
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
printWidth: 100,
};
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
### 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.
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ _Please avoid double posting across multiple channels!_

```js
// functions/index.js
const functions = require('firebase-functions');
const notifyUsers = require('./notify-users');

exports.newPost = functions.database
.ref('/posts/{postId}')
.onCreate((snapshot, context) => {
functions.logger.info('Received new post with ID:', context.params.postId);
return notifyUsers(snapshot.val());
});
const functions = require("firebase-functions");
const notifyUsers = require("./notify-users");

exports.newPost = functions.database.ref("/posts/{postId}").onCreate((snapshot, context) => {
functions.logger.info("Received new post with ID:", context.params.postId);
return notifyUsers(snapshot.val());
});
```

## Contributing
Expand Down
Loading