@rsconcept/rstool 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +21 -26
  2. package/dist/analysis-JiwOYDKx.d.ts +16 -0
  3. package/dist/common-DxLg3eXX.d.ts +17 -0
  4. package/dist/constituenta-Dnd6iToB.d.ts +36 -0
  5. package/dist/diagnostic-BMYvciz8.d.ts +15 -0
  6. package/dist/evaluation-CCVYH0wA.d.ts +21 -0
  7. package/dist/index.d.ts +12 -15
  8. package/dist/index.js +7 -585
  9. package/dist/mappers/model-adapter.d.ts +18 -23
  10. package/dist/mappers/model-adapter.js +183 -231
  11. package/dist/mappers/model-adapter.js.map +1 -1
  12. package/dist/mappers/schema-adapter.d.ts +16 -18
  13. package/dist/mappers/schema-adapter.js +55 -84
  14. package/dist/mappers/schema-adapter.js.map +1 -1
  15. package/dist/mappers/types.d.ts +15 -16
  16. package/dist/mappers/types.js +16 -17
  17. package/dist/mappers/types.js.map +1 -1
  18. package/dist/model-value-SFAVj0dw.d.ts +35 -0
  19. package/dist/models/analysis.d.ts +2 -18
  20. package/dist/models/analysis.js +1 -1
  21. package/dist/models/common.d.ts +2 -15
  22. package/dist/models/common.js +1 -8
  23. package/dist/models/constituenta.d.ts +2 -38
  24. package/dist/models/constituenta.js +1 -1
  25. package/dist/models/diagnostic.d.ts +2 -17
  26. package/dist/models/diagnostic.js +1 -1
  27. package/dist/models/evaluation.d.ts +2 -23
  28. package/dist/models/evaluation.js +1 -1
  29. package/dist/models/index.d.ts +10 -13
  30. package/dist/models/index.js +4 -491
  31. package/dist/models/model-value.d.ts +2 -37
  32. package/dist/models/model-value.js +1 -1
  33. package/dist/models/rstool-agent.d.ts +2 -36
  34. package/dist/models/rstool-agent.js +90 -477
  35. package/dist/models/rstool-agent.js.map +1 -1
  36. package/dist/models/session.d.ts +2 -29
  37. package/dist/models/session.js +1 -1
  38. package/dist/models/tool-contract.d.ts +2 -33
  39. package/dist/models/tool-contract.js +5 -5
  40. package/dist/models/tool-contract.js.map +1 -1
  41. package/dist/rstool-agent-DkeH5Qml.d.ts +33 -0
  42. package/dist/session/session-store.d.ts +14 -21
  43. package/dist/session/session-store.js +59 -63
  44. package/dist/session/session-store.js.map +1 -1
  45. package/dist/session-BHGCCLfQ.d.ts +24 -0
  46. package/dist/tool-contract-CsGqg_0P.d.ts +30 -0
  47. package/dist/wrapper/client.d.ts +26 -24
  48. package/dist/wrapper/client.js +90 -93
  49. package/dist/wrapper/client.js.map +1 -1
  50. package/dist/wrapper/stdio-wrapper.d.ts +1 -1
  51. package/dist/wrapper/stdio-wrapper.js +166 -664
  52. package/dist/wrapper/stdio-wrapper.js.map +1 -1
  53. package/docs/CONCEPTUAL-SCHEMA.md +168 -0
  54. package/docs/CONSTITUENTA.md +46 -23
  55. package/docs/DIAGNOSTICS.md +79 -74
  56. package/docs/DOMAIN.md +32 -30
  57. package/docs/GRAMMAR-REF.md +55 -55
  58. package/docs/PORTAL-API.md +7 -10
  59. package/docs/README.md +1 -0
  60. package/docs/SYNTAX.md +32 -32
  61. package/docs/TYPIFICATION.md +14 -9
  62. package/package.json +8 -7
  63. package/skills/INSTALL.md +35 -0
  64. package/skills/README.md +17 -9
  65. package/skills/rstool-helper/EXAMPLES.md +51 -10
  66. package/skills/rstool-helper/GUIDE.md +141 -0
  67. package/skills/rstool-helper/REFERENCE.md +5 -3
  68. package/skills/rstool-helper/SKILL.md +23 -134
  69. package/dist/index.js.map +0 -1
  70. package/dist/models/analysis.js.map +0 -1
  71. package/dist/models/common.js.map +0 -1
  72. package/dist/models/constituenta.js.map +0 -1
  73. package/dist/models/diagnostic.js.map +0 -1
  74. package/dist/models/evaluation.js.map +0 -1
  75. package/dist/models/index.js.map +0 -1
  76. package/dist/models/model-value.js.map +0 -1
  77. package/dist/models/session.js.map +0 -1
@@ -1,248 +1,200 @@
1
- // src/mappers/model-adapter.ts
1
+ import { toPublicError } from "./types.js";
2
+ import { CstType } from "@rsconcept/domain/library/rsform";
3
+ import { EvalStatus } from "@rsconcept/domain/library/rsmodel";
4
+ import { RSLangAnalyzer } from "@rsconcept/domain/rslang";
2
5
  import { Graph } from "@rsconcept/domain/graph/graph";
3
6
  import { extractGlobals } from "@rsconcept/domain/rslang/api";
4
- import { RSLangAnalyzer } from "@rsconcept/domain/rslang";
5
7
  import { isBaseSet } from "@rsconcept/domain/library/rsform-api";
6
- import { CstType } from "@rsconcept/domain/library/rsform";
7
8
  import { RSEngine } from "@rsconcept/domain/library/rsengine";
