@velajs/cloudflare 1.32.0 → 1.33.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,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.33.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b7d0725: Remove obsolete contracts and backward-compatibility paths.
8
+
9
+ Validation now requires Standard Schema or DTO descriptors. Decorated events require event definitions and use EventDispatcher; EventEmitter.emit always settles every matching callback. Remove token-only discovery, instance-based schedule views, ownerless entrypoints, disposed-container reuse, unmanaged scope finalization, and the `(.*)` middleware alias. Queue driver bind returns cleanup and enqueue after inline disposal rejects. Configure HTTP body caps through security.body.maxBytes.
10
+
11
+ WebSocket clients must report admission with trySendRaw. Tiered caches require expiry-aware read/write methods; KV entries without expiry metadata miss. Aggregate specs use only aggregations, the default CRUD adapter can be undefined, and Studio discovers resources registered through Crud. Remove the Studio path alias, the mail envelope argument overload, the AI embedding resolver fallback, and the obsolete contentHash export.
12
+
13
+ Storage encryption rejects invalid ciphertext; compression requires format metadata and a metadata-capable store.
14
+
15
+ Update adapters, examples, tests, API snapshots and migration documentation to the current contracts.
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [b7d0725]
20
+ - Updated dependencies [b7d0725]
21
+ - @velajs/vela@1.33.0
22
+ - @velajs/testing@1.33.0
23
+ - @velajs/storage@1.33.0
24
+ - @velajs/feature-flags@1.31.0
25
+
3
26
  ## 1.32.0
4
27
 
5
28
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -88,8 +88,8 @@ export declare function workflow<Params = unknown>(ref: BindingRef): Binding<Wor
88
88
  type KVNamespaceSource = KVNamespace | (() => KVNamespace);
89
89
  /**
90
90
  * Native KV JSON value store. Metadata retains logical expiry even when KV's
91
- * physical retention rounds up to its 60-second minimum. Legacy values without
92
- * metadata remain readable, but cannot safely backfill another tier.
91
+ * physical retention rounds up to its 60-second minimum. Values without
92
+ * Vela expiry metadata are cache misses.
93
93
  */
