273 lines
5.4 KiB
JSON
273 lines
5.4 KiB
JSON
{
|
|
"schemaVersion": 1,
|
|
"flowKey": "COMPRA",
|
|
"version": 1,
|
|
"initialState": "CREADA",
|
|
"initialDataSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"client": {
|
|
"type": "string",
|
|
"minLength": 1
|
|
},
|
|
"orderId": {
|
|
"type": "string",
|
|
"minLength": 1
|
|
},
|
|
"amount": {
|
|
"type": "number",
|
|
"exclusiveMinimum": 0
|
|
}
|
|
},
|
|
"required": [
|
|
"client",
|
|
"orderId",
|
|
"amount"
|
|
],
|
|
"additionalProperties": false
|
|
},
|
|
"dataSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"client": {
|
|
"type": "string",
|
|
"minLength": 1
|
|
},
|
|
"orderId": {
|
|
"type": "string",
|
|
"minLength": 1
|
|
},
|
|
"amount": {
|
|
"type": "number",
|
|
"exclusiveMinimum": 0
|
|
},
|
|
"cliente": {
|
|
"type": "object",
|
|
"properties": {
|
|
"found": {
|
|
"type": "boolean"
|
|
},
|
|
"customerId": {
|
|
"type": "string",
|
|
"minLength": 1
|
|
}
|
|
},
|
|
"required": [
|
|
"found"
|
|
],
|
|
"additionalProperties": false,
|
|
"allOf": [
|
|
{
|
|
"if": {
|
|
"properties": {
|
|
"found": {
|
|
"const": true
|
|
}
|
|
}
|
|
},
|
|
"then": {
|
|
"required": [
|
|
"customerId"
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"confirmada": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"required": [
|
|
"client",
|
|
"orderId",
|
|
"amount"
|
|
],
|
|
"additionalProperties": false
|
|
},
|
|
"states": [
|
|
{
|
|
"key": "CREADA",
|
|
"terminal": false
|
|
},
|
|
{
|
|
"key": "CONFIRMACION_PENDIENTE",
|
|
"terminal": false
|
|
},
|
|
{
|
|
"key": "COMPRA_CONFIRMADA",
|
|
"terminal": true
|
|
},
|
|
{
|
|
"key": "COMPRA_CANCELADA",
|
|
"terminal": true
|
|
}
|
|
],
|
|
"events": [
|
|
{
|
|
"key": "ASIGNAR_CLIENTE",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {},
|
|
"required": [],
|
|
"additionalProperties": false
|
|
}
|
|
},
|
|
{
|
|
"key": "CONFIRMAR_COMPRA",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"confirmada": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"required": [
|
|
"confirmada"
|
|
],
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
],
|
|
"transitions": [
|
|
{
|
|
"id": "asignar-cliente",
|
|
"from": "CREADA",
|
|
"event": "ASIGNAR_CLIENTE",
|
|
"allowedRoles": [
|
|
"ANALISTA"
|
|
],
|
|
"actions": [
|
|
{
|
|
"id": "cliente",
|
|
"type": "INVOKE_INTEGRATION",
|
|
"integrationKey": "CLIENTES_CONSULTA",
|
|
"contractVersion": "1",
|
|
"inputs": {
|
|
"client": {
|
|
"path": "/request/data/client"
|
|
}
|
|
},
|
|
"resultKey": "cliente"
|
|
}
|
|
],
|
|
"decision": "CLIENTE_EXISTE",
|
|
"destinations": {
|
|
"CLIENTE_ENCONTRADO": "CONFIRMACION_PENDIENTE",
|
|
"CLIENTE_NO_ENCONTRADO": "CREADA"
|
|
},
|
|
"updates": [
|
|
{
|
|
"target": "/cliente",
|
|
"value": {
|
|
"path": "/results/cliente"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"id": "confirmar-compra",
|
|
"from": "CONFIRMACION_PENDIENTE",
|
|
"event": "CONFIRMAR_COMPRA",
|
|
"allowedRoles": [
|
|
"ANALISTA"
|
|
],
|
|
"actions": [],
|
|
"decision": "CONFIRMACION",
|
|
"destinations": {
|
|
"CONFIRMADA": "COMPRA_CONFIRMADA",
|
|
"CANCELADA": "COMPRA_CANCELADA"
|
|
},
|
|
"updates": [
|
|
{
|
|
"target": "/confirmada",
|
|
"value": {
|
|
"path": "/event/data/confirmada"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"decisions": [
|
|
{
|
|
"id": "CLIENTE_EXISTE",
|
|
"hitPolicy": "UNIQUE",
|
|
"rules": [
|
|
{
|
|
"id": "encontrado",
|
|
"when": {
|
|
"op": "EQ",
|
|
"left": {
|
|
"path": "/results/cliente/found"
|
|
},
|
|
"right": {
|
|
"literal": true
|
|
}
|
|
},
|
|
"output": "CLIENTE_ENCONTRADO"
|
|
}
|
|
],
|
|
"defaultOutput": "CLIENTE_NO_ENCONTRADO"
|
|
},
|
|
{
|
|
"id": "CONFIRMACION",
|
|
"hitPolicy": "UNIQUE",
|
|
"rules": [
|
|
{
|
|
"id": "confirmada",
|
|
"when": {
|
|
"op": "EQ",
|
|
"left": {
|
|
"path": "/event/data/confirmada"
|
|
},
|
|
"right": {
|
|
"literal": true
|
|
}
|
|
},
|
|
"output": "CONFIRMADA"
|
|
}
|
|
],
|
|
"defaultOutput": "CANCELADA"
|
|
}
|
|
],
|
|
"tasks": [
|
|
{
|
|
"state": "CREADA",
|
|
"event": "ASIGNAR_CLIENTE",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {},
|
|
"required": [],
|
|
"additionalProperties": false
|
|
},
|
|
"ui": {
|
|
"component": "FORM",
|
|
"title": "Consultar cliente",
|
|
"fieldOrder": []
|
|
}
|
|
},
|
|
{
|
|
"state": "CONFIRMACION_PENDIENTE",
|
|
"event": "CONFIRMAR_COMPRA",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"confirmada": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"required": [
|
|
"confirmada"
|
|
],
|
|
"additionalProperties": false
|
|
},
|
|
"ui": {
|
|
"component": "FORM",
|
|
"title": "Confirmar o cancelar compra de demostración",
|
|
"fieldOrder": [
|
|
"confirmada"
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|