@stainlessdev/xray-hono 0.3.1-dev.ae29cd0 → 0.4.0-branch.bg-rework-exporters.2fa33ac
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.cjs +2 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -5
package/dist/index.cjs
CHANGED
|
@@ -20,18 +20,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
createCoreEmitter: () =>
|
|
23
|
+
createCoreEmitter: () => import_xray_fetch.createEmitter,
|
|
24
24
|
createEmitter: () => createEmitter,
|
|
25
25
|
createHonoMiddleware: () => createHonoMiddleware
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
var import_factory = require("hono/factory");
|
|
29
29
|
var import_route = require("hono/route");
|
|
30
|
-
var import_xray_core = require("@stainlessdev/xray-core");
|
|
31
30
|
var import_internal = require("@stainlessdev/xray-core/internal");
|
|
32
31
|
var import_xray_fetch = require("@stainlessdev/xray-fetch");
|
|
33
32
|
function createEmitter(config, options) {
|
|
34
|
-
const emitter = (0,
|
|
33
|
+
const emitter = (0, import_xray_fetch.createEmitter)(config);
|
|
35
34
|
const middleware = createHonoMiddleware(emitter, options);
|
|
36
35
|
middleware.flush = emitter.flush;
|
|
37
36
|
middleware.shutdown = emitter.shutdown;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Env, MiddlewareHandler } from 'hono';\nimport { createMiddleware } from 'hono/factory';\nimport { routePath } from 'hono/route';\nimport type { XrayEmitter, XrayContext,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Env, MiddlewareHandler } from 'hono';\nimport { createMiddleware } from 'hono/factory';\nimport { routePath } from 'hono/route';\nimport type { XrayEmitter, XrayContext, XrayRuntimeConfig } from '@stainlessdev/xray-core';\nimport { setContextRoute } from '@stainlessdev/xray-core/internal';\nimport {\n createEmitter as createFetchEmitter,\n getXrayContext,\n wrapFetchPreserve,\n type WrapOptions,\n} from '@stainlessdev/xray-fetch';\n\nexport { createFetchEmitter as createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n XrayRuntimeConfig,\n} from '@stainlessdev/xray-core';\nexport type { WrapOptions } from '@stainlessdev/xray-fetch';\n\nexport type HonoXrayEnv = {\n Variables: { xray?: XrayContext };\n};\n\ndeclare module 'hono' {\n interface ContextVariableMap {\n xray?: XrayContext;\n }\n}\n\nexport type HonoEmitter<E extends Env = Env> = MiddlewareHandler<E & HonoXrayEnv> & {\n flush: XrayEmitter['flush'];\n shutdown: XrayEmitter['shutdown'];\n};\n\nexport function createEmitter<E extends Env = Env>(\n config: XrayRuntimeConfig,\n options?: WrapOptions,\n): HonoEmitter<E> {\n const emitter = createFetchEmitter(config);\n const middleware = createHonoMiddleware<E>(emitter, options) as HonoEmitter<E>;\n middleware.flush = emitter.flush;\n middleware.shutdown = emitter.shutdown;\n return middleware;\n}\n\nexport function createHonoMiddleware<E extends Env = Env>(\n xray: XrayEmitter,\n options?: WrapOptions,\n) {\n return createMiddleware<E & HonoXrayEnv>(async (c, next) => {\n const request = c.req.raw;\n if (!request) {\n await next();\n return;\n }\n\n const wrapped = wrapFetchPreserve(\n async (req) => {\n const ctx = getXrayContext(req);\n if (ctx) {\n c.set('xray', ctx);\n }\n\n let route = resolveRoutePath(c, -1);\n try {\n await next();\n return c.res;\n } finally {\n if (!route) {\n route = resolveRoutePath(c);\n }\n if (route && ctx) {\n setContextRoute(ctx, route);\n }\n }\n },\n xray,\n options,\n );\n\n const response = await wrapped(request);\n if (response instanceof Response && response !== c.res) {\n c.res = response;\n }\n });\n}\n\nfunction resolveRoutePath(ctx: unknown, index?: number): string | undefined {\n try {\n if (index === undefined) {\n return routePath(ctx as Parameters<typeof routePath>[0]);\n }\n return routePath(ctx as Parameters<typeof routePath>[0], index);\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6CAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AACA,qBAAiC;AACjC,mBAA0B;AAE1B,sBAAgC;AAChC,wBAKO;AA6BA,SAAS,cACd,QACA,SACgB;AAChB,QAAM,cAAU,kBAAAC,eAAmB,MAAM;AACzC,QAAM,aAAa,qBAAwB,SAAS,OAAO;AAC3D,aAAW,QAAQ,QAAQ;AAC3B,aAAW,WAAW,QAAQ;AAC9B,SAAO;AACT;AAEO,SAAS,qBACd,MACA,SACA;AACA,aAAO,iCAAkC,OAAO,GAAG,SAAS;AAC1D,UAAM,UAAU,EAAE,IAAI;AACtB,QAAI,CAAC,SAAS;AACZ,YAAM,KAAK;AACX;AAAA,IACF;AAEA,UAAM,cAAU;AAAA,MACd,OAAO,QAAQ;AACb,cAAM,UAAM,kCAAe,GAAG;AAC9B,YAAI,KAAK;AACP,YAAE,IAAI,QAAQ,GAAG;AAAA,QACnB;AAEA,YAAI,QAAQ,iBAAiB,GAAG,EAAE;AAClC,YAAI;AACF,gBAAM,KAAK;AACX,iBAAO,EAAE;AAAA,QACX,UAAE;AACA,cAAI,CAAC,OAAO;AACV,oBAAQ,iBAAiB,CAAC;AAAA,UAC5B;AACA,cAAI,SAAS,KAAK;AAChB,iDAAgB,KAAK,KAAK;AAAA,UAC5B;AAAA,QACF;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAQ,OAAO;AACtC,QAAI,oBAAoB,YAAY,aAAa,EAAE,KAAK;AACtD,QAAE,MAAM;AAAA,IACV;AAAA,EACF,CAAC;AACH;AAEA,SAAS,iBAAiB,KAAc,OAAoC;AAC1E,MAAI;AACF,QAAI,UAAU,QAAW;AACvB,iBAAO,wBAAU,GAAsC;AAAA,IACzD;AACA,eAAO,wBAAU,KAAwC,KAAK;AAAA,EAChE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["createFetchEmitter","createFetchEmitter"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Env, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { XrayContext, XrayEmitter,
|
|
3
|
-
export { CaptureConfig, RedactionConfig, RequestLog, XrayConfig, XrayContext, XrayEmitter,
|
|
2
|
+
import { XrayContext, XrayEmitter, XrayRuntimeConfig } from '@stainlessdev/xray-core';
|
|
3
|
+
export { CaptureConfig, RedactionConfig, RequestLog, XrayConfig, XrayContext, XrayEmitter, XrayRuntimeConfig } from '@stainlessdev/xray-core';
|
|
4
4
|
import { WrapOptions } from '@stainlessdev/xray-fetch';
|
|
5
|
-
export { WrapOptions } from '@stainlessdev/xray-fetch';
|
|
5
|
+
export { WrapOptions, createEmitter as createCoreEmitter } from '@stainlessdev/xray-fetch';
|
|
6
6
|
|
|
7
7
|
type HonoXrayEnv = {
|
|
8
8
|
Variables: {
|
|
@@ -18,7 +18,7 @@ type HonoEmitter<E extends Env = Env> = MiddlewareHandler<E & HonoXrayEnv> & {
|
|
|
18
18
|
flush: XrayEmitter['flush'];
|
|
19
19
|
shutdown: XrayEmitter['shutdown'];
|
|
20
20
|
};
|
|
21
|
-
declare function createEmitter<E extends Env = Env>(config:
|
|
21
|
+
declare function createEmitter<E extends Env = Env>(config: XrayRuntimeConfig, options?: WrapOptions): HonoEmitter<E>;
|
|
22
22
|
declare function createHonoMiddleware<E extends Env = Env>(xray: XrayEmitter, options?: WrapOptions): MiddlewareHandler<E & HonoXrayEnv, string, {}, Response>;
|
|
23
23
|
|
|
24
24
|
export { type HonoEmitter, type HonoXrayEnv, createEmitter, createHonoMiddleware };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Env, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { XrayContext, XrayEmitter,
|
|
3
|
-
export { CaptureConfig, RedactionConfig, RequestLog, XrayConfig, XrayContext, XrayEmitter,
|
|
2
|
+
import { XrayContext, XrayEmitter, XrayRuntimeConfig } from '@stainlessdev/xray-core';
|
|
3
|
+
export { CaptureConfig, RedactionConfig, RequestLog, XrayConfig, XrayContext, XrayEmitter, XrayRuntimeConfig } from '@stainlessdev/xray-core';
|
|
4
4
|
import { WrapOptions } from '@stainlessdev/xray-fetch';
|
|
5
|
-
export { WrapOptions } from '@stainlessdev/xray-fetch';
|
|
5
|
+
export { WrapOptions, createEmitter as createCoreEmitter } from '@stainlessdev/xray-fetch';
|
|
6
6
|
|
|
7
7
|
type HonoXrayEnv = {
|
|
8
8
|
Variables: {
|
|
@@ -18,7 +18,7 @@ type HonoEmitter<E extends Env = Env> = MiddlewareHandler<E & HonoXrayEnv> & {
|
|
|
18
18
|
flush: XrayEmitter['flush'];
|
|
19
19
|
shutdown: XrayEmitter['shutdown'];
|
|
20
20
|
};
|
|
21
|
-
declare function createEmitter<E extends Env = Env>(config:
|
|
21
|
+
declare function createEmitter<E extends Env = Env>(config: XrayRuntimeConfig, options?: WrapOptions): HonoEmitter<E>;
|
|
22
22
|
declare function createHonoMiddleware<E extends Env = Env>(xray: XrayEmitter, options?: WrapOptions): MiddlewareHandler<E & HonoXrayEnv, string, {}, Response>;
|
|
23
23
|
|
|
24
24
|
export { type HonoEmitter, type HonoXrayEnv, createEmitter, createHonoMiddleware };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { createMiddleware } from "hono/factory";
|
|
3
3
|
import { routePath } from "hono/route";
|
|
4
|
-
import { createEmitter as createCoreEmitter } from "@stainlessdev/xray-core";
|
|
5
4
|
import { setContextRoute } from "@stainlessdev/xray-core/internal";
|
|
6
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createEmitter as createFetchEmitter,
|
|
7
|
+
getXrayContext,
|
|
8
|
+
wrapFetchPreserve
|
|
9
|
+
} from "@stainlessdev/xray-fetch";
|
|
7
10
|
function createEmitter(config, options) {
|
|
8
|
-
const emitter =
|
|
11
|
+
const emitter = createFetchEmitter(config);
|
|
9
12
|
const middleware = createHonoMiddleware(emitter, options);
|
|
10
13
|
middleware.flush = emitter.flush;
|
|
11
14
|
middleware.shutdown = emitter.shutdown;
|
|
@@ -57,7 +60,7 @@ function resolveRoutePath(ctx, index) {
|
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
export {
|
|
60
|
-
createCoreEmitter,
|
|
63
|
+
createFetchEmitter as createCoreEmitter,
|
|
61
64
|
createEmitter,
|
|
62
65
|
createHonoMiddleware
|
|
63
66
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Env, MiddlewareHandler } from 'hono';\nimport { createMiddleware } from 'hono/factory';\nimport { routePath } from 'hono/route';\nimport type { XrayEmitter, XrayContext,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Env, MiddlewareHandler } from 'hono';\nimport { createMiddleware } from 'hono/factory';\nimport { routePath } from 'hono/route';\nimport type { XrayEmitter, XrayContext, XrayRuntimeConfig } from '@stainlessdev/xray-core';\nimport { setContextRoute } from '@stainlessdev/xray-core/internal';\nimport {\n createEmitter as createFetchEmitter,\n getXrayContext,\n wrapFetchPreserve,\n type WrapOptions,\n} from '@stainlessdev/xray-fetch';\n\nexport { createFetchEmitter as createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n XrayRuntimeConfig,\n} from '@stainlessdev/xray-core';\nexport type { WrapOptions } from '@stainlessdev/xray-fetch';\n\nexport type HonoXrayEnv = {\n Variables: { xray?: XrayContext };\n};\n\ndeclare module 'hono' {\n interface ContextVariableMap {\n xray?: XrayContext;\n }\n}\n\nexport type HonoEmitter<E extends Env = Env> = MiddlewareHandler<E & HonoXrayEnv> & {\n flush: XrayEmitter['flush'];\n shutdown: XrayEmitter['shutdown'];\n};\n\nexport function createEmitter<E extends Env = Env>(\n config: XrayRuntimeConfig,\n options?: WrapOptions,\n): HonoEmitter<E> {\n const emitter = createFetchEmitter(config);\n const middleware = createHonoMiddleware<E>(emitter, options) as HonoEmitter<E>;\n middleware.flush = emitter.flush;\n middleware.shutdown = emitter.shutdown;\n return middleware;\n}\n\nexport function createHonoMiddleware<E extends Env = Env>(\n xray: XrayEmitter,\n options?: WrapOptions,\n) {\n return createMiddleware<E & HonoXrayEnv>(async (c, next) => {\n const request = c.req.raw;\n if (!request) {\n await next();\n return;\n }\n\n const wrapped = wrapFetchPreserve(\n async (req) => {\n const ctx = getXrayContext(req);\n if (ctx) {\n c.set('xray', ctx);\n }\n\n let route = resolveRoutePath(c, -1);\n try {\n await next();\n return c.res;\n } finally {\n if (!route) {\n route = resolveRoutePath(c);\n }\n if (route && ctx) {\n setContextRoute(ctx, route);\n }\n }\n },\n xray,\n options,\n );\n\n const response = await wrapped(request);\n if (response instanceof Response && response !== c.res) {\n c.res = response;\n }\n });\n}\n\nfunction resolveRoutePath(ctx: unknown, index?: number): string | undefined {\n try {\n if (index === undefined) {\n return routePath(ctx as Parameters<typeof routePath>[0]);\n }\n return routePath(ctx as Parameters<typeof routePath>[0], index);\n } catch {\n return undefined;\n }\n}\n"],"mappings":";AACA,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAE1B,SAAS,uBAAuB;AAChC;AAAA,EACE,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,OAEK;AA6BA,SAAS,cACd,QACA,SACgB;AAChB,QAAM,UAAU,mBAAmB,MAAM;AACzC,QAAM,aAAa,qBAAwB,SAAS,OAAO;AAC3D,aAAW,QAAQ,QAAQ;AAC3B,aAAW,WAAW,QAAQ;AAC9B,SAAO;AACT;AAEO,SAAS,qBACd,MACA,SACA;AACA,SAAO,iBAAkC,OAAO,GAAG,SAAS;AAC1D,UAAM,UAAU,EAAE,IAAI;AACtB,QAAI,CAAC,SAAS;AACZ,YAAM,KAAK;AACX;AAAA,IACF;AAEA,UAAM,UAAU;AAAA,MACd,OAAO,QAAQ;AACb,cAAM,MAAM,eAAe,GAAG;AAC9B,YAAI,KAAK;AACP,YAAE,IAAI,QAAQ,GAAG;AAAA,QACnB;AAEA,YAAI,QAAQ,iBAAiB,GAAG,EAAE;AAClC,YAAI;AACF,gBAAM,KAAK;AACX,iBAAO,EAAE;AAAA,QACX,UAAE;AACA,cAAI,CAAC,OAAO;AACV,oBAAQ,iBAAiB,CAAC;AAAA,UAC5B;AACA,cAAI,SAAS,KAAK;AAChB,4BAAgB,KAAK,KAAK;AAAA,UAC5B;AAAA,QACF;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAQ,OAAO;AACtC,QAAI,oBAAoB,YAAY,aAAa,EAAE,KAAK;AACtD,QAAE,MAAM;AAAA,IACV;AAAA,EACF,CAAC;AACH;AAEA,SAAS,iBAAiB,KAAc,OAAoC;AAC1E,MAAI;AACF,QAAI,UAAU,QAAW;AACvB,aAAO,UAAU,GAAsC;AAAA,IACzD;AACA,WAAO,UAAU,KAAwC,KAAK;AAAA,EAChE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stainlessdev/xray-hono",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-branch.bg-rework-exporters.2fa33ac",
|
|
4
4
|
"description": "Hono integration for Stainless X-ray request logging",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -20,14 +20,13 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@stainlessdev/xray-core": "0.
|
|
24
|
-
"@stainlessdev/xray-fetch": "0.
|
|
23
|
+
"@stainlessdev/xray-core": "0.4.0-branch.bg-rework-exporters.2fa33ac",
|
|
24
|
+
"@stainlessdev/xray-fetch": "0.4.0-branch.bg-rework-exporters.2fa33ac"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@hono/node-server": "^1.19.8",
|
|
28
28
|
"@opentelemetry/api": "^1.9.0",
|
|
29
29
|
"@opentelemetry/core": "^2.2.0",
|
|
30
|
-
"@opentelemetry/otlp-transformer": "^0.208.0",
|
|
31
30
|
"@opentelemetry/resources": "^2.2.0",
|
|
32
31
|
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
33
32
|
"@opentelemetry/semantic-conventions": "^1.29.0",
|
|
@@ -41,7 +40,6 @@
|
|
|
41
40
|
"peerDependencies": {
|
|
42
41
|
"@opentelemetry/api": "^1.9.0",
|
|
43
42
|
"@opentelemetry/core": "^2.2.0",
|
|
44
|
-
"@opentelemetry/otlp-transformer": "^0.208.0",
|
|
45
43
|
"@opentelemetry/resources": "^2.2.0",
|
|
46
44
|
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
47
45
|
"@opentelemetry/semantic-conventions": "^1.29.0",
|