@neat.is/core 0.9.0 → 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.
package/dist/neatd.js CHANGED
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  reconcileDaemonRecordSync,
4
4
  startDaemon
5
- } from "./chunk-WMYVJXUF.js";
5
+ } from "./chunk-ICO37D3H.js";
6
6
  import {
7
7
  listProjects,
8
8
  registryPath
9
- } from "./chunk-RDLDSIEY.js";
9
+ } from "./chunk-JUVJBH23.js";
10
10
  import {
11
11
  BindAuthorityError,
12
12
  __require
package/dist/server.cjs CHANGED
@@ -10812,6 +10812,11 @@ var import_node_path40 = __toESM(require("path"), 1);
10812
10812
  var import_types29 = require("@neat.is/types");
10813
10813
  var PRODUCER_TOPIC_RE = /(?:producer|kafkaProducer)[\s\S]{0,40}?\.send\s*\(\s*\{[\s\S]{0,200}?topic\s*:\s*['"`]([^'"`]+)['"`]/g;
10814
10814
  var CONSUMER_TOPIC_RE = /(?:consumer|kafkaConsumer)[\s\S]{0,40}?\.(?:subscribe|run)\s*\(\s*\{[\s\S]{0,200}?topic[s]?\s*:\s*(?:\[\s*)?['"`]([^'"`]+)['"`]/g;
10815
+ var SARAMA_IMPORT_RE = /"[^"]*\/sarama"/;
10816
+ var GO_PRODUCER_RE = /ProducerMessage\s*\{[\s\S]{0,300}?\bTopic\s*:\s*(?:"([^"]+)"|`([^`]+)`|([A-Za-z_]\w*))/g;
10817
+ var GO_CONSUMER_RE = /\.Consume\s*\([\s\S]{0,120}?\[\]string\s*\{([^}]*)\}/g;
10818
+ var GO_STRING_LITERAL_RE = /"([^"]+)"|`([^`]+)`/g;
10819
+ var GO_IDENT_RE = /[A-Za-z_]\w*/g;
10815
10820
  function findAll(re, text) {
10816
10821
  re.lastIndex = 0;
10817
10822
  const out = [];
@@ -10821,22 +10826,74 @@ function findAll(re, text) {
10821
10826
  }
10822
10827
  return out;
10823
10828
  }
10829
+ function resolveGoLiteral(ident, text) {
10830
+ const esc = ident.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
10831
+ const re = new RegExp(
10832
+ `\\b${esc}(?:\\s+\\w[\\w.\\[\\]*]*)?\\s*(?::=|=)\\s*(?:"([^"]+)"|\`([^\`]+)\`)`
10833
+ );
10834
+ const m = re.exec(text);
10835
+ if (!m) return void 0;
10836
+ return m[1] ?? m[2];
10837
+ }
10838
+ function producerTopicAnchor(match) {
10839
+ const [full] = match;
10840
+ const tokenLen = match[1] ? match[1].length + 2 : match[2] ? match[2].length + 2 : match[3]?.length ?? 0;
10841
+ return match.index + full.length - tokenLen;
10842
+ }
10843
+ function goSaramaEndpoints(text, emit) {
10844
+ if (!SARAMA_IMPORT_RE.test(text)) return;
10845
+ GO_PRODUCER_RE.lastIndex = 0;
10846
+ let m;
10847
+ while ((m = GO_PRODUCER_RE.exec(text)) !== null) {
10848
+ const literal = m[1] ?? m[2];
10849
+ const anchor = producerTopicAnchor(m);
10850
+ if (literal) {
10851
+ emit(literal, "PUBLISHES_TO", anchor);
10852
+ } else if (m[3]) {
10853
+ const resolved = resolveGoLiteral(m[3], text);
10854
+ if (resolved) emit(resolved, "PUBLISHES_TO", anchor);
10855
+ }
10856
+ }
10857
+ GO_CONSUMER_RE.lastIndex = 0;
10858
+ while ((m = GO_CONSUMER_RE.exec(text)) !== null) {
10859
+ const inside = m[1] ?? "";
10860
+ const anchor = m.index + Math.max(0, m[0].indexOf("[]string"));
10861
+ let sawLiteral = false;
10862
+ GO_STRING_LITERAL_RE.lastIndex = 0;
10863
+ let s;
10864
+ while ((s = GO_STRING_LITERAL_RE.exec(inside)) !== null) {
10865
+ const topic = s[1] ?? s[2];
10866
+ if (topic) {
10867
+ emit(topic, "CONSUMES_FROM", anchor);
10868
+ sawLiteral = true;
10869
+ }
10870
+ }
10871
+ if (sawLiteral) continue;
10872
+ GO_IDENT_RE.lastIndex = 0;
10873
+ let id;
10874
+ while ((id = GO_IDENT_RE.exec(inside)) !== null) {
10875
+ const resolved = resolveGoLiteral(id[0], text);
10876
+ if (resolved) emit(resolved, "CONSUMES_FROM", anchor);
10877
+ }
10878
+ }
10879
+ }
10824
10880
  function kafkaEndpointsFromFile(file, serviceDir) {
10825
10881
  const out = [];
10826
10882
  const seen = /* @__PURE__ */ new Set();
10827
- const make = (topic, edgeType) => {
10883
+ const make = (topic, edgeType, anchor) => {
10828
10884
  const key = `${edgeType}|${topic}`;
10829
10885
  if (seen.has(key)) return;
10830
10886
  seen.add(key);
10831
- const line = lineOf(file.content, topic);
10887
+ const line = anchor !== void 0 ? file.content.slice(0, anchor).split("\n").length : lineOf(file.content, topic);
10832
10888
  out.push({
10833
10889
  infraId: (0, import_types29.infraId)("kafka-topic", topic),
10834
10890
  name: topic,
10835
10891
  kind: "kafka-topic",
10836
10892
  edgeType,
10837
- // `producer.send({topic: 'x'})` / `consumer.subscribe({topic: 'x'})`
10838
- // framework-aware (kafkajs / node-rdkafka shape). Verified-call-site
10839
- // tier (ADR-066).
10893
+ // JS: `producer.send({topic: 'x'})` / `consumer.subscribe({topic: 'x'})`
10894
+ // (kafkajs / node-rdkafka). Go: `sarama.ProducerMessage{Topic: 'x'}` /
10895
+ // `consumerGroup.Consume(ctx, []string{'x'}, …)`. Both are framework-aware
10896
+ // call sites — verified-call-site tier (ADR-066).
10840
10897
  confidenceKind: "verified-call-site",
10841
10898
  evidence: {
10842
10899
  file: import_node_path40.default.relative(serviceDir, file.path),
@@ -10845,8 +10902,12 @@ function kafkaEndpointsFromFile(file, serviceDir) {
10845
10902
  }
10846
10903
  });
10847
10904
  };
10848
- for (const { topic } of findAll(PRODUCER_TOPIC_RE, file.content)) make(topic, "PUBLISHES_TO");
10849
- for (const { topic } of findAll(CONSUMER_TOPIC_RE, file.content)) make(topic, "CONSUMES_FROM");
10905
+ if (import_node_path40.default.extname(file.path) === ".go") {
10906
+ goSaramaEndpoints(file.content, make);
10907
+ } else {
10908
+ for (const { topic } of findAll(PRODUCER_TOPIC_RE, file.content)) make(topic, "PUBLISHES_TO");
10909
+ for (const { topic } of findAll(CONSUMER_TOPIC_RE, file.content)) make(topic, "CONSUMES_FROM");
10910
+ }
10850
10911
  return out;
10851
10912
  }
10852
10913