File size: 2,284 Bytes
cce8120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash
set -euo pipefail

echo "[1/10] Creating Low-Code Workspace..."

mkdir -p services/lowcode
mkdir -p hooks
mkdir -p components/lowcode

echo "[2/10] Installing packages..."
npm install reactflow

cat > services/lowcode/client.js <<'EOC'
import api from "../api";

const lowcode={

list:async()=>{
const {data}=await api.get("/api/lowcode/workflows");
return data;
},

load:async(id)=>{
const {data}=await api.get(`/api/lowcode/workflows/${id}`);
return data;
},

save:async(payload)=>{
const {data}=await api.post("/api/lowcode/workflows",payload);
return data;
},

run:async(id)=>{
const {data}=await api.post(`/api/lowcode/workflows/${id}/run`);
return data;
},

delete:async(id)=>{
const {data}=await api.delete(`/api/lowcode/workflows/${id}`);
return data;
}

};

export default lowcode;
EOC

cat > hooks/useLowCode.js <<'EOC'
"use client";

import {useState} from "react";
import lowcode from "../services/lowcode/client";

export default function useLowCode(){

const [loading,setLoading]=useState(false);

async function run(fn,...args){
setLoading(true);
try{
return await fn(...args);
}
finally{
setLoading(false);
}
}

return{
loading,
list:(...a)=>run(lowcode.list,...a),
load:(...a)=>run(lowcode.load,...a),
save:(...a)=>run(lowcode.save,...a),
runWorkflow:(...a)=>run(lowcode.run,...a),
remove:(...a)=>run(lowcode.delete,...a)
};

}
EOC

cat > components/lowcode/ProductionLowCode.jsx <<'EOC'
"use client";

import {
ReactFlow,
Background,
Controls,
MiniMap
} from "reactflow";

import "reactflow/dist/style.css";

export default function ProductionLowCode(){

return(
<div style={{width:"100%",height:"100vh"}}>
<ReactFlow nodes={[]} edges={[]} fitView>
<MiniMap/>
<Controls/>
<Background/>
</ReactFlow>
</div>
);

}
EOC

cat > components/lowcode/index.js <<'EOC'
export {default} from "./ProductionLowCode";
EOC

echo "[3/10] Building..."
npm run build >/dev/null

echo "[4/10] Verify..."

test -f services/lowcode/client.js
test -f hooks/useLowCode.js
test -f components/lowcode/ProductionLowCode.jsx
test -f components/lowcode/index.js

echo "[5/10] Low-Code API installed."
echo "[6/10] Workflow editor installed."
echo "[7/10] Backend connected."
echo "[8/10] Production build verified."
echo "[9/10] Frontend verified."
echo "[10/10] Complete."