ConceptPortal-public/rsconcept/frontend/src/features/oss/models/oss.ts

119 lines
3.0 KiB
TypeScript
Raw Normal View History

2024-06-04 23:00:22 +03:00
/**
* Module: Schema of Synthesis Operations.
*/
2025-02-12 21:36:25 +03:00
2025-03-12 12:04:50 +03:00
import { type Graph } from '@/models/graph';
2024-07-21 15:19:57 +03:00
2025-04-20 15:55:52 +03:00
import {
type IBlockDTO,
type ICstSubstituteInfo,
type IOperationDTO,
2025-08-04 22:58:08 +03:00
type IOperationSchemaDTO,
type OperationType
2025-04-20 15:55:52 +03:00
} from '../backend/types';
/** Represents OSS node type. */
export const NodeType = {
OPERATION: 1,
BLOCK: 2
} as const;
export type NodeType = (typeof NodeType)[keyof typeof NodeType];
2025-08-04 22:58:08 +03:00
/** Represents OSS graph node. */
export interface IOssNode {
nodeID: string;
2025-08-04 22:58:08 +03:00
nodeType: NodeType;
parent: number | null;
2025-04-06 15:49:43 +03:00
x: number;
y: number;
2025-08-04 22:58:08 +03:00
width: number;
height: number;
}
/** Represents Operation common attributes. */
export interface IOperationBase
extends IOssNode,
Pick<IOperationDTO, 'alias' | 'title' | 'description' | 'id' | 'operation_type' | 'result'> {
nodeType: typeof NodeType.OPERATION;
}
/** Represents Input Operation. */
export interface IOperationInput extends IOperationBase {
operation_type: typeof OperationType.INPUT;
is_import: boolean;
2025-08-04 22:58:08 +03:00
}
/** Represents Reference Operation. */
export interface IOperationReference extends IOperationBase {
operation_type: typeof OperationType.REFERENCE;
target: number;
}
/** Represents Synthesis Operation. */
export interface IOperationSynthesis extends IOperationBase {
operation_type: typeof OperationType.SYNTHESIS;
is_consolidation: boolean; // aka 'diamond synthesis'
substitutions: ICstSubstituteInfo[];
arguments: number[];
}
2024-07-21 15:19:57 +03:00
2025-08-04 22:58:08 +03:00
/** Represents Operation. */
export type IOperation = IOperationInput | IOperationReference | IOperationSynthesis;
2025-04-20 15:55:52 +03:00
/** Represents Block. */
2025-08-04 22:58:08 +03:00
export interface IBlock extends IOssNode, IBlockDTO {
nodeType: typeof NodeType.BLOCK;
2025-04-20 15:55:52 +03:00
}
/** Represents item of OperationSchema. */
export type IOssItem = IOperation | IBlock;
2025-03-14 20:44:23 +03:00
/** Represents {@link IOperationSchema} statistics. */
2024-07-26 00:34:08 +03:00
export interface IOperationSchemaStats {
2025-04-20 15:55:52 +03:00
count_all: number;
2024-07-26 00:34:08 +03:00
count_inputs: number;
count_synthesis: number;
count_schemas: number;
2024-08-23 21:29:07 +03:00
count_owned: number;
2025-04-20 15:55:52 +03:00
count_block: number;
2025-08-04 22:58:08 +03:00
count_references: number;
2024-07-26 00:34:08 +03:00
}
2025-03-14 20:44:23 +03:00
/** Represents OperationSchema. */
2025-08-04 22:58:08 +03:00
export interface IOperationSchema extends Omit<IOperationSchemaDTO, 'operations'> {
2025-04-06 15:49:43 +03:00
operations: IOperation[];
2025-04-20 15:55:52 +03:00
blocks: IBlock[];
2024-06-04 23:00:22 +03:00
2024-07-21 15:19:57 +03:00
graph: Graph;
2025-08-04 22:58:08 +03:00
extendedGraph: Graph;
hierarchy: Graph<string>;
2025-02-12 15:13:37 +03:00
schemas: number[];
2024-07-26 00:34:08 +03:00
stats: IOperationSchemaStats;
2025-02-17 15:12:15 +03:00
operationByID: Map<number, IOperation>;
2025-04-20 15:55:52 +03:00
blockByID: Map<number, IBlock>;
itemByNodeID: Map<string, IOssItem>;
2024-07-21 15:19:57 +03:00
}
2025-03-14 20:44:23 +03:00
/** Represents substitution error description. */
2024-08-26 17:25:07 +03:00
export interface ISubstitutionErrorDescription {
errorType: SubstitutionErrorType;
params: string[];
}
2025-03-14 20:44:23 +03:00
/** Represents Substitution table error types. */
export const SubstitutionErrorType = {
invalidIDs: 0,
incorrectCst: 1,
invalidClasses: 2,
invalidBasic: 3,
invalidConstant: 4,
typificationCycle: 5,
baseSubstitutionNotSet: 6,
unequalTypification: 7,
unequalExpressions: 8,
unequalArgsCount: 9,
unequalArgs: 10
} as const;
export type SubstitutionErrorType = (typeof SubstitutionErrorType)[keyof typeof SubstitutionErrorType];