// Builds n8n/W3-expiry-sync.json — the 5-min expiry sweep. // Single source of truth: shared/effective-grants.js (inlined) + w3-body.js. // Run: node n8n/gen_w3.js const fs = require('fs'); const path = require('path'); const { sharedSource } = require('./inline_shared'); let body = fs.readFileSync(path.join(__dirname, 'w3-body.js'), 'utf8'); body = body.replace('// __SHARED_INLINE__ (replaced by shared/effective-grants.js source at build)', sharedSource()); const workflow = { name: 'W3 - Expiry Sync (AList Role Reconciliation)', nodes: [ { parameters: { rule: { interval: [{ field: 'minutes', minutesInterval: 5 }] } }, id: 'trigger-schedule', name: 'Every 5 minutes', type: 'n8n-nodes-base.scheduleTrigger', typeVersion: 1.2, position: [0, 0] }, { parameters: { jsCode: body }, id: 'reconcile', name: 'Reconcile & Apply (Expiry Sweep)', type: 'n8n-nodes-base.code', typeVersion: 2, position: [220, 0] } ], connections: { 'Every 5 minutes': { main: [[{ node: 'Reconcile & Apply (Expiry Sweep)', type: 'main', index: 0 }]] } }, settings: { executionOrder: 'v1' }, pinData: {} }; fs.writeFileSync(path.join(__dirname, 'W3-expiry-sync.json'), JSON.stringify(workflow, null, 2) + '\n'); console.log('wrote W3-expiry-sync.json (' + body.length + ' chars body)');