@boxrouter/sdk 0.0.0-stage → 0.12.190
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/LICENSE +202 -0
- package/NOTICE +40 -0
- package/README.md +508 -2
- package/dist/addresses.d.ts +5 -0
- package/dist/addresses.js +10 -0
- package/dist/api-error.d.ts +62 -0
- package/dist/api-error.js +264 -0
- package/dist/boxrouter.d.ts +68 -0
- package/dist/boxrouter.js +291 -0
- package/dist/browser-session/index.d.ts +17 -0
- package/dist/browser-session/index.js +48 -0
- package/dist/browser-session/operations.gen.d.ts +272 -0
- package/dist/browser-session/operations.gen.js +58 -0
- package/dist/browser-session/responseContracts/api_keys.d.ts +2 -0
- package/dist/browser-session/responseContracts/api_keys.js +10 -0
- package/dist/browser-session/responseContracts/credits.d.ts +2 -0
- package/dist/browser-session/responseContracts/credits.js +8 -0
- package/dist/browser-session/responseContracts/github.d.ts +2 -0
- package/dist/browser-session/responseContracts/github.js +11 -0
- package/dist/browser-session/responseContracts/identity.d.ts +2 -0
- package/dist/browser-session/responseContracts/identity.js +30 -0
- package/dist/browser-session/responseContracts/organizations.d.ts +2 -0
- package/dist/browser-session/responseContracts/organizations.js +17 -0
- package/dist/browser-session/responseContracts/privacy.d.ts +2 -0
- package/dist/browser-session/responseContracts/privacy.js +7 -0
- package/dist/browser-session/responseContracts.gen.d.ts +3 -0
- package/dist/browser-session/responseContracts.gen.js +10 -0
- package/dist/browser-session/responseValidators/api_keys-diagnostics.cjs +1 -0
- package/dist/browser-session/responseValidators/api_keys-diagnostics.d.cts +4 -0
- package/dist/browser-session/responseValidators/api_keys.cjs +2 -0
- package/dist/browser-session/responseValidators/api_keys.d.cts +4 -0
- package/dist/browser-session/responseValidators/credits-diagnostics.cjs +1 -0
- package/dist/browser-session/responseValidators/credits-diagnostics.d.cts +3 -0
- package/dist/browser-session/responseValidators/credits.cjs +2 -0
- package/dist/browser-session/responseValidators/credits.d.cts +3 -0
- package/dist/browser-session/responseValidators/github-diagnostics.cjs +1 -0
- package/dist/browser-session/responseValidators/github-diagnostics.d.cts +3 -0
- package/dist/browser-session/responseValidators/github.cjs +2 -0
- package/dist/browser-session/responseValidators/github.d.cts +3 -0
- package/dist/browser-session/responseValidators/identity-diagnostics.cjs +1 -0
- package/dist/browser-session/responseValidators/identity-diagnostics.d.cts +23 -0
- package/dist/browser-session/responseValidators/identity.cjs +2 -0
- package/dist/browser-session/responseValidators/identity.d.cts +23 -0
- package/dist/browser-session/responseValidators/organizations-diagnostics.cjs +1 -0
- package/dist/browser-session/responseValidators/organizations-diagnostics.d.cts +15 -0
- package/dist/browser-session/responseValidators/organizations.cjs +2 -0
- package/dist/browser-session/responseValidators/organizations.d.cts +15 -0
- package/dist/browser-session/responseValidators/privacy-diagnostics.cjs +1 -0
- package/dist/browser-session/responseValidators/privacy-diagnostics.d.cts +2 -0
- package/dist/browser-session/responseValidators/privacy.cjs +2 -0
- package/dist/browser-session/responseValidators/privacy.d.cts +2 -0
- package/dist/client/client.gen.d.ts +2 -0
- package/dist/client/client.gen.js +168 -0
- package/dist/client/index.d.ts +10 -0
- package/dist/client/index.js +17 -0
- package/dist/client/types.gen.d.ts +120 -0
- package/dist/client/types.gen.js +3 -0
- package/dist/client/utils.gen.d.ts +37 -0
- package/dist/client/utils.gen.js +239 -0
- package/dist/client.gen.d.ts +12 -0
- package/dist/client.gen.js +6 -0
- package/dist/command-check.gen.d.ts +14 -0
- package/dist/command-check.gen.js +23 -0
- package/dist/command-input.gen.d.ts +6 -0
- package/dist/command-input.gen.js +45 -0
- package/dist/core/auth.gen.d.ts +25 -0
- package/dist/core/auth.gen.js +18 -0
- package/dist/core/binaryStream.d.ts +8 -0
- package/dist/core/binaryStream.js +76 -0
- package/dist/core/bodySerializer.gen.d.ts +25 -0
- package/dist/core/bodySerializer.gen.js +60 -0
- package/dist/core/commandValidators.cjs +1 -0
- package/dist/core/commandValidators.d.cts +14 -0
- package/dist/core/eventValidation.d.ts +17 -0
- package/dist/core/eventValidation.js +56 -0
- package/dist/core/eventValidators.cjs +1 -0
- package/dist/core/eventValidators.d.cts +2 -0
- package/dist/core/json.d.ts +3 -0
- package/dist/core/json.js +33 -0
- package/dist/core/params.gen.d.ts +43 -0
- package/dist/core/params.gen.js +112 -0
- package/dist/core/pathSerializer.gen.d.ts +33 -0
- package/dist/core/pathSerializer.gen.js +115 -0
- package/dist/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/core/queryKeySerializer.gen.js +98 -0
- package/dist/core/responseContracts/actions.d.ts +2 -0
- package/dist/core/responseContracts/actions.js +30 -0
- package/dist/core/responseContracts/agents.d.ts +2 -0
- package/dist/core/responseContracts/agents.js +7 -0
- package/dist/core/responseContracts/artifacts.d.ts +2 -0
- package/dist/core/responseContracts/artifacts.js +8 -0
- package/dist/core/responseContracts/commands.d.ts +2 -0
- package/dist/core/responseContracts/commands.js +6 -0
- package/dist/core/responseContracts/credits.d.ts +2 -0
- package/dist/core/responseContracts/credits.js +27 -0
- package/dist/core/responseContracts/files.d.ts +2 -0
- package/dist/core/responseContracts/files.js +15 -0
- package/dist/core/responseContracts/github.d.ts +2 -0
- package/dist/core/responseContracts/github.js +8 -0
- package/dist/core/responseContracts/images.d.ts +2 -0
- package/dist/core/responseContracts/images.js +8 -0
- package/dist/core/responseContracts/launchRuns.d.ts +2 -0
- package/dist/core/responseContracts/launchRuns.js +10 -0
- package/dist/core/responseContracts/launches.d.ts +2 -0
- package/dist/core/responseContracts/launches.js +10 -0
- package/dist/core/responseContracts/operations.d.ts +2 -0
- package/dist/core/responseContracts/operations.js +7 -0
- package/dist/core/responseContracts/previews.d.ts +2 -0
- package/dist/core/responseContracts/previews.js +8 -0
- package/dist/core/responseContracts/pricing.d.ts +2 -0
- package/dist/core/responseContracts/pricing.js +6 -0
- package/dist/core/responseContracts/processes.d.ts +2 -0
- package/dist/core/responseContracts/processes.js +11 -0
- package/dist/core/responseContracts/provider_accounts.d.ts +2 -0
- package/dist/core/responseContracts/provider_accounts.js +13 -0
- package/dist/core/responseContracts/providers.d.ts +2 -0
- package/dist/core/responseContracts/providers.js +6 -0
- package/dist/core/responseContracts/routing.d.ts +2 -0
- package/dist/core/responseContracts/routing.js +8 -0
- package/dist/core/responseContracts/sandboxes.d.ts +2 -0
- package/dist/core/responseContracts/sandboxes.js +15 -0
- package/dist/core/responseContracts/secrets.d.ts +2 -0
- package/dist/core/responseContracts/secrets.js +8 -0
- package/dist/core/responseContracts/spend_limits.d.ts +2 -0
- package/dist/core/responseContracts/spend_limits.js +8 -0
- package/dist/core/responseContracts/terminals.d.ts +2 -0
- package/dist/core/responseContracts/terminals.js +11 -0
- package/dist/core/responseContracts/usage.d.ts +2 -0
- package/dist/core/responseContracts/usage.js +7 -0
- package/dist/core/responseContracts/volumes.d.ts +2 -0
- package/dist/core/responseContracts/volumes.js +19 -0
- package/dist/core/responseContracts.gen.d.ts +3 -0
- package/dist/core/responseContracts.gen.js +27 -0
- package/dist/core/responseModes.d.ts +19 -0
- package/dist/core/responseModes.js +13 -0
- package/dist/core/responseValidation.d.ts +44 -0
- package/dist/core/responseValidation.js +174 -0
- package/dist/core/responseValidators/actions-diagnostics.cjs +4 -0
- package/dist/core/responseValidators/actions-diagnostics.d.cts +24 -0
- package/dist/core/responseValidators/actions.cjs +2 -0
- package/dist/core/responseValidators/actions.d.cts +24 -0
- package/dist/core/responseValidators/agents-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/agents-diagnostics.d.cts +2 -0
- package/dist/core/responseValidators/agents.cjs +2 -0
- package/dist/core/responseValidators/agents.d.cts +2 -0
- package/dist/core/responseValidators/artifacts-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/artifacts-diagnostics.d.cts +2 -0
- package/dist/core/responseValidators/artifacts.cjs +2 -0
- package/dist/core/responseValidators/artifacts.d.cts +2 -0
- package/dist/core/responseValidators/commands-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/commands-diagnostics.d.cts +1 -0
- package/dist/core/responseValidators/commands.cjs +2 -0
- package/dist/core/responseValidators/commands.d.cts +1 -0
- package/dist/core/responseValidators/compact.cjs +122 -0
- package/dist/core/responseValidators/credits-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/credits-diagnostics.d.cts +21 -0
- package/dist/core/responseValidators/credits.cjs +2 -0
- package/dist/core/responseValidators/credits.d.cts +21 -0
- package/dist/core/responseValidators/files-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/files-diagnostics.d.cts +5 -0
- package/dist/core/responseValidators/files.cjs +2 -0
- package/dist/core/responseValidators/files.d.cts +5 -0
- package/dist/core/responseValidators/github-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/github-diagnostics.d.cts +2 -0
- package/dist/core/responseValidators/github.cjs +2 -0
- package/dist/core/responseValidators/github.d.cts +2 -0
- package/dist/core/responseValidators/images-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/images-diagnostics.d.cts +3 -0
- package/dist/core/responseValidators/images.cjs +2 -0
- package/dist/core/responseValidators/images.d.cts +3 -0
- package/dist/core/responseValidators/launchRuns-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/launchRuns-diagnostics.d.cts +5 -0
- package/dist/core/responseValidators/launchRuns.cjs +2 -0
- package/dist/core/responseValidators/launchRuns.d.cts +5 -0
- package/dist/core/responseValidators/launches-diagnostics.cjs +10 -0
- package/dist/core/responseValidators/launches-diagnostics.d.cts +5 -0
- package/dist/core/responseValidators/launches.cjs +2 -0
- package/dist/core/responseValidators/launches.d.cts +5 -0
- package/dist/core/responseValidators/operations-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/operations-diagnostics.d.cts +2 -0
- package/dist/core/responseValidators/operations.cjs +2 -0
- package/dist/core/responseValidators/operations.d.cts +2 -0
- package/dist/core/responseValidators/previews-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/previews-diagnostics.d.cts +3 -0
- package/dist/core/responseValidators/previews.cjs +2 -0
- package/dist/core/responseValidators/previews.d.cts +3 -0
- package/dist/core/responseValidators/pricing-diagnostics.cjs +7 -0
- package/dist/core/responseValidators/pricing-diagnostics.d.cts +1 -0
- package/dist/core/responseValidators/pricing.cjs +2 -0
- package/dist/core/responseValidators/pricing.d.cts +1 -0
- package/dist/core/responseValidators/processes-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/processes-diagnostics.d.cts +2 -0
- package/dist/core/responseValidators/processes.cjs +2 -0
- package/dist/core/responseValidators/processes.d.cts +2 -0
- package/dist/core/responseValidators/provider_accounts-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/provider_accounts-diagnostics.d.cts +8 -0
- package/dist/core/responseValidators/provider_accounts.cjs +2 -0
- package/dist/core/responseValidators/provider_accounts.d.cts +8 -0
- package/dist/core/responseValidators/providers-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/providers-diagnostics.d.cts +1 -0
- package/dist/core/responseValidators/providers.cjs +2 -0
- package/dist/core/responseValidators/providers.d.cts +1 -0
- package/dist/core/responseValidators/routing-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/routing-diagnostics.d.cts +3 -0
- package/dist/core/responseValidators/routing.cjs +2 -0
- package/dist/core/responseValidators/routing.d.cts +3 -0
- package/dist/core/responseValidators/sandboxes-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/sandboxes-diagnostics.d.cts +10 -0
- package/dist/core/responseValidators/sandboxes.cjs +2 -0
- package/dist/core/responseValidators/sandboxes.d.cts +10 -0
- package/dist/core/responseValidators/secrets-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/secrets-diagnostics.d.cts +1 -0
- package/dist/core/responseValidators/secrets.cjs +2 -0
- package/dist/core/responseValidators/secrets.d.cts +1 -0
- package/dist/core/responseValidators/spend_limits-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/spend_limits-diagnostics.d.cts +3 -0
- package/dist/core/responseValidators/spend_limits.cjs +2 -0
- package/dist/core/responseValidators/spend_limits.d.cts +3 -0
- package/dist/core/responseValidators/terminals-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/terminals-diagnostics.d.cts +2 -0
- package/dist/core/responseValidators/terminals.cjs +2 -0
- package/dist/core/responseValidators/terminals.d.cts +2 -0
- package/dist/core/responseValidators/usage-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/usage-diagnostics.d.cts +1 -0
- package/dist/core/responseValidators/usage.cjs +2 -0
- package/dist/core/responseValidators/usage.d.cts +1 -0
- package/dist/core/responseValidators/volumes-diagnostics.cjs +1 -0
- package/dist/core/responseValidators/volumes-diagnostics.d.cts +10 -0
- package/dist/core/responseValidators/volumes.cjs +2 -0
- package/dist/core/responseValidators/volumes.d.cts +10 -0
- package/dist/core/serverSentEvents.gen.d.ts +30 -0
- package/dist/core/serverSentEvents.gen.js +313 -0
- package/dist/core/streamErrors.d.ts +32 -0
- package/dist/core/streamErrors.js +51 -0
- package/dist/core/types.gen.d.ts +83 -0
- package/dist/core/types.gen.js +3 -0
- package/dist/core/utils.gen.d.ts +19 -0
- package/dist/core/utils.gen.js +93 -0
- package/dist/creation.gen.d.ts +21 -0
- package/dist/creation.gen.js +35 -0
- package/dist/data-origin.d.ts +25 -0
- package/dist/data-origin.js +57 -0
- package/dist/error-codes.gen.d.ts +2 -0
- package/dist/error-codes.gen.js +2 -0
- package/dist/idempotency.gen.d.ts +1 -0
- package/dist/idempotency.gen.js +60 -0
- package/dist/images.d.ts +74 -0
- package/dist/images.js +88 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +80 -0
- package/dist/launch-input.gen.d.ts +9 -0
- package/dist/launch-input.gen.js +83 -0
- package/dist/launch.d.ts +28 -0
- package/dist/launch.js +222 -0
- package/dist/namespace-actions.d.mts +307 -0
- package/dist/namespace-actions.mjs +595 -0
- package/dist/namespace-agents.d.mts +33 -0
- package/dist/namespace-agents.mjs +40 -0
- package/dist/namespace-artifacts.d.mts +46 -0
- package/dist/namespace-artifacts.mjs +69 -0
- package/dist/namespace-base.d.mts +7 -0
- package/dist/namespace-base.mjs +7 -0
- package/dist/namespace-commands.d.mts +57 -0
- package/dist/namespace-commands.mjs +57 -0
- package/dist/namespace-credits.d.mts +213 -0
- package/dist/namespace-credits.mjs +476 -0
- package/dist/namespace-files.d.mts +203 -0
- package/dist/namespace-files.mjs +334 -0
- package/dist/namespace-github.d.mts +50 -0
- package/dist/namespace-github.mjs +68 -0
- package/dist/namespace-images.d.mts +52 -0
- package/dist/namespace-images.mjs +78 -0
- package/dist/namespace-launch_runs.d.mts +89 -0
- package/dist/namespace-launch_runs.mjs +133 -0
- package/dist/namespace-launches.d.mts +89 -0
- package/dist/namespace-launches.mjs +133 -0
- package/dist/namespace-operations.d.mts +45 -0
- package/dist/namespace-operations.mjs +52 -0
- package/dist/namespace-previews.d.mts +79 -0
- package/dist/namespace-previews.mjs +101 -0
- package/dist/namespace-pricing.d.mts +31 -0
- package/dist/namespace-pricing.mjs +22 -0
- package/dist/namespace-processes.d.mts +125 -0
- package/dist/namespace-processes.mjs +184 -0
- package/dist/namespace-provider_accounts.d.mts +156 -0
- package/dist/namespace-provider_accounts.mjs +241 -0
- package/dist/namespace-providers.d.mts +28 -0
- package/dist/namespace-providers.mjs +24 -0
- package/dist/namespace-routing.d.mts +64 -0
- package/dist/namespace-routing.mjs +86 -0
- package/dist/namespace-sandboxes.d.mts +287 -0
- package/dist/namespace-sandboxes.mjs +402 -0
- package/dist/namespace-secrets.d.mts +46 -0
- package/dist/namespace-secrets.mjs +68 -0
- package/dist/namespace-spend_limits.d.mts +48 -0
- package/dist/namespace-spend_limits.mjs +70 -0
- package/dist/namespace-terminals.d.mts +112 -0
- package/dist/namespace-terminals.mjs +177 -0
- package/dist/namespace-usage.d.mts +46 -0
- package/dist/namespace-usage.mjs +53 -0
- package/dist/namespace-volumes.d.mts +110 -0
- package/dist/namespace-volumes.mjs +269 -0
- package/dist/operations.d.ts +14 -0
- package/dist/operations.js +31 -0
- package/dist/retry.d.ts +8 -0
- package/dist/retry.js +63 -0
- package/dist/routing-choices.gen.d.ts +132 -0
- package/dist/routing-choices.gen.js +136 -0
- package/dist/routing.d.ts +23 -0
- package/dist/routing.js +38 -0
- package/dist/sandbox-handle.gen.d.ts +8 -0
- package/dist/sandbox-handle.gen.js +14 -0
- package/dist/sandboxes.d.ts +213 -0
- package/dist/sandboxes.js +507 -0
- package/dist/sdk.gen.d.ts +2029 -0
- package/dist/sdk.gen.js +3862 -0
- package/dist/server-timing.d.ts +19 -0
- package/dist/server-timing.gen.d.ts +265 -0
- package/dist/server-timing.gen.js +254 -0
- package/dist/server-timing.js +421 -0
- package/dist/spend-limits.d.ts +17 -0
- package/dist/spend-limits.js +26 -0
- package/dist/telemetry.d.ts +51 -0
- package/dist/telemetry.gen.d.ts +1 -0
- package/dist/telemetry.gen.js +5 -0
- package/dist/telemetry.js +438 -0
- package/dist/terminal.d.ts +61 -0
- package/dist/terminal.js +266 -0
- package/dist/transfer.d.ts +75 -0
- package/dist/transfer.js +389 -0
- package/dist/types.gen.d.ts +15016 -0
- package/dist/types.gen.js +3 -0
- package/dist/user-agent.d.ts +2 -0
- package/dist/user-agent.js +18 -0
- package/dist/version.gen.d.ts +1 -0
- package/dist/version.gen.js +5 -0
- package/dist/volumes.d.ts +33 -0
- package/dist/volumes.js +221 -0
- package/dist/waits.d.ts +31 -0
- package/dist/waits.js +42 -0
- package/dist/workflow-policy.gen.d.ts +41 -0
- package/dist/workflow-policy.gen.js +45 -0
- package/package.json +135 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = require("./compact.cjs")({"roots":{"validate0":{"$":0},"validate1":{"$":1},"validate2":{"$":1},"validate3":{"$":7},"validate4":{"$":8},"validate5":{"$":8},"validate6":{"$":12},"validate7":{"$":16},"validate8":{"$":17},"validate9":{"$":18}},"definitions":[{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$":1}},"next_cursor":{"type":["string","null"]},"stored_bytes":{"minimum":0,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}},"live_volume_policy":{"$":6},"allowance_bytes":{"minimum":0,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}},"gib_hours_this_month":{"minimum":0,"allOf":[{"anyOf":[{"type":"number"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}}}},{"type":"object","required":["id","name","state","labels","created_at","updated_at","last_used_at","head_checkpoint","checkpoint_count","stored_bytes","limits","attachments"],"properties":{"id":{"$":2},"name":{"$":3},"state":{"type":"string"},"labels":{"type":"object","additionalProperties":{"type":"string"}},"observed_volume_bytes":{"minimum":0,"allOf":[{"anyOf":[{"type":["integer","null"]},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"last_used_at":{"type":["string","null"],"format":"date-time"},"head_checkpoint":{"minimum":1,"allOf":[{"anyOf":[{"type":["integer","null"]},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":1}},"checkpoint_count":{"minimum":0,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}},"stored_bytes":{"minimum":0,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}},"limits":{"$":4},"attachments":{"type":"array","items":{"$":5}}}},{"type":"string","pattern":"^vol_[0-9a-f]{32}$"},{"type":"string","minLength":1,"maxLength":63,"pattern":"^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$"},{"type":"object","required":["max_checkpoints"],"properties":{"max_checkpoints":{"minimum":1,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":1}}}},{"type":"object","required":["sandbox_id","access","attached_at","restored_checkpoint"],"properties":{"sandbox_id":{"type":"string"},"access":{"type":"string","enum":["write","read","shared","branch"]},"attached_at":{"type":["string","null"],"format":"date-time"},"restored_checkpoint":{"minimum":1,"allOf":[{"anyOf":[{"type":["integer","null"]},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":1}}}},{"type":"object","required":["enabled","soft_quota_bytes"],"properties":{"enabled":{"type":"boolean"},"soft_quota_bytes":{"minimum":1,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":1}}}},{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$":8}},"next_cursor":{"type":["string","null"]}}},{"type":"object","required":["volume_id","checkpoint","state","created_at","reason","saved_on","image","arch","user","path","observed_volume_bytes","duration_ms","message"],"properties":{"volume_id":{"$":2},"checkpoint":{"minimum":1,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":1}},"state":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"reason":{"type":"string"},"saved_on":{"$":9},"image":{"$":10},"arch":{"type":"string","enum":["amd64","arm64"]},"user":{"$":11},"path":{"type":"string","pattern":"^/[^\\u0000]*$"},"observed_volume_bytes":{"minimum":0,"allOf":[{"anyOf":[{"type":["integer","null"]},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}},"duration_ms":{"minimum":0,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}},"message":{"type":["string","null"],"maxLength":500}}},{"type":"object","required":["sandbox_id","provider","class","region"],"properties":{"sandbox_id":{"type":"string"},"provider":{"type":"string"},"class":{"type":["string","null"]},"region":{"type":["string","null"]}}},{"type":"object","required":["value","digest"],"properties":{"value":{"type":"string"},"digest":{"type":["string","null"]}}},{"type":"object","required":["name","uid"],"properties":{"name":{"type":"string"},"uid":{"minimum":0,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}}}},{"type":"object","required":["id","volume_id","path","size","part_size","parts","expires_at"],"properties":{"id":{"$":13},"volume_id":{"$":2},"path":{"$":14},"size":{"minimum":0,"maximum":5497558138880,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0,"maximum":5497558138880}},"part_size":{"minimum":1,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":1}},"parts":{"type":"array","minItems":1,"maxItems":10000,"items":{"$":15}},"expires_at":{"type":"string","format":"date-time"}}},{"type":"string","pattern":"^vup_[0-9a-f]{32}$"},{"type":"string","minLength":1,"maxLength":1024,"pattern":"^(?!/)(?!.*//)(?!\\.{1,2}(?:/|$))(?!.*\\/\\.{1,2}(?:/|$))(?!.*\\u0000).+$"},{"type":"object","required":["number","size","url"],"properties":{"number":{"minimum":1,"maximum":10000,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":1,"maximum":10000}},"size":{"minimum":0,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}},"url":{"type":"string","format":"uri"}}},{"type":"object","required":["path","size"],"properties":{"path":{"$":14},"size":{"minimum":0,"maximum":5497558138880,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0,"maximum":5497558138880}}}},{"type":"object","required":["url","path","size","expires_at"],"properties":{"url":{"type":"string","format":"uri"},"path":{"$":14},"size":{"minimum":0,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}},"expires_at":{"type":"string","format":"date-time"}}},{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$":19}},"next_cursor":{"type":["string","null"]}}},{"type":"object","required":["path","size","modified_at"],"properties":{"path":{"$":14},"size":{"minimum":0,"allOf":[{"anyOf":[{"type":"integer"},{"x-boxrouter-bigint":true}]}],"x-boxrouter-bigint-range":{"minimum":0}},"modified_at":{"type":"string","format":"date-time"}}}]});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const validate0: (value: unknown) => boolean;
|
|
2
|
+
export declare const validate1: (value: unknown) => boolean;
|
|
3
|
+
export declare const validate2: (value: unknown) => boolean;
|
|
4
|
+
export declare const validate3: (value: unknown) => boolean;
|
|
5
|
+
export declare const validate4: (value: unknown) => boolean;
|
|
6
|
+
export declare const validate5: (value: unknown) => boolean;
|
|
7
|
+
export declare const validate6: (value: unknown) => boolean;
|
|
8
|
+
export declare const validate7: (value: unknown) => boolean;
|
|
9
|
+
export declare const validate8: (value: unknown) => boolean;
|
|
10
|
+
export declare const validate9: (value: unknown) => boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StreamHTTPError } from './streamErrors';
|
|
2
|
+
import type { Config } from './types.gen';
|
|
3
|
+
type EventValue<T> = T extends Record<string, unknown> ? T[keyof T] : T;
|
|
4
|
+
export interface StreamEvent<TData = unknown> {
|
|
5
|
+
data: TData;
|
|
6
|
+
event?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
}
|
|
9
|
+
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
|
|
12
|
+
onSseError?: (error: unknown) => void;
|
|
13
|
+
onSseEvent?: (event: TData) => void;
|
|
14
|
+
serializedBody?: RequestInit['body'];
|
|
15
|
+
/** Maximum SSE block bytes after CR/CRLF normalization, including fields and delimiters. */
|
|
16
|
+
sseMaxBufferSize?: number;
|
|
17
|
+
/** @internal Generated operation completion check, before successful EOF. */
|
|
18
|
+
validateStreamEnd?: () => void;
|
|
19
|
+
/** @internal Canonical generated path, before parameter substitution. */
|
|
20
|
+
telemetryPath?: string;
|
|
21
|
+
url: string;
|
|
22
|
+
};
|
|
23
|
+
export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
|
24
|
+
stream: AsyncGenerator<EventValue<TData>, TReturn, TNext>;
|
|
25
|
+
/** Interrupt pending reads and close this HTTP stream, without cancelling remote work. */
|
|
26
|
+
close: () => void;
|
|
27
|
+
};
|
|
28
|
+
export { StreamHTTPError };
|
|
29
|
+
/** One request, incremental SSE envelopes, no reconnect or mutation replay. */
|
|
30
|
+
export declare function createSseClient<TData = unknown>({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, fetch: fetchImplementation, serializedBody, sseMaxBufferSize, validateStreamEnd, telemetryPath, url, signal, ...options }: ServerSentEventsOptions): ServerSentEventsResult<TData>;
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamHTTPError = void 0;
|
|
4
|
+
exports.createSseClient = createSseClient;
|
|
5
|
+
const eventsource_parser_1 = require("eventsource-parser");
|
|
6
|
+
const api_1 = require("@opentelemetry/api");
|
|
7
|
+
const json_1 = require("./json");
|
|
8
|
+
const api_error_1 = require("../api-error");
|
|
9
|
+
const streamErrors_1 = require("./streamErrors");
|
|
10
|
+
Object.defineProperty(exports, "StreamHTTPError", { enumerable: true, get: function () { return streamErrors_1.StreamHTTPError; } });
|
|
11
|
+
const telemetry_1 = require("../telemetry");
|
|
12
|
+
const workflow_policy_gen_1 = require("../workflow-policy.gen");
|
|
13
|
+
function monotonicMilliseconds() {
|
|
14
|
+
try {
|
|
15
|
+
const performance = globalThis.performance;
|
|
16
|
+
const value = performance?.now?.call(performance);
|
|
17
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Bound raw bytes before text decoding or the library can buffer a partial event. */
|
|
24
|
+
function boundedInput(limit) {
|
|
25
|
+
let size = 0;
|
|
26
|
+
let lineBytes = 0;
|
|
27
|
+
let skipLf = false;
|
|
28
|
+
return new TransformStream({
|
|
29
|
+
transform(chunk, controller) {
|
|
30
|
+
for (const byte of chunk) {
|
|
31
|
+
if (byte === 10 && skipLf) {
|
|
32
|
+
skipLf = false;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (++size > limit)
|
|
36
|
+
throw Object.assign(new RangeError(`SSE block exceeds ${limit} normalized bytes`), { type: 'max-buffer-size-exceeded' });
|
|
37
|
+
if (byte === 10 || byte === 13) {
|
|
38
|
+
if (lineBytes === 0)
|
|
39
|
+
size = 0;
|
|
40
|
+
lineBytes = 0;
|
|
41
|
+
skipLf = byte === 13;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
skipLf = false;
|
|
45
|
+
lineBytes++;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
controller.enqueue(chunk);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function eventParser(maxBufferSize) {
|
|
53
|
+
let parser;
|
|
54
|
+
let lastId;
|
|
55
|
+
return new TransformStream({
|
|
56
|
+
start(controller) {
|
|
57
|
+
parser = (0, eventsource_parser_1.createParser)({
|
|
58
|
+
maxBufferSize,
|
|
59
|
+
onId(id) { lastId = id; },
|
|
60
|
+
onEvent(event) {
|
|
61
|
+
// Snapshot the cursor before later blocks in this chunk can update it.
|
|
62
|
+
controller.enqueue({ ...event, id: lastId });
|
|
63
|
+
},
|
|
64
|
+
onError(error) {
|
|
65
|
+
if (error.type === 'max-buffer-size-exceeded')
|
|
66
|
+
controller.error(error);
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
transform(chunk) { parser.feed(chunk); },
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async function httpError(request, response, signal) {
|
|
74
|
+
const reader = response.body?.getReader();
|
|
75
|
+
const abort = () => { void reader?.cancel(signal.reason).catch(() => { }); };
|
|
76
|
+
const buffer = new Uint8Array(workflow_policy_gen_1.MAX_ERROR_BYTES);
|
|
77
|
+
let length = 0;
|
|
78
|
+
let truncated = false;
|
|
79
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
80
|
+
try {
|
|
81
|
+
if (signal.aborted)
|
|
82
|
+
abort();
|
|
83
|
+
signal.throwIfAborted();
|
|
84
|
+
if (reader) {
|
|
85
|
+
while (true) {
|
|
86
|
+
const { done, value } = await reader.read();
|
|
87
|
+
signal.throwIfAborted();
|
|
88
|
+
if (done)
|
|
89
|
+
break;
|
|
90
|
+
const remaining = workflow_policy_gen_1.MAX_ERROR_BYTES - length;
|
|
91
|
+
buffer.set(value.subarray(0, remaining), length);
|
|
92
|
+
length += Math.min(value.byteLength, remaining);
|
|
93
|
+
if (value.byteLength > remaining) {
|
|
94
|
+
truncated = true;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
signal.removeEventListener('abort', abort);
|
|
102
|
+
if (reader) {
|
|
103
|
+
await reader.cancel().catch(() => { });
|
|
104
|
+
reader.releaseLock();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Fetch supplies decoded bytes. Keep upstream headers for diagnostics; their
|
|
108
|
+
// Content-Length describes the original response, not the bounded body copy.
|
|
109
|
+
const captured = new Response(length ? buffer.slice(0, length) : null, {
|
|
110
|
+
status: response.status, statusText: response.statusText, headers: response.headers,
|
|
111
|
+
});
|
|
112
|
+
let payload;
|
|
113
|
+
try {
|
|
114
|
+
payload = (0, json_1.parseJson)(new TextDecoder().decode(buffer.subarray(0, length)));
|
|
115
|
+
}
|
|
116
|
+
catch { /* Malformed diagnostics do not replace the HTTP failure. */ }
|
|
117
|
+
return new streamErrors_1.StreamHTTPError(request, captured, truncated, payload);
|
|
118
|
+
}
|
|
119
|
+
/** One request, incremental SSE envelopes, no reconnect or mutation replay. */
|
|
120
|
+
function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, fetch: fetchImplementation = globalThis.fetch, serializedBody, sseMaxBufferSize = workflow_policy_gen_1.DEFAULT_EVENT_BYTES, validateStreamEnd, telemetryPath, url, signal, ...options }) {
|
|
121
|
+
const controller = new AbortController();
|
|
122
|
+
const parent = api_1.context.active();
|
|
123
|
+
async function* receive() {
|
|
124
|
+
let reader;
|
|
125
|
+
let pipes = [];
|
|
126
|
+
let response;
|
|
127
|
+
let request;
|
|
128
|
+
const telemetry = new telemetry_1.RequestTrace(options.method, telemetryPath, parent);
|
|
129
|
+
let completed = false;
|
|
130
|
+
let failed = false;
|
|
131
|
+
let events = 0;
|
|
132
|
+
let eventProcessingChecked = false;
|
|
133
|
+
let eventProcessingRecording = false;
|
|
134
|
+
let eventProcessingMeasured = true;
|
|
135
|
+
let eventProcessingMilliseconds = 0;
|
|
136
|
+
let firstEventReadyStarted;
|
|
137
|
+
let firstEventReadyMeasured = true;
|
|
138
|
+
let firstEventReadyMilliseconds;
|
|
139
|
+
const abort = () => controller.abort(signal?.reason);
|
|
140
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
141
|
+
try {
|
|
142
|
+
if (signal?.aborted)
|
|
143
|
+
abort();
|
|
144
|
+
controller.signal.throwIfAborted();
|
|
145
|
+
if (!Number.isSafeInteger(sseMaxBufferSize) || sseMaxBufferSize < 1) {
|
|
146
|
+
throw new RangeError('sseMaxBufferSize must be a positive safe integer');
|
|
147
|
+
}
|
|
148
|
+
const headers = new Headers(options.headers);
|
|
149
|
+
if (!headers.has('Accept'))
|
|
150
|
+
headers.set('Accept', 'text/event-stream');
|
|
151
|
+
const init = {
|
|
152
|
+
redirect: 'error', ...options, headers, body: serializedBody, signal: controller.signal,
|
|
153
|
+
};
|
|
154
|
+
request = onRequest ? await onRequest(url, init) : new Request(url, init);
|
|
155
|
+
controller.signal.throwIfAborted();
|
|
156
|
+
telemetry.inject(request.headers);
|
|
157
|
+
const sentRequest = request;
|
|
158
|
+
response = await telemetry.fetchResponse(() => api_1.context.with(telemetry.context, () => fetchImplementation(sentRequest)));
|
|
159
|
+
telemetry.response(response);
|
|
160
|
+
if (!response.ok) {
|
|
161
|
+
throw await httpError(request, response, controller.signal);
|
|
162
|
+
}
|
|
163
|
+
if (response.headers.get('content-type')?.split(';', 1)[0].trim().toLowerCase() !== 'text/event-stream') {
|
|
164
|
+
throw new streamErrors_1.StreamParseError('Expected text/event-stream response');
|
|
165
|
+
}
|
|
166
|
+
if (!response.body)
|
|
167
|
+
throw new streamErrors_1.StreamParseError('Missing event stream body');
|
|
168
|
+
telemetry.finishObserverOutcome('success');
|
|
169
|
+
telemetry.startStreamLifetime();
|
|
170
|
+
const bounded = boundedInput(sseMaxBufferSize);
|
|
171
|
+
const decoder = new TextDecoderStream('utf-8', { fatal: true });
|
|
172
|
+
const parser = eventParser(sseMaxBufferSize);
|
|
173
|
+
if (!eventProcessingChecked) {
|
|
174
|
+
eventProcessingChecked = true;
|
|
175
|
+
try {
|
|
176
|
+
eventProcessingRecording = telemetry.span.isRecording();
|
|
177
|
+
}
|
|
178
|
+
catch { /* Optional timing observation. */ }
|
|
179
|
+
}
|
|
180
|
+
if (eventProcessingRecording) {
|
|
181
|
+
firstEventReadyStarted = monotonicMilliseconds();
|
|
182
|
+
if (firstEventReadyStarted === undefined)
|
|
183
|
+
firstEventReadyMeasured = false;
|
|
184
|
+
}
|
|
185
|
+
pipes = [
|
|
186
|
+
response.body.pipeTo(bounded.writable, { signal: controller.signal }),
|
|
187
|
+
bounded.readable.pipeTo(decoder.writable, { signal: controller.signal }),
|
|
188
|
+
decoder.readable.pipeTo(parser.writable, { signal: controller.signal }),
|
|
189
|
+
].map(pipe => pipe.catch(() => { })); // Reader errors retain the original failure.
|
|
190
|
+
reader = parser.readable.getReader();
|
|
191
|
+
while (true) {
|
|
192
|
+
const { done, value } = await reader.read();
|
|
193
|
+
controller.signal.throwIfAborted();
|
|
194
|
+
if (done) {
|
|
195
|
+
validateStreamEnd?.();
|
|
196
|
+
completed = true;
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const processingStarted = eventProcessingRecording ? monotonicMilliseconds() : undefined;
|
|
200
|
+
if (eventProcessingRecording && processingStarted === undefined)
|
|
201
|
+
eventProcessingMeasured = false;
|
|
202
|
+
let skip = false;
|
|
203
|
+
let event;
|
|
204
|
+
try {
|
|
205
|
+
event = {
|
|
206
|
+
data: (0, json_1.parseJson)(value.data),
|
|
207
|
+
...(value.event === undefined ? {} : { event: value.event }),
|
|
208
|
+
...(value.id === undefined ? {} : { id: value.id }),
|
|
209
|
+
};
|
|
210
|
+
if (responseValidator) {
|
|
211
|
+
try {
|
|
212
|
+
await responseValidator(event);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
if (error instanceof streamErrors_1.UnknownEventKind)
|
|
216
|
+
skip = true;
|
|
217
|
+
else
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (!skip) {
|
|
222
|
+
if (responseTransformer)
|
|
223
|
+
event = await responseTransformer(event);
|
|
224
|
+
if (firstEventReadyStarted !== undefined && firstEventReadyMeasured && firstEventReadyMilliseconds === undefined) {
|
|
225
|
+
const ready = monotonicMilliseconds();
|
|
226
|
+
if (ready === undefined || ready < firstEventReadyStarted ||
|
|
227
|
+
(processingStarted !== undefined && ready < processingStarted)) {
|
|
228
|
+
firstEventReadyMeasured = false;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
const elapsed = ready - firstEventReadyStarted;
|
|
232
|
+
if (Number.isFinite(elapsed))
|
|
233
|
+
firstEventReadyMilliseconds = elapsed;
|
|
234
|
+
else
|
|
235
|
+
firstEventReadyMeasured = false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
onSseEvent?.(event);
|
|
239
|
+
events++;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
if (eventProcessingRecording) {
|
|
244
|
+
const processingFinished = monotonicMilliseconds();
|
|
245
|
+
if (processingStarted === undefined || processingFinished === undefined || processingFinished < processingStarted) {
|
|
246
|
+
eventProcessingMeasured = false;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
eventProcessingMilliseconds += processingFinished - processingStarted;
|
|
250
|
+
if (!Number.isFinite(eventProcessingMilliseconds))
|
|
251
|
+
eventProcessingMeasured = false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (skip)
|
|
256
|
+
continue;
|
|
257
|
+
yield event;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
failed = !controller.signal.aborted || (0, telemetry_1.isTimeoutError)(controller.signal.reason);
|
|
262
|
+
if (failed)
|
|
263
|
+
telemetry.error(error);
|
|
264
|
+
try {
|
|
265
|
+
const outcome = telemetry.responseOutcome(error);
|
|
266
|
+
telemetry.finishRequestPreparationOutcome(outcome);
|
|
267
|
+
telemetry.finishObserverOutcome(outcome);
|
|
268
|
+
}
|
|
269
|
+
catch { /* Preserve the caller's original failure. */ }
|
|
270
|
+
// Observation hooks cannot turn a failed stream into successful iteration.
|
|
271
|
+
const failure = (0, api_error_1.requestFailure)(error, request, response);
|
|
272
|
+
try {
|
|
273
|
+
onSseError?.(failure);
|
|
274
|
+
}
|
|
275
|
+
finally {
|
|
276
|
+
throw failure;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
finally {
|
|
280
|
+
signal?.removeEventListener('abort', abort);
|
|
281
|
+
if (reader) {
|
|
282
|
+
await reader.cancel().catch(() => { });
|
|
283
|
+
reader.releaseLock();
|
|
284
|
+
await Promise.all(pipes);
|
|
285
|
+
}
|
|
286
|
+
else if (response?.ok) {
|
|
287
|
+
await response.body?.cancel().catch(() => { });
|
|
288
|
+
}
|
|
289
|
+
// Failed HTTP bodies are closed; only a bounded diagnostic copy is retained.
|
|
290
|
+
telemetry.span.setAttribute('boxrouter.stream.events', events);
|
|
291
|
+
telemetry.span.setAttribute('boxrouter.stream.end', completed ? 'completed' : failed ? 'error' : 'cancelled');
|
|
292
|
+
// Sum only local decode/validation/transform/callback intervals. Reader and caller waits stay out.
|
|
293
|
+
if (eventProcessingRecording && eventProcessingMeasured) {
|
|
294
|
+
try {
|
|
295
|
+
telemetry.span.setAttribute('boxrouter.stream.event_processing_ms', eventProcessingMilliseconds);
|
|
296
|
+
}
|
|
297
|
+
catch { /* Preserve the stream result. */ }
|
|
298
|
+
}
|
|
299
|
+
if (eventProcessingRecording && firstEventReadyMeasured && firstEventReadyMilliseconds !== undefined) {
|
|
300
|
+
try {
|
|
301
|
+
telemetry.span.setAttribute('boxrouter.stream.first_event_ready_ms', firstEventReadyMilliseconds);
|
|
302
|
+
}
|
|
303
|
+
catch { /* Preserve the stream result. */ }
|
|
304
|
+
}
|
|
305
|
+
telemetry.finishStreamLifetime(completed ? 'success' : failed ? 'stream_error' : 'stream_cancelled');
|
|
306
|
+
telemetry.span.end();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
stream: receive(),
|
|
311
|
+
close: () => controller.abort(new DOMException('Stream closed', 'AbortError')),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { APIError } from '../api-error';
|
|
2
|
+
export declare class StreamValidationError extends TypeError {
|
|
3
|
+
readonly schema: string;
|
|
4
|
+
readonly issues: ReadonlyArray<{
|
|
5
|
+
instancePath: string;
|
|
6
|
+
keyword: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
}>;
|
|
9
|
+
constructor(schema: string, issues: ReadonlyArray<{
|
|
10
|
+
instancePath: string;
|
|
11
|
+
keyword: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
}>);
|
|
14
|
+
}
|
|
15
|
+
/** An event of a kind this client does not know; the stream skips it. Never thrown to callers. */
|
|
16
|
+
export declare class UnknownEventKind extends Error {
|
|
17
|
+
readonly kind: string;
|
|
18
|
+
constructor(kind: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class IncompleteStream extends Error {
|
|
21
|
+
constructor();
|
|
22
|
+
}
|
|
23
|
+
/** A successful HTTP response that cannot be consumed as the requested stream. */
|
|
24
|
+
export declare class StreamParseError extends TypeError {
|
|
25
|
+
readonly code = "parse_error";
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class StreamHTTPError extends APIError {
|
|
29
|
+
readonly bodyTruncated: boolean;
|
|
30
|
+
readonly request: Request;
|
|
31
|
+
constructor(request: Request, response: Response, bodyTruncated?: boolean, payload?: unknown);
|
|
32
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamHTTPError = exports.StreamParseError = exports.IncompleteStream = exports.UnknownEventKind = exports.StreamValidationError = void 0;
|
|
4
|
+
const api_error_1 = require("../api-error");
|
|
5
|
+
// One definition for every generated surface, so callers catch the same classes.
|
|
6
|
+
class StreamValidationError extends TypeError {
|
|
7
|
+
schema;
|
|
8
|
+
issues;
|
|
9
|
+
constructor(schema, issues) {
|
|
10
|
+
super(`Event does not match ${schema}`);
|
|
11
|
+
this.schema = schema;
|
|
12
|
+
this.issues = issues;
|
|
13
|
+
this.name = 'StreamValidationError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.StreamValidationError = StreamValidationError;
|
|
17
|
+
/** An event of a kind this client does not know; the stream skips it. Never thrown to callers. */
|
|
18
|
+
class UnknownEventKind extends Error {
|
|
19
|
+
kind;
|
|
20
|
+
constructor(kind) {
|
|
21
|
+
super(`Skipped an event of unknown kind ${JSON.stringify(kind)}`);
|
|
22
|
+
this.kind = kind;
|
|
23
|
+
this.name = 'UnknownEventKind';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.UnknownEventKind = UnknownEventKind;
|
|
27
|
+
class IncompleteStream extends Error {
|
|
28
|
+
constructor() {
|
|
29
|
+
super('Stream ended before a terminal event');
|
|
30
|
+
this.name = 'IncompleteStream';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.IncompleteStream = IncompleteStream;
|
|
34
|
+
/** A successful HTTP response that cannot be consumed as the requested stream. */
|
|
35
|
+
class StreamParseError extends TypeError {
|
|
36
|
+
code = 'parse_error';
|
|
37
|
+
constructor(message) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = 'StreamParseError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.StreamParseError = StreamParseError;
|
|
43
|
+
class StreamHTTPError extends api_error_1.APIError {
|
|
44
|
+
bodyTruncated;
|
|
45
|
+
constructor(request, response, bodyTruncated = false, payload) {
|
|
46
|
+
super(payload, response, request, 'Stream request failed.');
|
|
47
|
+
this.bodyTruncated = bodyTruncated;
|
|
48
|
+
this.name = 'StreamHTTPError';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.StreamHTTPError = StreamHTTPError;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Auth, AuthToken } from './auth.gen';
|
|
2
|
+
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen';
|
|
3
|
+
export type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
|
|
4
|
+
export type Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the final request URL.
|
|
7
|
+
*/
|
|
8
|
+
buildUrl: BuildUrlFn;
|
|
9
|
+
getConfig: () => Config;
|
|
10
|
+
request: RequestFn;
|
|
11
|
+
setConfig: (config: Config) => Config;
|
|
12
|
+
} & {
|
|
13
|
+
[K in HttpMethod]: MethodFn;
|
|
14
|
+
} & ([SseFn] extends [never] ? {
|
|
15
|
+
sse?: never;
|
|
16
|
+
} : {
|
|
17
|
+
sse: {
|
|
18
|
+
[K in HttpMethod]: SseFn;
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
export interface Config {
|
|
22
|
+
/**
|
|
23
|
+
* Auth token or a function returning auth token. The resolved value will be
|
|
24
|
+
* added to the request payload as defined by its `security` array.
|
|
25
|
+
*/
|
|
26
|
+
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
|
|
27
|
+
/**
|
|
28
|
+
* A function for serializing request body parameter. By default,
|
|
29
|
+
* {@link JSON.stringify()} will be used.
|
|
30
|
+
*/
|
|
31
|
+
bodySerializer?: BodySerializer | null;
|
|
32
|
+
/**
|
|
33
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
34
|
+
* `Headers` object with.
|
|
35
|
+
*
|
|
36
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
37
|
+
*/
|
|
38
|
+
headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* The request method.
|
|
41
|
+
*
|
|
42
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
43
|
+
*/
|
|
44
|
+
method?: Uppercase<HttpMethod>;
|
|
45
|
+
/**
|
|
46
|
+
* A function for serializing request query parameters. By default, arrays
|
|
47
|
+
* will be exploded in form style, objects will be exploded in deepObject
|
|
48
|
+
* style, and reserved characters are percent-encoded.
|
|
49
|
+
*
|
|
50
|
+
* This method will have no effect if the native `paramsSerializer()` Axios
|
|
51
|
+
* API function is used.
|
|
52
|
+
*
|
|
53
|
+
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
|
54
|
+
*/
|
|
55
|
+
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
|
56
|
+
/**
|
|
57
|
+
* A function validating request data. This is useful if you want to ensure
|
|
58
|
+
* the request conforms to the desired shape, so it can be safely sent to
|
|
59
|
+
* the server.
|
|
60
|
+
*/
|
|
61
|
+
requestValidator?: (data: unknown) => Promise<unknown>;
|
|
62
|
+
/**
|
|
63
|
+
* A function transforming response data before it's returned. This is useful
|
|
64
|
+
* for post-processing data, e.g., converting ISO strings into Date objects.
|
|
65
|
+
*/
|
|
66
|
+
responseTransformer?: (data: unknown) => Promise<unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* A function validating response data. This is useful if you want to ensure
|
|
69
|
+
* the response conforms to the desired shape, so it can be safely passed to
|
|
70
|
+
* the transformers and returned to the user.
|
|
71
|
+
*/
|
|
72
|
+
responseValidator?: (data: unknown) => Promise<unknown>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Arbitrary metadata passed through the `meta` request option.
|
|
76
|
+
*/
|
|
77
|
+
export interface ClientMeta {
|
|
78
|
+
}
|
|
79
|
+
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] ? true : [T] extends [never | undefined] ? [undefined] extends [T] ? false : true : false;
|
|
80
|
+
export type OmitNever<T extends Record<string, unknown>> = {
|
|
81
|
+
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
|
|
82
|
+
};
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
|
|
2
|
+
export interface PathSerializer {
|
|
3
|
+
path: Record<string, unknown>;
|
|
4
|
+
url: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const PATH_PARAM_RE: RegExp;
|
|
7
|
+
export declare const defaultPathSerializer: ({ path, url: _url }: PathSerializer) => string;
|
|
8
|
+
export declare const getUrl: ({ baseUrl, path, query, querySerializer, url: _url, }: {
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
path?: Record<string, unknown>;
|
|
11
|
+
query?: Record<string, unknown>;
|
|
12
|
+
querySerializer: QuerySerializer;
|
|
13
|
+
url: string;
|
|
14
|
+
}) => string;
|
|
15
|
+
export declare function getValidRequestBody(options: {
|
|
16
|
+
body?: unknown;
|
|
17
|
+
bodySerializer?: BodySerializer | null;
|
|
18
|
+
serializedBody?: unknown;
|
|
19
|
+
}): unknown;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getUrl = exports.defaultPathSerializer = exports.PATH_PARAM_RE = void 0;
|
|
5
|
+
exports.getValidRequestBody = getValidRequestBody;
|
|
6
|
+
const pathSerializer_gen_1 = require("./pathSerializer.gen");
|
|
7
|
+
exports.PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
8
|
+
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
9
|
+
let url = _url;
|
|
10
|
+
const matches = _url.match(exports.PATH_PARAM_RE);
|
|
11
|
+
if (matches) {
|
|
12
|
+
for (const match of matches) {
|
|
13
|
+
let explode = false;
|
|
14
|
+
let name = match.substring(1, match.length - 1);
|
|
15
|
+
let style = 'simple';
|
|
16
|
+
if (name.endsWith('*')) {
|
|
17
|
+
explode = true;
|
|
18
|
+
name = name.substring(0, name.length - 1);
|
|
19
|
+
}
|
|
20
|
+
if (name.startsWith('.')) {
|
|
21
|
+
name = name.substring(1);
|
|
22
|
+
style = 'label';
|
|
23
|
+
}
|
|
24
|
+
else if (name.startsWith(';')) {
|
|
25
|
+
name = name.substring(1);
|
|
26
|
+
style = 'matrix';
|
|
27
|
+
}
|
|
28
|
+
const value = path[name];
|
|
29
|
+
if (value === undefined || value === null) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(value)) {
|
|
33
|
+
url = url.replace(match, (0, pathSerializer_gen_1.serializeArrayParam)({ explode, name, style, value }));
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'object') {
|
|
37
|
+
url = url.replace(match, (0, pathSerializer_gen_1.serializeObjectParam)({
|
|
38
|
+
explode,
|
|
39
|
+
name,
|
|
40
|
+
style,
|
|
41
|
+
value: value,
|
|
42
|
+
valueOnly: true,
|
|
43
|
+
}));
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (style === 'matrix') {
|
|
47
|
+
url = url.replace(match, `;${(0, pathSerializer_gen_1.serializePrimitiveParam)({
|
|
48
|
+
name,
|
|
49
|
+
value: value,
|
|
50
|
+
})}`);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
|
|
54
|
+
url = url.replace(match, replaceValue);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return url;
|
|
58
|
+
};
|
|
59
|
+
exports.defaultPathSerializer = defaultPathSerializer;
|
|
60
|
+
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
61
|
+
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
62
|
+
let url = (baseUrl ?? '') + pathUrl;
|
|
63
|
+
if (path) {
|
|
64
|
+
url = (0, exports.defaultPathSerializer)({ path, url });
|
|
65
|
+
}
|
|
66
|
+
let search = query ? querySerializer(query) : '';
|
|
67
|
+
if (search.startsWith('?')) {
|
|
68
|
+
search = search.substring(1);
|
|
69
|
+
}
|
|
70
|
+
if (search) {
|
|
71
|
+
url += `?${search}`;
|
|
72
|
+
}
|
|
73
|
+
return url;
|
|
74
|
+
};
|
|
75
|
+
exports.getUrl = getUrl;
|
|
76
|
+
function getValidRequestBody(options) {
|
|
77
|
+
const hasBody = options.body !== undefined;
|
|
78
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
79
|
+
if (isSerializedBody) {
|
|
80
|
+
if ('serializedBody' in options) {
|
|
81
|
+
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== '';
|
|
82
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
83
|
+
}
|
|
84
|
+
// not all clients implement a serializedBody property (i.e., client-axios)
|
|
85
|
+
return options.body !== '' ? options.body : null;
|
|
86
|
+
}
|
|
87
|
+
// plain/text body
|
|
88
|
+
if (hasBody) {
|
|
89
|
+
return options.body;
|
|
90
|
+
}
|
|
91
|
+
// no body was provided
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|