| 1234567891011121314151617181920212223242526 |
- {
- "name": "verify-merge-combine-by-nested-key",
- "nodes": [
- {"id": "n1", "name": "Trigger", "type": "click-trigger", "position": {"x": 0, "y": 0}, "config": {}},
- {"id": "left", "name": "Left", "type": "code", "position": {"x": -150, "y": 100},
- "config": {"code": "return { items: [ { id: 'a.ru', enclosure: { url: 'https://cdn/1.jpg' }, from: 'left' }, { id: 'b.ru', enclosure: { url: 'https://cdn/2.jpg' }, from: 'left' } ] };"}},
- {"id": "right", "name": "Right", "type": "code", "position": {"x": 150, "y": 100},
- "config": {"code": "return { items: [ { id: 'a.pro', enclosure: { url: 'https://cdn/1.jpg' }, from: 'right' }, { id: 'c.pro', enclosure: { url: 'https://cdn/3.jpg' }, from: 'right' } ] };"}},
- {"id": "merge", "name": "Merge", "type": "merge", "position": {"x": 0, "y": 220},
- "config": {"mode": "combine-by-key", "key": "enclosure.url", "path1": "result.items", "path2": "result.items"}},
- {"id": "check", "name": "Check", "type": "code", "position": {"x": 0, "y": 340},
- "config": {"code": "const m = (input.data || input).merged || []; const urls = m.map(function (i) { return i.enclosure.url; }); return { count: m.length, unique: new Set(urls).size, ids: m.map(function (i) { return i.id; }).join(','), overlapTookTheSecond: (m.find(function (i) { return i.enclosure.url === 'https://cdn/1.jpg'; }) || {}).from };"}}
- ],
- "connections": [
- {"sourceNodeId": "n1", "sourceOutput": "main", "targetNodeId": "left", "targetInput": "data"},
- {"sourceNodeId": "n1", "sourceOutput": "main", "targetNodeId": "right", "targetInput": "data"},
- {"sourceNodeId": "left", "sourceOutput": "main", "targetNodeId": "merge", "targetInput": "input1"},
- {"sourceNodeId": "right", "sourceOutput": "main", "targetNodeId": "merge", "targetInput": "input2"},
- {"sourceNodeId": "merge", "sourceOutput": "main", "targetNodeId": "check", "targetInput": "data"}
- ],
- "expect": {
- "merge": {"status": "completed", "output": {"count": 3}},
- "check": {"status": "completed",
- "output": {"result": {"count": 3, "unique": 3, "overlapTookTheSecond": "right"}}}
- }
- }
|