T-1: a TypeScript part reads a definition's callers as the format's list
Text and a bare name are refused naming the verb, as the Go reader does. Builds: design 47 G §196, §336, §392 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -174,3 +174,25 @@ export function parseConfiguredVerbCallers(raw: unknown, verbs: readonly string[
|
||||
if (typeof raw === "string") return parseVerbCallers(raw, verbs, defaults);
|
||||
return parseVerbCallers(JSON.stringify(raw), verbs, defaults);
|
||||
}
|
||||
|
||||
/** The kinds of name a seat definition's `callers` entry may be besides `seat:<seat>`, `module:<module>` and `holder:<seat>@same-node` (design 47 G §336, §392). */
|
||||
const callerWords = ["operator", "healers", "persons", "sessions", "invokers"];
|
||||
const callerForm = /^(seat:[a-z][a-z0-9-]*|module:[a-z][a-z0-9-]*|holder:[a-z][a-z0-9-]*@same-node)$/;
|
||||
|
||||
/**
|
||||
* The callers a seat definition names for a verb or an accepted kind (design 47 G §336, §392): a list of entries, each
|
||||
* one of the forms the format knows. Text is refused naming the verb, and so is an entry that is no form (a bare name
|
||||
* among them), as the Go reader does.
|
||||
*/
|
||||
export function readDefinitionCallers(verb: string, value: unknown): readonly string[] {
|
||||
if (typeof value === "string") {
|
||||
throw new Error(`${verb}: callers are text ("${value}"): a definition gives its callers as a list`);
|
||||
}
|
||||
if (!Array.isArray(value)) throw new Error(`${verb}: callers is not a list of entries`);
|
||||
for (const e of value) {
|
||||
if (typeof e !== "string" || !(callerWords.includes(e) || callerForm.test(e))) {
|
||||
throw new Error(`${verb}: the callers entry ${JSON.stringify(e)} is none of ${callerWords.join(", ")}, seat:<seat>, module:<module> and holder:<seat>@same-node`);
|
||||
}
|
||||
}
|
||||
return value as string[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user