@nwire/handler 0.12.0 → 0.13.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/define-handler.d.ts +10 -0
- package/dist/define-handler.js +16 -0
- package/package.json +5 -5
package/dist/define-handler.d.ts
CHANGED
|
@@ -280,6 +280,16 @@ export type HandlerLike<TInput = unknown, TOutput = unknown> = HandlerDefinition
|
|
|
280
280
|
* await ListTodos.run({ input: { status: "open" }, signal });
|
|
281
281
|
*/
|
|
282
282
|
export declare function defineHandler<TInputSchema extends ZodTypeAny | undefined, TOutput, TExtras extends object = object>(name: string, config: HandlerConfig<TInputSchema, TOutput, TExtras>): HandlerDefinition<TInputSchema, TOutput, TExtras>;
|
|
283
|
+
/**
|
|
284
|
+
* Flavored definers — `defineHandler.kind("action")(name, config)` stamps
|
|
285
|
+
* `config.kind` so one primitive produces every flavor. Forge's `defineAction`
|
|
286
|
+
* / `defineQuery` are built on these (plus their own thin decoration); a bare
|
|
287
|
+
* `defineHandler` is `kind: "handler"`. This is the single-definer guarantee:
|
|
288
|
+
* there is no parallel `defineAction` primitive to drift — only `kind` differs.
|
|
289
|
+
*/
|
|
290
|
+
export declare namespace defineHandler {
|
|
291
|
+
function kind(k: HandlerKind): <TInputSchema extends ZodTypeAny | undefined, TOutput, TExtras extends object = object>(name: string, config: Omit<HandlerConfig<TInputSchema, TOutput, TExtras>, "kind">) => HandlerDefinition<TInputSchema, TOutput, TExtras>;
|
|
292
|
+
}
|
|
283
293
|
/**
|
|
284
294
|
* App-boundary sugar — pin `TExtras` once so every handler in the app reads
|
|
285
295
|
* `ctx` as the bound shape without per-call annotations.
|
package/dist/define-handler.js
CHANGED
|
@@ -144,6 +144,22 @@ export function defineHandler(name, config) {
|
|
|
144
144
|
});
|
|
145
145
|
return factory;
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Flavored definers — `defineHandler.kind("action")(name, config)` stamps
|
|
149
|
+
* `config.kind` so one primitive produces every flavor. Forge's `defineAction`
|
|
150
|
+
* / `defineQuery` are built on these (plus their own thin decoration); a bare
|
|
151
|
+
* `defineHandler` is `kind: "handler"`. This is the single-definer guarantee:
|
|
152
|
+
* there is no parallel `defineAction` primitive to drift — only `kind` differs.
|
|
153
|
+
*/
|
|
154
|
+
(function (defineHandler) {
|
|
155
|
+
function kind(k) {
|
|
156
|
+
return (name, config) => defineHandler(name, {
|
|
157
|
+
...config,
|
|
158
|
+
kind: k,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
defineHandler.kind = kind;
|
|
162
|
+
})(defineHandler || (defineHandler = {}));
|
|
147
163
|
/**
|
|
148
164
|
* App-boundary sugar — pin `TExtras` once so every handler in the app reads
|
|
149
165
|
* `ctx` as the bound shape without per-call annotations.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nwire/handler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Nwire — the operation primitive. Typed, callable, hookable value built on @nwire/hooks. defineHandler / defineError / defineResource / response factories / framework errors. Standalone; every transport (HTTP, queue, MCP, CLI) speaks the same handler shape.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"execute",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"zod": "^4.0.0",
|
|
31
|
-
"@nwire/container": "0.
|
|
32
|
-
"@nwire/
|
|
33
|
-
"@nwire/hooks": "0.
|
|
34
|
-
"@nwire/
|
|
31
|
+
"@nwire/container": "0.13.0",
|
|
32
|
+
"@nwire/envelope": "0.13.0",
|
|
33
|
+
"@nwire/hooks": "0.13.0",
|
|
34
|
+
"@nwire/messages": "0.13.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^22.19.9",
|