@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/neatd.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  startDaemon
4
- } from "./chunk-LS6NS72S.js";
4
+ } from "./chunk-RC3CIDZO.js";
5
5
  import {
6
6
  listProjects,
7
7
  registryPath
8
- } from "./chunk-7FTK47JQ.js";
8
+ } from "./chunk-J5CEKCTR.js";
9
9
  import {
10
10
  BindAuthorityError,
11
11
  __require
package/dist/server.cjs CHANGED
@@ -939,6 +939,24 @@ function isFrontierNode(graph, nodeId) {
939
939
  const attrs = graph.getNodeAttributes(nodeId);
940
940
  return attrs.type === import_types.NodeType.FrontierNode;
941
941
  }
942
+ function resolveOwningService(graph, nodeId) {
943
+ if (!graph.hasNode(nodeId)) return null;
944
+ const attrs = graph.getNodeAttributes(nodeId);
945
+ if (attrs.type === import_types.NodeType.ServiceNode) {
946
+ return { id: nodeId, svc: attrs };
947
+ }
948
+ if (attrs.type === import_types.NodeType.FileNode) {
949
+ for (const edgeId of graph.inboundEdges(nodeId)) {
950
+ const e = graph.getEdgeAttributes(edgeId);
951
+ if (e.type !== import_types.EdgeType.CONTAINS) continue;
952
+ const owner = graph.getNodeAttributes(e.source);
953
+ if (owner.type === import_types.NodeType.ServiceNode) {
954
+ return { id: e.source, svc: owner };
955
+ }
956
+ }
957
+ }
958
+ return null;
959
+ }
942
960
  function bestEdgeBySource(graph, edgeIds) {
943
961
  const best = /* @__PURE__ */ new Map();
944
962
  for (const id of edgeIds) {
@@ -1045,9 +1063,9 @@ function databaseRootCauseShape(graph, origin, walk) {
1045
1063
  const candidatePairs = compatPairs().filter((p) => p.engine === targetDb.engine);
1046
1064
  if (candidatePairs.length === 0) return null;
1047
1065
  for (const id of walk.path) {
1048
- const attrs = graph.getNodeAttributes(id);
1049
- if (attrs.type !== import_types.NodeType.ServiceNode) continue;
1050
- const svc = attrs;
1066
+ const owner = resolveOwningService(graph, id);
1067
+ if (!owner) continue;
1068
+ const { id: serviceId3, svc } = owner;
1051
1069
  const deps = svc.dependencies ?? {};
1052
1070
  for (const pair of candidatePairs) {
1053
1071
  const declared = deps[pair.driver];
@@ -1060,7 +1078,7 @@ function databaseRootCauseShape(graph, origin, walk) {
1060
1078
  );
1061
1079
  if (!result.compatible) {
1062
1080
  return {
1063
- rootCauseNode: id,
1081
+ rootCauseNode: serviceId3,
1064
1082
  rootCauseReason: result.reason ?? "incompatible driver",
1065
1083
  ...result.minDriverVersion ? {
1066
1084
  fixRecommendation: `Upgrade ${svc.name} ${pair.driver} driver to >= ${result.minDriverVersion}`
@@ -1073,9 +1091,9 @@ function databaseRootCauseShape(graph, origin, walk) {
1073
1091
  }
1074
1092
  function serviceRootCauseShape(graph, _origin, walk) {
1075
1093
  for (const id of walk.path) {
1076
- const attrs = graph.getNodeAttributes(id);
1077
- if (attrs.type !== import_types.NodeType.ServiceNode) continue;
1078
- const svc = attrs;
1094
+ const owner = resolveOwningService(graph, id);
1095
+ if (!owner) continue;
1096
+ const { id: serviceId3, svc } = owner;
1079
1097
  const deps = svc.dependencies ?? {};
1080
1098
  const serviceNodeEngine = svc.nodeEngine;
1081
1099
  for (const constraint of nodeEngineConstraints()) {
@@ -1084,7 +1102,7 @@ function serviceRootCauseShape(graph, _origin, walk) {
1084
1102
  const result = checkNodeEngineConstraint(constraint, declared, serviceNodeEngine);
1085
1103
  if (!result.compatible && result.reason) {
1086
1104
  return {
1087
- rootCauseNode: id,
1105
+ rootCauseNode: serviceId3,
1088
1106
  rootCauseReason: result.reason,
1089
1107
  ...result.requiredNodeVersion ? {
1090
1108
  fixRecommendation: `Bump ${svc.name}'s engines.node to >= ${result.requiredNodeVersion}`
@@ -1099,7 +1117,7 @@ function serviceRootCauseShape(graph, _origin, walk) {
1099
1117
  const result = checkPackageConflict(conflict, declared, requiredDeclared);
1100
1118
  if (!result.compatible && result.reason) {
1101
1119
  return {
1102
- rootCauseNode: id,
1120
+ rootCauseNode: serviceId3,
1103
1121
  rootCauseReason: result.reason,
1104
1122
  fixRecommendation: `Upgrade ${svc.name}'s ${conflict.requires.name} to >= ${conflict.requires.minVersion}`
1105
1123
  };
@@ -1108,9 +1126,15 @@ function serviceRootCauseShape(graph, _origin, walk) {
1108
1126
  }
1109
1127
  return null;
1110
1128
  }
1129
+ function fileRootCauseShape(graph, origin, walk) {
1130
+ const owner = resolveOwningService(graph, origin.id);
1131
+ if (!owner) return null;
1132
+ return serviceRootCauseShape(graph, owner.svc, walk);
1133
+ }
1111
1134
  var rootCauseShapes = {
1112
1135
  [import_types.NodeType.DatabaseNode]: databaseRootCauseShape,
1113
- [import_types.NodeType.ServiceNode]: serviceRootCauseShape
1136
+ [import_types.NodeType.ServiceNode]: serviceRootCauseShape,
1137
+ [import_types.NodeType.FileNode]: fileRootCauseShape
1114
1138
  };
1115
1139
  function getRootCause(graph, errorNodeId, errorEvent) {
1116
1140
  if (!graph.hasNode(errorNodeId)) return null;
@@ -4026,9 +4050,17 @@ async function addHttpCallEdges(graph, services) {
4026
4050
  line: site.line,
4027
4051
  snippet: snippet(file.content, site.line)
4028
4052
  };
4053
+ const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
4054
+ graph,
4055
+ service.pkg.name,
4056
+ service.node.id,
4057
+ relFile
4058
+ );
4059
+ nodesAdded += n;
4060
+ edgesAdded += e;
4029
4061
  if (!(0, import_types11.passesExtractedFloor)(confidence)) {
4030
4062
  noteExtractedDropped({
4031
- source: service.node.id,
4063
+ source: fileNodeId,
4032
4064
  target: targetId,
4033
4065
  type: import_types11.EdgeType.CALLS,
4034
4066
  confidence,
@@ -4037,14 +4069,6 @@ async function addHttpCallEdges(graph, services) {
4037
4069
  });
4038
4070
  continue;
4039
4071
  }
4040
- const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
4041
- graph,
4042
- service.pkg.name,
4043
- service.node.id,
4044
- relFile
4045
- );
4046
- nodesAdded += n;
4047
- edgesAdded += e;
4048
4072
  const edgeId = (0, import_types5.extractedEdgeId)(fileNodeId, targetId, import_types11.EdgeType.CALLS);
4049
4073
  if (!graph.hasEdge(edgeId)) {
4050
4074
  const edge = {
@@ -4319,9 +4343,18 @@ async function addExternalEndpointEdges(graph, services) {
4319
4343
  }
4320
4344
  const edgeType = edgeTypeFromEndpoint(ep);
4321
4345
  const confidence = (0, import_types16.confidenceForExtracted)(ep.confidenceKind);
4346
+ const relFile = toPosix2(ep.evidence.file);
4347
+ const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
4348
+ graph,
4349
+ service.pkg.name,
4350
+ service.node.id,
4351
+ relFile
4352
+ );
4353
+ nodesAdded += n;
4354
+ edgesAdded += e;
4322
4355
  if (!(0, import_types16.passesExtractedFloor)(confidence)) {
4323
4356
  noteExtractedDropped({
4324
- source: service.node.id,
4357
+ source: fileNodeId,
4325
4358
  target: ep.infraId,
4326
4359
  type: edgeType,
4327
4360
  confidence,
@@ -4330,15 +4363,6 @@ async function addExternalEndpointEdges(graph, services) {
4330
4363
  });
4331
4364
  continue;
4332
4365
  }
4333
- const relFile = toPosix2(ep.evidence.file);
4334
- const { fileNodeId, nodesAdded: n, edgesAdded: e } = ensureFileNode(
4335
- graph,
4336
- service.pkg.name,
4337
- service.node.id,
4338
- relFile
4339
- );
4340
- nodesAdded += n;
4341
- edgesAdded += e;
4342
4366
  const edgeId = (0, import_types5.extractedEdgeId)(fileNodeId, ep.infraId, edgeType);
4343
4367
  if (seenEdges.has(edgeId)) continue;
4344
4368
  seenEdges.add(edgeId);
@@ -5497,14 +5521,18 @@ function registerRoutes(scope, ctx) {
5497
5521
  async function buildApi(opts) {
5498
5522
  const app = (0, import_fastify.default)({ logger: false });
5499
5523
  await app.register(import_cors.default, { origin: true });
5524
+ const env = readAuthEnv();
5525
+ const authToken = opts.authToken ?? env.authToken;
5526
+ const trustProxy = opts.trustProxy ?? env.trustProxy;
5527
+ const publicRead = opts.publicRead ?? env.publicRead;
5500
5528
  mountBearerAuth(app, {
5501
- token: opts.authToken,
5502
- trustProxy: opts.trustProxy,
5503
- publicRead: opts.publicRead
5529
+ token: authToken,
5530
+ trustProxy,
5531
+ publicRead
5504
5532
  });
5505
5533
  app.get("/api/config", async () => ({
5506
- publicRead: opts.publicRead === true,
5507
- authProxy: opts.trustProxy === true
5534
+ publicRead: publicRead === true,
5535
+ authProxy: trustProxy === true
5508
5536
  }));
5509
5537
  const startedAt = opts.startedAt ?? Date.now();
5510
5538
  const registry = buildLegacyRegistry(opts);