@rsconcept/domain 2.1.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/api-Bf0f_uiI.d.ts +57 -0
  2. package/dist/{diagnostics-CY9sKggB.js → diagnostics-B1OfMra1.js} +412 -174
  3. package/dist/diagnostics-B1OfMra1.js.map +1 -0
  4. package/dist/{diagnostics-EaIt3zIw.d.ts → diagnostics-Db1F7ruF.d.ts} +3 -3
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +2 -2
  7. package/dist/library/diagnostics.d.ts +1 -1
  8. package/dist/library/diagnostics.js +1 -1
  9. package/dist/library/index.d.ts +1 -1
  10. package/dist/library/index.js +1 -1
  11. package/dist/library/oss-api.d.ts +1 -1
  12. package/dist/library/oss-api.js +3 -3
  13. package/dist/library/oss-api.js.map +1 -1
  14. package/dist/library/rsengine.d.ts +1 -1
  15. package/dist/library/rsengine.js +1 -1
  16. package/dist/library/{rsform-api.d.ts → rsform-api/index.d.ts} +109 -66
  17. package/dist/library/rsform-api/index.js +2 -0
  18. package/dist/library/rsform.d.ts +1 -1
  19. package/dist/library/rsform.js.map +1 -1
  20. package/dist/library/rsmodel-api.d.ts +1 -1
  21. package/dist/library/rsmodel-api.js +3 -1
  22. package/dist/library/rsmodel-api.js.map +1 -1
  23. package/dist/library/rsmodel.d.ts +1 -1
  24. package/dist/library/structure-planner.d.ts +1 -1
  25. package/dist/library/structure-planner.js +1 -1
  26. package/dist/rslang/api.d.ts +2 -58
  27. package/dist/rslang/api.js +1 -1
  28. package/dist/rslang/index.js +1 -1
  29. package/dist/rslang/parser/syntax-errors/index.js +1 -1
  30. package/dist/rslang/semantic/analyzer.js +2 -2
  31. package/dist/{syntax-errors-DwPXhpVe.js → syntax-errors-BN_bqTaX.js} +2 -2
  32. package/dist/{syntax-errors-DwPXhpVe.js.map → syntax-errors-BN_bqTaX.js.map} +1 -1
  33. package/package.json +3 -3
  34. package/src/library/oss-api.ts +5 -2
  35. package/src/library/rsform-api/alias.ts +104 -0
  36. package/src/library/rsform-api/analysis.ts +157 -0
  37. package/src/library/rsform-api/cst-type.ts +216 -0
  38. package/src/library/rsform-api/expression.ts +73 -0
  39. package/src/library/rsform-api/formal-graph.test.ts +72 -0
  40. package/src/library/rsform-api/formal-graph.ts +195 -0
  41. package/src/library/rsform-api/index.ts +32 -0
  42. package/src/library/rsform-api/semantic-relations.ts +117 -0
  43. package/src/library/rsform-api/stats.ts +170 -0
  44. package/src/library/rsform-api/structure.ts +93 -0
  45. package/src/library/rsform-api/synthesis.ts +27 -0
  46. package/src/library/rsform-api/types.ts +21 -0
  47. package/src/library/rsform.ts +2 -2
  48. package/src/library/rsmodel-api.ts +7 -1
  49. package/dist/diagnostics-CY9sKggB.js.map +0 -1
  50. package/dist/library/rsform-api.js +0 -2
  51. package/src/library/rsform-api.ts +0 -755
