From 4b42997fedc70eef17823746f191e99c4317f1d0 Mon Sep 17 00:00:00 2001 From: nichenqin Date: Fri, 18 Oct 2024 16:51:16 +0800 Subject: [PATCH] fix: fix event spaceis --- packages/base/src/events/base-created.event.ts | 7 +++++-- packages/base/src/events/base-updated.event.ts | 4 ++-- packages/space/src/events/space-created.event.ts | 7 +++++-- packages/space/src/events/space-updated.event.ts | 7 +++++-- packages/table/src/events/field-created.event.ts | 7 +++++-- packages/table/src/events/field-deleted.event.ts | 7 +++++-- packages/table/src/events/field-updated.event.ts | 7 +++++-- .../table/src/events/set-table-form.event.ts | 7 +++++-- packages/table/src/events/set-table-rls.event.ts | 7 +++++-- .../table/src/events/set-view-aggregate.event.ts | 7 +++++-- .../table/src/events/set-view-color.event.ts | 7 +++++-- .../table/src/events/set-view-fields.event.ts | 7 +++++-- .../table/src/events/set-view-filter.event.ts | 7 +++++-- .../table/src/events/set-view-option.event.ts | 7 +++++-- packages/table/src/events/set-view-sort.event.ts | 7 +++++-- packages/table/src/events/table-created.event.ts | 7 +++++-- packages/table/src/events/view-created.event.ts | 7 +++++-- packages/table/src/events/view-deleted.event.ts | 7 +++++-- packages/table/src/events/view-updated.event.ts | 7 +++++-- .../table/src/methods/create-field.method.ts | 15 +++++++++------ packages/table/src/methods/create-view.method.ts | 11 +++++++---- .../table/src/methods/delete-field.method.ts | 11 +++++++---- packages/table/src/methods/delete-view.method.ts | 11 +++++++---- .../table/src/methods/duplicate-view.method.ts | 11 +++++++---- .../table/src/methods/set-table-form.method.ts | 13 ++++++++----- .../src/methods/set-view-aggregate.method.ts | 16 +++++++++------- .../table/src/methods/set-view-color.method.ts | 16 +++++++++------- .../table/src/methods/set-view-fields.method.ts | 16 +++++++++------- .../table/src/methods/set-view-filter.method.ts | 15 +++++++++------ .../table/src/methods/set-view-option.method.ts | 16 +++++++++------- .../table/src/methods/set-view-sort.method.ts | 16 +++++++++------- .../table/src/methods/update-field.method.ts | 13 ++++++++----- packages/table/src/methods/update-view.method.ts | 13 ++++++++----- 33 files changed, 207 insertions(+), 116 deletions(-) diff --git a/packages/base/src/events/base-created.event.ts b/packages/base/src/events/base-created.event.ts index 763240999..ff3190fed 100644 --- a/packages/base/src/events/base-created.event.ts +++ b/packages/base/src/events/base-created.event.ts @@ -13,7 +13,10 @@ export type IBaseCreatedEventPayload = z.infer export class BaseCreatedEvent extends BaseEvent { name = EVT_BASE_CREATED - constructor(public readonly payload: IBaseCreatedEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: IBaseCreatedEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/base/src/events/base-updated.event.ts b/packages/base/src/events/base-updated.event.ts index b67283c0a..2e5d11462 100644 --- a/packages/base/src/events/base-updated.event.ts +++ b/packages/base/src/events/base-updated.event.ts @@ -14,7 +14,7 @@ export type IBaseUpdatedEventPayload = z.infer export class BaseUpdatedEvent extends BaseEvent { name = EVT_BASE_UPDATED - constructor(public readonly payload: IBaseUpdatedEventPayload) { - super(payload, undefined) + constructor(public readonly payload: IBaseUpdatedEventPayload, spaceId: string ) { + super(payload, undefined, spaceId) } } diff --git a/packages/space/src/events/space-created.event.ts b/packages/space/src/events/space-created.event.ts index a0c277c0e..0735aa631 100644 --- a/packages/space/src/events/space-created.event.ts +++ b/packages/space/src/events/space-created.event.ts @@ -13,7 +13,10 @@ export type ISpaceCreatedEventPayload = z.infer export class SpaceCreatedEvent extends BaseEvent { name = EVT_SPACE_CREATED - constructor(public readonly payload: ISpaceCreatedEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ISpaceCreatedEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/space/src/events/space-updated.event.ts b/packages/space/src/events/space-updated.event.ts index 38571458b..a67b3e5b6 100644 --- a/packages/space/src/events/space-updated.event.ts +++ b/packages/space/src/events/space-updated.event.ts @@ -14,7 +14,10 @@ export type ISpaceUpdatedEventPayload = z.infer export class SpaceUpdatedEvent extends BaseEvent { name = EVT_SPACE_UPDATED - constructor(public readonly payload: ISpaceUpdatedEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ISpaceUpdatedEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/field-created.event.ts b/packages/table/src/events/field-created.event.ts index b1231b84a..f8b80c6ee 100644 --- a/packages/table/src/events/field-created.event.ts +++ b/packages/table/src/events/field-created.event.ts @@ -17,7 +17,10 @@ export type IFieldCreatedEventPayload = z.infer export class FieldCreatedEvent extends BaseEvent { name = EVT_FIELD_CREATED - constructor(public readonly payload: IFieldCreatedEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: IFieldCreatedEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/field-deleted.event.ts b/packages/table/src/events/field-deleted.event.ts index aa24a334e..27a8285b5 100644 --- a/packages/table/src/events/field-deleted.event.ts +++ b/packages/table/src/events/field-deleted.event.ts @@ -15,7 +15,10 @@ export type IFieldDeletedEventPayload = z.infer export class FieldDeletedEvent extends BaseEvent { name = EVT_FIELD_DELETED - constructor(public readonly payload: IFieldDeletedEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: IFieldDeletedEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/field-updated.event.ts b/packages/table/src/events/field-updated.event.ts index ca4329208..fe58db757 100644 --- a/packages/table/src/events/field-updated.event.ts +++ b/packages/table/src/events/field-updated.event.ts @@ -16,7 +16,10 @@ export type IFieldUpdatedEventPayload = z.infer export class FieldUpdatedEvent extends BaseEvent { name = EVT_FIELD_UPDATED - constructor(public readonly payload: IFieldUpdatedEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: IFieldUpdatedEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/set-table-form.event.ts b/packages/table/src/events/set-table-form.event.ts index d101c0397..09ba19d5c 100644 --- a/packages/table/src/events/set-table-form.event.ts +++ b/packages/table/src/events/set-table-form.event.ts @@ -16,7 +16,10 @@ export type ISetTableFormEventPayload = z.infer export class SetTableFormEvent extends BaseEvent { name = EVT_SET_TABLE_VIEW - constructor(public readonly payload: ISetTableFormEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ISetTableFormEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/set-table-rls.event.ts b/packages/table/src/events/set-table-rls.event.ts index 49da73eee..d8d964522 100644 --- a/packages/table/src/events/set-table-rls.event.ts +++ b/packages/table/src/events/set-table-rls.event.ts @@ -16,7 +16,10 @@ export type ISetTableRLSEventPayload = z.infer export class SetTableRLSEvent extends BaseEvent { name = EVT_SET_TABLE_RLS - constructor(public readonly payload: ISetTableRLSEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ISetTableRLSEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/set-view-aggregate.event.ts b/packages/table/src/events/set-view-aggregate.event.ts index c2ac62606..c1c00708f 100644 --- a/packages/table/src/events/set-view-aggregate.event.ts +++ b/packages/table/src/events/set-view-aggregate.event.ts @@ -17,7 +17,10 @@ export type ISetViewAggregateEventPayload = z.infer { name = EVT_SET_VIEW_COLOR - constructor(public readonly payload: ISetViewAggregateEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ISetViewAggregateEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/set-view-color.event.ts b/packages/table/src/events/set-view-color.event.ts index c43569771..9168fb1ff 100644 --- a/packages/table/src/events/set-view-color.event.ts +++ b/packages/table/src/events/set-view-color.event.ts @@ -18,7 +18,10 @@ export type ISetViewColorEventPayload = z.infer export class SetViewColorEvent extends BaseEvent { name = EVT_SET_VIEW_COLOR - constructor(public readonly payload: ISetViewColorEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ISetViewColorEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/set-view-fields.event.ts b/packages/table/src/events/set-view-fields.event.ts index f3f80f3d5..41f8e7344 100644 --- a/packages/table/src/events/set-view-fields.event.ts +++ b/packages/table/src/events/set-view-fields.event.ts @@ -18,7 +18,10 @@ export type ISetViewFieldsEventPayload = z.infer { name = EVT_SET_VIEW_FIELDS - constructor(public readonly payload: ISetViewFieldsEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ISetViewFieldsEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/set-view-filter.event.ts b/packages/table/src/events/set-view-filter.event.ts index b05a1d327..47842e6e5 100644 --- a/packages/table/src/events/set-view-filter.event.ts +++ b/packages/table/src/events/set-view-filter.event.ts @@ -17,7 +17,10 @@ export type ISetViewFilterEventPayload = z.infer { name = EVT_SET_VIEW_FILTER - constructor(public readonly payload: ISetViewFilterEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ISetViewFilterEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/set-view-option.event.ts b/packages/table/src/events/set-view-option.event.ts index 9a6dd4f4f..0f8ca9266 100644 --- a/packages/table/src/events/set-view-option.event.ts +++ b/packages/table/src/events/set-view-option.event.ts @@ -17,7 +17,10 @@ export type ISetViewOptionEventPayload = z.infer { name = EVT_SET_VIEW_OPTION - constructor(public readonly payload: ISetViewOptionEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ISetViewOptionEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/set-view-sort.event.ts b/packages/table/src/events/set-view-sort.event.ts index 72f291a0a..ddcdb9884 100644 --- a/packages/table/src/events/set-view-sort.event.ts +++ b/packages/table/src/events/set-view-sort.event.ts @@ -17,7 +17,10 @@ export type ISetViewSortEventPayload = z.infer export class SetViewSortEvent extends BaseEvent { name = EVT_SET_VIEW_SORT - constructor(public readonly payload: ISetViewSortEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ISetViewSortEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/table-created.event.ts b/packages/table/src/events/table-created.event.ts index d615de79d..42276d481 100644 --- a/packages/table/src/events/table-created.event.ts +++ b/packages/table/src/events/table-created.event.ts @@ -13,7 +13,10 @@ export type ITableCreatedEventPayload = z.infer export class TableCreatedEvent extends BaseEvent { name = EVT_TABLE_CREATED - constructor(public readonly payload: ITableCreatedEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: ITableCreatedEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/view-created.event.ts b/packages/table/src/events/view-created.event.ts index 76d0958db..bf74e537c 100644 --- a/packages/table/src/events/view-created.event.ts +++ b/packages/table/src/events/view-created.event.ts @@ -15,7 +15,10 @@ export type IViewCreatedEventPayload = z.infer export class ViewCreatedEvent extends BaseEvent { name = EVT_VIEW_CREATED - constructor(public readonly payload: IViewCreatedEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: IViewCreatedEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/view-deleted.event.ts b/packages/table/src/events/view-deleted.event.ts index 90ed17e26..eaaf24312 100644 --- a/packages/table/src/events/view-deleted.event.ts +++ b/packages/table/src/events/view-deleted.event.ts @@ -15,7 +15,10 @@ export type IViewDeletedEventPayload = z.infer export class ViewDeletedEvent extends BaseEvent { name = EVT_VIEW_DELETED - constructor(public readonly payload: IViewDeletedEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: IViewDeletedEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/events/view-updated.event.ts b/packages/table/src/events/view-updated.event.ts index 79fa8cf25..6049cef52 100644 --- a/packages/table/src/events/view-updated.event.ts +++ b/packages/table/src/events/view-updated.event.ts @@ -16,7 +16,10 @@ export type IViewUpdatedEventPayload = z.infer export class ViewUpdatedEvent extends BaseEvent { name = EVT_VIEW_UPDATED - constructor(public readonly payload: IViewUpdatedEventPayload) { - super(payload, undefined) + constructor( + public readonly payload: IViewUpdatedEventPayload, + spaceId: string, + ) { + super(payload, undefined, spaceId) } } diff --git a/packages/table/src/methods/create-field.method.ts b/packages/table/src/methods/create-field.method.ts index ead56a37e..72397d6fa 100644 --- a/packages/table/src/methods/create-field.method.ts +++ b/packages/table/src/methods/create-field.method.ts @@ -21,12 +21,15 @@ export function $createFieldSpec(this: TableDo, field: Field): Option v.name.value) applyRules(new ViewNameShouldBeUnique(names)) - const event = new ViewCreatedEvent({ - tableId: this.id.value, - view: view.toJSON(), - }) + const event = new ViewCreatedEvent( + { + tableId: this.id.value, + view: view.toJSON(), + }, + this.spaceId, + ) this.addDomainEvent(event) return { spec: Some(spec), view } diff --git a/packages/table/src/methods/delete-field.method.ts b/packages/table/src/methods/delete-field.method.ts index 337fe1394..20201e91c 100644 --- a/packages/table/src/methods/delete-field.method.ts +++ b/packages/table/src/methods/delete-field.method.ts @@ -23,10 +23,13 @@ export function deleteFieldMethod(this: TableDo, dto: IDeleteFieldDTO): [Field, spec.mutate(this) - const event = new FieldDeletedEvent({ - tableId: this.id.value, - field: field.toJSON(), - }) + const event = new FieldDeletedEvent( + { + tableId: this.id.value, + field: field.toJSON(), + }, + this.spaceId, + ) this.addDomainEvent(event) return [field, Some(spec)] diff --git a/packages/table/src/methods/delete-view.method.ts b/packages/table/src/methods/delete-view.method.ts index 546392eb2..e5d0c5ba2 100644 --- a/packages/table/src/methods/delete-view.method.ts +++ b/packages/table/src/methods/delete-view.method.ts @@ -15,10 +15,13 @@ export function deleteViewMethod(this: TableDo, dto: IDeleteViewDTO): Option v.name.value) applyRules(new ViewNameShouldBeUnique(names)) - const event = new ViewUpdatedEvent({ - tableId: this.id.value, - previous: spec.unwrap().previous.toJSON() ?? null, - view: view?.toJSON() ?? null, - }) + const event = new ViewUpdatedEvent( + { + tableId: this.id.value, + previous: spec.unwrap().previous.toJSON() ?? null, + view: view?.toJSON() ?? null, + }, + this.spaceId, + ) this.addDomainEvent(event) }