-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve typing on Database Events #9819
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { ObjectRecordCreateEvent } from 'src/engine/core-modules/event-emitter/types/object-record-create.event'; | ||
import { ObjectRecordBaseEvent } from 'src/engine/core-modules/event-emitter/types/object-record.base.event'; | ||
|
||
export class ObjectRecordRestoreEvent< | ||
T = object, | ||
> extends ObjectRecordCreateEvent<T> { | ||
> extends ObjectRecordBaseEvent<T> { | ||
properties: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was enforced on purpose because from an API perspective I think the RestoreEvent should always have the properties that the create event has, because people don't want to implemented two different hooks with different logics. I think adding it creates a protection and if there's a need to remove it then it will raise the point |
||
after: T; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queu | |
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator'; | ||
import { WorkspaceEventBatch } from 'src/engine/workspace-event-emitter/types/workspace-event.type'; | ||
import { TimelineActivityService } from 'src/modules/timeline/services/timeline-activity.service'; | ||
import { TimelineActivityWorkspaceEntity } from 'src/modules/timeline/standard-objects/timeline-activity.workspace-entity'; | ||
import { WorkspaceMemberRepository } from 'src/modules/workspace-member/repositories/workspace-member.repository'; | ||
import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/standard-objects/workspace-member.workspace-entity'; | ||
|
||
|
@@ -18,7 +19,9 @@ export class UpsertTimelineActivityFromInternalEvent { | |
|
||
@Process(UpsertTimelineActivityFromInternalEvent.name) | ||
async handle( | ||
workspaceEventBatch: WorkspaceEventBatch<ObjectRecordNonDestructiveEvent>, | ||
workspaceEventBatch: WorkspaceEventBatch< | ||
ObjectRecordNonDestructiveEvent<TimelineActivityWorkspaceEntity> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment |
||
>, | ||
): Promise<void> { | ||
for (const eventData of workspaceEventBatch.events) { | ||
if (eventData.userId) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,10 @@ import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/work | |
import { TimelineActivityRepository } from 'src/modules/timeline/repositiories/timeline-activity.repository'; | ||
import { TimelineActivityWorkspaceEntity } from 'src/modules/timeline/standard-objects/timeline-activity.workspace-entity'; | ||
|
||
type TimelineActivity = Omit<ObjectRecordNonDestructiveEvent, 'properties'> & { | ||
type TimelineActivity = Omit< | ||
ObjectRecordNonDestructiveEvent<TimelineActivityWorkspaceEntity>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The event itself is not about a timeline activity, there's a confusion |
||
'properties' | ||
> & { | ||
name: string; | ||
objectName?: string; | ||
linkedRecordCachedName?: string; | ||
|
@@ -34,7 +37,7 @@ export class TimelineActivityService { | |
eventName, | ||
workspaceId, | ||
}: { | ||
event: ObjectRecordBaseEvent; | ||
event: ObjectRecordBaseEvent<TimelineActivityWorkspaceEntity>; | ||
eventName: string; | ||
workspaceId: string; | ||
}) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I didn't add it because it wasn't needed)