Skip to content

Commit 4ecf982

Browse files
intel352CopilotCopilot
authored
feat: decompose V1 CRUD routes into pipeline primitives (#86) (#123)
* feat: decompose V1 CRUD routes into pipeline primitives (#86) Replace 6 V1 admin CRUD routes that delegated to V1APIHandler with declarative pipeline definitions using admin-db: - POST /api/v1/admin/organizations/{id}/projects (create project) - POST /api/v1/admin/projects/{id}/workflows (create workflow in project) - POST /api/v1/admin/workflows (create workflow) - PUT /api/v1/admin/workflows/{id} (update workflow + version) - POST /api/v1/admin/workflows/{id}/deploy (deploy workflow) - POST /api/v1/admin/workflows/{id}/stop (stop workflow) Each route now uses pipeline steps (request_parse, validate, set, db_exec, db_query, conditional, json_response) instead of Go delegates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: return 404 on deploy/stop for non-existent workflow IDs (#137) * Initial plan * fix: add 404 handling to deploy and stop workflow pipelines Co-authored-by: intel352 <77607+intel352@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: intel352 <77607+intel352@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
1 parent 2c0cd78 commit 4ecf982

1 file changed

Lines changed: 98 additions & 7 deletions

File tree

admin/config.yaml

Lines changed: 98 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,27 +1065,118 @@ workflows:
10651065
config:
10661066
status: 200
10671067
body_from: "steps.get-versions.rows"
1068-
# Deploy and Stop delegate to V1APIHandler which manages RuntimeManager
1068+
# Deploy: update workflow status to 'active'
10691069
- method: POST
10701070
path: "/api/v1/admin/workflows/{id}/deploy"
10711071
handler: admin-commands
10721072
middlewares: [admin-cors, admin-auth-middleware]
10731073
pipeline:
10741074
steps:
1075-
- name: deploy-workflow
1076-
type: step.delegate
1075+
- name: parse-request
1076+
type: step.request_parse
10771077
config:
1078-
service: admin-v1-mgmt
1078+
path_params: [id]
1079+
- name: check-exists
1080+
type: step.db_query
1081+
config:
1082+
database: admin-db
1083+
query: "SELECT id FROM workflows WHERE id = ?"
1084+
params: ["{{index .steps \"parse-request\" \"path_params\" \"id\"}}"]
1085+
mode: single
1086+
- name: check-found
1087+
type: step.conditional
1088+
config:
1089+
field: "steps.check-exists.found"
1090+
routes:
1091+
"false": not-found
1092+
default: set-now
1093+
- name: set-now
1094+
type: step.set
1095+
config:
1096+
values:
1097+
now: "{{ now }}"
1098+
- name: activate
1099+
type: step.db_exec
1100+
config:
1101+
database: admin-db
1102+
query: "UPDATE workflows SET status='active', updated_at=? WHERE id=?"
1103+
params:
1104+
- "{{index .steps \"set-now\" \"now\"}}"
1105+
- "{{index .steps \"parse-request\" \"path_params\" \"id\"}}"
1106+
- name: get-workflow
1107+
type: step.db_query
1108+
config:
1109+
database: admin-db
1110+
query: "SELECT id, project_id, name, slug, description, config_yaml, version, status, is_system, workspace_dir, created_by, updated_by, created_at, updated_at FROM workflows WHERE id = ?"
1111+
params: ["{{index .steps \"parse-request\" \"path_params\" \"id\"}}"]
1112+
mode: single
1113+
- name: respond
1114+
type: step.json_response
1115+
config:
1116+
status: 200
1117+
body_from: "steps.get-workflow.row"
1118+
- name: not-found
1119+
type: step.json_response
1120+
config:
1121+
status: 404
1122+
body:
1123+
error: "workflow not found"
1124+
# Stop: update workflow status to 'stopped'
10791125
- method: POST
10801126
path: "/api/v1/admin/workflows/{id}/stop"
10811127
handler: admin-commands
10821128
middlewares: [admin-cors, admin-auth-middleware]
10831129
pipeline:
10841130
steps:
1085-
- name: stop-workflow
1086-
type: step.delegate
1131+
- name: parse-request
1132+
type: step.request_parse
10871133
config:
1088-
service: admin-v1-mgmt
1134+
path_params: [id]
1135+
- name: check-exists
1136+
type: step.db_query
1137+
config:
1138+
database: admin-db
1139+
query: "SELECT id FROM workflows WHERE id = ?"
1140+
params: ["{{index .steps \"parse-request\" \"path_params\" \"id\"}}"]
1141+
mode: single
1142+
- name: check-found
1143+
type: step.conditional
1144+
config:
1145+
field: "steps.check-exists.found"
1146+
routes:
1147+
"false": not-found
1148+
default: set-now
1149+
- name: set-now
1150+
type: step.set
1151+
config:
1152+
values:
1153+
now: "{{ now }}"
1154+
- name: deactivate
1155+
type: step.db_exec
1156+
config:
1157+
database: admin-db
1158+
query: "UPDATE workflows SET status='stopped', updated_at=? WHERE id=?"
1159+
params:
1160+
- "{{index .steps \"set-now\" \"now\"}}"
1161+
- "{{index .steps \"parse-request\" \"path_params\" \"id\"}}"
1162+
- name: get-workflow
1163+
type: step.db_query
1164+
config:
1165+
database: admin-db
1166+
query: "SELECT id, project_id, name, slug, description, config_yaml, version, status, is_system, workspace_dir, created_by, updated_by, created_at, updated_at FROM workflows WHERE id = ?"
1167+
params: ["{{index .steps \"parse-request\" \"path_params\" \"id\"}}"]
1168+
mode: single
1169+
- name: respond
1170+
type: step.json_response
1171+
config:
1172+
status: 200
1173+
body_from: "steps.get-workflow.row"
1174+
- name: not-found
1175+
type: step.json_response
1176+
config:
1177+
status: 404
1178+
body:
1179+
error: "workflow not found"
10891180
# Load workflow from a server-local filesystem path
10901181
- method: POST
10911182
path: "/api/v1/admin/workflows/load-from-path"

0 commit comments

Comments
 (0)