@crvouga/mockingbird-service-rxvortex 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-O5I472TG.js → chunk-234XQ6Z2.js} +75 -6
- package/dist/chunk-234XQ6Z2.js.map +7 -0
- package/dist/{chunk-7CSIHJ45.js → chunk-L4NOLXGM.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-O5I472TG.js.map +0 -7
- /package/dist/{chunk-7CSIHJ45.js.map → chunk-L4NOLXGM.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-rxvortex
|
|
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
|
|
@@ -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
|
|
|
@@ -1766,7 +1799,42 @@ var verifyOperations = (document2, handlers) => {
|
|
|
1766
1799
|
}
|
|
1767
1800
|
return problems;
|
|
1768
1801
|
};
|
|
1769
|
-
var
|
|
1802
|
+
var escapePattern = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1803
|
+
var serviceRoute = (template) => {
|
|
1804
|
+
const names = [];
|
|
1805
|
+
let pattern = "", end = 0;
|
|
1806
|
+
for (const match of template.matchAll(/\{([^}]+)\}/g)) {
|
|
1807
|
+
pattern += `${escapePattern(template.slice(end, match.index))}([^/]+?)`;
|
|
1808
|
+
const name = match[1];
|
|
1809
|
+
if (!name)
|
|
1810
|
+
throw new Error(`Invalid OpenAPI route template: ${template}`);
|
|
1811
|
+
names.push(name);
|
|
1812
|
+
end = match.index + match[0].length;
|
|
1813
|
+
}
|
|
1814
|
+
pattern += escapePattern(template.slice(end));
|
|
1815
|
+
const matcher = new RegExp(`^${pattern}$`);
|
|
1816
|
+
const path = template.split("/").map((segment, index) => {
|
|
1817
|
+
if (!segment.includes("{"))
|
|
1818
|
+
return segment;
|
|
1819
|
+
const literal = /^\{([^}]+)\}$/.exec(segment);
|
|
1820
|
+
if (literal)
|
|
1821
|
+
return `:${literal[1]}`;
|
|
1822
|
+
let expression = "", offset = 0;
|
|
1823
|
+
for (const match of segment.matchAll(/\{[^}]+\}/g)) {
|
|
1824
|
+
expression += `${escapePattern(segment.slice(offset, match.index))}[^/]+?`;
|
|
1825
|
+
offset = match.index + match[0].length;
|
|
1826
|
+
}
|
|
1827
|
+
expression += escapePattern(segment.slice(offset));
|
|
1828
|
+
return `:mockingbirdSegment${index}{${expression}}`;
|
|
1829
|
+
}).join("/");
|
|
1830
|
+
return {
|
|
1831
|
+
path,
|
|
1832
|
+
params: (pathname) => {
|
|
1833
|
+
const values = matcher.exec(pathname);
|
|
1834
|
+
return Object.fromEntries(names.map((name, index) => [name, decodeURIComponent(values?.[index + 1] ?? "")]));
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
};
|
|
1770
1838
|
var routeOrder = (a, b) => {
|
|
1771
1839
|
const sa = a.path.split("/");
|
|
1772
1840
|
const sb = b.path.split("/");
|
|
@@ -1801,6 +1869,7 @@ var createService = (options) => {
|
|
|
1801
1869
|
for (const operation of operations) {
|
|
1802
1870
|
const metadata = operationMetadata(operation.operation);
|
|
1803
1871
|
const handler = options.handlers[operation.operationId];
|
|
1872
|
+
const registeredRoute = serviceRoute(operation.path);
|
|
1804
1873
|
const route = async (c) => {
|
|
1805
1874
|
const request = c.req.raw;
|
|
1806
1875
|
if (!metadata.supported || !handler) {
|
|
@@ -1810,7 +1879,7 @@ var createService = (options) => {
|
|
|
1810
1879
|
const context = {
|
|
1811
1880
|
request,
|
|
1812
1881
|
url,
|
|
1813
|
-
params:
|
|
1882
|
+
params: registeredRoute.params(url.pathname),
|
|
1814
1883
|
query: queryOf(url),
|
|
1815
1884
|
body: await readBody(request),
|
|
1816
1885
|
sqlite: options.sqlite,
|
|
@@ -1822,7 +1891,7 @@ var createService = (options) => {
|
|
|
1822
1891
|
const short = await options.before?.(context);
|
|
1823
1892
|
return withIssues(request, short ?? await handler(context));
|
|
1824
1893
|
};
|
|
1825
|
-
app.on(operation.method.toUpperCase(),
|
|
1894
|
+
app.on(operation.method.toUpperCase(), registeredRoute.path, route);
|
|
1826
1895
|
}
|
|
1827
1896
|
return {
|
|
1828
1897
|
app,
|
|
@@ -2291,7 +2360,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
2291
2360
|
};
|
|
2292
2361
|
|
|
2293
2362
|
// ../core/dist/version.js
|
|
2294
|
-
var PACKAGE_VERSION = true ? "2.
|
|
2363
|
+
var PACKAGE_VERSION = true ? "2.2.0" : UNRELEASED_VERSION;
|
|
2295
2364
|
|
|
2296
2365
|
// ../core/dist/signing.js
|
|
2297
2366
|
var encoder = new TextEncoder();
|
|
@@ -4275,4 +4344,4 @@ export {
|
|
|
4275
4344
|
tokenCredential,
|
|
4276
4345
|
RxVortexAPI
|
|
4277
4346
|
};
|
|
4278
|
-
//# sourceMappingURL=chunk-
|
|
4347
|
+
//# sourceMappingURL=chunk-234XQ6Z2.js.map
|