{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "REST DTO contracts v1", "$defs": { "Key": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "Revision": { "type": "integer", "minimum": 0 }, "Data": { "type": "object" }, "UtcTimestamp": { "type": "string", "format": "date-time", "pattern": "Z$" }, "ExecutionStatus": { "type": "string", "enum": [ "PENDING", "RUNNING", "RETRY_WAIT", "SUCCEEDED", "FAILED", "RECONCILIATION_REQUIRED" ] }, "FlowRef": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "flowKey": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "version": { "type": "integer", "minimum": 1 } }, "required": [ "id", "flowKey", "version" ], "additionalProperties": false }, "CreateRequest": { "type": "object", "properties": { "typeKey": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "data": { "$ref": "#/$defs/Data" } }, "required": [ "typeKey", "data" ], "additionalProperties": false }, "EventCommand": { "type": "object", "properties": { "event": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "data": { "$ref": "#/$defs/Data" } }, "required": [ "event", "data" ], "additionalProperties": false }, "RequestView": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "typeKey": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "flow": { "$ref": "#/$defs/FlowRef" }, "currentState": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "data": { "$ref": "#/$defs/Data" }, "revision": { "$ref": "#/$defs/Revision" }, "activeExecutionId": { "type": "string", "format": "uuid" }, "createdAt": { "type": "string", "format": "date-time", "pattern": "Z$" }, "updatedAt": { "type": "string", "format": "date-time", "pattern": "Z$" } }, "required": [ "id", "typeKey", "flow", "currentState", "data", "revision", "createdAt", "updatedAt" ], "additionalProperties": false }, "AcceptedEvent": { "type": "object", "properties": { "executionId": { "type": "string", "format": "uuid" }, "requestId": { "type": "string", "format": "uuid" }, "status": { "$ref": "#/$defs/ExecutionStatus" } }, "required": [ "executionId", "requestId", "status" ], "additionalProperties": false }, "BusinessResult": { "type": "object", "properties": { "outcome": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "fromState": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "toState": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "reasonCodes": { "type": "array", "items": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "minItems": 0, "maxItems": 100 } }, "required": [ "outcome", "fromState", "toState" ], "additionalProperties": false }, "ExecutionError": { "type": "object", "properties": { "code": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "message": { "type": "string", "maxLength": 2000 } }, "required": [ "code" ], "additionalProperties": false }, "ExecutionView": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "requestId": { "type": "string", "format": "uuid" }, "event": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "status": { "$ref": "#/$defs/ExecutionStatus" }, "result": { "$ref": "#/$defs/BusinessResult" }, "error": { "$ref": "#/$defs/ExecutionError" }, "createdAt": { "type": "string", "format": "date-time", "pattern": "Z$" }, "updatedAt": { "type": "string", "format": "date-time", "pattern": "Z$" } }, "required": [ "id", "requestId", "event", "status", "createdAt", "updatedAt" ], "additionalProperties": false, "allOf": [ { "if": { "properties": { "status": { "const": "SUCCEEDED" } } }, "then": { "required": [ "result" ], "not": { "required": [ "error" ] } }, "else": { "not": { "required": [ "result" ] } } } ] }, "AvailableEvent": { "type": "object", "properties": { "event": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "inputSchema": { "$ref": "flow-definition.schema.json#/$defs/InlineSchema" }, "ui": { "$ref": "flow-definition.schema.json#/$defs/Ui" } }, "required": [ "event", "inputSchema" ], "additionalProperties": false }, "BlockedEvent": { "type": "object", "properties": { "event": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "reasonCode": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" } }, "required": [ "event", "reasonCode" ], "additionalProperties": false }, "AvailableEvents": { "type": "object", "properties": { "requestId": { "type": "string", "format": "uuid" }, "revision": { "type": "integer", "minimum": 0 }, "events": { "type": "array", "items": { "$ref": "#/$defs/AvailableEvent" }, "minItems": 0, "maxItems": 500 }, "blocked": { "type": "array", "items": { "$ref": "#/$defs/BlockedEvent" }, "minItems": 0, "maxItems": 500 }, "blockedByExecutionId": { "type": "string", "format": "uuid" } }, "required": [ "requestId", "revision", "events", "blocked" ], "additionalProperties": false, "allOf": [ { "if": { "required": [ "blockedByExecutionId" ] }, "then": { "properties": { "events": { "maxItems": 0 } } } } ] }, "Violation": { "type": "object", "properties": { "pointer": { "type": "string", "pattern": "^(?:/(?:[^~/]|~[01])*)*$" }, "code": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "message": { "type": "string", "minLength": 1, "maxLength": 2000 } }, "required": [ "pointer", "code", "message" ], "additionalProperties": false }, "ValidationReport": { "type": "object", "properties": { "valid": { "type": "boolean" }, "errors": { "type": "array", "items": { "$ref": "#/$defs/Violation" }, "minItems": 0, "maxItems": 1000 } }, "required": [ "valid", "errors" ], "additionalProperties": false, "oneOf": [ { "properties": { "valid": { "const": true }, "errors": { "maxItems": 0 } } }, { "properties": { "valid": { "const": false }, "errors": { "minItems": 1 } } } ] }, "Problem": { "type": "object", "properties": { "type": { "type": "string", "format": "uri-reference" }, "title": { "type": "string", "minLength": 1 }, "status": { "type": "integer", "minimum": 400, "maximum": 599 }, "detail": { "type": "string", "maxLength": 2000 }, "instance": { "type": "string", "format": "uri-reference" }, "code": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "correlationId": { "type": "string", "minLength": 1, "maxLength": 200 }, "errors": { "type": "array", "items": { "$ref": "#/$defs/Violation" }, "minItems": 0, "maxItems": 1000 } }, "required": [ "type", "title", "status", "code", "correlationId" ], "additionalProperties": false }, "AuditEntry": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "requestId": { "type": "string", "format": "uuid" }, "executionId": { "type": "string", "format": "uuid" }, "kind": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "actorSubject": { "type": "string", "minLength": 1, "maxLength": 200 }, "flowId": { "type": "string", "format": "uuid" }, "fromState": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "toState": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "detail": { "$ref": "#/$defs/Data" }, "createdAt": { "type": "string", "format": "date-time", "pattern": "Z$" } }, "required": [ "id", "requestId", "kind", "actorSubject", "flowId", "detail", "createdAt" ], "additionalProperties": false }, "HistoryPage": { "type": "object", "properties": { "items": { "type": "array", "items": { "$ref": "#/$defs/AuditEntry" }, "minItems": 0, "maxItems": 100 }, "nextCursor": { "type": "string", "minLength": 1, "maxLength": 2000 } }, "required": [ "items" ], "additionalProperties": false }, "FlowView": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "status": { "type": "string", "enum": [ "DRAFT", "PUBLISHED", "RETIRED" ] }, "revision": { "type": "integer", "minimum": 0 }, "definition": { "$ref": "flow-definition.schema.json" }, "checksum": { "type": "string", "pattern": "^[a-f0-9]{64}$" }, "createdAt": { "type": "string", "format": "date-time", "pattern": "Z$" }, "createdBy": { "type": "string", "minLength": 1, "maxLength": 200 }, "publishedAt": { "type": "string", "format": "date-time", "pattern": "Z$" } }, "required": [ "id", "status", "revision", "definition", "createdAt", "createdBy" ], "additionalProperties": false, "allOf": [ { "if": { "properties": { "status": { "type": "string", "enum": [ "PUBLISHED", "RETIRED" ] } } }, "then": { "required": [ "checksum", "publishedAt" ] } } ] }, "ActivateFlow": { "type": "object", "properties": { "flowId": { "type": "string", "format": "uuid" } }, "required": [ "flowId" ], "additionalProperties": false }, "RequestTypeView": { "type": "object", "properties": { "typeKey": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "activeFlowId": { "type": "string", "format": "uuid" }, "enabled": { "type": "boolean" }, "revision": { "type": "integer", "minimum": 0 } }, "required": [ "typeKey", "activeFlowId", "enabled", "revision" ], "additionalProperties": false }, "SimulationInput": { "type": "object", "properties": { "state": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "requestData": { "$ref": "#/$defs/Data" }, "event": { "$ref": "#/$defs/EventCommand" }, "actor": { "type": "object", "properties": { "subject": { "type": "string", "minLength": 1, "maxLength": 200 }, "roles": { "type": "array", "items": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "minItems": 0, "uniqueItems": true, "maxItems": 100 }, "businessScope": { "type": "string", "minLength": 1, "maxLength": 100 } }, "required": [ "subject", "roles", "businessScope" ], "additionalProperties": false }, "results": { "type": "object", "propertyNames": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "additionalProperties": { "type": "object" } } }, "required": [ "state", "requestData", "event", "actor", "results" ], "additionalProperties": false }, "SimulationResult": { "type": "object", "properties": { "transitionId": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "outcome": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "toState": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "data": { "$ref": "#/$defs/Data" }, "matchedRuleIds": { "type": "array", "items": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "minItems": 0, "maxItems": 1000 } }, "required": [ "transitionId", "outcome", "toState", "data", "matchedRuleIds" ], "additionalProperties": false }, "ReconciliationCommand": { "oneOf": [ { "type": "object", "properties": { "mode": { "const": "RESUME" }, "evidence": { "type": "object", "properties": { "reference": { "type": "string", "minLength": 1, "maxLength": 500 }, "reason": { "type": "string", "minLength": 1, "maxLength": 2000 } }, "required": [ "reference", "reason" ], "additionalProperties": false }, "verifiedActions": { "type": "array", "items": { "type": "object", "properties": { "actionId": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$" }, "result": { "$ref": "#/$defs/Data" }, "providerReference": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": [ "actionId", "result" ], "additionalProperties": false }, "minItems": 1, "maxItems": 50 } }, "required": [ "mode", "evidence", "verifiedActions" ], "additionalProperties": false }, { "type": "object", "properties": { "mode": { "const": "CLOSE_WITHOUT_TRANSITION" }, "evidence": { "type": "object", "properties": { "reference": { "type": "string", "minLength": 1, "maxLength": 500 }, "reason": { "type": "string", "minLength": 1, "maxLength": 2000 } }, "required": [ "reference", "reason" ], "additionalProperties": false }, "effectStatus": { "type": "string", "enum": [ "ABSENT_VERIFIED", "COMPENSATED_VERIFIED" ] } }, "required": [ "mode", "evidence", "effectStatus" ], "additionalProperties": false } ] }, "ReconciliationView": { "type": "object", "properties": { "resolutionId": { "type": "string", "format": "uuid" }, "executionId": { "type": "string", "format": "uuid" }, "status": { "type": "string", "enum": [ "PENDING", "FAILED" ] }, "resolvedAt": { "type": "string", "format": "date-time", "pattern": "Z$" } }, "required": [ "resolutionId", "executionId", "status", "resolvedAt" ], "additionalProperties": false } } }