@rsconcept/domain 2.3.0 → 3.0.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/{diagnostics-Dac5sJhO.d.ts → diagnostics-DsEhmFh0.d.ts} +5 -3
- package/dist/{diagnostics-CljEzVBV.js → diagnostics-ndGYbvgh.js} +21 -11
- package/dist/diagnostics-ndGYbvgh.js.map +1 -0
- package/dist/index-DpiTybDB.d.ts +376 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/library/diagnostics.d.ts +1 -1
- package/dist/library/diagnostics.js +1 -1
- package/dist/library/index.d.ts +5 -4
- package/dist/library/index.js +1 -1
- package/dist/library/index.js.map +1 -1
- package/dist/library/oss-api.d.ts +1 -1
- package/dist/library/oss-api.js.map +1 -1
- package/dist/library/rsengine.d.ts +1 -1
- package/dist/library/rsengine.js +1 -1
- package/dist/library/rsform-api/index.d.ts +2 -299
- package/dist/library/rsform-api/index.js +1 -1
- package/dist/library/rsform.d.ts +1 -1
- package/dist/library/rsmodel-api.d.ts +9 -4
- package/dist/library/rsmodel-api.js +6 -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 +1 -1
- package/dist/library/structure-planner.js.map +1 -1
- package/package.json +1 -1
- package/src/library/diagnostics.ts +20 -9
- package/src/library/oss-api.ts +5 -1
- package/src/library/rsform-api/alias.ts +8 -8
- package/src/library/rsform-api/cst-type.ts +7 -5
- package/src/library/rsform-api/expression.ts +3 -3
- package/src/library/rsform-api/formal-graph.test.ts +2 -2
- package/src/library/rsform-api/formal-graph.ts +6 -10
- package/src/library/rsform-api/index.ts +18 -3
- package/src/library/rsform-api/semantic-relations.ts +4 -7
- package/src/library/rsform-api/stats.ts +6 -5
- package/src/library/rsform-api/structure.ts +12 -6
- package/src/library/rsform-api/substitution.ts +2 -2
- package/src/library/rsform-api/synthesis.test.ts +33 -2
- package/src/library/rsform-api/synthesis.ts +16 -12
- package/src/library/rsform-api/text-resolution.test.ts +2 -4
- package/src/library/rsform-api/text-resolution.ts +8 -8
- package/src/library/rsform-api/types.ts +89 -8
- package/src/library/rsmodel-api.ts +10 -5
- package/src/library/structure-planner.ts +6 -2
- package/src/library/template-instantiation.ts +11 -9
- package/dist/diagnostics-CljEzVBV.js.map +0 -1
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { t as Graph } from "./graph-CL73WdW1.js";
|
|
2
|
+
import { t as AstNode } from "./ast-C8sIpKdL.js";
|
|
3
|
+
import { f as ExpressionType, g as TypeClass, y as TypePath } from "./typification-9lNu9R4k.js";
|
|
4
|
+
import { t as ValueClass } from "./value-class-CNI-lqXJ.js";
|
|
5
|
+
import { r as AnalysisFull } from "./analyzer-fNhkwO-6.js";
|
|
6
|
+
import { r as LibraryItem } from "./library-CYun28Xz.js";
|
|
7
|
+
import { C as RSFormStats, S as RSForm, T as TermForm, _ as Attribution, b as CstStatus, g as ArgumentValue, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "./diagnostics-DsEhmFh0.js";
|
|
8
|
+
import { t as AliasMapping } from "./api-Bf0f_uiI.js";
|
|
9
|
+
|
|
10
|
+
//#region src/library/rsform-api/types.d.ts
|
|
11
|
+
/** Fields needed to restore formal dependency order. */
|
|
12
|
+
interface FormalOrderFields {
|
|
13
|
+
id: number;
|
|
14
|
+
alias: string;
|
|
15
|
+
cst_type: CstType;
|
|
16
|
+
definition_formal: string;
|
|
17
|
+
}
|
|
18
|
+
/** Semantic parent/children derived from formal definitions (backend SemanticInfo). */
|
|
19
|
+
interface SemanticRelations {
|
|
20
|
+
/** Parent id for each constituenta (self when none). */
|
|
21
|
+
parentOf: Map<number, number>;
|
|
22
|
+
/** Semantic children ids for each constituenta. */
|
|
23
|
+
childrenOf: Map<number, number[]>;
|
|
24
|
+
}
|
|
25
|
+
/** Fields needed to resolve term/definition entity references. */
|
|
26
|
+
interface TextResolvableFields {
|
|
27
|
+
id: number;
|
|
28
|
+
alias: string;
|
|
29
|
+
term_raw: string;
|
|
30
|
+
term_resolved: string;
|
|
31
|
+
term_forms: TermForm[];
|
|
32
|
+
definition_raw: string;
|
|
33
|
+
definition_resolved: string;
|
|
34
|
+
}
|
|
35
|
+
/** Fields needed to allocate or reset aliases by type. */
|
|
36
|
+
interface AliasTypedFields {
|
|
37
|
+
alias: string;
|
|
38
|
+
cst_type: CstType;
|
|
39
|
+
}
|
|
40
|
+
/** Fields needed to decide whether structure can be produced. */
|
|
41
|
+
interface StructureCapableFields {
|
|
42
|
+
cst_type: CstType;
|
|
43
|
+
effectiveType: ExpressionType | null;
|
|
44
|
+
}
|
|
45
|
+
/** Fields needed for schema-issue checks (status + diagnostics). */
|
|
46
|
+
interface SchemaIssueFields {
|
|
47
|
+
status: CstStatus;
|
|
48
|
+
diagnostics?: readonly {
|
|
49
|
+
code: number;
|
|
50
|
+
}[] | null;
|
|
51
|
+
}
|
|
52
|
+
/** Fields needed to look up evaluation status for a model item. */
|
|
53
|
+
interface ModelEvalFields {
|
|
54
|
+
id: number;
|
|
55
|
+
cst_type: CstType;
|
|
56
|
+
}
|
|
57
|
+
/** Fields needed to check missing convention / resolved term on basics. */
|
|
58
|
+
interface BasicTextCheckFields {
|
|
59
|
+
cst_type: CstType;
|
|
60
|
+
convention: string;
|
|
61
|
+
term_resolved: string;
|
|
62
|
+
}
|
|
63
|
+
/** Fields needed to walk spawn paths for structure helpers. */
|
|
64
|
+
interface SpawnPathFields {
|
|
65
|
+
id: number;
|
|
66
|
+
spawner?: number;
|
|
67
|
+
spawner_path?: TypePath;
|
|
68
|
+
}
|
|
69
|
+
/** Fields needed to extract template parameters from a bank item. */
|
|
70
|
+
interface TemplateParamSourceFields {
|
|
71
|
+
definition_formal: string;
|
|
72
|
+
effectiveType: ExpressionType | null;
|
|
73
|
+
}
|
|
74
|
+
/** Fields copied from a template bank item when instantiating. */
|
|
75
|
+
interface TemplateSourceFields extends TemplateParamSourceFields {
|
|
76
|
+
alias: string;
|
|
77
|
+
cst_type: CstType;
|
|
78
|
+
crucial: boolean;
|
|
79
|
+
convention: string;
|
|
80
|
+
definition_raw: string;
|
|
81
|
+
term_raw: string;
|
|
82
|
+
term_forms: TermForm[];
|
|
83
|
+
typification_manual: string;
|
|
84
|
+
value_is_property: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** Fields needed to expand schema/model diagnostics into expressions. */
|
|
87
|
+
interface DiagnosticSourceFields {
|
|
88
|
+
id: number;
|
|
89
|
+
alias: string;
|
|
90
|
+
cst_type: CstType;
|
|
91
|
+
term_resolved: string;
|
|
92
|
+
convention: string;
|
|
93
|
+
typification_manual: string;
|
|
94
|
+
definition_formal: string;
|
|
95
|
+
}
|
|
96
|
+
/** Fields needed for text search over constituenta content. */
|
|
97
|
+
interface SearchableFields {
|
|
98
|
+
alias: string;
|
|
99
|
+
cst_type: CstType;
|
|
100
|
+
term_raw: string;
|
|
101
|
+
term_resolved: string;
|
|
102
|
+
definition_formal: string;
|
|
103
|
+
definition_raw: string;
|
|
104
|
+
definition_resolved: string;
|
|
105
|
+
convention: string;
|
|
106
|
+
}
|
|
107
|
+
/** Fields needed to build short UI descriptions / labels. */
|
|
108
|
+
type DescribableFields = SearchableFields;
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/library/rsform-api/alias.d.ts
|
|
111
|
+
/** Fields updated in place by alias mapping. */
|
|
112
|
+
interface MappableFields {
|
|
113
|
+
alias: string;
|
|
114
|
+
definition_formal: string;
|
|
115
|
+
typification_manual: string;
|
|
116
|
+
term_raw: string;
|
|
117
|
+
definition_raw: string;
|
|
118
|
+
}
|
|
119
|
+
/** Build alias mapping from template argument bindings. */
|
|
120
|
+
declare function argumentValuesToMapping(args: ArgumentValue[]): AliasMapping;
|
|
121
|
+
/** Validate alias format for a given {@link CstType} (prefix + digits, min length 2). */
|
|
122
|
+
declare function validateAliasFormat(alias: string, type: CstType): boolean;
|
|
123
|
+
/** Validate new alias against {@link CstType} and {@link RSForm}. */
|
|
124
|
+
declare function validateNewAlias(alias: string, type: CstType, schema: RSForm): boolean;
|
|
125
|
+
/** Generate alias for new {@link Constituenta} of a given {@link CstType} for current {@link RSForm}. */
|
|
126
|
+
declare function generateAlias(type: CstType, schema: RSForm, takenAliases?: string[]): string;
|
|
127
|
+
/**
|
|
128
|
+
* Remap formal expressions and terminological entity references in constituent fields.
|
|
129
|
+
* Mutates each element of `items` in place; pass owned or cloned data only.
|
|
130
|
+
*/
|
|
131
|
+
declare function applyMappingToConstituents<T extends MappableFields>(items: T[], mapping: AliasMapping, changeAliases: boolean): void;
|
|
132
|
+
/** Highest numeric alias suffix for {@link type} among {@link items} (0 when none). */
|
|
133
|
+
declare function maxAliasIndex(items: readonly AliasTypedFields[], type: CstType): number;
|
|
134
|
+
/**
|
|
135
|
+
* Build alias → new-alias mapping that renumbers each type sequentially in list order.
|
|
136
|
+
* Matches backend {@code RSFormCached.reset_aliases}.
|
|
137
|
+
*/
|
|
138
|
+
declare function buildSequentialAliasMapping(items: readonly AliasTypedFields[]): AliasMapping;
|
|
139
|
+
/**
|
|
140
|
+
* Allocate fresh aliases for {@link source} constituents being imported into a non-empty receiver.
|
|
141
|
+
* Returns an empty mapping when the receiver has no items (aliases kept as-is).
|
|
142
|
+
*/
|
|
143
|
+
declare function allocateImportAliases(receiver: readonly AliasTypedFields[], source: readonly AliasTypedFields[]): AliasMapping;
|
|
144
|
+
/** Remove alias from expression. */
|
|
145
|
+
declare function removeAliasReference(expression: string, alias: string): string;
|
|
146
|
+
/** Add alias to expression. */
|
|
147
|
+
declare function addAliasReference(expression: string, alias: string): string;
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/library/rsform-api/analysis.d.ts
|
|
150
|
+
declare function getAnalysisFor(expression: string, cstType: CstType, schema: RSForm, alias?: string): AnalysisFull;
|
|
151
|
+
/**
|
|
152
|
+
* When an untyped / bare F·P reference names a constituent on a definition cycle with the
|
|
153
|
+
* current expression, replace that error with {@link RSDiagnosticCode.schemaDependencyCycle}.
|
|
154
|
+
*
|
|
155
|
+
* Covers both semantic `globalNotTyped` (e.g. `F3[σ]`) and parser `globalFuncWithoutArgs`
|
|
156
|
+
* (bare `P1` / `F1` treated as a call without arguments).
|
|
157
|
+
*
|
|
158
|
+
* Uses a draft dependency graph: incoming edges of the edited constituent are taken from
|
|
159
|
+
* `expression`, so Check works before Save.
|
|
160
|
+
*/
|
|
161
|
+
declare function refineAnalysisForDependencyCycles(analysis: AnalysisFull, expression: string, schema: RSForm, alias?: string): AnalysisFull;
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/library/rsform-api/attribution.d.ts
|
|
164
|
+
/**
|
|
165
|
+
* Remap attributions when constituents are substituted (original → replacement).
|
|
166
|
+
* Drops self-loops and duplicates. Matches sandbox / backend substitute attribution rewrite.
|
|
167
|
+
*/
|
|
168
|
+
declare function remapAttributionsUnderSubstitution(attributions: readonly Attribution[], origToSub: ReadonlyMap<number, number>): Attribution[];
|
|
169
|
+
/**
|
|
170
|
+
* Copy attributions whose both endpoints are in {@link sourceIdSet}, remapping ids via {@link idMap}.
|
|
171
|
+
* Appends onto a clone of {@link existing} with dedupe. Used by schema embedding / insert.
|
|
172
|
+
*/
|
|
173
|
+
declare function importAttributions(sourceAttributions: readonly Attribution[], sourceIdSet: ReadonlySet<number>, idMap: Readonly<Record<number, number>>, existing?: readonly Attribution[]): Attribution[];
|
|
174
|
+
/** Drop attributions that reference any id in {@link deletedIds}. */
|
|
175
|
+
declare function filterAttributions(attributions: readonly Attribution[], deletedIds: ReadonlySet<number>): Attribution[];
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/library/rsform-api/cst-type.d.ts
|
|
178
|
+
/** Prefix for alias indicating {@link CstType}. */
|
|
179
|
+
declare function getCstTypePrefix(type: CstType): string;
|
|
180
|
+
/** Guess {@link CstType} from user input hint. */
|
|
181
|
+
declare function guessCstType(hint: string): CstType | null;
|
|
182
|
+
/** Infers the {@link CstClass} based on the provided {@link CstType} and template status. */
|
|
183
|
+
declare function inferClass(type: CstType, isTemplate?: boolean): CstClass;
|
|
184
|
+
/** Check if item type is a template or a category. */
|
|
185
|
+
declare function isTemplateCst(cst: {
|
|
186
|
+
cst_type: CstType;
|
|
187
|
+
}): boolean;
|
|
188
|
+
/** Evaluate if {@link CstType} is basic concept. */
|
|
189
|
+
declare function isBasicConcept(type: CstType): boolean;
|
|
190
|
+
/** Evaluate if {@link CstType} is base set or constant set. */
|
|
191
|
+
declare function isBaseSet(type: CstType): boolean;
|
|
192
|
+
/** Evaluate if {@link CstType} is a function. */
|
|
193
|
+
declare function isFunctional(type: CstType): boolean;
|
|
194
|
+
/** Evaluate if {@link CstType} is logical. */
|
|
195
|
+
declare function isLogical(type: CstType): boolean;
|
|
196
|
+
/** Evaluate if {@link CstType} can have manual typification. */
|
|
197
|
+
declare function canHaveManualTypification(type: CstType): boolean;
|
|
198
|
+
/** Checks whether a constituenta type supports formal definitions. */
|
|
199
|
+
declare function canHaveFormalDefinition(cstType: CstType): boolean;
|
|
200
|
+
/** Returns expected {@link TypeClass} of formal definition for {@link CstType}. */
|
|
201
|
+
declare function typeClassForCstType(cstType: CstType): TypeClass;
|
|
202
|
+
/** Evaluate if an item can be used to produce structure. */
|
|
203
|
+
declare function canProduceStructure(cst: StructureCapableFields): boolean;
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/library/rsform-api/expression.d.ts
|
|
206
|
+
/** Infers the status of an expression based on parsing and value information. */
|
|
207
|
+
declare function inferStatus(parse: boolean, value?: ValueClass | null): CstStatus;
|
|
208
|
+
/** Infers type of constituent for a given template and arguments. */
|
|
209
|
+
declare function inferTemplatedType(templateType: CstType, args: ArgumentValue[]): CstType;
|
|
210
|
+
/**
|
|
211
|
+
* Normalize a RSLang expression for duplicate comparison.
|
|
212
|
+
*
|
|
213
|
+
* Returns `null` for basic concepts without formal definitions. Pass a pre-parsed `ast`
|
|
214
|
+
* when the expression was already analyzed to avoid re-parsing.
|
|
215
|
+
*/
|
|
216
|
+
declare function normalizeExpression(expression: string, cst_type: CstType, ast?: AstNode | null): string | null;
|
|
217
|
+
/** Checks if given expression is a template. */
|
|
218
|
+
declare function inferTemplate(expression: string): boolean;
|
|
219
|
+
/** Apply filter based on start item type within an ordered list. */
|
|
220
|
+
declare function applyFilterCategory<T extends {
|
|
221
|
+
cst_type: CstType;
|
|
222
|
+
}>(start: T, items: readonly T[]): T[];
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/library/rsform-api/formal-graph.d.ts
|
|
225
|
+
/**
|
|
226
|
+
* Build the formal dependency graph: supplier → dependent.
|
|
227
|
+
* Matches backend {@code RSForm.graph_formal}.
|
|
228
|
+
*/
|
|
229
|
+
declare function buildFormalDependencyGraph(items: readonly FormalOrderFields[]): Graph<number>;
|
|
230
|
+
/**
|
|
231
|
+
* Reorder constituents: formal topology hard, semantic children sticky when ready,
|
|
232
|
+
* otherwise stable against type/kernel preferred ranks.
|
|
233
|
+
*
|
|
234
|
+
* One Kahn pass over the formal dependency graph.
|
|
235
|
+
*/
|
|
236
|
+
declare function restoreConstituentOrder<T extends FormalOrderFields>(items: readonly T[], graph?: Graph<number>, relations?: SemanticRelations): T[];
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/library/rsform-api/stats.d.ts
|
|
239
|
+
/** Checks if an item is a schema issue. */
|
|
240
|
+
declare function isSchemaIssue(cst: SchemaIssueFields): boolean;
|
|
241
|
+
/** Calculate statistics for {@link RSForm}. */
|
|
242
|
+
declare function calculateSchemaStats(target: RSForm): RSFormStats;
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/library/rsform-api/structure.d.ts
|
|
245
|
+
/**
|
|
246
|
+
* Id to pass as `insert_after` when creating a new {@link Constituenta} spawned by `targetId`:
|
|
247
|
+
* after the last existing child of that spawner, or after the spawner itself if none.
|
|
248
|
+
*/
|
|
249
|
+
declare function inferNewSpawnPosition(schema: RSForm, targetId: number): number;
|
|
250
|
+
/** Finds schema item by absolute structure path under `targetId`. */
|
|
251
|
+
declare function findCstByStructure(schema: RSForm, target: {
|
|
252
|
+
id: number;
|
|
253
|
+
}, path: TypePath): Constituenta | null;
|
|
254
|
+
/** Retrieves name for piece of target structure. */
|
|
255
|
+
declare function getStructureName(schema: RSForm, target: StructureCapableFields & {
|
|
256
|
+
id: number;
|
|
257
|
+
}, path: TypePath): string;
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/library/rsform-api/substitution.d.ts
|
|
260
|
+
/** Result of applying substitutions to a schema fragment. */
|
|
261
|
+
interface SubstitutionResult<T> {
|
|
262
|
+
items: T[];
|
|
263
|
+
attributions: Attribution[];
|
|
264
|
+
deletedIds: Set<number>;
|
|
265
|
+
/** Replacement constituent ids (survivors referenced by substitutions). */
|
|
266
|
+
replacementIds: number[];
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Apply constituenta substitutions: remap attributions, drop originals, rewrite aliases in survivors.
|
|
270
|
+
* Does not resolve texts — call {@link resolveAllConstituentTexts} afterwards.
|
|
271
|
+
*/
|
|
272
|
+
declare function applyConstituentSubstitutions<T extends MappableFields & {
|
|
273
|
+
id: number;
|
|
274
|
+
alias: string;
|
|
275
|
+
}>(items: readonly T[], attributions: readonly Attribution[], substitutions: readonly Substitution[]): SubstitutionResult<T>;
|
|
276
|
+
/**
|
|
277
|
+
* Remap substitution endpoints after source constituents were inserted under new ids.
|
|
278
|
+
* If {@link original} was imported, map it; otherwise map {@link substitution}.
|
|
279
|
+
*/
|
|
280
|
+
declare function remapSubstitutionsAfterImport(substitutions: readonly Substitution[], sourceIdSet: ReadonlySet<number>, idMap: Readonly<Record<number, number>>): Substitution[];
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/library/rsform-api/synthesis.d.ts
|
|
283
|
+
/** Field intersection required for embedding / synthesis transforms. */
|
|
284
|
+
type SynthesizableFields = MappableFields & TextResolvableFields & AliasTypedFields & {
|
|
285
|
+
id: number;
|
|
286
|
+
alias: string;
|
|
287
|
+
cst_type: CstType;
|
|
288
|
+
};
|
|
289
|
+
/** Input for {@link inlineSynthesis}. */
|
|
290
|
+
interface InlineSynthesisInput<T extends SynthesizableFields> {
|
|
291
|
+
/** Receiver schema constituents (order preserved; imports append). */
|
|
292
|
+
receiverItems: readonly T[];
|
|
293
|
+
/** Receiver attributions (default empty). */
|
|
294
|
+
receiverAttributions?: readonly Attribution[];
|
|
295
|
+
/**
|
|
296
|
+
* Source constituents to insert (already filtered to the desired subset).
|
|
297
|
+
* Cloned; originals are not mutated.
|
|
298
|
+
*/
|
|
299
|
+
sourceItems: readonly T[];
|
|
300
|
+
/** Source attributions whose both endpoints are among {@link sourceItems}. */
|
|
301
|
+
sourceAttributions?: readonly Attribution[];
|
|
302
|
+
/**
|
|
303
|
+
* Identification table using pre-import ids:
|
|
304
|
+
* one endpoint is a source id, the other a receiver id
|
|
305
|
+
* (same rules as backend embedding / InlineSynthesis).
|
|
306
|
+
*/
|
|
307
|
+
substitutions?: readonly Substitution[];
|
|
308
|
+
/** Next free numeric id for inserted constituents. */
|
|
309
|
+
nextId: number;
|
|
310
|
+
}
|
|
311
|
+
/** Result of {@link inlineSynthesis}. */
|
|
312
|
+
interface InlineSynthesisResult<T extends SynthesizableFields> {
|
|
313
|
+
items: T[];
|
|
314
|
+
attributions: Attribution[];
|
|
315
|
+
/** Updated next-id after inserts. */
|
|
316
|
+
nextId: number;
|
|
317
|
+
/** Source id → inserted id. */
|
|
318
|
+
idMap: Record<number, number>;
|
|
319
|
+
/** Alias remapping applied to imported constituents (empty when receiver was empty). */
|
|
320
|
+
aliasMapping: AliasMapping;
|
|
321
|
+
/** Ids removed by substitutions. */
|
|
322
|
+
deletedIds: Set<number>;
|
|
323
|
+
/** Ids of newly inserted constituents (before any were deleted by substitutions). */
|
|
324
|
+
insertedIds: number[];
|
|
325
|
+
/** Survivor ids referenced by applied substitutions. */
|
|
326
|
+
replacementIds: number[];
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Embed {@link InlineSynthesisInput.sourceItems} into the receiver and apply substitutions.
|
|
330
|
+
* Resolves term/definition entity references on the result.
|
|
331
|
+
* Does not mutate inputs.
|
|
332
|
+
*/
|
|
333
|
+
declare function inlineSynthesis<T extends SynthesizableFields>(input: InlineSynthesisInput<T>): InlineSynthesisResult<T>;
|
|
334
|
+
/** Sorts library items relevant for schema embedding with specified {@link RSForm}. */
|
|
335
|
+
declare function sortItemsForInlineSynthesis(receiver: RSForm, items: readonly LibraryItem[]): LibraryItem[];
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/library/rsform-api/text-resolution.d.ts
|
|
338
|
+
/** Options controlling which texts to re-resolve after an edit. */
|
|
339
|
+
interface TextChangeOptions {
|
|
340
|
+
termChanged: boolean;
|
|
341
|
+
termRawChanged: boolean;
|
|
342
|
+
definitionRawChanged: boolean;
|
|
343
|
+
clearTargetForms: boolean;
|
|
344
|
+
}
|
|
345
|
+
/** Build term-reference graph: referenced constituent → dependent (backend {@code graph_term}). */
|
|
346
|
+
declare function buildTermReferenceGraph(items: readonly TextResolvableFields[]): Graph<number>;
|
|
347
|
+
/** Build definition-reference graph: referenced constituent → dependent (backend {@code graph_text}). */
|
|
348
|
+
declare function buildDefinitionReferenceGraph(items: readonly TextResolvableFields[]): Graph<number>;
|
|
349
|
+
/** Resolve all term and definition texts in topological order. Mutates items in place. */
|
|
350
|
+
declare function resolveAllConstituentTexts(items: TextResolvableFields[]): void;
|
|
351
|
+
/**
|
|
352
|
+
* Resolve texts after a single constituent change, cascading dependents when the term changed.
|
|
353
|
+
* Mutates items in place.
|
|
354
|
+
*/
|
|
355
|
+
declare function resolveConstituentTextChange(items: TextResolvableFields[], targetID: number, options: TextChangeOptions): void;
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/library/rsform-api/transforms.d.ts
|
|
358
|
+
/**
|
|
359
|
+
* Pure constituenta list transforms: reorder, move, insert position.
|
|
360
|
+
*/
|
|
361
|
+
/** Rebuild an item list following {@link orderedIds}. Throws if an id is missing. */
|
|
362
|
+
declare function reorderItemsByIds<T extends {
|
|
363
|
+
id: number;
|
|
364
|
+
}>(items: readonly T[], orderedIds: readonly number[]): T[];
|
|
365
|
+
/**
|
|
366
|
+
* Move a subset of ids within an ordered id list.
|
|
367
|
+
* {@link moveTo} is clamped to `[0, rest.length]` (index among non-moving items).
|
|
368
|
+
*/
|
|
369
|
+
declare function moveIdsInOrder(ids: readonly number[], moving: readonly number[], moveTo: number): number[];
|
|
370
|
+
/** Insert {@link item} after {@link insertAfter}, or append when null/undefined/missing. Mutates {@link items}. */
|
|
371
|
+
declare function insertItemAfter<T extends {
|
|
372
|
+
id: number;
|
|
373
|
+
}>(items: T[], item: T, insertAfter: number | null | undefined): void;
|
|
374
|
+
//#endregion
|
|
375
|
+
export { removeAliasReference as $, canProduceStructure as A, filterAttributions as B, restoreConstituentOrder as C, inferTemplatedType as D, inferTemplate as E, isBasicConcept as F, MappableFields as G, remapAttributionsUnderSubstitution as H, isFunctional as I, applyMappingToConstituents as J, addAliasReference as K, isLogical as L, guessCstType as M, inferClass as N, normalizeExpression as O, isBaseSet as P, maxAliasIndex as Q, isTemplateCst as R, buildFormalDependencyGraph as S, inferStatus as T, getAnalysisFor as U, importAttributions as V, refineAnalysisForDependencyCycles as W, buildSequentialAliasMapping as X, argumentValuesToMapping as Y, generateAlias as Z, findCstByStructure as _, buildDefinitionReferenceGraph as a, DiagnosticSourceFields as at, calculateSchemaStats as b, resolveConstituentTextChange as c, SchemaIssueFields as ct, SynthesizableFields as d, SpawnPathFields as dt, validateAliasFormat as et, inlineSynthesis as f, StructureCapableFields as ft, remapSubstitutionsAfterImport as g, applyConstituentSubstitutions as h, TextResolvableFields as ht, TextChangeOptions as i, DescribableFields as it, getCstTypePrefix as j, canHaveManualTypification as k, InlineSynthesisInput as l, SearchableFields as lt, SubstitutionResult as m, TemplateSourceFields as mt, moveIdsInOrder as n, AliasTypedFields as nt, buildTermReferenceGraph as o, FormalOrderFields as ot, sortItemsForInlineSynthesis as p, TemplateParamSourceFields as pt, allocateImportAliases as q, reorderItemsByIds as r, BasicTextCheckFields as rt, resolveAllConstituentTexts as s, ModelEvalFields as st, insertItemAfter as t, validateNewAlias as tt, InlineSynthesisResult as u, SemanticRelations as ut, getStructureName as v, applyFilterCategory as w, isSchemaIssue as x, inferNewSpawnPosition as y, typeClassForCstType as z };
|
|
376
|
+
//# sourceMappingURL=index-DpiTybDB.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { n as ArgumentsType } from "./arguments-extractor-ngatANBI.js";
|
|
|
18
18
|
import { n as applyAsciiTypeSubstitutions, r as parseTypeText } from "./typification-parser-Dytsv9CI.js";
|
|
19
19
|
import { n as TypificationNodeData, t as TypificationGraph } from "./typification-graph-BY_oGT82.js";
|
|
20
20
|
import { a as LibraryItemType, i as LibraryItemReference, n as CurrentVersion, o as LocationHead, r as LibraryItem, s as VersionInfo, t as AccessPolicy } from "./library-CYun28Xz.js";
|
|
21
|
-
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, a as detectDependencyCycleDiagnostics, b as CstStatus, c as modelStatusCstDiagnostic, d as DEFAULT_VALUE_TEXT, f as EvalStatus, g as ArgumentValue, i as assignSchemaDiagnostics, l as BasicBinding, m as RSModelStats, n as DiagnosticKind, o as formatDependencyCycle, p as RSModel, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic, u as BasicsContext, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "./diagnostics-
|
|
21
|
+
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, a as detectDependencyCycleDiagnostics, b as CstStatus, c as modelStatusCstDiagnostic, d as DEFAULT_VALUE_TEXT, f as EvalStatus, g as ArgumentValue, i as assignSchemaDiagnostics, l as BasicBinding, m as RSModelStats, n as DiagnosticKind, o as formatDependencyCycle, p as RSModel, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic, u as BasicsContext, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "./diagnostics-DsEhmFh0.js";
|
|
22
22
|
import { FolderNode, FolderTree } from "./library/folder-tree.js";
|
|
23
23
|
import { n as OssLayout, r as Position2D } from "./oss-layout-3glgAqfn.js";
|
|
24
24
|
import { Block, CstSubstituteInfo, NodeType, Operation, OperationInput, OperationSchema, OperationSchemaStats, OperationSynthesis, OperationType, OssItem, SubstitutionErrorDescription, SubstitutionErrorType } from "./library/oss.js";
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { ValueClass } from "./rslang/semantic/value-class.js";
|
|
|
15
15
|
import { RSLangAnalyzer } from "./rslang/semantic/analyzer.js";
|
|
16
16
|
import { applyAsciiTypeSubstitutions, parseTypeText } from "./rslang/semantic/typification-parser.js";
|
|
17
17
|
import { TypificationGraph } from "./rslang/typification-graph.js";
|
|
18
|
-
import { a as formatDependencyCycle, i as detectDependencyCycleDiagnostics, n as RSDiagnosticCode, o as hasCstDiagnostic, r as assignSchemaDiagnostics, s as modelStatusCstDiagnostic, t as DiagnosticKind } from "./diagnostics-
|
|
18
|
+
import { a as formatDependencyCycle, i as detectDependencyCycleDiagnostics, n as RSDiagnosticCode, o as hasCstDiagnostic, r as assignSchemaDiagnostics, s as modelStatusCstDiagnostic, t as DiagnosticKind } from "./diagnostics-ndGYbvgh.js";
|
|
19
19
|
import { DEFAULT_VALUE_TEXT, EvalStatus } from "./library/rsmodel.js";
|
|
20
20
|
import { FolderNode, FolderTree } from "./library/folder-tree.js";
|
|
21
21
|
import { AccessPolicy, LibraryItemType, LocationHead } from "./library/library.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as detectDependencyCycleDiagnostics, c as modelStatusCstDiagnostic, i as assignSchemaDiagnostics, n as DiagnosticKind, o as formatDependencyCycle, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic } from "../diagnostics-
|
|
1
|
+
import { a as detectDependencyCycleDiagnostics, c as modelStatusCstDiagnostic, i as assignSchemaDiagnostics, n as DiagnosticKind, o as formatDependencyCycle, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic } from "../diagnostics-DsEhmFh0.js";
|
|
2
2
|
export { CstDiagnostic, DiagnosticKind, RSDiagnosticCode, assignSchemaDiagnostics, detectDependencyCycleDiagnostics, formatDependencyCycle, hasCstDiagnostic, modelStatusCstDiagnostic };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as formatDependencyCycle, i as detectDependencyCycleDiagnostics, n as RSDiagnosticCode, o as hasCstDiagnostic, r as assignSchemaDiagnostics, s as modelStatusCstDiagnostic, t as DiagnosticKind } from "../diagnostics-
|
|
1
|
+
import { a as formatDependencyCycle, i as detectDependencyCycleDiagnostics, n as RSDiagnosticCode, o as hasCstDiagnostic, r as assignSchemaDiagnostics, s as modelStatusCstDiagnostic, t as DiagnosticKind } from "../diagnostics-ndGYbvgh.js";
|
|
2
2
|
export { DiagnosticKind, RSDiagnosticCode, assignSchemaDiagnostics, detectDependencyCycleDiagnostics, formatDependencyCycle, hasCstDiagnostic, modelStatusCstDiagnostic };
|
package/dist/library/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { a as LibraryItemType, i as LibraryItemReference, n as CurrentVersion, o as LocationHead, r as LibraryItem, s as VersionInfo, t as AccessPolicy } from "../library-CYun28Xz.js";
|
|
2
|
-
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, a as detectDependencyCycleDiagnostics, b as CstStatus, c as modelStatusCstDiagnostic, d as DEFAULT_VALUE_TEXT, f as EvalStatus, g as ArgumentValue, i as assignSchemaDiagnostics, l as BasicBinding, m as RSModelStats, n as DiagnosticKind, o as formatDependencyCycle, p as RSModel, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic, u as BasicsContext, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-
|
|
2
|
+
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, a as detectDependencyCycleDiagnostics, b as CstStatus, c as modelStatusCstDiagnostic, d as DEFAULT_VALUE_TEXT, f as EvalStatus, g as ArgumentValue, i as assignSchemaDiagnostics, l as BasicBinding, m as RSModelStats, n as DiagnosticKind, o as formatDependencyCycle, p as RSModel, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic, u as BasicsContext, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-DsEhmFh0.js";
|
|
3
3
|
import { FolderNode, FolderTree } from "./folder-tree.js";
|
|
4
4
|
import { n as OssLayout, r as Position2D } from "../oss-layout-3glgAqfn.js";
|
|
5
5
|
import { Block, CstSubstituteInfo, NodeType, Operation, OperationInput, OperationSchema, OperationSchemaStats, OperationSynthesis, OperationType, OssItem, SubstitutionErrorDescription, SubstitutionErrorType } from "./oss.js";
|
|
6
6
|
import { RSEngine } from "./rsengine.js";
|
|
7
|
+
import { mt as TemplateSourceFields } from "../index-DpiTybDB.js";
|
|
7
8
|
|
|
8
9
|
//#region src/library/template-instantiation.d.ts
|
|
9
10
|
/**
|
|
@@ -22,7 +23,7 @@ interface TemplateInstantiationItem {
|
|
|
22
23
|
definition_formal: string;
|
|
23
24
|
definition_raw: string;
|
|
24
25
|
term_raw: string;
|
|
25
|
-
term_forms:
|
|
26
|
+
term_forms: TermForm[];
|
|
26
27
|
typification_manual: string;
|
|
27
28
|
value_is_property: boolean;
|
|
28
29
|
}
|
|
@@ -55,9 +56,9 @@ interface TemplateInstantiationInput {
|
|
|
55
56
|
/** Schema that will receive new constituents. */
|
|
56
57
|
targetSchema: RSForm;
|
|
57
58
|
/** All constituents of the selected expression-bank RSForm (not only the prototype). */
|
|
58
|
-
templateItems:
|
|
59
|
+
templateItems: TemplateSourceFields[];
|
|
59
60
|
/** Template constituent chosen in the UI (main expression to add). */
|
|
60
|
-
prototype:
|
|
61
|
+
prototype: TemplateSourceFields;
|
|
61
62
|
/** User bindings from template parameter aliases to target-schema global aliases. */
|
|
62
63
|
userArgs: ArgumentValue[];
|
|
63
64
|
/**
|
package/dist/library/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { TypeID } from "../rslang/semantic/typification.js";
|
|
|
5
5
|
import { labelType } from "../rslang/labels.js";
|
|
6
6
|
import { applyAliasMapping, isGlobalAlias, parseRSLangExpression, splitTemplateDefinition, substituteLocalAliases, substituteTemplateArgs } from "../rslang/api.js";
|
|
7
7
|
import { CstClass, CstStatus, CstType } from "./rsform.js";
|
|
8
|
-
import { $ as isFunctional, A as normalizeExpression, R as applyMappingToConstituents, V as generateAlias, a as formatDependencyCycle, i as detectDependencyCycleDiagnostics, k as inferTemplatedType, n as RSDiagnosticCode, o as hasCstDiagnostic, r as assignSchemaDiagnostics, s as modelStatusCstDiagnostic, t as DiagnosticKind, z as argumentValuesToMapping } from "../diagnostics-
|
|
8
|
+
import { $ as isFunctional, A as normalizeExpression, R as applyMappingToConstituents, V as generateAlias, a as formatDependencyCycle, i as detectDependencyCycleDiagnostics, k as inferTemplatedType, n as RSDiagnosticCode, o as hasCstDiagnostic, r as assignSchemaDiagnostics, s as modelStatusCstDiagnostic, t as DiagnosticKind, z as argumentValuesToMapping } from "../diagnostics-ndGYbvgh.js";
|
|
9
9
|
import { DEFAULT_VALUE_TEXT, EvalStatus } from "./rsmodel.js";
|
|
10
10
|
import { FolderNode, FolderTree } from "./folder-tree.js";
|
|
11
11
|
import { AccessPolicy, LibraryItemType, LocationHead } from "./library.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/library/template-instantiation.ts"],"sourcesContent":["/**\n * Module: template instantiation from the expression bank into a target {@link RSForm}.\n */\n\nimport { type AstNode, visitAstDFS } from '../parsing';\nimport {\n type AliasMapping,\n applyAliasMapping,\n isGlobalAlias,\n parseRSLangExpression,\n splitTemplateDefinition,\n substituteLocalAliases,\n substituteTemplateArgs\n} from '../rslang/api';\nimport { labelType } from '../rslang/labels';\nimport { TokenID } from '../rslang/parser/token';\nimport { TypeID } from '../rslang/semantic/typification';\n\nimport { type ArgumentValue, type Constituenta, type CstType, type RSForm } from './rsform';\nimport {\n applyMappingToConstituents,\n argumentValuesToMapping,\n generateAlias,\n inferTemplatedType,\n isFunctional,\n normalizeExpression\n} from './rsform-api';\n\n/**\n * Payload for one {@link Constituenta} to create when instantiating an expression-bank template.\n *\n * Aliases are generated for the target schema. Formal definitions and typifications already\n * reflect user argument substitution and remapping of bank aliases to those new aliases.\n */\nexport interface TemplateInstantiationItem {\n /** Alias to assign in the target schema. */\n alias: string;\n /** Inferred type after argument substitution (function/predicate may become term/axiom). */\n cst_type: CstType;\n crucial: boolean;\n convention: string;\n definition_formal: string;\n definition_raw: string;\n term_raw: string;\n term_forms: Constituenta['term_forms'];\n typification_manual: string;\n value_is_property: boolean;\n}\n\n/** Conflicting argument bindings inferred for the same template dependency. */\nexport interface TemplateBindingConflict {\n templateAlias: string;\n paramAlias: string;\n existing: string;\n incoming: string;\n}\n\n/**\n * Batch create plan: dependencies first, selected template constituent last.\n *\n * Reuses constituents whose substituted formal definition already exists in the target schema\n * (normalized comparison), even when the bank alias differs from the matched target alias.\n * {@link TemplateInstantiationPlan.mainDuplicateAlias} reports when the selected template is a duplicate.\n * Does not set `insert_after`; the caller supplies insertion on the batch DTO.\n */\nexport interface TemplateInstantiationPlan {\n items: TemplateInstantiationItem[];\n /** Set when the selected template expression already exists in the target schema. */\n mainDuplicateAlias: string | null;\n /** Set when nested template calls bind the same parameter to different global aliases. */\n bindingConflict: TemplateBindingConflict | null;\n}\n\n/**\n * Input for planning template instantiation into a conceptual schema.\n */\nexport interface TemplateInstantiationInput {\n /** Schema that will receive new constituents. */\n targetSchema: RSForm;\n /** All constituents of the selected expression-bank RSForm (not only the prototype). */\n templateItems: Constituenta[];\n /** Template constituent chosen in the UI (main expression to add). */\n prototype: Constituenta;\n /** User bindings from template parameter aliases to target-schema global aliases. */\n userArgs: ArgumentValue[];\n /**\n * Main constituent attributes from the create dialog (alias, labels, flags).\n * `definition_formal` and `cst_type` may be overridden from `prototype` and `userArgs`.\n */\n mainItem: TemplateInstantiationItem;\n}\n\ninterface FuncCallRef {\n callee: string;\n args: string[];\n}\n\ninterface TemplateParam {\n alias: string;\n typification: string;\n}\n\n/**\n * Build a batch create plan for a template expression and its bank dependencies.\n *\n * Walks nested `F#` / `P#` calls in the substituted expression, collects missing term-functions\n * and predicate-functions from `templateItems`, propagates argument bindings into nested calls,\n * topologically orders dependencies, and remaps bank aliases to freshly generated target aliases.\n */\nexport function planTemplateInstantiation(input: TemplateInstantiationInput): TemplateInstantiationPlan {\n return new TemplateInstantiationPlanner(input).plan();\n}\n\n/**\n * Stateful planner for {@link planTemplateInstantiation}.\n *\n * Prefer the function wrapper unless you need to hold or reuse planner state between calls.\n */\nexport class TemplateInstantiationPlanner {\n private readonly targetSchema: RSForm;\n private readonly prototype: Constituenta;\n private readonly userArgs: ArgumentValue[];\n private readonly mainItemTemplate: TemplateInstantiationItem;\n private readonly templateByAlias: Map<string, Constituenta>;\n private readonly userMapping: AliasMapping;\n private readonly depBindings = new Map<string, Map<string, string>>();\n private readonly depRefs = new Map<string, Set<string>>();\n private bindingConflict: TemplateBindingConflict | null = null;\n\n /** @param input - See {@link TemplateInstantiationInput}. */\n constructor(input: TemplateInstantiationInput) {\n this.targetSchema = input.targetSchema;\n this.prototype = input.prototype;\n this.userArgs = input.userArgs;\n this.mainItemTemplate = input.mainItem;\n this.templateByAlias = new Map(\n input.templateItems.filter(cst => isFunctional(cst.cst_type)).map(cst => [cst.alias, cst])\n );\n this.userMapping = argumentValuesToMapping(input.userArgs);\n }\n\n /** @returns Dependency items in topological order, then the main template item when it is not a duplicate. */\n plan(): TemplateInstantiationPlan {\n const mainDefinition = substituteTemplateArgs(this.prototype.definition_formal, this.userMapping);\n this.collectDependencies(mainDefinition, this.userMapping);\n\n if (this.bindingConflict) {\n return { items: [], mainDuplicateAlias: null, bindingConflict: this.bindingConflict };\n }\n\n const definitionIndex = createFormalDefinitionIndex(this.targetSchema);\n const dependencyItems = this.buildDependencyItems(definitionIndex);\n const { item: mainItem, duplicateAlias: mainDuplicateAlias } = this.buildMainItem(\n mainDefinition,\n dependencyItems.takenAliases,\n dependencyItems.aliasMapping,\n definitionIndex\n );\n\n return {\n items: mainItem ? [...dependencyItems.items, mainItem] : dependencyItems.items,\n mainDuplicateAlias,\n bindingConflict: null\n };\n }\n\n private buildDependencyItems(definitionIndex: FormalDefinitionIndex): {\n items: TemplateInstantiationItem[];\n aliasMapping: AliasMapping;\n takenAliases: string[];\n } {\n const dependencyAliases = topologicalSort([...this.depBindings.keys()], this.depRefs);\n const aliasMapping: AliasMapping = {};\n const takenAliases: string[] = [];\n const reservedAliases = [this.mainItemTemplate.alias];\n const items: TemplateInstantiationItem[] = [];\n\n for (const templateAlias of dependencyAliases) {\n const template = this.templateByAlias.get(templateAlias)!;\n const bindings = this.depBindings.get(templateAlias)!;\n const args = bindingMapToArgs(getTemplateParams(template), bindings);\n const cst_type = inferTemplatedType(template.cst_type, args);\n const definition = applyAliasMapping(\n substituteTemplateArgs(template.definition_formal, argumentValuesToMapping(args)),\n aliasMapping\n );\n\n const existingAlias = definitionIndex.find(cst_type, definition);\n if (existingAlias) {\n aliasMapping[templateAlias] = existingAlias;\n continue;\n }\n\n const alias = generateAlias(template.cst_type, this.targetSchema, [...reservedAliases, ...takenAliases]);\n takenAliases.push(alias);\n aliasMapping[templateAlias] = alias;\n\n const item = instantiateTemplateItem(template, args, alias);\n item.definition_formal = definition;\n applyMappingToConstituents([item], aliasMapping, false);\n definitionIndex.register(cst_type, item.definition_formal, alias);\n items.push(item);\n }\n\n return { items, aliasMapping, takenAliases };\n }\n\n private buildMainItem(\n mainDefinition: string,\n takenAliases: string[],\n aliasMapping: AliasMapping,\n definitionIndex: FormalDefinitionIndex\n ): { item: TemplateInstantiationItem | null; duplicateAlias: string | null } {\n const mappedDefinition = applyAliasMapping(mainDefinition, aliasMapping);\n const cst_type = inferTemplatedType(this.prototype.cst_type, this.userArgs);\n\n const duplicateAlias = definitionIndex.find(cst_type, mappedDefinition);\n if (duplicateAlias) {\n return { item: null, duplicateAlias };\n }\n\n const mainItem: TemplateInstantiationItem = {\n ...this.mainItemTemplate,\n definition_formal: mappedDefinition,\n cst_type\n };\n applyMappingToConstituents([mainItem], aliasMapping, false);\n\n if (takenAliases.includes(mainItem.alias)) {\n mainItem.alias = generateAlias(mainItem.cst_type, this.targetSchema, [\n ...takenAliases,\n this.mainItemTemplate.alias\n ]);\n }\n\n return { item: mainItem, duplicateAlias: null };\n }\n\n private ensureDep(templateAlias: string, bindings: Map<string, string>, referrer?: string): void {\n if (this.bindingConflict) {\n return;\n }\n if (!this.templateByAlias.has(templateAlias)) {\n return;\n }\n if (referrer && this.depBindings.has(referrer)) {\n const refs = this.depRefs.get(referrer) ?? new Set<string>();\n refs.add(templateAlias);\n this.depRefs.set(referrer, refs);\n }\n const mergeResult = mergeBindings(this.depBindings.get(templateAlias), bindings);\n if (!mergeResult.ok) {\n this.bindingConflict = { templateAlias, ...mergeResult.conflict };\n return;\n }\n const merged = mergeResult.bindings;\n const changed =\n !this.depBindings.has(templateAlias) || merged.size !== (this.depBindings.get(templateAlias)?.size ?? 0);\n this.depBindings.set(templateAlias, merged);\n if (!changed && referrer) {\n return;\n }\n const template = this.templateByAlias.get(templateAlias)!;\n const args = bindingMapToArgs(getTemplateParams(template), merged);\n const definition = substituteTemplateArgs(template.definition_formal, argumentValuesToMapping(args));\n this.collectDependencies(definition, argumentValuesToMapping(args), templateAlias);\n }\n\n private collectDependencies(expression: string, scope: AliasMapping, referrer?: string): void {\n if (this.bindingConflict) {\n return;\n }\n const ast = parseRSLangExpression(expression);\n if (!ast) {\n return;\n }\n for (const call of extractFuncCalls(ast, expression)) {\n const template = this.templateByAlias.get(call.callee);\n if (!template) {\n continue;\n }\n const scopedArgs = call.args.map(arg => substituteLocalAliases(arg, scope));\n const bindings = bindingsFromCall(getTemplateParams(template), scopedArgs, scope);\n this.ensureDep(call.callee, bindings, referrer);\n }\n }\n}\n\n// ======= Internals ========\n\n/** Normalized formal definitions in the target schema and in the current plan. */\nclass FormalDefinitionIndex {\n private readonly byKey = new Map<string, string>();\n\n register(cst_type: CstType, definition_formal: string, alias: string): void {\n const normalized = normalizeExpression(definition_formal, cst_type);\n if (!normalized) {\n return;\n }\n this.byKey.set(formalDefinitionKey(cst_type, normalized), alias);\n }\n\n find(cst_type: CstType, definition_formal: string): string | null {\n const normalized = normalizeExpression(definition_formal, cst_type);\n if (!normalized) {\n return null;\n }\n return this.byKey.get(formalDefinitionKey(cst_type, normalized)) ?? null;\n }\n}\n\nfunction createFormalDefinitionIndex(schema: RSForm): FormalDefinitionIndex {\n const index = new FormalDefinitionIndex();\n for (const cst of schema.items) {\n index.register(cst.cst_type, cst.definition_formal, cst.alias);\n }\n return index;\n}\n\nfunction formalDefinitionKey(cst_type: CstType, normalized: string): string {\n return `${cst_type}\\0${normalized}`;\n}\n\nfunction instantiateTemplateItem(\n template: Constituenta,\n args: ArgumentValue[],\n alias: string\n): TemplateInstantiationItem {\n return {\n alias,\n cst_type: inferTemplatedType(template.cst_type, args),\n crucial: template.crucial,\n convention: template.convention,\n definition_formal: substituteTemplateArgs(template.definition_formal, argumentValuesToMapping(args)),\n definition_raw: template.definition_raw,\n term_raw: template.term_raw,\n term_forms: [...template.term_forms],\n typification_manual: template.typification_manual,\n value_is_property: template.value_is_property\n };\n}\n\nfunction bindingsFromCall(params: TemplateParam[], callArgs: string[], scope: AliasMapping): Map<string, string> {\n const bindings = new Map<string, string>();\n params.forEach((param, index) => {\n const value = resolveArgBinding(callArgs[index] ?? '', scope);\n if (value) {\n bindings.set(param.alias, value);\n }\n });\n return bindings;\n}\n\nfunction resolveArgBinding(argExpr: string, scope: AliasMapping): string | undefined {\n const scoped = substituteLocalAliases(argExpr, scope).trim();\n if (isGlobalAlias(scoped)) {\n return scoped;\n }\n return undefined;\n}\n\ntype MergeBindingsResult =\n | { ok: true; bindings: Map<string, string> }\n | { ok: false; conflict: { paramAlias: string; existing: string; incoming: string } };\n\nfunction mergeBindings(existing: Map<string, string> | undefined, incoming: Map<string, string>): MergeBindingsResult {\n const result = new Map(existing);\n for (const [alias, value] of incoming) {\n const existingValue = result.get(alias);\n if (existingValue === undefined) {\n result.set(alias, value);\n } else if (existingValue !== value) {\n return { ok: false, conflict: { paramAlias: alias, existing: existingValue, incoming: value } };\n }\n }\n return { ok: true, bindings: result };\n}\n\nfunction bindingMapToArgs(params: TemplateParam[], bindings: Map<string, string>): ArgumentValue[] {\n return params.map(param => ({\n alias: param.alias,\n typification: param.typification,\n value: bindings.get(param.alias)\n }));\n}\n\nfunction getTemplateParams(template: Constituenta): TemplateParam[] {\n const effectiveType = template.effectiveType;\n if (effectiveType && (effectiveType.typeID === TypeID.function || effectiveType.typeID === TypeID.predicate)) {\n return effectiveType.args.map(arg => ({\n alias: arg.alias,\n typification: labelType(arg.type)\n }));\n }\n const { head } = splitTemplateDefinition(template.definition_formal);\n if (!head) {\n return [];\n }\n return head.split(',').map(part => {\n const trimmed = part.trim();\n const separator = trimmed.indexOf('∈');\n if (separator === -1) {\n return { alias: trimmed, typification: '' };\n }\n return {\n alias: trimmed.slice(0, separator).trim(),\n typification: trimmed.slice(separator + 1).trim()\n };\n });\n}\n\nfunction extractFuncCalls(ast: AstNode, expression: string): FuncCallRef[] {\n const result: FuncCallRef[] = [];\n visitAstDFS(ast, node => {\n if (node.typeID !== TokenID.NT_FUNC_CALL || node.children.length < 1) {\n return;\n }\n const calleeNode = node.children[0];\n if (\n calleeNode.typeID !== TokenID.ID_FUNCTION &&\n calleeNode.typeID !== TokenID.ID_PREDICATE &&\n calleeNode.typeID !== TokenID.ID_GLOBAL\n ) {\n return;\n }\n const callee = expression.slice(calleeNode.from, calleeNode.to);\n if (!/^[FP]\\d+$/.test(callee)) {\n return;\n }\n result.push({\n callee,\n args: node.children.slice(1).map(child => expression.slice(child.from, child.to).trim())\n });\n });\n return result;\n}\n\nfunction topologicalSort(aliases: string[], refs: Map<string, Set<string>>): string[] {\n const remaining = new Set(aliases);\n const sorted: string[] = [];\n while (remaining.size > 0) {\n const ready = [...remaining].filter(alias => {\n const deps = refs.get(alias) ?? new Set<string>();\n return [...deps].every(dep => !remaining.has(dep));\n });\n if (ready.length === 0) {\n return [...remaining, ...sorted].reverse();\n }\n ready.sort();\n for (const alias of ready) {\n sorted.push(alias);\n remaining.delete(alias);\n }\n }\n return sorted;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6GA,SAAgB,0BAA0B,OAA8D;CACtG,OAAO,IAAI,6BAA6B,KAAK,CAAC,CAAC,KAAK;AACtD;;;;;;AAOA,IAAa,+BAAb,MAA0C;CACxC;CACA;CACA;CACA;CACA;CACA;CACA,8BAA+B,IAAI,IAAiC;CACpE,0BAA2B,IAAI,IAAyB;CACxD,kBAA0D;;CAG1D,YAAY,OAAmC;EAC7C,KAAK,eAAe,MAAM;EAC1B,KAAK,YAAY,MAAM;EACvB,KAAK,WAAW,MAAM;EACtB,KAAK,mBAAmB,MAAM;EAC9B,KAAK,kBAAkB,IAAI,IACzB,MAAM,cAAc,QAAO,QAAO,aAAa,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAI,QAAO,CAAC,IAAI,OAAO,GAAG,CAAC,CAC3F;EACA,KAAK,cAAc,wBAAwB,MAAM,QAAQ;CAC3D;;CAGA,OAAkC;EAChC,MAAM,iBAAiB,uBAAuB,KAAK,UAAU,mBAAmB,KAAK,WAAW;EAChG,KAAK,oBAAoB,gBAAgB,KAAK,WAAW;EAEzD,IAAI,KAAK,iBACP,OAAO;GAAE,OAAO,CAAC;GAAG,oBAAoB;GAAM,iBAAiB,KAAK;EAAgB;EAGtF,MAAM,kBAAkB,4BAA4B,KAAK,YAAY;EACrE,MAAM,kBAAkB,KAAK,qBAAqB,eAAe;EACjE,MAAM,EAAE,MAAM,UAAU,gBAAgB,uBAAuB,KAAK,cAClE,gBACA,gBAAgB,c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AAC,GADK,KAAK,IAAI,KAAK,qBAAK,IAAI,IAAY,CACjC,CAAC,CAAC,OAAM,QAAO,CAAC,UAAU,IAAI,GAAG,CAAC;EACnD,CAAC;EACD,IAAI,MAAM,WAAW,GACnB,OAAO,CAAC,GAAG,WAAW,GAAG,MAAM,CAAC,CAAC,QAAQ;EAE3C,MAAM,KAAK;EACX,KAAK,MAAM,SAAS,OAAO;GACzB,OAAO,KAAK,KAAK;GACjB,UAAU,OAAO,KAAK;EACxB;CACF;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/library/template-instantiation.ts"],"sourcesContent":["/**\n * Module: template instantiation from the expression bank into a target {@link RSForm}.\n */\n\nimport { type AstNode, visitAstDFS } from '../parsing';\nimport {\n type AliasMapping,\n applyAliasMapping,\n isGlobalAlias,\n parseRSLangExpression,\n splitTemplateDefinition,\n substituteLocalAliases,\n substituteTemplateArgs\n} from '../rslang/api';\nimport { labelType } from '../rslang/labels';\nimport { TokenID } from '../rslang/parser/token';\nimport { TypeID } from '../rslang/semantic/typification';\n\nimport { type ArgumentValue, type CstType, type RSForm, type TermForm } from './rsform';\nimport {\n applyMappingToConstituents,\n argumentValuesToMapping,\n generateAlias,\n inferTemplatedType,\n isFunctional,\n normalizeExpression,\n type TemplateParamSourceFields,\n type TemplateSourceFields\n} from './rsform-api';\n\n/**\n * Payload for one {@link Constituenta} to create when instantiating an expression-bank template.\n *\n * Aliases are generated for the target schema. Formal definitions and typifications already\n * reflect user argument substitution and remapping of bank aliases to those new aliases.\n */\nexport interface TemplateInstantiationItem {\n /** Alias to assign in the target schema. */\n alias: string;\n /** Inferred type after argument substitution (function/predicate may become term/axiom). */\n cst_type: CstType;\n crucial: boolean;\n convention: string;\n definition_formal: string;\n definition_raw: string;\n term_raw: string;\n term_forms: TermForm[];\n typification_manual: string;\n value_is_property: boolean;\n}\n\n/** Conflicting argument bindings inferred for the same template dependency. */\nexport interface TemplateBindingConflict {\n templateAlias: string;\n paramAlias: string;\n existing: string;\n incoming: string;\n}\n\n/**\n * Batch create plan: dependencies first, selected template constituent last.\n *\n * Reuses constituents whose substituted formal definition already exists in the target schema\n * (normalized comparison), even when the bank alias differs from the matched target alias.\n * {@link TemplateInstantiationPlan.mainDuplicateAlias} reports when the selected template is a duplicate.\n * Does not set `insert_after`; the caller supplies insertion on the batch DTO.\n */\nexport interface TemplateInstantiationPlan {\n items: TemplateInstantiationItem[];\n /** Set when the selected template expression already exists in the target schema. */\n mainDuplicateAlias: string | null;\n /** Set when nested template calls bind the same parameter to different global aliases. */\n bindingConflict: TemplateBindingConflict | null;\n}\n\n/**\n * Input for planning template instantiation into a conceptual schema.\n */\nexport interface TemplateInstantiationInput {\n /** Schema that will receive new constituents. */\n targetSchema: RSForm;\n /** All constituents of the selected expression-bank RSForm (not only the prototype). */\n templateItems: TemplateSourceFields[];\n /** Template constituent chosen in the UI (main expression to add). */\n prototype: TemplateSourceFields;\n /** User bindings from template parameter aliases to target-schema global aliases. */\n userArgs: ArgumentValue[];\n /**\n * Main constituent attributes from the create dialog (alias, labels, flags).\n * `definition_formal` and `cst_type` may be overridden from `prototype` and `userArgs`.\n */\n mainItem: TemplateInstantiationItem;\n}\n\ninterface FuncCallRef {\n callee: string;\n args: string[];\n}\n\ninterface TemplateParam {\n alias: string;\n typification: string;\n}\n\n/**\n * Build a batch create plan for a template expression and its bank dependencies.\n *\n * Walks nested `F#` / `P#` calls in the substituted expression, collects missing term-functions\n * and predicate-functions from `templateItems`, propagates argument bindings into nested calls,\n * topologically orders dependencies, and remaps bank aliases to freshly generated target aliases.\n */\nexport function planTemplateInstantiation(input: TemplateInstantiationInput): TemplateInstantiationPlan {\n return new TemplateInstantiationPlanner(input).plan();\n}\n\n/**\n * Stateful planner for {@link planTemplateInstantiation}.\n *\n * Prefer the function wrapper unless you need to hold or reuse planner state between calls.\n */\nexport class TemplateInstantiationPlanner {\n private readonly targetSchema: RSForm;\n private readonly prototype: TemplateSourceFields;\n private readonly userArgs: ArgumentValue[];\n private readonly mainItemTemplate: TemplateInstantiationItem;\n private readonly templateByAlias: Map<string, TemplateSourceFields>;\n private readonly userMapping: AliasMapping;\n private readonly depBindings = new Map<string, Map<string, string>>();\n private readonly depRefs = new Map<string, Set<string>>();\n private bindingConflict: TemplateBindingConflict | null = null;\n\n /** @param input - See {@link TemplateInstantiationInput}. */\n constructor(input: TemplateInstantiationInput) {\n this.targetSchema = input.targetSchema;\n this.prototype = input.prototype;\n this.userArgs = input.userArgs;\n this.mainItemTemplate = input.mainItem;\n this.templateByAlias = new Map(\n input.templateItems.filter(cst => isFunctional(cst.cst_type)).map(cst => [cst.alias, cst])\n );\n this.userMapping = argumentValuesToMapping(input.userArgs);\n }\n\n /** @returns Dependency items in topological order, then the main template item when it is not a duplicate. */\n plan(): TemplateInstantiationPlan {\n const mainDefinition = substituteTemplateArgs(this.prototype.definition_formal, this.userMapping);\n this.collectDependencies(mainDefinition, this.userMapping);\n\n if (this.bindingConflict) {\n return { items: [], mainDuplicateAlias: null, bindingConflict: this.bindingConflict };\n }\n\n const definitionIndex = createFormalDefinitionIndex(this.targetSchema);\n const dependencyItems = this.buildDependencyItems(definitionIndex);\n const { item: mainItem, duplicateAlias: mainDuplicateAlias } = this.buildMainItem(\n mainDefinition,\n dependencyItems.takenAliases,\n dependencyItems.aliasMapping,\n definitionIndex\n );\n\n return {\n items: mainItem ? [...dependencyItems.items, mainItem] : dependencyItems.items,\n mainDuplicateAlias,\n bindingConflict: null\n };\n }\n\n private buildDependencyItems(definitionIndex: FormalDefinitionIndex): {\n items: TemplateInstantiationItem[];\n aliasMapping: AliasMapping;\n takenAliases: string[];\n } {\n const dependencyAliases = topologicalSort([...this.depBindings.keys()], this.depRefs);\n const aliasMapping: AliasMapping = {};\n const takenAliases: string[] = [];\n const reservedAliases = [this.mainItemTemplate.alias];\n const items: TemplateInstantiationItem[] = [];\n\n for (const templateAlias of dependencyAliases) {\n const template = this.templateByAlias.get(templateAlias)!;\n const bindings = this.depBindings.get(templateAlias)!;\n const args = bindingMapToArgs(getTemplateParams(template), bindings);\n const cst_type = inferTemplatedType(template.cst_type, args);\n const definition = applyAliasMapping(\n substituteTemplateArgs(template.definition_formal, argumentValuesToMapping(args)),\n aliasMapping\n );\n\n const existingAlias = definitionIndex.find(cst_type, definition);\n if (existingAlias) {\n aliasMapping[templateAlias] = existingAlias;\n continue;\n }\n\n const alias = generateAlias(template.cst_type, this.targetSchema, [...reservedAliases, ...takenAliases]);\n takenAliases.push(alias);\n aliasMapping[templateAlias] = alias;\n\n const item = instantiateTemplateItem(template, args, alias);\n item.definition_formal = definition;\n applyMappingToConstituents([item], aliasMapping, false);\n definitionIndex.register(cst_type, item.definition_formal, alias);\n items.push(item);\n }\n\n return { items, aliasMapping, takenAliases };\n }\n\n private buildMainItem(\n mainDefinition: string,\n takenAliases: string[],\n aliasMapping: AliasMapping,\n definitionIndex: FormalDefinitionIndex\n ): { item: TemplateInstantiationItem | null; duplicateAlias: string | null } {\n const mappedDefinition = applyAliasMapping(mainDefinition, aliasMapping);\n const cst_type = inferTemplatedType(this.prototype.cst_type, this.userArgs);\n\n const duplicateAlias = definitionIndex.find(cst_type, mappedDefinition);\n if (duplicateAlias) {\n return { item: null, duplicateAlias };\n }\n\n const mainItem: TemplateInstantiationItem = {\n ...this.mainItemTemplate,\n definition_formal: mappedDefinition,\n cst_type\n };\n applyMappingToConstituents([mainItem], aliasMapping, false);\n\n if (takenAliases.includes(mainItem.alias)) {\n mainItem.alias = generateAlias(mainItem.cst_type, this.targetSchema, [\n ...takenAliases,\n this.mainItemTemplate.alias\n ]);\n }\n\n return { item: mainItem, duplicateAlias: null };\n }\n\n private ensureDep(templateAlias: string, bindings: Map<string, string>, referrer?: string): void {\n if (this.bindingConflict) {\n return;\n }\n if (!this.templateByAlias.has(templateAlias)) {\n return;\n }\n if (referrer && this.depBindings.has(referrer)) {\n const refs = this.depRefs.get(referrer) ?? new Set<string>();\n refs.add(templateAlias);\n this.depRefs.set(referrer, refs);\n }\n const mergeResult = mergeBindings(this.depBindings.get(templateAlias), bindings);\n if (!mergeResult.ok) {\n this.bindingConflict = { templateAlias, ...mergeResult.conflict };\n return;\n }\n const merged = mergeResult.bindings;\n const changed =\n !this.depBindings.has(templateAlias) || merged.size !== (this.depBindings.get(templateAlias)?.size ?? 0);\n this.depBindings.set(templateAlias, merged);\n if (!changed && referrer) {\n return;\n }\n const template = this.templateByAlias.get(templateAlias)!;\n const args = bindingMapToArgs(getTemplateParams(template), merged);\n const definition = substituteTemplateArgs(template.definition_formal, argumentValuesToMapping(args));\n this.collectDependencies(definition, argumentValuesToMapping(args), templateAlias);\n }\n\n private collectDependencies(expression: string, scope: AliasMapping, referrer?: string): void {\n if (this.bindingConflict) {\n return;\n }\n const ast = parseRSLangExpression(expression);\n if (!ast) {\n return;\n }\n for (const call of extractFuncCalls(ast, expression)) {\n const template = this.templateByAlias.get(call.callee);\n if (!template) {\n continue;\n }\n const scopedArgs = call.args.map(arg => substituteLocalAliases(arg, scope));\n const bindings = bindingsFromCall(getTemplateParams(template), scopedArgs, scope);\n this.ensureDep(call.callee, bindings, referrer);\n }\n }\n}\n\n// ======= Internals ========\n\n/** Normalized formal definitions in the target schema and in the current plan. */\nclass FormalDefinitionIndex {\n private readonly byKey = new Map<string, string>();\n\n register(cst_type: CstType, definition_formal: string, alias: string): void {\n const normalized = normalizeExpression(definition_formal, cst_type);\n if (!normalized) {\n return;\n }\n this.byKey.set(formalDefinitionKey(cst_type, normalized), alias);\n }\n\n find(cst_type: CstType, definition_formal: string): string | null {\n const normalized = normalizeExpression(definition_formal, cst_type);\n if (!normalized) {\n return null;\n }\n return this.byKey.get(formalDefinitionKey(cst_type, normalized)) ?? null;\n }\n}\n\nfunction createFormalDefinitionIndex(schema: RSForm): FormalDefinitionIndex {\n const index = new FormalDefinitionIndex();\n for (const cst of schema.items) {\n index.register(cst.cst_type, cst.definition_formal, cst.alias);\n }\n return index;\n}\n\nfunction formalDefinitionKey(cst_type: CstType, normalized: string): string {\n return `${cst_type}\\0${normalized}`;\n}\n\nfunction instantiateTemplateItem(\n template: TemplateSourceFields,\n args: ArgumentValue[],\n alias: string\n): TemplateInstantiationItem {\n return {\n alias,\n cst_type: inferTemplatedType(template.cst_type, args),\n crucial: template.crucial,\n convention: template.convention,\n definition_formal: substituteTemplateArgs(template.definition_formal, argumentValuesToMapping(args)),\n definition_raw: template.definition_raw,\n term_raw: template.term_raw,\n term_forms: [...template.term_forms],\n typification_manual: template.typification_manual,\n value_is_property: template.value_is_property\n };\n}\n\nfunction bindingsFromCall(params: TemplateParam[], callArgs: string[], scope: AliasMapping): Map<string, string> {\n const bindings = new Map<string, string>();\n params.forEach((param, index) => {\n const value = resolveArgBinding(callArgs[index] ?? '', scope);\n if (value) {\n bindings.set(param.alias, value);\n }\n });\n return bindings;\n}\n\nfunction resolveArgBinding(argExpr: string, scope: AliasMapping): string | undefined {\n const scoped = substituteLocalAliases(argExpr, scope).trim();\n if (isGlobalAlias(scoped)) {\n return scoped;\n }\n return undefined;\n}\n\ntype MergeBindingsResult =\n | { ok: true; bindings: Map<string, string> }\n | { ok: false; conflict: { paramAlias: string; existing: string; incoming: string } };\n\nfunction mergeBindings(existing: Map<string, string> | undefined, incoming: Map<string, string>): MergeBindingsResult {\n const result = new Map(existing);\n for (const [alias, value] of incoming) {\n const existingValue = result.get(alias);\n if (existingValue === undefined) {\n result.set(alias, value);\n } else if (existingValue !== value) {\n return { ok: false, conflict: { paramAlias: alias, existing: existingValue, incoming: value } };\n }\n }\n return { ok: true, bindings: result };\n}\n\nfunction bindingMapToArgs(params: TemplateParam[], bindings: Map<string, string>): ArgumentValue[] {\n return params.map(param => ({\n alias: param.alias,\n typification: param.typification,\n value: bindings.get(param.alias)\n }));\n}\n\nfunction getTemplateParams(template: TemplateParamSourceFields): TemplateParam[] {\n const effectiveType = template.effectiveType;\n if (effectiveType && (effectiveType.typeID === TypeID.function || effectiveType.typeID === TypeID.predicate)) {\n return effectiveType.args.map(arg => ({\n alias: arg.alias,\n typification: labelType(arg.type)\n }));\n }\n const { head } = splitTemplateDefinition(template.definition_formal);\n if (!head) {\n return [];\n }\n return head.split(',').map(part => {\n const trimmed = part.trim();\n const separator = trimmed.indexOf('∈');\n if (separator === -1) {\n return { alias: trimmed, typification: '' };\n }\n return {\n alias: trimmed.slice(0, separator).trim(),\n typification: trimmed.slice(separator + 1).trim()\n };\n });\n}\n\nfunction extractFuncCalls(ast: AstNode, expression: string): FuncCallRef[] {\n const result: FuncCallRef[] = [];\n visitAstDFS(ast, node => {\n if (node.typeID !== TokenID.NT_FUNC_CALL || node.children.length < 1) {\n return;\n }\n const calleeNode = node.children[0];\n if (\n calleeNode.typeID !== TokenID.ID_FUNCTION &&\n calleeNode.typeID !== TokenID.ID_PREDICATE &&\n calleeNode.typeID !== TokenID.ID_GLOBAL\n ) {\n return;\n }\n const callee = expression.slice(calleeNode.from, calleeNode.to);\n if (!/^[FP]\\d+$/.test(callee)) {\n return;\n }\n result.push({\n callee,\n args: node.children.slice(1).map(child => expression.slice(child.from, child.to).trim())\n });\n });\n return result;\n}\n\nfunction topologicalSort(aliases: string[], refs: Map<string, Set<string>>): string[] {\n const remaining = new Set(aliases);\n const sorted: string[] = [];\n while (remaining.size > 0) {\n const ready = [...remaining].filter(alias => {\n const deps = refs.get(alias) ?? new Set<string>();\n return [...deps].every(dep => !remaining.has(dep));\n });\n if (ready.length === 0) {\n return [...remaining, ...sorted].reverse();\n }\n ready.sort();\n for (const alias of ready) {\n sorted.push(alias);\n remaining.delete(alias);\n }\n }\n return sorted;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+GA,SAAgB,0BAA0B,OAA8D;CACtG,OAAO,IAAI,6BAA6B,KAAK,CAAC,CAAC,KAAK;AACtD;;;;;;AAOA,IAAa,+BAAb,MAA0C;CACxC;CACA;CACA;CACA;CACA;CACA;CACA,8BAA+B,IAAI,IAAiC;CACpE,0BAA2B,IAAI,IAAyB;CACxD,kBAA0D;;CAG1D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AQ;EACvB,IAAI,KAAK,WAAW,QAAQ,gBAAgB,KAAK,SAAS,SAAS,GACjE;EAEF,MAAM,aAAa,KAAK,SAAS;EACjC,IACE,WAAW,WAAW,QAAQ,eAC9B,WAAW,WAAW,QAAQ,gBAC9B,WAAW,WAAW,QAAQ,WAE9B;EAEF,MAAM,SAAS,WAAW,MAAM,WAAW,MAAM,WAAW,EAAE;EAC9D,IAAI,CAAC,YAAY,KAAK,MAAM,GAC1B;EAEF,OAAO,KAAK;GACV;GACA,MAAM,KAAK,SAAS,MAAM,CAAC,CAAC,CAAC,KAAI,UAAS,WAAW,MAAM,MAAM,MAAM,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC;EACzF,CAAC;CACH,CAAC;CACD,OAAO;AACT;AAEA,SAAS,gBAAgB,SAAmB,MAA0C;CACpF,MAAM,YAAY,IAAI,IAAI,OAAO;CACjC,MAAM,SAAmB,CAAC;CAC1B,OAAO,UAAU,OAAO,GAAG;EACzB,MAAM,QAAQ,CAAC,GAAG,SAAS,CAAC,CAAC,QAAO,UAAS;GAE3C,OAAO,CAAC,GADK,KAAK,IAAI,KAAK,qBAAK,IAAI,IAAY,CACjC,CAAC,CAAC,OAAM,QAAO,CAAC,UAAU,IAAI,GAAG,CAAC;EACnD,CAAC;EACD,IAAI,MAAM,WAAW,GACnB,OAAO,CAAC,GAAG,WAAW,GAAG,MAAM,CAAC,CAAC,QAAQ;EAE3C,MAAM,KAAK;EACX,KAAK,MAAM,SAAS,OAAO;GACzB,OAAO,KAAK,KAAK;GACjB,UAAU,OAAO,KAAK;EACxB;CACF;CACA,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as LibraryItem } from "../library-CYun28Xz.js";
|
|
2
|
-
import { S as RSForm, v as Constituenta, w as Substitution } from "../diagnostics-
|
|
2
|
+
import { S as RSForm, v as Constituenta, w as Substitution } from "../diagnostics-DsEhmFh0.js";
|
|
3
3
|
import { NodeType, OperationSchema, SubstitutionErrorDescription } from "./oss.js";
|
|
4
4
|
|
|
5
5
|
//#region src/library/oss-api.d.ts
|