Skip to content

Commit

Permalink
feat: add base handler to commands
Browse files Browse the repository at this point in the history
  • Loading branch information
cafadev committed Feb 11, 2024
1 parent 6d6e850 commit 8fe3554
Show file tree
Hide file tree
Showing 37 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/create-form.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { ResponseInterceptorState } from '@packages/core/common/response-interceptor/axioma'
import type { NotificationState } from '@packages/core/common/notifications/axioma'
import type { BaseObjectWithRawFields, Form, RawFormButtons, RawSetting } from '../typing'
Expand All @@ -26,7 +26,7 @@ export class CreateFormCommand<
) {}
}

export abstract class ICreateFormHandler {
export abstract class ICreateFormHandler implements BaseHandler {
/**
* Creates a form from raw fields and settings.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { StandardErrorResponseStructure } from '../typing'

export class DispatchOnFailedFormEventCommand implements BaseCommand {
Expand All @@ -11,6 +11,6 @@ export class DispatchOnFailedFormEventCommand implements BaseCommand {
) {}
}

export abstract class IDispatchOnFailedFormEventHandler {
export abstract class IDispatchOnFailedFormEventHandler implements BaseHandler {
abstract execute(command: DispatchOnFailedFormEventCommand): void
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { StandardErrorResponseStructure } from '../typing'

export class DispatchOnSuccessFormEventCommand implements BaseCommand {
Expand All @@ -11,6 +11,6 @@ export class DispatchOnSuccessFormEventCommand implements BaseCommand {
) {}
}

export abstract class IDispatchOnSuccessFormEventHandler {
export abstract class IDispatchOnSuccessFormEventHandler implements BaseHandler {
abstract execute(command: DispatchOnSuccessFormEventCommand): void
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { BaseObjectWithNormalizedFields, FormMode, NormalizedField } from '@packages/core/forms/axioma'
import { FORM_MODE, UnknownFormMode } from '@packages/core/forms/axioma'

Expand All @@ -17,6 +17,6 @@ export class FilterFieldsByFormModeCommand<T extends FilterFieldsByFormModeComma
}
}

export abstract class IFilterFieldsByFormModeHandler {
export abstract class IFilterFieldsByFormModeHandler implements BaseHandler {
abstract execute<T extends FilterFieldsByFormModeCommandInput = NormalizedField>({ mode, fields }: FilterFieldsByFormModeCommand<T>): [string, T][]
}
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/generate-form-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { BaseObjectWithNormalizedFields, NormalizedField } from '@packages/core/forms/axioma'

import { meta } from '@fancy-crud/bus'
Expand All @@ -24,7 +24,7 @@ export class GenerateFormDataCommand<T extends BaseObjectWithNormalizedFields<Mi
/**
* Class responsible for generating form data in the appropriate format.
*/
export abstract class IGenerateFormDataHandler {
export abstract class IGenerateFormDataHandler implements BaseHandler {
/**
* Generates the form data in the appropriate format.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FormMode } from '@packages/core/forms/axioma'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import { meta } from '@fancy-crud/bus'

export class GetButtonLabelByFormModeCommand implements BaseCommand {
Expand All @@ -11,6 +11,6 @@ export class GetButtonLabelByFormModeCommand implements BaseCommand {
) {}
}

export abstract class IGetButtonLabelByFormModeHandler {
export abstract class IGetButtonLabelByFormModeHandler implements BaseHandler {
abstract execute({ mode, text }: GetButtonLabelByFormModeCommand): string
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FormMode } from '@packages/core/forms/axioma'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import { meta } from '@fancy-crud/bus'

export class GetTitleByFormModeCommand implements BaseCommand {
Expand All @@ -11,6 +11,6 @@ export class GetTitleByFormModeCommand implements BaseCommand {
) {}
}

export abstract class IGetTitleByFomModeHandler {
export abstract class IGetTitleByFomModeHandler implements BaseHandler {
abstract execute(command: GetTitleByFormModeCommand): string
}
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/load-remote-record.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { RetrieveRequestOptions } from '@packages/core/common/http/axioma'

export class LoadRemoteRecordCommand implements BaseCommand {
Expand All @@ -12,6 +12,6 @@ export class LoadRemoteRecordCommand implements BaseCommand {
) {}
}

export abstract class ILoadRemoteRecordHandler {
export abstract class ILoadRemoteRecordHandler implements BaseHandler {
abstract execute(command: LoadRemoteRecordCommand): void
}
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/normalize-buttons.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { NormalizedFormButtons, RawFormButtons } from '@packages/core/forms/axioma'

export type NormalizeButtonsInputType = RawFormButtons
Expand All @@ -12,6 +12,6 @@ export class NormalizeButtonsCommand<T extends NormalizeButtonsInputType> implem
) {}
}

export abstract class INormalizeButtonsHandler {
export abstract class INormalizeButtonsHandler implements BaseHandler {
abstract execute<T extends NormalizeButtonsInputType>({ buttons }: NormalizeButtonsCommand<T>): NormalizedFormButtons
}
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/normalize-fields.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { BaseObjectWithRawFields, NormalizedFields } from '@packages/core/forms/axioma'

export type NormalizeFormFieldsCommandInputType = BaseObjectWithRawFields
Expand All @@ -17,7 +17,7 @@ export class NormalizeFormFieldsCommand<T extends NormalizeFormFieldsCommandInpu
Provides a static execute method that takes an object containing form fields and returns
a new object with normalized fields.
**/
export abstract class INormalizeFormFieldsHandler {
export abstract class INormalizeFormFieldsHandler implements BaseHandler {
/**
Normalizes an object containing form fields by merging each field with the default keys and values.
Returns a new object with normalized fields.
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/normalize-settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { NormalizedSettings, RawSetting } from '@packages/core/forms/axioma'

export class NormalizeSettingsCommand implements BaseCommand {
Expand All @@ -15,7 +15,7 @@ export class NormalizeSettingsCommand implements BaseCommand {
* Provides an `execute` method that takes an optional object containing settings configurations
* and returns a new object with normalized settings properties.
*/
export abstract class INormalizeSettingsHandler {
export abstract class INormalizeSettingsHandler implements BaseHandler {
/**
* Normalizes an optional object containing settings configurations by merging each configuration
* with the default properties. Returns a new object with normalized settings properties.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'

export class ResetFieldsByFormIdCommand implements BaseCommand {
public readonly meta = meta(IResetFieldsByFormIdHandler)
Expand All @@ -9,7 +9,7 @@ export class ResetFieldsByFormIdCommand implements BaseCommand {
) {}
}

export abstract class IResetFieldsByFormIdHandler {
export abstract class IResetFieldsByFormIdHandler implements BaseHandler {
/**
* Resets the model value of fields in a normalized fields object to their original values.
*
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/reset-fields.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { meta } from '@fancy-crud/bus'
import type { BaseObjectWithNormalizedFields } from '@packages/core/forms/axioma'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'

type ObjectRecord = Record<string, unknown>

Expand All @@ -13,6 +13,6 @@ export class ResetFieldsCommand implements BaseCommand {
) {}
}

export abstract class IResetFieldsHandler {
export abstract class IResetFieldsHandler implements BaseHandler {
abstract execute(command: ResetFieldsCommand): void
}
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/save-form.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { CreateRequestOptions, UpdateRequestOptions } from '@packages/core/common/http/axioma'

export class SaveFormCommand implements BaseCommand {
Expand All @@ -11,6 +11,6 @@ export class SaveFormCommand implements BaseCommand {
) {}
}

export abstract class ISaveFormHandler {
export abstract class ISaveFormHandler implements BaseHandler {
abstract execute(command: SaveFormCommand): void
}
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/set-fields-errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { BaseObjectWithNormalizedFields, FieldErrors, NormalizedField } from '@packages/core/forms/axioma'

type MinimumNormalizedField = Pick<NormalizedField, 'errors'>
Expand All @@ -16,6 +16,6 @@ export class SetFieldsErrorsCommand implements BaseCommand {
/**
* Class that fills the normalized fields of a form with corresponding values from a record.
*/
export abstract class ISetFieldsErrorsHandler {
export abstract class ISetFieldsErrorsHandler implements BaseHandler {
abstract execute({ normalizedFields, errors }: SetFieldsErrorsCommand): void
}
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/set-fields-values.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import { meta } from '@fancy-crud/bus'
import type { BaseObjectWithNormalizedFields, NormalizedField, NormalizedSettings } from '@packages/core/forms/axioma'

Expand All @@ -17,6 +17,6 @@ export class SetFieldsValuesCommand implements BaseCommand {
) {}
}

export abstract class ISetFieldsValuesHandler {
export abstract class ISetFieldsValuesHandler implements BaseHandler {
abstract execute(command: SetFieldsValuesCommand): void
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import { meta } from '@fancy-crud/bus'
import type { BaseObjectWithNormalizedFields, NormalizedSettings, ObjectWithNormalizedButtons } from '@packages/core/forms/axioma'

Expand All @@ -18,6 +18,6 @@ export class SwitchFormToCreateModeCommand implements BaseCommand {
) {}
}

export abstract class ISwitchFormToCreateModeHandler {
export abstract class ISwitchFormToCreateModeHandler implements BaseHandler {
abstract execute(command: SwitchFormToCreateModeCommand): void
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { meta } from '@fancy-crud/bus'
import type { BaseObjectWithNormalizedFields, NormalizedSettings, ObjectWithNormalizedButtons } from '@packages/core/forms/axioma'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'

export type SwitchFormToUpdateModeCommandInput = symbol | {
originalNormalizedFields: BaseObjectWithNormalizedFields
Expand All @@ -18,6 +18,6 @@ export class SwitchFormToUpdateModeCommand implements BaseCommand {
) {}
}

export abstract class ISwitchFormToUpdateModeHandler {
export abstract class ISwitchFormToUpdateModeHandler implements BaseHandler {
abstract execute(command: SwitchFormToUpdateModeCommand): void
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { NotificationType } from '@packages/core/common/notifications/axioma'

export class TriggerFormNotificationCommand implements BaseCommand {
Expand All @@ -11,6 +11,6 @@ export class TriggerFormNotificationCommand implements BaseCommand {
) {}
}

export abstract class ITriggerFormNotificationHandler {
export abstract class ITriggerFormNotificationHandler implements BaseHandler {
abstract execute(command: TriggerFormNotificationCommand): void
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { StandardErrorResponseStructure } from '../typing'

export class TriggerFormResponseInterceptorCommand implements BaseCommand {
Expand All @@ -12,6 +12,6 @@ export class TriggerFormResponseInterceptorCommand implements BaseCommand {
) {}
}

export abstract class ITriggerFormResponseInterceptorHandler {
export abstract class ITriggerFormResponseInterceptorHandler implements BaseHandler {
abstract execute(command: TriggerFormResponseInterceptorCommand): void
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { meta } from '@fancy-crud/bus'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { NormalizedField, Rule, RuleConfig, RuleResult } from '@packages/core/forms/axioma'

export type NormalizedFieldToValidate = Pick<NormalizedField, 'errors' | 'modelValue' | 'modelKey'> & { rules?: Rule }
Expand All @@ -13,6 +13,6 @@ export class ValidateFieldRulesCommand implements BaseCommand {
) {}
}

export abstract class IValidateFieldRulesHandler {
export abstract class IValidateFieldRulesHandler implements BaseHandler {
abstract execute(command: ValidateFieldRulesCommand): RuleResult
}
4 changes: 2 additions & 2 deletions packages/core/src/forms/axioma/commands/validate-form.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { BaseObjectWithNormalizedFields, NormalizedField, RuleConfig } from '@packages/core/forms/axioma'
import { meta } from '@fancy-crud/bus'

Expand All @@ -13,6 +13,6 @@ export class ValidateFormCommand implements BaseCommand {
) {}
}

export abstract class IValidateFormHandler {
export abstract class IValidateFormHandler implements BaseHandler {
abstract execute({ fields, options }: ValidateFormCommand): boolean
}
4 changes: 2 additions & 2 deletions packages/core/src/tables/axioma/commands/column-value.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import { meta } from '@fancy-crud/bus'
import type { NormalizedColumn } from '../typing'

Expand All @@ -12,6 +12,6 @@ export class GetColumnValueCommand implements BaseCommand {
) {}
}

export abstract class IGetColumnValueHandler {
export abstract class IGetColumnValueHandler implements BaseHandler {
abstract execute({ row, column, rowIndex }: GetColumnValueCommand): unknown
}
4 changes: 2 additions & 2 deletions packages/core/src/tables/axioma/commands/create-table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { BaseTableForm, MappedRawColumn, ObjectWithRawColumns, RawTableFilters, RawTableList, RawTablePagination, RawTableSettings, Table } from '@packages/core/tables/axioma'
import { meta } from '@fancy-crud/bus'
import type { RawTableButtons } from '../typing/buttons'
Expand All @@ -25,6 +25,6 @@ export class CreateTableCommand<
) {}
}

export abstract class ICreateTableHandler {
export abstract class ICreateTableHandler implements BaseHandler {
abstract execute<T extends BaseTableForm, U extends ObjectWithRawColumns, S extends RawTableSettings, F extends RawTableFilters, B extends RawTableButtons, L extends RawTableList, P extends RawTablePagination>(command: CreateTableCommand<T, U, S, F, B, L, P>): Table<T, U, S, F, B, L, P>
}
4 changes: 2 additions & 2 deletions packages/core/src/tables/axioma/commands/delete-record.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DeleteRecordOptions, NormalizedTableSettings, Row } from '@packages/core/tables/axioma'
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import { meta } from '@fancy-crud/bus'

export class DeleteRecordCommand implements BaseCommand {
Expand All @@ -13,6 +13,6 @@ export class DeleteRecordCommand implements BaseCommand {
) {}
}

export abstract class IDeleteRecordHandler {
export abstract class IDeleteRecordHandler implements BaseHandler {
abstract execute({ row, options, tableSettings }: DeleteRecordCommand): void
}
4 changes: 2 additions & 2 deletions packages/core/src/tables/axioma/commands/fetch-list-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BaseCommand } from '@fancy-crud/bus'
import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import { meta } from '@fancy-crud/bus'
import type { ListRequestOptions } from '@packages/core/common/http/axioma'

Expand All @@ -12,6 +12,6 @@ export class FetchListDataCommand implements BaseCommand {
) {}
}

export abstract class IFetchListDataHandler {
export abstract class IFetchListDataHandler implements BaseHandler {
abstract execute(command: FetchListDataCommand): void
}
Loading

0 comments on commit 8fe3554

Please sign in to comment.