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

92 lines
2.1 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,
type IOperationSchemaDTO
} 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-03-14 20:44:23 +03:00
/** Represents Operation. */
export interface IOperation extends IOperationDTO {
nodeID: string;
nodeType: typeof NodeType.OPERATION;
2025-04-06 15:49:43 +03:00
x: number;
y: number;
is_owned: boolean;
is_consolidation: boolean; // aka 'diamond synthesis'
substitutions: ICstSubstituteInfo[];
arguments: number[];
}
2024-07-21 15:19:57 +03:00
2025-04-20 15:55:52 +03:00
/** Represents Block. */
export interface IBlock extends IBlockDTO {
nodeID: string;
nodeType: typeof NodeType.BLOCK;
2025-04-20 15:55:52 +03:00
x: number;
y: number;
width: number;
height: number;
}
/** 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;
2024-07-26 00:34:08 +03:00
}
2025-03-14 20:44:23 +03:00
/** Represents OperationSchema. */
export interface IOperationSchema extends IOperationSchemaDTO {
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;
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];