@rsconcept/domain 1.8.1 → 2.0.2
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/diagnostics-Clo3mkba.d.ts +279 -0
- package/dist/diagnostics-D7SiHAwW.js +518 -0
- package/dist/diagnostics-D7SiHAwW.js.map +1 -0
- package/dist/index.d.ts +6 -7
- package/dist/index.js +7 -6
- package/dist/library/diagnostics.d.ts +2 -0
- package/dist/library/diagnostics.js +2 -0
- package/dist/library/index.d.ts +3 -4
- package/dist/library/index.js +5 -5
- package/dist/library/oss-api.d.ts +1 -1
- package/dist/library/oss-api.js +1 -1
- package/dist/library/rsengine.d.ts +1 -2
- package/dist/library/rsengine.js +1 -1
- package/dist/library/rsform-api.d.ts +2 -2
- package/dist/library/rsform-api.js +1 -404
- package/dist/library/rsform.d.ts +2 -198
- package/dist/library/rsform.js.map +1 -1
- package/dist/library/rsmodel-api.d.ts +1 -2
- package/dist/library/rsmodel-api.js +2 -4
- package/dist/library/rsmodel-api.js.map +1 -1
- package/dist/library/rsmodel.d.ts +2 -46
- package/dist/library/structure-planner.d.ts +1 -1
- package/dist/library/structure-planner.js +1 -1
- package/dist/rslang/eval/evaluator.js +2 -2
- package/dist/rslang/index.js +2 -2
- package/dist/rslang/parser/syntax-errors/index.js +1 -1
- package/dist/rslang/semantic/analyzer.js +3 -3
- package/dist/rslang/semantic/arguments-extractor.js +1 -1
- package/dist/rslang/semantic/type-auditor.js +2 -2
- package/dist/rslang/semantic/value-auditor.js +2 -2
- package/dist/{syntax-errors-B6c2vsan.js → syntax-errors-D_VV5hAM.js} +3 -3
- package/dist/{syntax-errors-B6c2vsan.js.map → syntax-errors-D_VV5hAM.js.map} +1 -1
- package/package.json +5 -1
- package/src/index.ts +8 -0
- package/src/library/diagnostics.test.ts +85 -0
- package/src/library/diagnostics.ts +182 -0
- package/src/library/index.ts +8 -0
- package/src/library/oss-api.test.ts +1 -2
- package/src/library/rsform-api.ts +12 -17
- package/src/library/rsform.ts +4 -2
- package/src/library/rsmodel-api.ts +2 -8
- package/src/library/template-instantiation.test.ts +1 -2
- package/dist/library/rsform-api.js.map +0 -1
package/dist/library/rsform.d.ts
CHANGED
|
@@ -1,198 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { f as ExpressionType, y as TypePath } from "../typification-9lNu9R4k.js";
|
|
4
|
-
import { a as RSLangAnalyzer, t as AnalysisBase } from "../analyzer-iqAXyROE.js";
|
|
5
|
-
//#region src/library/rsform.d.ts
|
|
6
|
-
/** Represents {@link Constituenta} type. */
|
|
7
|
-
declare const CstType: {
|
|
8
|
-
readonly NOMINAL: "nominal";
|
|
9
|
-
readonly BASE: "basic";
|
|
10
|
-
readonly STRUCTURED: "structure";
|
|
11
|
-
readonly TERM: "term";
|
|
12
|
-
readonly AXIOM: "axiom";
|
|
13
|
-
readonly FUNCTION: "function";
|
|
14
|
-
readonly PREDICATE: "predicate";
|
|
15
|
-
readonly CONSTANT: "constant";
|
|
16
|
-
readonly STATEMENT: "statement";
|
|
17
|
-
};
|
|
18
|
-
type CstType = (typeof CstType)[keyof typeof CstType];
|
|
19
|
-
/** Represents attribution of a {@link Constituenta} to another {@link Constituenta}. */
|
|
20
|
-
interface Attribution {
|
|
21
|
-
container: number;
|
|
22
|
-
attribute: number;
|
|
23
|
-
}
|
|
24
|
-
/** Represents global identifier type info. */
|
|
25
|
-
interface TypeInfo {
|
|
26
|
-
alias: string;
|
|
27
|
-
type: ExpressionType;
|
|
28
|
-
}
|
|
29
|
-
/** Represents function argument value. */
|
|
30
|
-
interface ArgumentValue {
|
|
31
|
-
alias: string;
|
|
32
|
-
typification: string;
|
|
33
|
-
value?: string;
|
|
34
|
-
}
|
|
35
|
-
/** Represents Constituenta classification in terms of system of concepts. */
|
|
36
|
-
declare const CstClass: {
|
|
37
|
-
readonly NOMINAL: "nominal";
|
|
38
|
-
readonly BASIC: "basic";
|
|
39
|
-
readonly DERIVED: "derived";
|
|
40
|
-
readonly STATEMENT: "statement";
|
|
41
|
-
readonly TEMPLATE: "template";
|
|
42
|
-
};
|
|
43
|
-
type CstClass = (typeof CstClass)[keyof typeof CstClass];
|
|
44
|
-
/** Represents formal expression Status. */
|
|
45
|
-
declare const CstStatus: {
|
|
46
|
-
readonly VERIFIED: "verified";
|
|
47
|
-
readonly INCORRECT: "incorrect";
|
|
48
|
-
readonly INCALCULABLE: "incalculable";
|
|
49
|
-
readonly PROPERTY: "property";
|
|
50
|
-
readonly UNKNOWN: "unknown";
|
|
51
|
-
};
|
|
52
|
-
type CstStatus = (typeof CstStatus)[keyof typeof CstStatus];
|
|
53
|
-
/** Represents substitution of {@link Constituenta}. */
|
|
54
|
-
interface Substitution {
|
|
55
|
-
original: number;
|
|
56
|
-
substitution: number;
|
|
57
|
-
}
|
|
58
|
-
/** Represents word form for natural language. */
|
|
59
|
-
interface TermForm {
|
|
60
|
-
text: string;
|
|
61
|
-
tags: string;
|
|
62
|
-
}
|
|
63
|
-
/** Represents Constituenta. */
|
|
64
|
-
interface Constituenta {
|
|
65
|
-
id: number;
|
|
66
|
-
crucial: boolean;
|
|
67
|
-
alias: string;
|
|
68
|
-
convention: string;
|
|
69
|
-
cst_type: CstType;
|
|
70
|
-
definition_formal: string;
|
|
71
|
-
definition_raw: string;
|
|
72
|
-
definition_resolved: string;
|
|
73
|
-
term_raw: string;
|
|
74
|
-
term_resolved: string;
|
|
75
|
-
term_forms: TermForm[];
|
|
76
|
-
attributes: number[];
|
|
77
|
-
/** Manual typification of the constituent */
|
|
78
|
-
typification_manual: string;
|
|
79
|
-
/** Controls whether base concepts expose property values or full values */
|
|
80
|
-
value_is_property: boolean;
|
|
81
|
-
homonyms: number[];
|
|
82
|
-
formalDuplicates: number[];
|
|
83
|
-
analysis: AnalysisBase;
|
|
84
|
-
/** Typification used for dependents, model values, and display (manual when it overrides computed). */
|
|
85
|
-
effectiveType: ExpressionType | null;
|
|
86
|
-
/**
|
|
87
|
-
* True when manual typification is non-empty, parses to a type, and its label differs from the
|
|
88
|
-
* typification inferred from the formal definition ({@link Constituenta.analysis}.type).
|
|
89
|
-
*/
|
|
90
|
-
is_type_mismatch: boolean;
|
|
91
|
-
/** Identifier of {@link LibraryItem} containing this {@link Constituenta}. */
|
|
92
|
-
schema: number;
|
|
93
|
-
/** {@link CstClass} of this {@link Constituenta}. */
|
|
94
|
-
cst_class: CstClass;
|
|
95
|
-
/** {@link CstStatus} of this {@link Constituenta}. */
|
|
96
|
-
status: CstStatus;
|
|
97
|
-
/** Indicates if this {@link Constituenta} is a template. */
|
|
98
|
-
is_template: boolean;
|
|
99
|
-
/** Indicates if this {@link Constituenta} has a simple expression. */
|
|
100
|
-
is_simple_expression: boolean;
|
|
101
|
-
/** Index of {@link LibraryItem} that contains this cst (or inheritance parent).
|
|
102
|
-
* 0 - not inherited, 1 - inherited by 1st schema, 2 - inherited by 2nd schema, etc.
|
|
103
|
-
*/
|
|
104
|
-
parent_schema_index: number;
|
|
105
|
-
/** {@link LibraryItem} that contains parent of this inherited {@link Constituenta}. */
|
|
106
|
-
parent_schema: number | null;
|
|
107
|
-
/** Indicates if this {@link Constituenta} is inherited. */
|
|
108
|
-
is_inherited: boolean;
|
|
109
|
-
/** Indicates if this {@link Constituenta} has children that are inherited. */
|
|
110
|
-
has_inherited_children: boolean;
|
|
111
|
-
/** {@link Constituenta} that spawned this one. */
|
|
112
|
-
spawner?: number;
|
|
113
|
-
/** Alias of {@link Constituenta} that spawned this one. */
|
|
114
|
-
spawner_alias?: string;
|
|
115
|
-
/** Structure path that spawned this one. */
|
|
116
|
-
spawner_path?: TypePath;
|
|
117
|
-
/** List of {@link Constituenta} that are spawned by this one. */
|
|
118
|
-
spawn: number[];
|
|
119
|
-
/** List of aliases of {@link Constituenta} that are spawned by this one. */
|
|
120
|
-
spawn_alias: string[];
|
|
121
|
-
}
|
|
122
|
-
/** Represents {@link RSForm} statistics. */
|
|
123
|
-
interface RSFormStats {
|
|
124
|
-
step_complexity: number;
|
|
125
|
-
/** Total number of constituents in the RSForm. */
|
|
126
|
-
count_all: number;
|
|
127
|
-
/** Number of crucial constituents in the RSForm. */
|
|
128
|
-
count_crucial: number;
|
|
129
|
-
count_problematic: number;
|
|
130
|
-
/** Constituents that have same term. */
|
|
131
|
-
count_homonyms: number;
|
|
132
|
-
/** Constituents that have same formal definition and term. */
|
|
133
|
-
count_formal_duplicates: number;
|
|
134
|
-
/** Base constituents with no convention and alias. */
|
|
135
|
-
count_missing_convention: number;
|
|
136
|
-
/** Constituents with non-empty manual typification that disagrees with inferred typification. */
|
|
137
|
-
count_type_mismatch: number;
|
|
138
|
-
count_incorrect: number;
|
|
139
|
-
count_property: number;
|
|
140
|
-
count_incalculable: number;
|
|
141
|
-
count_inherited: number;
|
|
142
|
-
count_text_term: number;
|
|
143
|
-
count_definition: number;
|
|
144
|
-
count_convention: number;
|
|
145
|
-
count_comment: number;
|
|
146
|
-
count_base: number;
|
|
147
|
-
count_constant: number;
|
|
148
|
-
count_structured: number;
|
|
149
|
-
count_axiom: number;
|
|
150
|
-
count_term: number;
|
|
151
|
-
count_function: number;
|
|
152
|
-
count_predicate: number;
|
|
153
|
-
count_statement: number;
|
|
154
|
-
count_nominal: number;
|
|
155
|
-
}
|
|
156
|
-
/** Represents inheritance data for {@link RSForm}. */
|
|
157
|
-
interface InheritanceInfo {
|
|
158
|
-
child: number;
|
|
159
|
-
child_source: number;
|
|
160
|
-
parent: number;
|
|
161
|
-
parent_source: number;
|
|
162
|
-
}
|
|
163
|
-
/** Represents formal explication for set of concepts. */
|
|
164
|
-
interface RSForm extends LibraryItem {
|
|
165
|
-
/** Whether this RSForm was produced (vs imported or inherited) */
|
|
166
|
-
is_produced: boolean;
|
|
167
|
-
/** Whether this RSForm has attribution feature */
|
|
168
|
-
is_attributive: boolean;
|
|
169
|
-
/** List of user IDs who can edit this RSForm */
|
|
170
|
-
editors: number[];
|
|
171
|
-
/** Information about the current version of this RSForm */
|
|
172
|
-
version: CurrentVersion;
|
|
173
|
-
/** Full version history of this RSForm */
|
|
174
|
-
versions: VersionInfo[];
|
|
175
|
-
/** Full list of constituents in the RSForm */
|
|
176
|
-
items: Constituenta[];
|
|
177
|
-
/** List of inheritance relationships between constituents */
|
|
178
|
-
inheritance: InheritanceInfo[];
|
|
179
|
-
/** List of constituent attribution relationships */
|
|
180
|
-
attribution: Attribution[];
|
|
181
|
-
/** References to Operational Schemes/Systems associated with the RSForm */
|
|
182
|
-
oss: LibraryItemReference[];
|
|
183
|
-
/** References to conceptual models associated with the RSForm */
|
|
184
|
-
models: LibraryItemReference[];
|
|
185
|
-
/** Analyzer instance for RS language features and validation */
|
|
186
|
-
analyzer: RSLangAnalyzer;
|
|
187
|
-
/** Graph structure representing formal dependencies between constituents */
|
|
188
|
-
graph: Graph;
|
|
189
|
-
/** Graph structure representing attribution relationships */
|
|
190
|
-
attribution_graph: Graph;
|
|
191
|
-
/** Map for quick lookup of constituents by alias */
|
|
192
|
-
cstByAlias: Map<string, Constituenta>;
|
|
193
|
-
/** Map for quick lookup of constituents by ID */
|
|
194
|
-
cstByID: Map<number, Constituenta>;
|
|
195
|
-
}
|
|
196
|
-
//#endregion
|
|
197
|
-
export { ArgumentValue, Attribution, Constituenta, CstClass, CstStatus, CstType, RSForm, RSFormStats, Substitution, TypeInfo };
|
|
198
|
-
//# sourceMappingURL=rsform.d.ts.map
|
|
1
|
+
import { C as TypeInfo, S as Substitution, _ as CstClass, b as RSForm, g as Constituenta, h as Attribution, m as ArgumentValue, v as CstStatus, x as RSFormStats, y as CstType } from "../diagnostics-Clo3mkba.js";
|
|
2
|
+
export { ArgumentValue, Attribution, Constituenta, CstClass, CstStatus, CstType, RSForm, RSFormStats, Substitution, TypeInfo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsform.js","names":[],"sources":["../../src/library/rsform.ts"],"sourcesContent":["/**\n * Module: Models for formal representation for systems of concepts.\n */\n\nimport { type Graph } from '../graph';\nimport { type AnalysisBase, type ExpressionType, type RSLangAnalyzer, type TypePath } from '../rslang';\n\nimport { type CurrentVersion, type LibraryItem, type LibraryItemReference, type VersionInfo } from './library';\n\n/** Represents {@link Constituenta} type. */\nexport const CstType = {\n NOMINAL: 'nominal',\n BASE: 'basic',\n STRUCTURED: 'structure',\n TERM: 'term',\n AXIOM: 'axiom',\n FUNCTION: 'function',\n PREDICATE: 'predicate',\n CONSTANT: 'constant',\n STATEMENT: 'statement'\n} as const;\nexport type CstType = (typeof CstType)[keyof typeof CstType];\n\n/** Represents attribution of a {@link Constituenta} to another {@link Constituenta}. */\nexport interface Attribution {\n container: number;\n attribute: number;\n}\n\n/** Represents global identifier type info. */\nexport interface TypeInfo {\n alias: string;\n type: ExpressionType;\n}\n\n/** Represents function argument value. */\nexport interface ArgumentValue {\n alias: string;\n typification: string;\n value?: string;\n}\n\n/** Represents Constituenta classification in terms of system of concepts. */\nexport const CstClass = {\n NOMINAL: 'nominal',\n BASIC: 'basic',\n DERIVED: 'derived',\n STATEMENT: 'statement',\n TEMPLATE: 'template'\n} as const;\nexport type CstClass = (typeof CstClass)[keyof typeof CstClass];\n\n/** Represents formal expression Status. */\nexport const CstStatus = {\n VERIFIED: 'verified',\n INCORRECT: 'incorrect',\n INCALCULABLE: 'incalculable',\n PROPERTY: 'property',\n UNKNOWN: 'unknown'\n} as const;\nexport type CstStatus = (typeof CstStatus)[keyof typeof CstStatus];\n\n/** Represents substitution of {@link Constituenta}. */\nexport interface Substitution {\n original: number;\n substitution: number;\n}\n\n/** Represents word form for natural language. */\ninterface TermForm {\n text: string;\n tags: string;\n}\n\n/** Represents Constituenta. */\nexport interface Constituenta {\n id: number;\n crucial: boolean;\n alias: string;\n convention: string;\n cst_type: CstType;\n definition_formal: string;\n definition_raw: string;\n definition_resolved: string;\n term_raw: string;\n term_resolved: string;\n term_forms: TermForm[];\n attributes: number[];\n\n /** Manual typification of the constituent */\n typification_manual: string;\n\n /** Controls whether base concepts expose property values or full values */\n value_is_property: boolean;\n\n
|
|
1
|
+
{"version":3,"file":"rsform.js","names":[],"sources":["../../src/library/rsform.ts"],"sourcesContent":["/**\n * Module: Models for formal representation for systems of concepts.\n */\n\nimport { type Graph } from '../graph';\nimport { type AnalysisBase, type ExpressionType, type RSLangAnalyzer, type TypePath } from '../rslang';\n\nimport { type CstDiagnostic } from './diagnostics';\nimport { type CurrentVersion, type LibraryItem, type LibraryItemReference, type VersionInfo } from './library';\n\n/** Represents {@link Constituenta} type. */\nexport const CstType = {\n NOMINAL: 'nominal',\n BASE: 'basic',\n STRUCTURED: 'structure',\n TERM: 'term',\n AXIOM: 'axiom',\n FUNCTION: 'function',\n PREDICATE: 'predicate',\n CONSTANT: 'constant',\n STATEMENT: 'statement'\n} as const;\nexport type CstType = (typeof CstType)[keyof typeof CstType];\n\n/** Represents attribution of a {@link Constituenta} to another {@link Constituenta}. */\nexport interface Attribution {\n container: number;\n attribute: number;\n}\n\n/** Represents global identifier type info. */\nexport interface TypeInfo {\n alias: string;\n type: ExpressionType;\n}\n\n/** Represents function argument value. */\nexport interface ArgumentValue {\n alias: string;\n typification: string;\n value?: string;\n}\n\n/** Represents Constituenta classification in terms of system of concepts. */\nexport const CstClass = {\n NOMINAL: 'nominal',\n BASIC: 'basic',\n DERIVED: 'derived',\n STATEMENT: 'statement',\n TEMPLATE: 'template'\n} as const;\nexport type CstClass = (typeof CstClass)[keyof typeof CstClass];\n\n/** Represents formal expression Status. */\nexport const CstStatus = {\n VERIFIED: 'verified',\n INCORRECT: 'incorrect',\n INCALCULABLE: 'incalculable',\n PROPERTY: 'property',\n UNKNOWN: 'unknown'\n} as const;\nexport type CstStatus = (typeof CstStatus)[keyof typeof CstStatus];\n\n/** Represents substitution of {@link Constituenta}. */\nexport interface Substitution {\n original: number;\n substitution: number;\n}\n\n/** Represents word form for natural language. */\ninterface TermForm {\n text: string;\n tags: string;\n}\n\n/** Represents Constituenta. */\nexport interface Constituenta {\n id: number;\n crucial: boolean;\n alias: string;\n convention: string;\n cst_type: CstType;\n definition_formal: string;\n definition_raw: string;\n definition_resolved: string;\n term_raw: string;\n term_resolved: string;\n term_forms: TermForm[];\n attributes: number[];\n\n /** Manual typification of the constituent */\n typification_manual: string;\n\n /** Controls whether base concepts expose property values or full values */\n value_is_property: boolean;\n\n analysis: AnalysisBase;\n\n /** Schema-kind {@link CstDiagnostic} list, populated during schema loading. */\n diagnostics: CstDiagnostic[];\n\n /** Typification used for dependents, model values, and display (manual when it overrides computed). */\n effectiveType: ExpressionType | null;\n\n /**\n * True when manual typification is non-empty, parses to a type, and its label differs from the\n * typification inferred from the formal definition ({@link Constituenta.analysis}.type).\n */\n is_type_mismatch: boolean;\n\n /** Identifier of {@link LibraryItem} containing this {@link Constituenta}. */\n schema: number;\n\n /** {@link CstClass} of this {@link Constituenta}. */\n cst_class: CstClass;\n /** {@link CstStatus} of this {@link Constituenta}. */\n status: CstStatus;\n\n /** Indicates if this {@link Constituenta} is a template. */\n is_template: boolean;\n /** Indicates if this {@link Constituenta} has a simple expression. */\n is_simple_expression: boolean;\n\n /** Index of {@link LibraryItem} that contains this cst (or inheritance parent).\n * 0 - not inherited, 1 - inherited by 1st schema, 2 - inherited by 2nd schema, etc.\n */\n parent_schema_index: number;\n /** {@link LibraryItem} that contains parent of this inherited {@link Constituenta}. */\n parent_schema: number | null;\n /** Indicates if this {@link Constituenta} is inherited. */\n is_inherited: boolean;\n /** Indicates if this {@link Constituenta} has children that are inherited. */\n has_inherited_children: boolean;\n\n /** {@link Constituenta} that spawned this one. */\n spawner?: number;\n /** Alias of {@link Constituenta} that spawned this one. */\n spawner_alias?: string;\n /** Structure path that spawned this one. */\n spawner_path?: TypePath;\n\n /** List of {@link Constituenta} that are spawned by this one. */\n spawn: number[];\n /** List of aliases of {@link Constituenta} that are spawned by this one. */\n spawn_alias: string[];\n}\n\n/** Represents {@link RSForm} statistics. */\nexport interface RSFormStats {\n step_complexity: number;\n\n /** Total number of constituents in the RSForm. */\n count_all: number;\n /** Number of crucial constituents in the RSForm. */\n count_crucial: number;\n\n count_problematic: number;\n /** Constituents that have same term. */\n count_homonyms: number;\n /** Constituents that have same formal definition and term. */\n count_formal_duplicates: number;\n /** Base constituents with no convention and alias. */\n count_missing_convention: number;\n /** Constituents with non-empty manual typification that disagrees with inferred typification. */\n count_type_mismatch: number;\n\n count_incorrect: number;\n count_property: number;\n count_incalculable: number;\n count_inherited: number;\n\n count_text_term: number;\n count_definition: number;\n count_convention: number;\n count_comment: number;\n\n count_base: number;\n count_constant: number;\n count_structured: number;\n count_axiom: number;\n count_term: number;\n count_function: number;\n count_predicate: number;\n count_statement: number;\n count_nominal: number;\n}\n\n/** Represents inheritance data for {@link RSForm}. */\ninterface InheritanceInfo {\n child: number;\n child_source: number;\n parent: number;\n parent_source: number;\n}\n\n/** Represents formal explication for set of concepts. */\nexport interface RSForm extends LibraryItem {\n /** Whether this RSForm was produced (vs imported or inherited) */\n is_produced: boolean;\n /** Whether this RSForm has attribution feature */\n is_attributive: boolean;\n /** List of user IDs who can edit this RSForm */\n editors: number[];\n /** Information about the current version of this RSForm */\n version: CurrentVersion;\n /** Full version history of this RSForm */\n versions: VersionInfo[];\n\n /** Full list of constituents in the RSForm */\n items: Constituenta[];\n /** List of inheritance relationships between constituents */\n inheritance: InheritanceInfo[];\n /** List of constituent attribution relationships */\n attribution: Attribution[];\n /** References to Operational Schemes/Systems associated with the RSForm */\n oss: LibraryItemReference[];\n /** References to conceptual models associated with the RSForm */\n models: LibraryItemReference[];\n\n /** Analyzer instance for RS language features and validation */\n analyzer: RSLangAnalyzer;\n /** Graph structure representing formal dependencies between constituents */\n graph: Graph;\n /** Graph structure representing attribution relationships */\n attribution_graph: Graph;\n /** Map for quick lookup of constituents by alias */\n cstByAlias: Map<string, Constituenta>;\n /** Map for quick lookup of constituents by ID */\n cstByID: Map<number, Constituenta>;\n}\n"],"mappings":";;AAWA,MAAa,UAAU;CACrB,SAAS;CACT,MAAM;CACN,YAAY;CACZ,MAAM;CACN,OAAO;CACP,UAAU;CACV,WAAW;CACX,UAAU;CACV,WAAW;AACb;;AAuBA,MAAa,WAAW;CACtB,SAAS;CACT,OAAO;CACP,SAAS;CACT,WAAW;CACX,UAAU;AACZ;;AAIA,MAAa,YAAY;CACvB,UAAU;CACV,WAAW;CACX,cAAc;CACd,UAAU;CACV,SAAS;AACX"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { b as Typification, f as ExpressionType } from "../typification-9lNu9R4k.js";
|
|
2
2
|
import { d as ValuePath, l as Value } from "../value-BduA_ZGp.js";
|
|
3
|
-
import { Constituenta,
|
|
4
|
-
import { BasicBinding, EvalStatus, RSModelStats } from "./rsmodel.js";
|
|
3
|
+
import { b as RSForm, f as RSModelStats, g as Constituenta, s as BasicBinding, u as EvalStatus, y as CstType } from "../diagnostics-Clo3mkba.js";
|
|
5
4
|
import { RSEngine } from "./rsengine.js";
|
|
6
5
|
|
|
7
6
|
//#region src/library/rsmodel-api.d.ts
|
|
@@ -2,7 +2,7 @@ import { TypeID } from "../rslang/semantic/typification.js";
|
|
|
2
2
|
import { O as setNestedValue, _ as extractValue, b as isTupleValue, f as tuple, l as compare, x as makeDefaultValue } from "../value-COprb2Je.js";
|
|
3
3
|
import "../rslang/index.js";
|
|
4
4
|
import { CstType } from "./rsform.js";
|
|
5
|
-
import {
|
|
5
|
+
import { E as isBasicConcept, T as isBaseSet, a as modelStatusCstDiagnostic, u as calculateSchemaStats } from "../diagnostics-D7SiHAwW.js";
|
|
6
6
|
import { EvalStatus } from "./rsmodel.js";
|
|
7
7
|
//#region src/library/rsmodel-api.ts
|
|
8
8
|
const RANDOM_INTEGER_MIN = -100;
|
|
@@ -73,9 +73,7 @@ function calculateModelStats(schema, engine, _engineGeneration) {
|
|
|
73
73
|
}
|
|
74
74
|
/** Checks whether evaluation status contributes to model status issues. */
|
|
75
75
|
function isModelIssue(engine, cst) {
|
|
76
|
-
|
|
77
|
-
const isBasic = isBasicConcept(cst.cst_type);
|
|
78
|
-
return status === EvalStatus.EVAL_FAIL || status === EvalStatus.AXIOM_FALSE || status === EvalStatus.INVALID_DATA || isBasic && status === EvalStatus.EMPTY;
|
|
76
|
+
return modelStatusCstDiagnostic(engine.getCstStatus(cst.id), cst.cst_type) !== null;
|
|
79
77
|
}
|
|
80
78
|
/** Evaluate if {@link CstType} is interpretable. */
|
|
81
79
|
function isInterpretable(type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsmodel-api.js","names":[],"sources":["../../src/library/rsmodel-api.ts"],"sourcesContent":["import { type ExpressionType, TypeID, type Typification, type Value } from '../rslang';\nimport { compare, tuple, TUPLE_ID, VALUE_TRUE, type ValuePath } from '../rslang/eval/value';\nimport { extractValue, isTupleValue, makeDefaultValue, setNestedValue } from '../rslang/eval/value-api';\nimport { type EchelonCollection } from '../rslang/semantic/typification';\n\nimport { type RSEngine } from './rsengine';\nimport { type Constituenta, CstType, type RSForm } from './rsform';\nimport { calculateSchemaStats, isBaseSet, isBasicConcept } from './rsform-api';\nimport { type BasicBinding, EvalStatus, type RSModelStats } from './rsmodel';\n\nconst RANDOM_INTEGER_MIN = -100;\nconst RANDOM_INTEGER_MAX = 100;\nconst DEFAULT_RANDOM_SET_ELEMENTS_COUNT = 5;\n\n/** Evaluate if parsed data is a basic binding data. */\nexport function validateBasicBindingData(data: unknown): data is Record<string, string> {\n if (!data || typeof data !== 'object' || Array.isArray(data)) {\n return false;\n }\n return Object.entries(data).every(([key, value]) => typeof value === 'string' && Number.isInteger(Number(key)));\n}\n\n/** Convert parsed data to a basic binding. */\nexport function toBasicBinding(data: Record<string | number, string>): BasicBinding {\n const result: BasicBinding = {};\n for (const [k, v] of Object.entries(data)) {\n result[Number(k)] = v;\n }\n return result;\n}\n\n/** Evaluate if parsed data is a {@link Value} data. */\nexport function validateValueData(data: unknown): data is Value {\n if (typeof data === 'number') {\n return Number.isFinite(data);\n }\n if (!Array.isArray(data)) {\n return false;\n }\n return data.every(item => validateValueData(item));\n}\n\nexport function generateRandomValue(\n type: Typification,\n basics: Map<number, BasicBinding>,\n cstByAlias: Map<string, Constituenta>,\n setElementsCount: number = DEFAULT_RANDOM_SET_ELEMENTS_COUNT\n): Value | null {\n switch (type.typeID) {\n case TypeID.integer:\n return Math.floor(Math.random() * (RANDOM_INTEGER_MAX - RANDOM_INTEGER_MIN + 1)) + RANDOM_INTEGER_MIN;\n case TypeID.basic: {\n const cst = cstByAlias.get(type.baseID);\n const binding = cst ? basics.get(cst.id) : undefined;\n const ids = Object.keys(binding ?? {}).map(Number);\n if (ids.length === 0) {\n return null;\n }\n return ids[Math.floor(Math.random() * ids.length)];\n }\n case TypeID.tuple: {\n const factors: Value[] = [];\n for (const factor of type.factors) {\n const sample = generateRandomValue(factor, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n factors.push(sample);\n }\n return tuple(factors);\n }\n case TypeID.collection: {\n const result: Value[] = [];\n const randomElementsCount = Math.floor(Math.random() * (setElementsCount + 1));\n for (let i = 0; i < randomElementsCount; i++) {\n const sample = generateRandomValue(type.base, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n result.push(sample);\n }\n return result;\n }\n case TypeID.anyTypification:\n return null;\n }\n}\n\n/** Calculate statistics for {@link RSModel}. */\nexport function calculateModelStats(schema: RSForm, engine: RSEngine, _engineGeneration?: number): RSModelStats {\n const items = schema.items;\n const statusByID = new Map<number, EvalStatus>();\n for (const cst of items) {\n statusByID.set(cst.id, engine.getCstStatus(cst.id));\n }\n return {\n ...calculateSchemaStats(schema),\n base_elements: items.reduce((sum, cst) => sum + countBaseElements(cst, engine), 0),\n count_missing_base: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && isBasicConcept(cst.cst_type) ? 1 : 0),\n 0\n ),\n count_false_axioms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.AXIOM_FALSE ? 1 : 0),\n 0\n ),\n count_invalid_data: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.INVALID_DATA ? 1 : 0),\n 0\n ),\n count_invalid_calculations: items.reduce(\n (sum, cst) =>\n sum +\n (statusByID.get(cst.id) === EvalStatus.EVAL_FAIL || statusByID.get(cst.id) === EvalStatus.NOT_PROCESSED\n ? 1\n : 0),\n 0\n ),\n count_empty_terms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && cst.cst_type === CstType.TERM ? 1 : 0),\n 0\n )\n };\n}\n\n/** Checks whether evaluation status contributes to model status issues. */\nexport function isModelIssue(engine: RSEngine, cst: Constituenta): boolean {\n const status = engine.getCstStatus(cst.id);\n const isBasic = isBasicConcept(cst.cst_type);\n return (\n status === EvalStatus.EVAL_FAIL ||\n status === EvalStatus.AXIOM_FALSE ||\n status === EvalStatus.INVALID_DATA ||\n (isBasic && status === EvalStatus.EMPTY)\n );\n}\n\n/** Evaluate if {@link CstType} is interpretable. */\nexport function isInterpretable(type: CstType): boolean {\n switch (type) {\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.STATEMENT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is inferrable. */\nexport function isInferrable(type: CstType): boolean {\n switch (type) {\n case CstType.AXIOM:\n case CstType.STATEMENT:\n case CstType.TERM:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Infers status of a given {@link Value} and {@link CstType}. */\nexport function inferEvalStatus(\n value: Value | null,\n cstType: CstType,\n wasCalculated: boolean = true,\n isInvalid: boolean = false\n): EvalStatus {\n if (isBaseSet(cstType) || cstType === CstType.STRUCTURED) {\n if (isInvalid) {\n return EvalStatus.INVALID_DATA;\n }\n if (value === null || (Array.isArray(value) && value.length === 0)) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n }\n if (!isInferrable(cstType)) {\n return EvalStatus.NO_EVAL;\n }\n if (!wasCalculated) {\n return EvalStatus.NOT_PROCESSED;\n }\n if (value === null) {\n return EvalStatus.EVAL_FAIL;\n }\n if (cstType === CstType.AXIOM && value !== VALUE_TRUE) {\n return EvalStatus.AXIOM_FALSE;\n }\n if (Array.isArray(value) && value.length === 0) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n}\n\n/** Tries to fix value removing invalid base elements not present in the target value.\n * returns null if no fixing is possible.\n * returns true if fixing was successful.\n * returns false if fixing was not needed.\n */\nexport function tryFixValue(\n value: Value,\n type: ExpressionType,\n targetAlias: string,\n targetValue: Value[]\n): boolean | null {\n switch (type.typeID) {\n case TypeID.integer:\n return false;\n case TypeID.basic:\n if (type.baseID !== targetAlias) {\n return false;\n }\n if (typeof value !== 'number') {\n return null;\n }\n if (!targetValue.includes(value)) {\n return null;\n }\n return false;\n case TypeID.tuple: {\n if (!isTupleValue(value)) {\n return null;\n }\n let wasChanged = false;\n for (let i = 0; i < type.factors.length; i++) {\n const componentChanged = tryFixValue(value[i + 1], type.factors[i], targetAlias, targetValue);\n if (componentChanged === null) {\n return null;\n }\n if (componentChanged) {\n wasChanged = true;\n }\n }\n return wasChanged;\n }\n case TypeID.collection:\n if (!Array.isArray(value) || (value.length > 1 && value[0] === TUPLE_ID)) {\n return null;\n }\n let wasChanged = false;\n const removeElements: Value[] = [];\n for (const item of value) {\n const elementChanged = tryFixValue(item, type.base, targetAlias, targetValue);\n if (elementChanged === null || elementChanged === true) {\n wasChanged = true;\n if (elementChanged === null) {\n removeElements.push(item);\n }\n }\n }\n for (const item of removeElements) {\n const index = value.indexOf(item);\n if (index !== -1) {\n value.splice(index, 1);\n }\n }\n if (wasChanged) {\n value.sort((a, b) => compare(a, b));\n let i = 1;\n while (i < value.length) {\n if (compare(value[i], value[i - 1]) === 0) {\n value.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n return wasChanged;\n\n case TypeID.logic:\n case TypeID.anyTypification:\n case TypeID.predicate:\n case TypeID.function:\n return null;\n }\n}\n\nexport function updateValueElement(value: Value | null, path: ValuePath, newValue: number): Value | null {\n return setNestedValue(value, path, newValue);\n}\n\nexport function deleteValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n target: number\n): Value | null {\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return null;\n }\n\n const arrayValue = extractValue(value!, path)! as Value[];\n const updatedArray = [...arrayValue.slice(0, target), ...arrayValue.slice(target + 1)];\n return setNestedValue(value, path, updatedArray);\n}\n\nexport function addValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n currentType: Typification\n): Value | null {\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return makeDefaultValue(type);\n }\n\n const newElem = makeDefaultValue((currentType as EchelonCollection).base);\n const arrayValue = (extractValue(value!, path) as Value[] | null) ?? [];\n const updatedArray = [newElem, ...arrayValue];\n return setNestedValue(value, path, updatedArray);\n}\n\n// ========= Internal functions ==========\n\nfunction countBaseElements(cst: Constituenta, engine: RSEngine): number {\n if (!isBasicConcept(cst.cst_type)) {\n return 0;\n }\n const value = engine.getCstValue(cst.id);\n if (value === null) {\n return 0;\n }\n if (!Array.isArray(value) || value[0] === TUPLE_ID) {\n return 1;\n }\n return value.length;\n}\n"],"mappings":";;;;;;;AAUA,MAAM,qBAAqB;AAE3B,MAAM,oCAAoC;;AAG1C,SAAgB,yBAAyB,MAA+C;CACtF,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,GACzD,OAAO;CAET,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,WAAW,OAAO,UAAU,YAAY,OAAO,UAAU,OAAO,GAAG,CAAC,CAAC;AAChH;;AAGA,SAAgB,eAAe,MAAqD;CAClF,MAAM,SAAuB,CAAC;CAC9B,KAAK,MAAM,CAAC,GAAG,M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AAa,aAAa,OAAQ,IAAI;CAE5C,OAAO,eAAe,OAAO,MAAM,CADb,GAAG,WAAW,MAAM,GAAG,MAAM,GAAG,GAAG,WAAW,MAAM,SAAS,CAAC,CACjD,CAAY;AACjD;AAEA,SAAgB,gBACd,OACA,MACA,MACA,aACc;CACd,IAAI,KAAK,WAAW,KAAK,KAAK,WAAW,OAAO,YAC9C,OAAO,iBAAiB,IAAI;CAM9B,OAAO,eAAe,OAAO,MAAM,CAHnB,iBAAkB,YAAkC,IAE9C,GAAS,GADX,aAAa,OAAQ,IAAI,KAAwB,CAAC,CAEnC,CAAY;AACjD;AAIA,SAAS,kBAAkB,KAAmB,QAA0B;CACtE,IAAI,CAAC,eAAe,IAAI,QAAQ,GAC9B,OAAO;CAET,MAAM,QAAQ,OAAO,YAAY,IAAI,EAAE;CACvC,IAAI,UAAU,MACZ,OAAO;CAET,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAA,MACjC,OAAO;CAET,OAAO,MAAM;AACf"}
|
|
1
|
+
{"version":3,"file":"rsmodel-api.js","names":[],"sources":["../../src/library/rsmodel-api.ts"],"sourcesContent":["import { type ExpressionType, TypeID, type Typification, type Value } from '../rslang';\nimport { compare, tuple, TUPLE_ID, VALUE_TRUE, type ValuePath } from '../rslang/eval/value';\nimport { extractValue, isTupleValue, makeDefaultValue, setNestedValue } from '../rslang/eval/value-api';\nimport { type EchelonCollection } from '../rslang/semantic/typification';\n\nimport { modelStatusCstDiagnostic } from './diagnostics';\nimport { type RSEngine } from './rsengine';\nimport { type Constituenta, CstType, type RSForm } from './rsform';\nimport { calculateSchemaStats, isBaseSet, isBasicConcept } from './rsform-api';\nimport { type BasicBinding, EvalStatus, type RSModelStats } from './rsmodel';\n\nconst RANDOM_INTEGER_MIN = -100;\nconst RANDOM_INTEGER_MAX = 100;\nconst DEFAULT_RANDOM_SET_ELEMENTS_COUNT = 5;\n\n/** Evaluate if parsed data is a basic binding data. */\nexport function validateBasicBindingData(data: unknown): data is Record<string, string> {\n if (!data || typeof data !== 'object' || Array.isArray(data)) {\n return false;\n }\n return Object.entries(data).every(([key, value]) => typeof value === 'string' && Number.isInteger(Number(key)));\n}\n\n/** Convert parsed data to a basic binding. */\nexport function toBasicBinding(data: Record<string | number, string>): BasicBinding {\n const result: BasicBinding = {};\n for (const [k, v] of Object.entries(data)) {\n result[Number(k)] = v;\n }\n return result;\n}\n\n/** Evaluate if parsed data is a {@link Value} data. */\nexport function validateValueData(data: unknown): data is Value {\n if (typeof data === 'number') {\n return Number.isFinite(data);\n }\n if (!Array.isArray(data)) {\n return false;\n }\n return data.every(item => validateValueData(item));\n}\n\nexport function generateRandomValue(\n type: Typification,\n basics: Map<number, BasicBinding>,\n cstByAlias: Map<string, Constituenta>,\n setElementsCount: number = DEFAULT_RANDOM_SET_ELEMENTS_COUNT\n): Value | null {\n switch (type.typeID) {\n case TypeID.integer:\n return Math.floor(Math.random() * (RANDOM_INTEGER_MAX - RANDOM_INTEGER_MIN + 1)) + RANDOM_INTEGER_MIN;\n case TypeID.basic: {\n const cst = cstByAlias.get(type.baseID);\n const binding = cst ? basics.get(cst.id) : undefined;\n const ids = Object.keys(binding ?? {}).map(Number);\n if (ids.length === 0) {\n return null;\n }\n return ids[Math.floor(Math.random() * ids.length)];\n }\n case TypeID.tuple: {\n const factors: Value[] = [];\n for (const factor of type.factors) {\n const sample = generateRandomValue(factor, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n factors.push(sample);\n }\n return tuple(factors);\n }\n case TypeID.collection: {\n const result: Value[] = [];\n const randomElementsCount = Math.floor(Math.random() * (setElementsCount + 1));\n for (let i = 0; i < randomElementsCount; i++) {\n const sample = generateRandomValue(type.base, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n result.push(sample);\n }\n return result;\n }\n case TypeID.anyTypification:\n return null;\n }\n}\n\n/** Calculate statistics for {@link RSModel}. */\nexport function calculateModelStats(schema: RSForm, engine: RSEngine, _engineGeneration?: number): RSModelStats {\n const items = schema.items;\n const statusByID = new Map<number, EvalStatus>();\n for (const cst of items) {\n statusByID.set(cst.id, engine.getCstStatus(cst.id));\n }\n return {\n ...calculateSchemaStats(schema),\n base_elements: items.reduce((sum, cst) => sum + countBaseElements(cst, engine), 0),\n count_missing_base: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && isBasicConcept(cst.cst_type) ? 1 : 0),\n 0\n ),\n count_false_axioms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.AXIOM_FALSE ? 1 : 0),\n 0\n ),\n count_invalid_data: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.INVALID_DATA ? 1 : 0),\n 0\n ),\n count_invalid_calculations: items.reduce(\n (sum, cst) =>\n sum +\n (statusByID.get(cst.id) === EvalStatus.EVAL_FAIL || statusByID.get(cst.id) === EvalStatus.NOT_PROCESSED\n ? 1\n : 0),\n 0\n ),\n count_empty_terms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && cst.cst_type === CstType.TERM ? 1 : 0),\n 0\n )\n };\n}\n\n/** Checks whether evaluation status contributes to model status issues. */\nexport function isModelIssue(engine: RSEngine, cst: Constituenta): boolean {\n return modelStatusCstDiagnostic(engine.getCstStatus(cst.id), cst.cst_type) !== null;\n}\n\n/** Evaluate if {@link CstType} is interpretable. */\nexport function isInterpretable(type: CstType): boolean {\n switch (type) {\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.STATEMENT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is inferrable. */\nexport function isInferrable(type: CstType): boolean {\n switch (type) {\n case CstType.AXIOM:\n case CstType.STATEMENT:\n case CstType.TERM:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Infers status of a given {@link Value} and {@link CstType}. */\nexport function inferEvalStatus(\n value: Value | null,\n cstType: CstType,\n wasCalculated: boolean = true,\n isInvalid: boolean = false\n): EvalStatus {\n if (isBaseSet(cstType) || cstType === CstType.STRUCTURED) {\n if (isInvalid) {\n return EvalStatus.INVALID_DATA;\n }\n if (value === null || (Array.isArray(value) && value.length === 0)) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n }\n if (!isInferrable(cstType)) {\n return EvalStatus.NO_EVAL;\n }\n if (!wasCalculated) {\n return EvalStatus.NOT_PROCESSED;\n }\n if (value === null) {\n return EvalStatus.EVAL_FAIL;\n }\n if (cstType === CstType.AXIOM && value !== VALUE_TRUE) {\n return EvalStatus.AXIOM_FALSE;\n }\n if (Array.isArray(value) && value.length === 0) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n}\n\n/** Tries to fix value removing invalid base elements not present in the target value.\n * returns null if no fixing is possible.\n * returns true if fixing was successful.\n * returns false if fixing was not needed.\n */\nexport function tryFixValue(\n value: Value,\n type: ExpressionType,\n targetAlias: string,\n targetValue: Value[]\n): boolean | null {\n switch (type.typeID) {\n case TypeID.integer:\n return false;\n case TypeID.basic:\n if (type.baseID !== targetAlias) {\n return false;\n }\n if (typeof value !== 'number') {\n return null;\n }\n if (!targetValue.includes(value)) {\n return null;\n }\n return false;\n case TypeID.tuple: {\n if (!isTupleValue(value)) {\n return null;\n }\n let wasChanged = false;\n for (let i = 0; i < type.factors.length; i++) {\n const componentChanged = tryFixValue(value[i + 1], type.factors[i], targetAlias, targetValue);\n if (componentChanged === null) {\n return null;\n }\n if (componentChanged) {\n wasChanged = true;\n }\n }\n return wasChanged;\n }\n case TypeID.collection:\n if (!Array.isArray(value) || (value.length > 1 && value[0] === TUPLE_ID)) {\n return null;\n }\n let wasChanged = false;\n const removeElements: Value[] = [];\n for (const item of value) {\n const elementChanged = tryFixValue(item, type.base, targetAlias, targetValue);\n if (elementChanged === null || elementChanged === true) {\n wasChanged = true;\n if (elementChanged === null) {\n removeElements.push(item);\n }\n }\n }\n for (const item of removeElements) {\n const index = value.indexOf(item);\n if (index !== -1) {\n value.splice(index, 1);\n }\n }\n if (wasChanged) {\n value.sort((a, b) => compare(a, b));\n let i = 1;\n while (i < value.length) {\n if (compare(value[i], value[i - 1]) === 0) {\n value.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n return wasChanged;\n\n case TypeID.logic:\n case TypeID.anyTypification:\n case TypeID.predicate:\n case TypeID.function:\n return null;\n }\n}\n\nexport function updateValueElement(value: Value | null, path: ValuePath, newValue: number): Value | null {\n return setNestedValue(value, path, newValue);\n}\n\nexport function deleteValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n target: number\n): Value | null {\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return null;\n }\n\n const arrayValue = extractValue(value!, path)! as Value[];\n const updatedArray = [...arrayValue.slice(0, target), ...arrayValue.slice(target + 1)];\n return setNestedValue(value, path, updatedArray);\n}\n\nexport function addValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n currentType: Typification\n): Value | null {\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return makeDefaultValue(type);\n }\n\n const newElem = makeDefaultValue((currentType as EchelonCollection).base);\n const arrayValue = (extractValue(value!, path) as Value[] | null) ?? [];\n const updatedArray = [newElem, ...arrayValue];\n return setNestedValue(value, path, updatedArray);\n}\n\n// ========= Internal functions ==========\n\nfunction countBaseElements(cst: Constituenta, engine: RSEngine): number {\n if (!isBasicConcept(cst.cst_type)) {\n return 0;\n }\n const value = engine.getCstValue(cst.id);\n if (value === null) {\n return 0;\n }\n if (!Array.isArray(value) || value[0] === TUPLE_ID) {\n return 1;\n }\n return value.length;\n}\n"],"mappings":";;;;;;;AAWA,MAAM,qBAAqB;AAE3B,MAAM,oCAAoC;;AAG1C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AAO;CACX;AACF;AAEA,SAAgB,mBAAmB,OAAqB,MAAiB,UAAgC;CACvG,OAAO,eAAe,OAAO,MAAM,QAAQ;AAC7C;AAEA,SAAgB,mBACd,OACA,MACA,MACA,QACc;CACd,IAAI,KAAK,WAAW,KAAK,KAAK,WAAW,OAAO,YAC9C,OAAO;CAGT,MAAM,aAAa,aAAa,OAAQ,IAAI;CAE5C,OAAO,eAAe,OAAO,MAAM,CADb,GAAG,WAAW,MAAM,GAAG,MAAM,GAAG,GAAG,WAAW,MAAM,SAAS,CAAC,CACjD,CAAY;AACjD;AAEA,SAAgB,gBACd,OACA,MACA,MACA,aACc;CACd,IAAI,KAAK,WAAW,KAAK,KAAK,WAAW,OAAO,YAC9C,OAAO,iBAAiB,IAAI;CAM9B,OAAO,eAAe,OAAO,MAAM,CAHnB,iBAAkB,YAAkC,IAE9C,GAAS,GADX,aAAa,OAAQ,IAAI,KAAwB,CAAC,CAEnC,CAAY;AACjD;AAIA,SAAS,kBAAkB,KAAmB,QAA0B;CACtE,IAAI,CAAC,eAAe,IAAI,QAAQ,GAC9B,OAAO;CAET,MAAM,QAAQ,OAAO,YAAY,IAAI,EAAE;CACvC,IAAI,UAAU,MACZ,OAAO;CAET,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAA,MACjC,OAAO;CAET,OAAO,MAAM;AACf"}
|
|
@@ -1,46 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { RSFormStats } from "./rsform.js";
|
|
4
|
-
|
|
5
|
-
//#region src/library/rsmodel.d.ts
|
|
6
|
-
declare const TYPE_BASIC = "basic";
|
|
7
|
-
/** Evaluation status enumeration. */
|
|
8
|
-
declare const EvalStatus: {
|
|
9
|
-
readonly NO_EVAL: 1;
|
|
10
|
-
readonly NOT_PROCESSED: 2;
|
|
11
|
-
readonly INVALID_DATA: 3;
|
|
12
|
-
readonly EVAL_FAIL: 4;
|
|
13
|
-
readonly AXIOM_FALSE: 5;
|
|
14
|
-
readonly EMPTY: 6;
|
|
15
|
-
readonly HAS_DATA: 7;
|
|
16
|
-
};
|
|
17
|
-
type EvalStatus = (typeof EvalStatus)[keyof typeof EvalStatus];
|
|
18
|
-
/** Represents basic element binding. */
|
|
19
|
-
type BasicBinding = Record<number, string>;
|
|
20
|
-
/** Represents {@link RSModel} basic sets binding. */
|
|
21
|
-
type BasicsContext = Map<number, BasicBinding>;
|
|
22
|
-
/** Default value for structured data. */
|
|
23
|
-
declare const DEFAULT_VALUE_TEXT = "N/A";
|
|
24
|
-
interface RSModelData extends LibraryItem {
|
|
25
|
-
editors: number[];
|
|
26
|
-
schema: number;
|
|
27
|
-
items: {
|
|
28
|
-
id: number;
|
|
29
|
-
type: string;
|
|
30
|
-
value: Value | BasicBinding;
|
|
31
|
-
}[];
|
|
32
|
-
}
|
|
33
|
-
/** Represents {@link RSModel} structured data. */
|
|
34
|
-
type RSModel = RSModelData;
|
|
35
|
-
/** Represents {@link RSModel} statistics. */
|
|
36
|
-
interface RSModelStats extends RSFormStats {
|
|
37
|
-
count_missing_base: number;
|
|
38
|
-
count_false_axioms: number;
|
|
39
|
-
count_invalid_data: number;
|
|
40
|
-
count_invalid_calculations: number;
|
|
41
|
-
count_empty_terms: number;
|
|
42
|
-
base_elements: number;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { BasicBinding, BasicsContext, DEFAULT_VALUE_TEXT, EvalStatus, RSModel, RSModelStats, TYPE_BASIC };
|
|
46
|
-
//# sourceMappingURL=rsmodel.d.ts.map
|
|
1
|
+
import { c as BasicsContext, d as RSModel, f as RSModelStats, l as DEFAULT_VALUE_TEXT, p as TYPE_BASIC, s as BasicBinding, u as EvalStatus } from "../diagnostics-Clo3mkba.js";
|
|
2
|
+
export { BasicBinding, BasicsContext, DEFAULT_VALUE_TEXT, EvalStatus, RSModel, RSModelStats, TYPE_BASIC };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as Typification, y as TypePath } from "../typification-9lNu9R4k.js";
|
|
2
|
-
import {
|
|
2
|
+
import { b as RSForm, g as Constituenta } from "../diagnostics-Clo3mkba.js";
|
|
3
3
|
|
|
4
4
|
//#region src/library/structure-planner.d.ts
|
|
5
5
|
/** Represents a node in the structure planner. */
|
|
@@ -3,7 +3,7 @@ import { labelType } from "../rslang/labels.js";
|
|
|
3
3
|
import { splitTemplateDefinition } from "../rslang/api.js";
|
|
4
4
|
import "../rslang/index.js";
|
|
5
5
|
import { CstType } from "./rsform.js";
|
|
6
|
-
import { findCstByStructure } from "
|
|
6
|
+
import { m as findCstByStructure } from "../diagnostics-D7SiHAwW.js";
|
|
7
7
|
//#region src/library/structure-planner.ts
|
|
8
8
|
/** Structure planner for {@link Constituenta}. */
|
|
9
9
|
var StructurePlanner = class {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { annotateError } from "../ast-annotations.js";
|
|
2
|
-
import { RSErrorCode } from "../error.js";
|
|
3
1
|
import { getNodeIndices, getNodeText } from "../../parsing/ast.js";
|
|
4
2
|
import "../../parsing/index.js";
|
|
5
3
|
import { TokenID } from "../parser/token.js";
|
|
6
4
|
import { labelRSLangNode } from "../labels.js";
|
|
5
|
+
import { annotateError } from "../ast-annotations.js";
|
|
6
|
+
import { RSErrorCode } from "../error.js";
|
|
7
7
|
import { EvaluationCache, EvaluationMetadata } from "./evaluation-cache.js";
|
|
8
8
|
import { A as setUnion, D as setIntersection, E as setDiff, T as reduce, a as SET_INFINITY, d as set, f as tuple, h as contains, k as setSymDiff, l as compare, m as cartesianProduct, n as CalcInvalidDataError, p as boolean, r as EmptySetV, w as projection, y as isSubsetOrEq } from "../../value-COprb2Je.js";
|
|
9
9
|
//#region src/rslang/eval/evaluator.ts
|
package/dist/rslang/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { readErrorAnnotation, readTypeAnnotation } from "./ast-annotations.js";
|
|
2
|
-
import { RSErrorCode } from "./error.js";
|
|
3
1
|
import { TokenID } from "./parser/token.js";
|
|
4
2
|
import { AnyTypificationT, EmptySetT, LogicT, TypeClass, TypeID, makeTypePath } from "./semantic/typification.js";
|
|
3
|
+
import { readErrorAnnotation, readTypeAnnotation } from "./ast-annotations.js";
|
|
4
|
+
import { RSErrorCode } from "./error.js";
|
|
5
5
|
import { C as printValue, u as makeValuePath } from "../value-COprb2Je.js";
|
|
6
6
|
import { RSCalculator } from "./eval/calculator.js";
|
|
7
7
|
import { parser } from "./parser/parser.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as extractSyntaxErrors } from "../../../syntax-errors-
|
|
1
|
+
import { t as extractSyntaxErrors } from "../../../syntax-errors-D_VV5hAM.js";
|
|
2
2
|
export { extractSyntaxErrors };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { annotateError } from "../ast-annotations.js";
|
|
2
|
-
import { RSErrorCode } from "../error.js";
|
|
3
1
|
import { TokenID } from "../parser/token.js";
|
|
4
2
|
import { TypeID, basic, bool, constant, debool } from "./typification.js";
|
|
5
3
|
import { labelType } from "../labels.js";
|
|
4
|
+
import { annotateError } from "../ast-annotations.js";
|
|
5
|
+
import { RSErrorCode } from "../error.js";
|
|
6
6
|
import { parseRSLangExpression } from "../api.js";
|
|
7
|
-
import { t as extractSyntaxErrors } from "../../syntax-errors-
|
|
7
|
+
import { t as extractSyntaxErrors } from "../../syntax-errors-D_VV5hAM.js";
|
|
8
8
|
import { getTypeClass } from "./typification-api.js";
|
|
9
9
|
import { TypeAuditor } from "./type-auditor.js";
|
|
10
10
|
import { ValueClass } from "./value-class.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { readTypeAnnotation } from "../ast-annotations.js";
|
|
2
1
|
import { getNodeText } from "../../parsing/ast.js";
|
|
3
2
|
import "../../parsing/index.js";
|
|
4
3
|
import { TokenID } from "../parser/token.js";
|
|
4
|
+
import { readTypeAnnotation } from "../ast-annotations.js";
|
|
5
5
|
//#region src/rslang/semantic/arguments-extractor.ts
|
|
6
6
|
/**
|
|
7
7
|
* Module: Type auditor for AST type checking.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { annotateError, annotateType } from "../ast-annotations.js";
|
|
2
|
-
import { RSErrorCode } from "../error.js";
|
|
3
1
|
import { getNodeIndices, getNodeText } from "../../parsing/ast.js";
|
|
4
2
|
import "../../parsing/index.js";
|
|
5
3
|
import { TokenID } from "../parser/token.js";
|
|
6
4
|
import { EmptySetT, IntegerT, LogicT, TypeID, bool, component, debool, isTemplateRadical, isTypification, mangleParamAlias, mangleRadicalId, tuple } from "./typification.js";
|
|
7
5
|
import { labelRSLangNode, labelToken, labelType } from "../labels.js";
|
|
6
|
+
import { annotateError, annotateType } from "../ast-annotations.js";
|
|
7
|
+
import { RSErrorCode } from "../error.js";
|
|
8
8
|
import { checkCompatibility, checkEquality, cloneTypification, compareTemplated, hasGenerics, mergeTypifications, substituteBase } from "./typification-api.js";
|
|
9
9
|
//#region src/rslang/semantic/type-auditor.ts
|
|
10
10
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { annotateError } from "../ast-annotations.js";
|
|
2
|
-
import { RSErrorCode } from "../error.js";
|
|
3
1
|
import { getNodeText } from "../../parsing/ast.js";
|
|
4
2
|
import "../../parsing/index.js";
|
|
5
3
|
import { TokenID } from "../parser/token.js";
|
|
4
|
+
import { annotateError } from "../ast-annotations.js";
|
|
5
|
+
import { RSErrorCode } from "../error.js";
|
|
6
6
|
import { ValueClass } from "./value-class.js";
|
|
7
7
|
//#region src/rslang/semantic/value-auditor.ts
|
|
8
8
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { annotateError } from "./rslang/ast-annotations.js";
|
|
2
|
-
import { RSErrorCode } from "./rslang/error.js";
|
|
3
1
|
import { visitAstDFS } from "./parsing/ast.js";
|
|
4
2
|
import "./parsing/index.js";
|
|
5
3
|
import { TokenID } from "./rslang/parser/token.js";
|
|
6
4
|
import { TypeClass } from "./rslang/semantic/typification.js";
|
|
5
|
+
import { annotateError } from "./rslang/ast-annotations.js";
|
|
6
|
+
import { RSErrorCode } from "./rslang/error.js";
|
|
7
7
|
import "./rslang/parser/parser.terms.js";
|
|
8
8
|
//#region src/rslang/parser/syntax-errors/context.ts
|
|
9
9
|
/** Skips classifiers that conflict with bracket-level diagnostics. */
|
|
@@ -708,4 +708,4 @@ function extractInternal(node, expression, collect, hasBracketErrors, options) {
|
|
|
708
708
|
//#endregion
|
|
709
709
|
export { extractSyntaxErrors as t };
|
|
710
710
|
|
|
711
|
-
//# sourceMappingURL=syntax-errors-
|
|
711
|
+
//# sourceMappingURL=syntax-errors-D_VV5hAM.js.map
|