@interfere/next 3.0.0 → 5.0.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/_virtual/_rolldown/runtime.mjs +13 -0
- package/dist/config.d.mts +21 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +103 -0
- package/dist/config.mjs.map +1 -0
- package/dist/instrument-client.d.mts +3 -0
- package/dist/instrument-client.mjs +2 -0
- package/dist/internal/build/configure-build.d.mts +25 -0
- package/dist/internal/build/configure-build.d.mts.map +1 -0
- package/dist/internal/build/configure-build.mjs +87 -0
- package/dist/internal/build/configure-build.mjs.map +1 -0
- package/dist/internal/build/pipeline.d.mts +49 -0
- package/dist/internal/build/pipeline.d.mts.map +1 -0
- package/dist/internal/build/pipeline.mjs +67 -0
- package/dist/internal/build/pipeline.mjs.map +1 -0
- package/dist/internal/build/release/destinations/vercel.d.mts +6 -0
- package/dist/internal/build/release/destinations/vercel.d.mts.map +1 -0
- package/dist/internal/build/release/destinations/vercel.mjs +25 -0
- package/dist/internal/build/release/destinations/vercel.mjs.map +1 -0
- package/dist/internal/build/release/git.d.mts +4 -0
- package/dist/internal/build/release/git.d.mts.map +1 -0
- package/dist/internal/build/release/git.mjs +21 -0
- package/dist/internal/build/release/git.mjs.map +1 -0
- package/dist/internal/build/release/index.d.mts +8 -0
- package/dist/internal/build/release/index.d.mts.map +1 -0
- package/dist/internal/build/release/index.mjs +20 -0
- package/dist/internal/build/release/index.mjs.map +1 -0
- package/dist/internal/build/release/sources/github.d.mts +6 -0
- package/dist/internal/build/release/sources/github.d.mts.map +1 -0
- package/dist/internal/build/release/sources/github.mjs +15 -0
- package/dist/internal/build/release/sources/github.mjs.map +1 -0
- package/dist/internal/build/source-maps/discover.d.mts +15 -0
- package/dist/internal/build/source-maps/discover.d.mts.map +1 -0
- package/dist/internal/build/source-maps/discover.mjs +62 -0
- package/dist/internal/build/source-maps/discover.mjs.map +1 -0
- package/dist/internal/build/source-maps/index.d.mts +26 -0
- package/dist/internal/build/source-maps/index.d.mts.map +1 -0
- package/dist/internal/build/source-maps/index.mjs +28 -0
- package/dist/internal/build/source-maps/index.mjs.map +1 -0
- package/dist/internal/build/value-injection-loader.d.mts +13 -0
- package/dist/internal/build/value-injection-loader.d.mts.map +1 -0
- package/dist/internal/build/value-injection-loader.mjs +24 -0
- package/dist/internal/build/value-injection-loader.mjs.map +1 -0
- package/dist/internal/env.d.mts +16 -0
- package/dist/internal/env.d.mts.map +1 -0
- package/dist/internal/env.mjs +19 -0
- package/dist/internal/env.mjs.map +1 -0
- package/dist/internal/logger.d.mts +9 -0
- package/dist/internal/logger.d.mts.map +1 -0
- package/dist/internal/logger.mjs +60 -0
- package/dist/internal/logger.mjs.map +1 -0
- package/dist/internal/route/handle-get.d.mts +4 -0
- package/dist/internal/route/handle-get.d.mts.map +1 -0
- package/dist/internal/route/handle-get.mjs +23 -0
- package/dist/internal/route/handle-get.mjs.map +1 -0
- package/dist/internal/route/handle-post.d.mts +4 -0
- package/dist/internal/route/handle-post.d.mts.map +1 -0
- package/dist/internal/route/handle-post.mjs +65 -0
- package/dist/internal/route/handle-post.mjs.map +1 -0
- package/dist/internal/route/proxy.d.mts +18 -0
- package/dist/internal/route/proxy.d.mts.map +1 -0
- package/dist/internal/route/proxy.mjs +82 -0
- package/dist/internal/route/proxy.mjs.map +1 -0
- package/dist/internal/route/sw-script.d.mts +4 -0
- package/dist/internal/route/sw-script.d.mts.map +1 -0
- package/dist/internal/route/sw-script.mjs +38 -0
- package/dist/internal/route/sw-script.mjs.map +1 -0
- package/dist/internal/server/capture.d.mts +9 -0
- package/dist/internal/server/capture.d.mts.map +1 -0
- package/dist/internal/server/capture.mjs +52 -0
- package/dist/internal/server/capture.mjs.map +1 -0
- package/dist/internal/server/dedupe.d.mts +5 -0
- package/dist/internal/server/dedupe.d.mts.map +1 -0
- package/dist/internal/server/dedupe.mjs +11 -0
- package/dist/internal/server/dedupe.mjs.map +1 -0
- package/dist/internal/server/envelope.d.mts +14 -0
- package/dist/internal/server/envelope.d.mts.map +1 -0
- package/dist/internal/server/envelope.mjs +57 -0
- package/dist/internal/server/envelope.mjs.map +1 -0
- package/dist/internal/server/normalize-request.d.mts +7 -0
- package/dist/internal/server/normalize-request.d.mts.map +1 -0
- package/dist/internal/server/normalize-request.mjs +50 -0
- package/dist/internal/server/normalize-request.mjs.map +1 -0
- package/dist/internal/server/remote-config.d.mts +5 -0
- package/dist/internal/server/remote-config.d.mts.map +1 -0
- package/dist/internal/server/remote-config.mjs +28 -0
- package/dist/internal/server/remote-config.mjs.map +1 -0
- package/dist/internal/server/runtime.d.mts +14 -0
- package/dist/internal/server/runtime.d.mts.map +1 -0
- package/dist/internal/server/runtime.mjs +18 -0
- package/dist/internal/server/runtime.mjs.map +1 -0
- package/dist/internal/server/transport.d.mts +12 -0
- package/dist/internal/server/transport.d.mts.map +1 -0
- package/dist/internal/server/transport.mjs +17 -0
- package/dist/internal/server/transport.mjs.map +1 -0
- package/dist/internal/server/types.d.mts +17 -0
- package/dist/internal/server/types.d.mts.map +1 -0
- package/dist/internal/server/types.mjs +1 -0
- package/dist/internal/version.d.mts +4 -0
- package/dist/internal/version.d.mts.map +1 -0
- package/dist/internal/version.mjs +5 -0
- package/dist/internal/version.mjs.map +1 -0
- package/dist/package.mjs +5 -0
- package/dist/package.mjs.map +1 -0
- package/dist/provider.d.mts +3 -0
- package/dist/provider.mjs +3 -0
- package/dist/route-handler.d.mts +7 -0
- package/dist/route-handler.d.mts.map +1 -0
- package/dist/route-handler.mjs +26 -0
- package/dist/route-handler.mjs.map +1 -0
- package/dist/server.d.mts +4 -0
- package/dist/server.mjs +3 -0
- package/package.json +26 -26
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CaptureErrorContext, OnRequestErrorContext } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/internal/server/capture.d.ts
|
|
4
|
+
declare function captureError(error: unknown, request?: unknown, context?: CaptureErrorContext): Promise<void>;
|
|
5
|
+
declare function onRequestError(error: Error & {
|
|
6
|
+
digest?: string;
|
|
7
|
+
}, request: unknown, context: OnRequestErrorContext): Promise<void>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { captureError, onRequestError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.d.mts","names":[],"sources":["../../../src/internal/server/capture.ts"],"mappings":";;;iBAsBsB,YAAA,CACpB,KAAA,WACA,OAAA,YACA,OAAA,GAAU,mBAAA,GACT,OAAA;AAAA,iBAgCmB,cAAA,CACpB,KAAA,EAAO,KAAA;EAAU,MAAA;AAAA,GACjB,OAAA,WACA,OAAA,EAAS,qBAAA,GACR,OAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isErrorCaptured, markErrorCaptured } from "./dedupe.mjs";
|
|
2
|
+
import { buildErrorEnvelope } from "./envelope.mjs";
|
|
3
|
+
import { normalizeRequest } from "./normalize-request.mjs";
|
|
4
|
+
import { isPluginEnabled } from "./remote-config.mjs";
|
|
5
|
+
import { resolveServerCaptureRuntime } from "./runtime.mjs";
|
|
6
|
+
import { sendEnvelope } from "./transport.mjs";
|
|
7
|
+
//#region src/internal/server/capture.ts
|
|
8
|
+
const ON_REQUEST_ERROR_MECHANISM = {
|
|
9
|
+
type: "onRequestError",
|
|
10
|
+
handled: false,
|
|
11
|
+
synthetic: false
|
|
12
|
+
};
|
|
13
|
+
const DEFAULT_REQUEST = {
|
|
14
|
+
method: "GET",
|
|
15
|
+
path: "/",
|
|
16
|
+
headers: new Headers()
|
|
17
|
+
};
|
|
18
|
+
async function captureError(error, request, context) {
|
|
19
|
+
if (!isPluginEnabled("errors")) return;
|
|
20
|
+
const runtime = resolveServerCaptureRuntime();
|
|
21
|
+
if (runtime.apiKey === null) return;
|
|
22
|
+
const normalizedRequest = normalizeRequest(request);
|
|
23
|
+
const envelope = buildErrorEnvelope({
|
|
24
|
+
error,
|
|
25
|
+
request: normalizedRequest,
|
|
26
|
+
context,
|
|
27
|
+
runtime
|
|
28
|
+
});
|
|
29
|
+
try {
|
|
30
|
+
await sendEnvelope({
|
|
31
|
+
envelope,
|
|
32
|
+
runtime,
|
|
33
|
+
traceparent: context?.traceparent ?? normalizedRequest?.headers.get("traceparent") ?? void 0
|
|
34
|
+
});
|
|
35
|
+
} catch {}
|
|
36
|
+
}
|
|
37
|
+
async function onRequestError(error, request, context) {
|
|
38
|
+
if (isErrorCaptured(error)) return;
|
|
39
|
+
markErrorCaptured(error);
|
|
40
|
+
const normalizedRequest = normalizeRequest(request) ?? DEFAULT_REQUEST;
|
|
41
|
+
await captureError(error, normalizedRequest, {
|
|
42
|
+
mechanism: ON_REQUEST_ERROR_MECHANISM,
|
|
43
|
+
nextjs: {
|
|
44
|
+
...context,
|
|
45
|
+
requestMethod: normalizedRequest.method,
|
|
46
|
+
requestPath: normalizedRequest.path,
|
|
47
|
+
...error.digest ? { errorDigest: error.digest } : {}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { captureError, onRequestError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.mjs","names":[],"sources":["../../../src/internal/server/capture.ts"],"sourcesContent":["import type { ErrorMechanism } from \"@interfere/types/sdk/plugins/payload/errors\";\n\nimport { isErrorCaptured, markErrorCaptured } from \"./dedupe.js\";\nimport { buildErrorEnvelope } from \"./envelope.js\";\nimport { normalizeRequest, TRACEPARENT_HEADER } from \"./normalize-request.js\";\nimport { isPluginEnabled } from \"./remote-config.js\";\nimport { resolveServerCaptureRuntime } from \"./runtime.js\";\nimport { sendEnvelope } from \"./transport.js\";\nimport type { CaptureErrorContext, OnRequestErrorContext } from \"./types.js\";\n\nconst ON_REQUEST_ERROR_MECHANISM: ErrorMechanism = {\n type: \"onRequestError\",\n handled: false,\n synthetic: false,\n};\n\nconst DEFAULT_REQUEST = {\n method: \"GET\",\n path: \"/\",\n headers: new Headers(),\n};\n\nexport async function captureError(\n error: unknown,\n request?: unknown,\n context?: CaptureErrorContext\n): Promise<void> {\n if (!isPluginEnabled(\"errors\")) {\n return;\n }\n\n const runtime = resolveServerCaptureRuntime();\n if (runtime.apiKey === null) {\n return;\n }\n\n const normalizedRequest = normalizeRequest(request);\n const envelope = buildErrorEnvelope({\n error,\n request: normalizedRequest,\n context,\n runtime,\n });\n\n try {\n await sendEnvelope({\n envelope,\n runtime,\n traceparent:\n context?.traceparent ??\n normalizedRequest?.headers.get(TRACEPARENT_HEADER) ??\n undefined,\n });\n } catch {\n /* best-effort */\n }\n}\n\nexport async function onRequestError(\n error: Error & { digest?: string },\n request: unknown,\n context: OnRequestErrorContext\n): Promise<void> {\n if (isErrorCaptured(error)) {\n return;\n }\n markErrorCaptured(error);\n\n const normalizedRequest = normalizeRequest(request) ?? DEFAULT_REQUEST;\n\n await captureError(error, normalizedRequest, {\n mechanism: ON_REQUEST_ERROR_MECHANISM,\n nextjs: {\n ...context,\n requestMethod: normalizedRequest.method,\n requestPath: normalizedRequest.path,\n ...(error.digest ? { errorDigest: error.digest } : {}),\n },\n });\n}\n"],"mappings":";;;;;;;AAUA,MAAM,6BAA6C;CACjD,MAAM;CACN,SAAS;CACT,WAAW;CACZ;AAED,MAAM,kBAAkB;CACtB,QAAQ;CACR,MAAM;CACN,SAAS,IAAI,SAAS;CACvB;AAED,eAAsB,aACpB,OACA,SACA,SACe;AACf,KAAI,CAAC,gBAAgB,SAAS,CAC5B;CAGF,MAAM,UAAU,6BAA6B;AAC7C,KAAI,QAAQ,WAAW,KACrB;CAGF,MAAM,oBAAoB,iBAAiB,QAAQ;CACnD,MAAM,WAAW,mBAAmB;EAClC;EACA,SAAS;EACT;EACA;EACD,CAAC;AAEF,KAAI;AACF,QAAM,aAAa;GACjB;GACA;GACA,aACE,SAAS,eACT,mBAAmB,QAAQ,IAAA,cAAuB,IAClD,KAAA;GACH,CAAC;SACI;;AAKV,eAAsB,eACpB,OACA,SACA,SACe;AACf,KAAI,gBAAgB,MAAM,CACxB;AAEF,mBAAkB,MAAM;CAExB,MAAM,oBAAoB,iBAAiB,QAAQ,IAAI;AAEvD,OAAM,aAAa,OAAO,mBAAmB;EAC3C,WAAW;EACX,QAAQ;GACN,GAAG;GACH,eAAe,kBAAkB;GACjC,aAAa,kBAAkB;GAC/B,GAAI,MAAM,SAAS,EAAE,aAAa,MAAM,QAAQ,GAAG,EAAE;GACtD;EACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dedupe.d.mts","names":[],"sources":["../../../src/internal/server/dedupe.ts"],"mappings":";iBAEgB,eAAA,CAAgB,KAAA;AAAA,iBAIhB,iBAAA,CAAkB,KAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/internal/server/dedupe.ts
|
|
2
|
+
const seenErrors = /* @__PURE__ */ new WeakSet();
|
|
3
|
+
function isErrorCaptured(error) {
|
|
4
|
+
return error instanceof Error && seenErrors.has(error);
|
|
5
|
+
}
|
|
6
|
+
function markErrorCaptured(error) {
|
|
7
|
+
if (!(error instanceof Error)) return;
|
|
8
|
+
seenErrors.add(error);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { isErrorCaptured, markErrorCaptured };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dedupe.mjs","names":[],"sources":["../../../src/internal/server/dedupe.ts"],"sourcesContent":["const seenErrors = new WeakSet<Error>();\n\nexport function isErrorCaptured(error: unknown): boolean {\n return error instanceof Error && seenErrors.has(error);\n}\n\nexport function markErrorCaptured(error: unknown): void {\n if (!(error instanceof Error)) {\n return;\n }\n\n seenErrors.add(error);\n}\n"],"mappings":";AAAA,MAAM,6BAAa,IAAI,SAAgB;AAEvC,SAAgB,gBAAgB,OAAyB;AACvD,QAAO,iBAAiB,SAAS,WAAW,IAAI,MAAM;;AAGxD,SAAgB,kBAAkB,OAAsB;AACtD,KAAI,EAAE,iBAAiB,OACrB;AAGF,YAAW,IAAI,MAAM"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CaptureErrorContext, NormalizedRequest } from "./types.mjs";
|
|
2
|
+
import { ServerCaptureRuntime } from "./runtime.mjs";
|
|
3
|
+
import { Envelope } from "@interfere/types/sdk/envelope";
|
|
4
|
+
|
|
5
|
+
//#region src/internal/server/envelope.d.ts
|
|
6
|
+
interface BuildErrorEnvelopeParams {
|
|
7
|
+
readonly context?: CaptureErrorContext;
|
|
8
|
+
readonly error: unknown;
|
|
9
|
+
readonly request: NormalizedRequest | null;
|
|
10
|
+
readonly runtime: ServerCaptureRuntime;
|
|
11
|
+
}
|
|
12
|
+
declare function buildErrorEnvelope(params: BuildErrorEnvelopeParams): Envelope<"error">;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { buildErrorEnvelope };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.mts","names":[],"sources":["../../../src/internal/server/envelope.ts"],"mappings":";;;;;UAoBU,wBAAA;EAAA,SACC,OAAA,GAAU,mBAAA;EAAA,SACV,KAAA;EAAA,SACA,OAAA,EAAS,iBAAA;EAAA,SACT,OAAA,EAAS,oBAAA;AAAA;AAAA,iBAGJ,kBAAA,CACd,MAAA,EAAQ,wBAAA,GACP,QAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { PRODUCER_VERSION } from "../version.mjs";
|
|
2
|
+
import { sessionIdSchema } from "@interfere/types/data/session";
|
|
3
|
+
import { toError, toExceptions } from "@interfere/types/sdk/errors";
|
|
4
|
+
import { v7 } from "uuid";
|
|
5
|
+
//#region src/internal/server/envelope.ts
|
|
6
|
+
const SESSION_HEADER = "x-interfere-session";
|
|
7
|
+
const DEFAULT_ERROR_MECHANISM = {
|
|
8
|
+
type: "captureError",
|
|
9
|
+
handled: true
|
|
10
|
+
};
|
|
11
|
+
function buildErrorEnvelope(params) {
|
|
12
|
+
const { error, request, context, runtime } = params;
|
|
13
|
+
const session = resolveSession(request?.headers ?? new Headers());
|
|
14
|
+
let nextjsContext;
|
|
15
|
+
if (context?.nextjs) nextjsContext = toNextjsContext(context.nextjs);
|
|
16
|
+
else if (request) nextjsContext = toNextjsRequestContext(request);
|
|
17
|
+
return {
|
|
18
|
+
uuid: v7(),
|
|
19
|
+
v: 0,
|
|
20
|
+
type: "error",
|
|
21
|
+
payload: { exceptions: toExceptions(toError(error), context?.mechanism ?? DEFAULT_ERROR_MECHANISM) },
|
|
22
|
+
clientTs: Date.now(),
|
|
23
|
+
runtime: runtime.runtime,
|
|
24
|
+
environment: runtime.environment,
|
|
25
|
+
buildId: runtime.buildId,
|
|
26
|
+
releaseId: runtime.releaseId,
|
|
27
|
+
producerVersion: PRODUCER_VERSION,
|
|
28
|
+
sessionId: session.id,
|
|
29
|
+
...session.source ? { sessionSource: session.source } : {},
|
|
30
|
+
...nextjsContext ? { context: nextjsContext } : {}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function toNextjsRequestContext(request) {
|
|
34
|
+
return {
|
|
35
|
+
runtime: "nextjs",
|
|
36
|
+
requestMethod: request.method,
|
|
37
|
+
requestPath: request.path
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function toNextjsContext(context) {
|
|
41
|
+
return {
|
|
42
|
+
runtime: "nextjs",
|
|
43
|
+
...context
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function resolveSession(headers) {
|
|
47
|
+
const sessionId = headers.get(SESSION_HEADER);
|
|
48
|
+
if (sessionId === null) return { id: null };
|
|
49
|
+
const parsed = sessionIdSchema.safeParse(sessionId);
|
|
50
|
+
if (!parsed.success) return { id: null };
|
|
51
|
+
return {
|
|
52
|
+
id: parsed.data,
|
|
53
|
+
source: "header"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { buildErrorEnvelope };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.mjs","names":["uuidv7"],"sources":["../../../src/internal/server/envelope.ts"],"sourcesContent":["import type { SessionId } from \"@interfere/types/data/session\";\nimport { sessionIdSchema } from \"@interfere/types/data/session\";\nimport type { Envelope, SessionSource } from \"@interfere/types/sdk/envelope\";\nimport { toError, toExceptions } from \"@interfere/types/sdk/errors\";\nimport type { NextjsContext } from \"@interfere/types/sdk/plugins/context/next\";\nimport type { ErrorMechanism } from \"@interfere/types/sdk/plugins/payload/errors\";\n\nimport { v7 as uuidv7 } from \"uuid\";\n\nimport { PRODUCER_VERSION } from \"../version.js\";\nimport type { ServerCaptureRuntime } from \"./runtime.js\";\nimport type { CaptureErrorContext, NormalizedRequest } from \"./types.js\";\n\nconst SESSION_HEADER = \"x-interfere-session\";\n\nconst DEFAULT_ERROR_MECHANISM: ErrorMechanism = {\n type: \"captureError\",\n handled: true,\n};\n\ninterface BuildErrorEnvelopeParams {\n readonly context?: CaptureErrorContext;\n readonly error: unknown;\n readonly request: NormalizedRequest | null;\n readonly runtime: ServerCaptureRuntime;\n}\n\nexport function buildErrorEnvelope(\n params: BuildErrorEnvelopeParams\n): Envelope<\"error\"> {\n const { error, request, context, runtime } = params;\n const session = resolveSession(request?.headers ?? new Headers());\n\n let nextjsContext: NextjsContext | undefined;\n if (context?.nextjs) {\n nextjsContext = toNextjsContext(context.nextjs);\n } else if (request) {\n nextjsContext = toNextjsRequestContext(request);\n }\n\n return {\n uuid: uuidv7(),\n v: 0,\n type: \"error\",\n payload: {\n exceptions: toExceptions(\n toError(error),\n context?.mechanism ?? DEFAULT_ERROR_MECHANISM\n ),\n },\n clientTs: Date.now(),\n runtime: runtime.runtime,\n environment: runtime.environment,\n buildId: runtime.buildId,\n releaseId: runtime.releaseId,\n producerVersion: PRODUCER_VERSION,\n sessionId: session.id,\n ...(session.source ? { sessionSource: session.source } : {}),\n ...(nextjsContext ? { context: nextjsContext } : {}),\n };\n}\n\nfunction toNextjsRequestContext(request: NormalizedRequest): NextjsContext {\n return {\n runtime: \"nextjs\",\n requestMethod: request.method,\n requestPath: request.path,\n };\n}\n\nfunction toNextjsContext(\n context: Omit<NextjsContext, \"runtime\">\n): NextjsContext {\n return {\n runtime: \"nextjs\",\n ...context,\n };\n}\n\nfunction resolveSession(headers: Headers): {\n readonly id: SessionId | null;\n readonly source?: SessionSource;\n} {\n const sessionId = headers.get(SESSION_HEADER);\n if (sessionId === null) {\n return { id: null };\n }\n\n const parsed = sessionIdSchema.safeParse(sessionId);\n if (!parsed.success) {\n return { id: null };\n }\n\n return {\n id: parsed.data,\n source: \"header\",\n };\n}\n"],"mappings":";;;;;AAaA,MAAM,iBAAiB;AAEvB,MAAM,0BAA0C;CAC9C,MAAM;CACN,SAAS;CACV;AASD,SAAgB,mBACd,QACmB;CACnB,MAAM,EAAE,OAAO,SAAS,SAAS,YAAY;CAC7C,MAAM,UAAU,eAAe,SAAS,WAAW,IAAI,SAAS,CAAC;CAEjE,IAAI;AACJ,KAAI,SAAS,OACX,iBAAgB,gBAAgB,QAAQ,OAAO;UACtC,QACT,iBAAgB,uBAAuB,QAAQ;AAGjD,QAAO;EACL,MAAMA,IAAQ;EACd,GAAG;EACH,MAAM;EACN,SAAS,EACP,YAAY,aACV,QAAQ,MAAM,EACd,SAAS,aAAa,wBACvB,EACF;EACD,UAAU,KAAK,KAAK;EACpB,SAAS,QAAQ;EACjB,aAAa,QAAQ;EACrB,SAAS,QAAQ;EACjB,WAAW,QAAQ;EACnB,iBAAiB;EACjB,WAAW,QAAQ;EACnB,GAAI,QAAQ,SAAS,EAAE,eAAe,QAAQ,QAAQ,GAAG,EAAE;EAC3D,GAAI,gBAAgB,EAAE,SAAS,eAAe,GAAG,EAAE;EACpD;;AAGH,SAAS,uBAAuB,SAA2C;AACzE,QAAO;EACL,SAAS;EACT,eAAe,QAAQ;EACvB,aAAa,QAAQ;EACtB;;AAGH,SAAS,gBACP,SACe;AACf,QAAO;EACL,SAAS;EACT,GAAG;EACJ;;AAGH,SAAS,eAAe,SAGtB;CACA,MAAM,YAAY,QAAQ,IAAI,eAAe;AAC7C,KAAI,cAAc,KAChB,QAAO,EAAE,IAAI,MAAM;CAGrB,MAAM,SAAS,gBAAgB,UAAU,UAAU;AACnD,KAAI,CAAC,OAAO,QACV,QAAO,EAAE,IAAI,MAAM;AAGrB,QAAO;EACL,IAAI,OAAO;EACX,QAAQ;EACT"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NormalizedRequest } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/internal/server/normalize-request.d.ts
|
|
4
|
+
declare const TRACEPARENT_HEADER = "traceparent";
|
|
5
|
+
declare function normalizeRequest(request: unknown): NormalizedRequest | null;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { TRACEPARENT_HEADER, normalizeRequest };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-request.d.mts","names":[],"sources":["../../../src/internal/server/normalize-request.ts"],"mappings":";;;cAEa,kBAAA;AAAA,iBAEG,gBAAA,CAAiB,OAAA,YAAmB,iBAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/internal/server/normalize-request.ts
|
|
2
|
+
const TRACEPARENT_HEADER = "traceparent";
|
|
3
|
+
function normalizeRequest(request) {
|
|
4
|
+
if (request instanceof Request) return {
|
|
5
|
+
method: normalizeMethod(request.method),
|
|
6
|
+
path: normalizePath(request.url),
|
|
7
|
+
headers: request.headers
|
|
8
|
+
};
|
|
9
|
+
if (typeof request !== "object" || request === null) return null;
|
|
10
|
+
const value = request;
|
|
11
|
+
return {
|
|
12
|
+
method: normalizeMethod(value.method),
|
|
13
|
+
path: normalizePath(typeof value.path === "string" ? value.path : toStringOrDefault(value.url)),
|
|
14
|
+
headers: normalizeHeaders(value.headers)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function normalizeMethod(value) {
|
|
18
|
+
if (typeof value !== "string") return "GET";
|
|
19
|
+
const method = value.trim();
|
|
20
|
+
return method.length > 0 ? method.toUpperCase() : "GET";
|
|
21
|
+
}
|
|
22
|
+
function normalizePath(value) {
|
|
23
|
+
if (value.length === 0) return "/";
|
|
24
|
+
try {
|
|
25
|
+
return new URL(value, "http://localhost").pathname || "/";
|
|
26
|
+
} catch {
|
|
27
|
+
return value.startsWith("/") ? value : `/${value}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function toStringOrDefault(value, fallback = "/") {
|
|
31
|
+
if (typeof value !== "string") return fallback;
|
|
32
|
+
const trimmed = value.trim();
|
|
33
|
+
return trimmed.length > 0 ? trimmed : fallback;
|
|
34
|
+
}
|
|
35
|
+
function normalizeHeaders(value) {
|
|
36
|
+
if (value instanceof Headers) return new Headers(value);
|
|
37
|
+
if (typeof value !== "object" || value === null) return new Headers();
|
|
38
|
+
const headers = new Headers();
|
|
39
|
+
for (const [key, headerValue] of Object.entries(value)) {
|
|
40
|
+
if (headerValue === void 0) continue;
|
|
41
|
+
if (Array.isArray(headerValue)) {
|
|
42
|
+
headers.set(key, headerValue.join(", "));
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
headers.set(key, String(headerValue));
|
|
46
|
+
}
|
|
47
|
+
return headers;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { TRACEPARENT_HEADER, normalizeRequest };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-request.mjs","names":[],"sources":["../../../src/internal/server/normalize-request.ts"],"sourcesContent":["import type { NormalizedRequest } from \"./types.js\";\n\nexport const TRACEPARENT_HEADER = \"traceparent\";\n\nexport function normalizeRequest(request: unknown): NormalizedRequest | null {\n if (request instanceof Request) {\n return {\n method: normalizeMethod(request.method),\n path: normalizePath(request.url),\n headers: request.headers,\n };\n }\n\n if (typeof request !== \"object\" || request === null) {\n return null;\n }\n\n const value = request as {\n headers?: unknown;\n method?: unknown;\n path?: unknown;\n url?: unknown;\n };\n\n return {\n method: normalizeMethod(value.method),\n path: normalizePath(\n typeof value.path === \"string\" ? value.path : toStringOrDefault(value.url)\n ),\n headers: normalizeHeaders(value.headers),\n };\n}\n\nfunction normalizeMethod(value: unknown): string {\n if (typeof value !== \"string\") {\n return \"GET\";\n }\n\n const method = value.trim();\n return method.length > 0 ? method.toUpperCase() : \"GET\";\n}\n\nfunction normalizePath(value: string): string {\n if (value.length === 0) {\n return \"/\";\n }\n\n try {\n const parsed = new URL(value, \"http://localhost\");\n return parsed.pathname || \"/\";\n } catch {\n return value.startsWith(\"/\") ? value : `/${value}`;\n }\n}\n\nfunction toStringOrDefault(value: unknown, fallback = \"/\"): string {\n if (typeof value !== \"string\") {\n return fallback;\n }\n\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : fallback;\n}\n\nfunction normalizeHeaders(value: unknown): Headers {\n if (value instanceof Headers) {\n return new Headers(value);\n }\n\n if (typeof value !== \"object\" || value === null) {\n return new Headers();\n }\n\n const headers = new Headers();\n for (const [key, headerValue] of Object.entries(value)) {\n if (headerValue === undefined) {\n continue;\n }\n\n if (Array.isArray(headerValue)) {\n headers.set(key, headerValue.join(\", \"));\n continue;\n }\n\n headers.set(key, String(headerValue));\n }\n\n return headers;\n}\n"],"mappings":";AAEA,MAAa,qBAAqB;AAElC,SAAgB,iBAAiB,SAA4C;AAC3E,KAAI,mBAAmB,QACrB,QAAO;EACL,QAAQ,gBAAgB,QAAQ,OAAO;EACvC,MAAM,cAAc,QAAQ,IAAI;EAChC,SAAS,QAAQ;EAClB;AAGH,KAAI,OAAO,YAAY,YAAY,YAAY,KAC7C,QAAO;CAGT,MAAM,QAAQ;AAOd,QAAO;EACL,QAAQ,gBAAgB,MAAM,OAAO;EACrC,MAAM,cACJ,OAAO,MAAM,SAAS,WAAW,MAAM,OAAO,kBAAkB,MAAM,IAAI,CAC3E;EACD,SAAS,iBAAiB,MAAM,QAAQ;EACzC;;AAGH,SAAS,gBAAgB,OAAwB;AAC/C,KAAI,OAAO,UAAU,SACnB,QAAO;CAGT,MAAM,SAAS,MAAM,MAAM;AAC3B,QAAO,OAAO,SAAS,IAAI,OAAO,aAAa,GAAG;;AAGpD,SAAS,cAAc,OAAuB;AAC5C,KAAI,MAAM,WAAW,EACnB,QAAO;AAGT,KAAI;AAEF,SADe,IAAI,IAAI,OAAO,mBAAmB,CACnC,YAAY;SACpB;AACN,SAAO,MAAM,WAAW,IAAI,GAAG,QAAQ,IAAI;;;AAI/C,SAAS,kBAAkB,OAAgB,WAAW,KAAa;AACjE,KAAI,OAAO,UAAU,SACnB,QAAO;CAGT,MAAM,UAAU,MAAM,MAAM;AAC5B,QAAO,QAAQ,SAAS,IAAI,UAAU;;AAGxC,SAAS,iBAAiB,OAAyB;AACjD,KAAI,iBAAiB,QACnB,QAAO,IAAI,QAAQ,MAAM;AAG3B,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO,IAAI,SAAS;CAGtB,MAAM,UAAU,IAAI,SAAS;AAC7B,MAAK,MAAM,CAAC,KAAK,gBAAgB,OAAO,QAAQ,MAAM,EAAE;AACtD,MAAI,gBAAgB,KAAA,EAClB;AAGF,MAAI,MAAM,QAAQ,YAAY,EAAE;AAC9B,WAAQ,IAAI,KAAK,YAAY,KAAK,KAAK,CAAC;AACxC;;AAGF,UAAQ,IAAI,KAAK,OAAO,YAAY,CAAC;;AAGvC,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-config.d.mts","names":[],"sources":["../../../src/internal/server/remote-config.ts"],"mappings":";iBAUsB,yBAAA,CAAA,GAA6B,OAAA;AAAA,iBA8BnC,eAAA,CAAgB,MAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readInterfereEnv } from "../env.mjs";
|
|
2
|
+
import { API_PATHS } from "@interfere/constants/api";
|
|
3
|
+
//#region src/internal/server/remote-config.ts
|
|
4
|
+
let cachedConfig = null;
|
|
5
|
+
async function fetchAndCacheRemoteConfig() {
|
|
6
|
+
const env = readInterfereEnv();
|
|
7
|
+
if (env.apiKey === null) return;
|
|
8
|
+
try {
|
|
9
|
+
const url = `${env.apiUrl}${API_PATHS.CONFIG}`;
|
|
10
|
+
const response = await fetch(url, {
|
|
11
|
+
method: "GET",
|
|
12
|
+
headers: {
|
|
13
|
+
"content-type": "application/json",
|
|
14
|
+
"x-api-key": env.apiKey
|
|
15
|
+
},
|
|
16
|
+
signal: AbortSignal.timeout(1e4)
|
|
17
|
+
});
|
|
18
|
+
if (!response.ok) return;
|
|
19
|
+
const config = await response.json();
|
|
20
|
+
if (config?.plugins) cachedConfig = config.plugins;
|
|
21
|
+
} catch {}
|
|
22
|
+
}
|
|
23
|
+
function isPluginEnabled(plugin) {
|
|
24
|
+
if (!cachedConfig) return true;
|
|
25
|
+
return cachedConfig[plugin] !== false;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { fetchAndCacheRemoteConfig, isPluginEnabled };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-config.mjs","names":[],"sources":["../../../src/internal/server/remote-config.ts"],"sourcesContent":["import { API_PATHS } from \"@interfere/constants/api\";\nimport type {\n RemoteConfig,\n RemotePluginConfig,\n} from \"@interfere/types/sdk/remote-config\";\n\nimport { readInterfereEnv } from \"../env.js\";\n\nlet cachedConfig: RemotePluginConfig | null = null;\n\nexport async function fetchAndCacheRemoteConfig(): Promise<void> {\n const env = readInterfereEnv();\n if (env.apiKey === null) {\n return;\n }\n\n try {\n const url = `${env.apiUrl}${API_PATHS.CONFIG}`;\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n \"content-type\": \"application/json\",\n \"x-api-key\": env.apiKey,\n },\n signal: AbortSignal.timeout(10_000),\n });\n\n if (!response.ok) {\n return;\n }\n\n const config = (await response.json()) as RemoteConfig;\n if (config?.plugins) {\n cachedConfig = config.plugins;\n }\n } catch {\n // Fail silently — all plugins remain enabled\n }\n}\n\nexport function isPluginEnabled(plugin: string): boolean {\n if (!cachedConfig) {\n return true;\n }\n return cachedConfig[plugin as keyof RemotePluginConfig] !== false;\n}\n"],"mappings":";;;AAQA,IAAI,eAA0C;AAE9C,eAAsB,4BAA2C;CAC/D,MAAM,MAAM,kBAAkB;AAC9B,KAAI,IAAI,WAAW,KACjB;AAGF,KAAI;EACF,MAAM,MAAM,GAAG,IAAI,SAAS,UAAU;EACtC,MAAM,WAAW,MAAM,MAAM,KAAK;GAChC,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,aAAa,IAAI;IAClB;GACD,QAAQ,YAAY,QAAQ,IAAO;GACpC,CAAC;AAEF,MAAI,CAAC,SAAS,GACZ;EAGF,MAAM,SAAU,MAAM,SAAS,MAAM;AACrC,MAAI,QAAQ,QACV,gBAAe,OAAO;SAElB;;AAKV,SAAgB,gBAAgB,QAAyB;AACvD,KAAI,CAAC,aACH,QAAO;AAET,QAAO,aAAa,YAAwC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Env, Runtime } from "@interfere/types/sdk/runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/internal/server/runtime.d.ts
|
|
4
|
+
interface ServerCaptureRuntime {
|
|
5
|
+
readonly apiKey: string | null;
|
|
6
|
+
readonly buildId: string;
|
|
7
|
+
readonly environment: Env;
|
|
8
|
+
readonly ingestUrl: string;
|
|
9
|
+
readonly releaseId: string | null;
|
|
10
|
+
readonly runtime: Runtime;
|
|
11
|
+
}
|
|
12
|
+
declare function resolveServerCaptureRuntime(): ServerCaptureRuntime;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ServerCaptureRuntime, resolveServerCaptureRuntime };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../../../src/internal/server/runtime.ts"],"mappings":";;;UAMiB,oBAAA;EAAA,SACN,MAAA;EAAA,SACA,OAAA;EAAA,SACA,WAAA,EAAa,GAAA;EAAA,SACb,SAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA,EAAS,OAAA;AAAA;AAAA,iBAGJ,2BAAA,CAAA,GAA+B,oBAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readInterfereEnv } from "../env.mjs";
|
|
2
|
+
import { API_PATHS } from "@interfere/constants/api";
|
|
3
|
+
import { inferRuntime } from "@interfere/types/sdk/runtime";
|
|
4
|
+
//#region src/internal/server/runtime.ts
|
|
5
|
+
function resolveServerCaptureRuntime() {
|
|
6
|
+
const env = readInterfereEnv();
|
|
7
|
+
if (env.release.sourceId === null) throw new Error("[interfere] Missing NEXT_PUBLIC_INTERFERE_BUILD_ID at runtime. Ensure withInterfere() wraps your Next.js config.");
|
|
8
|
+
return {
|
|
9
|
+
apiKey: env.apiKey,
|
|
10
|
+
ingestUrl: `${env.apiUrl}${API_PATHS.INGEST}`,
|
|
11
|
+
environment: env.nodeEnvironment,
|
|
12
|
+
runtime: inferRuntime({ nextRuntime: env.nextRuntime }),
|
|
13
|
+
buildId: env.release.sourceId,
|
|
14
|
+
releaseId: env.release.destinationId
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { resolveServerCaptureRuntime };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/internal/server/runtime.ts"],"sourcesContent":["import { API_PATHS } from \"@interfere/constants/api\";\nimport type { Env, Runtime } from \"@interfere/types/sdk/runtime\";\nimport { inferRuntime } from \"@interfere/types/sdk/runtime\";\n\nimport { readInterfereEnv } from \"../env.js\";\n\nexport interface ServerCaptureRuntime {\n readonly apiKey: string | null;\n readonly buildId: string;\n readonly environment: Env;\n readonly ingestUrl: string;\n readonly releaseId: string | null;\n readonly runtime: Runtime;\n}\n\nexport function resolveServerCaptureRuntime(): ServerCaptureRuntime {\n const env = readInterfereEnv();\n\n if (env.release.sourceId === null) {\n throw new Error(\n \"[interfere] Missing NEXT_PUBLIC_INTERFERE_BUILD_ID at runtime. \" +\n \"Ensure withInterfere() wraps your Next.js config.\"\n );\n }\n\n return {\n apiKey: env.apiKey,\n ingestUrl: `${env.apiUrl}${API_PATHS.INGEST}`,\n environment: env.nodeEnvironment,\n runtime: inferRuntime({ nextRuntime: env.nextRuntime }),\n buildId: env.release.sourceId,\n releaseId: env.release.destinationId,\n };\n}\n"],"mappings":";;;;AAeA,SAAgB,8BAAoD;CAClE,MAAM,MAAM,kBAAkB;AAE9B,KAAI,IAAI,QAAQ,aAAa,KAC3B,OAAM,IAAI,MACR,mHAED;AAGH,QAAO;EACL,QAAQ,IAAI;EACZ,WAAW,GAAG,IAAI,SAAS,UAAU;EACrC,aAAa,IAAI;EACjB,SAAS,aAAa,EAAE,aAAa,IAAI,aAAa,CAAC;EACvD,SAAS,IAAI,QAAQ;EACrB,WAAW,IAAI,QAAQ;EACxB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ServerCaptureRuntime } from "./runtime.mjs";
|
|
2
|
+
import { Envelope } from "@interfere/types/sdk/envelope";
|
|
3
|
+
|
|
4
|
+
//#region src/internal/server/transport.d.ts
|
|
5
|
+
interface SendEnvelopeInput {
|
|
6
|
+
readonly envelope: Envelope<"error">;
|
|
7
|
+
readonly runtime: ServerCaptureRuntime;
|
|
8
|
+
readonly traceparent?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function sendEnvelope(input: SendEnvelopeInput): Promise<void>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { SendEnvelopeInput, sendEnvelope };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.mts","names":[],"sources":["../../../src/internal/server/transport.ts"],"mappings":";;;;UAIiB,iBAAA;EAAA,SACN,QAAA,EAAU,QAAA;EAAA,SACV,OAAA,EAAS,oBAAA;EAAA,SACT,WAAA;AAAA;AAAA,iBAGW,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAoB,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/internal/server/transport.ts
|
|
2
|
+
async function sendEnvelope(input) {
|
|
3
|
+
const { envelope, runtime, traceparent } = input;
|
|
4
|
+
if (runtime.apiKey === null) return;
|
|
5
|
+
await fetch(runtime.ingestUrl, {
|
|
6
|
+
method: "POST",
|
|
7
|
+
headers: {
|
|
8
|
+
"content-type": "application/json",
|
|
9
|
+
"x-api-key": runtime.apiKey,
|
|
10
|
+
...traceparent ? { traceparent } : {}
|
|
11
|
+
},
|
|
12
|
+
body: JSON.stringify([envelope]),
|
|
13
|
+
keepalive: true
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { sendEnvelope };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.mjs","names":[],"sources":["../../../src/internal/server/transport.ts"],"sourcesContent":["import type { Envelope } from \"@interfere/types/sdk/envelope\";\n\nimport type { ServerCaptureRuntime } from \"./runtime.js\";\n\nexport interface SendEnvelopeInput {\n readonly envelope: Envelope<\"error\">;\n readonly runtime: ServerCaptureRuntime;\n readonly traceparent?: string;\n}\n\nexport async function sendEnvelope(input: SendEnvelopeInput): Promise<void> {\n const { envelope, runtime, traceparent } = input;\n\n if (runtime.apiKey === null) {\n return;\n }\n\n await fetch(runtime.ingestUrl, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n \"x-api-key\": runtime.apiKey,\n ...(traceparent ? { traceparent } : {}),\n },\n body: JSON.stringify([envelope]),\n keepalive: true,\n });\n}\n"],"mappings":";AAUA,eAAsB,aAAa,OAAyC;CAC1E,MAAM,EAAE,UAAU,SAAS,gBAAgB;AAE3C,KAAI,QAAQ,WAAW,KACrB;AAGF,OAAM,MAAM,QAAQ,WAAW;EAC7B,QAAQ;EACR,SAAS;GACP,gBAAgB;GAChB,aAAa,QAAQ;GACrB,GAAI,cAAc,EAAE,aAAa,GAAG,EAAE;GACvC;EACD,MAAM,KAAK,UAAU,CAAC,SAAS,CAAC;EAChC,WAAW;EACZ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NextjsContext } from "@interfere/types/sdk/plugins/context/next";
|
|
2
|
+
import { ErrorMechanism } from "@interfere/types/sdk/plugins/payload/errors";
|
|
3
|
+
|
|
4
|
+
//#region src/internal/server/types.d.ts
|
|
5
|
+
type OnRequestErrorContext = Omit<NextjsContext, "errorDigest" | "requestMethod" | "requestPath" | "runtime">;
|
|
6
|
+
interface CaptureErrorContext {
|
|
7
|
+
readonly mechanism?: ErrorMechanism;
|
|
8
|
+
readonly nextjs?: Omit<NextjsContext, "runtime">;
|
|
9
|
+
readonly traceparent?: string;
|
|
10
|
+
}
|
|
11
|
+
interface NormalizedRequest {
|
|
12
|
+
readonly headers: Headers;
|
|
13
|
+
readonly method: string;
|
|
14
|
+
readonly path: string;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { CaptureErrorContext, NormalizedRequest, OnRequestErrorContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../src/internal/server/types.ts"],"mappings":";;;;KAGY,qBAAA,GAAwB,IAAA,CAClC,aAAA;AAAA,UAIe,mBAAA;EAAA,SACN,SAAA,GAAY,cAAA;EAAA,SACZ,MAAA,GAAS,IAAA,CAAK,aAAA;EAAA,SACd,WAAA;AAAA;AAAA,UAGM,iBAAA;EAAA,SACN,OAAA,EAAS,OAAA;EAAA,SACT,MAAA;EAAA,SACA,IAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.mts","names":[],"sources":["../../src/internal/version.ts"],"mappings":";cAEa,gBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.mjs","names":["pkg.name","pkg.version"],"sources":["../../src/internal/version.ts"],"sourcesContent":["import pkg from \"../../package.json\" with { type: \"json\" };\n\nexport const PRODUCER_VERSION = `${pkg.name}@${pkg.version}`;\n"],"mappings":";;AAEA,MAAa,mBAAmB,GAAGA,KAAS,GAAGC"}
|
package/dist/package.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { InterfereProvider, useInterfere, useSession } from "@interfere/react/provider";
|
|
2
|
+
import { ConsentCategory, ConsentState, GateableCategory } from "@interfere/types/sdk/plugins/manifest";
|
|
3
|
+
export { type ConsentCategory, type ConsentState, type GateableCategory, InterfereProvider, useInterfere, useSession };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/route-handler.d.ts
|
|
2
|
+
declare function GET(request: Request): Promise<Response>;
|
|
3
|
+
declare function POST(request: Request): Promise<Response>;
|
|
4
|
+
declare function PUT(request: Request): Promise<Response>;
|
|
5
|
+
declare function OPTIONS(): Response;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { GET, OPTIONS, POST, PUT };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-handler.d.mts","names":[],"sources":["../src/route-handler.ts"],"mappings":";iBAGsB,GAAA,CAAI,OAAA,EAAS,OAAA,GAAU,OAAA,CAAQ,QAAA;AAAA,iBAIrC,IAAA,CAAK,OAAA,EAAS,OAAA,GAAU,OAAA,CAAQ,QAAA;AAAA,iBAIhC,GAAA,CAAI,OAAA,EAAS,OAAA,GAAU,OAAA,CAAQ,QAAA;AAAA,iBAW/B,OAAA,CAAA,GAAW,QAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { handleGet } from "./internal/route/handle-get.mjs";
|
|
2
|
+
import { handlePost } from "./internal/route/handle-post.mjs";
|
|
3
|
+
//#region src/route-handler.ts
|
|
4
|
+
async function GET(request) {
|
|
5
|
+
return await handleGet(request);
|
|
6
|
+
}
|
|
7
|
+
function POST(request) {
|
|
8
|
+
return handlePost(request);
|
|
9
|
+
}
|
|
10
|
+
function PUT(request) {
|
|
11
|
+
return handlePost(request);
|
|
12
|
+
}
|
|
13
|
+
const CORS_HEADERS = {
|
|
14
|
+
"Access-Control-Allow-Origin": "*",
|
|
15
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, OPTIONS",
|
|
16
|
+
"Access-Control-Allow-Headers": "Content-Type",
|
|
17
|
+
"Access-Control-Max-Age": "86400"
|
|
18
|
+
};
|
|
19
|
+
function OPTIONS() {
|
|
20
|
+
return new Response(null, {
|
|
21
|
+
status: 200,
|
|
22
|
+
headers: CORS_HEADERS
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { GET, OPTIONS, POST, PUT };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-handler.mjs","names":[],"sources":["../src/route-handler.ts"],"sourcesContent":["import { handleGet } from \"./internal/route/handle-get.js\";\nimport { handlePost } from \"./internal/route/handle-post.js\";\n\nexport async function GET(request: Request): Promise<Response> {\n return await handleGet(request);\n}\n\nexport function POST(request: Request): Promise<Response> {\n return handlePost(request);\n}\n\nexport function PUT(request: Request): Promise<Response> {\n return handlePost(request);\n}\n\nconst CORS_HEADERS = {\n \"Access-Control-Allow-Origin\": \"*\",\n \"Access-Control-Allow-Methods\": \"GET, POST, PUT, OPTIONS\",\n \"Access-Control-Allow-Headers\": \"Content-Type\",\n \"Access-Control-Max-Age\": \"86400\",\n};\n\nexport function OPTIONS(): Response {\n return new Response(null, { status: 200, headers: CORS_HEADERS });\n}\n"],"mappings":";;;AAGA,eAAsB,IAAI,SAAqC;AAC7D,QAAO,MAAM,UAAU,QAAQ;;AAGjC,SAAgB,KAAK,SAAqC;AACxD,QAAO,WAAW,QAAQ;;AAG5B,SAAgB,IAAI,SAAqC;AACvD,QAAO,WAAW,QAAQ;;AAG5B,MAAM,eAAe;CACnB,+BAA+B;CAC/B,gCAAgC;CAChC,gCAAgC;CAChC,0BAA0B;CAC3B;AAED,SAAgB,UAAoB;AAClC,QAAO,IAAI,SAAS,MAAM;EAAE,QAAQ;EAAK,SAAS;EAAc,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CaptureErrorContext, OnRequestErrorContext } from "./internal/server/types.mjs";
|
|
2
|
+
import { captureError, onRequestError } from "./internal/server/capture.mjs";
|
|
3
|
+
import { fetchAndCacheRemoteConfig } from "./internal/server/remote-config.mjs";
|
|
4
|
+
export { type CaptureErrorContext, type OnRequestErrorContext, captureError, onRequestError, fetchAndCacheRemoteConfig as register };
|
package/dist/server.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interfere/next",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Build software that never breaks.",
|
|
6
6
|
"keywords": [
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"test": "bun run test:unit && bun run test:browser"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@interfere/constants": "
|
|
68
|
-
"@interfere/react": "
|
|
69
|
-
"@interfere/sdk": "
|
|
70
|
-
"@interfere/types": "
|
|
71
|
-
"chalk": "
|
|
72
|
-
"uuid": "
|
|
67
|
+
"@interfere/constants": "^5.0.0",
|
|
68
|
+
"@interfere/react": "^5.0.0",
|
|
69
|
+
"@interfere/sdk": "^5.0.0",
|
|
70
|
+
"@interfere/types": "^5.0.0",
|
|
71
|
+
"chalk": "^5.6.2",
|
|
72
|
+
"uuid": "^13.0.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@vercel/blob": "^2",
|
|
@@ -78,24 +78,24 @@
|
|
|
78
78
|
"react-dom": ">=19"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@interfere/typescript-config": "
|
|
82
|
-
"@interfere/vitest-config": "
|
|
83
|
-
"@testing-library/react": "
|
|
84
|
-
"@types/node": "
|
|
85
|
-
"@types/react": "
|
|
86
|
-
"@types/react-dom": "
|
|
87
|
-
"@vitejs/plugin-react": "
|
|
88
|
-
"@vitest/browser": "
|
|
89
|
-
"@vitest/browser-playwright": "
|
|
90
|
-
"@vitest/coverage-v8": "
|
|
91
|
-
"jsdom": "
|
|
92
|
-
"next": "
|
|
93
|
-
"playwright": "
|
|
94
|
-
"react": "
|
|
95
|
-
"react-dom": "
|
|
96
|
-
"tsdown": "
|
|
97
|
-
"typescript": "
|
|
98
|
-
"vitest": "
|
|
99
|
-
"webpack": "
|
|
81
|
+
"@interfere/typescript-config": "^5.0.0",
|
|
82
|
+
"@interfere/vitest-config": "^5.0.0",
|
|
83
|
+
"@testing-library/react": "^16.3.2",
|
|
84
|
+
"@types/node": "^24.12.0",
|
|
85
|
+
"@types/react": "19.2.14",
|
|
86
|
+
"@types/react-dom": "19.2.3",
|
|
87
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
88
|
+
"@vitest/browser": "4.1.0",
|
|
89
|
+
"@vitest/browser-playwright": "4.1.0",
|
|
90
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
91
|
+
"jsdom": "^29.0.0",
|
|
92
|
+
"next": "^16.1.6",
|
|
93
|
+
"playwright": "^1.56.1",
|
|
94
|
+
"react": "^19.2.4",
|
|
95
|
+
"react-dom": "^19.2.4",
|
|
96
|
+
"tsdown": "^0.21.3",
|
|
97
|
+
"typescript": "5.9.3",
|
|
98
|
+
"vitest": "^4.0.18",
|
|
99
|
+
"webpack": "^5.105.1"
|
|
100
100
|
}
|
|
101
101
|
}
|