@@ -1,64 +1,13 @@
1
- import { t as AstNode } from "../ast-C8sIpKdL.js";
2
- import { g as TypeClass, y as TypePath } from "../typification-9lNu9R4k.js";
3
- import { t as ValueClass } from "../value-class-CNI-lqXJ.js";
4
- import { r as AnalysisFull } from "../analyzer-fNhkwO-6.js";
5
- import { r as LibraryItem } from "../library-CYun28Xz.js";
6
- import { C as RSFormStats, S as RSForm, b as CstStatus, g as ArgumentValue, v as Constituenta, x as CstType, y as CstClass } from "../diagnostics-EaIt3zIw.js";
7
- import { AliasMapping } from "../rslang/api.js";
1
+ import { t as Graph } from "../../graph-CL73WdW1.js";
2
+ import { t as AstNode } from "../../ast-C8sIpKdL.js";
3
+ import { g as TypeClass, y as TypePath } from "../../typification-9lNu9R4k.js";
4
+ import { t as ValueClass } from "../../value-class-CNI-lqXJ.js";
5
+ import { r as AnalysisFull } from "../../analyzer-fNhkwO-6.js";
6
+ import { r as LibraryItem } from "../../library-CYun28Xz.js";
7
+ import { C as RSFormStats, S as RSForm, b as CstStatus, g as ArgumentValue, v as Constituenta, x as CstType, y as CstClass } from "../../diagnostics-Db1F7ruF.js";
8
+ import { t as AliasMapping } from "../../api-Bf0f_uiI.js";
8
9
 
9
- //#region src/library/rsform-api.d.ts
10
- /** Checks if {@link Constituenta} is a schema issue. */
11
- declare function isSchemaIssue(cst: Constituenta): boolean;
12
- /** Infers the status of an expression based on parsing and value information. */
13
- declare function inferStatus(parse: boolean, value?: ValueClass | null): CstStatus;
14
- /** Infers type of constituent for a given template and arguments. */
15
- declare function inferTemplatedType(templateType: CstType, args: ArgumentValue[]): CstType;
16
- /** Build alias mapping from template argument bindings. */
17
- declare function argumentValuesToMapping(args: ArgumentValue[]): AliasMapping;
18
- /**
19
- * Normalize a RSLang expression for duplicate comparison.
20
- *
21
- * Returns `null` for basic concepts without formal definitions. Pass a pre-parsed `ast`
22
- * when the expression was already analyzed to avoid re-parsing.
23
- */
24
- declare function normalizeExpression(expression: string, cst_type: CstType, ast?: AstNode | null): string | null;
25
- /** Checks if given expression is a template. */
26
- declare function inferTemplate(expression: string): boolean;
27
- /** Infers the {@link CstClass} based on the provided {@link CstType} and template status. */
28
- declare function inferClass(type: CstType, isTemplate?: boolean): CstClass;
29
- /** Check if {@link Constituenta} is a template or a category. */
30
- declare function isTemplateCst(cst: Constituenta): boolean;
31
- /** Apply filter based on start {@link Constituenta} type. */
32
- declare function applyFilterCategory(start: Constituenta, items: Constituenta[]): Constituenta[];
33
- /** Prefix for alias indicating {@link CstType}. */
34
- declare function getCstTypePrefix(type: CstType): string;
35
- /** Guess {@link CstType} from user input hint. */
36
- declare function guessCstType(hint: string): CstType | null;
37
- /** Evaluate if {@link CstType} is basic concept. */
38
- declare function isBasicConcept(type: CstType): boolean;
39
- /** Evaluate if {@link CstType} is base set or constant set. */
40
- declare function isBaseSet(type: CstType): boolean;
41
- /** Evaluate if {@link CstType} is a function. */
42
- declare function isFunctional(type: CstType): boolean;
43
- /** Evaluate if {@link CstType} is logical. */
44
- declare function isLogical(type: CstType): boolean;
45
- /** Evaluate if {@link Constituenta} can be used produce structure. */
46
- declare function canProduceStructure(cst: Constituenta): boolean;
47
- /** Evaluate if {@link CstType} can have manual typification. */
48
- declare function canHaveManualTypification(type: CstType): boolean;
49
- /** Validate alias format for a given {@link CstType} (prefix + digits, min length 2). */
50
- declare function validateAliasFormat(alias: string, type: CstType): boolean;
51
- /** Validate new alias against {@link CstType} and {@link RSForm}. */
52
- declare function validateNewAlias(alias: string, type: CstType, schema: RSForm): boolean;
53
- /** Generate alias for new {@link Constituenta} of a given {@link CstType} for current {@link RSForm}. */
54
- declare function generateAlias(type: CstType, schema: RSForm, takenAliases?: string[]): string;
55
- /**
56
- * Id to pass as `insert_after` when creating a new {@link Constituenta} spawned by `targetId`:
57
- * after the last existing child of that spawner, or after the spawner itself if none.
58
- */
59
- declare function inferNewSpawnPosition(schema: RSForm, targetId: number): number;
60
- /** Sorts library items relevant for InlineSynthesis with specified {@link RSForm}. */
61
- declare function sortItemsForInlineSynthesis(receiver: RSForm, items: readonly LibraryItem[]): LibraryItem[];
10
+ //#region src/library/rsform-api/alias.d.ts
62
11
  /** Fields of {@link Constituenta} updated in place by alias mapping. */
