@stainlessdev/xray-hono 0.1.0-branch.bg-publish-to-npm.18b1cb1 → 0.1.0-branch.bg-fix-examples.3b7695a
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 +10 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -6
- package/dist/index.d.ts +10 -6
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
|
|
23
|
+
createCoreEmitter: () => import_xray_core.createEmitter,
|
|
24
|
+
createEmitter: () => createEmitter,
|
|
24
25
|
createHonoMiddleware: () => createHonoMiddleware
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -29,6 +30,13 @@ var import_route = require("hono/route");
|
|
|
29
30
|
var import_xray_core = require("@stainlessdev/xray-core");
|
|
30
31
|
var import_internal = require("@stainlessdev/xray-core/internal");
|
|
31
32
|
var import_xray_fetch = require("@stainlessdev/xray-fetch");
|
|
33
|
+
function createEmitter(config, options) {
|
|
34
|
+
const emitter = (0, import_xray_core.createEmitter)(config);
|
|
35
|
+
const middleware = createHonoMiddleware(emitter, options);
|
|
36
|
+
middleware.flush = emitter.flush;
|
|
37
|
+
middleware.shutdown = emitter.shutdown;
|
|
38
|
+
return middleware;
|
|
39
|
+
}
|
|
32
40
|
function createHonoMiddleware(xray, options) {
|
|
33
41
|
return (0, import_factory.createMiddleware)(async (c, next) => {
|
|
34
42
|
const request = c.req.raw;
|
|
@@ -76,6 +84,7 @@ function resolveRoutePath(ctx, index) {
|
|
|
76
84
|
}
|
|
77
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
78
86
|
0 && (module.exports = {
|
|
87
|
+
createCoreEmitter,
|
|
79
88
|
createEmitter,
|
|
80
89
|
createHonoMiddleware
|
|
81
90
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Env } from 'hono';\nimport { createMiddleware } from 'hono/factory';\nimport { routePath } from 'hono/route';\nimport type { XrayEmitter, XrayContext } from '@stainlessdev/xray-core';\nimport { createEmitter } from '@stainlessdev/xray-core';\nimport { setContextRoute } from '@stainlessdev/xray-core/internal';\nimport { getXrayContext, wrapFetchPreserve, type WrapOptions } from '@stainlessdev/xray-fetch';\n\nexport {
|
|
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, XrayConfig } from '@stainlessdev/xray-core';\nimport { createEmitter as createCoreEmitter } from '@stainlessdev/xray-core';\nimport { setContextRoute } from '@stainlessdev/xray-core/internal';\nimport { getXrayContext, wrapFetchPreserve, type WrapOptions } from '@stainlessdev/xray-fetch';\n\nexport { createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n} from '@stainlessdev/xray-core';\nexport type { WrapOptions } from '@stainlessdev/xray-fetch';\n\nexport type HonoXrayEnv = {\n Variables: { xray: XrayContext };\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: XrayConfig,\n options?: WrapOptions,\n): HonoEmitter<E> {\n const emitter = createCoreEmitter(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,4CAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AACA,qBAAiC;AACjC,mBAA0B;AAE1B,uBAAmD;AACnD,sBAAgC;AAChC,wBAAoE;AAsB7D,SAAS,cACd,QACA,SACgB;AAChB,QAAM,cAAU,iBAAAC,eAAkB,MAAM;AACxC,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":["createCoreEmitter","createCoreEmitter"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export { CaptureConfig, RedactionConfig, RequestLog, XrayConfig, XrayContext, XrayEmitter, createEmitter } from '@stainlessdev/xray-core';
|
|
1
|
+
import { Env, MiddlewareHandler } from 'hono';
|
|
2
|
+
import { XrayContext, XrayEmitter, XrayConfig } from '@stainlessdev/xray-core';
|
|
3
|
+
export { CaptureConfig, RedactionConfig, RequestLog, XrayConfig, XrayContext, XrayEmitter, createEmitter as createCoreEmitter } from '@stainlessdev/xray-core';
|
|
5
4
|
import { WrapOptions } from '@stainlessdev/xray-fetch';
|
|
6
5
|
export { WrapOptions } from '@stainlessdev/xray-fetch';
|
|
7
6
|
|
|
@@ -10,6 +9,11 @@ type HonoXrayEnv = {
|
|
|
10
9
|
xray: XrayContext;
|
|
11
10
|
};
|
|
12
11
|
};
|
|
13
|
-
|
|
12
|
+
type HonoEmitter<E extends Env = Env> = MiddlewareHandler<E & HonoXrayEnv> & {
|
|
13
|
+
flush: XrayEmitter['flush'];
|
|
14
|
+
shutdown: XrayEmitter['shutdown'];
|
|
15
|
+
};
|
|
16
|
+
declare function createEmitter<E extends Env = Env>(config: XrayConfig, options?: WrapOptions): HonoEmitter<E>;
|
|
17
|
+
declare function createHonoMiddleware<E extends Env = Env>(xray: XrayEmitter, options?: WrapOptions): MiddlewareHandler<E & HonoXrayEnv, string, {}, Response>;
|
|
14
18
|
|
|
15
|
-
export { type HonoXrayEnv, createHonoMiddleware };
|
|
19
|
+
export { type HonoEmitter, type HonoXrayEnv, createEmitter, createHonoMiddleware };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export { CaptureConfig, RedactionConfig, RequestLog, XrayConfig, XrayContext, XrayEmitter, createEmitter } from '@stainlessdev/xray-core';
|
|
1
|
+
import { Env, MiddlewareHandler } from 'hono';
|
|
2
|
+
import { XrayContext, XrayEmitter, XrayConfig } from '@stainlessdev/xray-core';
|
|
3
|
+
export { CaptureConfig, RedactionConfig, RequestLog, XrayConfig, XrayContext, XrayEmitter, createEmitter as createCoreEmitter } from '@stainlessdev/xray-core';
|
|
5
4
|
import { WrapOptions } from '@stainlessdev/xray-fetch';
|
|
6
5
|
export { WrapOptions } from '@stainlessdev/xray-fetch';
|
|
7
6
|
|
|
@@ -10,6 +9,11 @@ type HonoXrayEnv = {
|
|
|
10
9
|
xray: XrayContext;
|
|
11
10
|
};
|
|
12
11
|
};
|
|
13
|
-
|
|
12
|
+
type HonoEmitter<E extends Env = Env> = MiddlewareHandler<E & HonoXrayEnv> & {
|
|
13
|
+
flush: XrayEmitter['flush'];
|
|
14
|
+
shutdown: XrayEmitter['shutdown'];
|
|
15
|
+
};
|
|
16
|
+
declare function createEmitter<E extends Env = Env>(config: XrayConfig, options?: WrapOptions): HonoEmitter<E>;
|
|
17
|
+
declare function createHonoMiddleware<E extends Env = Env>(xray: XrayEmitter, options?: WrapOptions): MiddlewareHandler<E & HonoXrayEnv, string, {}, Response>;
|
|
14
18
|
|
|
15
|
-
export { type HonoXrayEnv, createHonoMiddleware };
|
|
19
|
+
export { type HonoEmitter, type HonoXrayEnv, createEmitter, createHonoMiddleware };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { createMiddleware } from "hono/factory";
|
|
3
3
|
import { routePath } from "hono/route";
|
|
4
|
-
import { createEmitter } from "@stainlessdev/xray-core";
|
|
4
|
+
import { createEmitter as createCoreEmitter } from "@stainlessdev/xray-core";
|
|
5
5
|
import { setContextRoute } from "@stainlessdev/xray-core/internal";
|
|
6
6
|
import { getXrayContext, wrapFetchPreserve } from "@stainlessdev/xray-fetch";
|
|
7
|
+
function createEmitter(config, options) {
|
|
8
|
+
const emitter = createCoreEmitter(config);
|
|
9
|
+
const middleware = createHonoMiddleware(emitter, options);
|
|
10
|
+
middleware.flush = emitter.flush;
|
|
11
|
+
middleware.shutdown = emitter.shutdown;
|
|
12
|
+
return middleware;
|
|
13
|
+
}
|
|
7
14
|
function createHonoMiddleware(xray, options) {
|
|
8
15
|
return createMiddleware(async (c, next) => {
|
|
9
16
|
const request = c.req.raw;
|
|
@@ -50,6 +57,7 @@ function resolveRoutePath(ctx, index) {
|
|
|
50
57
|
}
|
|
51
58
|
}
|
|
52
59
|
export {
|
|
60
|
+
createCoreEmitter,
|
|
53
61
|
createEmitter,
|
|
54
62
|
createHonoMiddleware
|
|
55
63
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Env } from 'hono';\nimport { createMiddleware } from 'hono/factory';\nimport { routePath } from 'hono/route';\nimport type { XrayEmitter, XrayContext } from '@stainlessdev/xray-core';\nimport { createEmitter } from '@stainlessdev/xray-core';\nimport { setContextRoute } from '@stainlessdev/xray-core/internal';\nimport { getXrayContext, wrapFetchPreserve, type WrapOptions } from '@stainlessdev/xray-fetch';\n\nexport {
|
|
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, XrayConfig } from '@stainlessdev/xray-core';\nimport { createEmitter as createCoreEmitter } from '@stainlessdev/xray-core';\nimport { setContextRoute } from '@stainlessdev/xray-core/internal';\nimport { getXrayContext, wrapFetchPreserve, type WrapOptions } from '@stainlessdev/xray-fetch';\n\nexport { createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n} from '@stainlessdev/xray-core';\nexport type { WrapOptions } from '@stainlessdev/xray-fetch';\n\nexport type HonoXrayEnv = {\n Variables: { xray: XrayContext };\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: XrayConfig,\n options?: WrapOptions,\n): HonoEmitter<E> {\n const emitter = createCoreEmitter(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,iBAAiB,yBAAyB;AACnD,SAAS,uBAAuB;AAChC,SAAS,gBAAgB,yBAA2C;AAsB7D,SAAS,cACd,QACA,SACgB;AAChB,QAAM,UAAU,kBAAkB,MAAM;AACxC,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.1.0-branch.bg-
|
|
3
|
+
"version": "0.1.0-branch.bg-fix-examples.3b7695a",
|
|
4
4
|
"description": "Hono integration for Stainless X-ray request logging",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@stainlessdev/xray-core": "0.1.0-branch.bg-
|
|
24
|
-
"@stainlessdev/xray-fetch": "0.1.0-branch.bg-
|
|
23
|
+
"@stainlessdev/xray-core": "0.1.0-branch.bg-fix-examples.3b7695a",
|
|
24
|
+
"@stainlessdev/xray-fetch": "0.1.0-branch.bg-fix-examples.3b7695a"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@hono/node-server": "^1.19.8",
|