@continuous-excellence/ze-great-dashboard-aws 0.31.53 → 0.31.54

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.
Files changed (2) hide show
  1. package/dist/lambda.mjs +111 -77
  2. package/package.json +1 -1
package/dist/lambda.mjs CHANGED
@@ -74241,6 +74241,15 @@ var getPathNoStrict = (request) => {
74241
74241
  const result = getPath(request);
74242
74242
  return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
74243
74243
  };
74244
+ var stripPathPrefix = (rawPath, decodedPath, prefixLength) => {
74245
+ if (rawPath.at(-1) === "/" && decodedPath.at(-1) !== "/") rawPath = rawPath.slice(0, -1);
74246
+ let index = 0;
74247
+ for (let i6 = decodedPath.indexOf("/"); i6 !== -1 && i6 < prefixLength; i6 = decodedPath.indexOf("/", i6 + 1)) {
74248
+ index = rawPath.indexOf("/", index + 1);
74249
+ if (index === -1) return "/";
74250
+ }
74251
+ return rawPath.slice(index) || "/";
74252
+ };
74244
74253
  var mergePath = (base, sub, ...rest) => {
74245
74254
  if (rest.length) sub = mergePath(sub, ...rest);
74246
74255
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
@@ -74821,7 +74830,7 @@ var Context = class {
74821
74830
  * ```
74822
74831
  */
74823
74832
  header = (name, value, options) => {
74824
- if (this.finalized) this.#res = createResponseInstance(this.#res.body, this.#res);
74833
+ if (this.finalized && !this.#res.bodyUsed) this.#res = createResponseInstance(this.#res.body, this.#res);
74825
74834
  const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers();
74826
74835
  if (value === void 0) headers.delete(name);
74827
74836
  else if (options?.append) headers.append(name, value);
@@ -75050,6 +75059,37 @@ var UnsupportedPathError = class extends Error {
75050
75059
  // node_modules/hono/dist/utils/constants.js
75051
75060
  var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
75052
75061
 
75062
+ // node_modules/hono/dist/utils/mount.js
75063
+ var getPathPrefixLength = (c5, pathPrefix, routePath) => {
75064
+ if (!/[:*]/.test(pathPrefix)) return pathPrefix.length;
75065
+ const path = c5.req.path;
75066
+ const matchResult = c5.req[GET_MATCH_RESULT];
75067
+ const paramNames = /* @__PURE__ */ new Set();
75068
+ let length = 0;
75069
+ for (const part of splitRoutingPath(pathPrefix)) {
75070
+ const pattern = getPattern(part);
75071
+ if (pattern && pattern !== "*") {
75072
+ const name = pattern[1];
75073
+ if (paramNames.has(name)) throw new Error(`mount(): Duplicate path parameter "${name}" in "${routePath}".`);
75074
+ paramNames.add(name);
75075
+ }
75076
+ if (pattern && pattern !== "*" && pattern[2] !== true) {
75077
+ const value = matchResult.length === 2 ? matchResult[1][matchResult[0][c5.req.routeIndex][1][pattern[1]]] : matchResult[0][c5.req.routeIndex][1][pattern[1]];
75078
+ length += value.length + 1;
75079
+ } else if (pattern || part.endsWith("*")) {
75080
+ const end2 = path.indexOf("/", length + 1);
75081
+ length = end2 === -1 ? path.length : end2;
75082
+ } else length += part.length + 1;
75083
+ }
75084
+ return length;
75085
+ };
75086
+ var createMountedRequest = (c5, pathPrefix, routePath) => {
75087
+ if (/[^/]\*$/.test(routePath)) throw new Error(`mount(): Wildcard must follow "/" in "${routePath}".`);
75088
+ const url2 = new URL(c5.req.raw.url);
75089
+ url2.pathname = stripPathPrefix(url2.pathname, c5.req.path, getPathPrefixLength(c5, pathPrefix, routePath));
75090
+ return new Request(url2, c5.req.raw);
75091
+ };
75092
+
75053
75093
  // node_modules/hono/dist/hono-base.js
75054
75094
  var notFoundHandler = (c5) => {
75055
75095
  return c5.text("404 Not Found", 404);
@@ -75271,17 +75311,10 @@ var Hono = class Hono2 {
75271
75311
  }
75272
75312
  return [c5.env, executionContext];
75273
75313
  };
75274
- replaceRequest ||= (() => {
75275
- const mergedPath = mergePath(this._basePath, path);
75276
- const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
75277
- return (request) => {
75278
- const url2 = new URL(request.url);
75279
- url2.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
75280
- return new Request(url2, request);
75281
- };
75282
- })();
75314
+ const mergedPath = mergePath(this._basePath, path);
75315
+ const defaultReplaceRequest = (c5) => createMountedRequest(c5, mergedPath.replace(/\/$/, ""), mergePath(mergedPath, "*"));
75283
75316
  const handler2 = async (c5, next) => {
75284
- const res = await applicationHandler(replaceRequest(c5.req.raw), ...getOptions(c5));
75317
+ const res = await applicationHandler(replaceRequest ? replaceRequest(c5.req.raw) : defaultReplaceRequest(c5), ...getOptions(c5));
75285
75318
  if (res) return res;
75286
75319
  await next();
75287
75320
  };
@@ -75413,14 +75446,15 @@ function match(method, path) {
75413
75446
 
75414
75447
  // node_modules/hono/dist/router/reg-exp-router/node.js
75415
75448
  var LABEL_REG_EXP_STR = "[^/]+";
75416
- var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
75449
+ var ONLY_WILDCARD_REG_EXP_STR = "[^]*";
75450
+ var TAIL_WILDCARD_REG_EXP_STR = "(?:|/[^]*)";
75417
75451
  var PATH_ERROR = /* @__PURE__ */ Symbol();
75418
75452
  var regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
75419
75453
  function compareKey(a5, b5) {
75420
75454
  if (a5.length === 1) return b5.length === 1 ? a5 < b5 ? -1 : 1 : -1;
75421
75455
  if (b5.length === 1) return 1;
75422
- if (a5 === ".*" || a5 === "(?:|/.*)") return b5 === "(?:|/.*)" ? -1 : 1;
75423
- else if (b5 === ".*" || b5 === "(?:|/.*)") return -1;
75456
+ if (a5 === "[^]*" || a5 === "(?:|/[^]*)") return b5 === "[^]*" ? -1 : 1;
75457
+ else if (b5 === "[^]*" || b5 === "(?:|/[^]*)") return -1;
75424
75458
  if (a5 === "[^/]+") return 1;
75425
75459
  else if (b5 === "[^/]+") return -1;
75426
75460
  return a5.length === b5.length ? a5 < b5 ? -1 : 1 : b5.length - a5.length;
@@ -75429,14 +75463,14 @@ var Node = class Node2 {
75429
75463
  #index;
75430
75464
  #varIndex;
75431
75465
  #children = createNullObject();
75432
- insert(tokens, index, paramMap, context, isStatic) {
75466
+ insert(tokens, index, paramMap, context, keys) {
75433
75467
  let node2 = this;
75434
75468
  for (let i6 = 0, len = tokens.length; i6 < len; i6++) {
75435
75469
  const token = tokens[i6];
75436
75470
  const pattern = token.length === 1 ? token === "*" ? i6 === len - 1 ? [
75437
75471
  "",
75438
75472
  "",
75439
- ".*"
75473
+ ONLY_WILDCARD_REG_EXP_STR
75440
75474
  ] : [
75441
75475
  "",
75442
75476
  "",
@@ -75451,15 +75485,16 @@ var Node = class Node2 {
75451
75485
  const name = pattern[1];
75452
75486
  let regexpStr = pattern[2] || "[^/]+";
75453
75487
  if (name && pattern[2]) {
75454
- if (regexpStr === ".*") throw PATH_ERROR;
75488
+ if (new RegExp(regexpStr).test("")) throw PATH_ERROR;
75455
75489
  regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
75456
75490
  if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
75457
75491
  if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) throw PATH_ERROR;
75458
75492
  }
75493
+ keys.push(regexpStr);
75459
75494
  nextNode = node2.#children[regexpStr];
75460
75495
  if (!nextNode) {
75461
- if (regexpStr !== ".*" && regexpStr !== "(?:|/.*)") {
75462
- for (const k5 in node2.#children) if ((regexpStr.length > 1 || k5.length > 1) && k5 !== ".*" && k5 !== "(?:|/.*)") throw PATH_ERROR;
75496
+ if (regexpStr !== "[^]*" && regexpStr !== "(?:|/[^]*)") {
75497
+ for (const k5 in node2.#children) if ((regexpStr.length > 1 || k5.length > 1) && k5 !== "[^]*" && k5 !== "(?:|/[^]*)") throw PATH_ERROR;
75463
75498
  }
75464
75499
  nextNode = node2.#children[regexpStr] = new Node2();
75465
75500
  }
@@ -75468,16 +75503,17 @@ var Node = class Node2 {
75468
75503
  paramMap.push([name, nextNode.#varIndex]);
75469
75504
  }
75470
75505
  } else {
75506
+ keys.push(token);
75471
75507
  nextNode = node2.#children[token];
75472
75508
  if (!nextNode) {
75473
- for (const k5 in node2.#children) if (k5.length > 1 && k5 !== ".*" && k5 !== "(?:|/.*)") throw PATH_ERROR;
75509
+ for (const k5 in node2.#children) if (k5.length > 1 && k5 !== "[^]*" && k5 !== "(?:|/[^]*)") throw PATH_ERROR;
75474
75510
  nextNode = node2.#children[token] = new Node2();
75475
75511
  }
75476
75512
  }
75477
75513
  node2 = nextNode;
75478
75514
  }
75479
75515
  if (node2.#index !== void 0) throw PATH_ERROR;
75480
- node2.#index = isStatic ? -1 : index;
75516
+ node2.#index = index;
75481
75517
  }
75482
75518
  buildRegExpStr() {
75483
75519
  const strList = Object.keys(this.#children).sort(compareKey).map((k5) => {
@@ -75499,8 +75535,14 @@ var Trie = class {
75499
75535
  #index = 0;
75500
75536
  paths = createNullObject();
75501
75537
  insert(path, isStatic) {
75538
+ const keys = [];
75502
75539
  if (isStatic) {
75503
- this.#root.insert(path.split(""), 0, [], this.#context, true);
75540
+ this.#root.insert(path.split(""), -1, [], this.#context, keys);
75541
+ this.paths[path] = [
75542
+ -1,
75543
+ [],
75544
+ keys
75545
+ ];
75504
75546
  return;
75505
75547
  }
75506
75548
  const paramAssoc = [];
@@ -75508,7 +75550,7 @@ var Trie = class {
75508
75550
  let markedPath = path;
75509
75551
  for (let i6 = 0; ; ) {
75510
75552
  let replaced = false;
75511
- markedPath = markedPath.replace(/\{[^}]+\}/g, (m3) => {
75553
+ markedPath = markedPath.replace(/\{(?:\{[\d,]+\}|[^}])+\}/g, (m3) => {
75512
75554
  const mark = `@\\${i6}`;
75513
75555
  groups[i6] = [mark, m3];
75514
75556
  i6++;
@@ -75517,7 +75559,7 @@ var Trie = class {
75517
75559
  });
75518
75560
  if (!replaced) break;
75519
75561
  }
75520
- const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
75562
+ const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./gs) || [];
75521
75563
  for (let i6 = groups.length - 1; i6 >= 0; i6--) {
75522
75564
  const [mark] = groups[i6];
75523
75565
  for (let j5 = tokens.length - 1; j5 >= 0; j5--) if (tokens[j5].indexOf(mark) !== -1) {
@@ -75525,8 +75567,12 @@ var Trie = class {
75525
75567
  break;
75526
75568
  }
75527
75569
  }
75528
- this.#root.insert(tokens, this.#index, paramAssoc, this.#context, false);
75529
- this.paths[path] = [this.#index++, paramAssoc];
75570
+ this.#root.insert(tokens, this.#index, paramAssoc, this.#context, keys);
75571
+ this.paths[path] = [
75572
+ this.#index++,
75573
+ paramAssoc,
75574
+ keys
75575
+ ];
75530
75576
  }
75531
75577
  buildRegExp() {
75532
75578
  let regexp = this.#root.buildRegExpStr();
@@ -75558,21 +75604,21 @@ var Trie = class {
75558
75604
  };
75559
75605
 
75560
75606
  // node_modules/hono/dist/router/reg-exp-router/router.js
75561
- var wildcardRegExpCache = createNullObject();
75562
- function buildWildcardRegExp(path) {
75563
- return wildcardRegExpCache[path] ??= new RegExp(`^${path.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (match2, metaChar) => metaChar ? `\\${metaChar}` : match2 === "/*" ? TAIL_WILDCARD_REG_EXP_STR : match2 === "*" ? ".*" : `/:${LABEL_REG_EXP_STR}`)}$`);
75607
+ function endsWithWildcard(keys) {
75608
+ const tail = keys[keys.length - 1];
75609
+ return tail === "[^]*" || tail === "(?:|/[^]*)";
75564
75610
  }
75565
- function findMiddleware(middleware, path) {
75566
- for (const k5 of Object.keys(middleware).sort((a5, b5) => b5.length - a5.length)) if (buildWildcardRegExp(k5).test(path)) return [...middleware[k5]];
75611
+ function covers(wildcard, target) {
75612
+ const last = wildcard.length - 1;
75613
+ for (let i6 = 0; i6 < last; i6++) if (wildcard[i6] !== target[i6]) return false;
75614
+ return wildcard[last] === "[^]*" || target.length === last || target[last] === "/";
75567
75615
  }
75568
75616
  var RegExpRouter = class {
75569
75617
  name = "RegExpRouter";
75570
- #middleware;
75571
- #routes;
75618
+ #handlers;
75572
75619
  #tries;
75573
75620
  constructor() {
75574
- this.#middleware = { ["ALL"]: createNullObject() };
75575
- this.#routes = { ["ALL"]: createNullObject() };
75621
+ this.#handlers = { ["ALL"]: [] };
75576
75622
  this.#tries = { ["ALL"]: new Trie() };
75577
75623
  }
75578
75624
  #insertPath(method, path) {
@@ -75583,65 +75629,53 @@ var RegExpRouter = class {
75583
75629
  }
75584
75630
  }
75585
75631
  add(method, path, handler2) {
75586
- const middleware = this.#middleware;
75587
- const routes = this.#routes;
75588
- if (!middleware) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
75589
- if (!middleware[method]) {
75590
- this.#tries[method] = new Trie();
75591
- for (const handlerMap of [middleware, routes]) {
75592
- handlerMap[method] = createNullObject();
75593
- for (const p3 in handlerMap["ALL"]) {
75594
- handlerMap[method][p3] = [...handlerMap["ALL"][p3]];
75595
- this.#insertPath(method, p3);
75596
- }
75597
- }
75632
+ const handlers = this.#handlers;
75633
+ if (!handlers) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
75634
+ const tries = this.#tries;
75635
+ if (!handlers[method]) {
75636
+ tries[method] = new Trie();
75637
+ handlers[method] = [...handlers["ALL"]];
75638
+ for (const p3 in tries["ALL"].paths) this.#insertPath(method, p3);
75598
75639
  }
75599
75640
  if (path === "/*") path = "*";
75600
- const methods = method === "ALL" ? Object.keys(middleware) : [method];
75601
- if (/\*$/.test(path)) {
75602
- const re = buildWildcardRegExp(path);
75603
- for (const m3 of methods) if (!middleware[m3][path]) {
75604
- this.#insertPath(m3, path);
75605
- middleware[m3][path] = findMiddleware(middleware[m3], path) || findMiddleware(middleware["ALL"], path) || [];
75606
- }
75607
- for (const handlerMap of [middleware, routes]) for (const m3 of methods) for (const p3 in handlerMap[m3]) re.test(p3) && handlerMap[m3][p3].push([handler2, path]);
75608
- return;
75609
- }
75641
+ const methods = method === "ALL" ? Object.keys(handlers) : [method];
75610
75642
  const paths = checkOptionalParameter(path) || [path];
75611
75643
  for (const path2 of paths) for (const m3 of methods) {
75612
- if (!routes[m3][path2]) {
75613
- this.#insertPath(m3, path2);
75614
- routes[m3][path2] = findMiddleware(middleware[m3], path2) || findMiddleware(middleware["ALL"], path2) || [];
75615
- }
75616
- routes[m3][path2].push([handler2, path2]);
75644
+ if (!tries[m3].paths[path2]) this.#insertPath(m3, path2);
75645
+ handlers[m3].push([handler2, path2]);
75617
75646
  }
75618
75647
  }
75619
75648
  match = match;
75620
75649
  buildAllMatchers() {
75621
75650
  const matchers = createNullObject();
75622
- for (const method of Object.keys(this.#routes)) matchers[method] = this.#buildMatcher(method);
75623
- this.#middleware = this.#routes = this.#tries = void 0;
75624
- wildcardRegExpCache = createNullObject();
75651
+ for (const method of Object.keys(this.#handlers)) matchers[method] = this.#buildMatcher(method);
75652
+ this.#handlers = this.#tries = void 0;
75625
75653
  return matchers;
75626
75654
  }
75627
75655
  #buildMatcher(method) {
75628
- const middleware = this.#middleware[method];
75629
- const routes = this.#routes[method];
75656
+ const handlers = this.#handlers[method];
75630
75657
  const trie = this.#tries[method];
75631
75658
  const staticMap = createNullObject();
75632
75659
  const handlerData = [];
75633
75660
  const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
75634
- for (const r5 of [middleware, routes]) for (const path in r5) {
75635
- const handlers = r5[path];
75636
- const pathData = trie.paths[path];
75637
- if (!pathData) {
75638
- staticMap[path] = [handlers.map(([h5]) => [h5, createNullObject()]), emptyParam];
75639
- continue;
75640
- }
75641
- handlerData[pathData[0]] = handlers.map(([h5, handlerPath]) => [h5, trie.paths[handlerPath][1].reduceRight((map4, [key], i6) => {
75642
- map4[key] = paramReplacementMap[pathData[1][i6][1]];
75661
+ const own2 = createNullObject();
75662
+ const entries = handlers.map(([h5, p3], i6) => {
75663
+ (own2[p3] ??= []).push(i6);
75664
+ return [h5, trie.paths[p3][1].reduceRight((map4, [key, varIndex]) => {
75665
+ map4[key] = paramReplacementMap[varIndex];
75643
75666
  return map4;
75644
- }, createNullObject())]);
75667
+ }, createNullObject())];
75668
+ });
75669
+ const wildcards = Object.keys(own2).filter((p3) => endsWithWildcard(trie.paths[p3][2]));
75670
+ for (const path in trie.paths) {
75671
+ const [index, , keys] = trie.paths[path];
75672
+ const indexes = [...own2[path]];
75673
+ for (const p3 of wildcards) if (p3 !== path && covers(trie.paths[p3][2], keys)) indexes.push(...own2[p3]);
75674
+ const data = indexes.sort((a5, b5) => a5 - b5).map((i6) => entries[i6]);
75675
+ if (index === -1) {
75676
+ const last = Math.max(-1, ...data.flatMap(([, map4]) => Object.values(map4)));
75677
+ staticMap[path] = [data, last === -1 ? emptyParam : path.match(regexp).slice(0, last + 1)];
75678
+ } else handlerData[index] = data;
75645
75679
  }
75646
75680
  return [
75647
75681
  regexp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@continuous-excellence/ze-great-dashboard-aws",
3
- "version": "0.31.53",
3
+ "version": "0.31.54",
4
4
  "type": "module",
5
5
  "description": "AWS server runtime and CloudFormation deployment tooling for Ze Great Dashboard.",
6
6
  "keywords": [