@nwire/handler 0.7.0 → 0.8.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/README.md CHANGED
@@ -2,63 +2,87 @@
2
2
 
3
3
  > Operation primitive — one shape for action / query / resolver, usable from any transport.
4
4
 
5
- ## What it is
6
-
7
- `defineHandler(name, config)` describes a single operation: input schema, response shape, the function. `execute(handler, input, ctx?)` runs one. Same shape whether the caller is HTTP, a queue worker, a CLI command, or an MCP tool. No framework lock-in — a foreign host (Express, Fastify, NestJS) can mount a handler with two lines of glue.
8
-
9
- ## Install
5
+ `defineHandler(name, config)` describes a single operation: input
6
+ schema, response shape, the function. `execute(handler, input, ctx?)`
7
+ runs one. Every Nwire transport (`@nwire/http`, `@nwire/queue`,
8
+ `@nwire/mcp`) speaks this exact shape; `@nwire/forge`'s `defineAction`
9
+ and `defineQuery` are flavored sugar on top.
10
10
 
11
11
  ```bash
12
- pnpm add @nwire/handler
12
+ pnpm add @nwire/handler zod
13
13
  ```
14
14
 
15
- ## Standalone use
16
-
17
- For developers who want a portable operation primitive without pulling in the rest of Nwire. Define a handler once, run it from anywhere.
15
+ ## Quick example
18
16
 
19
17
  ```ts
20
- import { defineHandler, execute, ok } from "@nwire/handler";
21
18
  import { z } from "zod";
22
-
23
- const createUser = defineHandler("createUser", {
24
- input: z.object({ email: z.string().email() }),
25
- handler: async ({ input }) => ok({ id: crypto.randomUUID(), email: input.email }),
19
+ import {
20
+ defineHandler,
21
+ defineMiddleware,
22
+ defineHook,
23
+ pipe,
24
+ execute,
25
+ NotFound,
26
+ ok,
27
+ } from "@nwire/handler";
28
+
29
+ const authenticate = defineMiddleware("authenticate", async (ctx, next) => {
30
+ ctx.user = await verifyToken(ctx.header("authorization"));
31
+ await next();
26
32
  });
27
33
 
28
- // Run it directly:
29
- const res = await execute(createUser, { email: "a@b.co" });
30
-
31
- // Or mount in Express:
32
- app.post("/users", async (req, res) => {
33
- const out = await execute(createUser, req.body);
34
- res.status(out.status).json(out.body);
34
+ const auditLog = defineHook("after", "audit", async (ctx, result) => {
35
+ await audit.write({ user: ctx.user.id, result });
35
36
  });
36
- ```
37
-
38
- ## Within nwire-app
39
37
 
40
- For developers using this package as part of the Nwire stack. Every Nwire transport (`@nwire/http`, `@nwire/queue`, `@nwire/mcp`) speaks this exact shape; `@nwire/forge`'s `defineAction` / `defineQuery` are flavored sugar over `defineHandler`.
41
-
42
- ```ts
43
- import { defineAction } from "@nwire/forge"; // sugar over defineHandler
44
- import { httpInterface, post } from "@nwire/http";
45
-
46
- const createUser = defineAction("createUser", {
47
- input: z.object({ email: z.string().email() }),
48
- handler: async ({ input }) => ({ id: crypto.randomUUID(), email: input.email }),
38
+ const userPipeline = pipe("user-pipeline", authenticate, auditLog);
39
+
40
+ const getUser = defineHandler("getUser", {
41
+ input: z.object({ id: z.string() }),
42
+ middleware: [userPipeline],
43
+ handler: async ({ input, resolve }) => {
44
+ const repo = resolve<UserRepo>("UserRepo");
45
+ const user = await repo.findById(input.id);
46
+ if (!user) throw NotFound("user", input.id);
47
+ return ok(user);
48
+ },
49
49
  });
50
50
 
51
- const api = httpInterface("api").wire(post("/users", createUser));
51
+ const res = await execute(getUser, { id: "u_1" }, { resolve });
52
52
  ```
