@crvouga/mockingbird-service-payload-cms 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-TR5SV7HY.js → chunk-3S4V5W6D.js} +75 -6
- package/dist/chunk-3S4V5W6D.js.map +7 -0
- package/dist/{chunk-2JAJSWIZ.js → chunk-GS3DI33O.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-TR5SV7HY.js.map +0 -7
- /package/dist/{chunk-2JAJSWIZ.js.map → chunk-GS3DI33O.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-payload-cms
|
|
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
|
|
@@ -132,7 +132,40 @@ var decodeBody = (contentType, bytes) => {
|
|
|
132
132
|
return { kind: "bytes", value: bytes };
|
|
133
133
|
};
|
|
134
134
|
var readBody = async (message) => {
|
|
135
|
-
|
|
135
|
+
if (!(message instanceof Request) || !message.body) {
|
|
136
|
+
if (message instanceof Request)
|
|
137
|
+
message.signal.throwIfAborted();
|
|
138
|
+
return decodeBody(message.headers.get("content-type"), new Uint8Array(await message.arrayBuffer()));
|
|
139
|
+
}
|
|
140
|
+
message.signal.throwIfAborted();
|
|
141
|
+
const reader = message.body.getReader();
|
|
142
|
+
const cancel = () => {
|
|
143
|
+
void reader.cancel(message.signal.reason).catch(() => {
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
message.signal.addEventListener("abort", cancel, { once: true });
|
|
147
|
+
const chunks = [];
|
|
148
|
+
let size = 0;
|
|
149
|
+
try {
|
|
150
|
+
for (; ; ) {
|
|
151
|
+
message.signal.throwIfAborted();
|
|
152
|
+
const { done, value } = await reader.read();
|
|
153
|
+
message.signal.throwIfAborted();
|
|
154
|
+
if (done)
|
|
155
|
+
break;
|
|
156
|
+
chunks.push(value);
|
|
157
|
+
size += value.byteLength;
|
|
158
|
+
}
|
|
159
|
+
} finally {
|
|
160
|
+
message.signal.removeEventListener("abort", cancel);
|
|
161
|
+
reader.releaseLock();
|
|
162
|
+
}
|
|
163
|
+
const bytes = new Uint8Array(size);
|
|
164
|
+
let offset = 0;
|
|
165
|
+
for (const chunk of chunks) {
|
|
166
|
+
bytes.set(chunk, offset);
|
|
167
|
+
offset += chunk.byteLength;
|
|
168
|
+
}
|
|
136
169
|
return decodeBody(message.headers.get("content-type"), bytes);
|
|
137
170
|
};
|
|
138
171
|
|
|
@@ -1487,7 +1520,42 @@ var verifyOperations = (document2, handlers) => {
|
|
|
1487
1520
|
}
|
|
1488
1521
|
return problems;
|
|
1489
1522
|
};
|
|
1490
|
-
var
|
|
1523
|
+
var escapePattern = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1524
|
+
var serviceRoute = (template) => {
|
|
1525
|
+
const names = [];
|
|
1526
|
+
let pattern = "", end = 0;
|
|
1527
|
+
for (const match of template.matchAll(/\{([^}]+)\}/g)) {
|
|
1528
|
+
pattern += `${escapePattern(template.slice(end, match.index))}([^/]+?)`;
|
|
1529
|
+
const name = match[1];
|
|
1530
|
+
if (!name)
|
|
1531
|
+
throw new Error(`Invalid OpenAPI route template: ${template}`);
|
|
1532
|
+
names.push(name);
|
|
1533
|
+
end = match.index + match[0].length;
|
|
1534
|
+
}
|
|
1535
|
+
pattern += escapePattern(template.slice(end));
|
|
1536
|
+
const matcher = new RegExp(`^${pattern}$`);
|
|
1537
|
+
const path = template.split("/").map((segment, index) => {
|
|
1538
|
+
if (!segment.includes("{"))
|
|
1539
|
+
return segment;
|
|
1540
|
+
const literal = /^\{([^}]+)\}$/.exec(segment);
|
|
1541
|
+
if (literal)
|
|
1542
|
+
return `:${literal[1]}`;
|
|
1543
|
+
let expression = "", offset = 0;
|
|
1544
|
+
for (const match of segment.matchAll(/\{[^}]+\}/g)) {
|
|
1545
|
+
expression += `${escapePattern(segment.slice(offset, match.index))}[^/]+?`;
|
|
1546
|
+
offset = match.index + match[0].length;
|
|
1547
|
+
}
|
|
1548
|
+
expression += escapePattern(segment.slice(offset));
|
|
1549
|
+
return `:mockingbirdSegment${index}{${expression}}`;
|
|
1550
|
+
}).join("/");
|
|
1551
|
+
return {
|
|
1552
|
+
path,
|
|
1553
|
+
params: (pathname) => {
|
|
1554
|
+
const values = matcher.exec(pathname);
|
|
1555
|
+
return Object.fromEntries(names.map((name, index) => [name, decodeURIComponent(values?.[index + 1] ?? "")]));
|
|
1556
|
+
}
|
|
1557
|
+
};
|
|
1558
|
+
};
|
|
1491
1559
|
var routeOrder = (a, b) => {
|
|
1492
1560
|
const sa = a.path.split("/");
|
|
1493
1561
|
const sb = b.path.split("/");
|
|
@@ -1522,6 +1590,7 @@ var createService = (options) => {
|
|
|
1522
1590
|
for (const operation of operations) {
|
|
1523
1591
|
const metadata = operationMetadata(operation.operation);
|
|
1524
1592
|
const handler = options.handlers[operation.operationId];
|
|
1593
|
+
const registeredRoute = serviceRoute(operation.path);
|
|
1525
1594
|
const route = async (c) => {
|
|
1526
1595
|
const request = c.req.raw;
|
|
1527
1596
|
if (!metadata.supported || !handler) {
|
|
@@ -1531,7 +1600,7 @@ var createService = (options) => {
|
|
|
1531
1600
|
const context = {
|
|
1532
1601
|
request,
|
|
1533
1602
|
url,
|
|
1534
|
-
params:
|
|
1603
|
+
params: registeredRoute.params(url.pathname),
|
|
1535
1604
|
query: queryOf(url),
|
|
1536
1605
|
body: await readBody(request),
|
|
1537
1606
|
sqlite: options.sqlite,
|
|
@@ -1543,7 +1612,7 @@ var createService = (options) => {
|
|
|
1543
1612
|
const short = await options.before?.(context);
|
|
1544
1613
|
return withIssues(request, short ?? await handler(context));
|
|
1545
1614
|
};
|
|
1546
|
-
app.on(operation.method.toUpperCase(),
|
|
1615
|
+
app.on(operation.method.toUpperCase(), registeredRoute.path, route);
|
|
1547
1616
|
}
|
|
1548
1617
|
return {
|
|
1549
1618
|
app,
|
|
@@ -2012,7 +2081,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
2012
2081
|
};
|
|
2013
2082
|
|
|
2014
2083
|
// ../core/dist/version.js
|
|
2015
|
-
var PACKAGE_VERSION = true ? "2.
|
|
2084
|
+
var PACKAGE_VERSION = true ? "2.2.0" : UNRELEASED_VERSION;
|
|
2016
2085
|
|
|
2017
2086
|
// ../core/dist/webhooks.js
|
|
2018
2087
|
var json4 = (status, body) => new Response(JSON.stringify(body), {
|
|
@@ -3302,4 +3371,4 @@ export {
|
|
|
3302
3371
|
compileWhere,
|
|
3303
3372
|
PayloadCmsAPI
|
|
3304
3373
|
};
|
|
3305
|
-
//# sourceMappingURL=chunk-
|
|
3374
|
+
//# sourceMappingURL=chunk-3S4V5W6D.js.map
|