8
- import { EvalStatus } from "@rsconcept/domain/library/rsmodel";
9
- import {
10
- isInferrable,
11
- isInterpretable,
12
- toBasicBinding,
13
- validateBasicBindingData,
14
- validateValueData
15
- } from "@rsconcept/domain/library/rsmodel-api";
16
-
17
- // src/mappers/types.ts
18
- function toPublicError(error) {
19
- return {
20
- code: error.code,
21
- from: error.from,
22
- to: error.to,
23
- params: error.params
24
- };
25
- }
26
-
27
- // src/mappers/model-adapter.ts
28
- var SESSION_MODEL_ID = 0;
9
+ import { isInferrable, isInterpretable, toBasicBinding, validateBasicBindingData, validateValueData } from "@rsconcept/domain/library/rsmodel-api";
10
+ //#region src/mappers/model-adapter.ts
11
+ const SESSION_MODEL_ID = 0;
29
12
  var ModelAdapter = class {
30
- async setConstituentaValue(session, input) {
31
- this.validateSetInput(session, input);
32
- const engine = this.createEngine(session);
33
- const cst = session.items.find((item) => item.id === input.target);
34
- const frontendType = cst.cstType;
35
- if (isBaseSet(frontendType)) {
36
- const binding = toBasicBinding(input.value);
37
- await engine.setBasicValue(input.target, binding);
38
- } else {
39
- await engine.setStructureValue(input.target, input.value);
40
- }
41
- session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
42
- return structuredClone(session.model);
43
- }
44
- async setConstituentaValues(session, input) {
45
- for (const item of input.items) {
46
- await this.setConstituentaValue(session, item);
47
- }
48
- return structuredClone(session.model);
49
- }
50
- async clearConstituentaValues(session, ids) {
51
- const engine = this.createEngine(session);
52
- for (const id of ids) {
53
- await engine.resetValue(id);
54
- session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
55
- }
56
- return structuredClone(session.model);
57
- }
58
- evaluateExpression(session, expression, cstType) {
59
- const engine = this.createEngine(session);
60
- const result = engine.evaluateExpression(expression, cstType);
61
- const status = result.value === null ? result.errors.length > 0 ? EvalStatus.EVAL_FAIL : EvalStatus.EMPTY : EvalStatus.HAS_DATA;
62
- return toPublicEvaluationResult(result.value, result.errors, result.iterations, result.cacheHits, status);
63
- }
64
- evaluateConstituenta(session, constituentId) {
65
- const cst = session.items.find((item) => item.id === constituentId);
66
- if (!cst) {
67
- throw new Error(`Unknown constituent: ${constituentId}`);
68
- }
69
- const engine = this.createEngine(session);
70
- const result = engine.calculateCst(constituentId);
71
- const status = engine.getCstStatus(constituentId);
72
- return toPublicEvaluationResult(result.value, result.errors, result.iterations, result.cacheHits, status);
73
- }
74
- recalculateModel(session) {
75
- const engine = this.createEngine(session);
76
- engine.recalculateAll();
77
- const items = session.items.map((item) => ({
78
- id: item.id,
79
- alias: item.alias,
80
- value: engine.getCstValue(item.id),
81
- status: engine.getCstStatus(item.id)
82
- }));
83
- return { items };
84
- }
85
- createEngine(session) {
86
- const schema = buildRSFormFromSession(session);
87
- const model = buildRSModelFromSession(session);
88
- const engine = new RSEngine(SESSION_MODEL_ID, createInMemoryServices(session));
89
- engine.loadData(schema, model);
90
- return engine;
91
- }
92
- validateSetInput(session, input) {
93
- const cst = session.items.find((item) => item.id === input.target);
94
- if (!cst) {
95
- throw new Error(`Unknown constituent: ${input.target}`);
96
- }
97
- const frontendType = cst.cstType;
98
- if (!isInterpretable(frontendType)) {
99
- throw new Error(`Constituent ${cst.alias} is not interpretable`);
100
- }
101
- if (isInferrable(frontendType)) {
102
- throw new Error(`Constituent ${cst.alias} is inferrable and cannot be set directly`);
103
- }
104
- if (isBaseSet(frontendType)) {
105
- if (!validateBasicBindingData(input.value)) {
106
- throw new Error(`Invalid basic binding for ${cst.alias}`);
107
- }
108
- return;
109
- }
110
- if (!validateValueData(input.value)) {
111
- throw new Error(`Invalid structured value for ${cst.alias}`);
112
- }
113
- }
13
+ async setConstituentaValue(session, input) {
14
+ this.validateSetInput(session, input);
15
+ const engine = this.createEngine(session);
16
+ const frontendType = session.items.find((item) => item.id === input.target).cstType;
17
+ if (isBaseSet(frontendType)) {
18
+ const binding = toBasicBinding(input.value);
19
+ await engine.setBasicValue(input.target, binding);
20
+ } else await engine.setStructureValue(input.target, input.value);
21
+ session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
22
+ return structuredClone(session.model);
23
+ }
24
+ async setConstituentaValues(session, input) {
25
+ for (const item of input.items) await this.setConstituentaValue(session, item);
26
+ return structuredClone(session.model);
27
+ }
28
+ async clearConstituentaValues(session, ids) {
29
+ const engine = this.createEngine(session);
30
+ for (const id of ids) {
31
+ await engine.resetValue(id);
32
+ session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
33
+ }
34
+ return structuredClone(session.model);
35
+ }
36
+ evaluateExpression(session, expression, cstType) {
37
+ const result = this.createEngine(session).evaluateExpression(expression, cstType);
38
+ const status = result.value === null ? result.errors.length > 0 ? EvalStatus.EVAL_FAIL : EvalStatus.EMPTY : EvalStatus.HAS_DATA;
39
+ return toPublicEvaluationResult(result.value, result.errors, result.iterations, result.cacheHits, status);
40
+ }
41
+ evaluateConstituenta(session, constituentId) {
42
+ if (!session.items.find((item) => item.id === constituentId)) throw new Error(`Unknown constituent: ${constituentId}`);
43
+ const engine = this.createEngine(session);
44
+ const result = engine.calculateCst(constituentId);
45
+ const status = engine.getCstStatus(constituentId);
46
+ return toPublicEvaluationResult(result.value, result.errors, result.iterations, result.cacheHits, status);
47
+ }
48
+ recalculateModel(session) {
49
+ const engine = this.createEngine(session);
50
+ engine.recalculateAll();
51
+ return { items: session.items.map((item) => ({
52
+ id: item.id,
53
+ alias: item.alias,
54
+ value: engine.getCstValue(item.id),
55
+ status: engine.getCstStatus(item.id)
56
+ })) };
57
+ }
58
+ createEngine(session) {
59
+ const schema = buildRSFormFromSession(session);
60
+ const model = buildRSModelFromSession(session);
61
+ const engine = new RSEngine(SESSION_MODEL_ID, createInMemoryServices(session));
62
+ engine.loadData(schema, model);
63
+ return engine;
64
+ }
65
+ validateSetInput(session, input) {
66
+ const cst = session.items.find((item) => item.id === input.target);
67
+ if (!cst) throw new Error(`Unknown constituent: ${input.target}`);
68
+ const frontendType = cst.cstType;
69
+ if (!isInterpretable(frontendType)) throw new Error(`Constituent ${cst.alias} is not interpretable`);
70
+ if (isInferrable(frontendType)) throw new Error(`Constituent ${cst.alias} is inferrable and cannot be set directly`);
71
+ if (isBaseSet(frontendType)) {
72
+ if (!validateBasicBindingData(input.value)) throw new Error(`Invalid basic binding for ${cst.alias}`);
73
+ return;
74
+ }
75
+ if (!validateValueData(input.value)) throw new Error(`Invalid structured value for ${cst.alias}`);
76
+ }
114
77
  };
