mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
refactor(views): share artifact summary fields (#15554)
This commit is contained in:
1 parent
11cbd62d11
commit
58bd0febff
4 files changed
+24
-37
No files matched your search
@@ -1,6 +1,9 @@
|
||||
import { z } from "zod";
|
||||
import { digestSchema, prefixedDigestSchema } from "../digests.js";
|
||||
import { analysisViewCoverageSchema } from "./analysisViewCoverage.js";
|
||||
import {
|
||||
analysisViewCoverageSchema,
|
||||
completeWithinViewCoverage,
|
||||
} from "./analysisViewCoverage.js";
|
||||
import { summaryViewSchema } from "./analysisViewShape.js";
|
||||
|
||||
export const artifactSchema = z.strictObject({
|
||||
@@ -28,3 +31,17 @@ export const summaryViewResultBase = {
|
||||
view: summaryViewSchema,
|
||||
...viewResultBaseFields,
|
||||
} as const;
|
||||
|
||||
/** Project artifact identity and the complete context for a one-row summary. */
|
||||
export const artifactSummaryViewFields = <
|
||||
Context extends { readonly artifact: z.output<typeof artifactSchema> },
|
||||
>(
|
||||
view: z.output<typeof summaryViewSchema>,
|
||||
context: Context,
|
||||
) => ({
|
||||
kind: "summary" as const,
|
||||
view,
|
||||
artifact: { path: context.artifact.path, sha256: context.artifact.sha256 },
|
||||
summary: context,
|
||||
coverage: completeWithinViewCoverage(1),
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
import { artifactSummaryViewFields } from "./analysisViewBase.js";
|
||||
import { viewParentIdentity } from "./viewParentIdentity.js";
|
||||
import { graphqlContractSchema } from "../apiContract/graphqlContract.js";
|
||||
import { projectGraphqlContractView } from "./graphqlContractView.js";
|
||||
@@ -23,7 +24,6 @@ import {
|
||||
} from "./analysisViewShape.js";
|
||||
import {
|
||||
boundedViewLimitations,
|
||||
completeWithinViewCoverage,
|
||||
selectedViewPage,
|
||||
} from "./analysisViewCoverage.js";
|
||||
import { pickFields, selectViewRows, filterSet } from "./selectViewRows.js";
|
||||
@@ -179,17 +179,7 @@ export const projectApiContractView = (
|
||||
: [],
|
||||
};
|
||||
if (view.kind === "summary")
|
||||
return ok({
|
||||
...shared,
|
||||
kind: "summary" as const,
|
||||
view,
|
||||
artifact: {
|
||||
path: context.artifact.path,
|
||||
sha256: context.artifact.sha256,
|
||||
},
|
||||
summary: context,
|
||||
coverage: completeWithinViewCoverage(1),
|
||||
});
|
||||
return ok({ ...shared, ...artifactSummaryViewFields(view, context) });
|
||||
const selected = selectRows(parsed.value, view);
|
||||
return ok({
|
||||
...shared,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { artifactSummaryViewFields } from "./analysisViewBase.js";
|
||||
import { viewParentIdentity } from "./viewParentIdentity.js";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
@@ -21,7 +22,6 @@ import {
|
||||
} from "./analysisViewShape.js";
|
||||
import {
|
||||
boundedViewLimitations,
|
||||
completeWithinViewCoverage,
|
||||
selectedViewPage,
|
||||
} from "./analysisViewCoverage.js";
|
||||
import { invalidAnalysisView } from "./analysisViewErrors.js";
|
||||
@@ -273,17 +273,7 @@ export const projectGraphqlContractView = (
|
||||
: [],
|
||||
};
|
||||
if (view.kind === "summary")
|
||||
return ok({
|
||||
...shared,
|
||||
kind: "summary" as const,
|
||||
view,
|
||||
artifact: {
|
||||
path: context.artifact.path,
|
||||
sha256: context.artifact.sha256,
|
||||
},
|
||||
summary: context,
|
||||
coverage: completeWithinViewCoverage(1),
|
||||
});
|
||||
return ok({ ...shared, ...artifactSummaryViewFields(view, context) });
|
||||
const envelope = { ...shared, ...context, view };
|
||||
const selected = selectRows(report, view, {
|
||||
parentEvidenceId: parent.evidenceId,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { artifactSummaryViewFields } from "./analysisViewBase.js";
|
||||
import { viewParentIdentity } from "./viewParentIdentity.js";
|
||||
import { appendToMapList } from "../appendToMapList.js";
|
||||
import {
|
||||
@@ -30,7 +31,6 @@ import {
|
||||
import {
|
||||
analysisViewCoverageSchema,
|
||||
boundedViewLimitations,
|
||||
completeWithinViewCoverage,
|
||||
pageViewCoverage,
|
||||
} from "./analysisViewCoverage.js";
|
||||
import { isImmutableJsonSnapshot } from "../immutableJson.js";
|
||||
@@ -448,17 +448,7 @@ export const projectPlaywrightTraceView = (
|
||||
],
|
||||
};
|
||||
if (view.kind === "summary")
|
||||
return ok({
|
||||
...shared,
|
||||
kind: "summary" as const,
|
||||
view,
|
||||
artifact: {
|
||||
path: context.artifact.path,
|
||||
sha256: context.artifact.sha256,
|
||||
},
|
||||
summary: context,
|
||||
coverage: completeWithinViewCoverage(1),
|
||||
});
|
||||
return ok({ ...shared, ...artifactSummaryViewFields(view, context) });
|
||||
if (view.collection === "event-text") {
|
||||
const text = selectEventText(parsed.value, view);
|
||||
return text.ok
|
||||
|
||||
Reference in new issue
Block a user