@zuplo/cli 6.70.28 → 6.70.29

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 (30) hide show
  1. package/node_modules/@zuplo/core/package.json +1 -1
  2. package/node_modules/@zuplo/graphql/package.json +1 -1
  3. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  4. package/node_modules/@zuplo/otel/package.json +1 -1
  5. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  6. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
  7. package/node_modules/@zuplo/runtime/package.json +1 -1
  8. package/node_modules/hono/dist/adapter/bun/serve-static.js +1 -1
  9. package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static.js +1 -1
  10. package/node_modules/hono/dist/adapter/deno/serve-static.js +1 -1
  11. package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
  12. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static.js +1 -1
  13. package/node_modules/hono/dist/cjs/adapter/deno/serve-static.js +1 -1
  14. package/node_modules/hono/dist/cjs/middleware/cache/index.js +30 -25
  15. package/node_modules/hono/dist/cjs/request.js +15 -0
  16. package/node_modules/hono/dist/cjs/utils/cookie.js +3 -3
  17. package/node_modules/hono/dist/cjs/utils/stream.js +4 -2
  18. package/node_modules/hono/dist/middleware/cache/index.js +30 -25
  19. package/node_modules/hono/dist/request.js +15 -0
  20. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +1 -1
  21. package/node_modules/hono/dist/types/adapter/bun/serve-static.d.ts +1 -1
  22. package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static.d.ts +2 -2
  23. package/node_modules/hono/dist/types/adapter/deno/serve-static.d.ts +1 -1
  24. package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +6 -5
  25. package/node_modules/hono/dist/types/middleware/cache/index.d.ts +1 -1
  26. package/node_modules/hono/dist/types/request.d.ts +13 -0
  27. package/node_modules/hono/dist/utils/cookie.js +3 -3
  28. package/node_modules/hono/dist/utils/stream.js +4 -2
  29. package/node_modules/hono/package.json +2 -2
  30. package/package.json +6 -6
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.70.28",
4
+ "version": "6.70.29",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -2,7 +2,7 @@
2
2
  import { stat } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  import { serveStatic as baseServeStatic } from "../../middleware/serve-static/index.js";
