feat(appstate): Remove helper function for stripping class instances from data fetching
This commit is contained in:
		| @@ -2,11 +2,6 @@ import * as plugins from './plugins.js'; | |||||||
| import * as domtools from '@design.estate/dees-domtools'; | import * as domtools from '@design.estate/dees-domtools'; | ||||||
|  |  | ||||||
| const appstate = new plugins.deesDomtools.plugins.smartstate.Smartstate(); | const appstate = new plugins.deesDomtools.plugins.smartstate.Smartstate(); | ||||||
|  |  | ||||||
| // Helper: strip class instances (with circular refs) to plain objects |  | ||||||
| type IdData<T> = { id: string; data: T }; |  | ||||||
| const toPlain = <D>(items: Array<{ id: string; data: D }> = []): Array<IdData<D>> => |  | ||||||
|   items.map(({ id, data }) => ({ id, data })); |  | ||||||
| export interface ILoginState { | export interface ILoginState { | ||||||
|   identity: plugins.interfaces.data.IIdentity; |   identity: plugins.interfaces.data.IIdentity; | ||||||
| } | } | ||||||
| @@ -107,7 +102,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { | |||||||
|     const secretGroups = await apiClient.secretgroup.getSecretGroups(); |     const secretGroups = await apiClient.secretgroup.getSecretGroups(); | ||||||
|     currentState = { |     currentState = { | ||||||
|       ...currentState, |       ...currentState, | ||||||
|       secretGroups: toPlain(secretGroups), |       secretGroups: secretGroups, | ||||||
|     }; |     }; | ||||||
|   } catch (err) { |   } catch (err) { | ||||||
|     console.error('Failed to fetch secret groups:', err); |     console.error('Failed to fetch secret groups:', err); | ||||||
| @@ -123,7 +118,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { | |||||||
|     const responseSecretBundles = await apiClient.secretbundle.getSecretBundles(); |     const responseSecretBundles = await apiClient.secretbundle.getSecretBundles(); | ||||||
|     currentState = { |     currentState = { | ||||||
|       ...currentState, |       ...currentState, | ||||||
|       secretBundles: toPlain(responseSecretBundles), |       secretBundles: responseSecretBundles, | ||||||
|     }; |     }; | ||||||
|   } catch (err) { |   } catch (err) { | ||||||
|     console.error('Failed to fetch secret bundles:', err); |     console.error('Failed to fetch secret bundles:', err); | ||||||
| @@ -139,7 +134,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { | |||||||
|     const images = await apiClient.image.getImages(); |     const images = await apiClient.image.getImages(); | ||||||
|     currentState = { |     currentState = { | ||||||
|       ...currentState, |       ...currentState, | ||||||
|       images: toPlain(images), |       images: images, | ||||||
|     }; |     }; | ||||||
|   } catch (err) { |   } catch (err) { | ||||||
|     console.error('Failed to fetch images:', err); |     console.error('Failed to fetch images:', err); | ||||||
| @@ -155,7 +150,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { | |||||||
|     const clusters = await apiClient.cluster.getClusters(); |     const clusters = await apiClient.cluster.getClusters(); | ||||||
|     currentState = { |     currentState = { | ||||||
|       ...currentState, |       ...currentState, | ||||||
|       clusters: toPlain(clusters), |       clusters: clusters, | ||||||
|     } |     } | ||||||
|   } catch (err) { |   } catch (err) { | ||||||
|     console.error('Failed to fetch clusters:', err); |     console.error('Failed to fetch clusters:', err); | ||||||
| @@ -171,7 +166,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { | |||||||
|     const registries = await apiClient.externalRegistry.getRegistries(); |     const registries = await apiClient.externalRegistry.getRegistries(); | ||||||
|     currentState = { |     currentState = { | ||||||
|       ...currentState, |       ...currentState, | ||||||
|       externalRegistries: toPlain(registries), |       externalRegistries: registries, | ||||||
|     }; |     }; | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     console.error('Failed to fetch external registries:', error); |     console.error('Failed to fetch external registries:', error); | ||||||
| @@ -187,7 +182,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => { | |||||||
|     const services = await apiClient.services.getServices(); |     const services = await apiClient.services.getServices(); | ||||||
|     currentState = { |     currentState = { | ||||||
|       ...currentState, |       ...currentState, | ||||||
|       services: toPlain(services), |       services: services, | ||||||
|     }; |     }; | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     console.error('Failed to fetch services:', error); |     console.error('Failed to fetch services:', error); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user