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>>; find( draftId: string, signal?: AbortSignal, ): Promise>; remove( command: RemoveLocalDraftCommand, signal?: AbortSignal, ): Promise>; }>; export type LocalDraftFeatureInput = Readonly<{ saveDraft( command: SaveLocalDraftCommand, context?: Readonly<{ signal?: AbortSignal }>, ): Promise>>; findDraft( draftId: string, context?: Readonly<{ signal?: AbortSignal }>, ): Promise>; removeDraft( command: RemoveLocalDraftCommand, context?: Readonly<{ signal?: AbortSignal }>, ): Promise>; }>; 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); }, }); }