@azure/eventgrid 4.15.1-alpha.20231016.2 → 4.15.1-alpha.20231026.2
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.20231026.2",
|
7
7
|
"keywords": [
|
8
8
|
"node",
|
9
9
|
"azure",
|
@@ -128,13 +128,13 @@
|
|
128
128
|
"karma-sourcemap-loader": "^0.3.8",
|
129
129
|
"mocha": "^10.0.0",
|
130
130
|
"mocha-junit-reporter": "^2.0.0",
|
131
|
-
"
|
131
|
+
"c8": "^8.0.0",
|
132
132
|
"prettier": "^2.5.1",
|
133
133
|
"rimraf": "^3.0.0",
|
134
134
|
"sinon": "^15.0.0",
|
135
135
|
"source-map-support": "^0.5.9",
|
136
136
|
"ts-node": "^10.0.0",
|
137
|
-
"typescript": "~5.
|
137
|
+
"typescript": "~5.2.0",
|
138
138
|
"esm": "^3.2.18"
|
139
139
|
}
|
140
140
|
}
|