{
  "name": "FLUF — a publication ledger in Google Sheets",
  "nodes": [
    {
      "name": "FLUF event",
      "type": "n8n-nodes-fluf-connect.flufConnectTrigger",
      "parameters": {
        "event": "listing_crosslisted"
      },
      "position": [
        240,
        300
      ],
      "typeVersion": 1,
      "id": "e52705cf-c6da-4f21-95e8-0a7534ac84a4",
      "webhookId": "bdf5c921-fb36-4497-8c70-8ec75d64b1b2"
    },
    {
      "name": "Prepare event",
      "type": "n8n-nodes-base.code",
      "parameters": {
        "jsCode": "return $input.all().map((item, i) => {\n const s = item.json;\n if (s.test || s.synthetic || s.event !== \"listing_crosslisted\" || !s.event_id || !s.listing_id || !s.channel || !s.external_id) throw new Error('Use a real listing_crosslisted event with an event_id and required fields.');\n const row = {event_id: String(s.event_id), listing_id: String(s.listing_id), channel: s.channel, external_id: String(s.external_id), channel_url: s.channel_url ?? '', fired_at: s.fired_at ?? ''};\n return {json: row, pairedItem: {item: i}};\n});"
      },
      "position": [
        480,
        300
      ],
      "typeVersion": 2,
      "id": "4665bb8e-5943-448f-b0c8-79d797be9b46"
    },
    {
      "name": "Save in Published",
      "type": "n8n-nodes-base.googleSheets",
      "parameters": {
        "resource": "sheet",
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Published",
          "mode": "name"
        },
        "options": {
          "cellFormat": "RAW"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "event_id": "={{ $json.event_id }}",
            "listing_id": "={{ $json.listing_id }}",
            "channel": "={{ $json.channel }}",
            "external_id": "={{ $json.external_id }}",
            "channel_url": "={{ $json.channel_url }}",
            "fired_at": "={{ $json.fired_at }}"
          },
          "matchingColumns": [
            "event_id"
          ],
          "schema": [
            {
              "id": "event_id",
              "displayName": "event_id",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "listing_id",
              "displayName": "listing_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "channel",
              "displayName": "channel",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "external_id",
              "displayName": "external_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "channel_url",
              "displayName": "channel_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "fired_at",
              "displayName": "fired_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "position": [
        720,
        300
      ],
      "typeVersion": 4.7,
      "id": "06c40397-64c8-4c0f-84c5-56ca1af3adb9"
    },
    {
      "name": "Start here",
      "type": "n8n-nodes-base.stickyNote",
      "parameters": {
        "content": "## Publication ledger\nCreate a Published tab with headers: event_id, listing_id, channel, external_id, channel_url, fired_at\nSelect FLUF and Google credentials and set the spreadsheet ID. Records confirmed crosslisting events, not queued jobs. A public URL may be missing or awaiting moderation. This is event history, not current live availability. Upsert by event_id is best-effort; concurrent runs can duplicate rows.\nSetup: https://fluf.io/support/connect-n8n/#publication-ledger",
        "height": 260,
        "width": 720
      },
      "position": [
        240,
        -20
      ],
      "typeVersion": 1,
      "id": "842ebc1c-f81d-424e-b68c-223ca54a5027"
    }
  ],
  "connections": {
    "FLUF event": {
      "main": [
        [
          {
            "node": "Prepare event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare event": {
      "main": [
        [
          {
            "node": "Save in Published",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}
