feat(FN-3784): document report archive feature in fusion-plugin-reports REA
Documents the report archive feature in the Fusion Plugin Reports README and adds a patch changeset for the release. Fusion-Task-Id: FN-3784
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import type { PluginContext } from "@fusion/core";
|
||||
import { definePlugin } from "@fusion/plugin-sdk";
|
||||
import { runReviewPanel } from "./review-panel.js";
|
||||
import { ensureReportSchema } from "./report-schema.js";
|
||||
import type { CombinedReview, ReviewPanelMember, RunReviewPanelInput } from "./review-types.js";
|
||||
import type { ReportCadence, ReportCreateInput } from "./store/report-types.js";
|
||||
import { ReportStore } from "./store/report-store.js";
|
||||
import { settingsSchema } from "./settings.js";
|
||||
|
||||
const plugin = definePlugin({
|
||||
@@ -15,7 +18,9 @@ const plugin = definePlugin({
|
||||
settingsSchema,
|
||||
},
|
||||
state: "installed",
|
||||
hooks: {},
|
||||
hooks: {
|
||||
onSchemaInit: ensureReportSchema,
|
||||
},
|
||||
});
|
||||
|
||||
export interface RunGeneratedReportReviewInput {
|
||||
@@ -25,13 +30,51 @@ export interface RunGeneratedReportReviewInput {
|
||||
cwd: string;
|
||||
}
|
||||
|
||||
const reportStoreCache = new WeakMap<object, ReportStore>();
|
||||
|
||||
export function getReportStore(ctx: PluginContext): ReportStore {
|
||||
const key = ctx.taskStore as object;
|
||||
const cached = reportStoreCache.get(key);
|
||||
if (cached) return cached;
|
||||
|
||||
const store = new ReportStore(ctx.taskStore.getDatabase());
|
||||
reportStoreCache.set(key, store);
|
||||
return store;
|
||||
}
|
||||
|
||||
function toCadence(cadence: RunReviewPanelInput["reportMetadata"]["cadence"]): ReportCadence {
|
||||
return cadence;
|
||||
}
|
||||
|
||||
export async function runGeneratedReportReview(input: RunGeneratedReportReviewInput, ctx: PluginContext): Promise<CombinedReview> {
|
||||
return runReviewPanel({
|
||||
const store = getReportStore(ctx);
|
||||
const reportInput: ReportCreateInput = {
|
||||
cadence: toCadence(input.reportMetadata.cadence),
|
||||
periodStart: input.reportMetadata.periodStart,
|
||||
periodEnd: input.reportMetadata.periodEnd,
|
||||
title: `Generated ${input.reportMetadata.cadence} report`,
|
||||
draftMarkdown: input.reportDraft,
|
||||
metadata: {
|
||||
reportMetadata: input.reportMetadata,
|
||||
source: "runGeneratedReportReview",
|
||||
},
|
||||
};
|
||||
const report = store.createReport(reportInput);
|
||||
store.setStatus(report.id, "review_pending");
|
||||
store.setStatus(report.id, "review_in_progress");
|
||||
|
||||
const combinedReview = await runReviewPanel({
|
||||
reportDraft: input.reportDraft,
|
||||
reportMetadata: input.reportMetadata,
|
||||
reportMetadata: {
|
||||
...input.reportMetadata,
|
||||
reportId: report.id,
|
||||
},
|
||||
panel: input.panel,
|
||||
cwd: input.cwd,
|
||||
}, ctx);
|
||||
|
||||
store.attachReview(report.id, combinedReview);
|
||||
return combinedReview;
|
||||
}
|
||||
|
||||
export default plugin;
|
||||
@@ -39,3 +82,6 @@ export default plugin;
|
||||
export * from "./settings.js";
|
||||
export * from "./review-types.js";
|
||||
export * from "./review-panel.js";
|
||||
export { ensureReportSchema } from "./report-schema.js";
|
||||
export { ReportStore, ReportStoreError, type ReportStoreEvents } from "./store/report-store.js";
|
||||
export * from "./store/report-types.js";
|
||||
|
||||
Reference in New Issue
Block a user