@rsconcept/domain 2.3.0 → 3.0.1
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-fNhkwO-6.d.ts → analyzer-CzFaWR7w.d.ts} +4 -4
- package/dist/{api-Bf0f_uiI.d.ts → api-DgecYHjR.d.ts} +5 -3
- package/dist/{arguments-extractor-ngatANBI.d.ts → arguments-extractor-CXWRT5Ou.d.ts} +4 -4
- package/dist/{ast-C8sIpKdL.d.ts → ast-D-D6Rq3T.d.ts} +2 -3
- package/dist/{ast-annotations-CiIx8qBM.d.ts → ast-annotations-x4PJ_Lhc.d.ts} +4 -4
- package/dist/{calculator-DE89LtIM.d.ts → calculator-uPaTV3hc.d.ts} +5 -5
- package/dist/cctext/language-api.d.ts +0 -1
- package/dist/{diagnostics-CljEzVBV.js → diagnostics-D1Cp21nP.js} +36 -13
- package/dist/diagnostics-D1Cp21nP.js.map +1 -0
- package/dist/{diagnostics-Dac5sJhO.d.ts → diagnostics-DKyMf6q-.d.ts} +24 -8
- package/dist/{expression-generator-CoucLIkE.d.ts → expression-generator-CADzBw-C.d.ts} +3 -2
- package/dist/graph/index.d.ts +1 -0
- package/dist/index-CnuO4w8e.d.ts +13 -0
- package/dist/index-D5RahF1K.d.ts +2 -0
- package/dist/index-DCO4mxiO.d.ts +378 -0
- package/dist/index-DntDUXW1.d.ts +1 -0
- package/dist/index-x0_Y5uPV.d.ts +2 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.js +1 -1
- package/dist/{lezer-tree-iS7LpLBJ.d.ts → lezer-tree-BQZqBT5A.d.ts} +1 -2
- package/dist/library/diagnostics.d.ts +1 -1
- package/dist/library/diagnostics.js +1 -1
- package/dist/library/index.d.ts +5 -5
- package/dist/library/index.js +1 -1
- package/dist/library/index.js.map +1 -1
- package/dist/library/oss-api.d.ts +11 -3
- package/dist/library/oss-api.js +45 -4
- package/dist/library/oss-api.js.map +1 -1
- package/dist/library/oss-layout-api.d.ts +0 -1
- package/dist/library/oss.d.ts +21 -16
- package/dist/library/oss.js +19 -13
- package/dist/library/oss.js.map +1 -1
- package/dist/library/rsengine.d.ts +6 -5
- package/dist/library/rsengine.js +1 -1
- package/dist/library/rsform-api/index.d.ts +2 -299
- package/dist/library/rsform-api/index.js +1 -1
- package/dist/library/rsform.d.ts +1 -1
- package/dist/library/rsmodel-api.d.ts +12 -7
- package/dist/library/rsmodel-api.js +6 -2
- package/dist/library/rsmodel-api.js.map +1 -1
- package/dist/library/rsmodel.d.ts +1 -1
- package/dist/library/structure-planner.d.ts +3 -3
- package/dist/library/structure-planner.js +1 -1
- package/dist/library/structure-planner.js.map +1 -1
- package/dist/{parser-Bwd8LxJ1.d.ts → parser-DkejtiOR.d.ts} +1 -2
- package/dist/parsing/ast.d.ts +1 -1
- package/dist/parsing/index.d.ts +3 -2
- package/dist/parsing/lezer-tree.d.ts +1 -1
- package/dist/rslang/api.d.ts +2 -2
- package/dist/rslang/ast-annotations.d.ts +1 -1
- package/dist/rslang/eval/calculator.d.ts +1 -1
- package/dist/rslang/eval/evaluation-cache.d.ts +3 -3
- package/dist/rslang/eval/evaluator.d.ts +3 -3
- package/dist/rslang/eval/value-api.d.ts +1 -1
- package/dist/rslang/eval/value.d.ts +1 -1
- package/dist/rslang/index.d.ts +11 -10
- package/dist/rslang/labels.d.ts +3 -3
- package/dist/rslang/parser/expression-generator.d.ts +1 -1
- package/dist/rslang/parser/normalize.d.ts +2 -1
- package/dist/rslang/parser/parser.d.ts +1 -1
- package/dist/rslang/parser/parser.terms.d.ts +1 -40
- package/dist/rslang/parser/syntax-errors/index.d.ts +3 -3
- package/dist/rslang/semantic/analyzer.d.ts +1 -1
- package/dist/rslang/semantic/arguments-extractor.d.ts +1 -1
- package/dist/rslang/semantic/type-auditor.d.ts +3 -3
- package/dist/rslang/semantic/typification-api.d.ts +1 -2
- package/dist/rslang/semantic/typification-parser.d.ts +1 -1
- package/dist/rslang/semantic/typification.d.ts +1 -1
- package/dist/rslang/semantic/value-auditor.d.ts +2 -2
- package/dist/rslang/typification-graph.d.ts +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/{typification-graph-BY_oGT82.d.ts → typification-graph-CSxDt18X.d.ts} +2 -3
- package/dist/{typification-9lNu9R4k.d.ts → typification-hWUoWCba.d.ts} +2 -1
- package/dist/{typification-parser-Dytsv9CI.d.ts → typification-parser-DFxj4JiQ.d.ts} +2 -3
- package/dist/{value-BduA_ZGp.d.ts → value-XpJOVzMP.d.ts} +2 -1
- package/dist/{value-api-CXLl_zg0.d.ts → value-api-Dw8UkwCD.d.ts} +3 -4
- package/package.json +8 -8
- package/src/library/diagnostics.ts +36 -11
- package/src/library/oss-api.test.ts +100 -5
- package/src/library/oss-api.ts +76 -6
- package/src/library/oss.ts +22 -16
- package/src/library/rsform-api/alias.ts +8 -8
- package/src/library/rsform-api/cst-type.ts +7 -5
- package/src/library/rsform-api/expression.ts +3 -3
- package/src/library/rsform-api/formal-graph.test.ts +2 -2
- package/src/library/rsform-api/formal-graph.ts +6 -10
- package/src/library/rsform-api/index.ts +18 -3
- package/src/library/rsform-api/semantic-relations.ts +4 -7
- package/src/library/rsform-api/stats.ts +6 -5
- package/src/library/rsform-api/structure.ts +12 -6
- package/src/library/rsform-api/substitution.ts +2 -2
- package/src/library/rsform-api/synthesis.test.ts +33 -2
- package/src/library/rsform-api/synthesis.ts +16 -12
- package/src/library/rsform-api/text-resolution.test.ts +2 -4
- package/src/library/rsform-api/text-resolution.ts +8 -8
- package/src/library/rsform-api/types.ts +89 -8
- package/src/library/rsmodel-api.ts +10 -5
- package/src/library/structure-planner.ts +6 -2
- package/src/library/template-instantiation.ts +11 -9
- package/dist/diagnostics-CljEzVBV.js.map +0 -1
- package/dist/index-BKZ67WMa.d.ts +0 -1
- package/dist/index-BVVgDSdq.d.ts +0 -1
- package/dist/index-DmtQKWjk.d.ts +0 -1
- package/dist/index-_6s0AX1B.d.ts +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
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-DKyMf6q-.js";
|
|
3
3
|
import { NodeType, OperationSchema, SubstitutionErrorDescription } from "./oss.js";
|
|
4
|
-
|
|
5
4
|
//#region src/library/oss-api.d.ts
|
|
6
5
|
declare function constructNodeID(type: NodeType, itemID: number): string;
|
|
7
6
|
/** Sorts library items relevant for the specified {@link OperationSchema}. */
|
|
@@ -22,7 +21,16 @@ declare class SubstitutionValidator {
|
|
|
22
21
|
validate(): boolean;
|
|
23
22
|
private calculateSuggestions;
|
|
24
23
|
private checkTypes;
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Detect cycles among base/constant sets implied by typifications of non-base
|
|
26
|
+
* constituents under the substitution table.
|
|
27
|
+
*/
|
|
28
|
+
private checkTypificationCycles;
|
|
29
|
+
/**
|
|
30
|
+
* Detect logical cycles in formal definitions after applying the substitution table
|
|
31
|
+
* (e.g. D16 := F2[D15] with identification D15 → D16 yields D16 := F2[D16]).
|
|
32
|
+
*/
|
|
33
|
+
private checkDefinitionCycles;
|
|
26
34
|
private checkSubstitutions;
|
|
27
35
|
private prepareBaseMappings;
|
|
28
36
|
private calculateSubstituteMappings;
|
package/dist/library/oss-api.js
CHANGED
|
@@ -3,6 +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-D1Cp21nP.js";
|
|
6
7
|
import "../graph/index.js";
|
|
7
8
|
import { NodeType, SubstitutionErrorType } from "./oss.js";
|
|
8
9
|
//#region src/library/oss-api.ts
|
|
@@ -66,7 +67,8 @@ var SubstitutionValidator = class {
|
|
|
66
67
|
this.calculateSuggestions();
|
|
67
68
|
if (this.substitutions.length === 0) return true;
|
|
68
69
|
if (!this.checkTypes()) return false;
|
|
69
|
-
if (!this.
|
|
70
|
+
if (!this.checkTypificationCycles()) return false;
|
|
71
|
+
if (!this.checkDefinitionCycles()) return false;
|
|
70
72
|
if (!this.checkSubstitutions()) return false;
|
|
71
73
|
return true;
|
|
72
74
|
}
|
|
@@ -131,7 +133,11 @@ var SubstitutionValidator = class {
|
|
|
131
133
|
}
|
|
132
134
|
return true;
|
|
133
135
|
}
|
|
134
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Detect cycles among base/constant sets implied by typifications of non-base
|
|
138
|
+
* constituents under the substitution table.
|
|
139
|
+
*/
|
|
140
|
+
checkTypificationCycles() {
|
|
135
141
|
const graph = new Graph();
|
|
136
142
|
for (const schema of this.schemas) for (const cst of schema.items) if (cst.cst_type === CstType.BASE || cst.cst_type === CstType.CONSTANT) graph.addNode(cst.id);
|
|
137
143
|
for (const item of this.substitutions) {
|
|
@@ -161,6 +167,41 @@ var SubstitutionValidator = class {
|
|
|
161
167
|
}
|
|
162
168
|
return true;
|
|
163
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Detect logical cycles in formal definitions after applying the substitution table
|
|
172
|
+
* (e.g. D16 := F2[D15] with identification D15 → D16 yields D16 := F2[D16]).
|
|
173
|
+
*/
|
|
174
|
+
checkDefinitionCycles() {
|
|
175
|
+
const graph = new Graph();
|
|
176
|
+
for (const schema of this.schemas) for (const [id, node] of schema.graph.nodes) {
|
|
177
|
+
graph.addNode(id);
|
|
178
|
+
for (const output of node.outputs) graph.addEdge(id, output);
|
|
179
|
+
}
|
|
180
|
+
const deleted = /* @__PURE__ */ new Map();
|
|
181
|
+
for (const item of this.substitutions) deleted.set(item.original, item.substitution);
|
|
182
|
+
const resolve = (id) => deleted.get(id) ?? id;
|
|
183
|
+
const result = new Graph();
|
|
184
|
+
for (const id of graph.nodes.keys()) if (!deleted.has(id)) result.addNode(id);
|
|
185
|
+
for (const substitutionId of deleted.values()) result.addNode(substitutionId);
|
|
186
|
+
for (const [id, node] of graph.nodes) for (const output of node.outputs) {
|
|
187
|
+
if (deleted.has(output)) continue;
|
|
188
|
+
result.addEdge(resolve(id), output);
|
|
189
|
+
}
|
|
190
|
+
const cycle = result.findCycle();
|
|
191
|
+
if (cycle !== null) {
|
|
192
|
+
const aliases = cycle.map((id) => {
|
|
193
|
+
const cst = this.cstByID.get(id);
|
|
194
|
+
if (!cst) return String(id);
|
|
195
|
+
if (this.schemas.length > 1) {
|
|
196
|
+
const schema = this.schemaByID.get(cst.schema);
|
|
197
|
+
return schema ? `[${schema.alias}]-${cst.alias}` : cst.alias;
|
|
198
|
+
}
|
|
199
|
+
return cst.alias;
|
|
200
|
+
});
|
|
201
|
+
return this.reportError(SubstitutionErrorType.definitionCycle, [formatDependencyCycle(aliases)]);
|
|
202
|
+
}
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
164
205
|
checkSubstitutions() {
|
|
165
206
|
const baseMappings = this.prepareBaseMappings();
|
|
166
207
|
const typeMappings = this.calculateSubstituteMappings(baseMappings);
|
|
@@ -233,9 +274,9 @@ var SubstitutionValidator = class {
|
|
|
233
274
|
const expression2 = applyAliasMapping(right.definition_formal, this.mapping.get(schema2.id));
|
|
234
275
|
return expression1.replace(/\s+/g, "") === expression2.replace(/\s+/g, "");
|
|
235
276
|
}
|
|
236
|
-
reportError(
|
|
277
|
+
reportError(code, params) {
|
|
237
278
|
this.errors.push({
|
|
238
|
-
|
|
279
|
+
code,
|
|
239
280
|
params
|
|
240
281
|
});
|
|
241
282
|
return false;
|
|
@@ -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 { type LibraryItem } from './library';\nimport { NodeType, type OperationSchema, type SubstitutionErrorDescription, SubstitutionErrorType } from './oss';\nimport { type Constituenta, CstClass, CstType, type RSForm, type Substitution } from './rsform';\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.checkCycles()) {\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 private checkCycles(): 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 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(left: Constituenta, right: Constituenta): 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(errorType: SubstitutionErrorType, params: string[]): boolean {\n this.errors.push({\n errorType: errorType,\n params: 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":";;;;;;;;;;;AAaA,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;CACl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AAgB,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
|
+
{"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,MA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C;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"}
|
package/dist/library/oss.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Graph } from "../graph-CL73WdW1.js";
|
|
2
|
+
import "../index-DntDUXW1.js";
|
|
2
3
|
import { r as LibraryItem } from "../library-CYun28Xz.js";
|
|
3
4
|
import { n as OssLayout, t as NodePosition } from "../oss-layout-3glgAqfn.js";
|
|
4
|
-
|
|
5
5
|
//#region src/library/oss.d.ts
|
|
6
6
|
/** Represents OSS node type. */
|
|
7
7
|
declare const NodeType: {
|
|
@@ -108,25 +108,30 @@ interface OperationSchema extends LibraryItem {
|
|
|
108
108
|
blockByID: Map<number, Block>;
|
|
109
109
|
itemByNodeID: Map<string, OssItem>;
|
|
110
110
|
}
|
|
111
|
-
/** Represents substitution error description. */
|
|
111
|
+
/** Represents substitution error description (same code space as {@link RSDiagnosticCode}). */
|
|
112
112
|
interface SubstitutionErrorDescription {
|
|
113
|
-
|
|
113
|
+
code: SubstitutionErrorType;
|
|
114
114
|
params: string[];
|
|
115
115
|
}
|
|
116
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Substitution-table error codes — aliases into {@link RSDiagnosticCode}.
|
|
118
|
+
* Logical definition cycles reuse {@link RSDiagnosticCode.schemaDependencyCycle}.
|
|
119
|
+
*/
|
|
117
120
|
declare const SubstitutionErrorType: {
|
|
118
|
-
readonly invalidIDs:
|
|
119
|
-
readonly incorrectCst:
|
|
120
|
-
readonly invalidClasses:
|
|
121
|
-
readonly invalidBasic:
|
|
122
|
-
readonly invalidConstant:
|
|
123
|
-
readonly typificationCycle:
|
|
124
|
-
readonly baseSubstitutionNotSet:
|
|
125
|
-
readonly unequalTypification:
|
|
126
|
-
readonly unequalExpressions:
|
|
127
|
-
readonly unequalArgsCount:
|
|
128
|
-
readonly unequalArgs:
|
|
129
|
-
readonly invalidNominal:
|
|
121
|
+
readonly invalidIDs: 35104;
|
|
122
|
+
readonly incorrectCst: 35105;
|
|
123
|
+
readonly invalidClasses: 35106;
|
|
124
|
+
readonly invalidBasic: 35107;
|
|
125
|
+
readonly invalidConstant: 35108;
|
|
126
|
+
readonly typificationCycle: 35109;
|
|
127
|
+
readonly baseSubstitutionNotSet: 35110;
|
|
128
|
+
readonly unequalTypification: 35111;
|
|
129
|
+
readonly unequalExpressions: 10536;
|
|
130
|
+
readonly unequalArgsCount: 35113;
|
|
131
|
+
readonly unequalArgs: 35114;
|
|
132
|
+
readonly invalidNominal: 35115;
|
|
133
|
+
/** Same code as constituent schema dependency cycle. */
|
|
134
|
+
readonly definitionCycle: 35078;
|
|
130
135
|
};
|
|
131
136
|
type SubstitutionErrorType = (typeof SubstitutionErrorType)[keyof typeof SubstitutionErrorType];
|
|
132
137
|
//#endregion
|
package/dist/library/oss.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as RSDiagnosticCode } from "../diagnostics-D1Cp21nP.js";
|
|
1
2
|
//#region src/library/oss.ts
|
|
2
3
|
/** Represents OSS node type. */
|
|
3
4
|
const NodeType = {
|
|
@@ -10,20 +11,25 @@ const OperationType = {
|
|
|
10
11
|
SYNTHESIS: "synthesis",
|
|
11
12
|
REPLICA: "replica"
|
|
12
13
|
};
|
|
13
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Substitution-table error codes — aliases into {@link RSDiagnosticCode}.
|
|
16
|
+
* Logical definition cycles reuse {@link RSDiagnosticCode.schemaDependencyCycle}.
|
|
17
|
+
*/
|
|
14
18
|
const SubstitutionErrorType = {
|
|
15
|
-
invalidIDs:
|
|
16
|
-
incorrectCst:
|
|
17
|
-
invalidClasses:
|
|
18
|
-
invalidBasic:
|
|
19
|
-
invalidConstant:
|
|
20
|
-
typificationCycle:
|
|
21
|
-
baseSubstitutionNotSet:
|
|
22
|
-
unequalTypification:
|
|
23
|
-
unequalExpressions:
|
|
24
|
-
unequalArgsCount:
|
|
25
|
-
unequalArgs:
|
|
26
|
-
invalidNominal:
|
|
19
|
+
invalidIDs: RSDiagnosticCode.substitutionInvalidIDs,
|
|
20
|
+
incorrectCst: RSDiagnosticCode.substitutionIncorrectCst,
|
|
21
|
+
invalidClasses: RSDiagnosticCode.substitutionInvalidClasses,
|
|
22
|
+
invalidBasic: RSDiagnosticCode.substitutionInvalidBasic,
|
|
23
|
+
invalidConstant: RSDiagnosticCode.substitutionInvalidConstant,
|
|
24
|
+
typificationCycle: RSDiagnosticCode.substitutionTypificationCycle,
|
|
25
|
+
baseSubstitutionNotSet: RSDiagnosticCode.substitutionBaseNotSet,
|
|
26
|
+
unequalTypification: RSDiagnosticCode.substitutionUnequalTypification,
|
|
27
|
+
unequalExpressions: RSDiagnosticCode.substitutionUnequalExpressions,
|
|
28
|
+
unequalArgsCount: RSDiagnosticCode.substitutionUnequalArgsCount,
|
|
29
|
+
unequalArgs: RSDiagnosticCode.substitutionUnequalArgs,
|
|
30
|
+
invalidNominal: RSDiagnosticCode.substitutionInvalidNominal,
|
|
31
|
+
/** Same code as constituent schema dependency cycle. */
|
|
32
|
+
definitionCycle: RSDiagnosticCode.schemaDependencyCycle
|
|
27
33
|
};
|
|
28
34
|
//#endregion
|
|
29
35
|
export { NodeType, OperationType, SubstitutionErrorType };
|
package/dist/library/oss.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oss.js","names":[],"sources":["../../src/library/oss.ts"],"sourcesContent":["/**\n * Module: Schema of Synthesis Operations.\n */\n\nimport { type Graph } from '../graph';\n\nimport { type LibraryItem } from './library';\nimport { type NodePosition, type OssLayout } from './oss-layout';\n\n/** Represents OSS node type. */\nexport const NodeType = {\n OPERATION: 1,\n BLOCK: 2\n} as const;\nexport type NodeType = (typeof NodeType)[keyof typeof NodeType];\n\n/** Represents OSS graph node. */\ninterface OssNode extends NodePosition {\n nodeType: NodeType;\n parent: number | null;\n}\n\n/** Represents {@link Operation} type. */\nexport const OperationType = {\n INPUT: 'input',\n SYNTHESIS: 'synthesis',\n REPLICA: 'replica'\n} as const;\nexport type OperationType = (typeof OperationType)[keyof typeof OperationType];\n\n/** Represents {@link Substitution} extended data. */\nexport interface CstSubstituteInfo {\n original: number;\n substitution: number;\n operation: number;\n original_schema: number;\n original_alias: string;\n original_term: string;\n substitution_schema: number;\n substitution_alias: string;\n substitution_term: string;\n}\n\n/** Represents Operation common attributes. */\ninterface OperationBase extends OssNode {\n id: number;\n alias: string;\n title: string;\n description: string;\n operation_type: OperationType;\n result: number | null;\n nodeType: typeof NodeType.OPERATION;\n has_additions: boolean;\n}\n\n/** Represents Input Operation. */\nexport interface OperationInput extends OperationBase {\n operation_type: typeof OperationType.INPUT;\n is_import: boolean;\n}\n\n/** Represents Replica Operation. */\ninterface OperationReplica extends OperationBase {\n operation_type: typeof OperationType.REPLICA;\n target: number;\n}\n\n/** Represents Synthesis Operation. */\nexport interface OperationSynthesis extends OperationBase {\n operation_type: typeof OperationType.SYNTHESIS;\n is_consolidation: boolean; // aka 'diamond synthesis'\n substitutions: CstSubstituteInfo[];\n arguments: number[];\n}\n\n/** Represents Operation. */\nexport type Operation = OperationInput | OperationReplica | OperationSynthesis;\n\n/** Represents Block. */\nexport interface Block extends OssNode {\n id: number;\n oss: number;\n title: string;\n description: string;\n parent: number | null;\n nodeType: typeof NodeType.BLOCK;\n}\n\n/** Represents item of OperationSchema. */\nexport type OssItem = Operation | Block;\n\n/** Represents {@link OperationSchema} statistics. */\nexport interface OperationSchemaStats {\n count_all: number;\n count_inputs: number;\n count_synthesis: number;\n count_schemas: number;\n count_owned: number;\n count_block: number;\n count_references: number;\n}\n\n/** Represents OperationSchema. */\nexport interface OperationSchema extends LibraryItem {\n editors: number[];\n operations: Operation[];\n blocks: Block[];\n replicas: {\n original: number;\n replica: number;\n }[];\n layout: OssLayout;\n arguments: {\n operation: number;\n argument: number;\n }[];\n substitutions: CstSubstituteInfo[];\n\n graph: Graph;\n extendedGraph: Graph;\n hierarchy: Graph<string>;\n schemas: number[];\n stats: OperationSchemaStats;\n operationByID: Map<number, Operation>;\n blockByID: Map<number, Block>;\n itemByNodeID: Map<string, OssItem>;\n}\n\n/** Represents substitution error description. */\nexport interface SubstitutionErrorDescription {\n
|
|
1
|
+
{"version":3,"file":"oss.js","names":[],"sources":["../../src/library/oss.ts"],"sourcesContent":["/**\n * Module: Schema of Synthesis Operations.\n */\n\nimport { type Graph } from '../graph';\n\nimport { RSDiagnosticCode } from './diagnostics';\nimport { type LibraryItem } from './library';\nimport { type NodePosition, type OssLayout } from './oss-layout';\n\n/** Represents OSS node type. */\nexport const NodeType = {\n OPERATION: 1,\n BLOCK: 2\n} as const;\nexport type NodeType = (typeof NodeType)[keyof typeof NodeType];\n\n/** Represents OSS graph node. */\ninterface OssNode extends NodePosition {\n nodeType: NodeType;\n parent: number | null;\n}\n\n/** Represents {@link Operation} type. */\nexport const OperationType = {\n INPUT: 'input',\n SYNTHESIS: 'synthesis',\n REPLICA: 'replica'\n} as const;\nexport type OperationType = (typeof OperationType)[keyof typeof OperationType];\n\n/** Represents {@link Substitution} extended data. */\nexport interface CstSubstituteInfo {\n original: number;\n substitution: number;\n operation: number;\n original_schema: number;\n original_alias: string;\n original_term: string;\n substitution_schema: number;\n substitution_alias: string;\n substitution_term: string;\n}\n\n/** Represents Operation common attributes. */\ninterface OperationBase extends OssNode {\n id: number;\n alias: string;\n title: string;\n description: string;\n operation_type: OperationType;\n result: number | null;\n nodeType: typeof NodeType.OPERATION;\n has_additions: boolean;\n}\n\n/** Represents Input Operation. */\nexport interface OperationInput extends OperationBase {\n operation_type: typeof OperationType.INPUT;\n is_import: boolean;\n}\n\n/** Represents Replica Operation. */\ninterface OperationReplica extends OperationBase {\n operation_type: typeof OperationType.REPLICA;\n target: number;\n}\n\n/** Represents Synthesis Operation. */\nexport interface OperationSynthesis extends OperationBase {\n operation_type: typeof OperationType.SYNTHESIS;\n is_consolidation: boolean; // aka 'diamond synthesis'\n substitutions: CstSubstituteInfo[];\n arguments: number[];\n}\n\n/** Represents Operation. */\nexport type Operation = OperationInput | OperationReplica | OperationSynthesis;\n\n/** Represents Block. */\nexport interface Block extends OssNode {\n id: number;\n oss: number;\n title: string;\n description: string;\n parent: number | null;\n nodeType: typeof NodeType.BLOCK;\n}\n\n/** Represents item of OperationSchema. */\nexport type OssItem = Operation | Block;\n\n/** Represents {@link OperationSchema} statistics. */\nexport interface OperationSchemaStats {\n count_all: number;\n count_inputs: number;\n count_synthesis: number;\n count_schemas: number;\n count_owned: number;\n count_block: number;\n count_references: number;\n}\n\n/** Represents OperationSchema. */\nexport interface OperationSchema extends LibraryItem {\n editors: number[];\n operations: Operation[];\n blocks: Block[];\n replicas: {\n original: number;\n replica: number;\n }[];\n layout: OssLayout;\n arguments: {\n operation: number;\n argument: number;\n }[];\n substitutions: CstSubstituteInfo[];\n\n graph: Graph;\n extendedGraph: Graph;\n hierarchy: Graph<string>;\n schemas: number[];\n stats: OperationSchemaStats;\n operationByID: Map<number, Operation>;\n blockByID: Map<number, Block>;\n itemByNodeID: Map<string, OssItem>;\n}\n\n/** Represents substitution error description (same code space as {@link RSDiagnosticCode}). */\nexport interface SubstitutionErrorDescription {\n code: SubstitutionErrorType;\n params: string[];\n}\n\n/**\n * Substitution-table error codes — aliases into {@link RSDiagnosticCode}.\n * Logical definition cycles reuse {@link RSDiagnosticCode.schemaDependencyCycle}.\n */\nexport const SubstitutionErrorType = {\n invalidIDs: RSDiagnosticCode.substitutionInvalidIDs,\n incorrectCst: RSDiagnosticCode.substitutionIncorrectCst,\n invalidClasses: RSDiagnosticCode.substitutionInvalidClasses,\n invalidBasic: RSDiagnosticCode.substitutionInvalidBasic,\n invalidConstant: RSDiagnosticCode.substitutionInvalidConstant,\n typificationCycle: RSDiagnosticCode.substitutionTypificationCycle,\n baseSubstitutionNotSet: RSDiagnosticCode.substitutionBaseNotSet,\n unequalTypification: RSDiagnosticCode.substitutionUnequalTypification,\n unequalExpressions: RSDiagnosticCode.substitutionUnequalExpressions,\n unequalArgsCount: RSDiagnosticCode.substitutionUnequalArgsCount,\n unequalArgs: RSDiagnosticCode.substitutionUnequalArgs,\n invalidNominal: RSDiagnosticCode.substitutionInvalidNominal,\n /** Same code as constituent schema dependency cycle. */\n definitionCycle: RSDiagnosticCode.schemaDependencyCycle\n} as const satisfies Record<string, (typeof RSDiagnosticCode)[keyof typeof RSDiagnosticCode]>;\nexport type SubstitutionErrorType = (typeof SubstitutionErrorType)[keyof typeof SubstitutionErrorType];\n"],"mappings":";;;AAWA,MAAa,WAAW;CACtB,WAAW;CACX,OAAO;AACT;;AAUA,MAAa,gBAAgB;CAC3B,OAAO;CACP,WAAW;CACX,SAAS;AACX;;;;;AA+GA,MAAa,wBAAwB;CACnC,YAAY,iBAAiB;CAC7B,cAAc,iBAAiB;CAC/B,gBAAgB,iBAAiB;CACjC,cAAc,iBAAiB;CAC/B,iBAAiB,iBAAiB;CAClC,mBAAmB,iBAAiB;CACpC,wBAAwB,iBAAiB;CACzC,qBAAqB,iBAAiB;CACtC,oBAAoB,iBAAiB;CACrC,kBAAkB,iBAAiB;CACnC,aAAa,iBAAiB;CAC9B,gBAAgB,iBAAiB;;CAEjC,iBAAiB,iBAAiB;AACpC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { t as AstNode } from "../ast-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { t as AstNode } from "../ast-D-D6Rq3T.js";
|
|
2
|
+
import "../index-D5RahF1K.js";
|
|
3
|
+
import { l as Value } from "../value-XpJOVzMP.js";
|
|
4
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../calculator-uPaTV3hc.js";
|
|
5
|
+
import "../index-CnuO4w8e.js";
|
|
6
|
+
import { S as RSForm, f as EvalStatus, l as BasicBinding, p as RSModel, u as BasicsContext, x as CstType } from "../diagnostics-DKyMf6q-.js";
|
|
6
7
|
//#region src/library/rsengine.d.ts
|
|
7
8
|
/** Services for {@link RSEngine}. */
|
|
8
9
|
interface RSEngineServices {
|
package/dist/library/rsengine.js
CHANGED
|
@@ -4,7 +4,7 @@ import { CstType } from "./rsform.js";
|
|
|
4
4
|
import { l as compare } from "../value-COprb2Je.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-D1Cp21nP.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
|