{
  "id": "rMY8O0y43F6oRGQa",
  "name": "40_460_GDRIVE_SYNC",
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "nodes": [
    {
      "id": "sched-460",
      "name": "Trigger: t\u00e4glich 07:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 7 * * *"
            }
          ]
        }
      }
    },
    {
      "id": "nocodb-assets",
      "name": "NocoDB media_assets laden",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        240,
        0
      ],
      "parameters": {
        "method": "GET",
        "url": "https://directus.automation-plus-ki.de/items/420_media_assets?limit=50&sort=-CreatedAt",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer ={{ $env.DIRECTUS_TOKEN }}"
            }
          ]
        }
      }
    },
    {
      "id": "stats-460",
      "name": "Stats berechnen",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        480,
        0
      ],
      "parameters": {
        "jsCode": "const d=$input.first().json;\nconst list=d.data||[];\nconst total=d.pageInfo?.totalRows||list.length;\nconst images=list.filter(a=>a.asset_type==='image').length;\nconst audio=list.filter(a=>a.asset_type==='audio').length;\nreturn [{json:{total,images,audio,last_sync:new Date().toISOString()}}];"
      }
    },
    {
      "id": "audit-460",
      "name": "Audit Trail",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        0
      ],
      "parameters": {
        "method": "POST",
        "url": "https://directus.automation-plus-ki.de/items/audit_log",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer ={{ $env.DIRECTUS_TOKEN }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "json",
        "body": "={{ JSON.stringify({audit_id:$randomString(16),ts:new Date().toISOString(),actor:'40_460_GDRIVE_SYNC',action:'gdrive.sync',resource_type:'media_assets',resource_id:'all',after_json:JSON.stringify($json),result:'ok'}) }}"
      }
    }
  ],
  "connections": {
    "Trigger: t\u00e4glich 07:00": {
      "main": [
        [
          {
            "node": "NocoDB media_assets laden",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "NocoDB media_assets laden": {
      "main": [
        [
          {
            "node": "Stats berechnen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stats berechnen": {
      "main": [
        [
          {
            "node": "Audit Trail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}