{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "/schema/contracts", "title": "Contract", "description": "Scheduled contracts that can trigger actions (email, push, blockchain, etc.) based on conditions", "type": "object", "properties": { "contractid": { "title": "Unique identification", "description": "A unique uuid string identifying a contract", "type": "string", "format": "uuid" }, "owner": { "title": "Owner of this contract", "description": "For accessright purpose this is always equal as alias, owner can read, update or cancel", "type": "string" }, "status": { "title": "Contract status", "description": "todo = pending execution, done = successfully executed, error = failed, cancelled = manually stopped", "type": "string", "enum": ["todo", "done", "error", "cancelled"] }, "tribe": { "title": "Tribe", "description": "Tribe ID where this contract belongs and where the rule is defined", "type": "string" }, "action": { "title": "Action to execute", "description": "Name of the action function to execute (e.g., sendEmail, sendPush, webhook, blockchainWrite)", "type": "string" }, "payload": { "title": "Action payload", "description": "Data to pass to the action handler", "type": "object" }, "rule": { "title": "Rule function name", "description": "Name of the rule function in apxtri/Models/Rules.js to evaluate before execution", "type": "string" }, "ruleData": { "title": "Rule data", "description": "Data object passed to the rule function, which returns {result, error}", "type": "object" }, "ruleResult": { "title": "Rule evaluation result", "description": "Result returned by the rule function after evaluation", "type": "object" }, "ruleError": { "title": "Rule evaluation error", "description": "Error message if rule evaluation failed", "type": "string" }, "scheduledFor": { "title": "Scheduled execution date", "description": "Date and time when the contract should run (YYYYMMDD HH:mm:ss)", "type": "string" }, "scheduledDay": { "title": "Scheduled day for cron filtering", "description": "Day portion for efficient cron filtering (YYYYMMDD)", "type": "string" }, "maxRetries": { "title": "Maximum retry attempts", "description": "Number of times to retry on error", "type": "integer", "minimum": 0, "maximum": 10, "default": 0 }, "retryCount": { "title": "Current retry count", "description": "Number of times the contract has been retried", "type": "integer", "minimum": 0 }, "result": { "title": "Execution result", "description": "Result data after successful execution", "type": "object" }, "error": { "title": "Error message", "description": "Error message if execution failed", "type": "string" }, "datesRun": { "title": "Execution timestamps", "description": "Array of timestamps when the contract was executed", "type": "array", "items": { "type": "string" } }, "blockchainTxHash": { "title": "Blockchain transaction hash", "description": "Transaction hash if action involved blockchain write", "type": "string" }, "dt_create": { "title": "Creation date", "type": "string", "format": "date-time" }, "dt_update": { "type": "string", "format": "date-time" } }, "required": [ "contractid", "owner", "tribe", "status", "action" ], "additionalProperties": true, "apxref": [], "apxid": "contractid", "apxuniquekey": [ "contractid" ], "apxidx": [ { "name": "lst_contractid", "type": "array", "keyval": "contractid" }, { "name": "lst_owner", "type": "array", "keyval": "owner" }, { "name": "lst_tribe", "type": "array", "keyval": "tribe" }, { "name": "contractid", "type": "view", "keyval": "contractid", "objkey": [ "contractid", "owner", "tribe", "status", "action", "payload", "rule", "ruleData", "ruleResult", "ruleError", "scheduledFor", "scheduledDay", "maxRetries", "retryCount", "result", "error", "datesRun", "blockchainTxHash", "dt_create", "dt_update" ], "filter": "" }, { "name": "status_scheduledDay", "type": "view", "keyval": "contractid", "objkey": [ "contractid", "tribe", "status", "action", "scheduledFor", "scheduledDay", "rule", "ruleData", "payload", "owner" ], "filter": "status=todo" }, { "name": "tribe_status", "type": "distribution", "keyval": "tribe", "filter": "status" }, { "name": "status_contractid", "type": "distribution", "keyval": "status", "filter": "" } ], "apxaccessrights": { "owner": { "C": [], "D": [], "R": [], "U": [ "status", "tribe", "payload", "rule", "ruleData", "ruleResult", "ruleError", "scheduledFor", "scheduledDay", "maxRetries", "result", "error", "datesRun", "blockchainTxHash" ] }, "druid": { "R": [ "contractid", "owner", "tribe", "status", "action", "payload", "rule", "ruleData", "ruleResult", "ruleError", "scheduledFor", "scheduledDay", "maxRetries", "retryCount", "result", "error", "datesRun", "blockchainTxHash", "dt_create", "dt_update" ] }, "anonymous": { "R": [ "contractid", "status", "action", "scheduledFor", "scheduledDay", "dt_create" ] } } }