All files / core/blong-kukum/orchestrator/kukum check.ts

54.83% Statements 17/31
100% Branches 1/1
0% Functions 0/1
54.83% Lines 17/31

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x                             1x  
import {library} from '@feasibleone/blong';
import {find as findInstances} from '../../engine.ts';
import {
    baseResult,
    contextOf,
    descriptorFor,
    diagnose,
    type KukumLibContext,
    type OperationParams,
    type OperationResult,
} from '../../operation.ts';
 
/** `kukum.<primitive>.check` — validate inputs and lint what the primitive produced. */
export default library(
    () =>
        async function check(
            this: KukumLibContext,
            id: string,
            params: OperationParams,
        ): Promise<OperationResult> {
            const host = this.platform;
            const root = host.resolve(params.target ?? '.');
            const descriptor = descriptorFor(id);
            const ctx = contextOf(id, params);
            const base = baseResult(id, 'check', ctx);
            const messages = [...(descriptor.check?.(ctx) ?? [])];
            const instances = await findInstances(host, descriptor, root);
            const diagnostics = await diagnose(host, root, instances);
            return {...base, messages, diagnostics};
        },
);