115
78
  function createInMemoryServices(session) {
116
- return {
117
- setCstValue: async ({ data }) => {
118
- for (const item of data) {
119
- const entry = {
120
- id: item.target,
121
- type: item.type,
122
- value: item.data
123
- };
124
- const index = session.model.items.findIndex((existing) => existing.id === item.target);
125
- if (index === -1) {
126
- session.model.items.push(entry);
127
- } else {
128
- session.model.items[index] = entry;
129
- }
130
- }
131
- },
132
- clearValues: async ({ data }) => {
133
- const ids = new Set(data.items);
134
- session.model.items = session.model.items.filter((item) => !ids.has(item.id));
135
- }
136
- };
79
+ return {
80
+ setCstValue: async ({ data }) => {
81
+ for (const item of data) {
82
+ const entry = {
83
+ id: item.target,
84
+ type: item.type,
85
+ value: item.data
86
+ };
87
+ const index = session.model.items.findIndex((existing) => existing.id === item.target);
88
+ if (index === -1) session.model.items.push(entry);
89
+ else session.model.items[index] = entry;
90
+ }
91
+ },
92
+ clearValues: async ({ data }) => {
93
+ const ids = new Set(data.items);
94
+ session.model.items = session.model.items.filter((item) => !ids.has(item.id));
95
+ }
96
+ };
137
97
  }
138
98
  function buildRSFormFromSession(session) {
139
- const graph = new Graph();
140
- const cstByAlias = /* @__PURE__ */ new Map();
141
- const cstByID = /* @__PURE__ */ new Map();
142
- const analyzer = new RSLangAnalyzer();
143
- const items = session.items.map((item) => {
144
- const cst = toFrontendConstituenta(item);
145
- cstByAlias.set(cst.alias, cst);
146
- cstByID.set(cst.id, cst);
147
- graph.addNode(cst.id);
148
- if (item.cstType === CstType.BASE) {
149
- analyzer.addBase(cst.alias);
150
- }
151
- if (cst.effectiveType) {
152
- analyzer.setGlobal(cst.alias, cst.effectiveType, cst.analysis.valueClass);
153
- }
154
- return cst;
155
- });
156
- for (const cst of items) {
157
- for (const alias of extractGlobals(cst.definition_formal)) {
158
- const source = cstByAlias.get(alias);
159
- if (source) {
160
- graph.addEdge(source.id, cst.id);
161
- }
162
- }
163
- }
164
- return {
165
- id: 0,
166
- items,
167
- cstByAlias,
168
- cstByID,
169
- graph,
170
- analyzer,
171
- inheritance: [],
172
- attribution: [],
173
- attribution_graph: graph.clone(),
174
- oss: [],
175
- models: [],
176
- editors: [],
177
- versions: [],
178
- is_produced: false,
179
- is_attributive: false,
180
- version: "latest"
181
- };
99
+ const graph = new Graph();
100
+ const cstByAlias = /* @__PURE__ */ new Map();
101
+ const cstByID = /* @__PURE__ */ new Map();
102
+ const analyzer = new RSLangAnalyzer();
103
+ const items = session.items.map((item) => {
104
+ const cst = toFrontendConstituenta(item);
105
+ cstByAlias.set(cst.alias, cst);
106
+ cstByID.set(cst.id, cst);
107
+ graph.addNode(cst.id);
108
+ if (item.cstType === CstType.BASE) analyzer.addBase(cst.alias);
109
+ if (cst.effectiveType) analyzer.setGlobal(cst.alias, cst.effectiveType, cst.analysis.valueClass);
110
+ return cst;
111
+ });
112
+ for (const cst of items) for (const alias of extractGlobals(cst.definition_formal)) {
113
+ const source = cstByAlias.get(alias);
114
+ if (source) graph.addEdge(source.id, cst.id);
115
+ }
116
+ return {
117
+ id: 0,
118
+ items,
119
+ cstByAlias,
120
+ cstByID,
121
+ graph,
122
+ analyzer,
123
+ inheritance: [],
124
+ attribution: [],
125
+ attribution_graph: graph.clone(),
126
+ oss: [],
127
+ models: [],
128
+ editors: [],
129
+ versions: [],
130
+ is_produced: false,
131
+ is_attributive: false,
132
+ version: "latest"
133
+ };
182
134
  }
