/
models.ts
176 lines (170 loc) · 4.09 KB
/
models.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* The shape of the input for EventGridProducerClient#sendEventGridEvents
*/
export interface SendEventGridEventInput<T> {
/**
* The type of the event.
*/
eventType: string;
/**
* The time the event was generated. If not provided, the current time will be used.
*/
eventTime?: Date;
/**
* An unique identifier for the event. If an ID is not provided, a random UUID will be generated
* and used.
*/
id?: string;
/**
* The resource path of the event source.
*/
topic?: string;
/**
* A resource path relative to the topic path.
*/
subject: string;
/**
* The schema version of the data object.
*/
dataVersion: string;
/**
* Event data specific to the event type.
*/
data: T;
}
/**
* An event in the in the Event Grid Schema.
*/
export interface EventGridEvent<T> {
/**
* The type of the event.
*/
eventType: string;
/**
* The time the event was generated.
*/
eventTime: Date;
/**
* An unique identifier for the event.
*/
id: string;
/**
* The resource path of the event source.
*/
topic?: string;
/**
* A resource path relative to the topic path.
*/
subject: string;
/**
* The schema version of the data object.
*/
dataVersion: string;
/**
* Event data specific to the event type.
*/
data: T;
}
/**
* * The shape of the input for EventGridProducerClient#sendCloudEvents
*/
export interface SendCloudEventInput<T> {
/**
* Type of event related to the originating occurrence.
*/
type: string;
/**
* Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event.
*/
source: string;
/**
* An identifier for the event. The combination of id and source must be unique for each distinct event. If an ID is not provided,
* a random UUID will be generated and used.
*/
id?: string;
/**
* The time the event was generated. If not provided, the current time will be used.
*/
time?: Date;
/**
* Identifies the schema that data adheres to.
*/
dataschema?: string;
/**
* Content type of data value.
*/
datacontenttype?: string;
/**
* Event data specific to the event type.
*/
data?: T;
/**
* This describes the subject of the event in the context of the event producer (identified by source).
*/
subject?: string;
/**
* Additional context attributes for the event. The Cloud Event specification refers to these as "extension attributes".
*/
extensionAttributes?: Record<string, unknown>;
}
/**
* An event in the Cloud Event 1.0 schema.
*/
export interface CloudEvent<T> {
/**
* Type of event related to the originating occurrence.
*/
type: string;
/**
* Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event.
*/
source: string;
/**
* An identifier for the event. The combination of id and source must be unique for each distinct event.
*/
id: string;
/**
* The time the event was generated.
*/
time?: Date;
/**
* Identifies the schema that data adheres to.
*/
dataschema?: string;
/**
* Content type of data value.
*/
datacontenttype?: string;
/**
* Event data specific to the event type.
*/
data?: T;
/**
* This describes the subject of the event in the context of the event producer (identified by source).
*/
subject?: string;
/**
* Additional context attributes for the event. The Cloud Event specification refers to these as "extension attributes".
*/
extensionAttributes?: Record<string, unknown>;
}
/**
* Property names defined by the CloudEvents 1.0 specification, these may not be reused as the names of extension properties.
*/
export const cloudEventReservedPropertyNames = [
"specversion",
"id",
"source",
"type",
"datacontenttype",
"dataschema",
"subject",
"time",
"data",
];
/**
* A function which provides custom logic to be used when decoding events.
*/
export type CustomEventDataDeserializer = (o: any) => Promise<any>;