From 6e8192404f6cf7d01cde49a662c24251a9442356 Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Tue, 18 Feb 2025 19:40:24 +0300 Subject: [PATCH] R: Refactor type definitions --- .../frontend/src/components/DomainIcons.tsx | 60 +----- .../src/features/library/backend/api.ts | 5 +- .../src/features/library/backend/types.ts | 148 ++++++++----- .../library/backend/useSetAccessPolicy.tsx | 3 +- .../library/backend/useSetLocation.tsx | 3 +- .../features/library/backend/useSetOwner.tsx | 3 +- .../library/backend/useUpdateItem.tsx | 4 +- .../library/backend/useUpdateTimestamp.tsx | 3 +- .../library/components/EditorLibraryItem.tsx | 2 +- .../library/components/PickSchema.tsx | 2 +- .../library/components/SelectAccessPolicy.tsx | 17 +- .../library/components/SelectItemType.tsx | 15 +- .../library/components/SelectLibraryItem.tsx | 2 +- .../library/components/SelectVersion.tsx | 2 +- .../library/components/ToolbarItemAccess.tsx | 2 +- .../library/dialogs/DlgCloneLibraryItem.tsx | 4 +- .../library/dialogs/DlgCreateVersion.tsx | 3 +- .../dialogs/DlgEditVersions/TableVersions.tsx | 2 +- .../frontend/src/features/library/index.ts | 9 +- .../src/features/library/models/library.ts | 56 +---- .../library/models/libraryAPI.test.ts | 4 +- .../src/features/library/models/libraryAPI.ts | 2 +- .../pages/CreateItemPage/FormCreateItem.tsx | 4 +- .../pages/LibraryPage/TableLibraryItems.tsx | 2 +- .../src/features/oss/backend/OssLoader.ts | 6 +- .../frontend/src/features/oss/backend/api.ts | 2 +- .../src/features/oss/backend/types.ts | 191 ++++++++++------- .../oss/backend/useOperationUpdate.tsx | 2 +- .../oss/components/PickMultiOperation.tsx | 2 +- .../oss/components/SelectOperation.tsx | 2 +- .../oss/components/TooltipOperation.tsx | 2 +- .../oss/dialogs/DlgChangeInputSchema.tsx | 4 +- .../DlgCreateOperation/DlgCreateOperation.tsx | 4 +- .../oss/dialogs/DlgDeleteOperation.tsx | 4 +- .../DlgEditOperation/DlgEditOperation.tsx | 10 +- .../oss/dialogs/DlgRelocateConstituents.tsx | 4 +- rsconcept/frontend/src/features/oss/labels.ts | 3 +- .../frontend/src/features/oss/models/oss.ts | 54 +---- .../src/features/oss/models/ossAPI.ts | 12 +- .../src/features/oss/models/ossLayout.ts | 3 +- .../EditorOssGraph/NodeContextMenu.tsx | 2 +- .../EditorOssGraph/ToolbarOssGraph.tsx | 2 +- .../OssPage/EditorOssGraph/graph/NodeCore.tsx | 2 +- .../oss/pages/OssPage/OssEditContext.tsx | 4 +- .../features/rsform/backend/RSFormLoader.ts | 5 +- .../src/features/rsform/backend/api.ts | 3 +- .../src/features/rsform/backend/types.ts | 201 +++++++++++++++++- .../features/rsform/backend/useCstDelete.tsx | 3 +- .../features/rsform/backend/useUploadTRS.tsx | 2 +- .../frontend/src/features/rsform/colors.ts | 3 +- .../rsform/components/RSInput/RSInput.tsx | 4 +- .../rsform/components/RSInput/index.tsx | 2 +- .../rsform/components/RSInput/textEditing.ts | 2 +- .../rsform/components/SelectCstType.tsx | 2 +- .../dialogs/DlgCreateCst/FormCreateCst.tsx | 6 +- .../dialogs/DlgCstTemplate/DlgCstTemplate.tsx | 4 +- .../dialogs/DlgCstTemplate/TabArguments.tsx | 2 +- .../dialogs/DlgCstTemplate/TabTemplate.tsx | 2 +- .../rsform/dialogs/DlgGraphParams.tsx | 2 +- .../features/rsform/dialogs/DlgRenameCst.tsx | 4 +- .../frontend/src/features/rsform/index.ts | 3 +- .../frontend/src/features/rsform/labels.ts | 6 +- .../src/features/rsform/models/rsform.ts | 31 +-- .../src/features/rsform/models/rsformAPI.ts | 7 +- .../src/features/rsform/models/rslang.ts | 195 +---------------- .../src/features/rsform/models/rslangAPI.ts | 5 +- .../EditorConstituenta/FormConstituenta.tsx | 5 +- .../EditorRSExpression/EditorRSExpression.tsx | 6 +- .../EditorRSExpression/RSEditControls.tsx | 2 +- .../EditorRSExpression/RSLocalButton.tsx | 2 +- .../EditorRSExpression/RSTokenButton.tsx | 2 +- .../EditorRSExpression/StatusBar.tsx | 3 +- .../RSFormPage/EditorRSList/EditorRSList.tsx | 4 +- .../RSFormPage/EditorRSList/ToolbarRSList.tsx | 36 +++- .../RSFormPage/EditorTermGraph/TGFlow.tsx | 3 +- .../rsform/pages/RSFormPage/MenuRSTabs.tsx | 3 +- .../rsform/pages/RSFormPage/RSEditContext.tsx | 4 +- rsconcept/frontend/src/utils/labels.ts | 2 +- 78 files changed, 585 insertions(+), 653 deletions(-) diff --git a/rsconcept/frontend/src/components/DomainIcons.tsx b/rsconcept/frontend/src/components/DomainIcons.tsx index 3c22ffd6..b7f5f625 100644 --- a/rsconcept/frontend/src/components/DomainIcons.tsx +++ b/rsconcept/frontend/src/components/DomainIcons.tsx @@ -1,18 +1,10 @@ -import { AccessPolicy, LibraryItemType, LocationHead } from '@/features/library/models/library'; -import { CstType, ExpressionStatus } from '@/features/rsform/models/rsform'; +import { LocationHead } from '@/features/library/models/library'; +import { ExpressionStatus } from '@/features/rsform/models/rsform'; import { CstMatchMode, DependencyMode } from '@/features/rsform/stores/cstSearch'; import { IconAlias, IconBusiness, - IconCstAxiom, - IconCstBaseSet, - IconCstConstSet, - IconCstFunction, - IconCstPredicate, - IconCstStructured, - IconCstTerm, - IconCstTheorem, IconFilter, IconFormula, IconGraphCollapse, @@ -22,12 +14,8 @@ import { IconHide, IconMoveDown, IconMoveUp, - IconOSS, - IconPrivate, IconProps, - IconProtected, IconPublic, - IconRSForm, IconSettings, IconShow, IconStatusError, @@ -45,28 +33,6 @@ export interface DomIconProps extends IconProps { value: RequestData; } -/** Icon for library item type. */ -export function ItemTypeIcon({ value, size = '1.25rem', className }: DomIconProps) { - switch (value) { - case LibraryItemType.RSFORM: - return ; - case LibraryItemType.OSS: - return ; - } -} - -/** Icon for access policy. */ -export function PolicyIcon({ value, size = '1.25rem', className }: DomIconProps) { - switch (value) { - case AccessPolicy.PRIVATE: - return ; - case AccessPolicy.PROTECTED: - return ; - case AccessPolicy.PUBLIC: - return ; - } -} - /** Icon for visibility. */ export function VisibilityIcon({ value, size = '1.25rem', className }: DomIconProps) { if (value) { @@ -149,28 +115,6 @@ export function StatusIcon({ value, size = '1.25rem', className }: DomIconProps< } } -/** Icon for constituenta type. */ -export function CstTypeIcon({ value, size = '1.25rem', className }: DomIconProps) { - switch (value) { - case CstType.BASE: - return ; - case CstType.CONSTANT: - return ; - case CstType.STRUCTURED: - return ; - case CstType.TERM: - return ; - case CstType.AXIOM: - return ; - case CstType.FUNCTION: - return ; - case CstType.PREDICATE: - return ; - case CstType.THEOREM: - return ; - } -} - /** Icon for relocation direction. */ export function RelocateUpIcon({ value, size = '1.25rem', className }: DomIconProps) { if (value) { diff --git a/rsconcept/frontend/src/features/library/backend/api.ts b/rsconcept/frontend/src/features/library/backend/api.ts index 9648d152..fb9f9709 100644 --- a/rsconcept/frontend/src/features/library/backend/api.ts +++ b/rsconcept/frontend/src/features/library/backend/api.ts @@ -6,15 +6,16 @@ import { axiosDelete, axiosGet, axiosPatch, axiosPost } from '@/backend/apiTrans import { DELAYS, KEYS } from '@/backend/configuration'; import { infoMsg } from '@/utils/labels'; -import { AccessPolicy, ILibraryItem, IVersionInfo } from '../models/library'; - import { + AccessPolicy, ICloneLibraryItemDTO, ICreateLibraryItemDTO, + ILibraryItem, IRenameLocationDTO, IUpdateLibraryItemDTO, IVersionCreatedResponse, IVersionCreateDTO, + IVersionInfo, IVersionUpdateDTO } from './types'; diff --git a/rsconcept/frontend/src/features/library/backend/types.ts b/rsconcept/frontend/src/features/library/backend/types.ts index dbb10cfd..4bdd89f8 100644 --- a/rsconcept/frontend/src/features/library/backend/types.ts +++ b/rsconcept/frontend/src/features/library/backend/types.ts @@ -4,9 +4,46 @@ import { IRSFormDTO } from '@/features/rsform/backend/types'; import { errorMsg } from '@/utils/labels'; -import { AccessPolicy, LibraryItemType } from '../models/library'; import { validateLocation } from '../models/libraryAPI'; +/** Represents type of library items. */ +export enum LibraryItemType { + RSFORM = 'rsform', + OSS = 'oss' +} + +/** Represents Access policy for library items.*/ +export enum AccessPolicy { + PUBLIC = 'public', + PROTECTED = 'protected', + PRIVATE = 'private' +} + +/** + * Represents library item common data typical for all item types. + */ +export interface ILibraryItem { + id: number; + item_type: LibraryItemType; + title: string; + alias: string; + comment: string; + visible: boolean; + read_only: boolean; + location: string; + access_policy: AccessPolicy; + time_create: string; + time_update: string; + owner: number | null; +} + +/** + * Represents {@link ILibraryItem} constant data loaded for both OSS and RSForm. + */ +export interface ILibraryItemData extends ILibraryItem { + editors: number[]; +} + /** * Represents update data for renaming Location. */ @@ -15,57 +52,13 @@ export interface IRenameLocationDTO { new_location: string; } -/** - * Represents data, used for cloning {@link IRSForm}. - */ -export const schemaCloneLibraryItem = z.object({ - id: z.number(), - item_type: z.nativeEnum(LibraryItemType), - title: z.string().nonempty(errorMsg.requiredField), - alias: z.string().nonempty(errorMsg.requiredField), - comment: z.string(), - visible: z.boolean(), - read_only: z.boolean(), - location: z.string().refine(data => validateLocation(data), { message: errorMsg.invalidLocation }), - access_policy: z.nativeEnum(AccessPolicy), +/** Represents library item version information. */ +export type IVersionInfo = z.infer; - items: z.array(z.number()).optional() -}); - -/** - * Represents data, used for cloning {@link IRSForm}. - */ +/** Represents data, used for cloning {@link IRSForm}. */ export type ICloneLibraryItemDTO = z.infer; -/** - * Represents data, used for creating {@link IRSForm}. - */ -export const schemaCreateLibraryItem = z - .object({ - item_type: z.nativeEnum(LibraryItemType), - title: z.string().optional(), - alias: z.string().optional(), - comment: z.string(), - visible: z.boolean(), - read_only: z.boolean(), - location: z.string().refine(data => validateLocation(data), { message: errorMsg.invalidLocation }), - access_policy: z.nativeEnum(AccessPolicy), - - file: z.instanceof(File).optional(), - fileName: z.string().optional() - }) - .refine(data => !!data.file || !!data.title, { - path: ['title'], - message: errorMsg.requiredField - }) - .refine(data => !!data.file || !!data.alias, { - path: ['alias'], - message: errorMsg.requiredField - }); - -/** - * Represents data, used for creating {@link IRSForm}. - */ +/** Represents data, used for creating {@link IRSForm}. */ export type ICreateLibraryItemDTO = z.infer; /** @@ -108,16 +101,57 @@ export interface IVersionCreatedResponse { schema: IRSFormDTO; } -/** - * Represents version data, intended to update version metadata in persistent storage. - */ +/** Represents version data, intended to update version metadata in persistent storage. */ +export type IVersionUpdateDTO = z.infer; + +// ======= SCHEMAS ========= +/** Represents data, used for cloning {@link IRSForm}. */ +export const schemaCloneLibraryItem = z.object({ + id: z.number(), + item_type: z.nativeEnum(LibraryItemType), + title: z.string().nonempty(errorMsg.requiredField), + alias: z.string().nonempty(errorMsg.requiredField), + comment: z.string(), + visible: z.boolean(), + read_only: z.boolean(), + location: z.string().refine(data => validateLocation(data), { message: errorMsg.invalidLocation }), + access_policy: z.nativeEnum(AccessPolicy), + + items: z.array(z.number()).optional() +}); + +export const schemaCreateLibraryItem = z + .object({ + item_type: z.nativeEnum(LibraryItemType), + title: z.string().optional(), + alias: z.string().optional(), + comment: z.string(), + visible: z.boolean(), + read_only: z.boolean(), + location: z.string().refine(data => validateLocation(data), { message: errorMsg.invalidLocation }), + access_policy: z.nativeEnum(AccessPolicy), + + file: z.instanceof(File).optional(), + fileName: z.string().optional() + }) + .refine(data => !!data.file || !!data.title, { + path: ['title'], + message: errorMsg.requiredField + }) + .refine(data => !!data.file || !!data.alias, { + path: ['alias'], + message: errorMsg.requiredField + }); + +export const schemaVersionInfo = z.object({ + id: z.coerce.number(), + version: z.string(), + description: z.string(), + time_create: z.string() +}); + export const schemaVersionUpdate = z.object({ id: z.number(), version: z.string().nonempty(errorMsg.requiredField), description: z.string() }); - -/** - * Represents version data, intended to update version metadata in persistent storage. - */ -export type IVersionUpdateDTO = z.infer; diff --git a/rsconcept/frontend/src/features/library/backend/useSetAccessPolicy.tsx b/rsconcept/frontend/src/features/library/backend/useSetAccessPolicy.tsx index ed76bb8f..89e98107 100644 --- a/rsconcept/frontend/src/features/library/backend/useSetAccessPolicy.tsx +++ b/rsconcept/frontend/src/features/library/backend/useSetAccessPolicy.tsx @@ -5,9 +5,8 @@ import { IRSFormDTO } from '@/features/rsform/backend/types'; import { KEYS } from '@/backend/configuration'; -import { AccessPolicy, ILibraryItem } from '../models/library'; - import { libraryApi } from './api'; +import { AccessPolicy, ILibraryItem } from './types'; export const useSetAccessPolicy = () => { const client = useQueryClient(); diff --git a/rsconcept/frontend/src/features/library/backend/useSetLocation.tsx b/rsconcept/frontend/src/features/library/backend/useSetLocation.tsx index d11fd075..10196b5a 100644 --- a/rsconcept/frontend/src/features/library/backend/useSetLocation.tsx +++ b/rsconcept/frontend/src/features/library/backend/useSetLocation.tsx @@ -5,9 +5,8 @@ import { IRSFormDTO } from '@/features/rsform/backend/types'; import { KEYS } from '@/backend/configuration'; -import { ILibraryItem } from '../models/library'; - import { libraryApi } from './api'; +import { ILibraryItem } from './types'; export const useSetLocation = () => { const client = useQueryClient(); diff --git a/rsconcept/frontend/src/features/library/backend/useSetOwner.tsx b/rsconcept/frontend/src/features/library/backend/useSetOwner.tsx index ebf4d6af..8e0f5e34 100644 --- a/rsconcept/frontend/src/features/library/backend/useSetOwner.tsx +++ b/rsconcept/frontend/src/features/library/backend/useSetOwner.tsx @@ -5,9 +5,8 @@ import { IRSFormDTO } from '@/features/rsform/backend/types'; import { KEYS } from '@/backend/configuration'; -import { ILibraryItem } from '../models/library'; - import { libraryApi } from './api'; +import { ILibraryItem } from './types'; export const useSetOwner = () => { const client = useQueryClient(); diff --git a/rsconcept/frontend/src/features/library/backend/useUpdateItem.tsx b/rsconcept/frontend/src/features/library/backend/useUpdateItem.tsx index f306c8f1..e9081063 100644 --- a/rsconcept/frontend/src/features/library/backend/useUpdateItem.tsx +++ b/rsconcept/frontend/src/features/library/backend/useUpdateItem.tsx @@ -5,10 +5,8 @@ import { IRSFormDTO } from '@/features/rsform/backend/types'; import { KEYS } from '@/backend/configuration'; -import { ILibraryItem, LibraryItemType } from '../models/library'; - import { libraryApi } from './api'; -import { IUpdateLibraryItemDTO } from './types'; +import { ILibraryItem, IUpdateLibraryItemDTO, LibraryItemType } from './types'; export const useUpdateItem = () => { const client = useQueryClient(); diff --git a/rsconcept/frontend/src/features/library/backend/useUpdateTimestamp.tsx b/rsconcept/frontend/src/features/library/backend/useUpdateTimestamp.tsx index 55ba4fed..1eef1423 100644 --- a/rsconcept/frontend/src/features/library/backend/useUpdateTimestamp.tsx +++ b/rsconcept/frontend/src/features/library/backend/useUpdateTimestamp.tsx @@ -1,8 +1,7 @@ import { useQueryClient } from '@tanstack/react-query'; -import { ILibraryItem } from '../models/library'; - import { libraryApi } from './api'; +import { ILibraryItem } from './types'; export function useUpdateTimestamp() { const client = useQueryClient(); diff --git a/rsconcept/frontend/src/features/library/components/EditorLibraryItem.tsx b/rsconcept/frontend/src/features/library/components/EditorLibraryItem.tsx index 11493ce0..94edda53 100644 --- a/rsconcept/frontend/src/features/library/components/EditorLibraryItem.tsx +++ b/rsconcept/frontend/src/features/library/components/EditorLibraryItem.tsx @@ -23,10 +23,10 @@ import { useModificationStore } from '@/stores/modification'; import { prefixes } from '@/utils/constants'; import { promptText } from '@/utils/labels'; +import { ILibraryItemData } from '../backend/types'; import { useMutatingLibrary } from '../backend/useMutatingLibrary'; import { useSetLocation } from '../backend/useSetLocation'; import { useSetOwner } from '../backend/useSetOwner'; -import { ILibraryItemData } from '../models/library'; import { useLibrarySearchStore } from '../stores/librarySearch'; /** diff --git a/rsconcept/frontend/src/features/library/components/PickSchema.tsx b/rsconcept/frontend/src/features/library/components/PickSchema.tsx index 9d1a9169..3c5a1e7b 100644 --- a/rsconcept/frontend/src/features/library/components/PickSchema.tsx +++ b/rsconcept/frontend/src/features/library/components/PickSchema.tsx @@ -12,7 +12,7 @@ import { CProps } from '@/components/props'; import { APP_COLORS } from '@/styling/colors'; import { prefixes } from '@/utils/constants'; -import { ILibraryItem, LibraryItemType } from '../models/library'; +import { ILibraryItem, LibraryItemType } from '../backend/types'; import { matchLibraryItem } from '../models/libraryAPI'; import SelectLocation from './SelectLocation'; diff --git a/rsconcept/frontend/src/features/library/components/SelectAccessPolicy.tsx b/rsconcept/frontend/src/features/library/components/SelectAccessPolicy.tsx index 6a72083a..04efe285 100644 --- a/rsconcept/frontend/src/features/library/components/SelectAccessPolicy.tsx +++ b/rsconcept/frontend/src/features/library/components/SelectAccessPolicy.tsx @@ -1,13 +1,14 @@ 'use client'; import { MiniButton } from '@/components/Control'; -import { PolicyIcon } from '@/components/DomainIcons'; +import { DomIconProps } from '@/components/DomainIcons'; import { Dropdown, DropdownButton, useDropdown } from '@/components/Dropdown'; +import { IconPrivate, IconProtected, IconPublic } from '@/components/Icons'; import { CProps } from '@/components/props'; import { prefixes } from '@/utils/constants'; import { describeAccessPolicy, labelAccessPolicy } from '@/utils/labels'; -import { AccessPolicy } from '../models/library'; +import { AccessPolicy } from '../backend/types'; interface SelectAccessPolicyProps extends CProps.Styling { value: AccessPolicy; @@ -51,3 +52,15 @@ export function SelectAccessPolicy({ value, disabled, stretchLeft, onChange, ... ); } + +/** Icon for access policy. */ +function PolicyIcon({ value, size = '1.25rem', className }: DomIconProps) { + switch (value) { + case AccessPolicy.PRIVATE: + return ; + case AccessPolicy.PROTECTED: + return ; + case AccessPolicy.PUBLIC: + return ; + } +} diff --git a/rsconcept/frontend/src/features/library/components/SelectItemType.tsx b/rsconcept/frontend/src/features/library/components/SelectItemType.tsx index 86d38606..c917f66d 100644 --- a/rsconcept/frontend/src/features/library/components/SelectItemType.tsx +++ b/rsconcept/frontend/src/features/library/components/SelectItemType.tsx @@ -1,13 +1,14 @@ 'use client'; import { SelectorButton } from '@/components/Control'; -import { ItemTypeIcon } from '@/components/DomainIcons'; +import { DomIconProps } from '@/components/DomainIcons'; import { Dropdown, DropdownButton, useDropdown } from '@/components/Dropdown'; +import { IconOSS, IconRSForm } from '@/components/Icons'; import { CProps } from '@/components/props'; import { prefixes } from '@/utils/constants'; import { describeLibraryItemType, labelLibraryItemType } from '@/utils/labels'; -import { LibraryItemType } from '../models/library'; +import { LibraryItemType } from '../backend/types'; interface SelectItemTypeProps extends CProps.Styling { value: LibraryItemType; @@ -52,3 +53,13 @@ export function SelectItemType({ value, disabled, stretchLeft, onChange, ...rest ); } + +/** Icon for library item type. */ +function ItemTypeIcon({ value, size = '1.25rem', className }: DomIconProps) { + switch (value) { + case LibraryItemType.RSFORM: + return ; + case LibraryItemType.OSS: + return ; + } +} diff --git a/rsconcept/frontend/src/features/library/components/SelectLibraryItem.tsx b/rsconcept/frontend/src/features/library/components/SelectLibraryItem.tsx index 508c0415..0d80deb3 100644 --- a/rsconcept/frontend/src/features/library/components/SelectLibraryItem.tsx +++ b/rsconcept/frontend/src/features/library/components/SelectLibraryItem.tsx @@ -5,7 +5,7 @@ import clsx from 'clsx'; import { SelectSingle } from '@/components/Input'; import { CProps } from '@/components/props'; -import { ILibraryItem } from '../models/library'; +import { ILibraryItem } from '../backend/types'; import { matchLibraryItem } from '../models/libraryAPI'; interface SelectLibraryItemProps extends CProps.Styling { diff --git a/rsconcept/frontend/src/features/library/components/SelectVersion.tsx b/rsconcept/frontend/src/features/library/components/SelectVersion.tsx index a21f8608..5fd14144 100644 --- a/rsconcept/frontend/src/features/library/components/SelectVersion.tsx +++ b/rsconcept/frontend/src/features/library/components/SelectVersion.tsx @@ -6,7 +6,7 @@ import { SelectSingle } from '@/components/Input'; import { CProps } from '@/components/props'; import { labelVersion } from '../../rsform/labels'; -import { IVersionInfo } from '../models/library'; +import { IVersionInfo } from '../backend/types'; interface SelectVersionProps extends CProps.Styling { id?: string; diff --git a/rsconcept/frontend/src/features/library/components/ToolbarItemAccess.tsx b/rsconcept/frontend/src/features/library/components/ToolbarItemAccess.tsx index a7a1c208..ae40c52b 100644 --- a/rsconcept/frontend/src/features/library/components/ToolbarItemAccess.tsx +++ b/rsconcept/frontend/src/features/library/components/ToolbarItemAccess.tsx @@ -8,9 +8,9 @@ import { IconImmutable, IconMutable } from '@/components/Icons'; import { Label } from '@/components/Input'; import { PARAMETER } from '@/utils/constants'; +import { AccessPolicy } from '../backend/types'; import { useMutatingLibrary } from '../backend/useMutatingLibrary'; import { useSetAccessPolicy } from '../backend/useSetAccessPolicy'; -import { AccessPolicy } from '../models/library'; import { ILibraryItemEditor } from './EditorLibraryItem'; import { SelectAccessPolicy } from './SelectAccessPolicy'; diff --git a/rsconcept/frontend/src/features/library/dialogs/DlgCloneLibraryItem.tsx b/rsconcept/frontend/src/features/library/dialogs/DlgCloneLibraryItem.tsx index d3c93fb2..ab3fb74e 100644 --- a/rsconcept/frontend/src/features/library/dialogs/DlgCloneLibraryItem.tsx +++ b/rsconcept/frontend/src/features/library/dialogs/DlgCloneLibraryItem.tsx @@ -13,12 +13,12 @@ import { Checkbox, Label, TextArea, TextInput } from '@/components/Input'; import { ModalForm } from '@/components/Modal'; import { useDialogsStore } from '@/stores/dialogs'; -import { ICloneLibraryItemDTO, schemaCloneLibraryItem } from '../backend/types'; +import { AccessPolicy, ICloneLibraryItemDTO, ILibraryItem, schemaCloneLibraryItem } from '../backend/types'; import { useCloneItem } from '../backend/useCloneItem'; import { SelectAccessPolicy } from '../components/SelectAccessPolicy'; import { SelectLocationContext } from '../components/SelectLocationContext'; import { SelectLocationHead } from '../components/SelectLocationHead'; -import { AccessPolicy, ILibraryItem, LocationHead } from '../models/library'; +import { LocationHead } from '../models/library'; import { cloneTitle, combineLocation } from '../models/libraryAPI'; export interface DlgCloneLibraryItemProps { diff --git a/rsconcept/frontend/src/features/library/dialogs/DlgCreateVersion.tsx b/rsconcept/frontend/src/features/library/dialogs/DlgCreateVersion.tsx index 4053703c..c50fdf1c 100644 --- a/rsconcept/frontend/src/features/library/dialogs/DlgCreateVersion.tsx +++ b/rsconcept/frontend/src/features/library/dialogs/DlgCreateVersion.tsx @@ -9,9 +9,8 @@ import { ModalForm } from '@/components/Modal'; import { useDialogsStore } from '@/stores/dialogs'; import { errorMsg } from '@/utils/labels'; -import { IVersionCreateDTO, schemaVersionCreate } from '../backend/types'; +import { IVersionCreateDTO, IVersionInfo, schemaVersionCreate } from '../backend/types'; import { useVersionCreate } from '../backend/useVersionCreate'; -import { IVersionInfo } from '../models/library'; import { nextVersion } from '../models/libraryAPI'; export interface DlgCreateVersionProps { diff --git a/rsconcept/frontend/src/features/library/dialogs/DlgEditVersions/TableVersions.tsx b/rsconcept/frontend/src/features/library/dialogs/DlgEditVersions/TableVersions.tsx index 4cc6cc0b..54e726b9 100644 --- a/rsconcept/frontend/src/features/library/dialogs/DlgEditVersions/TableVersions.tsx +++ b/rsconcept/frontend/src/features/library/dialogs/DlgEditVersions/TableVersions.tsx @@ -8,7 +8,7 @@ import DataTable, { createColumnHelper, IConditionalStyle } from '@/components/D import { IconRemove } from '@/components/Icons'; import { APP_COLORS } from '@/styling/colors'; -import { IVersionInfo } from '../../models/library'; +import { IVersionInfo } from '../../backend/types'; interface TableVersionsProps { processing: boolean; diff --git a/rsconcept/frontend/src/features/library/index.ts b/rsconcept/frontend/src/features/library/index.ts index 11b3a967..3df013b0 100644 --- a/rsconcept/frontend/src/features/library/index.ts +++ b/rsconcept/frontend/src/features/library/index.ts @@ -1,3 +1,4 @@ +export { AccessPolicy, type ILibraryItem, type IVersionInfo, LibraryItemType } from './backend/types'; export { useDeleteItem } from './backend/useDeleteItem'; export { useLibrary, useLibrarySuspense } from './backend/useLibrary'; export { useMutatingLibrary } from './backend/useMutatingLibrary'; @@ -11,11 +12,5 @@ export { PickSchema } from './components/PickSchema'; export { SelectLibraryItem } from './components/SelectLibraryItem'; export { SelectVersion } from './components/SelectVersion'; export { ToolbarItemAccess } from './components/ToolbarItemAccess'; -export { - AccessPolicy, - type ILibraryItem, - type ILibraryItemReference, - type IVersionInfo, - LibraryItemType -} from './models/library'; +export { type ILibraryItemReference } from './models/library'; export { useLibrarySearchStore } from './stores/librarySearch'; diff --git a/rsconcept/frontend/src/features/library/models/library.ts b/rsconcept/frontend/src/features/library/models/library.ts index a03292e7..91978530 100644 --- a/rsconcept/frontend/src/features/library/models/library.ts +++ b/rsconcept/frontend/src/features/library/models/library.ts @@ -2,24 +2,7 @@ * Module: Models for LibraryItem. */ -import { z } from 'zod'; - -/** - * Represents type of library items. - */ -export enum LibraryItemType { - RSFORM = 'rsform', - OSS = 'oss' -} - -/** - * Represents Access policy for library items. - */ -export enum AccessPolicy { - PUBLIC = 'public', - PROTECTED = 'protected', - PRIVATE = 'private' -} +import { ILibraryItemData, IVersionInfo, LibraryItemType } from '../backend/types'; /** * Represents valid location headers. @@ -33,43 +16,6 @@ export enum LocationHead { export const BASIC_SCHEMAS = '/L/Базовые'; -export const schemaVersionInfo = z.object({ - id: z.coerce.number(), - version: z.string(), - description: z.string(), - time_create: z.string() -}); - -/** - * Represents library item version information. - */ -export type IVersionInfo = z.infer; - -/** - * Represents library item common data typical for all item types. - */ -export interface ILibraryItem { - id: number; - item_type: LibraryItemType; - title: string; - alias: string; - comment: string; - visible: boolean; - read_only: boolean; - location: string; - access_policy: AccessPolicy; - time_create: string; - time_update: string; - owner: number | null; -} - -/** - * Represents {@link ILibraryItem} constant data loaded for both OSS and RSForm. - */ -export interface ILibraryItemData extends ILibraryItem { - editors: number[]; -} - /** * Represents {@link ILibraryItem} minimal reference data. */ diff --git a/rsconcept/frontend/src/features/library/models/libraryAPI.test.ts b/rsconcept/frontend/src/features/library/models/libraryAPI.test.ts index 28b10231..4671fb09 100644 --- a/rsconcept/frontend/src/features/library/models/libraryAPI.test.ts +++ b/rsconcept/frontend/src/features/library/models/libraryAPI.test.ts @@ -1,4 +1,6 @@ -import { AccessPolicy, ILibraryItem, LibraryItemType, LocationHead } from './library'; +import { AccessPolicy, ILibraryItem, LibraryItemType } from '../backend/types'; + +import { LocationHead } from './library'; import { matchLibraryItem, validateLocation } from './libraryAPI'; describe('Testing matching LibraryItem', () => { diff --git a/rsconcept/frontend/src/features/library/models/libraryAPI.ts b/rsconcept/frontend/src/features/library/models/libraryAPI.ts index ac7d1c27..93906ff9 100644 --- a/rsconcept/frontend/src/features/library/models/libraryAPI.ts +++ b/rsconcept/frontend/src/features/library/models/libraryAPI.ts @@ -5,7 +5,7 @@ import { limits } from '@/utils/constants'; import { TextMatcher } from '@/utils/utils'; -import { ILibraryItem } from './library'; +import { ILibraryItem } from '../backend/types'; const LOCATION_REGEXP = /^\/[PLUS]((\/[!\d\p{L}]([!\d\p{L}\- ]*[!\d\p{L}])?)*)?$/u; // cspell:disable-line diff --git a/rsconcept/frontend/src/features/library/pages/CreateItemPage/FormCreateItem.tsx b/rsconcept/frontend/src/features/library/pages/CreateItemPage/FormCreateItem.tsx index 64b330d5..67677d7d 100644 --- a/rsconcept/frontend/src/features/library/pages/CreateItemPage/FormCreateItem.tsx +++ b/rsconcept/frontend/src/features/library/pages/CreateItemPage/FormCreateItem.tsx @@ -16,13 +16,13 @@ import { InfoError } from '@/components/InfoError'; import { Label, TextArea, TextInput } from '@/components/Input'; import { EXTEOR_TRS_FILE } from '@/utils/constants'; -import { ICreateLibraryItemDTO, schemaCreateLibraryItem } from '../../backend/types'; +import { AccessPolicy, ICreateLibraryItemDTO, LibraryItemType, schemaCreateLibraryItem } from '../../backend/types'; import { useCreateItem } from '../../backend/useCreateItem'; import { SelectAccessPolicy } from '../../components/SelectAccessPolicy'; import { SelectItemType } from '../../components/SelectItemType'; import { SelectLocationContext } from '../../components/SelectLocationContext'; import { SelectLocationHead } from '../../components/SelectLocationHead'; -import { AccessPolicy, LibraryItemType, LocationHead } from '../../models/library'; +import { LocationHead } from '../../models/library'; import { combineLocation } from '../../models/libraryAPI'; import { useLibrarySearchStore } from '../../stores/librarySearch'; diff --git a/rsconcept/frontend/src/features/library/pages/LibraryPage/TableLibraryItems.tsx b/rsconcept/frontend/src/features/library/pages/LibraryPage/TableLibraryItems.tsx index 77af1613..b2682469 100644 --- a/rsconcept/frontend/src/features/library/pages/LibraryPage/TableLibraryItems.tsx +++ b/rsconcept/frontend/src/features/library/pages/LibraryPage/TableLibraryItems.tsx @@ -17,8 +17,8 @@ import { useFitHeight } from '@/stores/appLayout'; import { usePreferencesStore } from '@/stores/preferences'; import { APP_COLORS } from '@/styling/colors'; +import { ILibraryItem, LibraryItemType } from '../../backend/types'; import BadgeLocation from '../../components/BadgeLocation'; -import { ILibraryItem, LibraryItemType } from '../../models/library'; import { useLibrarySearchStore } from '../../stores/librarySearch'; interface TableLibraryItemsProps { diff --git a/rsconcept/frontend/src/features/oss/backend/OssLoader.ts b/rsconcept/frontend/src/features/oss/backend/OssLoader.ts index a6c7f306..849d5503 100644 --- a/rsconcept/frontend/src/features/oss/backend/OssLoader.ts +++ b/rsconcept/frontend/src/features/oss/backend/OssLoader.ts @@ -2,13 +2,13 @@ * Module: OSS data loading and processing. */ -import { ILibraryItem } from '@/features/library/models/library'; +import { ILibraryItem } from '@/features/library/backend/types'; import { Graph } from '@/models/Graph'; -import { IOperation, IOperationSchema, IOperationSchemaStats, OperationType } from '../models/oss'; +import { IOperationSchema, IOperationSchemaStats } from '../models/oss'; -import { IOperationSchemaDTO } from './types'; +import { IOperation, IOperationSchemaDTO, OperationType } from './types'; /** * Loads data into an {@link IOperationSchema} based on {@link IOperationSchemaDTO}. diff --git a/rsconcept/frontend/src/features/oss/backend/api.ts b/rsconcept/frontend/src/features/oss/backend/api.ts index 5ebef418..a045ab63 100644 --- a/rsconcept/frontend/src/features/oss/backend/api.ts +++ b/rsconcept/frontend/src/features/oss/backend/api.ts @@ -1,13 +1,13 @@ import { queryOptions } from '@tanstack/react-query'; import { ITargetCst } from '@/features/rsform/backend/types'; -import { IConstituentaReference } from '@/features/rsform/models/rsform'; import { axiosGet, axiosPatch, axiosPost } from '@/backend/apiTransport'; import { DELAYS, KEYS } from '@/backend/configuration'; import { infoMsg } from '@/utils/labels'; import { + IConstituentaReference, ICstRelocateDTO, IInputCreatedResponse, IInputUpdateDTO, diff --git a/rsconcept/frontend/src/features/oss/backend/types.ts b/rsconcept/frontend/src/features/oss/backend/types.ts index d248fe9c..8e9dcd6d 100644 --- a/rsconcept/frontend/src/features/oss/backend/types.ts +++ b/rsconcept/frontend/src/features/oss/backend/types.ts @@ -1,9 +1,57 @@ import { z } from 'zod'; -import { ILibraryItem, ILibraryItemData } from '@/features/library/models/library'; -import { schemaCstSubstitute } from '@/features/rsform/backend/types'; +import { ILibraryItem, ILibraryItemData } from '@/features/library/backend/types'; +import { ICstSubstitute, schemaCstSubstitute } from '@/features/rsform/backend/types'; -import { IArgument, ICstSubstituteEx, IOperation, OperationType } from '../models/oss'; +/** + * Represents {@link IOperation} type. + */ +export enum OperationType { + INPUT = 'input', + SYNTHESIS = 'synthesis' +} + +/** + * Represents {@link ICstSubstitute} extended data. + */ +export interface ICstSubstituteEx extends ICstSubstitute { + operation: number; + original_alias: string; + original_term: string; + substitution_alias: string; + substitution_term: string; +} + +/** + * Represents Operation. + */ +export interface IOperation { + id: number; + operation_type: OperationType; + oss: number; + + alias: string; + title: string; + comment: string; + + position_x: number; + position_y: number; + + result: number | null; + + is_owned: boolean; + is_consolidation: boolean; // aka 'diamond synthesis' + substitutions: ICstSubstituteEx[]; + arguments: number[]; +} + +/** + * Represents {@link IOperation} Argument. + */ +export interface IArgument { + operation: number; + argument: number; +} /** * Represents {@link IOperation} data from server. @@ -19,41 +67,10 @@ export interface IOperationSchemaDTO extends ILibraryItemData { substitutions: ICstSubstituteEx[]; } -/** - * Represents {@link IOperation} position. - */ -export const schemaOperationPosition = z.object({ - id: z.number(), - position_x: z.number(), - position_y: z.number() -}); - -/** - * Represents {@link IOperation} position. - */ +/** Represents {@link IOperation} position. */ export type IOperationPosition = z.infer; -/** - * Represents {@link IOperation} data, used in creation process. - */ -export const schemaOperationCreate = z.object({ - positions: z.array(schemaOperationPosition), - item_data: z.object({ - alias: z.string().nonempty(), - operation_type: z.nativeEnum(OperationType), - title: z.string(), - comment: z.string(), - position_x: z.number(), - position_y: z.number(), - result: z.number().nullable() - }), - arguments: z.array(z.number()), - create_schema: z.boolean() -}); - -/** - * Represents {@link IOperation} data, used in creation process. - */ +/** Represents {@link IOperation} data, used in creation process. */ export type IOperationCreateDTO = z.infer; /** @@ -72,19 +89,7 @@ export interface ITargetOperation { target: number; } -/** - * Represents {@link IOperation} data, used in destruction process. - */ -export const schemaOperationDelete = z.object({ - target: z.number(), - positions: z.array(schemaOperationPosition), - keep_constituents: z.boolean(), - delete_schema: z.boolean() -}); - -/** - * Represents {@link IOperation} data, used in destruction process. - */ +/** Represents {@link IOperation} data, used in destruction process. */ export type IOperationDeleteDTO = z.infer; /** @@ -95,38 +100,10 @@ export interface IInputCreatedResponse { oss: IOperationSchemaDTO; } -/** - * Represents {@link IOperation} data, used in setInput process. - */ -export const schemaInputUpdate = z.object({ - target: z.number(), - positions: z.array(schemaOperationPosition), - input: z.number().nullable() -}); - -/** - * Represents {@link IOperation} data, used in setInput process. - */ +/** Represents {@link IOperation} data, used in setInput process. */ export type IInputUpdateDTO = z.infer; -/** - * Represents {@link IOperation} data, used in update process. - */ -export const schemaOperationUpdate = z.object({ - target: z.number(), - positions: z.array(schemaOperationPosition), - item_data: z.object({ - alias: z.string().nonempty(), - title: z.string(), - comment: z.string() - }), - arguments: z.array(z.number()), - substitutions: z.array(schemaCstSubstitute) -}); - -/** - * Represents {@link IOperation} data, used in update process. - */ +/** Represents {@link IOperation} data, used in update process. */ export type IOperationUpdateDTO = z.infer; /** @@ -141,3 +118,59 @@ export const schemaCstRelocate = z.object({ * Represents data, used relocating {@link IConstituenta}s between {@link ILibraryItem}s. */ export type ICstRelocateDTO = z.infer; + +/** + * Represents {@link IConstituenta} reference. + */ +export interface IConstituentaReference { + id: number; + schema: number; +} + +// ====== Schemas ====== + +export const schemaOperationPosition = z.object({ + id: z.number(), + position_x: z.number(), + position_y: z.number() +}); + +export const schemaOperationCreate = z.object({ + positions: z.array(schemaOperationPosition), + item_data: z.object({ + alias: z.string().nonempty(), + operation_type: z.nativeEnum(OperationType), + title: z.string(), + comment: z.string(), + position_x: z.number(), + position_y: z.number(), + result: z.number().nullable() + }), + arguments: z.array(z.number()), + create_schema: z.boolean() +}); + +export const schemaOperationDelete = z.object({ + target: z.number(), + positions: z.array(schemaOperationPosition), + keep_constituents: z.boolean(), + delete_schema: z.boolean() +}); + +export const schemaInputUpdate = z.object({ + target: z.number(), + positions: z.array(schemaOperationPosition), + input: z.number().nullable() +}); + +export const schemaOperationUpdate = z.object({ + target: z.number(), + positions: z.array(schemaOperationPosition), + item_data: z.object({ + alias: z.string().nonempty(), + title: z.string(), + comment: z.string() + }), + arguments: z.array(z.number()), + substitutions: z.array(schemaCstSubstitute) +}); diff --git a/rsconcept/frontend/src/features/oss/backend/useOperationUpdate.tsx b/rsconcept/frontend/src/features/oss/backend/useOperationUpdate.tsx index 6c6c6c77..e2d3eb89 100644 --- a/rsconcept/frontend/src/features/oss/backend/useOperationUpdate.tsx +++ b/rsconcept/frontend/src/features/oss/backend/useOperationUpdate.tsx @@ -1,6 +1,6 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { ILibraryItem } from '@/features/library/models/library'; +import { ILibraryItem } from '@/features/library/backend/types'; import { KEYS } from '@/backend/configuration'; diff --git a/rsconcept/frontend/src/features/oss/components/PickMultiOperation.tsx b/rsconcept/frontend/src/features/oss/components/PickMultiOperation.tsx index 9560eeb5..a6218c36 100644 --- a/rsconcept/frontend/src/features/oss/components/PickMultiOperation.tsx +++ b/rsconcept/frontend/src/features/oss/components/PickMultiOperation.tsx @@ -9,7 +9,7 @@ import { IconMoveDown, IconMoveUp, IconRemove } from '@/components/Icons'; import { CProps } from '@/components/props'; import { NoData } from '@/components/View'; -import { IOperation } from '../models/oss'; +import { IOperation } from '../backend/types'; import SelectOperation from './SelectOperation'; diff --git a/rsconcept/frontend/src/features/oss/components/SelectOperation.tsx b/rsconcept/frontend/src/features/oss/components/SelectOperation.tsx index 33869c5e..abf69742 100644 --- a/rsconcept/frontend/src/features/oss/components/SelectOperation.tsx +++ b/rsconcept/frontend/src/features/oss/components/SelectOperation.tsx @@ -5,7 +5,7 @@ import clsx from 'clsx'; import { SelectSingle } from '@/components/Input'; import { CProps } from '@/components/props'; -import { IOperation } from '../models/oss'; +import { IOperation } from '../backend/types'; import { matchOperation } from '../models/ossAPI'; interface SelectOperationProps extends CProps.Styling { diff --git a/rsconcept/frontend/src/features/oss/components/TooltipOperation.tsx b/rsconcept/frontend/src/features/oss/components/TooltipOperation.tsx index 45c8eeae..8413f01f 100644 --- a/rsconcept/frontend/src/features/oss/components/TooltipOperation.tsx +++ b/rsconcept/frontend/src/features/oss/components/TooltipOperation.tsx @@ -6,8 +6,8 @@ import { Tooltip } from '@/components/Container'; import DataTable from '@/components/DataTable'; import { IconPageRight } from '@/components/Icons'; +import { ICstSubstituteEx, OperationType } from '../backend/types'; import { labelOperationType } from '../labels'; -import { ICstSubstituteEx, OperationType } from '../models/oss'; import { OssNodeInternal } from '../models/ossLayout'; interface TooltipOperationProps { diff --git a/rsconcept/frontend/src/features/oss/dialogs/DlgChangeInputSchema.tsx b/rsconcept/frontend/src/features/oss/dialogs/DlgChangeInputSchema.tsx index 7bab46fb..94d88ae7 100644 --- a/rsconcept/frontend/src/features/oss/dialogs/DlgChangeInputSchema.tsx +++ b/rsconcept/frontend/src/features/oss/dialogs/DlgChangeInputSchema.tsx @@ -12,9 +12,9 @@ import { Label } from '@/components/Input'; import { ModalForm } from '@/components/Modal'; import { useDialogsStore } from '@/stores/dialogs'; -import { IInputUpdateDTO, IOperationPosition, schemaInputUpdate } from '../backend/types'; +import { IInputUpdateDTO, IOperation, IOperationPosition, schemaInputUpdate } from '../backend/types'; import { useInputUpdate } from '../backend/useInputUpdate'; -import { IOperation, IOperationSchema } from '../models/oss'; +import { IOperationSchema } from '../models/oss'; import { sortItemsForOSS } from '../models/ossAPI'; export interface DlgChangeInputSchemaProps { diff --git a/rsconcept/frontend/src/features/oss/dialogs/DlgCreateOperation/DlgCreateOperation.tsx b/rsconcept/frontend/src/features/oss/dialogs/DlgCreateOperation/DlgCreateOperation.tsx index d745245c..5ab0db8f 100644 --- a/rsconcept/frontend/src/features/oss/dialogs/DlgCreateOperation/DlgCreateOperation.tsx +++ b/rsconcept/frontend/src/features/oss/dialogs/DlgCreateOperation/DlgCreateOperation.tsx @@ -11,10 +11,10 @@ import { ModalForm } from '@/components/Modal'; import { TabLabel, TabList, TabPanel, Tabs } from '@/components/Tabs'; import { useDialogsStore } from '@/stores/dialogs'; -import { IOperationCreateDTO, IOperationPosition, schemaOperationCreate } from '../../backend/types'; +import { IOperationCreateDTO, IOperationPosition, OperationType, schemaOperationCreate } from '../../backend/types'; import { useOperationCreate } from '../../backend/useOperationCreate'; import { describeOperationType, labelOperationType } from '../../labels'; -import { IOperationSchema, OperationType } from '../../models/oss'; +import { IOperationSchema } from '../../models/oss'; import { calculateInsertPosition } from '../../models/ossAPI'; import TabInputOperation from './TabInputOperation'; diff --git a/rsconcept/frontend/src/features/oss/dialogs/DlgDeleteOperation.tsx b/rsconcept/frontend/src/features/oss/dialogs/DlgDeleteOperation.tsx index 6233d601..1f8e5526 100644 --- a/rsconcept/frontend/src/features/oss/dialogs/DlgDeleteOperation.tsx +++ b/rsconcept/frontend/src/features/oss/dialogs/DlgDeleteOperation.tsx @@ -10,9 +10,9 @@ import { Checkbox, TextInput } from '@/components/Input'; import { ModalForm } from '@/components/Modal'; import { useDialogsStore } from '@/stores/dialogs'; -import { IOperationDeleteDTO, IOperationPosition, schemaOperationDelete } from '../backend/types'; +import { IOperation, IOperationDeleteDTO, IOperationPosition, schemaOperationDelete } from '../backend/types'; import { useOperationDelete } from '../backend/useOperationDelete'; -import { IOperation, IOperationSchema } from '../models/oss'; +import { IOperationSchema } from '../models/oss'; export interface DlgDeleteOperationProps { oss: IOperationSchema; diff --git a/rsconcept/frontend/src/features/oss/dialogs/DlgEditOperation/DlgEditOperation.tsx b/rsconcept/frontend/src/features/oss/dialogs/DlgEditOperation/DlgEditOperation.tsx index 8231042b..31c50a00 100644 --- a/rsconcept/frontend/src/features/oss/dialogs/DlgEditOperation/DlgEditOperation.tsx +++ b/rsconcept/frontend/src/features/oss/dialogs/DlgEditOperation/DlgEditOperation.tsx @@ -12,9 +12,15 @@ import { ModalForm } from '@/components/Modal'; import { TabLabel, TabList, TabPanel, Tabs } from '@/components/Tabs'; import { useDialogsStore } from '@/stores/dialogs'; -import { IOperationPosition, IOperationUpdateDTO, schemaOperationUpdate } from '../../backend/types'; +import { + IOperation, + IOperationPosition, + IOperationUpdateDTO, + OperationType, + schemaOperationUpdate +} from '../../backend/types'; import { useOperationUpdate } from '../../backend/useOperationUpdate'; -import { IOperation, IOperationSchema, OperationType } from '../../models/oss'; +import { IOperationSchema } from '../../models/oss'; import TabArguments from './TabArguments'; import TabOperation from './TabOperation'; diff --git a/rsconcept/frontend/src/features/oss/dialogs/DlgRelocateConstituents.tsx b/rsconcept/frontend/src/features/oss/dialogs/DlgRelocateConstituents.tsx index 50b52afe..938e78c6 100644 --- a/rsconcept/frontend/src/features/oss/dialogs/DlgRelocateConstituents.tsx +++ b/rsconcept/frontend/src/features/oss/dialogs/DlgRelocateConstituents.tsx @@ -15,10 +15,10 @@ import { Loader } from '@/components/Loader'; import { ModalForm } from '@/components/Modal'; import { useDialogsStore } from '@/stores/dialogs'; -import { ICstRelocateDTO, IOperationPosition, schemaCstRelocate } from '../backend/types'; +import { ICstRelocateDTO, IOperation, IOperationPosition, schemaCstRelocate } from '../backend/types'; import { useRelocateConstituents } from '../backend/useRelocateConstituents'; import { useUpdatePositions } from '../backend/useUpdatePositions'; -import { IOperation, IOperationSchema } from '../models/oss'; +import { IOperationSchema } from '../models/oss'; import { getRelocateCandidates } from '../models/ossAPI'; export interface DlgRelocateConstituentsProps { diff --git a/rsconcept/frontend/src/features/oss/labels.ts b/rsconcept/frontend/src/features/oss/labels.ts index 03ef4a3e..d1c79cf5 100644 --- a/rsconcept/frontend/src/features/oss/labels.ts +++ b/rsconcept/frontend/src/features/oss/labels.ts @@ -1,4 +1,5 @@ -import { ISubstitutionErrorDescription, OperationType, SubstitutionErrorType } from './models/oss'; +import { OperationType } from './backend/types'; +import { ISubstitutionErrorDescription, SubstitutionErrorType } from './models/oss'; /** * Retrieves label for {@link OperationType}. diff --git a/rsconcept/frontend/src/features/oss/models/oss.ts b/rsconcept/frontend/src/features/oss/models/oss.ts index a7cd6ef6..aaca4b80 100644 --- a/rsconcept/frontend/src/features/oss/models/oss.ts +++ b/rsconcept/frontend/src/features/oss/models/oss.ts @@ -1,60 +1,12 @@ /** * Module: Schema of Synthesis Operations. */ -import { ILibraryItemData } from '@/features/library/models/library'; -import { ICstSubstitute } from '@/features/rsform'; + +import { ILibraryItemData } from '@/features/library/backend/types'; import { Graph } from '@/models/Graph'; -/** - * Represents {@link IOperation} type. - */ -export enum OperationType { - INPUT = 'input', - SYNTHESIS = 'synthesis' -} - -/** - * Represents Operation. - */ -export interface IOperation { - id: number; - operation_type: OperationType; - oss: number; - - alias: string; - title: string; - comment: string; - - position_x: number; - position_y: number; - - result: number | null; - - is_owned: boolean; - is_consolidation: boolean; // aka 'diamond synthesis' - substitutions: ICstSubstituteEx[]; - arguments: number[]; -} - -/** - * Represents {@link IOperation} Argument. - */ -export interface IArgument { - operation: number; - argument: number; -} - -/** - * Represents {@link ICstSubstitute} extended data. - */ -export interface ICstSubstituteEx extends ICstSubstitute { - operation: number; - original_alias: string; - original_term: string; - substitution_alias: string; - substitution_term: string; -} +import { IArgument, ICstSubstituteEx, IOperation } from '../backend/types'; /** * Represents {@link IOperationSchema} statistics. diff --git a/rsconcept/frontend/src/features/oss/models/ossAPI.ts b/rsconcept/frontend/src/features/oss/models/ossAPI.ts index 4c06a03f..3ba0f00e 100644 --- a/rsconcept/frontend/src/features/oss/models/ossAPI.ts +++ b/rsconcept/frontend/src/features/oss/models/ossAPI.ts @@ -2,10 +2,10 @@ * Module: API for OperationSystem. */ -import { ILibraryItem } from '@/features/library/models/library'; -import { CstClass, CstType, IConstituenta, IRSForm } from '@/features/rsform'; -import { ICstSubstitute } from '@/features/rsform/backend/types'; -import { AliasMapping, ParsingStatus } from '@/features/rsform/models/rslang'; +import { ILibraryItem } from '@/features/library/backend/types'; +import { CstType, ICstSubstitute, ParsingStatus } from '@/features/rsform/backend/types'; +import { CstClass, IConstituenta, IRSForm } from '@/features/rsform/models/rsform'; +import { AliasMapping } from '@/features/rsform/models/rslang'; import { applyAliasMapping, applyTypificationMapping, @@ -18,10 +18,10 @@ import { infoMsg } from '@/utils/labels'; import { TextMatcher } from '@/utils/utils'; import { Graph } from '../../../models/Graph'; -import { IOperationPosition } from '../backend/types'; +import { IOperation, IOperationPosition, OperationType } from '../backend/types'; import { describeSubstitutionError } from '../labels'; -import { IOperation, IOperationSchema, OperationType, SubstitutionErrorType } from './oss'; +import { IOperationSchema, SubstitutionErrorType } from './oss'; import { Position2D } from './ossLayout'; /** diff --git a/rsconcept/frontend/src/features/oss/models/ossLayout.ts b/rsconcept/frontend/src/features/oss/models/ossLayout.ts index 731244bb..b58b5447 100644 --- a/rsconcept/frontend/src/features/oss/models/ossLayout.ts +++ b/rsconcept/frontend/src/features/oss/models/ossLayout.ts @@ -3,8 +3,7 @@ */ import { Node } from 'reactflow'; -import { IOperation } from './oss'; - +import { IOperation } from '../backend/types'; /** * Represents XY Position. */ diff --git a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/NodeContextMenu.tsx b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/NodeContextMenu.tsx index 82f2b162..58dea338 100644 --- a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/NodeContextMenu.tsx +++ b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/NodeContextMenu.tsx @@ -16,8 +16,8 @@ import useClickedOutside from '@/hooks/useClickedOutside'; import { PARAMETER } from '@/utils/constants'; import { prepareTooltip } from '@/utils/utils'; +import { IOperation, OperationType } from '../../../backend/types'; import { useMutatingOss } from '../../../backend/useMutatingOss'; -import { IOperation, OperationType } from '../../../models/oss'; import { useOssEdit } from '../OssEditContext'; export interface ContextMenuData { diff --git a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/ToolbarOssGraph.tsx b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/ToolbarOssGraph.tsx index 62bbf75a..4411779c 100644 --- a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/ToolbarOssGraph.tsx +++ b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/ToolbarOssGraph.tsx @@ -24,8 +24,8 @@ import { useModificationStore } from '@/stores/modification'; import { PARAMETER } from '@/utils/constants'; import { prepareTooltip } from '@/utils/utils'; +import { OperationType } from '../../../backend/types'; import { useMutatingOss } from '../../../backend/useMutatingOss'; -import { OperationType } from '../../../models/oss'; import { useOSSGraphStore } from '../../../stores/ossGraph'; import { useOssEdit } from '../OssEditContext'; diff --git a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/graph/NodeCore.tsx b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/graph/NodeCore.tsx index 2e8c80f9..7d6203f6 100644 --- a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/graph/NodeCore.tsx +++ b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/graph/NodeCore.tsx @@ -6,8 +6,8 @@ import { Indicator } from '@/components/View'; import { PARAMETER, prefixes } from '@/utils/constants'; import { truncateToLastWord } from '@/utils/utils'; +import { OperationType } from '../../../../backend/types'; import TooltipOperation from '../../../../components/TooltipOperation'; -import { OperationType } from '../../../../models/oss'; import { OssNodeInternal } from '../../../../models/ossLayout'; import { useOssEdit } from '../../OssEditContext'; diff --git a/rsconcept/frontend/src/features/oss/pages/OssPage/OssEditContext.tsx b/rsconcept/frontend/src/features/oss/pages/OssPage/OssEditContext.tsx index 65292c88..a32e0a95 100644 --- a/rsconcept/frontend/src/features/oss/pages/OssPage/OssEditContext.tsx +++ b/rsconcept/frontend/src/features/oss/pages/OssPage/OssEditContext.tsx @@ -12,9 +12,9 @@ import { useDialogsStore } from '@/stores/dialogs'; import { usePreferencesStore } from '@/stores/preferences'; import { promptText } from '@/utils/labels'; -import { IOperationPosition } from '../../backend/types'; +import { IOperationPosition, OperationType } from '../../backend/types'; import { useOssSuspense } from '../../backend/useOSS'; -import { IOperationSchema, OperationType } from '../../models/oss'; +import { IOperationSchema } from '../../models/oss'; export enum OssTabID { CARD = 0, diff --git a/rsconcept/frontend/src/features/rsform/backend/RSFormLoader.ts b/rsconcept/frontend/src/features/rsform/backend/RSFormLoader.ts index 08e29570..138832d2 100644 --- a/rsconcept/frontend/src/features/rsform/backend/RSFormLoader.ts +++ b/rsconcept/frontend/src/features/rsform/backend/RSFormLoader.ts @@ -4,12 +4,11 @@ import { Graph } from '@/models/Graph'; -import { CstType, IConstituenta, IRSForm, IRSFormStats } from '../models/rsform'; +import { IConstituenta, IRSForm, IRSFormStats } from '../models/rsform'; import { inferClass, inferStatus, inferTemplate, isBaseSet, isFunctional } from '../models/rsformAPI'; -import { ParsingStatus, ValueClass } from '../models/rslang'; import { extractGlobals, isSimpleExpression, splitTemplateDefinition } from '../models/rslangAPI'; -import { IRSFormDTO } from './types'; +import { CstType, IRSFormDTO, ParsingStatus, ValueClass } from './types'; /** * Loads data into an {@link IRSForm} based on {@link IRSFormDTO}. diff --git a/rsconcept/frontend/src/features/rsform/backend/api.ts b/rsconcept/frontend/src/features/rsform/backend/api.ts index 375eeb8e..50f515c9 100644 --- a/rsconcept/frontend/src/features/rsform/backend/api.ts +++ b/rsconcept/frontend/src/features/rsform/backend/api.ts @@ -4,11 +4,10 @@ import { axiosGet, axiosPatch, axiosPost } from '@/backend/apiTransport'; import { DELAYS, KEYS } from '@/backend/configuration'; import { infoMsg } from '@/utils/labels'; -import { IConstituentaList } from '../models/rsform'; - import { ICheckConstituentaDTO, IConstituentaBasicsDTO, + IConstituentaList, ICstCreatedResponse, ICstCreateDTO, ICstMoveDTO, diff --git a/rsconcept/frontend/src/features/rsform/backend/types.ts b/rsconcept/frontend/src/features/rsform/backend/types.ts index c5fd4ffe..4a4b0267 100644 --- a/rsconcept/frontend/src/features/rsform/backend/types.ts +++ b/rsconcept/frontend/src/features/rsform/backend/types.ts @@ -1,11 +1,41 @@ import { z } from 'zod'; -import { AccessPolicy, LibraryItemType, schemaVersionInfo } from '@/features/library/models/library'; +import { AccessPolicy, LibraryItemType, schemaVersionInfo } from '@/features/library/backend/types'; import { errorMsg } from '@/utils/labels'; -import { CstType } from '../models/rsform'; -import { ParsingStatus, RSErrorType, Syntax, TokenID, ValueClass } from '../models/rslang'; +/** Represents {@link IConstituenta} type. */ +export enum CstType { + BASE = 'basic', + STRUCTURED = 'structure', + TERM = 'term', + AXIOM = 'axiom', + FUNCTION = 'function', + PREDICATE = 'predicate', + CONSTANT = 'constant', + THEOREM = 'theorem' +} + +/** Represents syntax type. */ +export enum Syntax { + UNDEF = 'undefined', + ASCII = 'ascii', + MATH = 'math' +} + +/** Represents computability class. */ +export enum ValueClass { + INVALID = 'invalid', // incalculable + VALUE = 'value', + PROPERTY = 'property' +} + +/** Represents parsing status. */ +export enum ParsingStatus { + UNDEF = 'undefined', + VERIFIED = 'verified', + INCORRECT = 'incorrect' +} /** Represents Constituenta basic persistent data. */ export type IConstituentaBasicsDTO = z.infer; @@ -66,12 +96,177 @@ export interface ICheckConstituentaDTO { /** Represents data, used in merging multiple {@link IConstituenta}. */ export type ICstSubstitutionsDTO = z.infer; +/** + * Represents Constituenta list. + */ +export interface IConstituentaList { + items: number[]; +} + /** Represents parsing error description. */ export type IRSErrorDescription = z.infer; /** Represents results of expression parse in RSLang. */ export type IExpressionParseDTO = z.infer; +/** Represents RSLang token types. */ +export enum TokenID { + // Global, local IDs and literals + ID_LOCAL = 258, + ID_GLOBAL, + ID_FUNCTION, + ID_PREDICATE, + ID_RADICAL, + LIT_INTEGER, + LIT_WHOLE_NUMBERS, + LIT_EMPTYSET, + + // Arithmetic + PLUS, + MINUS, + MULTIPLY, + + // Integer predicate symbols + GREATER, + LESSER, + GREATER_OR_EQ, + LESSER_OR_EQ, + + // Equality comparison + EQUAL, + NOTEQUAL, + + // Logic predicate symbols + QUANTOR_UNIVERSAL, + QUANTOR_EXISTS, + LOGIC_NOT, + LOGIC_EQUIVALENT, + LOGIC_IMPLICATION, + LOGIC_OR, + LOGIC_AND, + + // Set theory predicate symbols + SET_IN, + SET_NOT_IN, + SUBSET, + SUBSET_OR_EQ, + NOT_SUBSET, + + // Set theory operators + DECART, + SET_UNION, + SET_INTERSECTION, + SET_MINUS, + SET_SYMMETRIC_MINUS, + BOOLEAN, + + // Structure operations + BIGPR, + SMALLPR, + FILTER, + CARD, + BOOL, + DEBOOL, + REDUCE, + + // Term constructions prefixes + DECLARATIVE, + RECURSIVE, + IMPERATIVE, + + ITERATE, + ASSIGN, + + // Punctuation + PUNCTUATION_DEFINE, + PUNCTUATION_STRUCT, + PUNCTUATION_PL, + PUNCTUATION_PR, + PUNCTUATION_CL, + PUNCTUATION_CR, + PUNCTUATION_SL, + PUNCTUATION_SR, + PUNCTUATION_BAR, + PUNCTUATION_COMMA, + PUNCTUATION_SEMICOLON, + + // ======= Non-terminal tokens ========= + NT_ENUM_DECL, + NT_TUPLE, + NT_ENUMERATION, + NT_TUPLE_DECL, + NT_ARG_DECL, + + NT_FUNC_DEFINITION, + NT_ARGUMENTS, + NT_FUNC_CALL, + + NT_DECLARATIVE_EXPR, + NT_IMPERATIVE_EXPR, + NT_RECURSIVE_FULL, + NT_RECURSIVE_SHORT, + + // ======= Helper tokens ======== + INTERRUPT, + END +} + +/** Represents RSLang expression error types. */ +export enum RSErrorType { + unknownSymbol = 33283, + syntax = 33792, + missingParenthesis = 33798, + missingCurlyBrace = 33799, + invalidQuantifier = 33800, + invalidImperative = 33801, + expectedArgDeclaration = 33812, + expectedLocal = 33813, + localDoubleDeclare = 10241, + localNotUsed = 10242, + + localUndeclared = 34817, + localShadowing = 34818, + + typesNotEqual = 34819, + globalNotTyped = 34820, + invalidDecart = 34821, + invalidBoolean = 34822, + invalidTypeOperation = 34823, + invalidCard = 34824, + invalidDebool = 34825, + globalFuncMissing = 34826, + globalFuncWithoutArgs = 34827, + invalidReduce = 34832, + invalidProjectionTuple = 34833, + invalidProjectionSet = 34834, + invalidEnumeration = 34835, + invalidBinding = 34836, + localOutOfScope = 34837, + invalidElementPredicate = 34838, + invalidEmptySetUsage = 34839, + invalidArgsArity = 34840, + invalidArgumentType = 34841, + globalStructure = 34844, + radicalUsage = 34849, + invalidFilterArgumentType = 34850, + invalidFilterArity = 34851, + arithmeticNotSupported = 34852, + typesNotCompatible = 34853, + orderingNotSupported = 34854, + + globalNoValue = 34880, + invalidPropertyUsage = 34881, + globalMissingAST = 34882, + globalFuncNoInterpretation = 34883, + + cstNonemptyBase = 34912, + cstEmptyDerived = 34913, + cstCallableNoArgs = 34914, + cstNonCallableHasArgs = 34915, + cstExpectedLogical = 34916, + cstExpectedTyped = 34917 +} + // ========= SCHEMAS ======== export const schemaConstituentaBasics = z.object({ id: z.coerce.number(), diff --git a/rsconcept/frontend/src/features/rsform/backend/useCstDelete.tsx b/rsconcept/frontend/src/features/rsform/backend/useCstDelete.tsx index 7434ac25..fc4e4857 100644 --- a/rsconcept/frontend/src/features/rsform/backend/useCstDelete.tsx +++ b/rsconcept/frontend/src/features/rsform/backend/useCstDelete.tsx @@ -4,9 +4,8 @@ import { useUpdateTimestamp } from '@/features/library'; import { KEYS } from '@/backend/configuration'; -import { IConstituentaList } from '../models/rsform'; - import { rsformsApi } from './api'; +import { IConstituentaList } from './types'; export const useCstDelete = () => { const client = useQueryClient(); diff --git a/rsconcept/frontend/src/features/rsform/backend/useUploadTRS.tsx b/rsconcept/frontend/src/features/rsform/backend/useUploadTRS.tsx index 7a8b88c6..88824d2b 100644 --- a/rsconcept/frontend/src/features/rsform/backend/useUploadTRS.tsx +++ b/rsconcept/frontend/src/features/rsform/backend/useUploadTRS.tsx @@ -1,6 +1,6 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { ILibraryItem } from '@/features/library/models/library'; +import { ILibraryItem } from '@/features/library/backend/types'; import { KEYS } from '@/backend/configuration'; diff --git a/rsconcept/frontend/src/features/rsform/colors.ts b/rsconcept/frontend/src/features/rsform/colors.ts index fa8f47e8..89cd2df7 100644 --- a/rsconcept/frontend/src/features/rsform/colors.ts +++ b/rsconcept/frontend/src/features/rsform/colors.ts @@ -1,9 +1,10 @@ import { APP_COLORS } from '@/styling/colors'; import { PARAMETER } from '@/utils/constants'; +import { TokenID } from './backend/types'; import { GramData, Grammeme, NounGrams, PartOfSpeech, VerbGrams } from './models/language'; import { CstClass, ExpressionStatus, IConstituenta } from './models/rsform'; -import { ISyntaxTreeNode, TokenID } from './models/rslang'; +import { ISyntaxTreeNode } from './models/rslang'; import { TMGraphNode } from './models/TMGraph'; import { GraphColoring } from './stores/termGraph'; diff --git a/rsconcept/frontend/src/features/rsform/components/RSInput/RSInput.tsx b/rsconcept/frontend/src/features/rsform/components/RSInput/RSInput.tsx index 2ef3ef89..cd065330 100644 --- a/rsconcept/frontend/src/features/rsform/components/RSInput/RSInput.tsx +++ b/rsconcept/frontend/src/features/rsform/components/RSInput/RSInput.tsx @@ -45,7 +45,7 @@ interface RSInputProps onOpenEdit?: (cstID: number) => void; } -const RSInput = forwardRef( +export const RSInput = forwardRef( ( { id, // @@ -176,8 +176,6 @@ const RSInput = forwardRef( } ); -export default RSInput; - // ======= Internal ========== const editorSetup: BasicSetupOptions = { highlightSpecialChars: false, diff --git a/rsconcept/frontend/src/features/rsform/components/RSInput/index.tsx b/rsconcept/frontend/src/features/rsform/components/RSInput/index.tsx index 1a46b244..8d472e5f 100644 --- a/rsconcept/frontend/src/features/rsform/components/RSInput/index.tsx +++ b/rsconcept/frontend/src/features/rsform/components/RSInput/index.tsx @@ -1 +1 @@ -export { default } from './RSInput'; +export { RSInput } from './RSInput'; diff --git a/rsconcept/frontend/src/features/rsform/components/RSInput/textEditing.ts b/rsconcept/frontend/src/features/rsform/components/RSInput/textEditing.ts index c637d45d..aeb40762 100644 --- a/rsconcept/frontend/src/features/rsform/components/RSInput/textEditing.ts +++ b/rsconcept/frontend/src/features/rsform/components/RSInput/textEditing.ts @@ -4,7 +4,7 @@ import { ReactCodeMirrorRef } from '@uiw/react-codemirror'; import { CodeMirrorWrapper } from '@/utils/codemirror'; -import { TokenID } from '../../models/rslang'; +import { TokenID } from '../../backend/types'; export function getSymbolSubstitute(keyCode: string, shiftPressed: boolean): string | undefined { // prettier-ignore diff --git a/rsconcept/frontend/src/features/rsform/components/SelectCstType.tsx b/rsconcept/frontend/src/features/rsform/components/SelectCstType.tsx index e7142e02..3198ae13 100644 --- a/rsconcept/frontend/src/features/rsform/components/SelectCstType.tsx +++ b/rsconcept/frontend/src/features/rsform/components/SelectCstType.tsx @@ -1,8 +1,8 @@ import { SelectSingle } from '@/components/Input'; import { CProps } from '@/components/props'; +import { CstType } from '../backend/types'; import { labelCstType } from '../labels'; -import { CstType } from '../models/rsform'; const SelectorCstType = Object.values(CstType).map(typeStr => ({ value: typeStr as CstType, diff --git a/rsconcept/frontend/src/features/rsform/dialogs/DlgCreateCst/FormCreateCst.tsx b/rsconcept/frontend/src/features/rsform/dialogs/DlgCreateCst/FormCreateCst.tsx index 1a80e2c7..d6564e73 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/DlgCreateCst/FormCreateCst.tsx +++ b/rsconcept/frontend/src/features/rsform/dialogs/DlgCreateCst/FormCreateCst.tsx @@ -9,10 +9,10 @@ import { BadgeHelp, HelpTopic } from '@/features/help'; import { TextArea, TextInput } from '@/components/Input'; import { PARAMETER } from '@/utils/constants'; -import { ICstCreateDTO } from '../../backend/types'; -import RSInput from '../../components/RSInput'; +import { CstType, ICstCreateDTO } from '../../backend/types'; +import { RSInput } from '../../components/RSInput'; import { SelectCstType } from '../../components/SelectCstType'; -import { CstType, IRSForm } from '../../models/rsform'; +import { IRSForm } from '../../models/rsform'; import { generateAlias, isBaseSet, isBasicConcept, isFunctional } from '../../models/rsformAPI'; interface FormCreateCstProps { diff --git a/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/DlgCstTemplate.tsx b/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/DlgCstTemplate.tsx index e7c490a7..c226f459 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/DlgCstTemplate.tsx +++ b/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/DlgCstTemplate.tsx @@ -12,9 +12,9 @@ import { ModalForm } from '@/components/Modal'; import { TabLabel, TabList, TabPanel, Tabs } from '@/components/Tabs'; import { useDialogsStore } from '@/stores/dialogs'; -import { IConstituentaBasicsDTO, ICstCreateDTO, schemaCstCreate } from '../../backend/types'; +import { CstType, IConstituentaBasicsDTO, ICstCreateDTO, schemaCstCreate } from '../../backend/types'; import { useCstCreate } from '../../backend/useCstCreate'; -import { CstType, IRSForm } from '../../models/rsform'; +import { IRSForm } from '../../models/rsform'; import { generateAlias, validateNewAlias } from '../../models/rsformAPI'; import FormCreateCst from '../DlgCreateCst/FormCreateCst'; diff --git a/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/TabArguments.tsx b/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/TabArguments.tsx index 540417c7..eb2ec43a 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/TabArguments.tsx +++ b/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/TabArguments.tsx @@ -14,7 +14,7 @@ import { APP_COLORS } from '@/styling/colors'; import { ICstCreateDTO } from '../../backend/types'; import { PickConstituenta } from '../../components/PickConstituenta'; -import RSInput from '../../components/RSInput'; +import { RSInput } from '../../components/RSInput'; import { IConstituenta } from '../../models/rsform'; import { IArgumentValue } from '../../models/rslang'; diff --git a/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/TabTemplate.tsx b/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/TabTemplate.tsx index 0fed45d4..c6e6f9d4 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/TabTemplate.tsx +++ b/rsconcept/frontend/src/features/rsform/dialogs/DlgCstTemplate/TabTemplate.tsx @@ -6,7 +6,7 @@ import { SelectSingle, TextArea } from '@/components/Input'; import { useRSForm } from '../../backend/useRSForm'; import { PickConstituenta } from '../../components/PickConstituenta'; -import RSInput from '../../components/RSInput'; +import { RSInput } from '../../components/RSInput'; import { CATEGORY_CST_TYPE } from '../../models/rsform'; import { applyFilterCategory } from '../../models/rsformAPI'; diff --git a/rsconcept/frontend/src/features/rsform/dialogs/DlgGraphParams.tsx b/rsconcept/frontend/src/features/rsform/dialogs/DlgGraphParams.tsx index 85cff672..61f60e73 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/DlgGraphParams.tsx +++ b/rsconcept/frontend/src/features/rsform/dialogs/DlgGraphParams.tsx @@ -5,8 +5,8 @@ import { Controller, useForm } from 'react-hook-form'; import { Checkbox } from '@/components/Input'; import { ModalForm } from '@/components/Modal'; +import { CstType } from '../backend/types'; import { labelCstType } from '../labels'; -import { CstType } from '../models/rsform'; import { GraphFilterParams, useTermGraphStore } from '../stores/termGraph'; function DlgGraphParams() { diff --git a/rsconcept/frontend/src/features/rsform/dialogs/DlgRenameCst.tsx b/rsconcept/frontend/src/features/rsform/dialogs/DlgRenameCst.tsx index cff1d99c..396d5cd8 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/DlgRenameCst.tsx +++ b/rsconcept/frontend/src/features/rsform/dialogs/DlgRenameCst.tsx @@ -10,10 +10,10 @@ import { TextInput } from '@/components/Input'; import { ModalForm } from '@/components/Modal'; import { useDialogsStore } from '@/stores/dialogs'; -import { ICstRenameDTO, schemaCstRename } from '../backend/types'; +import { CstType, ICstRenameDTO, schemaCstRename } from '../backend/types'; import { useCstRename } from '../backend/useCstRename'; import { SelectCstType } from '../components/SelectCstType'; -import { CstType, IConstituenta, IRSForm } from '../models/rsform'; +import { IConstituenta, IRSForm } from '../models/rsform'; import { generateAlias, validateNewAlias } from '../models/rsformAPI'; export interface DlgRenameCstProps { diff --git a/rsconcept/frontend/src/features/rsform/index.ts b/rsconcept/frontend/src/features/rsform/index.ts index e0770ac0..d72991c2 100644 --- a/rsconcept/frontend/src/features/rsform/index.ts +++ b/rsconcept/frontend/src/features/rsform/index.ts @@ -1,7 +1,8 @@ export { type ICstSubstitute } from './backend/types'; +export { CstType } from './backend/types'; export { useRSForm, useRSFormSuspense } from './backend/useRSForm'; export { useRSForms } from './backend/useRSForms'; export { PickMultiConstituenta } from './components/PickMultiConstituenta'; export { PickSubstitutions } from './components/PickSubstitutions'; export { ToolbarRSFormCard } from './components/ToolbarRSFormCard'; -export { CstClass, CstType, type IConstituenta, type IRSForm } from './models/rsform'; +export { CstClass, type IConstituenta, type IRSForm } from './models/rsform'; diff --git a/rsconcept/frontend/src/features/rsform/labels.ts b/rsconcept/frontend/src/features/rsform/labels.ts index 027d6a5b..8eace1af 100644 --- a/rsconcept/frontend/src/features/rsform/labels.ts +++ b/rsconcept/frontend/src/features/rsform/labels.ts @@ -5,10 +5,10 @@ import { PARAMETER } from '@/utils/constants'; import { prepareTooltip } from '@/utils/utils'; -import { IRSErrorDescription } from './backend/types'; +import { CstType, IRSErrorDescription, ParsingStatus, RSErrorType, TokenID } from './backend/types'; import { GramData, Grammeme, ReferenceType } from './models/language'; -import { CstClass, CstType, ExpressionStatus, IConstituenta, IRSForm } from './models/rsform'; -import { IArgumentInfo, ISyntaxTreeNode, ParsingStatus, RSErrorType, TokenID } from './models/rslang'; +import { CstClass, ExpressionStatus, IConstituenta, IRSForm } from './models/rsform'; +import { IArgumentInfo, ISyntaxTreeNode } from './models/rslang'; import { CstMatchMode, DependencyMode } from './stores/cstSearch'; import { GraphColoring } from './stores/termGraph'; diff --git a/rsconcept/frontend/src/features/rsform/models/rsform.ts b/rsconcept/frontend/src/features/rsform/models/rsform.ts index a2bc7a5f..675acd17 100644 --- a/rsconcept/frontend/src/features/rsform/models/rsform.ts +++ b/rsconcept/frontend/src/features/rsform/models/rsform.ts @@ -6,21 +6,9 @@ import { ILibraryItemReference, ILibraryItemVersioned } from '@/features/library import { Graph } from '@/models/Graph'; -import { IArgumentInfo, ParsingStatus, ValueClass } from './rslang'; +import { CstType, ParsingStatus, ValueClass } from '../backend/types'; -/** - * Represents {@link IConstituenta} type. - */ -export enum CstType { - BASE = 'basic', - STRUCTURED = 'structure', - TERM = 'term', - AXIOM = 'axiom', - FUNCTION = 'function', - PREDICATE = 'predicate', - CONSTANT = 'constant', - THEOREM = 'theorem' -} +import { IArgumentInfo } from './rslang'; // CstType constant for category dividers in TemplateSchemas export const CATEGORY_CST_TYPE = CstType.THEOREM; @@ -112,21 +100,6 @@ export interface IConstituenta { spawn_alias: string[]; } -/** - * Represents {@link IConstituenta} reference. - */ -export interface IConstituentaReference { - id: number; - schema: number; -} - -/** - * Represents Constituenta list. - */ -export interface IConstituentaList { - items: number[]; -} - /** * Represents {@link IRSForm} statistics. */ diff --git a/rsconcept/frontend/src/features/rsform/models/rsformAPI.ts b/rsconcept/frontend/src/features/rsform/models/rsformAPI.ts index c208fde6..84c87fb7 100644 --- a/rsconcept/frontend/src/features/rsform/models/rsformAPI.ts +++ b/rsconcept/frontend/src/features/rsform/models/rsformAPI.ts @@ -2,14 +2,15 @@ * Module: API for formal representation for systems of concepts. */ -import { BASIC_SCHEMAS, ILibraryItem } from '@/features/library/models/library'; +import { ILibraryItem } from '@/features/library/backend/types'; +import { BASIC_SCHEMAS } from '@/features/library/models/library'; import { TextMatcher } from '@/utils/utils'; +import { CstType, ParsingStatus, ValueClass } from '../backend/types'; import { CstMatchMode } from '../stores/cstSearch'; -import { CATEGORY_CST_TYPE, CstClass, CstType, ExpressionStatus, IConstituenta, IRSForm } from './rsform'; -import { ParsingStatus, ValueClass } from './rslang'; +import { CATEGORY_CST_TYPE, CstClass, ExpressionStatus, IConstituenta, IRSForm } from './rsform'; /** * Checks if a given target {@link IConstituenta} matches the specified query using the provided matching mode. diff --git a/rsconcept/frontend/src/features/rsform/models/rslang.ts b/rsconcept/frontend/src/features/rsform/models/rslang.ts index f892c8a0..340c6e56 100644 --- a/rsconcept/frontend/src/features/rsform/models/rslang.ts +++ b/rsconcept/frontend/src/features/rsform/models/rslang.ts @@ -2,38 +2,13 @@ * Module: Models for RSLanguage. */ +import { TokenID } from '../backend/types'; + /** * Represents alias mapping. */ export type AliasMapping = Record; -/** - * Represents syntax type. - */ -export enum Syntax { - UNDEF = 'undefined', - ASCII = 'ascii', - MATH = 'math' -} - -/** - * Represents computability class. - */ -export enum ValueClass { - INVALID = 'invalid', // incalculable - VALUE = 'value', - PROPERTY = 'property' -} - -/** - * Represents parsing status. - */ -export enum ParsingStatus { - UNDEF = 'undefined', - VERIFIED = 'verified', - INCORRECT = 'incorrect' -} - /** * Represents AST node. */ @@ -76,171 +51,7 @@ export interface IArgumentValue extends IArgumentInfo { value?: string; } -/** - * Represents RSLang token types. - */ -export enum TokenID { - // Global, local IDs and literals - ID_LOCAL = 258, - ID_GLOBAL, - ID_FUNCTION, - ID_PREDICATE, - ID_RADICAL, - LIT_INTEGER, - LIT_WHOLE_NUMBERS, - LIT_EMPTYSET, - - // Arithmetic - PLUS, - MINUS, - MULTIPLY, - - // Integer predicate symbols - GREATER, - LESSER, - GREATER_OR_EQ, - LESSER_OR_EQ, - - // Equality comparison - EQUAL, - NOTEQUAL, - - // Logic predicate symbols - QUANTOR_UNIVERSAL, - QUANTOR_EXISTS, - LOGIC_NOT, - LOGIC_EQUIVALENT, - LOGIC_IMPLICATION, - LOGIC_OR, - LOGIC_AND, - - // Set theory predicate symbols - SET_IN, - SET_NOT_IN, - SUBSET, - SUBSET_OR_EQ, - NOT_SUBSET, - - // Set theory operators - DECART, - SET_UNION, - SET_INTERSECTION, - SET_MINUS, - SET_SYMMETRIC_MINUS, - BOOLEAN, - - // Structure operations - BIGPR, - SMALLPR, - FILTER, - CARD, - BOOL, - DEBOOL, - REDUCE, - - // Term constructions prefixes - DECLARATIVE, - RECURSIVE, - IMPERATIVE, - - ITERATE, - ASSIGN, - - // Punctuation - PUNCTUATION_DEFINE, - PUNCTUATION_STRUCT, - PUNCTUATION_PL, - PUNCTUATION_PR, - PUNCTUATION_CL, - PUNCTUATION_CR, - PUNCTUATION_SL, - PUNCTUATION_SR, - PUNCTUATION_BAR, - PUNCTUATION_COMMA, - PUNCTUATION_SEMICOLON, - - // ======= Non-terminal tokens ========= - NT_ENUM_DECL, - NT_TUPLE, - NT_ENUMERATION, - NT_TUPLE_DECL, - NT_ARG_DECL, - - NT_FUNC_DEFINITION, - NT_ARGUMENTS, - NT_FUNC_CALL, - - NT_DECLARATIVE_EXPR, - NT_IMPERATIVE_EXPR, - NT_RECURSIVE_FULL, - NT_RECURSIVE_SHORT, - - // ======= Helper tokens ======== - INTERRUPT, - END -} - -/** - * Represents RSLang expression error types. - */ -export enum RSErrorType { - unknownSymbol = 33283, - syntax = 33792, - missingParenthesis = 33798, - missingCurlyBrace = 33799, - invalidQuantifier = 33800, - invalidImperative = 33801, - expectedArgDeclaration = 33812, - expectedLocal = 33813, - localDoubleDeclare = 10241, - localNotUsed = 10242, - - localUndeclared = 34817, - localShadowing = 34818, - - typesNotEqual = 34819, - globalNotTyped = 34820, - invalidDecart = 34821, - invalidBoolean = 34822, - invalidTypeOperation = 34823, - invalidCard = 34824, - invalidDebool = 34825, - globalFuncMissing = 34826, - globalFuncWithoutArgs = 34827, - invalidReduce = 34832, - invalidProjectionTuple = 34833, - invalidProjectionSet = 34834, - invalidEnumeration = 34835, - invalidBinding = 34836, - localOutOfScope = 34837, - invalidElementPredicate = 34838, - invalidEmptySetUsage = 34839, - invalidArgsArity = 34840, - invalidArgumentType = 34841, - globalStructure = 34844, - radicalUsage = 34849, - invalidFilterArgumentType = 34850, - invalidFilterArity = 34851, - arithmeticNotSupported = 34852, - typesNotCompatible = 34853, - orderingNotSupported = 34854, - - globalNoValue = 34880, - invalidPropertyUsage = 34881, - globalMissingAST = 34882, - globalFuncNoInterpretation = 34883, - - cstNonemptyBase = 34912, - cstEmptyDerived = 34913, - cstCallableNoArgs = 34914, - cstNonCallableHasArgs = 34915, - cstExpectedLogical = 34916, - cstExpectedTyped = 34917 -} - -/** - * Represents error class. - */ +/** Represents error class. */ export enum RSErrorClass { LEXER, PARSER, diff --git a/rsconcept/frontend/src/features/rsform/models/rslangAPI.ts b/rsconcept/frontend/src/features/rsform/models/rslangAPI.ts index b3ade302..77c066e8 100644 --- a/rsconcept/frontend/src/features/rsform/models/rslangAPI.ts +++ b/rsconcept/frontend/src/features/rsform/models/rslangAPI.ts @@ -7,10 +7,9 @@ import { Tree } from '@lezer/common'; import { cursorNode } from '@/utils/codemirror'; import { PARAMETER } from '@/utils/constants'; -import { IRSErrorDescription } from '../backend/types'; +import { CstType, IRSErrorDescription, RSErrorType } from '../backend/types'; -import { CstType } from './rsform'; -import { AliasMapping, IArgumentValue, RSErrorClass, RSErrorType, SyntaxTree } from './rslang'; +import { AliasMapping, IArgumentValue, RSErrorClass, SyntaxTree } from './rslang'; // cspell:disable const LOCALS_REGEXP = /[_a-zα-ω][a-zα-ω]*\d*/g; diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorConstituenta/FormConstituenta.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorConstituenta/FormConstituenta.tsx index 8b4e6eef..97eaa9f1 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorConstituenta/FormConstituenta.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorConstituenta/FormConstituenta.tsx @@ -16,14 +16,13 @@ import { useDialogsStore } from '@/stores/dialogs'; import { useModificationStore } from '@/stores/modification'; import { errorMsg } from '@/utils/labels'; -import { ICstUpdateDTO, IExpressionParseDTO, schemaCstUpdate } from '../../../backend/types'; +import { CstType, ICstUpdateDTO, IExpressionParseDTO, ParsingStatus, schemaCstUpdate } from '../../../backend/types'; import { useCstUpdate } from '../../../backend/useCstUpdate'; import { useMutatingRSForm } from '../../../backend/useMutatingRSForm'; import { RefsInput } from '../../../components/RefsInput'; import { labelCstTypification, labelTypification } from '../../../labels'; -import { CstType, IConstituenta, IRSForm } from '../../../models/rsform'; +import { IConstituenta, IRSForm } from '../../../models/rsform'; import { isBaseSet, isBasicConcept, isFunctional } from '../../../models/rsformAPI'; -import { ParsingStatus } from '../../../models/rslang'; import EditorRSExpression from '../EditorRSExpression'; interface FormConstituentaProps { diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/EditorRSExpression.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/EditorRSExpression.tsx index 2d3cef7f..89bde127 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/EditorRSExpression.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/EditorRSExpression.tsx @@ -5,7 +5,6 @@ import { toast } from 'react-toastify'; import { ReactCodeMirrorRef } from '@uiw/react-codemirror'; import { BadgeHelp, HelpTopic } from '@/features/help'; -import { IExpressionParseDTO } from '@/features/rsform/backend/types'; import { DataCallback } from '@/backend/apiTransport'; import { Overlay } from '@/components/Container'; @@ -14,15 +13,14 @@ import { useDialogsStore } from '@/stores/dialogs'; import { usePreferencesStore } from '@/stores/preferences'; import { errorMsg } from '@/utils/labels'; -import { ICheckConstituentaDTO, IRSErrorDescription } from '../../../backend/types'; +import { ICheckConstituentaDTO, IExpressionParseDTO, IRSErrorDescription, TokenID } from '../../../backend/types'; import { useCheckConstituenta } from '../../../backend/useCheckConstituenta'; import { useMutatingRSForm } from '../../../backend/useMutatingRSForm'; -import RSInput from '../../../components/RSInput'; +import { RSInput } from '../../../components/RSInput'; import { parser as rslangParser } from '../../../components/RSInput/rslang/parserAST'; import { RSTextWrapper } from '../../../components/RSInput/textEditing'; import { IConstituenta } from '../../../models/rsform'; import { getDefinitionPrefix } from '../../../models/rsformAPI'; -import { TokenID } from '../../../models/rslang'; import { transformAST } from '../../../models/rslangAPI'; import { useRSEdit } from '../RSEditContext'; diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSEditControls.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSEditControls.tsx index e7c30584..845d288f 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSEditControls.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSEditControls.tsx @@ -2,7 +2,7 @@ import clsx from 'clsx'; import { PARAMETER, prefixes } from '@/utils/constants'; -import { TokenID } from '../../../models/rslang'; +import { TokenID } from '../../../backend/types'; import RSLocalButton from './RSLocalButton'; import RSTokenButton from './RSTokenButton'; diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSLocalButton.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSLocalButton.tsx index a7cf64ee..262f93f3 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSLocalButton.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSLocalButton.tsx @@ -3,7 +3,7 @@ import clsx from 'clsx'; import { CProps } from '@/components/props'; import { globals } from '@/utils/constants'; -import { TokenID } from '../../../models/rslang'; +import { TokenID } from '../../../backend/types'; interface RSLocalButtonProps extends CProps.Titled, CProps.Styling { text: string; diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSTokenButton.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSTokenButton.tsx index b2c29978..ad7e0c9f 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSTokenButton.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/RSTokenButton.tsx @@ -2,8 +2,8 @@ import clsx from 'clsx'; import { globals } from '@/utils/constants'; +import { TokenID } from '../../../backend/types'; import { describeToken, labelToken } from '../../../labels'; -import { TokenID } from '../../../models/rslang'; interface RSTokenButtonProps { token: TokenID; diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/StatusBar.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/StatusBar.tsx index a57c4664..6a5b433e 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/StatusBar.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSExpression/StatusBar.tsx @@ -8,12 +8,11 @@ import { APP_COLORS } from '@/styling/colors'; import { globals } from '@/utils/constants'; import { prepareTooltip } from '@/utils/utils'; -import { IExpressionParseDTO } from '../../../backend/types'; +import { IExpressionParseDTO, ParsingStatus } from '../../../backend/types'; import { colorStatusBar } from '../../../colors'; import { labelExpressionStatus } from '../../../labels'; import { ExpressionStatus, IConstituenta } from '../../../models/rsform'; import { inferStatus } from '../../../models/rsformAPI'; -import { ParsingStatus } from '../../../models/rslang'; interface StatusBarProps { processing?: boolean; diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSList/EditorRSList.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSList/EditorRSList.tsx index b8485b4c..d857935d 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSList/EditorRSList.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSList/EditorRSList.tsx @@ -13,14 +13,14 @@ import { useFitHeight } from '@/stores/appLayout'; import { infoMsg } from '@/utils/labels'; import { convertToCSV } from '@/utils/utils'; +import { CstType } from '../../../backend/types'; import { useMutatingRSForm } from '../../../backend/useMutatingRSForm'; -import { CstType } from '../../../models/rsform'; import { matchConstituenta } from '../../../models/rsformAPI'; import { CstMatchMode } from '../../../stores/cstSearch'; import { useRSEdit } from '../RSEditContext'; import TableRSList from './TableRSList'; -import ToolbarRSList from './ToolbarRSList'; +import { ToolbarRSList } from './ToolbarRSList'; function EditorRSList() { const controller = useRSEdit(); diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSList/ToolbarRSList.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSList/ToolbarRSList.tsx index 8fea37ff..aad06873 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSList/ToolbarRSList.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorRSList/ToolbarRSList.tsx @@ -1,12 +1,21 @@ import { BadgeHelp, HelpTopic } from '@/features/help'; import { MiniSelectorOSS } from '@/features/library'; +import { CstType } from '@/features/rsform'; import { Overlay } from '@/components/Container'; import { MiniButton } from '@/components/Control'; -import { CstTypeIcon } from '@/components/DomainIcons'; +import { DomIconProps } from '@/components/DomainIcons'; import { Dropdown, DropdownButton, useDropdown } from '@/components/Dropdown'; import { IconClone, + IconCstAxiom, + IconCstBaseSet, + IconCstConstSet, + IconCstFunction, + IconCstPredicate, + IconCstStructured, + IconCstTerm, + IconCstTheorem, IconDestroy, IconMoveDown, IconMoveUp, @@ -19,10 +28,9 @@ import { prepareTooltip } from '@/utils/utils'; import { useMutatingRSForm } from '../../../backend/useMutatingRSForm'; import { getCstTypeShortcut, labelCstType } from '../../../labels'; -import { CstType } from '../../../models/rsform'; import { useRSEdit } from '../RSEditContext'; -function ToolbarRSList() { +export function ToolbarRSList() { const controller = useRSEdit(); const isProcessing = useMutatingRSForm(); const insertMenu = useDropdown(); @@ -107,4 +115,24 @@ function ToolbarRSList() { ); } -export default ToolbarRSList; +/** Icon for constituenta type. */ +function CstTypeIcon({ value, size = '1.25rem', className }: DomIconProps) { + switch (value) { + case CstType.BASE: + return ; + case CstType.CONSTANT: + return ; + case CstType.STRUCTURED: + return ; + case CstType.TERM: + return ; + case CstType.AXIOM: + return ; + case CstType.FUNCTION: + return ; + case CstType.PREDICATE: + return ; + case CstType.THEOREM: + return ; + } +} diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorTermGraph/TGFlow.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorTermGraph/TGFlow.tsx index 7dcbd8a4..8e6bdf92 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorTermGraph/TGFlow.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/EditorTermGraph/TGFlow.tsx @@ -27,11 +27,12 @@ import { APP_COLORS } from '@/styling/colors'; import { PARAMETER } from '@/utils/constants'; import { errorMsg } from '@/utils/labels'; +import { CstType } from '../../../backend/types'; import { useMutatingRSForm } from '../../../backend/useMutatingRSForm'; import { colorBgGraphNode } from '../../../colors'; import InfoConstituenta from '../../../components/InfoConstituenta'; import ToolbarGraphSelection from '../../../components/ToolbarGraphSelection'; -import { CstType, IConstituenta, IRSForm } from '../../../models/rsform'; +import { IConstituenta, IRSForm } from '../../../models/rsform'; import { isBasicConcept } from '../../../models/rsformAPI'; import { GraphFilterParams, useTermGraphStore } from '../../../stores/termGraph'; import { useRSEdit } from '../RSEditContext'; diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/MenuRSTabs.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/MenuRSTabs.tsx index 9949498a..c6e39f46 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/MenuRSTabs.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/MenuRSTabs.tsx @@ -4,7 +4,8 @@ import fileDownload from 'js-file-download'; import { urls, useConceptNavigation } from '@/app'; import { useAuthSuspense } from '@/features/auth'; -import { AccessPolicy, LocationHead } from '@/features/library/models/library'; +import { AccessPolicy } from '@/features/library'; +import { LocationHead } from '@/features/library/models/library'; import { useRoleStore, UserRole } from '@/features/users'; import { Divider } from '@/components/Container'; diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/RSEditContext.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/RSEditContext.tsx index c0430f8d..2d8517d6 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/RSEditContext.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/RSEditContext.tsx @@ -14,11 +14,11 @@ import { PARAMETER, prefixes } from '@/utils/constants'; import { promptText } from '@/utils/labels'; import { promptUnsaved } from '@/utils/utils'; -import { IConstituentaBasicsDTO, ICstCreateDTO } from '../../backend/types'; +import { CstType, IConstituentaBasicsDTO, ICstCreateDTO } from '../../backend/types'; import { useCstCreate } from '../../backend/useCstCreate'; import { useCstMove } from '../../backend/useCstMove'; import { useRSFormSuspense } from '../../backend/useRSForm'; -import { CstType, IConstituenta, IRSForm } from '../../models/rsform'; +import { IConstituenta, IRSForm } from '../../models/rsform'; import { generateAlias } from '../../models/rsformAPI'; export enum RSTabID { diff --git a/rsconcept/frontend/src/utils/labels.ts b/rsconcept/frontend/src/utils/labels.ts index 2a252451..ca907363 100644 --- a/rsconcept/frontend/src/utils/labels.ts +++ b/rsconcept/frontend/src/utils/labels.ts @@ -4,7 +4,7 @@ * Label is a short text used to represent an entity. * Description is a long description used in tooltips. */ -import { AccessPolicy, LibraryItemType } from '@/features/library/models/library'; +import { AccessPolicy, LibraryItemType } from '@/features/library/backend/types'; import { UserRole } from '@/features/users/stores/role'; /**