File tree 2 files changed +33
-7
lines changed
2 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,9 @@ export function getBinaryCloudEventContext(
47
47
const context : CloudEventsContext = { } ;
48
48
for ( const name in req . headers ) {
49
49
if ( name . startsWith ( 'ce-' ) ) {
50
- const attributeName = name . substr ( 'ce-' . length ) ;
50
+ const attributeName = name . substr (
51
+ 'ce-' . length
52
+ ) as keyof CloudEventsContext ;
51
53
context [ attributeName ] = req . header ( name ) ;
52
54
}
53
55
}
Original file line number Diff line number Diff line change @@ -40,6 +40,19 @@ export type HandlerFunction =
40
40
| CloudEventFunction
41
41
| CloudEventFunctionWithCallback ;
42
42
43
+ /**
44
+ * A legacy event.
45
+ */
46
+ export interface LegacyEvent {
47
+ data : object ;
48
+ context : CloudFunctionsContext ;
49
+ }
50
+
51
+ interface Data {
52
+ data : object ;
53
+ }
54
+ export type LegacyCloudFunctionsContext = CloudFunctionsContext | Data ;
55
+
43
56
/**
44
57
* The Cloud Functions context object for the event.
45
58
*
@@ -62,7 +75,7 @@ export interface CloudFunctionsContext {
62
75
/**
63
76
* The resource that emitted the event.
64
77
*/
65
- resource ?: string ;
78
+ resource ?: string | object ;
66
79
}
67
80
68
81
/**
@@ -91,17 +104,28 @@ export interface CloudEventsContext {
91
104
* Timestamp of when the event happened.
92
105
*/
93
106
time ?: string ;
107
+ /**
108
+ * Describes the subject of the event in the context of the event producer.
109
+ */
110
+ subject ?: string ;
94
111
/**
95
112
* A link to the schema that the event data adheres to.
96
113
*/
97
- schemaurl ?: string ;
114
+ dataschema ?: string ;
98
115
/**
99
116
* Content type of the event data.
100
117
*/
101
- contenttype ?: string ;
102
-
103
- // CloudEvents extension attributes.
104
- [ key : string ] : any ;
118
+ datacontenttype ?: string ;
119
+ /**
120
+ * The event data.
121
+ */
122
+ data ?:
123
+ | Record < string , unknown | string | number | boolean >
124
+ | string
125
+ | number
126
+ | boolean
127
+ | null
128
+ | unknown ;
105
129
}
106
130
107
131
export type Context = CloudFunctionsContext | CloudEventsContext ;
You can’t perform that action at this time.
0 commit comments