@mailwoman/api-kit 9.1.0 → 9.2.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
@@ -1,6 +1,6 @@
1
1
  # @mailwoman/api-kit
2
2
 
3
- Plumbing for [Mailwoman](https://mailwoman.sister.software)'s HTTP surfaces — a node `serve` wrapper and
3
+ Plumbing for [Mailwoman](https://mailwoman.ai)'s HTTP surfaces — a node `serve` wrapper and
4
4
  OpenAPI emit helpers shared by the drop-in packages ([`@mailwoman/libpostal`](../libpostal),
5
5
  [`@mailwoman/photon`](../photon), [`@mailwoman/nominatim`](../nominatim)).
6
6
 
package/error.ts CHANGED
@@ -29,6 +29,21 @@ export const APIErrorSchema = z
29
29
  * handler's return type against that specific route's declared per-status `responses` map. A flat-typed `status` param
30
30
  * would widen every branch to "any content-carrying status", which no single declared response branch matches.
31
31
  */
32
- export function apiError<S extends ContentfulStatusCode>(c: Context, status: S, error: string, detail?: string) {
32
+ export function errorResponse<S extends ContentfulStatusCode>(c: Context, status: S, error: string, detail?: string) {
33
33
  return c.json(detail === undefined ? { error } : { error, detail }, status)
34
34
  }
35
+
36
+ const GEOCODER_UNAVAILABLE_DETAIL =
37
+ "install @mailwoman/neural + @mailwoman/resolver-wof-sqlite and provide gazetteer data (MAILWOMAN_WOF_DB / MAILWOMAN_CANDIDATE_DB)"
38
+
39
+ /**
40
+ * The "engine method absent" 503, for the engine method the route actually needed.
41
+ *
42
+ * `subject` is a WIRE VALUE, not a label. `<subject> not available` is published verbatim in the HTTP API reference
43
+ * table and in the docker deploy guide, so a caller branching on it is doing what the docs told them to — and
44
+ * `/v1/resolve` answers `resolver`, not `geocoder`, because the method it found missing is `engine.resolveTree`. Rename
45
+ * this function freely; never the string it emits.
46
+ */
47
+ export function geocoderUnavailableError(c: Context, subject: "geocoder" | "resolver" = "geocoder") {
48
+ return errorResponse(c, 503, `${subject} not available`, GEOCODER_UNAVAILABLE_DETAIL)
49
+ }
package/openapi.ts CHANGED
@@ -13,6 +13,8 @@ import { dirname } from "node:path"
13
13
 
14
14
  import type { OpenAPIHono } from "@hono/zod-openapi"
15
15
 
16
+ type OpenAPISecurityRequirements = Parameters<OpenAPIHono["getOpenAPI31Document"]>[0]["security"]
17
+
16
18
  /**
17
19
  * The document config stamped into emitted documents: `title`/`version`/`description`/`summary`/`license`/`contact`
18
20
  * land under the document's `info` block; `externalDocs`/`servers`/`tags`/`security` are top-level document fields. All
@@ -32,7 +34,7 @@ export interface OpenAPIDocInfo {
32
34
  variables?: Record<string, { default: string; description?: string }>
33
35
  }>
34
36
  tags?: Array<{ name: string; description?: string }>
35
- security?: unknown[]
37
+ security?: OpenAPISecurityRequirements
36
38
  }
37
39
 
38
40
  /**
@@ -54,18 +56,28 @@ function toDocumentConfig(info: OpenAPIDocInfo) {
54
56
  * Mount the OpenAPI 3.1 document endpoint on `app` (default `/openapi.json`).
55
57
  */
56
58
  export function attachOpenAPIDocs(app: OpenAPIHono, info: OpenAPIDocInfo, path = "/openapi.json"): void {
57
- // openapi3-ts's InfoObject/OpenAPIObject carry an `x-${string}` extension index signature that
58
- // a plain interface can't satisfy — cast at the boundary rather than widening the public type.
59
- app.doc31(path, { openapi: "3.1.0", ...toDocumentConfig(info) } as never)
59
+ const config: Parameters<OpenAPIHono["doc31"]>[1] = { openapi: "3.1.0", ...toDocumentConfig(info) }
60
+
61
+ app.doc31(path, config)
60
62
  }
61
63
 
62
64
  /**
63
65
  * Emit both document flavors programmatically (build artifacts, parity tests, client generation).
64
66
  */
65
67
  export function emitOpenAPIDocuments(app: OpenAPIHono, info: OpenAPIDocInfo): { v31: object; v30: object } {
68
+ const v31Config: Parameters<OpenAPIHono["getOpenAPI31Document"]>[0] = {
69
+ openapi: "3.1.0",
70
+ ...toDocumentConfig(info),
71
+ }
72
+
73
+ const v30Config: Parameters<OpenAPIHono["getOpenAPIDocument"]>[0] = {
74
+ openapi: "3.0.3",
75
+ ...toDocumentConfig(info),
76
+ }
77
+
66
78
  return {
67
- v31: app.getOpenAPI31Document({ openapi: "3.1.0", ...toDocumentConfig(info) } as never),
68
- v30: app.getOpenAPIDocument({ openapi: "3.0.3", ...toDocumentConfig(info) } as never),
79
+ v31: app.getOpenAPI31Document(v31Config),
80
+ v30: app.getOpenAPIDocument(v30Config),
69
81
  }
70
82
  }
71
83
 
package/out/error.d.ts CHANGED
@@ -24,10 +24,24 @@ export declare const APIErrorSchema: z.ZodObject<{
24
24
  * handler's return type against that specific route's declared per-status `responses` map. A flat-typed `status` param
25
25
  * would widen every branch to "any content-carrying status", which no single declared response branch matches.
26
26
  */
27
- export declare function apiError<S extends ContentfulStatusCode>(c: Context, status: S, error: string, detail?: string): Response & import("hono").TypedResponse<{
27
+ export declare function errorResponse<S extends ContentfulStatusCode>(c: Context, status: S, error: string, detail?: string): Response & import("hono").TypedResponse<{
28
28
  error: string;
29
29
  } | {
30
30
  error: string;
31
31
  detail: string;
32
32
  }, S, "json">;
33
+ /**
34
+ * The "engine method absent" 503, for the engine method the route actually needed.
35
+ *
36
+ * `subject` is a WIRE VALUE, not a label. `<subject> not available` is published verbatim in the HTTP API reference
37
+ * table and in the docker deploy guide, so a caller branching on it is doing what the docs told them to — and
38
+ * `/v1/resolve` answers `resolver`, not `geocoder`, because the method it found missing is `engine.resolveTree`. Rename
39
+ * this function freely; never the string it emits.
40
+ */
41
+ export declare function geocoderUnavailableError(c: Context, subject?: "geocoder" | "resolver"): Response & import("hono").TypedResponse<{
42
+ error: string;
43
+ } | {
44
+ error: string;
45
+ detail: string;
46
+ }, 503, "json">;
33
47
  //# sourceMappingURL=error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAElE;;GAEG;AACH,eAAO,MAAM,cAAc;;;iBAKN,CAAA;AAErB;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,oBAAoB,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;;;;;cAE7G"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAElE;;GAEG;AACH,eAAO,MAAM,cAAc;;;iBAKN,CAAA;AAErB;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,oBAAoB,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;;;;;cAElH;AAKD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAE,UAAU,GAAG,UAAuB;;;;;gBAEjG"}
package/out/error.js CHANGED
@@ -24,7 +24,19 @@ export const APIErrorSchema = z
24
24
  * handler's return type against that specific route's declared per-status `responses` map. A flat-typed `status` param
25
25
  * would widen every branch to "any content-carrying status", which no single declared response branch matches.
26
26
  */
27
- export function apiError(c, status, error, detail) {
27
+ export function errorResponse(c, status, error, detail) {
28
28
  return c.json(detail === undefined ? { error } : { error, detail }, status);
29
29
  }
30
+ const GEOCODER_UNAVAILABLE_DETAIL = "install @mailwoman/neural + @mailwoman/resolver-wof-sqlite and provide gazetteer data (MAILWOMAN_WOF_DB / MAILWOMAN_CANDIDATE_DB)";
31
+ /**
32
+ * The "engine method absent" 503, for the engine method the route actually needed.
33
+ *
34
+ * `subject` is a WIRE VALUE, not a label. `<subject> not available` is published verbatim in the HTTP API reference
35
+ * table and in the docker deploy guide, so a caller branching on it is doing what the docs told them to — and
36
+ * `/v1/resolve` answers `resolver`, not `geocoder`, because the method it found missing is `engine.resolveTree`. Rename
37
+ * this function freely; never the string it emits.
38
+ */
39
+ export function geocoderUnavailableError(c, subject = "geocoder") {
40
+ return errorResponse(c, 503, `${subject} not available`, GEOCODER_UNAVAILABLE_DETAIL);
41
+ }
30
42
  //# sourceMappingURL=error.js.map
package/out/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAIrC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC7B,MAAM,CAAC;IACP,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC;KACD,OAAO,CAAC,UAAU,CAAC,CAAA;AAErB;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAiC,CAAU,EAAE,MAAS,EAAE,KAAa,EAAE,MAAe;IAC7G,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,CAAA;AAC5E,CAAC"}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAIrC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC7B,MAAM,CAAC;IACP,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC;KACD,OAAO,CAAC,UAAU,CAAC,CAAA;AAErB;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAiC,CAAU,EAAE,MAAS,EAAE,KAAa,EAAE,MAAe;IAClH,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,CAAA;AAC5E,CAAC;AAED,MAAM,2BAA2B,GAChC,mIAAmI,CAAA;AAEpI;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CAAC,CAAU,EAAE,UAAmC,UAAU;IACjG,OAAO,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,gBAAgB,EAAE,2BAA2B,CAAC,CAAA;AACtF,CAAC"}
package/out/openapi.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  * (progenitor), replacing the old hand-downgrade step.
9
9
  */
10
10
  import type { OpenAPIHono } from "@hono/zod-openapi";
11
+ type OpenAPISecurityRequirements = Parameters<OpenAPIHono["getOpenAPI31Document"]>[0]["security"];
11
12
  /**
12
13
  * The document config stamped into emitted documents: `title`/`version`/`description`/`summary`/`license`/`contact`
13
14
  * land under the document's `info` block; `externalDocs`/`servers`/`tags`/`security` are top-level document fields. All
@@ -42,7 +43,7 @@ export interface OpenAPIDocInfo {
42
43
  name: string;
43
44
  description?: string;
44
45
  }>;
45
- security?: unknown[];
46
+ security?: OpenAPISecurityRequirements;
46
47
  }
47
48
  /**
48
49
  * Mount the OpenAPI 3.1 document endpoint on `app` (default `/openapi.json`).
@@ -83,4 +84,5 @@ export declare function errorContent<S>(description: string, schema: S): {
83
84
  };
84
85
  };
85
86
  };
87
+ export {};
86
88
  //#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;QACf,GAAG,EAAE,MAAM,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KACrE,CAAC,CAAA;IACF,IAAI,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACpD,QAAQ,CAAC,EAAE,2BAA2B,CAAA;CACtC;AAiBD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,SAAkB,GAAG,IAAI,CAItG;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAezG;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,cAAc,EACpB,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1C,IAAI,CAUN;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;;;;;;;EAK7D"}
package/out/openapi.js CHANGED
@@ -26,17 +26,24 @@ function toDocumentConfig(info) {
26
26
  * Mount the OpenAPI 3.1 document endpoint on `app` (default `/openapi.json`).
27
27
  */
28
28
  export function attachOpenAPIDocs(app, info, path = "/openapi.json") {
29
- // openapi3-ts's InfoObject/OpenAPIObject carry an `x-${string}` extension index signature that
30
- // a plain interface can't satisfy — cast at the boundary rather than widening the public type.
31
- app.doc31(path, { openapi: "3.1.0", ...toDocumentConfig(info) });
29
+ const config = { openapi: "3.1.0", ...toDocumentConfig(info) };
30
+ app.doc31(path, config);
32
31
  }
33
32
  /**
34
33
  * Emit both document flavors programmatically (build artifacts, parity tests, client generation).
35
34
  */
36
35
  export function emitOpenAPIDocuments(app, info) {
36
+ const v31Config = {
37
+ openapi: "3.1.0",
38
+ ...toDocumentConfig(info),
39
+ };
40
+ const v30Config = {
41
+ openapi: "3.0.3",
42
+ ...toDocumentConfig(info),
43
+ };
37
44
  return {
38
- v31: app.getOpenAPI31Document({ openapi: "3.1.0", ...toDocumentConfig(info) }),
39
- v30: app.getOpenAPIDocument({ openapi: "3.0.3", ...toDocumentConfig(info) }),
45
+ v31: app.getOpenAPI31Document(v31Config),
46
+ v30: app.getOpenAPIDocument(v30Config),
40
47
  };
41
48
  }
42
49
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.js","sourceRoot":"","sources":["../openapi.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA0BnC;;GAEG;AACH,SAAS,gBAAgB,CAAC,IAAoB;IAC7C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;IAE9G,OAAO;QACN,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;QAChE,YAAY;QACZ,OAAO;QACP,IAAI;QACJ,QAAQ;KACR,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAgB,EAAE,IAAoB,EAAE,IAAI,GAAG,eAAe;IAC/F,+FAA+F;IA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C;QACxC,GAAG,EAAE,GAAG,CAAC,kBAAkB,CAAC,SAAS,CAAC;KACtC,CAAA;AACF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CACnC,GAAgB,EAChB,IAAoB,EACpB,OAA0C,EAAE;IAE5C,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,oBAAoB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACpD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IAE9D,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QACd,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACjD,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,CAAA;IACrC,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAClB,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAI,WAAmB,EAAE,MAAS;IAC7D,OAAO;QACN,WAAW;QACX,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE;KAC3C,CAAA;AACF,CAAC"}
package/out/serve.d.ts CHANGED
@@ -7,14 +7,15 @@
7
7
  * surface packages stay web-standard (they only export `fetch`-shaped apps) so an edge
8
8
  * deployment needs no changes to them.
9
9
  */
10
+ import { serve } from "@hono/node-server";
10
11
  /**
11
12
  * A `fetch`-shaped request handler (what `OpenAPIHono.fetch` provides).
12
13
  */
13
14
  export type FetchLike = (request: Request, ...args: never[]) => Response | Promise<Response>;
14
- export interface ServeNodeOptions {
15
- fetch: FetchLike;
16
- port: number;
17
- hostname: string;
15
+ /**
16
+ * Options for `serveNode()`. Extracted since Hono doesn't seem to export them.
17
+ */
18
+ export type ServeNodeOptions = Parameters<typeof serve>[0] & {
18
19
  /**
19
20
  * Called once the listener is bound — receives the actual port (useful with `port: 0`).
20
21
  */
@@ -22,7 +23,7 @@ export interface ServeNodeOptions {
22
23
  port: number;
23
24
  address: string;
24
25
  }) => void;
25
- }
26
+ };
26
27
  export interface ServerHandle {
27
28
  close(): Promise<void>;
28
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../serve.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAE5F,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,SAAS,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CAC5D;AAED,MAAM,WAAW,YAAY;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,YAAY,CAWjE"}
1
+ {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../serve.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAE5F;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,CAAC"}
1
+ {"version":3,"file":"serve.js","sourceRoot":"","sources":["../serve.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAqBzC;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAyB;IAClD,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CACvG,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAC9D,CAAA;IAED,OAAO;QACN,KAAK,EAAE,GAAG,EAAE,CACX,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;QACrE,CAAC,CAAC;KACH,CAAA;AACF,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mailwoman/api-kit",
3
- "version": "9.1.0",
3
+ "version": "9.2.0",
4
4
  "description": "API plumbing for Mailwoman's HTTP surfaces — Hono node serve wrapper, OpenAPI emit helpers, shared wire atoms. Plumbing only: domain schemas live with their routes.",
5
5
  "license": "AGPL-3.0-only OR LicenseRef-Commercial",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/sister-software/mailwoman.git",
9
- "directory": "api-kit"
9
+ "directory": "packages/api-kit"
10
10
  },
11
11
  "files": [
12
12
  "out/**/*.js",
@@ -21,7 +21,8 @@
21
21
  "!*.test.ts",
22
22
  "!*.test.tsx",
23
23
  "!**/*.test.ts",
24
- "!**/*.test.tsx"
24
+ "!**/*.test.tsx",
25
+ "!test/**"
25
26
  ],
26
27
  "type": "module",
27
28
  "exports": {
@@ -29,6 +30,10 @@
29
30
  ".": {
30
31
  "types": "./out/index.d.ts",
31
32
  "default": "./out/index.js"
33
+ },
34
+ "./metrics": {
35
+ "types": "./out/metrics.d.ts",
36
+ "default": "./out/metrics.js"
32
37
  }
33
38
  },
34
39
  "publishConfig": {
@@ -38,6 +43,10 @@
38
43
  ".": {
39
44
  "types": "./out/index.d.ts",
40
45
  "default": "./out/index.js"
46
+ },
47
+ "./metrics": {
48
+ "types": "./out/metrics.d.ts",
49
+ "default": "./out/metrics.js"
41
50
  }
42
51
  }
43
52
  },
package/serve.ts CHANGED
@@ -15,10 +15,10 @@ import { serve } from "@hono/node-server"
15
15
  */
16
16
  export type FetchLike = (request: Request, ...args: never[]) => Response | Promise<Response>
17
17
 
18
- export interface ServeNodeOptions {
19
- fetch: FetchLike
20
- port: number
21
- hostname: string
18
+ /**
19
+ * Options for `serveNode()`. Extracted since Hono doesn't seem to export them.
20
+ */
21
+ export type ServeNodeOptions = Parameters<typeof serve>[0] & {
22
22
  /**
23
23
  * Called once the listener is bound — receives the actual port (useful with `port: 0`).
24
24
  */
@@ -33,7 +33,7 @@ export interface ServerHandle {
33
33
  * Boot a node HTTP listener for a Hono app. Returns a handle whose `close()` resolves when the listener is down.
34
34
  */
35
35
  export function serveNode(options: ServeNodeOptions): ServerHandle {
36
- const server = serve({ fetch: options.fetch as never, port: options.port, hostname: options.hostname }, (info) =>
36
+ const server = serve({ fetch: options.fetch, port: options.port, hostname: options.hostname }, (info) =>
37
37
  options.onListen?.({ port: info.port, address: info.address })
38
38
  )
39
39