From cd1fc992dd4a88e657d8eedab4f0f13f5fdcd969 Mon Sep 17 00:00:00 2001 From: Simon Woolf <simon.woolf@ably.com> Date: Tue, 7 Jan 2025 23:36:50 +0000 Subject: [PATCH] MessageAction enum changes as agreed in https://github.com/ably/sdk-api-reference/pull/44#discussion_r1903102862 and https://github.com/ably/realtime/discussions/6810 , plus addition of summary --- ably.d.ts | 23 +++++++---------------- src/common/lib/types/message.ts | 4 +--- test/realtime/message.test.js | 6 +++--- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/ably.d.ts b/ably.d.ts index 3d90eb97f..77ed8b98e 100644 --- a/ably.d.ts +++ b/ably.d.ts @@ -2387,10 +2387,6 @@ export interface Operation { * The namespace containing the different types of message actions. */ declare namespace MessageActions { - /** - * Message action has not been set. - */ - type MESSAGE_UNSET = 'message.unset'; /** * Message action for a newly created message. */ @@ -2403,31 +2399,26 @@ declare namespace MessageActions { * Message action for a deleted message. */ type MESSAGE_DELETE = 'message.delete'; - /** - * Message action for a newly created annotation. - */ - type ANNOTATION_CREATE = 'annotation.create'; - /** - * Message action for a deleted annotation. - */ - type ANNOTATION_DELETE = 'annotation.delete'; /** * Message action for a meta-message that contains channel occupancy information. */ type META_OCCUPANCY = 'meta.occupancy'; + /** + * Message action for a message containing the latest rolled-up summary of annotations + * that have been made to this message. + */ + type MESSAGE_SUMMARY = 'message.summary'; } /** * Describes the possible action types used on an {@link Message}. */ export type MessageAction = - | MessageActions.MESSAGE_UNSET | MessageActions.MESSAGE_CREATE | MessageActions.MESSAGE_UPDATE | MessageActions.MESSAGE_DELETE - | MessageActions.ANNOTATION_CREATE - | MessageActions.ANNOTATION_DELETE - | MessageActions.META_OCCUPANCY; + | MessageActions.META_OCCUPANCY + | MessageActions.MESSAGE_SUMMARY; /** * A message received from Ably. diff --git a/src/common/lib/types/message.ts b/src/common/lib/types/message.ts index d0ac41d62..4946f34d8 100644 --- a/src/common/lib/types/message.ts +++ b/src/common/lib/types/message.ts @@ -14,13 +14,11 @@ import type RealtimeChannel from '../client/realtimechannel'; type Channel = RestChannel | RealtimeChannel; const MessageActionArray: API.MessageAction[] = [ - 'message.unset', 'message.create', 'message.update', 'message.delete', - 'annotation.create', - 'annotation.delete', 'meta.occupancy', + 'message.summary' ]; const MessageActionMap = new Map<API.MessageAction, number>(MessageActionArray.map((action, index) => [action, index])); diff --git a/test/realtime/message.test.js b/test/realtime/message.test.js index 9f54cce7d..9e57327e5 100644 --- a/test/realtime/message.test.js +++ b/test/realtime/message.test.js @@ -1279,15 +1279,15 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, Helper, async const testCases = [ { description: 'should stringify the numeric action', - action: 1, + action: 0, expectedString: '[Message; action=message.create]', - expectedJSON: { action: 1 }, + expectedJSON: { action: 0 }, }, { description: 'should accept an already stringified action', action: 'message.update', expectedString: '[Message; action=message.update]', - expectedJSON: { action: 2 }, + expectedJSON: { action: 1 }, }, { description: 'should handle no action provided',