export const MESSAGE_TYPE = { // Commit events are acked with the GENERIC pair below — the reply is // correlated by SOURCE_REF, not by name. Real Genesis never replies // _ACK/_NACK: foundation-comms' kv.service checks // MESSAGE_TYPE === 'EVENT_ACK' exactly, and entity-management (and the // showcase's customEvents.ts) check MESSAGE_TYPE === 'EVENT_NACK' exactly. // Reply with the name-suffixed form and every successful commit renders as // a failure toast while every NACK passes silently. EVENT_ACK: 'EVENT_ACK', EVENT_NACK: 'EVENT_NACK', EVENT_LOGIN_AUTH: 'EVENT_LOGIN_AUTH', EVENT_LOGIN_AUTH_ACK: 'EVENT_LOGIN_AUTH_ACK', EVENT_LOGIN_AUTH_NACK: 'EVENT_LOGIN_AUTH_NACK', EVENT_LOGOUT: 'EVENT_LOGOUT', LOGOUT_ACK: 'LOGOUT_ACK', EVENT_LOGOUT_NACK: 'EVENT_LOGOUT_NACK', HEARTBEAT_PING: 'HEARTBEAT_PING', HEARTBEAT_PONG: 'HEARTBEAT_PONG', DATA_LOGON: 'DATA_LOGON', LOGON_ACK: 'LOGON_ACK', LOGON_NACK: 'LOGON_NACK', DATA_LOGOFF: 'DATA_LOGOFF', LOGOFF_ACK: 'LOGOFF_ACK', QUERY_UPDATE: 'QUERY_UPDATE', MORE_ROWS: 'MORE_ROWS', MORE_ROWS_ACK: 'MORE_ROWS_ACK', META_REQUEST: 'META_REQUEST', FEATURE_ACK: 'FEATURE_ACK', JSON_SCHEMA_REQUEST: 'JSON_SCHEMA_REQUEST', JSON_SCHEMA_FEATURE_ACK: 'JSON_SCHEMA_FEATURE_ACK', // The router's generic rejection (unknown resource, missing or duplicate // dataserver subscription) — see protocol/msgNack.ts. MSG_NACK: 'MSG_NACK', RESOURCES_REQUEST: 'RESOURCES_REQUEST', RESOURCES_REQUEST_ACK: 'RESOURCES_REQUEST_ACK', RESOURCES_REQUEST_NACK: 'RESOURCES_REQUEST_NACK', } as const; export const ERROR_CODE = { INCORRECT_CREDENTIALS: 'INCORRECT_CREDENTIALS', VALIDATION_ERROR: 'VALIDATION_ERROR', UNKNOWN_RESOURCE: 'UNKNOWN_RESOURCE', NOT_LOGGED_ON: 'NOT_LOGGED_ON', } as const; export function isCommitEvent(messageType: unknown): messageType is string { return ( typeof messageType === 'string' && messageType.startsWith('EVENT_') && messageType !== MESSAGE_TYPE.EVENT_LOGIN_AUTH && messageType !== MESSAGE_TYPE.EVENT_LOGOUT ); } export function isRequestReply(messageType: unknown): messageType is string { return typeof messageType === 'string' && messageType.startsWith('REQ_'); }