@azure/eventgrid 4.15.1-alpha.20231023.1 → 4.15.1-alpha.20231030.1
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 +25 -32
- package/package.json +3 -3
package/README.md
CHANGED
@@ -252,45 +252,38 @@ await client.send([
|
|
252
252
|
|
253
253
|
### Deserializing an Event
|
254
254
|
|
255
|
-
`EventGridDeserializer` can be used to deserialize events delivered by Event Grid.
|
255
|
+
`EventGridDeserializer` can be used to deserialize events delivered by Event Grid. In this example we have a cloud event that is deserialized using `EventGridDeserializer` and use `isSystemEvent` to detect what type of events they are.
|
256
256
|
|
257
257
|
```js
|
258
|
-
const { ServiceBusClient } = require("@azure/service-bus");
|
259
|
-
const { DefaultAzureCredential } = require("@azure/identity");
|
260
258
|
const { EventGridDeserializer, isSystemEvent } = require("@azure/eventgrid");
|
261
259
|
|
262
|
-
|
263
|
-
|
264
|
-
const
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
260
|
+
async function main() {
|
261
|
+
const deserializer = new EventGridDeserializer();
|
262
|
+
const message = {
|
263
|
+
id: "5bc888aa-c2f4-11ea-b3de-0242ac130004",
|
264
|
+
source:
|
265
|
+
"/subscriptions/<subscriptionid>/resourceGroups/dummy-rg/providers/Microsoft.EventGrid/topics/dummy-topic",
|
266
|
+
specversion: "1.0",
|
267
|
+
type: "Microsoft.ContainerRegistry.ImagePushed",
|
268
|
+
subject: "Test Subject",
|
269
|
+
time: "2020-07-10T21:27:12.925Z",
|
270
|
+
data: {
|
271
|
+
hello: "world",
|
272
|
+
},
|
273
|
+
};
|
274
|
+
const deserializedMessage = await deserializer.deserializeCloudEvents(message);
|
275
|
+
console.log(deserializedMessage);
|
276
|
+
|
277
|
+
if (
|
278
|
+
deserializedMessage != null &&
|
279
|
+
deserializedMessage.length !== 0 &&
|
280
|
+
isSystemEvent("Microsoft.ContainerRegistry.ImagePushed", deserializedMessage[0])
|
281
|
+
) {
|
282
|
+
console.log("This is a Microsoft.ContainerRegistry.ImagePushed event");
|
281
283
|
}
|
282
|
-
|
283
|
-
await message.complete();
|
284
284
|
}
|
285
285
|
|
286
|
-
|
287
|
-
|
288
|
-
receiver.subscribe({
|
289
|
-
processError: async (err) => {
|
290
|
-
console.error(err);
|
291
|
-
},
|
292
|
-
processMessage,
|
293
|
-
});
|
286
|
+
main();
|
294
287
|
```
|
295
288
|
|
296
289
|
## Troubleshooting
|
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"sdk-type": "client",
|
4
4
|
"author": "Microsoft Corporation",
|
5
5
|
"description": "An isomorphic client library for the Azure Event Grid service.",
|
6
|
-
"version": "4.15.1-alpha.
|
6
|
+
"version": "4.15.1-alpha.20231030.1",
|
7
7
|
"keywords": [
|
8
8
|
"node",
|
9
9
|
"azure",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
23
23
|
},
|
24
24
|
"engines": {
|
25
|
-
"node": ">=
|
25
|
+
"node": ">=18.0.0"
|
26
26
|
},
|
27
27
|
"files": [
|
28
28
|
"dist/",
|
@@ -109,7 +109,7 @@
|
|
109
109
|
"@types/chai": "^4.1.6",
|
110
110
|
"@types/chai-as-promised": "^7.1.0",
|
111
111
|
"@types/mocha": "^10.0.0",
|
112
|
-
"@types/node": "^
|
112
|
+
"@types/node": "^18.0.0",
|
113
113
|
"@types/sinon": "^10.0.0",
|
114
114
|
"@types/uuid": "^8.0.0",
|
115
115
|
"chai": "^4.2.0",
|