@neat.is/core 0.4.7 → 0.4.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/{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 +118 -38
- 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 +20 -5
- 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.cjs
CHANGED
|
@@ -1017,6 +1017,24 @@ function isFrontierNode(graph, nodeId) {
|
|
|
1017
1017
|
const attrs = graph.getNodeAttributes(nodeId);
|
|
1018
1018
|
return attrs.type === import_types.NodeType.FrontierNode;
|
|
1019
1019
|
}
|
|
1020
|
+
function resolveOwningService(graph, nodeId) {
|
|
1021
|
+
if (!graph.hasNode(nodeId)) return null;
|
|
1022
|
+
const attrs = graph.getNodeAttributes(nodeId);
|
|
1023
|
+
if (attrs.type === import_types.NodeType.ServiceNode) {
|
|
1024
|
+
return { id: nodeId, svc: attrs };
|
|
1025
|
+
}
|
|
1026
|
+
if (attrs.type === import_types.NodeType.FileNode) {
|
|
1027
|
+
for (const edgeId of graph.inboundEdges(nodeId)) {
|
|
1028
|
+
const e = graph.getEdgeAttributes(edgeId);
|
|
1029
|
+
if (e.type !== import_types.EdgeType.CONTAINS) continue;
|
|
1030
|
+
const owner = graph.getNodeAttributes(e.source);
|
|
1031
|
+
if (owner.type === import_types.NodeType.ServiceNode) {
|
|
1032
|
+
return { id: e.source, svc: owner };
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
return null;
|
|
1037
|
+
}
|
|
1020
1038
|
function bestEdgeBySource(graph, edgeIds) {
|
|
1021
1039
|
const best = /* @__PURE__ */ new Map();
|
|
1022
1040
|
for (const id of edgeIds) {
|
|
@@ -1123,9 +1141,9 @@ function databaseRootCauseShape(graph, origin, walk) {
|
|
|
1123
1141
|
const candidatePairs = compatPairs().filter((p) => p.engine === targetDb.engine);
|
|
1124
1142
|
if (candidatePairs.length === 0) return null;
|
|
1125
1143
|
for (const id of walk.path) {
|
|
1126
|
-
const
|
|
1127
|
-
if (
|
|
1128
|
-
const svc =
|
|
1144
|
+
const owner = resolveOwningService(graph, id);
|
|
1145
|
+
if (!owner) continue;
|
|
1146
|
+
const { id: serviceId3, svc } = owner;
|
|
1129
1147
|
const deps = svc.dependencies ?? {};
|
|
1130
1148
|
for (const pair of candidatePairs) {
|
|
1131
1149
|
const declared = deps[pair.driver];
|
|
@@ -1138,7 +1156,7 @@ function databaseRootCauseShape(graph, origin, walk) {
|
|
|
1138
1156
|
);
|
|
1139
1157
|
if (!result.compatible) {
|
|
1140
1158
|
return {
|
|
1141
|
-
rootCauseNode:
|
|
1159
|
+
rootCauseNode: serviceId3,
|
|
1142
1160
|
rootCauseReason: result.reason ?? "incompatible driver",
|
|
1143
1161
|
...result.minDriverVersion ? {
|
|
1144
1162
|
fixRecommendation: `Upgrade ${svc.name} ${pair.driver} driver to >= ${result.minDriverVersion}`
|
|
@@ -1151,9 +1169,9 @@ function databaseRootCauseShape(graph, origin, walk) {
|
|
|
1151
1169
|
}
|
|
1152
1170
|
function serviceRootCauseShape(graph, _origin, walk) {
|
|
1153
1171
|
for (const id of walk.path) {
|
|
1154
|
-
const
|
|
1155
|
-
if (
|
|
1156
|
-
const svc =
|
|
1172
|
+
const owner = resolveOwningService(graph, id);
|
|
1173
|
+
if (!owner) continue;
|
|
1174
|
+
const { id: serviceId3, svc } = owner;
|
|
1157
1175
|
const deps = svc.dependencies ?? {};
|
|
1158
1176
|
const serviceNodeEngine = svc.nodeEngine;
|
|
1159
1177
|
for (const constraint of nodeEngineConstraints()) {
|
|
@@ -1162,7 +1180,7 @@ function serviceRootCauseShape(graph, _origin, walk) {
|
|
|
1162
1180
|
const result = checkNodeEngineConstraint(constraint, declared, serviceNodeEngine);
|
|
1163
1181
|
if (!result.compatible && result.reason) {
|
|
1164
1182
|
return {
|
|
1165
|
-
rootCauseNode:
|
|
1183
|
+
rootCauseNode: serviceId3,
|
|
1166
1184
|
rootCauseReason: result.reason,
|
|
1167
1185
|
...result.requiredNodeVersion ? {
|
|
1168
1186
|
fixRecommendation: `Bump ${svc.name}'s engines.node to >= ${result.requiredNodeVersion}`
|
|
@@ -1177,7 +1195,7 @@ function serviceRootCauseShape(graph, _origin, walk) {
|
|
|
1177
1195
|
const result = checkPackageConflict(conflict, declared, requiredDeclared);
|
|
1178
1196
|
if (!result.compatible && result.reason) {
|
|
1179
1197
|
return {
|
|
1180
|
-
rootCauseNode:
|
|
1198
|
+
rootCauseNode: serviceId3,
|
|
1181
1199
|
rootCauseReason: result.reason,
|
|
1182
1200
|
fixRecommendation: `Upgrade ${svc.name}'s ${conflict.requires.name} to >= ${conflict.requires.minVersion}`
|
|
1183
1201
|
};
|
|
@@ -1186,9 +1204,15 @@ function serviceRootCauseShape(graph, _origin, walk) {
|
|
|
1186
1204
|
}
|
|
1187
1205
|
return null;
|
|
1188
1206
|
}
|
|
1207
|
+
function fileRootCauseShape(graph, origin, walk) {
|
|
1208
|
+
const owner = resolveOwningService(graph, origin.id);
|
|
1209
|
+
if (!owner) return null;
|
|
1210
|
+
return serviceRootCauseShape(graph, owner.svc, walk);
|
|
1211
|
+
}
|
|
1189
1212
|
var rootCauseShapes = {
|
|
1190
1213
|
[import_types.NodeType.DatabaseNode]: databaseRootCauseShape,
|
|
1191
|
-
[import_types.NodeType.ServiceNode]: serviceRootCauseShape
|
|
1214
|
+
[import_types.NodeType.ServiceNode]: serviceRootCauseShape,
|
|
1215
|
+
[import_types.NodeType.FileNode]: fileRootCauseShape
|
|
1192
1216
|
};
|
|
1193
1217
|
function getRootCause(graph, errorNodeId, errorEvent) {
|
|
1194
1218
|
if (!graph.hasNode(errorNodeId)) return null;
|
|
@@ -3866,9 +3890,17 @@ async function addHttpCallEdges(graph, services) {
|
|
|
3866
3890
|
line: site.line,
|
|
3867
3891
|
snippet: snippet(file.content, site.line)
|
|
3868
3892
|
};
|
|
3893
|
+
const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
|
|
3894
|
+
graph,
|
|
3895
|
+
service.pkg.name,
|
|
3896
|
+
service.node.id,
|
|
3897
|
+
relFile
|
|
3898
|
+
);
|
|
3899
|
+
nodesAdded += n;
|
|
3900
|
+
edgesAdded += e;
|
|
3869
3901
|
if (!(0, import_types10.passesExtractedFloor)(confidence)) {
|
|
3870
3902
|
noteExtractedDropped({
|
|
3871
|
-
source:
|
|
3903
|
+
source: fileNodeId,
|
|
3872
3904
|
target: targetId,
|
|
3873
3905
|
type: import_types10.EdgeType.CALLS,
|
|
3874
3906
|
confidence,
|
|
@@ -3877,14 +3909,6 @@ async function addHttpCallEdges(graph, services) {
|
|
|
3877
3909
|
});
|
|
3878
3910
|
continue;
|
|
3879
3911
|
}
|
|
3880
|
-
const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
|
|
3881
|
-
graph,
|
|
3882
|
-
service.pkg.name,
|
|
3883
|
-
service.node.id,
|
|
3884
|
-
relFile
|
|
3885
|
-
);
|
|
3886
|
-
nodesAdded += n;
|
|
3887
|
-
edgesAdded += e;
|
|
3888
3912
|
const edgeId = (0, import_types4.extractedEdgeId)(fileNodeId, targetId, import_types10.EdgeType.CALLS);
|
|
3889
3913
|
if (!graph.hasEdge(edgeId)) {
|
|
3890
3914
|
const edge = {
|
|
@@ -4159,9 +4183,18 @@ async function addExternalEndpointEdges(graph, services) {
|
|
|
4159
4183
|
}
|
|
4160
4184
|
const edgeType = edgeTypeFromEndpoint(ep);
|
|
4161
4185
|
const confidence = (0, import_types15.confidenceForExtracted)(ep.confidenceKind);
|
|
4186
|
+
const relFile = toPosix2(ep.evidence.file);
|
|
4187
|
+
const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
|
|
4188
|
+
graph,
|
|
4189
|
+
service.pkg.name,
|
|
4190
|
+
service.node.id,
|
|
4191
|
+
relFile
|
|
4192
|
+
);
|
|
4193
|
+
nodesAdded += n;
|
|
4194
|
+
edgesAdded += e;
|
|
4162
4195
|
if (!(0, import_types15.passesExtractedFloor)(confidence)) {
|
|
4163
4196
|
noteExtractedDropped({
|
|
4164
|
-
source:
|
|
4197
|
+
source: fileNodeId,
|
|
4165
4198
|
target: ep.infraId,
|
|
4166
4199
|
type: edgeType,
|
|
4167
4200
|
confidence,
|
|
@@ -4170,15 +4203,6 @@ async function addExternalEndpointEdges(graph, services) {
|
|
|
4170
4203
|
});
|
|
4171
4204
|
continue;
|
|
4172
4205
|
}
|
|
4173
|
-
const relFile = toPosix2(ep.evidence.file);
|
|
4174
|
-
const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
|
|
4175
|
-
graph,
|
|
4176
|
-
service.pkg.name,
|
|
4177
|
-
service.node.id,
|
|
4178
|
-
relFile
|
|
4179
|
-
);
|
|
4180
|
-
nodesAdded += n;
|
|
4181
|
-
edgesAdded += e;
|
|
4182
4206
|
const edgeId = (0, import_types4.extractedEdgeId)(fileNodeId, ep.infraId, edgeType);
|
|
4183
4207
|
if (seenEdges.has(edgeId)) continue;
|
|
4184
4208
|
seenEdges.add(edgeId);
|
|
@@ -5708,14 +5732,18 @@ function registerRoutes(scope, ctx) {
|
|
|
5708
5732
|
async function buildApi(opts) {
|
|
5709
5733
|
const app = (0, import_fastify.default)({ logger: false });
|
|
5710
5734
|
await app.register(import_cors.default, { origin: true });
|
|
5735
|
+
const env = readAuthEnv();
|
|
5736
|
+
const authToken = opts.authToken ?? env.authToken;
|
|
5737
|
+
const trustProxy = opts.trustProxy ?? env.trustProxy;
|
|
5738
|
+
const publicRead = opts.publicRead ?? env.publicRead;
|
|
5711
5739
|
mountBearerAuth(app, {
|
|
5712
|
-
token:
|
|
5713
|
-
trustProxy
|
|
5714
|
-
publicRead
|
|
5740
|
+
token: authToken,
|
|
5741
|
+
trustProxy,
|
|
5742
|
+
publicRead
|
|
5715
5743
|
});
|
|
5716
5744
|
app.get("/api/config", async () => ({
|
|
5717
|
-
publicRead:
|
|
5718
|
-
authProxy:
|
|
5745
|
+
publicRead: publicRead === true,
|
|
5746
|
+
authProxy: trustProxy === true
|
|
5719
5747
|
}));
|
|
5720
5748
|
const startedAt = opts.startedAt ?? Date.now();
|
|
5721
5749
|
const registry = buildLegacyRegistry(opts);
|