openai 7.5.0 → 7.7.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 +117 -0
- package/README.md +46 -2
- package/auth/index.d.mts +1 -1
- package/auth/index.d.mts.map +1 -1
- package/auth/index.d.ts +1 -1
- package/auth/index.d.ts.map +1 -1
- package/auth/index.js.map +1 -1
- package/auth/index.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 +176 -4
- package/auth/subject-token-providers.js.map +1 -1
- package/auth/subject-token-providers.mjs +176 -4
- package/auth/subject-token-providers.mjs.map +1 -1
- package/auth/types.d.mts +17 -0
- package/auth/types.d.mts.map +1 -1
- package/auth/types.d.ts +17 -0
- package/auth/types.d.ts.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 +80 -7
- package/auth/workload-identity-auth.js.map +1 -1
- package/auth/workload-identity-auth.mjs +80 -7
- package/auth/workload-identity-auth.mjs.map +1 -1
- package/auth/x509-transport.d.mts +5 -0
- package/auth/x509-transport.d.mts.map +1 -0
- package/auth/x509-transport.d.ts +5 -0
- package/auth/x509-transport.d.ts.map +1 -0
- package/auth/x509-transport.js +39 -0
- package/auth/x509-transport.js.map +1 -0
- package/auth/x509-transport.mjs +36 -0
- package/auth/x509-transport.mjs.map +1 -0
- package/azure.d.mts +11 -2
- package/azure.d.mts.map +1 -1
- package/azure.d.ts +11 -2
- package/azure.d.ts.map +1 -1
- package/azure.js +7 -1
- package/azure.js.map +1 -1
- package/azure.mjs +7 -1
- package/azure.mjs.map +1 -1
- package/bedrock.d.mts +6 -2
- package/bedrock.d.mts.map +1 -1
- package/bedrock.d.ts +6 -2
- package/bedrock.d.ts.map +1 -1
- package/bedrock.js +34 -4
- package/bedrock.js.map +1 -1
- package/bedrock.mjs +35 -5
- package/bedrock.mjs.map +1 -1
- package/beta/realtime/internal-base.d.mts +2 -0
- package/beta/realtime/internal-base.d.mts.map +1 -1
- package/beta/realtime/internal-base.d.ts +2 -0
- package/beta/realtime/internal-base.d.ts.map +1 -1
- package/beta/realtime/internal-base.js +15 -0
- package/beta/realtime/internal-base.js.map +1 -1
- package/beta/realtime/internal-base.mjs +14 -0
- package/beta/realtime/internal-base.mjs.map +1 -1
- package/beta/realtime/websocket.d.mts +11 -5
- package/beta/realtime/websocket.d.mts.map +1 -1
- package/beta/realtime/websocket.d.ts +11 -5
- package/beta/realtime/websocket.d.ts.map +1 -1
- package/beta/realtime/websocket.js +106 -31
- package/beta/realtime/websocket.js.map +1 -1
- package/beta/realtime/websocket.mjs +107 -32
- package/beta/realtime/websocket.mjs.map +1 -1
- package/beta/realtime/ws.d.mts +0 -2
- package/beta/realtime/ws.d.mts.map +1 -1
- package/beta/realtime/ws.d.ts +0 -2
- package/beta/realtime/ws.d.ts.map +1 -1
- package/beta/realtime/ws.js +24 -5
- package/beta/realtime/ws.js.map +1 -1
- package/beta/realtime/ws.mjs +25 -6
- package/beta/realtime/ws.mjs.map +1 -1
- package/client.d.mts +17 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +17 -2
- package/client.d.ts.map +1 -1
- package/client.js +422 -70
- package/client.js.map +1 -1
- package/client.mjs +423 -71
- 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 +67 -9
- package/core/EventEmitter.js.map +1 -1
- package/core/EventEmitter.mjs +68 -10
- 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 +216 -26
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +216 -26
- package/core/streaming.mjs.map +1 -1
- package/helpers/audio.d.mts +5 -5
- package/helpers/audio.d.mts.map +1 -1
- package/helpers/audio.d.ts +5 -5
- package/helpers/audio.d.ts.map +1 -1
- package/helpers/audio.js +93 -22
- package/helpers/audio.js.map +1 -1
- package/helpers/audio.mjs +93 -22
- 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 +34 -14
- package/helpers/standard-schema.js.map +1 -1
- package/helpers/standard-schema.mjs +35 -15
- package/helpers/standard-schema.mjs.map +1 -1
- package/helpers/zod-v3-strict-schema.d.mts +7 -0
- package/helpers/zod-v3-strict-schema.d.mts.map +1 -0
- package/helpers/zod-v3-strict-schema.d.ts +7 -0
- package/helpers/zod-v3-strict-schema.d.ts.map +1 -0
- package/helpers/zod-v3-strict-schema.js +403 -0
- package/helpers/zod-v3-strict-schema.js.map +1 -0
- package/helpers/zod-v3-strict-schema.mjs +399 -0
- package/helpers/zod-v3-strict-schema.mjs.map +1 -0
- package/helpers/zod.d.mts.map +1 -1
- package/helpers/zod.d.ts.map +1 -1
- package/helpers/zod.js +11 -3
- package/helpers/zod.js.map +1 -1
- package/helpers/zod.mjs +12 -4
- package/helpers/zod.mjs.map +1 -1
- package/index.d.mts +1 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/index.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 +28 -8
- package/internal/assistant-stream-delta.js.map +1 -1
- package/internal/assistant-stream-delta.mjs +28 -8
- package/internal/assistant-stream-delta.mjs.map +1 -1
- package/internal/auth/x509-token-exchange.d.mts +16 -0
- package/internal/auth/x509-token-exchange.d.mts.map +1 -0
- package/internal/auth/x509-token-exchange.d.ts +16 -0
- package/internal/auth/x509-token-exchange.d.ts.map +1 -0
- package/internal/auth/x509-token-exchange.js +246 -0
- package/internal/auth/x509-token-exchange.js.map +1 -0
- package/internal/auth/x509-token-exchange.mjs +243 -0
- package/internal/auth/x509-token-exchange.mjs.map +1 -0
- package/internal/auth/x509-transport-capability.d.mts +37 -0
- package/internal/auth/x509-transport-capability.d.mts.map +1 -0
- package/internal/auth/x509-transport-capability.d.ts +37 -0
- package/internal/auth/x509-transport-capability.d.ts.map +1 -0
- package/internal/auth/x509-transport-capability.js +169 -0
- package/internal/auth/x509-transport-capability.js.map +1 -0
- package/internal/auth/x509-transport-capability.mjs +164 -0
- package/internal/auth/x509-transport-capability.mjs.map +1 -0
- package/internal/auth/x509-transport-registry.d.mts +63 -0
- package/internal/auth/x509-transport-registry.d.mts.map +1 -0
- package/internal/auth/x509-transport-registry.d.ts +63 -0
- package/internal/auth/x509-transport-registry.d.ts.map +1 -0
- package/internal/auth/x509-transport-registry.js +53 -0
- package/internal/auth/x509-transport-registry.js.map +1 -0
- package/internal/auth/x509-transport-registry.mjs +48 -0
- package/internal/auth/x509-transport-registry.mjs.map +1 -0
- package/internal/auth/x509-transport-state-browser.d.mts +21 -0
- package/internal/auth/x509-transport-state-browser.d.mts.map +1 -0
- package/internal/auth/x509-transport-state-browser.d.ts +21 -0
- package/internal/auth/x509-transport-state-browser.d.ts.map +1 -0
- package/internal/auth/x509-transport-state-browser.js +30 -0
- package/internal/auth/x509-transport-state-browser.js.map +1 -0
- package/internal/auth/x509-transport-state-browser.mjs +27 -0
- package/internal/auth/x509-transport-state-browser.mjs.map +1 -0
- package/internal/auth/x509-transport-state.cjs +30 -0
- package/internal/auth/x509-transport-state.cjs.map +1 -0
- package/internal/auth/x509-transport-state.d.cts +21 -0
- package/internal/auth/x509-transport-state.d.cts.map +1 -0
- package/internal/auth/x509-workload-identity-auth.d.mts +128 -0
- package/internal/auth/x509-workload-identity-auth.d.mts.map +1 -0
- package/internal/auth/x509-workload-identity-auth.d.ts +128 -0
- package/internal/auth/x509-workload-identity-auth.d.ts.map +1 -0
- package/internal/auth/x509-workload-identity-auth.js +767 -0
- package/internal/auth/x509-workload-identity-auth.js.map +1 -0
- package/internal/auth/x509-workload-identity-auth.mjs +757 -0
- package/internal/auth/x509-workload-identity-auth.mjs.map +1 -0
- package/internal/bedrock.d.mts +2 -0
- package/internal/bedrock.d.mts.map +1 -1
- package/internal/bedrock.d.ts +2 -0
- package/internal/bedrock.d.ts.map +1 -1
- package/internal/bedrock.js +169 -5
- package/internal/bedrock.js.map +1 -1
- package/internal/bedrock.mjs +168 -5
- package/internal/bedrock.mjs.map +1 -1
- package/internal/data-residency.d.mts +12 -0
- package/internal/data-residency.d.mts.map +1 -0
- package/internal/data-residency.d.ts +12 -0
- package/internal/data-residency.d.ts.map +1 -0
- package/internal/data-residency.js +34 -0
- package/internal/data-residency.js.map +1 -0
- package/internal/data-residency.mjs +30 -0
- package/internal/data-residency.mjs.map +1 -0
- package/internal/multipart-encoding.d.mts +8 -0
- package/internal/multipart-encoding.d.mts.map +1 -0
- package/internal/multipart-encoding.d.ts +8 -0
- package/internal/multipart-encoding.d.ts.map +1 -0
- package/internal/multipart-encoding.js +51 -0
- package/internal/multipart-encoding.js.map +1 -0
- package/internal/multipart-encoding.mjs +48 -0
- package/internal/multipart-encoding.mjs.map +1 -0
- package/internal/qs/utils.d.mts.map +1 -1
- package/internal/qs/utils.d.ts.map +1 -1
- package/internal/qs/utils.js +307 -10
- package/internal/qs/utils.js.map +1 -1
- package/internal/qs/utils.mjs +307 -10
- package/internal/qs/utils.mjs.map +1 -1
- package/internal/request-options.d.mts +7 -0
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +7 -0
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js +43 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs +42 -1
- package/internal/request-options.mjs.map +1 -1
- package/internal/responses/canonical-output-text.js +3 -3
- package/internal/responses/canonical-output-text.js.map +1 -1
- package/internal/responses/canonical-output-text.mjs +3 -3
- package/internal/responses/canonical-output-text.mjs.map +1 -1
- package/internal/responses/response-accumulator.d.mts +1 -1
- package/internal/responses/response-accumulator.d.mts.map +1 -1
- package/internal/responses/response-accumulator.d.ts +1 -1
- package/internal/responses/response-accumulator.d.ts.map +1 -1
- package/internal/responses/response-accumulator.js +331 -25
- package/internal/responses/response-accumulator.js.map +1 -1
- package/internal/responses/response-accumulator.mjs +331 -25
- package/internal/responses/response-accumulator.mjs.map +1 -1
- package/internal/tslib.js +6 -0
- package/internal/tslib.mjs +6 -1
- package/internal/uploads.d.mts +10 -6
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +10 -6
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js +65 -24
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +65 -24
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/env.d.mts.map +1 -1
- package/internal/utils/env.d.ts.map +1 -1
- package/internal/utils/env.js +9 -4
- package/internal/utils/env.js.map +1 -1
- package/internal/utils/env.mjs +9 -4
- package/internal/utils/env.mjs.map +1 -1
- package/internal/ws.d.mts.map +1 -1
- package/internal/ws.d.ts.map +1 -1
- package/internal/ws.js +23 -1
- package/internal/ws.js.map +1 -1
- package/internal/ws.mjs +23 -1
- 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 +32 -7
- package/lib/AbstractChatCompletionRunner.js.map +1 -1
- package/lib/AbstractChatCompletionRunner.mjs +34 -9
- 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 +211 -23
- package/lib/AssistantStream.js.map +1 -1
- package/lib/AssistantStream.mjs +211 -23
- package/lib/AssistantStream.mjs.map +1 -1
- package/lib/ChatCompletionStream.d.mts +1 -1
- package/lib/ChatCompletionStream.d.mts.map +1 -1
- package/lib/ChatCompletionStream.d.ts +1 -1
- package/lib/ChatCompletionStream.d.ts.map +1 -1
- package/lib/ChatCompletionStream.js +1118 -67
- package/lib/ChatCompletionStream.js.map +1 -1
- package/lib/ChatCompletionStream.mjs +1119 -68
- 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 +67 -9
- package/lib/EventEmitter.js.map +1 -1
- package/lib/EventEmitter.mjs +68 -10
- package/lib/EventEmitter.mjs.map +1 -1
- package/lib/EventStream.d.mts +4 -0
- package/lib/EventStream.d.mts.map +1 -1
- package/lib/EventStream.d.ts +4 -0
- package/lib/EventStream.d.ts.map +1 -1
- package/lib/EventStream.js +1096 -11
- package/lib/EventStream.js.map +1 -1
- package/lib/EventStream.mjs +1097 -12
- 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 +1 -1
- package/lib/ResponsesParser.js.map +1 -1
- package/lib/ResponsesParser.mjs +1 -1
- package/lib/ResponsesParser.mjs.map +1 -1
- package/lib/Util.d.mts +2 -0
- package/lib/Util.d.mts.map +1 -1
- package/lib/Util.d.ts +2 -0
- package/lib/Util.d.ts.map +1 -1
- package/lib/Util.js +7 -4
- package/lib/Util.js.map +1 -1
- package/lib/Util.mjs +7 -4
- package/lib/Util.mjs.map +1 -1
- package/lib/assistant-run-polling.d.mts +12 -0
- package/lib/assistant-run-polling.d.mts.map +1 -0
- package/lib/assistant-run-polling.d.ts +12 -0
- package/lib/assistant-run-polling.d.ts.map +1 -0
- package/lib/assistant-run-polling.js +17 -0
- package/lib/assistant-run-polling.js.map +1 -0
- package/lib/assistant-run-polling.mjs +14 -0
- package/lib/assistant-run-polling.mjs.map +1 -0
- package/lib/embeddings.d.mts +18 -0
- package/lib/embeddings.d.mts.map +1 -0
- package/lib/embeddings.d.ts +18 -0
- package/lib/embeddings.d.ts.map +1 -0
- package/lib/embeddings.js +50 -0
- package/lib/embeddings.js.map +1 -0
- package/lib/embeddings.mjs +47 -0
- package/lib/embeddings.mjs.map +1 -0
- package/lib/file-processing.d.mts +10 -0
- package/lib/file-processing.d.mts.map +1 -0
- package/lib/file-processing.d.ts +10 -0
- package/lib/file-processing.d.ts.map +1 -0
- package/lib/file-processing.js +30 -0
- package/lib/file-processing.js.map +1 -0
- package/lib/file-processing.mjs +27 -0
- package/lib/file-processing.mjs.map +1 -0
- package/lib/parser.d.mts.map +1 -1
- package/lib/parser.d.ts.map +1 -1
- package/lib/parser.js +16 -4
- package/lib/parser.js.map +1 -1
- package/lib/parser.mjs +16 -4
- package/lib/parser.mjs.map +1 -1
- package/lib/polling.d.mts +20 -0
- package/lib/polling.d.mts.map +1 -0
- package/lib/polling.d.ts +20 -0
- package/lib/polling.d.ts.map +1 -0
- package/lib/polling.js +130 -0
- package/lib/polling.js.map +1 -0
- package/lib/polling.mjs +127 -0
- package/lib/polling.mjs.map +1 -0
- package/lib/responses/ResponseStream.d.mts.map +1 -1
- package/lib/responses/ResponseStream.d.ts.map +1 -1
- package/lib/responses/ResponseStream.js +21 -11
- package/lib/responses/ResponseStream.js.map +1 -1
- package/lib/responses/ResponseStream.mjs +21 -11
- package/lib/responses/ResponseStream.mjs.map +1 -1
- package/lib/vector-store-polling.d.mts +22 -0
- package/lib/vector-store-polling.d.mts.map +1 -0
- package/lib/vector-store-polling.d.ts +22 -0
- package/lib/vector-store-polling.d.ts.map +1 -0
- package/lib/vector-store-polling.js +24 -0
- package/lib/vector-store-polling.js.map +1 -0
- package/lib/vector-store-polling.mjs +20 -0
- package/lib/vector-store-polling.mjs.map +1 -0
- package/lib/vector-store-upload.d.mts +17 -0
- package/lib/vector-store-upload.d.mts.map +1 -0
- package/lib/vector-store-upload.d.ts +17 -0
- package/lib/vector-store-upload.d.ts.map +1 -0
- package/lib/vector-store-upload.js +37 -0
- package/lib/vector-store-upload.js.map +1 -0
- package/lib/vector-store-upload.mjs +34 -0
- package/lib/vector-store-upload.mjs.map +1 -0
- package/lib/webhook-signature.d.mts +15 -0
- package/lib/webhook-signature.d.mts.map +1 -0
- package/lib/webhook-signature.d.ts +15 -0
- package/lib/webhook-signature.d.ts.map +1 -0
- package/lib/webhook-signature.js +125 -0
- package/lib/webhook-signature.js.map +1 -0
- package/lib/webhook-signature.mjs +121 -0
- package/lib/webhook-signature.mjs.map +1 -0
- package/package.json +14 -1
- package/realtime/internal-base.d.mts +2 -0
- package/realtime/internal-base.d.mts.map +1 -1
- package/realtime/internal-base.d.ts +2 -0
- package/realtime/internal-base.d.ts.map +1 -1
- package/realtime/internal-base.js +15 -0
- package/realtime/internal-base.js.map +1 -1
- package/realtime/internal-base.mjs +14 -0
- package/realtime/internal-base.mjs.map +1 -1
- package/realtime/websocket.d.mts +3 -2
- package/realtime/websocket.d.mts.map +1 -1
- package/realtime/websocket.d.ts +3 -2
- package/realtime/websocket.d.ts.map +1 -1
- package/realtime/websocket.js +90 -26
- package/realtime/websocket.js.map +1 -1
- package/realtime/websocket.mjs +91 -27
- 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 +9 -1
- package/realtime/ws.js.map +1 -1
- package/realtime/ws.mjs +10 -2
- package/realtime/ws.mjs.map +1 -1
- package/resources/admin/organization/index.d.mts +2 -2
- package/resources/admin/organization/index.d.mts.map +1 -1
- package/resources/admin/organization/index.d.ts +2 -2
- package/resources/admin/organization/index.d.ts.map +1 -1
- package/resources/admin/organization/index.js.map +1 -1
- package/resources/admin/organization/index.mjs.map +1 -1
- package/resources/admin/organization/organization.d.mts +4 -4
- package/resources/admin/organization/organization.d.mts.map +1 -1
- package/resources/admin/organization/organization.d.ts +4 -4
- package/resources/admin/organization/organization.d.ts.map +1 -1
- package/resources/admin/organization/organization.js.map +1 -1
- package/resources/admin/organization/organization.mjs.map +1 -1
- package/resources/admin/organization/projects/index.d.mts +1 -1
- package/resources/admin/organization/projects/index.d.mts.map +1 -1
- package/resources/admin/organization/projects/index.d.ts +1 -1
- package/resources/admin/organization/projects/index.d.ts.map +1 -1
- package/resources/admin/organization/projects/index.js.map +1 -1
- package/resources/admin/organization/projects/index.mjs.map +1 -1
- package/resources/admin/organization/projects/projects.d.mts +22 -5
- package/resources/admin/organization/projects/projects.d.mts.map +1 -1
- package/resources/admin/organization/projects/projects.d.ts +22 -5
- package/resources/admin/organization/projects/projects.d.ts.map +1 -1
- package/resources/admin/organization/projects/projects.js.map +1 -1
- package/resources/admin/organization/projects/projects.mjs.map +1 -1
- package/resources/admin/organization/usage.d.mts +62 -1
- package/resources/admin/organization/usage.d.mts.map +1 -1
- package/resources/admin/organization/usage.d.ts +62 -1
- package/resources/admin/organization/usage.d.ts.map +1 -1
- package/resources/admin/organization/usage.js.map +1 -1
- package/resources/admin/organization/usage.mjs.map +1 -1
- package/resources/beta/responses/internal-base.d.mts.map +1 -1
- package/resources/beta/responses/internal-base.d.ts.map +1 -1
- package/resources/beta/responses/internal-base.js +2 -0
- package/resources/beta/responses/internal-base.js.map +1 -1
- package/resources/beta/responses/internal-base.mjs +2 -0
- package/resources/beta/responses/internal-base.mjs.map +1 -1
- package/resources/beta/responses/responses.d.mts +17 -20
- package/resources/beta/responses/responses.d.mts.map +1 -1
- package/resources/beta/responses/responses.d.ts +17 -20
- 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/threads/runs/index.d.mts +1 -1
- package/resources/beta/threads/runs/index.d.mts.map +1 -1
- package/resources/beta/threads/runs/index.d.ts +1 -1
- package/resources/beta/threads/runs/index.d.ts.map +1 -1
- package/resources/beta/threads/runs/runs.d.mts.map +1 -1
- package/resources/beta/threads/runs/runs.d.ts.map +1 -1
- package/resources/beta/threads/runs/runs.js +2 -43
- package/resources/beta/threads/runs/runs.js.map +1 -1
- package/resources/beta/threads/runs/runs.mjs +2 -43
- package/resources/beta/threads/runs/runs.mjs.map +1 -1
- package/resources/chat/completions/completions.d.mts +6 -0
- package/resources/chat/completions/completions.d.mts.map +1 -1
- package/resources/chat/completions/completions.d.ts +6 -0
- package/resources/chat/completions/completions.d.ts.map +1 -1
- package/resources/chat/completions/completions.js.map +1 -1
- package/resources/chat/completions/completions.mjs.map +1 -1
- package/resources/embeddings.d.mts.map +1 -1
- package/resources/embeddings.d.ts.map +1 -1
- package/resources/embeddings.js +2 -36
- package/resources/embeddings.js.map +1 -1
- package/resources/embeddings.mjs +2 -36
- package/resources/embeddings.mjs.map +1 -1
- package/resources/files.d.mts.map +1 -1
- package/resources/files.d.ts.map +1 -1
- package/resources/files.js +2 -15
- package/resources/files.js.map +1 -1
- package/resources/files.mjs +2 -15
- package/resources/files.mjs.map +1 -1
- package/resources/images.d.mts +12 -22
- package/resources/images.d.mts.map +1 -1
- package/resources/images.d.ts +12 -22
- package/resources/images.d.ts.map +1 -1
- package/resources/realtime/calls.d.mts +23 -1
- package/resources/realtime/calls.d.mts.map +1 -1
- package/resources/realtime/calls.d.ts +23 -1
- package/resources/realtime/calls.d.ts.map +1 -1
- package/resources/realtime/calls.js +24 -0
- package/resources/realtime/calls.js.map +1 -1
- package/resources/realtime/calls.mjs +24 -0
- package/resources/realtime/calls.mjs.map +1 -1
- package/resources/realtime/index.d.mts +1 -1
- package/resources/realtime/index.d.mts.map +1 -1
- package/resources/realtime/index.d.ts +1 -1
- package/resources/realtime/index.d.ts.map +1 -1
- package/resources/realtime/index.js.map +1 -1
- package/resources/realtime/index.mjs +1 -1
- package/resources/realtime/index.mjs.map +1 -1
- package/resources/realtime/realtime.d.mts +5 -4
- package/resources/realtime/realtime.d.mts.map +1 -1
- package/resources/realtime/realtime.d.ts +5 -4
- package/resources/realtime/realtime.d.ts.map +1 -1
- package/resources/realtime/realtime.js.map +1 -1
- package/resources/realtime/realtime.mjs.map +1 -1
- package/resources/responses/internal-base.d.mts.map +1 -1
- package/resources/responses/internal-base.d.ts.map +1 -1
- package/resources/responses/internal-base.js +2 -0
- package/resources/responses/internal-base.js.map +1 -1
- package/resources/responses/internal-base.mjs +2 -0
- package/resources/responses/internal-base.mjs.map +1 -1
- package/resources/responses/responses.d.mts +17 -20
- package/resources/responses/responses.d.mts.map +1 -1
- package/resources/responses/responses.d.ts +17 -20
- 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/vector-stores/file-batches.d.mts.map +1 -1
- package/resources/vector-stores/file-batches.d.ts.map +1 -1
- package/resources/vector-stores/file-batches.js +4 -61
- package/resources/vector-stores/file-batches.js.map +1 -1
- package/resources/vector-stores/file-batches.mjs +4 -61
- package/resources/vector-stores/file-batches.mjs.map +1 -1
- package/resources/vector-stores/files.d.mts +1 -1
- package/resources/vector-stores/files.d.mts.map +1 -1
- package/resources/vector-stores/files.d.ts +1 -1
- package/resources/vector-stores/files.d.ts.map +1 -1
- package/resources/vector-stores/files.js +2 -35
- package/resources/vector-stores/files.js.map +1 -1
- package/resources/vector-stores/files.mjs +2 -35
- package/resources/vector-stores/files.mjs.map +1 -1
- package/resources/webhooks/webhooks.d.mts.map +1 -1
- package/resources/webhooks/webhooks.d.ts.map +1 -1
- package/resources/webhooks/webhooks.js +5 -43
- package/resources/webhooks/webhooks.js.map +1 -1
- package/resources/webhooks/webhooks.mjs +5 -43
- package/resources/webhooks/webhooks.mjs.map +1 -1
- package/src/auth/index.ts +6 -1
- package/src/auth/subject-token-providers.ts +196 -4
- package/src/auth/types.ts +24 -0
- package/src/auth/workload-identity-auth.ts +104 -7
- package/src/auth/x509-transport.ts +49 -0
- package/src/azure.ts +22 -1
- package/src/bedrock.ts +49 -5
- package/src/beta/realtime/internal-base.ts +15 -0
- package/src/beta/realtime/websocket.ts +148 -40
- package/src/beta/realtime/ws.ts +31 -13
- package/src/client.ts +536 -92
- package/src/core/EventEmitter.ts +91 -7
- package/src/core/streaming.ts +226 -30
- package/src/helpers/audio.ts +93 -22
- package/src/helpers/standard-schema.ts +50 -16
- package/src/helpers/zod-v3-strict-schema.ts +514 -0
- package/src/helpers/zod.ts +17 -4
- package/src/index.ts +1 -1
- package/src/internal/assistant-stream-delta.ts +33 -10
- package/src/internal/auth/x509-token-exchange.ts +310 -0
- package/src/internal/auth/x509-transport-capability.ts +219 -0
- package/src/internal/auth/x509-transport-registry.ts +118 -0
- package/src/internal/auth/x509-transport-state-browser.ts +36 -0
- package/src/internal/auth/x509-transport-state.cts +36 -0
- package/src/internal/auth/x509-workload-identity-auth.ts +958 -0
- package/src/internal/bedrock.ts +182 -5
- package/src/internal/data-residency.ts +44 -0
- package/src/internal/multipart-encoding.ts +53 -0
- package/src/internal/qs/utils.ts +375 -13
- package/src/internal/request-options.ts +52 -1
- package/src/internal/responses/canonical-output-text.ts +3 -3
- package/src/internal/responses/response-accumulator.ts +411 -24
- package/src/internal/uploads.ts +81 -26
- package/src/internal/utils/env.ts +9 -5
- package/src/internal/ws.ts +24 -3
- package/src/lib/AbstractChatCompletionRunner.ts +33 -6
- package/src/lib/AssistantStream.ts +262 -22
- package/src/lib/ChatCompletionStream.ts +1467 -103
- package/src/lib/EventEmitter.ts +91 -7
- package/src/lib/EventStream.ts +1483 -10
- package/src/lib/ResponsesParser.ts +4 -1
- package/src/lib/Util.ts +7 -5
- package/src/lib/assistant-run-polling.ts +27 -0
- package/src/lib/embeddings.ts +65 -0
- package/src/lib/file-processing.ts +36 -0
- package/src/lib/parser.ts +19 -4
- package/src/lib/polling.ts +144 -0
- package/src/lib/responses/ResponseStream.ts +22 -10
- package/src/lib/vector-store-polling.ts +46 -0
- package/src/lib/vector-store-upload.ts +53 -0
- package/src/lib/webhook-signature.ts +164 -0
- package/src/realtime/internal-base.ts +15 -0
- package/src/realtime/websocket.ts +130 -27
- package/src/realtime/ws.ts +15 -2
- package/src/resources/admin/organization/index.ts +2 -0
- package/src/resources/admin/organization/organization.ts +4 -0
- package/src/resources/admin/organization/projects/index.ts +1 -0
- package/src/resources/admin/organization/projects/projects.ts +37 -4
- package/src/resources/admin/organization/usage.ts +83 -0
- package/src/resources/beta/responses/internal-base.ts +2 -0
- package/src/resources/beta/responses/responses.ts +19 -22
- package/src/resources/beta/threads/runs/index.ts +1 -1
- package/src/resources/beta/threads/runs/runs.ts +2 -45
- package/src/resources/chat/completions/completions.ts +7 -0
- package/src/resources/embeddings.ts +2 -42
- package/src/resources/files.ts +2 -19
- package/src/resources/images.ts +12 -22
- package/src/resources/realtime/api.md +1 -0
- package/src/resources/realtime/calls.ts +46 -0
- package/src/resources/realtime/index.ts +7 -1
- package/src/resources/realtime/realtime.ts +5 -3
- package/src/resources/responses/internal-base.ts +2 -0
- package/src/resources/responses/responses.ts +19 -22
- package/src/resources/vector-stores/file-batches.ts +8 -77
- package/src/resources/vector-stores/files.ts +3 -43
- package/src/resources/webhooks/webhooks.ts +5 -61
- 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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.resolveDataResidency = resolveDataResidency;
|
|
5
|
+
exports.assertNoDataResidency = assertNoDataResidency;
|
|
6
|
+
const error_1 = require("../core/error.js");
|
|
7
|
+
const values_1 = require("./utils/values.js");
|
|
8
|
+
const endpoints = new Map([
|
|
9
|
+
['global', 'https://api.openai.com/v1'],
|
|
10
|
+
['us', 'https://us.api.openai.com/v1'],
|
|
11
|
+
['eu', 'https://eu.api.openai.com/v1'],
|
|
12
|
+
['ae', 'https://ae.api.openai.com/v1'],
|
|
13
|
+
]);
|
|
14
|
+
/** Resolves an explicit residency selection before client options are inherited. */
|
|
15
|
+
function resolveDataResidency(options) {
|
|
16
|
+
if (options.dataResidency === null || options.dataResidency === undefined) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
if ((0, values_1.hasOwn)(options, 'baseURL')) {
|
|
20
|
+
throw new error_1.OpenAIError('The `dataResidency` and `baseURL` options are mutually exclusive.');
|
|
21
|
+
}
|
|
22
|
+
const endpoint = endpoints.get(options.dataResidency);
|
|
23
|
+
if (endpoint === undefined) {
|
|
24
|
+
throw new error_1.OpenAIError('Invalid `dataResidency`; expected one of: global, us, eu, ae.');
|
|
25
|
+
}
|
|
26
|
+
return endpoint;
|
|
27
|
+
}
|
|
28
|
+
/** Prevents legacy provider clients from selecting an OpenAI endpoint. */
|
|
29
|
+
function assertNoDataResidency(dataResidency, clientName) {
|
|
30
|
+
if (dataResidency !== null && dataResidency !== undefined) {
|
|
31
|
+
throw new error_1.OpenAIError(`${clientName} does not support \`dataResidency\`.`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=data-residency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-residency.js","sourceRoot":"","sources":["../src/internal/data-residency.ts"],"names":[],"mappings":";AAAA,qFAAqF;;AAgBrF,oDAiBC;AAGD,sDAOC;AAzCD,4CAA4C;AAC5C,8CAAwC;AAKxC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAwB;IAC/C,CAAC,QAAQ,EAAE,2BAA2B,CAAC;IACvC,CAAC,IAAI,EAAE,8BAA8B,CAAC;IACtC,CAAC,IAAI,EAAE,8BAA8B,CAAC;IACtC,CAAC,IAAI,EAAE,8BAA8B,CAAC;CACvC,CAAC,CAAC;AAEH,oFAAoF;AACpF,SAAgB,oBAAoB,CAAC,OAKpC;IACC,IAAI,OAAO,CAAC,aAAa,KAAK,IAAI,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QAC1E,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,IAAA,eAAM,EAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,mBAAW,CAAC,mEAAmE,CAAC,CAAC;IAC7F,CAAC;IACD,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACtD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,mBAAW,CAAC,+DAA+D,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,0EAA0E;AAC1E,SAAgB,qBAAqB,CACnC,aAA+C,EAC/C,UAAkB;IAElB,IAAI,aAAa,KAAK,IAAI,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAC1D,MAAM,IAAI,mBAAW,CAAC,GAAG,UAAU,sCAAsC,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
2
|
+
import { OpenAIError } from "../core/error.mjs";
|
|
3
|
+
import { hasOwn } from "./utils/values.mjs";
|
|
4
|
+
const endpoints = new Map([
|
|
5
|
+
['global', 'https://api.openai.com/v1'],
|
|
6
|
+
['us', 'https://us.api.openai.com/v1'],
|
|
7
|
+
['eu', 'https://eu.api.openai.com/v1'],
|
|
8
|
+
['ae', 'https://ae.api.openai.com/v1'],
|
|
9
|
+
]);
|
|
10
|
+
/** Resolves an explicit residency selection before client options are inherited. */
|
|
11
|
+
export function resolveDataResidency(options) {
|
|
12
|
+
if (options.dataResidency === null || options.dataResidency === undefined) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
if (hasOwn(options, 'baseURL')) {
|
|
16
|
+
throw new OpenAIError('The `dataResidency` and `baseURL` options are mutually exclusive.');
|
|
17
|
+
}
|
|
18
|
+
const endpoint = endpoints.get(options.dataResidency);
|
|
19
|
+
if (endpoint === undefined) {
|
|
20
|
+
throw new OpenAIError('Invalid `dataResidency`; expected one of: global, us, eu, ae.');
|
|
21
|
+
}
|
|
22
|
+
return endpoint;
|
|
23
|
+
}
|
|
24
|
+
/** Prevents legacy provider clients from selecting an OpenAI endpoint. */
|
|
25
|
+
export function assertNoDataResidency(dataResidency, clientName) {
|
|
26
|
+
if (dataResidency !== null && dataResidency !== undefined) {
|
|
27
|
+
throw new OpenAIError(`${clientName} does not support \`dataResidency\`.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=data-residency.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-residency.mjs","sourceRoot":"","sources":["../src/internal/data-residency.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,MAAM,EAAE,2BAAuB;AAKxC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAwB;IAC/C,CAAC,QAAQ,EAAE,2BAA2B,CAAC;IACvC,CAAC,IAAI,EAAE,8BAA8B,CAAC;IACtC,CAAC,IAAI,EAAE,8BAA8B,CAAC;IACtC,CAAC,IAAI,EAAE,8BAA8B,CAAC;CACvC,CAAC,CAAC;AAEH,oFAAoF;AACpF,MAAM,UAAU,oBAAoB,CAAC,OAKpC;IACC,IAAI,OAAO,CAAC,aAAa,KAAK,IAAI,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QAC1E,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,WAAW,CAAC,mEAAmE,CAAC,CAAC;IAC7F,CAAC;IACD,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACtD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,WAAW,CAAC,+DAA+D,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,qBAAqB,CACnC,aAA+C,EAC/C,UAAkB;IAElB,IAAI,aAAa,KAAK,IAAI,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAC1D,MAAM,IAAI,WAAW,CAAC,GAAG,UAAU,sCAAsC,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { multipartFormRequestOptions } from "./uploads.mjs";
|
|
2
|
+
import type { RequestOptions } from "./request-options.mjs";
|
|
3
|
+
/** Encode explicitly typed fields as single, filename-less multipart parts. */
|
|
4
|
+
export declare function encodedMultipartFormRequestOptions(options: RequestOptions, client: Parameters<typeof multipartFormRequestOptions>[1], encodings: Record<string, {
|
|
5
|
+
content_type: string;
|
|
6
|
+
json: boolean;
|
|
7
|
+
}>, rawBodyField?: string | null): Promise<RequestOptions>;
|
|
8
|
+
//# sourceMappingURL=multipart-encoding.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multipart-encoding.d.mts","sourceRoot":"","sources":["../src/internal/multipart-encoding.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAY,sBAAkB;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA0B;AAExD,+EAA+E;AAC/E,wBAAsB,kCAAkC,CACtD,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC,CAAC,CAAC,EACzD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,EAClE,YAAY,GAAE,MAAM,GAAG,IAAW,GACjC,OAAO,CAAC,cAAc,CAAC,CAwCzB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { multipartFormRequestOptions } from "./uploads.js";
|
|
2
|
+
import type { RequestOptions } from "./request-options.js";
|
|
3
|
+
/** Encode explicitly typed fields as single, filename-less multipart parts. */
|
|
4
|
+
export declare function encodedMultipartFormRequestOptions(options: RequestOptions, client: Parameters<typeof multipartFormRequestOptions>[1], encodings: Record<string, {
|
|
5
|
+
content_type: string;
|
|
6
|
+
json: boolean;
|
|
7
|
+
}>, rawBodyField?: string | null): Promise<RequestOptions>;
|
|
8
|
+
//# sourceMappingURL=multipart-encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multipart-encoding.d.ts","sourceRoot":"","sources":["../src/internal/multipart-encoding.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAY,qBAAkB;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,6BAA0B;AAExD,+EAA+E;AAC/E,wBAAsB,kCAAkC,CACtD,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC,CAAC,CAAC,EACzD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,EAClE,YAAY,GAAE,MAAM,GAAG,IAAW,GACjC,OAAO,CAAC,cAAc,CAAC,CAwCzB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.encodedMultipartFormRequestOptions = encodedMultipartFormRequestOptions;
|
|
5
|
+
const uploads_1 = require("./uploads.js");
|
|
6
|
+
const headers_1 = require("./headers.js");
|
|
7
|
+
/** Encode explicitly typed fields as single, filename-less multipart parts. */
|
|
8
|
+
async function encodedMultipartFormRequestOptions(options, client, encodings, rawBodyField = null) {
|
|
9
|
+
if (options.body === null || typeof options.body !== 'object' || Array.isArray(options.body)) {
|
|
10
|
+
throw new TypeError('Multipart request body must be an object');
|
|
11
|
+
}
|
|
12
|
+
const body = Object.fromEntries(Object.entries(options.body).filter(([, value]) => value !== undefined));
|
|
13
|
+
if (rawBodyField !== null &&
|
|
14
|
+
Object.keys(body).length === 1 &&
|
|
15
|
+
Object.prototype.hasOwnProperty.call(body, rawBodyField)) {
|
|
16
|
+
const value = body[rawBodyField];
|
|
17
|
+
if (typeof value !== 'string')
|
|
18
|
+
throw new TypeError('Raw multipart alternative must be a string');
|
|
19
|
+
return {
|
|
20
|
+
...options,
|
|
21
|
+
body: value,
|
|
22
|
+
headers: (0, headers_1.buildHeaders)([options.headers, { 'content-type': encodings[rawBodyField].content_type }]),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const encoded = [];
|
|
26
|
+
for (const [name, encoding] of Object.entries(encodings)) {
|
|
27
|
+
if (!Object.prototype.hasOwnProperty.call(body, name))
|
|
28
|
+
continue;
|
|
29
|
+
const value = body[name];
|
|
30
|
+
const data = encoding.json ? JSON.stringify(value) : value;
|
|
31
|
+
if (typeof data !== 'string')
|
|
32
|
+
throw new TypeError(`Multipart field ${name} must encode as a string`);
|
|
33
|
+
encoded.push([name, (0, uploads_1.makeFile)([data], '', { type: encoding.content_type })]);
|
|
34
|
+
delete body[name];
|
|
35
|
+
}
|
|
36
|
+
const multipart = await (0, uploads_1.multipartFormRequestOptions)({ ...options, body }, client);
|
|
37
|
+
const form = multipart.body;
|
|
38
|
+
// Declared upload fields are rejected during code generation. Defend against untyped body overrides.
|
|
39
|
+
if (!(form instanceof FormData)) {
|
|
40
|
+
await form.cancel();
|
|
41
|
+
throw new TypeError('Unexpected streaming upload in typed multipart request body');
|
|
42
|
+
}
|
|
43
|
+
for (const [name, part] of encoded)
|
|
44
|
+
form.append(name, part, '');
|
|
45
|
+
return {
|
|
46
|
+
...options,
|
|
47
|
+
body: form,
|
|
48
|
+
headers: (0, headers_1.buildHeaders)([options.headers, { 'content-type': null }]),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=multipart-encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multipart-encoding.js","sourceRoot":"","sources":["../src/internal/multipart-encoding.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
2
|
+
import { multipartFormRequestOptions, makeFile } from "./uploads.mjs";
|
|
3
|
+
import { buildHeaders } from "./headers.mjs";
|
|
4
|
+
/** Encode explicitly typed fields as single, filename-less multipart parts. */
|
|
5
|
+
export async function encodedMultipartFormRequestOptions(options, client, encodings, rawBodyField = null) {
|
|
6
|
+
if (options.body === null || typeof options.body !== 'object' || Array.isArray(options.body)) {
|
|
7
|
+
throw new TypeError('Multipart request body must be an object');
|
|
8
|
+
}
|
|
9
|
+
const body = Object.fromEntries(Object.entries(options.body).filter(([, value]) => value !== undefined));
|
|
10
|
+
if (rawBodyField !== null &&
|
|
11
|
+
Object.keys(body).length === 1 &&
|
|
12
|
+
Object.prototype.hasOwnProperty.call(body, rawBodyField)) {
|
|
13
|
+
const value = body[rawBodyField];
|
|
14
|
+
if (typeof value !== 'string')
|
|
15
|
+
throw new TypeError('Raw multipart alternative must be a string');
|
|
16
|
+
return {
|
|
17
|
+
...options,
|
|
18
|
+
body: value,
|
|
19
|
+
headers: buildHeaders([options.headers, { 'content-type': encodings[rawBodyField].content_type }]),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const encoded = [];
|
|
23
|
+
for (const [name, encoding] of Object.entries(encodings)) {
|
|
24
|
+
if (!Object.prototype.hasOwnProperty.call(body, name))
|
|
25
|
+
continue;
|
|
26
|
+
const value = body[name];
|
|
27
|
+
const data = encoding.json ? JSON.stringify(value) : value;
|
|
28
|
+
if (typeof data !== 'string')
|
|
29
|
+
throw new TypeError(`Multipart field ${name} must encode as a string`);
|
|
30
|
+
encoded.push([name, makeFile([data], '', { type: encoding.content_type })]);
|
|
31
|
+
delete body[name];
|
|
32
|
+
}
|
|
33
|
+
const multipart = await multipartFormRequestOptions({ ...options, body }, client);
|
|
34
|
+
const form = multipart.body;
|
|
35
|
+
// Declared upload fields are rejected during code generation. Defend against untyped body overrides.
|
|
36
|
+
if (!(form instanceof FormData)) {
|
|
37
|
+
await form.cancel();
|
|
38
|
+
throw new TypeError('Unexpected streaming upload in typed multipart request body');
|
|
39
|
+
}
|
|
40
|
+
for (const [name, part] of encoded)
|
|
41
|
+
form.append(name, part, '');
|
|
42
|
+
return {
|
|
43
|
+
...options,
|
|
44
|
+
body: form,
|
|
45
|
+
headers: buildHeaders([options.headers, { 'content-type': null }]),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=multipart-encoding.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multipart-encoding.mjs","sourceRoot":"","sources":["../src/internal/multipart-encoding.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../src/internal/qs/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,oBAAgB;AAKtD,eAAO,MAAM,GAAG,GAAI,KAAK,MAAM,EAAE,KAAK,WAAW,KAAG,OAKnD,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../src/internal/qs/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,oBAAgB;AAKtD,eAAO,MAAM,GAAG,GAAI,KAAK,MAAM,EAAE,KAAK,WAAW,KAAG,OAKnD,CAAC;AA4bF,wBAAgB,KAAK,CACnB,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,GAAG,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CAAO,OAUpE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAgB5D;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,UAY1D;AAID,eAAO,MAAM,MAAM,EAAE,CACnB,GAAG,EAAE,GAAG,EACR,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,KAAK,GAAG,OAAO,EACrB,MAAM,EAAE,MAAM,KACX,MAiFJ,CAAC;AAEF,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,OAqBjC;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,WAEjC;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,WAMjC;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,WAGrC;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WASrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/internal/qs/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAgB;AAKtD,eAAO,MAAM,GAAG,GAAI,KAAK,MAAM,EAAE,KAAK,WAAW,KAAG,OAKnD,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/internal/qs/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAgB;AAKtD,eAAO,MAAM,GAAG,GAAI,KAAK,MAAM,EAAE,KAAK,WAAW,KAAG,OAKnD,CAAC;AA4bF,wBAAgB,KAAK,CACnB,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,GAAG,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CAAO,OAUpE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAgB5D;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,UAY1D;AAID,eAAO,MAAM,MAAM,EAAE,CACnB,GAAG,EAAE,GAAG,EACR,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,KAAK,GAAG,OAAO,EACrB,MAAM,EAAE,MAAM,KACX,MAiFJ,CAAC;AAEF,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,OAqBjC;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,WAEjC;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,WAMjC;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,WAGrC;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WASrD"}
|
package/internal/qs/utils.js
CHANGED
|
@@ -18,6 +18,268 @@ const has = (obj, key) => {
|
|
|
18
18
|
return resolvedHas(obj, key);
|
|
19
19
|
};
|
|
20
20
|
exports.has = has;
|
|
21
|
+
function isUnsafePropertyKey(key) {
|
|
22
|
+
return key === '__proto__' || key === 'constructor' || key === 'prototype';
|
|
23
|
+
}
|
|
24
|
+
const maxAdoptedRecords = 10000;
|
|
25
|
+
function isIntrinsicFunctionPrototype(value, key, descriptor) {
|
|
26
|
+
return (typeof value === 'function' && key === 'prototype' && !descriptor.enumerable && !descriptor.configurable);
|
|
27
|
+
}
|
|
28
|
+
function isObjectLike(value) {
|
|
29
|
+
return value !== null && (typeof value === 'object' || typeof value === 'function');
|
|
30
|
+
}
|
|
31
|
+
function rememberAdoption(state, target, key, value) {
|
|
32
|
+
if (!isObjectLike(value)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (state.adopted.length >= maxAdoptedRecords) {
|
|
36
|
+
throw new Error('Adopted record traversal exceeds the supported safety limit.');
|
|
37
|
+
}
|
|
38
|
+
state.adopted.push({ target, key });
|
|
39
|
+
}
|
|
40
|
+
function sanitizeAdoptions(state) {
|
|
41
|
+
if (state.adopted.length === 0) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const records = new WeakMap();
|
|
45
|
+
const visited = [];
|
|
46
|
+
const locations = [];
|
|
47
|
+
let inspectedProperties = 0;
|
|
48
|
+
function inspect(value) {
|
|
49
|
+
const known = records.get(value);
|
|
50
|
+
if (known) {
|
|
51
|
+
return known;
|
|
52
|
+
}
|
|
53
|
+
if (visited.length >= maxAdoptedRecords) {
|
|
54
|
+
throw new Error('Adopted record traversal exceeds the supported safety limit.');
|
|
55
|
+
}
|
|
56
|
+
const keys = Reflect.ownKeys(value);
|
|
57
|
+
if (keys.length > maxAdoptedRecords - inspectedProperties) {
|
|
58
|
+
throw new Error('Adopted record traversal exceeds the supported safety limit.');
|
|
59
|
+
}
|
|
60
|
+
inspectedProperties += keys.length;
|
|
61
|
+
const descriptors = Object.create(null);
|
|
62
|
+
for (const key of keys) {
|
|
63
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
64
|
+
if (descriptor) {
|
|
65
|
+
Reflect.set(descriptors, key, descriptor);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const prototype = Object.getPrototypeOf(value);
|
|
69
|
+
const array = (0, values_1.isArray)(value);
|
|
70
|
+
const extensible = Object.isExtensible(value);
|
|
71
|
+
const ordinary = typeof value !== 'function' &&
|
|
72
|
+
(array ? prototype === Array.prototype : prototype === Object.prototype || prototype === null);
|
|
73
|
+
const record = {
|
|
74
|
+
value,
|
|
75
|
+
descriptors,
|
|
76
|
+
keys,
|
|
77
|
+
prototype,
|
|
78
|
+
parents: new Set(),
|
|
79
|
+
ordinary,
|
|
80
|
+
array,
|
|
81
|
+
detached: ordinary && (extensible || !Object.isFrozen(value)),
|
|
82
|
+
unsafe: false,
|
|
83
|
+
extensible,
|
|
84
|
+
};
|
|
85
|
+
records.set(value, record);
|
|
86
|
+
visited.push(record);
|
|
87
|
+
return record;
|
|
88
|
+
}
|
|
89
|
+
for (const { target, key } of state.adopted) {
|
|
90
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
91
|
+
if (descriptor && 'value' in descriptor && isObjectLike(descriptor.value)) {
|
|
92
|
+
locations.push({ target, key, descriptor, record: inspect(descriptor.value) });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const detached = [];
|
|
96
|
+
for (const record of visited) {
|
|
97
|
+
for (const key of record.keys) {
|
|
98
|
+
const descriptor = Reflect.get(record.descriptors, key);
|
|
99
|
+
if (!descriptor) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (isUnsafePropertyKey(key)) {
|
|
103
|
+
if (record.ordinary) {
|
|
104
|
+
record.detached = true;
|
|
105
|
+
record.unsafe = true;
|
|
106
|
+
}
|
|
107
|
+
else if (!isIntrinsicFunctionPrototype(record.value, key, descriptor)) {
|
|
108
|
+
throw new TypeError('Cannot safely sanitize an adopted callable or unsupported prototype.');
|
|
109
|
+
}
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (!record.ordinary && !descriptor.enumerable) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if ('value' in descriptor && isObjectLike(descriptor.value)) {
|
|
116
|
+
inspect(descriptor.value).parents.add(record);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (record.detached) {
|
|
120
|
+
detached.push(record);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
for (let index = visited.length - 1; index >= 0; index -= 1) {
|
|
124
|
+
const record = visited[index];
|
|
125
|
+
if (record.ordinary) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
for (const key of ['__proto__', 'constructor', 'prototype']) {
|
|
129
|
+
const descriptor = Object.getOwnPropertyDescriptor(record.value, key);
|
|
130
|
+
if (descriptor && !isIntrinsicFunctionPrototype(record.value, key, descriptor)) {
|
|
131
|
+
throw new TypeError('Cannot safely sanitize an adopted callable or unsupported prototype.');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const unsafe = visited.filter((record) => record.unsafe);
|
|
136
|
+
for (const record of unsafe) {
|
|
137
|
+
for (const parent of record.parents) {
|
|
138
|
+
if (!parent.ordinary) {
|
|
139
|
+
throw new TypeError('Cannot safely sanitize an adopted callable or unsupported prototype.');
|
|
140
|
+
}
|
|
141
|
+
if (!parent.unsafe) {
|
|
142
|
+
parent.unsafe = true;
|
|
143
|
+
unsafe.push(parent);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (const record of detached) {
|
|
148
|
+
for (const parent of record.parents) {
|
|
149
|
+
if (!parent.ordinary) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (!parent.detached) {
|
|
153
|
+
parent.detached = true;
|
|
154
|
+
detached.push(parent);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const copies = new WeakMap();
|
|
159
|
+
for (const record of detached) {
|
|
160
|
+
copies.set(record.value, record.array ? [] : Object.create(record.prototype));
|
|
161
|
+
}
|
|
162
|
+
for (const record of detached) {
|
|
163
|
+
const copy = copies.get(record.value);
|
|
164
|
+
for (const key of record.keys) {
|
|
165
|
+
if (isUnsafePropertyKey(key)) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const descriptor = Reflect.get(record.descriptors, key);
|
|
169
|
+
if (!descriptor) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if ('value' in descriptor && isObjectLike(descriptor.value) && copies.has(descriptor.value)) {
|
|
173
|
+
descriptor.value = copies.get(descriptor.value);
|
|
174
|
+
}
|
|
175
|
+
Object.defineProperty(copy, key, descriptor);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
for (const { target, key, descriptor, record } of locations) {
|
|
179
|
+
const value = copies.get(record.value) ?? record.value;
|
|
180
|
+
if (value !== descriptor.value) {
|
|
181
|
+
Object.defineProperty(copies.get(target) ?? target, key, { ...descriptor, value });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
for (const record of detached) {
|
|
185
|
+
if (!record.extensible) {
|
|
186
|
+
Object.preventExtensions(copies.get(record.value));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function readPreparedTarget(state, target, key) {
|
|
191
|
+
const prepared = state.preparedTargets.get(target);
|
|
192
|
+
if (prepared?.has(key)) {
|
|
193
|
+
const value = prepared.get(key);
|
|
194
|
+
prepared.delete(key);
|
|
195
|
+
return value;
|
|
196
|
+
}
|
|
197
|
+
return target[key];
|
|
198
|
+
}
|
|
199
|
+
function previewTarget(state, target, key) {
|
|
200
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
201
|
+
if (descriptor && 'value' in descriptor) {
|
|
202
|
+
return descriptor.value;
|
|
203
|
+
}
|
|
204
|
+
const value = Reflect.get(target, key, target);
|
|
205
|
+
let prepared = state.preparedTargets.get(target);
|
|
206
|
+
if (!prepared) {
|
|
207
|
+
prepared = new Map();
|
|
208
|
+
state.preparedTargets.set(target, prepared);
|
|
209
|
+
}
|
|
210
|
+
prepared.set(key, value);
|
|
211
|
+
return value;
|
|
212
|
+
}
|
|
213
|
+
function prepareMergeSource(target, source, state, assign = false) {
|
|
214
|
+
if (!source || typeof source !== 'object' || !target || typeof target !== 'object') {
|
|
215
|
+
return source;
|
|
216
|
+
}
|
|
217
|
+
let preparedTargets = state.preparedSources.get(source);
|
|
218
|
+
if (!preparedTargets) {
|
|
219
|
+
preparedTargets = new WeakMap();
|
|
220
|
+
state.preparedSources.set(source, preparedTargets);
|
|
221
|
+
}
|
|
222
|
+
const existing = preparedTargets.get(target);
|
|
223
|
+
if (existing) {
|
|
224
|
+
return existing;
|
|
225
|
+
}
|
|
226
|
+
state.inspectedSources += 1;
|
|
227
|
+
if (state.inspectedSources > maxAdoptedRecords) {
|
|
228
|
+
throw new Error('Adopted record traversal exceeds the supported safety limit.');
|
|
229
|
+
}
|
|
230
|
+
const sourceKeys = Reflect.ownKeys(source);
|
|
231
|
+
if (sourceKeys.length > maxAdoptedRecords - state.inspectedSourceProperties) {
|
|
232
|
+
throw new Error('Adopted record traversal exceeds the supported safety limit.');
|
|
233
|
+
}
|
|
234
|
+
state.inspectedSourceProperties += sourceKeys.length;
|
|
235
|
+
const sourceIsArray = (0, values_1.isArray)(source);
|
|
236
|
+
const prepared = sourceIsArray ? [] : Object.create(null);
|
|
237
|
+
preparedTargets.set(target, prepared);
|
|
238
|
+
if ((0, values_1.isArray)(target) && sourceIsArray && !assign) {
|
|
239
|
+
const sourceLength = source.length;
|
|
240
|
+
prepared.length = sourceLength;
|
|
241
|
+
for (let index = 0; index < sourceLength; index += 1) {
|
|
242
|
+
if (!(index in source)) {
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
const value = source[index];
|
|
246
|
+
if ((0, exports.has)(target, index)) {
|
|
247
|
+
const targetValue = previewTarget(state, target, index);
|
|
248
|
+
prepared[index] =
|
|
249
|
+
targetValue && typeof targetValue === 'object' && value && typeof value === 'object'
|
|
250
|
+
? prepareMergeSource(targetValue, value, state)
|
|
251
|
+
: value;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
prepared[index] = value;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return prepared;
|
|
258
|
+
}
|
|
259
|
+
const enumerableKeys = [];
|
|
260
|
+
for (const key of sourceKeys) {
|
|
261
|
+
if (typeof key === 'string' && Object.getOwnPropertyDescriptor(source, key)?.enumerable) {
|
|
262
|
+
enumerableKeys.push(key);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
for (const key of enumerableKeys) {
|
|
266
|
+
if (isUnsafePropertyKey(key)) {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const value = source[key];
|
|
270
|
+
prepared[key] =
|
|
271
|
+
!assign && (0, exports.has)(target, key) && value && typeof value === 'object'
|
|
272
|
+
? prepareMergeSource(previewTarget(state, target, key), value, state)
|
|
273
|
+
: value;
|
|
274
|
+
}
|
|
275
|
+
return prepared;
|
|
276
|
+
}
|
|
277
|
+
function prepareSource(target, source, state, assign = false) {
|
|
278
|
+
const holder = { value: prepareMergeSource(target, source, state, assign) };
|
|
279
|
+
rememberAdoption(state, holder, 'value', holder.value);
|
|
280
|
+
sanitizeAdoptions(state);
|
|
281
|
+
return holder.value;
|
|
282
|
+
}
|
|
21
283
|
const hex_table = /* @__PURE__ */ (() => {
|
|
22
284
|
const array = [];
|
|
23
285
|
for (let i = 0; i < 256; ++i) {
|
|
@@ -53,7 +315,7 @@ function array_to_object(source, options) {
|
|
|
53
315
|
}
|
|
54
316
|
return obj;
|
|
55
317
|
}
|
|
56
|
-
function
|
|
318
|
+
function mergeWithState(target, source, options, state) {
|
|
57
319
|
if (!source) {
|
|
58
320
|
return target;
|
|
59
321
|
}
|
|
@@ -62,8 +324,13 @@ function merge(target, source, options = {}) {
|
|
|
62
324
|
target.push(source);
|
|
63
325
|
}
|
|
64
326
|
else if (target && typeof target === 'object') {
|
|
65
|
-
|
|
66
|
-
|
|
327
|
+
const propertyKey = typeof source === 'string' || typeof source === 'symbol'
|
|
328
|
+
? source
|
|
329
|
+
: Reflect.ownKeys({ [source]: true })[0];
|
|
330
|
+
if (!isUnsafePropertyKey(propertyKey) &&
|
|
331
|
+
((options && (options.plainObjects || options.allowPrototypes)) ||
|
|
332
|
+
!(0, exports.has)(Object.prototype, propertyKey))) {
|
|
333
|
+
target[propertyKey] = true;
|
|
67
334
|
}
|
|
68
335
|
}
|
|
69
336
|
else {
|
|
@@ -86,30 +353,60 @@ function merge(target, source, options = {}) {
|
|
|
86
353
|
if (i in source) {
|
|
87
354
|
const item = source[i];
|
|
88
355
|
if ((0, exports.has)(target, i)) {
|
|
89
|
-
const targetItem = target
|
|
356
|
+
const targetItem = readPreparedTarget(state, target, i);
|
|
90
357
|
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
91
|
-
|
|
358
|
+
const merged = mergeWithState(targetItem, item, options, state);
|
|
359
|
+
target[i] = merged;
|
|
92
360
|
}
|
|
93
361
|
else {
|
|
94
|
-
|
|
362
|
+
const adopted = item;
|
|
363
|
+
target.push(adopted);
|
|
95
364
|
}
|
|
96
365
|
}
|
|
97
366
|
else {
|
|
98
|
-
|
|
367
|
+
const adopted = item;
|
|
368
|
+
target[i] = adopted;
|
|
99
369
|
}
|
|
100
370
|
}
|
|
101
371
|
}
|
|
102
372
|
return target;
|
|
103
373
|
}
|
|
104
374
|
for (const key of Object.keys(source)) {
|
|
375
|
+
if (isUnsafePropertyKey(key)) {
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
105
378
|
const value = source[key];
|
|
106
|
-
|
|
379
|
+
const adopted = (0, exports.has)(mergeTarget, key)
|
|
380
|
+
? mergeWithState(readPreparedTarget(state, mergeTarget, key), value, options, state)
|
|
381
|
+
: value;
|
|
382
|
+
mergeTarget[key] = adopted;
|
|
107
383
|
}
|
|
108
384
|
return mergeTarget;
|
|
109
385
|
}
|
|
386
|
+
function merge(target, source, options = {}) {
|
|
387
|
+
const state = {
|
|
388
|
+
adopted: [],
|
|
389
|
+
preparedTargets: new WeakMap(),
|
|
390
|
+
preparedSources: new WeakMap(),
|
|
391
|
+
inspectedSources: 0,
|
|
392
|
+
inspectedSourceProperties: 0,
|
|
393
|
+
};
|
|
394
|
+
return mergeWithState(target, prepareSource(target, source, state), options, state);
|
|
395
|
+
}
|
|
110
396
|
function assign_single_source(target, source) {
|
|
111
|
-
|
|
112
|
-
|
|
397
|
+
const state = {
|
|
398
|
+
adopted: [],
|
|
399
|
+
preparedTargets: new WeakMap(),
|
|
400
|
+
preparedSources: new WeakMap(),
|
|
401
|
+
inspectedSources: 0,
|
|
402
|
+
inspectedSourceProperties: 0,
|
|
403
|
+
};
|
|
404
|
+
const prepared = prepareSource(target, source, state, true);
|
|
405
|
+
for (const key of Object.keys(prepared)) {
|
|
406
|
+
if (isUnsafePropertyKey(key)) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
target[key] = prepared[key];
|
|
113
410
|
}
|
|
114
411
|
return target;
|
|
115
412
|
}
|