@crvouga/mockingbird-service-pharmetika 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-KV3DM7ZV.js → chunk-6FWPEEOJ.js} +2 -2
- package/dist/{chunk-53L7T7DP.js → chunk-BQ7EIQNF.js} +75 -6
- package/dist/chunk-BQ7EIQNF.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-53L7T7DP.js.map +0 -7
- /package/dist/{chunk-KV3DM7ZV.js.map → chunk-6FWPEEOJ.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-pharmetika
|
|
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-BQ7EIQNF.js";
|
|
7
7
|
|
|
8
8
|
// ../../adapters/node/dist/cli.js
|
|
9
9
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -883,4 +883,4 @@ export {
|
|
|
883
883
|
createServer2 as createServer,
|
|
884
884
|
serveTarget
|
|
885
885
|
};
|
|
886
|
-
//# sourceMappingURL=chunk-
|
|
886
|
+
//# sourceMappingURL=chunk-6FWPEEOJ.js.map
|
|
@@ -1029,7 +1029,40 @@ var decodeBody = (contentType, bytes) => {
|
|
|
1029
1029
|
return { kind: "bytes", value: bytes };
|
|
1030
1030
|
};
|
|
1031
1031
|
var readBody = async (message) => {
|
|
1032
|
-
|
|
1032
|
+
if (!(message instanceof Request) || !message.body) {
|
|
1033
|
+
if (message instanceof Request)
|
|
1034
|
+
message.signal.throwIfAborted();
|
|
1035
|
+
return decodeBody(message.headers.get("content-type"), new Uint8Array(await message.arrayBuffer()));
|
|
1036
|
+
}
|
|
1037
|
+
message.signal.throwIfAborted();
|
|
1038
|
+
const reader = message.body.getReader();
|
|
1039
|
+
const cancel = () => {
|
|
1040
|
+
void reader.cancel(message.signal.reason).catch(() => {
|
|
1041
|
+
});
|
|
1042
|
+
};
|
|
1043
|
+
message.signal.addEventListener("abort", cancel, { once: true });
|
|
1044
|
+
const chunks = [];
|
|
1045
|
+
let size = 0;
|
|
1046
|
+
try {
|
|
1047
|
+
for (; ; ) {
|
|
1048
|
+
message.signal.throwIfAborted();
|
|
1049
|
+
const { done, value } = await reader.read();
|
|
1050
|
+
message.signal.throwIfAborted();
|
|
1051
|
+
if (done)
|
|
1052
|
+
break;
|
|
1053
|
+
chunks.push(value);
|
|
1054
|
+
size += value.byteLength;
|
|
1055
|
+
}
|
|
1056
|
+
} finally {
|
|
1057
|
+
message.signal.removeEventListener("abort", cancel);
|
|
1058
|
+
reader.releaseLock();
|
|
1059
|
+
}
|
|
1060
|
+
const bytes = new Uint8Array(size);
|
|
1061
|
+
let offset = 0;
|
|
1062
|
+
for (const chunk of chunks) {
|
|
1063
|
+
bytes.set(chunk, offset);
|
|
1064
|
+
offset += chunk.byteLength;
|
|
1065
|
+
}
|
|
1033
1066
|
return decodeBody(message.headers.get("content-type"), bytes);
|
|
1034
1067
|
};
|
|
1035
1068
|
|
|
@@ -1807,7 +1840,42 @@ var verifyOperations = (document2, handlers) => {
|
|
|
1807
1840
|
}
|
|
1808
1841
|
return problems;
|
|
1809
1842
|
};
|
|
1810
|
-
var
|
|
1843
|
+
var escapePattern = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1844
|
+
var serviceRoute = (template) => {
|
|
1845
|
+
const names = [];
|
|
1846
|
+
let pattern = "", end = 0;
|
|
1847
|
+
for (const match of template.matchAll(/\{([^}]+)\}/g)) {
|
|
1848
|
+
pattern += `${escapePattern(template.slice(end, match.index))}([^/]+?)`;
|
|
1849
|
+
const name = match[1];
|
|
1850
|
+
if (!name)
|
|
1851
|
+
throw new Error(`Invalid OpenAPI route template: ${template}`);
|
|
1852
|
+
names.push(name);
|
|
1853
|
+
end = match.index + match[0].length;
|
|
1854
|
+
}
|
|
1855
|
+
pattern += escapePattern(template.slice(end));
|
|
1856
|
+
const matcher = new RegExp(`^${pattern}$`);
|
|
1857
|
+
const path = template.split("/").map((segment, index) => {
|
|
1858
|
+
if (!segment.includes("{"))
|
|
1859
|
+
return segment;
|
|
1860
|
+
const literal = /^\{([^}]+)\}$/.exec(segment);
|
|
1861
|
+
if (literal)
|
|
1862
|
+
return `:${literal[1]}`;
|
|
1863
|
+
let expression = "", offset = 0;
|
|
1864
|
+
for (const match of segment.matchAll(/\{[^}]+\}/g)) {
|
|
1865
|
+
expression += `${escapePattern(segment.slice(offset, match.index))}[^/]+?`;
|
|
1866
|
+
offset = match.index + match[0].length;
|
|
1867
|
+
}
|
|
1868
|
+
expression += escapePattern(segment.slice(offset));
|
|
1869
|
+
return `:mockingbirdSegment${index}{${expression}}`;
|
|
1870
|
+
}).join("/");
|
|
1871
|
+
return {
|
|
1872
|
+
path,
|
|
1873
|
+
params: (pathname) => {
|
|
1874
|
+
const values = matcher.exec(pathname);
|
|
1875
|
+
return Object.fromEntries(names.map((name, index) => [name, decodeURIComponent(values?.[index + 1] ?? "")]));
|
|
1876
|
+
}
|
|
1877
|
+
};
|
|
1878
|
+
};
|
|
1811
1879
|
var routeOrder = (a, b) => {
|
|
1812
1880
|
const sa = a.path.split("/");
|
|
1813
1881
|
const sb = b.path.split("/");
|
|
@@ -1842,6 +1910,7 @@ var createService = (options) => {
|
|
|
1842
1910
|
for (const operation of operations) {
|
|
1843
1911
|
const metadata = operationMetadata(operation.operation);
|
|
1844
1912
|
const handler = options.handlers[operation.operationId];
|
|
1913
|
+
const registeredRoute = serviceRoute(operation.path);
|
|
1845
1914
|
const route = async (c) => {
|
|
1846
1915
|
const request = c.req.raw;
|
|
1847
1916
|
if (!metadata.supported || !handler) {
|
|
@@ -1851,7 +1920,7 @@ var createService = (options) => {
|
|
|
1851
1920
|
const context = {
|
|
1852
1921
|
request,
|
|
1853
1922
|
url,
|
|
1854
|
-
params:
|
|
1923
|
+
params: registeredRoute.params(url.pathname),
|
|
1855
1924
|
query: queryOf(url),
|
|
1856
1925
|
body: await readBody(request),
|
|
1857
1926
|
sqlite: options.sqlite,
|
|
@@ -1863,7 +1932,7 @@ var createService = (options) => {
|
|
|
1863
1932
|
const short = await options.before?.(context);
|
|
1864
1933
|
return withIssues(request, short ?? await handler(context));
|
|
1865
1934
|
};
|
|
1866
|
-
app.on(operation.method.toUpperCase(),
|
|
1935
|
+
app.on(operation.method.toUpperCase(), registeredRoute.path, route);
|
|
1867
1936
|
}
|
|
1868
1937
|
return {
|
|
1869
1938
|
app,
|
|
@@ -2332,7 +2401,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
2332
2401
|
};
|
|
2333
2402
|
|
|
2334
2403
|
// ../core/dist/version.js
|
|
2335
|
-
var PACKAGE_VERSION = true ? "2.
|
|
2404
|
+
var PACKAGE_VERSION = true ? "2.2.0" : UNRELEASED_VERSION;
|
|
2336
2405
|
|
|
2337
2406
|
// ../core/dist/signing.js
|
|
2338
2407
|
var encoder = new TextEncoder();
|
|
@@ -4452,4 +4521,4 @@ export {
|
|
|
4452
4521
|
tokenCredential,
|
|
4453
4522
|
PharmetikaAPI
|
|
4454
4523
|
};
|
|
4455
|
-
//# sourceMappingURL=chunk-
|
|
4524
|
+
//# sourceMappingURL=chunk-BQ7EIQNF.js.map
|