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 0f3427d commit a266489
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 98 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";
90 changes: 20 additions & 70 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,30 @@ export interface Scope {
persPhysiqueId?: number | null;
}

export type ConnectorOperation = Operation[
keyof Omit<Operation, "void">
];

export type ConnectorScope = Scope;

export interface Connector {
name: "connector";
scope: ConnectorScope;
operation: ConnectorOperation;
operation: "CREATE" | "UPDATE" | "DELETE";
data: {
id: string;
code: string;
userId?: string | null;
}
}

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

export type AccountingFolderScope = Scope & Required<Pick<Scope, "firmId">>;

export interface AccountingFolder {
name: "accountingFolder";
scope: AccountingFolderScope;
operation: AccountingFolderOperation;
operation: "CREATE" | "UPDATE" | "DELETE";
data: {
id: string;
};
}

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

export type DocumentScope = Scope;

export enum DocumentKind {
Expand All @@ -63,54 +51,42 @@ export enum DocumentKind {
export interface Document {
name: "document";
scope: DocumentScope;
operation: DocumentOperation;
operation: "CREATE" | "DELETE";
data: {
id: string;
kind: DocumentKind;
name: string;
}
}

export type PortfolioOperation = Operation[
keyof Omit<Operation, "update" | "void">
];

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<Operation, "create">
];

export type AccountingLineEntryScope = Scope;

export interface AccountingLineEntry {
name: "accountingLineEntry";
scope: AccountingLineEntryScope;
operation: AccountingLineEntryOperation;
operation: "CREATE";
data: {
id: string;
}
}

export type AdminMessageOperation = Operation[
keyof Pick<Operation, "void">
];

export type AdminMessageScope = Scope;

export interface AdminMessage {
name: "adminMessage";
scope: AdminMessageScope;
operation: AdminMessageOperation;
operation: "VOID";
data: {
event: "admin_message";
socketMessage: {
Expand All @@ -122,31 +98,23 @@ export interface AdminMessage {
}
}

export type ThirdPartyOperation = Operation[
keyof Omit<Operation, "void">
];

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<Operation, "create" | "delete">
];

export type AccountingEntryLetteringScope = Scope;

export interface AccountingEntryLettering {
name: "accountingEntryLettering";
scope: AccountingEntryLetteringScope;
operation: AccountingEntryLetteringOperation;
operation: "CREATE" | "DELETE";
data: {
id: string;
piece2: string;
Expand All @@ -155,16 +123,12 @@ export interface AccountingEntryLettering {
}
}

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

export type CloudDocumentScope = Scope;

export interface CloudDocument {
name: "cloudDocument";
scope: CloudDocumentScope;
operation: CloudDocumentOperation;
operation: "CREATE" | "UPDATE";
data: {
id: string;
status: "rejected" | "completed";
Expand All @@ -174,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 @@ -233,5 +184,4 @@ export interface Events {
cloudDocument: CloudDocument;
discussionRoom: DiscussionRoom;
discussionMessage: DiscussionMessage;
discussionUnreadMessage: DiscussionUnreadMessage;
}

0 comments on commit a266489

Please sign in to comment.