Portal/rsconcept/frontend/src/models/rsform.ts

269 lines
5.9 KiB
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
/**
* Module: Models for formal representation for systems of concepts.
*/
import { Graph } from '@/models/Graph';
2024-08-01 00:35:49 +03:00
import { ILibraryItem, ILibraryItemReference, ILibraryItemVersioned, LibraryItemID } from './library';
2024-07-20 18:26:32 +03:00
import { ICstSubstitute } from './oss';
2024-06-07 20:17:03 +03:00
import { IArgumentInfo, ParsingStatus, ValueClass } from './rslang';
/**
2024-07-20 18:26:32 +03:00
* Represents {@link IConstituenta} type.
2024-06-07 20:17:03 +03:00
*/
export enum CstType {
BASE = 'basic',
STRUCTURED = 'structure',
TERM = 'term',
AXIOM = 'axiom',
FUNCTION = 'function',
PREDICATE = 'predicate',
CONSTANT = 'constant',
THEOREM = 'theorem'
}
2024-07-20 18:26:32 +03:00
// CstType constant for category dividers in TemplateSchemas
2024-06-07 20:17:03 +03:00
export const CATEGORY_CST_TYPE = CstType.THEOREM;
/**
* Represents position in linear order.
*/
export type Position = number;
/**
2024-07-20 18:26:32 +03:00
* Represents {@link IConstituenta} identifier type.
2024-06-07 20:17:03 +03:00
*/
export type ConstituentaID = number;
/**
* Represents Constituenta classification in terms of system of concepts.
*/
export enum CstClass {
BASIC = 'basic',
DERIVED = 'derived',
STATEMENT = 'statement',
TEMPLATE = 'template'
}
/**
* Represents formal expression Status.
*/
export enum ExpressionStatus {
VERIFIED = 'verified',
INCORRECT = 'incorrect',
INCALCULABLE = 'incalculable',
PROPERTY = 'property',
UNDEFINED = 'undefined',
UNKNOWN = 'unknown'
}
/**
* Represents word form for natural language.
*/
export interface TermForm {
text: string;
tags: string;
}
/**
* Represents Constituenta basic persistent data.
*/
export interface IConstituentaMeta {
id: ConstituentaID;
schema: LibraryItemID;
order: Position;
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[];
}
/**
* Represents target {@link IConstituenta}.
*/
export interface ITargetCst {
target: ConstituentaID;
}
/**
* Represents {@link IConstituenta} data from server.
2024-06-07 20:17:03 +03:00
*/
export interface IConstituentaData extends IConstituentaMeta {
parse: {
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:35:49 +03:00
is_inherited: boolean;
is_inherited_parent: boolean;
2024-06-07 20:17:03 +03:00
parent?: ConstituentaID;
parent_alias?: string;
children: number[];
children_alias: string[];
}
/**
* Represents {@link IConstituenta} reference.
*/
export interface IConstituentaReference extends Pick<IConstituentaMeta, 'id' | 'schema'> {}
2024-06-07 20:17:03 +03:00
/**
* Represents Constituenta list.
*/
export interface IConstituentaList {
items: ConstituentaID[];
}
/**
2024-07-20 18:26:32 +03:00
* Represents {@link IConstituenta} data, used in creation process.
2024-06-07 20:17:03 +03:00
*/
export interface ICstCreateData
extends Pick<
IConstituentaMeta,
'alias' | 'cst_type' | 'definition_raw' | 'term_raw' | 'convention' | 'definition_formal' | 'term_forms'
> {
insert_after: ConstituentaID | null;
}
/**
2024-07-20 18:26:32 +03:00
* Represents data, used in ordering a list of {@link IConstituenta}.
2024-06-07 20:17:03 +03:00
*/
export interface ICstMovetoData extends IConstituentaList {
move_to: Position;
}
/**
* Represents data, used in updating persistent attributes in {@link IConstituenta}.
*/
2024-08-10 11:41:28 +03:00
export interface ICstUpdateData {
target: ConstituentaID;
item_data: Partial<
Pick<IConstituentaMeta, 'convention' | 'definition_formal' | 'definition_raw' | 'term_raw' | 'term_forms'>
>;
}
2024-06-07 20:17:03 +03:00
/**
* Represents data, used in renaming {@link IConstituenta}.
*/
export interface ICstRenameData extends ITargetCst, Pick<IConstituentaMeta, 'alias' | 'cst_type'> {}
/**
* Represents data response when creating {@link IConstituenta}.
*/
export interface ICstCreatedResponse {
new_cst: IConstituentaMeta;
schema: IRSFormData;
}
/**
* Represents data response when creating producing structure of {@link IConstituenta}.
*/
export interface IProduceStructureResponse {
cst_list: ConstituentaID[];
schema: IRSFormData;
}
/**
* Represents {@link IRSForm} statistics.
*/
export interface IRSFormStats {
count_all: number;
count_errors: number;
count_property: number;
count_incalculable: number;
2024-08-01 00:35:49 +03:00
count_inherited: number;
2024-06-07 20:17:03 +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;
}
2024-08-01 00:35:49 +03:00
/**
* Represents data for {@link IRSForm} provided by backend.
*/
export interface IRSFormData extends ILibraryItemVersioned {
items: IConstituentaData[];
inheritance: ConstituentaID[][];
oss: ILibraryItemReference[];
}
2024-06-07 20:17:03 +03:00
/**
* Represents formal explication for set of concepts.
*/
2024-08-01 00:35:49 +03:00
export interface IRSForm extends IRSFormData {
2024-06-07 20:17:03 +03:00
items: IConstituenta[];
stats: IRSFormStats;
graph: Graph;
cstByAlias: Map<string, IConstituenta>;
cstByID: Map<ConstituentaID, IConstituenta>;
}
/**
* 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.
*/
export interface IRSFormUploadData {
load_metadata: boolean;
file: File;
fileName: string;
}
/**
* Represents data response when creating {@link IVersionInfo}.
*/
export interface IVersionCreatedResponse {
version: number;
schema: IRSFormData;
}
2024-07-20 18:26:32 +03:00
/**
2024-07-29 16:55:48 +03:00
* Represents single substitution for binary synthesis table.
2024-07-20 18:26:32 +03:00
*/
2024-07-29 16:55:48 +03:00
export interface IBinarySubstitution {
2024-07-20 18:26:32 +03:00
leftCst: IConstituenta;
rightCst: IConstituenta;
deleteRight: boolean;
}
2024-06-07 20:17:03 +03:00
/**
* Represents input data for inline synthesis.
*/
export interface IInlineSynthesisData {
receiver: LibraryItemID;
source: LibraryItemID;
items: ConstituentaID[];
substitutions: ICstSubstitute[];
}