mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 05:02:40 +00:00
test(cli): derive CLI tool coverage and schema parity from command registry (#11776)
* test(cli): derive CLI tool coverage and schema parity from command registry * test(cli): check recorded routed operations and host operation bindings
This commit is contained in:
1 parent
e741366c94
commit
e44f0077c9
11 files changed
+605
-389
No files matched your search
@@ -165,3 +165,31 @@ export const distinctOperations = (
|
||||
const seen = new Set<string>();
|
||||
return operations.filter(({ name }) => !seen.has(name) && seen.add(name));
|
||||
};
|
||||
|
||||
/**
|
||||
* Contract operations the command itself answers, excluding the session-target
|
||||
* opener and any Evidence-target source operation it runs first.
|
||||
*/
|
||||
export const commandOwnOperations = (
|
||||
entry: CliCommandEntry,
|
||||
): readonly CliCommandOperation[] => {
|
||||
const { source, operations } = entry;
|
||||
if (source.kind === "contract") {
|
||||
const opening = source.description.sessionTarget?.opening;
|
||||
const targetSource = source.description.evidenceTargets?.source;
|
||||
return operations.filter(
|
||||
({ name }) => name !== opening && name !== targetSource,
|
||||
);
|
||||
}
|
||||
if (source.kind === "routed") {
|
||||
const own = new Set<string>(
|
||||
source.descriptions.map((description) => description.contract.name),
|
||||
);
|
||||
return operations.filter(({ name }) => own.has(name));
|
||||
}
|
||||
if (source.kind === "document") {
|
||||
const opening = source.description.sessionTarget?.opening;
|
||||
return operations.filter(({ name }) => name !== opening);
|
||||
}
|
||||
return operations;
|
||||
};
|
||||
Reference in new issue
Block a user