@stainlessdev/xray-hono 0.1.0 → 0.2.0-branch.bg-basic-auth.4c8723c
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.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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, 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
|
|
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\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: 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;AA4B7D,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
|
@@ -6,9 +6,14 @@ export { WrapOptions } from '@stainlessdev/xray-fetch';
|
|
|
6
6
|
|
|
7
7
|
type HonoXrayEnv = {
|
|
8
8
|
Variables: {
|
|
9
|
-
xray
|
|
9
|
+
xray?: XrayContext;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
+
declare module 'hono' {
|
|
13
|
+
interface ContextVariableMap {
|
|
14
|
+
xray?: XrayContext;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
12
17
|
type HonoEmitter<E extends Env = Env> = MiddlewareHandler<E & HonoXrayEnv> & {
|
|
13
18
|
flush: XrayEmitter['flush'];
|
|
14
19
|
shutdown: XrayEmitter['shutdown'];
|
package/dist/index.d.ts
CHANGED
|
@@ -6,9 +6,14 @@ export { WrapOptions } from '@stainlessdev/xray-fetch';
|
|
|
6
6
|
|
|
7
7
|
type HonoXrayEnv = {
|
|
8
8
|
Variables: {
|
|
9
|
-
xray
|
|
9
|
+
xray?: XrayContext;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
+
declare module 'hono' {
|
|
13
|
+
interface ContextVariableMap {
|
|
14
|
+
xray?: XrayContext;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
12
17
|
type HonoEmitter<E extends Env = Env> = MiddlewareHandler<E & HonoXrayEnv> & {
|
|
13
18
|
flush: XrayEmitter['flush'];
|
|
14
19
|
shutdown: XrayEmitter['shutdown'];
|
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, 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
|
|
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\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: 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;AA4B7D,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.
|
|
3
|
+
"version": "0.2.0-branch.bg-basic-auth.4c8723c",
|
|
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.
|
|
24
|
-
"@stainlessdev/xray-fetch": "0.
|
|
23
|
+
"@stainlessdev/xray-core": "0.2.0-branch.bg-basic-auth.4c8723c",
|
|
24
|
+
"@stainlessdev/xray-fetch": "0.2.0-branch.bg-basic-auth.4c8723c"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@hono/node-server": "^1.19.8",
|