mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
refactor(views): share byte-bounded item page envelopes (#15718)
This commit is contained in:
1 parent
449fef2c03
commit
1d0588f6f3
5 files changed
+33
-48
No files matched your search
@@ -25,9 +25,8 @@ import {
|
||||
type AdmittedView,
|
||||
type SummaryAnalysisView,
|
||||
} from "./analysisViewShape.js";
|
||||
import type { JsonValue } from "../jsonValue.js";
|
||||
import {
|
||||
PLACEHOLDER_COVERAGE,
|
||||
byteBoundedItemsPageOwner,
|
||||
selectByteBoundedViewRows,
|
||||
type ByteBoundedPageOwner,
|
||||
type ByteBoundedRows,
|
||||
@@ -293,15 +292,10 @@ export const projectAndroidClassView = (
|
||||
view,
|
||||
class_name: value.class_name,
|
||||
};
|
||||
const page = selectMembers(value, view, {
|
||||
parentEvidenceId: parent.evidenceId,
|
||||
envelope: {
|
||||
...context,
|
||||
items: [],
|
||||
byte_limited: false,
|
||||
coverage: PLACEHOLDER_COVERAGE,
|
||||
} as unknown as JsonValue,
|
||||
facet: view.facet,
|
||||
});
|
||||
const page = selectMembers(
|
||||
value,
|
||||
view,
|
||||
byteBoundedItemsPageOwner(parent.evidenceId, view.facet, context),
|
||||
);
|
||||
return page.ok ? ok({ ...context, ...page.value }) : page;
|
||||
};
|
||||
@@ -5,10 +5,9 @@ import { androidResultSchemas } from "../android/androidAnalysis.js";
|
||||
import { androidReferencesViewSchema } from "../android/androidReferencesQuery.js";
|
||||
import { evidenceSubjectTarget } from "../evidence.js";
|
||||
import { boundedList } from "../boundedList.js";
|
||||
import type { JsonValue } from "../jsonValue.js";
|
||||
import { ok } from "../result.js";
|
||||
import {
|
||||
PLACEHOLDER_COVERAGE,
|
||||
byteBoundedItemsPageOwner,
|
||||
selectByteBoundedViewRows,
|
||||
type ByteBoundedPageOwner,
|
||||
} from "./byteBoundedViewRows.js";
|
||||
@@ -307,17 +306,10 @@ export const projectAndroidReferencesView = (
|
||||
view,
|
||||
target,
|
||||
};
|
||||
const owner = {
|
||||
parentEvidenceId: parent.evidenceId,
|
||||
envelope: {
|
||||
...context,
|
||||
facet: view.facet,
|
||||
items: [],
|
||||
byte_limited: false,
|
||||
coverage: PLACEHOLDER_COVERAGE,
|
||||
} as unknown as JsonValue,
|
||||
const owner = byteBoundedItemsPageOwner(parent.evidenceId, view.facet, {
|
||||
...context,
|
||||
facet: view.facet,
|
||||
};
|
||||
});
|
||||
const page =
|
||||
view.facet === "top-classes"
|
||||
? topClassesPage(trace, view, owner)
|
||||
|
||||
@@ -7,11 +7,10 @@ import {
|
||||
type ApktoolDecodeResult,
|
||||
} from "../apktool/apktoolResourceAnalysis.js";
|
||||
import { apktoolResourcesViewRequestSchema } from "../apktool/apktoolResourcesQuery.js";
|
||||
import type { JsonValue } from "../jsonValue.js";
|
||||
import { isRecord } from "../../kernel/isRecord.js";
|
||||
import { ok } from "../result.js";
|
||||
import {
|
||||
PLACEHOLDER_COVERAGE,
|
||||
byteBoundedItemsPageOwner,
|
||||
selectByteBoundedViewRows,
|
||||
} from "./byteBoundedViewRows.js";
|
||||
import { filterSet } from "./selectViewRows.js";
|
||||
@@ -172,16 +171,7 @@ const stringsPage = <Shared extends object>(
|
||||
rows,
|
||||
view,
|
||||
{ matches, project: (row) => row },
|
||||
{
|
||||
parentEvidenceId: parent.evidenceId,
|
||||
envelope: {
|
||||
...context,
|
||||
items: [],
|
||||
byte_limited: false,
|
||||
coverage: PLACEHOLDER_COVERAGE,
|
||||
} as unknown as JsonValue,
|
||||
facet: "strings",
|
||||
},
|
||||
byteBoundedItemsPageOwner(parent.evidenceId, "strings", context),
|
||||
);
|
||||
if (!page.ok) return page;
|
||||
return ok({
|
||||
|
||||
@@ -9,10 +9,9 @@ import {
|
||||
import { boundedList, byteBoundedList } from "../boundedList.js";
|
||||
import { prefixedDigestSchema } from "../digests.js";
|
||||
import { evidenceSubjectTarget } from "../evidence.js";
|
||||
import type { JsonValue } from "../jsonValue.js";
|
||||
import { ok } from "../result.js";
|
||||
import {
|
||||
PLACEHOLDER_COVERAGE,
|
||||
byteBoundedItemsPageOwner,
|
||||
selectByteBoundedViewRows,
|
||||
type ByteBoundedPageOwner,
|
||||
} from "./byteBoundedViewRows.js";
|
||||
@@ -286,16 +285,11 @@ export const projectArtifactExtractionView = (
|
||||
view,
|
||||
output_root: extraction.output_root,
|
||||
};
|
||||
const owner = {
|
||||
parentEvidenceId: parent.evidenceId,
|
||||
envelope: {
|
||||
...context,
|
||||
items: [],
|
||||
byte_limited: false,
|
||||
coverage: PLACEHOLDER_COVERAGE,
|
||||
} as unknown as JsonValue,
|
||||
facet: view.collection,
|
||||
};
|
||||
const owner = byteBoundedItemsPageOwner(
|
||||
parent.evidenceId,
|
||||
view.collection,
|
||||
context,
|
||||
);
|
||||
const page = collectionPage(extraction, view, owner);
|
||||
if (!page.ok) return page;
|
||||
return ok({
|
||||
|
||||
@@ -34,6 +34,21 @@ export interface ByteBoundedPageOwner {
|
||||
readonly facet: string;
|
||||
}
|
||||
|
||||
export const byteBoundedItemsPageOwner = (
|
||||
parentEvidenceId: string,
|
||||
facet: string,
|
||||
context: object,
|
||||
): ByteBoundedPageOwner => ({
|
||||
parentEvidenceId,
|
||||
envelope: {
|
||||
...context,
|
||||
items: [],
|
||||
byte_limited: false,
|
||||
coverage: PLACEHOLDER_COVERAGE,
|
||||
} as JsonValue,
|
||||
facet,
|
||||
});
|
||||
|
||||
/**
|
||||
* Select rows from `offset` up to `limit` that fit the analysis-view page
|
||||
* bytes beside `owner.envelope`. A row that does not fit ends the page with
|
||||
|
||||
Reference in new issue
Block a user