5
- var serveStatic = (options) => {
5
+ var serveStatic = (options = {}) => {
6
6
  return async function serveStatic2(c, next) {
7
7
  const getContent = async (path) => {
8
8
  const file = Bun.file(path);
@@ -1,7 +1,7 @@
1
1
  // src/adapter/cloudflare-workers/serve-static.ts
2
2
  import { serveStatic as baseServeStatic } from "../../middleware/serve-static/index.js";
3
3
  import { getContentFromKVAsset } from "./utils.js";
4
- var serveStatic = (options) => {
4
+ var serveStatic = (options = {}) => {
5
5
  return async function serveStatic2(c, next) {
6
6
  const getContent = async (path) => {
7
7
  return getContentFromKVAsset(path, {
@@ -2,7 +2,7 @@
2
2
  import { join } from "node:path";
3
3
  import { serveStatic as baseServeStatic } from "../../middleware/serve-static/index.js";
4
4
  var { open, lstatSync, errors } = Deno;
5
- var serveStatic = (options) => {
5
+ var serveStatic = (options = {}) => {
6
6
  return async function serveStatic2(c, next) {
7
7
  const getContent = async (path) => {
8
8
  try {
@@ -23,7 +23,7 @@ module.exports = __toCommonJS(serve_static_exports);
23
23
  var import_promises = require("node:fs/promises");
24
24
  var import_node_path = require("node:path");
25
25
  var import_serve_static = require("../../middleware/serve-static");
26
- const serveStatic = (options) => {
26
+ const serveStatic = (options = {}) => {
27
27
  return async function serveStatic2(c, next) {
28
28
  const getContent = async (path) => {
29
29
  const file = Bun.file(path);
@@ -22,7 +22,7 @@ __export(serve_static_exports, {
22
22
  module.exports = __toCommonJS(serve_static_exports);
23
23
  var import_serve_static = require("../../middleware/serve-static");
24
24
  var import_utils = require("./utils");
25
- const serveStatic = (options) => {
25
+ const serveStatic = (options = {}) => {
26
26
  return async function serveStatic2(c, next) {
27
27
  const getContent = async (path) => {
28
28
  return (0, import_utils.getContentFromKVAsset)(path, {
@@ -23,7 +23,7 @@ module.exports = __toCommonJS(serve_static_exports);
23
23
  var import_node_path = require("node:path");
24
24
  var import_serve_static = require("../../middleware/serve-static");
25
25
  const { open, lstatSync, errors } = Deno;
26
- const serveStatic = (options) => {
26
+ const serveStatic = (options = {}) => {
27
27
  return async function serveStatic2(c, next) {
28
28
  const getContent = async (path) => {
29
29
  try {
@@ -21,19 +21,14 @@ __export(cache_exports, {
21
21
  });
22
22
  module.exports = __toCommonJS(cache_exports);
23
23
  const defaultCacheableStatusCodes = [200];
24
- const shouldSkipCache = (res) => {
25
- if (res.headers.has("Vary")) {
26
- return true;
24
+ const shouldSkipCacheControl = (cacheControl) => !!cacheControl && /(?:^|,\s*)(?:private|no-(?:store|cache))(?:\s*(?:=|,|$))/i.test(cacheControl);
25
+ const parseVaryDirectives = (vary) => {
26
+ if (vary == null) {
27
+ return [];
27
28
  }
28
- const cacheControl = res.headers.get("Cache-Control");
29
- if (cacheControl && /(?:^|,\s*)(?:private|no-(?:store|cache))(?:\s*(?:=|,|$))/i.test(cacheControl)) {
30
- return true;
31
- }
32
- if (res.headers.has("Set-Cookie")) {
33
- return true;
34
- }
35
- return false;
29
+ return (Array.isArray(vary) ? vary : vary.split(",")).map((directive) => directive.trim().toLowerCase()).filter(Boolean);
36
30
  };
31
+ const shouldSkipCache = (res, optionsVaryDirectives, responseVary) => responseVary.length && (!optionsVaryDirectives || responseVary.some((name) => !optionsVaryDirectives.has(name))) || shouldSkipCacheControl(res.headers.get("Cache-Control")) || res.headers.has("Set-Cookie");
37
32
  const cache = (options) => {
38
33
  if (!globalThis.caches) {
39
34
  if (options.onCacheNotAvailable === false) {
@@ -48,8 +43,9 @@ const cache = (options) => {
48
43
  options.wait = false;
49
44
  }
50
45
  const cacheControlDirectives = options.cacheControl?.split(",").map((directive) => directive.toLowerCase());
51
- const varyDirectives = Array.isArray(options.vary) ? options.vary : options.vary?.split(",").map((directive) => directive.trim());
52
- if (options.vary?.includes("*")) {
46
+ const optionsVaryList = parseVaryDirectives(options.vary);
47
+ const varyDirectives = optionsVaryList.length ? new Set(optionsVaryList) : void 0;
48
+ if (varyDirectives?.has("*")) {
53
49
  throw new Error(
54
50
  'Middleware vary configuration cannot include "*", as it disallows effective caching.'
55
51
  );
@@ -57,7 +53,7 @@ const cache = (options) => {
57
53
  const cacheableStatusCodes = new Set(
58
54
  options.cacheableStatusCodes ?? defaultCacheableStatusCodes
59
55
  );
60
- const addHeader = (c) => {
56
+ const addHeader = (c, responseVary) => {
61
57
  if (cacheControlDirectives) {
62
58
  const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0]) ?? [];
63
59
  for (const directive of cacheControlDirectives) {
@@ -69,16 +65,18 @@ const cache = (options) => {
69
65
  }
70
66
  }
71
67
  if (varyDirectives) {
72
- const existingDirectives = c.res.headers.get("Vary")?.split(",").map((d) => d.trim()) ?? [];
73
- const vary = Array.from(
74
- new Set(
75
- [...existingDirectives, ...varyDirectives].map((directive) => directive.toLowerCase())
76
- )
77
- ).sort();
78
- if (vary.includes("*")) {
79
- c.header("Vary", "*");
68
+ if (responseVary.length === 0) {
69
+ c.header("Vary", Array.from(varyDirectives).join(", "));
80
70
  } else {
81
- c.header("Vary", vary.join(", "));
71
+ const merged = new Set(varyDirectives);
72
+ for (const directive of responseVary) {
73
+ merged.add(directive);
74
+ }
75
+ if (merged.has("*")) {
76
+ c.header("Vary", "*");
77
+ } else {
78
+ c.header("Vary", Array.from(merged).join(", "));
79
+ }
82
80
  }
83
81
  }
84
82
  };
@@ -91,6 +89,12 @@ const cache = (options) => {
91
89
  if (options.keyGenerator) {
92
90
  key = await options.keyGenerator(c);
93
91
  }
92
+ if (varyDirectives) {
93
+ for (const directive of varyDirectives) {
94
+ const value = c.req.raw.headers.get(directive) ?? "";
95
+ key += `::${directive}=${encodeURIComponent(value)}`;
96
+ }
97
+ }
94
98
  const cacheName = typeof options.cacheName === "function" ? await options.cacheName(c) : options.cacheName;
95
99
  const cache3 = await caches.open(cacheName);
96
100
  const response = await cache3.match(key);
@@ -101,8 +105,9 @@ const cache = (options) => {
101
105
  if (!cacheableStatusCodes.has(c.res.status)) {
102
106
  return;
103
107
  }
104
- addHeader(c);
105
- if (shouldSkipCache(c.res)) {
108
+ const responseVary = parseVaryDirectives(c.res.headers.get("Vary"));
109
+ addHeader(c, responseVary);
110
+ if (shouldSkipCache(c.res, varyDirectives, responseVary)) {
106
111
  return;
107
112
  }
108
113
  const res = c.res.clone();
@@ -169,6 +169,21 @@ class HonoRequest {
169
169
  arrayBuffer() {
170
170
  return this.#cachedBody("arrayBuffer");
171
171
  }
172
+ /**
173
+ * `.bytes()` parses the request body as a `Uint8Array`.
174
+ *
175
+ * @see {@link https://hono.dev/docs/api/request#bytes}
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * app.post('/entry', async (c) => {
180
+ * const body = await c.req.bytes()
181
+ * })
182
+ * ```
183
+ */
184
+ bytes() {
185
+ return this.#cachedBody("arrayBuffer").then((buffer) => new Uint8Array(buffer));
186
+ }
172
187
  /**
173
188
  * Parses the request body as a `Blob`.
174
189
  * @example
@@ -72,14 +72,14 @@ const parse = (cookie, name) => {
72
72
  return {};
73
73
  }
74
74
  const pairs = cookie.split(";");
75
- const parsedCookie = {};
75
+ const parsedCookie = /* @__PURE__ */ Object.create(null);
76
76
  for (const pairStr of pairs) {
77
77
  const valueStartPos = pairStr.indexOf("=");
78
78
  if (valueStartPos === -1) {
79
79
  continue;
80
80
  }
81
81
  const cookieName = trimCookieWhitespace(pairStr.substring(0, valueStartPos));
82
- if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName)) {
82
+ if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) {
83
83
  continue;
84
84
  }
85
85
  let cookieValue = trimCookieWhitespace(pairStr.substring(valueStartPos + 1));
@@ -96,7 +96,7 @@ const parse = (cookie, name) => {
96
96
  return parsedCookie;
97
97
  };
98
98
  const parseSigned = async (cookie, secret, name) => {
99
- const parsedCookie = {};
99
+ const parsedCookie = /* @__PURE__ */ Object.create(null);
100
100
  const secretKey = await getCryptoKey(secret);
101
101
  for (const [key, value] of Object.entries(parse(cookie, name))) {
102
102
  const signatureStartPos = value.lastIndexOf(".");
@@ -48,7 +48,9 @@ class StreamingApi {
48
48
  done ? controller.close() : controller.enqueue(value);
49
49
  },
50
50
  cancel: () => {
51
- this.abort();
51
+ if (!this.closed) {
52
+ this.abort();
53
+ }
52
54
  }
53
55
  });
54
56
  }
@@ -70,11 +72,11 @@ class StreamingApi {
70
72
  return new Promise((res) => setTimeout(res, ms));
71
73
  }
72
74
  async close() {
75
+ this.closed = true;
73
76
  try {
74
77
  await this.writer.close();
75
78
  } catch {
76
79
  }
77
- this.closed = true;
78
80
  }
79
81
  async pipe(body) {
80
82
  this.writer.releaseLock();
@@ -1,18 +1,13 @@
1
1
  // src/middleware/cache/index.ts
2
2
  var defaultCacheableStatusCodes = [200];
3
- var shouldSkipCache = (res) => {
4
- if (res.headers.has("Vary")) {
5
- return true;
3
+ var shouldSkipCacheControl = (cacheControl) => !!cacheControl && /(?:^|,\s*)(?:private|no-(?:store|cache))(?:\s*(?:=|,|$))/i.test(cacheControl);
4
+ var parseVaryDirectives = (vary) => {
5
+ if (vary == null) {
6
+ return [];
6
7
  }
7
- const cacheControl = res.headers.get("Cache-Control");
8
- if (cacheControl && /(?:^|,\s*)(?:private|no-(?:store|cache))(?:\s*(?:=|,|$))/i.test(cacheControl)) {
9
- return true;
10
- }
11
- if (res.headers.has("Set-Cookie")) {
12
- return true;
13
- }
14
- return false;
8
+ return (Array.isArray(vary) ? vary : vary.split(",")).map((directive) => directive.trim().toLowerCase()).filter(Boolean);
15
9
  };
10
+ var shouldSkipCache = (res, optionsVaryDirectives, responseVary) => responseVary.length && (!optionsVaryDirectives || responseVary.some((name) => !optionsVaryDirectives.has(name))) || shouldSkipCacheControl(res.headers.get("Cache-Control")) || res.headers.has("Set-Cookie");
16
11
  var cache = (options) => {
17
12
  if (!globalThis.caches) {
18
13
  if (options.onCacheNotAvailable === false) {
@@ -27,8 +22,9 @@ var cache = (options) => {
27
22
  options.wait = false;
28
23
  }
29
24
  const cacheControlDirectives = options.cacheControl?.split(",").map((directive) => directive.toLowerCase());
30
- const varyDirectives = Array.isArray(options.vary) ? options.vary : options.vary?.split(",").map((directive) => directive.trim());
31
- if (options.vary?.includes("*")) {
25
+ const optionsVaryList = parseVaryDirectives(options.vary);
26
+ const varyDirectives = optionsVaryList.length ? new Set(optionsVaryList) : void 0;
27
+ if (varyDirectives?.has("*")) {
32
28
  throw new Error(
33
29
  'Middleware vary configuration cannot include "*", as it disallows effective caching.'
34
30
  );
@@ -36,7 +32,7 @@ var cache = (options) => {
36
32
  const cacheableStatusCodes = new Set(
37
33
  options.cacheableStatusCodes ?? defaultCacheableStatusCodes
38
34
  );
39
- const addHeader = (c) => {
35
+ const addHeader = (c, responseVary) => {
40
36
  if (cacheControlDirectives) {
41
37
  const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0]) ?? [];
42
38
  for (const directive of cacheControlDirectives) {
@@ -48,16 +44,18 @@ var cache = (options) => {
48
44
  }
49
45
  }
50
46
  if (varyDirectives) {
51
- const existingDirectives = c.res.headers.get("Vary")?.split(",").map((d) => d.trim()) ?? [];
52
- const vary = Array.from(
53
- new Set(
54
- [...existingDirectives, ...varyDirectives].map((directive) => directive.toLowerCase())
55
- )
56
- ).sort();
57
- if (vary.includes("*")) {
58
- c.header("Vary", "*");
47
+ if (responseVary.length === 0) {
48
+ c.header("Vary", Array.from(varyDirectives).join(", "));
59
49
  } else {
60
- c.header("Vary", vary.join(", "));
50
+ const merged = new Set(varyDirectives);
51
+ for (const directive of responseVary) {
52
+ merged.add(directive);
53
+ }
54
+ if (merged.has("*")) {
55
+ c.header("Vary", "*");
56
+ } else {
57
+ c.header("Vary", Array.from(merged).join(", "));
58
+ }
61
59
  }
62
60
  }
63
61
  };
@@ -70,6 +68,12 @@ var cache = (options) => {
70
68
  if (options.keyGenerator) {
71
69
  key = await options.keyGenerator(c);
72
70
  }
71
+ if (varyDirectives) {
72
+ for (const directive of varyDirectives) {
73
+ const value = c.req.raw.headers.get(directive) ?? "";
74
+ key += `::${directive}=${encodeURIComponent(value)}`;
75
+ }
76
+ }
73
77
  const cacheName = typeof options.cacheName === "function" ? await options.cacheName(c) : options.cacheName;
74
78
  const cache3 = await caches.open(cacheName);
75
79
  const response = await cache3.match(key);
@@ -80,8 +84,9 @@ var cache = (options) => {
80
84
  if (!cacheableStatusCodes.has(c.res.status)) {
81
85
  return;
82
86
  }
83
- addHeader(c);
84
- if (shouldSkipCache(c.res)) {
87
+ const responseVary = parseVaryDirectives(c.res.headers.get("Vary"));
88
+ addHeader(c, responseVary);
89
+ if (shouldSkipCache(c.res, varyDirectives, responseVary)) {
85
90
  return;
86
91
  }
87
92
  const res = c.res.clone();
@@ -147,6 +147,21 @@ var HonoRequest = class {
147
147
  arrayBuffer() {
148
148
  return this.#cachedBody("arrayBuffer");
149
149
  }
150
+ /**
151
+ * `.bytes()` parses the request body as a `Uint8Array`.
152
+ *
153
+ * @see {@link https://hono.dev/docs/api/request#bytes}
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * app.post('/entry', async (c) => {
158
+ * const body = await c.req.bytes()
159
+ * })
160
+ * ```
161
+ */
162
+ bytes() {
163
+ return this.#cachedBody("arrayBuffer").then((buffer) => new Uint8Array(buffer));
164
+ }
150
165
  /**
151
166
  * Parses the request body as a `Blob`.
152
167
  * @example