@living-architecture/riviere-cli 0.8.7 → 0.8.8
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/bin.js +217 -101
- package/dist/index.js +216 -100
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -5388,20 +5388,20 @@ var require_dependencies = __commonJS({
|
|
|
5388
5388
|
const deps = propertyDeps[prop];
|
|
5389
5389
|
if (deps.length === 0)
|
|
5390
5390
|
continue;
|
|
5391
|
-
const
|
|
5391
|
+
const hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties);
|
|
5392
5392
|
cxt.setParams({
|
|
5393
5393
|
property: prop,
|
|
5394
5394
|
depsCount: deps.length,
|
|
5395
5395
|
deps: deps.join(", ")
|
|
5396
5396
|
});
|
|
5397
5397
|
if (it.allErrors) {
|
|
5398
|
-
gen.if(
|
|
5398
|
+
gen.if(hasProperty, () => {
|
|
5399
5399
|
for (const depProp of deps) {
|
|
5400
5400
|
(0, code_1.checkReportMissingProp)(cxt, depProp);
|
|
5401
5401
|
}
|
|
5402
5402
|
});
|
|
5403
5403
|
} else {
|
|
5404
|
-
gen.if((0, codegen_1._)`${
|
|
5404
|
+
gen.if((0, codegen_1._)`${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps, missing)})`);
|
|
5405
5405
|
(0, code_1.reportMissingProp)(cxt, missing);
|
|
5406
5406
|
gen.else();
|
|
5407
5407
|
}
|
|
@@ -25289,21 +25289,9 @@ var COMPONENT_TYPES = [
|
|
|
25289
25289
|
"domainOp",
|
|
25290
25290
|
"event",
|
|
25291
25291
|
"eventHandler",
|
|
25292
|
+
"eventPublisher",
|
|
25292
25293
|
"ui"
|
|
25293
25294
|
];
|
|
25294
|
-
var FIND_TARGETS = ["classes", "methods", "functions"];
|
|
25295
|
-
function hasProperty(obj, key) {
|
|
25296
|
-
return key in obj;
|
|
25297
|
-
}
|
|
25298
|
-
function isDetectionRule(rule) {
|
|
25299
|
-
if (typeof rule !== "object" || rule === null) {
|
|
25300
|
-
return false;
|
|
25301
|
-
}
|
|
25302
|
-
if (!hasProperty(rule, "find") || !hasProperty(rule, "where")) {
|
|
25303
|
-
return false;
|
|
25304
|
-
}
|
|
25305
|
-
return typeof rule.find === "string" && FIND_TARGETS.includes(rule.find);
|
|
25306
|
-
}
|
|
25307
25295
|
function extractComponents(project, sourceFilePaths, config2, globMatcher, configDir) {
|
|
25308
25296
|
return sourceFilePaths.flatMap((filePath) => extractFromFile(project, filePath, config2, globMatcher, configDir));
|
|
25309
25297
|
}
|
|
@@ -25343,7 +25331,7 @@ function extractWithRule(sourceFile, filePath, domain2, componentType, rule) {
|
|
|
25343
25331
|
}
|
|
25344
25332
|
function extractComponentType(sourceFile, filePath, module, componentType) {
|
|
25345
25333
|
const rule = module[componentType];
|
|
25346
|
-
if (!
|
|
25334
|
+
if (!("find" in rule)) {
|
|
25347
25335
|
return [];
|
|
25348
25336
|
}
|
|
25349
25337
|
return extractWithRule(sourceFile, filePath, module.name, componentType, rule);
|
|
@@ -25565,6 +25553,18 @@ function extractString(expression) {
|
|
|
25565
25553
|
function extractNumber(expression) {
|
|
25566
25554
|
return Number(expression.getText());
|
|
25567
25555
|
}
|
|
25556
|
+
function extractStringArray(expression) {
|
|
25557
|
+
const arrayLiteral = expression.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);
|
|
25558
|
+
const elements = arrayLiteral.getElements();
|
|
25559
|
+
const values = [];
|
|
25560
|
+
for (const element of elements) {
|
|
25561
|
+
if (element.getKind() !== SyntaxKind.StringLiteral) {
|
|
25562
|
+
return void 0;
|
|
25563
|
+
}
|
|
25564
|
+
values.push(element.asKindOrThrow(SyntaxKind.StringLiteral).getLiteralValue());
|
|
25565
|
+
}
|
|
25566
|
+
return values;
|
|
25567
|
+
}
|
|
25568
25568
|
function buildExtractionResult(expression) {
|
|
25569
25569
|
const syntaxKind = expression.getKind();
|
|
25570
25570
|
switch (syntaxKind) {
|
|
@@ -25588,6 +25588,16 @@ function buildExtractionResult(expression) {
|
|
|
25588
25588
|
kind: "boolean",
|
|
25589
25589
|
value: false
|
|
25590
25590
|
};
|
|
25591
|
+
case SyntaxKind.ArrayLiteralExpression: {
|
|
25592
|
+
const values = extractStringArray(expression);
|
|
25593
|
+
if (values === void 0) {
|
|
25594
|
+
return void 0;
|
|
25595
|
+
}
|
|
25596
|
+
return {
|
|
25597
|
+
kind: "string[]",
|
|
25598
|
+
value: values
|
|
25599
|
+
};
|
|
25600
|
+
}
|
|
25591
25601
|
default:
|
|
25592
25602
|
return void 0;
|
|
25593
25603
|
}
|
|
@@ -25596,7 +25606,7 @@ function throwMissingInitializer(file2, line) {
|
|
|
25596
25606
|
throw new ExtractionError("No initializer found", file2, line);
|
|
25597
25607
|
}
|
|
25598
25608
|
function throwNonLiteralValue(expression, file2, line) {
|
|
25599
|
-
throw new ExtractionError(`Non-literal value detected (${expression.getKindName()}): ${expression.getText()}. Only inline literals (strings, numbers, booleans) are supported`, file2, line);
|
|
25609
|
+
throw new ExtractionError(`Non-literal value detected (${expression.getKindName()}): ${expression.getText()}. Only inline literals (strings, numbers, booleans, string arrays) are supported`, file2, line);
|
|
25600
25610
|
}
|
|
25601
25611
|
function extractLiteralValue(expression, file2, line) {
|
|
25602
25612
|
if (expression === void 0) {
|
|
@@ -27608,64 +27618,120 @@ function resolveTypeThroughInterface(typeName, project, componentIndex, options)
|
|
|
27608
27618
|
uncertain: interfaceResult.typeDefinedInSource ? interfaceResult.reason : void 0
|
|
27609
27619
|
};
|
|
27610
27620
|
}
|
|
27611
|
-
function
|
|
27621
|
+
function findClassByNameInProject(project, typeName) {
|
|
27612
27622
|
for (const sourceFile of project.getSourceFiles()) {
|
|
27613
27623
|
for (const classDecl of sourceFile.getClasses()) {
|
|
27614
|
-
if (classDecl.getName()
|
|
27615
|
-
|
|
27624
|
+
if (classDecl.getType().getSymbol()?.getName() === typeName) {
|
|
27625
|
+
return {
|
|
27626
|
+
classDecl,
|
|
27627
|
+
sourceFile
|
|
27628
|
+
};
|
|
27616
27629
|
}
|
|
27617
|
-
return {
|
|
27618
|
-
method: classDecl.getMethod(methodName),
|
|
27619
|
-
classFound: true
|
|
27620
|
-
};
|
|
27621
27630
|
}
|
|
27622
27631
|
}
|
|
27632
|
+
return void 0;
|
|
27633
|
+
}
|
|
27634
|
+
function resolveContainerMethod(project, typeName, calledMethodName, componentIndex) {
|
|
27635
|
+
const lookup = findClassByNameInProject(project, typeName);
|
|
27636
|
+
if (lookup === void 0) {
|
|
27637
|
+
return void 0;
|
|
27638
|
+
}
|
|
27639
|
+
const method = lookup.classDecl.getMethod(calledMethodName);
|
|
27640
|
+
if (method === void 0) {
|
|
27641
|
+
return void 0;
|
|
27642
|
+
}
|
|
27643
|
+
return componentIndex.getComponentByLocation(lookup.sourceFile.getFilePath(), method.getStartLineNumber());
|
|
27644
|
+
}
|
|
27645
|
+
function findMethodInProject(project, typeName, methodName) {
|
|
27646
|
+
const lookup = findClassByNameInProject(project, typeName);
|
|
27647
|
+
if (lookup === void 0) {
|
|
27648
|
+
return {
|
|
27649
|
+
method: void 0,
|
|
27650
|
+
classFound: false
|
|
27651
|
+
};
|
|
27652
|
+
}
|
|
27623
27653
|
return {
|
|
27624
|
-
method:
|
|
27625
|
-
classFound:
|
|
27654
|
+
method: lookup.classDecl.getMethod(methodName),
|
|
27655
|
+
classFound: true
|
|
27626
27656
|
};
|
|
27627
27657
|
}
|
|
27628
27658
|
|
|
27629
27659
|
// ../riviere-extract-ts/dist/domain/connection-detection/call-graph/trace-calls.js
|
|
27630
|
-
function
|
|
27631
|
-
const
|
|
27632
|
-
|
|
27633
|
-
|
|
27634
|
-
|
|
27635
|
-
|
|
27636
|
-
|
|
27637
|
-
}
|
|
27638
|
-
|
|
27639
|
-
|
|
27640
|
-
|
|
27641
|
-
|
|
27642
|
-
|
|
27643
|
-
|
|
27644
|
-
|
|
27645
|
-
|
|
27646
|
-
|
|
27647
|
-
|
|
27648
|
-
|
|
27649
|
-
|
|
27650
|
-
|
|
27651
|
-
|
|
27652
|
-
|
|
27653
|
-
|
|
27654
|
-
|
|
27655
|
-
|
|
27656
|
-
|
|
27657
|
-
|
|
27658
|
-
|
|
27659
|
-
|
|
27660
|
-
|
|
27661
|
-
uncertainResults.push({
|
|
27662
|
-
source: sourceComponent,
|
|
27663
|
-
reason: uncertain,
|
|
27664
|
-
callSite: originCallSite
|
|
27660
|
+
function resolveComponentTarget(typeName, calledMethodName, ctx) {
|
|
27661
|
+
const { component: directMatch, resolvedTypeName, uncertain } = resolveTypeThroughInterface(typeName, ctx.project, ctx.componentIndex, ctx.options);
|
|
27662
|
+
if (directMatch !== void 0) {
|
|
27663
|
+
return {
|
|
27664
|
+
target: directMatch,
|
|
27665
|
+
resolvedTypeName: void 0,
|
|
27666
|
+
uncertain: void 0
|
|
27667
|
+
};
|
|
27668
|
+
}
|
|
27669
|
+
const containerTarget = resolveContainerMethod(ctx.project, resolvedTypeName ?? typeName, calledMethodName, ctx.componentIndex);
|
|
27670
|
+
return {
|
|
27671
|
+
target: containerTarget,
|
|
27672
|
+
resolvedTypeName,
|
|
27673
|
+
uncertain
|
|
27674
|
+
};
|
|
27675
|
+
}
|
|
27676
|
+
function traceCallExpression(callExpr, ctx) {
|
|
27677
|
+
const sourceFile = callExpr.getSourceFile();
|
|
27678
|
+
const typeResult = resolveCallExpressionReceiverType(callExpr, sourceFile, { strict: ctx.options.strict });
|
|
27679
|
+
if (!typeResult.resolved) {
|
|
27680
|
+
return;
|
|
27681
|
+
}
|
|
27682
|
+
const typeName = typeResult.typeName;
|
|
27683
|
+
const calledMethodName = getCalledMethodName(callExpr);
|
|
27684
|
+
const outcome = resolveComponentTarget(typeName, calledMethodName, ctx);
|
|
27685
|
+
if (outcome.target !== void 0) {
|
|
27686
|
+
if (componentIdentity(ctx.sourceComponent) !== componentIdentity(outcome.target)) {
|
|
27687
|
+
ctx.results.push({
|
|
27688
|
+
source: ctx.sourceComponent,
|
|
27689
|
+
target: outcome.target,
|
|
27690
|
+
callSite: ctx.originCallSite
|
|
27665
27691
|
});
|
|
27666
27692
|
}
|
|
27693
|
+
return;
|
|
27694
|
+
}
|
|
27695
|
+
traceIntoNonComponent(typeName, calledMethodName, outcome, ctx);
|
|
27696
|
+
}
|
|
27697
|
+
function traceIntoNonComponent(typeName, calledMethodName, outcome, ctx) {
|
|
27698
|
+
const traceTypeName = outcome.resolvedTypeName ?? typeName;
|
|
27699
|
+
const visitKey = `${traceTypeName}.${calledMethodName}`;
|
|
27700
|
+
if (ctx.visited.has(visitKey)) {
|
|
27701
|
+
return;
|
|
27702
|
+
}
|
|
27703
|
+
ctx.visited.add(visitKey);
|
|
27704
|
+
const { method: resolvedMethod, classFound } = findMethodInProject(ctx.project, traceTypeName, calledMethodName);
|
|
27705
|
+
if (resolvedMethod !== void 0) {
|
|
27706
|
+
traceBody(resolvedMethod, ctx);
|
|
27707
|
+
return;
|
|
27708
|
+
}
|
|
27709
|
+
if (!classFound && outcome.uncertain !== void 0) {
|
|
27710
|
+
ctx.uncertainResults.push({
|
|
27711
|
+
source: ctx.sourceComponent,
|
|
27712
|
+
reason: outcome.uncertain,
|
|
27713
|
+
callSite: ctx.originCallSite
|
|
27714
|
+
});
|
|
27715
|
+
}
|
|
27716
|
+
}
|
|
27717
|
+
function traceBody(body, ctx) {
|
|
27718
|
+
const callExpressions = body.getDescendantsOfKind(SyntaxKind5.CallExpression);
|
|
27719
|
+
for (const callExpr of callExpressions) {
|
|
27720
|
+
traceCallExpression(callExpr, ctx);
|
|
27667
27721
|
}
|
|
27668
27722
|
}
|
|
27723
|
+
function traceCallsInBody(body, project, componentIndex, sourceComponent, originCallSite, visited, results, uncertainResults, options) {
|
|
27724
|
+
traceBody(body, {
|
|
27725
|
+
project,
|
|
27726
|
+
componentIndex,
|
|
27727
|
+
sourceComponent,
|
|
27728
|
+
originCallSite,
|
|
27729
|
+
visited,
|
|
27730
|
+
results,
|
|
27731
|
+
uncertainResults,
|
|
27732
|
+
options
|
|
27733
|
+
});
|
|
27734
|
+
}
|
|
27669
27735
|
function findClassInProject(project, component) {
|
|
27670
27736
|
const sourceFile = project.getSourceFile(component.location.file);
|
|
27671
27737
|
if (sourceFile === void 0) {
|
|
@@ -27673,6 +27739,29 @@ function findClassInProject(project, component) {
|
|
|
27673
27739
|
}
|
|
27674
27740
|
return sourceFile.getClasses().find((c) => c.getStartLineNumber() === component.location.line);
|
|
27675
27741
|
}
|
|
27742
|
+
function findMethodLevelComponent(project, component) {
|
|
27743
|
+
const sourceFile = project.getSourceFile(component.location.file);
|
|
27744
|
+
if (sourceFile === void 0) {
|
|
27745
|
+
return void 0;
|
|
27746
|
+
}
|
|
27747
|
+
for (const classDecl of sourceFile.getClasses()) {
|
|
27748
|
+
const method = classDecl.getMethods().find((m) => m.getStartLineNumber() === component.location.line);
|
|
27749
|
+
if (method !== void 0) {
|
|
27750
|
+
return {
|
|
27751
|
+
classDecl,
|
|
27752
|
+
method
|
|
27753
|
+
};
|
|
27754
|
+
}
|
|
27755
|
+
}
|
|
27756
|
+
return void 0;
|
|
27757
|
+
}
|
|
27758
|
+
function findFunctionInProject(project, component) {
|
|
27759
|
+
const sourceFile = project.getSourceFile(component.location.file);
|
|
27760
|
+
if (sourceFile === void 0) {
|
|
27761
|
+
return void 0;
|
|
27762
|
+
}
|
|
27763
|
+
return sourceFile.getFunctions().find((f) => f.getStartLineNumber() === component.location.line);
|
|
27764
|
+
}
|
|
27676
27765
|
|
|
27677
27766
|
// ../riviere-extract-ts/dist/domain/connection-detection/call-graph/deduplicate-links.js
|
|
27678
27767
|
function linkKey(source, target, type) {
|
|
@@ -27761,8 +27850,26 @@ function processCallExpression(callExpr, component, methodName, project, compone
|
|
|
27761
27850
|
}
|
|
27762
27851
|
return;
|
|
27763
27852
|
}
|
|
27853
|
+
const containerTarget = resolveContainerMethod(project, resolvedTypeName ?? typeName, calledMethodName, componentIndex);
|
|
27854
|
+
if (containerTarget !== void 0) {
|
|
27855
|
+
if (componentIdentity(component) !== componentIdentity(containerTarget)) {
|
|
27856
|
+
rawLinks.push({
|
|
27857
|
+
source: component,
|
|
27858
|
+
target: containerTarget,
|
|
27859
|
+
callSite: currentCallSite
|
|
27860
|
+
});
|
|
27861
|
+
}
|
|
27862
|
+
return;
|
|
27863
|
+
}
|
|
27764
27864
|
traceNonComponent(project, componentIndex, component, resolvedTypeName ?? typeName, calledMethodName, currentCallSite, rawLinks, uncertainLinks, uncertain, options);
|
|
27765
27865
|
}
|
|
27866
|
+
function processFunction(funcDecl, component, project, componentIndex, rawLinks, uncertainLinks, options) {
|
|
27867
|
+
const functionName = funcDecl.getNameOrThrow();
|
|
27868
|
+
const callExpressions = funcDecl.getDescendantsOfKind(SyntaxKind6.CallExpression);
|
|
27869
|
+
for (const callExpr of callExpressions) {
|
|
27870
|
+
processCallExpression(callExpr, component, functionName, project, componentIndex, rawLinks, uncertainLinks, options);
|
|
27871
|
+
}
|
|
27872
|
+
}
|
|
27766
27873
|
function processMethod(method, component, project, componentIndex, rawLinks, uncertainLinks, options) {
|
|
27767
27874
|
const methodName = method.getName();
|
|
27768
27875
|
const callExpressions = method.getDescendantsOfKind(SyntaxKind6.CallExpression);
|
|
@@ -27775,11 +27882,20 @@ function buildCallGraph(project, components, componentIndex, options) {
|
|
|
27775
27882
|
const uncertainLinks = [];
|
|
27776
27883
|
for (const component of components) {
|
|
27777
27884
|
const classDecl = findClassInProject(project, component);
|
|
27778
|
-
if (classDecl
|
|
27885
|
+
if (classDecl !== void 0) {
|
|
27886
|
+
for (const method of classDecl.getMethods()) {
|
|
27887
|
+
processMethod(method, component, project, componentIndex, rawLinks, uncertainLinks, options);
|
|
27888
|
+
}
|
|
27889
|
+
continue;
|
|
27890
|
+
}
|
|
27891
|
+
const methodTarget = findMethodLevelComponent(project, component);
|
|
27892
|
+
if (methodTarget !== void 0) {
|
|
27893
|
+
processMethod(methodTarget.method, component, project, componentIndex, rawLinks, uncertainLinks, options);
|
|
27779
27894
|
continue;
|
|
27780
27895
|
}
|
|
27781
|
-
|
|
27782
|
-
|
|
27896
|
+
const funcDecl = findFunctionInProject(project, component);
|
|
27897
|
+
if (funcDecl !== void 0) {
|
|
27898
|
+
processFunction(funcDecl, component, project, componentIndex, rawLinks, uncertainLinks, options);
|
|
27783
27899
|
}
|
|
27784
27900
|
}
|
|
27785
27901
|
return deduplicateLinks(rawLinks, uncertainLinks);
|
|
@@ -27808,6 +27924,15 @@ function detectPublishConnections(project, components, options) {
|
|
|
27808
27924
|
return publishers.flatMap((publisher) => extractPublisherLinks(project, publisher, events, options));
|
|
27809
27925
|
}
|
|
27810
27926
|
function extractPublisherLinks(project, publisher, events, options) {
|
|
27927
|
+
const publishedEventType = publisher.metadata["publishedEventType"];
|
|
27928
|
+
if (typeof publishedEventType === "string") {
|
|
27929
|
+
const sourceLocation = {
|
|
27930
|
+
repository: "",
|
|
27931
|
+
filePath: publisher.location.file,
|
|
27932
|
+
lineNumber: publisher.location.line
|
|
27933
|
+
};
|
|
27934
|
+
return resolvePublishTarget(publisher, publishedEventType, events, options, sourceLocation);
|
|
27935
|
+
}
|
|
27811
27936
|
const classDecl = findClassInProject(project, publisher);
|
|
27812
27937
|
if (classDecl === void 0) {
|
|
27813
27938
|
return [];
|
|
@@ -27960,7 +28085,7 @@ function detectConnections(project, components, options, globMatcher) {
|
|
|
27960
28085
|
const componentIndex = new ComponentIndex(components);
|
|
27961
28086
|
const sourceFilePaths = computeFilteredFilePaths(project, options.moduleGlobs, globMatcher);
|
|
27962
28087
|
const setupMs = performance.now() - setupStart;
|
|
27963
|
-
const strict =
|
|
28088
|
+
const strict = options.allowIncomplete !== true;
|
|
27964
28089
|
const callGraphStart = performance.now();
|
|
27965
28090
|
const syncLinks = buildCallGraph(project, components, componentIndex, {
|
|
27966
28091
|
strict,
|
|
@@ -27990,12 +28115,6 @@ function findMatchingModule2(filePath, modules, globMatcher, configDir) {
|
|
|
27990
28115
|
const pathToMatch = posix2.relative(configDir.replaceAll(/\\+/g, "/"), normalized);
|
|
27991
28116
|
return modules.find((m) => globMatcher(pathToMatch, m.path));
|
|
27992
28117
|
}
|
|
27993
|
-
function isDetectionRule2(rule) {
|
|
27994
|
-
if (typeof rule !== "object" || rule === null) {
|
|
27995
|
-
return false;
|
|
27996
|
-
}
|
|
27997
|
-
return "find" in rule && "where" in rule;
|
|
27998
|
-
}
|
|
27999
28118
|
function getBuiltInRule(module, componentType) {
|
|
28000
28119
|
const ruleMap = {
|
|
28001
28120
|
api: module.api,
|
|
@@ -28007,10 +28126,10 @@ function getBuiltInRule(module, componentType) {
|
|
|
28007
28126
|
ui: module.ui
|
|
28008
28127
|
};
|
|
28009
28128
|
const rule = ruleMap[componentType];
|
|
28010
|
-
if (
|
|
28011
|
-
return
|
|
28129
|
+
if (rule === void 0 || !("find" in rule)) {
|
|
28130
|
+
return void 0;
|
|
28012
28131
|
}
|
|
28013
|
-
return
|
|
28132
|
+
return rule;
|
|
28014
28133
|
}
|
|
28015
28134
|
function findDetectionRule(module, componentType) {
|
|
28016
28135
|
const builtInTypes = [
|
|
@@ -28019,6 +28138,7 @@ function findDetectionRule(module, componentType) {
|
|
|
28019
28138
|
"domainOp",
|
|
28020
28139
|
"event",
|
|
28021
28140
|
"eventHandler",
|
|
28141
|
+
"eventPublisher",
|
|
28022
28142
|
"ui"
|
|
28023
28143
|
];
|
|
28024
28144
|
if (builtInTypes.includes(componentType)) {
|
|
@@ -28026,24 +28146,6 @@ function findDetectionRule(module, componentType) {
|
|
|
28026
28146
|
}
|
|
28027
28147
|
return module.customTypes?.[componentType];
|
|
28028
28148
|
}
|
|
28029
|
-
function isLiteralRule(rule) {
|
|
28030
|
-
return "literal" in rule;
|
|
28031
|
-
}
|
|
28032
|
-
function isFromClassNameRule(rule) {
|
|
28033
|
-
return "fromClassName" in rule;
|
|
28034
|
-
}
|
|
28035
|
-
function isFromFilePathRule(rule) {
|
|
28036
|
-
return "fromFilePath" in rule;
|
|
28037
|
-
}
|
|
28038
|
-
function isFromPropertyRule(rule) {
|
|
28039
|
-
return "fromProperty" in rule;
|
|
28040
|
-
}
|
|
28041
|
-
function isFromMethodNameRule(rule) {
|
|
28042
|
-
return "fromMethodName" in rule;
|
|
28043
|
-
}
|
|
28044
|
-
function isFromGenericArgRule(rule) {
|
|
28045
|
-
return "fromGenericArg" in rule;
|
|
28046
|
-
}
|
|
28047
28149
|
function findClassAtLine(project, draft) {
|
|
28048
28150
|
const sourceFile = project.getSourceFile(draft.location.file);
|
|
28049
28151
|
if (sourceFile === void 0) {
|
|
@@ -28084,29 +28186,44 @@ function findContainingClass(project, draft) {
|
|
|
28084
28186
|
throw new ExtractionError(`No containing class found for method at line ${methodLine}`, draft.location.file, draft.location.line);
|
|
28085
28187
|
}
|
|
28086
28188
|
function evaluateClassRule(rule, classDecl) {
|
|
28087
|
-
if (
|
|
28189
|
+
if ("fromClassName" in rule) {
|
|
28088
28190
|
return evaluateFromClassNameRule(rule, classDecl);
|
|
28089
28191
|
}
|
|
28090
|
-
if (!
|
|
28192
|
+
if (!("fromProperty" in rule)) {
|
|
28091
28193
|
throw new ExtractionError("Unsupported extraction rule type for class-based component", classDecl.getSourceFile().getFilePath(), classDecl.getStartLineNumber());
|
|
28092
28194
|
}
|
|
28093
28195
|
return evaluateFromPropertyRule(rule, classDecl);
|
|
28094
28196
|
}
|
|
28095
28197
|
function evaluateRule(rule, draft, project) {
|
|
28096
|
-
if (
|
|
28198
|
+
if ("literal" in rule) {
|
|
28097
28199
|
return evaluateLiteralRule(rule);
|
|
28098
28200
|
}
|
|
28099
|
-
if (
|
|
28201
|
+
if ("fromFilePath" in rule) {
|
|
28100
28202
|
return evaluateFromFilePathRule(rule, draft.location.file);
|
|
28101
28203
|
}
|
|
28102
|
-
if (
|
|
28204
|
+
if ("fromMethodName" in rule) {
|
|
28103
28205
|
const methodDecl = findMethodAtLine(project, draft);
|
|
28104
28206
|
return evaluateFromMethodNameRule(rule, methodDecl);
|
|
28105
28207
|
}
|
|
28106
|
-
if (
|
|
28208
|
+
if ("fromGenericArg" in rule) {
|
|
28107
28209
|
const classDecl2 = findContainingClass(project, draft);
|
|
28108
28210
|
return evaluateFromGenericArgRule(rule, classDecl2);
|
|
28109
28211
|
}
|
|
28212
|
+
if ("fromParameterType" in rule) {
|
|
28213
|
+
const methodDecl = findMethodAtLine(project, draft);
|
|
28214
|
+
const params = methodDecl.getParameters();
|
|
28215
|
+
const position = rule.fromParameterType.position;
|
|
28216
|
+
const param = params[position];
|
|
28217
|
+
if (param === void 0) {
|
|
28218
|
+
throw new ExtractionError(`Parameter position ${position} out of bounds. Method has ${params.length} parameter(s)`, draft.location.file, draft.location.line);
|
|
28219
|
+
}
|
|
28220
|
+
const typeName = param.getTypeNode()?.getText() ?? "unknown";
|
|
28221
|
+
const transform2 = rule.fromParameterType.transform;
|
|
28222
|
+
if (transform2 === void 0) {
|
|
28223
|
+
return { value: typeName };
|
|
28224
|
+
}
|
|
28225
|
+
return { value: applyTransforms(typeName, transform2) };
|
|
28226
|
+
}
|
|
28110
28227
|
const classDecl = findClassAtLine(project, draft);
|
|
28111
28228
|
return evaluateClassRule(rule, classDecl);
|
|
28112
28229
|
}
|
|
@@ -29610,7 +29727,7 @@ function parsePackageJson(pkg) {
|
|
|
29610
29727
|
}
|
|
29611
29728
|
function loadPackageJson() {
|
|
29612
29729
|
if (true) {
|
|
29613
|
-
return { version: "0.8.
|
|
29730
|
+
return { version: "0.8.7" };
|
|
29614
29731
|
}
|
|
29615
29732
|
const require2 = createRequire2(import.meta.url);
|
|
29616
29733
|
return parsePackageJson(require2("../../package.json"));
|
|
@@ -29659,7 +29776,6 @@ program.parseAsync().catch((error48) => {
|
|
|
29659
29776
|
/* istanbul ignore next -- @preserve: unreachable with valid Predicate type */
|
|
29660
29777
|
/* istanbul ignore next -- @preserve: Anonymous declarations have undefined names; predicate correctly returns false */
|
|
29661
29778
|
/* istanbul ignore next -- @preserve: Methods in object literals have non-class parents; predicate correctly returns false */
|
|
29662
|
-
/* istanbul ignore if -- @preserve: unreachable with typed ResolvedExtractionConfig; defensive guard */
|
|
29663
29779
|
/* istanbul ignore else -- @preserve: false branch is unreachable; FindTarget is exhaustive */
|
|
29664
29780
|
/* istanbul ignore next -- @preserve: unreachable with valid FindTarget type; defensive fallback */
|
|
29665
29781
|
/* v8 ignore next -- @preserve: getExtends() !== undefined guarantees getBaseClass() returns a value */
|
package/dist/index.js
CHANGED
|
@@ -5387,20 +5387,20 @@ var require_dependencies = __commonJS({
|
|
|
5387
5387
|
const deps = propertyDeps[prop];
|
|
5388
5388
|
if (deps.length === 0)
|
|
5389
5389
|
continue;
|
|
5390
|
-
const
|
|
5390
|
+
const hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties);
|
|
5391
5391
|
cxt.setParams({
|
|
5392
5392
|
property: prop,
|
|
5393
5393
|
depsCount: deps.length,
|
|
5394
5394
|
deps: deps.join(", ")
|
|
5395
5395
|
});
|
|
5396
5396
|
if (it.allErrors) {
|
|
5397
|
-
gen.if(
|
|
5397
|
+
gen.if(hasProperty, () => {
|
|
5398
5398
|
for (const depProp of deps) {
|
|
5399
5399
|
(0, code_1.checkReportMissingProp)(cxt, depProp);
|
|
5400
5400
|
}
|
|
5401
5401
|
});
|
|
5402
5402
|
} else {
|
|
5403
|
-
gen.if((0, codegen_1._)`${
|
|
5403
|
+
gen.if((0, codegen_1._)`${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps, missing)})`);
|
|
5404
5404
|
(0, code_1.reportMissingProp)(cxt, missing);
|
|
5405
5405
|
gen.else();
|
|
5406
5406
|
}
|
|
@@ -25315,21 +25315,9 @@ var COMPONENT_TYPES = [
|
|
|
25315
25315
|
"domainOp",
|
|
25316
25316
|
"event",
|
|
25317
25317
|
"eventHandler",
|
|
25318
|
+
"eventPublisher",
|
|
25318
25319
|
"ui"
|
|
25319
25320
|
];
|
|
25320
|
-
var FIND_TARGETS = ["classes", "methods", "functions"];
|
|
25321
|
-
function hasProperty(obj, key) {
|
|
25322
|
-
return key in obj;
|
|
25323
|
-
}
|
|
25324
|
-
function isDetectionRule(rule) {
|
|
25325
|
-
if (typeof rule !== "object" || rule === null) {
|
|
25326
|
-
return false;
|
|
25327
|
-
}
|
|
25328
|
-
if (!hasProperty(rule, "find") || !hasProperty(rule, "where")) {
|
|
25329
|
-
return false;
|
|
25330
|
-
}
|
|
25331
|
-
return typeof rule.find === "string" && FIND_TARGETS.includes(rule.find);
|
|
25332
|
-
}
|
|
25333
25321
|
function extractComponents(project, sourceFilePaths, config2, globMatcher, configDir) {
|
|
25334
25322
|
return sourceFilePaths.flatMap((filePath) => extractFromFile(project, filePath, config2, globMatcher, configDir));
|
|
25335
25323
|
}
|
|
@@ -25369,7 +25357,7 @@ function extractWithRule(sourceFile, filePath, domain2, componentType, rule) {
|
|
|
25369
25357
|
}
|
|
25370
25358
|
function extractComponentType(sourceFile, filePath, module, componentType) {
|
|
25371
25359
|
const rule = module[componentType];
|
|
25372
|
-
if (!
|
|
25360
|
+
if (!("find" in rule)) {
|
|
25373
25361
|
return [];
|
|
25374
25362
|
}
|
|
25375
25363
|
return extractWithRule(sourceFile, filePath, module.name, componentType, rule);
|
|
@@ -25591,6 +25579,18 @@ function extractString(expression) {
|
|
|
25591
25579
|
function extractNumber(expression) {
|
|
25592
25580
|
return Number(expression.getText());
|
|
25593
25581
|
}
|
|
25582
|
+
function extractStringArray(expression) {
|
|
25583
|
+
const arrayLiteral = expression.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);
|
|
25584
|
+
const elements = arrayLiteral.getElements();
|
|
25585
|
+
const values = [];
|
|
25586
|
+
for (const element of elements) {
|
|
25587
|
+
if (element.getKind() !== SyntaxKind.StringLiteral) {
|
|
25588
|
+
return void 0;
|
|
25589
|
+
}
|
|
25590
|
+
values.push(element.asKindOrThrow(SyntaxKind.StringLiteral).getLiteralValue());
|
|
25591
|
+
}
|
|
25592
|
+
return values;
|
|
25593
|
+
}
|
|
25594
25594
|
function buildExtractionResult(expression) {
|
|
25595
25595
|
const syntaxKind = expression.getKind();
|
|
25596
25596
|
switch (syntaxKind) {
|
|
@@ -25614,6 +25614,16 @@ function buildExtractionResult(expression) {
|
|
|
25614
25614
|
kind: "boolean",
|
|
25615
25615
|
value: false
|
|
25616
25616
|
};
|
|
25617
|
+
case SyntaxKind.ArrayLiteralExpression: {
|
|
25618
|
+
const values = extractStringArray(expression);
|
|
25619
|
+
if (values === void 0) {
|
|
25620
|
+
return void 0;
|
|
25621
|
+
}
|
|
25622
|
+
return {
|
|
25623
|
+
kind: "string[]",
|
|
25624
|
+
value: values
|
|
25625
|
+
};
|
|
25626
|
+
}
|
|
25617
25627
|
default:
|
|
25618
25628
|
return void 0;
|
|
25619
25629
|
}
|
|
@@ -25622,7 +25632,7 @@ function throwMissingInitializer(file2, line) {
|
|
|
25622
25632
|
throw new ExtractionError("No initializer found", file2, line);
|
|
25623
25633
|
}
|
|
25624
25634
|
function throwNonLiteralValue(expression, file2, line) {
|
|
25625
|
-
throw new ExtractionError(`Non-literal value detected (${expression.getKindName()}): ${expression.getText()}. Only inline literals (strings, numbers, booleans) are supported`, file2, line);
|
|
25635
|
+
throw new ExtractionError(`Non-literal value detected (${expression.getKindName()}): ${expression.getText()}. Only inline literals (strings, numbers, booleans, string arrays) are supported`, file2, line);
|
|
25626
25636
|
}
|
|
25627
25637
|
function extractLiteralValue(expression, file2, line) {
|
|
25628
25638
|
if (expression === void 0) {
|
|
@@ -27634,64 +27644,120 @@ function resolveTypeThroughInterface(typeName, project, componentIndex, options)
|
|
|
27634
27644
|
uncertain: interfaceResult.typeDefinedInSource ? interfaceResult.reason : void 0
|
|
27635
27645
|
};
|
|
27636
27646
|
}
|
|
27637
|
-
function
|
|
27647
|
+
function findClassByNameInProject(project, typeName) {
|
|
27638
27648
|
for (const sourceFile of project.getSourceFiles()) {
|
|
27639
27649
|
for (const classDecl of sourceFile.getClasses()) {
|
|
27640
|
-
if (classDecl.getName()
|
|
27641
|
-
|
|
27650
|
+
if (classDecl.getType().getSymbol()?.getName() === typeName) {
|
|
27651
|
+
return {
|
|
27652
|
+
classDecl,
|
|
27653
|
+
sourceFile
|
|
27654
|
+
};
|
|
27642
27655
|
}
|
|
27643
|
-
return {
|
|
27644
|
-
method: classDecl.getMethod(methodName),
|
|
27645
|
-
classFound: true
|
|
27646
|
-
};
|
|
27647
27656
|
}
|
|
27648
27657
|
}
|
|
27658
|
+
return void 0;
|
|
27659
|
+
}
|
|
27660
|
+
function resolveContainerMethod(project, typeName, calledMethodName, componentIndex) {
|
|
27661
|
+
const lookup = findClassByNameInProject(project, typeName);
|
|
27662
|
+
if (lookup === void 0) {
|
|
27663
|
+
return void 0;
|
|
27664
|
+
}
|
|
27665
|
+
const method = lookup.classDecl.getMethod(calledMethodName);
|
|
27666
|
+
if (method === void 0) {
|
|
27667
|
+
return void 0;
|
|
27668
|
+
}
|
|
27669
|
+
return componentIndex.getComponentByLocation(lookup.sourceFile.getFilePath(), method.getStartLineNumber());
|
|
27670
|
+
}
|
|
27671
|
+
function findMethodInProject(project, typeName, methodName) {
|
|
27672
|
+
const lookup = findClassByNameInProject(project, typeName);
|
|
27673
|
+
if (lookup === void 0) {
|
|
27674
|
+
return {
|
|
27675
|
+
method: void 0,
|
|
27676
|
+
classFound: false
|
|
27677
|
+
};
|
|
27678
|
+
}
|
|
27649
27679
|
return {
|
|
27650
|
-
method:
|
|
27651
|
-
classFound:
|
|
27680
|
+
method: lookup.classDecl.getMethod(methodName),
|
|
27681
|
+
classFound: true
|
|
27652
27682
|
};
|
|
27653
27683
|
}
|
|
27654
27684
|
|
|
27655
27685
|
// ../riviere-extract-ts/dist/domain/connection-detection/call-graph/trace-calls.js
|
|
27656
|
-
function
|
|
27657
|
-
const
|
|
27658
|
-
|
|
27659
|
-
|
|
27660
|
-
|
|
27661
|
-
|
|
27662
|
-
|
|
27663
|
-
}
|
|
27664
|
-
|
|
27665
|
-
|
|
27666
|
-
|
|
27667
|
-
|
|
27668
|
-
|
|
27669
|
-
|
|
27670
|
-
|
|
27671
|
-
|
|
27672
|
-
|
|
27673
|
-
|
|
27674
|
-
|
|
27675
|
-
|
|
27676
|
-
|
|
27677
|
-
|
|
27678
|
-
|
|
27679
|
-
|
|
27680
|
-
|
|
27681
|
-
|
|
27682
|
-
|
|
27683
|
-
|
|
27684
|
-
|
|
27685
|
-
|
|
27686
|
-
|
|
27687
|
-
uncertainResults.push({
|
|
27688
|
-
source: sourceComponent,
|
|
27689
|
-
reason: uncertain,
|
|
27690
|
-
callSite: originCallSite
|
|
27686
|
+
function resolveComponentTarget(typeName, calledMethodName, ctx) {
|
|
27687
|
+
const { component: directMatch, resolvedTypeName, uncertain } = resolveTypeThroughInterface(typeName, ctx.project, ctx.componentIndex, ctx.options);
|
|
27688
|
+
if (directMatch !== void 0) {
|
|
27689
|
+
return {
|
|
27690
|
+
target: directMatch,
|
|
27691
|
+
resolvedTypeName: void 0,
|
|
27692
|
+
uncertain: void 0
|
|
27693
|
+
};
|
|
27694
|
+
}
|
|
27695
|
+
const containerTarget = resolveContainerMethod(ctx.project, resolvedTypeName ?? typeName, calledMethodName, ctx.componentIndex);
|
|
27696
|
+
return {
|
|
27697
|
+
target: containerTarget,
|
|
27698
|
+
resolvedTypeName,
|
|
27699
|
+
uncertain
|
|
27700
|
+
};
|
|
27701
|
+
}
|
|
27702
|
+
function traceCallExpression(callExpr, ctx) {
|
|
27703
|
+
const sourceFile = callExpr.getSourceFile();
|
|
27704
|
+
const typeResult = resolveCallExpressionReceiverType(callExpr, sourceFile, { strict: ctx.options.strict });
|
|
27705
|
+
if (!typeResult.resolved) {
|
|
27706
|
+
return;
|
|
27707
|
+
}
|
|
27708
|
+
const typeName = typeResult.typeName;
|
|
27709
|
+
const calledMethodName = getCalledMethodName(callExpr);
|
|
27710
|
+
const outcome = resolveComponentTarget(typeName, calledMethodName, ctx);
|
|
27711
|
+
if (outcome.target !== void 0) {
|
|
27712
|
+
if (componentIdentity(ctx.sourceComponent) !== componentIdentity(outcome.target)) {
|
|
27713
|
+
ctx.results.push({
|
|
27714
|
+
source: ctx.sourceComponent,
|
|
27715
|
+
target: outcome.target,
|
|
27716
|
+
callSite: ctx.originCallSite
|
|
27691
27717
|
});
|
|
27692
27718
|
}
|
|
27719
|
+
return;
|
|
27720
|
+
}
|
|
27721
|
+
traceIntoNonComponent(typeName, calledMethodName, outcome, ctx);
|
|
27722
|
+
}
|
|
27723
|
+
function traceIntoNonComponent(typeName, calledMethodName, outcome, ctx) {
|
|
27724
|
+
const traceTypeName = outcome.resolvedTypeName ?? typeName;
|
|
27725
|
+
const visitKey = `${traceTypeName}.${calledMethodName}`;
|
|
27726
|
+
if (ctx.visited.has(visitKey)) {
|
|
27727
|
+
return;
|
|
27728
|
+
}
|
|
27729
|
+
ctx.visited.add(visitKey);
|
|
27730
|
+
const { method: resolvedMethod, classFound } = findMethodInProject(ctx.project, traceTypeName, calledMethodName);
|
|
27731
|
+
if (resolvedMethod !== void 0) {
|
|
27732
|
+
traceBody(resolvedMethod, ctx);
|
|
27733
|
+
return;
|
|
27734
|
+
}
|
|
27735
|
+
if (!classFound && outcome.uncertain !== void 0) {
|
|
27736
|
+
ctx.uncertainResults.push({
|
|
27737
|
+
source: ctx.sourceComponent,
|
|
27738
|
+
reason: outcome.uncertain,
|
|
27739
|
+
callSite: ctx.originCallSite
|
|
27740
|
+
});
|
|
27741
|
+
}
|
|
27742
|
+
}
|
|
27743
|
+
function traceBody(body, ctx) {
|
|
27744
|
+
const callExpressions = body.getDescendantsOfKind(SyntaxKind5.CallExpression);
|
|
27745
|
+
for (const callExpr of callExpressions) {
|
|
27746
|
+
traceCallExpression(callExpr, ctx);
|
|
27693
27747
|
}
|
|
27694
27748
|
}
|
|
27749
|
+
function traceCallsInBody(body, project, componentIndex, sourceComponent, originCallSite, visited, results, uncertainResults, options) {
|
|
27750
|
+
traceBody(body, {
|
|
27751
|
+
project,
|
|
27752
|
+
componentIndex,
|
|
27753
|
+
sourceComponent,
|
|
27754
|
+
originCallSite,
|
|
27755
|
+
visited,
|
|
27756
|
+
results,
|
|
27757
|
+
uncertainResults,
|
|
27758
|
+
options
|
|
27759
|
+
});
|
|
27760
|
+
}
|
|
27695
27761
|
function findClassInProject(project, component) {
|
|
27696
27762
|
const sourceFile = project.getSourceFile(component.location.file);
|
|
27697
27763
|
if (sourceFile === void 0) {
|
|
@@ -27699,6 +27765,29 @@ function findClassInProject(project, component) {
|
|
|
27699
27765
|
}
|
|
27700
27766
|
return sourceFile.getClasses().find((c) => c.getStartLineNumber() === component.location.line);
|
|
27701
27767
|
}
|
|
27768
|
+
function findMethodLevelComponent(project, component) {
|
|
27769
|
+
const sourceFile = project.getSourceFile(component.location.file);
|
|
27770
|
+
if (sourceFile === void 0) {
|
|
27771
|
+
return void 0;
|
|
27772
|
+
}
|
|
27773
|
+
for (const classDecl of sourceFile.getClasses()) {
|
|
27774
|
+
const method = classDecl.getMethods().find((m) => m.getStartLineNumber() === component.location.line);
|
|
27775
|
+
if (method !== void 0) {
|
|
27776
|
+
return {
|
|
27777
|
+
classDecl,
|
|
27778
|
+
method
|
|
27779
|
+
};
|
|
27780
|
+
}
|
|
27781
|
+
}
|
|
27782
|
+
return void 0;
|
|
27783
|
+
}
|
|
27784
|
+
function findFunctionInProject(project, component) {
|
|
27785
|
+
const sourceFile = project.getSourceFile(component.location.file);
|
|
27786
|
+
if (sourceFile === void 0) {
|
|
27787
|
+
return void 0;
|
|
27788
|
+
}
|
|
27789
|
+
return sourceFile.getFunctions().find((f) => f.getStartLineNumber() === component.location.line);
|
|
27790
|
+
}
|
|
27702
27791
|
|
|
27703
27792
|
// ../riviere-extract-ts/dist/domain/connection-detection/call-graph/deduplicate-links.js
|
|
27704
27793
|
function linkKey(source, target, type) {
|
|
@@ -27787,8 +27876,26 @@ function processCallExpression(callExpr, component, methodName, project, compone
|
|
|
27787
27876
|
}
|
|
27788
27877
|
return;
|
|
27789
27878
|
}
|
|
27879
|
+
const containerTarget = resolveContainerMethod(project, resolvedTypeName ?? typeName, calledMethodName, componentIndex);
|
|
27880
|
+
if (containerTarget !== void 0) {
|
|
27881
|
+
if (componentIdentity(component) !== componentIdentity(containerTarget)) {
|
|
27882
|
+
rawLinks.push({
|
|
27883
|
+
source: component,
|
|
27884
|
+
target: containerTarget,
|
|
27885
|
+
callSite: currentCallSite
|
|
27886
|
+
});
|
|
27887
|
+
}
|
|
27888
|
+
return;
|
|
27889
|
+
}
|
|
27790
27890
|
traceNonComponent(project, componentIndex, component, resolvedTypeName ?? typeName, calledMethodName, currentCallSite, rawLinks, uncertainLinks, uncertain, options);
|
|
27791
27891
|
}
|
|
27892
|
+
function processFunction(funcDecl, component, project, componentIndex, rawLinks, uncertainLinks, options) {
|
|
27893
|
+
const functionName = funcDecl.getNameOrThrow();
|
|
27894
|
+
const callExpressions = funcDecl.getDescendantsOfKind(SyntaxKind6.CallExpression);
|
|
27895
|
+
for (const callExpr of callExpressions) {
|
|
27896
|
+
processCallExpression(callExpr, component, functionName, project, componentIndex, rawLinks, uncertainLinks, options);
|
|
27897
|
+
}
|
|
27898
|
+
}
|
|
27792
27899
|
function processMethod(method, component, project, componentIndex, rawLinks, uncertainLinks, options) {
|
|
27793
27900
|
const methodName = method.getName();
|
|
27794
27901
|
const callExpressions = method.getDescendantsOfKind(SyntaxKind6.CallExpression);
|
|
@@ -27801,11 +27908,20 @@ function buildCallGraph(project, components, componentIndex, options) {
|
|
|
27801
27908
|
const uncertainLinks = [];
|
|
27802
27909
|
for (const component of components) {
|
|
27803
27910
|
const classDecl = findClassInProject(project, component);
|
|
27804
|
-
if (classDecl
|
|
27911
|
+
if (classDecl !== void 0) {
|
|
27912
|
+
for (const method of classDecl.getMethods()) {
|
|
27913
|
+
processMethod(method, component, project, componentIndex, rawLinks, uncertainLinks, options);
|
|
27914
|
+
}
|
|
27915
|
+
continue;
|
|
27916
|
+
}
|
|
27917
|
+
const methodTarget = findMethodLevelComponent(project, component);
|
|
27918
|
+
if (methodTarget !== void 0) {
|
|
27919
|
+
processMethod(methodTarget.method, component, project, componentIndex, rawLinks, uncertainLinks, options);
|
|
27805
27920
|
continue;
|
|
27806
27921
|
}
|
|
27807
|
-
|
|
27808
|
-
|
|
27922
|
+
const funcDecl = findFunctionInProject(project, component);
|
|
27923
|
+
if (funcDecl !== void 0) {
|
|
27924
|
+
processFunction(funcDecl, component, project, componentIndex, rawLinks, uncertainLinks, options);
|
|
27809
27925
|
}
|
|
27810
27926
|
}
|
|
27811
27927
|
return deduplicateLinks(rawLinks, uncertainLinks);
|
|
@@ -27834,6 +27950,15 @@ function detectPublishConnections(project, components, options) {
|
|
|
27834
27950
|
return publishers.flatMap((publisher) => extractPublisherLinks(project, publisher, events, options));
|
|
27835
27951
|
}
|
|
27836
27952
|
function extractPublisherLinks(project, publisher, events, options) {
|
|
27953
|
+
const publishedEventType = publisher.metadata["publishedEventType"];
|
|
27954
|
+
if (typeof publishedEventType === "string") {
|
|
27955
|
+
const sourceLocation = {
|
|
27956
|
+
repository: "",
|
|
27957
|
+
filePath: publisher.location.file,
|
|
27958
|
+
lineNumber: publisher.location.line
|
|
27959
|
+
};
|
|
27960
|
+
return resolvePublishTarget(publisher, publishedEventType, events, options, sourceLocation);
|
|
27961
|
+
}
|
|
27837
27962
|
const classDecl = findClassInProject(project, publisher);
|
|
27838
27963
|
if (classDecl === void 0) {
|
|
27839
27964
|
return [];
|
|
@@ -27986,7 +28111,7 @@ function detectConnections(project, components, options, globMatcher) {
|
|
|
27986
28111
|
const componentIndex = new ComponentIndex(components);
|
|
27987
28112
|
const sourceFilePaths = computeFilteredFilePaths(project, options.moduleGlobs, globMatcher);
|
|
27988
28113
|
const setupMs = performance.now() - setupStart;
|
|
27989
|
-
const strict =
|
|
28114
|
+
const strict = options.allowIncomplete !== true;
|
|
27990
28115
|
const callGraphStart = performance.now();
|
|
27991
28116
|
const syncLinks = buildCallGraph(project, components, componentIndex, {
|
|
27992
28117
|
strict,
|
|
@@ -28016,12 +28141,6 @@ function findMatchingModule2(filePath, modules, globMatcher, configDir) {
|
|
|
28016
28141
|
const pathToMatch = posix2.relative(configDir.replaceAll(/\\+/g, "/"), normalized);
|
|
28017
28142
|
return modules.find((m) => globMatcher(pathToMatch, m.path));
|
|
28018
28143
|
}
|
|
28019
|
-
function isDetectionRule2(rule) {
|
|
28020
|
-
if (typeof rule !== "object" || rule === null) {
|
|
28021
|
-
return false;
|
|
28022
|
-
}
|
|
28023
|
-
return "find" in rule && "where" in rule;
|
|
28024
|
-
}
|
|
28025
28144
|
function getBuiltInRule(module, componentType) {
|
|
28026
28145
|
const ruleMap = {
|
|
28027
28146
|
api: module.api,
|
|
@@ -28033,10 +28152,10 @@ function getBuiltInRule(module, componentType) {
|
|
|
28033
28152
|
ui: module.ui
|
|
28034
28153
|
};
|
|
28035
28154
|
const rule = ruleMap[componentType];
|
|
28036
|
-
if (
|
|
28037
|
-
return
|
|
28155
|
+
if (rule === void 0 || !("find" in rule)) {
|
|
28156
|
+
return void 0;
|
|
28038
28157
|
}
|
|
28039
|
-
return
|
|
28158
|
+
return rule;
|
|
28040
28159
|
}
|
|
28041
28160
|
function findDetectionRule(module, componentType) {
|
|
28042
28161
|
const builtInTypes = [
|
|
@@ -28045,6 +28164,7 @@ function findDetectionRule(module, componentType) {
|
|
|
28045
28164
|
"domainOp",
|
|
28046
28165
|
"event",
|
|
28047
28166
|
"eventHandler",
|
|
28167
|
+
"eventPublisher",
|
|
28048
28168
|
"ui"
|
|
28049
28169
|
];
|
|
28050
28170
|
if (builtInTypes.includes(componentType)) {
|
|
@@ -28052,24 +28172,6 @@ function findDetectionRule(module, componentType) {
|
|
|
28052
28172
|
}
|
|
28053
28173
|
return module.customTypes?.[componentType];
|
|
28054
28174
|
}
|
|
28055
|
-
function isLiteralRule(rule) {
|
|
28056
|
-
return "literal" in rule;
|
|
28057
|
-
}
|
|
28058
|
-
function isFromClassNameRule(rule) {
|
|
28059
|
-
return "fromClassName" in rule;
|
|
28060
|
-
}
|
|
28061
|
-
function isFromFilePathRule(rule) {
|
|
28062
|
-
return "fromFilePath" in rule;
|
|
28063
|
-
}
|
|
28064
|
-
function isFromPropertyRule(rule) {
|
|
28065
|
-
return "fromProperty" in rule;
|
|
28066
|
-
}
|
|
28067
|
-
function isFromMethodNameRule(rule) {
|
|
28068
|
-
return "fromMethodName" in rule;
|
|
28069
|
-
}
|
|
28070
|
-
function isFromGenericArgRule(rule) {
|
|
28071
|
-
return "fromGenericArg" in rule;
|
|
28072
|
-
}
|
|
28073
28175
|
function findClassAtLine(project, draft) {
|
|
28074
28176
|
const sourceFile = project.getSourceFile(draft.location.file);
|
|
28075
28177
|
if (sourceFile === void 0) {
|
|
@@ -28110,29 +28212,44 @@ function findContainingClass(project, draft) {
|
|
|
28110
28212
|
throw new ExtractionError(`No containing class found for method at line ${methodLine}`, draft.location.file, draft.location.line);
|
|
28111
28213
|
}
|
|
28112
28214
|
function evaluateClassRule(rule, classDecl) {
|
|
28113
|
-
if (
|
|
28215
|
+
if ("fromClassName" in rule) {
|
|
28114
28216
|
return evaluateFromClassNameRule(rule, classDecl);
|
|
28115
28217
|
}
|
|
28116
|
-
if (!
|
|
28218
|
+
if (!("fromProperty" in rule)) {
|
|
28117
28219
|
throw new ExtractionError("Unsupported extraction rule type for class-based component", classDecl.getSourceFile().getFilePath(), classDecl.getStartLineNumber());
|
|
28118
28220
|
}
|
|
28119
28221
|
return evaluateFromPropertyRule(rule, classDecl);
|
|
28120
28222
|
}
|
|
28121
28223
|
function evaluateRule(rule, draft, project) {
|
|
28122
|
-
if (
|
|
28224
|
+
if ("literal" in rule) {
|
|
28123
28225
|
return evaluateLiteralRule(rule);
|
|
28124
28226
|
}
|
|
28125
|
-
if (
|
|
28227
|
+
if ("fromFilePath" in rule) {
|
|
28126
28228
|
return evaluateFromFilePathRule(rule, draft.location.file);
|
|
28127
28229
|
}
|
|
28128
|
-
if (
|
|
28230
|
+
if ("fromMethodName" in rule) {
|
|
28129
28231
|
const methodDecl = findMethodAtLine(project, draft);
|
|
28130
28232
|
return evaluateFromMethodNameRule(rule, methodDecl);
|
|
28131
28233
|
}
|
|
28132
|
-
if (
|
|
28234
|
+
if ("fromGenericArg" in rule) {
|
|
28133
28235
|
const classDecl2 = findContainingClass(project, draft);
|
|
28134
28236
|
return evaluateFromGenericArgRule(rule, classDecl2);
|
|
28135
28237
|
}
|
|
28238
|
+
if ("fromParameterType" in rule) {
|
|
28239
|
+
const methodDecl = findMethodAtLine(project, draft);
|
|
28240
|
+
const params = methodDecl.getParameters();
|
|
28241
|
+
const position = rule.fromParameterType.position;
|
|
28242
|
+
const param = params[position];
|
|
28243
|
+
if (param === void 0) {
|
|
28244
|
+
throw new ExtractionError(`Parameter position ${position} out of bounds. Method has ${params.length} parameter(s)`, draft.location.file, draft.location.line);
|
|
28245
|
+
}
|
|
28246
|
+
const typeName = param.getTypeNode()?.getText() ?? "unknown";
|
|
28247
|
+
const transform2 = rule.fromParameterType.transform;
|
|
28248
|
+
if (transform2 === void 0) {
|
|
28249
|
+
return { value: typeName };
|
|
28250
|
+
}
|
|
28251
|
+
return { value: applyTransforms(typeName, transform2) };
|
|
28252
|
+
}
|
|
28136
28253
|
const classDecl = findClassAtLine(project, draft);
|
|
28137
28254
|
return evaluateClassRule(rule, classDecl);
|
|
28138
28255
|
}
|
|
@@ -29686,7 +29803,6 @@ export {
|
|
|
29686
29803
|
/* istanbul ignore next -- @preserve: unreachable with valid Predicate type */
|
|
29687
29804
|
/* istanbul ignore next -- @preserve: Anonymous declarations have undefined names; predicate correctly returns false */
|
|
29688
29805
|
/* istanbul ignore next -- @preserve: Methods in object literals have non-class parents; predicate correctly returns false */
|
|
29689
|
-
/* istanbul ignore if -- @preserve: unreachable with typed ResolvedExtractionConfig; defensive guard */
|
|
29690
29806
|
/* istanbul ignore else -- @preserve: false branch is unreachable; FindTarget is exhaustive */
|
|
29691
29807
|
/* istanbul ignore next -- @preserve: unreachable with valid FindTarget type; defensive fallback */
|
|
29692
29808
|
/* v8 ignore next -- @preserve: getExtends() !== undefined guarantees getBaseClass() returns a value */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@living-architecture/riviere-cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"yaml": "^2.7.0",
|
|
35
35
|
"@living-architecture/riviere-builder": "0.6.3",
|
|
36
36
|
"@living-architecture/riviere-extract-config": "0.4.3",
|
|
37
|
-
"@living-architecture/riviere-extract-ts": "0.2.
|
|
37
|
+
"@living-architecture/riviere-extract-ts": "0.2.7",
|
|
38
38
|
"@living-architecture/riviere-query": "0.5.3",
|
|
39
39
|
"@living-architecture/riviere-schema": "0.5.3"
|
|
40
40
|
}
|