All files / core/blong-kukum/primitives checks.ts

100% Statements 31/31
100% Branches 3/3
100% Functions 1/1
100% Lines 31/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 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 6x 1x 7x  
import type {PrimitiveContext} from '../engine.ts';
import {layerOf} from './shared.ts';
 
/** The checks several descriptors share before they generate anything. */
 
/** Standard predicate priority — never invent one that already exists. */
export const STANDARD_PREDICATES = [
    'get',
    'find',
    'add',
    'edit',
    'remove',
    'merge',
    'insert',
    'update',
    'delete',
    'list',
    'create',
    'check',
    'refresh',
    'start',
    'stop',
];
 
/** Reject a layer the descriptor is not allowed to write into. */
export function checkLayer(ctx: PrimitiveContext, allowed: string[]): string[] {
    const layer = layerOf(ctx, allowed[0]);
    return allowed.includes(layer)
        ? []
        : [`layer '${layer}' must be one of: ${allowed.join(', ')}`];
}