94
94
  export declare class KVCacheStore implements CacheStore, CacheEntryReader, CacheEntryWriter {
95
95
  #private;
@@ -3,8 +3,8 @@ import { kv } from "../bindings.js";
3
3
  const namespaceOf = (source) => typeof source === "function" ? source : () => source;
4
4
  /**
5
5
  * Native KV JSON value store. Metadata retains logical expiry even when KV's
6
- * physical retention rounds up to its 60-second minimum. Legacy values without
7
- * metadata remain readable, but cannot safely backfill another tier.
6
+ * physical retention rounds up to its 60-second minimum. Values without
7
+ * Vela expiry metadata are cache misses.
8
8
  */
9
9
  var KVCacheStore = class {
10
10
  #namespace;
@@ -22,13 +22,13 @@ var KVCacheStore = class {
22
22
  if (value === null) return void 0;
23
23
  if (typeof metadata === "object" && metadata !== null && "velaCacheExpiresAt" in metadata) {
24
24
  const expiresAt = metadata.velaCacheExpiresAt;
25
+ if (expiresAt === null) return { value };
25
26
  if (typeof expiresAt !== "number" || !Number.isFinite(expiresAt) || expiresAt <= Date.now()) return void 0;
26
27
  return {
27
28
  value,
28
29
  expiresAt
29
30
  };
30
31
  }
31
- return { value };
32
32
  }
33
33
  async set(key, value, ttl) {
34
34
  if (ttl !== void 0 && (!Number.isFinite(ttl) || ttl < 0)) throw new TypeError("Cache TTL must be finite and nonnegative.");
@@ -36,7 +36,7 @@ var KVCacheStore = class {
36
36
  value,
37
37
  expiresAt: Date.now() + ttl * 1e3
38
38
  });
39
- await this.ns.put(key, JSON.stringify(value));
39
+ await this.ns.put(key, JSON.stringify(value), { metadata: { velaCacheExpiresAt: null } });
40
40
  }
41
41
  async setEntry(key, entry) {
42
42
  if (!Number.isFinite(entry.expiresAt)) throw new TypeError("Cache expiry must be finite.");
@@ -1 +1 @@
1
- {"version":3,"file":"kv-cache.store.js","names":[],"sources":["../../src/services/kv-cache.store.ts"],"sourcesContent":["import type {\n CacheEntry,\n CacheEntryReader,\n CacheEntryWriter,\n CacheInvalidationStore,\n CacheStore,\n} from '@velajs/vela/cache';\nimport type { EnvFactory } from '@velajs/vela/module-kit';\nimport { kv } from '../bindings';\n\n/** A KV namespace, or a function that reads it when an operation needs it. */\nexport type KVNamespaceSource = KVNamespace | (() => KVNamespace);\n\nconst namespaceOf = (source: KVNamespaceSource): (() => KVNamespace) =>\n typeof source === 'function' ? source : () => source;\n\n/**\n * Native KV JSON value store. Metadata retains logical expiry even when KV's\n * physical retention rounds up to its 60-second minimum. Legacy values without\n * metadata remain readable, but cannot safely backfill another tier.\n */\nexport class KVCacheStore implements CacheStore, CacheEntryReader, CacheEntryWriter {\n readonly #namespace: () => KVNamespace;\n constructor(namespace: KVNamespaceSource) {\n this.#namespace = namespaceOf(namespace);\n }\n\n private get ns(): KVNamespace {\n return this.#namespace();\n }\n\n async get(key: string): Promise<unknown> {\n return (await this.getEntry(key))?.value;\n }\n\n async getEntry(key: string): Promise<{ value: unknown; expiresAt?: number } | undefined> {\n const { value, metadata } = await this.ns.getWithMetadata<unknown, unknown>(key, 'json');\n if (value === null) return undefined;\n if (typeof metadata === 'object' && metadata !== null && 'velaCacheExpiresAt' in metadata) {\n const expiresAt = metadata.velaCacheExpiresAt;\n if (typeof expiresAt !== 'number' || !Number.isFinite(expiresAt) || expiresAt <= Date.now())\n return undefined;\n return { value, expiresAt };\n }\n return { value };\n }\n\n async set(key: string, value: unknown, ttl?: number): Promise<void> {\n if (ttl !== undefined && (!Number.isFinite(ttl) || ttl < 0))\n throw new TypeError('Cache TTL must be finite and nonnegative.');\n if (ttl !== undefined) return this.setEntry(key, { value, expiresAt: Date.now() + ttl * 1000 });\n await this.ns.put(key, JSON.stringify(value));\n }\n\n async setEntry(key: string, entry: CacheEntry): Promise<void> {\n if (!Number.isFinite(entry.expiresAt)) throw new TypeError('Cache expiry must be finite.');\n const remaining = (entry.expiresAt - Date.now()) / 1000;\n if (remaining <= 0) return this.del(key);\n await this.ns.put(key, JSON.stringify(entry.value), {\n expirationTtl: Math.max(60, Math.ceil(remaining)),\n metadata: { velaCacheExpiresAt: entry.expiresAt },\n });\n }\n\n async del(key: string): Promise<void> {\n await this.ns.delete(key);\n }\n\n /** Namespace-wide, best effort. Use a dedicated value namespace; never use for scoped invalidation. */\n async clear(): Promise<void> {\n let cursor: string | undefined;\n do {\n const list = await this.ns.list(cursor ? { cursor } : undefined);\n await Promise.all(list.keys.map((entry) => this.ns.delete(entry.name)));\n cursor = list.list_complete ? undefined : list.cursor;\n } while (cursor);\n }\n}\n\n/**\n * Optional, eventually consistent generation store. Use a dedicated KV namespace\n * without TTL/lifecycle cleanup. Never delete/reset generations while entries can\n * survive. Concurrent writes and cached/negative reads prevent strong invalidation;\n * this is unsuitable for strict read-after-write or authorization revocation.\n */\nexport class KVCacheInvalidationStore implements CacheInvalidationStore {\n readonly #namespace: () => KVNamespace;\n constructor(namespace: KVNamespaceSource) {\n this.#namespace = namespaceOf(namespace);\n }\n\n private get ns(): KVNamespace {\n return this.#namespace();\n }\n\n async getVersion(key: string): Promise<string> {\n const value: unknown = await this.ns.get(key, 'json');\n if (value === null) return 'initial';\n if (typeof value !== 'string' || value.length === 0 || value.length > 2048)\n throw new TypeError('Invalid cache generation.');\n return value;\n }\n async invalidate(key: string): Promise<void> {\n await this.ns.put(key, JSON.stringify(crypto.randomUUID()));\n }\n}\n\n/**\n * `CacheModule`'s value store over the KV namespace named `binding`, read from\n * each application's `ENV` when an operation needs it:\n * `CacheModule.forRoot({ namespace, scope, store: kvCache({ binding: 'CACHE' }) })`.\n */\nexport function kvCache(ref: { binding: string }): EnvFactory<CacheStore> {\n const namespace = kv(ref);\n return (env) => new KVCacheStore(() => namespace(env));\n}\n\n/**\n * `CacheModule`'s generation store over a dedicated KV namespace named\n * `binding`, without TTLs or lifecycle cleanup. Eventually consistent; see\n * {@link KVCacheInvalidationStore}.\n */\nexport function kvCacheInvalidation(ref: { binding: string }): EnvFactory<CacheInvalidationStore> {\n const namespace = kv(ref);\n return (env) => new KVCacheInvalidationStore(() => namespace(env));\n}\n"],"mappings":";;AAaA,MAAM,eAAe,WACn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Content":["import type {\n CacheEntry,\n CacheEntryReader,\n CacheEntryWriter,\n CacheInvalidationStore,\n CacheStore,\n} from '@velajs/vela/cache';\nimport type { EnvFactory } from '@velajs/vela/module-kit';\nimport { kv } from '../bindings';\n\n/** A KV namespace, or a function that reads it when an operation needs it. */\nexport type KVNamespaceSource = KVNamespace | (() => KVNamespace);\n\nconst namespaceOf = (source: KVNamespaceSource): (() => KVNamespace) =>\n typeof source === 'function' ? source : () => source;\n\n/**\n * Native KV JSON value store. Metadata retains logical expiry even when KV's\n * physical retention rounds up to its 60-second minimum. Values without\n * Vela expiry metadata are cache misses.\n */\nexport class KVCacheStore implements CacheStore, CacheEntryReader, CacheEntryWriter {\n readonly #namespace: () => KVNamespace;\n constructor(namespace: KVNamespaceSource) {\n this.#namespace = namespaceOf(namespace);\n }\n\n private get ns(): KVNamespace {\n return this.#namespace();\n }\n\n async get(key: string): Promise<unknown> {\n return (await this.getEntry(key))?.value;\n }\n\n async getEntry(key: string): Promise<{ value: unknown; expiresAt?: number } | undefined> {\n const { value, metadata } = await this.ns.getWithMetadata<unknown, unknown>(key, 'json');\n if (value === null) return undefined;\n if (typeof metadata === 'object' && metadata !== null && 'velaCacheExpiresAt' in metadata) {\n const expiresAt = metadata.velaCacheExpiresAt;\n if (expiresAt === null) return { value };\n if (typeof expiresAt !== 'number' || !Number.isFinite(expiresAt) || expiresAt <= Date.now())\n return undefined;\n return { value, expiresAt };\n }\n return undefined;\n }\n\n async set(key: string, value: unknown, ttl?: number): Promise<void> {\n if (ttl !== undefined && (!Number.isFinite(ttl) || ttl < 0))\n throw new TypeError('Cache TTL must be finite and nonnegative.');\n if (ttl !== undefined) return this.setEntry(key, { value, expiresAt: Date.now() + ttl * 1000 });\n await this.ns.put(key, JSON.stringify(value), { metadata: { velaCacheExpiresAt: null } });\n }\n\n async setEntry(key: string, entry: CacheEntry): Promise<void> {\n if (!Number.isFinite(entry.expiresAt)) throw new TypeError('Cache expiry must be finite.');\n const remaining = (entry.expiresAt - Date.now()) / 1000;\n if (remaining <= 0) return this.del(key);\n await this.ns.put(key, JSON.stringify(entry.value), {\n expirationTtl: Math.max(60, Math.ceil(remaining)),\n metadata: { velaCacheExpiresAt: entry.expiresAt },\n });\n }\n\n async del(key: string): Promise<void> {\n await this.ns.delete(key);\n }\n\n /** Namespace-wide, best effort. Use a dedicated value namespace; never use for scoped invalidation. */\n async clear(): Promise<void> {\n let cursor: string | undefined;\n do {\n const list = await this.ns.list(cursor ? { cursor } : undefined);\n await Promise.all(list.keys.map((entry) => this.ns.delete(entry.name)));\n cursor = list.list_complete ? undefined : list.cursor;\n } while (cursor);\n }\n}\n\n/**\n * Optional, eventually consistent generation store. Use a dedicated KV namespace\n * without TTL/lifecycle cleanup. Never delete/reset generations while entries can\n * survive. Concurrent writes and cached/negative reads prevent strong invalidation;\n * this is unsuitable for strict read-after-write or authorization revocation.\n */\nexport class KVCacheInvalidationStore implements CacheInvalidationStore {\n readonly #namespace: () => KVNamespace;\n constructor(namespace: KVNamespaceSource) {\n this.#namespace = namespaceOf(namespace);\n }\n\n private get ns(): KVNamespace {\n return this.#namespace();\n }\n\n async getVersion(key: string): Promise<string> {\n const value: unknown = await this.ns.get(key, 'json');\n if (value === null) return 'initial';\n if (typeof value !== 'string' || value.length === 0 || value.length > 2048)\n throw new TypeError('Invalid cache generation.');\n return value;\n }\n async invalidate(key: string): Promise<void> {\n await this.ns.put(key, JSON.stringify(crypto.randomUUID()));\n }\n}\n\n/**\n * `CacheModule`'s value store over the KV namespace named `binding`, read from\n * each application's `ENV` when an operation needs it:\n * `CacheModule.forRoot({ namespace, scope, store: kvCache({ binding: 'CACHE' }) })`.\n */\nexport function kvCache(ref: { binding: string }): EnvFactory<CacheStore> {\n const namespace = kv(ref);\n return (env) => new KVCacheStore(() => namespace(env));\n}\n\n/**\n * `CacheModule`'s generation store over a dedicated KV namespace named\n * `binding`, without TTLs or lifecycle cleanup. Eventually consistent; see\n * {@link KVCacheInvalidationStore}.\n */\nexport function kvCacheInvalidation(ref: { binding: string }): EnvFactory<CacheInvalidationStore> {\n const namespace = kv(ref);\n return (env) => new KVCacheInvalidationStore(() => namespace(env));\n}\n"],"mappings":";;AAaA,MAAM,eAAe,WACnB,OAAO,WAAW,aAAa,eAAe;;;;;;AAOhD,IAAa,eAAb,MAAoF;CAClF;CACA,YAAY,WAA8B;EACxC,KAAK,aAAa,YAAY,SAAS;CACzC;CAEA,IAAY,KAAkB;EAC5B,OAAO,KAAK,WAAW;CACzB;CAEA,MAAM,IAAI,KAA+B;EACvC,QAAQ,MAAM,KAAK,SAAS,GAAG,EAAA,EAAI;CACrC;CAEA,MAAM,SAAS,KAA0E;EACvF,MAAM,EAAE,OAAO,aAAa,MAAM,KAAK,GAAG,gBAAkC,KAAK,MAAM;EACvF,IAAI,UAAU,MAAM,OAAO,KAAA;EAC3B,IAAI,OAAO,aAAa,YAAY,aAAa,QAAQ,wBAAwB,UAAU;GACzF,MAAM,YAAY,SAAS;GAC3B,IAAI,cAAc,MAAM,OAAO,EAAE,MAAM;GACvC,IAAI,OAAO,cAAc,YAAY,CAAC,OAAO,SAAS,SAAS,KAAK,aAAa,KAAK,IAAI,GACxF,OAAO,KAAA;GACT,OAAO;IAAE;IAAO;GAAU;EAC5B;CAEF;CAEA,MAAM,IAAI,KAAa,OAAgB,KAA6B;EAClE,IAAI,QAAQ,KAAA,MAAc,CAAC,OAAO,SAAS,GAAG,KAAK,MAAM,IACvD,MAAM,IAAI,UAAU,2CAA2C;EACjE,IAAI,QAAQ,KAAA,GAAW,OAAO,KAAK,SAAS,KAAK;GAAE;GAAO,WAAW,KAAK,IAAI,IAAI,MAAM;EAAK,CAAC;EAC9F,MAAM,KAAK,GAAG,IAAI,KAAK,KAAK,UAAU,KAAK,GAAG,EAAE,UAAU,EAAE,oBAAoB,KAAK,EAAE,CAAC;CAC1F;CAEA,MAAM,SAAS,KAAa,OAAkC;EAC5D,IAAI,CAAC,OAAO,SAAS,MAAM,SAAS,GAAG,MAAM,IAAI,U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D;;;;;;AAOA,SAAgB,oBAAoB,KAA8D;CAChG,MAAM,YAAY,GAAG,GAAG;CACxB,QAAQ,QAAQ,IAAI,+BAA+B,UAAU,GAAG,CAAC;AACnE"}
@@ -7,7 +7,7 @@ import { WS_GATEWAY_METADATA, WS_SERVER } from "@velajs/vela/websocket";
7
7
  */
8
8
  function bindingGateways(discovery) {
9
9
  const gateways = /* @__PURE__ */ new Map();
10
- for (const { metatype, meta } of discovery.providersWithMeta(WS_GATEWAY_METADATA, { metadataOnly: true })) {
10
+ for (const { metatype, meta } of discovery.registrationsWithMeta(WS_GATEWAY_METADATA, { metadataOnly: true })) {
11
11
  const path = meta.path ?? "";
12
12
  if (typeof meta.binding !== "string" || gateways.has(path)) continue;
13
13
  gateways.set(path, {
@@ -1 +1 @@
1
- {"version":3,"file":"binding-gateways.js","names":[],"sources":["../../src/websocket/binding-gateways.ts"],"sourcesContent":["import type { Container, DiscoveryService } from '@velajs/vela/module-kit';\nimport {\n WS_GATEWAY_METADATA,\n WS_SERVER,\n type WebSocketGatewayOptions,\n} from '@velajs/vela/websocket';\nimport { reportDiagnostic } from '../diagnostics';\n\n/** A gateway whose rooms live in Durable Objects: its path and namespace binding. */\nexport interface BindingGateway {\n path: string;\n binding: string;\n /** The gateway class name, for diagnostics. */\n name: string;\n}\n\n/**\n * The application's gateways that name a `binding`, in discovery order, once\n * per path. Read from decorator metadata, so lifecycle hooks can use it.\n */\nexport function bindingGateways(discovery: DiscoveryService): BindingGateway[] {\n const gateways = new Map<string, BindingGateway>();\n for (const { metatype, meta } of discovery.providersWithMeta<WebSocketGatewayOptions>(\n WS_GATEWAY_METADATA,\n { metadataOnly: true },\n )) {\n const path = meta.path ?? '';\n if (typeof meta.binding !== 'string' || gateways.has(path)) continue;\n gateways.set(path, {\n path,\n binding: meta.binding,\n name: metatype.name,\n });\n }\n return [...gateways.values()];\n}\n\n/**\n * `WebSocketModule` mounts the Worker's upgrade routes. An application with a\n * binding-backed gateway but without that module answers its upgrades with\n * 404, so report each such gateway through the diagnostics policy.\n */\nexport function reportUnservedGateways(container: Container, discovery: DiscoveryService): void {\n if (container.has(WS_SERVER)) return;\n for (const { name, binding, path } of bindingGateways(discovery)) {\n reportDiagnostic(\n container,\n `[vela] ${name} is a @WebSocketGateway with binding '${binding}', but the application ` +\n `does not import WebSocketModule.forRoot() from @velajs/vela/websocket, so upgrades ` +\n `to '${path}' answer 404 instead of reaching its Durable Object.`,\n );\n }\n}\n"],"mappings":";;;;;;;AAoBA,SAAgB,gBAAgB,WAA+C;CAC7E,MAAM,2BAAW,IAAI,IAA4B;CACjD,KAAK,MAAM,EAAE,UAAU,UAAU,UAAU,kBACzC,qBACA,EAAE,cAAc,KAAK,CACvB,GAAG;EACD,MAAM,OAAO,KAAK,QAAQ;EAC1B,IAAI,OAAO,KAAK,YAAY,YAAY,SAAS,IAAI,IAAI,GAAG;EAC5D,SAAS,IAAI,MAAM;GACjB;GACA,SAAS,KAAK;GACd,MAAM,SAAS;EACjB,CAAC;CACH;CACA,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC;AAC9B;;;;;;AAOA,SAAgB,uBAAuB,WAAsB,WAAmC;CAC9F,IAAI,UAAU,IAAI,SAAS,GAAG;CAC9B,KAAK,MAAM,EAAE,MAAM,SAAS,UAAU,gBAAgB,SAAS,GAC7D,iBACE,WACA,UAAU,KAAK,wCAAwC,QAAQ,gHAEtD,KAAK,qDAChB;AAEJ"}
1
+ {"version":3,"file":"binding-gateways.js","names":[],"sources":["../../src/websocket/binding-gateways.ts"],"sourcesContent":["import type { Container, DiscoveryService } from '@velajs/vela/module-kit';\nimport {\n WS_GATEWAY_METADATA,\n WS_SERVER,\n type WebSocketGatewayOptions,\n} from '@velajs/vela/websocket';\nimport { reportDiagnostic } from '../diagnostics';\n\n/** A gateway whose rooms live in Durable Objects: its path and namespace binding. */\nexport interface BindingGateway {\n path: string;\n binding: string;\n /** The gateway class name, for diagnostics. */\n name: string;\n}\n\n/**\n * The application's gateways that name a `binding`, in discovery order, once\n * per path. Read from decorator metadata, so lifecycle hooks can use it.\n */\nexport function bindingGateways(discovery: DiscoveryService): BindingGateway[] {\n const gateways = new Map<string, BindingGateway>();\n for (const { metatype, meta } of discovery.registrationsWithMeta<WebSocketGatewayOptions>(\n WS_GATEWAY_METADATA,\n { metadataOnly: true },\n )) {\n const path = meta.path ?? '';\n if (typeof meta.binding !== 'string' || gateways.has(path)) continue;\n gateways.set(path, {\n path,\n binding: meta.binding,\n name: metatype.name,\n });\n }\n return [...gateways.values()];\n}\n\n/**\n * `WebSocketModule` mounts the Worker's upgrade routes. An application with a\n * binding-backed gateway but without that module answers its upgrades with\n * 404, so report each such gateway through the diagnostics policy.\n */\nexport function reportUnservedGateways(container: Container, discovery: DiscoveryService): void {\n if (container.has(WS_SERVER)) return;\n for (const { name, binding, path } of bindingGateways(discovery)) {\n reportDiagnostic(\n container,\n `[vela] ${name} is a @WebSocketGateway with binding '${binding}', but the application ` +\n `does not import WebSocketModule.forRoot() from @velajs/vela/websocket, so upgrades ` +\n `to '${path}' answer 404 instead of reaching its Durable Object.`,\n );\n }\n}\n"],"mappings":";;;;;;;AAoBA,SAAgB,gBAAgB,WAA+C;CAC7E,MAAM,2BAAW,IAAI,IAA4B;CACjD,KAAK,MAAM,EAAE,UAAU,UAAU,UAAU,sBACzC,qBACA,EAAE,cAAc,KAAK,CACvB,GAAG;EACD,MAAM,OAAO,KAAK,QAAQ;EAC1B,IAAI,OAAO,KAAK,YAAY,YAAY,SAAS,IAAI,IAAI,GAAG;EAC5D,SAAS,IAAI,MAAM;GACjB;GACA,SAAS,KAAK;GACd,MAAM,SAAS;EACjB,CAAC;CACH;CACA,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC;AAC9B;;;;;;AAOA,SAAgB,uBAAuB,WAAsB,WAAmC;CAC9F,IAAI,UAAU,IAAI,SAAS,GAAG;CAC9B,KAAK,MAAM,EAAE,MAAM,SAAS,UAAU,gBAAgB,SAAS,GAC7D,iBACE,WACA,UAAU,KAAK,wCAAwC,QAAQ,gHAEtD,KAAK,qDAChB;AAEJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velajs/cloudflare",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "description": "Cloudflare Workers integration for Vela framework",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -92,17 +92,17 @@
92
92
  "vitest": "4.1.11",
93
93
  "zod": "^3.25.76",
94
94
  "@velajs/feature-flags": "1.31.0",
95
- "@velajs/storage": "1.32.0",
96
- "@velajs/testing": "1.32.0",
97
- "@velajs/vela": "1.32.0"
95
+ "@velajs/storage": "1.33.0",
96
+ "@velajs/testing": "1.33.0",
97
+ "@velajs/vela": "1.33.0"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@cloudflare/workers-types": ">=4",
101
101
  "hono": ">=4",
102
102
  "@velajs/feature-flags": "^1.31.0",
103
- "@velajs/storage": "^1.32.0",
104
- "@velajs/testing": "^1.32.0",
105
- "@velajs/vela": "^1.32.0"
103
+ "@velajs/storage": "^1.33.0",
104
+ "@velajs/vela": "^1.33.0",
105
+ "@velajs/testing": "^1.33.0"
106
106
  },
107
107
  "peerDependenciesMeta": {
108
108
  "@velajs/feature-flags": {