Implement Studio root and placement capabilities on the replica graph (WI-10)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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));
|
||||
}
|
||||
Reference in New Issue
Block a user