@crvouga/mockingbird-service-formbricks 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-KIJQHMEA.js → chunk-OFA5MXAJ.js} +75 -6
- package/dist/chunk-OFA5MXAJ.js.map +7 -0
- package/dist/{chunk-VBJ5ARFE.js → chunk-XS5QMW2C.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-KIJQHMEA.js.map +0 -7
- /package/dist/{chunk-VBJ5ARFE.js.map → chunk-XS5QMW2C.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-formbricks
|
|
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
|
|
@@ -820,7 +820,40 @@ var decodeBody = (contentType, bytes) => {
|
|
|
820
820
|
return { kind: "bytes", value: bytes };
|
|
821
821
|
};
|
|
822
822
|
var readBody = async (message) => {
|
|
823
|
-
|
|
823
|
+
if (!(message instanceof Request) || !message.body) {
|
|
824
|
+
if (message instanceof Request)
|
|
825
|
+
message.signal.throwIfAborted();
|
|
826
|
+
return decodeBody(message.headers.get("content-type"), new Uint8Array(await message.arrayBuffer()));
|
|
827
|
+
}
|
|
828
|
+
message.signal.throwIfAborted();
|
|
829
|
+
const reader = message.body.getReader();
|
|
830
|
+
const cancel = () => {
|
|
831
|
+
void reader.cancel(message.signal.reason).catch(() => {
|
|
832
|
+
});
|
|
833
|
+
};
|
|
834
|
+
message.signal.addEventListener("abort", cancel, { once: true });
|
|
835
|
+
const chunks = [];
|
|
836
|
+
let size = 0;
|
|
837
|
+
try {
|
|
838
|
+
for (; ; ) {
|
|
839
|
+
message.signal.throwIfAborted();
|
|
840
|
+
const { done, value } = await reader.read();
|
|
841
|
+
message.signal.throwIfAborted();
|
|
842
|
+
if (done)
|
|
843
|
+
break;
|
|
844
|
+
chunks.push(value);
|
|
845
|
+
size += value.byteLength;
|
|
846
|
+
}
|
|
847
|
+
} finally {
|
|
848
|
+
message.signal.removeEventListener("abort", cancel);
|
|
849
|
+
reader.releaseLock();
|
|
850
|
+
}
|
|
851
|
+
const bytes = new Uint8Array(size);
|
|
852
|
+
let offset = 0;
|
|
853
|
+
for (const chunk of chunks) {
|
|
854
|
+
bytes.set(chunk, offset);
|
|
855
|
+
offset += chunk.byteLength;
|
|
856
|
+
}
|
|
824
857
|
return decodeBody(message.headers.get("content-type"), bytes);
|
|
825
858
|
};
|
|
826
859
|
|
|
@@ -1484,7 +1517,42 @@ var verifyOperations = (document2, handlers) => {
|
|
|
1484
1517
|
}
|
|
1485
1518
|
return problems;
|
|
1486
1519
|
};
|
|
1487
|
-
var
|
|
1520
|
+
var escapePattern = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1521
|
+
var serviceRoute = (template) => {
|
|
1522
|
+
const names = [];
|
|
1523
|
+
let pattern = "", end = 0;
|
|
1524
|
+
for (const match of template.matchAll(/\{([^}]+)\}/g)) {
|
|
1525
|
+
pattern += `${escapePattern(template.slice(end, match.index))}([^/]+?)`;
|
|
1526
|
+
const name = match[1];
|
|
1527
|
+
if (!name)
|
|
1528
|
+
throw new Error(`Invalid OpenAPI route template: ${template}`);
|
|
1529
|
+
names.push(name);
|
|
1530
|
+
end = match.index + match[0].length;
|
|
1531
|
+
}
|
|
1532
|
+
pattern += escapePattern(template.slice(end));
|
|
1533
|
+
const matcher = new RegExp(`^${pattern}$`);
|
|
1534
|
+
const path = template.split("/").map((segment, index) => {
|
|
1535
|
+
if (!segment.includes("{"))
|
|
1536
|
+
return segment;
|
|
1537
|
+
const literal = /^\{([^}]+)\}$/.exec(segment);
|
|
1538
|
+
if (literal)
|
|
1539
|
+
return `:${literal[1]}`;
|
|
1540
|
+
let expression = "", offset = 0;
|
|
1541
|
+
for (const match of segment.matchAll(/\{[^}]+\}/g)) {
|
|
1542
|
+
expression += `${escapePattern(segment.slice(offset, match.index))}[^/]+?`;
|
|
1543
|
+
offset = match.index + match[0].length;
|
|
1544
|
+
}
|
|
1545
|
+
expression += escapePattern(segment.slice(offset));
|
|
1546
|
+
return `:mockingbirdSegment${index}{${expression}}`;
|
|
1547
|
+
}).join("/");
|
|
1548
|
+
return {
|
|
1549
|
+
path,
|
|
1550
|
+
params: (pathname) => {
|
|
1551
|
+
const values = matcher.exec(pathname);
|
|
1552
|
+
return Object.fromEntries(names.map((name, index) => [name, decodeURIComponent(values?.[index + 1] ?? "")]));
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
};
|
|
1488
1556
|
var routeOrder = (a, b) => {
|
|
1489
1557
|
const sa = a.path.split("/");
|
|
1490
1558
|
const sb = b.path.split("/");
|
|
@@ -1519,6 +1587,7 @@ var createService = (options) => {
|
|
|
1519
1587
|
for (const operation of operations) {
|
|
1520
1588
|
const metadata = operationMetadata(operation.operation);
|
|
1521
1589
|
const handler = options.handlers[operation.operationId];
|
|
1590
|
+
const registeredRoute = serviceRoute(operation.path);
|
|
1522
1591
|
const route = async (c) => {
|
|
1523
1592
|
const request = c.req.raw;
|
|
1524
1593
|
if (!metadata.supported || !handler) {
|
|
@@ -1528,7 +1597,7 @@ var createService = (options) => {
|
|
|
1528
1597
|
const context = {
|
|
1529
1598
|
request,
|
|
1530
1599
|
url,
|
|
1531
|
-
params:
|
|
1600
|
+
params: registeredRoute.params(url.pathname),
|
|
1532
1601
|
query: queryOf(url),
|
|
1533
1602
|
body: await readBody(request),
|
|
1534
1603
|
sqlite: options.sqlite,
|
|
@@ -1540,7 +1609,7 @@ var createService = (options) => {
|
|
|
1540
1609
|
const short = await options.before?.(context);
|
|
1541
1610
|
return withIssues(request, short ?? await handler(context));
|
|
1542
1611
|
};
|
|
1543
|
-
app.on(operation.method.toUpperCase(),
|
|
1612
|
+
app.on(operation.method.toUpperCase(), registeredRoute.path, route);
|
|
1544
1613
|
}
|
|
1545
1614
|
return {
|
|
1546
1615
|
app,
|
|
@@ -2009,7 +2078,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
2009
2078
|
};
|
|
2010
2079
|
|
|
2011
2080
|
// ../core/dist/version.js
|
|
2012
|
-
var PACKAGE_VERSION = true ? "2.
|
|
2081
|
+
var PACKAGE_VERSION = true ? "2.2.0" : UNRELEASED_VERSION;
|
|
2013
2082
|
|
|
2014
2083
|
// ../core/dist/signing.js
|
|
2015
2084
|
var encoder = new TextEncoder();
|
|
@@ -4946,4 +5015,4 @@ export {
|
|
|
4946
5015
|
formbricksError,
|
|
4947
5016
|
FormbricksAPI
|
|
4948
5017
|
};
|
|
4949
|
-
//# sourceMappingURL=chunk-
|
|
5018
|
+
//# sourceMappingURL=chunk-OFA5MXAJ.js.map
|