183
135
  function buildRSModelFromSession(session) {
184
- return {
185
- id: SESSION_MODEL_ID,
186
- schema: 0,
187
- editors: [],
188
- items: session.model.items.map((item) => ({
189
- id: item.id,
190
- type: item.type,
191
- value: item.value
192
- }))
193
- };
136
+ return {
137
+ id: SESSION_MODEL_ID,
138
+ schema: 0,
139
+ editors: [],
140
+ items: session.model.items.map((item) => ({
141
+ id: item.id,
142
+ type: item.type,
143
+ value: item.value
144
+ }))
145
+ };
194
146
  }
195
147
  function toFrontendConstituenta(item) {
196
- const effectiveType = item.analysis.type ?? null;
197
- return {
198
- id: item.id,
199
- alias: item.alias,
200
- cst_type: item.cstType,
201
- definition_formal: item.definitionFormal,
202
- definition_raw: item.definitionFormal,
203
- definition_resolved: item.definitionFormal,
204
- term_raw: item.term,
205
- term_resolved: item.term,
206
- term_forms: [],
207
- convention: item.convention,
208
- typification_manual: "",
209
- value_is_property: false,
210
- crucial: false,
211
- attributes: [],
212
- homonyms: [],
213
- formalDuplicates: [],
214
- analysis: {
215
- success: item.analysis.success,
216
- type: effectiveType,
217
- valueClass: item.analysis.valueClass
218
- },
219
- effectiveType,
220
- is_type_mismatch: false,
221
- schema: 0,
222
- cst_class: "derived",
223
- status: item.analysis.success ? "verified" : "incorrect",
224
- is_template: false,
225
- is_simple_expression: true,
226
- parent_schema_index: 0,
227
- parent_schema: null,
228
- is_inherited: false,
229
- has_inherited_children: false,
230
- spawn: [],
231
- spawn_alias: []
232
- };
148
+ const effectiveType = item.analysis.type ?? null;
149
+ return {
150
+ id: item.id,
151
+ alias: item.alias,
152
+ cst_type: item.cstType,
153
+ definition_formal: item.definitionFormal,
154
+ definition_raw: item.definitionFormal,
155
+ definition_resolved: item.definitionFormal,
156
+ term_raw: item.term,
157
+ term_resolved: item.term,
158
+ term_forms: [],
159
+ convention: item.convention,
160
+ typification_manual: "",
161
+ value_is_property: false,
162
+ crucial: false,
163
+ attributes: [],
164
+ homonyms: [],
165
+ formalDuplicates: [],
166
+ analysis: {
167
+ success: item.analysis.success,
168
+ type: effectiveType,
169
+ valueClass: item.analysis.valueClass
170
+ },
171
+ effectiveType,
172
+ is_type_mismatch: false,
173
+ schema: 0,
174
+ cst_class: "derived",
175
+ status: item.analysis.success ? "verified" : "incorrect",
176
+ is_template: false,
177
+ is_simple_expression: true,
178
+ parent_schema_index: 0,
179
+ parent_schema: null,
180
+ is_inherited: false,
181
+ has_inherited_children: false,
182
+ spawn: [],
183
+ spawn_alias: []
184
+ };
233
185
  }
234
186
  function toPublicEvaluationResult(value, errors, iterations, cacheHits, status) {
235
- const diagnostics = errors.map(toPublicError);
236
- return {
237
- success: diagnostics.length === 0 && value !== null,
238
- value,
239
- status,
240
- iterations,
241
- cacheHits,
242
- diagnostics
243
- };
187
+ const diagnostics = errors.map(toPublicError);
188
+ return {
189
+ success: diagnostics.length === 0 && value !== null,
190
+ value,
191
+ status,
192
+ iterations,
193
+ cacheHits,
194
+ diagnostics
195
+ };
244
196
  }
