ConceptPortal-public/rsconcept/frontend/src/models/rsform.ts

266 lines
5.8 KiB
TypeScript
Raw Normal View History

/**
* Module: Models for formal representation for systems of concepts.
*/
2024-01-04 14:35:46 +03:00
import { Graph } from '@/models/Graph';
2024-08-01 00:36:06 +03:00
import { ILibraryItem, ILibraryItemReference, ILibraryItemVersioned, LibraryItemID } from './library';
2024-07-21 15:19:57 +03:00
import { ICstSubstitute } from './oss';
2023-12-28 14:04:44 +03:00
import { IArgumentInfo, ParsingStatus, ValueClass } from './rslang';
2023-07-29 03:31:21 +03:00
/**
2024-07-21 15:19:57 +03:00
* Represents {@link IConstituenta} type.
2023-12-28 14:04:44 +03:00
*/
export enum CstType {
BASE = 'basic',
STRUCTURED = 'structure',
TERM = 'term',
AXIOM = 'axiom',
FUNCTION = 'function',
PREDICATE = 'predicate',
CONSTANT = 'constant',
THEOREM = 'theorem'
}
2024-07-21 15:19:57 +03:00
// CstType constant for category dividers in TemplateSchemas
2023-11-04 01:29:21 +03:00
export const CATEGORY_CST_TYPE = CstType.THEOREM;
/**
2024-03-17 19:24:12 +03:00
* Represents position in linear order.
*/
2024-03-17 19:24:12 +03:00
export type Position = number;
/**
2024-07-21 15:19:57 +03:00
* Represents {@link IConstituenta} identifier type.
2024-03-17 19:24:12 +03:00
*/
export type ConstituentaID = number;
/**
* Represents Constituenta classification in terms of system of concepts.
2023-12-28 14:04:44 +03:00
*/
2023-08-16 00:39:16 +03:00
export enum CstClass {
BASIC = 'basic',
DERIVED = 'derived',
STATEMENT = 'statement',
TEMPLATE = 'template'
}
/**
* Represents formal expression Status.
2023-12-28 14:04:44 +03:00
*/
2023-09-11 20:31:54 +03:00
export enum ExpressionStatus {
2023-09-26 00:24:50 +03:00
VERIFIED = 'verified',
2023-09-11 20:31:54 +03:00
INCORRECT = 'incorrect',
2023-09-26 00:24:50 +03:00
INCALCULABLE = 'incalculable',
2023-10-02 23:43:29 +03:00
PROPERTY = 'property',
2023-09-26 00:24:50 +03:00
UNDEFINED = 'undefined',
2023-12-28 14:04:44 +03:00
UNKNOWN = 'unknown'
2023-09-11 20:31:54 +03:00
}
/**
2023-12-26 14:23:51 +03:00
* Represents word form for natural language.
2023-12-28 14:04:44 +03:00
*/
export interface TermForm {
2023-12-28 14:04:44 +03:00
text: string;
tags: string;
2023-07-20 17:11:03 +03:00
}
/**
* Represents Constituenta basic persistent data.
2023-12-28 14:04:44 +03:00
*/
export interface IConstituentaMeta {
2024-03-17 19:24:12 +03:00
id: ConstituentaID;
schema: LibraryItemID;
order: Position;
2023-12-28 14:04:44 +03:00
alias: string;
convention: string;
cst_type: CstType;
definition_formal: string;
definition_raw: string;
definition_resolved: string;
term_raw: string;
term_resolved: string;
term_forms: TermForm[];
}
2024-03-15 12:34:41 +03:00
/**
* Represents target {@link IConstituenta}.
2024-03-15 12:34:41 +03:00
*/
export interface ITargetCst {
target: ConstituentaID;
}
2024-03-15 12:34:41 +03:00
/**
* Represents Constituenta data from server.
2023-12-28 14:04:44 +03:00
*/
export interface IConstituentaData extends IConstituentaMeta {
parse: {
2023-12-28 14:04:44 +03:00
status: ParsingStatus;
valueClass: ValueClass;
typification: string;
syntaxTree: string;
args: IArgumentInfo[];
};
}
/**
* Represents Constituenta.
*/
export interface IConstituenta extends IConstituentaData {
cst_class: CstClass;
status: ExpressionStatus;
is_template: boolean;
is_simple_expression: boolean;
2024-08-01 00:36:06 +03:00
is_inherited: boolean;
is_inherited_parent: boolean;
parent?: ConstituentaID;
parent_alias?: string;
children: number[];
children_alias: string[];
}
/**
* Represents Constituenta list.
2023-12-28 14:04:44 +03:00
*/
export interface IConstituentaList {
2024-03-17 19:24:12 +03:00
items: ConstituentaID[];
}
/**
2024-07-21 15:19:57 +03:00
* Represents {@link IConstituenta} data, used in creation process.
2023-12-28 14:04:44 +03:00
*/
export interface ICstCreateData
extends Pick<
IConstituentaMeta,
'alias' | 'cst_type' | 'definition_raw' | 'term_raw' | 'convention' | 'definition_formal' | 'term_forms'
> {
2024-03-17 19:24:12 +03:00
insert_after: ConstituentaID | null;
}
/**
2024-07-21 15:19:57 +03:00
* Represents data, used in ordering a list of {@link IConstituenta}.
2023-12-28 14:04:44 +03:00
*/
export interface ICstMovetoData extends IConstituentaList {
2024-03-17 19:24:12 +03:00
move_to: Position;
}
/**
* Represents data, used in updating persistent attributes in {@link IConstituenta}.
2023-12-28 14:04:44 +03:00
*/
export interface ICstUpdateData
2023-12-28 14:04:44 +03:00
extends Pick<IConstituentaMeta, 'id'>,
Partial<
Pick<
IConstituentaMeta,
'alias' | 'convention' | 'definition_formal' | 'definition_raw' | 'term_raw' | 'term_forms'
>
> {}
/**
* Represents data, used in renaming {@link IConstituenta}.
2023-12-28 14:04:44 +03:00
*/
export interface ICstRenameData extends ITargetCst, Pick<IConstituentaMeta, 'alias' | 'cst_type'> {}
/**
* Represents data response when creating {@link IConstituenta}.
2023-12-28 14:04:44 +03:00
*/
export interface ICstCreatedResponse {
2023-12-28 14:04:44 +03:00
new_cst: IConstituentaMeta;
schema: IRSFormData;
}
2024-03-15 12:34:41 +03:00
/**
* Represents data response when creating producing structure of {@link IConstituenta}.
*/
export interface IProduceStructureResponse {
2024-03-17 19:24:12 +03:00
cst_list: ConstituentaID[];
2024-03-15 12:34:41 +03:00
schema: IRSFormData;
}
/**
* Represents {@link IRSForm} statistics.
2023-12-28 14:04:44 +03:00
*/
2023-07-20 17:11:03 +03:00
export interface IRSFormStats {
2023-12-28 14:04:44 +03:00
count_all: number;
count_errors: number;
count_property: number;
count_incalculable: number;
2024-08-01 00:36:06 +03:00
count_inherited: number;
2023-12-28 14:04:44 +03:00
count_text_term: number;
count_definition: number;
count_convention: number;
count_base: number;
count_constant: number;
count_structured: number;
count_axiom: number;
count_term: number;
count_function: number;
count_predicate: number;
count_theorem: number;
2023-07-20 17:11:03 +03:00
}
2024-08-01 00:36:06 +03:00
/**
* Represents data for {@link IRSForm} provided by backend.
*/
export interface IRSFormData extends ILibraryItemVersioned {
items: IConstituentaData[];
inheritance: ConstituentaID[][];
oss: ILibraryItemReference[];
}
/**
* Represents formal explication for set of concepts.
2023-12-28 14:04:44 +03:00
*/
2024-08-01 00:36:06 +03:00
export interface IRSForm extends IRSFormData {
2023-12-28 14:04:44 +03:00
items: IConstituenta[];
stats: IRSFormStats;
graph: Graph;
cstByAlias: Map<string, IConstituenta>;
cstByID: Map<ConstituentaID, IConstituenta>;
2023-07-20 17:11:03 +03:00
}
/**
* Represents data, used for cloning {@link IRSForm}.
*/
export interface IRSFormCloneData extends Omit<ILibraryItem, 'time_create' | 'time_update' | 'id' | 'owner'> {
items?: ConstituentaID[];
}
/**
* Represents data, used for uploading {@link IRSForm} as file.
2023-12-28 14:04:44 +03:00
*/
2023-07-27 22:04:25 +03:00
export interface IRSFormUploadData {
2023-12-28 14:04:44 +03:00
load_metadata: boolean;
file: File;
fileName: string;
}
2024-03-04 19:22:22 +03:00
/**
* Represents data response when creating {@link IVersionInfo}.
*/
export interface IVersionCreatedResponse {
version: number;
schema: IRSFormData;
}
2024-03-17 19:24:12 +03:00
2024-07-21 15:19:57 +03:00
/**
2024-07-29 16:56:24 +03:00
* Represents single substitution for binary synthesis table.
2024-07-21 15:19:57 +03:00
*/
2024-07-29 16:56:24 +03:00
export interface IBinarySubstitution {
2024-07-21 15:19:57 +03:00
leftCst: IConstituenta;
rightCst: IConstituenta;
deleteRight: boolean;
}
2024-03-17 19:24:12 +03:00
/**
* Represents input data for inline synthesis.
*/
export interface IInlineSynthesisData {
2024-03-17 19:24:12 +03:00
receiver: LibraryItemID;
source: LibraryItemID;
items: ConstituentaID[];
substitutions: ICstSubstitute[];
2024-03-17 19:24:12 +03:00
}