Skip to content

Type Alias: GetFunctionResponse

@kortexya/reasoninglayer


@kortexya/reasoninglayer / GetFunctionResponse

GetFunctionResponse = FunctionDefinitionSignature & { clauses: FunctionClauseDto[]; unrepresentable?: undefined; } | { clauses?: undefined; unrepresentable: string; }

Defined in: src/types/functions.ts:587

One registered function’s definition, as GET /functions/{name} answers it.

The clauses come back in the shape PUT takes

Section titled “The clauses come back in the shape PUT takes”

The clauses of a readable definition are the exact payload FunctionsClient.registerFunction and FunctionsClient.replaceFunction accept, so a read-modify-write is an edit rather than a re-authoring. That is the point of the route: PUT replaces the WHOLE definition, so before it a client fixing one clause of a three-clause function had to remember the other two or lose them.

Withheld is not empty, and the type says so

Section titled “Withheld is not empty, and the type says so”

clauses: [] is a function with no clauses. A definition holding a construct the register shape cannot express comes back with no clauses at all and an unrepresentable reason — the engine declines to describe it rather than degrading it, because a PUT of a degraded read would destroy the real definition.

The two are modelled as a union rather than two optional fields, so a client cannot read clauses without first ruling the withheld case out:

const definition = await client.functions.getFunction('scale');
if (definition.clauses === undefined) {
console.warn(`cannot edit scale: ${definition.unrepresentable}`);
} else {
await client.functions.replaceFunction('scale', {
arity: definition.arity,
clauses: [...definition.clauses, extraClause],
});
}

A plugin-contributed function is refused by DELETE/PUT and RETURNED here, with replaceable: false and the refusal the mutation would give.