245
- export {
246
- ModelAdapter
247
- };
197
+ //#endregion
198
+ export { ModelAdapter };
199
+
248
200
  //# sourceMappingURL=model-adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mappers/model-adapter.ts","../../src/mappers/types.ts"],"sourcesContent":["import { Graph } from '@rsconcept/domain/graph/graph';\nimport { extractGlobals } from '@rsconcept/domain/rslang/api';\nimport { type ExpressionType, RSLangAnalyzer, type Value, type ValueClass } from '@rsconcept/domain/rslang';\nimport { isBaseSet } from '@rsconcept/domain/library/rsform-api';\nimport { type Constituenta, CstType, type RSForm } from '@rsconcept/domain/library/rsform';\nimport { RSEngine, type RSEngineServices } from '@rsconcept/domain/library/rsengine';\nimport { type BasicBinding, EvalStatus, type RSModel } from '@rsconcept/domain/library/rsmodel';\nimport {\n isInferrable,\n isInterpretable,\n toBasicBinding,\n validateBasicBindingData,\n validateValueData\n} from '@rsconcept/domain/library/rsmodel-api';\n\nimport {\n type ConstituentaState,\n type EvaluationResult,\n type RecalculateModelResult,\n type SessionModelState,\n type SessionState,\n type SetConstituentaValueInput\n} from '../models';\nimport { toPublicError } from './types';\n\nconst SESSION_MODEL_ID = 0;\n\nexport class ModelAdapter {\n public async setConstituentaValue(\n session: SessionState,\n input: SetConstituentaValueInput\n ): Promise<SessionModelState> {\n this.validateSetInput(session, input);\n const engine = this.createEngine(session);\n const cst = session.items.find(item => item.id === input.target)!;\n const frontendType = cst.cstType;\n\n if (isBaseSet(frontendType)) {\n const binding = toBasicBinding(input.value as Record<string | number, string>);\n await engine.setBasicValue(input.target, binding);\n } else {\n await engine.setStructureValue(input.target, input.value as Value);\n }\n session.updatedAt = new Date().toISOString();\n return structuredClone(session.model);\n }\n\n public async setConstituentaValues(\n session: SessionState,\n input: { items: SetConstituentaValueInput[] }\n ): Promise<SessionModelState> {\n for (const item of input.items) {\n await this.setConstituentaValue(session, item);\n }\n return structuredClone(session.model);\n }\n\n public async clearConstituentaValues(session: SessionState, ids: number[]): Promise<SessionModelState> {\n const engine = this.createEngine(session);\n for (const id of ids) {\n await engine.resetValue(id);\n session.updatedAt = new Date().toISOString();\n }\n return structuredClone(session.model);\n }\n\n public evaluateExpression(session: SessionState, expression: string, cstType: CstType): EvaluationResult {\n const engine = this.createEngine(session);\n const result = engine.evaluateExpression(expression, cstType);\n const status =\n result.value === null\n ? result.errors.length > 0\n ? EvalStatus.EVAL_FAIL\n : EvalStatus.EMPTY\n : EvalStatus.HAS_DATA;\n return toPublicEvaluationResult(result.value, result.errors, result.iterations, result.cacheHits, status);\n }\n\n public evaluateConstituenta(session: SessionState, constituentId: number): EvaluationResult {\n const cst = session.items.find(item => item.id === constituentId);\n if (!cst) {\n throw new Error(`Unknown constituent: ${constituentId}`);\n }\n const engine = this.createEngine(session);\n const result = engine.calculateCst(constituentId);\n const status = engine.getCstStatus(constituentId);\n return toPublicEvaluationResult(result.value, result.errors, result.iterations, result.cacheHits, status);\n }\n\n public recalculateModel(session: SessionState): RecalculateModelResult {\n const engine = this.createEngine(session);\n engine.recalculateAll();\n const items = session.items.map(item => ({\n id: item.id,\n alias: item.alias,\n value: engine.getCstValue(item.id) as number | number[] | null,\n status: engine.getCstStatus(item.id)\n }));\n return { items };\n }\n\n public createEngine(session: SessionState): RSEngine {\n const schema = buildRSFormFromSession(session);\n const model = buildRSModelFromSession(session);\n const engine = new RSEngine(SESSION_MODEL_ID, createInMemoryServices(session));\n engine.loadData(schema, model);\n return engine;\n }\n\n private validateSetInput(session: SessionState, input: SetConstituentaValueInput): void {\n const cst = session.items.find(item => item.id === input.target);\n if (!cst) {\n throw new Error(`Unknown constituent: ${input.target}`);\n }\n const frontendType = cst.cstType;\n if (!isInterpretable(frontendType)) {\n throw new Error(`Constituent ${cst.alias} is not interpretable`);\n }\n if (isInferrable(frontendType)) {\n throw new Error(`Constituent ${cst.alias} is inferrable and cannot be set directly`);\n }\n if (isBaseSet(frontendType)) {\n if (!validateBasicBindingData(input.value)) {\n throw new Error(`Invalid basic binding for ${cst.alias}`);\n }\n return;\n }\n if (!validateValueData(input.value)) {\n throw new Error(`Invalid structured value for ${cst.alias}`);\n }\n }\n}\n\nfunction createInMemoryServices(session: SessionState): RSEngineServices {\n return {\n setCstValue: async ({ data }) => {\n for (const item of data) {\n const entry = {\n id: item.target,\n type: item.type,\n value: item.data as Value | BasicBinding\n };\n const index = session.model.items.findIndex(existing => existing.id === item.target);\n if (index === -1) {\n session.model.items.push(entry);\n } else {\n session.model.items[index] = entry;\n }\n }\n },\n clearValues: async ({ data }) => {\n const ids = new Set(data.items);\n session.model.items = session.model.items.filter(item => !ids.has(item.id));\n }\n };\n}\n\nfunction buildRSFormFromSession(session: SessionState): RSForm {\n const graph = new Graph<number>();\n const cstByAlias = new Map<string, Constituenta>();\n const cstByID = new Map<number, Constituenta>();\n const analyzer = new RSLangAnalyzer();\n\n const items = session.items.map(item => {\n const cst = toFrontendConstituenta(item);\n cstByAlias.set(cst.alias, cst);\n cstByID.set(cst.id, cst);\n graph.addNode(cst.id);\n if (item.cstType === CstType.BASE) {\n analyzer.addBase(cst.alias);\n }\n if (cst.effectiveType) {\n analyzer.setGlobal(cst.alias, cst.effectiveType, cst.analysis.valueClass as ValueClass | null);\n }\n return cst;\n });\n\n for (const cst of items) {\n for (const alias of extractGlobals(cst.definition_formal)) {\n const source = cstByAlias.get(alias);\n if (source) {\n graph.addEdge(source.id, cst.id);\n }\n }\n }\n\n return {\n id: 0,\n items,\n cstByAlias,\n cstByID,\n graph,\n analyzer,\n inheritance: [],\n attribution: [],\n attribution_graph: graph.clone(),\n oss: [],\n models: [],\n editors: [],\n versions: [],\n is_produced: false,\n is_attributive: false,\n version: 'latest'\n } as unknown as RSForm;\n}\n\nfunction buildRSModelFromSession(session: SessionState): RSModel {\n return {\n id: SESSION_MODEL_ID,\n schema: 0,\n editors: [],\n items: session.model.items.map(item => ({\n id: item.id,\n type: item.type,\n value: item.value as Value | BasicBinding\n }))\n } as unknown as RSModel;\n}\n\nfunction toFrontendConstituenta(item: ConstituentaState): Constituenta {\n const effectiveType = (item.analysis.type ?? null) as ExpressionType | null;\n return {\n id: item.id,\n alias: item.alias,\n cst_type: item.cstType,\n definition_formal: item.definitionFormal,\n definition_raw: item.definitionFormal,\n definition_resolved: item.definitionFormal,\n term_raw: item.term,\n term_resolved: item.term,\n term_forms: [],\n convention: item.convention,\n typification_manual: '',\n value_is_property: false,\n crucial: false,\n attributes: [],\n homonyms: [],\n formalDuplicates: [],\n analysis: {\n success: item.analysis.success,\n type: effectiveType,\n valueClass: item.analysis.valueClass\n },\n effectiveType,\n is_type_mismatch: false,\n schema: 0,\n cst_class: 'derived',\n status: item.analysis.success ? 'verified' : 'incorrect',\n is_template: false,\n is_simple_expression: true,\n parent_schema_index: 0,\n parent_schema: null,\n is_inherited: false,\n has_inherited_children: false,\n spawn: [],\n spawn_alias: []\n } as unknown as Constituenta;\n}\n\nfunction toPublicEvaluationResult(\n value: Value | null,\n errors: { code: number; from: number; to: number; params?: readonly string[] }[],\n iterations: number,\n cacheHits: number,\n status: EvalStatus\n): EvaluationResult {\n const diagnostics = errors.map(toPublicError);\n return {\n success: diagnostics.length === 0 && value !== null,\n value: value as EvaluationResult['value'],\n status,\n iterations,\n cacheHits,\n diagnostics\n };\n}\n","import { type ValueClass } from '@rsconcept/domain/rslang';\n\nimport { type AnalysisResult, type RSToolErrorDescription } from '../models';\n\nexport interface DomainErrorLike {\n code: number;\n from: number;\n to: number;\n params?: readonly string[];\n}\n\nexport interface DomainAnalysisLike {\n success: boolean;\n type: Record<string, unknown> | null;\n valueClass: ValueClass | null;\n errors: DomainErrorLike[];\n}\n\nexport function toPublicError(error: DomainErrorLike): RSToolErrorDescription {\n return {\n code: error.code,\n from: error.from,\n to: error.to,\n params: error.params\n };\n}\n\nexport function toPublicAnalysis(analysis: DomainAnalysisLike): AnalysisResult {\n return {\n success: analysis.success,\n type: analysis.type,\n valueClass: analysis.valueClass,\n diagnostics: analysis.errors.map(toPublicError)\n };\n}\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,sBAAsB;AAC/B,SAA8B,sBAAmD;AACjF,SAAS,iBAAiB;AAC1B,SAA4B,eAA4B;AACxD,SAAS,gBAAuC;AAChD,SAA4B,kBAAgC;AAC5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACKA,SAAS,cAAc,OAAgD;AAC5E,SAAO;AAAA,IACL,MAAM,MAAM;AAAA,IACZ,MAAM,MAAM;AAAA,IACZ,IAAI,MAAM;AAAA,IACV,QAAQ,MAAM;AAAA,EAChB;AACF;;;ADAA,IAAM,mBAAmB;AAElB,IAAM,eAAN,MAAmB;AAAA,EACxB,MAAa,qBACX,SACA,OAC4B;AAC5B,SAAK,iBAAiB,SAAS,KAAK;AACpC,UAAM,S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AAAA,IACpB,YAAY,CAAC;AAAA,IACb,YAAY,KAAK;AAAA,IACjB,qBAAqB;AAAA,IACrB,mBAAmB;AAAA,IACnB,SAAS;AAAA,IACT,YAAY,CAAC;AAAA,IACb,UAAU,CAAC;AAAA,IACX,kBAAkB,CAAC;AAAA,IACnB,UAAU;AAAA,MACR,SAAS,KAAK,SAAS;AAAA,MACvB,MAAM;AAAA,MACN,YAAY,KAAK,SAAS;AAAA,IAC5B;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,QAAQ,KAAK,SAAS,UAAU,aAAa;AAAA,IAC7C,aAAa;AAAA,IACb,sBAAsB;AAAA,IACtB,qBAAqB;AAAA,IACrB,eAAe;AAAA,IACf,cAAc;AAAA,IACd,wBAAwB;AAAA,IACxB,OAAO,CAAC;AAAA,IACR,aAAa,CAAC;AAAA,EAChB;AACF;AAEA,SAAS,yBACP,OACA,QACA,YACA,WACA,QACkB;AAClB,QAAM,cAAc,OAAO,IAAI,aAAa;AAC5C,SAAO;AAAA,IACL,SAAS,YAAY,WAAW,KAAK,UAAU;AAAA,IAC/C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"model-adapter.js","names":[],"sources":["../../src/mappers/model-adapter.ts"],"sourcesContent":["import { Graph } from '@rsconcept/domain/graph/graph';\nimport { extractGlobals } from '@rsconcept/domain/rslang/api';\nimport { type ExpressionType, RSLangAnalyzer, type Value, type ValueClass } from '@rsconcept/domain/rslang';\nimport { isBaseSet } from '@rsconcept/domain/library/rsform-api';\nimport { type Constituenta, CstType, type RSForm } from '@rsconcept/domain/library/rsform';\nimport { RSEngine, type RSEngineServices } from '@rsconcept/domain/library/rsengine';\nimport { type BasicBinding, EvalStatus, type RSModel } from '@rsconcept/domain/library/rsmodel';\nimport {\n isInferrable,\n isInterpretable,\n toBasicBinding,\n validateBasicBindingData,\n validateValueData\n} from '@rsconcept/domain/library/rsmodel-api';\n\nimport {\n type ConstituentaState,\n type EvaluationResult,\n type RecalculateModelResult,\n type SessionModelState,\n type SessionState,\n type SetConstituentaValueInput\n} from '../models';\nimport { toPublicError } from './types';\n\nconst SESSION_MODEL_ID = 0;\n\nexport class ModelAdapter {\n public async setConstituentaValue(\n session: SessionState,\n input: SetConstituentaValueInput\n ): Promise<SessionModelState> {\n this.validateSetInput(session, input);\n const engine = this.createEngine(session);\n const cst = session.items.find(item => item.id === input.target)!;\n const frontendType = cst.cstType;\n\n if (isBaseSet(frontendType)) {\n const binding = toBasicBinding(input.value as Record<string | number, string>);\n await engine.setBasicValue(input.target, binding);\n } else {\n await engine.setStructureValue(input.target, input.value as Value);\n }\n session.updatedAt = new Date().toISOString();\n return structuredClone(session.model);\n }\n\n public async setConstituentaValues(\n session: SessionState,\n input: { items: SetConstituentaValueInput[] }\n ): Promise<SessionModelState> {\n for (const item of input.items) {\n await this.setConstituentaValue(session, item);\n }\n return structuredClone(session.model);\n }\n\n public async clearConstituentaValues(session: SessionState, ids: number[]): Promise<SessionModelState> {\n const engine = this.createEngine(session);\n for (const id of ids) {\n await engine.resetValue(id);\n session.updatedAt = new Date().toISOString();\n }\n return structuredClone(session.model);\n }\n\n public evaluateExpression(session: SessionState, expression: string, cstType: CstType): EvaluationResult {\n const engine = this.createEngine(session);\n const result = engine.evaluateExpression(expression, cstType);\n const status =\n result.value === null\n ? result.errors.length > 0\n ? EvalStatus.EVAL_FAIL\n : EvalStatus.EMPTY\n : EvalStatus.HAS_DATA;\n return toPublicEvaluationResult(result.value, result.errors, result.iterations, result.cacheHits, status);\n }\n\n public evaluateConstituenta(session: SessionState, constituentId: number): EvaluationResult {\n const cst = session.items.find(item => item.id === constituentId);\n if (!cst) {\n throw new Error(`Unknown constituent: ${constituentId}`);\n }\n const engine = this.createEngine(session);\n const result = engine.calculateCst(constituentId);\n const status = engine.getCstStatus(constituentId);\n return toPublicEvaluationResult(result.value, result.errors, result.iterations, result.cacheHits, status);\n }\n\n public recalculateModel(session: SessionState): RecalculateModelResult {\n const engine = this.createEngine(session);\n engine.recalculateAll();\n const items = session.items.map(item => ({\n id: item.id,\n alias: item.alias,\n value: engine.getCstValue(item.id) as number | number[] | null,\n status: engine.getCstStatus(item.id)\n }));\n return { items };\n }\n\n public createEngine(session: SessionState): RSEngine {\n const schema = buildRSFormFromSession(session);\n const model = buildRSModelFromSession(session);\n const engine = new RSEngine(SESSION_MODEL_ID, createInMemoryServices(session));\n engine.loadData(schema, model);\n return engine;\n }\n\n private validateSetInput(session: SessionState, input: SetConstituentaValueInput): void {\n const cst = session.items.find(item => item.id === input.target);\n if (!cst) {\n throw new Error(`Unknown constituent: ${input.target}`);\n }\n const frontendType = cst.cstType;\n if (!isInterpretable(frontendType)) {\n throw new Error(`Constituent ${cst.alias} is not interpretable`);\n }\n if (isInferrable(frontendType)) {\n throw new Error(`Constituent ${cst.alias} is inferrable and cannot be set directly`);\n }\n if (isBaseSet(frontendType)) {\n if (!validateBasicBindingData(input.value)) {\n throw new Error(`Invalid basic binding for ${cst.alias}`);\n }\n return;\n }\n if (!validateValueData(input.value)) {\n throw new Error(`Invalid structured value for ${cst.alias}`);\n }\n }\n}\n\nfunction createInMemoryServices(session: SessionState): RSEngineServices {\n return {\n setCstValue: async ({ data }) => {\n for (const item of data) {\n const entry = {\n id: item.target,\n type: item.type,\n value: item.data as Value | BasicBinding\n };\n const index = session.model.items.findIndex(existing => existing.id === item.target);\n if (index === -1) {\n session.model.items.push(entry);\n } else {\n session.model.items[index] = entry;\n }\n }\n },\n clearValues: async ({ data }) => {\n const ids = new Set(data.items);\n session.model.items = session.model.items.filter(item => !ids.has(item.id));\n }\n };\n}\n\nfunction buildRSFormFromSession(session: SessionState): RSForm {\n const graph = new Graph<number>();\n const cstByAlias = new Map<string, Constituenta>();\n const cstByID = new Map<number, Constituenta>();\n const analyzer = new RSLangAnalyzer();\n\n const items = session.items.map(item => {\n const cst = toFrontendConstituenta(item);\n cstByAlias.set(cst.alias, cst);\n cstByID.set(cst.id, cst);\n graph.addNode(cst.id);\n if (item.cstType === CstType.BASE) {\n analyzer.addBase(cst.alias);\n }\n if (cst.effectiveType) {\n analyzer.setGlobal(cst.alias, cst.effectiveType, cst.analysis.valueClass as ValueClass | null);\n }\n return cst;\n });\n\n for (const cst of items) {\n for (const alias of extractGlobals(cst.definition_formal)) {\n const source = cstByAlias.get(alias);\n if (source) {\n graph.addEdge(source.id, cst.id);\n }\n }\n }\n\n return {\n id: 0,\n items,\n cstByAlias,\n cstByID,\n graph,\n analyzer,\n inheritance: [],\n attribution: [],\n attribution_graph: graph.clone(),\n oss: [],\n models: [],\n editors: [],\n versions: [],\n is_produced: false,\n is_attributive: false,\n version: 'latest'\n } as unknown as RSForm;\n}\n\nfunction buildRSModelFromSession(session: SessionState): RSModel {\n return {\n id: SESSION_MODEL_ID,\n schema: 0,\n editors: [],\n items: session.model.items.map(item => ({\n id: item.id,\n type: item.type,\n value: item.value as Value | BasicBinding\n }))\n } as unknown as RSModel;\n}\n\nfunction toFrontendConstituenta(item: ConstituentaState): Constituenta {\n const effectiveType = (item.analysis.type ?? null) as ExpressionType | null;\n return {\n id: item.id,\n alias: item.alias,\n cst_type: item.cstType,\n definition_formal: item.definitionFormal,\n definition_raw: item.definitionFormal,\n definition_resolved: item.definitionFormal,\n term_raw: item.term,\n term_resolved: item.term,\n term_forms: [],\n convention: item.convention,\n typification_manual: '',\n value_is_property: false,\n crucial: false,\n attributes: [],\n homonyms: [],\n formalDuplicates: [],\n analysis: {\n success: item.analysis.success,\n type: effectiveType,\n valueClass: item.analysis.valueClass\n },\n effectiveType,\n is_type_mismatch: false,\n schema: 0,\n cst_class: 'derived',\n status: item.analysis.success ? 'verified' : 'incorrect',\n is_template: false,\n is_simple_expression: true,\n parent_schema_index: 0,\n parent_schema: null,\n is_inherited: false,\n has_inherited_children: false,\n spawn: [],\n spawn_alias: []\n } as unknown as Constituenta;\n}\n\nfunction toPublicEvaluationResult(\n value: Value | null,\n errors: { code: number; from: number; to: number; params?: readonly string[] }[],\n iterations: number,\n cacheHits: number,\n status: EvalStatus\n): EvaluationResult {\n const diagnostics = errors.map(toPublicError);\n return {\n success: diagnostics.length === 0 && value !== null,\n value: value as EvaluationResult['value'],\n status,\n iterations,\n cacheHits,\n diagnostics\n };\n}\n"],"mappings":";;;;;;;;;;AAyBA,MAAM,mBAAmB;AAEzB,IAAa,eAAb,MAA0B;CACxB,MAAa,qBACX,SACA,OAC4B;EAC5B,KAAK,iBAAiB,SAAS,KAAK;EACpC,MAAM,SAAS,KAAK,aAAa,OAAO;EAExC,MAAM,eADM,QAAQ,MAAM,MAAK,SAAQ,KAAK,OAAO,MAAM,MACpC,EAAI;EAEzB,IAAI,UAAU,YAAY,GAAG;GAC3B,MAAM,UAAU,eAAe,MAAM,KAAwC;GAC7E,MAAM,OAAO,cAAc,MAAM,QAAQ,OAAO;EAClD,OACE,MAAM,OAAO,kBAAkB,MAAM,QAAQ,MAAM,KAAc;EAEnE,QAAQ,6BAAY,IAAI,KAAK,GAAE,YAAY;EAC3C,OAAO,gBAAgB,QAAQ,KAAK;CACtC;CAEA,MAAa,sBACX,SACA,OAC4B;EAC5B,KAAK,MAAM,QAAQ,MAAM,OACvB,MAAM,KAAK,qBAAqB,SAAS,IAAI;EAE/C,OAAO,gBAAgB,QAAQ,KAAK;CACtC;CAEA,MAAa,wBAAwB,SAAuB,KAA2C;EACrG,MAAM,SAAS,KAAK,aAAa,OAAO;EACxC,KAAK,MAAM,MAAM,KAAK;GACpB,MAAM,OAAO,WAAW,EAAE;GAC1B,QAAQ,6BAAY,IAAI,KAAK,GAAE,YAAY;EAC7C;EACA,OAAO,gBAAgB,QAAQ,KAAK;CACtC;CAEA,mBAA0B,SAAuB,YAAoB,SAAoC;EAEvG,MAAM,SADS,KAAK,aAAa,OAClB,EAAO,mBAAmB,YAAY,OAAO;EAC5D,MAAM,SACJ,OAAO,UAAU,OACb,OAAO,OAAO,SAAS,IACrB,WA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;EACR,aAAa,CAAC;CAChB;AACF;AAEA,SAAS,yBACP,OACA,QACA,YACA,WACA,QACkB;CAClB,MAAM,cAAc,OAAO,IAAI,aAAa;CAC5C,OAAO;EACL,SAAS,YAAY,WAAW,KAAK,UAAU;EACxC;EACP;EACA;EACA;EACA;CACF;AACF"}
