Written by seatgen at c62650e4 (GEN3) with mesh-sdk b19fc7fa (reader release): the seat mesh-grants new, every TypeScript contract as index.js with index.d.ts, events with subject and stream. mesh-watchdogs gains its family, which a definition with events needs. Written with the reader as it is: the field needs-approval (node-login-shell) and the section bodies (mesh-conditions) are unknown to it, so they were laid aside for the run; nothing generated carries either. Builds: design 47 G §339, §341, §261, §389 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
181 lines
5.8 KiB
JavaScript
181 lines
5.8 KiB
JavaScript
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
|
|
|
// The contract of the seat "mesh-module-assigner", defined whole (seats/mesh-module-assigner/seat.json): The seat that places modules on nodes (ADR 0567): the state of assignments and the proposals that change it.
|
|
|
|
export const seat = "mesh-module-assigner";
|
|
|
|
export const verbs = {
|
|
assignments: "assignments",
|
|
proposals: "proposals",
|
|
propose: "propose",
|
|
withdraw: "withdraw",
|
|
again: "again",
|
|
};
|
|
|
|
export const events = {
|
|
assignmentsProposed: "assignments-proposed",
|
|
assignmentsWithdrawn: "assignments-withdrawn",
|
|
assignmentsJudged: "assignments-judged",
|
|
assignmentsChanged: "assignments-changed",
|
|
};
|
|
|
|
export const family = { name: "mesh-module-assigner.events", maxAgeDays: 7 };
|
|
|
|
export const assignmentsProposedSubject = "mesh.seat.mesh-module-assigner.event.assignments-proposed";
|
|
|
|
export const assignmentsWithdrawnSubject = "mesh.seat.mesh-module-assigner.event.assignments-withdrawn";
|
|
|
|
export const assignmentsJudgedSubject = "mesh.seat.mesh-module-assigner.event.assignments-judged";
|
|
|
|
export const assignmentsChangedSubject = "mesh.seat.mesh-module-assigner.event.assignments-changed";
|
|
|
|
export const states = {
|
|
assignments: "assignments",
|
|
proposals: "proposals",
|
|
candidates: "candidates",
|
|
pulses: "pulses",
|
|
seatHolders: "seat-holders",
|
|
};
|
|
|
|
/** The key of one value of the state assignments under the form "<node>.node". */
|
|
export function assignmentsByNodeNodeKey(node) {
|
|
return node + ".node";
|
|
}
|
|
|
|
/** The parts of a key of the form "<node>.node", or undefined for a key of another form. */
|
|
export function parseAssignmentsByNodeNodeKey(_key) {
|
|
let _rest = _key;
|
|
const _at0 = _rest.indexOf(".node");
|
|
if (_at0 <= 0) return undefined;
|
|
const node = _rest.slice(0, _at0);
|
|
_rest = _rest.slice(_at0 + 5);
|
|
if (_rest !== "") return undefined;
|
|
return { node };
|
|
}
|
|
|
|
/** The key of one value of the state assignments under the form "<node>.<module>". */
|
|
export function assignmentsByNodeModuleKey(node, module) {
|
|
return node + "." + module;
|
|
}
|
|
|
|
/** The parts of a key of the form "<node>.<module>", or undefined for a key of another form. */
|
|
export function parseAssignmentsByNodeModuleKey(_key) {
|
|
let _rest = _key;
|
|
const _at0 = _rest.indexOf(".");
|
|
if (_at0 <= 0) return undefined;
|
|
const node = _rest.slice(0, _at0);
|
|
_rest = _rest.slice(_at0 + 1);
|
|
if (_rest === "") return undefined;
|
|
const module = _rest;
|
|
_rest = "";
|
|
if (_rest !== "") return undefined;
|
|
return { node, module };
|
|
}
|
|
|
|
/** The key of one value of the state proposals under the form "<proposal>". */
|
|
export function proposalsByProposalKey(proposal) {
|
|
return proposal;
|
|
}
|
|
|
|
/** The parts of a key of the form "<proposal>", or undefined for a key of another form. */
|
|
export function parseProposalsByProposalKey(_key) {
|
|
let _rest = _key;
|
|
if (_rest === "") return undefined;
|
|
const proposal = _rest;
|
|
_rest = "";
|
|
if (_rest !== "") return undefined;
|
|
return { proposal };
|
|
}
|
|
|
|
/** The key of one value of the state candidates under the form "<proposal>.<node>". */
|
|
export function candidatesByProposalNodeKey(proposal, node) {
|
|
return proposal + "." + node;
|
|
}
|
|
|
|
/** The parts of a key of the form "<proposal>.<node>", or undefined for a key of another form. */
|
|
export function parseCandidatesByProposalNodeKey(_key) {
|
|
let _rest = _key;
|
|
const _at0 = _rest.indexOf(".");
|
|
if (_at0 <= 0) return undefined;
|
|
const proposal = _rest.slice(0, _at0);
|
|
_rest = _rest.slice(_at0 + 1);
|
|
if (_rest === "") return undefined;
|
|
const node = _rest;
|
|
_rest = "";
|
|
if (_rest !== "") return undefined;
|
|
return { proposal, node };
|
|
}
|
|
|
|
/** The key of one value of the state pulses under the form "answer.<proposal>.<node>". */
|
|
export function pulsesByAnswerProposalNodeKey(proposal, node) {
|
|
return "answer." + proposal + "." + node;
|
|
}
|
|
|
|
/** The parts of a key of the form "answer.<proposal>.<node>", or undefined for a key of another form. */
|
|
export function parsePulsesByAnswerProposalNodeKey(_key) {
|
|
let _rest = _key;
|
|
if (!_rest.startsWith("answer.")) return undefined;
|
|
_rest = _rest.slice(7);
|
|
const _at1 = _rest.indexOf(".");
|
|
if (_at1 <= 0) return undefined;
|
|
const proposal = _rest.slice(0, _at1);
|
|
_rest = _rest.slice(_at1 + 1);
|
|
if (_rest === "") return undefined;
|
|
const node = _rest;
|
|
_rest = "";
|
|
if (_rest !== "") return undefined;
|
|
return { proposal, node };
|
|
}
|
|
|
|
/** The key of one value of the state pulses under the form "ask.<proposal>". */
|
|
export function pulsesByAskProposalKey(proposal) {
|
|
return "ask." + proposal;
|
|
}
|
|
|
|
/** The parts of a key of the form "ask.<proposal>", or undefined for a key of another form. */
|
|
export function parsePulsesByAskProposalKey(_key) {
|
|
let _rest = _key;
|
|
if (!_rest.startsWith("ask.")) return undefined;
|
|
_rest = _rest.slice(4);
|
|
if (_rest === "") return undefined;
|
|
const proposal = _rest;
|
|
_rest = "";
|
|
if (_rest !== "") return undefined;
|
|
return { proposal };
|
|
}
|
|
|
|
/** The key of one value of the state seat-holders under the form "<seat>". */
|
|
export function seatHoldersBySeatKey(seat) {
|
|
return seat;
|
|
}
|
|
|
|
/** The parts of a key of the form "<seat>", or undefined for a key of another form. */
|
|
export function parseSeatHoldersBySeatKey(_key) {
|
|
let _rest = _key;
|
|
if (_rest === "") return undefined;
|
|
const seat = _rest;
|
|
_rest = "";
|
|
if (_rest !== "") return undefined;
|
|
return { seat };
|
|
}
|
|
|
|
/** The key of one value of the state seat-holders under the form "<seat>.<node>". */
|
|
export function seatHoldersBySeatNodeKey(seat, node) {
|
|
return seat + "." + node;
|
|
}
|
|
|
|
/** The parts of a key of the form "<seat>.<node>", or undefined for a key of another form. */
|
|
export function parseSeatHoldersBySeatNodeKey(_key) {
|
|
let _rest = _key;
|
|
const _at0 = _rest.indexOf(".");
|
|
if (_at0 <= 0) return undefined;
|
|
const seat = _rest.slice(0, _at0);
|
|
_rest = _rest.slice(_at0 + 1);
|
|
if (_rest === "") return undefined;
|
|
const node = _rest;
|
|
_rest = "";
|
|
if (_rest !== "") return undefined;
|
|
return { seat, node };
|
|
}
|
|
|