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 22, 2024
1 parent 9cf12b1 commit 5e78a1d
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 @@ -125,48 +125,35 @@ export interface CloudDocument {

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

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

Check failure on line 132 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Property 'create' does not exist on type 'Operation'.

Check failure on line 132 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Property 'delete' does not exist on type 'Operation'.

Check failure on line 132 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Property 'update' does not exist on type 'Operation'.

Check failure on line 132 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Type '"create" | "update" | "delete"' does not satisfy the constraint 'number | unique symbol | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | ... 35 more ... | "at"'.

Check failure on line 132 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'create' does not exist on type 'Operation'.

Check failure on line 132 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'delete' does not exist on type 'Operation'.

Check failure on line 132 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'update' does not exist on type 'Operation'.

Check failure on line 132 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Type '"create" | "update" | "delete"' does not satisfy the constraint 'number | unique symbol | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | ... 35 more ... | "at"'.
];


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">] ? {

Check failure on line 142 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Property 'create' does not exist on type 'Operation'.

Check failure on line 142 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Property 'update' does not exist on type 'Operation'.

Check failure on line 142 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Type '"create" | "update"' does not satisfy the constraint 'number | unique symbol | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | ... 35 more ... | "at"'.

Check failure on line 142 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'create' does not exist on type 'Operation'.

Check failure on line 142 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'update' does not exist on type 'Operation'.

Check failure on line 142 in src/types/events.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Type '"create" | "update"' does not satisfy the constraint 'number | unique symbol | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | ... 35 more ... | "at"'.
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 @@ -184,5 +171,4 @@ export interface Events {
cloudDocument: CloudDocument;
discussionRoom: DiscussionRoom;
discussionMessage: DiscussionMessage;
discussionUnreadMessage: DiscussionUnreadMessage;
}

0 comments on commit 5e78a1d

Please sign in to comment.