-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_demo_workflow.js
More file actions
35 lines (31 loc) · 871 Bytes
/
Copy pathfetch_demo_workflow.js
File metadata and controls
35 lines (31 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const { PrismaClient } = require('@prisma/client');
const fs = require('fs');
const prisma = new PrismaClient();
async function main() {
try {
const wf = await prisma.workflow.findFirst({
where: { name: { contains: 'Demo' } },
select: { id: true, name: true, nodes: true }
});
if (wf) {
const nodes = JSON.parse(JSON.stringify(wf.nodes));
const output = nodes.map(n => ({
id: n.id,
type: n.type,
position: n.position,
label: n.data?.label,
videoUrl: n.data?.videoUrl,
imageUrl: n.data?.imageUrl
}));
fs.writeFileSync('workflow_nodes.json', JSON.stringify(output, null, 2));
console.log('WORKFLOW_SAVED');
} else {
console.log('WORKFLOW_NOT_FOUND');
}
} catch (e) {
console.error(e);
} finally {
await prisma.$disconnect();
}
}
main();