Skip to content

Commit

Permalink
refactor(./types/events): removed operation types, discussionUnreadMe…
Browse files Browse the repository at this point in the history
…ssage event, enhanced DiscussionRoom event
  • Loading branch information
Rossb0b committed Aug 8, 2024
1 parent 0c84590 commit d84dcdb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 53 deletions.
36 changes: 33 additions & 3 deletions src/schema/events/discussion/room.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,59 @@
"properties": {
"id": {
"type": "number"
},
"folderId": {
"type": "number"
},
"roomTypeId": {
"type": "number"
},
"memberIds": {
"type": "array",
"items": {
"type": "number"
}
}
},
"required": ["id"],
"required": ["id", "folderId", "roomTypeId"],
"additionalProperties": false
},
"update": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"folderId": {
"type": "number"
},
"roomTypeId": {
"type": "number"
},
"memberIds": {
"type": "array",
"items": {
"type": "number"
}
}
},
"required": ["id"],
"required": ["id", "folderId", "roomTypeId", "memberIds"],
"additionalProperties": false
},
"delete": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"folderId": {
"type": "number"
},
"roomTypeId": {
"type": "number"
}
},
"required": ["id"],
"required": ["id", "folderId", "roomTypeId"],
"additionalProperties": false
}
}
Expand Down
24 changes: 0 additions & 24 deletions src/schema/events/discussion/unreadMessage.json

This file was deleted.

1 change: 0 additions & 1 deletion src/schema/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ export { cloudDocument } from "./cloudDocument.json";

export { discussion_room } from "./discussion/room.json";
export { discussion_message } from "./discussion/message.json";
export { discussion_unread_message } from "./discussion/unreadMessage.json";
36 changes: 11 additions & 25 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,48 +138,35 @@ export interface CloudDocument {

export type PushNotificationScope = Scope & {
persPhysiqueId: number;
accountingFolderId: number;
};

export type DiscussionRoomOperation = Operation[
keyof Pick<Operation, "create" | "update" | "delete">
];


export type DiscussionRoomScope = PushNotificationScope;

export interface DiscussionRoom {
export interface DiscussionRoom<T extends DiscussionRoomOperation = DiscussionRoomOperation> {
name: "discussion_room";
scope: DiscussionRoomScope;
operation: DiscussionRoomOperation;
data: {
operation: T;
data: (T extends Operation[keyof Pick<Operation, "create" | "update">] ? {
memberIds: number[];
} : unknown) & {
id: number;
}
folderId: number;
roomTypeId: number;
};
}

export type DiscussionMessageOperation = Operation[
keyof Pick<Operation, "create" | "update">
];

export type DiscussionMessageScope = PushNotificationScope;

export interface DiscussionMessage {
name: "discussion_message";
scope: DiscussionMessageScope;
operation: DiscussionMessageOperation;
data: {
id: number;
}
}

export type DiscussionUnreadMessageOperation = Operation[
keyof Pick<Operation, "create" | "update">
];

export type DiscussionUnreadMessageScope = PushNotificationScope;

export interface DiscussionUnreadMessage {
name: "discussion_unread_message";
scope: DiscussionUnreadMessageScope;
operation: DiscussionUnreadMessageOperation;
operation: "CREATE" | "UPDATE";
data: {
id: number;
}
Expand All @@ -197,5 +184,4 @@ export interface Events {
cloudDocument: CloudDocument;
discussionRoom: DiscussionRoom;
discussionMessage: DiscussionMessage;
discussionUnreadMessage: DiscussionUnreadMessage;
}

0 comments on commit d84dcdb

Please sign in to comment.