@@ -1,22 +1,20 @@
1
- import { RSLangAnalyzer } from '@rsconcept/domain/rslang';
2
- import { RSForm } from '@rsconcept/domain/library/rsform';
3
- import { AnalysisResult } from '../models/analysis.js';
4
- import { ConstituentaDraft, ConstituentaState } from '../models/constituenta.js';
5
- import { DiagnosticRecord } from '../models/diagnostic.js';
6
- import { SessionState } from '../models/session.js';
7
- import '../models/common.js';
8
- import '@rsconcept/domain/library/rsmodel';
9
- import '@rsconcept/domain/rslang/error';
10
- import '../models/model-value.js';
1
+ import { t as AnalysisResult } from "../analysis-JiwOYDKx.js";
2
+ import { t as DiagnosticRecord } from "../diagnostic-BMYvciz8.js";
3
+ import { i as ConstituentaState, r as ConstituentaDraft } from "../constituenta-Dnd6iToB.js";
4
+ import { r as SessionState } from "../session-BHGCCLfQ.js";
5
+ import { RSForm } from "@rsconcept/domain/library/rsform";
6
+ import { RSLangAnalyzer } from "@rsconcept/domain/rslang";
11
7
 
8
+ //#region src/mappers/schema-adapter.d.ts
12
9
  declare class SchemaAdapter {
13
- analyzeAgainstSession(session: SessionState, draft: ConstituentaDraft): {
14
- result: AnalysisResult;
15
- diagnostics: DiagnosticRecord[];
16
- };
17
- mergeStateWithDraft(session: SessionState, draft: ConstituentaDraft, analysis: AnalysisResult): ConstituentaState;
18
- toPseudoRSFormState(session: SessionState, analyzer: RSLangAnalyzer): Pick<RSForm, 'items' | 'cstByAlias' | 'analyzer'>;
19
- private buildAnalyzer;
10
+ analyzeAgainstSession(session: SessionState, draft: ConstituentaDraft): {
11
+ result: AnalysisResult;
12
+ diagnostics: DiagnosticRecord[];
13
+ };
14
+ mergeStateWithDraft(session: SessionState, draft: ConstituentaDraft, analysis: AnalysisResult): ConstituentaState;
15
+ toPseudoRSFormState(session: SessionState, analyzer: RSLangAnalyzer): Pick<RSForm, 'items' | 'cstByAlias' | 'analyzer'>;
16
+ private buildAnalyzer;
20
17
  }
21
-
18
+ //#endregion
22
19
  export { SchemaAdapter };
20
+ //# sourceMappingURL=schema-adapter.d.ts.map