53
53
 
54
- ## API
55
-
56
- - `defineHandler(name, config)` — declare an operation: `{ input, handler, returns?, errors?, summary?, policy?, emits? }`.
57
- - `execute(handler, input, ctx?)` — run one; returns a response envelope.
58
- - `defineResource(...)` / `defineError(...)` REST resource + typed error definitions.
59
- - Response factories: `ok` / `created` / `accepted` / `noContent` / `notFound` / etc.
60
-
61
- ## See also
62
-
63
- - [Architecture sketch §08 Handler, the operation](../../architecture-sketch.html#handler)
64
- - Sibling packages: [@nwire/hooks](../nwire-hooks), [@nwire/interface](../nwire-interface), [@nwire/http](../nwire-http)
54
+ ## Surface
55
+
56
+ | Export | Role |
57
+ | ----------------------------------- | --------------------------------------------------------------- |
58
+ | `defineHandler(name, config)` | The operation primitive: `{ input, handler, returns?, errors?, summary?, policy?, middleware? }`. |
59
+ | `execute(handler, input, ctx?)` | Run one handler; returns a response envelope. |
60
+ | `defineMiddleware(name?, fn)` | Chain step `(ctx, next)`. Captures `$source`. Reusable. |
61
+ | `defineHook("before" \| "after", name?, fn)` | Before-or-after-only step (cleaner than mw that forgets `next()`). |
62
+ | `pipe(name?, ...steps)` | Compose middleware + hooks into a reusable pipe value. Attaches a per-pipe `$hook` (`@nwire/hooks`) so transports adopt it for telemetry. |
63
+ | `unwindPipe(steps)` | Walk a pipe into `{ middlewares, beforeHooks, afterHooks }` — transports call this when mounting. |
64
+ | `defineResource(name, opts)` | Public response shape (field allowlist, OpenAPI schema). |
65
+ | `defineError(meta)` | Typed throwable with status code. |
66
+ | Response factories | `ok` / `created` / `accepted` / `noContent` / `notModified` / `gone`. |
67
+ | Framework errors | `Unauthorized` / `Forbidden` / `NotFound` / `Conflict` / `Gone` / `BadRequest`. |
68
+ | Type guards | `isHandlerDefinition` / `isMiddleware` / `isHook` / `isPipe` / `isResourceDefinition` / `isNwireError` / `isResponseSpec` / `isResponseInstance`. |
69
+
70
+ ### `$source` + `$hook`
71
+
72
+ - Every `defineMiddleware` / `pipe` captures its call site as `$source`
73
+ via `@nwire/messages.captureSourceLocation`, so Studio can render
74
+ click-to-open chips.
75
+ - Every `pipe(...)` creates a per-pipe `Hook<ResolverCtx>` (one
76
+ `.use()` per middleware step). Runtimes adopt it via
77
+ `runtime.adoptHook($hook)` to route taps into telemetry; consumers
78
+ that don't know about `$hook` ignore the field.
79
+
80
+ ## Related
81
+
82
+ - `@nwire/forge` — re-exports this surface and layers `defineAction` (`defineHandler` + `emits`) + `defineQuery` on top.
83
+ - `@nwire/hooks` — backs `pipe()`'s per-pipe `$hook` and the resolver-level dispatch chain.
84
+ - `@nwire/http` — mounts handlers by `unwindPipe`-ing their middleware.
85
+
86
+ ## Status
87
+
88
+ v0.x — handler shape, middleware/hook/pipe primitives, response factories, and core errors are locked. Per-pipe `$hook` adoption is the canonical observation seam.
@@ -21,12 +21,15 @@
21
21
  * Status: types are open (RestrictedCtx = the resolver's ctx after enrichment).
22
22
  * Type-narrowing middleware composition is a follow-up.
23
23
  */
24
+ import { type Hook, type SourceLocation } from "@nwire/hooks";
24
25
  export type ResolverCtx = Record<string, any>;
25
26
  export type Next = () => Promise<void> | void;
26
27
  export interface MiddlewareDefinition {
27
28
  readonly $kind: "middleware";
28
29
  readonly name?: string;
29
30
  readonly fn: (ctx: ResolverCtx, next: Next) => Promise<void> | void;
31
+ /** Source location of the `defineMiddleware(...)` call site. */
32
+ readonly $source?: SourceLocation;
30
33
  }
31
34
  export interface HookDefinition {
32
35
  readonly $kind: "hook";
@@ -38,6 +41,14 @@ export interface MiddlewarePipe {
38
41
  readonly $kind: "pipe";
39
42
  readonly steps: ReadonlyArray<MiddlewareDefinition | HookDefinition>;
40
43
  readonly name?: string;
44
+ /**
45
+ * Per-pipe observability hook. Internal — transports/runtime call
46
+ * `runtime.adoptHook($hook)` to route taps into telemetry. Consumers that
47
+ * don't know about $hook simply ignore it.
48
+ */
49
+ readonly $hook?: Hook<ResolverCtx>;
50
+ /** Source location of the `pipe(...)` call site. */
51
+ readonly $source?: SourceLocation;
41
52
  }
42
53
  export type PipeStep = MiddlewareDefinition | HookDefinition | MiddlewarePipe;
43
54
  /**
@@ -58,7 +69,14 @@ export declare function defineHook(when: "before" | "after", name: string, fn: (
58
69
  * Compose middleware + hooks into a reusable pipe value. The pipe runs in
59
70
  * declared order: middleware wraps the handler (onion style), `after` hooks
60
71
  * run after the handler succeeds.
72
+ *
73
+ * Optional first-arg `name` labels the pipe for observability; otherwise we
74
+ * synthesize `pipe@<file:line>` from the call site. A per-pipe `$hook`
75
+ * (Hook<ResolverCtx>) is attached for transports/runtime to adopt — each
76
+ * middleware step in the flattened list becomes a `.use()` chain entry on
77
+ * the hook, so taps emit start/end per step at run time.
61
78
  */
79
+ export declare function pipe(name: string, ...steps: PipeStep[]): MiddlewarePipe;
62
80
  export declare function pipe(...steps: PipeStep[]): MiddlewarePipe;
63
81
  /**
64
82
  * Walk a list of pipe steps and split into middleware + hooks. Transports
@@ -1 +1 @@
1
- {"version":3,"file":"define-middleware.d.ts","sourceRoot":"","sources":["../src/define-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE9C,MAAM,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAE9C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACrE;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC3E;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,oBAAoB,GAAG,cAAc,CAAC,CAAC;IACrE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,QAAQ,GAAG,oBAAoB,GAAG,cAAc,GAAG,cAAc,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,MA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;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;AACzE,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;AAoC3D;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG;IAC1D,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B,CAeA;AAED,oBAAoB;AACpB,eAAO,MAAM,YAAY,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,oBAC2C,CAAC;AAE3F,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,cAC2C,CAAC;AAErF,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,cAC2C,CAAC"}
@@ -21,11 +21,13 @@
21
21
  * Status: types are open (RestrictedCtx = the resolver's ctx after enrichment).
22
22
  * Type-narrowing middleware composition is a follow-up.
23
23
  */
24
+ import { hook, captureSourceLocation } from "@nwire/hooks";
24
25
  export function defineMiddleware(nameOrFn, fn) {
26
+ const $source = captureSourceLocation(2);
25
27
  if (typeof nameOrFn === "string") {
26
- return { $kind: "middleware", name: nameOrFn, fn: fn };
28
+ return { $kind: "middleware", name: nameOrFn, fn: fn, $source };
27
29
  }
28
- return { $kind: "middleware", fn: nameOrFn };
30
+ return { $kind: "middleware", fn: nameOrFn, $source };
29
31
  }
30
32
  export function defineHook(when, nameOrFn, maybeFn) {
31
33
  if (typeof nameOrFn === "string") {
@@ -33,12 +35,17 @@ export function defineHook(when, nameOrFn, maybeFn) {
33
35
  }
34
36
  return { $kind: "hook", when, fn: nameOrFn };
35
37
  }
36
- /**
37
- * Compose middleware + hooks into a reusable pipe value. The pipe runs in
38
- * declared order: middleware wraps the handler (onion style), `after` hooks
39
- * run after the handler succeeds.
40
- */
41
- export function pipe(...steps) {
38
+ export function pipe(...args) {
39
+ const $source = captureSourceLocation(2);
40
+ let name;
41
+ let steps;
42
+ if (typeof args[0] === "string") {
43
+ name = args[0];
44
+ steps = args.slice(1);
45
+ }
46
+ else {
47
+ steps = args;
48
+ }
42
49
  const flattened = [];
43
50
  for (const s of steps) {
44
51
  if (s.$kind === "pipe")
@@ -46,7 +53,16 @@ export function pipe(...steps) {
46
53
  else
47
54
  flattened.push(s);
48
55
  }
49
- return { $kind: "pipe", steps: flattened };
56
+ const hookName = name ??
57
+ ($source ? `pipe@${$source.file}:${$source.line}` : "pipe@<unknown>");
58
+ const $hook = hook(hookName);
59
+ for (const step of flattened) {
60
+ if (step.$kind !== "middleware")
61
+ continue;
62
+ const stepName = step.name ?? "anonymous";
63
+ $hook.use(async (ctx, next) => { await step.fn(ctx, next); }, { name: stepName });
64
+ }
65
+ return { $kind: "pipe", steps: flattened, name, $hook, $source };
50
66
  }
51
67
  /**
52
68
  * Walk a list of pipe steps and split into middleware + hooks. Transports
@@ -1 +1 @@
1
- {"version":3,"file":"define-middleware.js","sourceRoot":"","sources":["../src/define-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA8CH,MAAM,UAAU,gBAAgB,CAC9B,QAA2E,EAC3E,EAA2D;IAE3D,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAG,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AAC/C,CAAC;AAWD,MAAM,UAAU,UAAU,CACxB,IAAwB,EACxB,QAAiF,EACjF,OAAsE;IAEtE,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACj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;AAClD,CAAC;AAED,oBAAoB;AACpB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAU,EAA6B,EAAE,CACpE,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAK,CAAyB,CAAC,KAAK,KAAK,YAAY,CAAC;AAE3F,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAU,EAAuB,EAAE,CACxD,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAK,CAAyB,CAAC,KAAK,KAAK,MAAM,CAAC;AAErF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAU,EAAuB,EAAE,CACxD,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAK,CAAyB,CAAC,KAAK,KAAK,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nwire/handler",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Nwire — the operation primitive. defineHandler / defineError / defineResource / defineMiddleware / pipe / response factories / typed framework errors. Standalone — depend on this without pulling forge. Every transport (HTTP, queue, MCP, …) speaks the same handler shape.",
5
5
  "keywords": [
6
6
  "execute",
@@ -8,9 +8,11 @@
8
8
  "nwire",
9
9
  "operation"
10
10
  ],
11
+ "license": "MIT",
11
12
  "files": [
12
13
  "dist",
13
- "README.md"
14
+ "README.md",
15
+ "LICENSE"
14
16
  ],
15
17
  "type": "module",
16
18
  "main": "./dist/handler-index.js",
@@ -26,10 +28,11 @@
26
28
  },
27
29
  "dependencies": {
28
30
  "zod": "^4.0.0",
29
- "@nwire/container": "0.7.0",
30
- "@nwire/envelope": "0.7.0",
31
- "@nwire/logger": "0.7.0",
32
- "@nwire/messages": "0.7.0"
31
+ "@nwire/container": "0.8.0",
32
+ "@nwire/hooks": "0.8.0",
33
+ "@nwire/envelope": "0.8.0",
34
+ "@nwire/messages": "0.8.0",
35
+ "@nwire/logger": "0.8.0"
33
36
  },
34
37
  "devDependencies": {
35
38
  "@types/node": "^22.19.9",