@crvouga/mockingbird-service-wholescripts 1.0.0 → 1.0.2
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/CHANGELOG.md +13 -4
- package/dist/{chunk-WGRFFBW4.js → chunk-A2547YFQ.js} +97 -25
- package/dist/chunk-A2547YFQ.js.map +7 -0
- package/dist/{chunk-DXX432IY.js → chunk-FATLEILG.js} +5 -3
- package/dist/chunk-FATLEILG.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +117 -89
- package/dist/index.js +1 -1
- package/dist/server.d.ts +221 -165
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-DXX432IY.js.map +0 -7
- package/dist/chunk-WGRFFBW4.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-wholescripts
|
|
2
2
|
|
|
3
|
+
## 1.0.2 (2026-09-26)
|
|
4
|
+
|
|
5
|
+
### Fixes and improvements
|
|
6
|
+
|
|
7
|
+
- treat enum [""] branches as unset markers in form coercion ([7177835](https://github.com/crvouga/mockingbird/commit/7177835cc510e14245d6648ad2821daa694bb80c))
|
|
8
|
+
|
|
9
|
+
## 1.0.1 (2026-09-25)
|
|
10
|
+
|
|
11
|
+
### Fixes and improvements
|
|
12
|
+
|
|
13
|
+
- take the rejected-request byte count from content-length, never by reading the body ([a0e5fb2](https://github.com/crvouga/mockingbird/commit/a0e5fb2fc80ab725c3552b612f3f091fd6c857fb))
|
|
14
|
+
- reject a present body by media type, and log what a rejected request sent ([12e351a](https://github.com/crvouga/mockingbird/commit/12e351aba53cfb7b41e31a7809419455fc2902eb))
|
|
15
|
+
|
|
3
16
|
## 1.0.0 (2026-09-24)
|
|
4
17
|
|
|
5
18
|
### ⚠️ Breaking changes
|
|
6
19
|
|
|
7
20
|
- vendor branding for every service; purge internal mocks and consumer names ([f689534](https://github.com/crvouga/mockingbird/commit/f6895343543550dafcb7d76b426cae7635e03226))
|
|
8
21
|
|
|
9
|
-
### Dependencies
|
|
10
|
-
|
|
11
|
-
- `@crvouga/mockingbird-service-sqlite`
|
|
12
|
-
|
|
13
22
|
## 0.2.0 (2026-09-23)
|
|
14
23
|
|
|
15
24
|
### Features
|
|
@@ -1358,6 +1358,90 @@ var operationMetadata = (operation) => {
|
|
|
1358
1358
|
|
|
1359
1359
|
// ../core/dist/service.js
|
|
1360
1360
|
import { Hono } from "hono";
|
|
1361
|
+
|
|
1362
|
+
// ../core/dist/validation.js
|
|
1363
|
+
var requestBodyOf = (context) => {
|
|
1364
|
+
const requestBody = context.operation.operation.requestBody;
|
|
1365
|
+
return requestBody ? deref(context.document, requestBody) : void 0;
|
|
1366
|
+
};
|
|
1367
|
+
var mediaTypeMatches = (accepted, actual) => {
|
|
1368
|
+
const pattern = mediaTypeOf(accepted) ?? accepted.toLowerCase();
|
|
1369
|
+
if (pattern === actual || pattern === "*/*")
|
|
1370
|
+
return true;
|
|
1371
|
+
const [type, subtype] = pattern.split("/");
|
|
1372
|
+
const [actualType, actualSubtype] = actual.split("/");
|
|
1373
|
+
if (type !== actualType && type !== "*")
|
|
1374
|
+
return false;
|
|
1375
|
+
if (subtype === void 0 || subtype === "*")
|
|
1376
|
+
return true;
|
|
1377
|
+
if (subtype.startsWith("*+"))
|
|
1378
|
+
return actualSubtype?.endsWith(subtype.slice(1)) === true;
|
|
1379
|
+
return false;
|
|
1380
|
+
};
|
|
1381
|
+
var acceptedKeyFor = (content, mediaType) => {
|
|
1382
|
+
if (!content || mediaType === void 0)
|
|
1383
|
+
return void 0;
|
|
1384
|
+
const keys = Object.keys(content);
|
|
1385
|
+
return keys.find((key) => mediaTypeOf(key) === mediaType) ?? keys.find((key) => mediaTypeMatches(key, mediaType));
|
|
1386
|
+
};
|
|
1387
|
+
var unsupportedMediaType = (context, options = {}) => {
|
|
1388
|
+
if (context.body.kind === "empty" && options.includeEmpty !== true)
|
|
1389
|
+
return void 0;
|
|
1390
|
+
const content = requestBodyOf(context)?.content;
|
|
1391
|
+
if (!content || Object.keys(content).length === 0)
|
|
1392
|
+
return void 0;
|
|
1393
|
+
const mediaType = mediaTypeOf(context.request.headers.get("content-type"));
|
|
1394
|
+
if (acceptedKeyFor(content, mediaType) !== void 0)
|
|
1395
|
+
return void 0;
|
|
1396
|
+
return { mediaType: mediaType ?? null, accepted: Object.keys(content) };
|
|
1397
|
+
};
|
|
1398
|
+
var recorded = /* @__PURE__ */ new WeakMap();
|
|
1399
|
+
var recordedIssues = (request) => recorded.get(request);
|
|
1400
|
+
var bodyIssues = (context, contentType = "application/json") => {
|
|
1401
|
+
const issues = findBodyIssues(context, contentType);
|
|
1402
|
+
if (issues.length > 0)
|
|
1403
|
+
recorded.set(context.request, issues);
|
|
1404
|
+
return issues;
|
|
1405
|
+
};
|
|
1406
|
+
var findBodyIssues = (context, contentType) => {
|
|
1407
|
+
const resolved = requestBodyOf(context);
|
|
1408
|
+
if (!resolved)
|
|
1409
|
+
return [];
|
|
1410
|
+
const unsupported = unsupportedMediaType(context);
|
|
1411
|
+
if (unsupported) {
|
|
1412
|
+
return [
|
|
1413
|
+
{
|
|
1414
|
+
path: "",
|
|
1415
|
+
kind: "media_type",
|
|
1416
|
+
message: unsupported.mediaType === null ? "request body has no content-type" : `request body media type ${unsupported.mediaType} is not supported`
|
|
1417
|
+
}
|
|
1418
|
+
];
|
|
1419
|
+
}
|
|
1420
|
+
const key = acceptedKeyFor(resolved.content, mediaTypeOf(context.request.headers.get("content-type"))) ?? contentType;
|
|
1421
|
+
const schema = resolved.content?.[key]?.schema;
|
|
1422
|
+
if (!schema)
|
|
1423
|
+
return [];
|
|
1424
|
+
if (context.body.kind === "invalid") {
|
|
1425
|
+
return [
|
|
1426
|
+
{
|
|
1427
|
+
path: "",
|
|
1428
|
+
kind: "syntax",
|
|
1429
|
+
message: `request body is not valid ${context.body.mediaType}`
|
|
1430
|
+
}
|
|
1431
|
+
];
|
|
1432
|
+
}
|
|
1433
|
+
const value = context.body.kind === "json" || context.body.kind === "form" || context.body.kind === "text" ? context.body.value : void 0;
|
|
1434
|
+
if (value === void 0) {
|
|
1435
|
+
return resolved.required && context.body.kind === "empty" ? [{ path: "", kind: "required", message: "request body is required" }] : [];
|
|
1436
|
+
}
|
|
1437
|
+
return validateValue(context.document, resolveSchema(context.document, schema), value).map((issue) => ({ path: issue.path.join("."), kind: "schema", message: issue.message }));
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
// ../core/dist/service.js
|
|
1441
|
+
var withIssues = (request, response) => {
|
|
1442
|
+
const issues = response.status >= 400 ? recordedIssues(request) : void 0;
|
|
1443
|
+
return issues && issues.length > 0 ? annotateResponse(response, { issues }) : response;
|
|
1444
|
+
};
|
|
1361
1445
|
var defineOperations = (handlers) => handlers;
|
|
1362
1446
|
var OperationRegistryError = class extends Error {
|
|
1363
1447
|
problems;
|
|
@@ -1443,9 +1527,7 @@ var createService = (options) => {
|
|
|
1443
1527
|
now
|
|
1444
1528
|
};
|
|
1445
1529
|
const short = await options.before?.(context);
|
|
1446
|
-
|
|
1447
|
-
return short;
|
|
1448
|
-
return handler(context);
|
|
1530
|
+
return withIssues(request, short ?? await handler(context));
|
|
1449
1531
|
};
|
|
1450
1532
|
app.on(operation.method.toUpperCase(), honoPath(operation.path), route);
|
|
1451
1533
|
}
|
|
@@ -1482,7 +1564,7 @@ var restoreNamespace = (sqlite, namespace, snapshot) => {
|
|
|
1482
1564
|
};
|
|
1483
1565
|
|
|
1484
1566
|
// ../core/dist/version.js
|
|
1485
|
-
var PACKAGE_VERSION = true ? "1.0.
|
|
1567
|
+
var PACKAGE_VERSION = true ? "1.0.2" : UNRELEASED_VERSION;
|
|
1486
1568
|
|
|
1487
1569
|
// ../core/dist/webhooks.js
|
|
1488
1570
|
var json2 = (status, body) => new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json" } });
|
|
@@ -1922,8 +2004,15 @@ var createRuntime = (options) => {
|
|
|
1922
2004
|
const started = monotonicNow();
|
|
1923
2005
|
const url = new URL(request.url);
|
|
1924
2006
|
const operationId = operationIdFor(request, url.pathname);
|
|
2007
|
+
const contentLength = request.headers.get("content-length");
|
|
2008
|
+
const received = {
|
|
2009
|
+
contentType: request.headers.get("content-type"),
|
|
2010
|
+
bodyBytes: contentLength !== null && /^\d+$/.test(contentLength) ? Number(contentLength) : null,
|
|
2011
|
+
transferEncoding: request.headers.get("transfer-encoding")
|
|
2012
|
+
};
|
|
1925
2013
|
const log = (status, faultId, response2) => {
|
|
1926
2014
|
const noted = response2 ? responseNotes(response2) : void 0;
|
|
2015
|
+
const rejected = status >= 400 && faultId === void 0;
|
|
1927
2016
|
const entry = {
|
|
1928
2017
|
service: options.name,
|
|
1929
2018
|
namespace,
|
|
@@ -1935,7 +2024,9 @@ var createRuntime = (options) => {
|
|
|
1935
2024
|
unmatched: options.document !== void 0 && operationId === void 0,
|
|
1936
2025
|
...faultId !== void 0 ? { faultId } : {},
|
|
1937
2026
|
...noted?.ids && Object.keys(noted.ids).length > 0 ? { ids: noted.ids } : {},
|
|
1938
|
-
...noted?.adopted ? { adopted: true } : {}
|
|
2027
|
+
...noted?.adopted ? { adopted: true } : {},
|
|
2028
|
+
...rejected ? { request: { ...received } } : {},
|
|
2029
|
+
...rejected && noted?.issues && noted.issues.length > 0 ? { issues: noted.issues.map((issue) => ({ ...issue })) } : {}
|
|
1939
2030
|
};
|
|
1940
2031
|
metrics.record(entry);
|
|
1941
2032
|
journal.record({ ...entry, at: new Date(clock.now()).toISOString() });
|
|
@@ -2142,25 +2233,6 @@ var presetRoutes = (presets, runtime) => ({
|
|
|
2142
2233
|
}
|
|
2143
2234
|
});
|
|
2144
2235
|
|
|
2145
|
-
// ../core/dist/validation.js
|
|
2146
|
-
var bodyIssues = (context, contentType = "application/json") => {
|
|
2147
|
-
const requestBody = context.operation.operation.requestBody;
|
|
2148
|
-
if (!requestBody)
|
|
2149
|
-
return [];
|
|
2150
|
-
const resolved = deref(context.document, requestBody);
|
|
2151
|
-
const schema = resolved.content?.[contentType]?.schema;
|
|
2152
|
-
if (!schema)
|
|
2153
|
-
return [];
|
|
2154
|
-
const value = context.body.kind === "json" || context.body.kind === "form" ? context.body.value : void 0;
|
|
2155
|
-
if (context.body.kind === "invalid") {
|
|
2156
|
-
return [{ path: "", message: `request body is not valid ${context.body.mediaType}` }];
|
|
2157
|
-
}
|
|
2158
|
-
if (value === void 0) {
|
|
2159
|
-
return resolved.required ? [{ path: "", message: "request body is required" }] : [];
|
|
2160
|
-
}
|
|
2161
|
-
return validateValue(context.document, resolveSchema(context.document, schema), value).map((issue) => ({ path: issue.path.join("."), message: issue.message }));
|
|
2162
|
-
};
|
|
2163
|
-
|
|
2164
2236
|
// src/catalog.ts
|
|
2165
2237
|
var MEDPAX_BOX_SKU = "000000000200095263";
|
|
2166
2238
|
var product = (row) => ({
|
|
@@ -2782,4 +2854,4 @@ export {
|
|
|
2782
2854
|
canonicalStatus,
|
|
2783
2855
|
WholescriptsAPI
|
|
2784
2856
|
};
|
|
2785
|
-
//# sourceMappingURL=chunk-
|
|
2857
|
+
//# sourceMappingURL=chunk-A2547YFQ.js.map
|