@crvouga/mockingbird-service-google-calendar 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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog — @crvouga/mockingbird-service-google-calendar
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-AHASTBVP.js";
6
+ } from "./chunk-ULHPKJB6.js";
7
7
 
8
8
  // ../../adapters/node/dist/cli.js
9
9
  import { readFile as readFile2 } from "node:fs/promises";
@@ -848,4 +848,4 @@ export {
848
848
  createServer2 as createServer,
849
849
  serveTarget
850
850
  };
851
- //# sourceMappingURL=chunk-7YEQGVTX.js.map
851
+ //# sourceMappingURL=chunk-74NKRZ5I.js.map
@@ -1036,7 +1036,40 @@ var decodeBody = (contentType, bytes) => {
1036
1036
  return { kind: "bytes", value: bytes };
1037
1037
  };
1038
1038
  var readBody = async (message) => {
1039
- const bytes = new Uint8Array(await message.arrayBuffer());
1039
+ if (!(message instanceof Request) || !message.body) {
1040
+ if (message instanceof Request)
1041
+ message.signal.throwIfAborted();
1042
+ return decodeBody(message.headers.get("content-type"), new Uint8Array(await message.arrayBuffer()));
1043
+ }
1044
+ message.signal.throwIfAborted();
1045
+ const reader = message.body.getReader();
1046
+ const cancel = () => {
1047
+ void reader.cancel(message.signal.reason).catch(() => {
1048
+ });
1049
+ };
1050
+ message.signal.addEventListener("abort", cancel, { once: true });
1051
+ const chunks = [];
1052
+ let size = 0;
1053
+ try {
1054
+ for (; ; ) {
1055
+ message.signal.throwIfAborted();
1056
+ const { done, value } = await reader.read();
1057
+ message.signal.throwIfAborted();
1058
+ if (done)
1059
+ break;
1060
+ chunks.push(value);
1061
+ size += value.byteLength;
1062
+ }
1063
+ } finally {
1064
+ message.signal.removeEventListener("abort", cancel);
1065
+ reader.releaseLock();
1066
+ }
1067
+ const bytes = new Uint8Array(size);
1068
+ let offset = 0;
1069
+ for (const chunk of chunks) {
1070
+ bytes.set(chunk, offset);
1071
+ offset += chunk.byteLength;
1072
+ }
1040
1073
  return decodeBody(message.headers.get("content-type"), bytes);
1041
1074
  };
1042
1075
 
@@ -1774,7 +1807,42 @@ var verifyOperations = (document2, handlers) => {
1774
1807
  }
1775
1808
  return problems;
1776
1809
  };
1777
- var honoPath = (template) => template.replace(/\{([^}]+)\}/g, ":$1");
1810
+ var escapePattern = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1811
+ var serviceRoute = (template) => {
1812
+ const names = [];
1813
+ let pattern = "", end = 0;
1814
+ for (const match of template.matchAll(/\{([^}]+)\}/g)) {
1815
+ pattern += `${escapePattern(template.slice(end, match.index))}([^/]+?)`;
1816
+ const name = match[1];
1817
+ if (!name)
1818
+ throw new Error(`Invalid OpenAPI route template: ${template}`);
1819
+ names.push(name);
1820
+ end = match.index + match[0].length;
1821
+ }
1822
+ pattern += escapePattern(template.slice(end));
1823
+ const matcher = new RegExp(`^${pattern}$`);
1824
+ const path = template.split("/").map((segment, index) => {
1825
+ if (!segment.includes("{"))
1826
+ return segment;
1827
+ const literal = /^\{([^}]+)\}$/.exec(segment);
1828
+ if (literal)
1829
+ return `:${literal[1]}`;
1830
+ let expression = "", offset = 0;
1831
+ for (const match of segment.matchAll(/\{[^}]+\}/g)) {
1832
+ expression += `${escapePattern(segment.slice(offset, match.index))}[^/]+?`;
1833
+ offset = match.index + match[0].length;
1834
+ }
1835
+ expression += escapePattern(segment.slice(offset));
1836
+ return `:mockingbirdSegment${index}{${expression}}`;
1837
+ }).join("/");
1838
+ return {
1839
+ path,
1840
+ params: (pathname) => {
1841
+ const values = matcher.exec(pathname);
1842
+ return Object.fromEntries(names.map((name, index) => [name, decodeURIComponent(values?.[index + 1] ?? "")]));
1843
+ }
1844
+ };
1845
+ };
1778
1846
  var routeOrder = (a, b) => {
1779
1847
  const sa = a.path.split("/");
1780
1848
  const sb = b.path.split("/");
@@ -1809,6 +1877,7 @@ var createService = (options) => {
1809
1877
  for (const operation of operations) {
1810
1878
  const metadata = operationMetadata(operation.operation);
1811
1879
  const handler = options.handlers[operation.operationId];
1880
+ const registeredRoute = serviceRoute(operation.path);
1812
1881
  const route = async (c) => {
1813
1882
  const request = c.req.raw;
1814
1883
  if (!metadata.supported || !handler) {
@@ -1818,7 +1887,7 @@ var createService = (options) => {
1818
1887
  const context = {
1819
1888
  request,
1820
1889
  url,
1821
- params: c.req.param(),
1890
+ params: registeredRoute.params(url.pathname),
1822
1891
  query: queryOf(url),
1823
1892
  body: await readBody(request),
1824
1893
  sqlite: options.sqlite,
@@ -1830,7 +1899,7 @@ var createService = (options) => {
1830
1899
  const short = await options.before?.(context);
1831
1900
  return withIssues(request, short ?? await handler(context));
1832
1901
  };
1833
- app.on(operation.method.toUpperCase(), honoPath(operation.path), route);
1902
+ app.on(operation.method.toUpperCase(), registeredRoute.path, route);
1834
1903
  }
1835
1904
  return {
1836
1905
  app,
@@ -2299,7 +2368,7 @@ var stateAdminRoutes = (routes) => {
2299
2368
  };
2300
2369
 
2301
2370
  // ../core/dist/version.js
2302
- var PACKAGE_VERSION = true ? "2.1.0" : UNRELEASED_VERSION;
2371
+ var PACKAGE_VERSION = true ? "2.2.0" : UNRELEASED_VERSION;
2303
2372
 
2304
2373
  // ../core/dist/signing.js
2305
2374
  var encoder = new TextEncoder();
@@ -4545,4 +4614,4 @@ export {
4545
4614
  emailFromCode,
4546
4615
  GoogleCalendarAPI
4547
4616
  };
4548
- //# sourceMappingURL=chunk-AHASTBVP.js.map
4617
+ //# sourceMappingURL=chunk-ULHPKJB6.js.map