{
  "schema_version": "1.0",
  "identity": {
    "name": "Northstar invoice review queues",
    "description": "Synthetic PS-RULE-01 proof; authored IR; no payment or approval."
  },
  "interface": {
    "inputs": [
      {
        "name": "amount",
        "schema": {
          "type": "number"
        }
      },
      {
        "name": "owner",
        "schema": {
          "type": "string"
        }
      }
    ],
    "outputs": [
      {
        "name": "invoice_id",
        "schema": {
          "type": "string"
        }
      },
      {
        "name": "queue",
        "schema": {
          "type": "string"
        }
      }
    ]
  },
  "triggers": [
    {
      "id": "trigger-schedule",
      "operation": "schedule.run",
      "config": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24
            }
          ]
        }
      }
    }
  ],
  "steps": [
    {
      "id": "input-INV-101",
      "operation": "data.transform",
      "config": {},
      "mappings": {
        "invoice_id": "INV-101",
        "amount": 750,
        "owner": "Operations"
      }
    },
    {
      "id": "rule-INV-101",
      "operation": "data.transform",
      "config": {},
      "mappings": {
        "invoice_id": "={{ $json.invoice_id }}",
        "rule_id": "PS-RULE-01",
        "queue": "={{ !$json.owner || !$json.owner.trim() ? 'needs_information' : ($json.amount > 1000 ? 'manager_review' : 'standard_review') }}"
      }
    },
    {
      "id": "input-INV-102",
      "operation": "data.transform",
      "config": {},
      "mappings": {
        "invoice_id": "INV-102",
        "amount": 1250,
        "owner": "Operations"
      }
    },
    {
      "id": "rule-INV-102",
      "operation": "data.transform",
      "config": {},
      "mappings": {
        "invoice_id": "={{ $json.invoice_id }}",
        "rule_id": "PS-RULE-01",
        "queue": "={{ !$json.owner || !$json.owner.trim() ? 'needs_information' : ($json.amount > 1000 ? 'manager_review' : 'standard_review') }}"
      }
    },
    {
      "id": "input-INV-103",
      "operation": "data.transform",
      "config": {},
      "mappings": {
        "invoice_id": "INV-103",
        "amount": 1250,
        "owner": ""
      }
    },
    {
      "id": "rule-INV-103",
      "operation": "data.transform",
      "config": {},
      "mappings": {
        "invoice_id": "={{ $json.invoice_id }}",
        "rule_id": "PS-RULE-01",
        "queue": "={{ !$json.owner || !$json.owner.trim() ? 'needs_information' : ($json.amount > 1000 ? 'manager_review' : 'standard_review') }}"
      }
    },
    {
      "id": "input-INV-104",
      "operation": "data.transform",
      "config": {},
      "mappings": {
        "invoice_id": "INV-104",
        "amount": 1000,
        "owner": "Operations"
      }
    },
    {
      "id": "rule-INV-104",
      "operation": "data.transform",
      "config": {},
      "mappings": {
        "invoice_id": "={{ $json.invoice_id }}",
        "rule_id": "PS-RULE-01",
        "queue": "={{ !$json.owner || !$json.owner.trim() ? 'needs_information' : ($json.amount > 1000 ? 'manager_review' : 'standard_review') }}"
      }
    },
    {
      "id": "input-INV-105",
      "operation": "data.transform",
      "config": {},
      "mappings": {
        "invoice_id": "INV-105",
        "amount": 750,
        "owner": "   "
      }
    },
    {
      "id": "rule-INV-105",
      "operation": "data.transform",
      "config": {},
      "mappings": {
        "invoice_id": "={{ $json.invoice_id }}",
        "rule_id": "PS-RULE-01",
        "queue": "={{ !$json.owner || !$json.owner.trim() ? 'needs_information' : ($json.amount > 1000 ? 'manager_review' : 'standard_review') }}"
      }
    }
  ],
  "edges": [
    {
      "id": "edge-trigger-INV-101",
      "source_id": "trigger-schedule",
      "target_id": "input-INV-101",
      "condition": null
    },
    {
      "id": "edge-input-INV-101",
      "source_id": "input-INV-101",
      "target_id": "rule-INV-101",
      "condition": null
    },
    {
      "id": "edge-trigger-INV-102",
      "source_id": "trigger-schedule",
      "target_id": "input-INV-102",
      "condition": null
    },
    {
      "id": "edge-input-INV-102",
      "source_id": "input-INV-102",
      "target_id": "rule-INV-102",
      "condition": null
    },
    {
      "id": "edge-trigger-INV-103",
      "source_id": "trigger-schedule",
      "target_id": "input-INV-103",
      "condition": null
    },
    {
      "id": "edge-input-INV-103",
      "source_id": "input-INV-103",
      "target_id": "rule-INV-103",
      "condition": null
    },
    {
      "id": "edge-trigger-INV-104",
      "source_id": "trigger-schedule",
      "target_id": "input-INV-104",
      "condition": null
    },
    {
      "id": "edge-input-INV-104",
      "source_id": "input-INV-104",
      "target_id": "rule-INV-104",
      "condition": null
    },
    {
      "id": "edge-trigger-INV-105",
      "source_id": "trigger-schedule",
      "target_id": "input-INV-105",
      "condition": null
    },
    {
      "id": "edge-input-INV-105",
      "source_id": "input-INV-105",
      "target_id": "rule-INV-105",
      "condition": null
    }
  ],
  "controls": {
    "retries": [],
    "timeouts": [
      {
        "scope": "workflow",
        "seconds": 60
      }
    ],
    "error_routes": [],
    "compensation": []
  },
  "data_contracts": [],
  "credential_requirements": [],
  "runtime_requirements": [],
  "native_extensions": {}
}
