@neat.is/core 0.5.4-dev.20260721 → 0.6.0

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  routeSpanToProject,
3
3
  startDaemon
4
- } from "./chunk-VR73QNJD.js";
4
+ } from "./chunk-5PVQJLPR.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-PEFX3DBR.js";
40
+ } from "./chunk-CS4GHQO3.js";
41
41
  import {
42
42
  startOtelGrpcReceiver
43
- } from "./chunk-4RU3AAOI.js";
43
+ } from "./chunk-MVINCLQM.js";
44
44
  import {
45
45
  buildOtelReceiver,
46
46
  logSpanHandler,
47
47
  parseOtlpRequest
48
- } from "./chunk-I4NZ7PSN.js";
48
+ } from "./chunk-BZ3AJVAC.js";
49
49
  export {
50
50
  ProjectNameCollisionError,
51
51
  addProject,
package/dist/neatd.cjs CHANGED
@@ -342,6 +342,11 @@ function pickEnv(spanAttrs, resourceAttrs) {
342
342
  }
343
343
  return ENV_FALLBACK;
344
344
  }
345
+ function normalizeDbSystem(attrs) {
346
+ const raw = attrs["db.system"];
347
+ if (typeof raw !== "string") return void 0;
348
+ return raw === "mongoose" ? "mongodb" : raw;
349
+ }
345
350
  function messagingDestinationOf(attrs) {
346
351
  for (const key of ["messaging.destination.name", "messaging.destination"]) {
347
352
  const v = attrs[key];
@@ -396,7 +401,7 @@ function parseOtlpRequest(body) {
396
401
  durationNanos: durationNanos(span.startTimeUnixNano, span.endTimeUnixNano),
397
402
  env: pickEnv(attrs, resourceAttrs),
398
403
  attributes: attrs,
399
- dbSystem: typeof attrs["db.system"] === "string" ? attrs["db.system"] : void 0,
404
+ dbSystem: normalizeDbSystem(attrs),
400
405
  dbName: typeof attrs["db.name"] === "string" ? attrs["db.name"] : void 0,
401
406
  dbCollection: typeof attrs["db.collection.name"] === "string" ? attrs["db.collection.name"] : typeof attrs["db.mongodb.collection"] === "string" ? attrs["db.mongodb.collection"] : void 0,
402
407
  messagingSystem: typeof attrs["messaging.system"] === "string" ? attrs["messaging.system"] : void 0,
@@ -9774,6 +9779,42 @@ function registerRoutes(scope, ctx) {
9774
9779
  return reply.code(500).send({ error: err.message });
9775
9780
  }
9776
9781
  });
9782
+ scope.get("/instrumentation", async (req2, reply) => {
9783
+ const proj = resolveProject(registry, req2, reply, ctx.bootstrap, ctx.singleProject);
9784
+ if (!proj) return;
9785
+ if (!proj.scanPath) {
9786
+ return { engaged: null };
9787
+ }
9788
+ try {
9789
+ const state = await describeProjectInstrumentation({ project: proj.name, scanPath: proj.scanPath });
9790
+ const uninstrumented = await listUninstrumented({ project: proj.name, scanPath: proj.scanPath });
9791
+ if (state.hookFiles.length === 0) {
9792
+ return {
9793
+ engaged: false,
9794
+ diagnosis: {
9795
+ reason: "No instrumented entry point found \u2014 NEAT hasn't written an OTel init hook for this project.",
9796
+ fixCommand: "neat init",
9797
+ detail: "Run `neat init` so NEAT writes the instrumentation hook next to your entry point, then run your app."
9798
+ }
9799
+ };
9800
+ }
9801
+ if (uninstrumented.length > 0) {
9802
+ const names = uninstrumented.map((u) => u.library);
9803
+ const more = names.length > 1 ? ` (and ${names.length - 1} more)` : "";
9804
+ return {
9805
+ engaged: false,
9806
+ diagnosis: {
9807
+ reason: `\`${names[0]}\`${more} isn't in the auto-instrumentation set, so spans from it won't reach the graph.`,
9808
+ fixCommand: "neat extend",
9809
+ detail: `Uninstrumented on your hot path: ${names.join(", ")}. Run \`neat extend\` to wire the missing instrumentation.`
9810
+ }
9811
+ };
9812
+ }
9813
+ return { engaged: true };
9814
+ } catch {
9815
+ return { engaged: null };
9816
+ }
9817
+ });
9777
9818
  scope.post("/extend/apply", async (req2, reply) => {
9778
9819
  const proj = resolveProject(registry, req2, reply, ctx.bootstrap, ctx.singleProject);
9779
9820
  if (!proj) return;
@@ -11636,15 +11677,21 @@ var PROVIDER_DISPATCH = {
11636
11677
  resolveTarget: createCloudflareResolveTarget(config, graph)
11637
11678
  };
11638
11679
  },
11639
- // GET /user/tokens/verify — Cloudflare's own purpose-built "is this API
11640
- // token live" endpoint. 200 on a valid token, 401 on an invalid one.
11680
+ // GET /accounts/{accountId}/tokens/verify — the *account-scoped* token-verify
11681
+ // endpoint. A Workers connector token is scoped to the account, and the
11682
+ // user-level `GET /user/tokens/verify` returns 401 "Invalid API Token" for
11683
+ // such a token even though it authenticates fine against the account's own
11684
+ // resources (confirmed live). Probing the account-scoped verify endpoint —
11685
+ // `accountId` is already required for this provider — returns 200
11686
+ // `{status:"active"}` for a working token and 401 for a bad one, so a valid
11687
+ // Workers token is no longer falsely rejected at `neat connector add`.
11641
11688
  validate({ credentials, options, fetchImpl }) {
11642
11689
  const cfg = options;
11643
11690
  const baseUrl = cfg.baseUrl ?? CLOUDFLARE_API_BASE_URL;
11644
11691
  return authProbe({
11645
11692
  provider: "cloudflare",
11646
11693
  accountKey: cfg.accountId ?? "validate",
11647
- url: `${baseUrl}/user/tokens/verify`,
11694
+ url: `${baseUrl}/accounts/${cfg.accountId ?? ""}/tokens/verify`,
11648
11695
  token: String(credentials.apiToken ?? ""),
11649
11696
  ...fetchImpl ? { fetchImpl } : {}
11650
11697
  });