@neat.is/core 0.4.7 → 0.4.9
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/{chunk-7FTK47JQ.js → chunk-J5CEKCTR.js} +103 -73
- package/dist/chunk-J5CEKCTR.js.map +1 -0
- package/dist/{chunk-LS6NS72S.js → chunk-RC3CIDZO.js} +2 -2
- package/dist/cli.cjs +124 -40
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +2 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +26 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +62 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/neatd.cjs +62 -34
- package/dist/neatd.cjs.map +1 -1
- package/dist/neatd.js +2 -2
- package/dist/server.cjs +62 -34
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-7FTK47JQ.js.map +0 -1
- /package/dist/{chunk-LS6NS72S.js.map → chunk-RC3CIDZO.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
routeSpanToProject,
|
|
3
3
|
startDaemon
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RC3CIDZO.js";
|
|
5
5
|
import {
|
|
6
6
|
ProjectNameCollisionError,
|
|
7
7
|
addProject,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
thresholdForEdgeType,
|
|
38
38
|
touchLastSeen,
|
|
39
39
|
writeAtomically
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-J5CEKCTR.js";
|
|
41
41
|
import {
|
|
42
42
|
startOtelGrpcReceiver
|
|
43
43
|
} from "./chunk-3QCRUEQD.js";
|
package/dist/neatd.cjs
CHANGED
|
@@ -973,6 +973,24 @@ function isFrontierNode(graph, nodeId) {
|
|
|
973
973
|
const attrs = graph.getNodeAttributes(nodeId);
|
|
974
974
|
return attrs.type === import_types.NodeType.FrontierNode;
|
|
975
975
|
}
|
|
976
|
+
function resolveOwningService(graph, nodeId) {
|
|
977
|
+
if (!graph.hasNode(nodeId)) return null;
|
|
978
|
+
const attrs = graph.getNodeAttributes(nodeId);
|
|
979
|
+
if (attrs.type === import_types.NodeType.ServiceNode) {
|
|
980
|
+
return { id: nodeId, svc: attrs };
|
|
981
|
+
}
|
|
982
|
+
if (attrs.type === import_types.NodeType.FileNode) {
|
|
983
|
+
for (const edgeId of graph.inboundEdges(nodeId)) {
|
|
984
|
+
const e = graph.getEdgeAttributes(edgeId);
|
|
985
|
+
if (e.type !== import_types.EdgeType.CONTAINS) continue;
|
|
986
|
+
const owner = graph.getNodeAttributes(e.source);
|
|
987
|
+
if (owner.type === import_types.NodeType.ServiceNode) {
|
|
988
|
+
return { id: e.source, svc: owner };
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
return null;
|
|
993
|
+
}
|
|
976
994
|
function bestEdgeBySource(graph, edgeIds) {
|
|
977
995
|
const best = /* @__PURE__ */ new Map();
|
|
978
996
|
for (const id of edgeIds) {
|
|
@@ -1079,9 +1097,9 @@ function databaseRootCauseShape(graph, origin, walk) {
|
|
|
1079
1097
|
const candidatePairs = compatPairs().filter((p) => p.engine === targetDb.engine);
|
|
1080
1098
|
if (candidatePairs.length === 0) return null;
|
|
1081
1099
|
for (const id of walk.path) {
|
|
1082
|
-
const
|
|
1083
|
-
if (
|
|
1084
|
-
const svc =
|
|
1100
|
+
const owner = resolveOwningService(graph, id);
|
|
1101
|
+
if (!owner) continue;
|
|
1102
|
+
const { id: serviceId3, svc } = owner;
|
|
1085
1103
|
const deps = svc.dependencies ?? {};
|
|
1086
1104
|
for (const pair of candidatePairs) {
|
|
1087
1105
|
const declared = deps[pair.driver];
|
|
@@ -1094,7 +1112,7 @@ function databaseRootCauseShape(graph, origin, walk) {
|
|
|
1094
1112
|
);
|
|
1095
1113
|
if (!result.compatible) {
|
|
1096
1114
|
return {
|
|
1097
|
-
rootCauseNode:
|
|
1115
|
+
rootCauseNode: serviceId3,
|
|
1098
1116
|
rootCauseReason: result.reason ?? "incompatible driver",
|
|
1099
1117
|
...result.minDriverVersion ? {
|
|
1100
1118
|
fixRecommendation: `Upgrade ${svc.name} ${pair.driver} driver to >= ${result.minDriverVersion}`
|
|
@@ -1107,9 +1125,9 @@ function databaseRootCauseShape(graph, origin, walk) {
|
|
|
1107
1125
|
}
|
|
1108
1126
|
function serviceRootCauseShape(graph, _origin, walk) {
|
|
1109
1127
|
for (const id of walk.path) {
|
|
1110
|
-
const
|
|
1111
|
-
if (
|
|
1112
|
-
const svc =
|
|
1128
|
+
const owner = resolveOwningService(graph, id);
|
|
1129
|
+
if (!owner) continue;
|
|
1130
|
+
const { id: serviceId3, svc } = owner;
|
|
1113
1131
|
const deps = svc.dependencies ?? {};
|
|
1114
1132
|
const serviceNodeEngine = svc.nodeEngine;
|
|
1115
1133
|
for (const constraint of nodeEngineConstraints()) {
|
|
@@ -1118,7 +1136,7 @@ function serviceRootCauseShape(graph, _origin, walk) {
|
|
|
1118
1136
|
const result = checkNodeEngineConstraint(constraint, declared, serviceNodeEngine);
|
|
1119
1137
|
if (!result.compatible && result.reason) {
|
|
1120
1138
|
return {
|
|
1121
|
-
rootCauseNode:
|
|
1139
|
+
rootCauseNode: serviceId3,
|
|
1122
1140
|
rootCauseReason: result.reason,
|
|
1123
1141
|
...result.requiredNodeVersion ? {
|
|
1124
1142
|
fixRecommendation: `Bump ${svc.name}'s engines.node to >= ${result.requiredNodeVersion}`
|
|
@@ -1133,7 +1151,7 @@ function serviceRootCauseShape(graph, _origin, walk) {
|
|
|
1133
1151
|
const result = checkPackageConflict(conflict, declared, requiredDeclared);
|
|
1134
1152
|
if (!result.compatible && result.reason) {
|
|
1135
1153
|
return {
|
|
1136
|
-
rootCauseNode:
|
|
1154
|
+
rootCauseNode: serviceId3,
|
|
1137
1155
|
rootCauseReason: result.reason,
|
|
1138
1156
|
fixRecommendation: `Upgrade ${svc.name}'s ${conflict.requires.name} to >= ${conflict.requires.minVersion}`
|
|
1139
1157
|
};
|
|
@@ -1142,9 +1160,15 @@ function serviceRootCauseShape(graph, _origin, walk) {
|
|
|
1142
1160
|
}
|
|
1143
1161
|
return null;
|
|
1144
1162
|
}
|
|
1163
|
+
function fileRootCauseShape(graph, origin, walk) {
|
|
1164
|
+
const owner = resolveOwningService(graph, origin.id);
|
|
1165
|
+
if (!owner) return null;
|
|
1166
|
+
return serviceRootCauseShape(graph, owner.svc, walk);
|
|
1167
|
+
}
|
|
1145
1168
|
var rootCauseShapes = {
|
|
1146
1169
|
[import_types.NodeType.DatabaseNode]: databaseRootCauseShape,
|
|
1147
|
-
[import_types.NodeType.ServiceNode]: serviceRootCauseShape
|
|
1170
|
+
[import_types.NodeType.ServiceNode]: serviceRootCauseShape,
|
|
1171
|
+
[import_types.NodeType.FileNode]: fileRootCauseShape
|
|
1148
1172
|
};
|
|
1149
1173
|
function getRootCause(graph, errorNodeId, errorEvent) {
|
|
1150
1174
|
if (!graph.hasNode(errorNodeId)) return null;
|
|
@@ -3727,9 +3751,17 @@ async function addHttpCallEdges(graph, services) {
|
|
|
3727
3751
|
line: site.line,
|
|
3728
3752
|
snippet: snippet(file.content, site.line)
|
|
3729
3753
|
};
|
|
3754
|
+
const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
|
|
3755
|
+
graph,
|
|
3756
|
+
service.pkg.name,
|
|
3757
|
+
service.node.id,
|
|
3758
|
+
relFile
|
|
3759
|
+
);
|
|
3760
|
+
nodesAdded += n;
|
|
3761
|
+
edgesAdded += e;
|
|
3730
3762
|
if (!(0, import_types10.passesExtractedFloor)(confidence)) {
|
|
3731
3763
|
noteExtractedDropped({
|
|
3732
|
-
source:
|
|
3764
|
+
source: fileNodeId,
|
|
3733
3765
|
target: targetId,
|
|
3734
3766
|
type: import_types10.EdgeType.CALLS,
|
|
3735
3767
|
confidence,
|
|
@@ -3738,14 +3770,6 @@ async function addHttpCallEdges(graph, services) {
|
|
|
3738
3770
|
});
|
|
3739
3771
|
continue;
|
|
3740
3772
|
}
|
|
3741
|
-
const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
|
|
3742
|
-
graph,
|
|
3743
|
-
service.pkg.name,
|
|
3744
|
-
service.node.id,
|
|
3745
|
-
relFile
|
|
3746
|
-
);
|
|
3747
|
-
nodesAdded += n;
|
|
3748
|
-
edgesAdded += e;
|
|
3749
3773
|
const edgeId = (0, import_types4.extractedEdgeId)(fileNodeId, targetId, import_types10.EdgeType.CALLS);
|
|
3750
3774
|
if (!graph.hasEdge(edgeId)) {
|
|
3751
3775
|
const edge = {
|
|
@@ -4020,9 +4044,18 @@ async function addExternalEndpointEdges(graph, services) {
|
|
|
4020
4044
|
}
|
|
4021
4045
|
const edgeType = edgeTypeFromEndpoint(ep);
|
|
4022
4046
|
const confidence = (0, import_types15.confidenceForExtracted)(ep.confidenceKind);
|
|
4047
|
+
const relFile = toPosix2(ep.evidence.file);
|
|
4048
|
+
const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
|
|
4049
|
+
graph,
|
|
4050
|
+
service.pkg.name,
|
|
4051
|
+
service.node.id,
|
|
4052
|
+
relFile
|
|
4053
|
+
);
|
|
4054
|
+
nodesAdded += n;
|
|
4055
|
+
edgesAdded += e;
|
|
4023
4056
|
if (!(0, import_types15.passesExtractedFloor)(confidence)) {
|
|
4024
4057
|
noteExtractedDropped({
|
|
4025
|
-
source:
|
|
4058
|
+
source: fileNodeId,
|
|
4026
4059
|
target: ep.infraId,
|
|
4027
4060
|
type: edgeType,
|
|
4028
4061
|
confidence,
|
|
@@ -4031,15 +4064,6 @@ async function addExternalEndpointEdges(graph, services) {
|
|
|
4031
4064
|
});
|
|
4032
4065
|
continue;
|
|
4033
4066
|
}
|
|
4034
|
-
const relFile = toPosix2(ep.evidence.file);
|
|
4035
|
-
const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
|
|
4036
|
-
graph,
|
|
4037
|
-
service.pkg.name,
|
|
4038
|
-
service.node.id,
|
|
4039
|
-
relFile
|
|
4040
|
-
);
|
|
4041
|
-
nodesAdded += n;
|
|
4042
|
-
edgesAdded += e;
|
|
4043
4067
|
const edgeId = (0, import_types4.extractedEdgeId)(fileNodeId, ep.infraId, edgeType);
|
|
4044
4068
|
if (seenEdges.has(edgeId)) continue;
|
|
4045
4069
|
seenEdges.add(edgeId);
|
|
@@ -5511,14 +5535,18 @@ function registerRoutes(scope, ctx) {
|
|
|
5511
5535
|
async function buildApi(opts) {
|
|
5512
5536
|
const app = (0, import_fastify.default)({ logger: false });
|
|
5513
5537
|
await app.register(import_cors.default, { origin: true });
|
|
5538
|
+
const env = readAuthEnv();
|
|
5539
|
+
const authToken = opts.authToken ?? env.authToken;
|
|
5540
|
+
const trustProxy = opts.trustProxy ?? env.trustProxy;
|
|
5541
|
+
const publicRead = opts.publicRead ?? env.publicRead;
|
|
5514
5542
|
mountBearerAuth(app, {
|
|
5515
|
-
token:
|
|
5516
|
-
trustProxy
|
|
5517
|
-
publicRead
|
|
5543
|
+
token: authToken,
|
|
5544
|
+
trustProxy,
|
|
5545
|
+
publicRead
|
|
5518
5546
|
});
|
|
5519
5547
|
app.get("/api/config", async () => ({
|
|
5520
|
-
publicRead:
|
|
5521
|
-
authProxy:
|
|
5548
|
+
publicRead: publicRead === true,
|
|
5549
|
+
authProxy: trustProxy === true
|
|
5522
5550
|
}));
|
|
5523
5551
|
const startedAt = opts.startedAt ?? Date.now();
|
|
5524
5552
|
const registry = buildLegacyRegistry(opts);
|