New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Google CloudEvent Types #376
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* The CloudEvents v1.0 context object for the event. | ||
* {@link https://github.com/cloudevents/spec/blob/master/spec.md#context-attributes} | ||
* @public | ||
*/ | ||
export interface CloudEvent { | ||
/** | ||
* Type of occurrence which has happened. | ||
*/ | ||
type?: string; | ||
/** | ||
* The version of the CloudEvents specification which the event uses. | ||
*/ | ||
specversion?: string; | ||
/** | ||
* The event producer. | ||
*/ | ||
source?: string; | ||
/** | ||
* ID of the event. | ||
*/ | ||
id?: string; | ||
/** | ||
* Timestamp of when the event happened. | ||
*/ | ||
time?: string; | ||
/** | ||
* Describes the subject of the event in the context of the event producer. | ||
*/ | ||
subject?: string; | ||
/** | ||
* A link to the schema that the event data adheres to. | ||
*/ | ||
dataschema?: string; | ||
/** | ||
* Content type of the event data. | ||
*/ | ||
datacontenttype?: string; | ||
/** | ||
* The event data. | ||
*/ | ||
data?: | ||
| Record<string, unknown | string | number | boolean> | ||
| string | ||
| number | ||
| boolean | ||
| null | ||
| unknown; | ||
/** | ||
* The traceparent string, containing a trace version, trace ID, span ID, and trace options. | ||
* @see https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md | ||
*/ | ||
traceparent?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any*/ | ||
import {LogEntryData} from './cloud/audit/v1/LogEntryData'; | ||
import {BuildEventData} from './cloud/cloudbuild/v1/BuildEventData'; | ||
import {DocumentEventData} from './cloud/firestore/v1/DocumentEventData'; | ||
import {MessagePublishedData} from './cloud/pubsub/v1/MessagePublishedData'; | ||
import {SchedulerJobData} from './cloud/scheduler/v1/SchedulerJobData'; | ||
import {StorageObjectData} from './cloud/storage/v1/StorageObjectData'; | ||
import {AnalyticsLogData} from './firebase/analytics/v1/AnalyticsLogData'; | ||
import {AuthEventData} from './firebase/auth/v1/AuthEventData'; | ||
import {ReferenceEventData} from './firebase/database/v1/ReferenceEventData'; | ||
import {RemoteConfigEventData} from './firebase/remoteconfig/v1/RemoteConfigEventData'; | ||
import {TestMatrixEventData} from './firebase/testlab/v1/TestMatrixEventData'; | ||
import {CloudEvent} from './CloudEvent'; | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Cloud Audit Logs. | ||
* | ||
* @public | ||
*/ | ||
export interface LogEntryCloudEvent extends CloudEvent { | ||
type: 'google.cloud.audit.log.v1.written'; | ||
data: LogEntryData; | ||
} | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Cloud Build. | ||
* | ||
* @public | ||
*/ | ||
export interface BuildEventCloudEvent extends CloudEvent { | ||
type: 'google.cloud.cloudbuild.build.v1.statusChanged'; | ||
data: BuildEventData; | ||
} | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Cloud Firestore. | ||
* | ||
* @public | ||
*/ | ||
export interface DocumentEventCloudEvent extends CloudEvent { | ||
type: | ||
| 'google.cloud.firestore.document.v1.created' | ||
| 'google.cloud.firestore.document.v1.updated' | ||
| 'google.cloud.firestore.document.v1.deleted' | ||
| 'google.cloud.firestore.document.v1.written'; | ||
data: DocumentEventData; | ||
} | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Cloud Pub/Sub. | ||
* | ||
* @public | ||
*/ | ||
export interface MessagePublishedCloudEvent extends CloudEvent { | ||
type: 'google.cloud.pubsub.topic.v1.messagePublished'; | ||
data: MessagePublishedData; | ||
} | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Cloud Scheduler. | ||
* | ||
* @public | ||
*/ | ||
export interface SchedulerJobCloudEvent extends CloudEvent { | ||
type: 'google.cloud.scheduler.job.v1.executed'; | ||
data: SchedulerJobData; | ||
} | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Cloud Storage. | ||
* | ||
* @public | ||
*/ | ||
export interface StorageObjectCloudEvent extends CloudEvent { | ||
type: | ||
| 'google.cloud.storage.object.v1.finalized' | ||
| 'google.cloud.storage.object.v1.archived' | ||
| 'google.cloud.storage.object.v1.deleted' | ||
| 'google.cloud.storage.object.v1.metadataUpdated'; | ||
data: StorageObjectData; | ||
} | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Google Analytics for Firebase. | ||
* | ||
* @public | ||
*/ | ||
export interface AnalyticsLogCloudEvent extends CloudEvent { | ||
type: 'google.firebase.analytics.log.v1.written'; | ||
data: AnalyticsLogData; | ||
} | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Firebase Authentication. | ||
* | ||
* @public | ||
*/ | ||
export interface AuthEventCloudEvent extends CloudEvent { | ||
type: | ||
| 'google.firebase.auth.user.v1.created' | ||
| 'google.firebase.auth.user.v1.deleted'; | ||
data: AuthEventData; | ||
} | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Firebase Realtime Database. | ||
* | ||
* @public | ||
*/ | ||
export interface ReferenceEventCloudEvent extends CloudEvent { | ||
type: | ||
| 'google.firebase.database.ref.v1.created' | ||
| 'google.firebase.database.ref.v1.updated' | ||
| 'google.firebase.database.ref.v1.deleted' | ||
| 'google.firebase.database.ref.v1.written'; | ||
data: ReferenceEventData; | ||
} | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Firebase Remote Config. | ||
* | ||
* @public | ||
*/ | ||
export interface RemoteConfigEventCloudEvent extends CloudEvent { | ||
type: 'google.firebase.remoteconfig.remoteConfig.v1.updated'; | ||
data: RemoteConfigEventData; | ||
} | ||
|
||
/** | ||
* The schema of CloudEvents emmitted by Firebase Test Lab. | ||
* | ||
* @public | ||
*/ | ||
export interface TestMatrixEventCloudEvent extends CloudEvent { | ||
type: 'google.firebase.testlab.testMatrix.v1.completed'; | ||
data: TestMatrixEventData; | ||
} | ||
|
||
/** | ||
* Union of all known CloudEvents emitted by Google Cloud services | ||
*/ | ||
export type GoogleCloudEvent = | ||
| LogEntryCloudEvent | ||
| BuildEventCloudEvent | ||
| DocumentEventCloudEvent | ||
| MessagePublishedCloudEvent | ||
| SchedulerJobCloudEvent | ||
| StorageObjectCloudEvent | ||
| AnalyticsLogCloudEvent | ||
| AuthEventCloudEvent | ||
| ReferenceEventCloudEvent | ||
| RemoteConfigEventCloudEvent | ||
| TestMatrixEventCloudEvent; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this interface different than the interface here?
https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/master/src/functions.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same. My plan is to replace that interface with this one in a subsequent PR. I duplicated it in this PR so that it will revert cleanly. At this point we can
rm -rf src/cloudevent_types
and nothing is broken.