@neat.is/core 0.9.0-rc.1 → 0.9.1-dev.20260819

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.
@@ -20,7 +20,7 @@ import {
20
20
  startStalenessLoop,
21
21
  touchLastSeen,
22
22
  writeAtomically
23
- } from "./chunk-RDLDSIEY.js";
23
+ } from "./chunk-JUVJBH23.js";
24
24
  import {
25
25
  assertBindAuthority,
26
26
  buildOtelReceiver,
@@ -891,4 +891,4 @@ export {
891
891
  resolveHost,
892
892
  startDaemon
893
893
  };
894
- //# sourceMappingURL=chunk-WMYVJXUF.js.map
894
+ //# sourceMappingURL=chunk-ICO37D3H.js.map
@@ -9510,6 +9510,11 @@ import path38 from "path";
9510
9510
  import { infraId as infraId2 } from "@neat.is/types";
9511
9511
  var PRODUCER_TOPIC_RE = /(?:producer|kafkaProducer)[\s\S]{0,40}?\.send\s*\(\s*\{[\s\S]{0,200}?topic\s*:\s*['"`]([^'"`]+)['"`]/g;
9512
9512
  var CONSUMER_TOPIC_RE = /(?:consumer|kafkaConsumer)[\s\S]{0,40}?\.(?:subscribe|run)\s*\(\s*\{[\s\S]{0,200}?topic[s]?\s*:\s*(?:\[\s*)?['"`]([^'"`]+)['"`]/g;
9513
+ var SARAMA_IMPORT_RE = /"[^"]*\/sarama"/;
9514
+ var GO_PRODUCER_RE = /ProducerMessage\s*\{[\s\S]{0,300}?\bTopic\s*:\s*(?:"([^"]+)"|`([^`]+)`|([A-Za-z_]\w*))/g;
9515
+ var GO_CONSUMER_RE = /\.Consume\s*\([\s\S]{0,120}?\[\]string\s*\{([^}]*)\}/g;
9516
+ var GO_STRING_LITERAL_RE = /"([^"]+)"|`([^`]+)`/g;
9517
+ var GO_IDENT_RE = /[A-Za-z_]\w*/g;
9513
9518
  function findAll(re, text) {
9514
9519
  re.lastIndex = 0;
9515
9520
  const out = [];
@@ -9519,22 +9524,74 @@ function findAll(re, text) {
9519
9524
  }
9520
9525
  return out;
9521
9526
  }
9527
+ function resolveGoLiteral(ident, text) {
9528
+ const esc = ident.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
9529
+ const re = new RegExp(
9530
+ `\\b${esc}(?:\\s+\\w[\\w.\\[\\]*]*)?\\s*(?::=|=)\\s*(?:"([^"]+)"|\`([^\`]+)\`)`
9531
+ );
9532
+ const m = re.exec(text);
9533
+ if (!m) return void 0;
9534
+ return m[1] ?? m[2];
9535
+ }
9536
+ function producerTopicAnchor(match) {
9537
+ const [full] = match;
9538
+ const tokenLen = match[1] ? match[1].length + 2 : match[2] ? match[2].length + 2 : match[3]?.length ?? 0;
9539
+ return match.index + full.length - tokenLen;
9540
+ }
9541
+ function goSaramaEndpoints(text, emit) {
9542
+ if (!SARAMA_IMPORT_RE.test(text)) return;
9543
+ GO_PRODUCER_RE.lastIndex = 0;
9544
+ let m;
9545
+ while ((m = GO_PRODUCER_RE.exec(text)) !== null) {
9546
+ const literal = m[1] ?? m[2];
9547
+ const anchor = producerTopicAnchor(m);
9548
+ if (literal) {
9549
+ emit(literal, "PUBLISHES_TO", anchor);
9550
+ } else if (m[3]) {
9551
+ const resolved = resolveGoLiteral(m[3], text);
9552
+ if (resolved) emit(resolved, "PUBLISHES_TO", anchor);
9553
+ }
9554
+ }
9555
+ GO_CONSUMER_RE.lastIndex = 0;
9556
+ while ((m = GO_CONSUMER_RE.exec(text)) !== null) {
9557
+ const inside = m[1] ?? "";
9558
+ const anchor = m.index + Math.max(0, m[0].indexOf("[]string"));
9559
+ let sawLiteral = false;
9560
+ GO_STRING_LITERAL_RE.lastIndex = 0;
9561
+ let s;
9562
+ while ((s = GO_STRING_LITERAL_RE.exec(inside)) !== null) {
9563
+ const topic = s[1] ?? s[2];
9564
+ if (topic) {
9565
+ emit(topic, "CONSUMES_FROM", anchor);
9566
+ sawLiteral = true;
9567
+ }
9568
+ }
9569
+ if (sawLiteral) continue;
9570
+ GO_IDENT_RE.lastIndex = 0;
9571
+ let id;
9572
+ while ((id = GO_IDENT_RE.exec(inside)) !== null) {
9573
+ const resolved = resolveGoLiteral(id[0], text);
9574
+ if (resolved) emit(resolved, "CONSUMES_FROM", anchor);
9575
+ }
9576
+ }
9577
+ }
9522
9578
  function kafkaEndpointsFromFile(file, serviceDir) {
9523
9579
  const out = [];
9524
9580
  const seen = /* @__PURE__ */ new Set();
9525
- const make = (topic, edgeType) => {
9581
+ const make = (topic, edgeType, anchor) => {
9526
9582
  const key = `${edgeType}|${topic}`;
9527
9583
  if (seen.has(key)) return;
9528
9584
  seen.add(key);
9529
- const line = lineOf(file.content, topic);
9585
+ const line = anchor !== void 0 ? file.content.slice(0, anchor).split("\n").length : lineOf(file.content, topic);
9530
9586
  out.push({
9531
9587
  infraId: infraId2("kafka-topic", topic),
9532
9588
  name: topic,
9533
9589
  kind: "kafka-topic",
9534
9590
  edgeType,
9535
- // `producer.send({topic: 'x'})` / `consumer.subscribe({topic: 'x'})`
9536
- // framework-aware (kafkajs / node-rdkafka shape). Verified-call-site
9537
- // tier (ADR-066).
9591
+ // JS: `producer.send({topic: 'x'})` / `consumer.subscribe({topic: 'x'})`
9592
+ // (kafkajs / node-rdkafka). Go: `sarama.ProducerMessage{Topic: 'x'}` /
9593
+ // `consumerGroup.Consume(ctx, []string{'x'}, …)`. Both are framework-aware
9594
+ // call sites — verified-call-site tier (ADR-066).
9538
9595
  confidenceKind: "verified-call-site",
9539
9596
  evidence: {
9540
9597
  file: path38.relative(serviceDir, file.path),
@@ -9543,8 +9600,12 @@ function kafkaEndpointsFromFile(file, serviceDir) {
9543
9600
  }
9544
9601
  });
9545
9602
  };
9546
- for (const { topic } of findAll(PRODUCER_TOPIC_RE, file.content)) make(topic, "PUBLISHES_TO");
9547
- for (const { topic } of findAll(CONSUMER_TOPIC_RE, file.content)) make(topic, "CONSUMES_FROM");
9603
+ if (path38.extname(file.path) === ".go") {
9604
+ goSaramaEndpoints(file.content, make);
9605
+ } else {
9606
+ for (const { topic } of findAll(PRODUCER_TOPIC_RE, file.content)) make(topic, "PUBLISHES_TO");
9607
+ for (const { topic } of findAll(CONSUMER_TOPIC_RE, file.content)) make(topic, "CONSUMES_FROM");
9608
+ }
9548
9609
  return out;
9549
9610
  }
9550
9611
 
@@ -20040,4 +20101,4 @@ export {
20040
20101
  deprovisionConnector,
20041
20102
  buildApi
20042
20103
  };
20043
- //# sourceMappingURL=chunk-RDLDSIEY.js.map
20104
+ //# sourceMappingURL=chunk-JUVJBH23.js.map