41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
|
|
import type { DesktopArticleContent, JsonValue } from "@geo/shared-types";
|
||
|
|
import type { Session, WebContentsView } from "electron";
|
||
|
|
|
||
|
|
export type AdapterTaskPhase = "initial" | "resume";
|
||
|
|
export type AdapterCompletionStatus = "succeeded" | "failed" | "unknown";
|
||
|
|
|
||
|
|
export interface AdapterContext {
|
||
|
|
taskId: string;
|
||
|
|
accountId: string;
|
||
|
|
session: Session;
|
||
|
|
view: WebContentsView;
|
||
|
|
signal: AbortSignal;
|
||
|
|
mode: "auto" | "manual";
|
||
|
|
phase: AdapterTaskPhase;
|
||
|
|
reportProgress(stage: string): void;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface PublishAdapterContext extends AdapterContext {
|
||
|
|
article: DesktopArticleContent & {
|
||
|
|
publish_type: "publish" | "draft";
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface AdapterExecutionResult {
|
||
|
|
status: AdapterCompletionStatus;
|
||
|
|
summary: string;
|
||
|
|
payload?: Record<string, JsonValue>;
|
||
|
|
error?: Record<string, JsonValue>;
|
||
|
|
reviewUrl?: string | null;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface PublishAdapter {
|
||
|
|
platform: string;
|
||
|
|
publish(context: PublishAdapterContext, payload: Record<string, unknown>): Promise<AdapterExecutionResult>;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface MonitorAdapter {
|
||
|
|
provider: string;
|
||
|
|
query(context: AdapterContext, payload: Record<string, unknown>): Promise<AdapterExecutionResult>;
|
||
|
|
}
|