From a266489abf1f6a2dd8ace8cc50b7da1d3dddc596 Mon Sep 17 00:00:00 2001 From: Rossb0b Date: Mon, 5 Aug 2024 05:13:57 +0200 Subject: [PATCH] refactor(./types/events): removed operation types, discussionUnreadMessage event, enhanced DiscussionRoom event --- src/schema/events/discussion/room.json | 36 +++++++- .../events/discussion/unreadMessage.json | 24 ----- src/schema/events/index.ts | 1 - src/types/events.ts | 90 +++++-------------- 4 files changed, 53 insertions(+), 98 deletions(-) delete mode 100644 src/schema/events/discussion/unreadMessage.json diff --git a/src/schema/events/discussion/room.json b/src/schema/events/discussion/room.json index 16103bd..a6d6092 100644 --- a/src/schema/events/discussion/room.json +++ b/src/schema/events/discussion/room.json @@ -5,9 +5,21 @@ "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": { @@ -15,9 +27,21 @@ "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": { @@ -25,9 +49,15 @@ "properties": { "id": { "type": "number" + }, + "folderId": { + "type": "number" + }, + "roomTypeId": { + "type": "number" } }, - "required": ["id"], + "required": ["id", "folderId", "roomTypeId"], "additionalProperties": false } } diff --git a/src/schema/events/discussion/unreadMessage.json b/src/schema/events/discussion/unreadMessage.json deleted file mode 100644 index 1b9618f..0000000 --- a/src/schema/events/discussion/unreadMessage.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "discussion_unread_message": { - "create": { - "type": "object", - "properties": { - "id": { - "type": "number" - } - }, - "required": ["id"], - "additionalProperties": false - }, - "update": { - "type": "object", - "properties": { - "id": { - "type": "number" - } - }, - "required": ["id"], - "additionalProperties": false - } - } -} diff --git a/src/schema/events/index.ts b/src/schema/events/index.ts index 669dcf8..a96164f 100644 --- a/src/schema/events/index.ts +++ b/src/schema/events/index.ts @@ -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"; diff --git a/src/types/events.ts b/src/types/events.ts index 7f8b291..83964a5 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -15,16 +15,12 @@ export interface Scope { persPhysiqueId?: number | null; } -export type ConnectorOperation = Operation[ - keyof Omit -]; - export type ConnectorScope = Scope; export interface Connector { name: "connector"; scope: ConnectorScope; - operation: ConnectorOperation; + operation: "CREATE" | "UPDATE" | "DELETE"; data: { id: string; code: string; @@ -32,25 +28,17 @@ export interface Connector { } } -export type AccountingFolderOperation = Operation[ - keyof Pick -]; - export type AccountingFolderScope = Scope & Required>; export interface AccountingFolder { name: "accountingFolder"; scope: AccountingFolderScope; - operation: AccountingFolderOperation; + operation: "CREATE" | "UPDATE" | "DELETE"; data: { id: string; }; } -export type DocumentOperation = Operation[ - keyof Pick -]; - export type DocumentScope = Scope; export enum DocumentKind { @@ -63,7 +51,7 @@ export enum DocumentKind { export interface Document { name: "document"; scope: DocumentScope; - operation: DocumentOperation; + operation: "CREATE" | "DELETE"; data: { id: string; kind: DocumentKind; @@ -71,46 +59,34 @@ export interface Document { } } -export type PortfolioOperation = Operation[ - keyof Omit -]; - export type PortfolioScope = Scope; export interface Portfolio { name: "portfolio"; scope: PortfolioScope; - operation: PortfolioOperation; + operation: "CREATE" | "DELETE"; data: { id: string; } } -export type AccountingLineEntryOperation = Operation[ - keyof Pick -]; - export type AccountingLineEntryScope = Scope; export interface AccountingLineEntry { name: "accountingLineEntry"; scope: AccountingLineEntryScope; - operation: AccountingLineEntryOperation; + operation: "CREATE"; data: { id: string; } } -export type AdminMessageOperation = Operation[ - keyof Pick -]; - export type AdminMessageScope = Scope; export interface AdminMessage { name: "adminMessage"; scope: AdminMessageScope; - operation: AdminMessageOperation; + operation: "VOID"; data: { event: "admin_message"; socketMessage: { @@ -122,31 +98,23 @@ export interface AdminMessage { } } -export type ThirdPartyOperation = Operation[ - keyof Omit -]; - export type ThirdPartyScope = Scope; export interface ThirdParty { name: "thirdParty"; scope: ThirdPartyScope; - operation: ThirdPartyOperation; + operation: "CREATE" | "UPDATE" | "DELETE"; data: { code: string; } } -export type AccountingEntryLetteringOperation = Operation[ - keyof Pick -]; - export type AccountingEntryLetteringScope = Scope; export interface AccountingEntryLettering { name: "accountingEntryLettering"; scope: AccountingEntryLetteringScope; - operation: AccountingEntryLetteringOperation; + operation: "CREATE" | "DELETE"; data: { id: string; piece2: string; @@ -155,16 +123,12 @@ export interface AccountingEntryLettering { } } -export type CloudDocumentOperation = Operation[ - keyof Pick -]; - export type CloudDocumentScope = Scope; export interface CloudDocument { name: "cloudDocument"; scope: CloudDocumentScope; - operation: CloudDocumentOperation; + operation: "CREATE" | "UPDATE"; data: { id: string; status: "rejected" | "completed"; @@ -174,48 +138,35 @@ export interface CloudDocument { export type PushNotificationScope = Scope & { persPhysiqueId: number; + accountingFolderId: number; }; export type DiscussionRoomOperation = Operation[ keyof Pick ]; + export type DiscussionRoomScope = PushNotificationScope; -export interface DiscussionRoom { +export interface DiscussionRoom { name: "discussion_room"; scope: DiscussionRoomScope; - operation: DiscussionRoomOperation; - data: { + operation: T; + data: (T extends Operation[keyof Pick] ? { + memberIds: number[]; + } : unknown) & { id: number; - } + folderId: number; + roomTypeId: number; + }; } -export type DiscussionMessageOperation = Operation[ - keyof Pick -]; - export type DiscussionMessageScope = PushNotificationScope; export interface DiscussionMessage { name: "discussion_message"; scope: DiscussionMessageScope; - operation: DiscussionMessageOperation; - data: { - id: number; - } -} - -export type DiscussionUnreadMessageOperation = Operation[ - keyof Pick -]; - -export type DiscussionUnreadMessageScope = PushNotificationScope; - -export interface DiscussionUnreadMessage { - name: "discussion_unread_message"; - scope: DiscussionUnreadMessageScope; - operation: DiscussionUnreadMessageOperation; + operation: "CREATE" | "UPDATE"; data: { id: number; } @@ -233,5 +184,4 @@ export interface Events { cloudDocument: CloudDocument; discussionRoom: DiscussionRoom; discussionMessage: DiscussionMessage; - discussionUnreadMessage: DiscussionUnreadMessage; }