29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import type { ValueType, WorkspaceRevision } from "../capability-model/types.js";
|
|
import { ExecutionPlanError } from "./plan.js";
|
|
const string: ValueType = { kind: "scalar", name: "string" };
|
|
/** Narrow immutable installation metadata. No graph enumeration or live reflection. */
|
|
export function portableReflectionType(selector: string): ValueType {
|
|
if (selector !== "presentations")
|
|
throw new ExecutionPlanError(
|
|
"UNSUPPORTED_PORTABLE_REFLECTION",
|
|
selector,
|
|
"Only checked presentation metadata is portable",
|
|
);
|
|
return {
|
|
kind: "list",
|
|
value: { kind: "record", fields: { id: string, subject: string, atoms: { kind: "list", value: string } } },
|
|
};
|
|
}
|
|
export function portableReflectionValue(workspace: WorkspaceRevision, selector: string) {
|
|
portableReflectionType(selector);
|
|
return (workspace.presentations ?? [])
|
|
.map((p) => ({
|
|
id: p.id,
|
|
subject: p.subject,
|
|
atoms: [
|
|
...new Set(workspace.conformances.filter((c) => c.interfaceRevisionId === p.subject).map((c) => c.atomId)),
|
|
].sort(),
|
|
}))
|
|
.sort((a, b) => a.id.localeCompare(b.id));
|
|
}
|