11import { apiCall } from "../core" ;
22import { HttpMethod } from "../core/types" ;
3+ import { getAndWaitForOperationStatusCompleted } from "../operation" ;
4+ import type { OperationStatus } from "../operation/types" ;
35
46/**
57 * Start the process of adding an app to a server.
@@ -15,21 +17,21 @@ import { HttpMethod } from "../core/types";
1517 *
1618 * ```
1719 */
18- export function startAddAppProcess (
20+ export async function addApp (
1921 serverId : number ,
2022 application : string ,
2123 appLabel : string ,
2224 projectName ?: string
23- ) : Promise < number > {
25+ ) : Promise < OperationStatus > {
2426 const data = {
2527 server_id : serverId ,
2628 application : application ,
2729 app_label : appLabel ,
2830 project_name : projectName || "" ,
2931 } ;
30- return apiCall ( "/app" , HttpMethod . POST , data ) . then (
31- ( response ) => response . operation_id
32- ) ;
32+
33+ const req = await apiCall ( "/app" , HttpMethod . POST , data ) ;
34+ return await getAndWaitForOperationStatusCompleted ( req . operation_id ) ;
3335}
3436
3537/**
@@ -46,20 +48,18 @@ export function startAddAppProcess(
4648 * }
4749 * ```
4850 */
49- export function cloneApp (
51+ export async function cloneApp (
5052 serverId : number ,
5153 appId : number ,
5254 appLabel : string
53- ) : Promise < { appId : number ; operationId : number } > {
55+ ) : Promise < OperationStatus > {
5456 const data = {
5557 server_id : serverId ,
5658 app_id : appId ,
5759 app_label : appLabel ,
5860 } ;
59- return apiCall ( "/app/clone" , HttpMethod . POST , data ) . then ( ( response ) => ( {
60- appId : response . app_id ,
61- operationId : response . operation_id ,
62- } ) ) ;
61+ const req = await apiCall ( "/app/clone" , HttpMethod . POST , data ) ;
62+ return await getAndWaitForOperationStatusCompleted ( req . operation_id ) ;
6363}
6464
6565/**
0 commit comments