{
  "name": "Supplier Shield: check new suppliers from Google Sheets",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "event": "rowAdded",
        "options": {}
      },
      "id": "1b1f0b8e-0001-4c3a-9a10-000000000001",
      "name": "New supplier row",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 1,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://provenant.provenant.workers.dev/v1/shield/check",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ website: $json.website, name: $json.supplier, reference: $json.reference, source: 'api' }) }}",
        "options": {
          "timeout": 60000
        }
      },
      "id": "1b1f0b8e-0002-4c3a-9a10-000000000002",
      "name": "Provenant Supplier Shield check",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        260,
        300
      ],
      "notes": "Credential: Header Auth. Name = Authorization, Value = Bearer pv_your_key"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.decision }}",
              "rightValue": "proceed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "1b1f0b8e-0003-4c3a-9a10-000000000003",
      "name": "Low concern?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        520,
        300
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "website": "={{ $('New supplier row').item.json.website }}",
            "status": "Low concern: continue onboarding",
            "report": "={{ $json.report }}",
            "checked_at": "={{ $json.checkedAt }}"
          },
          "matchingColumns": [
            "website"
          ],
          "schema": []
        },
        "options": {}
      },
      "id": "1b1f0b8e-0004-4c3a-9a10-000000000004",
      "name": "Mark: continue onboarding",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        780,
        200
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "website": "={{ $('New supplier row').item.json.website }}",
            "status": "={{ $json.decision === 'avoid' ? 'Red flags: human review' : 'Caution: human review' }}",
            "flags": "={{ $json.signals.filter(s => s.level !== 'info').map(s => s.text).join('; ') }}",
            "report": "={{ $json.report }}",
            "checked_at": "={{ $json.checkedAt }}"
          },
          "matchingColumns": [
            "website"
          ],
          "schema": []
        },
        "options": {}
      },
      "id": "1b1f0b8e-0005-4c3a-9a10-000000000005",
      "name": "Flag for human review",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        780,
        420
      ]
    }
  ],
  "connections": {
    "New supplier row": {
      "main": [
        [
          {
            "node": "Provenant Supplier Shield check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Provenant Supplier Shield check": {
      "main": [
        [
          {
            "node": "Low concern?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Low concern?": {
      "main": [
        [
          {
            "node": "Mark: continue onboarding",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Flag for human review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
