@neat.is/core 0.4.13 → 0.4.15
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-HVF4S7J3.js → chunk-6CO7C4IU.js} +6 -3
- package/dist/{chunk-HVF4S7J3.js.map → chunk-6CO7C4IU.js.map} +1 -1
- package/dist/{chunk-3QCRUEQD.js → chunk-GHPHVXYM.js} +5 -3
- package/dist/chunk-GHPHVXYM.js.map +1 -0
- package/dist/{chunk-TWNJX26R.js → chunk-VMLWUK7W.js} +43 -31
- package/dist/chunk-VMLWUK7W.js.map +1 -0
- package/dist/{chunk-5W7H35JJ.js → chunk-XS4CGNRO.js} +2 -2
- package/dist/cli.cjs +17 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +13 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +96 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -4
- package/dist/neatd.cjs +96 -30
- package/dist/neatd.cjs.map +1 -1
- package/dist/neatd.js +3 -3
- package/dist/{otel-grpc-VSPMP3OS.js → otel-grpc-QAISVAY5.js} +3 -3
- package/dist/server.cjs +7 -2
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +3 -3
- package/package.json +6 -2
- package/dist/chunk-3QCRUEQD.js.map +0 -1
- package/dist/chunk-TWNJX26R.js.map +0 -1
- /package/dist/{chunk-5W7H35JJ.js.map → chunk-XS4CGNRO.js.map} +0 -0
- /package/dist/{otel-grpc-VSPMP3OS.js.map → otel-grpc-QAISVAY5.js.map} +0 -0
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
routeSpanToProject,
|
|
3
3
|
startDaemon
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VMLWUK7W.js";
|
|
5
5
|
import {
|
|
6
6
|
ProjectNameCollisionError,
|
|
7
7
|
addProject,
|
|
@@ -37,15 +37,15 @@ import {
|
|
|
37
37
|
thresholdForEdgeType,
|
|
38
38
|
touchLastSeen,
|
|
39
39
|
writeAtomically
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-XS4CGNRO.js";
|
|
41
41
|
import {
|
|
42
42
|
startOtelGrpcReceiver
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-GHPHVXYM.js";
|
|
44
44
|
import {
|
|
45
45
|
buildOtelReceiver,
|
|
46
46
|
logSpanHandler,
|
|
47
47
|
parseOtlpRequest
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-6CO7C4IU.js";
|
|
49
49
|
export {
|
|
50
50
|
ProjectNameCollisionError,
|
|
51
51
|
addProject,
|
package/dist/neatd.cjs
CHANGED
|
@@ -133,7 +133,9 @@ __export(otel_grpc_exports, {
|
|
|
133
133
|
});
|
|
134
134
|
function bytesToHex(buf) {
|
|
135
135
|
if (!buf) return "";
|
|
136
|
-
|
|
136
|
+
if (Buffer.isBuffer(buf)) return buf.toString("hex");
|
|
137
|
+
if (buf instanceof Uint8Array) return Buffer.from(buf).toString("hex");
|
|
138
|
+
return "";
|
|
137
139
|
}
|
|
138
140
|
function nanosToString(n) {
|
|
139
141
|
if (n === void 0 || n === null) return "0";
|
|
@@ -406,7 +408,10 @@ function encodeProtobufResponseBody() {
|
|
|
406
408
|
}
|
|
407
409
|
async function decodeProtobufBody(buf) {
|
|
408
410
|
const Type = loadProtobufDecoder();
|
|
409
|
-
const decoded = Type.decode(buf)
|
|
411
|
+
const decoded = Type.toObject(Type.decode(buf), {
|
|
412
|
+
longs: String,
|
|
413
|
+
enums: Number
|
|
414
|
+
});
|
|
410
415
|
const { reshapeGrpcRequest: reshapeGrpcRequest2 } = await Promise.resolve().then(() => (init_otel_grpc(), otel_grpc_exports));
|
|
411
416
|
return reshapeGrpcRequest2(decoded);
|
|
412
417
|
}
|
|
@@ -963,6 +968,56 @@ eventBus.setMaxListeners(0);
|
|
|
963
968
|
function emitNeatEvent(envelope) {
|
|
964
969
|
eventBus.emit(EVENT_BUS_CHANNEL, envelope);
|
|
965
970
|
}
|
|
971
|
+
function attachGraphToEventBus(graph, opts) {
|
|
972
|
+
const { project } = opts;
|
|
973
|
+
const onNodeAdded = (payload) => {
|
|
974
|
+
emitNeatEvent({
|
|
975
|
+
type: "node-added",
|
|
976
|
+
project,
|
|
977
|
+
payload: { node: payload.attributes }
|
|
978
|
+
});
|
|
979
|
+
};
|
|
980
|
+
const onNodeDropped = (payload) => {
|
|
981
|
+
emitNeatEvent({
|
|
982
|
+
type: "node-removed",
|
|
983
|
+
project,
|
|
984
|
+
payload: { id: payload.key }
|
|
985
|
+
});
|
|
986
|
+
};
|
|
987
|
+
const onEdgeAdded = (payload) => {
|
|
988
|
+
emitNeatEvent({
|
|
989
|
+
type: "edge-added",
|
|
990
|
+
project,
|
|
991
|
+
payload: { edge: payload.attributes }
|
|
992
|
+
});
|
|
993
|
+
};
|
|
994
|
+
const onEdgeDropped = (payload) => {
|
|
995
|
+
emitNeatEvent({
|
|
996
|
+
type: "edge-removed",
|
|
997
|
+
project,
|
|
998
|
+
payload: { id: payload.key }
|
|
999
|
+
});
|
|
1000
|
+
};
|
|
1001
|
+
const onNodeAttrsUpdated = (payload) => {
|
|
1002
|
+
emitNeatEvent({
|
|
1003
|
+
type: "node-updated",
|
|
1004
|
+
project,
|
|
1005
|
+
payload: { id: payload.key, changes: payload.attributes }
|
|
1006
|
+
});
|
|
1007
|
+
};
|
|
1008
|
+
graph.on("nodeAdded", onNodeAdded);
|
|
1009
|
+
graph.on("nodeDropped", onNodeDropped);
|
|
1010
|
+
graph.on("edgeAdded", onEdgeAdded);
|
|
1011
|
+
graph.on("edgeDropped", onEdgeDropped);
|
|
1012
|
+
graph.on("nodeAttributesUpdated", onNodeAttrsUpdated);
|
|
1013
|
+
return () => {
|
|
1014
|
+
graph.off("nodeAdded", onNodeAdded);
|
|
1015
|
+
graph.off("nodeDropped", onNodeDropped);
|
|
1016
|
+
graph.off("edgeAdded", onEdgeAdded);
|
|
1017
|
+
graph.off("edgeDropped", onEdgeDropped);
|
|
1018
|
+
graph.off("nodeAttributesUpdated", onNodeAttrsUpdated);
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
966
1021
|
|
|
967
1022
|
// src/traverse.ts
|
|
968
1023
|
init_cjs_shims();
|
|
@@ -6573,6 +6628,16 @@ function unroutedErrorsPath(neatHome3) {
|
|
|
6573
6628
|
}
|
|
6574
6629
|
|
|
6575
6630
|
// src/daemon.ts
|
|
6631
|
+
function teardownSlot(slot) {
|
|
6632
|
+
try {
|
|
6633
|
+
slot.stopPersist();
|
|
6634
|
+
} catch {
|
|
6635
|
+
}
|
|
6636
|
+
try {
|
|
6637
|
+
slot.detachEvents();
|
|
6638
|
+
} catch {
|
|
6639
|
+
}
|
|
6640
|
+
}
|
|
6576
6641
|
function neatHomeFor(opts) {
|
|
6577
6642
|
if (opts.neatHome && opts.neatHome.length > 0) return import_node_path41.default.resolve(opts.neatHome);
|
|
6578
6643
|
const env = process.env.NEAT_HOME;
|
|
@@ -6631,6 +6696,8 @@ async function bootstrapProject(entry2) {
|
|
|
6631
6696
|
paths,
|
|
6632
6697
|
stopPersist: () => {
|
|
6633
6698
|
},
|
|
6699
|
+
detachEvents: () => {
|
|
6700
|
+
},
|
|
6634
6701
|
status: "broken",
|
|
6635
6702
|
errorReason: err.message
|
|
6636
6703
|
};
|
|
@@ -6639,18 +6706,25 @@ async function bootstrapProject(entry2) {
|
|
|
6639
6706
|
const graph = getGraph(entry2.name);
|
|
6640
6707
|
const outPath = paths.snapshotPath;
|
|
6641
6708
|
await loadGraphFromDisk(graph, outPath);
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6709
|
+
const detachEvents = attachGraphToEventBus(graph, { project: entry2.name });
|
|
6710
|
+
try {
|
|
6711
|
+
await extractFromDirectory(graph, entry2.path);
|
|
6712
|
+
const stopPersist = startPersistLoop(graph, outPath);
|
|
6713
|
+
await touchLastSeen(entry2.name).catch(() => {
|
|
6714
|
+
});
|
|
6715
|
+
return {
|
|
6716
|
+
entry: entry2,
|
|
6717
|
+
graph,
|
|
6718
|
+
outPath,
|
|
6719
|
+
paths,
|
|
6720
|
+
stopPersist,
|
|
6721
|
+
detachEvents,
|
|
6722
|
+
status: "active"
|
|
6723
|
+
};
|
|
6724
|
+
} catch (err) {
|
|
6725
|
+
detachEvents();
|
|
6726
|
+
throw err;
|
|
6727
|
+
}
|
|
6654
6728
|
}
|
|
6655
6729
|
function resolveRestPort(opts) {
|
|
6656
6730
|
if (typeof opts.restPort === "number") return opts.restPort;
|
|
@@ -6732,6 +6806,8 @@ async function startDaemon(opts = {}) {
|
|
|
6732
6806
|
async function tryRecoverSlot(entry2) {
|
|
6733
6807
|
try {
|
|
6734
6808
|
const fresh = await bootstrapProject(entry2);
|
|
6809
|
+
const prior = slots.get(entry2.name);
|
|
6810
|
+
if (prior) teardownSlot(prior);
|
|
6735
6811
|
slots.set(entry2.name, fresh);
|
|
6736
6812
|
upsertRegistryFromSlot(fresh);
|
|
6737
6813
|
if (fresh.status === "active") {
|
|
@@ -6754,6 +6830,8 @@ async function startDaemon(opts = {}) {
|
|
|
6754
6830
|
bootstrapStartedAt.set(entry2.name, Date.now());
|
|
6755
6831
|
try {
|
|
6756
6832
|
const slot = await bootstrapProject(entry2);
|
|
6833
|
+
const prior = slots.get(entry2.name);
|
|
6834
|
+
if (prior) teardownSlot(prior);
|
|
6757
6835
|
slots.set(entry2.name, slot);
|
|
6758
6836
|
upsertRegistryFromSlot(slot);
|
|
6759
6837
|
bootstrapStatus.set(entry2.name, slot.status === "broken" ? "broken" : "active");
|
|
@@ -6789,10 +6867,7 @@ async function startDaemon(opts = {}) {
|
|
|
6789
6867
|
}
|
|
6790
6868
|
for (const [name, slot] of [...slots.entries()]) {
|
|
6791
6869
|
if (seen.has(name)) continue;
|
|
6792
|
-
|
|
6793
|
-
slot.stopPersist();
|
|
6794
|
-
} catch {
|
|
6795
|
-
}
|
|
6870
|
+
teardownSlot(slot);
|
|
6796
6871
|
slots.delete(name);
|
|
6797
6872
|
bootstrapStatus.delete(name);
|
|
6798
6873
|
bootstrapStartedAt.delete(name);
|
|
@@ -6838,10 +6913,7 @@ async function startDaemon(opts = {}) {
|
|
|
6838
6913
|
console.log(`neatd: REST listening on ${restAddress}`);
|
|
6839
6914
|
} catch (err) {
|
|
6840
6915
|
for (const slot of slots.values()) {
|
|
6841
|
-
|
|
6842
|
-
slot.stopPersist();
|
|
6843
|
-
} catch {
|
|
6844
|
-
}
|
|
6916
|
+
teardownSlot(slot);
|
|
6845
6917
|
}
|
|
6846
6918
|
if (restApp) await restApp.close().catch(() => {
|
|
6847
6919
|
});
|
|
@@ -6942,10 +7014,7 @@ async function startDaemon(opts = {}) {
|
|
|
6942
7014
|
console.log(`neatd: OTLP listening on ${otlpAddress}/v1/traces`);
|
|
6943
7015
|
} catch (err) {
|
|
6944
7016
|
for (const slot of slots.values()) {
|
|
6945
|
-
|
|
6946
|
-
slot.stopPersist();
|
|
6947
|
-
} catch {
|
|
6948
|
-
}
|
|
7017
|
+
teardownSlot(slot);
|
|
6949
7018
|
}
|
|
6950
7019
|
if (restApp) await restApp.close().catch(() => {
|
|
6951
7020
|
});
|
|
@@ -7037,10 +7106,7 @@ async function startDaemon(opts = {}) {
|
|
|
7037
7106
|
if (restApp) await restApp.close().catch(() => {
|
|
7038
7107
|
});
|
|
7039
7108
|
for (const slot of slots.values()) {
|
|
7040
|
-
|
|
7041
|
-
slot.stopPersist();
|
|
7042
|
-
} catch {
|
|
7043
|
-
}
|
|
7109
|
+
teardownSlot(slot);
|
|
7044
7110
|
}
|
|
7045
7111
|
await import_node_fs25.promises.unlink(pidPath).catch(() => {
|
|
7046
7112
|
});
|