diff --git a/ts_apiclient/classes.cloudlyapiclient.ts b/ts_apiclient/classes.cloudlyapiclient.ts index 2f962f2..2a1b0ba 100644 --- a/ts_apiclient/classes.cloudlyapiclient.ts +++ b/ts_apiclient/classes.cloudlyapiclient.ts @@ -180,6 +180,20 @@ export class CloudlyApiClient { getRegistryById: async (registryNameArg: string) => { return ExternalRegistry.getExternalRegistryById(this, registryNameArg); }, + updateRegistry: async (registryId: string, registryData: plugins.servezoneInterfaces.data.IExternalRegistry['data']): Promise<{ resultRegistry: plugins.servezoneInterfaces.data.IExternalRegistry }> => { + const op = 'updateExternalRegistry'; + const payload = { identity: this.identity, registryId, registryData } as any; + const wsReq = this.createWsRequest(op); + if (wsReq) return wsReq.fire(payload); + return this.createHttpRequest(op).fire(payload); + }, + deleteRegistry: async (registryId: string): Promise<{ ok: boolean }> => { + const op = 'deleteExternalRegistryById'; + const payload = { identity: this.identity, registryId } as any; + const wsReq = this.createWsRequest(op); + if (wsReq) return wsReq.fire(payload); + return this.createHttpRequest(op).fire(payload); + }, getRegistries: async () => { return ExternalRegistry.getExternalRegistries(this); }, @@ -292,6 +306,13 @@ export class CloudlyApiClient { }, createSecretBundle: async (optionsArg: Parameters[1]) => { return SecretBundle.createSecretBundle(this, optionsArg); + }, + deleteSecretBundleById: async (secretBundleId: string): Promise<{ ok: boolean }> => { + const op = 'deleteSecretBundleById'; + const payload = { identity: this.identity, secretBundleId } as any; + const wsReq = this.createWsRequest(op); + if (wsReq) return wsReq.fire(payload); + return this.createHttpRequest(op).fire(payload); } } @@ -305,6 +326,13 @@ export class CloudlyApiClient { }, createSecretGroup: async (optionsArg: Parameters[1]) => { return SecretGroup.createSecretGroup(this, optionsArg); + }, + deleteSecretGroupById: async (secretGroupId: string): Promise<{ ok: boolean }> => { + const op = 'deleteSecretGroupById'; + const payload = { identity: this.identity, secretGroupId } as any; + const wsReq = this.createWsRequest(op); + if (wsReq) return wsReq.fire(payload); + return this.createHttpRequest(op).fire(payload); } } diff --git a/ts_web/appstate.ts b/ts_web/appstate.ts index 654d8e9..a2896bb 100644 --- a/ts_web/appstate.ts +++ b/ts_web/appstate.ts @@ -102,7 +102,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { const secretGroups = await apiClient.secretgroup.getSecretGroups(); currentState = { ...currentState, - secretGroups: secretGroups as any, + secretGroups: (secretGroups as any[]).map((sg: any) => ({ id: sg.id, data: sg.data })), }; } catch (err) { console.error('Failed to fetch secret groups:', err); @@ -118,7 +118,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { const responseSecretBundles = await apiClient.secretbundle.getSecretBundles(); currentState = { ...currentState, - secretBundles: responseSecretBundles as any, + secretBundles: (responseSecretBundles as any[]).map((sb: any) => ({ id: sb.id, data: sb.data })), }; } catch (err) { console.error('Failed to fetch secret bundles:', err); @@ -134,7 +134,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { const images = await apiClient.image.getImages(); currentState = { ...currentState, - images: images as any, + images: (images as any[]).map((im: any) => ({ id: im.id, data: im.data })), }; } catch (err) { console.error('Failed to fetch images:', err); @@ -150,7 +150,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { const clusters = await apiClient.cluster.getClusters(); currentState = { ...currentState, - clusters: clusters as any, + clusters: (clusters as any[]).map((cl: any) => ({ id: cl.id, data: cl.data })), } } catch (err) { console.error('Failed to fetch clusters:', err); @@ -166,7 +166,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { const registries = await apiClient.externalRegistry.getRegistries(); currentState = { ...currentState, - externalRegistries: registries as any, + externalRegistries: (registries as any[]).map((r: any) => ({ id: r.id, data: r.data })), }; } catch (error) { console.error('Failed to fetch external registries:', error); @@ -182,7 +182,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { const services = await apiClient.services.getServices(); currentState = { ...currentState, - services: services as any, + services: (services as any[]).map((s: any) => ({ id: s.id, data: s.data })), }; } catch (error) { console.error('Failed to fetch services:', error); @@ -295,10 +295,7 @@ export const deleteSecretGroupAction = dataState.createAction( let currentState = statePartArg.getState(); try { apiClient.identity = loginStatePart.getState().identity; - const sg = (currentState.secretGroups as any[])?.find(s => s.id === payloadArg.secretGroupId); - if (sg) { - await sg.delete(apiClient as any, sg.id); - } + await apiClient.secretgroup.deleteSecretGroupById(payloadArg.secretGroupId); currentState = await dataState.dispatchAction(getAllDataAction, null); } catch (err) { console.error('Failed to delete secret group:', err); @@ -313,10 +310,7 @@ export const deleteSecretBundleAction = dataState.createAction( let currentState = statePartArg.getState(); try { apiClient.identity = loginStatePart.getState().identity; - const sb = (currentState.secretBundles as any[])?.find(b => b.id === payloadArg.configBundleId); - if (sb) { - await sb.delete(apiClient as any, sb.id); - } + await apiClient.secretbundle.deleteSecretBundleById(payloadArg.configBundleId); currentState = await dataState.dispatchAction(getAllDataAction, null); } catch (err) { console.error('Failed to delete secret bundle:', err); @@ -465,11 +459,7 @@ export const updateExternalRegistryAction = dataState.createAction( let currentState = statePartArg.getState(); try { apiClient.identity = loginStatePart.getState().identity; - const reg = (currentState.externalRegistries as any[])?.find(r => r.id === payloadArg.registryId); - if (reg) { - reg.data = payloadArg.registryData; - await reg.update(); - } + await apiClient.externalRegistry.updateRegistry(payloadArg.registryId, payloadArg.registryData); currentState = await dataState.dispatchAction(getAllDataAction, null); } catch (err) { console.error('Failed to update external registry:', err); @@ -483,10 +473,7 @@ export const deleteExternalRegistryAction = dataState.createAction( let currentState = statePartArg.getState(); try { apiClient.identity = loginStatePart.getState().identity; - const reg = (currentState.externalRegistries as any[])?.find(r => r.id === payloadArg.registryId); - if (reg) { - await reg.delete(apiClient as any, reg.id); - } + await apiClient.externalRegistry.deleteRegistry(payloadArg.registryId); currentState = await dataState.dispatchAction(getAllDataAction, null); } catch (err) { console.error('Failed to delete external registry:', err);