refactor: 프론트엔드 리펙토링
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import type { Result } from "../../../contracts/result.ts";
|
||||
import type {} from "../../../application/ports/in/application-api.ts";
|
||||
import type { LocalDraft } from "../domain/local-draft.ts";
|
||||
|
||||
export type LocalDraftRecord = Readonly<{
|
||||
draft: LocalDraft;
|
||||
revision: number;
|
||||
}>;
|
||||
|
||||
export type SaveLocalDraftCommand = Readonly<{
|
||||
draft: LocalDraft;
|
||||
expectedRevision: number | null;
|
||||
idempotencyKey: string;
|
||||
}>;
|
||||
|
||||
export type RemoveLocalDraftCommand = Readonly<{
|
||||
draftId: string;
|
||||
expectedRevision: number;
|
||||
idempotencyKey: string;
|
||||
}>;
|
||||
|
||||
export type LocalDraftStore = Readonly<{
|
||||
save(
|
||||
command: SaveLocalDraftCommand,
|
||||
signal?: AbortSignal,
|
||||
): Promise<Result<Readonly<{ revision: number }>>>;
|
||||
find(
|
||||
draftId: string,
|
||||
signal?: AbortSignal,
|
||||
): Promise<Result<LocalDraftRecord | null>>;
|
||||
remove(
|
||||
command: RemoveLocalDraftCommand,
|
||||
signal?: AbortSignal,
|
||||
): Promise<Result<void>>;
|
||||
}>;
|
||||
|
||||
export type LocalDraftFeatureInput = Readonly<{
|
||||
saveDraft(
|
||||
command: SaveLocalDraftCommand,
|
||||
context?: Readonly<{ signal?: AbortSignal }>,
|
||||
): Promise<Result<Readonly<{ revision: number }>>>;
|
||||
findDraft(
|
||||
draftId: string,
|
||||
context?: Readonly<{ signal?: AbortSignal }>,
|
||||
): Promise<Result<LocalDraftRecord | null>>;
|
||||
removeDraft(
|
||||
command: RemoveLocalDraftCommand,
|
||||
context?: Readonly<{ signal?: AbortSignal }>,
|
||||
): Promise<Result<void>>;
|
||||
}>;
|
||||
|
||||
declare module "../../../application/ports/in/application-api.ts" {
|
||||
interface ApplicationFeatureInputs {
|
||||
"local-draft": LocalDraftFeatureInput;
|
||||
}
|
||||
}
|
||||
|
||||
export function createLocalDraftFeatureInput(
|
||||
store: LocalDraftStore,
|
||||
): LocalDraftFeatureInput {
|
||||
return Object.freeze({
|
||||
saveDraft(command, context) {
|
||||
return store.save(command, context?.signal);
|
||||
},
|
||||
findDraft(draftId, context) {
|
||||
return store.find(draftId, context?.signal);
|
||||
},
|
||||
removeDraft(command, context) {
|
||||
return store.remove(command, context?.signal);
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user