openai 7.16.0 → 7.17.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 +28 -0
- package/_vendor/zod-to-json-schema/Options.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/Options.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/Options.js +2 -0
- package/_vendor/zod-to-json-schema/Options.js.map +1 -1
- package/_vendor/zod-to-json-schema/Options.mjs +2 -0
- package/_vendor/zod-to-json-schema/Options.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parseDef.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parseDef.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parseDef.js +1 -0
- package/_vendor/zod-to-json-schema/parseDef.js.map +1 -1
- package/_vendor/zod-to-json-schema/parseDef.mjs +1 -0
- package/_vendor/zod-to-json-schema/parseDef.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/bigint.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/bigint.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/bigint.js +2 -0
- package/_vendor/zod-to-json-schema/parsers/bigint.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/bigint.mjs +2 -0
- package/_vendor/zod-to-json-schema/parsers/bigint.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/literal.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/literal.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/literal.js +1 -0
- package/_vendor/zod-to-json-schema/parsers/literal.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/literal.mjs +1 -0
- package/_vendor/zod-to-json-schema/parsers/literal.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/null.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/null.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/null.js +1 -0
- package/_vendor/zod-to-json-schema/parsers/null.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/null.mjs +1 -0
- package/_vendor/zod-to-json-schema/parsers/null.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/nullable.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/nullable.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/nullable.js +4 -0
- package/_vendor/zod-to-json-schema/parsers/nullable.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/nullable.mjs +4 -0
- package/_vendor/zod-to-json-schema/parsers/nullable.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/number.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/number.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/number.js +2 -0
- package/_vendor/zod-to-json-schema/parsers/number.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/number.mjs +2 -0
- package/_vendor/zod-to-json-schema/parsers/number.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/optional.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/optional.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/optional.js +6 -7
- package/_vendor/zod-to-json-schema/parsers/optional.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/optional.mjs +6 -7
- package/_vendor/zod-to-json-schema/parsers/optional.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/record.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/record.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/record.js +2 -0
- package/_vendor/zod-to-json-schema/parsers/record.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/record.mjs +2 -0
- package/_vendor/zod-to-json-schema/parsers/record.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/string.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/string.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/string.js +1 -0
- package/_vendor/zod-to-json-schema/parsers/string.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/string.mjs +1 -0
- package/_vendor/zod-to-json-schema/parsers/string.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/union.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/union.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/union.js +3 -0
- package/_vendor/zod-to-json-schema/parsers/union.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/union.mjs +3 -0
- package/_vendor/zod-to-json-schema/parsers/union.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/util.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/util.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/util.js +1 -0
- package/_vendor/zod-to-json-schema/util.js.map +1 -1
- package/_vendor/zod-to-json-schema/util.mjs +1 -0
- package/_vendor/zod-to-json-schema/util.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/zodToJsonSchema.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/zodToJsonSchema.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/zodToJsonSchema.js +2 -0
- package/_vendor/zod-to-json-schema/zodToJsonSchema.js.map +1 -1
- package/_vendor/zod-to-json-schema/zodToJsonSchema.mjs +2 -0
- package/_vendor/zod-to-json-schema/zodToJsonSchema.mjs.map +1 -1
- package/auth/subject-token-providers.d.mts.map +1 -1
- package/auth/subject-token-providers.d.ts.map +1 -1
- package/auth/subject-token-providers.js +6 -1
- package/auth/subject-token-providers.js.map +1 -1
- package/auth/subject-token-providers.mjs +6 -1
- package/auth/subject-token-providers.mjs.map +1 -1
- package/auth/workload-identity-auth.d.mts.map +1 -1
- package/auth/workload-identity-auth.d.ts.map +1 -1
- package/auth/workload-identity-auth.js +9 -0
- package/auth/workload-identity-auth.js.map +1 -1
- package/auth/workload-identity-auth.mjs +9 -0
- package/auth/workload-identity-auth.mjs.map +1 -1
- package/auth/x509-transport.d.mts.map +1 -1
- package/auth/x509-transport.d.ts.map +1 -1
- package/auth/x509-transport.js +11 -0
- package/auth/x509-transport.js.map +1 -1
- package/auth/x509-transport.mjs +11 -0
- package/auth/x509-transport.mjs.map +1 -1
- package/azure.d.mts.map +1 -1
- package/azure.d.ts.map +1 -1
- package/azure.js +3 -0
- package/azure.js.map +1 -1
- package/azure.mjs +3 -0
- package/azure.mjs.map +1 -1
- package/bedrock.d.mts.map +1 -1
- package/bedrock.d.ts.map +1 -1
- package/bedrock.js +5 -0
- package/bedrock.js.map +1 -1
- package/bedrock.mjs +5 -0
- package/bedrock.mjs.map +1 -1
- package/beta/realtime/internal-base.d.mts.map +1 -1
- package/beta/realtime/internal-base.d.ts.map +1 -1
- package/beta/realtime/internal-base.js +1 -0
- package/beta/realtime/internal-base.js.map +1 -1
- package/beta/realtime/internal-base.mjs +1 -0
- package/beta/realtime/internal-base.mjs.map +1 -1
- package/beta/realtime/websocket.d.mts.map +1 -1
- package/beta/realtime/websocket.d.ts.map +1 -1
- package/beta/realtime/websocket.js +9 -1
- package/beta/realtime/websocket.js.map +1 -1
- package/beta/realtime/websocket.mjs +9 -1
- package/beta/realtime/websocket.mjs.map +1 -1
- package/beta/realtime/ws.d.mts.map +1 -1
- package/beta/realtime/ws.d.ts.map +1 -1
- package/beta/realtime/ws.js +3 -0
- package/beta/realtime/ws.js.map +1 -1
- package/beta/realtime/ws.mjs +3 -0
- package/beta/realtime/ws.mjs.map +1 -1
- package/client.d.mts +1 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +1 -0
- package/client.d.ts.map +1 -1
- package/client.js +27 -6
- package/client.js.map +1 -1
- package/client.mjs +27 -6
- package/client.mjs.map +1 -1
- package/core/EventEmitter.d.mts.map +1 -1
- package/core/EventEmitter.d.ts.map +1 -1
- package/core/EventEmitter.js +15 -0
- package/core/EventEmitter.js.map +1 -1
- package/core/EventEmitter.mjs +15 -0
- package/core/EventEmitter.mjs.map +1 -1
- package/core/streaming.d.mts +1 -0
- package/core/streaming.d.mts.map +1 -1
- package/core/streaming.d.ts +1 -0
- package/core/streaming.d.ts.map +1 -1
- package/core/streaming.js +28 -1
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +28 -1
- package/core/streaming.mjs.map +1 -1
- package/helpers/audio.d.mts.map +1 -1
- package/helpers/audio.d.ts.map +1 -1
- package/helpers/audio.js +2 -0
- package/helpers/audio.js.map +1 -1
- package/helpers/audio.mjs +2 -0
- package/helpers/audio.mjs.map +1 -1
- package/helpers/standard-schema.d.mts.map +1 -1
- package/helpers/standard-schema.d.ts.map +1 -1
- package/helpers/standard-schema.js +28 -18
- package/helpers/standard-schema.js.map +1 -1
- package/helpers/standard-schema.mjs +28 -18
- package/helpers/standard-schema.mjs.map +1 -1
- package/helpers/zod-v3-strict-schema.d.mts.map +1 -1
- package/helpers/zod-v3-strict-schema.d.ts.map +1 -1
- package/helpers/zod-v3-strict-schema.js +5 -0
- package/helpers/zod-v3-strict-schema.js.map +1 -1
- package/helpers/zod-v3-strict-schema.mjs +5 -0
- package/helpers/zod-v3-strict-schema.mjs.map +1 -1
- package/helpers/zod.d.mts.map +1 -1
- package/helpers/zod.d.ts.map +1 -1
- package/helpers/zod.js +16 -1
- package/helpers/zod.js.map +1 -1
- package/helpers/zod.mjs +17 -2
- package/helpers/zod.mjs.map +1 -1
- package/internal/assistant-stream-delta.d.mts.map +1 -1
- package/internal/assistant-stream-delta.d.ts.map +1 -1
- package/internal/assistant-stream-delta.js +8 -1
- package/internal/assistant-stream-delta.js.map +1 -1
- package/internal/assistant-stream-delta.mjs +8 -1
- package/internal/assistant-stream-delta.mjs.map +1 -1
- package/internal/auth/x509-credential-options.d.mts.map +1 -1
- package/internal/auth/x509-credential-options.d.ts.map +1 -1
- package/internal/auth/x509-credential-options.js +3 -0
- package/internal/auth/x509-credential-options.js.map +1 -1
- package/internal/auth/x509-credential-options.mjs +3 -0
- package/internal/auth/x509-credential-options.mjs.map +1 -1
- package/internal/auth/x509-token-exchange.d.mts.map +1 -1
- package/internal/auth/x509-token-exchange.d.ts.map +1 -1
- package/internal/auth/x509-token-exchange.js +2 -0
- package/internal/auth/x509-token-exchange.js.map +1 -1
- package/internal/auth/x509-token-exchange.mjs +2 -0
- package/internal/auth/x509-token-exchange.mjs.map +1 -1
- package/internal/auth/x509-transport-capability.d.mts.map +1 -1
- package/internal/auth/x509-transport-capability.d.ts.map +1 -1
- package/internal/auth/x509-transport-capability.js +1 -0
- package/internal/auth/x509-transport-capability.js.map +1 -1
- package/internal/auth/x509-transport-capability.mjs +1 -0
- package/internal/auth/x509-transport-capability.mjs.map +1 -1
- package/internal/auth/x509-transport-state.mjs +1 -0
- package/internal/auth/x509-workload-identity-auth.d.mts.map +1 -1
- package/internal/auth/x509-workload-identity-auth.d.ts.map +1 -1
- package/internal/auth/x509-workload-identity-auth.js +11 -0
- package/internal/auth/x509-workload-identity-auth.js.map +1 -1
- package/internal/auth/x509-workload-identity-auth.mjs +11 -0
- package/internal/auth/x509-workload-identity-auth.mjs.map +1 -1
- package/internal/bedrock.d.mts.map +1 -1
- package/internal/bedrock.d.ts.map +1 -1
- package/internal/bedrock.js +17 -1
- package/internal/bedrock.js.map +1 -1
- package/internal/bedrock.mjs +17 -1
- package/internal/bedrock.mjs.map +1 -1
- package/internal/decoders/line.d.mts.map +1 -1
- package/internal/decoders/line.d.ts.map +1 -1
- package/internal/decoders/line.js +1 -0
- package/internal/decoders/line.js.map +1 -1
- package/internal/decoders/line.mjs +1 -0
- package/internal/decoders/line.mjs.map +1 -1
- package/internal/parse.d.mts +1 -0
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts +1 -0
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs.map +1 -1
- package/internal/provider.d.mts.map +1 -1
- package/internal/provider.d.ts.map +1 -1
- package/internal/provider.js +3 -0
- package/internal/provider.js.map +1 -1
- package/internal/provider.mjs +3 -0
- package/internal/provider.mjs.map +1 -1
- package/internal/qs/stringify.d.mts.map +1 -1
- package/internal/qs/stringify.d.ts.map +1 -1
- package/internal/qs/stringify.js +3 -0
- package/internal/qs/stringify.js.map +1 -1
- package/internal/qs/stringify.mjs +3 -0
- package/internal/qs/stringify.mjs.map +1 -1
- package/internal/qs/utils.d.mts.map +1 -1
- package/internal/qs/utils.d.ts.map +1 -1
- package/internal/qs/utils.js +15 -3
- package/internal/qs/utils.js.map +1 -1
- package/internal/qs/utils.mjs +15 -3
- package/internal/qs/utils.mjs.map +1 -1
- package/internal/responses/response-accumulator.d.mts.map +1 -1
- package/internal/responses/response-accumulator.d.ts.map +1 -1
- package/internal/responses/response-accumulator.js +20 -4
- package/internal/responses/response-accumulator.js.map +1 -1
- package/internal/responses/response-accumulator.mjs +20 -4
- package/internal/responses/response-accumulator.mjs.map +1 -1
- package/internal/to-file.js.map +1 -1
- package/internal/to-file.mjs.map +1 -1
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js +10 -0
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +10 -0
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/abort.d.mts.map +1 -1
- package/internal/utils/abort.d.ts.map +1 -1
- package/internal/utils/abort.js +9 -2
- package/internal/utils/abort.js.map +1 -1
- package/internal/utils/abort.mjs +9 -2
- package/internal/utils/abort.mjs.map +1 -1
- package/internal/utils/bytes.d.mts.map +1 -1
- package/internal/utils/bytes.d.ts.map +1 -1
- package/internal/utils/bytes.js +2 -0
- package/internal/utils/bytes.js.map +1 -1
- package/internal/utils/bytes.mjs +2 -0
- package/internal/utils/bytes.mjs.map +1 -1
- package/internal/utils/path.d.mts.map +1 -1
- package/internal/utils/path.d.ts.map +1 -1
- package/internal/utils/path.js +2 -0
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +2 -0
- package/internal/utils/path.mjs.map +1 -1
- package/internal/utils/sleep.d.mts +1 -1
- package/internal/utils/sleep.d.mts.map +1 -1
- package/internal/utils/sleep.d.ts +1 -1
- package/internal/utils/sleep.d.ts.map +1 -1
- package/internal/utils/sleep.js +51 -1
- package/internal/utils/sleep.js.map +1 -1
- package/internal/utils/sleep.mjs +51 -1
- package/internal/utils/sleep.mjs.map +1 -1
- package/internal/ws-adapter-browser.d.mts.map +1 -1
- package/internal/ws-adapter-browser.d.ts.map +1 -1
- package/internal/ws-adapter-browser.js +2 -0
- package/internal/ws-adapter-browser.js.map +1 -1
- package/internal/ws-adapter-browser.mjs +2 -0
- package/internal/ws-adapter-browser.mjs.map +1 -1
- package/internal/ws.d.mts +9 -0
- package/internal/ws.d.mts.map +1 -1
- package/internal/ws.d.ts +9 -0
- package/internal/ws.d.ts.map +1 -1
- package/internal/ws.js +36 -4
- package/internal/ws.js.map +1 -1
- package/internal/ws.mjs +35 -4
- package/internal/ws.mjs.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.mts.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.ts.map +1 -1
- package/lib/AbstractChatCompletionRunner.js +41 -16
- package/lib/AbstractChatCompletionRunner.js.map +1 -1
- package/lib/AbstractChatCompletionRunner.mjs +42 -17
- package/lib/AbstractChatCompletionRunner.mjs.map +1 -1
- package/lib/AssistantStream.d.mts.map +1 -1
- package/lib/AssistantStream.d.ts.map +1 -1
- package/lib/AssistantStream.js +19 -5
- package/lib/AssistantStream.js.map +1 -1
- package/lib/AssistantStream.mjs +20 -6
- package/lib/AssistantStream.mjs.map +1 -1
- package/lib/ChatCompletionRunner.d.mts.map +1 -1
- package/lib/ChatCompletionRunner.d.ts.map +1 -1
- package/lib/ChatCompletionRunner.js +1 -0
- package/lib/ChatCompletionRunner.js.map +1 -1
- package/lib/ChatCompletionRunner.mjs +1 -0
- package/lib/ChatCompletionRunner.mjs.map +1 -1
- package/lib/ChatCompletionStream.d.mts +6 -1
- package/lib/ChatCompletionStream.d.mts.map +1 -1
- package/lib/ChatCompletionStream.d.ts +6 -1
- package/lib/ChatCompletionStream.d.ts.map +1 -1
- package/lib/ChatCompletionStream.js +63 -7
- package/lib/ChatCompletionStream.js.map +1 -1
- package/lib/ChatCompletionStream.mjs +64 -8
- package/lib/ChatCompletionStream.mjs.map +1 -1
- package/lib/EventEmitter.d.mts.map +1 -1
- package/lib/EventEmitter.d.ts.map +1 -1
- package/lib/EventEmitter.js +15 -0
- package/lib/EventEmitter.js.map +1 -1
- package/lib/EventEmitter.mjs +15 -0
- package/lib/EventEmitter.mjs.map +1 -1
- package/lib/EventStream.d.mts +2 -0
- package/lib/EventStream.d.mts.map +1 -1
- package/lib/EventStream.d.ts +2 -0
- package/lib/EventStream.d.ts.map +1 -1
- package/lib/EventStream.js +111 -14
- package/lib/EventStream.js.map +1 -1
- package/lib/EventStream.mjs +111 -14
- package/lib/EventStream.mjs.map +1 -1
- package/lib/ResponsesParser.d.mts.map +1 -1
- package/lib/ResponsesParser.d.ts.map +1 -1
- package/lib/ResponsesParser.js +4 -0
- package/lib/ResponsesParser.js.map +1 -1
- package/lib/ResponsesParser.mjs +4 -0
- package/lib/ResponsesParser.mjs.map +1 -1
- package/lib/RunnableFunction.d.mts.map +1 -1
- package/lib/RunnableFunction.d.ts.map +1 -1
- package/lib/RunnableFunction.js.map +1 -1
- package/lib/RunnableFunction.mjs.map +1 -1
- package/lib/agents/agent-session-stream.d.mts.map +1 -1
- package/lib/agents/agent-session-stream.d.ts.map +1 -1
- package/lib/agents/agent-session-stream.js +5 -2
- package/lib/agents/agent-session-stream.js.map +1 -1
- package/lib/agents/agent-session-stream.mjs +5 -2
- package/lib/agents/agent-session-stream.mjs.map +1 -1
- package/lib/embeddings.d.mts.map +1 -1
- package/lib/embeddings.d.ts.map +1 -1
- package/lib/embeddings.js +2 -0
- package/lib/embeddings.js.map +1 -1
- package/lib/embeddings.mjs +2 -0
- package/lib/embeddings.mjs.map +1 -1
- package/lib/live/transcript-grouper.d.mts.map +1 -1
- package/lib/live/transcript-grouper.d.ts.map +1 -1
- package/lib/live/transcript-grouper.js +8 -2
- package/lib/live/transcript-grouper.js.map +1 -1
- package/lib/live/transcript-grouper.mjs +8 -2
- package/lib/live/transcript-grouper.mjs.map +1 -1
- package/lib/parser.d.mts.map +1 -1
- package/lib/parser.d.ts.map +1 -1
- package/lib/parser.js +13 -0
- package/lib/parser.js.map +1 -1
- package/lib/parser.mjs +13 -0
- package/lib/parser.mjs.map +1 -1
- package/lib/responses/ResponseInputItems.d.mts.map +1 -1
- package/lib/responses/ResponseInputItems.d.ts.map +1 -1
- package/lib/responses/ResponseInputItems.js +11 -0
- package/lib/responses/ResponseInputItems.js.map +1 -1
- package/lib/responses/ResponseInputItems.mjs +11 -0
- package/lib/responses/ResponseInputItems.mjs.map +1 -1
- package/lib/responses/ResponseStream.d.mts.map +1 -1
- package/lib/responses/ResponseStream.d.ts.map +1 -1
- package/lib/responses/ResponseStream.js +7 -3
- package/lib/responses/ResponseStream.js.map +1 -1
- package/lib/responses/ResponseStream.mjs +8 -4
- package/lib/responses/ResponseStream.mjs.map +1 -1
- package/lib/transform.d.mts.map +1 -1
- package/lib/transform.d.ts.map +1 -1
- package/lib/transform.js +69 -33
- package/lib/transform.js.map +1 -1
- package/lib/transform.mjs +69 -33
- package/lib/transform.mjs.map +1 -1
- package/lib/webrtc/connection.d.mts.map +1 -1
- package/lib/webrtc/connection.d.ts.map +1 -1
- package/lib/webrtc/connection.js +6 -1
- package/lib/webrtc/connection.js.map +1 -1
- package/lib/webrtc/connection.mjs +6 -1
- package/lib/webrtc/connection.mjs.map +1 -1
- package/lib/webrtc/data-channel.d.mts.map +1 -1
- package/lib/webrtc/data-channel.d.ts.map +1 -1
- package/lib/webrtc/data-channel.js +9 -1
- package/lib/webrtc/data-channel.js.map +1 -1
- package/lib/webrtc/data-channel.mjs +9 -1
- package/lib/webrtc/data-channel.mjs.map +1 -1
- package/lib/webrtc/subscriptions.d.mts.map +1 -1
- package/lib/webrtc/subscriptions.d.ts.map +1 -1
- package/lib/webrtc/subscriptions.js +2 -0
- package/lib/webrtc/subscriptions.js.map +1 -1
- package/lib/webrtc/subscriptions.mjs +2 -0
- package/lib/webrtc/subscriptions.mjs.map +1 -1
- package/lib/webrtc/types.d.mts.map +1 -1
- package/lib/webrtc/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/providers/bedrock/aws.d.mts.map +1 -1
- package/providers/bedrock/aws.d.ts.map +1 -1
- package/providers/bedrock/aws.js +4 -0
- package/providers/bedrock/aws.js.map +1 -1
- package/providers/bedrock/aws.mjs +4 -0
- package/providers/bedrock/aws.mjs.map +1 -1
- package/realtime/internal-base.d.mts.map +1 -1
- package/realtime/internal-base.d.ts.map +1 -1
- package/realtime/internal-base.js +1 -0
- package/realtime/internal-base.js.map +1 -1
- package/realtime/internal-base.mjs +1 -0
- package/realtime/internal-base.mjs.map +1 -1
- package/realtime/websocket.d.mts.map +1 -1
- package/realtime/websocket.d.ts.map +1 -1
- package/realtime/websocket.js +9 -1
- package/realtime/websocket.js.map +1 -1
- package/realtime/websocket.mjs +9 -1
- package/realtime/websocket.mjs.map +1 -1
- package/realtime/ws.d.mts.map +1 -1
- package/realtime/ws.d.ts.map +1 -1
- package/realtime/ws.js +3 -0
- package/realtime/ws.js.map +1 -1
- package/realtime/ws.mjs +3 -0
- package/realtime/ws.mjs.map +1 -1
- package/resources/beta/agents/agents.d.mts +2 -1
- package/resources/beta/agents/agents.d.mts.map +1 -1
- package/resources/beta/agents/agents.d.ts +2 -1
- package/resources/beta/agents/agents.d.ts.map +1 -1
- package/resources/beta/agents/agents.js.map +1 -1
- package/resources/beta/agents/agents.mjs.map +1 -1
- package/resources/beta/beta.d.mts +2 -2
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +2 -2
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/index.d.mts +1 -1
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +1 -1
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/responses/index.d.mts +1 -1
- package/resources/beta/responses/index.d.mts.map +1 -1
- package/resources/beta/responses/index.d.ts +1 -1
- package/resources/beta/responses/index.d.ts.map +1 -1
- package/resources/beta/responses/index.js.map +1 -1
- package/resources/beta/responses/index.mjs.map +1 -1
- package/resources/beta/responses/internal-base.d.mts +3 -0
- package/resources/beta/responses/internal-base.d.mts.map +1 -1
- package/resources/beta/responses/internal-base.d.ts +3 -0
- package/resources/beta/responses/internal-base.d.ts.map +1 -1
- package/resources/beta/responses/internal-base.js +21 -12
- package/resources/beta/responses/internal-base.js.map +1 -1
- package/resources/beta/responses/internal-base.mjs +21 -12
- package/resources/beta/responses/internal-base.mjs.map +1 -1
- package/resources/beta/responses/responses.d.mts +51 -3
- package/resources/beta/responses/responses.d.mts.map +1 -1
- package/resources/beta/responses/responses.d.ts +51 -3
- package/resources/beta/responses/responses.d.ts.map +1 -1
- package/resources/beta/responses/responses.js.map +1 -1
- package/resources/beta/responses/responses.mjs.map +1 -1
- package/resources/beta/responses/ws-base.d.mts +5 -1
- package/resources/beta/responses/ws-base.d.mts.map +1 -1
- package/resources/beta/responses/ws-base.d.ts +5 -1
- package/resources/beta/responses/ws-base.d.ts.map +1 -1
- package/resources/beta/responses/ws-base.js +2 -4
- package/resources/beta/responses/ws-base.js.map +1 -1
- package/resources/beta/responses/ws-base.mjs +2 -4
- package/resources/beta/responses/ws-base.mjs.map +1 -1
- package/resources/beta/responses/ws.d.mts +2 -0
- package/resources/beta/responses/ws.d.mts.map +1 -1
- package/resources/beta/responses/ws.d.ts +2 -0
- package/resources/beta/responses/ws.d.ts.map +1 -1
- package/resources/beta/responses/ws.js +12 -3
- package/resources/beta/responses/ws.js.map +1 -1
- package/resources/beta/responses/ws.mjs +12 -3
- package/resources/beta/responses/ws.mjs.map +1 -1
- package/resources/live/forks/internal-base.d.mts +3 -0
- package/resources/live/forks/internal-base.d.mts.map +1 -1
- package/resources/live/forks/internal-base.d.ts +3 -0
- package/resources/live/forks/internal-base.d.ts.map +1 -1
- package/resources/live/forks/internal-base.js +21 -5
- package/resources/live/forks/internal-base.js.map +1 -1
- package/resources/live/forks/internal-base.mjs +21 -5
- package/resources/live/forks/internal-base.mjs.map +1 -1
- package/resources/live/internal-base.d.mts +3 -0
- package/resources/live/internal-base.d.mts.map +1 -1
- package/resources/live/internal-base.d.ts +3 -0
- package/resources/live/internal-base.d.ts.map +1 -1
- package/resources/live/internal-base.js +21 -5
- package/resources/live/internal-base.js.map +1 -1
- package/resources/live/internal-base.mjs +21 -5
- package/resources/live/internal-base.mjs.map +1 -1
- package/resources/live/sideband/internal-base.d.mts +3 -0
- package/resources/live/sideband/internal-base.d.mts.map +1 -1
- package/resources/live/sideband/internal-base.d.ts +3 -0
- package/resources/live/sideband/internal-base.d.ts.map +1 -1
- package/resources/live/sideband/internal-base.js +21 -5
- package/resources/live/sideband/internal-base.js.map +1 -1
- package/resources/live/sideband/internal-base.mjs +21 -5
- package/resources/live/sideband/internal-base.mjs.map +1 -1
- package/resources/responses/internal-base.d.mts +3 -0
- package/resources/responses/internal-base.d.mts.map +1 -1
- package/resources/responses/internal-base.d.ts +3 -0
- package/resources/responses/internal-base.d.ts.map +1 -1
- package/resources/responses/internal-base.js +21 -12
- package/resources/responses/internal-base.js.map +1 -1
- package/resources/responses/internal-base.mjs +21 -12
- package/resources/responses/internal-base.mjs.map +1 -1
- package/resources/responses/responses.d.mts +36 -3
- package/resources/responses/responses.d.mts.map +1 -1
- package/resources/responses/responses.d.ts +36 -3
- package/resources/responses/responses.d.ts.map +1 -1
- package/resources/responses/responses.js.map +1 -1
- package/resources/responses/responses.mjs.map +1 -1
- package/resources/responses/ws-base.d.mts +5 -1
- package/resources/responses/ws-base.d.mts.map +1 -1
- package/resources/responses/ws-base.d.ts +5 -1
- package/resources/responses/ws-base.d.ts.map +1 -1
- package/resources/responses/ws-base.js +2 -4
- package/resources/responses/ws-base.js.map +1 -1
- package/resources/responses/ws-base.mjs +2 -4
- package/resources/responses/ws-base.mjs.map +1 -1
- package/resources/responses/ws.d.mts +2 -0
- package/resources/responses/ws.d.mts.map +1 -1
- package/resources/responses/ws.d.ts +2 -0
- package/resources/responses/ws.d.ts.map +1 -1
- package/resources/responses/ws.js +12 -3
- package/resources/responses/ws.js.map +1 -1
- package/resources/responses/ws.mjs +12 -3
- package/resources/responses/ws.mjs.map +1 -1
- package/src/_vendor/zod-to-json-schema/Options.ts +2 -0
- package/src/_vendor/zod-to-json-schema/parseDef.ts +1 -0
- package/src/_vendor/zod-to-json-schema/parsers/bigint.ts +2 -0
- package/src/_vendor/zod-to-json-schema/parsers/literal.ts +1 -0
- package/src/_vendor/zod-to-json-schema/parsers/null.ts +1 -0
- package/src/_vendor/zod-to-json-schema/parsers/nullable.ts +4 -0
- package/src/_vendor/zod-to-json-schema/parsers/number.ts +2 -0
- package/src/_vendor/zod-to-json-schema/parsers/optional.ts +6 -7
- package/src/_vendor/zod-to-json-schema/parsers/record.ts +2 -0
- package/src/_vendor/zod-to-json-schema/parsers/string.ts +1 -0
- package/src/_vendor/zod-to-json-schema/parsers/union.ts +3 -0
- package/src/_vendor/zod-to-json-schema/util.ts +1 -0
- package/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts +3 -1
- package/src/auth/subject-token-providers.ts +6 -1
- package/src/auth/workload-identity-auth.ts +10 -1
- package/src/auth/x509-transport.ts +13 -2
- package/src/azure.ts +3 -0
- package/src/bedrock.ts +5 -0
- package/src/beta/realtime/internal-base.ts +2 -0
- package/src/beta/realtime/websocket.ts +11 -1
- package/src/beta/realtime/ws.ts +3 -0
- package/src/client.ts +35 -3
- package/src/core/EventEmitter.ts +15 -0
- package/src/core/streaming.ts +30 -2
- package/src/helpers/audio.ts +2 -0
- package/src/helpers/standard-schema.ts +31 -19
- package/src/helpers/zod-v3-strict-schema.ts +8 -2
- package/src/helpers/zod.ts +32 -13
- package/src/internal/assistant-stream-delta.ts +7 -1
- package/src/internal/auth/x509-credential-options.ts +3 -0
- package/src/internal/auth/x509-token-exchange.ts +10 -1
- package/src/internal/auth/x509-transport-capability.ts +2 -1
- package/src/internal/auth/x509-workload-identity-auth.ts +13 -8
- package/src/internal/bedrock.ts +15 -0
- package/src/internal/decoders/line.ts +1 -0
- package/src/internal/parse.ts +1 -0
- package/src/internal/provider.ts +3 -0
- package/src/internal/qs/stringify.ts +3 -0
- package/src/internal/qs/utils.ts +14 -3
- package/src/internal/responses/response-accumulator.ts +34 -4
- package/src/internal/to-file.ts +1 -1
- package/src/internal/uploads.ts +11 -1
- package/src/internal/utils/abort.ts +7 -2
- package/src/internal/utils/bytes.ts +2 -0
- package/src/internal/utils/path.ts +2 -0
- package/src/internal/utils/sleep.ts +52 -1
- package/src/internal/ws-adapter-browser.ts +2 -0
- package/src/internal/ws.ts +44 -4
- package/src/lib/AbstractChatCompletionRunner.ts +40 -17
- package/src/lib/AssistantStream.ts +31 -20
- package/src/lib/ChatCompletionRunner.ts +1 -0
- package/src/lib/ChatCompletionStream.ts +81 -14
- package/src/lib/EventEmitter.ts +15 -0
- package/src/lib/EventStream.ts +93 -3
- package/src/lib/ResponsesParser.ts +5 -0
- package/src/lib/RunnableFunction.ts +4 -1
- package/src/lib/agents/agent-session-stream.ts +5 -3
- package/src/lib/embeddings.ts +3 -1
- package/src/lib/live/transcript-grouper.ts +4 -0
- package/src/lib/parser.ts +16 -2
- package/src/lib/responses/ResponseInputItems.ts +11 -0
- package/src/lib/responses/ResponseStream.ts +6 -3
- package/src/lib/transform.ts +70 -35
- package/src/lib/webrtc/connection.ts +5 -1
- package/src/lib/webrtc/data-channel.ts +7 -0
- package/src/lib/webrtc/subscriptions.ts +3 -0
- package/src/lib/webrtc/types.ts +1 -0
- package/src/providers/bedrock/aws.ts +5 -1
- package/src/realtime/internal-base.ts +2 -0
- package/src/realtime/websocket.ts +11 -1
- package/src/realtime/ws.ts +3 -0
- package/src/resources/beta/agents/agents.ts +2 -0
- package/src/resources/beta/beta.ts +2 -0
- package/src/resources/beta/index.ts +1 -0
- package/src/resources/beta/responses/index.ts +1 -0
- package/src/resources/beta/responses/internal-base.ts +24 -11
- package/src/resources/beta/responses/responses.ts +58 -0
- package/src/resources/beta/responses/ws-base.ts +7 -5
- package/src/resources/beta/responses/ws.ts +21 -6
- package/src/resources/live/forks/internal-base.ts +24 -5
- package/src/resources/live/internal-base.ts +24 -5
- package/src/resources/live/sideband/internal-base.ts +24 -5
- package/src/resources/responses/api.md +1 -0
- package/src/resources/responses/internal-base.ts +24 -11
- package/src/resources/responses/responses.ts +41 -0
- package/src/resources/responses/ws-base.ts +7 -5
- package/src/resources/responses/ws.ts +21 -6
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/lib/transform.ts
CHANGED
|
@@ -119,6 +119,7 @@ export function forEachJSONSchemaChild(
|
|
|
119
119
|
path: string[],
|
|
120
120
|
visit: JSONSchemaChildVisitor,
|
|
121
121
|
): void {
|
|
122
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
122
123
|
const record = schema as Record<string, unknown>;
|
|
123
124
|
|
|
124
125
|
for (const keyword of JSON_SCHEMA_SINGLE_SCHEMA_KEYWORDS) {
|
|
@@ -204,11 +205,12 @@ export function toStrictJsonSchema(schema: JSONSchema): JSONSchema {
|
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
function stripUndefinedSchemaKeywords(schema: JSONSchemaDefinition, visited = new Set<JSONSchema>()): void {
|
|
207
|
-
if (
|
|
208
|
+
if (!isObject(schema) || visited.has(schema)) {
|
|
208
209
|
return;
|
|
209
210
|
}
|
|
210
211
|
visited.add(schema);
|
|
211
212
|
|
|
213
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
212
214
|
const schemaRecord = schema as Record<string, unknown>;
|
|
213
215
|
for (const keyword of Object.keys(schemaRecord)) {
|
|
214
216
|
if (schemaRecord[keyword] === undefined) {
|
|
@@ -217,6 +219,7 @@ function stripUndefinedSchemaKeywords(schema: JSONSchemaDefinition, visited = ne
|
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
forEachJSONSchemaChild(schema, [], (child) => {
|
|
222
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
220
223
|
stripUndefinedSchemaKeywords(child as JSONSchemaDefinition, visited);
|
|
221
224
|
});
|
|
222
225
|
}
|
|
@@ -308,6 +311,7 @@ function inlineRootRefObject(schema: JSONSchema): void {
|
|
|
308
311
|
}
|
|
309
312
|
for (const keyword of JSON_SCHEMA_ANNOTATION_KEYWORDS) {
|
|
310
313
|
if (!(keyword in inheritedAnnotations) && keyword in target) {
|
|
314
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
311
315
|
inheritedAnnotations[keyword] = (target as Record<string, unknown>)[keyword];
|
|
312
316
|
}
|
|
313
317
|
}
|
|
@@ -332,6 +336,7 @@ function inlineRootRefObject(schema: JSONSchema): void {
|
|
|
332
336
|
delete inlined[keyword];
|
|
333
337
|
}
|
|
334
338
|
}
|
|
339
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
335
340
|
const schemaRecord = schema as Record<string, unknown>;
|
|
336
341
|
|
|
337
342
|
for (const keyword of Object.keys(schema)) {
|
|
@@ -375,13 +380,14 @@ function normalizeRootAllOf(schema: JSONSchema): void {
|
|
|
375
380
|
}
|
|
376
381
|
|
|
377
382
|
const branch = allOf[0];
|
|
378
|
-
if (
|
|
383
|
+
if (!isObject(branch)) {
|
|
379
384
|
return;
|
|
380
385
|
}
|
|
381
386
|
|
|
382
387
|
const rootMetadata = { ...schema };
|
|
383
388
|
delete rootMetadata.allOf;
|
|
384
389
|
const normalized = structuredClone(branch);
|
|
390
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
385
391
|
const schemaRecord = schema as Record<string, unknown>;
|
|
386
392
|
|
|
387
393
|
for (const keyword of Object.keys(schema)) {
|
|
@@ -414,7 +420,7 @@ function normalizeRootAnyOf(schema: JSONSchema): boolean {
|
|
|
414
420
|
}
|
|
415
421
|
|
|
416
422
|
const { branch, index: branchIndex } = realBranches[0]!;
|
|
417
|
-
if (
|
|
423
|
+
if (!isObject(branch) || !isObjectOnlySchema(branch, schema)) {
|
|
418
424
|
return false;
|
|
419
425
|
}
|
|
420
426
|
|
|
@@ -432,7 +438,7 @@ function normalizeRootAnyOf(schema: JSONSchema): boolean {
|
|
|
432
438
|
}
|
|
433
439
|
|
|
434
440
|
const renames = definitionRenames.get(keyword);
|
|
435
|
-
const mergedDefinitions
|
|
441
|
+
const mergedDefinitions = { ...rootDefinitions };
|
|
436
442
|
for (const [name, definition] of Object.entries(branchDefinitions)) {
|
|
437
443
|
Object.defineProperty(mergedDefinitions, renames?.get(name) ?? name, {
|
|
438
444
|
value: definition,
|
|
@@ -445,6 +451,7 @@ function normalizeRootAnyOf(schema: JSONSchema): boolean {
|
|
|
445
451
|
delete rootMetadata[keyword];
|
|
446
452
|
}
|
|
447
453
|
|
|
454
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
448
455
|
const schemaRecord = schema as Record<string, unknown>;
|
|
449
456
|
|
|
450
457
|
for (const keyword of Object.keys(schema)) {
|
|
@@ -531,7 +538,7 @@ function rewriteLocalRefsIntoPromotedRootAnyOfBranch(
|
|
|
531
538
|
};
|
|
532
539
|
|
|
533
540
|
const rewriteRefs = (value: JSONSchemaDefinition): void => {
|
|
534
|
-
if (
|
|
541
|
+
if (!isObject(value)) {
|
|
535
542
|
return;
|
|
536
543
|
}
|
|
537
544
|
|
|
@@ -540,6 +547,7 @@ function rewriteLocalRefsIntoPromotedRootAnyOfBranch(
|
|
|
540
547
|
}
|
|
541
548
|
|
|
542
549
|
forEachJSONSchemaChild(value, [], (child) => {
|
|
550
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
543
551
|
rewriteRefs(child as JSONSchemaDefinition);
|
|
544
552
|
});
|
|
545
553
|
};
|
|
@@ -576,7 +584,7 @@ function hasOnlyRootRefAndDefinitions(schema: JSONSchema): boolean {
|
|
|
576
584
|
* Multi-type arrays carry real union semantics and must remain unchanged.
|
|
577
585
|
*/
|
|
578
586
|
function normalizeSingletonTypeArrays(schema: JSONSchemaDefinition): void {
|
|
579
|
-
if (
|
|
587
|
+
if (!isObject(schema)) {
|
|
580
588
|
return;
|
|
581
589
|
}
|
|
582
590
|
|
|
@@ -585,6 +593,7 @@ function normalizeSingletonTypeArrays(schema: JSONSchemaDefinition): void {
|
|
|
585
593
|
}
|
|
586
594
|
|
|
587
595
|
forEachJSONSchemaChild(schema, [], (child) => {
|
|
596
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
588
597
|
normalizeSingletonTypeArrays(child as JSONSchemaDefinition);
|
|
589
598
|
});
|
|
590
599
|
}
|
|
@@ -707,7 +716,7 @@ function ensureStrictJsonSchema(
|
|
|
707
716
|
// keywords without an explicit type, so those implicit object shapes need
|
|
708
717
|
// the same strict handling as type: 'object'. Explicitly open object schemas
|
|
709
718
|
// cannot be represented in Structured Outputs strict mode.
|
|
710
|
-
if (
|
|
719
|
+
if (hasObjectConstraints(jsonSchema)) {
|
|
711
720
|
if (!hasOwn(jsonSchema, 'additionalProperties')) {
|
|
712
721
|
jsonSchema.additionalProperties = false;
|
|
713
722
|
} else if (jsonSchema.additionalProperties !== false) {
|
|
@@ -728,7 +737,7 @@ function ensureStrictJsonSchema(
|
|
|
728
737
|
|
|
729
738
|
// Handle object properties
|
|
730
739
|
const properties = jsonSchema.properties;
|
|
731
|
-
if (
|
|
740
|
+
if (hasObjectConstraints(jsonSchema)) {
|
|
732
741
|
for (const key of required) {
|
|
733
742
|
if (!isObject(properties) || !hasOwn(properties, key)) {
|
|
734
743
|
throw new Error(
|
|
@@ -798,6 +807,7 @@ function ensureStrictJsonSchema(
|
|
|
798
807
|
|
|
799
808
|
normalizeArrayUnionWrapper(jsonSchema, root);
|
|
800
809
|
|
|
810
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
801
811
|
const schemaRecord = jsonSchema as Record<string, unknown>;
|
|
802
812
|
for (const keyword of JSON_SCHEMA_UNSUPPORTED_SCHEMA_KEYWORDS) {
|
|
803
813
|
// Optional converter output often keeps undefined placeholders on the
|
|
@@ -832,6 +842,7 @@ function ensureStrictJsonSchema(
|
|
|
832
842
|
return;
|
|
833
843
|
}
|
|
834
844
|
|
|
845
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
835
846
|
ensureStrictJsonSchema(child as JSONSchemaDefinition, childPath, root);
|
|
836
847
|
});
|
|
837
848
|
|
|
@@ -878,6 +889,7 @@ function parseLocalRef(ref: string): string[] | undefined {
|
|
|
878
889
|
return parts;
|
|
879
890
|
}
|
|
880
891
|
|
|
892
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- Resolving untrusted schema references may produce any value; callers perform the schema checks. JSON Schema traversal accepts arbitrary keyword values and validates each node before interpreting it.
|
|
881
893
|
function resolvePointerPart(resolved: unknown, part: string): unknown | undefined {
|
|
882
894
|
if (Array.isArray(resolved)) {
|
|
883
895
|
if (!/^(?:0|[1-9]\d*)$/.test(part)) {
|
|
@@ -974,7 +986,7 @@ function isObjectOnlySchema(
|
|
|
974
986
|
root: JSONSchema,
|
|
975
987
|
seenRefs = new Set<string>(),
|
|
976
988
|
): boolean {
|
|
977
|
-
if (
|
|
989
|
+
if (!isObject(schema)) {
|
|
978
990
|
return false;
|
|
979
991
|
}
|
|
980
992
|
|
|
@@ -1017,7 +1029,7 @@ function isArrayOnlySchema(
|
|
|
1017
1029
|
root: JSONSchema,
|
|
1018
1030
|
seenRefs = new Set<string>(),
|
|
1019
1031
|
): boolean {
|
|
1020
|
-
if (
|
|
1032
|
+
if (!isObject(schema)) {
|
|
1021
1033
|
return false;
|
|
1022
1034
|
}
|
|
1023
1035
|
|
|
@@ -1069,6 +1081,7 @@ export function hasOnlyRefAndAnnotations(schema: JSONSchema): boolean {
|
|
|
1069
1081
|
}
|
|
1070
1082
|
|
|
1071
1083
|
function hasOnlyAnnotationSiblings(schema: JSONSchema, keyword: string): boolean {
|
|
1084
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
1072
1085
|
const schemaRecord = schema as Record<string, unknown>;
|
|
1073
1086
|
return Object.keys(schema).every(
|
|
1074
1087
|
// Definition maps do not add sibling validation constraints. Keep them
|
|
@@ -1109,7 +1122,7 @@ function hasObjectKeywords(schema: JSONSchema): boolean {
|
|
|
1109
1122
|
return Object.keys(schema).some((keyword) => JSON_SCHEMA_OBJECT_KEYWORDS.has(keyword));
|
|
1110
1123
|
}
|
|
1111
1124
|
|
|
1112
|
-
function
|
|
1125
|
+
function hasObjectConstraints(schema: JSONSchema): boolean {
|
|
1113
1126
|
const typ = schema.type;
|
|
1114
1127
|
return (
|
|
1115
1128
|
typ === 'object' ||
|
|
@@ -1140,7 +1153,7 @@ function normalizeObjectUnionWrapper(jsonSchema: JSONSchema, path: string[], roo
|
|
|
1140
1153
|
delete jsonSchema.required;
|
|
1141
1154
|
}
|
|
1142
1155
|
|
|
1143
|
-
if (!
|
|
1156
|
+
if (!hasObjectConstraints(jsonSchema)) {
|
|
1144
1157
|
return;
|
|
1145
1158
|
}
|
|
1146
1159
|
|
|
@@ -1199,7 +1212,7 @@ function normalizeAnyOfFalseBranches(jsonSchema: JSONSchema): void {
|
|
|
1199
1212
|
*/
|
|
1200
1213
|
export function assertNoNestedSchemaIds(schema: JSONSchema): void {
|
|
1201
1214
|
const visit = (value: JSONSchemaDefinition, path: string[]): void => {
|
|
1202
|
-
if (
|
|
1215
|
+
if (!isObject(value)) {
|
|
1203
1216
|
return;
|
|
1204
1217
|
}
|
|
1205
1218
|
|
|
@@ -1212,6 +1225,7 @@ export function assertNoNestedSchemaIds(schema: JSONSchema): void {
|
|
|
1212
1225
|
}
|
|
1213
1226
|
|
|
1214
1227
|
forEachJSONSchemaChild(value, path, (child, childPath) => {
|
|
1228
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
1215
1229
|
visit(child as JSONSchemaDefinition, childPath);
|
|
1216
1230
|
});
|
|
1217
1231
|
};
|
|
@@ -1293,7 +1307,7 @@ export function rewriteLocalRefsIntoMovedOneOfBranches(root: JSONSchema): void {
|
|
|
1293
1307
|
};
|
|
1294
1308
|
|
|
1295
1309
|
const rewriteRefs = (value: JSONSchemaDefinition): void => {
|
|
1296
|
-
if (
|
|
1310
|
+
if (!isObject(value)) {
|
|
1297
1311
|
return;
|
|
1298
1312
|
}
|
|
1299
1313
|
|
|
@@ -1302,6 +1316,7 @@ export function rewriteLocalRefsIntoMovedOneOfBranches(root: JSONSchema): void {
|
|
|
1302
1316
|
}
|
|
1303
1317
|
|
|
1304
1318
|
forEachJSONSchemaChild(value, [], (child) => {
|
|
1319
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
1305
1320
|
rewriteRefs(child as JSONSchemaDefinition);
|
|
1306
1321
|
});
|
|
1307
1322
|
};
|
|
@@ -1326,10 +1341,8 @@ function rewriteLocalRefsIntoFilteredAnyOfBranches(root: JSONSchema): void {
|
|
|
1326
1341
|
let changed = false;
|
|
1327
1342
|
|
|
1328
1343
|
for (const [index, part] of originalParts.entries()) {
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
? (resolved as Record<string, unknown>)
|
|
1332
|
-
: undefined;
|
|
1344
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
1345
|
+
const resolvedRecord = isObject(resolved) ? (resolved as Record<string, unknown>) : undefined;
|
|
1333
1346
|
if (
|
|
1334
1347
|
part === 'anyOf' &&
|
|
1335
1348
|
index < originalParts.length - 1 &&
|
|
@@ -1375,7 +1388,7 @@ function rewriteLocalRefsIntoFilteredAnyOfBranches(root: JSONSchema): void {
|
|
|
1375
1388
|
};
|
|
1376
1389
|
|
|
1377
1390
|
const rewriteRefs = (value: JSONSchemaDefinition): void => {
|
|
1378
|
-
if (
|
|
1391
|
+
if (!isObject(value)) {
|
|
1379
1392
|
return;
|
|
1380
1393
|
}
|
|
1381
1394
|
|
|
@@ -1384,6 +1397,7 @@ function rewriteLocalRefsIntoFilteredAnyOfBranches(root: JSONSchema): void {
|
|
|
1384
1397
|
}
|
|
1385
1398
|
|
|
1386
1399
|
forEachJSONSchemaChild(value, [], (child) => {
|
|
1400
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
1387
1401
|
rewriteRefs(child as JSONSchemaDefinition);
|
|
1388
1402
|
});
|
|
1389
1403
|
};
|
|
@@ -1399,7 +1413,7 @@ function rewriteLocalRefsIntoFilteredAnyOfBranches(root: JSONSchema): void {
|
|
|
1399
1413
|
function preserveAllOfRefTargets(root: JSONSchema, rootOnly = false): void {
|
|
1400
1414
|
const refsToPreserve = new Set<string>();
|
|
1401
1415
|
const collectRefs = (value: JSONSchemaDefinition): void => {
|
|
1402
|
-
if (
|
|
1416
|
+
if (!isObject(value)) {
|
|
1403
1417
|
return;
|
|
1404
1418
|
}
|
|
1405
1419
|
|
|
@@ -1411,6 +1425,7 @@ function preserveAllOfRefTargets(root: JSONSchema, rootOnly = false): void {
|
|
|
1411
1425
|
}
|
|
1412
1426
|
|
|
1413
1427
|
forEachJSONSchemaChild(value, [], (child) => {
|
|
1428
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
1414
1429
|
collectRefs(child as JSONSchemaDefinition);
|
|
1415
1430
|
});
|
|
1416
1431
|
};
|
|
@@ -1429,6 +1444,7 @@ function preserveAllOfRefTargets(root: JSONSchema, rootOnly = false): void {
|
|
|
1429
1444
|
|
|
1430
1445
|
for (const ref of refsToPreserve) {
|
|
1431
1446
|
const target = resolveLocalRef(root, ref);
|
|
1447
|
+
// oxlint-disable-next-line anti-slop/no-known-value-widening -- Local references require runtime schema validation even when the static return type is narrower.
|
|
1432
1448
|
if (!isSchemaDefinition(target)) {
|
|
1433
1449
|
if (rootOnly) {
|
|
1434
1450
|
continue;
|
|
@@ -1445,7 +1461,7 @@ function preserveAllOfRefTargets(root: JSONSchema, rootOnly = false): void {
|
|
|
1445
1461
|
}
|
|
1446
1462
|
|
|
1447
1463
|
const rewriteRefs = (value: JSONSchemaDefinition): void => {
|
|
1448
|
-
if (
|
|
1464
|
+
if (!isObject(value)) {
|
|
1449
1465
|
return;
|
|
1450
1466
|
}
|
|
1451
1467
|
|
|
@@ -1454,6 +1470,7 @@ function preserveAllOfRefTargets(root: JSONSchema, rootOnly = false): void {
|
|
|
1454
1470
|
}
|
|
1455
1471
|
|
|
1456
1472
|
forEachJSONSchemaChild(value, [], (child) => {
|
|
1473
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
1457
1474
|
rewriteRefs(child as JSONSchemaDefinition);
|
|
1458
1475
|
});
|
|
1459
1476
|
};
|
|
@@ -1472,7 +1489,7 @@ function preserveDiscardedAllOfPropertyRefTargets(root: JSONSchema, discardedPat
|
|
|
1472
1489
|
|
|
1473
1490
|
const refsToPreserve = new Set<string>();
|
|
1474
1491
|
const collectRefs = (value: JSONSchemaDefinition): void => {
|
|
1475
|
-
if (
|
|
1492
|
+
if (!isObject(value)) {
|
|
1476
1493
|
return;
|
|
1477
1494
|
}
|
|
1478
1495
|
|
|
@@ -1491,6 +1508,7 @@ function preserveDiscardedAllOfPropertyRefTargets(root: JSONSchema, discardedPat
|
|
|
1491
1508
|
}
|
|
1492
1509
|
|
|
1493
1510
|
forEachJSONSchemaChild(value, [], (child) => {
|
|
1511
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
1494
1512
|
collectRefs(child as JSONSchemaDefinition);
|
|
1495
1513
|
});
|
|
1496
1514
|
};
|
|
@@ -1509,6 +1527,7 @@ function preserveDiscardedAllOfPropertyRefTargets(root: JSONSchema, discardedPat
|
|
|
1509
1527
|
|
|
1510
1528
|
for (const ref of refsToPreserve) {
|
|
1511
1529
|
const target = resolveLocalRef(root, ref);
|
|
1530
|
+
// oxlint-disable-next-line anti-slop/no-known-value-widening -- Validate referenced schema values at runtime before preserving them under generated definitions.
|
|
1512
1531
|
if (!isSchemaDefinition(target)) {
|
|
1513
1532
|
throw new Error('Local $ref cannot be preserved before allOf property removal: ' + JSON.stringify(ref));
|
|
1514
1533
|
}
|
|
@@ -1522,7 +1541,7 @@ function preserveDiscardedAllOfPropertyRefTargets(root: JSONSchema, discardedPat
|
|
|
1522
1541
|
}
|
|
1523
1542
|
|
|
1524
1543
|
const rewriteRefs = (value: JSONSchemaDefinition): void => {
|
|
1525
|
-
if (
|
|
1544
|
+
if (!isObject(value)) {
|
|
1526
1545
|
return;
|
|
1527
1546
|
}
|
|
1528
1547
|
|
|
@@ -1531,6 +1550,7 @@ function preserveDiscardedAllOfPropertyRefTargets(root: JSONSchema, discardedPat
|
|
|
1531
1550
|
}
|
|
1532
1551
|
|
|
1533
1552
|
forEachJSONSchemaChild(value, [], (child) => {
|
|
1553
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
1534
1554
|
rewriteRefs(child as JSONSchemaDefinition);
|
|
1535
1555
|
});
|
|
1536
1556
|
};
|
|
@@ -1538,7 +1558,7 @@ function preserveDiscardedAllOfPropertyRefTargets(root: JSONSchema, discardedPat
|
|
|
1538
1558
|
}
|
|
1539
1559
|
|
|
1540
1560
|
function validateRefSchemas(schema: JSONSchemaDefinition, path: string[], root: JSONSchema): void {
|
|
1541
|
-
if (
|
|
1561
|
+
if (!isObject(schema)) {
|
|
1542
1562
|
return;
|
|
1543
1563
|
}
|
|
1544
1564
|
|
|
@@ -1555,6 +1575,7 @@ function validateRefSchemas(schema: JSONSchemaDefinition, path: string[], root:
|
|
|
1555
1575
|
);
|
|
1556
1576
|
}
|
|
1557
1577
|
const resolved = resolveLocalRef(root, ref);
|
|
1578
|
+
// oxlint-disable-next-line anti-slop/no-known-value-widening -- Untrusted local references must pass the runtime schema predicate before normalization.
|
|
1558
1579
|
if (resolved === undefined || !isSchemaDefinition(resolved)) {
|
|
1559
1580
|
throw new Error(
|
|
1560
1581
|
`Local $ref at \`${
|
|
@@ -1575,6 +1596,7 @@ function validateRefSchemas(schema: JSONSchemaDefinition, path: string[], root:
|
|
|
1575
1596
|
}
|
|
1576
1597
|
|
|
1577
1598
|
forEachJSONSchemaChild(schema, path, (child, childPath) => {
|
|
1599
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
1578
1600
|
validateRefSchemas(child as JSONSchemaDefinition, childPath, root);
|
|
1579
1601
|
});
|
|
1580
1602
|
}
|
|
@@ -1609,7 +1631,7 @@ function resolveObjectAllOfBranch(
|
|
|
1609
1631
|
seenRefs.add(ref);
|
|
1610
1632
|
|
|
1611
1633
|
const target = resolveLocalRef(root, ref);
|
|
1612
|
-
if (
|
|
1634
|
+
if (!isObject(target)) {
|
|
1613
1635
|
return undefined;
|
|
1614
1636
|
}
|
|
1615
1637
|
const targetPath = parseLocalRef(ref);
|
|
@@ -1646,7 +1668,7 @@ function normalizeObjectAllOfBranches(
|
|
|
1646
1668
|
root: JSONSchema,
|
|
1647
1669
|
normalizing = new Set<JSONSchema>(),
|
|
1648
1670
|
): void {
|
|
1649
|
-
if (
|
|
1671
|
+
if (!isObject(schema)) {
|
|
1650
1672
|
return;
|
|
1651
1673
|
}
|
|
1652
1674
|
if (normalizing.has(schema)) {
|
|
@@ -1657,6 +1679,7 @@ function normalizeObjectAllOfBranches(
|
|
|
1657
1679
|
try {
|
|
1658
1680
|
while (true) {
|
|
1659
1681
|
forEachJSONSchemaChild(schema, path, (child, childPath) => {
|
|
1682
|
+
// SAFETY: The schema-child visitor supplies only recognized object or boolean schema positions; the recursive helper validates their contents.
|
|
1660
1683
|
normalizeObjectAllOfBranches(child as JSONSchemaDefinition, childPath, root, normalizing);
|
|
1661
1684
|
});
|
|
1662
1685
|
|
|
@@ -1703,7 +1726,7 @@ export function normalizeObjectAllOfForExclusivity(
|
|
|
1703
1726
|
}
|
|
1704
1727
|
|
|
1705
1728
|
const branch = allOf[0];
|
|
1706
|
-
if (
|
|
1729
|
+
if (!isObject(branch)) {
|
|
1707
1730
|
return undefined;
|
|
1708
1731
|
}
|
|
1709
1732
|
|
|
@@ -1711,6 +1734,7 @@ export function normalizeObjectAllOfForExclusivity(
|
|
|
1711
1734
|
delete siblings.allOf;
|
|
1712
1735
|
const flattened = structuredClone(branch);
|
|
1713
1736
|
for (const keyword of Object.keys(normalized)) {
|
|
1737
|
+
// SAFETY: Only an enumerated own keyword is deleted from this mutable schema object before installing its normalized replacement.
|
|
1714
1738
|
delete (normalized as Record<string, unknown>)[keyword];
|
|
1715
1739
|
}
|
|
1716
1740
|
assignSchema(normalized, flattened, siblings);
|
|
@@ -1757,19 +1781,19 @@ function mergeObjectAllOf(
|
|
|
1757
1781
|
return true;
|
|
1758
1782
|
}
|
|
1759
1783
|
|
|
1760
|
-
const
|
|
1784
|
+
const parentIsMergeableObject = isMergeableObjectSchema(jsonSchema);
|
|
1761
1785
|
const resolvedEntries = allOf.map((entry) =>
|
|
1762
1786
|
isObject(entry) ? resolveObjectAllOfBranch(entry, root, normalizing) : undefined,
|
|
1763
1787
|
);
|
|
1764
1788
|
const objectBranches = resolvedEntries
|
|
1765
1789
|
.map((entry) => entry?.schema)
|
|
1766
|
-
.filter((entry): entry is JSONSchema => entry !== undefined &&
|
|
1767
|
-
if (!
|
|
1790
|
+
.filter((entry): entry is JSONSchema => entry !== undefined && isMergeableObjectSchema(entry));
|
|
1791
|
+
if (!parentIsMergeableObject && objectBranches.length === 0) {
|
|
1768
1792
|
return false;
|
|
1769
1793
|
}
|
|
1770
1794
|
// A lone object branch with no object-valued parent is handled by the
|
|
1771
1795
|
// existing safe single-allOf flattening path below.
|
|
1772
|
-
if (!
|
|
1796
|
+
if (!parentIsMergeableObject && allOf.length === 1) {
|
|
1773
1797
|
return false;
|
|
1774
1798
|
}
|
|
1775
1799
|
|
|
@@ -1782,7 +1806,7 @@ function mergeObjectAllOf(
|
|
|
1782
1806
|
};
|
|
1783
1807
|
|
|
1784
1808
|
if (
|
|
1785
|
-
!
|
|
1809
|
+
!parentIsMergeableObject &&
|
|
1786
1810
|
['additionalProperties', 'properties', 'required', 'type'].some((keyword) => keyword in jsonSchema)
|
|
1787
1811
|
) {
|
|
1788
1812
|
fail();
|
|
@@ -1801,7 +1825,7 @@ function mergeObjectAllOf(
|
|
|
1801
1825
|
}
|
|
1802
1826
|
|
|
1803
1827
|
const branches: { schema: JSONSchema; sourcePath: string[] | undefined }[] = [];
|
|
1804
|
-
if (
|
|
1828
|
+
if (parentIsMergeableObject) {
|
|
1805
1829
|
branches.push({ schema: jsonSchema, sourcePath: path });
|
|
1806
1830
|
}
|
|
1807
1831
|
for (const [index, entry] of allOf.entries()) {
|
|
@@ -1817,7 +1841,7 @@ function mergeObjectAllOf(
|
|
|
1817
1841
|
// branch were preserved under stable root definitions before this merge,
|
|
1818
1842
|
// so a valid definitions-only branch can now be discarded like an
|
|
1819
1843
|
// annotation-only branch.
|
|
1820
|
-
if (
|
|
1844
|
+
if (isMergeableObjectSchema(branch)) {
|
|
1821
1845
|
branches.push({
|
|
1822
1846
|
schema: branch,
|
|
1823
1847
|
sourcePath: branch === entry ? [...path, 'allOf', String(index)] : undefined,
|
|
@@ -1828,6 +1852,7 @@ function mergeObjectAllOf(
|
|
|
1828
1852
|
}
|
|
1829
1853
|
|
|
1830
1854
|
const merged: JSONSchema = {};
|
|
1855
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
1831
1856
|
for (const keyword of ['$defs', 'definitions'] as const) {
|
|
1832
1857
|
if (jsonSchema[keyword] !== undefined) {
|
|
1833
1858
|
merged[keyword] = jsonSchema[keyword];
|
|
@@ -1836,11 +1861,14 @@ function mergeObjectAllOf(
|
|
|
1836
1861
|
if (path.length === 0) {
|
|
1837
1862
|
for (const keyword of JSON_SCHEMA_ROOT_METADATA_KEYWORDS) {
|
|
1838
1863
|
if (keyword in jsonSchema) {
|
|
1864
|
+
// SAFETY: Root annotation keywords are copied unchanged between schema objects; the record views preserve their unknown values.
|
|
1865
|
+
// oxlint-disable-next-line anti-slop/no-known-value-widening -- Root annotation keywords are copied dynamically; JSONSchema has no index signature for extension fields. Metadata merging preserves arbitrary annotation/default values under the selected schema keywords.
|
|
1839
1866
|
(merged as Record<string, unknown>)[keyword] = (jsonSchema as Record<string, unknown>)[keyword];
|
|
1840
1867
|
}
|
|
1841
1868
|
}
|
|
1842
1869
|
}
|
|
1843
1870
|
|
|
1871
|
+
// SAFETY: This fresh null-prototype dictionary receives only JSON schema definitions while merging the validated property maps.
|
|
1844
1872
|
const mergedProperties = Object.create(null) as Record<string, JSONSchemaDefinition>;
|
|
1845
1873
|
const mergedRequired = new Set<string>();
|
|
1846
1874
|
const closedPropertySets: Set<string>[] = [];
|
|
@@ -1863,6 +1891,7 @@ function mergeObjectAllOf(
|
|
|
1863
1891
|
// first value (the outer schema, then earlier branches) instead of
|
|
1864
1892
|
// rejecting an otherwise exactly mergeable intersection.
|
|
1865
1893
|
if (!(keyword in merged)) {
|
|
1894
|
+
// SAFETY: These annotation keywords are copied unchanged from the validated branch; arbitrary values are preserved without narrowing.
|
|
1866
1895
|
(merged as any)[keyword] = (schema as any)[keyword];
|
|
1867
1896
|
}
|
|
1868
1897
|
}
|
|
@@ -1883,6 +1912,7 @@ function mergeObjectAllOf(
|
|
|
1883
1912
|
if (keyword === 'allOf' && branch === jsonSchema) {
|
|
1884
1913
|
continue;
|
|
1885
1914
|
}
|
|
1915
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
1886
1916
|
if (
|
|
1887
1917
|
(keyword === '$defs' || keyword === 'definitions') &&
|
|
1888
1918
|
isObject((branch as Record<string, unknown>)[keyword])
|
|
@@ -1978,6 +2008,7 @@ function mergeObjectAllOf(
|
|
|
1978
2008
|
if (collapsesToNull) {
|
|
1979
2009
|
merged.type = 'null';
|
|
1980
2010
|
for (const keyword of Object.keys(jsonSchema)) {
|
|
2011
|
+
// SAFETY: Only an enumerated own keyword is deleted from this mutable schema object before installing its normalized replacement.
|
|
1981
2012
|
delete (jsonSchema as any)[keyword];
|
|
1982
2013
|
}
|
|
1983
2014
|
assignSchema(jsonSchema, merged);
|
|
@@ -2010,13 +2041,14 @@ function mergeObjectAllOf(
|
|
|
2010
2041
|
}
|
|
2011
2042
|
|
|
2012
2043
|
for (const keyword of Object.keys(jsonSchema)) {
|
|
2044
|
+
// SAFETY: Only an enumerated own keyword is deleted from this mutable schema object before installing its normalized replacement.
|
|
2013
2045
|
delete (jsonSchema as any)[keyword];
|
|
2014
2046
|
}
|
|
2015
2047
|
assignSchema(jsonSchema, merged);
|
|
2016
2048
|
return true;
|
|
2017
2049
|
}
|
|
2018
2050
|
|
|
2019
|
-
function
|
|
2051
|
+
function isMergeableObjectSchema(schema: JSONSchema): boolean {
|
|
2020
2052
|
if (schema.type !== undefined) {
|
|
2021
2053
|
return isMergeableObjectType(schema.type);
|
|
2022
2054
|
}
|
|
@@ -2024,6 +2056,7 @@ function hasObjectShapeWithoutAllOf(schema: JSONSchema): boolean {
|
|
|
2024
2056
|
}
|
|
2025
2057
|
|
|
2026
2058
|
function hasOnlyNeutralAllOfBranchKeywords(schema: JSONSchema): boolean {
|
|
2059
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
2027
2060
|
const schemaRecord = schema as Record<string, unknown>;
|
|
2028
2061
|
return Object.keys(schema).every(
|
|
2029
2062
|
(keyword) =>
|
|
@@ -2056,7 +2089,9 @@ function schemasEqual(left: unknown, right: unknown): boolean {
|
|
|
2056
2089
|
return false;
|
|
2057
2090
|
}
|
|
2058
2091
|
|
|
2092
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
2059
2093
|
const leftRecord = left as Record<string, unknown>;
|
|
2094
|
+
// SAFETY: This is an object schema at this traversal point; the record view permits dynamic keyword access while individual values remain subject to schema checks.
|
|
2060
2095
|
const rightRecord = right as Record<string, unknown>;
|
|
2061
2096
|
const leftKeys = Object.keys(leftRecord);
|
|
2062
2097
|
const rightKeys = Object.keys(rightRecord);
|
|
@@ -36,6 +36,7 @@ export class WebRTCConnection<ClientEvent, ServerEvent extends { type: string }>
|
|
|
36
36
|
|
|
37
37
|
/** Creates native resources, but does not request media, contact a server, or begin negotiation. */
|
|
38
38
|
constructor(configuration?: WebRTCConfiguration) {
|
|
39
|
+
// SAFETY: RTCPeerConnection is an optional runtime constructor checked before resource creation; the view keeps browser ambient types optional.
|
|
39
40
|
const host = globalThis as typeof globalThis & {
|
|
40
41
|
RTCPeerConnection?: new (configuration?: WebRTCConfiguration) => WebRTCPeerConnection;
|
|
41
42
|
};
|
|
@@ -59,7 +60,7 @@ export class WebRTCConnection<ClientEvent, ServerEvent extends { type: string }>
|
|
|
59
60
|
);
|
|
60
61
|
}
|
|
61
62
|
this.peer = peer;
|
|
62
|
-
this.peerConnection = peer
|
|
63
|
+
this.peerConnection = peer;
|
|
63
64
|
this.dataChannel = this.adapter.dataChannel;
|
|
64
65
|
peer.addEventListener('connectionstatechange', this.onPeerState);
|
|
65
66
|
this.adapter.onConnectionEvent(this.onChannelEvent);
|
|
@@ -73,17 +74,20 @@ export class WebRTCConnection<ClientEvent, ServerEvent extends { type: string }>
|
|
|
73
74
|
/** Subscribes to one server event type with its generated payload; returns an independent unsubscribe function. */
|
|
74
75
|
on<Type extends ServerEvent['type']>(
|
|
75
76
|
type: Type,
|
|
77
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- The existing public listener contract accepts any callback result; subscriptions discard it.
|
|
76
78
|
handler: (event: Extract<ServerEvent, { type: Type }>) => unknown,
|
|
77
79
|
): () => void {
|
|
78
80
|
return this.adapter.on(type, handler);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
/** Subscribes before connecting so initial server events are observable. API errors remain protocol data. */
|
|
84
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- The existing public listener contract accepts any callback result; subscriptions discard it.
|
|
82
85
|
onEvent(handler: (event: ServerEvent) => unknown): () => void {
|
|
83
86
|
return this.adapter.onEvent(handler);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
/** Subscribes to local diagnostics and lifecycle. Setup failures reject connect() instead of emitting errors here. */
|
|
90
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- The existing public listener contract accepts any callback result; subscriptions discard it.
|
|
87
91
|
onConnectionEvent(handler: (event: WebRTCConnectionEvent) => unknown): () => void {
|
|
88
92
|
if (this.currentState === 'closed') {
|
|
89
93
|
throw new WebRTCError('invalid_state', 'transport', 'The WebRTC connection is closed.');
|
|
@@ -14,6 +14,7 @@ export class DataChannel<ClientEvent, ServerEvent extends { type: string }> {
|
|
|
14
14
|
/** Attaches listeners without negotiating, opening, or taking ownership of the channel. */
|
|
15
15
|
constructor(channel: WebRTCDataChannel) {
|
|
16
16
|
this.channel = channel;
|
|
17
|
+
// SAFETY: Expose the supplied channel unchanged through the public alias, which uses native browser typings when DOM globals are present.
|
|
17
18
|
this.dataChannel = channel as BrowserDataChannel;
|
|
18
19
|
channel.addEventListener('message', this.onMessage);
|
|
19
20
|
channel.addEventListener('error', this.onError);
|
|
@@ -24,20 +25,24 @@ export class DataChannel<ClientEvent, ServerEvent extends { type: string }> {
|
|
|
24
25
|
/** Subscribes to one server event type with its generated payload; returns an independent unsubscribe function. */
|
|
25
26
|
on<Type extends ServerEvent['type']>(
|
|
26
27
|
type: Type,
|
|
28
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- The existing public listener contract accepts any callback result; subscriptions discard it.
|
|
27
29
|
handler: (event: Extract<ServerEvent, { type: Type }>) => unknown,
|
|
28
30
|
): () => void {
|
|
29
31
|
this.assertActive();
|
|
30
32
|
// The shared dispatcher matches the original discriminator before invoking this callback.
|
|
33
|
+
// SAFETY: The dispatcher checks the event discriminator against type before invoking this handler, preserving the corresponding union member.
|
|
31
34
|
return this.events.add((event) => handler(event as Extract<ServerEvent, { type: Type }>), type);
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
/** Subscribes to future server events, including raw API errors; returns an unsubscribe function. */
|
|
38
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- The existing public listener contract accepts any callback result; subscriptions discard it.
|
|
35
39
|
onEvent(handler: (event: ServerEvent) => unknown): () => void {
|
|
36
40
|
this.assertActive();
|
|
37
41
|
return this.events.add(handler);
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
/** Observes only this channel's local errors and lifecycle, not its owning peer connection. */
|
|
45
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- The existing public listener contract accepts any callback result; subscriptions discard it.
|
|
41
46
|
onConnectionEvent(handler: (event: WebRTCConnectionEvent) => unknown): () => void {
|
|
42
47
|
this.assertActive();
|
|
43
48
|
return this.connectionEvents.add(handler);
|
|
@@ -86,6 +91,7 @@ export class DataChannel<ClientEvent, ServerEvent extends { type: string }> {
|
|
|
86
91
|
}
|
|
87
92
|
let event: unknown;
|
|
88
93
|
try {
|
|
94
|
+
// SAFETY: The message event boundary reads only optional data and then checks it is a string before parsing.
|
|
89
95
|
const { data } = message as { data?: unknown };
|
|
90
96
|
if (typeof data !== 'string') {
|
|
91
97
|
throw new TypeError('Invalid protocol message.');
|
|
@@ -109,6 +115,7 @@ export class DataChannel<ClientEvent, ServerEvent extends { type: string }> {
|
|
|
109
115
|
return;
|
|
110
116
|
}
|
|
111
117
|
// Like the generated SDK, accept future event types without a runtime schema registry.
|
|
118
|
+
// SAFETY: The parsed event passed the object and string-discriminator checks; future server event types remain intentionally accepted.
|
|
112
119
|
this.events.emit(event as ServerEvent);
|
|
113
120
|
};
|
|
114
121
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
function reportApplicationError(error: unknown): void {
|
|
2
|
+
// SAFETY: reportError is an optional host facility and is checked to be callable before forwarding an application error.
|
|
2
3
|
const host = globalThis as typeof globalThis & { reportError?: (error: unknown) => void };
|
|
3
4
|
if (typeof host.reportError === 'function') {
|
|
4
5
|
host.reportError(error);
|
|
@@ -20,11 +21,13 @@ async function observeResult(result: unknown): Promise<void> {
|
|
|
20
21
|
/** Internal callback subscriptions with optional discriminator filters; no buffering or replay. */
|
|
21
22
|
export class Subscriptions<Event extends { type: string }> {
|
|
22
23
|
private readonly listeners = new Set<{
|
|
24
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- The existing public listener contract accepts any callback result; subscriptions discard it.
|
|
23
25
|
listener: (event: Event) => unknown;
|
|
24
26
|
type: Event['type'] | undefined;
|
|
25
27
|
}>();
|
|
26
28
|
|
|
27
29
|
/** Registers independently, including when the same function is supplied twice. */
|
|
30
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- The existing public listener contract accepts any callback result; subscriptions discard it.
|
|
28
31
|
add(listener: (event: Event) => unknown, type?: Event['type']): () => void {
|
|
29
32
|
const registration = { listener, type };
|
|
30
33
|
this.listeners.add(registration);
|
package/src/lib/webrtc/types.ts
CHANGED
|
@@ -55,6 +55,7 @@ export type BrowserDataChannel = typeof globalThis extends {
|
|
|
55
55
|
|
|
56
56
|
/** Standard RTCConfiguration in a browser project; no runtime polyfill is installed. */
|
|
57
57
|
export type WebRTCConfiguration = typeof globalThis extends {
|
|
58
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- This public conditional type extracts browser constructor parameters without constraining the instance type.
|
|
58
59
|
RTCPeerConnection: new (configuration?: infer Configuration) => unknown;
|
|
59
60
|
}
|
|
60
61
|
? Configuration
|