mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 04:50:36 +03:00
R: Refactor type definitions
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
This commit is contained in:
parent
6deedb3afd
commit
6e8192404f
|
@ -1,18 +1,10 @@
|
||||||
import { AccessPolicy, LibraryItemType, LocationHead } from '@/features/library/models/library';
|
import { LocationHead } from '@/features/library/models/library';
|
||||||
import { CstType, ExpressionStatus } from '@/features/rsform/models/rsform';
|
import { ExpressionStatus } from '@/features/rsform/models/rsform';
|
||||||
import { CstMatchMode, DependencyMode } from '@/features/rsform/stores/cstSearch';
|
import { CstMatchMode, DependencyMode } from '@/features/rsform/stores/cstSearch';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IconAlias,
|
IconAlias,
|
||||||
IconBusiness,
|
IconBusiness,
|
||||||
IconCstAxiom,
|
|
||||||
IconCstBaseSet,
|
|
||||||
IconCstConstSet,
|
|
||||||
IconCstFunction,
|
|
||||||
IconCstPredicate,
|
|
||||||
IconCstStructured,
|
|
||||||
IconCstTerm,
|
|
||||||
IconCstTheorem,
|
|
||||||
IconFilter,
|
IconFilter,
|
||||||
IconFormula,
|
IconFormula,
|
||||||
IconGraphCollapse,
|
IconGraphCollapse,
|
||||||
|
@ -22,12 +14,8 @@ import {
|
||||||
IconHide,
|
IconHide,
|
||||||
IconMoveDown,
|
IconMoveDown,
|
||||||
IconMoveUp,
|
IconMoveUp,
|
||||||
IconOSS,
|
|
||||||
IconPrivate,
|
|
||||||
IconProps,
|
IconProps,
|
||||||
IconProtected,
|
|
||||||
IconPublic,
|
IconPublic,
|
||||||
IconRSForm,
|
|
||||||
IconSettings,
|
IconSettings,
|
||||||
IconShow,
|
IconShow,
|
||||||
IconStatusError,
|
IconStatusError,
|
||||||
|
@ -45,28 +33,6 @@ export interface DomIconProps<RequestData> extends IconProps {
|
||||||
value: RequestData;
|
value: RequestData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Icon for library item type. */
|
|
||||||
export function ItemTypeIcon({ value, size = '1.25rem', className }: DomIconProps<LibraryItemType>) {
|
|
||||||
switch (value) {
|
|
||||||
case LibraryItemType.RSFORM:
|
|
||||||
return <IconRSForm size={size} className={className ?? 'text-sec-600'} />;
|
|
||||||
case LibraryItemType.OSS:
|
|
||||||
return <IconOSS size={size} className={className ?? 'text-ok-600'} />;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Icon for access policy. */
|
|
||||||
export function PolicyIcon({ value, size = '1.25rem', className }: DomIconProps<AccessPolicy>) {
|
|
||||||
switch (value) {
|
|
||||||
case AccessPolicy.PRIVATE:
|
|
||||||
return <IconPrivate size={size} className={className ?? 'text-warn-600'} />;
|
|
||||||
case AccessPolicy.PROTECTED:
|
|
||||||
return <IconProtected size={size} className={className ?? 'text-sec-600'} />;
|
|
||||||
case AccessPolicy.PUBLIC:
|
|
||||||
return <IconPublic size={size} className={className ?? 'text-ok-600'} />;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Icon for visibility. */
|
/** Icon for visibility. */
|
||||||
export function VisibilityIcon({ value, size = '1.25rem', className }: DomIconProps<boolean>) {
|
export function VisibilityIcon({ value, size = '1.25rem', className }: DomIconProps<boolean>) {
|
||||||
if (value) {
|
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<CstType>) {
|
|
||||||
switch (value) {
|
|
||||||
case CstType.BASE:
|
|
||||||
return <IconCstBaseSet size={size} className={className ?? 'text-ok-600'} />;
|
|
||||||
case CstType.CONSTANT:
|
|
||||||
return <IconCstConstSet size={size} className={className ?? 'text-ok-600'} />;
|
|
||||||
case CstType.STRUCTURED:
|
|
||||||
return <IconCstStructured size={size} className={className ?? 'text-ok-600'} />;
|
|
||||||
case CstType.TERM:
|
|
||||||
return <IconCstTerm size={size} className={className ?? 'text-sec-600'} />;
|
|
||||||
case CstType.AXIOM:
|
|
||||||
return <IconCstAxiom size={size} className={className ?? 'text-warn-600'} />;
|
|
||||||
case CstType.FUNCTION:
|
|
||||||
return <IconCstFunction size={size} className={className ?? 'text-sec-600'} />;
|
|
||||||
case CstType.PREDICATE:
|
|
||||||
return <IconCstPredicate size={size} className={className ?? 'text-warn-600'} />;
|
|
||||||
case CstType.THEOREM:
|
|
||||||
return <IconCstTheorem size={size} className={className ?? 'text-warn-600'} />;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Icon for relocation direction. */
|
/** Icon for relocation direction. */
|
||||||
export function RelocateUpIcon({ value, size = '1.25rem', className }: DomIconProps<boolean>) {
|
export function RelocateUpIcon({ value, size = '1.25rem', className }: DomIconProps<boolean>) {
|
||||||
if (value) {
|
if (value) {
|
||||||
|
|
|
@ -6,15 +6,16 @@ import { axiosDelete, axiosGet, axiosPatch, axiosPost } from '@/backend/apiTrans
|
||||||
import { DELAYS, KEYS } from '@/backend/configuration';
|
import { DELAYS, KEYS } from '@/backend/configuration';
|
||||||
import { infoMsg } from '@/utils/labels';
|
import { infoMsg } from '@/utils/labels';
|
||||||
|
|
||||||
import { AccessPolicy, ILibraryItem, IVersionInfo } from '../models/library';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
AccessPolicy,
|
||||||
ICloneLibraryItemDTO,
|
ICloneLibraryItemDTO,
|
||||||
ICreateLibraryItemDTO,
|
ICreateLibraryItemDTO,
|
||||||
|
ILibraryItem,
|
||||||
IRenameLocationDTO,
|
IRenameLocationDTO,
|
||||||
IUpdateLibraryItemDTO,
|
IUpdateLibraryItemDTO,
|
||||||
IVersionCreatedResponse,
|
IVersionCreatedResponse,
|
||||||
IVersionCreateDTO,
|
IVersionCreateDTO,
|
||||||
|
IVersionInfo,
|
||||||
IVersionUpdateDTO
|
IVersionUpdateDTO
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,46 @@ import { IRSFormDTO } from '@/features/rsform/backend/types';
|
||||||
|
|
||||||
import { errorMsg } from '@/utils/labels';
|
import { errorMsg } from '@/utils/labels';
|
||||||
|
|
||||||
import { AccessPolicy, LibraryItemType } from '../models/library';
|
|
||||||
import { validateLocation } from '../models/libraryAPI';
|
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.
|
* Represents update data for renaming Location.
|
||||||
*/
|
*/
|
||||||
|
@ -15,57 +52,13 @@ export interface IRenameLocationDTO {
|
||||||
new_location: string;
|
new_location: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Represents library item version information. */
|
||||||
* Represents data, used for cloning {@link IRSForm}.
|
export type IVersionInfo = z.infer<typeof schemaVersionInfo>;
|
||||||
*/
|
|
||||||
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()
|
/** Represents data, used for cloning {@link IRSForm}. */
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents data, used for cloning {@link IRSForm}.
|
|
||||||
*/
|
|
||||||
export type ICloneLibraryItemDTO = z.infer<typeof schemaCloneLibraryItem>;
|
export type ICloneLibraryItemDTO = z.infer<typeof schemaCloneLibraryItem>;
|
||||||
|
|
||||||
/**
|
/** Represents data, used for creating {@link IRSForm}. */
|
||||||
* 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}.
|
|
||||||
*/
|
|
||||||
export type ICreateLibraryItemDTO = z.infer<typeof schemaCreateLibraryItem>;
|
export type ICreateLibraryItemDTO = z.infer<typeof schemaCreateLibraryItem>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,16 +101,57 @@ export interface IVersionCreatedResponse {
|
||||||
schema: IRSFormDTO;
|
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<typeof schemaVersionUpdate>;
|
||||||
*/
|
|
||||||
|
// ======= 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({
|
export const schemaVersionUpdate = z.object({
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
version: z.string().nonempty(errorMsg.requiredField),
|
version: z.string().nonempty(errorMsg.requiredField),
|
||||||
description: z.string()
|
description: z.string()
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents version data, intended to update version metadata in persistent storage.
|
|
||||||
*/
|
|
||||||
export type IVersionUpdateDTO = z.infer<typeof schemaVersionUpdate>;
|
|
||||||
|
|
|
@ -5,9 +5,8 @@ import { IRSFormDTO } from '@/features/rsform/backend/types';
|
||||||
|
|
||||||
import { KEYS } from '@/backend/configuration';
|
import { KEYS } from '@/backend/configuration';
|
||||||
|
|
||||||
import { AccessPolicy, ILibraryItem } from '../models/library';
|
|
||||||
|
|
||||||
import { libraryApi } from './api';
|
import { libraryApi } from './api';
|
||||||
|
import { AccessPolicy, ILibraryItem } from './types';
|
||||||
|
|
||||||
export const useSetAccessPolicy = () => {
|
export const useSetAccessPolicy = () => {
|
||||||
const client = useQueryClient();
|
const client = useQueryClient();
|
||||||
|
|
|
@ -5,9 +5,8 @@ import { IRSFormDTO } from '@/features/rsform/backend/types';
|
||||||
|
|
||||||
import { KEYS } from '@/backend/configuration';
|
import { KEYS } from '@/backend/configuration';
|
||||||
|
|
||||||
import { ILibraryItem } from '../models/library';
|
|
||||||
|
|
||||||
import { libraryApi } from './api';
|
import { libraryApi } from './api';
|
||||||
|
import { ILibraryItem } from './types';
|
||||||
|
|
||||||
export const useSetLocation = () => {
|
export const useSetLocation = () => {
|
||||||
const client = useQueryClient();
|
const client = useQueryClient();
|
||||||
|
|
|
@ -5,9 +5,8 @@ import { IRSFormDTO } from '@/features/rsform/backend/types';
|
||||||
|
|
||||||
import { KEYS } from '@/backend/configuration';
|
import { KEYS } from '@/backend/configuration';
|
||||||
|
|
||||||
import { ILibraryItem } from '../models/library';
|
|
||||||
|
|
||||||
import { libraryApi } from './api';
|
import { libraryApi } from './api';
|
||||||
|
import { ILibraryItem } from './types';
|
||||||
|
|
||||||
export const useSetOwner = () => {
|
export const useSetOwner = () => {
|
||||||
const client = useQueryClient();
|
const client = useQueryClient();
|
||||||
|
|
|
@ -5,10 +5,8 @@ import { IRSFormDTO } from '@/features/rsform/backend/types';
|
||||||
|
|
||||||
import { KEYS } from '@/backend/configuration';
|
import { KEYS } from '@/backend/configuration';
|
||||||
|
|
||||||
import { ILibraryItem, LibraryItemType } from '../models/library';
|
|
||||||
|
|
||||||
import { libraryApi } from './api';
|
import { libraryApi } from './api';
|
||||||
import { IUpdateLibraryItemDTO } from './types';
|
import { ILibraryItem, IUpdateLibraryItemDTO, LibraryItemType } from './types';
|
||||||
|
|
||||||
export const useUpdateItem = () => {
|
export const useUpdateItem = () => {
|
||||||
const client = useQueryClient();
|
const client = useQueryClient();
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { ILibraryItem } from '../models/library';
|
|
||||||
|
|
||||||
import { libraryApi } from './api';
|
import { libraryApi } from './api';
|
||||||
|
import { ILibraryItem } from './types';
|
||||||
|
|
||||||
export function useUpdateTimestamp() {
|
export function useUpdateTimestamp() {
|
||||||
const client = useQueryClient();
|
const client = useQueryClient();
|
||||||
|
|
|
@ -23,10 +23,10 @@ import { useModificationStore } from '@/stores/modification';
|
||||||
import { prefixes } from '@/utils/constants';
|
import { prefixes } from '@/utils/constants';
|
||||||
import { promptText } from '@/utils/labels';
|
import { promptText } from '@/utils/labels';
|
||||||
|
|
||||||
|
import { ILibraryItemData } from '../backend/types';
|
||||||
import { useMutatingLibrary } from '../backend/useMutatingLibrary';
|
import { useMutatingLibrary } from '../backend/useMutatingLibrary';
|
||||||
import { useSetLocation } from '../backend/useSetLocation';
|
import { useSetLocation } from '../backend/useSetLocation';
|
||||||
import { useSetOwner } from '../backend/useSetOwner';
|
import { useSetOwner } from '../backend/useSetOwner';
|
||||||
import { ILibraryItemData } from '../models/library';
|
|
||||||
import { useLibrarySearchStore } from '../stores/librarySearch';
|
import { useLibrarySearchStore } from '../stores/librarySearch';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { CProps } from '@/components/props';
|
||||||
import { APP_COLORS } from '@/styling/colors';
|
import { APP_COLORS } from '@/styling/colors';
|
||||||
import { prefixes } from '@/utils/constants';
|
import { prefixes } from '@/utils/constants';
|
||||||
|
|
||||||
import { ILibraryItem, LibraryItemType } from '../models/library';
|
import { ILibraryItem, LibraryItemType } from '../backend/types';
|
||||||
import { matchLibraryItem } from '../models/libraryAPI';
|
import { matchLibraryItem } from '../models/libraryAPI';
|
||||||
|
|
||||||
import SelectLocation from './SelectLocation';
|
import SelectLocation from './SelectLocation';
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { MiniButton } from '@/components/Control';
|
import { MiniButton } from '@/components/Control';
|
||||||
import { PolicyIcon } from '@/components/DomainIcons';
|
import { DomIconProps } from '@/components/DomainIcons';
|
||||||
import { Dropdown, DropdownButton, useDropdown } from '@/components/Dropdown';
|
import { Dropdown, DropdownButton, useDropdown } from '@/components/Dropdown';
|
||||||
|
import { IconPrivate, IconProtected, IconPublic } from '@/components/Icons';
|
||||||
import { CProps } from '@/components/props';
|
import { CProps } from '@/components/props';
|
||||||
import { prefixes } from '@/utils/constants';
|
import { prefixes } from '@/utils/constants';
|
||||||
import { describeAccessPolicy, labelAccessPolicy } from '@/utils/labels';
|
import { describeAccessPolicy, labelAccessPolicy } from '@/utils/labels';
|
||||||
|
|
||||||
import { AccessPolicy } from '../models/library';
|
import { AccessPolicy } from '../backend/types';
|
||||||
|
|
||||||
interface SelectAccessPolicyProps extends CProps.Styling {
|
interface SelectAccessPolicyProps extends CProps.Styling {
|
||||||
value: AccessPolicy;
|
value: AccessPolicy;
|
||||||
|
@ -51,3 +52,15 @@ export function SelectAccessPolicy({ value, disabled, stretchLeft, onChange, ...
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Icon for access policy. */
|
||||||
|
function PolicyIcon({ value, size = '1.25rem', className }: DomIconProps<AccessPolicy>) {
|
||||||
|
switch (value) {
|
||||||
|
case AccessPolicy.PRIVATE:
|
||||||
|
return <IconPrivate size={size} className={className ?? 'text-warn-600'} />;
|
||||||
|
case AccessPolicy.PROTECTED:
|
||||||
|
return <IconProtected size={size} className={className ?? 'text-sec-600'} />;
|
||||||
|
case AccessPolicy.PUBLIC:
|
||||||
|
return <IconPublic size={size} className={className ?? 'text-ok-600'} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { SelectorButton } from '@/components/Control';
|
import { SelectorButton } from '@/components/Control';
|
||||||
import { ItemTypeIcon } from '@/components/DomainIcons';
|
import { DomIconProps } from '@/components/DomainIcons';
|
||||||
import { Dropdown, DropdownButton, useDropdown } from '@/components/Dropdown';
|
import { Dropdown, DropdownButton, useDropdown } from '@/components/Dropdown';
|
||||||
|
import { IconOSS, IconRSForm } from '@/components/Icons';
|
||||||
import { CProps } from '@/components/props';
|
import { CProps } from '@/components/props';
|
||||||
import { prefixes } from '@/utils/constants';
|
import { prefixes } from '@/utils/constants';
|
||||||
import { describeLibraryItemType, labelLibraryItemType } from '@/utils/labels';
|
import { describeLibraryItemType, labelLibraryItemType } from '@/utils/labels';
|
||||||
|
|
||||||
import { LibraryItemType } from '../models/library';
|
import { LibraryItemType } from '../backend/types';
|
||||||
|
|
||||||
interface SelectItemTypeProps extends CProps.Styling {
|
interface SelectItemTypeProps extends CProps.Styling {
|
||||||
value: LibraryItemType;
|
value: LibraryItemType;
|
||||||
|
@ -52,3 +53,13 @@ export function SelectItemType({ value, disabled, stretchLeft, onChange, ...rest
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Icon for library item type. */
|
||||||
|
function ItemTypeIcon({ value, size = '1.25rem', className }: DomIconProps<LibraryItemType>) {
|
||||||
|
switch (value) {
|
||||||
|
case LibraryItemType.RSFORM:
|
||||||
|
return <IconRSForm size={size} className={className ?? 'text-sec-600'} />;
|
||||||
|
case LibraryItemType.OSS:
|
||||||
|
return <IconOSS size={size} className={className ?? 'text-ok-600'} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import clsx from 'clsx';
|
||||||
import { SelectSingle } from '@/components/Input';
|
import { SelectSingle } from '@/components/Input';
|
||||||
import { CProps } from '@/components/props';
|
import { CProps } from '@/components/props';
|
||||||
|
|
||||||
import { ILibraryItem } from '../models/library';
|
import { ILibraryItem } from '../backend/types';
|
||||||
import { matchLibraryItem } from '../models/libraryAPI';
|
import { matchLibraryItem } from '../models/libraryAPI';
|
||||||
|
|
||||||
interface SelectLibraryItemProps extends CProps.Styling {
|
interface SelectLibraryItemProps extends CProps.Styling {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { SelectSingle } from '@/components/Input';
|
||||||
import { CProps } from '@/components/props';
|
import { CProps } from '@/components/props';
|
||||||
|
|
||||||
import { labelVersion } from '../../rsform/labels';
|
import { labelVersion } from '../../rsform/labels';
|
||||||
import { IVersionInfo } from '../models/library';
|
import { IVersionInfo } from '../backend/types';
|
||||||
|
|
||||||
interface SelectVersionProps extends CProps.Styling {
|
interface SelectVersionProps extends CProps.Styling {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
|
|
@ -8,9 +8,9 @@ import { IconImmutable, IconMutable } from '@/components/Icons';
|
||||||
import { Label } from '@/components/Input';
|
import { Label } from '@/components/Input';
|
||||||
import { PARAMETER } from '@/utils/constants';
|
import { PARAMETER } from '@/utils/constants';
|
||||||
|
|
||||||
|
import { AccessPolicy } from '../backend/types';
|
||||||
import { useMutatingLibrary } from '../backend/useMutatingLibrary';
|
import { useMutatingLibrary } from '../backend/useMutatingLibrary';
|
||||||
import { useSetAccessPolicy } from '../backend/useSetAccessPolicy';
|
import { useSetAccessPolicy } from '../backend/useSetAccessPolicy';
|
||||||
import { AccessPolicy } from '../models/library';
|
|
||||||
|
|
||||||
import { ILibraryItemEditor } from './EditorLibraryItem';
|
import { ILibraryItemEditor } from './EditorLibraryItem';
|
||||||
import { SelectAccessPolicy } from './SelectAccessPolicy';
|
import { SelectAccessPolicy } from './SelectAccessPolicy';
|
||||||
|
|
|
@ -13,12 +13,12 @@ import { Checkbox, Label, TextArea, TextInput } from '@/components/Input';
|
||||||
import { ModalForm } from '@/components/Modal';
|
import { ModalForm } from '@/components/Modal';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
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 { useCloneItem } from '../backend/useCloneItem';
|
||||||
import { SelectAccessPolicy } from '../components/SelectAccessPolicy';
|
import { SelectAccessPolicy } from '../components/SelectAccessPolicy';
|
||||||
import { SelectLocationContext } from '../components/SelectLocationContext';
|
import { SelectLocationContext } from '../components/SelectLocationContext';
|
||||||
import { SelectLocationHead } from '../components/SelectLocationHead';
|
import { SelectLocationHead } from '../components/SelectLocationHead';
|
||||||
import { AccessPolicy, ILibraryItem, LocationHead } from '../models/library';
|
import { LocationHead } from '../models/library';
|
||||||
import { cloneTitle, combineLocation } from '../models/libraryAPI';
|
import { cloneTitle, combineLocation } from '../models/libraryAPI';
|
||||||
|
|
||||||
export interface DlgCloneLibraryItemProps {
|
export interface DlgCloneLibraryItemProps {
|
||||||
|
|
|
@ -9,9 +9,8 @@ import { ModalForm } from '@/components/Modal';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
import { useDialogsStore } from '@/stores/dialogs';
|
||||||
import { errorMsg } from '@/utils/labels';
|
import { errorMsg } from '@/utils/labels';
|
||||||
|
|
||||||
import { IVersionCreateDTO, schemaVersionCreate } from '../backend/types';
|
import { IVersionCreateDTO, IVersionInfo, schemaVersionCreate } from '../backend/types';
|
||||||
import { useVersionCreate } from '../backend/useVersionCreate';
|
import { useVersionCreate } from '../backend/useVersionCreate';
|
||||||
import { IVersionInfo } from '../models/library';
|
|
||||||
import { nextVersion } from '../models/libraryAPI';
|
import { nextVersion } from '../models/libraryAPI';
|
||||||
|
|
||||||
export interface DlgCreateVersionProps {
|
export interface DlgCreateVersionProps {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import DataTable, { createColumnHelper, IConditionalStyle } from '@/components/D
|
||||||
import { IconRemove } from '@/components/Icons';
|
import { IconRemove } from '@/components/Icons';
|
||||||
import { APP_COLORS } from '@/styling/colors';
|
import { APP_COLORS } from '@/styling/colors';
|
||||||
|
|
||||||
import { IVersionInfo } from '../../models/library';
|
import { IVersionInfo } from '../../backend/types';
|
||||||
|
|
||||||
interface TableVersionsProps {
|
interface TableVersionsProps {
|
||||||
processing: boolean;
|
processing: boolean;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
export { AccessPolicy, type ILibraryItem, type IVersionInfo, LibraryItemType } from './backend/types';
|
||||||
export { useDeleteItem } from './backend/useDeleteItem';
|
export { useDeleteItem } from './backend/useDeleteItem';
|
||||||
export { useLibrary, useLibrarySuspense } from './backend/useLibrary';
|
export { useLibrary, useLibrarySuspense } from './backend/useLibrary';
|
||||||
export { useMutatingLibrary } from './backend/useMutatingLibrary';
|
export { useMutatingLibrary } from './backend/useMutatingLibrary';
|
||||||
|
@ -11,11 +12,5 @@ export { PickSchema } from './components/PickSchema';
|
||||||
export { SelectLibraryItem } from './components/SelectLibraryItem';
|
export { SelectLibraryItem } from './components/SelectLibraryItem';
|
||||||
export { SelectVersion } from './components/SelectVersion';
|
export { SelectVersion } from './components/SelectVersion';
|
||||||
export { ToolbarItemAccess } from './components/ToolbarItemAccess';
|
export { ToolbarItemAccess } from './components/ToolbarItemAccess';
|
||||||
export {
|
export { type ILibraryItemReference } from './models/library';
|
||||||
AccessPolicy,
|
|
||||||
type ILibraryItem,
|
|
||||||
type ILibraryItemReference,
|
|
||||||
type IVersionInfo,
|
|
||||||
LibraryItemType
|
|
||||||
} from './models/library';
|
|
||||||
export { useLibrarySearchStore } from './stores/librarySearch';
|
export { useLibrarySearchStore } from './stores/librarySearch';
|
||||||
|
|
|
@ -2,24 +2,7 @@
|
||||||
* Module: Models for LibraryItem.
|
* Module: Models for LibraryItem.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { z } from 'zod';
|
import { ILibraryItemData, IVersionInfo, LibraryItemType } from '../backend/types';
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 valid location headers.
|
* Represents valid location headers.
|
||||||
|
@ -33,43 +16,6 @@ export enum LocationHead {
|
||||||
|
|
||||||
export const BASIC_SCHEMAS = '/L/Базовые';
|
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<typeof schemaVersionInfo>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
* Represents {@link ILibraryItem} minimal reference data.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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';
|
import { matchLibraryItem, validateLocation } from './libraryAPI';
|
||||||
|
|
||||||
describe('Testing matching LibraryItem', () => {
|
describe('Testing matching LibraryItem', () => {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
import { limits } from '@/utils/constants';
|
import { limits } from '@/utils/constants';
|
||||||
import { TextMatcher } from '@/utils/utils';
|
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
|
const LOCATION_REGEXP = /^\/[PLUS]((\/[!\d\p{L}]([!\d\p{L}\- ]*[!\d\p{L}])?)*)?$/u; // cspell:disable-line
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,13 @@ import { InfoError } from '@/components/InfoError';
|
||||||
import { Label, TextArea, TextInput } from '@/components/Input';
|
import { Label, TextArea, TextInput } from '@/components/Input';
|
||||||
import { EXTEOR_TRS_FILE } from '@/utils/constants';
|
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 { useCreateItem } from '../../backend/useCreateItem';
|
||||||
import { SelectAccessPolicy } from '../../components/SelectAccessPolicy';
|
import { SelectAccessPolicy } from '../../components/SelectAccessPolicy';
|
||||||
import { SelectItemType } from '../../components/SelectItemType';
|
import { SelectItemType } from '../../components/SelectItemType';
|
||||||
import { SelectLocationContext } from '../../components/SelectLocationContext';
|
import { SelectLocationContext } from '../../components/SelectLocationContext';
|
||||||
import { SelectLocationHead } from '../../components/SelectLocationHead';
|
import { SelectLocationHead } from '../../components/SelectLocationHead';
|
||||||
import { AccessPolicy, LibraryItemType, LocationHead } from '../../models/library';
|
import { LocationHead } from '../../models/library';
|
||||||
import { combineLocation } from '../../models/libraryAPI';
|
import { combineLocation } from '../../models/libraryAPI';
|
||||||
import { useLibrarySearchStore } from '../../stores/librarySearch';
|
import { useLibrarySearchStore } from '../../stores/librarySearch';
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ import { useFitHeight } from '@/stores/appLayout';
|
||||||
import { usePreferencesStore } from '@/stores/preferences';
|
import { usePreferencesStore } from '@/stores/preferences';
|
||||||
import { APP_COLORS } from '@/styling/colors';
|
import { APP_COLORS } from '@/styling/colors';
|
||||||
|
|
||||||
|
import { ILibraryItem, LibraryItemType } from '../../backend/types';
|
||||||
import BadgeLocation from '../../components/BadgeLocation';
|
import BadgeLocation from '../../components/BadgeLocation';
|
||||||
import { ILibraryItem, LibraryItemType } from '../../models/library';
|
|
||||||
import { useLibrarySearchStore } from '../../stores/librarySearch';
|
import { useLibrarySearchStore } from '../../stores/librarySearch';
|
||||||
|
|
||||||
interface TableLibraryItemsProps {
|
interface TableLibraryItemsProps {
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
* Module: OSS data loading and processing.
|
* 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 { 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}.
|
* Loads data into an {@link IOperationSchema} based on {@link IOperationSchemaDTO}.
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { queryOptions } from '@tanstack/react-query';
|
import { queryOptions } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { ITargetCst } from '@/features/rsform/backend/types';
|
import { ITargetCst } from '@/features/rsform/backend/types';
|
||||||
import { IConstituentaReference } from '@/features/rsform/models/rsform';
|
|
||||||
|
|
||||||
import { axiosGet, axiosPatch, axiosPost } from '@/backend/apiTransport';
|
import { axiosGet, axiosPatch, axiosPost } from '@/backend/apiTransport';
|
||||||
import { DELAYS, KEYS } from '@/backend/configuration';
|
import { DELAYS, KEYS } from '@/backend/configuration';
|
||||||
import { infoMsg } from '@/utils/labels';
|
import { infoMsg } from '@/utils/labels';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
IConstituentaReference,
|
||||||
ICstRelocateDTO,
|
ICstRelocateDTO,
|
||||||
IInputCreatedResponse,
|
IInputCreatedResponse,
|
||||||
IInputUpdateDTO,
|
IInputUpdateDTO,
|
||||||
|
|
|
@ -1,9 +1,57 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { ILibraryItem, ILibraryItemData } from '@/features/library/models/library';
|
import { ILibraryItem, ILibraryItemData } from '@/features/library/backend/types';
|
||||||
import { schemaCstSubstitute } from '@/features/rsform/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.
|
* Represents {@link IOperation} data from server.
|
||||||
|
@ -19,41 +67,10 @@ export interface IOperationSchemaDTO extends ILibraryItemData {
|
||||||
substitutions: ICstSubstituteEx[];
|
substitutions: ICstSubstituteEx[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Represents {@link IOperation} position. */
|
||||||
* Represents {@link IOperation} position.
|
|
||||||
*/
|
|
||||||
export const schemaOperationPosition = z.object({
|
|
||||||
id: z.number(),
|
|
||||||
position_x: z.number(),
|
|
||||||
position_y: z.number()
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents {@link IOperation} position.
|
|
||||||
*/
|
|
||||||
export type IOperationPosition = z.infer<typeof schemaOperationPosition>;
|
export type IOperationPosition = z.infer<typeof schemaOperationPosition>;
|
||||||
|
|
||||||
/**
|
/** Represents {@link IOperation} data, used in creation process. */
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
export type IOperationCreateDTO = z.infer<typeof schemaOperationCreate>;
|
export type IOperationCreateDTO = z.infer<typeof schemaOperationCreate>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,19 +89,7 @@ export interface ITargetOperation {
|
||||||
target: number;
|
target: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Represents {@link IOperation} data, used in destruction process. */
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
export type IOperationDeleteDTO = z.infer<typeof schemaOperationDelete>;
|
export type IOperationDeleteDTO = z.infer<typeof schemaOperationDelete>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,38 +100,10 @@ export interface IInputCreatedResponse {
|
||||||
oss: IOperationSchemaDTO;
|
oss: IOperationSchemaDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Represents {@link IOperation} data, used in setInput process. */
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
export type IInputUpdateDTO = z.infer<typeof schemaInputUpdate>;
|
export type IInputUpdateDTO = z.infer<typeof schemaInputUpdate>;
|
||||||
|
|
||||||
/**
|
/** Represents {@link IOperation} data, used in update process. */
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
export type IOperationUpdateDTO = z.infer<typeof schemaOperationUpdate>;
|
export type IOperationUpdateDTO = z.infer<typeof schemaOperationUpdate>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,3 +118,59 @@ export const schemaCstRelocate = z.object({
|
||||||
* Represents data, used relocating {@link IConstituenta}s between {@link ILibraryItem}s.
|
* Represents data, used relocating {@link IConstituenta}s between {@link ILibraryItem}s.
|
||||||
*/
|
*/
|
||||||
export type ICstRelocateDTO = z.infer<typeof schemaCstRelocate>;
|
export type ICstRelocateDTO = z.infer<typeof schemaCstRelocate>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
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';
|
import { KEYS } from '@/backend/configuration';
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { IconMoveDown, IconMoveUp, IconRemove } from '@/components/Icons';
|
||||||
import { CProps } from '@/components/props';
|
import { CProps } from '@/components/props';
|
||||||
import { NoData } from '@/components/View';
|
import { NoData } from '@/components/View';
|
||||||
|
|
||||||
import { IOperation } from '../models/oss';
|
import { IOperation } from '../backend/types';
|
||||||
|
|
||||||
import SelectOperation from './SelectOperation';
|
import SelectOperation from './SelectOperation';
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import clsx from 'clsx';
|
||||||
import { SelectSingle } from '@/components/Input';
|
import { SelectSingle } from '@/components/Input';
|
||||||
import { CProps } from '@/components/props';
|
import { CProps } from '@/components/props';
|
||||||
|
|
||||||
import { IOperation } from '../models/oss';
|
import { IOperation } from '../backend/types';
|
||||||
import { matchOperation } from '../models/ossAPI';
|
import { matchOperation } from '../models/ossAPI';
|
||||||
|
|
||||||
interface SelectOperationProps extends CProps.Styling {
|
interface SelectOperationProps extends CProps.Styling {
|
||||||
|
|
|
@ -6,8 +6,8 @@ import { Tooltip } from '@/components/Container';
|
||||||
import DataTable from '@/components/DataTable';
|
import DataTable from '@/components/DataTable';
|
||||||
import { IconPageRight } from '@/components/Icons';
|
import { IconPageRight } from '@/components/Icons';
|
||||||
|
|
||||||
|
import { ICstSubstituteEx, OperationType } from '../backend/types';
|
||||||
import { labelOperationType } from '../labels';
|
import { labelOperationType } from '../labels';
|
||||||
import { ICstSubstituteEx, OperationType } from '../models/oss';
|
|
||||||
import { OssNodeInternal } from '../models/ossLayout';
|
import { OssNodeInternal } from '../models/ossLayout';
|
||||||
|
|
||||||
interface TooltipOperationProps {
|
interface TooltipOperationProps {
|
||||||
|
|
|
@ -12,9 +12,9 @@ import { Label } from '@/components/Input';
|
||||||
import { ModalForm } from '@/components/Modal';
|
import { ModalForm } from '@/components/Modal';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
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 { useInputUpdate } from '../backend/useInputUpdate';
|
||||||
import { IOperation, IOperationSchema } from '../models/oss';
|
import { IOperationSchema } from '../models/oss';
|
||||||
import { sortItemsForOSS } from '../models/ossAPI';
|
import { sortItemsForOSS } from '../models/ossAPI';
|
||||||
|
|
||||||
export interface DlgChangeInputSchemaProps {
|
export interface DlgChangeInputSchemaProps {
|
||||||
|
|
|
@ -11,10 +11,10 @@ import { ModalForm } from '@/components/Modal';
|
||||||
import { TabLabel, TabList, TabPanel, Tabs } from '@/components/Tabs';
|
import { TabLabel, TabList, TabPanel, Tabs } from '@/components/Tabs';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
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 { useOperationCreate } from '../../backend/useOperationCreate';
|
||||||
import { describeOperationType, labelOperationType } from '../../labels';
|
import { describeOperationType, labelOperationType } from '../../labels';
|
||||||
import { IOperationSchema, OperationType } from '../../models/oss';
|
import { IOperationSchema } from '../../models/oss';
|
||||||
import { calculateInsertPosition } from '../../models/ossAPI';
|
import { calculateInsertPosition } from '../../models/ossAPI';
|
||||||
|
|
||||||
import TabInputOperation from './TabInputOperation';
|
import TabInputOperation from './TabInputOperation';
|
||||||
|
|
|
@ -10,9 +10,9 @@ import { Checkbox, TextInput } from '@/components/Input';
|
||||||
import { ModalForm } from '@/components/Modal';
|
import { ModalForm } from '@/components/Modal';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
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 { useOperationDelete } from '../backend/useOperationDelete';
|
||||||
import { IOperation, IOperationSchema } from '../models/oss';
|
import { IOperationSchema } from '../models/oss';
|
||||||
|
|
||||||
export interface DlgDeleteOperationProps {
|
export interface DlgDeleteOperationProps {
|
||||||
oss: IOperationSchema;
|
oss: IOperationSchema;
|
||||||
|
|
|
@ -12,9 +12,15 @@ import { ModalForm } from '@/components/Modal';
|
||||||
import { TabLabel, TabList, TabPanel, Tabs } from '@/components/Tabs';
|
import { TabLabel, TabList, TabPanel, Tabs } from '@/components/Tabs';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
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 { useOperationUpdate } from '../../backend/useOperationUpdate';
|
||||||
import { IOperation, IOperationSchema, OperationType } from '../../models/oss';
|
import { IOperationSchema } from '../../models/oss';
|
||||||
|
|
||||||
import TabArguments from './TabArguments';
|
import TabArguments from './TabArguments';
|
||||||
import TabOperation from './TabOperation';
|
import TabOperation from './TabOperation';
|
||||||
|
|
|
@ -15,10 +15,10 @@ import { Loader } from '@/components/Loader';
|
||||||
import { ModalForm } from '@/components/Modal';
|
import { ModalForm } from '@/components/Modal';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
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 { useRelocateConstituents } from '../backend/useRelocateConstituents';
|
||||||
import { useUpdatePositions } from '../backend/useUpdatePositions';
|
import { useUpdatePositions } from '../backend/useUpdatePositions';
|
||||||
import { IOperation, IOperationSchema } from '../models/oss';
|
import { IOperationSchema } from '../models/oss';
|
||||||
import { getRelocateCandidates } from '../models/ossAPI';
|
import { getRelocateCandidates } from '../models/ossAPI';
|
||||||
|
|
||||||
export interface DlgRelocateConstituentsProps {
|
export interface DlgRelocateConstituentsProps {
|
||||||
|
|
|
@ -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}.
|
* Retrieves label for {@link OperationType}.
|
||||||
|
|
|
@ -1,60 +1,12 @@
|
||||||
/**
|
/**
|
||||||
* Module: Schema of Synthesis Operations.
|
* 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';
|
import { Graph } from '@/models/Graph';
|
||||||
|
|
||||||
/**
|
import { IArgument, ICstSubstituteEx, IOperation } from '../backend/types';
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents {@link IOperationSchema} statistics.
|
* Represents {@link IOperationSchema} statistics.
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
* Module: API for OperationSystem.
|
* Module: API for OperationSystem.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ILibraryItem } from '@/features/library/models/library';
|
import { ILibraryItem } from '@/features/library/backend/types';
|
||||||
import { CstClass, CstType, IConstituenta, IRSForm } from '@/features/rsform';
|
import { CstType, ICstSubstitute, ParsingStatus } from '@/features/rsform/backend/types';
|
||||||
import { ICstSubstitute } from '@/features/rsform/backend/types';
|
import { CstClass, IConstituenta, IRSForm } from '@/features/rsform/models/rsform';
|
||||||
import { AliasMapping, ParsingStatus } from '@/features/rsform/models/rslang';
|
import { AliasMapping } from '@/features/rsform/models/rslang';
|
||||||
import {
|
import {
|
||||||
applyAliasMapping,
|
applyAliasMapping,
|
||||||
applyTypificationMapping,
|
applyTypificationMapping,
|
||||||
|
@ -18,10 +18,10 @@ import { infoMsg } from '@/utils/labels';
|
||||||
import { TextMatcher } from '@/utils/utils';
|
import { TextMatcher } from '@/utils/utils';
|
||||||
|
|
||||||
import { Graph } from '../../../models/Graph';
|
import { Graph } from '../../../models/Graph';
|
||||||
import { IOperationPosition } from '../backend/types';
|
import { IOperation, IOperationPosition, OperationType } from '../backend/types';
|
||||||
import { describeSubstitutionError } from '../labels';
|
import { describeSubstitutionError } from '../labels';
|
||||||
|
|
||||||
import { IOperation, IOperationSchema, OperationType, SubstitutionErrorType } from './oss';
|
import { IOperationSchema, SubstitutionErrorType } from './oss';
|
||||||
import { Position2D } from './ossLayout';
|
import { Position2D } from './ossLayout';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import { Node } from 'reactflow';
|
import { Node } from 'reactflow';
|
||||||
|
|
||||||
import { IOperation } from './oss';
|
import { IOperation } from '../backend/types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents XY Position.
|
* Represents XY Position.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,8 +16,8 @@ import useClickedOutside from '@/hooks/useClickedOutside';
|
||||||
import { PARAMETER } from '@/utils/constants';
|
import { PARAMETER } from '@/utils/constants';
|
||||||
import { prepareTooltip } from '@/utils/utils';
|
import { prepareTooltip } from '@/utils/utils';
|
||||||
|
|
||||||
|
import { IOperation, OperationType } from '../../../backend/types';
|
||||||
import { useMutatingOss } from '../../../backend/useMutatingOss';
|
import { useMutatingOss } from '../../../backend/useMutatingOss';
|
||||||
import { IOperation, OperationType } from '../../../models/oss';
|
|
||||||
import { useOssEdit } from '../OssEditContext';
|
import { useOssEdit } from '../OssEditContext';
|
||||||
|
|
||||||
export interface ContextMenuData {
|
export interface ContextMenuData {
|
||||||
|
|
|
@ -24,8 +24,8 @@ import { useModificationStore } from '@/stores/modification';
|
||||||
import { PARAMETER } from '@/utils/constants';
|
import { PARAMETER } from '@/utils/constants';
|
||||||
import { prepareTooltip } from '@/utils/utils';
|
import { prepareTooltip } from '@/utils/utils';
|
||||||
|
|
||||||
|
import { OperationType } from '../../../backend/types';
|
||||||
import { useMutatingOss } from '../../../backend/useMutatingOss';
|
import { useMutatingOss } from '../../../backend/useMutatingOss';
|
||||||
import { OperationType } from '../../../models/oss';
|
|
||||||
import { useOSSGraphStore } from '../../../stores/ossGraph';
|
import { useOSSGraphStore } from '../../../stores/ossGraph';
|
||||||
import { useOssEdit } from '../OssEditContext';
|
import { useOssEdit } from '../OssEditContext';
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ import { Indicator } from '@/components/View';
|
||||||
import { PARAMETER, prefixes } from '@/utils/constants';
|
import { PARAMETER, prefixes } from '@/utils/constants';
|
||||||
import { truncateToLastWord } from '@/utils/utils';
|
import { truncateToLastWord } from '@/utils/utils';
|
||||||
|
|
||||||
|
import { OperationType } from '../../../../backend/types';
|
||||||
import TooltipOperation from '../../../../components/TooltipOperation';
|
import TooltipOperation from '../../../../components/TooltipOperation';
|
||||||
import { OperationType } from '../../../../models/oss';
|
|
||||||
import { OssNodeInternal } from '../../../../models/ossLayout';
|
import { OssNodeInternal } from '../../../../models/ossLayout';
|
||||||
import { useOssEdit } from '../../OssEditContext';
|
import { useOssEdit } from '../../OssEditContext';
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@ import { useDialogsStore } from '@/stores/dialogs';
|
||||||
import { usePreferencesStore } from '@/stores/preferences';
|
import { usePreferencesStore } from '@/stores/preferences';
|
||||||
import { promptText } from '@/utils/labels';
|
import { promptText } from '@/utils/labels';
|
||||||
|
|
||||||
import { IOperationPosition } from '../../backend/types';
|
import { IOperationPosition, OperationType } from '../../backend/types';
|
||||||
import { useOssSuspense } from '../../backend/useOSS';
|
import { useOssSuspense } from '../../backend/useOSS';
|
||||||
import { IOperationSchema, OperationType } from '../../models/oss';
|
import { IOperationSchema } from '../../models/oss';
|
||||||
|
|
||||||
export enum OssTabID {
|
export enum OssTabID {
|
||||||
CARD = 0,
|
CARD = 0,
|
||||||
|
|
|
@ -4,12 +4,11 @@
|
||||||
|
|
||||||
import { Graph } from '@/models/Graph';
|
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 { inferClass, inferStatus, inferTemplate, isBaseSet, isFunctional } from '../models/rsformAPI';
|
||||||
import { ParsingStatus, ValueClass } from '../models/rslang';
|
|
||||||
import { extractGlobals, isSimpleExpression, splitTemplateDefinition } from '../models/rslangAPI';
|
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}.
|
* Loads data into an {@link IRSForm} based on {@link IRSFormDTO}.
|
||||||
|
|
|
@ -4,11 +4,10 @@ import { axiosGet, axiosPatch, axiosPost } from '@/backend/apiTransport';
|
||||||
import { DELAYS, KEYS } from '@/backend/configuration';
|
import { DELAYS, KEYS } from '@/backend/configuration';
|
||||||
import { infoMsg } from '@/utils/labels';
|
import { infoMsg } from '@/utils/labels';
|
||||||
|
|
||||||
import { IConstituentaList } from '../models/rsform';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ICheckConstituentaDTO,
|
ICheckConstituentaDTO,
|
||||||
IConstituentaBasicsDTO,
|
IConstituentaBasicsDTO,
|
||||||
|
IConstituentaList,
|
||||||
ICstCreatedResponse,
|
ICstCreatedResponse,
|
||||||
ICstCreateDTO,
|
ICstCreateDTO,
|
||||||
ICstMoveDTO,
|
ICstMoveDTO,
|
||||||
|
|
|
@ -1,11 +1,41 @@
|
||||||
import { z } from 'zod';
|
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 { errorMsg } from '@/utils/labels';
|
||||||
|
|
||||||
import { CstType } from '../models/rsform';
|
/** Represents {@link IConstituenta} type. */
|
||||||
import { ParsingStatus, RSErrorType, Syntax, TokenID, ValueClass } from '../models/rslang';
|
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. */
|
/** Represents Constituenta basic persistent data. */
|
||||||
export type IConstituentaBasicsDTO = z.infer<typeof schemaConstituentaBasics>;
|
export type IConstituentaBasicsDTO = z.infer<typeof schemaConstituentaBasics>;
|
||||||
|
@ -66,12 +96,177 @@ export interface ICheckConstituentaDTO {
|
||||||
/** Represents data, used in merging multiple {@link IConstituenta}. */
|
/** Represents data, used in merging multiple {@link IConstituenta}. */
|
||||||
export type ICstSubstitutionsDTO = z.infer<typeof schemaCstSubstitutions>;
|
export type ICstSubstitutionsDTO = z.infer<typeof schemaCstSubstitutions>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents Constituenta list.
|
||||||
|
*/
|
||||||
|
export interface IConstituentaList {
|
||||||
|
items: number[];
|
||||||
|
}
|
||||||
|
|
||||||
/** Represents parsing error description. */
|
/** Represents parsing error description. */
|
||||||
export type IRSErrorDescription = z.infer<typeof schemaRSErrorDescription>;
|
export type IRSErrorDescription = z.infer<typeof schemaRSErrorDescription>;
|
||||||
|
|
||||||
/** Represents results of expression parse in RSLang. */
|
/** Represents results of expression parse in RSLang. */
|
||||||
export type IExpressionParseDTO = z.infer<typeof schemaExpressionParse>;
|
export type IExpressionParseDTO = z.infer<typeof schemaExpressionParse>;
|
||||||
|
|
||||||
|
/** 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 ========
|
// ========= SCHEMAS ========
|
||||||
export const schemaConstituentaBasics = z.object({
|
export const schemaConstituentaBasics = z.object({
|
||||||
id: z.coerce.number(),
|
id: z.coerce.number(),
|
||||||
|
|
|
@ -4,9 +4,8 @@ import { useUpdateTimestamp } from '@/features/library';
|
||||||
|
|
||||||
import { KEYS } from '@/backend/configuration';
|
import { KEYS } from '@/backend/configuration';
|
||||||
|
|
||||||
import { IConstituentaList } from '../models/rsform';
|
|
||||||
|
|
||||||
import { rsformsApi } from './api';
|
import { rsformsApi } from './api';
|
||||||
|
import { IConstituentaList } from './types';
|
||||||
|
|
||||||
export const useCstDelete = () => {
|
export const useCstDelete = () => {
|
||||||
const client = useQueryClient();
|
const client = useQueryClient();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
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';
|
import { KEYS } from '@/backend/configuration';
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import { APP_COLORS } from '@/styling/colors';
|
import { APP_COLORS } from '@/styling/colors';
|
||||||
import { PARAMETER } from '@/utils/constants';
|
import { PARAMETER } from '@/utils/constants';
|
||||||
|
|
||||||
|
import { TokenID } from './backend/types';
|
||||||
import { GramData, Grammeme, NounGrams, PartOfSpeech, VerbGrams } from './models/language';
|
import { GramData, Grammeme, NounGrams, PartOfSpeech, VerbGrams } from './models/language';
|
||||||
import { CstClass, ExpressionStatus, IConstituenta } from './models/rsform';
|
import { CstClass, ExpressionStatus, IConstituenta } from './models/rsform';
|
||||||
import { ISyntaxTreeNode, TokenID } from './models/rslang';
|
import { ISyntaxTreeNode } from './models/rslang';
|
||||||
import { TMGraphNode } from './models/TMGraph';
|
import { TMGraphNode } from './models/TMGraph';
|
||||||
import { GraphColoring } from './stores/termGraph';
|
import { GraphColoring } from './stores/termGraph';
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ interface RSInputProps
|
||||||
onOpenEdit?: (cstID: number) => void;
|
onOpenEdit?: (cstID: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RSInput = forwardRef<ReactCodeMirrorRef, RSInputProps>(
|
export const RSInput = forwardRef<ReactCodeMirrorRef, RSInputProps>(
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
id, //
|
id, //
|
||||||
|
@ -176,8 +176,6 @@ const RSInput = forwardRef<ReactCodeMirrorRef, RSInputProps>(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export default RSInput;
|
|
||||||
|
|
||||||
// ======= Internal ==========
|
// ======= Internal ==========
|
||||||
const editorSetup: BasicSetupOptions = {
|
const editorSetup: BasicSetupOptions = {
|
||||||
highlightSpecialChars: false,
|
highlightSpecialChars: false,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export { default } from './RSInput';
|
export { RSInput } from './RSInput';
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { ReactCodeMirrorRef } from '@uiw/react-codemirror';
|
||||||
|
|
||||||
import { CodeMirrorWrapper } from '@/utils/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 {
|
export function getSymbolSubstitute(keyCode: string, shiftPressed: boolean): string | undefined {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { SelectSingle } from '@/components/Input';
|
import { SelectSingle } from '@/components/Input';
|
||||||
import { CProps } from '@/components/props';
|
import { CProps } from '@/components/props';
|
||||||
|
|
||||||
|
import { CstType } from '../backend/types';
|
||||||
import { labelCstType } from '../labels';
|
import { labelCstType } from '../labels';
|
||||||
import { CstType } from '../models/rsform';
|
|
||||||
|
|
||||||
const SelectorCstType = Object.values(CstType).map(typeStr => ({
|
const SelectorCstType = Object.values(CstType).map(typeStr => ({
|
||||||
value: typeStr as CstType,
|
value: typeStr as CstType,
|
||||||
|
|
|
@ -9,10 +9,10 @@ import { BadgeHelp, HelpTopic } from '@/features/help';
|
||||||
import { TextArea, TextInput } from '@/components/Input';
|
import { TextArea, TextInput } from '@/components/Input';
|
||||||
import { PARAMETER } from '@/utils/constants';
|
import { PARAMETER } from '@/utils/constants';
|
||||||
|
|
||||||
import { ICstCreateDTO } from '../../backend/types';
|
import { CstType, ICstCreateDTO } from '../../backend/types';
|
||||||
import RSInput from '../../components/RSInput';
|
import { RSInput } from '../../components/RSInput';
|
||||||
import { SelectCstType } from '../../components/SelectCstType';
|
import { SelectCstType } from '../../components/SelectCstType';
|
||||||
import { CstType, IRSForm } from '../../models/rsform';
|
import { IRSForm } from '../../models/rsform';
|
||||||
import { generateAlias, isBaseSet, isBasicConcept, isFunctional } from '../../models/rsformAPI';
|
import { generateAlias, isBaseSet, isBasicConcept, isFunctional } from '../../models/rsformAPI';
|
||||||
|
|
||||||
interface FormCreateCstProps {
|
interface FormCreateCstProps {
|
||||||
|
|
|
@ -12,9 +12,9 @@ import { ModalForm } from '@/components/Modal';
|
||||||
import { TabLabel, TabList, TabPanel, Tabs } from '@/components/Tabs';
|
import { TabLabel, TabList, TabPanel, Tabs } from '@/components/Tabs';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
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 { useCstCreate } from '../../backend/useCstCreate';
|
||||||
import { CstType, IRSForm } from '../../models/rsform';
|
import { IRSForm } from '../../models/rsform';
|
||||||
import { generateAlias, validateNewAlias } from '../../models/rsformAPI';
|
import { generateAlias, validateNewAlias } from '../../models/rsformAPI';
|
||||||
import FormCreateCst from '../DlgCreateCst/FormCreateCst';
|
import FormCreateCst from '../DlgCreateCst/FormCreateCst';
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { APP_COLORS } from '@/styling/colors';
|
||||||
|
|
||||||
import { ICstCreateDTO } from '../../backend/types';
|
import { ICstCreateDTO } from '../../backend/types';
|
||||||
import { PickConstituenta } from '../../components/PickConstituenta';
|
import { PickConstituenta } from '../../components/PickConstituenta';
|
||||||
import RSInput from '../../components/RSInput';
|
import { RSInput } from '../../components/RSInput';
|
||||||
import { IConstituenta } from '../../models/rsform';
|
import { IConstituenta } from '../../models/rsform';
|
||||||
import { IArgumentValue } from '../../models/rslang';
|
import { IArgumentValue } from '../../models/rslang';
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { SelectSingle, TextArea } from '@/components/Input';
|
||||||
|
|
||||||
import { useRSForm } from '../../backend/useRSForm';
|
import { useRSForm } from '../../backend/useRSForm';
|
||||||
import { PickConstituenta } from '../../components/PickConstituenta';
|
import { PickConstituenta } from '../../components/PickConstituenta';
|
||||||
import RSInput from '../../components/RSInput';
|
import { RSInput } from '../../components/RSInput';
|
||||||
import { CATEGORY_CST_TYPE } from '../../models/rsform';
|
import { CATEGORY_CST_TYPE } from '../../models/rsform';
|
||||||
import { applyFilterCategory } from '../../models/rsformAPI';
|
import { applyFilterCategory } from '../../models/rsformAPI';
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import { Controller, useForm } from 'react-hook-form';
|
||||||
import { Checkbox } from '@/components/Input';
|
import { Checkbox } from '@/components/Input';
|
||||||
import { ModalForm } from '@/components/Modal';
|
import { ModalForm } from '@/components/Modal';
|
||||||
|
|
||||||
|
import { CstType } from '../backend/types';
|
||||||
import { labelCstType } from '../labels';
|
import { labelCstType } from '../labels';
|
||||||
import { CstType } from '../models/rsform';
|
|
||||||
import { GraphFilterParams, useTermGraphStore } from '../stores/termGraph';
|
import { GraphFilterParams, useTermGraphStore } from '../stores/termGraph';
|
||||||
|
|
||||||
function DlgGraphParams() {
|
function DlgGraphParams() {
|
||||||
|
|
|
@ -10,10 +10,10 @@ import { TextInput } from '@/components/Input';
|
||||||
import { ModalForm } from '@/components/Modal';
|
import { ModalForm } from '@/components/Modal';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
import { useDialogsStore } from '@/stores/dialogs';
|
||||||
|
|
||||||
import { ICstRenameDTO, schemaCstRename } from '../backend/types';
|
import { CstType, ICstRenameDTO, schemaCstRename } from '../backend/types';
|
||||||
import { useCstRename } from '../backend/useCstRename';
|
import { useCstRename } from '../backend/useCstRename';
|
||||||
import { SelectCstType } from '../components/SelectCstType';
|
import { SelectCstType } from '../components/SelectCstType';
|
||||||
import { CstType, IConstituenta, IRSForm } from '../models/rsform';
|
import { IConstituenta, IRSForm } from '../models/rsform';
|
||||||
import { generateAlias, validateNewAlias } from '../models/rsformAPI';
|
import { generateAlias, validateNewAlias } from '../models/rsformAPI';
|
||||||
|
|
||||||
export interface DlgRenameCstProps {
|
export interface DlgRenameCstProps {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
export { type ICstSubstitute } from './backend/types';
|
export { type ICstSubstitute } from './backend/types';
|
||||||
|
export { CstType } from './backend/types';
|
||||||
export { useRSForm, useRSFormSuspense } from './backend/useRSForm';
|
export { useRSForm, useRSFormSuspense } from './backend/useRSForm';
|
||||||
export { useRSForms } from './backend/useRSForms';
|
export { useRSForms } from './backend/useRSForms';
|
||||||
export { PickMultiConstituenta } from './components/PickMultiConstituenta';
|
export { PickMultiConstituenta } from './components/PickMultiConstituenta';
|
||||||
export { PickSubstitutions } from './components/PickSubstitutions';
|
export { PickSubstitutions } from './components/PickSubstitutions';
|
||||||
export { ToolbarRSFormCard } from './components/ToolbarRSFormCard';
|
export { ToolbarRSFormCard } from './components/ToolbarRSFormCard';
|
||||||
export { CstClass, CstType, type IConstituenta, type IRSForm } from './models/rsform';
|
export { CstClass, type IConstituenta, type IRSForm } from './models/rsform';
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
import { PARAMETER } from '@/utils/constants';
|
import { PARAMETER } from '@/utils/constants';
|
||||||
import { prepareTooltip } from '@/utils/utils';
|
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 { GramData, Grammeme, ReferenceType } from './models/language';
|
||||||
import { CstClass, CstType, ExpressionStatus, IConstituenta, IRSForm } from './models/rsform';
|
import { CstClass, ExpressionStatus, IConstituenta, IRSForm } from './models/rsform';
|
||||||
import { IArgumentInfo, ISyntaxTreeNode, ParsingStatus, RSErrorType, TokenID } from './models/rslang';
|
import { IArgumentInfo, ISyntaxTreeNode } from './models/rslang';
|
||||||
import { CstMatchMode, DependencyMode } from './stores/cstSearch';
|
import { CstMatchMode, DependencyMode } from './stores/cstSearch';
|
||||||
import { GraphColoring } from './stores/termGraph';
|
import { GraphColoring } from './stores/termGraph';
|
||||||
|
|
||||||
|
|
|
@ -6,21 +6,9 @@ import { ILibraryItemReference, ILibraryItemVersioned } from '@/features/library
|
||||||
|
|
||||||
import { Graph } from '@/models/Graph';
|
import { Graph } from '@/models/Graph';
|
||||||
|
|
||||||
import { IArgumentInfo, ParsingStatus, ValueClass } from './rslang';
|
import { CstType, ParsingStatus, ValueClass } from '../backend/types';
|
||||||
|
|
||||||
/**
|
import { IArgumentInfo } from './rslang';
|
||||||
* Represents {@link IConstituenta} type.
|
|
||||||
*/
|
|
||||||
export enum CstType {
|
|
||||||
BASE = 'basic',
|
|
||||||
STRUCTURED = 'structure',
|
|
||||||
TERM = 'term',
|
|
||||||
AXIOM = 'axiom',
|
|
||||||
FUNCTION = 'function',
|
|
||||||
PREDICATE = 'predicate',
|
|
||||||
CONSTANT = 'constant',
|
|
||||||
THEOREM = 'theorem'
|
|
||||||
}
|
|
||||||
|
|
||||||
// CstType constant for category dividers in TemplateSchemas
|
// CstType constant for category dividers in TemplateSchemas
|
||||||
export const CATEGORY_CST_TYPE = CstType.THEOREM;
|
export const CATEGORY_CST_TYPE = CstType.THEOREM;
|
||||||
|
@ -112,21 +100,6 @@ export interface IConstituenta {
|
||||||
spawn_alias: string[];
|
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.
|
* Represents {@link IRSForm} statistics.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,14 +2,15 @@
|
||||||
* Module: API for formal representation for systems of concepts.
|
* 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 { TextMatcher } from '@/utils/utils';
|
||||||
|
|
||||||
|
import { CstType, ParsingStatus, ValueClass } from '../backend/types';
|
||||||
import { CstMatchMode } from '../stores/cstSearch';
|
import { CstMatchMode } from '../stores/cstSearch';
|
||||||
|
|
||||||
import { CATEGORY_CST_TYPE, CstClass, CstType, ExpressionStatus, IConstituenta, IRSForm } from './rsform';
|
import { CATEGORY_CST_TYPE, CstClass, ExpressionStatus, IConstituenta, IRSForm } from './rsform';
|
||||||
import { ParsingStatus, ValueClass } from './rslang';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a given target {@link IConstituenta} matches the specified query using the provided matching mode.
|
* Checks if a given target {@link IConstituenta} matches the specified query using the provided matching mode.
|
||||||
|
|
|
@ -2,38 +2,13 @@
|
||||||
* Module: Models for RSLanguage.
|
* Module: Models for RSLanguage.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { TokenID } from '../backend/types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents alias mapping.
|
* Represents alias mapping.
|
||||||
*/
|
*/
|
||||||
export type AliasMapping = Record<string, string>;
|
export type AliasMapping = Record<string, string>;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
* Represents AST node.
|
||||||
*/
|
*/
|
||||||
|
@ -76,171 +51,7 @@ export interface IArgumentValue extends IArgumentInfo {
|
||||||
value?: string;
|
value?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Represents error class. */
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
export enum RSErrorClass {
|
export enum RSErrorClass {
|
||||||
LEXER,
|
LEXER,
|
||||||
PARSER,
|
PARSER,
|
||||||
|
|
|
@ -7,10 +7,9 @@ import { Tree } from '@lezer/common';
|
||||||
import { cursorNode } from '@/utils/codemirror';
|
import { cursorNode } from '@/utils/codemirror';
|
||||||
import { PARAMETER } from '@/utils/constants';
|
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, SyntaxTree } from './rslang';
|
||||||
import { AliasMapping, IArgumentValue, RSErrorClass, RSErrorType, SyntaxTree } from './rslang';
|
|
||||||
|
|
||||||
// cspell:disable
|
// cspell:disable
|
||||||
const LOCALS_REGEXP = /[_a-zα-ω][a-zα-ω]*\d*/g;
|
const LOCALS_REGEXP = /[_a-zα-ω][a-zα-ω]*\d*/g;
|
||||||
|
|
|
@ -16,14 +16,13 @@ import { useDialogsStore } from '@/stores/dialogs';
|
||||||
import { useModificationStore } from '@/stores/modification';
|
import { useModificationStore } from '@/stores/modification';
|
||||||
import { errorMsg } from '@/utils/labels';
|
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 { useCstUpdate } from '../../../backend/useCstUpdate';
|
||||||
import { useMutatingRSForm } from '../../../backend/useMutatingRSForm';
|
import { useMutatingRSForm } from '../../../backend/useMutatingRSForm';
|
||||||
import { RefsInput } from '../../../components/RefsInput';
|
import { RefsInput } from '../../../components/RefsInput';
|
||||||
import { labelCstTypification, labelTypification } from '../../../labels';
|
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 { isBaseSet, isBasicConcept, isFunctional } from '../../../models/rsformAPI';
|
||||||
import { ParsingStatus } from '../../../models/rslang';
|
|
||||||
import EditorRSExpression from '../EditorRSExpression';
|
import EditorRSExpression from '../EditorRSExpression';
|
||||||
|
|
||||||
interface FormConstituentaProps {
|
interface FormConstituentaProps {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { toast } from 'react-toastify';
|
||||||
import { ReactCodeMirrorRef } from '@uiw/react-codemirror';
|
import { ReactCodeMirrorRef } from '@uiw/react-codemirror';
|
||||||
|
|
||||||
import { BadgeHelp, HelpTopic } from '@/features/help';
|
import { BadgeHelp, HelpTopic } from '@/features/help';
|
||||||
import { IExpressionParseDTO } from '@/features/rsform/backend/types';
|
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
import { DataCallback } from '@/backend/apiTransport';
|
||||||
import { Overlay } from '@/components/Container';
|
import { Overlay } from '@/components/Container';
|
||||||
|
@ -14,15 +13,14 @@ import { useDialogsStore } from '@/stores/dialogs';
|
||||||
import { usePreferencesStore } from '@/stores/preferences';
|
import { usePreferencesStore } from '@/stores/preferences';
|
||||||
import { errorMsg } from '@/utils/labels';
|
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 { useCheckConstituenta } from '../../../backend/useCheckConstituenta';
|
||||||
import { useMutatingRSForm } from '../../../backend/useMutatingRSForm';
|
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 { parser as rslangParser } from '../../../components/RSInput/rslang/parserAST';
|
||||||
import { RSTextWrapper } from '../../../components/RSInput/textEditing';
|
import { RSTextWrapper } from '../../../components/RSInput/textEditing';
|
||||||
import { IConstituenta } from '../../../models/rsform';
|
import { IConstituenta } from '../../../models/rsform';
|
||||||
import { getDefinitionPrefix } from '../../../models/rsformAPI';
|
import { getDefinitionPrefix } from '../../../models/rsformAPI';
|
||||||
import { TokenID } from '../../../models/rslang';
|
|
||||||
import { transformAST } from '../../../models/rslangAPI';
|
import { transformAST } from '../../../models/rslangAPI';
|
||||||
import { useRSEdit } from '../RSEditContext';
|
import { useRSEdit } from '../RSEditContext';
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import clsx from 'clsx';
|
||||||
|
|
||||||
import { PARAMETER, prefixes } from '@/utils/constants';
|
import { PARAMETER, prefixes } from '@/utils/constants';
|
||||||
|
|
||||||
import { TokenID } from '../../../models/rslang';
|
import { TokenID } from '../../../backend/types';
|
||||||
|
|
||||||
import RSLocalButton from './RSLocalButton';
|
import RSLocalButton from './RSLocalButton';
|
||||||
import RSTokenButton from './RSTokenButton';
|
import RSTokenButton from './RSTokenButton';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import clsx from 'clsx';
|
||||||
import { CProps } from '@/components/props';
|
import { CProps } from '@/components/props';
|
||||||
import { globals } from '@/utils/constants';
|
import { globals } from '@/utils/constants';
|
||||||
|
|
||||||
import { TokenID } from '../../../models/rslang';
|
import { TokenID } from '../../../backend/types';
|
||||||
|
|
||||||
interface RSLocalButtonProps extends CProps.Titled, CProps.Styling {
|
interface RSLocalButtonProps extends CProps.Titled, CProps.Styling {
|
||||||
text: string;
|
text: string;
|
||||||
|
|
|
@ -2,8 +2,8 @@ import clsx from 'clsx';
|
||||||
|
|
||||||
import { globals } from '@/utils/constants';
|
import { globals } from '@/utils/constants';
|
||||||
|
|
||||||
|
import { TokenID } from '../../../backend/types';
|
||||||
import { describeToken, labelToken } from '../../../labels';
|
import { describeToken, labelToken } from '../../../labels';
|
||||||
import { TokenID } from '../../../models/rslang';
|
|
||||||
|
|
||||||
interface RSTokenButtonProps {
|
interface RSTokenButtonProps {
|
||||||
token: TokenID;
|
token: TokenID;
|
||||||
|
|
|
@ -8,12 +8,11 @@ import { APP_COLORS } from '@/styling/colors';
|
||||||
import { globals } from '@/utils/constants';
|
import { globals } from '@/utils/constants';
|
||||||
import { prepareTooltip } from '@/utils/utils';
|
import { prepareTooltip } from '@/utils/utils';
|
||||||
|
|
||||||
import { IExpressionParseDTO } from '../../../backend/types';
|
import { IExpressionParseDTO, ParsingStatus } from '../../../backend/types';
|
||||||
import { colorStatusBar } from '../../../colors';
|
import { colorStatusBar } from '../../../colors';
|
||||||
import { labelExpressionStatus } from '../../../labels';
|
import { labelExpressionStatus } from '../../../labels';
|
||||||
import { ExpressionStatus, IConstituenta } from '../../../models/rsform';
|
import { ExpressionStatus, IConstituenta } from '../../../models/rsform';
|
||||||
import { inferStatus } from '../../../models/rsformAPI';
|
import { inferStatus } from '../../../models/rsformAPI';
|
||||||
import { ParsingStatus } from '../../../models/rslang';
|
|
||||||
|
|
||||||
interface StatusBarProps {
|
interface StatusBarProps {
|
||||||
processing?: boolean;
|
processing?: boolean;
|
||||||
|
|
|
@ -13,14 +13,14 @@ import { useFitHeight } from '@/stores/appLayout';
|
||||||
import { infoMsg } from '@/utils/labels';
|
import { infoMsg } from '@/utils/labels';
|
||||||
import { convertToCSV } from '@/utils/utils';
|
import { convertToCSV } from '@/utils/utils';
|
||||||
|
|
||||||
|
import { CstType } from '../../../backend/types';
|
||||||
import { useMutatingRSForm } from '../../../backend/useMutatingRSForm';
|
import { useMutatingRSForm } from '../../../backend/useMutatingRSForm';
|
||||||
import { CstType } from '../../../models/rsform';
|
|
||||||
import { matchConstituenta } from '../../../models/rsformAPI';
|
import { matchConstituenta } from '../../../models/rsformAPI';
|
||||||
import { CstMatchMode } from '../../../stores/cstSearch';
|
import { CstMatchMode } from '../../../stores/cstSearch';
|
||||||
import { useRSEdit } from '../RSEditContext';
|
import { useRSEdit } from '../RSEditContext';
|
||||||
|
|
||||||
import TableRSList from './TableRSList';
|
import TableRSList from './TableRSList';
|
||||||
import ToolbarRSList from './ToolbarRSList';
|
import { ToolbarRSList } from './ToolbarRSList';
|
||||||
|
|
||||||
function EditorRSList() {
|
function EditorRSList() {
|
||||||
const controller = useRSEdit();
|
const controller = useRSEdit();
|
||||||
|
|
|
@ -1,12 +1,21 @@
|
||||||
import { BadgeHelp, HelpTopic } from '@/features/help';
|
import { BadgeHelp, HelpTopic } from '@/features/help';
|
||||||
import { MiniSelectorOSS } from '@/features/library';
|
import { MiniSelectorOSS } from '@/features/library';
|
||||||
|
import { CstType } from '@/features/rsform';
|
||||||
|
|
||||||
import { Overlay } from '@/components/Container';
|
import { Overlay } from '@/components/Container';
|
||||||
import { MiniButton } from '@/components/Control';
|
import { MiniButton } from '@/components/Control';
|
||||||
import { CstTypeIcon } from '@/components/DomainIcons';
|
import { DomIconProps } from '@/components/DomainIcons';
|
||||||
import { Dropdown, DropdownButton, useDropdown } from '@/components/Dropdown';
|
import { Dropdown, DropdownButton, useDropdown } from '@/components/Dropdown';
|
||||||
import {
|
import {
|
||||||
IconClone,
|
IconClone,
|
||||||
|
IconCstAxiom,
|
||||||
|
IconCstBaseSet,
|
||||||
|
IconCstConstSet,
|
||||||
|
IconCstFunction,
|
||||||
|
IconCstPredicate,
|
||||||
|
IconCstStructured,
|
||||||
|
IconCstTerm,
|
||||||
|
IconCstTheorem,
|
||||||
IconDestroy,
|
IconDestroy,
|
||||||
IconMoveDown,
|
IconMoveDown,
|
||||||
IconMoveUp,
|
IconMoveUp,
|
||||||
|
@ -19,10 +28,9 @@ import { prepareTooltip } from '@/utils/utils';
|
||||||
|
|
||||||
import { useMutatingRSForm } from '../../../backend/useMutatingRSForm';
|
import { useMutatingRSForm } from '../../../backend/useMutatingRSForm';
|
||||||
import { getCstTypeShortcut, labelCstType } from '../../../labels';
|
import { getCstTypeShortcut, labelCstType } from '../../../labels';
|
||||||
import { CstType } from '../../../models/rsform';
|
|
||||||
import { useRSEdit } from '../RSEditContext';
|
import { useRSEdit } from '../RSEditContext';
|
||||||
|
|
||||||
function ToolbarRSList() {
|
export function ToolbarRSList() {
|
||||||
const controller = useRSEdit();
|
const controller = useRSEdit();
|
||||||
const isProcessing = useMutatingRSForm();
|
const isProcessing = useMutatingRSForm();
|
||||||
const insertMenu = useDropdown();
|
const insertMenu = useDropdown();
|
||||||
|
@ -107,4 +115,24 @@ function ToolbarRSList() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ToolbarRSList;
|
/** Icon for constituenta type. */
|
||||||
|
function CstTypeIcon({ value, size = '1.25rem', className }: DomIconProps<CstType>) {
|
||||||
|
switch (value) {
|
||||||
|
case CstType.BASE:
|
||||||
|
return <IconCstBaseSet size={size} className={className ?? 'text-ok-600'} />;
|
||||||
|
case CstType.CONSTANT:
|
||||||
|
return <IconCstConstSet size={size} className={className ?? 'text-ok-600'} />;
|
||||||
|
case CstType.STRUCTURED:
|
||||||
|
return <IconCstStructured size={size} className={className ?? 'text-ok-600'} />;
|
||||||
|
case CstType.TERM:
|
||||||
|
return <IconCstTerm size={size} className={className ?? 'text-sec-600'} />;
|
||||||
|
case CstType.AXIOM:
|
||||||
|
return <IconCstAxiom size={size} className={className ?? 'text-warn-600'} />;
|
||||||
|
case CstType.FUNCTION:
|
||||||
|
return <IconCstFunction size={size} className={className ?? 'text-sec-600'} />;
|
||||||
|
case CstType.PREDICATE:
|
||||||
|
return <IconCstPredicate size={size} className={className ?? 'text-warn-600'} />;
|
||||||
|
case CstType.THEOREM:
|
||||||
|
return <IconCstTheorem size={size} className={className ?? 'text-warn-600'} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -27,11 +27,12 @@ import { APP_COLORS } from '@/styling/colors';
|
||||||
import { PARAMETER } from '@/utils/constants';
|
import { PARAMETER } from '@/utils/constants';
|
||||||
import { errorMsg } from '@/utils/labels';
|
import { errorMsg } from '@/utils/labels';
|
||||||
|
|
||||||
|
import { CstType } from '../../../backend/types';
|
||||||
import { useMutatingRSForm } from '../../../backend/useMutatingRSForm';
|
import { useMutatingRSForm } from '../../../backend/useMutatingRSForm';
|
||||||
import { colorBgGraphNode } from '../../../colors';
|
import { colorBgGraphNode } from '../../../colors';
|
||||||
import InfoConstituenta from '../../../components/InfoConstituenta';
|
import InfoConstituenta from '../../../components/InfoConstituenta';
|
||||||
import ToolbarGraphSelection from '../../../components/ToolbarGraphSelection';
|
import ToolbarGraphSelection from '../../../components/ToolbarGraphSelection';
|
||||||
import { CstType, IConstituenta, IRSForm } from '../../../models/rsform';
|
import { IConstituenta, IRSForm } from '../../../models/rsform';
|
||||||
import { isBasicConcept } from '../../../models/rsformAPI';
|
import { isBasicConcept } from '../../../models/rsformAPI';
|
||||||
import { GraphFilterParams, useTermGraphStore } from '../../../stores/termGraph';
|
import { GraphFilterParams, useTermGraphStore } from '../../../stores/termGraph';
|
||||||
import { useRSEdit } from '../RSEditContext';
|
import { useRSEdit } from '../RSEditContext';
|
||||||
|
|
|
@ -4,7 +4,8 @@ import fileDownload from 'js-file-download';
|
||||||
|
|
||||||
import { urls, useConceptNavigation } from '@/app';
|
import { urls, useConceptNavigation } from '@/app';
|
||||||
import { useAuthSuspense } from '@/features/auth';
|
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 { useRoleStore, UserRole } from '@/features/users';
|
||||||
|
|
||||||
import { Divider } from '@/components/Container';
|
import { Divider } from '@/components/Container';
|
||||||
|
|
|
@ -14,11 +14,11 @@ import { PARAMETER, prefixes } from '@/utils/constants';
|
||||||
import { promptText } from '@/utils/labels';
|
import { promptText } from '@/utils/labels';
|
||||||
import { promptUnsaved } from '@/utils/utils';
|
import { promptUnsaved } from '@/utils/utils';
|
||||||
|
|
||||||
import { IConstituentaBasicsDTO, ICstCreateDTO } from '../../backend/types';
|
import { CstType, IConstituentaBasicsDTO, ICstCreateDTO } from '../../backend/types';
|
||||||
import { useCstCreate } from '../../backend/useCstCreate';
|
import { useCstCreate } from '../../backend/useCstCreate';
|
||||||
import { useCstMove } from '../../backend/useCstMove';
|
import { useCstMove } from '../../backend/useCstMove';
|
||||||
import { useRSFormSuspense } from '../../backend/useRSForm';
|
import { useRSFormSuspense } from '../../backend/useRSForm';
|
||||||
import { CstType, IConstituenta, IRSForm } from '../../models/rsform';
|
import { IConstituenta, IRSForm } from '../../models/rsform';
|
||||||
import { generateAlias } from '../../models/rsformAPI';
|
import { generateAlias } from '../../models/rsformAPI';
|
||||||
|
|
||||||
export enum RSTabID {
|
export enum RSTabID {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Label is a short text used to represent an entity.
|
* Label is a short text used to represent an entity.
|
||||||
* Description is a long description used in tooltips.
|
* 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';
|
import { UserRole } from '@/features/users/stores/role';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user