@neat.is/core 0.5.2 → 0.5.3
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-BI3XKGVG.js → chunk-GJHEZC5K.js} +56 -21
- package/dist/chunk-GJHEZC5K.js.map +1 -0
- package/dist/{chunk-DPEPI2N6.js → chunk-X2AMX3QZ.js} +32 -14
- package/dist/chunk-X2AMX3QZ.js.map +1 -0
- package/dist/cli.cjs +366 -120
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +250 -58
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +85 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/neatd.cjs +85 -32
- package/dist/neatd.cjs.map +1 -1
- package/dist/neatd.js +2 -2
- package/dist/server.cjs +55 -20
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-BI3XKGVG.js.map +0 -1
- package/dist/chunk-DPEPI2N6.js.map +0 -1
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
touchLastSeen,
|
|
32
32
|
upsertObservedEdge,
|
|
33
33
|
writeAtomically
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-GJHEZC5K.js";
|
|
35
35
|
import {
|
|
36
36
|
assertBindAuthority,
|
|
37
37
|
buildOtelReceiver,
|
|
@@ -98,8 +98,8 @@ async function runConnectorPoll(connector, ctx, graph, resolveTarget) {
|
|
|
98
98
|
line: callSite.line
|
|
99
99
|
} : void 0;
|
|
100
100
|
const calls = Math.trunc(signal.callCount);
|
|
101
|
-
if (calls < 1) continue;
|
|
102
|
-
const errors = Math.min(Math.max(Math.trunc(signal.errorCount), 0), calls);
|
|
101
|
+
if (!Number.isFinite(calls) || calls < 1) continue;
|
|
102
|
+
const errors = Number.isFinite(signal.errorCount) ? Math.min(Math.max(Math.trunc(signal.errorCount), 0), calls) : 0;
|
|
103
103
|
let created = false;
|
|
104
104
|
let ok = true;
|
|
105
105
|
for (let i = 0; i < calls; i++) {
|
|
@@ -534,7 +534,10 @@ function targetFromRestPath(path3) {
|
|
|
534
534
|
var ERROR_STATUS_THRESHOLD = 500;
|
|
535
535
|
function mapEdgeLogRowsToSignals(rows) {
|
|
536
536
|
const buckets2 = /* @__PURE__ */ new Map();
|
|
537
|
+
if (!Array.isArray(rows)) return [];
|
|
537
538
|
for (const row of rows) {
|
|
539
|
+
if (!row || typeof row !== "object") continue;
|
|
540
|
+
if (typeof row.path !== "string" || typeof row.timestamp !== "string") continue;
|
|
538
541
|
const target = targetFromRestPath(row.path);
|
|
539
542
|
if (!target) continue;
|
|
540
543
|
const key = `${target.targetKind}:${target.name}`;
|
|
@@ -575,9 +578,12 @@ function tableNameFromQueryText(query) {
|
|
|
575
578
|
function diffPgStatStatementsToSignals(rows, previous, nowIso) {
|
|
576
579
|
const signals = [];
|
|
577
580
|
const seen = /* @__PURE__ */ new Set();
|
|
581
|
+
if (!Array.isArray(rows)) return signals;
|
|
578
582
|
for (const row of rows) {
|
|
579
|
-
|
|
583
|
+
if (!row || typeof row !== "object" || typeof row.queryid !== "string") continue;
|
|
580
584
|
const calls = Number(row.calls);
|
|
585
|
+
if (!Number.isFinite(calls)) continue;
|
|
586
|
+
seen.add(row.queryid);
|
|
581
587
|
const prior = previous.get(row.queryid);
|
|
582
588
|
previous.set(row.queryid, { calls });
|
|
583
589
|
if (!prior || calls < prior.calls) continue;
|
|
@@ -897,7 +903,12 @@ function upsertBucket(buckets2, key, isError, timestamp, build) {
|
|
|
897
903
|
}
|
|
898
904
|
function mapRailwayHttpLogsToSignals(entries, routeIndex) {
|
|
899
905
|
const buckets2 = /* @__PURE__ */ new Map();
|
|
906
|
+
if (!Array.isArray(entries)) return [];
|
|
900
907
|
for (const entry of entries) {
|
|
908
|
+
if (!entry || typeof entry !== "object") continue;
|
|
909
|
+
if (typeof entry.method !== "string" || typeof entry.path !== "string" || typeof entry.timestamp !== "string") {
|
|
910
|
+
continue;
|
|
911
|
+
}
|
|
901
912
|
const method = entry.method.toUpperCase();
|
|
902
913
|
const normalizedPath = normalizePathTemplate(entry.path);
|
|
903
914
|
const match = findRailwayRoute(routeIndex, method, normalizedPath);
|
|
@@ -936,8 +947,11 @@ function mapRailwayHttpLogsToSignals(entries, routeIndex) {
|
|
|
936
947
|
}
|
|
937
948
|
function mapRailwayNetworkFlowLogsToSignals(entries) {
|
|
938
949
|
const buckets2 = /* @__PURE__ */ new Map();
|
|
950
|
+
if (!Array.isArray(entries)) return [];
|
|
939
951
|
for (const entry of entries) {
|
|
940
|
-
if (!entry
|
|
952
|
+
if (!entry || typeof entry !== "object") continue;
|
|
953
|
+
if (typeof entry.peerServiceId !== "string" || entry.peerServiceId.length === 0) continue;
|
|
954
|
+
if (typeof entry.timestamp !== "string") continue;
|
|
941
955
|
const isError = entry.dropCause !== null && entry.dropCause !== "";
|
|
942
956
|
upsertBucket(buckets2, entry.peerServiceId, isError, entry.timestamp, () => ({
|
|
943
957
|
targetKind: PEER_SERVICE_TARGET_KIND,
|
|
@@ -1061,7 +1075,7 @@ async function fetchHttpRequestLogEntries(creds, sinceIso) {
|
|
|
1061
1075
|
throw new Error(`Cloud Logging entries.list failed: ${res.status} ${res.statusText}`);
|
|
1062
1076
|
}
|
|
1063
1077
|
const json = await res.json();
|
|
1064
|
-
out.push(...json.entries
|
|
1078
|
+
if (Array.isArray(json.entries)) out.push(...json.entries);
|
|
1065
1079
|
if (!json.nextPageToken) break;
|
|
1066
1080
|
pageToken = json.nextPageToken;
|
|
1067
1081
|
}
|
|
@@ -1097,7 +1111,7 @@ function resourceNameFor(type, labels) {
|
|
|
1097
1111
|
}
|
|
1098
1112
|
}
|
|
1099
1113
|
function pathFromRequestUrl(requestUrl) {
|
|
1100
|
-
if (
|
|
1114
|
+
if (typeof requestUrl !== "string" || requestUrl.length === 0) return null;
|
|
1101
1115
|
if (requestUrl.startsWith("/")) {
|
|
1102
1116
|
const withoutQuery = requestUrl.split("?")[0];
|
|
1103
1117
|
return withoutQuery && withoutQuery.length > 0 ? withoutQuery : "/";
|
|
@@ -1112,18 +1126,19 @@ function pathFromRequestUrl(requestUrl) {
|
|
|
1112
1126
|
}
|
|
1113
1127
|
var ERROR_STATUS_THRESHOLD2 = 500;
|
|
1114
1128
|
function mapLogEntryToSignal(entry) {
|
|
1129
|
+
if (!entry || typeof entry !== "object") return null;
|
|
1115
1130
|
const resourceType = entry.resource?.type;
|
|
1116
1131
|
if (!resourceType || !isFirebaseResourceType(resourceType)) return null;
|
|
1117
1132
|
const resourceName = resourceNameFor(resourceType, entry.resource?.labels);
|
|
1118
1133
|
if (!resourceName) return null;
|
|
1119
1134
|
const req = entry.httpRequest;
|
|
1120
1135
|
if (!req) return null;
|
|
1121
|
-
if (
|
|
1136
|
+
if (typeof req.requestMethod !== "string" || req.requestMethod.length === 0) return null;
|
|
1122
1137
|
const method = req.requestMethod.toUpperCase();
|
|
1123
1138
|
const path3 = pathFromRequestUrl(req.requestUrl);
|
|
1124
1139
|
if (path3 === null) return null;
|
|
1125
1140
|
const timestamp = entry.timestamp;
|
|
1126
|
-
if (
|
|
1141
|
+
if (typeof timestamp !== "string" || timestamp.length === 0) return null;
|
|
1127
1142
|
const isError = typeof req.status === "number" && req.status >= ERROR_STATUS_THRESHOLD2;
|
|
1128
1143
|
return {
|
|
1129
1144
|
targetKind: resourceType,
|
|
@@ -1269,7 +1284,7 @@ async function queryWorkerInvocations(ctx, config, window, fetchImpl = fetch) {
|
|
|
1269
1284
|
throw new Error(`cloudflare connector: telemetry query returned an error (${message})`);
|
|
1270
1285
|
}
|
|
1271
1286
|
const events = payload.result?.events?.events;
|
|
1272
|
-
if (events
|
|
1287
|
+
if (!Array.isArray(events)) {
|
|
1273
1288
|
console.warn(
|
|
1274
1289
|
"[neat connector] cloudflare: telemetry query returned success:true but no result.events.events array \u2014 the response shape may have changed; treating as zero events this tick"
|
|
1275
1290
|
);
|
|
@@ -1295,7 +1310,7 @@ var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
|
1295
1310
|
]);
|
|
1296
1311
|
var LEADING_TOKEN_RE = /^(\S+)\s+\S/;
|
|
1297
1312
|
function parseHttpMethodFromTrigger(trigger) {
|
|
1298
|
-
if (
|
|
1313
|
+
if (typeof trigger !== "string") return null;
|
|
1299
1314
|
const match = LEADING_TOKEN_RE.exec(trigger.trim());
|
|
1300
1315
|
const token = match?.[1];
|
|
1301
1316
|
if (!token) return null;
|
|
@@ -1311,14 +1326,17 @@ function parsePathFromTrigger(trigger) {
|
|
|
1311
1326
|
}
|
|
1312
1327
|
var ERROR_STATUS_THRESHOLD3 = 500;
|
|
1313
1328
|
function mapEventToSignal(event) {
|
|
1329
|
+
if (!event || typeof event !== "object") return null;
|
|
1314
1330
|
const metadata = event.$metadata;
|
|
1315
1331
|
const workers = event.$workers;
|
|
1316
1332
|
const method = parseHttpMethodFromTrigger(metadata?.trigger);
|
|
1317
1333
|
if (!method) return null;
|
|
1318
1334
|
const scriptName = workers?.scriptName ?? metadata?.service;
|
|
1319
|
-
if (
|
|
1335
|
+
if (typeof scriptName !== "string" || scriptName.length === 0) return null;
|
|
1320
1336
|
const timestampMs = event.timestamp ?? metadata?.startTime;
|
|
1321
1337
|
if (typeof timestampMs !== "number" || !Number.isFinite(timestampMs)) return null;
|
|
1338
|
+
const observedAt = new Date(timestampMs);
|
|
1339
|
+
if (Number.isNaN(observedAt.getTime())) return null;
|
|
1322
1340
|
const statusCode = metadata?.statusCode;
|
|
1323
1341
|
const isError = typeof statusCode === "number" && statusCode >= ERROR_STATUS_THRESHOLD3;
|
|
1324
1342
|
const path3 = metadata?.trigger ? parsePathFromTrigger(metadata.trigger) : void 0;
|
|
@@ -1327,7 +1345,7 @@ function mapEventToSignal(event) {
|
|
|
1327
1345
|
targetName: scriptName,
|
|
1328
1346
|
callCount: 1,
|
|
1329
1347
|
errorCount: isError ? 1 : 0,
|
|
1330
|
-
lastObservedIso:
|
|
1348
|
+
lastObservedIso: observedAt.toISOString(),
|
|
1331
1349
|
method,
|
|
1332
1350
|
...path3 ? { path: path3 } : {},
|
|
1333
1351
|
...typeof statusCode === "number" ? { statusCode } : {},
|
|
@@ -2488,4 +2506,4 @@ export {
|
|
|
2488
2506
|
resolveHost,
|
|
2489
2507
|
startDaemon
|
|
2490
2508
|
};
|
|
2491
|
-
//# sourceMappingURL=chunk-
|
|
2509
|
+
//# sourceMappingURL=chunk-X2AMX3QZ.js.map
|