├── .eslintignore ├── .eslintrc.json ├── .github ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── sync-repo-settings.yaml └── workflows │ ├── gen.yaml │ ├── lint.yaml │ ├── release-please.yml │ └── unit.yaml ├── .gitignore ├── .npmignore ├── .prettierrc.js ├── CHANGELOG.md ├── LICENSE ├── README.md ├── SECURITY.md ├── cloud ├── audit │ └── v1 │ │ └── LogEntryData.ts ├── cloudbuild │ └── v1 │ │ └── BuildEventData.ts ├── firestore │ └── v1 │ │ └── DocumentEventData.ts ├── pubsub │ └── v1 │ │ └── MessagePublishedData.ts ├── scheduler │ └── v1 │ │ └── SchedulerJobData.ts └── storage │ └── v1 │ └── StorageObjectData.ts ├── examples ├── javascript.js └── typescript.ts ├── firebase ├── analytics │ └── v1 │ │ └── AnalyticsLogData.ts ├── auth │ └── v1 │ │ └── AuthEventData.ts ├── database │ └── v1 │ │ └── ReferenceEventData.ts ├── firebasealerts │ └── v1 │ │ └── AlertData.ts ├── remoteconfig │ └── v1 │ │ └── RemoteConfigEventData.ts └── testlab │ └── v1 │ └── TestMatrixEventData.ts ├── package.json ├── reference.md ├── renovate.json ├── tests └── index.ts ├── tools ├── docs.ts ├── gen.sh └── postgen.ts └── tsconfig.json /.eslintignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | **/coverage 3 | test/fixtures 4 | build/ 5 | docs/ 6 | protos/ 7 | 8 | *.js 9 | *.d.ts -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/gts/", 3 | "rules": { 4 | "@typescript-eslint/no-explicit-any": 0, 5 | "node/no-unpublished-import": 0 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners file. 2 | # This file controls who is tagged for review for any given pull request. 3 | # 4 | # For syntax help see: 5 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax 6 | 7 | * @googleapis/cloudevents-admins 8 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Google Open Source Community Guidelines 2 | 3 | At Google, we recognize and celebrate the creativity and collaboration of open 4 | source contributors and the diversity of skills, experiences, cultures, and 5 | opinions they bring to the projects and communities they participate in. 6 | 7 | Every one of Google's open source projects and communities are inclusive 8 | environments, based on treating all individuals respectfully, regardless of 9 | gender identity and expression, sexual orientation, disabilities, 10 | neurodiversity, physical appearance, body size, ethnicity, nationality, race, 11 | age, religion, or similar personal characteristic. 12 | 13 | We value diverse opinions, but we value respectful behavior more. 14 | 15 | Respectful behavior includes: 16 | 17 | * Being considerate, kind, constructive, and helpful. 18 | * Not engaging in demeaning, discriminatory, harassing, hateful, sexualized, or 19 | physically threatening behavior, speech, and imagery. 20 | * Not engaging in unwanted physical contact. 21 | 22 | Some Google open source projects [may adopt][] an explicit project code of 23 | conduct, which may have additional detailed expectations for participants. Most 24 | of those projects will use our [modified Contributor Covenant][]. 25 | 26 | [may adopt]: https://opensource.google/docs/releasing/preparing/#conduct 27 | [modified Contributor Covenant]: https://opensource.google/docs/releasing/template/CODE_OF_CONDUCT/ 28 | 29 | ## Resolve peacefully 30 | 31 | We do not believe that all conflict is necessarily bad; healthy debate and 32 | disagreement often yields positive results. However, it is never okay to be 33 | disrespectful. 34 | 35 | If you see someone behaving disrespectfully, you are encouraged to address the 36 | behavior directly with those involved. Many issues can be resolved quickly and 37 | easily, and this gives people more control over the outcome of their dispute. 38 | If you are unable to resolve the matter for any reason, or if the behavior is 39 | threatening or harassing, report it. We are dedicated to providing an 40 | environment where participants feel welcome and safe. 41 | 42 | ## Reporting problems 43 | 44 | Some Google open source projects may adopt a project-specific code of conduct. 45 | In those cases, a Google employee will be identified as the Project Steward, 46 | who will receive and handle reports of code of conduct violations. In the event 47 | that a project hasn’t identified a Project Steward, you can report problems by 48 | emailing opensource@google.com. 49 | 50 | We will investigate every complaint, but you may not receive a direct response. 51 | We will use our discretion in determining when and how to follow up on reported 52 | incidents, which may range from not taking action to permanent expulsion from 53 | the project and project-sponsored spaces. We will notify the accused of the 54 | report and provide them an opportunity to discuss it before any action is 55 | taken. The identity of the reporter will be omitted from the details of the 56 | report supplied to the accused. In potentially harmful situations, such as 57 | ongoing harassment or threats to anyone's safety, we may take action without 58 | notice. 59 | 60 | *This document was adapted from the [IndieWeb Code of Conduct][] and can also 61 | be found at .* 62 | 63 | [IndieWeb Code of Conduct]: https://indieweb.org/code-of-conduct 64 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | This doc has some guidelines on how to generate and contribute to this library. 4 | 5 | ## Generate the Library 6 | 7 | The contents of this module are generated from the JSON Schemas defined in the source of truth repo: 8 | 9 | https://github.com/googleapis/google-cloudevents 10 | 11 | To generate this library, follow these steps: 12 | 13 | ### Setup 14 | 15 | - Install the `qt` CLI globally from https://github.com/googleapis/google-cloudevents/tree/main/tools/quicktype-wrapper 16 | - Clone the types source repo: `git clone git@github.com:googleapis/google-cloudevents.git` 17 | - Clone this language repo: `git clone git@github.com:googleapis/google-cloudevents-nodejs.git --depth 1` 18 | 19 | ### Generate and Build 20 | 21 | - Generate: In the root of this Node repo, run the script: `npm run gen`. This generates this library from JSON schemas. 22 | - Build: In the root of this repo, run the script: `npm run build`. This compiles the TypeScript source. 23 | - Your package should be ready to publish. 24 | 25 | ## Publish to npm 26 | 27 | This module is automatically published by [Release Please](https://github.com/googleapis/release-please) when merging a generated release PR. 28 | This PR is created from a GitHub Action that detects changes to the `main` branch. 29 | 30 | Sometimes publishing does not work. To publish manually, Googlers can run the following commands: 31 | 32 | ```sh 33 | npm run build 34 | npm login --registry https://wombat-dressing-room.appspot.com 35 | npm publish --registry https://wombat-dressing-room.appspot.com 36 | ``` 37 | 38 | ### Conventional Commit Requirement 39 | 40 | Only `feat` and `fix` or any commit that's breaking, as indicated by a `!`: `refactor!: foo` will trigger a release. Other commits will not trigger a PR from the bot. 41 | 42 | See: https://www.conventionalcommits.org/en/v1.0.0/#summary 43 | 44 | ## How to Contribute 45 | 46 | We'd love to accept your patches and contributions to this project. There are 47 | just a few small guidelines you need to follow. 48 | 49 | ## Contributor License Agreement 50 | 51 | Contributions to this project must be accompanied by a Contributor License 52 | Agreement. You (or your employer) retain the copyright to your contribution; 53 | this simply gives us permission to use and redistribute your contributions as 54 | part of the project. Head over to to see 55 | your current agreements on file or to sign a new one. 56 | 57 | You generally only need to submit a CLA once, so if you've already submitted one 58 | (even if it was for a different project), you probably don't need to do it 59 | again. 60 | 61 | ## Code reviews 62 | 63 | All submissions, including submissions by project members, require review. We 64 | use GitHub pull requests for this purpose. Consult 65 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 66 | information on using pull requests. 67 | 68 | ## Community Guidelines 69 | 70 | This project follows [Google's Open Source Community 71 | Guidelines](https://opensource.google/conduct/). 72 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Expected Behavior 2 | 3 | 4 | ## Actual Behavior 5 | 6 | 7 | ## Steps to Reproduce the Problem 8 | 9 | -------------------------------------------------------------------------------- /.github/sync-repo-settings.yaml: -------------------------------------------------------------------------------- 1 | # Whether or not rebase-merging is enabled on this repository. 2 | # Defaults to `true` 3 | rebaseMergeAllowed: true 4 | 5 | # Whether or not squash-merging is enabled on this repository. 6 | # Defaults to `true` 7 | squashMergeAllowed: true 8 | 9 | # Whether or not PRs are merged with a merge commit on this repository. 10 | # Defaults to `false` 11 | mergeCommitAllowed: false 12 | 13 | # Automatically delete head branches after merging PRs. Defaults to `true`. 14 | deleteBranchOnMerge: true 15 | 16 | # Rules for branch protection (add multiple entries to configure multiple branches) 17 | branchProtectionRules: 18 | # Identifies the protection rule pattern. Name of the branch to be protected. 19 | # Defaults to `main` 20 | - pattern: main 21 | # Can admins overwrite branch protection. 22 | # Defaults to `true` 23 | isAdminEnforced: true 24 | # Number of approving reviews required to update matching branches. 25 | # Defaults to `1` 26 | requiredApprovingReviewCount: 1 27 | # Are reviews from code owners required to update matching branches. 28 | # Defaults to `false` 29 | requiresCodeOwnerReviews: true 30 | # Require up to date branches 31 | requiresStrictStatusChecks: true 32 | # List of required status check contexts that must pass for commits to be accepted to matching branches. 33 | requiredStatusCheckContexts: 34 | - cla/google 35 | -------------------------------------------------------------------------------- /.github/workflows/gen.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Run Node Client Generator and Create Pull Request 16 | on: 17 | schedule: 18 | # Run at the end of every day 19 | - cron: 0 0 * * * 20 | workflow_dispatch: 21 | jobs: 22 | # Create a pull request 23 | create_pr: 24 | runs-on: ubuntu-18.04 25 | steps: 26 | # Check out this client repo and schema source repo 27 | - name: Checkout this repo 28 | uses: actions/checkout@v3 29 | with: 30 | repository: googleapis/google-cloudevents-nodejs 31 | path: google-cloudevents-nodejs 32 | - name: Checkout client repo 33 | uses: actions/checkout@v3 34 | with: 35 | repository: googleapis/google-cloudevents 36 | path: google-cloudevents 37 | # Setup Node 38 | - name: Setup Node for gen/postgen scripts 39 | uses: actions/setup-node@v3 40 | with: 41 | node-version: 14 42 | # Install the generator 43 | - name: Install the generator 44 | run: | 45 | cd google-cloudevents/tools/quicktype-wrapper 46 | npm i 47 | npm run cli 48 | # Run the generator 49 | - name: Run the generator 50 | run: | 51 | cd google-cloudevents-nodejs 52 | npm i 53 | npm run build 54 | npm run gen 55 | npm run fix 56 | # Create a pull request with the updates (if needed) 57 | - name: Commit and create PR is needed 58 | env: 59 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 60 | run: | 61 | cd google-cloudevents-nodejs 62 | # If a generator PR DNE 63 | if ! [[ `gh pr list --base main --search "Run the generator"` ]]; then 64 | # If there is a non-zero diff after running generator 65 | if [[ `git status --porcelain` ]]; then 66 | git config --global user.email "yoshi-code-bot@google.com" 67 | git config --global user.name "Google Bot" 68 | git checkout -b "pr_bot-$GITHUB_RUN_ID" 69 | git add -A 70 | NOW=$(date +"%m-%d-%Y") 71 | git commit --message "feat: run generator (${NOW})" 72 | git push origin "pr_bot-$GITHUB_RUN_ID" 73 | echo "Created commit: $(git rev-parse HEAD)" 74 | gh pr create \ 75 | --title "Run the generator (${NOW})" \ 76 | --body "AUTOMATED PR! This PR was created from a recent update in the google-cloudevents repo (https://github.com/googleapis/google-cloudevents/commit/$(git rev-parse HEAD)). Please check to ensure there are no CI failures or unexpected generated results." 77 | else 78 | # No changes after running generator 79 | echo "No PR to create." 80 | fi 81 | fi 82 | -------------------------------------------------------------------------------- /.github/workflows/lint.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | pull_request: 6 | name: lint 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | node: [10, 12, 14] 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: actions/setup-node@v3 16 | with: 17 | node-version: ${{ matrix.node }} 18 | - run: node --version 19 | - run: npm install 20 | - run: npm run check 21 | -------------------------------------------------------------------------------- /.github/workflows/release-please.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/GoogleCloudPlatform/release-please-action 2 | on: 3 | push: 4 | branches: 5 | - main 6 | name: release-please 7 | jobs: 8 | release-please-pr: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - id: release-pr 12 | uses: GoogleCloudPlatform/release-please-action@v3 13 | with: 14 | token: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} 15 | release-type: node 16 | fork: true 17 | package-name: "@google/events" 18 | command: release-pr 19 | - id: label 20 | if: ${{ steps.release-pr.outputs.pr }} 21 | uses: actions/github-script@v6 22 | with: 23 | github-token: ${{secrets.GITHUB_TOKEN}} 24 | script: | 25 | const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); 26 | await github.issues.addLabels({ 27 | owner, 28 | repo, 29 | issue_number: ${{steps.release-pr.outputs.pr}}, 30 | labels: ['autorelease: pending'] 31 | }); 32 | console.log(`Tagged ${{steps.release-pr.outputs.pr}}`) 33 | release-please-release: 34 | runs-on: ubuntu-latest 35 | steps: 36 | - uses: GoogleCloudPlatform/release-please-action@v3 37 | id: release 38 | with: 39 | token: ${{ secrets.GITHUB_TOKEN }} 40 | release-type: node 41 | package-name: "@google/events" 42 | command: github-release 43 | # The logic below handles the npm publication: 44 | - uses: actions/checkout@v3 45 | # these if statements ensure that a publication only occurs when 46 | # a new release is created: 47 | if: ${{ steps.release.outputs.release_created }} 48 | - uses: actions/setup-node@v3 49 | if: ${{ steps.release.outputs.release_created }} 50 | with: 51 | node-version: 12 52 | registry-url: 'https://wombat-dressing-room.appspot.com' 53 | - id: publish 54 | if: ${{ steps.release.outputs.release_created }} 55 | env: 56 | NODE_AUTH_TOKEN: ${{secrets.CLOUDEVENTS_NPM_TOKEN}} 57 | run: | 58 | npm install 59 | npm run build 60 | npm publish 61 | - uses: actions/github-script@v6 62 | if: ${{ steps.release.outputs.release_created }} 63 | with: 64 | github-token: ${{secrets.GITHUB_TOKEN}} 65 | script: | 66 | const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); 67 | await github.issues.addLabels({ 68 | owner, 69 | repo, 70 | issue_number: ${{steps.release.outputs.pr}}, 71 | labels: ['autorelease: published'] 72 | }); 73 | github.issues.removeLabel({ 74 | owner, 75 | repo, 76 | issue_number: ${{steps.release.outputs.pr}}, 77 | name: 'autorelease: tagged', 78 | }); 79 | console.log(`Tagged ${{steps.release.outputs.pr}}`) 80 | -------------------------------------------------------------------------------- /.github/workflows/unit.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | pull_request: 6 | name: test 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | node-version: [10.x, 12.x, 14.x] 13 | platform: [ubuntu-latest, macos-latest, windows-latest] 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: actions/setup-node@v3 17 | with: 18 | node-version: ${{ matrix.node }} 19 | - run: node --version 20 | - run: npm install 21 | - run: npm test -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/node_modules/** 2 | npm-debug.log 3 | coverage/ 4 | 5 | *.iml 6 | *.pb 7 | .idea/ 8 | .nyc_output 9 | *.d.ts 10 | yarn.lock 11 | package-lock.json 12 | 13 | .DS_STORE 14 | 15 | # Ignore JS besides examples 16 | **/*.js 17 | !.prettierrc.js 18 | !examples/**/*.js -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Ignore example data files when publishing 2 | data*.json 3 | tools/ -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | ...require('gts/.prettierrc.json') 3 | } 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [5.4.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v5.3.0...v5.4.0) (2022-02-17) 4 | 5 | 6 | ### Features 7 | 8 | * run generator (02-17-2022) ([#125](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/125)) ([b94cbcf](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/b94cbcf5ffa867745ad87129f3bf6a5153890dfa)) 9 | 10 | ## [5.3.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v5.2.0...v5.3.0) (2021-12-14) 11 | 12 | 13 | ### Features 14 | 15 | * run generator (12-14-2021) ([#122](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/122)) ([f1b91c2](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/f1b91c222ef13221efa8896d1e33d0c09a2a0c77)) 16 | 17 | ## [5.2.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v5.1.1...v5.2.0) (2021-10-15) 18 | 19 | 20 | ### Features 21 | 22 | * run generator (10-15-2021) ([#118](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/118)) ([0593d7e](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/0593d7ebf7f5a3a8f49045def46d901ba268b953)) 23 | 24 | ### [5.1.1](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v5.1.0...v5.1.1) (2021-09-03) 25 | 26 | 27 | ### Bug Fixes 28 | 29 | * **build:** migrate to main branch ([#107](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/107)) ([6798540](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/6798540b550f5d54662fd582900c314bd397a12b)) 30 | 31 | ## [5.1.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v5.0.0...v5.1.0) (2021-07-12) 32 | 33 | 34 | ### Features 35 | 36 | * improve types for protobuf duration fields ([#101](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/101)) ([7355dcf](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/7355dcf034259d73e32508e0947268ad1f73086c)) 37 | 38 | ## [5.0.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v4.0.1...v5.0.0) (2021-06-15) 39 | 40 | 41 | ### ⚠ BREAKING CHANGES 42 | 43 | * allow date types to be strings (#93) 44 | 45 | ### Bug Fixes 46 | 47 | * allow date types to be strings ([#93](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/93)) ([10e1889](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/10e18896d7ffa442d52098cdf558404c165122cb)) 48 | 49 | ### [4.0.1](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v4.0.0...v4.0.1) (2021-02-09) 50 | 51 | 52 | ### Bug Fixes 53 | 54 | * remove dep from package ([#88](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/88)) ([2b0ba10](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/2b0ba10187d791e378aa67e85ddab060d2065b10)) 55 | 56 | ## [4.0.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v3.2.1...v4.0.0) (2021-01-20) 57 | 58 | 59 | ### ⚠ BREAKING CHANGES 60 | 61 | * run the generator 2020/12 (#83) 62 | 63 | ### Features 64 | 65 | * run the generator 2020/12 ([#83](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/83)) ([d54cfbe](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/d54cfbec4a8d175c28bc145b9eda5a8eab5c05ca)) 66 | 67 | ### [3.2.1](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v3.2.0...v3.2.1) (2020-12-03) 68 | 69 | 70 | ### Bug Fixes 71 | 72 | * fix the build release workflow ([#81](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/81)) ([03ac5be](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/03ac5bea1a508fb8dfa0651ab4c29556fcbb6eee)) 73 | 74 | ## [3.2.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v3.1.0...v3.2.0) (2020-12-02) 75 | 76 | 77 | ### Features 78 | 79 | * **build:** split release PR and publish step ([#76](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/76)) ([1fe21d5](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/1fe21d54a0d8f3923f17c51534f1973dda136e8a)) 80 | 81 | 82 | ### Bug Fixes 83 | 84 | * **build:** Update release-please.yml ([#73](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/73)) ([87aa569](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/87aa56924a24c0aaa71453b1d908f8f8814334a4)) 85 | 86 | ## [3.1.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v3.0.0...v3.1.0) (2020-11-06) 87 | 88 | 89 | ### Features 90 | 91 | * run the generator, 11/2020 ([#67](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/67)) ([b1b5aeb](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/b1b5aebb488b19aab78136c8eeae83afe03cee39)) 92 | 93 | ## [3.0.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v2.0.0...v3.0.0) (2020-10-29) 94 | 95 | 96 | ### ⚠ BREAKING CHANGES 97 | 98 | * gen events from proto, more events ([#63](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/63)) ([ee25a88](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/ee25a88df2f373176c913e15911bfd399ae1bd63)) 99 | 100 | ## [2.0.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v1.5.0...v2.0.0) (2020-10-05) 101 | 102 | 103 | ### ⚠ BREAKING CHANGES 104 | 105 | * update cal types to use camelCase (#54) 106 | 107 | ### Bug Fixes 108 | 109 | * update cal types to use camelCase ([#54](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/54)) ([2c60859](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/2c6085947d22992d4d260d21b8d717e1fd1ad2e1)) 110 | 111 | ## [1.5.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v1.4.2...v1.5.0) (2020-10-01) 112 | 113 | 114 | ### Features 115 | 116 | * rework the gen and postgen setup with separate jsonschema dir ([#50](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/50)) ([3f7f70b](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/3f7f70bceff8cec04c5afb97da07863b1f66c4c5)) 117 | 118 | ### [1.4.2](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v1.4.1...v1.4.2) (2020-09-09) 119 | 120 | 121 | ### Bug Fixes 122 | 123 | * fix pub/sub message type ([#45](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/45)) ([bdbdd2a](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/bdbdd2a949e5003f0a439c164ca789fef9a7f1fe)) 124 | 125 | ### [1.4.1](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v1.4.0...v1.4.1) (2020-09-09) 126 | 127 | 128 | ### Bug Fixes 129 | 130 | * update publish steps ([#41](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/41)) ([ca67566](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/ca67566bb16049138a210f764e58de4a5fba89b0)) 131 | 132 | ## [1.4.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v1.3.1...v1.4.0) (2020-09-09) 133 | 134 | 135 | ### Features 136 | 137 | * trigger feat ([#39](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/39)) ([236999b](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/236999bef12c696b40f2d626b96629fed2a4e120)) 138 | 139 | ### [1.3.1](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v1.3.0...v1.3.1) (2020-09-03) 140 | 141 | 142 | ### Bug Fixes 143 | 144 | * **build:** update name for releases ([#35](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/35)) ([a1a185c](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/a1a185cdf472f0082fb8dcaf45d2bf57dd531e38)) 145 | 146 | ## [1.3.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v1.2.1...v1.3.0) (2020-09-03) 147 | 148 | 149 | ### Features 150 | 151 | * **docs:** add note about feat in contributing guide ([#32](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/32)) ([9df8ed1](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/9df8ed1a3610d8c093b7cda186741979e2561b2a)) 152 | 153 | ### [1.2.1](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v1.2.0...v1.2.1) (2020-08-27) 154 | 155 | 156 | ### Bug Fixes 157 | 158 | * compile before publishing ([#23](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/23)) ([4a1112f](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/4a1112f95e4772449a4d13217b72b9d82e7676a5)) 159 | 160 | ## [1.2.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v1.1.0...v1.2.0) (2020-08-26) 161 | 162 | 163 | ### Features 164 | 165 | * add better typescript types for pubsub ([#18](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/18)) ([fbde74c](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/fbde74cf21111ad13500c01f2f1da76d999ad046)) 166 | 167 | ## [1.1.0](https://www.github.com/googleapis/google-cloudevents-nodejs/compare/v1.0.0...v1.1.0) (2020-08-13) 168 | 169 | 170 | ### Features 171 | 172 | * init typescript example ([#8](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/8)) ([b6280b1](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/b6280b17234aa5e60959089f3ec35ab02b3e1dec)) 173 | 174 | ## 1.0.0 (2020-08-04) 175 | 176 | 177 | ### Features 178 | 179 | * init package files ([#9](https://www.github.com/googleapis/google-cloudevents-nodejs/issues/9)) ([9e91e8f](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/9e91e8f009def46b7a71a9dc53e4be95457b4146)) 180 | * initialize the generator ([58a9c3b](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/58a9c3b643bc5415e2bf333a112fcbda1665af27)) 181 | 182 | 183 | ### Bug Fixes 184 | 185 | * remove node_modules ([5dcb913](https://www.github.com/googleapis/google-cloudevents-nodejs/commit/5dcb91383071f37f4ab66ca24469fb2d6b75f55b)) 186 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **_THIS REPOSITORY AND PACKAGE WILL BE DEPRECATED IN JULY 2024._** 2 | 3 | # Google CloudEvents – Node.js [![npm version](https://badge.fury.io/js/%40google%2Fevents.svg)](https://www.npmjs.com/package/@google/events) [![github ci](https://github.com/googleapis/google-cloudevents-nodejs/workflows/ci/badge.svg)](https://github.com/googleapis/google-cloudevents-nodejs/actions?query=workflow%3Aci) 4 | 5 | This repository contains types for CloudEvents issued by Google, 6 | enabling you to have autocompletion in **JavaScript** or **TypeScript** projects. 7 | 8 | > Note: This repo is auto-generated from schemas in https://github.com/googleapis/google-cloudevents 9 | 10 | ## Prerequisites 11 | 12 | - Node 10+ 13 | 14 | ## Install 15 | 16 | Install the library from `npm`: 17 | 18 | ```sh 19 | npm i @google/events 20 | ``` 21 | 22 | ## Features 23 | 24 | This library is meant to provide types for Node projects accepting CloudEvent data, typically sent through a HTTP request's `POST` body. 25 | 26 | For every event type, this library contains: 27 | 28 | - Exports a JavaScript function `to[DataType]`. 29 | - Exports a TypeScript type interface `DataType`. 30 | 31 | This provides autocompletion and inline IDE documentation for event types. 32 | ## Example Usage 33 | 34 | Require or import the module. Here is an example JS and TS file: 35 | 36 | ### JS 37 | 38 | ```js 39 | const {toLogEntryData} = require('@google/events/cloud/audit/v1/LogEntryData'); 40 | 41 | const data = { 42 | // ... 43 | }; 44 | 45 | const jsExample = toLogEntryData(data); 46 | console.log(jsExample); 47 | ``` 48 | 49 | ### TS 50 | 51 | ```ts 52 | import {LogEntryData} from '@google/events/cloud/audit/v1/LogEntryData'; 53 | 54 | const data = { 55 | // ... 56 | }; 57 | 58 | const tsExample: LogEntryData = data; 59 | console.log(tsExample); 60 | ``` 61 | 62 | ## Reference 63 | 64 | The [`reference.md`](reference.md) file has detailed examples for how to use every event data type. 65 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). 4 | 5 | The Google Security Team will respond within 5 working days of your report on g.co/vulnz. 6 | 7 | We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. 8 | -------------------------------------------------------------------------------- /cloud/audit/v1/LogEntryData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The data within all Cloud Audit Logs log entry events. 19 | */ 20 | export interface LogEntryData { 21 | /** 22 | * A unique identifier for the log entry. 23 | */ 24 | insertId?: string; 25 | /** 26 | * A set of user-defined (key, value) data that provides additional 27 | * information about the log entry. 28 | */ 29 | labels?: {[key: string]: string}; 30 | /** 31 | * The resource name of the log to which this log entry belongs. 32 | */ 33 | logName?: string; 34 | /** 35 | * Information about an operation associated with the log entry, if 36 | * applicable. 37 | */ 38 | operation?: Operation; 39 | /** 40 | * The log entry payload, which is always an AuditLog for Cloud Audit Log 41 | * events. 42 | */ 43 | protoPayload?: ProtoPayload; 44 | /** 45 | * The time the log entry was received by Logging. 46 | */ 47 | receiveTimestamp?: Date | string; 48 | /** 49 | * The monitored resource that produced this log entry. 50 | * 51 | * Example: a log entry that reports a database error would be associated with 52 | * the monitored resource designating the particular database that reported 53 | * the error. 54 | */ 55 | resource?: ResourceObject; 56 | /** 57 | * The severity of the log entry. 58 | */ 59 | severity?: InsertID | number; 60 | /** 61 | * The span ID within the trace associated with the log entry, if any. 62 | * 63 | * For Trace spans, this is the same format that the Trace API v2 uses: a 64 | * 16-character hexadecimal encoding of an 8-byte array, such as 65 | * `000000000000004a`. 66 | */ 67 | spanId?: string; 68 | /** 69 | * Information indicating this LogEntry is part of a sequence of multiple logs 70 | * split from a single LogEntry. 71 | */ 72 | split?: Split; 73 | /** 74 | * The time the event described by the log entry occurred. 75 | */ 76 | timestamp?: Date | string; 77 | /** 78 | * Resource name of the trace associated with the log entry, if any. If it 79 | * contains a relative resource name, the name is assumed to be relative to 80 | * `//tracing.googleapis.com`. Example: 81 | * `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824` 82 | */ 83 | trace?: string; 84 | } 85 | 86 | /** 87 | * Information about an operation associated with the log entry, if 88 | * applicable. 89 | * 90 | * Additional information about a potentially long-running operation with which 91 | * a log entry is associated. 92 | */ 93 | export interface Operation { 94 | /** 95 | * True if this is the first log entry in the operation. 96 | */ 97 | first?: boolean; 98 | /** 99 | * An arbitrary operation identifier. Log entries with the same 100 | * identifier are assumed to be part of the same operation. 101 | */ 102 | id?: string; 103 | /** 104 | * True if this is the last log entry in the operation. 105 | */ 106 | last?: boolean; 107 | /** 108 | * An arbitrary producer identifier. The combination of `id` and 109 | * `producer` must be globally unique. Examples for `producer`: 110 | * `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`. 111 | */ 112 | producer?: string; 113 | } 114 | 115 | /** 116 | * The log entry payload, which is always an AuditLog for Cloud Audit Log 117 | * events. 118 | * 119 | * Common audit log format for Google Cloud Platform API operations. 120 | * Copied from 121 | * https://github.com/googleapis/googleapis/blob/master/google/cloud/audit/audit_log.proto, 122 | * but changing service_data from Any to Struct. 123 | */ 124 | export interface ProtoPayload { 125 | /** 126 | * Authentication information. 127 | */ 128 | authenticationInfo?: AuthenticationInfo; 129 | /** 130 | * Authorization information. If there are multiple 131 | * resources or permissions involved, then there is 132 | * one AuthorizationInfo element for each {resource, permission} tuple. 133 | */ 134 | authorizationInfo?: AuthorizationInfo[]; 135 | /** 136 | * Other service-specific data about the request, response, and other 137 | * information associated with the current audited event. 138 | */ 139 | metadata?: {[key: string]: any}; 140 | /** 141 | * The name of the service method or operation. 142 | * For API calls, this should be the name of the API method. 143 | * For example, 144 | * 145 | * "google.datastore.v1.Datastore.RunQuery" 146 | * "google.logging.v1.LoggingService.DeleteLog" 147 | */ 148 | methodName?: string; 149 | /** 150 | * The number of items returned from a List or Query API method, 151 | * if applicable. 152 | */ 153 | numResponseItems?: number; 154 | /** 155 | * The operation request. This may not include all request parameters, 156 | * such as those that are too large, privacy-sensitive, or duplicated 157 | * elsewhere in the log record. 158 | * It should never include user-generated data, such as file contents. 159 | * When the JSON object represented here has a proto equivalent, the proto 160 | * name will be indicated in the `@type` property. 161 | */ 162 | request?: {[key: string]: any}; 163 | /** 164 | * Metadata about the operation. 165 | */ 166 | requestMetadata?: RequestMetadata; 167 | /** 168 | * The resource location information. 169 | */ 170 | resourceLocation?: ResourceLocation; 171 | /** 172 | * The resource or collection that is the target of the operation. 173 | * The name is a scheme-less URI, not including the API service name. 174 | * For example: 175 | * 176 | * "shelves/SHELF_ID/books" 177 | * "shelves/SHELF_ID/books/BOOK_ID" 178 | */ 179 | resourceName?: string; 180 | /** 181 | * The resource's original state before mutation. Present only for 182 | * operations which have successfully modified the targeted resource(s). 183 | * In general, this field should contain all changed fields, except those 184 | * that are already been included in `request`, `response`, `metadata` or 185 | * `service_data` fields. 186 | * When the JSON object represented here has a proto equivalent, 187 | * the proto name will be indicated in the `@type` property. 188 | */ 189 | resourceOriginalState?: {[key: string]: any}; 190 | /** 191 | * The operation response. This may not include all response elements, 192 | * such as those that are too large, privacy-sensitive, or duplicated 193 | * elsewhere in the log record. 194 | * It should never include user-generated data, such as file contents. 195 | * When the JSON object represented here has a proto equivalent, the proto 196 | * name will be indicated in the `@type` property. 197 | */ 198 | response?: {[key: string]: any}; 199 | /** 200 | * Deprecated: Use `metadata` field instead. 201 | * Other service-specific data about the request, response, and other 202 | * activities. 203 | * When the JSON object represented here has a proto equivalent, the proto 204 | * name will be indicated in the `@type` property. 205 | */ 206 | serviceData?: {[key: string]: any}; 207 | /** 208 | * The name of the API service performing the operation. For example, 209 | * `"datastore.googleapis.com"`. 210 | */ 211 | serviceName?: string; 212 | /** 213 | * The status of the overall operation. 214 | */ 215 | status?: Status; 216 | } 217 | 218 | /** 219 | * Authentication information. 220 | * 221 | * Authentication information for the operation. 222 | */ 223 | export interface AuthenticationInfo { 224 | /** 225 | * The authority selector specified by the requestor, if any. 226 | * It is not guaranteed that the principal was allowed to use this authority. 227 | */ 228 | authoritySelector?: string; 229 | /** 230 | * The email address of the authenticated user (or service account on behalf 231 | * of third party principal) making the request. For privacy reasons, the 232 | * principal email address is redacted for all read-only operations that fail 233 | * with a "permission denied" error. 234 | */ 235 | principalEmail?: string; 236 | /** 237 | * String representation of identity of requesting party. 238 | * Populated for both first and third party identities. 239 | */ 240 | principalSubject?: string; 241 | /** 242 | * Identity delegation history of an authenticated service account that makes 243 | * the request. It contains information on the real authorities that try to 244 | * access GCP resources by delegating on a service account. When multiple 245 | * authorities present, they are guaranteed to be sorted based on the original 246 | * ordering of the identity delegation events. 247 | */ 248 | serviceAccountDelegationInfo?: ServiceAccountDelegationInfo[]; 249 | /** 250 | * The name of the service account key used to create or exchange 251 | * credentials for authenticating the service account making the request. 252 | * This is a scheme-less URI full resource name. For example: 253 | * 254 | * "//iam.googleapis.com/projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{key}" 255 | */ 256 | serviceAccountKeyName?: string; 257 | /** 258 | * The third party identification (if any) of the authenticated user making 259 | * the request. 260 | * When the JSON object represented here has a proto equivalent, the proto 261 | * name will be indicated in the `@type` property. 262 | */ 263 | thirdPartyPrincipal?: {[key: string]: any}; 264 | } 265 | 266 | /** 267 | * Identity delegation history of an authenticated service account. 268 | */ 269 | export interface ServiceAccountDelegationInfo { 270 | /** 271 | * First party (Google) identity as the real authority. 272 | */ 273 | firstPartyPrincipal?: FirstPartyPrincipal; 274 | /** 275 | * Third party identity as the real authority. 276 | */ 277 | thirdPartyPrincipal?: ThirdPartyPrincipal; 278 | } 279 | 280 | /** 281 | * First party (Google) identity as the real authority. 282 | * 283 | * First party identity principal. 284 | */ 285 | export interface FirstPartyPrincipal { 286 | /** 287 | * The email address of a Google account. 288 | */ 289 | principalEmail?: string; 290 | /** 291 | * Metadata about the service that uses the service account. 292 | */ 293 | serviceMetadata?: {[key: string]: any}; 294 | } 295 | 296 | /** 297 | * Third party identity as the real authority. 298 | * 299 | * Third party identity principal. 300 | */ 301 | export interface ThirdPartyPrincipal { 302 | /** 303 | * Metadata about third party identity. 304 | */ 305 | thirdPartyClaims?: {[key: string]: any}; 306 | } 307 | 308 | /** 309 | * Authorization information for the operation. 310 | */ 311 | export interface AuthorizationInfo { 312 | /** 313 | * Whether or not authorization for `resource` and `permission` 314 | * was granted. 315 | */ 316 | granted?: boolean; 317 | /** 318 | * The required IAM permission. 319 | */ 320 | permission?: string; 321 | /** 322 | * The resource being accessed, as a REST-style string. For example: 323 | * 324 | * bigquery.googleapis.com/projects/PROJECTID/datasets/DATASETID 325 | */ 326 | resource?: string; 327 | /** 328 | * Resource attributes used in IAM condition evaluation. This field contains 329 | * resource attributes like resource type and resource name. 330 | * 331 | * To get the whole view of the attributes used in IAM 332 | * condition evaluation, the user must also look into 333 | * `AuditLogData.request_metadata.request_attributes`. 334 | */ 335 | resourceAttributes?: ResourceAttributesObject; 336 | } 337 | 338 | /** 339 | * Resource attributes used in IAM condition evaluation. This field contains 340 | * resource attributes like resource type and resource name. 341 | * 342 | * To get the whole view of the attributes used in IAM 343 | * condition evaluation, the user must also look into 344 | * `AuditLogData.request_metadata.request_attributes`. 345 | * 346 | * This message defines core attributes for a resource. A resource is an 347 | * addressable (named) entity provided by the destination service. For 348 | * example, a file stored on a network storage service. 349 | */ 350 | export interface ResourceAttributesObject { 351 | /** 352 | * The labels or tags on the resource, such as AWS resource tags and 353 | * Kubernetes resource labels. 354 | */ 355 | labels?: {[key: string]: string}; 356 | /** 357 | * The stable identifier (name) of a resource on the `service`. A resource 358 | * can be logically identified as "//{resource.service}/{resource.name}". 359 | * The differences between a resource name and a URI are: 360 | * 361 | * * Resource name is a logical identifier, independent of network 362 | * protocol and API version. For example, 363 | * `//pubsub.googleapis.com/projects/123/topics/news-feed`. 364 | * * URI often includes protocol and version information, so it can 365 | * be used directly by applications. For example, 366 | * `https://pubsub.googleapis.com/v1/projects/123/topics/news-feed`. 367 | * 368 | * See https://cloud.google.com/apis/design/resource_names for details. 369 | */ 370 | name?: string; 371 | /** 372 | * The name of the service that this resource belongs to, such as 373 | * `pubsub.googleapis.com`. The service may be different from the DNS 374 | * hostname that actually serves the request. 375 | */ 376 | service?: string; 377 | /** 378 | * The type of the resource. The syntax is platform-specific because 379 | * different platforms define their resources differently. 380 | * 381 | * For Google APIs, the type format must be "{service}/{kind}". 382 | */ 383 | type?: string; 384 | } 385 | 386 | /** 387 | * Metadata about the operation. 388 | * 389 | * Metadata about the request. 390 | */ 391 | export interface RequestMetadata { 392 | /** 393 | * The IP address of the caller. 394 | * For caller from internet, this will be public IPv4 or IPv6 address. 395 | * For caller from a Compute Engine VM with external IP address, this 396 | * will be the VM's external IP address. For caller from a Compute 397 | * Engine VM without external IP address, if the VM is in the same 398 | * organization (or project) as the accessed resource, `caller_ip` will 399 | * be the VM's internal IPv4 address, otherwise the `caller_ip` will be 400 | * redacted to "gce-internal-ip". 401 | * See https://cloud.google.com/compute/docs/vpc/ for more information. 402 | */ 403 | callerIp?: string; 404 | /** 405 | * The network of the caller. 406 | * Set only if the network host project is part of the same GCP organization 407 | * (or project) as the accessed resource. 408 | * See https://cloud.google.com/compute/docs/vpc/ for more information. 409 | * This is a scheme-less URI full resource name. For example: 410 | * 411 | * "//compute.googleapis.com/projects/PROJECT_ID/global/networks/NETWORK_ID" 412 | */ 413 | callerNetwork?: string; 414 | /** 415 | * The user agent of the caller. 416 | * This information is not authenticated and should be treated accordingly. 417 | * For example: 418 | * 419 | * + `google-api-python-client/1.4.0`: 420 | * The request was made by the Google API client for Python. 421 | * + `Cloud SDK Command Line Tool apitools-client/1.0 gcloud/0.9.62`: 422 | * The request was made by the Google Cloud SDK CLI (gcloud). 423 | * + `AppEngine-Google; (+http://code.google.com/appengine; appid: 424 | * s~my-project`: 425 | * The request was made from the `my-project` App Engine app. 426 | */ 427 | callerSuppliedUserAgent?: string; 428 | /** 429 | * The destination of a network activity, such as accepting a TCP connection. 430 | * In a multi hop network activity, the destination represents the receiver of 431 | * the last hop. Only two fields are used in this message, Peer.port and 432 | * Peer.ip. These fields are optionally populated by those services utilizing 433 | * the IAM condition feature. 434 | */ 435 | destinationAttributes?: DestinationAttributes; 436 | /** 437 | * Request attributes used in IAM condition evaluation. This field contains 438 | * request attributes like request time and access levels associated with 439 | * the request. 440 | * 441 | * 442 | * To get the whole view of the attributes used in IAM 443 | * condition evaluation, the user must also look into 444 | * `AuditLog.authentication_info.resource_attributes`. 445 | */ 446 | requestAttributes?: Request; 447 | } 448 | 449 | /** 450 | * The destination of a network activity, such as accepting a TCP connection. 451 | * In a multi hop network activity, the destination represents the receiver of 452 | * the last hop. Only two fields are used in this message, Peer.port and 453 | * Peer.ip. These fields are optionally populated by those services utilizing 454 | * the IAM condition feature. 455 | * 456 | * This message defines attributes for a node that handles a network request. 457 | * The node can be either a service or an application that sends, forwards, 458 | * or receives the request. Service peers should fill in 459 | * `principal` and `labels` as appropriate. 460 | */ 461 | export interface DestinationAttributes { 462 | /** 463 | * The IP address of the peer. 464 | */ 465 | ip?: string; 466 | /** 467 | * The labels associated with the peer. 468 | */ 469 | labels?: {[key: string]: string}; 470 | /** 471 | * The network port of the peer. 472 | */ 473 | port?: number; 474 | /** 475 | * The identity of this peer. Similar to `Request.auth.principal`, but 476 | * relative to the peer instead of the request. For example, the 477 | * idenity associated with a load balancer that forwared the request. 478 | */ 479 | principal?: string; 480 | /** 481 | * The CLDR country/region code associated with the above IP address. 482 | * If the IP address is private, the `region_code` should reflect the 483 | * physical location where this peer is running. 484 | */ 485 | regionCode?: string; 486 | } 487 | 488 | /** 489 | * Request attributes used in IAM condition evaluation. This field contains 490 | * request attributes like request time and access levels associated with 491 | * the request. 492 | * 493 | * 494 | * To get the whole view of the attributes used in IAM 495 | * condition evaluation, the user must also look into 496 | * `AuditLog.authentication_info.resource_attributes`. 497 | * 498 | * This message defines attributes for an HTTP request. If the actual 499 | * request is not an HTTP request, the runtime system should try to map 500 | * the actual request to an equivalent HTTP request. 501 | */ 502 | export interface Request { 503 | /** 504 | * The request authentication. May be absent for unauthenticated requests. 505 | * Derived from the HTTP request `Authorization` header or equivalent. 506 | */ 507 | auth?: Auth; 508 | /** 509 | * The HTTP request headers. If multiple headers share the same key, they 510 | * must be merged according to the HTTP spec. All header keys must be 511 | * lowercased, because HTTP header keys are case-insensitive. 512 | */ 513 | headers?: {[key: string]: string}; 514 | /** 515 | * The HTTP request `Host` header value. 516 | */ 517 | host?: string; 518 | /** 519 | * The unique ID for a request, which can be propagated to downstream 520 | * systems. The ID should have low probability of collision 521 | * within a single day for a specific service. 522 | */ 523 | id?: string; 524 | /** 525 | * The HTTP request method, such as `GET`, `POST`. 526 | */ 527 | method?: string; 528 | /** 529 | * The HTTP URL path. 530 | */ 531 | path?: string; 532 | /** 533 | * The network protocol used with the request, such as "http/1.1", 534 | * "spdy/3", "h2", "h2c", "webrtc", "tcp", "udp", "quic". See 535 | * 536 | * https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids 537 | * for details. 538 | */ 539 | protocol?: string; 540 | /** 541 | * The HTTP URL query in the format of `name1=value1&name2=value2`, as it 542 | * appears in the first line of the HTTP request. No decoding is performed. 543 | */ 544 | query?: string; 545 | /** 546 | * A special parameter for request reason. It is used by security systems 547 | * to associate auditing information with a request. 548 | */ 549 | reason?: string; 550 | /** 551 | * The HTTP URL scheme, such as `http` and `https`. 552 | */ 553 | scheme?: string; 554 | /** 555 | * The HTTP request size in bytes. If unknown, it must be -1. 556 | */ 557 | size?: number; 558 | /** 559 | * The timestamp when the `destination` service receives the first byte of 560 | * the request. 561 | */ 562 | time?: Date | string; 563 | } 564 | 565 | /** 566 | * The request authentication. May be absent for unauthenticated requests. 567 | * Derived from the HTTP request `Authorization` header or equivalent. 568 | * 569 | * This message defines request authentication attributes. Terminology is 570 | * based on the JSON Web Token (JWT) standard, but the terms also 571 | * correlate to concepts in other standards. 572 | */ 573 | export interface Auth { 574 | /** 575 | * A list of access level resource names that allow resources to be 576 | * accessed by authenticated requester. It is part of Secure GCP processing 577 | * for the incoming request. An access level string has the format: 578 | * "//{api_service_name}/accessPolicies/{policy_id}/accessLevels/{short_name}" 579 | * 580 | * Example: 581 | * "//accesscontextmanager.googleapis.com/accessPolicies/MY_POLICY_ID/accessLevels/MY_LEVEL" 582 | */ 583 | accessLevels?: string[]; 584 | /** 585 | * The intended audience(s) for this authentication information. Reflects 586 | * the audience (`aud`) claim within a JWT. The audience 587 | * value(s) depends on the `issuer`, but typically include one or more of 588 | * the following pieces of information: 589 | * 590 | * * The services intended to receive the credential such as 591 | * ["pubsub.googleapis.com", "storage.googleapis.com"] 592 | * * A set of service-based scopes. For example, 593 | * ["https://www.googleapis.com/auth/cloud-platform"] 594 | * * The client id of an app, such as the Firebase project id for JWTs 595 | * from Firebase Auth. 596 | * 597 | * Consult the documentation for the credential issuer to determine the 598 | * information provided. 599 | */ 600 | audiences?: string[]; 601 | /** 602 | * Structured claims presented with the credential. JWTs include 603 | * `{key: value}` pairs for standard and private claims. The following 604 | * is a subset of the standard required and optional claims that would 605 | * typically be presented for a Google-based JWT: 606 | * 607 | * {'iss': 'accounts.google.com', 608 | * 'sub': '113289723416554971153', 609 | * 'aud': ['123456789012', 'pubsub.googleapis.com'], 610 | * 'azp': '123456789012.apps.googleusercontent.com', 611 | * 'email': 'jsmith@example.com', 612 | * 'iat': 1353601026, 613 | * 'exp': 1353604926} 614 | * 615 | * SAML assertions are similarly specified, but with an identity provider 616 | * dependent structure. 617 | */ 618 | claims?: {[key: string]: any}; 619 | /** 620 | * The authorized presenter of the credential. Reflects the optional 621 | * Authorized Presenter (`azp`) claim within a JWT or the 622 | * OAuth client id. For example, a Google Cloud Platform client id looks 623 | * as follows: "123456789012.apps.googleusercontent.com". 624 | */ 625 | presenter?: string; 626 | /** 627 | * The authenticated principal. Reflects the issuer (`iss`) and subject 628 | * (`sub`) claims within a JWT. The issuer and subject should be `/` 629 | * delimited, with `/` percent-encoded within the subject fragment. For 630 | * Google accounts, the principal format is: 631 | * "https://accounts.google.com/{id}" 632 | */ 633 | principal?: string; 634 | } 635 | 636 | /** 637 | * The resource location information. 638 | * 639 | * Location information about a resource. 640 | */ 641 | export interface ResourceLocation { 642 | /** 643 | * The locations of a resource after the execution of the operation. 644 | * Requests to create or delete a location based resource must populate 645 | * the 'current_locations' field and not the 'original_locations' field. 646 | * For example: 647 | * 648 | * "europe-west1-a" 649 | * "us-east1" 650 | * "nam3" 651 | */ 652 | currentLocations?: string[]; 653 | /** 654 | * The locations of a resource prior to the execution of the operation. 655 | * Requests that mutate the resource's location must populate both the 656 | * 'original_locations' as well as the 'current_locations' fields. 657 | * For example: 658 | * 659 | * "europe-west1-a" 660 | * "us-east1" 661 | * "nam3" 662 | */ 663 | originalLocations?: string[]; 664 | } 665 | 666 | /** 667 | * The status of the overall operation. 668 | * 669 | * The `Status` type defines a logical error model that is suitable for 670 | * different programming environments, including REST APIs and RPC APIs. It is 671 | * used by [gRPC](https://github.com/grpc). Each `Status` message contains 672 | * three pieces of data: error code, error message, and error details. 673 | * 674 | * You can find out more about this error model and how to work with it in the 675 | * [API Design Guide](https://cloud.google.com/apis/design/errors). 676 | */ 677 | export interface Status { 678 | /** 679 | * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. 680 | */ 681 | code?: number; 682 | /** 683 | * A list of messages that carry the error details. There is a common set of 684 | * message types for APIs to use. 685 | */ 686 | details?: Detail[]; 687 | /** 688 | * A developer-facing error message, which should be in English. Any 689 | * user-facing error message should be localized and sent in the 690 | * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. 691 | */ 692 | message?: string; 693 | } 694 | 695 | /** 696 | * `Any` contains an arbitrary serialized protocol buffer message along with a 697 | * URL that describes the type of the serialized message. 698 | * 699 | * Protobuf library provides support to pack/unpack Any values in the form 700 | * of utility functions or additional generated methods of the Any type. 701 | * 702 | * Example 1: Pack and unpack a message in C++. 703 | * 704 | * Foo foo = ...; 705 | * Any any; 706 | * any.PackFrom(foo); 707 | * ... 708 | * if (any.UnpackTo(&foo)) { 709 | * ... 710 | * } 711 | * 712 | * Example 2: Pack and unpack a message in Java. 713 | * 714 | * Foo foo = ...; 715 | * Any any = Any.pack(foo); 716 | * ... 717 | * if (any.is(Foo.class)) { 718 | * foo = any.unpack(Foo.class); 719 | * } 720 | * 721 | * Example 3: Pack and unpack a message in Python. 722 | * 723 | * foo = Foo(...) 724 | * any = Any() 725 | * any.Pack(foo) 726 | * ... 727 | * if any.Is(Foo.DESCRIPTOR): 728 | * any.Unpack(foo) 729 | * ... 730 | * 731 | * Example 4: Pack and unpack a message in Go 732 | * 733 | * foo := &pb.Foo{...} 734 | * any, err := ptypes.MarshalAny(foo) 735 | * ... 736 | * foo := &pb.Foo{} 737 | * if err := ptypes.UnmarshalAny(any, foo); err != nil { 738 | * ... 739 | * } 740 | * 741 | * The pack methods provided by protobuf library will by default use 742 | * 'type.googleapis.com/full.type.name' as the type URL and the unpack 743 | * methods only use the fully qualified type name after the last '/' 744 | * in the type URL, for example "foo.bar.com/x/y.z" will yield type 745 | * name "y.z". 746 | * 747 | * 748 | * JSON 749 | * ==== 750 | * The JSON representation of an `Any` value uses the regular 751 | * representation of the deserialized, embedded message, with an 752 | * additional field `@type` which contains the type URL. Example: 753 | * 754 | * package google.profile; 755 | * message Person { 756 | * string first_name = 1; 757 | * string last_name = 2; 758 | * } 759 | * 760 | * { 761 | * "@type": "type.googleapis.com/google.profile.Person", 762 | * "firstName": , 763 | * "lastName": 764 | * } 765 | * 766 | * If the embedded message type is well-known and has a custom JSON 767 | * representation, that representation will be embedded adding a field 768 | * `value` which holds the custom JSON in addition to the `@type` 769 | * field. Example (for message [google.protobuf.Duration][]): 770 | * 771 | * { 772 | * "@type": "type.googleapis.com/google.protobuf.Duration", 773 | * "value": "1.212s" 774 | * } 775 | */ 776 | export interface Detail { 777 | /** 778 | * A URL/resource name that uniquely identifies the type of the serialized 779 | * protocol buffer message. This string must contain at least 780 | * one "/" character. The last segment of the URL's path must represent 781 | * the fully qualified name of the type (as in 782 | * `path/google.protobuf.Duration`). The name should be in a canonical form 783 | * (e.g., leading "." is not accepted). 784 | * 785 | * In practice, teams usually precompile into the binary all types that they 786 | * expect it to use in the context of Any. However, for URLs which use the 787 | * scheme `http`, `https`, or no scheme, one can optionally set up a type 788 | * server that maps type URLs to message definitions as follows: 789 | * 790 | * * If no scheme is provided, `https` is assumed. 791 | * * An HTTP GET on the URL must yield a [google.protobuf.Type][] 792 | * value in binary format, or produce an error. 793 | * * Applications are allowed to cache lookup results based on the 794 | * URL, or have them precompiled into a binary to avoid any 795 | * lookup. Therefore, binary compatibility needs to be preserved 796 | * on changes to types. (Use versioned type names to manage 797 | * breaking changes.) 798 | * 799 | * Note: this functionality is not currently available in the official 800 | * protobuf release, and it is not used for type URLs beginning with 801 | * type.googleapis.com. 802 | * 803 | * Schemes other than `http`, `https` (or the empty scheme) might be 804 | * used with implementation specific semantics. 805 | */ 806 | typeUrl?: string; 807 | /** 808 | * Must be a valid serialized protocol buffer of the above specified type. 809 | */ 810 | value?: string; 811 | } 812 | 813 | /** 814 | * The monitored resource that produced this log entry. 815 | * 816 | * Example: a log entry that reports a database error would be associated with 817 | * the monitored resource designating the particular database that reported 818 | * the error. 819 | * 820 | * Note: this is a much-reduced version of the proto at 821 | * https://github.com/googleapis/googleapis/blob/master/google/api/monitored_resource.proto 822 | * to avoid other dependencies leaking into events. 823 | * 824 | * An object representing a resource that can be used for monitoring, logging, 825 | * billing, or other purposes. 826 | */ 827 | export interface ResourceObject { 828 | /** 829 | * Values for all of the labels listed in the associated monitored 830 | * resource descriptor. For example, Compute Engine VM instances use the 831 | * labels `"project_id"`, `"instance_id"`, and `"zone"`. 832 | */ 833 | labels?: {[key: string]: string}; 834 | /** 835 | * Required. The monitored resource type. For example, the type of a 836 | * Compute Engine VM instance is `gce_instance`. 837 | */ 838 | type?: string; 839 | } 840 | 841 | export enum InsertID { 842 | Alert = 'ALERT', 843 | Critical = 'CRITICAL', 844 | Debug = 'DEBUG', 845 | Default = 'DEFAULT', 846 | Emergency = 'EMERGENCY', 847 | Error = 'ERROR', 848 | Info = 'INFO', 849 | Notice = 'NOTICE', 850 | Warning = 'WARNING', 851 | } 852 | 853 | /** 854 | * Information indicating this LogEntry is part of a sequence of multiple logs 855 | * split from a single LogEntry. 856 | * 857 | * Additional information used to correlate multiple LogEntries. Used when a 858 | * single LogEntry would exceed the Google Cloud Logging size limit and is split 859 | * across multiple entries. 860 | */ 861 | export interface Split { 862 | /** 863 | * The index of this LogEntry in the sequence of split logs. LogEntries are 864 | * given |index| values 0, 1, ..., n-1 for a sequence of n entries. 865 | */ 866 | index?: number; 867 | /** 868 | * The total number of logs that the original LogEntry was split into. 869 | */ 870 | totalSplits?: number; 871 | /** 872 | * A globally unique identifier for all LogEntries in a sequence of split 873 | * logs. All LogEntries with the same |LogSplit.uid| are assumed to be part of 874 | * the same sequence of split logs. 875 | */ 876 | uid?: string; 877 | } 878 | 879 | /** 880 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 881 | * @param {object} json The JSON object 882 | * @return {LogEntryData} The object with type annotations 883 | */ 884 | export const toLogEntryData = (json: object) => { 885 | return json as LogEntryData; 886 | }; 887 | -------------------------------------------------------------------------------- /cloud/cloudbuild/v1/BuildEventData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Build event data for Google Cloud Platform API operations. 19 | */ 20 | export interface BuildEventData { 21 | /** 22 | * Artifacts produced by the build that should be uploaded upon 23 | * successful completion of all build steps. 24 | */ 25 | artifacts?: Artifacts; 26 | /** 27 | * The ID of the `BuildTrigger` that triggered this build, if it 28 | * was triggered automatically. 29 | */ 30 | buildTriggerId?: string; 31 | /** 32 | * Time at which the request to create the build was received. 33 | */ 34 | createTime?: Date | string; 35 | /** 36 | * Time at which execution of the build was finished. 37 | * 38 | * The difference between finish_time and start_time is the duration of the 39 | * build's execution. 40 | */ 41 | finishTime?: Date | string; 42 | /** 43 | * Unique identifier of the build. 44 | */ 45 | id?: string; 46 | /** 47 | * A list of images to be pushed upon the successful completion of all build 48 | * steps. 49 | * 50 | * The images are pushed using the builder service account's credentials. 51 | * 52 | * The digests of the pushed images will be stored in the `Build` resource's 53 | * results field. 54 | * 55 | * If any of the images fail to be pushed, the build status is marked 56 | * `FAILURE`. 57 | */ 58 | images?: string[]; 59 | /** 60 | * Google Cloud Storage bucket where logs should be written (see 61 | * [Bucket Name 62 | * Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)). 63 | * Logs file names will be of the format `${logs_bucket}/log-${build_id}.txt`. 64 | */ 65 | logsBucket?: string; 66 | /** 67 | * URL to logs for this build in Google Cloud Console. 68 | */ 69 | logUrl?: string; 70 | /** 71 | * Special options for this build. 72 | */ 73 | options?: Options; 74 | /** 75 | * ID of the project. 76 | */ 77 | projectId?: string; 78 | /** 79 | * TTL in queue for this build. If provided and the build is enqueued longer 80 | * than this value, the build will expire and the build status will be 81 | * `EXPIRED`. 82 | * 83 | * The TTL starts ticking from create_time. 84 | */ 85 | queueTtl?: string; 86 | /** 87 | * Results of the build. 88 | */ 89 | results?: Results; 90 | /** 91 | * Secrets to decrypt using Cloud Key Management Service. 92 | */ 93 | secrets?: Secret[]; 94 | /** 95 | * The location of the source files to build. 96 | */ 97 | source?: Source; 98 | /** 99 | * A permanent fixed identifier for source. 100 | */ 101 | sourceProvenance?: SourceProvenance; 102 | /** 103 | * Time at which execution of the build was started. 104 | */ 105 | startTime?: Date | string; 106 | /** 107 | * Status of the build. 108 | */ 109 | status?: StatusEnum | number; 110 | /** 111 | * Customer-readable message about the current status. 112 | */ 113 | statusDetail?: string; 114 | /** 115 | * The operations to be performed on the workspace. 116 | */ 117 | steps?: BuildStep[]; 118 | /** 119 | * Substitutions data for `Build` resource. 120 | */ 121 | substitutions?: {[key: string]: string}; 122 | /** 123 | * Tags for annotation of a `Build`. These are not docker tags. 124 | */ 125 | tags?: string[]; 126 | /** 127 | * Amount of time that this build should be allowed to run, to second 128 | * granularity. If this amount of time elapses, work on the build will cease 129 | * and the build status will be `TIMEOUT`. 130 | */ 131 | timeout?: string; 132 | /** 133 | * Stores timing information for phases of the build. Valid keys 134 | * are: 135 | * 136 | * * BUILD: time to execute all build steps 137 | * * PUSH: time to push all specified images. 138 | * * FETCHSOURCE: time to fetch source. 139 | * 140 | * If the build does not specify source or images, 141 | * these keys will not be included. 142 | */ 143 | timing?: {[key: string]: TimeSpan}; 144 | } 145 | 146 | /** 147 | * Artifacts produced by the build that should be uploaded upon 148 | * successful completion of all build steps. 149 | * 150 | * Artifacts produced by a build that should be uploaded upon 151 | * successful completion of all build steps. 152 | */ 153 | export interface Artifacts { 154 | /** 155 | * A list of images to be pushed upon the successful completion of all build 156 | * steps. 157 | * 158 | * The images will be pushed using the builder service account's credentials. 159 | * 160 | * The digests of the pushed images will be stored in the Build resource's 161 | * results field. 162 | * 163 | * If any of the images fail to be pushed, the build is marked FAILURE. 164 | */ 165 | images?: string[]; 166 | /** 167 | * A list of objects to be uploaded to Cloud Storage upon successful 168 | * completion of all build steps. 169 | * 170 | * Files in the workspace matching specified paths globs will be uploaded to 171 | * the specified Cloud Storage location using the builder service account's 172 | * credentials. 173 | * 174 | * The location and generation of the uploaded objects will be stored in the 175 | * Build resource's results field. 176 | * 177 | * If any objects fail to be pushed, the build is marked FAILURE. 178 | */ 179 | objects?: Objects; 180 | } 181 | 182 | /** 183 | * A list of objects to be uploaded to Cloud Storage upon successful 184 | * completion of all build steps. 185 | * 186 | * Files in the workspace matching specified paths globs will be uploaded to 187 | * the specified Cloud Storage location using the builder service account's 188 | * credentials. 189 | * 190 | * The location and generation of the uploaded objects will be stored in the 191 | * Build resource's results field. 192 | * 193 | * If any objects fail to be pushed, the build is marked FAILURE. 194 | * 195 | * Files in the workspace to upload to Cloud Storage upon successful 196 | * completion of all build steps. 197 | */ 198 | export interface Objects { 199 | /** 200 | * Cloud Storage bucket and optional object path, in the form 201 | * "gs://bucket/path/to/somewhere/". (see [Bucket Name 202 | * Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)). 203 | * 204 | * Files in the workspace matching any path pattern will be uploaded to 205 | * Cloud Storage with this location as a prefix. 206 | */ 207 | location?: string; 208 | /** 209 | * Path globs used to match files in the build's workspace. 210 | */ 211 | paths?: string[]; 212 | /** 213 | * Stores timing information for pushing all artifact objects. 214 | */ 215 | timing?: ObjectsTiming; 216 | } 217 | 218 | /** 219 | * Stores timing information for pushing all artifact objects. 220 | * 221 | * Start and end times for a build execution phase. 222 | */ 223 | export interface ObjectsTiming { 224 | /** 225 | * End of time span. 226 | */ 227 | endTime?: Date | string; 228 | /** 229 | * Start of time span. 230 | */ 231 | startTime?: Date | string; 232 | } 233 | 234 | /** 235 | * Special options for this build. 236 | * 237 | * Optional arguments to enable specific features of builds. 238 | */ 239 | export interface Options { 240 | /** 241 | * Requested disk size for the VM that runs the build. Note that this is *NOT* 242 | * "disk free"; some of the space will be used by the operating system and 243 | * build utilities. Also note that this is the minimum disk size that will be 244 | * allocated for the build -- the build may run with a larger disk than 245 | * requested. At present, the maximum disk size is 1000GB; builds that request 246 | * more than the maximum are rejected with an error. 247 | */ 248 | diskSizeGb?: number; 249 | /** 250 | * A list of global environment variable definitions that will exist for all 251 | * build steps in this build. If a variable is defined in both globally and in 252 | * a build step, the variable will use the build step value. 253 | * 254 | * The elements are of the form "KEY=VALUE" for the environment variable "KEY" 255 | * being given the value "VALUE". 256 | */ 257 | env?: string[]; 258 | /** 259 | * Option to specify the logging mode, which determines where the logs are 260 | * stored. 261 | */ 262 | logging?: LoggingEnum | number; 263 | /** 264 | * Option to define build log streaming behavior to Google Cloud 265 | * Storage. 266 | */ 267 | logStreamingOption?: LogStreamingOptionEnum | number; 268 | /** 269 | * Compute Engine machine type on which to run the build. 270 | */ 271 | machineType?: MachineTypeEnum | number; 272 | /** 273 | * Requested verifiability options. 274 | */ 275 | requestedVerifyOption?: RequestedVerifyOptionEnum | number; 276 | /** 277 | * A list of global environment variables, which are encrypted using a Cloud 278 | * Key Management Service crypto key. These values must be specified in the 279 | * build's `Secret`. These variables will be available to all build steps 280 | * in this build. 281 | */ 282 | secretEnv?: string[]; 283 | /** 284 | * Requested hash for SourceProvenance. 285 | */ 286 | sourceProvenanceHash?: Array; 287 | /** 288 | * Option to specify behavior when there is an error in the substitution 289 | * checks. 290 | */ 291 | substitutionOption?: SubstitutionOptionEnum | number; 292 | /** 293 | * Global list of volumes to mount for ALL build steps 294 | * 295 | * Each volume is created as an empty volume prior to starting the build 296 | * process. Upon completion of the build, volumes and their contents are 297 | * discarded. Global volume names and paths cannot conflict with the volumes 298 | * defined a build step. 299 | * 300 | * Using a global volume in a build with only one step is not valid as 301 | * it is indicative of a build request with an incorrect configuration. 302 | */ 303 | volumes?: Volume[]; 304 | /** 305 | * Option to specify a `WorkerPool` for the build. 306 | * Format: projects/{project}/locations/{location}/workerPools/{workerPool} 307 | */ 308 | workerPool?: string; 309 | } 310 | 311 | export enum LogStreamingOptionEnum { 312 | StreamDefault = 'STREAM_DEFAULT', 313 | StreamOff = 'STREAM_OFF', 314 | StreamOn = 'STREAM_ON', 315 | } 316 | 317 | export enum LoggingEnum { 318 | GcsOnly = 'GCS_ONLY', 319 | Legacy = 'LEGACY', 320 | LoggingUnspecified = 'LOGGING_UNSPECIFIED', 321 | } 322 | 323 | export enum MachineTypeEnum { 324 | N1Highcpu32 = 'N1_HIGHCPU_32', 325 | N1Highcpu8 = 'N1_HIGHCPU_8', 326 | Unspecified = 'UNSPECIFIED', 327 | } 328 | 329 | export enum RequestedVerifyOptionEnum { 330 | NotVerified = 'NOT_VERIFIED', 331 | Verified = 'VERIFIED', 332 | } 333 | 334 | export enum SourceProvenanceHashEnum { 335 | Md5 = 'MD5', 336 | None = 'NONE', 337 | Sha256 = 'SHA256', 338 | } 339 | 340 | export enum SubstitutionOptionEnum { 341 | AllowLoose = 'ALLOW_LOOSE', 342 | MustMatch = 'MUST_MATCH', 343 | } 344 | 345 | /** 346 | * Volume describes a Docker container volume which is mounted into build steps 347 | * in order to persist files across build step execution. 348 | */ 349 | export interface Volume { 350 | /** 351 | * Name of the volume to mount. 352 | * 353 | * Volume names must be unique per build step and must be valid names for 354 | * Docker volumes. Each named volume must be used by at least two build steps. 355 | */ 356 | name?: string; 357 | /** 358 | * Path at which to mount the volume. 359 | * 360 | * Paths must be absolute and cannot conflict with other volume paths on the 361 | * same build step or with certain reserved volume paths. 362 | */ 363 | path?: string; 364 | } 365 | 366 | /** 367 | * Results of the build. 368 | * 369 | * Artifacts created by the build pipeline. 370 | */ 371 | export interface Results { 372 | /** 373 | * Path to the artifact manifest. Only populated when artifacts are uploaded. 374 | */ 375 | artifactManifest?: string; 376 | /** 377 | * Time to push all non-container artifacts. 378 | */ 379 | artifactTiming?: ArtifactTiming; 380 | /** 381 | * List of build step digests, in the order corresponding to build step 382 | * indices. 383 | */ 384 | buildStepImages?: string[]; 385 | /** 386 | * List of build step outputs, produced by builder images, in the order 387 | * corresponding to build step indices. 388 | * 389 | * [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders) 390 | * can produce this output by writing to `$BUILDER_OUTPUT/output`. 391 | * Only the first 4KB of data is stored. 392 | */ 393 | buildStepOutputs?: string[]; 394 | /** 395 | * Container images that were built as a part of the build. 396 | */ 397 | images?: BuiltImage[]; 398 | /** 399 | * Number of artifacts uploaded. Only populated when artifacts are uploaded. 400 | */ 401 | numArtifacts?: number; 402 | } 403 | 404 | /** 405 | * Time to push all non-container artifacts. 406 | * 407 | * Stores timing information for pushing all artifact objects. 408 | * 409 | * Start and end times for a build execution phase. 410 | */ 411 | export interface ArtifactTiming { 412 | /** 413 | * End of time span. 414 | */ 415 | endTime?: Date | string; 416 | /** 417 | * Start of time span. 418 | */ 419 | startTime?: Date | string; 420 | } 421 | 422 | /** 423 | * An image built by the pipeline. 424 | */ 425 | export interface BuiltImage { 426 | /** 427 | * Docker Registry 2.0 digest. 428 | */ 429 | digest?: string; 430 | /** 431 | * Name used to push the container image to Google Container Registry, as 432 | * presented to `docker push`. 433 | */ 434 | name?: string; 435 | /** 436 | * Stores timing information for pushing the specified image. 437 | */ 438 | pushTiming?: PushTiming; 439 | } 440 | 441 | /** 442 | * Stores timing information for pushing the specified image. 443 | * 444 | * Stores timing information for pushing all artifact objects. 445 | * 446 | * Start and end times for a build execution phase. 447 | */ 448 | export interface PushTiming { 449 | /** 450 | * End of time span. 451 | */ 452 | endTime?: Date | string; 453 | /** 454 | * Start of time span. 455 | */ 456 | startTime?: Date | string; 457 | } 458 | 459 | /** 460 | * Pairs a set of secret environment variables containing encrypted 461 | * values with the Cloud KMS key to use to decrypt the value. 462 | */ 463 | export interface Secret { 464 | /** 465 | * Cloud KMS key name to use to decrypt these envs. 466 | */ 467 | kmsKeyName?: string; 468 | /** 469 | * Map of environment variable name to its encrypted value. 470 | * 471 | * Secret environment variables must be unique across all of a build's 472 | * secrets, and must be used by at least one build step. Values can be at most 473 | * 64 KB in size. There can be at most 100 secret values across all of a 474 | * build's secrets. 475 | */ 476 | secretEnv?: {[key: string]: string}; 477 | } 478 | 479 | /** 480 | * The location of the source files to build. 481 | */ 482 | export interface Source { 483 | /** 484 | * If provided, get the source from this location in a Cloud Source 485 | * Repository. 486 | */ 487 | repoSource?: RepoSourceObject; 488 | /** 489 | * If provided, get the source from this location in Google Cloud Storage. 490 | */ 491 | storageSource?: StorageSourceObject; 492 | } 493 | 494 | /** 495 | * If provided, get the source from this location in a Cloud Source 496 | * Repository. 497 | * 498 | * Location of the source in a Google Cloud Source Repository. 499 | */ 500 | export interface RepoSourceObject { 501 | /** 502 | * Regex matching branches to build. 503 | * 504 | * The syntax of the regular expressions accepted is the syntax accepted by 505 | * RE2 and described at https://github.com/google/re2/wiki/Syntax 506 | */ 507 | branchName?: string; 508 | /** 509 | * Explicit commit SHA to build. 510 | */ 511 | commitSha?: string; 512 | /** 513 | * Directory, relative to the source root, in which to run the build. 514 | * 515 | * This must be a relative path. If a step's `dir` is specified and is an 516 | * absolute path, this value is ignored for that step's execution. 517 | */ 518 | dir?: string; 519 | /** 520 | * Only trigger a build if the revision regex does NOT match the revision 521 | * regex. 522 | */ 523 | invertRegex?: boolean; 524 | /** 525 | * ID of the project that owns the Cloud Source Repository. 526 | */ 527 | projectId?: string; 528 | /** 529 | * Name of the Cloud Source Repository. 530 | */ 531 | repoName?: string; 532 | /** 533 | * Substitutions to use in a triggered build. 534 | * Should only be used with RunBuildTrigger 535 | */ 536 | substitutions?: {[key: string]: string}; 537 | /** 538 | * Regex matching tags to build. 539 | * 540 | * The syntax of the regular expressions accepted is the syntax accepted by 541 | * RE2 and described at https://github.com/google/re2/wiki/Syntax 542 | */ 543 | tagName?: string; 544 | } 545 | 546 | /** 547 | * If provided, get the source from this location in Google Cloud Storage. 548 | * 549 | * Location of the source in an archive file in Google Cloud Storage. 550 | */ 551 | export interface StorageSourceObject { 552 | /** 553 | * Google Cloud Storage bucket containing the source (see 554 | * [Bucket Name 555 | * Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)). 556 | */ 557 | bucket?: string; 558 | /** 559 | * Google Cloud Storage generation for the object. If the generation is 560 | * omitted, the latest generation will be used. 561 | */ 562 | generation?: number; 563 | /** 564 | * Google Cloud Storage object containing the source. 565 | */ 566 | object?: string; 567 | } 568 | 569 | /** 570 | * A permanent fixed identifier for source. 571 | * 572 | * Provenance of the source. Ways to find the original source, or verify that 573 | * some source was used for this build. 574 | */ 575 | export interface SourceProvenance { 576 | /** 577 | * Hash(es) of the build source, which can be used to verify that 578 | * the original source integrity was maintained in the build. Note that 579 | * `FileHashes` will only be populated if `BuildOptions` has requested a 580 | * `SourceProvenanceHash`. 581 | * 582 | * The keys to this map are file paths used as build source and the values 583 | * contain the hash values for those files. 584 | * 585 | * If the build source came in a single package such as a gzipped tarfile 586 | * (`.tar.gz`), the `FileHash` will be for the single path to that file. 587 | */ 588 | fileHashes?: {[key: string]: FileHashes}; 589 | /** 590 | * A copy of the build's `source.repo_source`, if exists, with any 591 | * revisions resolved. 592 | */ 593 | resolvedRepoSource?: ResolvedRepoSourceObject; 594 | /** 595 | * A copy of the build's `source.storage_source`, if exists, with any 596 | * generations resolved. 597 | */ 598 | resolvedStorageSource?: ResolvedStorageSourceObject; 599 | } 600 | 601 | /** 602 | * Container message for hashes of byte content of files, used in 603 | * SourceProvenance messages to verify integrity of source input to the build. 604 | */ 605 | export interface FileHashes { 606 | /** 607 | * Collection of file hashes. 608 | */ 609 | fileHash?: Hash[]; 610 | } 611 | 612 | /** 613 | * Container message for hash values. 614 | */ 615 | export interface Hash { 616 | /** 617 | * The type of hash that was performed. 618 | */ 619 | type?: SourceProvenanceHashEnum | number; 620 | /** 621 | * The hash value. 622 | */ 623 | value?: string; 624 | } 625 | 626 | /** 627 | * A copy of the build's `source.repo_source`, if exists, with any 628 | * revisions resolved. 629 | * 630 | * If provided, get the source from this location in a Cloud Source 631 | * Repository. 632 | * 633 | * Location of the source in a Google Cloud Source Repository. 634 | */ 635 | export interface ResolvedRepoSourceObject { 636 | /** 637 | * Regex matching branches to build. 638 | * 639 | * The syntax of the regular expressions accepted is the syntax accepted by 640 | * RE2 and described at https://github.com/google/re2/wiki/Syntax 641 | */ 642 | branchName?: string; 643 | /** 644 | * Explicit commit SHA to build. 645 | */ 646 | commitSha?: string; 647 | /** 648 | * Directory, relative to the source root, in which to run the build. 649 | * 650 | * This must be a relative path. If a step's `dir` is specified and is an 651 | * absolute path, this value is ignored for that step's execution. 652 | */ 653 | dir?: string; 654 | /** 655 | * Only trigger a build if the revision regex does NOT match the revision 656 | * regex. 657 | */ 658 | invertRegex?: boolean; 659 | /** 660 | * ID of the project that owns the Cloud Source Repository. 661 | */ 662 | projectId?: string; 663 | /** 664 | * Name of the Cloud Source Repository. 665 | */ 666 | repoName?: string; 667 | /** 668 | * Substitutions to use in a triggered build. 669 | * Should only be used with RunBuildTrigger 670 | */ 671 | substitutions?: {[key: string]: string}; 672 | /** 673 | * Regex matching tags to build. 674 | * 675 | * The syntax of the regular expressions accepted is the syntax accepted by 676 | * RE2 and described at https://github.com/google/re2/wiki/Syntax 677 | */ 678 | tagName?: string; 679 | } 680 | 681 | /** 682 | * A copy of the build's `source.storage_source`, if exists, with any 683 | * generations resolved. 684 | * 685 | * If provided, get the source from this location in Google Cloud Storage. 686 | * 687 | * Location of the source in an archive file in Google Cloud Storage. 688 | */ 689 | export interface ResolvedStorageSourceObject { 690 | /** 691 | * Google Cloud Storage bucket containing the source (see 692 | * [Bucket Name 693 | * Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)). 694 | */ 695 | bucket?: string; 696 | /** 697 | * Google Cloud Storage generation for the object. If the generation is 698 | * omitted, the latest generation will be used. 699 | */ 700 | generation?: number; 701 | /** 702 | * Google Cloud Storage object containing the source. 703 | */ 704 | object?: string; 705 | } 706 | 707 | export enum StatusEnum { 708 | Cancelled = 'CANCELLED', 709 | Expired = 'EXPIRED', 710 | Failure = 'FAILURE', 711 | InternalError = 'INTERNAL_ERROR', 712 | Queued = 'QUEUED', 713 | StatusUnknown = 'STATUS_UNKNOWN', 714 | Success = 'SUCCESS', 715 | Timeout = 'TIMEOUT', 716 | Working = 'WORKING', 717 | } 718 | 719 | /** 720 | * A step in the build pipeline. 721 | */ 722 | export interface BuildStep { 723 | /** 724 | * A list of arguments that will be presented to the step when it is started. 725 | * 726 | * If the image used to run the step's container has an entrypoint, the `args` 727 | * are used as arguments to that entrypoint. If the image does not define 728 | * an entrypoint, the first element in args is used as the entrypoint, 729 | * and the remainder will be used as arguments. 730 | */ 731 | args?: string[]; 732 | /** 733 | * Working directory to use when running this step's container. 734 | * 735 | * If this value is a relative path, it is relative to the build's working 736 | * directory. If this value is absolute, it may be outside the build's working 737 | * directory, in which case the contents of the path may not be persisted 738 | * across build step executions, unless a `volume` for that path is specified. 739 | * 740 | * If the build specifies a `RepoSource` with `dir` and a step with a `dir`, 741 | * which specifies an absolute path, the `RepoSource` `dir` is ignored for 742 | * the step's execution. 743 | */ 744 | dir?: string; 745 | /** 746 | * Entrypoint to be used instead of the build step image's default entrypoint. 747 | * If unset, the image's default entrypoint is used. 748 | */ 749 | entrypoint?: string; 750 | /** 751 | * A list of environment variable definitions to be used when running a step. 752 | * 753 | * The elements are of the form "KEY=VALUE" for the environment variable "KEY" 754 | * being given the value "VALUE". 755 | */ 756 | env?: string[]; 757 | /** 758 | * Unique identifier for this build step, used in `wait_for` to 759 | * reference this build step as a dependency. 760 | */ 761 | id?: string; 762 | /** 763 | * The name of the container image that will run this particular 764 | * build step. 765 | * 766 | * If the image is available in the host's Docker daemon's cache, it 767 | * will be run directly. If not, the host will attempt to pull the image 768 | * first, using the builder service account's credentials if necessary. 769 | * 770 | * The Docker daemon's cache will already have the latest versions of all of 771 | * the officially supported build steps 772 | * 773 | * ([https://github.com/GoogleCloudPlatform/cloud-builders](https://github.com/GoogleCloudPlatform/cloud-builders)). 774 | * The Docker daemon will also have cached many of the layers for some popular 775 | * images, like "ubuntu", "debian", but they will be refreshed at the time you 776 | * attempt to use them. 777 | * 778 | * If you built an image in a previous build step, it will be stored in the 779 | * host's Docker daemon's cache and is available to use as the name for a 780 | * later build step. 781 | */ 782 | name?: string; 783 | /** 784 | * Stores timing information for pulling this build step's 785 | * builder image only. 786 | */ 787 | pullTiming?: PullTiming; 788 | /** 789 | * A list of environment variables which are encrypted using a Cloud Key 790 | * Management Service crypto key. These values must be specified in the 791 | * build's `Secret`. 792 | */ 793 | secretEnv?: string[]; 794 | /** 795 | * Status of the build step. At this time, build step status is 796 | * only updated on build completion; step status is not updated in real-time 797 | * as the build progresses. 798 | */ 799 | status?: StatusEnum | number; 800 | /** 801 | * Time limit for executing this build step. If not defined, the step has no 802 | * time limit and will be allowed to continue to run until either it completes 803 | * or the build itself times out. 804 | */ 805 | timeout?: string; 806 | /** 807 | * Stores timing information for executing this build step. 808 | */ 809 | timing?: StepTiming; 810 | /** 811 | * List of volumes to mount into the build step. 812 | * 813 | * Each volume is created as an empty volume prior to execution of the 814 | * build step. Upon completion of the build, volumes and their contents are 815 | * discarded. 816 | * 817 | * Using a named volume in only one step is not valid as it is indicative 818 | * of a build request with an incorrect configuration. 819 | */ 820 | volumes?: Volume[]; 821 | /** 822 | * The ID(s) of the step(s) that this build step depends on. 823 | * This build step will not start until all the build steps in `wait_for` 824 | * have completed successfully. If `wait_for` is empty, this build step will 825 | * start when all previous build steps in the `Build.Steps` list have 826 | * completed successfully. 827 | */ 828 | waitFor?: string[]; 829 | } 830 | 831 | /** 832 | * Stores timing information for pulling this build step's 833 | * builder image only. 834 | * 835 | * Stores timing information for pushing all artifact objects. 836 | * 837 | * Start and end times for a build execution phase. 838 | */ 839 | export interface PullTiming { 840 | /** 841 | * End of time span. 842 | */ 843 | endTime?: Date | string; 844 | /** 845 | * Start of time span. 846 | */ 847 | startTime?: Date | string; 848 | } 849 | 850 | /** 851 | * Stores timing information for executing this build step. 852 | * 853 | * Stores timing information for pushing all artifact objects. 854 | * 855 | * Start and end times for a build execution phase. 856 | */ 857 | export interface StepTiming { 858 | /** 859 | * End of time span. 860 | */ 861 | endTime?: Date | string; 862 | /** 863 | * Start of time span. 864 | */ 865 | startTime?: Date | string; 866 | } 867 | 868 | /** 869 | * Stores timing information for pushing all artifact objects. 870 | * 871 | * Start and end times for a build execution phase. 872 | */ 873 | export interface TimeSpan { 874 | /** 875 | * End of time span. 876 | */ 877 | endTime?: Date | string; 878 | /** 879 | * Start of time span. 880 | */ 881 | startTime?: Date | string; 882 | } 883 | 884 | /** 885 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 886 | * @param {object} json The JSON object 887 | * @return {BuildEventData} The object with type annotations 888 | */ 889 | export const toBuildEventData = (json: object) => { 890 | return json as BuildEventData; 891 | }; 892 | -------------------------------------------------------------------------------- /cloud/firestore/v1/DocumentEventData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The data within all Firestore document events. 19 | */ 20 | export interface DocumentEventData { 21 | /** 22 | * A Document object containing a pre-operation document snapshot. 23 | * This is only populated for update and delete events. 24 | */ 25 | oldValue?: OldValue; 26 | /** 27 | * A DocumentMask object that lists changed fields. 28 | * This is only populated for update events. 29 | */ 30 | updateMask?: Mask; 31 | /** 32 | * A Document object containing a post-operation document snapshot. 33 | * This is not populated for delete events. 34 | */ 35 | value?: Value; 36 | } 37 | 38 | /** 39 | * A Document object containing a pre-operation document snapshot. 40 | * This is only populated for update and delete events. 41 | * 42 | * A Firestore document. 43 | */ 44 | export interface OldValue { 45 | /** 46 | * The time at which the document was created. 47 | * 48 | * This value increases monotonically when a document is deleted then 49 | * recreated. It can also be compared to values from other documents and 50 | * the `read_time` of a query. 51 | */ 52 | createTime?: Date | string; 53 | /** 54 | * The document's fields. 55 | * 56 | * The map keys represent field names. 57 | * 58 | * A simple field name contains only characters `a` to `z`, `A` to `Z`, 59 | * `0` to `9`, or `_`, and must not start with `0` to `9`. For example, 60 | * `foo_bar_17`. 61 | * 62 | * Field names matching the regular expression `__.*__` are reserved. Reserved 63 | * field names are forbidden except in certain documented contexts. The map 64 | * keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be 65 | * empty. 66 | * 67 | * Field paths may be used in other contexts to refer to structured fields 68 | * defined here. For `map_value`, the field path is represented by the simple 69 | * or quoted field names of the containing fields, delimited by `.`. For 70 | * example, the structured field 71 | * `"foo" : { map_value: { "x&y" : { string_value: "hello" }}}` would be 72 | * represented by the field path `foo.x&y`. 73 | * 74 | * Within a field path, a quoted field name starts and ends with `` ` `` and 75 | * may contain any character. Some characters, including `` ` ``, must be 76 | * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and 77 | * `` `bak\`tik` `` represents `` bak`tik ``. 78 | */ 79 | fields?: {[key: string]: OldValueField}; 80 | /** 81 | * The resource name of the document. For example: 82 | * `projects/{project_id}/databases/{database_id}/documents/{document_path}` 83 | */ 84 | name?: string; 85 | /** 86 | * The time at which the document was last changed. 87 | * 88 | * This value is initially set to the `create_time` then increases 89 | * monotonically with each change to the document. It can also be 90 | * compared to values from other documents and the `read_time` of a query. 91 | */ 92 | updateTime?: Date | string; 93 | } 94 | 95 | /** 96 | * A message that can hold any of the supported value types. 97 | */ 98 | export interface OldValueField { 99 | /** 100 | * An array value. 101 | * 102 | * Cannot directly contain another array value, though can contain an 103 | * map which contains another array. 104 | */ 105 | arrayValue?: ArrayValue; 106 | /** 107 | * A boolean value. 108 | */ 109 | booleanValue?: boolean; 110 | /** 111 | * A bytes value. 112 | * 113 | * Must not exceed 1 MiB - 89 bytes. 114 | * Only the first 1,500 bytes are considered by queries. 115 | */ 116 | bytesValue?: string; 117 | /** 118 | * A double value. 119 | */ 120 | doubleValue?: number; 121 | /** 122 | * A geo point value representing a point on the surface of Earth. 123 | */ 124 | geoPointValue?: GeoPointValue; 125 | /** 126 | * An integer value. 127 | */ 128 | integerValue?: number; 129 | /** 130 | * A map value. 131 | */ 132 | mapValue?: MapValue; 133 | /** 134 | * A null value. 135 | */ 136 | nullValue?: BytesValue | number; 137 | /** 138 | * A reference to a document. For example: 139 | * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. 140 | */ 141 | referenceValue?: string; 142 | /** 143 | * A string value. 144 | * 145 | * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. 146 | * Only the first 1,500 bytes of the UTF-8 representation are considered by 147 | * queries. 148 | */ 149 | stringValue?: string; 150 | /** 151 | * A timestamp value. 152 | * 153 | * Precise only to microseconds. When stored, any additional precision is 154 | * rounded down. 155 | */ 156 | timestampValue?: Date | string; 157 | } 158 | 159 | /** 160 | * A message that can hold any of the supported value types. 161 | */ 162 | export interface MapValueField { 163 | /** 164 | * An array value. 165 | * 166 | * Cannot directly contain another array value, though can contain an 167 | * map which contains another array. 168 | */ 169 | arrayValue?: ArrayValue; 170 | /** 171 | * A boolean value. 172 | */ 173 | booleanValue?: boolean; 174 | /** 175 | * A bytes value. 176 | * 177 | * Must not exceed 1 MiB - 89 bytes. 178 | * Only the first 1,500 bytes are considered by queries. 179 | */ 180 | bytesValue?: string; 181 | /** 182 | * A double value. 183 | */ 184 | doubleValue?: number; 185 | /** 186 | * A geo point value representing a point on the surface of Earth. 187 | */ 188 | geoPointValue?: GeoPointValue; 189 | /** 190 | * An integer value. 191 | */ 192 | integerValue?: number; 193 | /** 194 | * A map value. 195 | */ 196 | mapValue?: MapValue; 197 | /** 198 | * A null value. 199 | */ 200 | nullValue?: BytesValue | number; 201 | /** 202 | * A reference to a document. For example: 203 | * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. 204 | */ 205 | referenceValue?: string; 206 | /** 207 | * A string value. 208 | * 209 | * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. 210 | * Only the first 1,500 bytes of the UTF-8 representation are considered by 211 | * queries. 212 | */ 213 | stringValue?: string; 214 | /** 215 | * A timestamp value. 216 | * 217 | * Precise only to microseconds. When stored, any additional precision is 218 | * rounded down. 219 | */ 220 | timestampValue?: Date | string; 221 | } 222 | 223 | /** 224 | * A map value. 225 | */ 226 | export interface MapValue { 227 | /** 228 | * The map's fields. 229 | * 230 | * The map keys represent field names. Field names matching the regular 231 | * expression `__.*__` are reserved. Reserved field names are forbidden except 232 | * in certain documented contexts. The map keys, represented as UTF-8, must 233 | * not exceed 1,500 bytes and cannot be empty. 234 | */ 235 | fields?: {[key: string]: MapValueField}; 236 | } 237 | 238 | /** 239 | * A message that can hold any of the supported value types. 240 | */ 241 | export interface ValueElement { 242 | /** 243 | * An array value. 244 | * 245 | * Cannot directly contain another array value, though can contain an 246 | * map which contains another array. 247 | */ 248 | arrayValue?: ArrayValue; 249 | /** 250 | * A boolean value. 251 | */ 252 | booleanValue?: boolean; 253 | /** 254 | * A bytes value. 255 | * 256 | * Must not exceed 1 MiB - 89 bytes. 257 | * Only the first 1,500 bytes are considered by queries. 258 | */ 259 | bytesValue?: string; 260 | /** 261 | * A double value. 262 | */ 263 | doubleValue?: number; 264 | /** 265 | * A geo point value representing a point on the surface of Earth. 266 | */ 267 | geoPointValue?: GeoPointValue; 268 | /** 269 | * An integer value. 270 | */ 271 | integerValue?: number; 272 | /** 273 | * A map value. 274 | */ 275 | mapValue?: MapValue; 276 | /** 277 | * A null value. 278 | */ 279 | nullValue?: BytesValue | number; 280 | /** 281 | * A reference to a document. For example: 282 | * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. 283 | */ 284 | referenceValue?: string; 285 | /** 286 | * A string value. 287 | * 288 | * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. 289 | * Only the first 1,500 bytes of the UTF-8 representation are considered by 290 | * queries. 291 | */ 292 | stringValue?: string; 293 | /** 294 | * A timestamp value. 295 | * 296 | * Precise only to microseconds. When stored, any additional precision is 297 | * rounded down. 298 | */ 299 | timestampValue?: Date | string; 300 | } 301 | 302 | /** 303 | * An array value. 304 | * 305 | * Cannot directly contain another array value, though can contain an 306 | * map which contains another array. 307 | * 308 | * An array value. 309 | */ 310 | export interface ArrayValue { 311 | /** 312 | * Values in the array. 313 | */ 314 | values?: ValueElement[]; 315 | } 316 | 317 | /** 318 | * A geo point value representing a point on the surface of Earth. 319 | * 320 | * An object representing a latitude/longitude pair. This is expressed as a pair 321 | * of doubles representing degrees latitude and degrees longitude. Unless 322 | * specified otherwise, this must conform to the 323 | * WGS84 324 | * standard. Values must be within normalized ranges. 325 | */ 326 | export interface GeoPointValue { 327 | /** 328 | * The latitude in degrees. It must be in the range [-90.0, +90.0]. 329 | */ 330 | latitude?: number; 331 | /** 332 | * The longitude in degrees. It must be in the range [-180.0, +180.0]. 333 | */ 334 | longitude?: number; 335 | } 336 | 337 | export enum BytesValue { 338 | NullValue = 'NULL_VALUE', 339 | } 340 | 341 | /** 342 | * A DocumentMask object that lists changed fields. 343 | * This is only populated for update events. 344 | * 345 | * A set of field paths on a document. 346 | */ 347 | export interface Mask { 348 | /** 349 | * The list of field paths in the mask. 350 | * See [Document.fields][google.cloud.firestore.v1.events.Document.fields] 351 | * for a field path syntax reference. 352 | */ 353 | fieldPaths?: string[]; 354 | } 355 | 356 | /** 357 | * A Document object containing a post-operation document snapshot. 358 | * This is not populated for delete events. 359 | * 360 | * A Document object containing a pre-operation document snapshot. 361 | * This is only populated for update and delete events. 362 | * 363 | * A Firestore document. 364 | */ 365 | export interface Value { 366 | /** 367 | * The time at which the document was created. 368 | * 369 | * This value increases monotonically when a document is deleted then 370 | * recreated. It can also be compared to values from other documents and 371 | * the `read_time` of a query. 372 | */ 373 | createTime?: Date | string; 374 | /** 375 | * The document's fields. 376 | * 377 | * The map keys represent field names. 378 | * 379 | * A simple field name contains only characters `a` to `z`, `A` to `Z`, 380 | * `0` to `9`, or `_`, and must not start with `0` to `9`. For example, 381 | * `foo_bar_17`. 382 | * 383 | * Field names matching the regular expression `__.*__` are reserved. Reserved 384 | * field names are forbidden except in certain documented contexts. The map 385 | * keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be 386 | * empty. 387 | * 388 | * Field paths may be used in other contexts to refer to structured fields 389 | * defined here. For `map_value`, the field path is represented by the simple 390 | * or quoted field names of the containing fields, delimited by `.`. For 391 | * example, the structured field 392 | * `"foo" : { map_value: { "x&y" : { string_value: "hello" }}}` would be 393 | * represented by the field path `foo.x&y`. 394 | * 395 | * Within a field path, a quoted field name starts and ends with `` ` `` and 396 | * may contain any character. Some characters, including `` ` ``, must be 397 | * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and 398 | * `` `bak\`tik` `` represents `` bak`tik ``. 399 | */ 400 | fields?: {[key: string]: OldValueField}; 401 | /** 402 | * The resource name of the document. For example: 403 | * `projects/{project_id}/databases/{database_id}/documents/{document_path}` 404 | */ 405 | name?: string; 406 | /** 407 | * The time at which the document was last changed. 408 | * 409 | * This value is initially set to the `create_time` then increases 410 | * monotonically with each change to the document. It can also be 411 | * compared to values from other documents and the `read_time` of a query. 412 | */ 413 | updateTime?: Date | string; 414 | } 415 | 416 | /** 417 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 418 | * @param {object} json The JSON object 419 | * @return {DocumentEventData} The object with type annotations 420 | */ 421 | export const toDocumentEventData = (json: object) => { 422 | return json as DocumentEventData; 423 | }; 424 | -------------------------------------------------------------------------------- /cloud/pubsub/v1/MessagePublishedData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The event data when a message is published to a topic. 19 | */ 20 | export interface MessagePublishedData { 21 | /** 22 | * The message that was published. 23 | */ 24 | message?: Message; 25 | /** 26 | * The resource name of the subscription for which this event was 27 | * generated. The format of the value is 28 | * `projects/{project-id}/subscriptions/{subscription-id}`. 29 | */ 30 | subscription?: string; 31 | } 32 | 33 | /** 34 | * The message that was published. 35 | * 36 | * A message published to a topic. 37 | */ 38 | export interface Message { 39 | /** 40 | * Attributes for this message. 41 | */ 42 | attributes?: {[key: string]: string}; 43 | /** 44 | * The binary data in the message. 45 | */ 46 | data?: string; 47 | /** 48 | * ID of this message, assigned by the server when the message is published. 49 | * Guaranteed to be unique within the topic. 50 | */ 51 | messageId?: string; 52 | /** 53 | * If non-empty, identifies related messages for which publish order should be 54 | * respected. 55 | */ 56 | orderingKey?: string; 57 | /** 58 | * The time at which the message was published, populated by the server when 59 | * it receives the `Publish` call. 60 | */ 61 | publishTime?: Date | string; 62 | } 63 | 64 | /** 65 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 66 | * @param {object} json The JSON object 67 | * @return {MessagePublishedData} The object with type annotations 68 | */ 69 | export const toMessagePublishedData = (json: object) => { 70 | return json as MessagePublishedData; 71 | }; 72 | -------------------------------------------------------------------------------- /cloud/scheduler/v1/SchedulerJobData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Scheduler job data. 19 | */ 20 | export interface SchedulerJobData { 21 | /** 22 | * The custom data the user specified when creating the scheduler source. 23 | */ 24 | customData?: string; 25 | } 26 | 27 | /** 28 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 29 | * @param {object} json The JSON object 30 | * @return {SchedulerJobData} The object with type annotations 31 | */ 32 | export const toSchedulerJobData = (json: object) => { 33 | return json as SchedulerJobData; 34 | }; 35 | -------------------------------------------------------------------------------- /cloud/storage/v1/StorageObjectData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * An object within Google Cloud Storage. 19 | */ 20 | export interface StorageObjectData { 21 | /** 22 | * The name of the bucket containing this object. 23 | */ 24 | bucket?: string; 25 | /** 26 | * Cache-Control directive for the object data, matching 27 | * [https://tools.ietf.org/html/rfc7234#section-5.2"][RFC 7234 §5.2]. 28 | */ 29 | cacheControl?: string; 30 | /** 31 | * Number of underlying components that make up this object. Components are 32 | * accumulated by compose operations. 33 | * Attempting to set this field will result in an error. 34 | */ 35 | componentCount?: number; 36 | /** 37 | * Content-Disposition of the object data, matching 38 | * [https://tools.ietf.org/html/rfc6266][RFC 6266]. 39 | */ 40 | contentDisposition?: string; 41 | /** 42 | * Content-Encoding of the object data, matching 43 | * [https://tools.ietf.org/html/rfc7231#section-3.1.2.2][RFC 7231 §3.1.2.2] 44 | */ 45 | contentEncoding?: string; 46 | /** 47 | * Content-Language of the object data, matching 48 | * [https://tools.ietf.org/html/rfc7231#section-3.1.3.2][RFC 7231 §3.1.3.2]. 49 | */ 50 | contentLanguage?: string; 51 | /** 52 | * Content-Type of the object data, matching 53 | * [https://tools.ietf.org/html/rfc7231#section-3.1.1.5][RFC 7231 §3.1.1.5]. 54 | * If an object is stored without a Content-Type, it is served as 55 | * `application/octet-stream`. 56 | */ 57 | contentType?: string; 58 | /** 59 | * CRC32c checksum. For more information about using the CRC32c 60 | * checksum, see 61 | * [https://cloud.google.com/storage/docs/hashes-etags#_JSONAPI][Hashes and 62 | * ETags: Best Practices]. 63 | */ 64 | crc32c?: string; 65 | /** 66 | * Metadata of customer-supplied encryption key, if the object is encrypted by 67 | * such a key. 68 | */ 69 | customerEncryption?: CustomerEncryption; 70 | /** 71 | * HTTP 1.1 Entity tag for the object. See 72 | * [https://tools.ietf.org/html/rfc7232#section-2.3][RFC 7232 §2.3]. 73 | */ 74 | etag?: string; 75 | /** 76 | * Whether an object is under event-based hold. 77 | */ 78 | eventBasedHold?: boolean; 79 | /** 80 | * The content generation of this object. Used for object versioning. 81 | * Attempting to set this field will result in an error. 82 | */ 83 | generation?: number; 84 | /** 85 | * The ID of the object, including the bucket name, object name, and 86 | * generation number. 87 | */ 88 | id?: string; 89 | /** 90 | * The kind of item this is. For objects, this is always "storage#object". 91 | */ 92 | kind?: string; 93 | /** 94 | * Cloud KMS Key used to encrypt this object, if the object is encrypted by 95 | * such a key. 96 | */ 97 | kmsKeyName?: string; 98 | /** 99 | * MD5 hash of the data; encoded using base64 as per 100 | * [https://tools.ietf.org/html/rfc4648#section-4][RFC 4648 §4]. For more 101 | * information about using the MD5 hash, see 102 | * [https://cloud.google.com/storage/docs/hashes-etags#_JSONAPI][Hashes and 103 | * ETags: Best Practices]. 104 | */ 105 | md5Hash?: string; 106 | /** 107 | * Media download link. 108 | */ 109 | mediaLink?: string; 110 | /** 111 | * User-provided metadata, in key/value pairs. 112 | */ 113 | metadata?: {[key: string]: string}; 114 | /** 115 | * The version of the metadata for this object at this generation. Used for 116 | * preconditions and for detecting changes in metadata. A metageneration 117 | * number is only meaningful in the context of a particular generation of a 118 | * particular object. 119 | */ 120 | metageneration?: number; 121 | /** 122 | * The name of the object. 123 | */ 124 | name?: string; 125 | /** 126 | * A server-determined value that specifies the earliest time that the 127 | * object's retention period expires. 128 | */ 129 | retentionExpirationTime?: Date | string; 130 | /** 131 | * The link to this object. 132 | */ 133 | selfLink?: string; 134 | /** 135 | * Content-Length of the object data in bytes, matching 136 | * [https://tools.ietf.org/html/rfc7230#section-3.3.2][RFC 7230 §3.3.2]. 137 | */ 138 | size?: number; 139 | /** 140 | * Storage class of the object. 141 | */ 142 | storageClass?: string; 143 | /** 144 | * Whether an object is under temporary hold. 145 | */ 146 | temporaryHold?: boolean; 147 | /** 148 | * The creation time of the object. 149 | * Attempting to set this field will result in an error. 150 | */ 151 | timeCreated?: Date | string; 152 | /** 153 | * The deletion time of the object. Will be returned if and only if this 154 | * version of the object has been deleted. 155 | */ 156 | timeDeleted?: Date | string; 157 | /** 158 | * The time at which the object's storage class was last changed. 159 | */ 160 | timeStorageClassUpdated?: Date | string; 161 | /** 162 | * The modification time of the object metadata. 163 | */ 164 | updated?: Date | string; 165 | } 166 | 167 | /** 168 | * Metadata of customer-supplied encryption key, if the object is encrypted by 169 | * such a key. 170 | * 171 | * Describes the customer-specified mechanism used to store the data at rest. 172 | */ 173 | export interface CustomerEncryption { 174 | /** 175 | * The encryption algorithm. 176 | */ 177 | encryptionAlgorithm?: string; 178 | /** 179 | * SHA256 hash value of the encryption key. 180 | */ 181 | keySha256?: string; 182 | } 183 | 184 | /** 185 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 186 | * @param {object} json The JSON object 187 | * @return {StorageObjectData} The object with type annotations 188 | */ 189 | export const toStorageObjectData = (json: object) => { 190 | return json as StorageObjectData; 191 | }; 192 | -------------------------------------------------------------------------------- /examples/javascript.js: -------------------------------------------------------------------------------- 1 | const { 2 | toMessagePublishedData, 3 | } = require('@google/events/cloud/pubsub/v1/MessagePublishedData'); 4 | 5 | /** 6 | * A Pub/Sub message as an object, for example what you'd see from a POST request. 7 | */ 8 | const obj = { 9 | message: { 10 | data: Buffer.from('Pub/Sub data').toString('base64'), 11 | messageId: 'my-message-id', 12 | publishTime: '2020-08-14T20:50:04.994Z', 13 | }, 14 | subscription: 15 | 'projects/my-project/subscriptions/cre-us-central1-pubsub-trigger-5-sub-000', 16 | }; 17 | 18 | const jsExample = toMessagePublishedData(obj); 19 | console.log(jsExample.message.data); 20 | -------------------------------------------------------------------------------- /examples/typescript.ts: -------------------------------------------------------------------------------- 1 | import {MessagePublishedData} from '@google/events/cloud/pubsub/v1/MessagePublishedData'; 2 | 3 | /** 4 | * A Pub/Sub message as an object, for example what you'd see from a POST request. 5 | */ 6 | const obj = { 7 | message: { 8 | data: Buffer.from('Pub/Sub data').toString('base64'), 9 | messageId: 'my-message-id', 10 | publishTime: '2020-08-14T20:50:04.994Z', 11 | }, 12 | subscription: 13 | 'projects/my-project/subscriptions/cre-us-central1-pubsub-trigger-5-sub-000', 14 | }; 15 | 16 | const tsExample: MessagePublishedData = obj; 17 | console.log(tsExample.message.data); 18 | -------------------------------------------------------------------------------- /firebase/analytics/v1/AnalyticsLogData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The data within Firebase Analytics log events. 19 | */ 20 | export interface AnalyticsLogData { 21 | /** 22 | * A repeated record of event related dimensions. 23 | */ 24 | eventDim?: EventDimensions[]; 25 | /** 26 | * User related dimensions. 27 | */ 28 | userDim?: UserDim; 29 | } 30 | 31 | /** 32 | * Message containing information pertaining to the event. 33 | */ 34 | export interface EventDimensions { 35 | /** 36 | * The date on which this event was logged. 37 | * (YYYYMMDD format in the registered timezone of your app.) 38 | */ 39 | date?: string; 40 | /** 41 | * The name of this event. 42 | */ 43 | name?: string; 44 | /** 45 | * A repeated record of the parameters associated with this event. 46 | */ 47 | params?: {[key: string]: AnalyticsValue}; 48 | /** 49 | * UTC client time when the previous event happened. 50 | */ 51 | previousTimestampMicros?: number; 52 | /** 53 | * UTC client time when the event happened. 54 | */ 55 | timestampMicros?: number; 56 | /** 57 | * Value param in USD. 58 | */ 59 | valueInUsd?: number; 60 | } 61 | 62 | /** 63 | * Value for Event Params and UserProperty can be of type string or int or 64 | * float or double. 65 | */ 66 | export interface AnalyticsValue { 67 | doubleValue?: number; 68 | floatValue?: number; 69 | intValue?: number; 70 | stringValue?: string; 71 | } 72 | 73 | /** 74 | * User related dimensions. 75 | * 76 | * Message containing information about the user associated with the event. 77 | */ 78 | export interface UserDim { 79 | /** 80 | * App information. 81 | */ 82 | appInfo?: AppInfo; 83 | /** 84 | * Information regarding the bundle in which these events were uploaded. 85 | */ 86 | bundleInfo?: BundleInfo; 87 | /** 88 | * Device information. 89 | */ 90 | deviceInfo?: DeviceInfo; 91 | /** 92 | * The time (in microseconds) at which the user first opened the app. 93 | */ 94 | firstOpenTimestampMicros?: number; 95 | /** 96 | * User's geographic information. 97 | */ 98 | geoInfo?: GeoInfo; 99 | /** 100 | * Lifetime Value information about this user. 101 | */ 102 | ltvInfo?: LtvInfo; 103 | /** 104 | * Information about marketing campaign which acquired the user. 105 | */ 106 | trafficSource?: TrafficSource; 107 | /** 108 | * The user ID set via the setUserId API. 109 | */ 110 | userId?: string; 111 | /** 112 | * A repeated record of user properties set with the setUserProperty API. 113 | * https://firebase.google.com/docs/analytics/android/properties 114 | */ 115 | userProperties?: {[key: string]: UserPropertyValue}; 116 | } 117 | 118 | /** 119 | * App information. 120 | * 121 | * Message which contains App Information. 122 | */ 123 | export interface AppInfo { 124 | /** 125 | * Unique application identifier within an app store. 126 | */ 127 | appId?: string; 128 | /** 129 | * Unique id for this instance of the app. 130 | * Example: "71683BF9FA3B4B0D9535A1F05188BAF3" 131 | */ 132 | appInstanceId?: string; 133 | /** 134 | * The app platform. 135 | * Eg "ANDROID", "IOS". 136 | */ 137 | appPlatform?: string; 138 | /** 139 | * The identifier of the store that installed the app. 140 | * Eg. "com.sec.android.app.samsungapps", "com.amazon.venezia", 141 | * "com.nokia.nstore" 142 | */ 143 | appStore?: string; 144 | /** 145 | * The app's version name 146 | * Examples: "1.0", "4.3.1.1.213361", "2.3 (1824253)", "v1.8b22p6" 147 | */ 148 | appVersion?: string; 149 | } 150 | 151 | /** 152 | * Information regarding the bundle in which these events were uploaded. 153 | * 154 | * Message containing information regarding the bundle in which these 155 | * events were uploaded. 156 | */ 157 | export interface BundleInfo { 158 | /** 159 | * Monotonically increasing index for each bundle set by SDK. 160 | */ 161 | bundleSequenceId?: number; 162 | /** 163 | * Timestamp offset between collection time and upload time. 164 | */ 165 | serverTimestampOffsetMicros?: number; 166 | } 167 | 168 | /** 169 | * Device information. 170 | * 171 | * Message containing device informations. 172 | */ 173 | export interface DeviceInfo { 174 | /** 175 | * Device category. 176 | * Eg. tablet or mobile. 177 | */ 178 | deviceCategory?: string; 179 | /** 180 | * Vendor specific device identifier. This is IDFV on iOS. Not used for 181 | * Android. 182 | * Example: "599F9C00-92DC-4B5C-9464-7971F01F8370" 183 | */ 184 | deviceId?: string; 185 | /** 186 | * Device model. 187 | * Eg. GT-I9192 188 | */ 189 | deviceModel?: string; 190 | /** 191 | * The timezone of the device when data was uploaded as seconds skew from UTC. 192 | */ 193 | deviceTimeZoneOffsetSeconds?: number; 194 | /** 195 | * The device's Limit Ad Tracking setting. 196 | * When true, we cannot use device_id for remarketing, demographics or 197 | * influencing ads serving behaviour. However, we can use device_id for 198 | * conversion tracking and campaign attribution. 199 | */ 200 | limitedAdTracking?: boolean; 201 | /** 202 | * Device brand name. 203 | * Eg. Samsung, HTC, etc. 204 | */ 205 | mobileBrandName?: string; 206 | /** 207 | * Device marketing name. 208 | * Eg. Galaxy S4 Mini 209 | */ 210 | mobileMarketingName?: string; 211 | /** 212 | * Device model name. 213 | * Eg. GT-I9192 214 | */ 215 | mobileModelName?: string; 216 | /** 217 | * Device OS version when data capture ended. 218 | * Eg. 4.4.2 219 | */ 220 | platformVersion?: string; 221 | /** 222 | * The type of the resettable_device_id is always IDFA on iOS and AdId 223 | * on Android. 224 | * Example: "71683BF9-FA3B-4B0D-9535-A1F05188BAF3" 225 | */ 226 | resettableDeviceId?: string; 227 | /** 228 | * The user language. 229 | * Eg. "en-us", "en-za", "zh-tw", "jp" 230 | */ 231 | userDefaultLanguage?: string; 232 | } 233 | 234 | /** 235 | * User's geographic information. 236 | * 237 | * User's geographic informaiton. 238 | */ 239 | export interface GeoInfo { 240 | /** 241 | * The geographic city. 242 | * Eg. Sao Paulo 243 | */ 244 | city?: string; 245 | /** 246 | * The geographic continent. 247 | * Eg. Americas 248 | */ 249 | continent?: string; 250 | /** 251 | * The geographic country. 252 | * Eg. Brazil 253 | */ 254 | country?: string; 255 | /** 256 | * The geographic region. 257 | * Eg. State of Sao Paulo 258 | */ 259 | region?: string; 260 | } 261 | 262 | /** 263 | * Lifetime Value information about this user. 264 | */ 265 | export interface LtvInfo { 266 | /** 267 | * The currency corresponding to the revenue. 268 | */ 269 | currency?: string; 270 | /** 271 | * The Lifetime Value revenue of this user. 272 | */ 273 | revenue?: number; 274 | } 275 | 276 | /** 277 | * Information about marketing campaign which acquired the user. 278 | * 279 | * Mesage containing marketing campaign information which acquired the user. 280 | */ 281 | export interface TrafficSource { 282 | /** 283 | * The name of the campaign which acquired the user. 284 | */ 285 | userAcquiredCampaign?: string; 286 | /** 287 | * The name of the medium which acquired the user. 288 | */ 289 | userAcquiredMedium?: string; 290 | /** 291 | * The name of the network which acquired the user. 292 | */ 293 | userAcquiredSource?: string; 294 | } 295 | 296 | /** 297 | * Predefined (eg: LTV) or custom properties (eg: birthday) stored on client 298 | * side and associated with subsequent HitBundles. 299 | */ 300 | export interface UserPropertyValue { 301 | /** 302 | * Index for user property (one-based). 303 | */ 304 | index?: number; 305 | /** 306 | * UTC client time when user property was last set. 307 | */ 308 | setTimestampUsec?: number; 309 | /** 310 | * Last set value of user property. 311 | */ 312 | value?: Value; 313 | } 314 | 315 | /** 316 | * Last set value of user property. 317 | * 318 | * Value for Event Params and UserProperty can be of type string or int or 319 | * float or double. 320 | */ 321 | export interface Value { 322 | doubleValue?: number; 323 | floatValue?: number; 324 | intValue?: number; 325 | stringValue?: string; 326 | } 327 | 328 | /** 329 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 330 | * @param {object} json The JSON object 331 | * @return {AnalyticsLogData} The object with type annotations 332 | */ 333 | export const toAnalyticsLogData = (json: object) => { 334 | return json as AnalyticsLogData; 335 | }; 336 | -------------------------------------------------------------------------------- /firebase/auth/v1/AuthEventData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The data within all Firebase Auth events. 19 | */ 20 | export interface AuthEventData { 21 | /** 22 | * User's custom claims, typically used to define user roles and propagated 23 | * to an authenticated user's ID token. 24 | */ 25 | customClaims?: {[key: string]: any}; 26 | /** 27 | * Whether the user is disabled. 28 | */ 29 | disabled?: boolean; 30 | /** 31 | * The user's display name. 32 | */ 33 | displayName?: string; 34 | /** 35 | * The user's primary email, if set. 36 | */ 37 | email?: string; 38 | /** 39 | * Whether or not the user's primary email is verified. 40 | */ 41 | emailVerified?: boolean; 42 | /** 43 | * Additional metadata about the user. 44 | */ 45 | metadata?: Metadata; 46 | /** 47 | * The user's phone number. 48 | */ 49 | phoneNumber?: string; 50 | /** 51 | * The user's photo URL. 52 | */ 53 | photoURL?: string; 54 | /** 55 | * User's info at the providers 56 | */ 57 | providerData?: UserInfo[]; 58 | /** 59 | * The user identifier in the Firebase app. 60 | */ 61 | uid?: string; 62 | } 63 | 64 | /** 65 | * Additional metadata about the user. 66 | */ 67 | export interface Metadata { 68 | /** 69 | * The date the user was created. 70 | */ 71 | createTime?: Date | string; 72 | /** 73 | * The date the user last signed in. 74 | */ 75 | lastSignInTime?: Date | string; 76 | } 77 | 78 | /** 79 | * User's info at the identity provider 80 | */ 81 | export interface UserInfo { 82 | /** 83 | * The display name for the linked provider. 84 | */ 85 | displayName?: string; 86 | /** 87 | * The email for the linked provider. 88 | */ 89 | email?: string; 90 | /** 91 | * The photo URL for the linked provider. 92 | */ 93 | photoURL?: string; 94 | /** 95 | * The linked provider ID (e.g. "google.com" for the Google provider). 96 | */ 97 | providerId?: string; 98 | /** 99 | * The user identifier for the linked provider. 100 | */ 101 | uid?: string; 102 | } 103 | 104 | /** 105 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 106 | * @param {object} json The JSON object 107 | * @return {AuthEventData} The object with type annotations 108 | */ 109 | export const toAuthEventData = (json: object) => { 110 | return json as AuthEventData; 111 | }; 112 | -------------------------------------------------------------------------------- /firebase/database/v1/ReferenceEventData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The data within all Firebase Real Time Database reference events. 19 | */ 20 | export interface ReferenceEventData { 21 | /** 22 | * `Value` represents a dynamically typed value which can be either 23 | * null, a number, a string, a boolean, a recursive struct value, or a 24 | * list of values. A producer of value is expected to set one of that 25 | * variants, absence of any variant indicates an error. 26 | * 27 | * The JSON representation for `Value` is JSON value. 28 | */ 29 | data?: any[] | boolean | number | {[key: string]: any} | string; 30 | /** 31 | * `Value` represents a dynamically typed value which can be either 32 | * null, a number, a string, a boolean, a recursive struct value, or a 33 | * list of values. A producer of value is expected to set one of that 34 | * variants, absence of any variant indicates an error. 35 | * 36 | * The JSON representation for `Value` is JSON value. 37 | */ 38 | delta?: any[] | boolean | number | {[key: string]: any} | string; 39 | } 40 | 41 | /** 42 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 43 | * @param {object} json The JSON object 44 | * @return {ReferenceEventData} The object with type annotations 45 | */ 46 | export const toReferenceEventData = (json: object) => { 47 | return json as ReferenceEventData; 48 | }; 49 | -------------------------------------------------------------------------------- /firebase/firebasealerts/v1/AlertData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The data within all Firebase Alerts. 19 | */ 20 | export interface AlertData { 21 | /** 22 | * Time that the event has created 23 | */ 24 | createTime?: Date | string; 25 | /** 26 | * Time that the event has ended. Optional, only present for alertsthat are 27 | * ongoing 28 | */ 29 | endTime?: Date | string; 30 | /** 31 | * Payload of the event, which includes the details of the specific alert. 32 | * It's a map of keys of String type and values of various types 33 | */ 34 | payload?: {[key: string]: any}; 35 | } 36 | 37 | /** 38 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 39 | * @param {object} json The JSON object 40 | * @return {AlertData} The object with type annotations 41 | */ 42 | export const toAlertData = (json: object) => { 43 | return json as AlertData; 44 | }; 45 | -------------------------------------------------------------------------------- /firebase/remoteconfig/v1/RemoteConfigEventData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The data within all Firebase Remote Config events. 19 | */ 20 | export interface RemoteConfigEventData { 21 | /** 22 | * The user-provided description of the corresponding Remote Config template. 23 | */ 24 | description?: string; 25 | /** 26 | * Only present if this version is the result of a rollback, and will be the 27 | * version number of the Remote Config template that was rolled-back to. 28 | */ 29 | rollbackSource?: number; 30 | /** 31 | * Where the update action originated. 32 | */ 33 | updateOrigin?: UpdateOriginEnum | number; 34 | /** 35 | * When the Remote Config template was written to the Remote Config server. 36 | */ 37 | updateTime?: Date | string; 38 | /** 39 | * What type of update was made. 40 | */ 41 | updateType?: UpdateTypeEnum | number; 42 | /** 43 | * Aggregation of all metadata fields about the account that performed the 44 | * update. 45 | */ 46 | updateUser?: User; 47 | /** 48 | * The version number of the version's corresponding Remote Config template. 49 | */ 50 | versionNumber?: number; 51 | } 52 | 53 | export enum UpdateOriginEnum { 54 | AdminSDKNode = 'ADMIN_SDK_NODE', 55 | Console = 'CONSOLE', 56 | RESTAPI = 'REST_API', 57 | RemoteConfigUpdateOriginUnspecified = 'REMOTE_CONFIG_UPDATE_ORIGIN_UNSPECIFIED', 58 | } 59 | 60 | export enum UpdateTypeEnum { 61 | ForcedUpdate = 'FORCED_UPDATE', 62 | IncrementalUpdate = 'INCREMENTAL_UPDATE', 63 | RemoteConfigUpdateTypeUnspecified = 'REMOTE_CONFIG_UPDATE_TYPE_UNSPECIFIED', 64 | Rollback = 'ROLLBACK', 65 | } 66 | 67 | /** 68 | * Aggregation of all metadata fields about the account that performed the 69 | * update. 70 | * 71 | * All the fields associated with the person/service account 72 | * that wrote a Remote Config template. 73 | */ 74 | export interface User { 75 | /** 76 | * Email address. 77 | */ 78 | email?: string; 79 | /** 80 | * Image URL. 81 | */ 82 | imageUrl?: string; 83 | /** 84 | * Display name. 85 | */ 86 | name?: string; 87 | } 88 | 89 | /** 90 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 91 | * @param {object} json The JSON object 92 | * @return {RemoteConfigEventData} The object with type annotations 93 | */ 94 | export const toRemoteConfigEventData = (json: object) => { 95 | return json as RemoteConfigEventData; 96 | }; 97 | -------------------------------------------------------------------------------- /firebase/testlab/v1/TestMatrixEventData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The data within all Firebase test matrix events. 19 | */ 20 | export interface TestMatrixEventData { 21 | /** 22 | * Information provided by the client that created the test matrix. 23 | */ 24 | clientInfo?: ClientInfo; 25 | /** 26 | * Time the test matrix was created. 27 | */ 28 | createTime?: Date | string; 29 | /** 30 | * Code that describes why the test matrix is considered invalid. Only set for 31 | * matrices in the INVALID state. 32 | */ 33 | invalidMatrixDetails?: string; 34 | /** 35 | * Outcome summary of the test matrix. 36 | */ 37 | outcomeSummary?: OutcomeSummaryEnum | number; 38 | /** 39 | * Locations where test results are stored. 40 | */ 41 | resultStorage?: ResultStorage; 42 | /** 43 | * State of the test matrix. 44 | */ 45 | state?: StateEnum | number; 46 | /** 47 | * ID of the test matrix this event belongs to. 48 | */ 49 | testMatrixId?: string; 50 | } 51 | 52 | /** 53 | * Information provided by the client that created the test matrix. 54 | * 55 | * Information about the client which invoked the test. 56 | */ 57 | export interface ClientInfo { 58 | /** 59 | * Client name, such as "gcloud". 60 | */ 61 | client?: string; 62 | /** 63 | * Map of detailed information about the client. 64 | */ 65 | details?: {[key: string]: string}; 66 | } 67 | 68 | export enum OutcomeSummaryEnum { 69 | Failure = 'FAILURE', 70 | Inconclusive = 'INCONCLUSIVE', 71 | OutcomeSummaryUnspecified = 'OUTCOME_SUMMARY_UNSPECIFIED', 72 | Skipped = 'SKIPPED', 73 | Success = 'SUCCESS', 74 | } 75 | 76 | /** 77 | * Locations where test results are stored. 78 | */ 79 | export interface ResultStorage { 80 | /** 81 | * Location in Google Cloud Storage where test results are written to. 82 | * In the form "gs://bucket/path/to/somewhere". 83 | */ 84 | gcsPath?: string; 85 | /** 86 | * URI to the test results in the Firebase Web Console. 87 | */ 88 | resultsUri?: string; 89 | /** 90 | * Tool Results execution resource containing test results. Format is 91 | * `projects/{project_id}/histories/{history_id}/executions/{execution_id}`. 92 | * Optional, can be omitted in erroneous test states. 93 | * See https://firebase.google.com/docs/test-lab/reference/toolresults/rest 94 | * for more information. 95 | */ 96 | toolResultsExecution?: string; 97 | /** 98 | * Tool Results history resource containing test results. Format is 99 | * `projects/{project_id}/histories/{history_id}`. 100 | * See https://firebase.google.com/docs/test-lab/reference/toolresults/rest 101 | * for more information. 102 | */ 103 | toolResultsHistory?: string; 104 | } 105 | 106 | export enum StateEnum { 107 | Error = 'ERROR', 108 | Finished = 'FINISHED', 109 | Invalid = 'INVALID', 110 | Pending = 'PENDING', 111 | TestStateUnspecified = 'TEST_STATE_UNSPECIFIED', 112 | Validating = 'VALIDATING', 113 | } 114 | 115 | /** 116 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 117 | * @param {object} json The JSON object 118 | * @return {TestMatrixEventData} The object with type annotations 119 | */ 120 | export const toTestMatrixEventData = (json: object) => { 121 | return json as TestMatrixEventData; 122 | }; 123 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@google/events", 3 | "version": "5.4.0", 4 | "description": "Client library for CloudEvents issued by Google.", 5 | "main": "index.js", 6 | "engines": { 7 | "node": ">=12.0.0" 8 | }, 9 | "scripts": { 10 | "pretest": "npm run compile", 11 | "test": "mocha -r ts-node/register 'tests/index.ts'", 12 | "check": "gts check", 13 | "clean": "gts clean", 14 | "docs": "node tools/docs.js", 15 | "build": "tsc --skipLibCheck", 16 | "watch": "tsc --watch --skipLibCheck", 17 | "gen": "./tools/gen.sh && node tools/postgen.js", 18 | "lint": "gts lint", 19 | "compile": "tsc", 20 | "fix": "gts fix" 21 | }, 22 | "repository": "googleapis/google-cloudevents-nodejs", 23 | "author": "Google Inc.", 24 | "keywords": [ 25 | "google", 26 | "events", 27 | "cloudevents" 28 | ], 29 | "license": "Apache-2.0", 30 | "bugs": { 31 | "url": "https://github.com/googleapis/google-cloudevents-nodejs/issues" 32 | }, 33 | "homepage": "https://github.com/googleapis/google-cloudevents-nodejs#readme", 34 | "devDependencies": { 35 | "@types/chai": "^4.2.19", 36 | "@types/mocha": "^10.0.0", 37 | "@types/node": "^18.0.0", 38 | "chai": "^4.2.0", 39 | "gts": "^3.1.0", 40 | "mocha": "^10.0.0", 41 | "node-fetch": "^3.0.0", 42 | "quicktype-core": "^23.0.0", 43 | "recursive-readdir": "^2.2.2", 44 | "ts-node": "^10.0.0", 45 | "typescript": "^4.6.4" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /reference.md: -------------------------------------------------------------------------------- 1 | # Reference 2 | 3 | The following sections describe how to use this library with different event data types. 4 | 5 | 6 | ### Cloud Audit Logs 7 | 8 | The data within all Cloud Audit Logs log entry events. 9 | 10 | #### CloudEvent Types: 11 | 12 | - `google.cloud.audit.log.v1.written` 13 | 14 | #### JS 15 | 16 | ```js 17 | const {toLogEntryData} = require('@google/events/cloud/audit/v1/LogEntryData'); 18 | 19 | const data = { 20 | // ... 21 | }; 22 | 23 | const jsExample = toLogEntryData(data); 24 | console.log(jsExample); 25 | ``` 26 | 27 | #### TS 28 | 29 | ```ts 30 | import {LogEntryData} from '@google/events/cloud/audit/v1/LogEntryData'; 31 | 32 | const data = { 33 | // ... 34 | }; 35 | 36 | const tsExample: LogEntryData = data; 37 | console.log(tsExample); 38 | ``` 39 | 40 | ### Cloud Build 41 | 42 | Build event data for Google Cloud Platform API operations. 43 | 44 | #### CloudEvent Types: 45 | 46 | - `google.cloud.cloudbuild.build.v1.statusChanged` 47 | 48 | #### JS 49 | 50 | ```js 51 | const {toBuildEventData} = require('@google/events/cloud/cloudbuild/v1/BuildEventData'); 52 | 53 | const data = { 54 | // ... 55 | }; 56 | 57 | const jsExample = toBuildEventData(data); 58 | console.log(jsExample); 59 | ``` 60 | 61 | #### TS 62 | 63 | ```ts 64 | import {BuildEventData} from '@google/events/cloud/cloudbuild/v1/BuildEventData'; 65 | 66 | const data = { 67 | // ... 68 | }; 69 | 70 | const tsExample: BuildEventData = data; 71 | console.log(tsExample); 72 | ``` 73 | 74 | ### Cloud Firestore 75 | 76 | The data within all Firestore document events. 77 | 78 | #### CloudEvent Types: 79 | 80 | - `google.cloud.firestore.document.v1.created` 81 | - `google.cloud.firestore.document.v1.updated` 82 | - `google.cloud.firestore.document.v1.deleted` 83 | - `google.cloud.firestore.document.v1.written` 84 | 85 | #### JS 86 | 87 | ```js 88 | const {toDocumentEventData} = require('@google/events/cloud/firestore/v1/DocumentEventData'); 89 | 90 | const data = { 91 | // ... 92 | }; 93 | 94 | const jsExample = toDocumentEventData(data); 95 | console.log(jsExample); 96 | ``` 97 | 98 | #### TS 99 | 100 | ```ts 101 | import {DocumentEventData} from '@google/events/cloud/firestore/v1/DocumentEventData'; 102 | 103 | const data = { 104 | // ... 105 | }; 106 | 107 | const tsExample: DocumentEventData = data; 108 | console.log(tsExample); 109 | ``` 110 | 111 | ### Cloud Pub/Sub 112 | 113 | The event data when a message is published to a topic. 114 | 115 | #### CloudEvent Types: 116 | 117 | - `google.cloud.pubsub.topic.v1.messagePublished` 118 | 119 | #### JS 120 | 121 | ```js 122 | const {toMessagePublishedData} = require('@google/events/cloud/pubsub/v1/MessagePublishedData'); 123 | 124 | const data = { 125 | // ... 126 | }; 127 | 128 | const jsExample = toMessagePublishedData(data); 129 | console.log(jsExample); 130 | ``` 131 | 132 | #### TS 133 | 134 | ```ts 135 | import {MessagePublishedData} from '@google/events/cloud/pubsub/v1/MessagePublishedData'; 136 | 137 | const data = { 138 | // ... 139 | }; 140 | 141 | const tsExample: MessagePublishedData = data; 142 | console.log(tsExample); 143 | ``` 144 | 145 | ### Cloud Scheduler 146 | 147 | Scheduler job data. 148 | 149 | #### CloudEvent Types: 150 | 151 | - `google.cloud.scheduler.job.v1.executed` 152 | 153 | #### JS 154 | 155 | ```js 156 | const {toSchedulerJobData} = require('@google/events/cloud/scheduler/v1/SchedulerJobData'); 157 | 158 | const data = { 159 | // ... 160 | }; 161 | 162 | const jsExample = toSchedulerJobData(data); 163 | console.log(jsExample); 164 | ``` 165 | 166 | #### TS 167 | 168 | ```ts 169 | import {SchedulerJobData} from '@google/events/cloud/scheduler/v1/SchedulerJobData'; 170 | 171 | const data = { 172 | // ... 173 | }; 174 | 175 | const tsExample: SchedulerJobData = data; 176 | console.log(tsExample); 177 | ``` 178 | 179 | ### Cloud Storage 180 | 181 | An object within Google Cloud Storage. 182 | 183 | #### CloudEvent Types: 184 | 185 | - `google.cloud.storage.object.v1.finalized` 186 | - `google.cloud.storage.object.v1.archived` 187 | - `google.cloud.storage.object.v1.deleted` 188 | - `google.cloud.storage.object.v1.metadataUpdated` 189 | 190 | #### JS 191 | 192 | ```js 193 | const {toStorageObjectData} = require('@google/events/cloud/storage/v1/StorageObjectData'); 194 | 195 | const data = { 196 | // ... 197 | }; 198 | 199 | const jsExample = toStorageObjectData(data); 200 | console.log(jsExample); 201 | ``` 202 | 203 | #### TS 204 | 205 | ```ts 206 | import {StorageObjectData} from '@google/events/cloud/storage/v1/StorageObjectData'; 207 | 208 | const data = { 209 | // ... 210 | }; 211 | 212 | const tsExample: StorageObjectData = data; 213 | console.log(tsExample); 214 | ``` 215 | 216 | ### Google Analytics for Firebase 217 | 218 | The data within Firebase Analytics log events. 219 | 220 | #### CloudEvent Types: 221 | 222 | - `google.firebase.analytics.log.v1.written` 223 | 224 | #### JS 225 | 226 | ```js 227 | const {toAnalyticsLogData} = require('@google/events/firebase/analytics/v1/AnalyticsLogData'); 228 | 229 | const data = { 230 | // ... 231 | }; 232 | 233 | const jsExample = toAnalyticsLogData(data); 234 | console.log(jsExample); 235 | ``` 236 | 237 | #### TS 238 | 239 | ```ts 240 | import {AnalyticsLogData} from '@google/events/firebase/analytics/v1/AnalyticsLogData'; 241 | 242 | const data = { 243 | // ... 244 | }; 245 | 246 | const tsExample: AnalyticsLogData = data; 247 | console.log(tsExample); 248 | ``` 249 | 250 | ### Firebase Authentication 251 | 252 | The data within all Firebase Auth events. 253 | 254 | #### CloudEvent Types: 255 | 256 | - `google.firebase.auth.user.v1.created` 257 | - `google.firebase.auth.user.v1.deleted` 258 | 259 | #### JS 260 | 261 | ```js 262 | const {toAuthEventData} = require('@google/events/firebase/auth/v1/AuthEventData'); 263 | 264 | const data = { 265 | // ... 266 | }; 267 | 268 | const jsExample = toAuthEventData(data); 269 | console.log(jsExample); 270 | ``` 271 | 272 | #### TS 273 | 274 | ```ts 275 | import {AuthEventData} from '@google/events/firebase/auth/v1/AuthEventData'; 276 | 277 | const data = { 278 | // ... 279 | }; 280 | 281 | const tsExample: AuthEventData = data; 282 | console.log(tsExample); 283 | ``` 284 | 285 | ### Firebase Realtime Database 286 | 287 | The data within all Firebase Real Time Database reference events. 288 | 289 | #### CloudEvent Types: 290 | 291 | - `google.firebase.database.ref.v1.created` 292 | - `google.firebase.database.ref.v1.updated` 293 | - `google.firebase.database.ref.v1.deleted` 294 | - `google.firebase.database.ref.v1.written` 295 | 296 | #### JS 297 | 298 | ```js 299 | const {toReferenceEventData} = require('@google/events/firebase/database/v1/ReferenceEventData'); 300 | 301 | const data = { 302 | // ... 303 | }; 304 | 305 | const jsExample = toReferenceEventData(data); 306 | console.log(jsExample); 307 | ``` 308 | 309 | #### TS 310 | 311 | ```ts 312 | import {ReferenceEventData} from '@google/events/firebase/database/v1/ReferenceEventData'; 313 | 314 | const data = { 315 | // ... 316 | }; 317 | 318 | const tsExample: ReferenceEventData = data; 319 | console.log(tsExample); 320 | ``` 321 | 322 | ### Firebase Remote Config 323 | 324 | The data within all Firebase Remote Config events. 325 | 326 | #### CloudEvent Types: 327 | 328 | - `google.firebase.remoteconfig.remoteConfig.v1.updated` 329 | 330 | #### JS 331 | 332 | ```js 333 | const {toRemoteConfigEventData} = require('@google/events/firebase/remoteconfig/v1/RemoteConfigEventData'); 334 | 335 | const data = { 336 | // ... 337 | }; 338 | 339 | const jsExample = toRemoteConfigEventData(data); 340 | console.log(jsExample); 341 | ``` 342 | 343 | #### TS 344 | 345 | ```ts 346 | import {RemoteConfigEventData} from '@google/events/firebase/remoteconfig/v1/RemoteConfigEventData'; 347 | 348 | const data = { 349 | // ... 350 | }; 351 | 352 | const tsExample: RemoteConfigEventData = data; 353 | console.log(tsExample); 354 | ``` 355 | 356 | 357 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | "docker:disable", 5 | ":disableDependencyDashboard" 6 | ], 7 | "pinVersions": false, 8 | "rebaseStalePrs": true, 9 | "schedule": [ 10 | "every 3 months on the first day of the month" 11 | ], 12 | "gitAuthor": null, 13 | "packageRules": [ 14 | { 15 | "extends": "packages:linters", 16 | "groupName": "linters" 17 | } 18 | ], 19 | "ignoreDeps": ["typescript"] 20 | } 21 | -------------------------------------------------------------------------------- /tests/index.ts: -------------------------------------------------------------------------------- 1 | import {expect} from 'chai'; 2 | import {MessagePublishedData} from '../cloud/pubsub/v1/MessagePublishedData'; 3 | import {StorageObjectData} from '../cloud/storage/v1/StorageObjectData'; 4 | import {DocumentEventData} from '../cloud/firestore/v1/DocumentEventData'; 5 | import {BuildEventData} from '../cloud/cloudbuild/v1/BuildEventData'; 6 | import {SchedulerJobData} from '../cloud/scheduler/v1/SchedulerJobData'; 7 | import {LogEntryData} from '../cloud/audit/v1/LogEntryData'; 8 | import {AnalyticsLogData} from '../firebase/analytics/v1/AnalyticsLogData'; 9 | import {AuthEventData} from '../firebase/auth/v1/AuthEventData'; 10 | import {ReferenceEventData} from '../firebase/database/v1/ReferenceEventData'; 11 | import { 12 | RemoteConfigEventData, 13 | UpdateTypeEnum, 14 | UpdateOriginEnum, 15 | } from '../firebase/remoteconfig/v1/RemoteConfigEventData'; 16 | 17 | /** 18 | * JSON objects that are similar to what you'd see from a POST request. 19 | */ 20 | const PUBSUB_DATA: MessagePublishedData = { 21 | message: { 22 | data: Buffer.from('Pub/Sub data').toString('base64'), 23 | messageId: 'my-message-id', 24 | publishTime: '2020-08-14T20:50:04.994Z', 25 | }, 26 | subscription: 27 | 'projects/my-project/subscriptions/cre-us-central1-pubsub-trigger-5-sub-000', 28 | }; 29 | const BUILD_EVENT_DATA: BuildEventData = { 30 | timeout: '660s', 31 | createTime: '1993-07-25T02:32:41.388Z', 32 | tags: ['dolor exercitation', 'sit id consequat', 'dolore eu sit irure esse'], 33 | buildTriggerId: 'my-trigger-id', 34 | logUrl: 'http://example.com', 35 | images: ['http://example.com', 'http://example.com'], 36 | projectId: 'quis minim est laborum ex', 37 | queueTtl: '660s', 38 | }; 39 | const FIRESTORE_DATA: DocumentEventData = { 40 | oldValue: { 41 | createTime: '2020-04-23T09:58:53.211035Z', 42 | fields: { 43 | 'another test': { 44 | stringValue: 'asd', 45 | }, 46 | count: { 47 | integerValue: 3, 48 | }, 49 | foo: { 50 | stringValue: 'bar', 51 | }, 52 | }, 53 | name: 'projects/project-id/databases/(default)/documents/gcf-test/2Vm2mI1d0wIaK2Waj5to', 54 | updateTime: '2020-04-23T12:00:27.247187Z', 55 | }, 56 | updateMask: { 57 | fieldPaths: ['count'], 58 | }, 59 | value: { 60 | createTime: '2020-04-23T09:58:53.211035Z', 61 | fields: { 62 | 'another test': { 63 | stringValue: 'asd', 64 | }, 65 | count: { 66 | integerValue: 4, 67 | }, 68 | foo: { 69 | stringValue: 'bar', 70 | }, 71 | }, 72 | name: 'projects/project-id/databases/(default)/documents/gcf-test/2Vm2mI1d0wIaK2Waj5to', 73 | updateTime: '2020-04-23T12:00:27.247187Z', 74 | }, 75 | }; 76 | const SCHEDULER_DATA: SchedulerJobData = { 77 | customData: 'bXkgYmFzZTY0IGRhdGE=', 78 | }; 79 | const STORAGE_DATA: StorageObjectData = { 80 | bucket: 'some-bucket', 81 | contentType: 'text/plain', 82 | crc32c: 'rTVTeQ==', 83 | etag: 'CNHZkbuF/ugCEAE=', 84 | generation: 1587627537231057, 85 | id: 'some-bucket/folder/Test.cs/1587627537231057', 86 | kind: 'storage#object', 87 | md5Hash: 'kF8MuJ5+CTJxvyhHS1xzRg==', 88 | mediaLink: 89 | 'https://www.googleapis.com/download/storage/v1/b/some-bucket/o/folder%2FTest.cs?generation=1587627537231057\u0026alt=media', 90 | metageneration: 1, 91 | name: 'folder/Test.cs', 92 | selfLink: 93 | 'https://www.googleapis.com/storage/v1/b/some-bucket/o/folder/Test.cs', 94 | size: 352, 95 | storageClass: 'MULTI_REGIONAL', 96 | timeCreated: '2020-04-23T07:38:57.230Z', 97 | timeStorageClassUpdated: '2020-04-23T07:38:57.230Z', 98 | updated: '2020-04-23T07:38:57.230Z', 99 | }; 100 | const LOG_ENTRY_DATA: LogEntryData = { 101 | insertId: '9frck8cf9j', 102 | logName: 'projects/test-project/logs/cloudaudit.googleapis.com%2Factivity', 103 | protoPayload: { 104 | authenticationInfo: { 105 | principalEmail: 'robot@test-project.iam.gserviceaccount.com', 106 | principalSubject: 'user:robot@test-project.iam.gserviceaccount.com', 107 | serviceAccountKeyName: 108 | '//iam.googleapis.com/projects/test-project/serviceAccounts/robot@test-project.iam.gserviceaccount.com/keys/90f662482321f1ca8e82ea675b1a1c30c1fe681f', 109 | }, 110 | authorizationInfo: [ 111 | { 112 | granted: true, 113 | permission: 'pubsub.topics.create', 114 | resource: 'projects/test-project', 115 | resourceAttributes: {}, 116 | }, 117 | ], 118 | methodName: 'google.pubsub.v1.Publisher.CreateTopic', 119 | requestMetadata: { 120 | callerIp: '192.168.0.1', 121 | callerNetwork: 122 | '//compute.googleapis.com/projects/google.com:my-laptop/global/networks/__unknown__', 123 | callerSuppliedUserAgent: 'google-cloud-sdk', 124 | destinationAttributes: {}, 125 | requestAttributes: { 126 | auth: {}, 127 | time: '2020-06-30T16:14:47.600710407Z', 128 | }, 129 | }, 130 | resourceLocation: { 131 | currentLocations: [ 132 | 'asia-east1', 133 | 'asia-northeast1', 134 | 'asia-southeast1', 135 | 'australia-southeast1', 136 | 'europe-north1', 137 | 'europe-west1', 138 | 'europe-west2', 139 | 'europe-west3', 140 | 'europe-west4', 141 | 'us-central1', 142 | 'us-central2', 143 | 'us-east1', 144 | 'us-east4', 145 | 'us-west1', 146 | 'us-west2', 147 | 'us-west3', 148 | 'us-west4', 149 | ], 150 | }, 151 | resourceName: 'projects/test-project/topics/test-auditlogs-source', 152 | serviceName: 'pubsub.googleapis.com', 153 | }, 154 | receiveTimestamp: '2020-06-30T16:14:48.401489148Z', 155 | resource: { 156 | labels: { 157 | project_id: 'test-project', 158 | topic_id: 'projects/test-project/topics/test-auditlogs-source', 159 | }, 160 | type: 'pubsub_topic', 161 | }, 162 | timestamp: '2020-06-30T16:14:47.593398572Z', 163 | }; 164 | const ANALYTICS_DATA: AnalyticsLogData = { 165 | userDim: { 166 | appInfo: { 167 | appId: 'com.example.exampleapp', 168 | appInstanceId: 'aaabbb11122233344455566677788899', 169 | appPlatform: 'ANDROID', 170 | appStore: 'com.android.vending', 171 | appVersion: '1.67', 172 | }, 173 | bundleInfo: { 174 | bundleSequenceId: 58, 175 | serverTimestampOffsetMicros: 875910, 176 | }, 177 | deviceInfo: { 178 | deviceCategory: 'mobile', 179 | deviceModel: 'SM-A307G', 180 | deviceTimeZoneOffsetSeconds: -10800, 181 | mobileBrandName: 'Samsung', 182 | mobileMarketingName: 'Galaxy A30s', 183 | mobileModelName: 'SM-A307G', 184 | platformVersion: '10', 185 | resettableDeviceId: 'aaaaaa-1111-bbbb-2222-dddddddddddd', 186 | userDefaultLanguage: 'es-us', 187 | }, 188 | firstOpenTimestampMicros: 1606882687506000, 189 | geoInfo: { 190 | city: 'Burzaco', 191 | continent: '005', 192 | country: 'Argentina', 193 | region: 'Buenos Aires Province', 194 | }, 195 | userId: '0123456789abcdef0123456789abcdef', 196 | userProperties: { 197 | completed_tutorial: { 198 | setTimestampUsec: 1606948068187909, 199 | value: {stringValue: 'true'}, 200 | }, 201 | first_open_time: { 202 | setTimestampUsec: 1606882688381909, 203 | value: {intValue: 1606885200000}, 204 | }, 205 | last_level: { 206 | index: 10, 207 | setTimestampUsec: 1606952210498909, 208 | value: {stringValue: 'school'}, 209 | }, 210 | user_id: { 211 | setTimestampUsec: 1606955180040909, 212 | value: {stringValue: 'abcdef0123456789abcdef0123456789'}, 213 | }, 214 | }, 215 | }, 216 | eventDim: [ 217 | { 218 | date: '20201202', 219 | name: 'session_start', 220 | params: { 221 | engaged_session_event: {intValue: 1}, 222 | firebase_conversion: {intValue: 1}, 223 | firebase_event_origin: {stringValue: 'auto'}, 224 | firebase_screen: {stringValue: 'app_menu'}, 225 | firebase_screen_class: {stringValue: 'AppActivity'}, 226 | firebase_screen_id: {intValue: -2415111648950109400}, 227 | ga_session_id: {intValue: 1606965190}, 228 | ga_session_number: {intValue: 7}, 229 | session_engaged: {intValue: 1}, 230 | }, 231 | previousTimestampMicros: 1606951997533000, 232 | timestampMicros: 160695519124690, 233 | }, 234 | ], 235 | }; 236 | const AUTH_DATA: AuthEventData = { 237 | email: 'test@nowhere.com', 238 | metadata: { 239 | createTime: '2020-05-26T10:42:27Z', 240 | lastSignInTime: '2020-05-29T11:00:00Z', 241 | }, 242 | providerData: [ 243 | { 244 | email: 'test@nowhere.com', 245 | providerId: 'password', 246 | uid: 'test@nowhere.com', 247 | }, 248 | ], 249 | uid: 'UUpby3s4spZre6kHsgVSPetzQ8l2', 250 | }; 251 | const DATABASE_DATA: ReferenceEventData = { 252 | data: { 253 | deeply: { 254 | nested: { 255 | text: 'This is deeply nested', 256 | text2: 'Second value', 257 | }, 258 | }, 259 | grandchild: 'other changed', 260 | }, 261 | delta: { 262 | deeply: { 263 | abc: 'def', 264 | }, 265 | }, 266 | }; 267 | const REMOTE_CONFIG_DATA: RemoteConfigEventData = { 268 | updateOrigin: UpdateOriginEnum.Console, 269 | updateTime: '2020-11-16T16:35:33.569229Z', 270 | updateType: UpdateTypeEnum.IncrementalUpdate, 271 | updateUser: { 272 | name: 'Ut ad aute', 273 | email: 'test@nowhere.com', 274 | imageUrl: 'http://google.com/favicon.ico', 275 | }, 276 | versionNumber: 5, 277 | rollbackSource: 75404139, 278 | description: 'minim reprehenderit Lorem qui proident', 279 | }; 280 | 281 | describe('Event Types', () => { 282 | describe('cloud', () => { 283 | it('Audit Log: should work with a basic Audit Log sample', () => { 284 | const tsExample: LogEntryData = LOG_ENTRY_DATA; 285 | expect(tsExample.timestamp).to.equal('2020-06-30T16:14:47.593398572Z'); 286 | }); 287 | it('Cloud Build: should work with a basic Build sample', () => { 288 | const tsExample: BuildEventData = BUILD_EVENT_DATA; 289 | expect(tsExample.buildTriggerId).to.equal('my-trigger-id'); 290 | }); 291 | it('Firestore: should work with a basic Firestore sample', () => { 292 | const tsExample: DocumentEventData = FIRESTORE_DATA; 293 | expect(tsExample.value?.name).to.equal( 294 | 'projects/project-id/databases/(default)/documents/gcf-test/2Vm2mI1d0wIaK2Waj5to' 295 | ); 296 | }); 297 | it('Pub/Sub: should work with a basic Pub/Sub sample', () => { 298 | const tsExample: MessagePublishedData = PUBSUB_DATA; 299 | expect(tsExample?.message?.data).to.equal( 300 | Buffer.from('Pub/Sub data').toString('base64') 301 | ); 302 | }); 303 | it('Scheduler: should work with a basic Scheduler sample', () => { 304 | const tsExample: SchedulerJobData = SCHEDULER_DATA; 305 | expect(tsExample.customData).to.equal('bXkgYmFzZTY0IGRhdGE='); 306 | }); 307 | it('Storage: should work with a basic Storage sample', () => { 308 | const tsExample: StorageObjectData = STORAGE_DATA; 309 | expect(tsExample.bucket).to.equal('some-bucket'); 310 | }); 311 | }); 312 | describe('firebase', () => { 313 | it('Analytics: should work with a basic Analytics sample', () => { 314 | const tsExample: AnalyticsLogData = ANALYTICS_DATA; 315 | expect(tsExample.userDim?.userId).to.equal( 316 | '0123456789abcdef0123456789abcdef' 317 | ); 318 | }); 319 | it('Auth: should work with a basic Auth sample', () => { 320 | const tsExample: AuthEventData = AUTH_DATA; 321 | expect(tsExample.uid).to.equal('UUpby3s4spZre6kHsgVSPetzQ8l2'); 322 | }); 323 | it('Database: should work with a basic Database sample', () => { 324 | const tsExample: ReferenceEventData = DATABASE_DATA; 325 | const delta = tsExample?.delta as {[key: string]: any}; 326 | expect(delta.deeply.abc).to.equal('def'); 327 | }); 328 | it('Remote Config: should work with a basic Remote Config sample', () => { 329 | const tsExample: RemoteConfigEventData = REMOTE_CONFIG_DATA; 330 | expect(tsExample.rollbackSource).to.equal(75404139); 331 | }); 332 | }); 333 | }); 334 | -------------------------------------------------------------------------------- /tools/docs.ts: -------------------------------------------------------------------------------- 1 | const nodeFetch = require('node-fetch'); 2 | const fs = require('fs'); 3 | 4 | // Config 5 | const CATALOG_URL = 6 | 'https://googleapis.github.io/google-cloudevents/jsonschema/catalog.json'; 7 | 8 | /** 9 | * Gets markdown type documentation for this library. 10 | * @param {object} catalog The JSON schema event catalog. 11 | * @example 12 | * { 13 | * url: 'https://googleapis.github.io/google-cloudevents/jsonschema/google/events/cloud/firestore/v1/DocumentEventData.json', 14 | * product: 'Cloud Firestore', 15 | * name: 'DocumentEventData', 16 | * description: 'The data within all Firestore document events.', 17 | * datatype: 'google.events.cloud.firestore.v1.DocumentEventData', 18 | * cloudeventTypes: ['first', 'second'] 19 | * } 20 | * @returns {string} Markdown for the Node type documentation. 21 | */ 22 | function getTypeDocumentation(catalog: any): string { 23 | const result: any[] = catalog.schemas.map((schema: any) => { 24 | const requirePath = `@${schema.datatype.replace(/\./g, '/')}`; 25 | const toFunction = `to${schema.name}`; 26 | const requireString = `const {${toFunction}} = require('${requirePath}');`; 27 | const importString = `import {${schema.name}} from '${requirePath}';`; 28 | 29 | return `### ${schema.product} 30 | 31 | ${schema.description} 32 | 33 | #### CloudEvent Types: 34 | 35 | ${schema.cloudeventTypes?.map((t: string) => `- \`${t}\``).join('\n')} 36 | 37 | #### JS 38 | 39 | \`\`\`js 40 | ${requireString} 41 | 42 | const data = { 43 | // ... 44 | }; 45 | 46 | const jsExample = ${toFunction}(data); 47 | console.log(jsExample); 48 | \`\`\` 49 | 50 | #### TS 51 | 52 | \`\`\`ts 53 | ${importString} 54 | 55 | const data = { 56 | // ... 57 | }; 58 | 59 | const tsExample: ${schema.name} = data; 60 | console.log(tsExample); 61 | \`\`\` 62 | `; 63 | }); 64 | return result.join('\n'); 65 | } 66 | 67 | /** 68 | * Replaces the contents of a string's GENERATED comments with a replacement. 69 | * @param {string} s The string to replace. 70 | * @param {string} replacement The replacement string. 71 | */ 72 | const getGeneratedStringWithReplacement = (s: string, replacement: string) => { 73 | const README_GEN_START = ''; 74 | const README_GEN_END = ''; 75 | 76 | const README_BEFORE_TABLE = s.substring( 77 | 0, 78 | s.indexOf(README_GEN_START) + README_GEN_START.length 79 | ); 80 | const README_AFTER_TABLE = s.substring(s.indexOf(README_GEN_END)); 81 | 82 | // Return result (with newlines) 83 | return `${README_BEFORE_TABLE} 84 | ${replacement} 85 | ${README_AFTER_TABLE}`; 86 | }; 87 | 88 | // Runs the generator 89 | (async () => { 90 | const catalog = await nodeFetch(CATALOG_URL); 91 | const catalogJSON = await catalog.json(); 92 | 93 | const nodeDocumentation = getTypeDocumentation(catalogJSON); 94 | 95 | const README_PATH = `${__dirname}/../reference.md`; 96 | const readmeContents = fs.readFileSync(README_PATH).toString(); 97 | const updatedReadmeContents = getGeneratedStringWithReplacement( 98 | readmeContents, 99 | nodeDocumentation 100 | ); 101 | 102 | // Save updated reference 103 | fs.writeFileSync(README_PATH, updatedReadmeContents); 104 | })(); 105 | -------------------------------------------------------------------------------- /tools/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2020 Google LLC. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | # Generate TS library from JSON Schemas 20 | qt \ 21 | --in=$(dirname $PWD)/google-cloudevents/jsonschema \ 22 | --out=$PWD \ 23 | --l=typescript 24 | 25 | # Move generated library into correct directory 26 | cp -a google/events/. . 27 | rm -r google -------------------------------------------------------------------------------- /tools/postgen.ts: -------------------------------------------------------------------------------- 1 | import * as fs from 'fs'; 2 | const recursive = require('recursive-readdir'); 3 | 4 | /** 5 | * This tool makes the generated code from the quicktype wrapper usable to TypeScript clients. 6 | * 7 | * Prerequisites: 8 | * - A `cloud/` folder with `*Data.ts` files within subfolders. 9 | * 10 | * TypeScript "toTYPE" function: 11 | * - Loop through every type (ts file) 12 | * - 1st interface: wrapper type (ignore) 13 | * - 2nd interface: main type (use this). i.e. AuditLogWrittenEvent 14 | * - Add a to[TYPE] function to the file. Example: 15 | * export const toMessagePublishedEvent = (json: object) => { 16 | * return json as MessagePublishedEvent; 17 | * }; 18 | */ 19 | 20 | // Wrap in IIFE for top-level await 21 | (async () => { 22 | const filePaths: string[] = [ 23 | ...(await recursive('cloud')), 24 | ...(await recursive('firebase')), 25 | ]; 26 | 27 | // Get every data type file path 28 | const dataTsFilePaths = filePaths.filter(path => { 29 | const typeFilenamePostfix = 'Data.ts'; 30 | return path.endsWith(typeFilenamePostfix); 31 | }); 32 | 33 | // Read type file 34 | dataTsFilePaths.forEach(filename => { 35 | // For a single type file 36 | console.log(`- Fixing: ${filename}`); 37 | const typeFileContent = fs.readFileSync(filename).toString(); 38 | 39 | // Get TS interfaces 40 | let lines = typeFileContent.split('\n'); 41 | const interfaceLines = lines.filter(line => { 42 | return line.startsWith('export interface'); 43 | }); 44 | 45 | // Allow TS Date types to be strings 46 | lines = lines.map((l: string) => { 47 | return l.replace('Date;', 'Date | string;'); 48 | }); 49 | 50 | // The data name, e.g. 'export interface MessagePublishedData {' 51 | const dataName = interfaceLines[0] 52 | .split(' ') 53 | .filter(token => token.endsWith('Data'))[0]; 54 | 55 | const newTypeFileContent = 56 | lines.join('\n') + 57 | ` 58 | /** 59 | * Cast a raw JSON object to a typed event (useful for IDE autocompletion). 60 | * @param {object} json The JSON object 61 | * @return {${dataName}} The object with type annotations 62 | */ 63 | export const to${dataName} = (json: object) => { 64 | return json as ${dataName}; 65 | };`; 66 | // Write the updated file back 67 | fs.writeFileSync(filename, newTypeFileContent); 68 | }); 69 | })(); 70 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/gts/tsconfig-google.json", 3 | "compilerOptions": { 4 | "lib": [ 5 | "es2017" 6 | ], 7 | "rootDir": ".", 8 | "sourceMap": false, 9 | "target": "es2017" 10 | }, 11 | "include": [ 12 | "cloud/**/*.ts", 13 | "firebase/**/*.ts", 14 | "tools/**/*.ts", 15 | "tests/**/*.ts" 16 | ] 17 | } 18 | --------------------------------------------------------------------------------