@rsconcept/domain 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{analyzer-B35QsI3L.d.ts → analyzer-BcPMzR38.d.ts} +2 -2
- package/dist/{api-DgecYHjR.d.ts → api-BRrnB6yd.d.ts} +4 -2
- package/dist/{ast-annotations-DclU1Ser.d.ts → ast-annotations-B0XO6380.d.ts} +2 -2
- package/dist/{calculator-B-1p712X.d.ts → calculator-SVf1trzN.d.ts} +2 -2
- package/dist/cctext/index.js +1 -2
- package/dist/cctext/language-api.d.ts +11 -12
- package/dist/cctext/language.d.ts +13 -14
- package/dist/{diagnostics-D4_B7rt2.d.ts → diagnostics-DC6QECex.d.ts} +3 -3
- package/dist/{diagnostics-D1Cp21nP.js → diagnostics-D_4TpAH4.js} +4 -5
- package/dist/{diagnostics-D1Cp21nP.js.map → diagnostics-D_4TpAH4.js.map} +1 -1
- package/dist/{error-S1JghCNN.d.ts → error-DBbO_NIg.d.ts} +2 -1
- package/dist/graph/index.js +1 -2
- package/dist/{index-DzvllU3P.d.ts → index-CEOeehqz.d.ts} +5 -5
- package/dist/{index-D-w-bgei.d.ts → index-CEUOBGLn.d.ts} +6 -5
- package/dist/index.d.ts +8 -7
- package/dist/index.js +4 -3
- package/dist/library/diagnostics.d.ts +1 -1
- package/dist/library/diagnostics.js +1 -2
- package/dist/library/folder-tree.d.ts +2 -3
- package/dist/library/index.d.ts +5 -5
- package/dist/library/index.js +1 -1
- package/dist/library/library-api.d.ts +2 -3
- package/dist/library/oss-api.d.ts +5 -6
- package/dist/library/oss-api.js +2 -4
- package/dist/library/oss-api.js.map +1 -1
- package/dist/library/oss-layout-api.d.ts +4 -5
- package/dist/library/oss.d.ts +16 -16
- package/dist/library/oss.js +1 -1
- package/dist/library/rsengine.d.ts +6 -7
- package/dist/library/rsengine.js +23 -24
- package/dist/library/rsengine.js.map +1 -1
- package/dist/library/rsform-api/index.d.ts +1 -1
- package/dist/library/rsform-api/index.js +1 -2
- package/dist/library/rsform.d.ts +1 -1
- package/dist/library/rsmodel-api.d.ts +17 -18
- package/dist/library/rsmodel-api.js +6 -4
- package/dist/library/rsmodel-api.js.map +1 -1
- package/dist/library/rsmodel.d.ts +1 -1
- package/dist/library/structure-planner.d.ts +4 -5
- package/dist/library/structure-planner.js +1 -1
- package/dist/parsing/lezer-tree.js.map +1 -1
- package/dist/rslang/api.d.ts +2 -2
- package/dist/rslang/api.js +12 -7
- package/dist/rslang/api.js.map +1 -1
- package/dist/rslang/ast-annotations.d.ts +1 -1
- package/dist/rslang/error.d.ts +1 -1
- package/dist/rslang/error.js +1 -0
- package/dist/rslang/error.js.map +1 -1
- package/dist/rslang/eval/calculator.d.ts +1 -1
- package/dist/rslang/eval/calculator.js +1 -1
- package/dist/rslang/eval/evaluation-cache.d.ts +3 -4
- package/dist/rslang/eval/evaluation-cache.js +1 -3
- package/dist/rslang/eval/evaluation-cache.js.map +1 -1
- package/dist/rslang/eval/evaluator.d.ts +3 -4
- package/dist/rslang/eval/evaluator.js +5 -3
- package/dist/rslang/eval/evaluator.js.map +1 -1
- package/dist/rslang/eval/value-api.js +1 -2
- package/dist/rslang/eval/value.js +1 -2
- package/dist/rslang/index.d.ts +8 -7
- package/dist/rslang/index.js +3 -2
- package/dist/rslang/labels.d.ts +5 -6
- package/dist/rslang/parser/normalize.d.ts +1 -2
- package/dist/rslang/parser/normalize.js.map +1 -1
- package/dist/rslang/parser/parser.terms.d.ts +1 -2
- package/dist/rslang/parser/parser.terms.js.map +1 -1
- package/dist/rslang/parser/syntax-errors/index.d.ts +3 -4
- package/dist/rslang/parser/syntax-errors/index.js +1 -2
- package/dist/rslang/semantic/analyzer.d.ts +1 -1
- package/dist/rslang/semantic/analyzer.js +1 -1
- package/dist/rslang/semantic/arguments-extractor.js +6 -4
- package/dist/rslang/semantic/arguments-extractor.js.map +1 -1
- package/dist/rslang/semantic/type-auditor.d.ts +2 -3
- package/dist/rslang/semantic/type-auditor.js +20 -16
- package/dist/rslang/semantic/type-auditor.js.map +1 -1
- package/dist/rslang/semantic/typification-api.d.ts +10 -11
- package/dist/rslang/semantic/typification-api.js +10 -9
- package/dist/rslang/semantic/typification-api.js.map +1 -1
- package/dist/rslang/semantic/typification-parser.js +4 -1
- package/dist/rslang/semantic/typification-parser.js.map +1 -1
- package/dist/rslang/semantic/value-auditor.d.ts +2 -3
- package/dist/shared/index.js +1 -2
- package/dist/{syntax-errors-BN_bqTaX.js → syntax-errors-WGLQNaNe.js} +19 -4
- package/dist/{syntax-errors-BN_bqTaX.js.map → syntax-errors-WGLQNaNe.js.map} +1 -1
- package/dist/{value-COprb2Je.js → value-BDISzQqI.js} +3 -2
- package/dist/{value-COprb2Je.js.map → value-BDISzQqI.js.map} +1 -1
- package/package.json +24 -25
- package/src/index.ts +2 -1
- package/src/library/rsengine.test.ts +164 -0
- package/src/library/rsengine.ts +25 -24
- package/src/rslang/api.ts +3 -0
- package/src/rslang/error.ts +1 -0
- package/src/rslang/index.ts +2 -1
- package/src/rslang/parser/parser.test.ts +38 -0
- package/src/rslang/parser/syntax-errors/README.md +2 -2
- package/src/rslang/parser/syntax-errors/expression-errors.ts +18 -0
- package/src/rslang/parser/syntax-errors/index.ts +11 -4
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { DiagnosticKind, RSDiagnosticCode, assignSchemaDiagnostics, detectDependencyCycleDiagnostics, formatDependencyCycle, hasCstDiagnostic, modelStatusCstDiagnostic };
|
|
1
|
+
export { t as DiagnosticKind, n as RSDiagnosticCode, r as assignSchemaDiagnostics, i as detectDependencyCycleDiagnostics, a as formatDependencyCycle, o as hasCstDiagnostic, s as modelStatusCstDiagnostic } from "../diagnostics-D_4TpAH4.js";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Represents single node of a {@link FolderTree}.
|
|
7
7
|
*/
|
|
8
|
-
declare class FolderNode {
|
|
8
|
+
export declare class FolderNode {
|
|
9
9
|
rank: number;
|
|
10
10
|
text: string;
|
|
11
11
|
children: Map<string, FolderNode>;
|
|
@@ -20,7 +20,7 @@ declare class FolderNode {
|
|
|
20
20
|
getPath(): string;
|
|
21
21
|
}
|
|
22
22
|
/** Represents a FolderTree. */
|
|
23
|
-
declare class FolderTree {
|
|
23
|
+
export declare class FolderTree {
|
|
24
24
|
roots: Map<string, FolderNode>;
|
|
25
25
|
constructor(arr?: string[]);
|
|
26
26
|
at(path: string): FolderNode | undefined;
|
|
@@ -30,5 +30,4 @@ declare class FolderTree {
|
|
|
30
30
|
private addNode;
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
|
-
export { FolderNode, FolderTree };
|
|
34
33
|
//# sourceMappingURL=folder-tree.d.ts.map
|
package/dist/library/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as LibraryItemType, i as LibraryItemReference, n as CurrentVersion, o as LocationHead, r as LibraryItem, s as VersionInfo, t as AccessPolicy } from "../library-CYun28Xz.js";
|
|
2
|
-
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, a as detectDependencyCycleDiagnostics, b as CstStatus, c as modelStatusCstDiagnostic, d as DEFAULT_VALUE_TEXT, f as EvalStatus, g as ArgumentValue, i as assignSchemaDiagnostics, l as BasicBinding, m as RSModelStats, n as DiagnosticKind, o as formatDependencyCycle, p as RSModel, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic, u as BasicsContext, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-
|
|
2
|
+
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, a as detectDependencyCycleDiagnostics, b as CstStatus, c as modelStatusCstDiagnostic, d as DEFAULT_VALUE_TEXT, f as EvalStatus, g as ArgumentValue, i as assignSchemaDiagnostics, l as BasicBinding, m as RSModelStats, n as DiagnosticKind, o as formatDependencyCycle, p as RSModel, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic, u as BasicsContext, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-DC6QECex.js";
|
|
3
3
|
import { FolderNode, FolderTree } from "./folder-tree.js";
|
|
4
4
|
import { n as OssLayout, r as Position2D } from "../oss-layout-3glgAqfn.js";
|
|
5
5
|
import { Block, CstSubstituteInfo, NodeType, Operation, OperationInput, OperationSchema, OperationSchemaStats, OperationSynthesis, OperationType, OssItem, SubstitutionErrorDescription, SubstitutionErrorType } from "./oss.js";
|
|
6
6
|
import { RSEngine } from "./rsengine.js";
|
|
7
|
-
import { mt as TemplateSourceFields } from "../index-
|
|
7
|
+
import { mt as TemplateSourceFields } from "../index-CEOeehqz.js";
|
|
8
8
|
//#region src/library/template-instantiation.d.ts
|
|
9
9
|
/**
|
|
10
10
|
* Payload for one {@link Constituenta} to create when instantiating an expression-bank template.
|
|
@@ -73,13 +73,13 @@ interface TemplateInstantiationInput {
|
|
|
73
73
|
* and predicate-functions from `templateItems`, propagates argument bindings into nested calls,
|
|
74
74
|
* topologically orders dependencies, and remaps bank aliases to freshly generated target aliases.
|
|
75
75
|
*/
|
|
76
|
-
declare function planTemplateInstantiation(input: TemplateInstantiationInput): TemplateInstantiationPlan;
|
|
76
|
+
export declare function planTemplateInstantiation(input: TemplateInstantiationInput): TemplateInstantiationPlan;
|
|
77
77
|
/**
|
|
78
78
|
* Stateful planner for {@link planTemplateInstantiation}.
|
|
79
79
|
*
|
|
80
80
|
* Prefer the function wrapper unless you need to hold or reuse planner state between calls.
|
|
81
81
|
*/
|
|
82
|
-
declare class TemplateInstantiationPlanner {
|
|
82
|
+
export declare class TemplateInstantiationPlanner {
|
|
83
83
|
private readonly targetSchema;
|
|
84
84
|
private readonly prototype;
|
|
85
85
|
private readonly userArgs;
|
|
@@ -99,5 +99,5 @@ declare class TemplateInstantiationPlanner {
|
|
|
99
99
|
private collectDependencies;
|
|
100
100
|
}
|
|
101
101
|
//#endregion
|
|
102
|
-
export { AccessPolicy, type ArgumentValue, type Attribution, type BasicBinding, type BasicsContext, type Block, type Constituenta, CstClass, type CstDiagnostic, CstStatus, type CstSubstituteInfo, CstType, type CurrentVersion, DEFAULT_VALUE_TEXT, DiagnosticKind, EvalStatus, FolderNode, FolderTree, type LibraryItem, type LibraryItemReference, LibraryItemType, LocationHead, NodeType, type Operation, type OperationInput, type OperationSchema, type OperationSchemaStats, type OperationSynthesis, OperationType, type OssItem, type OssLayout, type Position2D, RSDiagnosticCode, RSEngine, type RSForm, type RSFormStats, type RSModel, type RSModelStats, type Substitution, type SubstitutionErrorDescription, SubstitutionErrorType, type TemplateBindingConflict, type TemplateInstantiationInput, type TemplateInstantiationItem, type TemplateInstantiationPlan,
|
|
102
|
+
export { AccessPolicy, type ArgumentValue, type Attribution, type BasicBinding, type BasicsContext, type Block, type Constituenta, CstClass, type CstDiagnostic, CstStatus, type CstSubstituteInfo, CstType, type CurrentVersion, DEFAULT_VALUE_TEXT, DiagnosticKind, EvalStatus, FolderNode, FolderTree, type LibraryItem, type LibraryItemReference, LibraryItemType, LocationHead, NodeType, type Operation, type OperationInput, type OperationSchema, type OperationSchemaStats, type OperationSynthesis, OperationType, type OssItem, type OssLayout, type Position2D, RSDiagnosticCode, RSEngine, type RSForm, type RSFormStats, type RSModel, type RSModelStats, type Substitution, type SubstitutionErrorDescription, SubstitutionErrorType, type TemplateBindingConflict, type TemplateInstantiationInput, type TemplateInstantiationItem, type TemplateInstantiationPlan, type TermForm, type TypeInfo, type VersionInfo, assignSchemaDiagnostics, detectDependencyCycleDiagnostics, formatDependencyCycle, hasCstDiagnostic, modelStatusCstDiagnostic };
|
|
103
103
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/library/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { TypeID } from "../rslang/semantic/typification.js";
|
|
|
5
5
|
import { labelType } from "../rslang/labels.js";
|
|
6
6
|
import { applyAliasMapping, isGlobalAlias, parseRSLangExpression, splitTemplateDefinition, substituteLocalAliases, substituteTemplateArgs } from "../rslang/api.js";
|
|
7
7
|
import { CstClass, CstStatus, CstType } from "./rsform.js";
|
|
8
|
-
import { $ as isFunctional, A as normalizeExpression, R as applyMappingToConstituents, V as generateAlias, a as formatDependencyCycle, i as detectDependencyCycleDiagnostics, k as inferTemplatedType, n as RSDiagnosticCode, o as hasCstDiagnostic, r as assignSchemaDiagnostics, s as modelStatusCstDiagnostic, t as DiagnosticKind, z as argumentValuesToMapping } from "../diagnostics-
|
|
8
|
+
import { $ as isFunctional, A as normalizeExpression, R as applyMappingToConstituents, V as generateAlias, a as formatDependencyCycle, i as detectDependencyCycleDiagnostics, k as inferTemplatedType, n as RSDiagnosticCode, o as hasCstDiagnostic, r as assignSchemaDiagnostics, s as modelStatusCstDiagnostic, t as DiagnosticKind, z as argumentValuesToMapping } from "../diagnostics-D_4TpAH4.js";
|
|
9
9
|
import { DEFAULT_VALUE_TEXT, EvalStatus } from "./rsmodel.js";
|
|
10
10
|
import { FolderNode, FolderTree } from "./folder-tree.js";
|
|
11
11
|
import { AccessPolicy, LibraryItemType, LocationHead } from "./library.js";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
//#region src/library/library-api.d.ts
|
|
2
2
|
/** Combining head and body into location. */
|
|
3
|
-
declare function combineLocation(head: string, body?: string): string;
|
|
3
|
+
export declare function combineLocation(head: string, body?: string): string;
|
|
4
4
|
/** Validation location against regexp. */
|
|
5
|
-
declare function validateLocationFormat(location: string): boolean;
|
|
5
|
+
export declare function validateLocationFormat(location: string): boolean;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { combineLocation, validateLocationFormat };
|
|
8
7
|
//# sourceMappingURL=library-api.d.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { r as LibraryItem } from "../library-CYun28Xz.js";
|
|
2
|
-
import { S as RSForm, v as Constituenta, w as Substitution } from "../diagnostics-
|
|
2
|
+
import { S as RSForm, v as Constituenta, w as Substitution } from "../diagnostics-DC6QECex.js";
|
|
3
3
|
import { NodeType, OperationSchema, SubstitutionErrorDescription } from "./oss.js";
|
|
4
4
|
//#region src/library/oss-api.d.ts
|
|
5
|
-
declare function constructNodeID(type: NodeType, itemID: number): string;
|
|
5
|
+
export declare function constructNodeID(type: NodeType, itemID: number): string;
|
|
6
6
|
/** Sorts library items relevant for the specified {@link OperationSchema}. */
|
|
7
|
-
declare function sortItemsForOSS(oss: OperationSchema, items: readonly LibraryItem[]): LibraryItem[];
|
|
7
|
+
export declare function sortItemsForOSS(oss: OperationSchema, items: readonly LibraryItem[]): LibraryItem[];
|
|
8
8
|
/** Validator for Substitution table. */
|
|
9
|
-
declare class SubstitutionValidator {
|
|
9
|
+
export declare class SubstitutionValidator {
|
|
10
10
|
errors: SubstitutionErrorDescription[];
|
|
11
11
|
suggestions: Substitution[];
|
|
12
12
|
private schemas;
|
|
@@ -38,7 +38,6 @@ declare class SubstitutionValidator {
|
|
|
38
38
|
private reportError;
|
|
39
39
|
}
|
|
40
40
|
/** Filter relocate candidates from gives schema. */
|
|
41
|
-
declare function getRelocateCandidates(source: number, destination: number, schema: RSForm, oss: OperationSchema): Constituenta[];
|
|
41
|
+
export declare function getRelocateCandidates(source: number, destination: number, schema: RSForm, oss: OperationSchema): Constituenta[];
|
|
42
42
|
//#endregion
|
|
43
|
-
export { SubstitutionValidator, constructNodeID, getRelocateCandidates, sortItemsForOSS };
|
|
44
43
|
//# sourceMappingURL=oss-api.d.ts.map
|
package/dist/library/oss-api.js
CHANGED
|
@@ -3,7 +3,7 @@ import { labelType } from "../rslang/labels.js";
|
|
|
3
3
|
import { applyAliasMapping, applyTypificationMapping, isSetTypification } from "../rslang/api.js";
|
|
4
4
|
import { CstClass, CstType } from "./rsform.js";
|
|
5
5
|
import { extractBases } from "../rslang/semantic/typification-api.js";
|
|
6
|
-
import { a as formatDependencyCycle } from "../diagnostics-
|
|
6
|
+
import { a as formatDependencyCycle } from "../diagnostics-D_4TpAH4.js";
|
|
7
7
|
import "../graph/index.js";
|
|
8
8
|
import { NodeType, SubstitutionErrorType } from "./oss.js";
|
|
9
9
|
//#region src/library/oss-api.ts
|
|
@@ -126,9 +126,7 @@ var SubstitutionValidator = class {
|
|
|
126
126
|
if (original.cst_type !== CstType.PREDICATE) return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);
|
|
127
127
|
break;
|
|
128
128
|
case CstType.TERM:
|
|
129
|
-
case CstType.STRUCTURED:
|
|
130
|
-
if (original.cst_type !== CstType.TERM && original.cst_type !== CstType.STRUCTURED && original.cst_type !== CstType.BASE) return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);
|
|
131
|
-
break;
|
|
129
|
+
case CstType.STRUCTURED: if (original.cst_type !== CstType.TERM && original.cst_type !== CstType.STRUCTURED && original.cst_type !== CstType.BASE) return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
132
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oss-api.js","names":[],"sources":["../../src/library/oss-api.ts"],"sourcesContent":["/**\n * Module: API for OperationSystem.\n */\n\nimport { Graph } from '../graph';\nimport { type AliasMapping, applyAliasMapping, applyTypificationMapping, isSetTypification } from '../rslang/api';\nimport { labelType } from '../rslang/labels';\nimport { extractBases } from '../rslang/semantic/typification-api';\n\nimport { formatDependencyCycle } from './diagnostics';\nimport { type LibraryItem } from './library';\nimport { NodeType, type OperationSchema, type SubstitutionErrorDescription, SubstitutionErrorType } from './oss';\nimport { type Constituenta, CstClass, CstType, type RSForm, type Substitution } from './rsform';\nimport { type FormalOrderFields } from './rsform-api';\n\nconst STARTING_SUB_INDEX = 900; // max semantic index for starting substitution\n\nexport function constructNodeID(type: NodeType, itemID: number): string {\n return type === NodeType.OPERATION ? 'o' + String(itemID) : 'b' + String(itemID);\n}\n\n/** Sorts library items relevant for the specified {@link OperationSchema}. */\nexport function sortItemsForOSS(oss: OperationSchema, items: readonly LibraryItem[]): LibraryItem[] {\n const result = items.filter(item => item.location === oss.location);\n for (const item of items) {\n if (item.visible && item.owner === oss.owner && !result.includes(item)) {\n result.push(item);\n }\n }\n for (const item of items) {\n if (item.visible && !result.includes(item)) {\n result.push(item);\n }\n }\n for (const item of items) {\n if (!result.includes(item)) {\n result.push(item);\n }\n }\n return result;\n}\n\ntype CrossMapping = Map<number, AliasMapping>;\n\n/** Validator for Substitution table. */\nexport class SubstitutionValidator {\n public errors: SubstitutionErrorDescription[] = [];\n public suggestions: Substitution[] = [];\n\n private schemas: RSForm[];\n private substitutions: Substitution[];\n private constituents = new Set<number>();\n private originals = new Set<number>();\n private mapping: CrossMapping = new Map();\n\n private cstByID = new Map<number, Constituenta>();\n private schemaByID = new Map<number, RSForm>();\n private schemaByCst = new Map<number, RSForm>();\n\n constructor(schemas: RSForm[], substitutions: Substitution[]) {\n this.schemas = schemas;\n this.substitutions = substitutions;\n if (schemas.length === 0) {\n return;\n }\n\n for (const schema of schemas) {\n this.schemaByID.set(schema.id, schema);\n this.mapping.set(schema.id, {});\n for (const item of schema.items) {\n this.cstByID.set(item.id, item);\n this.schemaByCst.set(item.id, schema);\n }\n }\n if (substitutions.length === 0) {\n return;\n }\n let index = STARTING_SUB_INDEX;\n for (const item of substitutions) {\n this.constituents.add(item.original);\n this.constituents.add(item.substitution);\n this.originals.add(item.original);\n const original = this.cstByID.get(item.original);\n const substitution = this.cstByID.get(item.substitution);\n if (!original || !substitution) {\n return;\n }\n index++;\n const newAlias = `${substitution.alias[0]}${index}`;\n this.mapping.get(original.schema)![original.alias] = newAlias;\n this.mapping.get(substitution.schema)![substitution.alias] = newAlias;\n }\n }\n\n public validate(): boolean {\n this.errors = [];\n this.suggestions = [];\n this.calculateSuggestions();\n if (this.substitutions.length === 0) {\n return true;\n }\n if (!this.checkTypes()) {\n return false;\n }\n if (!this.checkTypificationCycles()) {\n return false;\n }\n if (!this.checkDefinitionCycles()) {\n return false;\n }\n if (!this.checkSubstitutions()) {\n return false;\n }\n return true;\n }\n\n private calculateSuggestions(): void {\n const candidates = new Map<number, string>();\n const minors = new Set<number>();\n const schemaByCst = new Map<number, RSForm>();\n for (const schema of this.schemas) {\n for (const cst of schema.items) {\n if (this.originals.has(cst.id)) {\n continue;\n }\n if (cst.cst_class === CstClass.BASIC || cst.definition_formal.length === 0) {\n continue;\n }\n const inputs = schema.graph.at(cst.id)!.inputs;\n if (inputs.some(id => !this.constituents.has(id))) {\n continue;\n }\n if (inputs.some(id => this.originals.has(id))) {\n minors.add(cst.id);\n }\n candidates.set(\n cst.id,\n applyAliasMapping(cst.definition_formal, this.mapping.get(schema.id)!).replace(/\\s+/g, '')\n );\n schemaByCst.set(cst.id, schema);\n }\n }\n for (const [key1, value1] of candidates) {\n for (const [key2, value2] of candidates) {\n if (key1 >= key2) {\n continue;\n }\n if (schemaByCst.get(key1) === schemaByCst.get(key2)) {\n continue;\n }\n if (value1 != value2) {\n continue;\n }\n if (minors.has(key2)) {\n this.suggestions.push({\n original: key2,\n substitution: key1\n });\n } else {\n this.suggestions.push({\n original: key1,\n substitution: key2\n });\n }\n }\n }\n }\n\n private checkTypes(): boolean {\n for (const item of this.substitutions) {\n const original = this.cstByID.get(item.original);\n const substitution = this.cstByID.get(item.substitution);\n if (!original || !substitution) {\n return this.reportError(SubstitutionErrorType.invalidIDs, []);\n }\n if (\n substitution.analysis &&\n original.analysis &&\n (!original.analysis.success || !substitution.analysis.success)\n ) {\n return this.reportError(SubstitutionErrorType.incorrectCst, [substitution.alias, original.alias]);\n }\n switch (substitution.cst_type) {\n case CstType.NOMINAL: {\n if (original.cst_type !== CstType.NOMINAL) {\n return this.reportError(SubstitutionErrorType.invalidNominal, [substitution.alias, original.alias]);\n }\n break;\n }\n case CstType.BASE: {\n if (\n original.cst_type !== CstType.BASE &&\n original.cst_type !== CstType.CONSTANT &&\n original.cst_type !== CstType.NOMINAL\n ) {\n return this.reportError(SubstitutionErrorType.invalidBasic, [substitution.alias, original.alias]);\n }\n break;\n }\n\n case CstType.CONSTANT: {\n if (original.cst_type !== CstType.CONSTANT) {\n return this.reportError(SubstitutionErrorType.invalidConstant, [substitution.alias, original.alias]);\n }\n break;\n }\n\n case CstType.AXIOM:\n case CstType.STATEMENT: {\n if (original.cst_type !== CstType.AXIOM && original.cst_type !== CstType.STATEMENT) {\n return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);\n }\n break;\n }\n\n case CstType.FUNCTION: {\n if (original.cst_type !== CstType.FUNCTION) {\n return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);\n }\n break;\n }\n case CstType.PREDICATE: {\n if (original.cst_type !== CstType.PREDICATE) {\n return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);\n }\n break;\n }\n\n case CstType.TERM:\n case CstType.STRUCTURED: {\n if (\n original.cst_type !== CstType.TERM &&\n original.cst_type !== CstType.STRUCTURED &&\n original.cst_type !== CstType.BASE\n ) {\n return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);\n }\n break;\n }\n }\n }\n return true;\n }\n\n /**\n * Detect cycles among base/constant sets implied by typifications of non-base\n * constituents under the substitution table.\n */\n private checkTypificationCycles(): boolean {\n const graph = new Graph();\n for (const schema of this.schemas) {\n for (const cst of schema.items) {\n if (cst.cst_type === CstType.BASE || cst.cst_type === CstType.CONSTANT) {\n graph.addNode(cst.id);\n }\n }\n }\n for (const item of this.substitutions) {\n const original = this.cstByID.get(item.original)!;\n const substitution = this.cstByID.get(item.substitution)!;\n for (const cst of [original, substitution]) {\n if (cst.cst_type === CstType.BASE || cst.cst_type === CstType.CONSTANT) {\n continue;\n }\n graph.addNode(cst.id);\n if (cst.effectiveType === null) {\n continue;\n }\n const parents = extractBases(cst.effectiveType);\n if (parents.size === 0) {\n continue;\n }\n const schema = this.schemaByID.get(cst.schema)!;\n for (const alias of parents) {\n const parent = schema.cstByAlias.get(alias);\n if (parent) {\n graph.addEdge(parent.id, cst.id);\n }\n }\n }\n graph.addEdge(substitution.id, original.id);\n }\n const cycle = graph.findCycle();\n if (cycle !== null) {\n const cycleMsg = cycle\n .map(id => {\n const cst = this.cstByID.get(id)!;\n const schema = this.schemaByID.get(cst.schema)!;\n return `[${schema.alias}]-${cst.alias}`;\n })\n .join(', ');\n return this.reportError(SubstitutionErrorType.typificationCycle, [cycleMsg]);\n }\n return true;\n }\n\n /**\n * Detect logical cycles in formal definitions after applying the substitution table\n * (e.g. D16 := F2[D15] with identification D15 → D16 yields D16 := F2[D16]).\n */\n private checkDefinitionCycles(): boolean {\n const graph = new Graph();\n for (const schema of this.schemas) {\n for (const [id, node] of schema.graph.nodes) {\n graph.addNode(id);\n for (const output of node.outputs) {\n graph.addEdge(id, output);\n }\n }\n }\n\n const deleted = new Map<number, number>();\n for (const item of this.substitutions) {\n deleted.set(item.original, item.substitution);\n }\n const resolve = (id: number): number => deleted.get(id) ?? id;\n\n const result = new Graph();\n for (const id of graph.nodes.keys()) {\n if (!deleted.has(id)) {\n result.addNode(id);\n }\n }\n for (const substitutionId of deleted.values()) {\n result.addNode(substitutionId);\n }\n\n for (const [id, node] of graph.nodes) {\n for (const output of node.outputs) {\n if (deleted.has(output)) {\n continue;\n }\n result.addEdge(resolve(id), output);\n }\n }\n\n const cycle = result.findCycle();\n if (cycle !== null) {\n const aliases = cycle.map(id => {\n const cst = this.cstByID.get(id);\n if (!cst) {\n return String(id);\n }\n if (this.schemas.length > 1) {\n const schema = this.schemaByID.get(cst.schema);\n return schema ? `[${schema.alias}]-${cst.alias}` : cst.alias;\n }\n return cst.alias;\n });\n return this.reportError(SubstitutionErrorType.definitionCycle, [formatDependencyCycle(aliases)]);\n }\n return true;\n }\n\n private checkSubstitutions(): boolean {\n const baseMappings = this.prepareBaseMappings();\n const typeMappings = this.calculateSubstituteMappings(baseMappings);\n if (typeMappings === null) {\n return false;\n }\n for (const item of this.substitutions) {\n const original = this.cstByID.get(item.original)!;\n if (\n original.cst_type === CstType.BASE ||\n original.cst_type === CstType.CONSTANT ||\n original.cst_type === CstType.NOMINAL\n ) {\n continue;\n }\n const substitution = this.cstByID.get(item.substitution)!;\n if (original.cst_type === substitution.cst_type && original.cst_class !== CstClass.BASIC) {\n if (!this.checkEqual(original, substitution)) {\n this.reportError(SubstitutionErrorType.unequalExpressions, [substitution.alias, original.alias]);\n // Note: do not interrupt the validation process. Only warn about the problem.\n }\n }\n\n if (original.analysis.success !== substitution.analysis.success) {\n return this.reportError(SubstitutionErrorType.unequalTypification, [substitution.alias, original.alias]);\n }\n if (!original.analysis.success || !substitution.analysis.success) {\n continue;\n }\n\n const originalType = applyTypificationMapping(\n applyAliasMapping(labelType(original.effectiveType), baseMappings.get(original.schema)!),\n typeMappings\n );\n const substitutionType = applyTypificationMapping(\n applyAliasMapping(labelType(substitution.effectiveType), baseMappings.get(substitution.schema)!),\n typeMappings\n );\n if (originalType !== substitutionType) {\n return this.reportError(SubstitutionErrorType.unequalTypification, [substitution.alias, original.alias]);\n }\n }\n return true;\n }\n\n private prepareBaseMappings(): CrossMapping {\n const result: CrossMapping = new Map();\n let baseCount = 0;\n let constCount = 0;\n for (const schema of this.schemas) {\n const mapping: AliasMapping = {};\n for (const cst of schema.items) {\n if (cst.cst_type === CstType.BASE) {\n baseCount++;\n mapping[cst.alias] = `X${baseCount}`;\n } else if (cst.cst_type === CstType.CONSTANT) {\n constCount++;\n mapping[cst.alias] = `C${constCount}`;\n }\n result.set(schema.id, mapping);\n }\n }\n return result;\n }\n\n private calculateSubstituteMappings(baseMappings: CrossMapping): AliasMapping | null {\n const result: AliasMapping = {};\n const processed = new Set<string>();\n for (const item of this.substitutions) {\n const original = this.cstByID.get(item.original)!;\n if (original.cst_type !== CstType.BASE && original.cst_type !== CstType.CONSTANT) {\n continue;\n }\n const originalAlias = baseMappings.get(original.schema)![original.alias];\n\n const substitution = this.cstByID.get(item.substitution)!;\n let substitutionText = '';\n if (substitution.cst_type === original.cst_type || !substitution.effectiveType) {\n substitutionText = baseMappings.get(substitution.schema)![substitution.alias];\n } else {\n const typeText = labelType(substitution.effectiveType);\n substitutionText = applyAliasMapping(typeText, baseMappings.get(substitution.schema)!);\n substitutionText = applyTypificationMapping(substitutionText, result);\n if (!isSetTypification(substitutionText)) {\n this.reportError(SubstitutionErrorType.baseSubstitutionNotSet, [substitution.alias, typeText]);\n return null;\n }\n if (substitutionText.includes('×') || substitutionText.startsWith('ℬℬ')) {\n substitutionText = substitutionText.slice(1);\n } else {\n substitutionText = substitutionText.slice(2, -1);\n }\n }\n for (const prevAlias of processed) {\n result[prevAlias] = applyTypificationMapping(result[prevAlias], { [originalAlias]: substitutionText });\n }\n result[originalAlias] = substitutionText;\n processed.add(originalAlias);\n }\n return result;\n }\n\n private checkEqual(\n left: FormalOrderFields & { schema: number },\n right: FormalOrderFields & { schema: number }\n ): boolean {\n const schema1 = this.schemaByID.get(left.schema)!;\n const inputs1 = schema1.graph.at(left.id)!.inputs;\n if (inputs1.some(id => !this.constituents.has(id))) {\n return false;\n }\n const schema2 = this.schemaByID.get(right.schema)!;\n const inputs2 = schema2.graph.at(right.id)!.inputs;\n if (inputs2.some(id => !this.constituents.has(id))) {\n return false;\n }\n const expression1 = applyAliasMapping(left.definition_formal, this.mapping.get(schema1.id)!);\n const expression2 = applyAliasMapping(right.definition_formal, this.mapping.get(schema2.id)!);\n return expression1.replace(/\\s+/g, '') === expression2.replace(/\\s+/g, '');\n }\n\n private reportError(code: SubstitutionErrorType, params: string[]): boolean {\n this.errors.push({\n code,\n params\n });\n return false;\n }\n}\n\n/** Filter relocate candidates from gives schema. */\nexport function getRelocateCandidates(\n source: number,\n destination: number,\n schema: RSForm,\n oss: OperationSchema\n): Constituenta[] {\n const destinationSchema = oss.operationByID.get(destination)?.result;\n if (!destinationSchema) {\n return [];\n }\n const node = oss.graph.at(source);\n if (!node) {\n return [];\n }\n\n if (node.outputs.includes(destination)) {\n return schema.items;\n }\n\n const addedCst = schema.items.filter(item => !item.is_inherited).map(cst => cst.id);\n\n const unreachableBases: number[] = [];\n for (const cst of schema.items.filter(item => item.is_inherited)) {\n if (cst.parent_schema == destinationSchema) {\n continue;\n }\n const parent = schema.inheritance.find(item => item.child === cst.id && item.child_source === cst.schema)?.parent;\n if (parent) {\n const original = oss.substitutions.find(sub => sub.substitution === parent)?.original;\n if (original) {\n continue;\n }\n }\n unreachableBases.push(cst.id);\n }\n const unreachable = schema.graph.expandAllOutputs(unreachableBases);\n return schema.items.filter(\n cst => cst.parent_schema === destinationSchema || (addedCst.includes(cst.id) && !unreachable.includes(cst.id))\n );\n}\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,qBAAqB;AAE3B,SAAgB,gBAAgB,MAAgB,QAAwB;CACtE,OAAO,SAAS,SAAS,YAAY,MAAM,OAAO,MAAM,IAAI,MAAM,OAAO,MAAM;AACjF;;AAGA,SAAgB,gBAAgB,KAAsB,OAA8C;CAClG,MAAM,SAAS,MAAM,QAAO,SAAQ,KAAK,aAAa,IAAI,QAAQ;CAClE,KAAK,MAAM,QAAQ,OACjB,IAAI,KAAK,WAAW,KAAK,UAAU,IAAI,SAAS,CAAC,OAAO,SAAS,IAAI,GACnE,OAAO,KAAK,IAAI;CAGpB,KAAK,MAAM,QAAQ,OACjB,IAAI,KAAK,WAAW,CAAC,OAAO,SAAS,IAAI,GACvC,OAAO,KAAK,IAAI;CAGpB,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,OAAO,SAAS,IAAI,GACvB,OAAO,KAAK,IAAI;CAGpB,OAAO;AACT;;AAKA,IAAa,wBAAb,MAAmC;CACjC,SAAgD,CAAC;CACjD,cAAqC,CAAC;CAEtC;CACA;CACA,+BAAuB,IAAI,IAAY;CACvC,4BAAoB,IAAI,IAAY;CACpC,0BAAgC,IAAI,IAAI;CAExC,0BAAkB,IAAI,IAA0B;CAChD,6BAAqB,IAAI,IAAoB;CAC7C,8BAAsB,IAAI,IAAoB;CAE9C,YAAY,SAAmB,eAA+B;EAC5D,KAAK,UAAU;EACf,KAAK,gBAAgB;EACrB,IAAI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3E;EACF;EAEF,iBAAiB,KAAK,IAAI,EAAE;CAC9B;CACA,MAAM,cAAc,OAAO,MAAM,iBAAiB,gBAAgB;CAClE,OAAO,OAAO,MAAM,QAClB,QAAO,IAAI,kBAAkB,qBAAsB,SAAS,SAAS,IAAI,EAAE,KAAK,CAAC,YAAY,SAAS,IAAI,EAAE,CAC9G;AACF"}
|
|
1
|
+
{"version":3,"file":"oss-api.js","names":[],"sources":["../../src/library/oss-api.ts"],"sourcesContent":["/**\n * Module: API for OperationSystem.\n */\n\nimport { Graph } from '../graph';\nimport { type AliasMapping, applyAliasMapping, applyTypificationMapping, isSetTypification } from '../rslang/api';\nimport { labelType } from '../rslang/labels';\nimport { extractBases } from '../rslang/semantic/typification-api';\n\nimport { formatDependencyCycle } from './diagnostics';\nimport { type LibraryItem } from './library';\nimport { NodeType, type OperationSchema, type SubstitutionErrorDescription, SubstitutionErrorType } from './oss';\nimport { type Constituenta, CstClass, CstType, type RSForm, type Substitution } from './rsform';\nimport { type FormalOrderFields } from './rsform-api';\n\nconst STARTING_SUB_INDEX = 900; // max semantic index for starting substitution\n\nexport function constructNodeID(type: NodeType, itemID: number): string {\n return type === NodeType.OPERATION ? 'o' + String(itemID) : 'b' + String(itemID);\n}\n\n/** Sorts library items relevant for the specified {@link OperationSchema}. */\nexport function sortItemsForOSS(oss: OperationSchema, items: readonly LibraryItem[]): LibraryItem[] {\n const result = items.filter(item => item.location === oss.location);\n for (const item of items) {\n if (item.visible && item.owner === oss.owner && !result.includes(item)) {\n result.push(item);\n }\n }\n for (const item of items) {\n if (item.visible && !result.includes(item)) {\n result.push(item);\n }\n }\n for (const item of items) {\n if (!result.includes(item)) {\n result.push(item);\n }\n }\n return result;\n}\n\ntype CrossMapping = Map<number, AliasMapping>;\n\n/** Validator for Substitution table. */\nexport class SubstitutionValidator {\n public errors: SubstitutionErrorDescription[] = [];\n public suggestions: Substitution[] = [];\n\n private schemas: RSForm[];\n private substitutions: Substitution[];\n private constituents = new Set<number>();\n private originals = new Set<number>();\n private mapping: CrossMapping = new Map();\n\n private cstByID = new Map<number, Constituenta>();\n private schemaByID = new Map<number, RSForm>();\n private schemaByCst = new Map<number, RSForm>();\n\n constructor(schemas: RSForm[], substitutions: Substitution[]) {\n this.schemas = schemas;\n this.substitutions = substitutions;\n if (schemas.length === 0) {\n return;\n }\n\n for (const schema of schemas) {\n this.schemaByID.set(schema.id, schema);\n this.mapping.set(schema.id, {});\n for (const item of schema.items) {\n this.cstByID.set(item.id, item);\n this.schemaByCst.set(item.id, schema);\n }\n }\n if (substitutions.length === 0) {\n return;\n }\n let index = STARTING_SUB_INDEX;\n for (const item of substitutions) {\n this.constituents.add(item.original);\n this.constituents.add(item.substitution);\n this.originals.add(item.original);\n const original = this.cstByID.get(item.original);\n const substitution = this.cstByID.get(item.substitution);\n if (!original || !substitution) {\n return;\n }\n index++;\n const newAlias = `${substitution.alias[0]}${index}`;\n this.mapping.get(original.schema)![original.alias] = newAlias;\n this.mapping.get(substitution.schema)![substitution.alias] = newAlias;\n }\n }\n\n public validate(): boolean {\n this.errors = [];\n this.suggestions = [];\n this.calculateSuggestions();\n if (this.substitutions.length === 0) {\n return true;\n }\n if (!this.checkTypes()) {\n return false;\n }\n if (!this.checkTypificationCycles()) {\n return false;\n }\n if (!this.checkDefinitionCycles()) {\n return false;\n }\n if (!this.checkSubstitutions()) {\n return false;\n }\n return true;\n }\n\n private calculateSuggestions(): void {\n const candidates = new Map<number, string>();\n const minors = new Set<number>();\n const schemaByCst = new Map<number, RSForm>();\n for (const schema of this.schemas) {\n for (const cst of schema.items) {\n if (this.originals.has(cst.id)) {\n continue;\n }\n if (cst.cst_class === CstClass.BASIC || cst.definition_formal.length === 0) {\n continue;\n }\n const inputs = schema.graph.at(cst.id)!.inputs;\n if (inputs.some(id => !this.constituents.has(id))) {\n continue;\n }\n if (inputs.some(id => this.originals.has(id))) {\n minors.add(cst.id);\n }\n candidates.set(\n cst.id,\n applyAliasMapping(cst.definition_formal, this.mapping.get(schema.id)!).replace(/\\s+/g, '')\n );\n schemaByCst.set(cst.id, schema);\n }\n }\n for (const [key1, value1] of candidates) {\n for (const [key2, value2] of candidates) {\n if (key1 >= key2) {\n continue;\n }\n if (schemaByCst.get(key1) === schemaByCst.get(key2)) {\n continue;\n }\n if (value1 != value2) {\n continue;\n }\n if (minors.has(key2)) {\n this.suggestions.push({\n original: key2,\n substitution: key1\n });\n } else {\n this.suggestions.push({\n original: key1,\n substitution: key2\n });\n }\n }\n }\n }\n\n private checkTypes(): boolean {\n for (const item of this.substitutions) {\n const original = this.cstByID.get(item.original);\n const substitution = this.cstByID.get(item.substitution);\n if (!original || !substitution) {\n return this.reportError(SubstitutionErrorType.invalidIDs, []);\n }\n if (\n substitution.analysis &&\n original.analysis &&\n (!original.analysis.success || !substitution.analysis.success)\n ) {\n return this.reportError(SubstitutionErrorType.incorrectCst, [substitution.alias, original.alias]);\n }\n switch (substitution.cst_type) {\n case CstType.NOMINAL: {\n if (original.cst_type !== CstType.NOMINAL) {\n return this.reportError(SubstitutionErrorType.invalidNominal, [substitution.alias, original.alias]);\n }\n break;\n }\n case CstType.BASE: {\n if (\n original.cst_type !== CstType.BASE &&\n original.cst_type !== CstType.CONSTANT &&\n original.cst_type !== CstType.NOMINAL\n ) {\n return this.reportError(SubstitutionErrorType.invalidBasic, [substitution.alias, original.alias]);\n }\n break;\n }\n\n case CstType.CONSTANT: {\n if (original.cst_type !== CstType.CONSTANT) {\n return this.reportError(SubstitutionErrorType.invalidConstant, [substitution.alias, original.alias]);\n }\n break;\n }\n\n case CstType.AXIOM:\n case CstType.STATEMENT: {\n if (original.cst_type !== CstType.AXIOM && original.cst_type !== CstType.STATEMENT) {\n return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);\n }\n break;\n }\n\n case CstType.FUNCTION: {\n if (original.cst_type !== CstType.FUNCTION) {\n return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);\n }\n break;\n }\n case CstType.PREDICATE: {\n if (original.cst_type !== CstType.PREDICATE) {\n return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);\n }\n break;\n }\n\n case CstType.TERM:\n case CstType.STRUCTURED: {\n if (\n original.cst_type !== CstType.TERM &&\n original.cst_type !== CstType.STRUCTURED &&\n original.cst_type !== CstType.BASE\n ) {\n return this.reportError(SubstitutionErrorType.invalidClasses, [substitution.alias, original.alias]);\n }\n break;\n }\n }\n }\n return true;\n }\n\n /**\n * Detect cycles among base/constant sets implied by typifications of non-base\n * constituents under the substitution table.\n */\n private checkTypificationCycles(): boolean {\n const graph = new Graph();\n for (const schema of this.schemas) {\n for (const cst of schema.items) {\n if (cst.cst_type === CstType.BASE || cst.cst_type === CstType.CONSTANT) {\n graph.addNode(cst.id);\n }\n }\n }\n for (const item of this.substitutions) {\n const original = this.cstByID.get(item.original)!;\n const substitution = this.cstByID.get(item.substitution)!;\n for (const cst of [original, substitution]) {\n if (cst.cst_type === CstType.BASE || cst.cst_type === CstType.CONSTANT) {\n continue;\n }\n graph.addNode(cst.id);\n if (cst.effectiveType === null) {\n continue;\n }\n const parents = extractBases(cst.effectiveType);\n if (parents.size === 0) {\n continue;\n }\n const schema = this.schemaByID.get(cst.schema)!;\n for (const alias of parents) {\n const parent = schema.cstByAlias.get(alias);\n if (parent) {\n graph.addEdge(parent.id, cst.id);\n }\n }\n }\n graph.addEdge(substitution.id, original.id);\n }\n const cycle = graph.findCycle();\n if (cycle !== null) {\n const cycleMsg = cycle\n .map(id => {\n const cst = this.cstByID.get(id)!;\n const schema = this.schemaByID.get(cst.schema)!;\n return `[${schema.alias}]-${cst.alias}`;\n })\n .join(', ');\n return this.reportError(SubstitutionErrorType.typificationCycle, [cycleMsg]);\n }\n return true;\n }\n\n /**\n * Detect logical cycles in formal definitions after applying the substitution table\n * (e.g. D16 := F2[D15] with identification D15 → D16 yields D16 := F2[D16]).\n */\n private checkDefinitionCycles(): boolean {\n const graph = new Graph();\n for (const schema of this.schemas) {\n for (const [id, node] of schema.graph.nodes) {\n graph.addNode(id);\n for (const output of node.outputs) {\n graph.addEdge(id, output);\n }\n }\n }\n\n const deleted = new Map<number, number>();\n for (const item of this.substitutions) {\n deleted.set(item.original, item.substitution);\n }\n const resolve = (id: number): number => deleted.get(id) ?? id;\n\n const result = new Graph();\n for (const id of graph.nodes.keys()) {\n if (!deleted.has(id)) {\n result.addNode(id);\n }\n }\n for (const substitutionId of deleted.values()) {\n result.addNode(substitutionId);\n }\n\n for (const [id, node] of graph.nodes) {\n for (const output of node.outputs) {\n if (deleted.has(output)) {\n continue;\n }\n result.addEdge(resolve(id), output);\n }\n }\n\n const cycle = result.findCycle();\n if (cycle !== null) {\n const aliases = cycle.map(id => {\n const cst = this.cstByID.get(id);\n if (!cst) {\n return String(id);\n }\n if (this.schemas.length > 1) {\n const schema = this.schemaByID.get(cst.schema);\n return schema ? `[${schema.alias}]-${cst.alias}` : cst.alias;\n }\n return cst.alias;\n });\n return this.reportError(SubstitutionErrorType.definitionCycle, [formatDependencyCycle(aliases)]);\n }\n return true;\n }\n\n private checkSubstitutions(): boolean {\n const baseMappings = this.prepareBaseMappings();\n const typeMappings = this.calculateSubstituteMappings(baseMappings);\n if (typeMappings === null) {\n return false;\n }\n for (const item of this.substitutions) {\n const original = this.cstByID.get(item.original)!;\n if (\n original.cst_type === CstType.BASE ||\n original.cst_type === CstType.CONSTANT ||\n original.cst_type === CstType.NOMINAL\n ) {\n continue;\n }\n const substitution = this.cstByID.get(item.substitution)!;\n if (original.cst_type === substitution.cst_type && original.cst_class !== CstClass.BASIC) {\n if (!this.checkEqual(original, substitution)) {\n this.reportError(SubstitutionErrorType.unequalExpressions, [substitution.alias, original.alias]);\n // Note: do not interrupt the validation process. Only warn about the problem.\n }\n }\n\n if (original.analysis.success !== substitution.analysis.success) {\n return this.reportError(SubstitutionErrorType.unequalTypification, [substitution.alias, original.alias]);\n }\n if (!original.analysis.success || !substitution.analysis.success) {\n continue;\n }\n\n const originalType = applyTypificationMapping(\n applyAliasMapping(labelType(original.effectiveType), baseMappings.get(original.schema)!),\n typeMappings\n );\n const substitutionType = applyTypificationMapping(\n applyAliasMapping(labelType(substitution.effectiveType), baseMappings.get(substitution.schema)!),\n typeMappings\n );\n if (originalType !== substitutionType) {\n return this.reportError(SubstitutionErrorType.unequalTypification, [substitution.alias, original.alias]);\n }\n }\n return true;\n }\n\n private prepareBaseMappings(): CrossMapping {\n const result: CrossMapping = new Map();\n let baseCount = 0;\n let constCount = 0;\n for (const schema of this.schemas) {\n const mapping: AliasMapping = {};\n for (const cst of schema.items) {\n if (cst.cst_type === CstType.BASE) {\n baseCount++;\n mapping[cst.alias] = `X${baseCount}`;\n } else if (cst.cst_type === CstType.CONSTANT) {\n constCount++;\n mapping[cst.alias] = `C${constCount}`;\n }\n result.set(schema.id, mapping);\n }\n }\n return result;\n }\n\n private calculateSubstituteMappings(baseMappings: CrossMapping): AliasMapping | null {\n const result: AliasMapping = {};\n const processed = new Set<string>();\n for (const item of this.substitutions) {\n const original = this.cstByID.get(item.original)!;\n if (original.cst_type !== CstType.BASE && original.cst_type !== CstType.CONSTANT) {\n continue;\n }\n const originalAlias = baseMappings.get(original.schema)![original.alias];\n\n const substitution = this.cstByID.get(item.substitution)!;\n let substitutionText = '';\n if (substitution.cst_type === original.cst_type || !substitution.effectiveType) {\n substitutionText = baseMappings.get(substitution.schema)![substitution.alias];\n } else {\n const typeText = labelType(substitution.effectiveType);\n substitutionText = applyAliasMapping(typeText, baseMappings.get(substitution.schema)!);\n substitutionText = applyTypificationMapping(substitutionText, result);\n if (!isSetTypification(substitutionText)) {\n this.reportError(SubstitutionErrorType.baseSubstitutionNotSet, [substitution.alias, typeText]);\n return null;\n }\n if (substitutionText.includes('×') || substitutionText.startsWith('ℬℬ')) {\n substitutionText = substitutionText.slice(1);\n } else {\n substitutionText = substitutionText.slice(2, -1);\n }\n }\n for (const prevAlias of processed) {\n result[prevAlias] = applyTypificationMapping(result[prevAlias], { [originalAlias]: substitutionText });\n }\n result[originalAlias] = substitutionText;\n processed.add(originalAlias);\n }\n return result;\n }\n\n private checkEqual(\n left: FormalOrderFields & { schema: number },\n right: FormalOrderFields & { schema: number }\n ): boolean {\n const schema1 = this.schemaByID.get(left.schema)!;\n const inputs1 = schema1.graph.at(left.id)!.inputs;\n if (inputs1.some(id => !this.constituents.has(id))) {\n return false;\n }\n const schema2 = this.schemaByID.get(right.schema)!;\n const inputs2 = schema2.graph.at(right.id)!.inputs;\n if (inputs2.some(id => !this.constituents.has(id))) {\n return false;\n }\n const expression1 = applyAliasMapping(left.definition_formal, this.mapping.get(schema1.id)!);\n const expression2 = applyAliasMapping(right.definition_formal, this.mapping.get(schema2.id)!);\n return expression1.replace(/\\s+/g, '') === expression2.replace(/\\s+/g, '');\n }\n\n private reportError(code: SubstitutionErrorType, params: string[]): boolean {\n this.errors.push({\n code,\n params\n });\n return false;\n }\n}\n\n/** Filter relocate candidates from gives schema. */\nexport function getRelocateCandidates(\n source: number,\n destination: number,\n schema: RSForm,\n oss: OperationSchema\n): Constituenta[] {\n const destinationSchema = oss.operationByID.get(destination)?.result;\n if (!destinationSchema) {\n return [];\n }\n const node = oss.graph.at(source);\n if (!node) {\n return [];\n }\n\n if (node.outputs.includes(destination)) {\n return schema.items;\n }\n\n const addedCst = schema.items.filter(item => !item.is_inherited).map(cst => cst.id);\n\n const unreachableBases: number[] = [];\n for (const cst of schema.items.filter(item => item.is_inherited)) {\n if (cst.parent_schema == destinationSchema) {\n continue;\n }\n const parent = schema.inheritance.find(item => item.child === cst.id && item.child_source === cst.schema)?.parent;\n if (parent) {\n const original = oss.substitutions.find(sub => sub.substitution === parent)?.original;\n if (original) {\n continue;\n }\n }\n unreachableBases.push(cst.id);\n }\n const unreachable = schema.graph.expandAllOutputs(unreachableBases);\n return schema.items.filter(\n cst => cst.parent_schema === destinationSchema || (addedCst.includes(cst.id) && !unreachable.includes(cst.id))\n );\n}\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,qBAAqB;AAE3B,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AAY,QAAQ,QAAQ,EAAE,MAAM,YAAY,QAAQ,QAAQ,EAAE;CAC3E;CAEA,YAAoB,MAA6B,QAA2B;EAC1E,KAAK,OAAO,KAAK;GACf;GACA;EACF,CAAC;EACD,OAAO;CACT;AACF;;AAGA,SAAgB,sBACd,QACA,aACA,QACA,KACgB;CAChB,MAAM,oBAAoB,IAAI,cAAc,IAAI,WAAW,CAAC,EAAE;CAC9D,IAAI,CAAC,mBACH,OAAO,CAAC;CAEV,MAAM,OAAO,IAAI,MAAM,GAAG,MAAM;CAChC,IAAI,CAAC,MACH,OAAO,CAAC;CAGV,IAAI,KAAK,QAAQ,SAAS,WAAW,GACnC,OAAO,OAAO;CAGhB,MAAM,WAAW,OAAO,MAAM,QAAO,SAAQ,CAAC,KAAK,YAAY,CAAC,CAAC,KAAI,QAAO,IAAI,EAAE;CAElF,MAAM,mBAA6B,CAAC;CACpC,KAAK,MAAM,OAAO,OAAO,MAAM,QAAO,SAAQ,KAAK,YAAY,GAAG;EAChE,IAAI,IAAI,iBAAiB,mBACvB;EAEF,MAAM,SAAS,OAAO,YAAY,MAAK,SAAQ,KAAK,UAAU,IAAI,MAAM,KAAK,iBAAiB,IAAI,MAAM,CAAC,EAAE;EAC3G,IAAI,QAEF;OADiB,IAAI,cAAc,MAAK,QAAO,IAAI,iBAAiB,MAAM,CAAC,EAAE,UAE3E;EACF;EAEF,iBAAiB,KAAK,IAAI,EAAE;CAC9B;CACA,MAAM,cAAc,OAAO,MAAM,iBAAiB,gBAAgB;CAClE,OAAO,OAAO,MAAM,QAClB,QAAO,IAAI,kBAAkB,qBAAsB,SAAS,SAAS,IAAI,EAAE,KAAK,CAAC,YAAY,SAAS,IAAI,EAAE,CAC9G;AACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { i as Rectangle2D, n as OssLayout } from "../oss-layout-3glgAqfn.js";
|
|
2
2
|
import { OperationSchema } from "./oss.js";
|
|
3
3
|
//#region src/library/oss-layout-api.d.ts
|
|
4
|
-
declare const GRID_SIZE = 10;
|
|
5
|
-
declare const OPERATION_NODE_WIDTH = 150;
|
|
6
|
-
declare const OPERATION_NODE_HEIGHT = 40;
|
|
4
|
+
export declare const GRID_SIZE = 10;
|
|
5
|
+
export declare const OPERATION_NODE_WIDTH = 150;
|
|
6
|
+
export declare const OPERATION_NODE_HEIGHT = 40;
|
|
7
7
|
/** Layout manipulations for {@link OperationSchema}. */
|
|
8
|
-
declare class LayoutManager {
|
|
8
|
+
export declare class LayoutManager {
|
|
9
9
|
oss: OperationSchema;
|
|
10
10
|
layout: OssLayout;
|
|
11
11
|
constructor(oss: OperationSchema, layout?: OssLayout);
|
|
@@ -31,5 +31,4 @@ declare class LayoutManager {
|
|
|
31
31
|
private calculateOffsetForParentChange;
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
|
-
export { GRID_SIZE, LayoutManager, OPERATION_NODE_HEIGHT, OPERATION_NODE_WIDTH };
|
|
35
34
|
//# sourceMappingURL=oss-layout-api.d.ts.map
|
package/dist/library/oss.d.ts
CHANGED
|
@@ -4,25 +4,25 @@ import { r as LibraryItem } from "../library-CYun28Xz.js";
|
|
|
4
4
|
import { n as OssLayout, t as NodePosition } from "../oss-layout-3glgAqfn.js";
|
|
5
5
|
//#region src/library/oss.d.ts
|
|
6
6
|
/** Represents OSS node type. */
|
|
7
|
-
declare const NodeType: {
|
|
7
|
+
export declare const NodeType: {
|
|
8
8
|
readonly OPERATION: 1;
|
|
9
9
|
readonly BLOCK: 2;
|
|
10
10
|
};
|
|
11
|
-
type NodeType = (typeof NodeType)[keyof typeof NodeType];
|
|
11
|
+
export type NodeType = (typeof NodeType)[keyof typeof NodeType];
|
|
12
12
|
/** Represents OSS graph node. */
|
|
13
13
|
interface OssNode extends NodePosition {
|
|
14
14
|
nodeType: NodeType;
|
|
15
15
|
parent: number | null;
|
|
16
16
|
}
|
|
17
17
|
/** Represents {@link Operation} type. */
|
|
18
|
-
declare const OperationType: {
|
|
18
|
+
export declare const OperationType: {
|
|
19
19
|
readonly INPUT: "input";
|
|
20
20
|
readonly SYNTHESIS: "synthesis";
|
|
21
21
|
readonly REPLICA: "replica";
|
|
22
22
|
};
|
|
23
|
-
type OperationType = (typeof OperationType)[keyof typeof OperationType];
|
|
23
|
+
export type OperationType = (typeof OperationType)[keyof typeof OperationType];
|
|
24
24
|
/** Represents {@link Substitution} extended data. */
|
|
25
|
-
interface CstSubstituteInfo {
|
|
25
|
+
export interface CstSubstituteInfo {
|
|
26
26
|
original: number;
|
|
27
27
|
substitution: number;
|
|
28
28
|
operation: number;
|
|
@@ -45,7 +45,7 @@ interface OperationBase extends OssNode {
|
|
|
45
45
|
has_additions: boolean;
|
|
46
46
|
}
|
|
47
47
|
/** Represents Input Operation. */
|
|
48
|
-
interface OperationInput extends OperationBase {
|
|
48
|
+
export interface OperationInput extends OperationBase {
|
|
49
49
|
operation_type: typeof OperationType.INPUT;
|
|
50
50
|
is_import: boolean;
|
|
51
51
|
}
|
|
@@ -55,16 +55,16 @@ interface OperationReplica extends OperationBase {
|
|
|
55
55
|
target: number;
|
|
56
56
|
}
|
|
57
57
|
/** Represents Synthesis Operation. */
|
|
58
|
-
interface OperationSynthesis extends OperationBase {
|
|
58
|
+
export interface OperationSynthesis extends OperationBase {
|
|
59
59
|
operation_type: typeof OperationType.SYNTHESIS;
|
|
60
60
|
is_consolidation: boolean;
|
|
61
61
|
substitutions: CstSubstituteInfo[];
|
|
62
62
|
arguments: number[];
|
|
63
63
|
}
|
|
64
64
|
/** Represents Operation. */
|
|
65
|
-
type Operation = OperationInput | OperationReplica | OperationSynthesis;
|
|
65
|
+
export type Operation = OperationInput | OperationReplica | OperationSynthesis;
|
|
66
66
|
/** Represents Block. */
|
|
67
|
-
interface Block extends OssNode {
|
|
67
|
+
export interface Block extends OssNode {
|
|
68
68
|
id: number;
|
|
69
69
|
oss: number;
|
|
70
70
|
title: string;
|
|
@@ -73,9 +73,9 @@ interface Block extends OssNode {
|
|
|
73
73
|
nodeType: typeof NodeType.BLOCK;
|
|
74
74
|
}
|
|
75
75
|
/** Represents item of OperationSchema. */
|
|
76
|
-
type OssItem = Operation | Block;
|
|
76
|
+
export type OssItem = Operation | Block;
|
|
77
77
|
/** Represents {@link OperationSchema} statistics. */
|
|
78
|
-
interface OperationSchemaStats {
|
|
78
|
+
export interface OperationSchemaStats {
|
|
79
79
|
count_all: number;
|
|
80
80
|
count_inputs: number;
|
|
81
81
|
count_synthesis: number;
|
|
@@ -85,7 +85,7 @@ interface OperationSchemaStats {
|
|
|
85
85
|
count_references: number;
|
|
86
86
|
}
|
|
87
87
|
/** Represents OperationSchema. */
|
|
88
|
-
interface OperationSchema extends LibraryItem {
|
|
88
|
+
export interface OperationSchema extends LibraryItem {
|
|
89
89
|
editors: number[];
|
|
90
90
|
operations: Operation[];
|
|
91
91
|
blocks: Block[];
|
|
@@ -109,7 +109,7 @@ interface OperationSchema extends LibraryItem {
|
|
|
109
109
|
itemByNodeID: Map<string, OssItem>;
|
|
110
110
|
}
|
|
111
111
|
/** Represents substitution error description (same code space as {@link RSDiagnosticCode}). */
|
|
112
|
-
interface SubstitutionErrorDescription {
|
|
112
|
+
export interface SubstitutionErrorDescription {
|
|
113
113
|
code: SubstitutionErrorType;
|
|
114
114
|
params: string[];
|
|
115
115
|
}
|
|
@@ -117,7 +117,7 @@ interface SubstitutionErrorDescription {
|
|
|
117
117
|
* Substitution-table error codes — aliases into {@link RSDiagnosticCode}.
|
|
118
118
|
* Logical definition cycles reuse {@link RSDiagnosticCode.schemaDependencyCycle}.
|
|
119
119
|
*/
|
|
120
|
-
declare const SubstitutionErrorType: {
|
|
120
|
+
export declare const SubstitutionErrorType: {
|
|
121
121
|
readonly invalidIDs: 35104;
|
|
122
122
|
readonly incorrectCst: 35105;
|
|
123
123
|
readonly invalidClasses: 35106;
|
|
@@ -133,7 +133,7 @@ declare const SubstitutionErrorType: {
|
|
|
133
133
|
/** Same code as constituent schema dependency cycle. */
|
|
134
134
|
readonly definitionCycle: 35078;
|
|
135
135
|
};
|
|
136
|
-
type SubstitutionErrorType = (typeof SubstitutionErrorType)[keyof typeof SubstitutionErrorType];
|
|
136
|
+
export type SubstitutionErrorType = (typeof SubstitutionErrorType)[keyof typeof SubstitutionErrorType];
|
|
137
137
|
//#endregion
|
|
138
|
-
export {
|
|
138
|
+
export {};
|
|
139
139
|
//# sourceMappingURL=oss.d.ts.map
|
package/dist/library/oss.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as AstNode } from "../ast-D-D6Rq3T.js";
|
|
2
2
|
import "../index-D5RahF1K.js";
|
|
3
3
|
import { l as Value } from "../value-XpJOVzMP.js";
|
|
4
|
-
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../calculator-
|
|
5
|
-
import "../index-
|
|
6
|
-
import { S as RSForm, f as EvalStatus, l as BasicBinding, p as RSModel, u as BasicsContext, x as CstType } from "../diagnostics-
|
|
4
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../calculator-SVf1trzN.js";
|
|
5
|
+
import "../index-CEUOBGLn.js";
|
|
6
|
+
import { S as RSForm, f as EvalStatus, l as BasicBinding, p as RSModel, u as BasicsContext, x as CstType } from "../diagnostics-DC6QECex.js";
|
|
7
7
|
//#region src/library/rsengine.d.ts
|
|
8
8
|
/** Services for {@link RSEngine}. */
|
|
9
|
-
interface RSEngineServices {
|
|
9
|
+
export interface RSEngineServices {
|
|
10
10
|
setCstValue: (args: {
|
|
11
11
|
itemID: number;
|
|
12
12
|
data: {
|
|
@@ -23,12 +23,12 @@ interface RSEngineServices {
|
|
|
23
23
|
}) => Promise<unknown>;
|
|
24
24
|
}
|
|
25
25
|
/** Notifications for {@link RSEngine}. */
|
|
26
|
-
interface RSEngineNotifications {
|
|
26
|
+
export interface RSEngineNotifications {
|
|
27
27
|
onInvalidSetValue: () => void;
|
|
28
28
|
onCalculationSuccess: (timeSpent: string) => void;
|
|
29
29
|
}
|
|
30
30
|
/** Calculation engine for {@link RSModel}. */
|
|
31
|
-
declare class RSEngine {
|
|
31
|
+
export declare class RSEngine {
|
|
32
32
|
modelID: number;
|
|
33
33
|
schema: RSForm | null;
|
|
34
34
|
data: RSModel | null;
|
|
@@ -105,5 +105,4 @@ declare class RSEngine {
|
|
|
105
105
|
private recalculateInternal;
|
|
106
106
|
}
|
|
107
107
|
//#endregion
|
|
108
|
-
export { RSEngine, RSEngineNotifications, RSEngineServices };
|
|
109
108
|
//# sourceMappingURL=rsengine.d.ts.map
|
package/dist/library/rsengine.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TypeID } from "../rslang/semantic/typification.js";
|
|
2
2
|
import { normalizeType } from "../rslang/labels.js";
|
|
3
3
|
import { CstType } from "./rsform.js";
|
|
4
|
-
import { l as compare } from "../value-
|
|
4
|
+
import { l as compare } from "../value-BDISzQqI.js";
|
|
5
5
|
import { RSCalculator } from "../rslang/eval/calculator.js";
|
|
6
6
|
import "../rslang/index.js";
|
|
7
|
-
import { $ as isFunctional, P as getAnalysisFor, Q as isBasicConcept, Z as isBaseSet } from "../diagnostics-
|
|
7
|
+
import { $ as isFunctional, P as getAnalysisFor, Q as isBasicConcept, Z as isBaseSet } from "../diagnostics-D_4TpAH4.js";
|
|
8
8
|
import { TYPE_BASIC } from "./rsmodel.js";
|
|
9
9
|
import { inferEvalStatus, isInferrable, tryFixValue } from "./rsmodel-api.js";
|
|
10
10
|
//#region src/library/rsengine.ts
|
|
@@ -43,8 +43,8 @@ var RSEngine = class {
|
|
|
43
43
|
this.onChangeDefinitions(changedCst);
|
|
44
44
|
}
|
|
45
45
|
if (this.data !== model) {
|
|
46
|
+
this.prepareValues(model);
|
|
46
47
|
this.data = model;
|
|
47
|
-
this.prepareValues();
|
|
48
48
|
}
|
|
49
49
|
this.notifyAll();
|
|
50
50
|
}
|
|
@@ -66,7 +66,8 @@ var RSEngine = class {
|
|
|
66
66
|
getCstStatus(cstID) {
|
|
67
67
|
const cst = this.schema?.cstByID.get(cstID);
|
|
68
68
|
if (!cst) return inferEvalStatus(null, CstType.NOMINAL, false);
|
|
69
|
-
|
|
69
|
+
const value = this.calculator.getValue(cst.alias);
|
|
70
|
+
return inferEvalStatus(value, cst.cst_type, this.calculatedSet.has(cstID), this.invalidData.has(cstID));
|
|
70
71
|
}
|
|
71
72
|
/** Subscribe to value change of {@link Constituenta}. */
|
|
72
73
|
subscribeValue(cstID, callbackFn) {
|
|
@@ -183,16 +184,13 @@ var RSEngine = class {
|
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
|
-
|
|
187
|
+
await this.services.setCstValue({
|
|
187
188
|
itemID: this.modelID,
|
|
188
189
|
data: updateList
|
|
189
|
-
})
|
|
190
|
+
});
|
|
191
|
+
if (resetList.length > 0) await this.services.clearValues({
|
|
190
192
|
itemID: this.modelID,
|
|
191
193
|
data: { items: resetList }
|
|
192
|
-
})]);
|
|
193
|
-
else await this.services.setCstValue({
|
|
194
|
-
itemID: this.modelID,
|
|
195
|
-
data: updateList
|
|
196
194
|
});
|
|
197
195
|
const changed = [...resetList, ...updateList.map((item) => item.target)];
|
|
198
196
|
this.basics.set(cstID, data);
|
|
@@ -302,25 +300,26 @@ var RSEngine = class {
|
|
|
302
300
|
if (fullAnalysis.ast) this.calculator.setAST(cst.alias, fullAnalysis.ast);
|
|
303
301
|
}
|
|
304
302
|
}
|
|
305
|
-
prepareValues() {
|
|
303
|
+
prepareValues(model) {
|
|
306
304
|
this.basics.clear();
|
|
307
305
|
this.invalidData.clear();
|
|
308
306
|
this.calculatedSet.clear();
|
|
309
|
-
for (const item of
|
|
310
|
-
const cst = this.schema
|
|
311
|
-
if (item.type
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
this.calculator.setValue(cst.alias, Object.keys(data).map(Number));
|
|
307
|
+
for (const item of model.items) {
|
|
308
|
+
const cst = this.schema?.cstByID.get(item.id);
|
|
309
|
+
if (!cst || item.type !== "basic") continue;
|
|
310
|
+
if (!isBaseSet(cst.cst_type)) {
|
|
311
|
+
this.invalidData.add(item.id);
|
|
312
|
+
continue;
|
|
316
313
|
}
|
|
314
|
+
const data = item.value;
|
|
315
|
+
this.basics.set(cst.id, data);
|
|
316
|
+
this.calculator.setValue(cst.alias, Object.keys(data).map(Number));
|
|
317
317
|
}
|
|
318
|
-
for (const item of
|
|
319
|
-
const cst = this.schema
|
|
320
|
-
if (item.type
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
318
|
+
for (const item of model.items) {
|
|
319
|
+
const cst = this.schema?.cstByID.get(item.id);
|
|
320
|
+
if (!cst || item.type === "basic") continue;
|
|
321
|
+
this.calculator.setValue(cst.alias, item.value);
|
|
322
|
+
if (!cst.effectiveType || !this.calculator.validate(item.value, cst.effectiveType)) this.invalidData.add(item.id);
|
|
324
323
|
}
|
|
325
324
|
this.setupEmptySets();
|
|
326
325
|
}
|