@neat.is/core 0.4.26-dev.20260703 → 0.4.26

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/cli.js CHANGED
@@ -6,10 +6,10 @@ import {
6
6
  resolveHost,
7
7
  resolveNeatVersion,
8
8
  writeDaemonRecord
9
- } from "./chunk-S7TDPQDD.js";
9
+ } from "./chunk-XV4D7A3Z.js";
10
10
  import {
11
11
  buildSearchIndex
12
- } from "./chunk-4OR4RQEO.js";
12
+ } from "./chunk-BIY46Q6U.js";
13
13
  import {
14
14
  DEFAULT_PROJECT,
15
15
  PolicyViolationsLog,
@@ -59,10 +59,10 @@ import {
59
59
  signalDaemonStop,
60
60
  startPersistLoop,
61
61
  startStalenessLoop
62
- } from "./chunk-WZYH5DVG.js";
62
+ } from "./chunk-QM6BMPVJ.js";
63
63
  import {
64
64
  startOtelGrpcReceiver
65
- } from "./chunk-C5NCCKPZ.js";
65
+ } from "./chunk-UV5WSM7M.js";
66
66
  import {
67
67
  __dirname,
68
68
  __require,
@@ -70,7 +70,7 @@ import {
70
70
  buildOtelReceiver,
71
71
  listenSteppingOtlp,
72
72
  readAuthEnv
73
- } from "./chunk-2LNICOVU.js";
73
+ } from "./chunk-A3322JYS.js";
74
74
 
75
75
  // src/cli.ts
76
76
  import path9 from "path";
@@ -1220,6 +1220,9 @@ export async function register() {
1220
1220
  if (process.env.NEXT_RUNTIME === 'nodejs') {
1221
1221
  await import('./instrumentation.node')
1222
1222
  }
1223
+ if (process.env.NEXT_RUNTIME === 'edge') {
1224
+ await import('./instrumentation.edge')
1225
+ }
1223
1226
  }
1224
1227
  `;
1225
1228
  var NEXT_INSTRUMENTATION_JS = `${NEXT_INSTRUMENTATION_HEADER}
@@ -1227,6 +1230,9 @@ export async function register() {
1227
1230
  if (process.env.NEXT_RUNTIME === 'nodejs') {
1228
1231
  await import('./instrumentation.node')
1229
1232
  }
1233
+ if (process.env.NEXT_RUNTIME === 'edge') {
1234
+ await import('./instrumentation.edge')
1235
+ }
1230
1236
  }
1231
1237
  `;
1232
1238
  var NEXT_INSTRUMENTATION_NODE_TS = `${NEXT_INSTRUMENTATION_HEADER}
@@ -1262,6 +1268,18 @@ ${registrations.join("\n")}
1262
1268
  `;
1263
1269
  return template.replace(/__SERVICE_NAME__/g, serviceName).replace(/__PROJECT__/g, projectName).replace(/__INSTRUMENTATION_BLOCK__\n?/g, block);
1264
1270
  }
1271
+ var NEXT_INSTRUMENTATION_EDGE_HEADER = "// Generated by `neat init --apply` (ADR-126). Next.js edge-runtime instrumentation via @vercel/otel.";
1272
+ var NEXT_INSTRUMENTATION_EDGE_TS = `${NEXT_INSTRUMENTATION_EDGE_HEADER}
1273
+ import { registerOTel } from '@vercel/otel'
1274
+
1275
+ process.env.OTEL_SERVICE_NAME ||= '__SERVICE_NAME__'
1276
+ process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ||= 'http://localhost:4318/v1/traces'
1277
+ ${OTEL_OTLP_PROTOCOL_JS}
1278
+ ${OTEL_OTLP_HEADERS_JS}
1279
+
1280
+ registerOTel({ serviceName: process.env.OTEL_SERVICE_NAME })
1281
+ `;
1282
+ var NEXT_INSTRUMENTATION_EDGE_JS = NEXT_INSTRUMENTATION_EDGE_TS;
1265
1283
  var FRAMEWORK_OTEL_INIT_HEADER = "// Generated by `neat init --apply` (ADR-074). OpenTelemetry SDK hook.";
1266
1284
  var FRAMEWORK_OTEL_INIT_TS_BODY = `${FRAMEWORK_OTEL_INIT_HEADER}
