@crvouga/mockingbird-service-caretalk 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-UONXFCPB.js → chunk-BSB6CGDN.js} +2 -2
- package/dist/{chunk-CJB2FLM5.js → chunk-YN2RHGFZ.js} +75 -6
- package/dist/chunk-YN2RHGFZ.js.map +7 -0
- 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-CJB2FLM5.js.map +0 -7
- /package/dist/{chunk-UONXFCPB.js.map → chunk-BSB6CGDN.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-caretalk
|
|
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
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createRuntime,
|
|
4
4
|
parseDuration,
|
|
5
5
|
resolveAdminPrefix
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YN2RHGFZ.js";
|
|
7
7
|
|
|
8
8
|
// ../../adapters/node/dist/cli.js
|
|
9
9
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -845,4 +845,4 @@ export {
|
|
|
845
845
|
createServer2 as createServer,
|
|
846
846
|
serveTarget
|
|
847
847
|
};
|
|
848
|
-
//# sourceMappingURL=chunk-
|
|
848
|
+
//# sourceMappingURL=chunk-BSB6CGDN.js.map
|
|
@@ -1018,7 +1018,40 @@ var decodeBody = (contentType, bytes) => {
|
|
|
1018
1018
|
return { kind: "bytes", value: bytes };
|
|
1019
1019
|
};
|
|
1020
1020
|
var readBody = async (message) => {
|
|
1021
|
-
|
|
1021
|
+
if (!(message instanceof Request) || !message.body) {
|
|
1022
|
+
if (message instanceof Request)
|
|
1023
|
+
message.signal.throwIfAborted();
|
|
1024
|
+
return decodeBody(message.headers.get("content-type"), new Uint8Array(await message.arrayBuffer()));
|
|
1025
|
+
}
|
|
1026
|
+
message.signal.throwIfAborted();
|
|
1027
|
+
const reader = message.body.getReader();
|
|
1028
|
+
const cancel = () => {
|
|
1029
|
+
void reader.cancel(message.signal.reason).catch(() => {
|
|
1030
|
+
});
|
|
1031
|
+
};
|
|
1032
|
+
message.signal.addEventListener("abort", cancel, { once: true });
|
|
1033
|
+
const chunks = [];
|
|
1034
|
+
let size = 0;
|
|
1035
|
+
try {
|
|
1036
|
+
for (; ; ) {
|
|
1037
|
+
message.signal.throwIfAborted();
|
|
1038
|
+
const { done, value } = await reader.read();
|
|
1039
|
+
message.signal.throwIfAborted();
|
|
1040
|
+
if (done)
|
|
1041
|
+
break;
|
|
1042
|
+
chunks.push(value);
|
|
1043
|
+
size += value.byteLength;
|
|
1044
|
+
}
|
|
1045
|
+
} finally {
|
|
1046
|
+
message.signal.removeEventListener("abort", cancel);
|
|
1047
|
+
reader.releaseLock();
|
|
1048
|
+
}
|
|
1049
|
+
const bytes = new Uint8Array(size);
|
|
1050
|
+
let offset = 0;
|
|
1051
|
+
for (const chunk of chunks) {
|
|
1052
|
+
bytes.set(chunk, offset);
|
|
1053
|
+
offset += chunk.byteLength;
|
|
1054
|
+
}
|
|
1022
1055
|
return decodeBody(message.headers.get("content-type"), bytes);
|
|
1023
1056
|
};
|
|
1024
1057
|
|
|
@@ -1747,7 +1780,42 @@ var verifyOperations = (document2, handlers) => {
|
|
|
1747
1780
|
}
|
|
1748
1781
|
return problems;
|
|
1749
1782
|
};
|
|
1750
|
-
var
|
|
1783
|
+
var escapePattern = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1784
|
+
var serviceRoute = (template) => {
|
|
1785
|
+
const names = [];
|
|
1786
|
+
let pattern = "", end = 0;
|
|
1787
|
+
for (const match of template.matchAll(/\{([^}]+)\}/g)) {
|
|
1788
|
+
pattern += `${escapePattern(template.slice(end, match.index))}([^/]+?)`;
|
|
1789
|
+
const name = match[1];
|
|
1790
|
+
if (!name)
|
|
1791
|
+
throw new Error(`Invalid OpenAPI route template: ${template}`);
|
|
1792
|
+
names.push(name);
|
|
1793
|
+
end = match.index + match[0].length;
|
|
1794
|
+
}
|
|
1795
|
+
pattern += escapePattern(template.slice(end));
|
|
1796
|
+
const matcher = new RegExp(`^${pattern}$`);
|
|
1797
|
+
const path = template.split("/").map((segment, index) => {
|
|
1798
|
+
if (!segment.includes("{"))
|
|
1799
|
+
return segment;
|
|
1800
|
+
const literal = /^\{([^}]+)\}$/.exec(segment);
|
|
1801
|
+
if (literal)
|
|
1802
|
+
return `:${literal[1]}`;
|
|
1803
|
+
let expression = "", offset = 0;
|
|
1804
|
+
for (const match of segment.matchAll(/\{[^}]+\}/g)) {
|
|
1805
|
+
expression += `${escapePattern(segment.slice(offset, match.index))}[^/]+?`;
|
|
1806
|
+
offset = match.index + match[0].length;
|
|
1807
|
+
}
|
|
1808
|
+
expression += escapePattern(segment.slice(offset));
|
|
1809
|
+
return `:mockingbirdSegment${index}{${expression}}`;
|
|
1810
|
+
}).join("/");
|
|
1811
|
+
return {
|
|
1812
|
+
path,
|
|
1813
|
+
params: (pathname) => {
|
|
1814
|
+
const values = matcher.exec(pathname);
|
|
1815
|
+
return Object.fromEntries(names.map((name, index) => [name, decodeURIComponent(values?.[index + 1] ?? "")]));
|
|
1816
|
+
}
|
|
1817
|
+
};
|
|
1818
|
+
};
|
|
1751
1819
|
var routeOrder = (a, b) => {
|
|
1752
1820
|
const sa = a.path.split("/");
|
|
1753
1821
|
const sb = b.path.split("/");
|
|
@@ -1782,6 +1850,7 @@ var createService = (options) => {
|
|
|
1782
1850
|
for (const operation of operations) {
|
|
1783
1851
|
const metadata = operationMetadata(operation.operation);
|
|
1784
1852
|
const handler = options.handlers[operation.operationId];
|
|
1853
|
+
const registeredRoute = serviceRoute(operation.path);
|
|
1785
1854
|
const route = async (c) => {
|
|
1786
1855
|
const request = c.req.raw;
|
|
1787
1856
|
if (!metadata.supported || !handler) {
|
|
@@ -1791,7 +1860,7 @@ var createService = (options) => {
|
|
|
1791
1860
|
const context = {
|
|
1792
1861
|
request,
|
|
1793
1862
|
url,
|
|
1794
|
-
params:
|
|
1863
|
+
params: registeredRoute.params(url.pathname),
|
|
1795
1864
|
query: queryOf(url),
|
|
1796
1865
|
body: await readBody(request),
|
|
1797
1866
|
sqlite: options.sqlite,
|
|
@@ -1803,7 +1872,7 @@ var createService = (options) => {
|
|
|
1803
1872
|
const short = await options.before?.(context);
|
|
1804
1873
|
return withIssues(request, short ?? await handler(context));
|
|
1805
1874
|
};
|
|
1806
|
-
app.on(operation.method.toUpperCase(),
|
|
1875
|
+
app.on(operation.method.toUpperCase(), registeredRoute.path, route);
|
|
1807
1876
|
}
|
|
1808
1877
|
return {
|
|
1809
1878
|
app,
|
|
@@ -2272,7 +2341,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
2272
2341
|
};
|
|
2273
2342
|
|
|
2274
2343
|
// ../core/dist/version.js
|
|
2275
|
-
var PACKAGE_VERSION = true ? "2.
|
|
2344
|
+
var PACKAGE_VERSION = true ? "2.2.0" : UNRELEASED_VERSION;
|
|
2276
2345
|
|
|
2277
2346
|
// ../core/dist/signing.js
|
|
2278
2347
|
var encoder = new TextEncoder();
|
|
@@ -3971,4 +4040,4 @@ export {
|
|
|
3971
4040
|
normalizeDate,
|
|
3972
4041
|
CareTalkAPI
|
|
3973
4042
|
};
|
|
3974
|
-
//# sourceMappingURL=chunk-
|
|
4043
|
+
//# sourceMappingURL=chunk-YN2RHGFZ.js.map
|