@rsconcept/rstool 1.2.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/{agent-workflow-Gk0Vfnv1.d.ts → agent-workflow-D22FeODL.d.ts} +6 -6
- package/dist/{analysis-LLnPhmGa.d.ts → analysis-DA44pfgA.d.ts} +4 -3
- package/dist/common-D6TFl6l_.d.ts +11 -0
- package/dist/{constituenta-DnGR6bnM.d.ts → constituenta-QY5w1x91.d.ts} +7 -7
- package/dist/diagnostic-C6TRoBgt.d.ts +38 -0
- package/dist/diagnostic-assembly-DRunIcKQ.js +54 -0
- package/dist/diagnostic-assembly-DRunIcKQ.js.map +1 -0
- package/dist/{evaluation-Cns8BFm4.d.ts → evaluation-Cd4S7-3t.d.ts} +4 -3
- package/dist/index.d.ts +12 -12
- package/dist/index.js +4 -3
- package/dist/mappers/model-adapter.d.ts +3 -3
- package/dist/mappers/model-adapter.js +1 -199
- package/dist/mappers/schema-adapter.d.ts +5 -5
- package/dist/mappers/schema-adapter.js +8 -8
- package/dist/mappers/schema-adapter.js.map +1 -1
- package/dist/mappers/types.d.ts +6 -6
- package/dist/mappers/types.js +6 -10
- package/dist/mappers/types.js.map +1 -1
- package/dist/model-adapter-D-YmIvQW.js +225 -0
- package/dist/model-adapter-D-YmIvQW.js.map +1 -0
- package/dist/{model-value-BbonPzMz.d.ts → model-value-BUhr2IjA.d.ts} +2 -2
- package/dist/models/agent-workflow.d.ts +1 -1
- package/dist/models/analysis.d.ts +1 -1
- package/dist/models/common.d.ts +2 -2
- package/dist/models/common.js +1 -1
- package/dist/models/constituenta.d.ts +1 -1
- package/dist/models/diagnostic.d.ts +2 -2
- package/dist/models/diagnostic.js +3 -1
- package/dist/models/evaluation.d.ts +1 -1
- package/dist/models/index.d.ts +11 -11
- package/dist/models/index.js +3 -2
- package/dist/models/model-value.d.ts +1 -1
- package/dist/models/rstool-agent.d.ts +1 -1
- package/dist/models/rstool-agent.js +1 -1
- package/dist/models/session.d.ts +1 -1
- package/dist/models/tool-contract.d.ts +1 -1
- package/dist/models/tool-contract.js +1 -1
- package/dist/models/tool-contract.js.map +1 -1
- package/dist/{models-9G6ur_pg.js → models-DTLctDmB.js} +72 -15
- package/dist/models-DTLctDmB.js.map +1 -0
- package/dist/{rstool-agent-D2cQze_b.d.ts → rstool-agent-BMVAyMAG.d.ts} +11 -10
- package/dist/session/session-store.d.ts +6 -6
- package/dist/session/session-store.js +1 -1
- package/dist/{session-ChexW8i7.d.ts → session-CI4rLYby.d.ts} +3 -3
- package/dist/{tool-contract-0uRGhEfW.d.ts → tool-contract-sQfr-DYD.d.ts} +12 -12
- package/dist/wrapper/stdio-wrapper.js +1 -1
- package/docs/BASE-SELECTION.md +92 -0
- package/docs/CONCEPTUAL-SCHEMA.md +20 -15
- package/docs/CONSTITUENTA.md +3 -3
- package/docs/DIAGNOSTICS.md +63 -20
- package/docs/DOMAIN.md +27 -21
- package/docs/README.md +1 -0
- package/docs/SYNTAX.md +3 -2
- package/docs/TYPIFICATION.md +3 -9
- package/examples/README.md +2 -0
- package/examples/agent-client.ts +15 -3
- package/examples/audit-diagnostics.ts +40 -0
- package/examples/chocolate-nim/build-rsform.ts +15 -0
- package/examples/chocolate-nim/build-rsmodel.ts +15 -22
- package/examples/chocolate-nim/model-demo.ts +11 -0
- package/examples/chocolate-nim/rsform-session.json +329 -310
- package/examples/chocolate-nim/rsmodel-session.json +311 -311
- package/examples/diagnostics-utils.ts +25 -0
- package/examples/expression-bank/bank-constituents.ts +10 -10
- package/examples/expression-bank/build-rsform.ts +8 -0
- package/examples/expression-bank/rsform-session.json +1501 -1501
- package/examples/kinship/build-rsform.ts +16 -1
- package/examples/kinship/build-rsmodel.ts +15 -56
- package/examples/kinship/model-demo.ts +35 -0
- package/examples/kinship/rsform-session.json +300 -215
- package/examples/kinship/rsmodel-session.json +216 -216
- package/examples/movd/build-rsform.ts +15 -0
- package/examples/movd/build-rsmodel.ts +15 -46
- package/examples/movd/model-demo.ts +31 -0
- package/examples/movd/rsform-session.json +359 -270
- package/examples/movd/rsmodel-session.json +263 -263
- package/examples/sample/build-rsform.ts +43 -3
- package/examples/sample/build-rsmodel.ts +26 -2
- package/examples/sample/rsform-session.json +41 -12
- package/examples/sample/rsmodel-session.json +37 -37
- package/examples/template-apply/build-rsform.ts +26 -9
- package/examples/template-apply/rsform-session.json +100 -45
- package/package.json +3 -2
- package/skills/rstool-helper/EXAMPLES.md +22 -1
- package/skills/rstool-helper/GUIDE.md +23 -28
- package/skills/rstool-helper/REFERENCE.md +28 -23
- package/src/index.ts +7 -4
- package/src/mappers/diagnostic-assembly.ts +96 -0
- package/src/mappers/diagnostics-collector.test.ts +63 -0
- package/src/mappers/diagnostics-collector.ts +73 -0
- package/src/mappers/model-adapter.ts +28 -99
- package/src/mappers/rsform-builder.ts +127 -0
- package/src/mappers/schema-adapter.ts +19 -15
- package/src/mappers/types.ts +12 -12
- package/src/models/agent-workflow.ts +2 -2
- package/src/models/analysis.ts +3 -2
- package/src/models/common.ts +0 -12
- package/src/models/constituenta.ts +4 -4
- package/src/models/diagnostic.ts +15 -10
- package/src/models/evaluation.ts +3 -8
- package/src/models/index.ts +8 -2
- package/src/models/rstool-agent.test.ts +66 -5
- package/src/models/rstool-agent.ts +22 -10
- package/src/models/tool-contract.ts +4 -4
- package/src/session/persistence.ts +2 -2
- package/src/session/session-store.ts +14 -7
- package/dist/common-DHJalS-Q.d.ts +0 -22
- package/dist/diagnostic-D9yl_mEL.d.ts +0 -19
- package/dist/mappers/model-adapter.js.map +0 -1
- package/dist/models-9G6ur_pg.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Agent-facing library for **incremental RSForm construction**, **RSLang expression analysis**, **diagnostics**, **modeling**, and **evaluation**. It wraps [`@rsconcept/domain`](https://www.npmjs.com/package/@rsconcept/domain) with a deterministic session contract and a stdio JSON wrapper for LLM agents. MCP hosts can use it through [`@rsconcept/rstool-mcp`](https://www.npmjs.com/package/@rsconcept/rstool-mcp).
|
|
4
4
|
|
|
5
|
-
**Contract version:** `
|
|
5
|
+
**Contract version:** `3.0.0` — see [skills/rstool-helper/REFERENCE.md](./skills/rstool-helper/REFERENCE.md) for the full v3 API.
|
|
6
6
|
|
|
7
7
|
## Agent skill
|
|
8
8
|
|
|
@@ -77,7 +77,7 @@ Maintainers: see [PUBLISHING.md](./PUBLISHING.md) for npm release steps.
|
|
|
77
77
|
- If a session method is called without an active session, rstool creates one lazily.
|
|
78
78
|
- On startup, a ready handshake is printed.
|
|
79
79
|
|
|
80
|
-
Supported methods (contract `
|
|
80
|
+
Supported methods (contract `3.0.0`):
|
|
81
81
|
|
|
82
82
|
- `ping`
|
|
83
83
|
- `methods`
|
|
@@ -111,7 +111,7 @@ Request:
|
|
|
111
111
|
Response:
|
|
112
112
|
|
|
113
113
|
```json
|
|
114
|
-
{ "id": "1", "ok": true, "result": { "sessionId": "...", "contractVersion": "
|
|
114
|
+
{ "id": "1", "ok": true, "result": { "sessionId": "...", "contractVersion": "3.0.0" } }
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
Example `applySchemaPatch`:
|
|
@@ -140,7 +140,7 @@ Response:
|
|
|
140
140
|
"ok": true,
|
|
141
141
|
"result": {
|
|
142
142
|
"success": true,
|
|
143
|
-
"session": { "sessionId": "...", "contractVersion": "
|
|
143
|
+
"session": { "sessionId": "...", "contractVersion": "3.0.0" },
|
|
144
144
|
"summary": { "itemCount": 3 }
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as ApplyConstituentsResult, i as ApplyConstituentsMode, o as ConstituentaDraft } from "./constituenta-
|
|
4
|
-
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-
|
|
1
|
+
import { a as Diagnostic } from "./diagnostic-C6TRoBgt.js";
|
|
2
|
+
import { n as CstType } from "./common-D6TFl6l_.js";
|
|
3
|
+
import { a as ApplyConstituentsResult, i as ApplyConstituentsMode, o as ConstituentaDraft } from "./constituenta-QY5w1x91.js";
|
|
4
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-CI4rLYby.js";
|
|
5
5
|
|
|
6
6
|
//#region src/models/agent-workflow.d.ts
|
|
7
7
|
/** Level of detail returned by {@link RSToolAgent.getSessionState}. */
|
|
@@ -50,7 +50,7 @@ interface SessionSummary {
|
|
|
50
50
|
modelItemCount: number;
|
|
51
51
|
diagnosticsCount: number;
|
|
52
52
|
items: SessionSummaryItem[];
|
|
53
|
-
diagnostics:
|
|
53
|
+
diagnostics: Diagnostic[];
|
|
54
54
|
lastRevision?: SessionRevision;
|
|
55
55
|
}
|
|
56
56
|
/** Result of {@link RSToolAgent.applySchemaPatch}. */
|
|
@@ -61,4 +61,4 @@ interface ApplySchemaPatchResult extends ApplyConstituentsResult {
|
|
|
61
61
|
}
|
|
62
62
|
//#endregion
|
|
63
63
|
export { SessionStateResult as a, SessionStateDetail as i, ApplySchemaPatchInput as n, SessionSummary as o, ApplySchemaPatchResult as r, SessionSummaryItem as s, AgentConstituentaPatch as t };
|
|
64
|
-
//# sourceMappingURL=agent-workflow-
|
|
64
|
+
//# sourceMappingURL=agent-workflow-D22FeODL.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as Diagnostic } from "./diagnostic-C6TRoBgt.js";
|
|
2
|
+
import { n as CstType, o as ValueClass } from "./common-D6TFl6l_.js";
|
|
2
3
|
|
|
3
4
|
//#region src/models/analysis.d.ts
|
|
4
5
|
/** Input for {@link RSToolAgent.analyzeExpression}. */
|
|
@@ -16,8 +17,8 @@ interface AnalysisResult {
|
|
|
16
17
|
/** Inferred RS type AST as a plain object, or `null` on failure. */
|
|
17
18
|
type: Record<string, unknown> | null;
|
|
18
19
|
valueClass: ValueClass | null;
|
|
19
|
-
diagnostics:
|
|
20
|
+
diagnostics: Diagnostic[];
|
|
20
21
|
}
|
|
21
22
|
//#endregion
|
|
22
23
|
export { AnalyzeExpressionInput as n, AnalysisResult as t };
|
|
23
|
-
//# sourceMappingURL=analysis-
|
|
24
|
+
//# sourceMappingURL=analysis-DA44pfgA.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RSErrorCode as RSErrorCode$1 } from "@rsconcept/domain/rslang/error";
|
|
2
|
+
import { CstType as CstType$1 } from "@rsconcept/domain/library/rsform";
|
|
3
|
+
import { BasicBinding, EvalStatus as EvalStatus$1 } from "@rsconcept/domain/library/rsmodel";
|
|
4
|
+
import { ValueClass as ValueClass$1 } from "@rsconcept/domain/rslang";
|
|
5
|
+
|
|
6
|
+
//#region src/models/common.d.ts
|
|
7
|
+
/** Runtime evaluation value: number, nested array (set/tuple), or boolean 0/1. */
|
|
8
|
+
type RSToolValue = number | RSToolValue[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { RSToolValue as a, RSErrorCode$1 as i, CstType$1 as n, ValueClass$1 as o, EvalStatus$1 as r, BasicBinding as t };
|
|
11
|
+
//# sourceMappingURL=common-D6TFl6l_.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
1
|
+
import { a as Diagnostic } from "./diagnostic-C6TRoBgt.js";
|
|
2
|
+
import { n as CstType } from "./common-D6TFl6l_.js";
|
|
3
|
+
import { t as AnalysisResult } from "./analysis-DA44pfgA.js";
|
|
4
4
|
|
|
5
5
|
//#region src/models/constituenta.d.ts
|
|
6
6
|
/** Constituent payload before analysis and merge into session state. */
|
|
@@ -31,7 +31,7 @@ interface AddOrUpdateConstituentaInput {
|
|
|
31
31
|
}
|
|
32
32
|
interface AddOrUpdateConstituentaResult {
|
|
33
33
|
state: ConstituentaState;
|
|
34
|
-
diagnostics:
|
|
34
|
+
diagnostics: Diagnostic[];
|
|
35
35
|
}
|
|
36
36
|
/** How a multi-draft apply handles partial failures. */
|
|
37
37
|
type ApplyConstituentsMode = 'atomic' | 'best_effort';
|
|
@@ -45,10 +45,10 @@ interface ApplyConstituentsResult {
|
|
|
45
45
|
applied: ConstituentaState[];
|
|
46
46
|
failed: Array<{
|
|
47
47
|
draft: ConstituentaDraft;
|
|
48
|
-
diagnostics:
|
|
48
|
+
diagnostics: Diagnostic[];
|
|
49
49
|
}>;
|
|
50
|
-
diagnostics:
|
|
50
|
+
diagnostics: Diagnostic[];
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
53
53
|
export { ApplyConstituentsResult as a, ApplyConstituentsMode as i, AddOrUpdateConstituentaResult as n, ConstituentaDraft as o, ApplyConstituentsInput as r, ConstituentaState as s, AddOrUpdateConstituentaInput as t };
|
|
54
|
-
//# sourceMappingURL=constituenta-
|
|
54
|
+
//# sourceMappingURL=constituenta-QY5w1x91.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Constituenta, CstDiagnostic, CstDiagnostic as CstDiagnostic$1, DiagnosticKind, DiagnosticKind as DiagnosticKind$1, RSDiagnosticCode, RSDiagnosticCode as RSDiagnosticCode$1 } from "@rsconcept/domain/library";
|
|
2
|
+
import { RSErrorDescription } from "@rsconcept/domain/rslang/error";
|
|
3
|
+
import { EvalStatus } from "@rsconcept/domain/library/rsmodel";
|
|
4
|
+
|
|
5
|
+
//#region src/mappers/diagnostic-assembly.d.ts
|
|
6
|
+
/** Severity of a {@link Diagnostic}. */
|
|
7
|
+
type DiagnosticSeverity = 'error' | 'warning';
|
|
8
|
+
/** Agent-facing diagnostic with redundant fields for autonomous repair. */
|
|
9
|
+
interface Diagnostic extends CstDiagnostic {
|
|
10
|
+
name: string;
|
|
11
|
+
severity: DiagnosticSeverity;
|
|
12
|
+
constituentId?: number;
|
|
13
|
+
alias?: string;
|
|
14
|
+
expression: string;
|
|
15
|
+
from: number;
|
|
16
|
+
to: number;
|
|
17
|
+
}
|
|
18
|
+
/** Context for attributing a {@link Diagnostic} to a constituent. */
|
|
19
|
+
interface DiagnosticTarget {
|
|
20
|
+
constituentId?: number;
|
|
21
|
+
alias?: string;
|
|
22
|
+
}
|
|
23
|
+
declare function getDiagnosticName(code: number): string;
|
|
24
|
+
declare function getDiagnosticSeverity(code: number): DiagnosticSeverity;
|
|
25
|
+
declare function expandCstDiagnostic(cst: Constituenta, diagnostic: CstDiagnostic): Diagnostic;
|
|
26
|
+
declare function expressionDiagnostic(error: RSErrorDescription, expression: string, target?: DiagnosticTarget): Diagnostic;
|
|
27
|
+
declare function modelStatusDiagnostic(status: EvalStatus, cst: Constituenta): Diagnostic | null;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/models/diagnostic.d.ts
|
|
30
|
+
/** Filters for {@link RSToolAgent.listDiagnostics}. */
|
|
31
|
+
interface ListDiagnosticsFilters {
|
|
32
|
+
constituentId?: number;
|
|
33
|
+
kind?: DiagnosticKind;
|
|
34
|
+
severity?: DiagnosticSeverity;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Diagnostic as a, expandCstDiagnostic as c, getDiagnosticSeverity as d, modelStatusDiagnostic as f, RSDiagnosticCode as i, expressionDiagnostic as l, DiagnosticKind as n, DiagnosticSeverity as o, ListDiagnosticsFilters as r, DiagnosticTarget as s, CstDiagnostic$1 as t, getDiagnosticName as u };
|
|
38
|
+
//# sourceMappingURL=diagnostic-C6TRoBgt.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DiagnosticKind, RSDiagnosticCode, modelStatusCstDiagnostic } from "@rsconcept/domain/library";
|
|
2
|
+
import { RSErrorCode, isCritical } from "@rsconcept/domain/rslang/error";
|
|
3
|
+
//#region src/mappers/diagnostic-assembly.ts
|
|
4
|
+
const DIAGNOSTIC_NAMES = new Map([...Object.entries(RSErrorCode).map(([name, code]) => [code, name]), ...Object.entries(RSDiagnosticCode).map(([name, code]) => [code, name])]);
|
|
5
|
+
function getDiagnosticName(code) {
|
|
6
|
+
return DIAGNOSTIC_NAMES.get(code) ?? `0x${code.toString(16).toUpperCase()}`;
|
|
7
|
+
}
|
|
8
|
+
function getDiagnosticSeverity(code) {
|
|
9
|
+
return isCritical(code) ? "error" : "warning";
|
|
10
|
+
}
|
|
11
|
+
function expandCstDiagnostic(cst, diagnostic) {
|
|
12
|
+
const expression = expressionForCstDiagnostic(cst, diagnostic);
|
|
13
|
+
return {
|
|
14
|
+
...diagnostic,
|
|
15
|
+
name: getDiagnosticName(diagnostic.code),
|
|
16
|
+
severity: getDiagnosticSeverity(diagnostic.code),
|
|
17
|
+
constituentId: cst.id,
|
|
18
|
+
alias: cst.alias,
|
|
19
|
+
expression,
|
|
20
|
+
from: 0,
|
|
21
|
+
to: diagnostic.kind === DiagnosticKind.MODEL ? 0 : Math.max(expression.length, 1)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function expressionDiagnostic(error, expression, target) {
|
|
25
|
+
return {
|
|
26
|
+
kind: DiagnosticKind.EXPRESSION,
|
|
27
|
+
code: error.code,
|
|
28
|
+
name: getDiagnosticName(error.code),
|
|
29
|
+
severity: getDiagnosticSeverity(error.code),
|
|
30
|
+
constituentId: target?.constituentId,
|
|
31
|
+
alias: target?.alias,
|
|
32
|
+
expression,
|
|
33
|
+
from: error.from,
|
|
34
|
+
to: error.to,
|
|
35
|
+
...error.params ? { params: error.params } : {}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function modelStatusDiagnostic(status, cst) {
|
|
39
|
+
const base = modelStatusCstDiagnostic(status, cst.cst_type);
|
|
40
|
+
return base ? expandCstDiagnostic(cst, base) : null;
|
|
41
|
+
}
|
|
42
|
+
function expressionForCstDiagnostic(cst, diagnostic) {
|
|
43
|
+
switch (diagnostic.code) {
|
|
44
|
+
case RSDiagnosticCode.schemaHomonym:
|
|
45
|
+
case RSDiagnosticCode.schemaMissingTerm: return cst.term_resolved;
|
|
46
|
+
case RSDiagnosticCode.schemaMissingConvention: return cst.convention;
|
|
47
|
+
case RSDiagnosticCode.schemaTypeMismatch: return cst.typification_manual;
|
|
48
|
+
default: return cst.definition_formal;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { getDiagnosticSeverity as a, getDiagnosticName as i, expandCstDiagnostic as n, modelStatusDiagnostic as o, expressionDiagnostic as r, DiagnosticKind as t };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=diagnostic-assembly-DRunIcKQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-assembly-DRunIcKQ.js","names":[],"sources":["../src/mappers/diagnostic-assembly.ts"],"sourcesContent":["import {\n type Constituenta,\n type CstDiagnostic,\n DiagnosticKind,\n modelStatusCstDiagnostic,\n RSDiagnosticCode\n} from '@rsconcept/domain/library';\nimport { EvalStatus } from '@rsconcept/domain/library/rsmodel';\nimport { isCritical, RSErrorCode, type RSErrorDescription } from '@rsconcept/domain/rslang/error';\n\nexport { DiagnosticKind, RSDiagnosticCode };\n\n/** Severity of a {@link Diagnostic}. */\nexport type DiagnosticSeverity = 'error' | 'warning';\n\n/** Agent-facing diagnostic with redundant fields for autonomous repair. */\nexport interface Diagnostic extends CstDiagnostic {\n name: string;\n severity: DiagnosticSeverity;\n constituentId?: number;\n alias?: string;\n expression: string;\n from: number;\n to: number;\n}\n\n/** Context for attributing a {@link Diagnostic} to a constituent. */\nexport interface DiagnosticTarget {\n constituentId?: number;\n alias?: string;\n}\n\nconst DIAGNOSTIC_NAMES: ReadonlyMap<number, string> = new Map([\n ...Object.entries(RSErrorCode).map(([name, code]) => [code, name] as const),\n ...Object.entries(RSDiagnosticCode).map(([name, code]) => [code, name] as const)\n]);\n\nexport function getDiagnosticName(code: number): string {\n return DIAGNOSTIC_NAMES.get(code) ?? `0x${code.toString(16).toUpperCase()}`;\n}\n\nexport function getDiagnosticSeverity(code: number): DiagnosticSeverity {\n return isCritical(code as RSErrorCode) ? 'error' : 'warning';\n}\n\nexport function expandCstDiagnostic(cst: Constituenta, diagnostic: CstDiagnostic): Diagnostic {\n const expression = expressionForCstDiagnostic(cst, diagnostic);\n return {\n ...diagnostic,\n name: getDiagnosticName(diagnostic.code),\n severity: getDiagnosticSeverity(diagnostic.code),\n constituentId: cst.id,\n alias: cst.alias,\n expression,\n from: 0,\n to: diagnostic.kind === DiagnosticKind.MODEL ? 0 : Math.max(expression.length, 1)\n };\n}\n\nexport function expressionDiagnostic(\n error: RSErrorDescription,\n expression: string,\n target?: DiagnosticTarget\n): Diagnostic {\n return {\n kind: DiagnosticKind.EXPRESSION,\n code: error.code,\n name: getDiagnosticName(error.code),\n severity: getDiagnosticSeverity(error.code),\n constituentId: target?.constituentId,\n alias: target?.alias,\n expression,\n from: error.from,\n to: error.to,\n ...(error.params ? { params: error.params } : {})\n };\n}\n\nexport function modelStatusDiagnostic(status: EvalStatus, cst: Constituenta): Diagnostic | null {\n const base = modelStatusCstDiagnostic(status, cst.cst_type);\n return base ? expandCstDiagnostic(cst, base) : null;\n}\n\nfunction expressionForCstDiagnostic(cst: Constituenta, diagnostic: CstDiagnostic): string {\n switch (diagnostic.code) {\n case RSDiagnosticCode.schemaHomonym:\n case RSDiagnosticCode.schemaMissingTerm:\n return cst.term_resolved;\n case RSDiagnosticCode.schemaMissingConvention:\n return cst.convention;\n case RSDiagnosticCode.schemaTypeMismatch:\n return cst.typification_manual;\n default:\n return cst.definition_formal;\n }\n}\n"],"mappings":";;;AAgCA,MAAM,mBAAgD,IAAI,IAAI,CAC5D,GAAG,OAAO,QAAQ,WAAW,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,IAAI,CAAU,GAC1E,GAAG,OAAO,QAAQ,gBAAgB,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,IAAI,CAAU,CACjF,CAAC;AAED,SAAgB,kBAAkB,MAAsB;CACtD,OAAO,iBAAiB,IAAI,IAAI,KAAK,KAAK,KAAK,SAAS,EAAE,CAAC,CAAC,YAAY;AAC1E;AAEA,SAAgB,sBAAsB,MAAkC;CACtE,OAAO,WAAW,IAAmB,IAAI,UAAU;AACrD;AAEA,SAAgB,oBAAoB,KAAmB,YAAuC;CAC5F,MAAM,aAAa,2BAA2B,KAAK,UAAU;CAC7D,OAAO;EACL,GAAG;EACH,MAAM,kBAAkB,WAAW,IAAI;EACvC,UAAU,sBAAsB,WAAW,IAAI;EAC/C,eAAe,IAAI;EACnB,OAAO,IAAI;EACX;EACA,MAAM;EACN,IAAI,WAAW,SAAS,eAAe,QAAQ,IAAI,KAAK,IAAI,WAAW,QAAQ,CAAC;CAClF;AACF;AAEA,SAAgB,qBACd,OACA,YACA,QACY;CACZ,OAAO;EACL,MAAM,eAAe;EACrB,MAAM,MAAM;EACZ,MAAM,kBAAkB,MAAM,IAAI;EAClC,UAAU,sBAAsB,MAAM,IAAI;EAC1C,eAAe,QAAQ;EACvB,OAAO,QAAQ;EACf;EACA,MAAM,MAAM;EACZ,IAAI,MAAM;EACV,GAAI,MAAM,SAAS,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;CACjD;AACF;AAEA,SAAgB,sBAAsB,QAAoB,KAAsC;CAC9F,MAAM,OAAO,yBAAyB,QAAQ,IAAI,QAAQ;CAC1D,OAAO,OAAO,oBAAoB,KAAK,IAAI,IAAI;AACjD;AAEA,SAAS,2BAA2B,KAAmB,YAAmC;CACxF,QAAQ,WAAW,MAAnB;EACE,KAAK,iBAAiB;EACtB,KAAK,iBAAiB,mBACpB,OAAO,IAAI;EACb,KAAK,iBAAiB,yBACpB,OAAO,IAAI;EACb,KAAK,iBAAiB,oBACpB,OAAO,IAAI;EACb,SACE,OAAO,IAAI;CACf;AACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as Diagnostic } from "./diagnostic-C6TRoBgt.js";
|
|
2
|
+
import { a as RSToolValue, n as CstType, r as EvalStatus, t as BasicBinding } from "./common-D6TFl6l_.js";
|
|
2
3
|
|
|
3
4
|
//#region src/models/evaluation.d.ts
|
|
4
5
|
interface EvaluateExpressionInput {
|
|
@@ -24,8 +25,8 @@ interface EvaluationResult {
|
|
|
24
25
|
status: EvalStatus;
|
|
25
26
|
iterations: number;
|
|
26
27
|
cacheHits: number;
|
|
27
|
-
diagnostics:
|
|
28
|
+
diagnostics: Diagnostic[];
|
|
28
29
|
}
|
|
29
30
|
//#endregion
|
|
30
31
|
export { EvaluationResult as i, EvaluateExpressionInput as n, EvaluateInput as r, EvaluateConstituentaInput as t };
|
|
31
|
-
//# sourceMappingURL=evaluation-
|
|
32
|
+
//# sourceMappingURL=evaluation-Cd4S7-3t.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { n as
|
|
3
|
-
import { n as
|
|
4
|
-
import { o as ConstituentaDraft, s as ConstituentaState } from "./constituenta-
|
|
5
|
-
import { a as SetConstituentaValueInput, i as SessionModelState, n as ModelValueState, r as RecalculateModelResult, s as SetModelValuesInput } from "./model-value-
|
|
6
|
-
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-
|
|
7
|
-
import { a as SessionStateResult, i as SessionStateDetail, n as ApplySchemaPatchInput, o as SessionSummary, r as ApplySchemaPatchResult, s as SessionSummaryItem, t as AgentConstituentaPatch } from "./agent-workflow-
|
|
8
|
-
import { i as EvaluationResult, r as EvaluateInput } from "./evaluation-
|
|
9
|
-
import { a as ExportPortalInput, c as PortalExportKind, d as PortalModelImportData, f as PortalRsformDetails, h as PortalTermForm, i as ExportFormat, l as PORTAL_JSON_CONTRACT_VERSION, m as PortalSchemaImportData, n as RSToolAgentContract, o as ExportPortalResult, p as PortalSchemaConstituenta, r as RSToolAgentOptions, s as ImportDataKind, t as CONTRACT_VERSION, u as PortalImportMetadata } from "./tool-contract-
|
|
10
|
-
import { t as RSToolAgent } from "./rstool-agent-
|
|
11
|
-
import { DomainAnalysisLike, DomainErrorLike,
|
|
1
|
+
import { a as Diagnostic, i as RSDiagnosticCode, n as DiagnosticKind, o as DiagnosticSeverity, r as ListDiagnosticsFilters, t as CstDiagnostic } from "./diagnostic-C6TRoBgt.js";
|
|
2
|
+
import { a as RSToolValue, i as RSErrorCode, n as CstType, o as ValueClass, r as EvalStatus, t as BasicBinding } from "./common-D6TFl6l_.js";
|
|
3
|
+
import { n as AnalyzeExpressionInput, t as AnalysisResult } from "./analysis-DA44pfgA.js";
|
|
4
|
+
import { o as ConstituentaDraft, s as ConstituentaState } from "./constituenta-QY5w1x91.js";
|
|
5
|
+
import { a as SetConstituentaValueInput, i as SessionModelState, n as ModelValueState, r as RecalculateModelResult, s as SetModelValuesInput } from "./model-value-BUhr2IjA.js";
|
|
6
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-CI4rLYby.js";
|
|
7
|
+
import { a as SessionStateResult, i as SessionStateDetail, n as ApplySchemaPatchInput, o as SessionSummary, r as ApplySchemaPatchResult, s as SessionSummaryItem, t as AgentConstituentaPatch } from "./agent-workflow-D22FeODL.js";
|
|
8
|
+
import { i as EvaluationResult, r as EvaluateInput } from "./evaluation-Cd4S7-3t.js";
|
|
9
|
+
import { a as ExportPortalInput, c as PortalExportKind, d as PortalModelImportData, f as PortalRsformDetails, h as PortalTermForm, i as ExportFormat, l as PORTAL_JSON_CONTRACT_VERSION, m as PortalSchemaImportData, n as RSToolAgentContract, o as ExportPortalResult, p as PortalSchemaConstituenta, r as RSToolAgentOptions, s as ImportDataKind, t as CONTRACT_VERSION, u as PortalImportMetadata } from "./tool-contract-sQfr-DYD.js";
|
|
10
|
+
import { t as RSToolAgent } from "./rstool-agent-BMVAyMAG.js";
|
|
11
|
+
import { DomainAnalysisLike, DomainErrorLike, toDiagnostic, toPublicAnalysis } from "./mappers/types.js";
|
|
12
12
|
import { RSToolWrapperClient, RSToolWrapperClientOptions, WrapperResponse } from "./wrapper/client.js";
|
|
13
|
-
export { type AgentConstituentaPatch, type AnalysisResult, type AnalyzeExpressionInput, type ApplySchemaPatchInput, type ApplySchemaPatchResult, type BasicBinding, CONTRACT_VERSION, type ConstituentaDraft, type ConstituentaState, CstType, type
|
|
13
|
+
export { type AgentConstituentaPatch, type AnalysisResult, type AnalyzeExpressionInput, type ApplySchemaPatchInput, type ApplySchemaPatchResult, type BasicBinding, CONTRACT_VERSION, type ConstituentaDraft, type ConstituentaState, type CstDiagnostic, CstType, type Diagnostic, DiagnosticKind, type DiagnosticSeverity, type DomainAnalysisLike, type DomainErrorLike, EvalStatus, type EvaluateInput, type EvaluationResult, type ExportFormat, type ExportPortalInput, type ExportPortalResult, type ImportDataKind, type ListDiagnosticsFilters, type ModelValueState, PORTAL_JSON_CONTRACT_VERSION, type PortalExportKind, type PortalImportMetadata, type PortalModelImportData, type PortalRsformDetails, type PortalSchemaConstituenta, type PortalSchemaImportData, type PortalTermForm, RSDiagnosticCode, RSErrorCode, RSToolAgent, type RSToolAgentContract, type RSToolAgentOptions, type RSToolValue, RSToolWrapperClient, type RSToolWrapperClientOptions, type RecalculateModelResult, type SessionHandle, type SessionModelState, type SessionRevision, type SessionState, type SessionStateDetail, type SessionStateResult, type SessionSummary, type SessionSummaryItem, type SetConstituentaValueInput, type SetModelValuesInput, ValueClass, type WrapperResponse, toDiagnostic, toPublicAnalysis };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toDiagnostic, toPublicAnalysis } from "./mappers/types.js";
|
|
2
2
|
import { CstType, EvalStatus, RSErrorCode, ValueClass } from "./models/common.js";
|
|
3
|
-
import {
|
|
3
|
+
import { DiagnosticKind, RSDiagnosticCode } from "./models/diagnostic.js";
|
|
4
|
+
import { r as PORTAL_JSON_CONTRACT_VERSION, t as RSToolAgent } from "./models-DTLctDmB.js";
|
|
4
5
|
import { CONTRACT_VERSION } from "./models/tool-contract.js";
|
|
5
6
|
import { RSToolWrapperClient } from "./wrapper/client.js";
|
|
6
|
-
export { CONTRACT_VERSION, CstType, EvalStatus, PORTAL_JSON_CONTRACT_VERSION, RSErrorCode, RSToolAgent, RSToolWrapperClient, ValueClass,
|
|
7
|
+
export { CONTRACT_VERSION, CstType, DiagnosticKind, EvalStatus, PORTAL_JSON_CONTRACT_VERSION, RSDiagnosticCode, RSErrorCode, RSToolAgent, RSToolWrapperClient, ValueClass, toDiagnostic, toPublicAnalysis };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as SetConstituentaValueInput, i as SessionModelState, r as RecalculateModelResult } from "../model-value-
|
|
2
|
-
import { r as SessionState } from "../session-
|
|
3
|
-
import { i as EvaluationResult } from "../evaluation-
|
|
1
|
+
import { a as SetConstituentaValueInput, i as SessionModelState, r as RecalculateModelResult } from "../model-value-BUhr2IjA.js";
|
|
2
|
+
import { r as SessionState } from "../session-CI4rLYby.js";
|
|
3
|
+
import { i as EvaluationResult } from "../evaluation-Cd4S7-3t.js";
|
|
4
4
|
import { CstType } from "@rsconcept/domain/library/rsform";
|
|
5
5
|
import { RSEngine } from "@rsconcept/domain/library/rsengine";
|
|
6
6
|
|
|
@@ -1,200 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CstType } from "@rsconcept/domain/library/rsform";
|
|
3
|
-
import { EvalStatus } from "@rsconcept/domain/library/rsmodel";
|
|
4
|
-
import { RSLangAnalyzer } from "@rsconcept/domain/rslang";
|
|
5
|
-
import { Graph } from "@rsconcept/domain/graph/graph";
|
|
6
|
-
import { extractGlobals } from "@rsconcept/domain/rslang/api";
|
|
7
|
-
import { isBaseSet } from "@rsconcept/domain/library/rsform-api";
|
|
8
|
-
import { RSEngine } from "@rsconcept/domain/library/rsengine";
|
|
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;
|
|
12
|
-
var ModelAdapter = class {
|
|
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
|
-
}
|
|
77
|
-
};
|
|
78
|
-
function createInMemoryServices(session) {
|
|
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
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function buildRSFormFromSession(session) {
|
|
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
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function buildRSModelFromSession(session) {
|
|
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
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function toFrontendConstituenta(item) {
|
|
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
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function toPublicEvaluationResult(value, errors, iterations, cacheHits, status) {
|
|
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
|
-
};
|
|
196
|
-
}
|
|
197
|
-
//#endregion
|
|
1
|
+
import { t as ModelAdapter } from "../model-adapter-D-YmIvQW.js";
|
|
198
2
|
export { ModelAdapter };
|
|
199
|
-
|
|
200
|
-
//# sourceMappingURL=model-adapter.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { o as ConstituentaDraft, s as ConstituentaState } from "../constituenta-
|
|
4
|
-
import { r as SessionState } from "../session-
|
|
1
|
+
import { a as Diagnostic } from "../diagnostic-C6TRoBgt.js";
|
|
2
|
+
import { t as AnalysisResult } from "../analysis-DA44pfgA.js";
|
|
3
|
+
import { o as ConstituentaDraft, s as ConstituentaState } from "../constituenta-QY5w1x91.js";
|
|
4
|
+
import { r as SessionState } from "../session-CI4rLYby.js";
|
|
5
5
|
import { RSForm } from "@rsconcept/domain/library/rsform";
|
|
6
6
|
import { RSLangAnalyzer } from "@rsconcept/domain/rslang";
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ import { RSLangAnalyzer } from "@rsconcept/domain/rslang";
|
|
|
9
9
|
declare class SchemaAdapter {
|
|
10
10
|
analyzeAgainstSession(session: SessionState, draft: ConstituentaDraft): {
|
|
11
11
|
result: AnalysisResult;
|
|
12
|
-
diagnostics:
|
|
12
|
+
diagnostics: Diagnostic[];
|
|
13
13
|
};
|
|
14
14
|
mergeStateWithDraft(session: SessionState, draft: ConstituentaDraft, analysis: AnalysisResult): ConstituentaState;
|
|
15
15
|
toPseudoRSFormState(session: SessionState, analyzer: RSLangAnalyzer): Pick<RSForm, 'items' | 'cstByAlias' | 'analyzer'>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as expressionDiagnostic } from "../diagnostic-assembly-DRunIcKQ.js";
|
|
2
|
+
import { toPublicAnalysis } from "./types.js";
|
|
2
3
|
import { CstType } from "@rsconcept/domain/library/rsform";
|
|
3
4
|
import { RSLangAnalyzer } from "@rsconcept/domain/rslang";
|
|
4
5
|
import { getAnalysisFor } from "@rsconcept/domain/library/rsform-api";
|
|
@@ -8,19 +9,18 @@ var SchemaAdapter = class {
|
|
|
8
9
|
const analyzer = this.buildAnalyzer(session);
|
|
9
10
|
const schema = this.toPseudoRSFormState(session, analyzer);
|
|
10
11
|
const analysis = getAnalysisFor(draft.definitionFormal, draft.cstType, schema, draft.alias);
|
|
12
|
+
const target = {
|
|
13
|
+
constituentId: draft.id,
|
|
14
|
+
alias: draft.alias
|
|
15
|
+
};
|
|
11
16
|
return {
|
|
12
17
|
result: toPublicAnalysis({
|
|
13
18
|
success: analysis.success,
|
|
14
19
|
type: analysis.type,
|
|
15
20
|
valueClass: analysis.valueClass,
|
|
16
21
|
errors: analysis.errors
|
|
17
|
-
}),
|
|
18
|
-
diagnostics: analysis.errors.map((error) => (
|
|
19
|
-
sessionId: session.sessionId,
|
|
20
|
-
constituentId: draft.id,
|
|
21
|
-
expression: draft.definitionFormal,
|
|
22
|
-
error: toPublicError(error)
|
|
23
|
-
}))
|
|
22
|
+
}, draft.definitionFormal, target),
|
|
23
|
+
diagnostics: analysis.errors.map((error) => expressionDiagnostic(error, draft.definitionFormal, target))
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
mergeStateWithDraft(session, draft, analysis) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-adapter.js","names":[],"sources":["../../src/mappers/schema-adapter.ts"],"sourcesContent":["import { RSLangAnalyzer, type AnalysisFull, type ValueClass } from '@rsconcept/domain/rslang';\nimport { getAnalysisFor } from '@rsconcept/domain/library/rsform-api';\nimport { CstType, type RSForm } from '@rsconcept/domain/library/rsform';\n\nimport {\n type AnalysisResult,\n type ConstituentaDraft,\n type ConstituentaState,\n type
|
|
1
|
+
{"version":3,"file":"schema-adapter.js","names":[],"sources":["../../src/mappers/schema-adapter.ts"],"sourcesContent":["import { expressionDiagnostic } from './diagnostic-assembly';\nimport { RSLangAnalyzer, type AnalysisFull, type ValueClass } from '@rsconcept/domain/rslang';\nimport { type RSErrorDescription } from '@rsconcept/domain/rslang/error';\nimport { getAnalysisFor } from '@rsconcept/domain/library/rsform-api';\nimport { CstType, type RSForm } from '@rsconcept/domain/library/rsform';\n\nimport {\n type AnalysisResult,\n type ConstituentaDraft,\n type ConstituentaState,\n type Diagnostic,\n type SessionState\n} from '../models';\nimport { toPublicAnalysis } from './types';\n\nexport class SchemaAdapter {\n public analyzeAgainstSession(\n session: SessionState,\n draft: ConstituentaDraft\n ): { result: AnalysisResult; diagnostics: Diagnostic[] } {\n const analyzer = this.buildAnalyzer(session);\n const schema = this.toPseudoRSFormState(session, analyzer);\n const analysis = getAnalysisFor(draft.definitionFormal, draft.cstType, schema as unknown as RSForm, draft.alias);\n const target = { constituentId: draft.id, alias: draft.alias };\n const result = toPublicAnalysis(\n {\n success: analysis.success,\n type: analysis.type as Record<string, unknown> | null,\n valueClass: analysis.valueClass,\n errors: analysis.errors\n },\n draft.definitionFormal,\n target\n );\n return {\n result,\n diagnostics: analysis.errors.map(error =>\n expressionDiagnostic(error as RSErrorDescription, draft.definitionFormal, target)\n )\n };\n }\n\n public mergeStateWithDraft(\n session: SessionState,\n draft: ConstituentaDraft,\n analysis: AnalysisResult\n ): ConstituentaState {\n const state: ConstituentaState = {\n ...draft,\n term: draft.term ?? '',\n definitionText: draft.definitionText ?? '',\n convention: draft.convention ?? '',\n analysis\n };\n const index = session.items.findIndex(item => item.id === draft.id);\n if (index === -1) {\n session.items.push(state);\n } else {\n session.items[index] = state;\n }\n session.updatedAt = new Date().toISOString();\n return state;\n }\n\n public toPseudoRSFormState(\n session: SessionState,\n analyzer: RSLangAnalyzer\n ): Pick<RSForm, 'items' | 'cstByAlias' | 'analyzer'> {\n const cstByAlias = new Map(session.items.map(item => [item.alias, item]));\n return {\n items: session.items as unknown as RSForm['items'],\n cstByAlias: cstByAlias as unknown as RSForm['cstByAlias'],\n analyzer\n };\n }\n\n private buildAnalyzer(session: SessionState): RSLangAnalyzer {\n const analyzer = new RSLangAnalyzer();\n for (const item of session.items) {\n if (item.cstType === CstType.BASE) {\n analyzer.addBase(item.alias);\n }\n analyzer.setGlobal(\n item.alias,\n item.analysis.type as AnalysisFull['type'],\n item.analysis.valueClass as ValueClass | null\n );\n }\n return analyzer;\n }\n}\n"],"mappings":";;;;;;AAeA,IAAa,gBAAb,MAA2B;CACzB,sBACE,SACA,OACuD;EACvD,MAAM,WAAW,KAAK,cAAc,OAAO;EAC3C,MAAM,SAAS,KAAK,oBAAoB,SAAS,QAAQ;EACzD,MAAM,WAAW,eAAe,MAAM,kBAAkB,MAAM,SAAS,QAA6B,MAAM,KAAK;EAC/G,MAAM,SAAS;GAAE,eAAe,MAAM;GAAI,OAAO,MAAM;EAAM;EAW7D,OAAO;GACL,QAXa,iBACb;IACE,SAAS,SAAS;IAClB,MAAM,SAAS;IACf,YAAY,SAAS;IACrB,QAAQ,SAAS;GACnB,GACA,MAAM,kBACN,MAGA;GACA,aAAa,SAAS,OAAO,KAAI,UAC/B,qBAAqB,OAA6B,MAAM,kBAAkB,MAAM,CAClF;EACF;CACF;CAEA,oBACE,SACA,OACA,UACmB;EACnB,MAAM,QAA2B;GAC/B,GAAG;GACH,MAAM,MAAM,QAAQ;GACpB,gBAAgB,MAAM,kBAAkB;GACxC,YAAY,MAAM,cAAc;GAChC;EACF;EACA,MAAM,QAAQ,QAAQ,MAAM,WAAU,SAAQ,KAAK,OAAO,MAAM,EAAE;EAClE,IAAI,UAAU,IACZ,QAAQ,MAAM,KAAK,KAAK;OAExB,QAAQ,MAAM,SAAS;EAEzB,QAAQ,6BAAY,IAAI,KAAK,EAAC,CAAC,YAAY;EAC3C,OAAO;CACT;CAEA,oBACE,SACA,UACmD;EACnD,MAAM,aAAa,IAAI,IAAI,QAAQ,MAAM,KAAI,SAAQ,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC;EACxE,OAAO;GACL,OAAO,QAAQ;GACH;GACZ;EACF;CACF;CAEA,cAAsB,SAAuC;EAC3D,MAAM,WAAW,IAAI,eAAe;EACpC,KAAK,MAAM,QAAQ,QAAQ,OAAO;GAChC,IAAI,KAAK,YAAY,QAAQ,MAC3B,SAAS,QAAQ,KAAK,KAAK;GAE7B,SAAS,UACP,KAAK,OACL,KAAK,SAAS,MACd,KAAK,SAAS,UAChB;EACF;EACA,OAAO;CACT;AACF"}
|
package/dist/mappers/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as AnalysisResult } from "../analysis-
|
|
1
|
+
import { a as Diagnostic, s as DiagnosticTarget } from "../diagnostic-C6TRoBgt.js";
|
|
2
|
+
import { t as AnalysisResult } from "../analysis-DA44pfgA.js";
|
|
3
3
|
import { ValueClass } from "@rsconcept/domain/rslang";
|
|
4
4
|
|
|
5
5
|
//#region src/mappers/types.d.ts
|
|
6
|
-
/** Minimal domain error shape before mapping to {@link
|
|
6
|
+
/** Minimal domain error shape before mapping to {@link Diagnostic}. */
|
|
7
7
|
interface DomainErrorLike {
|
|
8
8
|
code: number;
|
|
9
9
|
from: number;
|
|
@@ -18,9 +18,9 @@ interface DomainAnalysisLike {
|
|
|
18
18
|
errors: DomainErrorLike[];
|
|
19
19
|
}
|
|
20
20
|
/** Map a domain parser/semantic error to the public diagnostic shape. */
|
|
21
|
-
declare function
|
|
21
|
+
declare function toDiagnostic(error: DomainErrorLike, expression: string, target?: DiagnosticTarget): Diagnostic;
|
|
22
22
|
/** Map a domain analysis result to the public {@link AnalysisResult} shape. */
|
|
23
|
-
declare function toPublicAnalysis(analysis: DomainAnalysisLike): AnalysisResult;
|
|
23
|
+
declare function toPublicAnalysis(analysis: DomainAnalysisLike, expression: string, target?: DiagnosticTarget): AnalysisResult;
|
|
24
24
|
//#endregion
|
|
25
|
-
export { DomainAnalysisLike, DomainErrorLike,
|
|
25
|
+
export { DomainAnalysisLike, DomainErrorLike, toDiagnostic, toPublicAnalysis };
|
|
26
26
|
//# sourceMappingURL=types.d.ts.map
|