@crvouga/mockingbird-service-edamam 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-4JE7KZHL.js → chunk-CWYJE4IF.js} +97 -25
- package/dist/chunk-CWYJE4IF.js.map +7 -0
- package/dist/{chunk-3N3BYDIZ.js → chunk-TAYOSRJD.js} +5 -3
- package/dist/chunk-TAYOSRJD.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-3N3BYDIZ.js.map +0 -7
- package/dist/chunk-4JE7KZHL.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-edamam
|
|
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/signing.js
|
|
1488
1570
|
var encoder = new TextEncoder();
|
|
@@ -1933,8 +2015,15 @@ var createRuntime = (options) => {
|
|
|
1933
2015
|
const started = monotonicNow();
|
|
1934
2016
|
const url = new URL(request.url);
|
|
1935
2017
|
const operationId = operationIdFor(request, url.pathname);
|
|
2018
|
+
const contentLength = request.headers.get("content-length");
|
|
2019
|
+
const received = {
|
|
2020
|
+
contentType: request.headers.get("content-type"),
|
|
2021
|
+
bodyBytes: contentLength !== null && /^\d+$/.test(contentLength) ? Number(contentLength) : null,
|
|
2022
|
+
transferEncoding: request.headers.get("transfer-encoding")
|
|
2023
|
+
};
|
|
1936
2024
|
const log = (status, faultId, response2) => {
|
|
1937
2025
|
const noted = response2 ? responseNotes(response2) : void 0;
|
|
2026
|
+
const rejected = status >= 400 && faultId === void 0;
|
|
1938
2027
|
const entry = {
|
|
1939
2028
|
service: options.name,
|
|
1940
2029
|
namespace,
|
|
@@ -1946,7 +2035,9 @@ var createRuntime = (options) => {
|
|
|
1946
2035
|
unmatched: options.document !== void 0 && operationId === void 0,
|
|
1947
2036
|
...faultId !== void 0 ? { faultId } : {},
|
|
1948
2037
|
...noted?.ids && Object.keys(noted.ids).length > 0 ? { ids: noted.ids } : {},
|
|
1949
|
-
...noted?.adopted ? { adopted: true } : {}
|
|
2038
|
+
...noted?.adopted ? { adopted: true } : {},
|
|
2039
|
+
...rejected ? { request: { ...received } } : {},
|
|
2040
|
+
...rejected && noted?.issues && noted.issues.length > 0 ? { issues: noted.issues.map((issue) => ({ ...issue })) } : {}
|
|
1950
2041
|
};
|
|
1951
2042
|
metrics.record(entry);
|
|
1952
2043
|
journal.record({ ...entry, at: new Date(clock.now()).toISOString() });
|
|
@@ -2153,25 +2244,6 @@ var presetRoutes = (presets, runtime) => ({
|
|
|
2153
2244
|
}
|
|
2154
2245
|
});
|
|
2155
2246
|
|
|
2156
|
-
// ../core/dist/validation.js
|
|
2157
|
-
var bodyIssues = (context, contentType = "application/json") => {
|
|
2158
|
-
const requestBody = context.operation.operation.requestBody;
|
|
2159
|
-
if (!requestBody)
|
|
2160
|
-
return [];
|
|
2161
|
-
const resolved = deref(context.document, requestBody);
|
|
2162
|
-
const schema = resolved.content?.[contentType]?.schema;
|
|
2163
|
-
if (!schema)
|
|
2164
|
-
return [];
|
|
2165
|
-
const value = context.body.kind === "json" || context.body.kind === "form" ? context.body.value : void 0;
|
|
2166
|
-
if (context.body.kind === "invalid") {
|
|
2167
|
-
return [{ path: "", message: `request body is not valid ${context.body.mediaType}` }];
|
|
2168
|
-
}
|
|
2169
|
-
if (value === void 0) {
|
|
2170
|
-
return resolved.required ? [{ path: "", message: "request body is required" }] : [];
|
|
2171
|
-
}
|
|
2172
|
-
return validateValue(context.document, resolveSchema(context.document, schema), value).map((issue) => ({ path: issue.path.join("."), message: issue.message }));
|
|
2173
|
-
};
|
|
2174
|
-
|
|
2175
2247
|
// src/corpus.ts
|
|
2176
2248
|
var MEASURE_URI = "http://www.edamam.com/ontologies/edamam.owl#Measure_";
|
|
2177
2249
|
var RECIPE_URI = "http://www.edamam.com/ontologies/edamam.owl#recipe_";
|
|
@@ -3482,4 +3554,4 @@ export {
|
|
|
3482
3554
|
appIdCredential,
|
|
3483
3555
|
EdamamAPI
|
|
3484
3556
|
};
|
|
3485
|
-
//# sourceMappingURL=chunk-
|
|
3557
|
+
//# sourceMappingURL=chunk-CWYJE4IF.js.map
|