From 0e32c70610bd265b144410be91d0d4689b0773f1 Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Wed, 30 Apr 2025 12:31:07 +0300 Subject: [PATCH] R: Add ReadOnly wrapper for backend data --- .../frontend/src/backend/api-transport.ts | 9 +- .../src/components/input/combo-box.tsx | 2 +- .../library/backend/use-set-access-policy.tsx | 3 +- .../library/backend/use-set-location.tsx | 3 +- .../library/backend/use-set-owner.tsx | 3 +- .../library/backend/use-update-item.tsx | 3 +- .../library/backend/use-update-timestamp.tsx | 4 +- .../library-page/table-library-items.tsx | 5 +- .../library-page/use-library-columns.tsx | 3 +- .../src/features/oss/backend/oss-loader.ts | 5 +- .../oss/backend/use-update-layout.tsx | 3 +- .../features/oss/components/pick-contents.tsx | 9 +- rsconcept/frontend/src/features/oss/labels.ts | 6 +- .../src/features/oss/models/oss-api.ts | 7 +- .../features/rsform/backend/rsform-loader.ts | 3 +- .../dialogs/dlg-create-cst/dlg-create-cst.tsx | 3 +- .../dlg-cst-template/dlg-cst-template.tsx | 3 +- .../rsform/dialogs/dlg-show-ast/ast-flow.tsx | 3 +- .../dialogs/dlg-show-ast/dlg-show-ast.tsx | 3 +- .../dlg-show-type-graph.tsx | 3 +- .../frontend/src/features/rsform/labels.ts | 17 ++-- .../src/features/rsform/models/rsform-api.ts | 7 +- .../src/features/rsform/models/rslang-api.ts | 11 +-- .../rsform/models/typification-graph.ts | 5 +- .../editor-constituenta/form-constituenta.tsx | 3 +- .../editor-rsexpression.tsx | 11 +-- .../editor-rsexpression/parsing-result.tsx | 6 +- .../editor-rsexpression/status-bar.tsx | 3 +- .../pages/rsform-page/menu-edit-schema.tsx | 2 +- .../rsform/pages/rsform-page/menu-main.tsx | 5 +- .../rsform/pages/rsform-page/rsedit-state.tsx | 3 +- rsconcept/frontend/src/utils/meta.ts | 83 +++++++++++++++++++ rsconcept/frontend/src/utils/utils.ts | 2 +- 33 files changed, 178 insertions(+), 63 deletions(-) create mode 100644 rsconcept/frontend/src/utils/meta.ts diff --git a/rsconcept/frontend/src/backend/api-transport.ts b/rsconcept/frontend/src/backend/api-transport.ts index ef0add70..8a88c449 100644 --- a/rsconcept/frontend/src/backend/api-transport.ts +++ b/rsconcept/frontend/src/backend/api-transport.ts @@ -8,6 +8,7 @@ import { type z, ZodError } from 'zod'; import { buildConstants } from '@/utils/build-constants'; import { PARAMETER } from '@/utils/constants'; import { errorMsg } from '@/utils/labels'; +import { type RO } from '@/utils/meta'; import { extractErrorMessage } from '@/utils/utils'; export { AxiosError } from 'axios'; @@ -58,7 +59,7 @@ export function axiosGet({ endpoint, options, schema }: IAxiosGetR .get(endpoint, options) .then(response => { schema?.parse(response.data); - return response.data; + return response.data as RO; }) .catch((error: Error | AxiosError) => { // Note: Ignore cancellation errors @@ -81,7 +82,7 @@ export function axiosPost({ .then(response => { schema?.parse(response.data); notifySuccess(response.data, request?.successMessage); - return response.data; + return response.data as RO; }) .catch((error: Error | AxiosError | ZodError) => { notifyError(error); @@ -100,7 +101,7 @@ export function axiosDelete({ .then(response => { schema?.parse(response.data); notifySuccess(response.data, request?.successMessage); - return response.data; + return response.data as RO; }) .catch((error: Error | AxiosError | ZodError) => { notifyError(error); @@ -119,7 +120,7 @@ export function axiosPatch({ .then(response => { schema?.parse(response.data); notifySuccess(response.data, request?.successMessage); - return response.data; + return response.data as RO; }) .catch((error: Error | AxiosError | ZodError) => { notifyError(error); diff --git a/rsconcept/frontend/src/components/input/combo-box.tsx b/rsconcept/frontend/src/components/input/combo-box.tsx index baeecb38..714ad927 100644 --- a/rsconcept/frontend/src/components/input/combo-box.tsx +++ b/rsconcept/frontend/src/components/input/combo-box.tsx @@ -11,7 +11,7 @@ import { cn } from '../utils'; interface ComboBoxProps