{
  "name": "Grownob | Webhook event review",
  "nodes": [
    {
      "parameters": {},
      "id": "e1304532-f0a6-49cc-872e-dc1d69769fdd",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "return [{json:{\"processedIds\":[\"evt-001\"],\"events\":[{\"id\":\"evt-001\",\"domain\":\"west.example\"},{\"id\":\"evt-002\",\"domain\":\"east.example\"},{\"id\":\"evt-002\",\"domain\":\"east.example\"},{\"id\":\"\",\"domain\":\"north.example\"},{\"id\":\"evt-003\",\"domain\":\"invalid\"},{\"id\":\"evt-004\",\"domain\":\"https://www.south.example/\"}]}}];"
      },
      "id": "b015f1fa-deaf-4dd2-9d2e-d42c6fad3e76",
      "name": "Load event records",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const x=$input.first().json;const domain=s=>String(s??'').trim().toLowerCase().replace(/^https?:\\/\\//,'').replace(/^www\\./,'').replace(/\\/$/,'');if(!Array.isArray(x.events)||!Array.isArray(x.processedIds))throw Error('Provide events and processedIds arrays.');const seen=new Set(x.processedIds);return x.events.map(e=>{const d=domain(e.domain),id=String(e.id??'').trim();let status;if(!id||!/^([a-z0-9-]+\\.)+[a-z]{2,}$/i.test(d))status='invalid';else if(seen.has(id))status='duplicate';else{seen.add(id);status='accepted_for_handoff';}return {json:{id,domain:d,status}};});"
      },
      "id": "82dee406-81ae-4200-8816-526fc56d4c03",
      "name": "Validate and deduplicate",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const rows=$input.all().map(i=>i.json);return [{json:{accepted:rows.filter(r=>r.status==='accepted_for_handoff'),duplicates:rows.filter(r=>r.status==='duplicate'),invalid:rows.filter(r=>r.status==='invalid')}}];"
      },
      "id": "c7b229c1-1ce2-4b3b-97be-63dcd8537526",
      "name": "Prepare review queues",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        780,
        0
      ]
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Load event records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load event records": {
      "main": [
        [
          {
            "node": "Validate and deduplicate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate and deduplicate": {
      "main": [
        [
          {
            "node": "Prepare review queues",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}