@crvouga/mockingbird-service-aha 2.1.0 → 2.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/CHANGELOG.md +10 -4
- package/dist/{chunk-ZJ5AX3P7.js → chunk-E3PPKVY5.js} +75 -6
- package/dist/chunk-E3PPKVY5.js.map +7 -0
- package/dist/{chunk-ELDZXOEH.js → chunk-RGXPG7C3.js} +2 -2
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-ZJ5AX3P7.js.map +0 -7
- /package/dist/{chunk-ELDZXOEH.js.map → chunk-RGXPG7C3.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-aha
|
|
2
2
|
|
|
3
|
+
## 2.2.0 (2026-10-05)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- add scripted local API mock ([4a76a11](https://github.com/crvouga/mockingbird/commit/4a76a114e2efad45934e0a93cf29576fd418e15c))
|
|
8
|
+
|
|
9
|
+
### Fixes and improvements
|
|
10
|
+
|
|
11
|
+
- support embedded route parameters ([127cad9](https://github.com/crvouga/mockingbird/commit/127cad997ef106950c1b866070eea191ba54403f))
|
|
12
|
+
|
|
3
13
|
## 2.1.0 (2026-10-04)
|
|
4
14
|
|
|
5
15
|
### Features
|
|
@@ -12,10 +22,6 @@
|
|
|
12
22
|
- fill the embedded viewport ([c1a35a4](https://github.com/crvouga/mockingbird/commit/c1a35a4789389ee9cd06c286d09bd47c4d06c71e))
|
|
13
23
|
- make dialog cleanup immediate ([0c1a3c5](https://github.com/crvouga/mockingbird/commit/0c1a3c5b12584d50c19dcae595b951b8e5417b9c))
|
|
14
24
|
|
|
15
|
-
### Dependencies
|
|
16
|
-
|
|
17
|
-
- `@crvouga/mockingbird-service-sqlite`
|
|
18
|
-
|
|
19
25
|
## 2.0.0 (2026-10-04)
|
|
20
26
|
|
|
21
27
|
### ⚠️ Breaking changes
|
|
@@ -1011,7 +1011,40 @@ var decodeBody = (contentType, bytes) => {
|
|
|
1011
1011
|
return { kind: "bytes", value: bytes };
|
|
1012
1012
|
};
|
|
1013
1013
|
var readBody = async (message) => {
|
|
1014
|
-
|
|
1014
|
+
if (!(message instanceof Request) || !message.body) {
|
|
1015
|
+
if (message instanceof Request)
|
|
1016
|
+
message.signal.throwIfAborted();
|
|
1017
|
+
return decodeBody(message.headers.get("content-type"), new Uint8Array(await message.arrayBuffer()));
|
|
1018
|
+
}
|
|
1019
|
+
message.signal.throwIfAborted();
|
|
1020
|
+
const reader = message.body.getReader();
|
|
1021
|
+
const cancel = () => {
|
|
1022
|
+
void reader.cancel(message.signal.reason).catch(() => {
|
|
1023
|
+
});
|
|
1024
|
+
};
|
|
1025
|
+
message.signal.addEventListener("abort", cancel, { once: true });
|
|
1026
|
+
const chunks = [];
|
|
1027
|
+
let size = 0;
|
|
1028
|
+
try {
|
|
1029
|
+
for (; ; ) {
|
|
1030
|
+
message.signal.throwIfAborted();
|
|
1031
|
+
const { done, value } = await reader.read();
|
|
1032
|
+
message.signal.throwIfAborted();
|
|
1033
|
+
if (done)
|
|
1034
|
+
break;
|
|
1035
|
+
chunks.push(value);
|
|
1036
|
+
size += value.byteLength;
|
|
1037
|
+
}
|
|
1038
|
+
} finally {
|
|
1039
|
+
message.signal.removeEventListener("abort", cancel);
|
|
1040
|
+
reader.releaseLock();
|
|
1041
|
+
}
|
|
1042
|
+
const bytes = new Uint8Array(size);
|
|
1043
|
+
let offset = 0;
|
|
1044
|
+
for (const chunk of chunks) {
|
|
1045
|
+
bytes.set(chunk, offset);
|
|
1046
|
+
offset += chunk.byteLength;
|
|
1047
|
+
}
|
|
1015
1048
|
return decodeBody(message.headers.get("content-type"), bytes);
|
|
1016
1049
|
};
|
|
1017
1050
|
|
|
@@ -1819,7 +1852,42 @@ var verifyOperations = (document2, handlers) => {
|
|
|
1819
1852
|
}
|
|
1820
1853
|
return problems;
|
|
1821
1854
|
};
|
|
1822
|
-
var
|
|
1855
|
+
var escapePattern = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1856
|
+
var serviceRoute = (template) => {
|
|
1857
|
+
const names = [];
|
|
1858
|
+
let pattern = "", end = 0;
|
|
1859
|
+
for (const match of template.matchAll(/\{([^}]+)\}/g)) {
|
|
1860
|
+
pattern += `${escapePattern(template.slice(end, match.index))}([^/]+?)`;
|
|
1861
|
+
const name = match[1];
|
|
1862
|
+
if (!name)
|
|
1863
|
+
throw new Error(`Invalid OpenAPI route template: ${template}`);
|
|
1864
|
+
names.push(name);
|
|
1865
|
+
end = match.index + match[0].length;
|
|
1866
|
+
}
|
|
1867
|
+
pattern += escapePattern(template.slice(end));
|
|
1868
|
+
const matcher = new RegExp(`^${pattern}$`);
|
|
1869
|
+
const path = template.split("/").map((segment, index) => {
|
|
1870
|
+
if (!segment.includes("{"))
|
|
1871
|
+
return segment;
|
|
1872
|
+
const literal = /^\{([^}]+)\}$/.exec(segment);
|
|
1873
|
+
if (literal)
|
|
1874
|
+
return `:${literal[1]}`;
|
|
1875
|
+
let expression = "", offset = 0;
|
|
1876
|
+
for (const match of segment.matchAll(/\{[^}]+\}/g)) {
|
|
1877
|
+
expression += `${escapePattern(segment.slice(offset, match.index))}[^/]+?`;
|
|
1878
|
+
offset = match.index + match[0].length;
|
|
1879
|
+
}
|
|
1880
|
+
expression += escapePattern(segment.slice(offset));
|
|
1881
|
+
return `:mockingbirdSegment${index}{${expression}}`;
|
|
1882
|
+
}).join("/");
|
|
1883
|
+
return {
|
|
1884
|
+
path,
|
|
1885
|
+
params: (pathname) => {
|
|
1886
|
+
const values = matcher.exec(pathname);
|
|
1887
|
+
return Object.fromEntries(names.map((name, index) => [name, decodeURIComponent(values?.[index + 1] ?? "")]));
|
|
1888
|
+
}
|
|
1889
|
+
};
|
|
1890
|
+
};
|
|
1823
1891
|
var routeOrder = (a, b) => {
|
|
1824
1892
|
const sa = a.path.split("/");
|
|
1825
1893
|
const sb = b.path.split("/");
|
|
@@ -1854,6 +1922,7 @@ var createService = (options) => {
|
|
|
1854
1922
|
for (const operation of operations) {
|
|
1855
1923
|
const metadata = operationMetadata(operation.operation);
|
|
1856
1924
|
const handler = options.handlers[operation.operationId];
|
|
1925
|
+
const registeredRoute = serviceRoute(operation.path);
|
|
1857
1926
|
const route = async (c) => {
|
|
1858
1927
|
const request = c.req.raw;
|
|
1859
1928
|
if (!metadata.supported || !handler) {
|
|
@@ -1863,7 +1932,7 @@ var createService = (options) => {
|
|
|
1863
1932
|
const context = {
|
|
1864
1933
|
request,
|
|
1865
1934
|
url,
|
|
1866
|
-
params:
|
|
1935
|
+
params: registeredRoute.params(url.pathname),
|
|
1867
1936
|
query: queryOf(url),
|
|
1868
1937
|
body: await readBody(request),
|
|
1869
1938
|
sqlite: options.sqlite,
|
|
@@ -1875,7 +1944,7 @@ var createService = (options) => {
|
|
|
1875
1944
|
const short = await options.before?.(context);
|
|
1876
1945
|
return withIssues(request, short ?? await handler(context));
|
|
1877
1946
|
};
|
|
1878
|
-
app.on(operation.method.toUpperCase(),
|
|
1947
|
+
app.on(operation.method.toUpperCase(), registeredRoute.path, route);
|
|
1879
1948
|
}
|
|
1880
1949
|
return {
|
|
1881
1950
|
app,
|
|
@@ -2344,7 +2413,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
2344
2413
|
};
|
|
2345
2414
|
|
|
2346
2415
|
// ../core/dist/version.js
|
|
2347
|
-
var PACKAGE_VERSION = true ? "2.
|
|
2416
|
+
var PACKAGE_VERSION = true ? "2.2.0" : UNRELEASED_VERSION;
|
|
2348
2417
|
|
|
2349
2418
|
// ../core/dist/signing.js
|
|
2350
2419
|
var encoder = new TextEncoder();
|
|
@@ -4225,4 +4294,4 @@ export {
|
|
|
4225
4294
|
apiKeyCredential,
|
|
4226
4295
|
AhaAPI
|
|
4227
4296
|
};
|
|
4228
|
-
//# sourceMappingURL=chunk-
|
|
4297
|
+
//# sourceMappingURL=chunk-E3PPKVY5.js.map
|