@rsconcept/domain 2.1.2 → 2.3.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/dist/api-Bf0f_uiI.d.ts +57 -0
- package/dist/diagnostics-CljEzVBV.js +1245 -0
- package/dist/diagnostics-CljEzVBV.js.map +1 -0
- package/dist/{diagnostics-EaIt3zIw.d.ts → diagnostics-Dac5sJhO.d.ts} +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/library/diagnostics.d.ts +1 -1
- package/dist/library/diagnostics.js +1 -1
- package/dist/library/index.d.ts +2 -2
- package/dist/library/index.js +1 -1
- package/dist/library/oss-api.d.ts +1 -1
- package/dist/library/oss-api.js +4 -4
- package/dist/library/oss-api.js.map +1 -1
- package/dist/library/rsengine.d.ts +1 -1
- package/dist/library/rsengine.js +2 -2
- package/dist/library/rsform-api/index.d.ts +299 -0
- package/dist/library/rsform-api/index.js +2 -0
- package/dist/library/rsform.d.ts +2 -2
- package/dist/library/rsform.js.map +1 -1
- package/dist/library/rsmodel-api.d.ts +1 -1
- package/dist/library/rsmodel-api.js +4 -2
- package/dist/library/rsmodel-api.js.map +1 -1
- package/dist/library/rsmodel.d.ts +1 -1
- package/dist/library/structure-planner.d.ts +1 -1
- package/dist/library/structure-planner.js +2 -2
- package/dist/rslang/api.d.ts +2 -58
- package/dist/rslang/api.js +1 -1
- package/dist/rslang/index.js +1 -1
- package/dist/rslang/parser/syntax-errors/index.js +1 -1
- package/dist/rslang/semantic/analyzer.js +2 -2
- package/dist/{syntax-errors-DwPXhpVe.js → syntax-errors-BN_bqTaX.js} +2 -2
- package/dist/{syntax-errors-DwPXhpVe.js.map → syntax-errors-BN_bqTaX.js.map} +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/library/index.ts +1 -0
- package/src/library/oss-api.ts +5 -2
- package/src/library/rsform-api/alias.ts +160 -0
- package/src/library/rsform-api/analysis.ts +157 -0
- package/src/library/rsform-api/attribution.ts +87 -0
- package/src/library/rsform-api/cst-type.ts +216 -0
- package/src/library/rsform-api/expression.ts +73 -0
- package/src/library/rsform-api/formal-graph.test.ts +72 -0
- package/src/library/rsform-api/formal-graph.ts +195 -0
- package/src/library/rsform-api/index.ts +53 -0
- package/src/library/rsform-api/semantic-relations.ts +117 -0
- package/src/library/rsform-api/stats.ts +170 -0
- package/src/library/rsform-api/structure.ts +93 -0
- package/src/library/rsform-api/substitution.ts +82 -0
- package/src/library/rsform-api/synthesis.test.ts +126 -0
- package/src/library/rsform-api/synthesis.ts +166 -0
- package/src/library/rsform-api/text-resolution.test.ts +86 -0
- package/src/library/rsform-api/text-resolution.ts +152 -0
- package/src/library/rsform-api/transforms.test.ts +161 -0
- package/src/library/rsform-api/transforms.ts +42 -0
- package/src/library/rsform-api/types.ts +38 -0
- package/src/library/rsform.ts +3 -3
- package/src/library/rsmodel-api.ts +7 -1
- package/dist/diagnostics-CY9sKggB.js +0 -658
- package/dist/diagnostics-CY9sKggB.js.map +0 -1
- package/dist/library/rsform-api.d.ts +0 -103
- package/dist/library/rsform-api.js +0 -2
- package/src/library/rsform-api.ts +0 -755
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure constituenta list transforms: reorder, move, insert position.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** Rebuild an item list following {@link orderedIds}. Throws if an id is missing. */
|
|
6
|
+
export function reorderItemsByIds<T extends { id: number }>(items: readonly T[], orderedIds: readonly number[]): T[] {
|
|
7
|
+
const byId = new Map(items.map(item => [item.id, item]));
|
|
8
|
+
return orderedIds.map(id => {
|
|
9
|
+
const item = byId.get(id);
|
|
10
|
+
if (!item) {
|
|
11
|
+
throw new Error(`reorderItemsByIds: missing id ${id}`);
|
|
12
|
+
}
|
|
13
|
+
return item;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Move a subset of ids within an ordered id list.
|
|
19
|
+
* {@link moveTo} is clamped to `[0, rest.length]` (index among non-moving items).
|
|
20
|
+
*/
|
|
21
|
+
export function moveIdsInOrder(ids: readonly number[], moving: readonly number[], moveTo: number): number[] {
|
|
22
|
+
const movingSet = new Set(moving);
|
|
23
|
+
const rest = ids.filter(id => !movingSet.has(id));
|
|
24
|
+
const movingItems = ids.filter(id => movingSet.has(id));
|
|
25
|
+
const clamped = Math.max(0, Math.min(moveTo, rest.length));
|
|
26
|
+
return [...rest.slice(0, clamped), ...movingItems, ...rest.slice(clamped)];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Insert {@link item} after {@link insertAfter}, or append when null/undefined/missing. Mutates {@link items}. */
|
|
30
|
+
export function insertItemAfter<T extends { id: number }>(
|
|
31
|
+
items: T[],
|
|
32
|
+
item: T,
|
|
33
|
+
insertAfter: number | null | undefined
|
|
34
|
+
): void {
|
|
35
|
+
if (insertAfter === null || insertAfter === undefined) {
|
|
36
|
+
items.push(item);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const idx = items.findIndex(row => row.id === insertAfter);
|
|
40
|
+
const insertAt = idx === -1 ? items.length : idx + 1;
|
|
41
|
+
items.splice(insertAt, 0, item);
|
|
42
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal constituenta shapes for schema transforms.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { type CstType, type TermForm } from '../rsform';
|
|
6
|
+
|
|
7
|
+
/** Minimal constituent fields required to restore order. */
|
|
8
|
+
export interface OrderableConstituenta {
|
|
9
|
+
id: number;
|
|
10
|
+
alias: string;
|
|
11
|
+
cst_type: CstType;
|
|
12
|
+
definition_formal: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Semantic parent/children derived from formal definitions (backend SemanticInfo). */
|
|
16
|
+
export interface SemanticRelations {
|
|
17
|
+
/** Parent id for each constituenta (self when none). */
|
|
18
|
+
parentOf: Map<number, number>;
|
|
19
|
+
/** Semantic children ids for each constituenta. */
|
|
20
|
+
childrenOf: Map<number, number[]>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Constituent fields needed to resolve term/definition entity references. */
|
|
24
|
+
export interface ResolvableConstituenta {
|
|
25
|
+
id: number;
|
|
26
|
+
alias: string;
|
|
27
|
+
term_raw: string;
|
|
28
|
+
term_resolved: string;
|
|
29
|
+
term_forms: TermForm[];
|
|
30
|
+
definition_raw: string;
|
|
31
|
+
definition_resolved: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Constituent fields needed to allocate or reset aliases by type. */
|
|
35
|
+
export interface AliasTypedConstituenta {
|
|
36
|
+
alias: string;
|
|
37
|
+
cst_type: CstType;
|
|
38
|
+
}
|
package/src/library/rsform.ts
CHANGED
|
@@ -68,7 +68,7 @@ export interface Substitution {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/** Represents word form for natural language. */
|
|
71
|
-
interface TermForm {
|
|
71
|
+
export interface TermForm {
|
|
72
72
|
text: string;
|
|
73
73
|
tags: string;
|
|
74
74
|
}
|
|
@@ -159,8 +159,8 @@ export interface RSFormStats {
|
|
|
159
159
|
count_homonyms: number;
|
|
160
160
|
/** Constituents that have same formal definition and term. */
|
|
161
161
|
count_formal_duplicates: number;
|
|
162
|
-
/**
|
|
163
|
-
|
|
162
|
+
/** Non-logical basic constituents missing convention and/or resolved term. */
|
|
163
|
+
count_missing_basic_text: number;
|
|
164
164
|
/** Constituents with non-empty manual typification that disagrees with inferred typification. */
|
|
165
165
|
count_type_mismatch: number;
|
|
166
166
|
|
|
@@ -292,11 +292,17 @@ export function deleteValueElement(
|
|
|
292
292
|
type: Typification,
|
|
293
293
|
target: number
|
|
294
294
|
): Value | null {
|
|
295
|
+
if (value === null) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
295
298
|
if (path.length === 0 && type.typeID !== TypeID.collection) {
|
|
296
299
|
return null;
|
|
297
300
|
}
|
|
298
301
|
|
|
299
|
-
const arrayValue = extractValue(value
|
|
302
|
+
const arrayValue = extractValue(value, path);
|
|
303
|
+
if (!Array.isArray(arrayValue)) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
300
306
|
const updatedArray = [...arrayValue.slice(0, target), ...arrayValue.slice(target + 1)];
|
|
301
307
|
return setNestedValue(value, path, updatedArray);
|
|
302
308
|
}
|