@@ -5,6 +5,7 @@ import { exeConnection, integrationStatus, authorizedClient, accessToken, create
55import { executionTargetResponse , triggerAvailabilityResponse , namedOption , providerOptions , githubInstallation , githubRepository , tailIntegration } from "./editor-contracts" ;
66import { runSummaryResponse , runPageResponse , runStatusResponse , revisionTracePage , revisionTraceQuery } from "./run-read-contracts" ;
77import { jobPageQuery , jobSummaryPage , jobSelectorPage , jobResponse , jobUpdateInput } from "./job-contracts" ;
8+ import { projectInput , projectResponse } from "./project-contracts" ;
89import { z } from "zod" ;
910import type { ApiService } from "./flow-service" ;
1011import {
@@ -73,6 +74,8 @@ const tailBody = z.object({
7374 . meta ( { writeOnly : true } ) ,
7475 generateSecret : z . boolean ( ) . optional ( ) ,
7576} ) ;
77+ const executionTargetBody = z . object ( { name : z . string ( ) . trim ( ) . min ( 1 ) . max ( 120 ) , integrationKind : z . enum ( [ "exe" , "amp" ] ) , integrationId : z . string ( ) . min ( 1 ) , tags : z . array ( z . string ( ) . regex ( / ^ [ A - Z a - z 0 - 9 ] [ A - Z a - z 0 - 9 . _ : - ] { 0 , 63 } $ / ) ) . max ( 20 ) . default ( [ ] ) , agentKind : z . string ( ) . min ( 1 ) . max ( 40 ) } ) ;
78+ const executionTargetUpdateBody = executionTargetBody ;
7679const deliveryQuery = z . object ( {
7780 provider : z . string ( ) . optional ( ) ,
7881 deliveryId : z . string ( ) . optional ( ) ,
@@ -236,6 +239,10 @@ export const API_ROUTES: RouteContract[] = [
236239 } ,
237240 ( service ) => service . listExecutionTargets ( ) ,
238241 ) ,
242+ route ( "POST" , "/api/v1/execution-targets" , "flows:write" , { summary : "Create execution target" , responses : { "201" : { description : "Created" , content : { "application/json" : { schema : jsonSchema ( executionTargetResponse , "output" ) } } } } } , ( service , { body } ) => service . createExecutionTarget ( body ) , { body : executionTargetBody } ) ,
243+ route ( "PUT" , "/api/v1/execution-targets/{targetId}" , "flows:write" , { summary : "Update execution target" , responses : { "200" : { description : "Updated" , content : { "application/json" : { schema : jsonSchema ( executionTargetResponse , "output" ) } } } } } , ( service , { params, body } ) => service . updateExecutionTarget ( params . targetId , body ) , { body : executionTargetUpdateBody } ) ,
244+ route ( "DELETE" , "/api/v1/execution-targets/{targetId}" , "flows:write" , { summary : "Delete execution target" , responses : { "200" : { description : "Deleted" } } } , ( service , { params } ) => service . deleteExecutionTarget ( params . targetId ) ) ,
245+ route ( "POST" , "/api/v1/execution-targets/{targetId}/diagnostics" , "flows:write" , { summary : "Diagnose an execution target" , responses : { "200" : { description : "Target-scoped credential-safe diagnostic result" , content : { "application/json" : { schema : jsonSchema ( z . object ( { ok : z . boolean ( ) , targetId : z . string ( ) , integrationId : z . string ( ) , agentKind : z . string ( ) , tags : z . array ( z . string ( ) ) , permissions : z . object ( { ok : z . boolean ( ) , missing : z . array ( z . string ( ) ) , tags : z . array ( z . string ( ) ) } ) , agent : z . object ( { ok : z . boolean ( ) , models : z . array ( z . string ( ) ) . optional ( ) , error : z . string ( ) . optional ( ) } ) . nullable ( ) } ) , "output" ) } } } } } , ( service , { params } ) => service . diagnoseExecutionTarget ( params . targetId ) ) ,
239246 route (
240247 "GET" ,
241248 "/api/v1/job-trigger-availability" ,
@@ -635,6 +642,18 @@ export const API_ROUTES: RouteContract[] = [
635642 summary : "Search bounded lifecycle job options" ,
636643 responses : { "200" : { description : "Selector page; same ordering/filter semantics as job-summaries" , content : { "application/json" : { schema : jsonSchema ( jobSelectorPage , "output" ) } } } } ,
637644 } , ( service , { query } ) => service . listJobSummaries ( query , true ) , { query : jobPageQuery } ) ,
645+ route (
646+ "GET" ,
647+ "/api/v1/projects" ,
648+ "flows:read" ,
649+ { summary : "List projects" , responses : { "200" : { description : "Projects" , content : { "application/json" : { schema : jsonSchema ( z . array ( projectResponse ) , "output" ) } } } } } ,
650+ ( service ) => service . listProjects ( ) ,
651+ ) ,
652+ route ( "POST" , "/api/v1/projects" , "flows:write" , { summary : "Create project" , responses : { "201" : { description : "Created" , content : { "application/json" : { schema : jsonSchema ( projectResponse , "output" ) } } } } } , ( service , { body } ) => service . createProject ( body ) , { body : projectInput } ) ,
653+ route ( "GET" , "/api/v1/projects/{projectId}" , "flows:read" , { summary : "Get project" , responses : { "200" : { description : "Project" , content : { "application/json" : { schema : jsonSchema ( projectResponse , "output" ) } } } } } , ( service , { params } ) => service . getProject ( params . projectId ) ) ,
654+ route ( "PUT" , "/api/v1/projects/{projectId}" , "flows:write" , { summary : "Update project" , responses : { "200" : { description : "Updated" , content : { "application/json" : { schema : jsonSchema ( projectResponse , "output" ) } } } } } , ( service , { params, body } ) => service . updateProject ( params . projectId , body ) , { body : projectInput } ) ,
655+ route ( "DELETE" , "/api/v1/projects/{projectId}" , "flows:write" , { summary : "Delete empty project" , responses : { "200" : { description : "Deleted" } } } , ( service , { params } ) => service . deleteProject ( params . projectId ) ) ,
656+ route ( "POST" , "/api/v1/jobs/{jobId}/project" , "flows:write" , { summary : "Move a job to a project" , responses : { "200" : { description : "Moved" , content : { "application/json" : { schema : jsonSchema ( jobResponse , "output" ) } } } } } , ( service , { params, body } ) => service . moveJob ( params . jobId , body . projectId , body . expectedUpdatedAt ) , { body : z . object ( { projectId : z . guid ( ) , expectedUpdatedAt : z . iso . datetime ( ) . optional ( ) } ) } ) ,
638657 route (
639658 "GET" ,
640659 "/api/v1/jobs" ,
0 commit comments