@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.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
|
}
|
|
@@ -1007,6 +1012,56 @@ eventBus.setMaxListeners(0);
|
|
|
1007
1012
|
function emitNeatEvent(envelope) {
|
|
1008
1013
|
eventBus.emit(EVENT_BUS_CHANNEL, envelope);
|
|
1009
1014
|
}
|
|
1015
|
+
function attachGraphToEventBus(graph, opts) {
|
|
1016
|
+
const { project } = opts;
|
|
1017
|
+
const onNodeAdded = (payload) => {
|
|
1018
|
+
emitNeatEvent({
|
|
1019
|
+
type: "node-added",
|
|
1020
|
+
project,
|
|
1021
|
+
payload: { node: payload.attributes }
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
const onNodeDropped = (payload) => {
|
|
1025
|
+
emitNeatEvent({
|
|
1026
|
+
type: "node-removed",
|
|
1027
|
+
project,
|
|
1028
|
+
payload: { id: payload.key }
|
|
1029
|
+
});
|
|
1030
|
+
};
|
|
1031
|
+
const onEdgeAdded = (payload) => {
|
|
1032
|
+
emitNeatEvent({
|
|
1033
|
+
type: "edge-added",
|
|
1034
|
+
project,
|
|
1035
|
+
payload: { edge: payload.attributes }
|
|
1036
|
+
});
|
|
1037
|
+
};
|
|
1038
|
+
const onEdgeDropped = (payload) => {
|
|
1039
|
+
emitNeatEvent({
|
|
1040
|
+
type: "edge-removed",
|
|
1041
|
+
project,
|
|
1042
|
+
payload: { id: payload.key }
|
|
1043
|
+
});
|
|
1044
|
+
};
|
|
1045
|
+
const onNodeAttrsUpdated = (payload) => {
|
|
1046
|
+
emitNeatEvent({
|
|
1047
|
+
type: "node-updated",
|
|
1048
|
+
project,
|
|
1049
|
+
payload: { id: payload.key, changes: payload.attributes }
|
|
1050
|
+
});
|
|
1051
|
+
};
|
|
1052
|
+
graph.on("nodeAdded", onNodeAdded);
|
|
1053
|
+
graph.on("nodeDropped", onNodeDropped);
|
|
1054
|
+
graph.on("edgeAdded", onEdgeAdded);
|
|
1055
|
+
graph.on("edgeDropped", onEdgeDropped);
|
|
1056
|
+
graph.on("nodeAttributesUpdated", onNodeAttrsUpdated);
|
|
1057
|
+
return () => {
|
|
1058
|
+
graph.off("nodeAdded", onNodeAdded);
|
|
1059
|
+
graph.off("nodeDropped", onNodeDropped);
|
|
1060
|
+
graph.off("edgeAdded", onEdgeAdded);
|
|
1061
|
+
graph.off("edgeDropped", onEdgeDropped);
|
|
1062
|
+
graph.off("nodeAttributesUpdated", onNodeAttrsUpdated);
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1010
1065
|
|
|
1011
1066
|
// src/traverse.ts
|
|
1012
1067
|
init_cjs_shims();
|
|
@@ -6777,6 +6832,16 @@ function unroutedErrorsPath(neatHome2) {
|
|
|
6777
6832
|
}
|
|
6778
6833
|
|
|
6779
6834
|
// src/daemon.ts
|
|
6835
|
+
function teardownSlot(slot) {
|
|
6836
|
+
try {
|
|
6837
|
+
slot.stopPersist();
|
|
6838
|
+
} catch {
|
|
6839
|
+
}
|
|
6840
|
+
try {
|
|
6841
|
+
slot.detachEvents();
|
|
6842
|
+
} catch {
|
|
6843
|
+
}
|
|
6844
|
+
}
|
|
6780
6845
|
function neatHomeFor(opts) {
|
|
6781
6846
|
if (opts.neatHome && opts.neatHome.length > 0) return import_node_path41.default.resolve(opts.neatHome);
|
|
6782
6847
|
const env = process.env.NEAT_HOME;
|
|
@@ -6835,6 +6900,8 @@ async function bootstrapProject(entry) {
|
|
|
6835
6900
|
paths,
|
|
6836
6901
|
stopPersist: () => {
|
|
6837
6902
|
},
|
|
6903
|
+
detachEvents: () => {
|
|
6904
|
+
},
|
|
6838
6905
|
status: "broken",
|
|
6839
6906
|
errorReason: err.message
|
|
6840
6907
|
};
|
|
@@ -6843,18 +6910,25 @@ async function bootstrapProject(entry) {
|
|
|
6843
6910
|
const graph = getGraph(entry.name);
|
|
6844
6911
|
const outPath = paths.snapshotPath;
|
|
6845
6912
|
await loadGraphFromDisk(graph, outPath);
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6913
|
+
const detachEvents = attachGraphToEventBus(graph, { project: entry.name });
|
|
6914
|
+
try {
|
|
6915
|
+
await extractFromDirectory(graph, entry.path);
|
|
6916
|
+
const stopPersist = startPersistLoop(graph, outPath);
|
|
6917
|
+
await touchLastSeen(entry.name).catch(() => {
|
|
6918
|
+
});
|
|
6919
|
+
return {
|
|
6920
|
+
entry,
|
|
6921
|
+
graph,
|
|
6922
|
+
outPath,
|
|
6923
|
+
paths,
|
|
6924
|
+
stopPersist,
|
|
6925
|
+
detachEvents,
|
|
6926
|
+
status: "active"
|
|
6927
|
+
};
|
|
6928
|
+
} catch (err) {
|
|
6929
|
+
detachEvents();
|
|
6930
|
+
throw err;
|
|
6931
|
+
}
|
|
6858
6932
|
}
|
|
6859
6933
|
function resolveRestPort(opts) {
|
|
6860
6934
|
if (typeof opts.restPort === "number") return opts.restPort;
|
|
@@ -6936,6 +7010,8 @@ async function startDaemon(opts = {}) {
|
|
|
6936
7010
|
async function tryRecoverSlot(entry) {
|
|
6937
7011
|
try {
|
|
6938
7012
|
const fresh = await bootstrapProject(entry);
|
|
7013
|
+
const prior = slots.get(entry.name);
|
|
7014
|
+
if (prior) teardownSlot(prior);
|
|
6939
7015
|
slots.set(entry.name, fresh);
|
|
6940
7016
|
upsertRegistryFromSlot(fresh);
|
|
6941
7017
|
if (fresh.status === "active") {
|
|
@@ -6958,6 +7034,8 @@ async function startDaemon(opts = {}) {
|
|
|
6958
7034
|
bootstrapStartedAt.set(entry.name, Date.now());
|
|
6959
7035
|
try {
|
|
6960
7036
|
const slot = await bootstrapProject(entry);
|
|
7037
|
+
const prior = slots.get(entry.name);
|
|
7038
|
+
if (prior) teardownSlot(prior);
|
|
6961
7039
|
slots.set(entry.name, slot);
|
|
6962
7040
|
upsertRegistryFromSlot(slot);
|
|
6963
7041
|
bootstrapStatus.set(entry.name, slot.status === "broken" ? "broken" : "active");
|
|
@@ -6993,10 +7071,7 @@ async function startDaemon(opts = {}) {
|
|
|
6993
7071
|
}
|
|
6994
7072
|
for (const [name, slot] of [...slots.entries()]) {
|
|
6995
7073
|
if (seen.has(name)) continue;
|
|
6996
|
-
|
|
6997
|
-
slot.stopPersist();
|
|
6998
|
-
} catch {
|
|
6999
|
-
}
|
|
7074
|
+
teardownSlot(slot);
|
|
7000
7075
|
slots.delete(name);
|
|
7001
7076
|
bootstrapStatus.delete(name);
|
|
7002
7077
|
bootstrapStartedAt.delete(name);
|
|
@@ -7042,10 +7117,7 @@ async function startDaemon(opts = {}) {
|
|
|
7042
7117
|
console.log(`neatd: REST listening on ${restAddress}`);
|
|
7043
7118
|
} catch (err) {
|
|
7044
7119
|
for (const slot of slots.values()) {
|
|
7045
|
-
|
|
7046
|
-
slot.stopPersist();
|
|
7047
|
-
} catch {
|
|
7048
|
-
}
|
|
7120
|
+
teardownSlot(slot);
|
|
7049
7121
|
}
|
|
7050
7122
|
if (restApp) await restApp.close().catch(() => {
|
|
7051
7123
|
});
|
|
@@ -7146,10 +7218,7 @@ async function startDaemon(opts = {}) {
|
|
|
7146
7218
|
console.log(`neatd: OTLP listening on ${otlpAddress}/v1/traces`);
|
|
7147
7219
|
} catch (err) {
|
|
7148
7220
|
for (const slot of slots.values()) {
|
|
7149
|
-
|
|
7150
|
-
slot.stopPersist();
|
|
7151
|
-
} catch {
|
|
7152
|
-
}
|
|
7221
|
+
teardownSlot(slot);
|
|
7153
7222
|
}
|
|
7154
7223
|
if (restApp) await restApp.close().catch(() => {
|
|
7155
7224
|
});
|
|
@@ -7241,10 +7310,7 @@ async function startDaemon(opts = {}) {
|
|
|
7241
7310
|
if (restApp) await restApp.close().catch(() => {
|
|
7242
7311
|
});
|
|
7243
7312
|
for (const slot of slots.values()) {
|
|
7244
|
-
|
|
7245
|
-
slot.stopPersist();
|
|
7246
|
-
} catch {
|
|
7247
|
-
}
|
|
7313
|
+
teardownSlot(slot);
|
|
7248
7314
|
}
|
|
7249
7315
|
await import_node_fs25.promises.unlink(pidPath).catch(() => {
|
|
7250
7316
|
});
|