@mailwoman/api-kit 8.6.0 → 9.1.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/index.ts +1 -0
- package/metrics.ts +8 -0
- package/openapi.ts +14 -0
- package/out/index.d.ts +1 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -0
- package/out/index.js.map +1 -1
- package/out/metrics.d.ts.map +1 -1
- package/out/metrics.js +8 -0
- package/out/metrics.js.map +1 -1
- package/out/openapi.d.ts +15 -0
- package/out/openapi.d.ts.map +1 -1
- package/out/openapi.js +13 -0
- package/out/openapi.js.map +1 -1
- package/out/request.d.ts +22 -0
- package/out/request.d.ts.map +1 -0
- package/out/request.js +27 -0
- package/out/request.js.map +1 -0
- package/package.json +2 -2
- package/request.ts +31 -0
package/index.ts
CHANGED
package/metrics.ts
CHANGED
|
@@ -49,6 +49,14 @@ export function recordTimed(latencyMs: number, tier: string): void {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Percentile for the metrics snapshot — deliberately NOT `percentile` from `@mailwoman/core/utils`.
|
|
54
|
+
*
|
|
55
|
+
* Three differences, each on purpose for a hot request-path counter: it takes an ALREADY-sorted array (the caller sorts
|
|
56
|
+
* once per snapshot, not once per percentile), returns `0` rather than `null` on empty so the snapshot stays a plain
|
|
57
|
+
* number map, and rounds to two decimals because these are milliseconds on a wire format. Core's returns `null` and
|
|
58
|
+
* does not round.
|
|
59
|
+
*/
|
|
52
60
|
function percentile(sorted: number[], p: number): number {
|
|
53
61
|
if (!sorted.length) return 0
|
|
54
62
|
const idx = Math.min(sorted.length - 1, Math.floor(p * sorted.length))
|
package/openapi.ts
CHANGED
|
@@ -93,3 +93,17 @@ export function printOpenAPIDocument(
|
|
|
93
93
|
console.log(json)
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* An OpenAPI error-response descriptor: a description plus a JSON body of `schema`.
|
|
99
|
+
*
|
|
100
|
+
* Takes the schema rather than owning one, because each drop-in's error envelope reproduces the wire shape of the
|
|
101
|
+
* project it replaces — Nominatim's differs from libpostal's, and both are recorded decisions rather than drift. What
|
|
102
|
+
* repeats between them is this four-line descriptor, not the shape it wraps.
|
|
103
|
+
*/
|
|
104
|
+
export function errorContent<S>(description: string, schema: S) {
|
|
105
|
+
return {
|
|
106
|
+
description,
|
|
107
|
+
content: { "application/json": { schema } },
|
|
108
|
+
}
|
|
109
|
+
}
|
package/out/index.d.ts
CHANGED
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
package/out/index.js
CHANGED
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
package/out/metrics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAkBH;;;GAGG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAejE;
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAkBH;;;GAGG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAejE;AAiBD,MAAM,WAAW,eAAe;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE;QACR,KAAK,EAAE,MAAM,CAAA;QACb,MAAM,EAAE,MAAM,CAAA;QACd;;;WAGG;QACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC7B,UAAU,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAA;QACzE,eAAe,EAAE,MAAM,CAAA;KACvB,CAAA;CACD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,eAAe,CAoBjD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAW1C"}
|
package/out/metrics.js
CHANGED
|
@@ -44,6 +44,14 @@ export function recordTimed(latencyMs, tier) {
|
|
|
44
44
|
writeIdx = (writeIdx + 1) % MAX_SAMPLES;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Percentile for the metrics snapshot — deliberately NOT `percentile` from `@mailwoman/core/utils`.
|
|
49
|
+
*
|
|
50
|
+
* Three differences, each on purpose for a hot request-path counter: it takes an ALREADY-sorted array (the caller sorts
|
|
51
|
+
* once per snapshot, not once per percentile), returns `0` rather than `null` on empty so the snapshot stays a plain
|
|
52
|
+
* number map, and rounds to two decimals because these are milliseconds on a wire format. Core's returns `null` and
|
|
53
|
+
* does not round.
|
|
54
|
+
*/
|
|
47
55
|
function percentile(sorted, p) {
|
|
48
56
|
if (!sorted.length)
|
|
49
57
|
return 0;
|
package/out/metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,WAAW,GAAG,IAAI,CAAA;AAExB,MAAM,SAAS,GAAa,EAAE,CAAA;AAC9B,IAAI,QAAQ,GAAG,CAAC,CAAA;AAEhB;;GAEG;AACH,MAAM,UAAU,GAA2B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAC9D,IAAI,KAAK,GAAG,CAAC,CAAA;AACb,IAAI,MAAM,GAAG,CAAC,CAAA;AACd,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;AAE5B;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,IAAY;IAC1D,KAAK,EAAE,CAAA;IAEP,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACtB,MAAM,EAAE,CAAA;IACT,CAAC;SAAM,CAAC;QACP,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;IAC/C,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,GAAG,WAAW,EAAE,CAAC;QACpC,SAAS,CAAC,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7B,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,GAAG,GAAG,CAAC,GAAG,GAAG;iBAC3C;gBACF,CAAC,CAAC,IAAI;YACP,eAAe,EAAE,MAAM,CAAC,MAAM;SAC9B;KACD,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAClC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;IACpB,QAAQ,GAAG,CAAC,CAAA;IAEZ,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3C,iIAAiI;QACjI,OAAO,UAAU,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAED,KAAK,GAAG,CAAC,CAAA;IACT,MAAM,GAAG,CAAC,CAAA;AACX,CAAC"}
|
package/out/openapi.d.ts
CHANGED
|
@@ -68,4 +68,19 @@ export declare function printOpenAPIDocument(app: OpenAPIHono, info: OpenAPIDocI
|
|
|
68
68
|
flavor?: string;
|
|
69
69
|
out?: string;
|
|
70
70
|
}): void;
|
|
71
|
+
/**
|
|
72
|
+
* An OpenAPI error-response descriptor: a description plus a JSON body of `schema`.
|
|
73
|
+
*
|
|
74
|
+
* Takes the schema rather than owning one, because each drop-in's error envelope reproduces the wire shape of the
|
|
75
|
+
* project it replaces — Nominatim's differs from libpostal's, and both are recorded decisions rather than drift. What
|
|
76
|
+
* repeats between them is this four-line descriptor, not the shape it wraps.
|
|
77
|
+
*/
|
|
78
|
+
export declare function errorContent<S>(description: string, schema: S): {
|
|
79
|
+
description: string;
|
|
80
|
+
content: {
|
|
81
|
+
"application/json": {
|
|
82
|
+
schema: S;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
71
86
|
//# sourceMappingURL=openapi.d.ts.map
|
package/out/openapi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi.d.ts","sourceRo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AW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACpD,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;CACpB;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,CAKzG;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
|
@@ -59,4 +59,17 @@ export function printOpenAPIDocument(app, info, opts = {}) {
|
|
|
59
59
|
console.log(json);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* An OpenAPI error-response descriptor: a description plus a JSON body of `schema`.
|
|
64
|
+
*
|
|
65
|
+
* Takes the schema rather than owning one, because each drop-in's error envelope reproduces the wire shape of the
|
|
66
|
+
* project it replaces — Nominatim's differs from libpostal's, and both are recorded decisions rather than drift. What
|
|
67
|
+
* repeats between them is this four-line descriptor, not the shape it wraps.
|
|
68
|
+
*/
|
|
69
|
+
export function errorContent(description, schema) {
|
|
70
|
+
return {
|
|
71
|
+
description,
|
|
72
|
+
content: { "application/json": { schema } },
|
|
73
|
+
};
|
|
74
|
+
}
|
|
62
75
|
//# sourceMappingURL=openapi.js.map
|
package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,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/request.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Request-side plumbing shared by the drop-in API surfaces.
|
|
7
|
+
*
|
|
8
|
+
* The drop-ins deliberately do NOT share their response envelopes — each one reproduces the wire
|
|
9
|
+
* shape of the project it replaces, and `libpostal/app.ts` records that as a free choice made on
|
|
10
|
+
* purpose. What they can share is everything upstream of the envelope: how a query string is read,
|
|
11
|
+
* how a route is described. That is what lives here.
|
|
12
|
+
*/
|
|
13
|
+
import type { Context } from "hono";
|
|
14
|
+
/**
|
|
15
|
+
* Read the query string as Express-shaped values: a repeated key becomes an array, a single occurrence stays a scalar.
|
|
16
|
+
*
|
|
17
|
+
* Nominatim and Photon both accept repeated parameters and both were written against Express, so their engines expect
|
|
18
|
+
* this shape rather than Hono's uniformly-array `queries()`. Built on a null-prototype object so a query key of
|
|
19
|
+
* `__proto__` or `constructor` cannot reach `Object`'s prototype — these handlers take arbitrary internet input.
|
|
20
|
+
*/
|
|
21
|
+
export declare function legacyQuery(c: Context): Record<string, string | string[]>;
|
|
22
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAQzE"}
|
package/out/request.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Request-side plumbing shared by the drop-in API surfaces.
|
|
7
|
+
*
|
|
8
|
+
* The drop-ins deliberately do NOT share their response envelopes — each one reproduces the wire
|
|
9
|
+
* shape of the project it replaces, and `libpostal/app.ts` records that as a free choice made on
|
|
10
|
+
* purpose. What they can share is everything upstream of the envelope: how a query string is read,
|
|
11
|
+
* how a route is described. That is what lives here.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Read the query string as Express-shaped values: a repeated key becomes an array, a single occurrence stays a scalar.
|
|
15
|
+
*
|
|
16
|
+
* Nominatim and Photon both accept repeated parameters and both were written against Express, so their engines expect
|
|
17
|
+
* this shape rather than Hono's uniformly-array `queries()`. Built on a null-prototype object so a query key of
|
|
18
|
+
* `__proto__` or `constructor` cannot reach `Object`'s prototype — these handlers take arbitrary internet input.
|
|
19
|
+
*/
|
|
20
|
+
export function legacyQuery(c) {
|
|
21
|
+
const out = Object.create(null);
|
|
22
|
+
for (const [key, values] of Object.entries(c.req.queries())) {
|
|
23
|
+
out[key] = values.length === 1 ? values[0] : values;
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACrC,MAAM,GAAG,GAAsC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAElE,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,MAAM,CAAA;IACrD,CAAC;IAED,OAAO,GAAG,CAAA;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/api-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.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": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@hono/node-server": "^2.0.12",
|
|
46
46
|
"@hono/zod-openapi": "^1.5.1",
|
|
47
|
-
"hono": "^4.
|
|
47
|
+
"hono": "^4.13.0",
|
|
48
48
|
"zod": "^4.4.3"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/request.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Request-side plumbing shared by the drop-in API surfaces.
|
|
7
|
+
*
|
|
8
|
+
* The drop-ins deliberately do NOT share their response envelopes — each one reproduces the wire
|
|
9
|
+
* shape of the project it replaces, and `libpostal/app.ts` records that as a free choice made on
|
|
10
|
+
* purpose. What they can share is everything upstream of the envelope: how a query string is read,
|
|
11
|
+
* how a route is described. That is what lives here.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { Context } from "hono"
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Read the query string as Express-shaped values: a repeated key becomes an array, a single occurrence stays a scalar.
|
|
18
|
+
*
|
|
19
|
+
* Nominatim and Photon both accept repeated parameters and both were written against Express, so their engines expect
|
|
20
|
+
* this shape rather than Hono's uniformly-array `queries()`. Built on a null-prototype object so a query key of
|
|
21
|
+
* `__proto__` or `constructor` cannot reach `Object`'s prototype — these handlers take arbitrary internet input.
|
|
22
|
+
*/
|
|
23
|
+
export function legacyQuery(c: Context): Record<string, string | string[]> {
|
|
24
|
+
const out: Record<string, string | string[]> = Object.create(null)
|
|
25
|
+
|
|
26
|
+
for (const [key, values] of Object.entries(c.req.queries())) {
|
|
27
|
+
out[key] = values.length === 1 ? values[0]! : values
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return out
|
|
31
|
+
}
|