1267
1285
  ${OTEL_ESM_NODE_IMPORTS}
@@ -1362,6 +1380,7 @@ var SDK_PACKAGES = [
1362
1380
  { name: "@opentelemetry/sdk-node", version: "^0.57.0" },
1363
1381
  { name: "@opentelemetry/auto-instrumentations-node", version: "^0.55.0" }
1364
1382
  ];
1383
+ var NEXT_EDGE_PACKAGES = [{ name: "@vercel/otel", version: "^2.1.3" }];
1365
1384
  function getMajor(versionRange) {
1366
1385
  if (!versionRange) return 0;
1367
1386
  const match = versionRange.match(/(\d+)/);
@@ -1738,6 +1757,10 @@ async function planNext(serviceDir, pkg, manifestPath, nextConfigPath, project)
1738
1757
  baseDir,
1739
1758
  useTs ? "instrumentation.node.ts" : "instrumentation.node.js"
1740
1759
  );
1760
+ const instrumentationEdgeFile = path5.join(
1761
+ baseDir,
1762
+ useTs ? "instrumentation.edge.ts" : "instrumentation.edge.js"
1763
+ );
1741
1764
  const envNeatFile = path5.join(baseDir, ".env.neat");
1742
1765
  const existingDeps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
1743
1766
  const dependencyEdits = [];
@@ -1750,6 +1773,15 @@ async function planNext(serviceDir, pkg, manifestPath, nextConfigPath, project)
1750
1773
  }
1751
1774
  dependencyEdits.push({ file: manifestPath, kind: "add", name: sdk.name, version: sdk.version });
1752
1775
  }
1776
+ for (const sdk of NEXT_EDGE_PACKAGES) {
1777
+ if (sdk.name in existingDeps) {
1778
+ if (needsVersionUpgrade(existingDeps[sdk.name], sdk.version)) {
1779
+ dependencyEdits.push({ file: manifestPath, kind: "upgrade", name: sdk.name, version: sdk.version, fromVersion: existingDeps[sdk.name] });
1780
+ }
1781
+ continue;
1782
+ }
1783
+ dependencyEdits.push({ file: manifestPath, kind: "add", name: sdk.name, version: sdk.version });
1784
+ }
1753
1785
  const nonBundled = detectNonBundledInstrumentations(pkg);
1754
1786
  for (const inst of nonBundled) {
1755
1787
  if (inst.pkg in existingDeps) {
@@ -1783,6 +1815,17 @@ async function planNext(serviceDir, pkg, manifestPath, nextConfigPath, project)
1783
1815
  skipIfExists: true
1784
1816
  });
1785
1817
  }
1818
+ if (!await exists(instrumentationEdgeFile)) {
1819
+ generatedFiles.push({
1820
+ file: instrumentationEdgeFile,
1821
+ contents: renderFrameworkOtelInit(
1822
+ useTs ? NEXT_INSTRUMENTATION_EDGE_TS : NEXT_INSTRUMENTATION_EDGE_JS,
1823
+ svcName,
1824
+ projectName
1825
+ ),
1826
+ skipIfExists: true
1827
+ });
1828
+ }
1786
1829
  if (!await exists(envNeatFile)) {
1787
1830
  generatedFiles.push({
1788
1831
  file: envNeatFile,
@@ -2276,7 +2319,7 @@ function isAllowedWritePath(serviceDir, target) {
2276
2319
  if (base === ".env.neat") return true;
2277
2320
  if (/^otel-init\.(?:js|cjs|mjs|ts)$/.test(base)) return true;
2278
2321
  const relPosix = rel.split(path5.sep).join("/");
2279
- if (/^instrumentation(?:\.node)?\.(?:js|cjs|mjs|ts)$/.test(base)) {
2322
+ if (/^instrumentation(?:\.(?:node|edge))?\.(?:js|cjs|mjs|ts)$/.test(base)) {
2280
2323
  if (relPosix === base) return true;
2281
2324
  if (relPosix === `src/${base}`) return true;
2282
2325
  return false;