Skip to content

Commit

Permalink
[EventGrid] Mappings for new ACS Events (#14410)
Browse files Browse the repository at this point in the history
* [EventGrid] Fix ACS Event Names

The Azure Communication Services team noticed that some of their event
shapes were wrong and have [updated the
swagger](Azure/azure-rest-api-specs#13485) to
address this.

This commit pulls these changes into our SDK.

Fixes #14345

* [EventGrid] Add types for  RecordingFileStatusUpdated event

This is a new event ACS is sending.

* [EventGrid] Remove incorrect ACS System Events

After discussion, we are comfortable removing these two event names
from our mapping. The rationale here is that the service never sent
events using these names (they made a typo when documenting the event
names in Swagger) and so any code using them was going to be wrong. In
this case, we like that if you're using TypeScript you'll see a
compile time issue here because it will be pointing to place in your
code where things were never going to behave as you might have
expected.

The `CHANGELOG.md` has been updated to provide a little more
perscriptive guidence on what to do here, and we feel OK about not
doing a major version bump.
  • Loading branch information
ellismg authored Mar 23, 2021
1 parent 3ab1242 commit fa38e08
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 15 deletions.
10 changes: 9 additions & 1 deletion sdk/eventgrid/eventgrid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Release History

## 4.0.1 (Unreleased)
## 4.1.0 (Unreleased)

- The system event names `Microsoft.Communication.ChatParticipantAddedToThread` and `Microsoft.Communication.ChatParticipantRemovedFromThread` have been removed, and
`Microsoft.Communication.ChatThreadParticipantAdded` and `Microsoft.Communication.ChatThreadParticipantRemoved` have been added. The old names did not match the
the type names that Azure Communication Services was using for these events. TypeScript users will now see compliation errors if they are calling `isSystemEvent` with
either `Microsoft.Communication.ChatParticipantAddedToThread` or `Microsoft.Communication.ChatParticipantRemovedFromThread` as the event name. To fix these issues,
replace all uses of `Microsoft.Communication.ChatParticipantAddedToThread` with `Microsoft.Communication.ChatThreadParticipantAdded` and
`Microsoft.Communication.ChatParticipantRemovedFromThread` with `Microsoft.Communication.ChatThreadParticipantRemoved`.

- Add `Microsoft.Communications.RecordingFileStatusUpdated` system event.

## 4.0.0 (2021-03-17)

Expand Down
6 changes: 3 additions & 3 deletions sdk/eventgrid/eventgrid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sdk-type": "client",
"author": "Microsoft Corporation",
"description": "An isomorphic client library for the Azure Event Grid service.",
"version": "4.0.1",
"version": "4.1.0",
"keywords": [
"node",
"azure",
Expand Down Expand Up @@ -34,8 +34,8 @@
"//metadata": {
"constantPaths": [
{
"path": "src/generated/generatedClientContext.ts",
"prefix": "packageVersion"
"path": "swagger/README.md",
"prefix": "package-version"
},
{
"path": "src/constants.ts",
Expand Down
27 changes: 25 additions & 2 deletions sdk/eventgrid/eventgrid/review/eventgrid.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface AcsChatEventBase {
// @public
export interface AcsChatEventInThreadBase {
threadId: string;
transactionId: string;
}

// @public
Expand Down Expand Up @@ -115,6 +116,26 @@ export type AcsChatThreadWithUserDeletedEventData = AcsChatThreadEventBase & {
deleteTime: string;
};

// @public
export interface AcsRecordingChunkInfo {
documentId: string;
endReason: string;
index: number;
}

// @public
export interface AcsRecordingFileStatusUpdatedEventData {
recordingDurationMs: number;
recordingStartTime: string;
recordingStorageInfo: AcsRecordingStorageInfo;
sessionEndReason: string;
}

// @public
export interface AcsRecordingStorageInfo {
recordingChunks: AcsRecordingChunkInfo[];
}

// @public
export interface AcsSmsDeliveryAttempt {
segmentsFailed: number;
Expand All @@ -128,6 +149,7 @@ export type AcsSmsDeliveryReportReceivedEventData = AcsSmsEventBase & {
deliveryStatusDetails: string;
deliveryAttempts: AcsSmsDeliveryAttempt[];
receivedTimestamp: string;
tag: string;
};

// @public
Expand Down Expand Up @@ -1172,13 +1194,14 @@ export interface SystemEventNameToEventData {
"Microsoft.Communication.ChatMessageDeleted": AcsChatMessageDeletedEventData;
"Microsoft.Communication.ChatMessageEdited": AcsChatMessageEditedEventData;
"Microsoft.Communication.ChatMessageReceived": AcsChatMessageReceivedEventData;
"Microsoft.Communication.ChatParticipantAddedToThread": AcsChatParticipantAddedToThreadEventData;
"Microsoft.Communication.ChatParticipantAddedToThreadWithUser": AcsChatParticipantAddedToThreadWithUserEventData;
"Microsoft.Communication.ChatParticipantRemovedFromThread": AcsChatParticipantRemovedFromThreadEventData;
"Microsoft.Communication.ChatParticipantRemovedFromThreadWithUser": AcsChatParticipantRemovedFromThreadWithUserEventData;
"Microsoft.Communication.ChatThreadCreatedWithUser": AcsChatThreadCreatedWithUserEventData;
"Microsoft.Communication.ChatThreadParticipantAdded": AcsChatParticipantAddedToThreadEventData;
"Microsoft.Communication.ChatThreadParticipantRemoved": AcsChatParticipantRemovedFromThreadEventData;
"Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser": AcsChatThreadPropertiesUpdatedPerUserEventData;
"Microsoft.Communication.ChatThreadWithUserDeleted": AcsChatThreadWithUserDeletedEventData;
"Microsoft.Communication.RecordingFileStatusUpdated": AcsRecordingFileStatusUpdatedEventData;
"Microsoft.Communication.SMSDeliveryReportReceived": AcsSmsDeliveryReportReceivedEventData;
"Microsoft.Communication.SMSReceived": AcsSmsReceivedEventData;
"Microsoft.ContainerRegistry.ChartDeleted": ContainerRegistryChartDeletedEventData;
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventgrid/eventgrid/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export const SDK_VERSION: string = "4.0.1";
export const SDK_VERSION: string = "4.1.0";
export const DEFAULT_API_VERSION = "2018-01-01";
36 changes: 34 additions & 2 deletions sdk/eventgrid/eventgrid/src/generated/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,8 @@ export interface AcsChatEventBase {

/** Schema of common properties of all thread-level chat events */
export interface AcsChatEventInThreadBase {
/** The transaction id will be used as co-relation vector */
transactionId: string;
/** The chat thread id */
threadId: string;
}
Expand Down Expand Up @@ -1896,6 +1898,34 @@ export interface AcsSmsEventBase {
to: string;
}

/** Schema of the Data property of an EventGridEvent for an Microsoft.Communication.RecordingFileStatusUpdated event. */
export interface AcsRecordingFileStatusUpdatedEventData {
/** The details of recording storage information */
recordingStorageInfo: AcsRecordingStorageInfo;
/** The time at which the recording started */
recordingStartTime: string;
/** The recording duration in milliseconds */
recordingDurationMs: number;
/** The reason for ending recording session */
sessionEndReason: string;
}

/** Schema for all properties of Recording Storage Information. */
export interface AcsRecordingStorageInfo {
/** List of details of recording chunks information */
recordingChunks: AcsRecordingChunkInfo[];
}

/** Schema for all properties of Recording Chunk Information. */
export interface AcsRecordingChunkInfo {
/** The documentId of the recording chunk */
documentId: string;
/** The index of the recording chunk */
index: number;
/** The reason for ending the recording chunk */
endReason: string;
}

/** Event data for Microsoft.Devices.DeviceCreated event. */
export type IotHubDeviceCreatedEventData = DeviceLifeCycleEvent & {};

Expand Down Expand Up @@ -2033,7 +2063,7 @@ export type AcsChatThreadEventInThreadBase = AcsChatEventInThreadBase & {
version: number;
};

/** Schema of the Data property of an EventGridEvent for an Microsoft.Communication.ChatParticipantAddedToThread event. */
/** Schema of the Data property of an EventGridEvent for an Microsoft.Communication.ChatThreadParticipantAdded event. */
export type AcsChatParticipantAddedToThreadEventData = AcsChatEventInThreadBase & {
/** The time at which the user was added to the thread */
time: string;
Expand All @@ -2045,7 +2075,7 @@ export type AcsChatParticipantAddedToThreadEventData = AcsChatEventInThreadBase
version: number;
};

/** Schema of the Data property of an EventGridEvent for an Microsoft.Communication.ChatParticipantRemovedFromThread event. */
/** Schema of the Data property of an EventGridEvent for an Microsoft.Communication.ChatThreadParticipantRemoved event. */
export type AcsChatParticipantRemovedFromThreadEventData = AcsChatEventInThreadBase & {
/** The time at which the user was removed to the thread */
time: string;
Expand All @@ -2067,6 +2097,8 @@ export type AcsSmsDeliveryReportReceivedEventData = AcsSmsEventBase & {
deliveryAttempts: AcsSmsDeliveryAttempt[];
/** The time at which the SMS delivery report was received */
receivedTimestamp: string;
/** Customer Content */
tag: string;
};

/** Schema of the Data property of an EventGridEvent for an Microsoft.Communication.SMSReceived event. */
Expand Down
103 changes: 103 additions & 0 deletions sdk/eventgrid/eventgrid/src/generated/models/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5350,6 +5350,13 @@ export const AcsChatEventInThreadBase: CompositeMapper = {
name: "Composite",
className: "AcsChatEventInThreadBase",
modelProperties: {
transactionId: {
serializedName: "transactionId",
required: true,
type: {
name: "String"
}
},
threadId: {
serializedName: "threadId",
required: true,
Expand Down Expand Up @@ -5444,6 +5451,95 @@ export const AcsSmsEventBase: CompositeMapper = {
}
};

export const AcsRecordingFileStatusUpdatedEventData: CompositeMapper = {
type: {
name: "Composite",
className: "AcsRecordingFileStatusUpdatedEventData",
modelProperties: {
recordingStorageInfo: {
serializedName: "recordingStorageInfo",
type: {
name: "Composite",
className: "AcsRecordingStorageInfo"
}
},
recordingStartTime: {
serializedName: "recordingStartTime",
required: true,
type: {
name: "String"
}
},
recordingDurationMs: {
serializedName: "recordingDurationMs",
required: true,
type: {
name: "Number"
}
},
sessionEndReason: {
serializedName: "sessionEndReason",
required: true,
type: {
name: "String"
}
}
}
}
};

export const AcsRecordingStorageInfo: CompositeMapper = {
type: {
name: "Composite",
className: "AcsRecordingStorageInfo",
modelProperties: {
recordingChunks: {
serializedName: "recordingChunks",
required: true,
type: {
name: "Sequence",
element: {
type: {
name: "Composite",
className: "AcsRecordingChunkInfo"
}
}
}
}
}
}
};

export const AcsRecordingChunkInfo: CompositeMapper = {
type: {
name: "Composite",
className: "AcsRecordingChunkInfo",
modelProperties: {
documentId: {
serializedName: "documentId",
required: true,
type: {
name: "String"
}
},
index: {
serializedName: "index",
required: true,
type: {
name: "Number"
}
},
endReason: {
serializedName: "endReason",
required: true,
type: {
name: "String"
}
}
}
}
};

export const IotHubDeviceCreatedEventData: CompositeMapper = {
type: {
name: "Composite",
Expand Down Expand Up @@ -6022,6 +6118,13 @@ export const AcsSmsDeliveryReportReceivedEventData: CompositeMapper = {
type: {
name: "String"
}
},
tag: {
serializedName: "tag",
required: true,
type: {
name: "String"
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions sdk/eventgrid/eventgrid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export {
AcsChatParticipantAddedToThreadWithUserEventData,
AcsChatParticipantRemovedFromThreadEventData,
AcsChatParticipantRemovedFromThreadWithUserEventData,
AcsRecordingFileStatusUpdatedEventData,
AcsRecordingStorageInfo,
AcsRecordingChunkInfo,
CommunicationIdentifierModel,
CommunicationUserIdentifierModel,
CommunicationCloudEnvironmentModel,
Expand Down
11 changes: 7 additions & 4 deletions sdk/eventgrid/eventgrid/src/predicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
AcsChatParticipantAddedToThreadWithUserEventData,
AcsChatParticipantRemovedFromThreadEventData,
AcsChatParticipantRemovedFromThreadWithUserEventData,
AcsRecordingFileStatusUpdatedEventData,
AcsSmsDeliveryReportReceivedEventData,
AcsSmsReceivedEventData,
AppConfigurationKeyValueDeletedEventData,
Expand Down Expand Up @@ -127,14 +128,16 @@ export interface SystemEventNameToEventData {
"Microsoft.Communication.ChatThreadWithUserDeleted": AcsChatThreadWithUserDeletedEventData;
/** An interface for the event data of a "Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser" event. */
"Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser": AcsChatThreadPropertiesUpdatedPerUserEventData;
/** An interface for the event data of a "Microsoft.Communication.ChatParticipantAddedToThread" event. */
"Microsoft.Communication.ChatParticipantAddedToThread": AcsChatParticipantAddedToThreadEventData;
/** An interface for the event data of a "Microsoft.Communication.ChatThreadParticipantAdded" event. */
"Microsoft.Communication.ChatThreadParticipantAdded": AcsChatParticipantAddedToThreadEventData;
/** An interface for the event data of a "Microsoft.Communication.ChatParticipantAddedToThreadWithUser" event. */
"Microsoft.Communication.ChatParticipantAddedToThreadWithUser": AcsChatParticipantAddedToThreadWithUserEventData;
/** An interface for the event data of a "Microsoft.Communication.ChatParticipantRemovedFromThread" event. */
"Microsoft.Communication.ChatParticipantRemovedFromThread": AcsChatParticipantRemovedFromThreadEventData;
/** An interface for the event data of a "Microsoft.Communication.ChatThreadParticipantRemoved" event. */
"Microsoft.Communication.ChatThreadParticipantRemoved": AcsChatParticipantRemovedFromThreadEventData;
/** An interface for the event data of a "Microsoft.Communication.ChatParticipantRemovedFromThreadWithUser" event. */
"Microsoft.Communication.ChatParticipantRemovedFromThreadWithUser": AcsChatParticipantRemovedFromThreadWithUserEventData;
/** An interface for the event data of a "Microsoft.Communication.RecordingFileStatusUpdated" event. */
"Microsoft.Communication.RecordingFileStatusUpdated": AcsRecordingFileStatusUpdatedEventData;
/** An interface for the event data of a "Microsoft.Communication.SMSDeliveryReportReceived" event. */
"Microsoft.Communication.SMSDeliveryReportReceived": AcsSmsDeliveryReportReceivedEventData;
/** An interface for the event data of a "Microsoft.Communication.SMSReceived" event. */
Expand Down
4 changes: 2 additions & 2 deletions sdk/eventgrid/eventgrid/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
## Configuration

```yaml
require: "https://github.com/Azure/azure-rest-api-specs/blob/bd75cbc7ae9c997f39362ac9d19d557219720bbd/specification/eventgrid/data-plane/readme.md"
require: "https://github.com/Azure/azure-rest-api-specs/blob/cf9d9c44d990d82a763cf8c23a324de337e387a5/specification/eventgrid/data-plane/readme.md"
package-name: "@azure/eventgrid"
package-version: "4.0.0"
package-version: "4.1.0"
title: GeneratedClient
description: EventGrid Client
generate-metadata: false
Expand Down

0 comments on commit fa38e08

Please sign in to comment.