@zuplo/cli 6.73.21 → 6.73.23

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.
@@ -249,6 +249,8 @@ export declare type AIGatewayCapability =
249
249
  * policies.
250
250
  * Entry options replace the declaration's options as a complete object; omit
251
251
  * them to inherit the declaration, including environment-backed credentials.
252
+ * Each occurrence receives a private deep copy of its entry options, so a
253
+ * policy mutating its options cannot corrupt the cached app configuration.
252
254
  *
253
255
  * @title AI Gateway Configuration Executor (v2)
254
256
  * @product ai-gateway
@@ -384,6 +386,12 @@ export declare function aiGatewayHandlerV2(
384
386
  * This policy is meant to be used as singleton.
385
387
  * You should only have one for your entire Gateway.
386
388
  *
389
+ * Metering runs at most once per request: when the policy appears more than
390
+ * once in the effective chain (for example repeated
391
+ * `configuration.inboundPolicyChain` entries, or a static route entry plus a
392
+ * chain entry), only the first occurrence checks quotas and registers the
393
+ * meter-increment hook, so usage is never billed twice.
394
+ *
387
395
  * @title AI Gateway Metering
388
396
  * @product ai-gateway
389
397
  * @hidden
@@ -998,6 +1006,11 @@ export declare interface AkamaiAIFirewallPolicyOptions {
998
1006
  * `request.user.configuration`, and presence in the route's `inbound[]` chain is
999
1007
  * what enables it.
1000
1008
  *
1009
+ * Options are validated at request time and invalid options fail closed with a
1010
+ * ConfigurationError: detect-call failures deliberately fail open for
1011
+ * availability, so a misconfigured credential must not degrade into a silent
1012
+ * pass-through.
1013
+ *
1001
1014
  * For streaming responses it uses a transform stream that can block content
1002
1015
  * mid-stream if harmful content is detected.
1003
1016
  *
@@ -1010,8 +1023,8 @@ export declare interface AkamaiAIFirewallPolicyOptions {
1010
1023
  export declare function AkamaiAIFirewallV2InboundPolicy(
1011
1024
  request: ZuploRequest,
1012
1025
  context: ZuploContext,
1013
- options: AkamaiAIFirewallV2PolicyOptions,
1014
- _policyName: string
1026
+ unparsedOptions: unknown,
1027
+ policyName: string
1015
1028
  ): Promise<ZuploRequest | Response>;
1016
1029
 
1017
1030
  /**
@@ -15687,65 +15700,92 @@ declare interface WebSearchTool {
15687
15700
  }
15688
15701
 
15689
15702
  /**
15690
- * Handler that proxies WebSocket connections to a different URL.
15691
- * Enables WebSocket support in your API gateway for real-time communication.
15703
+ * Proxies WebSocket connections to an upstream URL.
15692
15704
  *
15693
- * @param request - The incoming ZuploRequest with WebSocket upgrade headers
15694
- * @param context - The ZuploContext
15695
- * @returns A WebSocket upgrade Response (101 Switching Protocols)
15705
+ * @deprecated Use {@link webSocketPipelineHandler} instead. `webSocketHandler`
15706
+ * is retained as a backwards-compatible alias and resolves to the exact same
15707
+ * handler with no inbound/outbound message policies configured it is a
15708
+ * transparent passthrough, so existing routes keep working unchanged. Because
15709
+ * it is the same function, routes using this name report
15710
+ * `zuplo.handler.type = "websocket-pipeline"`.
15711
+ * @public
15712
+ */
15713
+ export declare const webSocketHandler: typeof webSocketPipelineHandler;
15714
+
15715
+ /**
15716
+ * A WebSocket connection-level hook, invoked once when the connection opens.
15696
15717
  *
15697
- * @beta
15698
- * @example
15699
- * ```json
15700
- * // routes.oas.json - WebSocket endpoint
15701
- * {
15702
- * "paths": {
15703
- * "/ws/chat": {
15704
- * "x-zuplo-route": {
15705
- * "handler": {
15706
- * "export": "webSocketHandler",
15707
- * "module": "$import(@zuplo/runtime)",
15708
- * "options": {
15709
- * "rewritePattern": "wss://chat-backend.example.com/ws"
15710
- * }
15711
- * }
15712
- * }
15713
- * }
15714
- * }
15715
- * }
15716
- * ```
15718
+ * Mirrors {@link WebSocketPolicyFunction} without the per-message `data`
15719
+ * argument. It runs after both the client and upstream legs are established and
15720
+ * before any frame is relayed. Throwing (or returning a rejected promise)
15721
+ * aborts the connection: both sockets are closed and no `101 Switching
15722
+ * Protocols` response is returned to the caller.
15723
+ *
15724
+ * @param target - The upstream socket (gateway to origin).
15725
+ * @param source - The client-facing socket (gateway to caller).
15726
+ * @param request - The {@link ZuploRequest} that initiated the upgrade.
15727
+ * @param context - The {@link ZuploContext}.
15728
+ *
15729
+ * @remarks
15730
+ * Configuring `onOpen` opts the connection out of the zero-overhead Cloudflare
15731
+ * passthrough splice: the worker stays in the data path so the hook has both
15732
+ * live sockets to act on. If you need connection-level `close`/`error`/`message`
15733
+ * handling, attach your own listeners to either socket from within the hook.
15734
+ *
15735
+ * @public
15736
+ */
15737
+ export declare type WebSocketOnOpenHook = (
15738
+ target: WebSocket,
15739
+ source: WebSocket,
15740
+ request: ZuploRequest,
15741
+ context: ZuploContext
15742
+ ) => void | Promise<void>;
15743
+
15744
+ /**
15745
+ * Handle WebSocket requests by proxying them to a different URL, optionally
15746
+ * running inbound/outbound message policies and/or a connection-level `onOpen`
15747
+ * hook.
15748
+ *
15749
+ * When no intercept policies are configured the handler behaves like the plain
15750
+ * `webSocketHandler`: messages are forwarded verbatim and, on Cloudflare,
15751
+ * the upstream socket is spliced directly to the client so the worker stays out
15752
+ * of the per-message data path. The worker only sits in the message path (and
15753
+ * policies are only wired up) when at least one inbound or outbound policy is
15754
+ * configured.
15755
+ *
15756
+ * The optional `onOpen` hook (see {@link WebSocketOnOpenHook}) runs once after
15757
+ * both legs are established and before any frame is relayed. Because it needs
15758
+ * both live sockets, configuring it keeps the worker in the data path (the
15759
+ * Cloudflare splice is skipped). Throwing from the hook aborts the connection.
15717
15760
  *
15718
15761
  * @example
15762
+ * A route that runs an `onOpen` hook and an inbound message policy. `onOpen`
15763
+ * is declared at the `options` level, a sibling of `policies`:
15719
15764
  * ```json
15720
- * // Dynamic WebSocket routing based on path parameters
15721
15765
  * {
15722
- * "paths": {
15723
- * "/ws/{room}": {
15724
- * "x-zuplo-route": {
15725
- * "handler": {
15726
- * "export": "webSocketHandler",
15727
- * "module": "$import(@zuplo/runtime)",
15728
- * "options": {
15729
- * "rewritePattern": "wss://chat.example.com/rooms/${params.room}"
15730
- * }
15731
- * }
15766
+ * "handler": {
15767
+ * "export": "webSocketPipelineHandler",
15768
+ * "module": "$import(@zuplo/runtime)",
15769
+ * "options": {
15770
+ * "rewritePattern": "https://example.com/socket",
15771
+ * "onOpen": {
15772
+ * "export": "onWebSocketOpen",
15773
+ * "module": "$import(./modules/ws-onopen)"
15774
+ * },
15775
+ * "policies": {
15776
+ * "inbound": [
15777
+ * { "export": "authFrame", "module": "$import(./modules/ws-auth)" }
15778
+ * ]
15732
15779
  * }
15733
15780
  * }
15734
15781
  * }
15735
15782
  * }
15736
15783
  * ```
15737
- */
15738
- export declare function webSocketHandler(
15739
- request: ZuploRequest,
15740
- context: ZuploContext
15741
- ): Promise<Response>;
15742
-
15743
- /**
15744
- * Handle websocket requests to a different url
15784
+ *
15745
15785
  * @param request - The ZuploRequest
15746
15786
  * @param context - The ZuploContext
15747
- * @returns
15748
- * @beta
15787
+ * @returns A WebSocket upgrade Response (101 Switching Protocols)
15788
+ * @public
15749
15789
  */
15750
15790
  export declare function webSocketPipelineHandler(
15751
15791
  request: ZuploRequest,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.73.21",
4
+ "version": "6.73.23",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "6.73.21",
3
+ "version": "6.73.23",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "type": "module",
@@ -27,10 +27,10 @@
27
27
  "@opentelemetry/api": "1.9.0",
28
28
  "@opentelemetry/api-logs": "0.220.0",
29
29
  "@swc/core": "1.10.18",
30
- "@zuplo/core": "6.73.21",
30
+ "@zuplo/core": "6.73.23",
31
31
  "@zuplo/editor": "1.0.29844086763",
32
- "@zuplo/openapi-tools": "6.73.21",
33
- "@zuplo/runtime": "6.73.21",
32
+ "@zuplo/openapi-tools": "6.73.23",
33
+ "@zuplo/runtime": "6.73.23",
34
34
  "chalk": "5.4.1",
35
35
  "chokidar": "3.5.3",
36
36
  "cookie": "1.0.2",
@@ -61,8 +61,8 @@
61
61
  "workerd": "1.20241230.0",
62
62
  "yargs": "17.7.2",
63
63
  "zod": "3.25.76",
64
- "@zuplo/graphql": "6.73.21",
65
- "@zuplo/otel": "6.73.21"
64
+ "@zuplo/graphql": "6.73.23",
65
+ "@zuplo/otel": "6.73.23"
66
66
  },
67
67
  "bundleDependencies": [
68
68
  "@inquirer/prompts",