@azure/eventgrid-namespaces 1.0.0-beta.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -16
- package/dist/index.js +403 -201
- package/dist/index.js.map +1 -1
- package/dist-esm/src/cadl-generated/EventGridClient.js +20 -28
- package/dist-esm/src/cadl-generated/EventGridClient.js.map +1 -1
- package/dist-esm/src/cadl-generated/api/EventGridContext.js +2 -2
- package/dist-esm/src/cadl-generated/api/EventGridContext.js.map +1 -1
- package/dist-esm/src/cadl-generated/api/operations.js +25 -29
- package/dist-esm/src/cadl-generated/api/operations.js.map +1 -1
- package/dist-esm/src/cadl-generated/index.js.map +1 -1
- package/dist-esm/src/cadl-generated/models/index.js.map +1 -1
- package/dist-esm/src/cadl-generated/models/models.js.map +1 -1
- package/dist-esm/src/cadl-generated/models/options.js.map +1 -1
- package/dist-esm/src/cadl-generated/rest/clientDefinitions.js.map +1 -1
- package/dist-esm/src/cadl-generated/rest/eventGridClient.js +9 -9
- package/dist-esm/src/cadl-generated/rest/eventGridClient.js.map +1 -1
- package/dist-esm/src/cadl-generated/rest/isUnexpected.js.map +1 -1
- package/dist-esm/src/cadl-generated/rest/models.js.map +1 -1
- package/dist-esm/src/cadl-generated/rest/parameters.js.map +1 -1
- package/dist-esm/src/cloudEventDistrubtedTracingEnricherPolicy.js +53 -0
- package/dist-esm/src/cloudEventDistrubtedTracingEnricherPolicy.js.map +1 -0
- package/dist-esm/src/consumer.js +73 -0
- package/dist-esm/src/consumer.js.map +1 -0
- package/dist-esm/src/eventGridNamespacesPublishBinaryMode.js.map +1 -1
- package/dist-esm/src/eventGridReceiverClient.js +98 -0
- package/dist-esm/src/eventGridReceiverClient.js.map +1 -0
- package/dist-esm/src/eventGridSenderClient.js +72 -0
- package/dist-esm/src/eventGridSenderClient.js.map +1 -0
- package/dist-esm/src/index.js +3 -2
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/models.js +3 -3
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/src/util.js +155 -0
- package/dist-esm/src/util.js.map +1 -0
- package/package.json +9 -10
- package/types/eventgrid-namespaces.d.ts +126 -99
- package/dist-esm/src/eventGridNamespacesClient.js +0 -147
- package/dist-esm/src/eventGridNamespacesClient.js.map +0 -1
@@ -1,11 +1,14 @@
|
|
1
1
|
import { AzureKeyCredential } from '@azure/core-auth';
|
2
2
|
import { ClientOptions } from '@azure-rest/core-client';
|
3
3
|
import { ErrorModel } from '@azure-rest/core-client';
|
4
|
-
import { EventGridDeserializer } from '@azure/eventgrid';
|
5
4
|
import { OperationOptions } from '@azure-rest/core-client';
|
6
5
|
import { TokenCredential } from '@azure/core-auth';
|
7
6
|
|
8
|
-
export declare interface
|
7
|
+
export declare interface AcknowledgeEventsOptionalParams extends OperationOptions {
|
8
|
+
}
|
9
|
+
|
10
|
+
/** Acknowledge Events Options */
|
11
|
+
export declare interface AcknowledgeEventsOptions extends AcknowledgeEventsOptionalParams {
|
9
12
|
}
|
10
13
|
|
11
14
|
/** The result of the Acknowledge operation. */
|
@@ -49,11 +52,11 @@ export declare interface CloudEvent<T> {
|
|
49
52
|
/**
|
50
53
|
* Identifies the schema that data adheres to.
|
51
54
|
*/
|
52
|
-
|
55
|
+
dataSchema?: string;
|
53
56
|
/**
|
54
57
|
* Content type of data value.
|
55
58
|
*/
|
56
|
-
|
59
|
+
dataContentType?: string;
|
57
60
|
/**
|
58
61
|
* Event data specific to the event type.
|
59
62
|
*/
|
@@ -69,75 +72,57 @@ export declare interface CloudEvent<T> {
|
|
69
72
|
/**
|
70
73
|
* The version of the CloudEvents specification which the event uses.
|
71
74
|
*/
|
72
|
-
|
75
|
+
specVersion?: string | "1.0";
|
73
76
|
}
|
74
77
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
id: string;
|
79
|
-
/** Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. */
|
80
|
-
source: string;
|
81
|
-
/** Event data specific to the event type. */
|
82
|
-
data?: unknown;
|
83
|
-
/** Event data specific to the event type, encoded as a base64 string. */
|
84
|
-
dataBase64?: Uint8Array;
|
85
|
-
/** Type of event related to the originating occurrence. */
|
86
|
-
type: string;
|
87
|
-
/** The time (in UTC) the event was generated, in RFC3339 format. */
|
88
|
-
time?: Date;
|
89
|
-
/** The version of the CloudEvents specification which the event uses. */
|
90
|
-
specversion: string;
|
91
|
-
/** Identifies the schema that data adheres to. */
|
92
|
-
dataschema?: string;
|
93
|
-
/** Content type of data value. */
|
94
|
-
datacontenttype?: string;
|
95
|
-
/** This describes the subject of the event in the context of the event producer (identified by source). */
|
96
|
-
subject?: string;
|
78
|
+
export declare interface EventGridClientOptions extends ClientOptions {
|
79
|
+
/** The API version to use for this operation. */
|
80
|
+
apiVersion?: string;
|
97
81
|
}
|
98
82
|
|
99
83
|
/**
|
100
|
-
*
|
84
|
+
* EventGridDeserializer is used to aid in processing events delivered by EventGrid. It can deserialize a JSON encoded payload
|
85
|
+
* of either a single event or batch of events as well as be used to convert the result of `JSON.parse` into an
|
86
|
+
* `EventGridEvent` or `CloudEvent` like object.
|
87
|
+
*
|
88
|
+
* Unlike normal JSON deseralization, EventGridDeserializer does some additional conversions:
|
89
|
+
*
|
90
|
+
* - The consumer parses the event time property into a `Date` object, for ease of use.
|
91
|
+
* - When deserializing an event in the CloudEvent schema, if the event contains binary data, it is base64 decoded
|
92
|
+
* and returned as an instance of the `Uint8Array` type.
|
101
93
|
*/
|
102
|
-
export declare class
|
103
|
-
private _client;
|
104
|
-
/** Azure Messaging EventGrid Client */
|
105
|
-
constructor(endpoint: string, credential: AzureKeyCredential | TokenCredential, options?: EventGridClientOptions);
|
94
|
+
export declare class EventGridDeserializer {
|
106
95
|
/**
|
107
|
-
*
|
108
|
-
* status code with an empty JSON object in response. Otherwise, the server can return various error codes.
|
109
|
-
* For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message
|
110
|
-
* is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for
|
111
|
-
* internal server error.
|
112
|
-
*
|
113
|
-
* @param event - Event to publish
|
114
|
-
* @param topicName - Topic to publish the event
|
115
|
-
* @param options - Options to publish
|
96
|
+
* Deserializes events encoded in the Cloud Events 1.0 schema.
|
116
97
|
*
|
98
|
+
* @param encodedEvents - the JSON encoded representation of either a single event or an array of
|
99
|
+
* events, encoded in the Cloud Events 1.0 Schema.
|
117
100
|
*/
|
118
|
-
|
101
|
+
deserializeCloudEvents(encodedEvents: string): Promise<CloudEvent<unknown>[]>;
|
119
102
|
/**
|
120
|
-
*
|
121
|
-
* status code with an empty JSON object in response. Otherwise, the server can return various error codes.
|
122
|
-
* For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message
|
123
|
-
* is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for
|
124
|
-
* internal server error.
|
125
|
-
*
|
126
|
-
* @param events - Events to publish
|
127
|
-
* @param topicName - Topic to publish the event
|
128
|
-
* @param options - Options to publish
|
103
|
+
* Deserializes events encoded in the Cloud Events 1.0 schema.
|
129
104
|
*
|
105
|
+
* @param encodedEvents - an object representing a single event, encoded in the Cloud Events 1.0 schema.
|
130
106
|
*/
|
131
|
-
|
107
|
+
deserializeCloudEvents(encodedEvents: Record<string, unknown>): Promise<CloudEvent<unknown>[]>;
|
108
|
+
}
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Event Grid Namespaces Client
|
112
|
+
*/
|
113
|
+
export declare class EventGridReceiverClient {
|
114
|
+
private _client;
|
115
|
+
private _topicName;
|
116
|
+
private _subscriptionName;
|
117
|
+
/** Azure Messaging EventGrid Client */
|
118
|
+
constructor(endpoint: string, credential: AzureKeyCredential | TokenCredential, topicName: string, subscriptionName: string, options?: EventGridReceiverClientOptions);
|
132
119
|
/**
|
133
120
|
* Receive Batch of Cloud Events from the Event Subscription.
|
134
121
|
*
|
135
|
-
* @param topicName - Topic to receive
|
136
|
-
* @param eventSubscriptionName - Name of the Event Subscription
|
137
122
|
* @param options - Options to receive
|
138
123
|
*
|
139
124
|
*/
|
140
|
-
|
125
|
+
receiveEvents<T>(options?: ReceiveEventsOptions): Promise<ReceiveResult<T>>;
|
141
126
|
/**
|
142
127
|
* Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one
|
143
128
|
* event is successfully acknowledged. The response body will include the set of successfully acknowledged
|
@@ -145,49 +130,66 @@ export declare class EventGridClient {
|
|
145
130
|
* acknowledged events will no longer be available to any consumer.
|
146
131
|
*
|
147
132
|
* @param lockTokens - Lock Tokens
|
148
|
-
* @param topicName - Topic Name
|
149
|
-
* @param eventSubscriptionName - Name of the Event Subscription
|
150
133
|
* @param options - Options to Acknowledge
|
151
134
|
*
|
152
135
|
*/
|
153
|
-
|
136
|
+
acknowledgeEvents(lockTokens: string[], options?: AcknowledgeEventsOptions): Promise<AcknowledgeResult>;
|
154
137
|
/**
|
155
138
|
* Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is
|
156
139
|
* successfully released. The response body will include the set of successfully released lockTokens, along
|
157
140
|
* with other failed lockTokens with their corresponding error information.
|
158
141
|
*
|
159
142
|
* @param lockTokens - Lock Tokens
|
160
|
-
* @param topicName - Topic Name
|
161
|
-
* @param eventSubscriptionName - Name of the Event Subscription
|
162
143
|
* @param options - Options to release
|
163
144
|
*
|
164
145
|
*/
|
165
|
-
|
146
|
+
releaseEvents(lockTokens: string[], options?: ReleaseEventsOptions): Promise<ReleaseResult>;
|
166
147
|
/**
|
167
148
|
* Reject batch of Cloud Events.
|
168
149
|
*
|
169
150
|
* @param lockTokens - Lock Tokens
|
170
|
-
* @param topicName - Topic Name
|
171
|
-
* @param eventSubscriptionName - Name of the Event Subscription
|
172
151
|
* @param options - Options to reject
|
173
152
|
*
|
174
153
|
*/
|
175
|
-
|
154
|
+
rejectEvents(lockTokens: string[], options?: RejectEventsOptions): Promise<RejectResult>;
|
176
155
|
/**
|
177
156
|
* Renew lock for batch of Cloud Events.
|
178
157
|
*
|
179
158
|
* @param lockTokens - Lock Tokens
|
180
|
-
* @param topicName - Topic Name
|
181
|
-
* @param eventSubscriptionName - Name of the Event Subscription
|
182
159
|
* @param options - Options to renew
|
183
160
|
*/
|
184
|
-
|
161
|
+
renewEventLocks(lockTokens: string[], options?: RenewEventLocksOptions): Promise<RenewLocksResult>;
|
185
162
|
}
|
186
163
|
|
187
|
-
|
164
|
+
/** Event Grid Receiver Client Options */
|
165
|
+
export declare interface EventGridReceiverClientOptions extends EventGridClientOptions {
|
166
|
+
}
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Event Grid Namespaces Client
|
170
|
+
*/
|
171
|
+
export declare class EventGridSenderClient {
|
172
|
+
private _client;
|
173
|
+
private _topicName;
|
174
|
+
/** Azure Messaging EventGrid Client */
|
175
|
+
constructor(endpoint: string, credential: AzureKeyCredential | TokenCredential, topicName: string, options?: EventGridSenderClientOptions);
|
176
|
+
/**
|
177
|
+
* Publish Cloud Events to namespace topic. In case of success, the server responds with an HTTP 200
|
178
|
+
* status code with an empty JSON object in response. Otherwise, the server can return various error codes.
|
179
|
+
* For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message
|
180
|
+
* is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for
|
181
|
+
* internal server error.
|
182
|
+
*
|
183
|
+
* @param events - Events to publish
|
184
|
+
* @param options - Options to publish
|
185
|
+
*
|
186
|
+
*/
|
187
|
+
sendEvents<T>(events: CloudEvent<T>[] | CloudEvent<T>, options?: SendEventsOptions): Promise<void>;
|
188
188
|
}
|
189
189
|
|
190
|
-
|
190
|
+
/** Event Grid Sender Client Options */
|
191
|
+
export declare interface EventGridSenderClientOptions extends EventGridClientOptions {
|
192
|
+
}
|
191
193
|
|
192
194
|
/** Failed LockToken information. */
|
193
195
|
export declare interface FailedLockToken {
|
@@ -197,46 +199,52 @@ export declare interface FailedLockToken {
|
|
197
199
|
error: ErrorModel;
|
198
200
|
}
|
199
201
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
202
|
+
/** Known values of {@link ReleaseDelay} that the service accepts. */
|
203
|
+
export declare const enum KnownReleaseDelay {
|
204
|
+
/** Ten Minutes */
|
205
|
+
TenMinutes = "600",
|
206
|
+
/** One Minute */
|
207
|
+
OneMinute = "60",
|
208
|
+
/** Ten Seconds */
|
209
|
+
TenSeconds = "10",
|
210
|
+
/** One Hour */
|
211
|
+
OneHour = "3600",
|
212
|
+
/** No Delay */
|
213
|
+
NoDelay = "0"
|
207
214
|
}
|
208
215
|
|
209
|
-
export
|
210
|
-
/** content type */
|
211
|
-
contentType?: string;
|
212
|
-
}
|
216
|
+
export { OperationOptions }
|
213
217
|
|
214
|
-
/**
|
215
|
-
export declare interface
|
218
|
+
/** Receive operation details per Cloud Event. */
|
219
|
+
export declare interface ReceiveDetails<T> {
|
220
|
+
/** The Event Broker details. */
|
221
|
+
brokerProperties: BrokerProperties;
|
222
|
+
/** Cloud Event details. */
|
223
|
+
event: CloudEvent<T>;
|
216
224
|
}
|
217
225
|
|
218
|
-
export declare interface
|
226
|
+
export declare interface ReceiveEventsOptionalParams extends OperationOptions {
|
219
227
|
/** Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not specified, the default value is 1. */
|
220
228
|
maxEvents?: number;
|
221
229
|
/** Max wait time value for receive operation in Seconds. It is the time in seconds that the server approximately waits for the availability of an event and responds to the request. If an event is available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120 seconds. If not specified, the default value is 60 seconds. */
|
222
230
|
maxWaitTime?: number;
|
223
231
|
}
|
224
232
|
|
225
|
-
/** Receive
|
226
|
-
export declare interface
|
227
|
-
/** The Event Broker details. */
|
228
|
-
brokerProperties: BrokerProperties;
|
229
|
-
/** Cloud Event details. */
|
230
|
-
event: CloudEvent_2;
|
233
|
+
/** Receive Events Options */
|
234
|
+
export declare interface ReceiveEventsOptions extends ReceiveEventsOptionalParams {
|
231
235
|
}
|
232
236
|
|
233
237
|
/** Details of the Receive operation response. */
|
234
|
-
export declare interface ReceiveResult {
|
238
|
+
export declare interface ReceiveResult<T> {
|
235
239
|
/** Array of receive responses, one per cloud event. */
|
236
|
-
|
240
|
+
details: ReceiveDetails<T>[];
|
237
241
|
}
|
238
242
|
|
239
|
-
export declare interface
|
243
|
+
export declare interface RejectEventsOptionalParams extends OperationOptions {
|
244
|
+
}
|
245
|
+
|
246
|
+
/** Reject Events Options */
|
247
|
+
export declare interface RejectEventsOptions extends RejectEventsOptionalParams {
|
240
248
|
}
|
241
249
|
|
242
250
|
/** The result of the Reject operation. */
|
@@ -247,15 +255,16 @@ export declare interface RejectResult {
|
|
247
255
|
succeededLockTokens: string[];
|
248
256
|
}
|
249
257
|
|
250
|
-
export declare interface ReleaseCloudEventsOptions extends OperationOptions {
|
251
|
-
/** Release cloud events with the specified delay in seconds. */
|
252
|
-
releaseDelayInSeconds?: ReleaseDelay;
|
253
|
-
}
|
254
|
-
|
255
258
|
/** Supported delays for release operation. */
|
256
259
|
/** "0", "10", "60", "600", "3600" */
|
257
260
|
export declare type ReleaseDelay = string;
|
258
261
|
|
262
|
+
/** Release Events Options */
|
263
|
+
export declare interface ReleaseEventsOptions extends OperationOptions {
|
264
|
+
/** Release events with the specified delay in seconds. */
|
265
|
+
releaseDelay?: ReleaseDelay;
|
266
|
+
}
|
267
|
+
|
259
268
|
/** The result of the Release operation. */
|
260
269
|
export declare interface ReleaseResult {
|
261
270
|
/** Array of FailedLockToken for failed cloud events. Each FailedLockToken includes the lock token along with the related error information (namely, the error code and description). */
|
@@ -264,15 +273,33 @@ export declare interface ReleaseResult {
|
|
264
273
|
succeededLockTokens: string[];
|
265
274
|
}
|
266
275
|
|
267
|
-
export declare interface
|
276
|
+
export declare interface RenewEventLocksOptionalParams extends OperationOptions {
|
277
|
+
}
|
278
|
+
|
279
|
+
/** Renew Event Locks Options */
|
280
|
+
export declare interface RenewEventLocksOptions extends RenewEventLocksOptionalParams {
|
268
281
|
}
|
269
282
|
|
270
283
|
/** The result of the RenewLock operation. */
|
271
|
-
export declare interface
|
284
|
+
export declare interface RenewLocksResult {
|
272
285
|
/** Array of FailedLockToken for failed cloud events. Each FailedLockToken includes the lock token along with the related error information (namely, the error code and description). */
|
273
286
|
failedLockTokens: FailedLockToken[];
|
274
287
|
/** Array of lock tokens for the successfully renewed locks. */
|
275
288
|
succeededLockTokens: string[];
|
276
289
|
}
|
277
290
|
|
291
|
+
export declare interface SendEventOptionalParams extends OperationOptions {
|
292
|
+
/** content type */
|
293
|
+
contentType?: string;
|
294
|
+
}
|
295
|
+
|
296
|
+
export declare interface SendEventsOptionalParams extends OperationOptions {
|
297
|
+
/** content type */
|
298
|
+
contentType?: string;
|
299
|
+
}
|
300
|
+
|
301
|
+
/** Send Events Options */
|
302
|
+
export declare interface SendEventsOptions extends SendEventOptionalParams {
|
303
|
+
}
|
304
|
+
|
278
305
|
export { }
|
@@ -1,147 +0,0 @@
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
2
|
-
// Licensed under the MIT license.
|
3
|
-
import { randomUUID } from "@azure/core-util";
|
4
|
-
import { EventGridClient as EventGridClientGenerated } from "./cadl-generated/EventGridClient";
|
5
|
-
import { cloudEventReservedPropertyNames } from "./models";
|
6
|
-
import { publishCloudEventInBinaryMode } from "./eventGridNamespacesPublishBinaryMode";
|
7
|
-
/**
|
8
|
-
* Event Grid Namespaces Client
|
9
|
-
*/
|
10
|
-
export class EventGridNamespacesClient {
|
11
|
-
/** Azure Messaging EventGrid Client */
|
12
|
-
constructor(endpoint, credential, options = {}) {
|
13
|
-
// credential.update(`SharedAccessKey ${credential.key}`);
|
14
|
-
this._client = new EventGridClientGenerated(endpoint, credential, options);
|
15
|
-
}
|
16
|
-
/**
|
17
|
-
* Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200
|
18
|
-
* status code with an empty JSON object in response. Otherwise, the server can return various error codes.
|
19
|
-
* For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message
|
20
|
-
* is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for
|
21
|
-
* internal server error.
|
22
|
-
*
|
23
|
-
* @param event - Event to publish
|
24
|
-
* @param topicName - Topic to publish the event
|
25
|
-
* @param options - Options to publish
|
26
|
-
*
|
27
|
-
*/
|
28
|
-
async publishCloudEvent(event, topicName, options = { requestOptions: {} }) {
|
29
|
-
const cloudEventWireModel = convertCloudEventToModelType(event);
|
30
|
-
if (!options.binaryMode) {
|
31
|
-
await this._client.publishCloudEvent(topicName, cloudEventWireModel, options);
|
32
|
-
}
|
33
|
-
else {
|
34
|
-
await publishCloudEventInBinaryMode(this._client.getClient(), topicName, cloudEventWireModel, Object.assign({ contentType: options.contentType }, options));
|
35
|
-
}
|
36
|
-
}
|
37
|
-
/**
|
38
|
-
* Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200
|
39
|
-
* status code with an empty JSON object in response. Otherwise, the server can return various error codes.
|
40
|
-
* For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message
|
41
|
-
* is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for
|
42
|
-
* internal server error.
|
43
|
-
*
|
44
|
-
* @param events - Events to publish
|
45
|
-
* @param topicName - Topic to publish the event
|
46
|
-
* @param options - Options to publish
|
47
|
-
*
|
48
|
-
*/
|
49
|
-
async publishCloudEvents(events, topicName, options = { requestOptions: {} }) {
|
50
|
-
const eventsWireModel = [];
|
51
|
-
for (const individualevent of events) {
|
52
|
-
eventsWireModel.push(convertCloudEventToModelType(individualevent));
|
53
|
-
}
|
54
|
-
await this._client.publishCloudEvents(topicName, eventsWireModel, options);
|
55
|
-
}
|
56
|
-
/**
|
57
|
-
* Receive Batch of Cloud Events from the Event Subscription.
|
58
|
-
*
|
59
|
-
* @param topicName - Topic to receive
|
60
|
-
* @param eventSubscriptionName - Name of the Event Subscription
|
61
|
-
* @param options - Options to receive
|
62
|
-
*
|
63
|
-
*/
|
64
|
-
receiveCloudEvents(topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
65
|
-
return this._client.receiveCloudEvents(topicName, eventSubscriptionName, options);
|
66
|
-
}
|
67
|
-
/**
|
68
|
-
* Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one
|
69
|
-
* event is successfully acknowledged. The response body will include the set of successfully acknowledged
|
70
|
-
* lockTokens, along with other failed lockTokens with their corresponding error information. Successfully
|
71
|
-
* acknowledged events will no longer be available to any consumer.
|
72
|
-
*
|
73
|
-
* @param lockTokens - Lock Tokens
|
74
|
-
* @param topicName - Topic Name
|
75
|
-
* @param eventSubscriptionName - Name of the Event Subscription
|
76
|
-
* @param options - Options to Acknowledge
|
77
|
-
*
|
78
|
-
*/
|
79
|
-
acknowledgeCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
80
|
-
return this._client.acknowledgeCloudEvents(topicName, eventSubscriptionName, { lockTokens }, options);
|
81
|
-
}
|
82
|
-
/**
|
83
|
-
* Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is
|
84
|
-
* successfully released. The response body will include the set of successfully released lockTokens, along
|
85
|
-
* with other failed lockTokens with their corresponding error information.
|
86
|
-
*
|
87
|
-
* @param lockTokens - Lock Tokens
|
88
|
-
* @param topicName - Topic Name
|
89
|
-
* @param eventSubscriptionName - Name of the Event Subscription
|
90
|
-
* @param options - Options to release
|
91
|
-
*
|
92
|
-
*/
|
93
|
-
releaseCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
94
|
-
return this._client.releaseCloudEvents(topicName, eventSubscriptionName, { lockTokens }, options);
|
95
|
-
}
|
96
|
-
/**
|
97
|
-
* Reject batch of Cloud Events.
|
98
|
-
*
|
99
|
-
* @param lockTokens - Lock Tokens
|
100
|
-
* @param topicName - Topic Name
|
101
|
-
* @param eventSubscriptionName - Name of the Event Subscription
|
102
|
-
* @param options - Options to reject
|
103
|
-
*
|
104
|
-
*/
|
105
|
-
rejectCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
106
|
-
return this._client.rejectCloudEvents(topicName, eventSubscriptionName, { lockTokens }, options);
|
107
|
-
}
|
108
|
-
/**
|
109
|
-
* Renew lock for batch of Cloud Events.
|
110
|
-
*
|
111
|
-
* @param lockTokens - Lock Tokens
|
112
|
-
* @param topicName - Topic Name
|
113
|
-
* @param eventSubscriptionName - Name of the Event Subscription
|
114
|
-
* @param options - Options to renew
|
115
|
-
*/
|
116
|
-
renewCloudEventLocks(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
117
|
-
return this._client.renewCloudEventLocks(topicName, eventSubscriptionName, { lockTokens }, options);
|
118
|
-
}
|
119
|
-
}
|
120
|
-
export function convertCloudEventToModelType(event) {
|
121
|
-
var _a, _b, _c, _d, _e;
|
122
|
-
if (event.extensionAttributes) {
|
123
|
-
for (const propName in event.extensionAttributes) {
|
124
|
-
// Per the cloud events spec: "CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z') or digits ('0' to '9') from the ASCII character set"
|
125
|
-
// they also can not match an existing defined property name.
|
126
|
-
if (!/^[a-z0-9]*$/.test(propName) ||
|
127
|
-
cloudEventReservedPropertyNames.indexOf(propName) !== -1) {
|
128
|
-
throw new Error(`invalid extension attribute name: ${propName}`);
|
129
|
-
}
|
130
|
-
}
|
131
|
-
}
|
132
|
-
const converted = Object.assign({ specversion: (_a = event.specversion) !== null && _a !== void 0 ? _a : "1.0", type: event.type, source: event.source, id: (_b = event.id) !== null && _b !== void 0 ? _b : randomUUID(), time: (_c = event.time) !== null && _c !== void 0 ? _c : new Date(), subject: event.subject, dataschema: event.dataschema }, ((_d = event.extensionAttributes) !== null && _d !== void 0 ? _d : []));
|
133
|
-
if (event.data instanceof Uint8Array) {
|
134
|
-
if (!event.datacontenttype) {
|
135
|
-
throw new Error("a data content type must be provided when sending an event with binary data");
|
136
|
-
}
|
137
|
-
converted.datacontenttype = event.datacontenttype;
|
138
|
-
converted.dataBase64 = event.data;
|
139
|
-
}
|
140
|
-
else {
|
141
|
-
converted.datacontenttype =
|
142
|
-
(_e = event.datacontenttype) !== null && _e !== void 0 ? _e : "application/cloudevents+json; charset=utf-8";
|
143
|
-
converted.data = event.data;
|
144
|
-
}
|
145
|
-
return converted;
|
146
|
-
}
|
147
|
-
//# sourceMappingURL=eventGridNamespacesClient.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"eventGridNamespacesClient.js","sourceRoot":"","sources":["../../src/eventGridNamespacesClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAiBlC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,IAAI,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE/F,OAAO,EAAwC,+BAA+B,EAAE,MAAM,UAAU,CAAC;AACjG,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAGpC,uCAAuC;IACvC,YACE,QAAgB,EAChB,UAAgD,EAChD,UAAkC,EAAE;QAEpC,0DAA0D;QAC1D,IAAI,CAAC,OAAO,GAAG,IAAI,wBAAwB,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,iBAAiB,CACrB,KAAoB,EACpB,SAAiB,EACjB,UAAoC,EAAE,cAAc,EAAE,EAAE,EAAE;QAE1D,MAAM,mBAAmB,GAAwB,4BAA4B,CAAC,KAAK,CAAC,CAAC;QAErF,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAChF,CAAC;aAAM,CAAC;YACN,MAAM,6BAA6B,CACjC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EACxB,SAAS,EACT,mBAAmB,kBAEjB,WAAW,EAAE,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I,EAAE,CAAC,CACrC,CAAC;IAEF,IAAI,KAAK,CAAC,IAAI,YAAY,UAAU,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;QACJ,CAAC;QAED,SAAS,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QAClD,SAAS,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,SAAS,CAAC,eAAe;YACvB,MAAA,KAAK,CAAC,eAAe,mCAAI,6CAA6C,CAAC;QACzE,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AzureKeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport {\n ReceiveResult,\n AcknowledgeResult,\n ReleaseResult,\n RejectResult,\n PublishCloudEventsOptions,\n ReceiveCloudEventsOptions,\n AcknowledgeCloudEventsOptions,\n ReleaseCloudEventsOptions,\n RejectCloudEventsOptions,\n RenewCloudEventLocksOptions,\n RenewCloudEventLocksResult,\n CloudEvent as CloudEventWireModel,\n} from \"./cadl-generated/models\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { EventGridClient as EventGridClientGenerated } from \"./cadl-generated/EventGridClient\";\nimport { EventGridClientOptions } from \"./cadl-generated/api\";\nimport { PublishCloudEventOptions, CloudEvent, cloudEventReservedPropertyNames } from \"./models\";\nimport { publishCloudEventInBinaryMode } from \"./eventGridNamespacesPublishBinaryMode\";\n\n/**\n * Event Grid Namespaces Client\n */\nexport class EventGridNamespacesClient {\n private _client: EventGridClientGenerated;\n\n /** Azure Messaging EventGrid Client */\n constructor(\n endpoint: string,\n credential: AzureKeyCredential | TokenCredential,\n options: EventGridClientOptions = {},\n ) {\n // credential.update(`SharedAccessKey ${credential.key}`);\n this._client = new EventGridClientGenerated(endpoint, credential, options);\n }\n\n /**\n * Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200\n * status code with an empty JSON object in response. Otherwise, the server can return various error codes.\n * For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message\n * is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for\n * internal server error.\n *\n * @param event - Event to publish\n * @param topicName - Topic to publish the event\n * @param options - Options to publish\n *\n */\n async publishCloudEvent<T>(\n event: CloudEvent<T>,\n topicName: string,\n options: PublishCloudEventOptions = { requestOptions: {} },\n ): Promise<void> {\n const cloudEventWireModel: CloudEventWireModel = convertCloudEventToModelType(event);\n\n if (!options.binaryMode) {\n await this._client.publishCloudEvent(topicName, cloudEventWireModel, options);\n } else {\n await publishCloudEventInBinaryMode(\n this._client.getClient(),\n topicName,\n cloudEventWireModel,\n {\n contentType: options.contentType,\n ...options,\n },\n );\n }\n }\n\n /**\n * Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200\n * status code with an empty JSON object in response. Otherwise, the server can return various error codes.\n * For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message\n * is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for\n * internal server error.\n *\n * @param events - Events to publish\n * @param topicName - Topic to publish the event\n * @param options - Options to publish\n *\n */\n async publishCloudEvents<T>(\n events: CloudEvent<T>[],\n topicName: string,\n options: PublishCloudEventsOptions = { requestOptions: {} },\n ): Promise<void> {\n const eventsWireModel: Array<CloudEventWireModel> = [];\n for (const individualevent of events) {\n eventsWireModel.push(convertCloudEventToModelType(individualevent));\n }\n await this._client.publishCloudEvents(topicName, eventsWireModel, options);\n }\n\n /**\n * Receive Batch of Cloud Events from the Event Subscription.\n *\n * @param topicName - Topic to receive\n * @param eventSubscriptionName - Name of the Event Subscription\n * @param options - Options to receive\n *\n */\n receiveCloudEvents(\n topicName: string,\n eventSubscriptionName: string,\n options: ReceiveCloudEventsOptions = { requestOptions: {} },\n ): Promise<ReceiveResult> {\n return this._client.receiveCloudEvents(topicName, eventSubscriptionName, options);\n }\n\n /**\n * Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one\n * event is successfully acknowledged. The response body will include the set of successfully acknowledged\n * lockTokens, along with other failed lockTokens with their corresponding error information. Successfully\n * acknowledged events will no longer be available to any consumer.\n *\n * @param lockTokens - Lock Tokens\n * @param topicName - Topic Name\n * @param eventSubscriptionName - Name of the Event Subscription\n * @param options - Options to Acknowledge\n *\n */\n acknowledgeCloudEvents(\n lockTokens: string[],\n topicName: string,\n eventSubscriptionName: string,\n options: AcknowledgeCloudEventsOptions = { requestOptions: {} },\n ): Promise<AcknowledgeResult> {\n return this._client.acknowledgeCloudEvents(\n topicName,\n eventSubscriptionName,\n { lockTokens },\n options,\n );\n }\n\n /**\n * Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is\n * successfully released. The response body will include the set of successfully released lockTokens, along\n * with other failed lockTokens with their corresponding error information.\n *\n * @param lockTokens - Lock Tokens\n * @param topicName - Topic Name\n * @param eventSubscriptionName - Name of the Event Subscription\n * @param options - Options to release\n *\n */\n releaseCloudEvents(\n lockTokens: string[],\n topicName: string,\n eventSubscriptionName: string,\n options: ReleaseCloudEventsOptions = { requestOptions: {} },\n ): Promise<ReleaseResult> {\n return this._client.releaseCloudEvents(\n topicName,\n eventSubscriptionName,\n { lockTokens },\n options,\n );\n }\n\n /**\n * Reject batch of Cloud Events.\n *\n * @param lockTokens - Lock Tokens\n * @param topicName - Topic Name\n * @param eventSubscriptionName - Name of the Event Subscription\n * @param options - Options to reject\n *\n */\n rejectCloudEvents(\n lockTokens: string[],\n topicName: string,\n eventSubscriptionName: string,\n options: RejectCloudEventsOptions = { requestOptions: {} },\n ): Promise<RejectResult> {\n return this._client.rejectCloudEvents(\n topicName,\n eventSubscriptionName,\n { lockTokens },\n options,\n );\n }\n\n /**\n * Renew lock for batch of Cloud Events.\n *\n * @param lockTokens - Lock Tokens\n * @param topicName - Topic Name\n * @param eventSubscriptionName - Name of the Event Subscription\n * @param options - Options to renew\n */\n renewCloudEventLocks(\n lockTokens: string[],\n topicName: string,\n eventSubscriptionName: string,\n options: RenewCloudEventLocksOptions = { requestOptions: {} },\n ): Promise<RenewCloudEventLocksResult> {\n return this._client.renewCloudEventLocks(\n topicName,\n eventSubscriptionName,\n { lockTokens },\n options,\n );\n }\n}\n\nexport function convertCloudEventToModelType<T>(event: CloudEvent<T>): CloudEventWireModel {\n if (event.extensionAttributes) {\n for (const propName in event.extensionAttributes) {\n // Per the cloud events spec: \"CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z') or digits ('0' to '9') from the ASCII character set\"\n // they also can not match an existing defined property name.\n\n if (\n !/^[a-z0-9]*$/.test(propName) ||\n cloudEventReservedPropertyNames.indexOf(propName) !== -1\n ) {\n throw new Error(`invalid extension attribute name: ${propName}`);\n }\n }\n }\n\n const converted: CloudEventWireModel = {\n specversion: event.specversion ?? \"1.0\",\n type: event.type,\n source: event.source,\n id: event.id ?? randomUUID(),\n time: event.time ?? new Date(),\n subject: event.subject,\n dataschema: event.dataschema,\n ...(event.extensionAttributes ?? []),\n };\n\n if (event.data instanceof Uint8Array) {\n if (!event.datacontenttype) {\n throw new Error(\n \"a data content type must be provided when sending an event with binary data\",\n );\n }\n\n converted.datacontenttype = event.datacontenttype;\n converted.dataBase64 = event.data;\n } else {\n converted.datacontenttype =\n event.datacontenttype ?? \"application/cloudevents+json; charset=utf-8\";\n converted.data = event.data;\n }\n\n return converted;\n}\n"]}
|