63
12
  interface ConstituentaMappableFields {
64
13
  alias: string;
@@ -67,6 +16,14 @@ interface ConstituentaMappableFields {
67
16
  term_raw: string;
68
17
  definition_raw: string;
69
18
  }
19
+ /** Build alias mapping from template argument bindings. */
20
+ declare function argumentValuesToMapping(args: ArgumentValue[]): AliasMapping;
21
+ /** Validate alias format for a given {@link CstType} (prefix + digits, min length 2). */
22
+ declare function validateAliasFormat(alias: string, type: CstType): boolean;
23
+ /** Validate new alias against {@link CstType} and {@link RSForm}. */
24
+ declare function validateNewAlias(alias: string, type: CstType, schema: RSForm): boolean;
25
+ /** Generate alias for new {@link Constituenta} of a given {@link CstType} for current {@link RSForm}. */
26
+ declare function generateAlias(type: CstType, schema: RSForm, takenAliases?: string[]): string;
70
27
  /**
71
28
  * Remap formal expressions and terminological entity references in constituent fields.
72
29
  * Mutates each element of `items` in place; pass owned or cloned data only.
@@ -76,10 +33,8 @@ declare function applyMappingToConstituents<T extends ConstituentaMappableFields
76
33
  declare function removeAliasReference(expression: string, alias: string): string;
77
34
  /** Add alias to expression. */
78
35
  declare function addAliasReference(expression: string, alias: string): string;
79
- /** Returns expected {@link TypeClass} of formal definition for {@link CstType}. */
80
- declare function typeClassForCstType(cstType: CstType): TypeClass;
81
- /** Checks whether a constituenta type supports formal definitions. */
82
- declare function canHaveFormalDefinition(cstType: CstType): boolean;
36
+ //#endregion
37
+ //#region src/library/rsform-api/analysis.d.ts
83
38
  declare function getAnalysisFor(expression: string, cstType: CstType, schema: RSForm, alias?: string): AnalysisFull;
84
39
  /**
85
40
  * When an untyped / bare F·P reference names a constituent on a definition cycle with the
@@ -92,12 +47,100 @@ declare function getAnalysisFor(expression: string, cstType: CstType, schema: RS
92
47
  * `expression`, so Check works before Save.
93
48
  */
94
49
  declare function refineAnalysisForDependencyCycles(analysis: AnalysisFull, expression: string, schema: RSForm, alias?: string): AnalysisFull;
50
+ //#endregion
51
+ //#region src/library/rsform-api/cst-type.d.ts
52
+ /** Prefix for alias indicating {@link CstType}. */
53
+ declare function getCstTypePrefix(type: CstType): string;
54
+ /** Guess {@link CstType} from user input hint. */
55
+ declare function guessCstType(hint: string): CstType | null;
56
+ /** Infers the {@link CstClass} based on the provided {@link CstType} and template status. */
57
+ declare function inferClass(type: CstType, isTemplate?: boolean): CstClass;
58
+ /** Check if {@link Constituenta} is a template or a category. */
59
+ declare function isTemplateCst(cst: Constituenta): boolean;
60
+ /** Evaluate if {@link CstType} is basic concept. */
61
+ declare function isBasicConcept(type: CstType): boolean;
62
+ /** Evaluate if {@link CstType} is base set or constant set. */
63
+ declare function isBaseSet(type: CstType): boolean;
64
+ /** Evaluate if {@link CstType} is a function. */
65
+ declare function isFunctional(type: CstType): boolean;
66
+ /** Evaluate if {@link CstType} is logical. */
67
+ declare function isLogical(type: CstType): boolean;
68
+ /** Evaluate if {@link CstType} can have manual typification. */
69
+ declare function canHaveManualTypification(type: CstType): boolean;
70
+ /** Checks whether a constituenta type supports formal definitions. */
71
+ declare function canHaveFormalDefinition(cstType: CstType): boolean;
72
+ /** Returns expected {@link TypeClass} of formal definition for {@link CstType}. */
73
+ declare function typeClassForCstType(cstType: CstType): TypeClass;
74
+ /** Evaluate if {@link Constituenta} can be used produce structure. */
75
+ declare function canProduceStructure(cst: Constituenta): boolean;
76
+ //#endregion
77
+ //#region src/library/rsform-api/expression.d.ts
78
+ /** Infers the status of an expression based on parsing and value information. */
79
+ declare function inferStatus(parse: boolean, value?: ValueClass | null): CstStatus;
80
+ /** Infers type of constituent for a given template and arguments. */
81
+ declare function inferTemplatedType(templateType: CstType, args: ArgumentValue[]): CstType;
82
+ /**
83
+ * Normalize a RSLang expression for duplicate comparison.
84
+ *
85
+ * Returns `null` for basic concepts without formal definitions. Pass a pre-parsed `ast`
86
+ * when the expression was already analyzed to avoid re-parsing.
87
+ */
88
+ declare function normalizeExpression(expression: string, cst_type: CstType, ast?: AstNode | null): string | null;
89
+ /** Checks if given expression is a template. */
90
+ declare function inferTemplate(expression: string): boolean;
91
+ /** Apply filter based on start {@link Constituenta} type. */
92
+ declare function applyFilterCategory(start: Constituenta, items: Constituenta[]): Constituenta[];
93
+ //#endregion
94
+ //#region src/library/rsform-api/types.d.ts
95
+ /** Minimal constituent fields required to restore order. */
96
+ interface OrderableConstituenta {
97
+ id: number;
98
+ alias: string;
99
+ cst_type: CstType;
100
+ definition_formal: string;
101
+ }
102
+ /** Semantic parent/children derived from formal definitions (backend SemanticInfo). */
103
+ interface SemanticRelations {
104
+ /** Parent id for each constituenta (self when none). */
105
+ parentOf: Map<number, number>;
106
+ /** Semantic children ids for each constituenta. */
107
+ childrenOf: Map<number, number[]>;
108
+ }
109
+ //#endregion
110
+ //#region src/library/rsform-api/formal-graph.d.ts
111
+ /**
112
+ * Build the formal dependency graph: supplier → dependent.
113
+ * Matches backend {@code RSForm.graph_formal}.
114
+ */
115
+ declare function buildFormalDependencyGraph(items: readonly OrderableConstituenta[]): Graph<number>;
116
+ /**
117
+ * Reorder constituents: formal topology hard, semantic children sticky when ready,
118
+ * otherwise stable against type/kernel preferred ranks.
119
+ *
120
+ * One Kahn pass over the formal dependency graph.
121
+ */
122
+ declare function restoreConstituentOrder<T extends OrderableConstituenta>(items: readonly T[], graph?: Graph<number>, relations?: SemanticRelations): T[];
123
+ //#endregion
124
+ //#region src/library/rsform-api/stats.d.ts
125
+ /** Checks if {@link Constituenta} is a schema issue. */
126
+ declare function isSchemaIssue(cst: Constituenta): boolean;
95
127
  /** Calculate statistics for {@link RSForm}. */
96
128
  declare function calculateSchemaStats(target: RSForm): RSFormStats;
129
+ //#endregion
130
+ //#region src/library/rsform-api/structure.d.ts
131
+ /**
132
+ * Id to pass as `insert_after` when creating a new {@link Constituenta} spawned by `targetId`:
133
+ * after the last existing child of that spawner, or after the spawner itself if none.
134
+ */
135
+ declare function inferNewSpawnPosition(schema: RSForm, targetId: number): number;
97
136
  /** Finds {@link Constituenta} by structure path. */
98
137
  declare function findCstByStructure(schema: RSForm, target: Constituenta, path: TypePath): Constituenta | null;
99
138
  /** Retrieves name for piece of target {@link Constituenta} structure. */
100
139
  declare function getStructureName(schema: RSForm, target: Constituenta, path: TypePath): string;
101
140
  //#endregion
102
- export { ConstituentaMappableFields, addAliasReference, applyFilterCategory, applyMappingToConstituents, argumentValuesToMapping, calculateSchemaStats, canHaveFormalDefinition, canHaveManualTypification, canProduceStructure, findCstByStructure, generateAlias, getAnalysisFor, getCstTypePrefix, getStructureName, guessCstType, inferClass, inferNewSpawnPosition, inferStatus, inferTemplate, inferTemplatedType, isBaseSet, isBasicConcept, isFunctional, isLogical, isSchemaIssue, isTemplateCst, normalizeExpression, refineAnalysisForDependencyCycles, removeAliasReference, sortItemsForInlineSynthesis, typeClassForCstType, validateAliasFormat, validateNewAlias };
103
- //# sourceMappingURL=rsform-api.d.ts.map
141
+ //#region src/library/rsform-api/synthesis.d.ts
142
+ /** Sorts library items relevant for InlineSynthesis with specified {@link RSForm}. */
143
+ declare function sortItemsForInlineSynthesis(receiver: RSForm, items: readonly LibraryItem[]): LibraryItem[];
144
+ //#endregion
145
+ export { addAliasReference, applyFilterCategory, applyMappingToConstituents, argumentValuesToMapping, calculateSchemaStats, canHaveManualTypification, canProduceStructure, findCstByStructure, generateAlias, getAnalysisFor, getCstTypePrefix, getStructureName, guessCstType, inferClass, inferNewSpawnPosition, inferStatus, inferTemplate, inferTemplatedType, isBaseSet, isBasicConcept, isFunctional, isLogical, isSchemaIssue, isTemplateCst, normalizeExpression, refineAnalysisForDependencyCycles, removeAliasReference, restoreConstituentOrder, sortItemsForInlineSynthesis, typeClassForCstType, validateAliasFormat, validateNewAlias };
146
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { A as canProduceStructure, C as applyMappingToConstituents, D as validateAliasFormat, E as removeAliasReference, F as isBasicConcept, I as isFunctional, L as isLogical, M as guessCstType, N as inferClass, O as validateNewAlias, P as isBaseSet, R as isTemplateCst, S as addAliasReference, T as generateAlias, _ as inferTemplate, b as getAnalysisFor, c as sortItemsForInlineSynthesis, d as inferNewSpawnPosition, f as calculateSchemaStats, g as inferStatus, h as applyFilterCategory, j as getCstTypePrefix, k as canHaveManualTypification, l as findCstByStructure, m as restoreConstituentOrder, p as isSchemaIssue, u as getStructureName, v as inferTemplatedType, w as argumentValuesToMapping, x as refineAnalysisForDependencyCycles, y as normalizeExpression, z as typeClassForCstType } from "../../diagnostics-B1OfMra1.js";
2
+ export { addAliasReference, applyFilterCategory, applyMappingToConstituents, argumentValuesToMapping, calculateSchemaStats, canHaveManualTypification, canProduceStructure, findCstByStructure, generateAlias, getAnalysisFor, getCstTypePrefix, getStructureName, guessCstType, inferClass, inferNewSpawnPosition, inferStatus, inferTemplate, inferTemplatedType, isBaseSet, isBasicConcept, isFunctional, isLogical, isSchemaIssue, isTemplateCst, normalizeExpression, refineAnalysisForDependencyCycles, removeAliasReference, restoreConstituentOrder, sortItemsForInlineSynthesis, typeClassForCstType, validateAliasFormat, validateNewAlias };
@@ -1,2 +1,2 @@
1
- import { C as RSFormStats, S as RSForm, T as TypeInfo, _ as Attribution, b as CstStatus, g as ArgumentValue, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-EaIt3zIw.js";
1
+ import { C as RSFormStats, S as RSForm, T as TypeInfo, _ as Attribution, b as CstStatus, g as ArgumentValue, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-Db1F7ruF.js";
2
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 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
+ {"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 /** Non-logical basic constituents missing convention and/or resolved term. */\n count_missing_basic_text: 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,6 +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 { S as RSForm, f as EvalStatus, l as BasicBinding, m as RSModelStats, v as Constituenta, x as CstType } from "../diagnostics-EaIt3zIw.js";
3
+ import { S as RSForm, f as EvalStatus, l as BasicBinding, m as RSModelStats, v as Constituenta, x as CstType } from "../diagnostics-Db1F7ruF.js";
4
4
  import { RSEngine } from "./rsengine.js";
5
5
 
6
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 { D as isBaseSet, O as isBasicConcept, f as calculateSchemaStats, s as modelStatusCstDiagnostic } from "../diagnostics-CY9sKggB.js";
5
+ import { F as isBasicConcept, P as isBaseSet, f as calculateSchemaStats, s as modelStatusCstDiagnostic } from "../diagnostics-B1OfMra1.js";
6
6
  import { EvalStatus } from "./rsmodel.js";
7
7
  //#region src/library/rsmodel-api.ts
8
8
  const RANDOM_INTEGER_MIN = -100;
@@ -172,8 +172,10 @@ function updateValueElement(value, path, newValue) {
172
172
  return setNestedValue(value, path, newValue);
173
173
  }
174
174
  function deleteValueElement(value, path, type, target) {
175
+ if (value === null) return null;
175
176
  if (path.length === 0 && type.typeID !== TypeID.collection) return null;
176
177
  const arrayValue = extractValue(value, path);
178
+ if (!Array.isArray(arrayValue)) return null;
177
179
  return setNestedValue(value, path, [...arrayValue.slice(0, target), ...arrayValue.slice(target + 1)]);
178
180
  }
179
181
  function addValueElement(value, path, type, currentType) {
@@ -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 { 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":";;;;;;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K,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,OAAO,UACV,OAAO;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
+ {"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 (value === null) {\n return null;\n }\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return null;\n }\n\n const arrayValue = extractValue(value, path);\n if (!Array.isArray(arrayValue)) {\n return null;\n }\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,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,MAAM,OAAO,QAAQ,IAAI,GACtC,OAAO,OAAO,CAAC,KAAK;CAEtB,OAAO;AACT;;AAGA,SAAgB,kBAAkB,MAA8B;CAC9D,IAAI,OAAO,SAAS,UAClB,OAAO,OAAO,SAAS,IAAI;CAE7B,IAAI,CAAC,MAAM,QAAQ,IAAI,GACrB,OAAO;CAET,OAAO,KAAK,OAAM,SAAQ,kBAAkB,IAAI,CAAC;AACnD;AAEA,SAAgB,oBACd,MACA,QACA,YACA,mBAA2B,mCACb;CACd,QAAQ,KAAK,QAAb;EACE,KAAK,OAAO,SACV,OAAO,KAAK,MAAM,KAAK,OAAO,IAAK,GAA4C,IAAI;EACrF,KAAK,OAAO,OAAO;GACjB,MAAM,MAAM,WAAW,IAAI,KAAK,MAAM;GACtC,MAAM,UAAU,MAAM,OAAO,IAAI,IAAI,EAAE,IAAI;GAC3C,MAAM,MAAM,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM;GACjD,IAAI,IAAI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2 +1,2 @@
1
- import { d as DEFAULT_VALUE_TEXT, f as EvalStatus, h as TYPE_BASIC, l as BasicBinding, m as RSModelStats, p as RSModel, u as BasicsContext } from "../diagnostics-EaIt3zIw.js";
1
+ import { d as DEFAULT_VALUE_TEXT, f as EvalStatus, h as TYPE_BASIC, l as BasicBinding, m as RSModelStats, p as RSModel, u as BasicsContext } from "../diagnostics-Db1F7ruF.js";
2
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 { S as RSForm, v as Constituenta } from "../diagnostics-EaIt3zIw.js";
2
+ import { S as RSForm, v as Constituenta } from "../diagnostics-Db1F7ruF.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 { g as findCstByStructure } from "../diagnostics-CY9sKggB.js";
6
+ import { l as findCstByStructure } from "../diagnostics-B1OfMra1.js";
7
7
  //#region src/library/structure-planner.ts
8
8
  /** Structure planner for {@link Constituenta}. */
9
9
  var StructurePlanner = class {
@@ -1,59 +1,3 @@
1
- import { t as AstNode } from "../ast-C8sIpKdL.js";
2
- import { n as ArgumentsType } from "../arguments-extractor-ngatANBI.js";
3
1
  import { t as generateExpressionFromAst } from "../expression-generator-CoucLIkE.js";
4
-
5
- //#region src/rslang/api.d.ts
6
- /** Represents alias mapping. */
7
- type AliasMapping = Record<string, string>;
8
- /** Whether {@link value} is a single schema global alias (e.g. `X1`, `F42`). */
9
- declare function isGlobalAlias(value: string): boolean;
10
- /**
11
- * Parse a RSLang expression into a normalized AST.
12
- *
13
- * Returns `null` for blank input. Parses the original `expression` string so node
14
- * offsets match the source text (required for slice-based AST walks).
15
- */
16
- declare function parseRSLangExpression(expression: string): AstNode | null;
17
- /** Extract arguments from AST. */
18
- declare function extractArguments(ast: AstNode): ArgumentsType[];
19
- /** Extracts global variable names from a given expression. */
20
- declare function extractGlobals(expression: string): Set<string>;
21
- /** Check if expression is simple derivation. */
22
- declare function isSimpleExpression(text: string): boolean;
23
- /** Check if expression is set typification. */
24
- declare function isSetTypification(text: string): boolean;
25
- /**
26
- * Splits a string containing a template definition into its head and body parts.
27
- *
28
- * A template definition is expected to have the following format: `[head] body`.
29
- * If the input string does not contain the opening square bracket '[', the entire
30
- * string is treated as the body, and an empty string is assigned to the head.
31
- * If the opening bracket is present, the function attempts to find the matching
32
- * closing bracket ']' to determine the head and body parts.
33
- *
34
- * @example
35
- * const template = '[header] body content';
36
- * const result = splitTemplateDefinition(template);
37
- * // result: `{ head: 'header', body: 'body content' }`
38
- */
39
- declare function splitTemplateDefinition(target: string): {
40
- head: string;
41
- body: string;
42
- };
43
- /**
44
- * Substitutes values for template arguments in a given expression.
45
- *
46
- * This function takes an input mathematical expression and a list of argument values.
47
- * It replaces template argument placeholders in the expression with their corresponding values
48
- * from the provided arguments.
49
- */
50
- declare function substituteTemplateArgs(expression: string, mapping: AliasMapping): string;
51
- /** Substitute local parameter aliases in an expression fragment. */
52
- declare function substituteLocalAliases(expression: string, mapping: AliasMapping): string;
53
- /** Apply alias mapping. */
54
- declare function applyAliasMapping(target: string, mapping: AliasMapping): string;
55
- /** Apply alias typification mapping. */
56
- declare function applyTypificationMapping(target: string, mapping: AliasMapping): string;
57
- //#endregion
58
- export { AliasMapping, applyAliasMapping, applyTypificationMapping, extractArguments, extractGlobals, generateExpressionFromAst, isGlobalAlias, isSetTypification, isSimpleExpression, parseRSLangExpression, splitTemplateDefinition, substituteLocalAliases, substituteTemplateArgs };
59
- //# sourceMappingURL=api.d.ts.map
2
+ import { a as extractGlobals, c as isSimpleExpression, d as substituteLocalAliases, f as substituteTemplateArgs, i as extractArguments, l as parseRSLangExpression, n as applyAliasMapping, o as isGlobalAlias, r as applyTypificationMapping, s as isSetTypification, t as AliasMapping, u as splitTemplateDefinition } from "../api-Bf0f_uiI.js";
3
+ export { AliasMapping, applyAliasMapping, applyTypificationMapping, extractArguments, extractGlobals, generateExpressionFromAst, isGlobalAlias, isSetTypification, isSimpleExpression, parseRSLangExpression, splitTemplateDefinition, substituteLocalAliases, substituteTemplateArgs };
@@ -1,7 +1,7 @@
1
1
  import { buildTree } from "../parsing/ast.js";
2
2
  import "../parsing/index.js";
3
- import { parser } from "./parser/parser.js";
4
3
  import { normalizeAST } from "./parser/normalize.js";
4
+ import { parser } from "./parser/parser.js";
5
5
  import { ArgumentsExtractor } from "./semantic/arguments-extractor.js";
6
6
  import { generateExpressionFromAst } from "./parser/expression-generator.js";
7
7
  //#region src/rslang/api.ts
@@ -1,10 +1,10 @@
1
1
  import { TokenID } from "./parser/token.js";
2
2
  import { AnyTypificationT, EmptySetT, LogicT, TypeClass, TypeID, makeTypePath } from "./semantic/typification.js";
3
+ import { parser } from "./parser/parser.js";
3
4
  import { readErrorAnnotation, readTypeAnnotation } from "./ast-annotations.js";
4
5
  import { RSErrorCode } from "./error.js";
5
6
  import { C as printValue, u as makeValuePath } from "../value-COprb2Je.js";
6
7
  import { RSCalculator } from "./eval/calculator.js";
7
- import { parser } from "./parser/parser.js";
8
8
  import { ValueClass } from "./semantic/value-class.js";
9
9
  import { RSLangAnalyzer } from "./semantic/analyzer.js";
10
10
  import { applyAsciiTypeSubstitutions, parseTypeText } from "./semantic/typification-parser.js";
@@ -1,2 +1,2 @@
1
- import { t as extractSyntaxErrors } from "../../../syntax-errors-DwPXhpVe.js";
1
+ import { t as extractSyntaxErrors } from "../../../syntax-errors-BN_bqTaX.js";
2
2
  export { extractSyntaxErrors };
@@ -2,9 +2,9 @@ import { TokenID } from "../parser/token.js";
2
2
  import { TypeID, basic, bool, constant, debool } from "./typification.js";
3
3
  import { labelType } from "../labels.js";
4
4
  import { annotateError } from "../ast-annotations.js";
5
- import { RSErrorCode } from "../error.js";
6
5
  import { parseRSLangExpression } from "../api.js";
7
- import { t as extractSyntaxErrors } from "../../syntax-errors-DwPXhpVe.js";
6
+ import { RSErrorCode } from "../error.js";
7
+ import { t as extractSyntaxErrors } from "../../syntax-errors-BN_bqTaX.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";
@@ -2,9 +2,9 @@ import { visitAstDFS } from "./parsing/ast.js";
2
2
  import "./parsing/index.js";
3
3
  import { TokenID } from "./rslang/parser/token.js";
4
4
  import { TypeClass } from "./rslang/semantic/typification.js";
5
+ import "./rslang/parser/parser.terms.js";
5
6
  import { annotateError } from "./rslang/ast-annotations.js";
6
7
  import { RSErrorCode } from "./rslang/error.js";
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. */
10
10
  function whenNoBracketErrors(classifier) {
@@ -722,4 +722,4 @@ function extractInternal(node, expression, collect, hasBracketErrors, options) {
722
722
  //#endregion
723
723
  export { extractSyntaxErrors as t };
724
724
 
725
- //# sourceMappingURL=syntax-errors-DwPXhpVe.js.map
725
+ //# sourceMappingURL=syntax-errors-BN_bqTaX.js.map