phonic 0.30.2 → 0.30.3
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/README.md +1 -770
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/api/resources/agents/client/Client.d.ts +3 -3
- package/dist/cjs/api/resources/agents/client/Client.js +27 -21
- package/dist/cjs/api/resources/agents/client/requests/AgentsCreateRequest.d.ts +2 -4
- package/dist/cjs/api/resources/agents/client/requests/AgentsDeleteRequest.d.ts +1 -3
- package/dist/cjs/api/resources/agents/client/requests/AgentsGetRequest.d.ts +1 -3
- package/dist/cjs/api/resources/agents/client/requests/AgentsListRequest.d.ts +1 -3
- package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.d.ts +2 -4
- package/dist/cjs/api/resources/agents/client/requests/UpsertAgentRequest.d.ts +2 -4
- package/dist/cjs/api/resources/conversations/client/requests/ConversationsListRequest.d.ts +9 -27
- package/dist/cjs/api/resources/conversations/client/requests/ConversationsSipOutboundCallRequest.d.ts +5 -15
- package/dist/cjs/api/resources/conversations/client/requests/OutboundCallRequest.d.ts +1 -1
- package/dist/cjs/api/resources/extractionSchemas/client/Client.js +20 -15
- package/dist/cjs/api/resources/extractionSchemas/client/requests/CreateExtractionSchemaRequest.d.ts +1 -3
- package/dist/cjs/api/resources/extractionSchemas/client/requests/ExtractionSchemasDeleteRequest.d.ts +1 -3
- package/dist/cjs/api/resources/extractionSchemas/client/requests/ExtractionSchemasGetRequest.d.ts +1 -3
- package/dist/cjs/api/resources/extractionSchemas/client/requests/ExtractionSchemasListRequest.d.ts +1 -3
- package/dist/cjs/api/resources/extractionSchemas/client/requests/UpdateExtractionSchemaRequest.d.ts +1 -3
- package/dist/cjs/api/resources/projects/client/Client.js +28 -21
- package/dist/cjs/api/resources/tools/client/Client.d.ts +10 -0
- package/dist/cjs/api/resources/tools/client/Client.js +30 -15
- package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.d.ts +15 -4
- package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.js +1 -0
- package/dist/cjs/api/resources/tools/client/requests/ToolsDeleteRequest.d.ts +1 -3
- package/dist/cjs/api/resources/tools/client/requests/ToolsGetRequest.d.ts +6 -3
- package/dist/cjs/api/resources/tools/client/requests/ToolsListRequest.d.ts +1 -3
- package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.d.ts +5 -4
- package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.js +1 -0
- package/dist/cjs/api/resources/voices/client/Client.js +8 -6
- package/dist/cjs/api/resources/voices/client/requests/VoicesListRequest.d.ts +1 -3
- package/dist/cjs/api/types/Conversation.d.ts +2 -0
- package/dist/cjs/api/types/ConversationItem.d.ts +0 -2
- package/dist/cjs/api/types/IsUserSpeakingPayload.d.ts +8 -0
- package/dist/cjs/api/types/IsUserSpeakingPayload.js +5 -0
- package/dist/cjs/api/types/OutboundCallConfig.d.ts +1 -1
- package/dist/cjs/api/types/Tool.d.ts +4 -1
- package/dist/cjs/api/types/Tool.js +1 -0
- package/dist/cjs/api/types/index.d.ts +1 -0
- package/dist/cjs/api/types/index.js +1 -0
- package/dist/cjs/core/auth/AuthProvider.d.ts +4 -0
- package/dist/cjs/core/auth/AuthProvider.js +2 -0
- package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
- package/dist/cjs/core/auth/AuthRequest.js +2 -0
- package/dist/cjs/core/auth/index.d.ts +2 -0
- package/dist/cjs/core/fetcher/Fetcher.js +2 -2
- package/dist/cjs/core/fetcher/index.d.ts +5 -5
- package/dist/cjs/core/fetcher/index.js +5 -5
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/index.d.mts +76 -122
- package/dist/index.d.ts +76 -122
- package/dist/index.js +37 -52
- package/dist/index.mjs +37 -52
- package/package.json +2 -2
- package/reference.md +4 -4
- package/dist/esm/Client.d.mts +0 -50
- package/dist/esm/Client.mjs +0 -47
- package/dist/esm/api/errors/BadRequestError.d.mts +0 -8
- package/dist/esm/api/errors/BadRequestError.mjs +0 -15
- package/dist/esm/api/errors/ConflictError.d.mts +0 -8
- package/dist/esm/api/errors/ConflictError.mjs +0 -15
- package/dist/esm/api/errors/ForbiddenError.d.mts +0 -8
- package/dist/esm/api/errors/ForbiddenError.mjs +0 -15
- package/dist/esm/api/errors/GatewayTimeoutError.d.mts +0 -9
- package/dist/esm/api/errors/GatewayTimeoutError.mjs +0 -15
- package/dist/esm/api/errors/InternalServerError.d.mts +0 -9
- package/dist/esm/api/errors/InternalServerError.mjs +0 -15
- package/dist/esm/api/errors/NotFoundError.d.mts +0 -8
- package/dist/esm/api/errors/NotFoundError.mjs +0 -15
- package/dist/esm/api/errors/UnauthorizedError.d.mts +0 -9
- package/dist/esm/api/errors/UnauthorizedError.mjs +0 -15
- package/dist/esm/api/errors/index.d.mts +0 -7
- package/dist/esm/api/errors/index.mjs +0 -7
- package/dist/esm/api/index.d.mts +0 -4
- package/dist/esm/api/index.mjs +0 -4
- package/dist/esm/api/resources/agents/client/Client.d.mts +0 -208
- package/dist/esm/api/resources/agents/client/Client.mjs +0 -552
- package/dist/esm/api/resources/agents/client/index.d.mts +0 -2
- package/dist/esm/api/resources/agents/client/index.mjs +0 -1
- package/dist/esm/api/resources/agents/client/requests/AgentsCreateRequest.d.mts +0 -43
- package/dist/esm/api/resources/agents/client/requests/AgentsCreateRequest.mjs +0 -4
- package/dist/esm/api/resources/agents/client/requests/AgentsDeleteRequest.d.mts +0 -15
- package/dist/esm/api/resources/agents/client/requests/AgentsDeleteRequest.mjs +0 -4
- package/dist/esm/api/resources/agents/client/requests/AgentsGetRequest.d.mts +0 -15
- package/dist/esm/api/resources/agents/client/requests/AgentsGetRequest.mjs +0 -4
- package/dist/esm/api/resources/agents/client/requests/AgentsListRequest.d.mts +0 -13
- package/dist/esm/api/resources/agents/client/requests/AgentsListRequest.mjs +0 -4
- package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.d.mts +0 -104
- package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.mjs +0 -10
- package/dist/esm/api/resources/agents/client/requests/UpsertAgentRequest.d.mts +0 -40
- package/dist/esm/api/resources/agents/client/requests/UpsertAgentRequest.mjs +0 -4
- package/dist/esm/api/resources/agents/client/requests/index.d.mts +0 -6
- package/dist/esm/api/resources/agents/client/requests/index.mjs +0 -1
- package/dist/esm/api/resources/agents/index.d.mts +0 -2
- package/dist/esm/api/resources/agents/index.mjs +0 -2
- package/dist/esm/api/resources/agents/types/AgentsCreateResponse.d.mts +0 -9
- package/dist/esm/api/resources/agents/types/AgentsCreateResponse.mjs +0 -4
- package/dist/esm/api/resources/agents/types/AgentsDeleteResponse.d.mts +0 -7
- package/dist/esm/api/resources/agents/types/AgentsDeleteResponse.mjs +0 -4
- package/dist/esm/api/resources/agents/types/AgentsGetResponse.d.mts +0 -7
- package/dist/esm/api/resources/agents/types/AgentsGetResponse.mjs +0 -4
- package/dist/esm/api/resources/agents/types/AgentsListResponse.d.mts +0 -7
- package/dist/esm/api/resources/agents/types/AgentsListResponse.mjs +0 -4
- package/dist/esm/api/resources/agents/types/AgentsUpdateResponse.d.mts +0 -7
- package/dist/esm/api/resources/agents/types/AgentsUpdateResponse.mjs +0 -4
- package/dist/esm/api/resources/agents/types/AgentsUpsertResponse.d.mts +0 -11
- package/dist/esm/api/resources/agents/types/AgentsUpsertResponse.mjs +0 -4
- package/dist/esm/api/resources/agents/types/index.d.mts +0 -6
- package/dist/esm/api/resources/agents/types/index.mjs +0 -6
- package/dist/esm/api/resources/conversations/client/Client.d.mts +0 -236
- package/dist/esm/api/resources/conversations/client/Client.mjs +0 -858
- package/dist/esm/api/resources/conversations/client/Socket.d.mts +0 -64
- package/dist/esm/api/resources/conversations/client/Socket.mjs +0 -159
- package/dist/esm/api/resources/conversations/client/index.d.mts +0 -2
- package/dist/esm/api/resources/conversations/client/index.mjs +0 -1
- package/dist/esm/api/resources/conversations/client/requests/ConversationsListRequest.d.mts +0 -48
- package/dist/esm/api/resources/conversations/client/requests/ConversationsListRequest.mjs +0 -4
- package/dist/esm/api/resources/conversations/client/requests/ConversationsSipOutboundCallRequest.d.mts +0 -39
- package/dist/esm/api/resources/conversations/client/requests/ConversationsSipOutboundCallRequest.mjs +0 -4
- package/dist/esm/api/resources/conversations/client/requests/EvaluateConversationRequest.d.mts +0 -13
- package/dist/esm/api/resources/conversations/client/requests/EvaluateConversationRequest.mjs +0 -4
- package/dist/esm/api/resources/conversations/client/requests/ExtractDataRequest.d.mts +0 -13
- package/dist/esm/api/resources/conversations/client/requests/ExtractDataRequest.mjs +0 -4
- package/dist/esm/api/resources/conversations/client/requests/OutboundCallRequest.d.mts +0 -30
- package/dist/esm/api/resources/conversations/client/requests/OutboundCallRequest.mjs +0 -4
- package/dist/esm/api/resources/conversations/client/requests/index.d.mts +0 -5
- package/dist/esm/api/resources/conversations/client/requests/index.mjs +0 -1
- package/dist/esm/api/resources/conversations/index.d.mts +0 -2
- package/dist/esm/api/resources/conversations/index.mjs +0 -2
- package/dist/esm/api/resources/conversations/types/ConversationsCancelResponse.d.mts +0 -7
- package/dist/esm/api/resources/conversations/types/ConversationsCancelResponse.mjs +0 -4
- package/dist/esm/api/resources/conversations/types/ConversationsExtractDataResponse.d.mts +0 -7
- package/dist/esm/api/resources/conversations/types/ConversationsExtractDataResponse.mjs +0 -4
- package/dist/esm/api/resources/conversations/types/ConversationsGetAnalysisResponse.d.mts +0 -7
- package/dist/esm/api/resources/conversations/types/ConversationsGetAnalysisResponse.mjs +0 -4
- package/dist/esm/api/resources/conversations/types/ConversationsGetResponse.d.mts +0 -7
- package/dist/esm/api/resources/conversations/types/ConversationsGetResponse.mjs +0 -4
- package/dist/esm/api/resources/conversations/types/ConversationsListEvaluationsResponse.d.mts +0 -7
- package/dist/esm/api/resources/conversations/types/ConversationsListEvaluationsResponse.mjs +0 -4
- package/dist/esm/api/resources/conversations/types/ConversationsListExtractionsResponse.d.mts +0 -7
- package/dist/esm/api/resources/conversations/types/ConversationsListExtractionsResponse.mjs +0 -4
- package/dist/esm/api/resources/conversations/types/ConversationsListResponse.d.mts +0 -9
- package/dist/esm/api/resources/conversations/types/ConversationsListResponse.mjs +0 -4
- package/dist/esm/api/resources/conversations/types/ConversationsOutboundCallResponse.d.mts +0 -7
- package/dist/esm/api/resources/conversations/types/ConversationsOutboundCallResponse.mjs +0 -4
- package/dist/esm/api/resources/conversations/types/ConversationsSipOutboundCallResponse.d.mts +0 -7
- package/dist/esm/api/resources/conversations/types/ConversationsSipOutboundCallResponse.mjs +0 -4
- package/dist/esm/api/resources/conversations/types/index.d.mts +0 -9
- package/dist/esm/api/resources/conversations/types/index.mjs +0 -9
- package/dist/esm/api/resources/extractionSchemas/client/Client.d.mts +0 -142
- package/dist/esm/api/resources/extractionSchemas/client/Client.mjs +0 -431
- package/dist/esm/api/resources/extractionSchemas/client/index.d.mts +0 -2
- package/dist/esm/api/resources/extractionSchemas/client/index.mjs +0 -1
- package/dist/esm/api/resources/extractionSchemas/client/requests/CreateExtractionSchemaRequest.d.mts +0 -37
- package/dist/esm/api/resources/extractionSchemas/client/requests/CreateExtractionSchemaRequest.mjs +0 -4
- package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasDeleteRequest.d.mts +0 -15
- package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasDeleteRequest.mjs +0 -4
- package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasGetRequest.d.mts +0 -15
- package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasGetRequest.mjs +0 -4
- package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasListRequest.d.mts +0 -15
- package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasListRequest.mjs +0 -4
- package/dist/esm/api/resources/extractionSchemas/client/requests/UpdateExtractionSchemaRequest.d.mts +0 -33
- package/dist/esm/api/resources/extractionSchemas/client/requests/UpdateExtractionSchemaRequest.mjs +0 -4
- package/dist/esm/api/resources/extractionSchemas/client/requests/index.d.mts +0 -5
- package/dist/esm/api/resources/extractionSchemas/client/requests/index.mjs +0 -1
- package/dist/esm/api/resources/extractionSchemas/index.d.mts +0 -2
- package/dist/esm/api/resources/extractionSchemas/index.mjs +0 -2
- package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasCreateResponse.d.mts +0 -9
- package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasCreateResponse.mjs +0 -4
- package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasDeleteResponse.d.mts +0 -7
- package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasDeleteResponse.mjs +0 -4
- package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasGetResponse.d.mts +0 -7
- package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasGetResponse.mjs +0 -4
- package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasListResponse.d.mts +0 -7
- package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasListResponse.mjs +0 -4
- package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasUpdateResponse.d.mts +0 -7
- package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasUpdateResponse.mjs +0 -4
- package/dist/esm/api/resources/extractionSchemas/types/index.d.mts +0 -5
- package/dist/esm/api/resources/extractionSchemas/types/index.mjs +0 -5
- package/dist/esm/api/resources/index.d.mts +0 -18
- package/dist/esm/api/resources/index.mjs +0 -18
- package/dist/esm/api/resources/projects/client/Client.d.mts +0 -157
- package/dist/esm/api/resources/projects/client/Client.mjs +0 -540
- package/dist/esm/api/resources/projects/client/index.d.mts +0 -2
- package/dist/esm/api/resources/projects/client/index.mjs +0 -1
- package/dist/esm/api/resources/projects/client/requests/CreateConversationEvalPromptRequest.d.mts +0 -16
- package/dist/esm/api/resources/projects/client/requests/CreateConversationEvalPromptRequest.mjs +0 -4
- package/dist/esm/api/resources/projects/client/requests/CreateProjectRequest.d.mts +0 -13
- package/dist/esm/api/resources/projects/client/requests/CreateProjectRequest.mjs +0 -4
- package/dist/esm/api/resources/projects/client/requests/UpdateProjectRequest.d.mts +0 -15
- package/dist/esm/api/resources/projects/client/requests/UpdateProjectRequest.mjs +0 -4
- package/dist/esm/api/resources/projects/client/requests/index.d.mts +0 -3
- package/dist/esm/api/resources/projects/client/requests/index.mjs +0 -1
- package/dist/esm/api/resources/projects/index.d.mts +0 -2
- package/dist/esm/api/resources/projects/index.mjs +0 -2
- package/dist/esm/api/resources/projects/types/ProjectsCreateEvalPromptResponse.d.mts +0 -7
- package/dist/esm/api/resources/projects/types/ProjectsCreateEvalPromptResponse.mjs +0 -4
- package/dist/esm/api/resources/projects/types/ProjectsCreateResponse.d.mts +0 -9
- package/dist/esm/api/resources/projects/types/ProjectsCreateResponse.mjs +0 -4
- package/dist/esm/api/resources/projects/types/ProjectsDeleteResponse.d.mts +0 -7
- package/dist/esm/api/resources/projects/types/ProjectsDeleteResponse.mjs +0 -4
- package/dist/esm/api/resources/projects/types/ProjectsGetResponse.d.mts +0 -7
- package/dist/esm/api/resources/projects/types/ProjectsGetResponse.mjs +0 -4
- package/dist/esm/api/resources/projects/types/ProjectsListEvalPromptsResponse.d.mts +0 -7
- package/dist/esm/api/resources/projects/types/ProjectsListEvalPromptsResponse.mjs +0 -4
- package/dist/esm/api/resources/projects/types/ProjectsListResponse.d.mts +0 -7
- package/dist/esm/api/resources/projects/types/ProjectsListResponse.mjs +0 -4
- package/dist/esm/api/resources/projects/types/ProjectsUpdateResponse.d.mts +0 -7
- package/dist/esm/api/resources/projects/types/ProjectsUpdateResponse.mjs +0 -4
- package/dist/esm/api/resources/projects/types/index.d.mts +0 -7
- package/dist/esm/api/resources/projects/types/index.mjs +0 -7
- package/dist/esm/api/resources/tools/client/Client.d.mts +0 -160
- package/dist/esm/api/resources/tools/client/Client.mjs +0 -442
- package/dist/esm/api/resources/tools/client/index.d.mts +0 -2
- package/dist/esm/api/resources/tools/client/index.mjs +0 -1
- package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.d.mts +0 -92
- package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.mjs +0 -14
- package/dist/esm/api/resources/tools/client/requests/ToolsDeleteRequest.d.mts +0 -15
- package/dist/esm/api/resources/tools/client/requests/ToolsDeleteRequest.mjs +0 -4
- package/dist/esm/api/resources/tools/client/requests/ToolsGetRequest.d.mts +0 -20
- package/dist/esm/api/resources/tools/client/requests/ToolsGetRequest.mjs +0 -4
- package/dist/esm/api/resources/tools/client/requests/ToolsListRequest.d.mts +0 -15
- package/dist/esm/api/resources/tools/client/requests/ToolsListRequest.mjs +0 -4
- package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.d.mts +0 -54
- package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.mjs +0 -14
- package/dist/esm/api/resources/tools/client/requests/index.d.mts +0 -5
- package/dist/esm/api/resources/tools/client/requests/index.mjs +0 -1
- package/dist/esm/api/resources/tools/index.d.mts +0 -2
- package/dist/esm/api/resources/tools/index.mjs +0 -2
- package/dist/esm/api/resources/tools/types/ToolsCreateResponse.d.mts +0 -9
- package/dist/esm/api/resources/tools/types/ToolsCreateResponse.mjs +0 -4
- package/dist/esm/api/resources/tools/types/ToolsDeleteResponse.d.mts +0 -7
- package/dist/esm/api/resources/tools/types/ToolsDeleteResponse.mjs +0 -4
- package/dist/esm/api/resources/tools/types/ToolsGetResponse.d.mts +0 -7
- package/dist/esm/api/resources/tools/types/ToolsGetResponse.mjs +0 -4
- package/dist/esm/api/resources/tools/types/ToolsListResponse.d.mts +0 -7
- package/dist/esm/api/resources/tools/types/ToolsListResponse.mjs +0 -4
- package/dist/esm/api/resources/tools/types/ToolsUpdateResponse.d.mts +0 -7
- package/dist/esm/api/resources/tools/types/ToolsUpdateResponse.mjs +0 -4
- package/dist/esm/api/resources/tools/types/index.d.mts +0 -5
- package/dist/esm/api/resources/tools/types/index.mjs +0 -5
- package/dist/esm/api/resources/voices/client/Client.d.mts +0 -65
- package/dist/esm/api/resources/voices/client/Client.mjs +0 -166
- package/dist/esm/api/resources/voices/client/index.d.mts +0 -2
- package/dist/esm/api/resources/voices/client/index.mjs +0 -1
- package/dist/esm/api/resources/voices/client/requests/VoicesListRequest.d.mts +0 -15
- package/dist/esm/api/resources/voices/client/requests/VoicesListRequest.mjs +0 -4
- package/dist/esm/api/resources/voices/client/requests/index.d.mts +0 -1
- package/dist/esm/api/resources/voices/client/requests/index.mjs +0 -1
- package/dist/esm/api/resources/voices/index.d.mts +0 -2
- package/dist/esm/api/resources/voices/index.mjs +0 -2
- package/dist/esm/api/resources/voices/types/VoicesGetResponse.d.mts +0 -7
- package/dist/esm/api/resources/voices/types/VoicesGetResponse.mjs +0 -4
- package/dist/esm/api/resources/voices/types/VoicesListResponse.d.mts +0 -7
- package/dist/esm/api/resources/voices/types/VoicesListResponse.mjs +0 -4
- package/dist/esm/api/resources/voices/types/index.d.mts +0 -2
- package/dist/esm/api/resources/voices/types/index.mjs +0 -2
- package/dist/esm/api/types/Agent.d.mts +0 -80
- package/dist/esm/api/types/Agent.mjs +0 -10
- package/dist/esm/api/types/AssistantChoseNotToRespondPayload.d.mts +0 -6
- package/dist/esm/api/types/AssistantChoseNotToRespondPayload.mjs +0 -4
- package/dist/esm/api/types/AssistantEndedConversationPayload.d.mts +0 -6
- package/dist/esm/api/types/AssistantEndedConversationPayload.mjs +0 -4
- package/dist/esm/api/types/AudioChunkPayload.d.mts +0 -10
- package/dist/esm/api/types/AudioChunkPayload.mjs +0 -4
- package/dist/esm/api/types/AudioChunkResponsePayload.d.mts +0 -10
- package/dist/esm/api/types/AudioChunkResponsePayload.mjs +0 -4
- package/dist/esm/api/types/AudioFinishedPayload.d.mts +0 -6
- package/dist/esm/api/types/AudioFinishedPayload.mjs +0 -4
- package/dist/esm/api/types/BadRequestErrorBody.d.mts +0 -5
- package/dist/esm/api/types/BadRequestErrorBody.mjs +0 -4
- package/dist/esm/api/types/BasicError.d.mts +0 -14
- package/dist/esm/api/types/BasicError.mjs +0 -4
- package/dist/esm/api/types/ConfigPayload.d.mts +0 -66
- package/dist/esm/api/types/ConfigPayload.mjs +0 -14
- package/dist/esm/api/types/Conversation.d.mts +0 -49
- package/dist/esm/api/types/Conversation.mjs +0 -4
- package/dist/esm/api/types/ConversationAnalysis.d.mts +0 -9
- package/dist/esm/api/types/ConversationAnalysis.mjs +0 -4
- package/dist/esm/api/types/ConversationCreatedPayload.d.mts +0 -8
- package/dist/esm/api/types/ConversationCreatedPayload.mjs +0 -4
- package/dist/esm/api/types/ConversationEval.d.mts +0 -4
- package/dist/esm/api/types/ConversationEval.mjs +0 -4
- package/dist/esm/api/types/ConversationEvalPrompt.d.mts +0 -11
- package/dist/esm/api/types/ConversationEvalPrompt.mjs +0 -4
- package/dist/esm/api/types/ConversationEvaluation.d.mts +0 -8
- package/dist/esm/api/types/ConversationEvaluation.mjs +0 -4
- package/dist/esm/api/types/ConversationEvaluationResult.d.mts +0 -32
- package/dist/esm/api/types/ConversationEvaluationResult.mjs +0 -12
- package/dist/esm/api/types/ConversationExtraction.d.mts +0 -22
- package/dist/esm/api/types/ConversationExtraction.mjs +0 -4
- package/dist/esm/api/types/ConversationItem.d.mts +0 -33
- package/dist/esm/api/types/ConversationItem.mjs +0 -10
- package/dist/esm/api/types/CreateAgentRequest.d.mts +0 -70
- package/dist/esm/api/types/CreateAgentRequest.mjs +0 -10
- package/dist/esm/api/types/DtmfPayload.d.mts +0 -8
- package/dist/esm/api/types/DtmfPayload.mjs +0 -4
- package/dist/esm/api/types/ErrorPayload.d.mts +0 -17
- package/dist/esm/api/types/ErrorPayload.mjs +0 -4
- package/dist/esm/api/types/Error_.d.mts +0 -5
- package/dist/esm/api/types/Error_.mjs +0 -4
- package/dist/esm/api/types/ExtractionField.d.mts +0 -23
- package/dist/esm/api/types/ExtractionField.mjs +0 -12
- package/dist/esm/api/types/ExtractionSchema.d.mts +0 -14
- package/dist/esm/api/types/ExtractionSchema.mjs +0 -4
- package/dist/esm/api/types/InputCancelledPayload.d.mts +0 -6
- package/dist/esm/api/types/InputCancelledPayload.mjs +0 -4
- package/dist/esm/api/types/InputTextPayload.d.mts +0 -8
- package/dist/esm/api/types/InputTextPayload.mjs +0 -4
- package/dist/esm/api/types/InterruptedResponsePayload.d.mts +0 -8
- package/dist/esm/api/types/InterruptedResponsePayload.mjs +0 -4
- package/dist/esm/api/types/OutboundCallConfig.d.mts +0 -39
- package/dist/esm/api/types/OutboundCallConfig.mjs +0 -4
- package/dist/esm/api/types/Project.d.mts +0 -22
- package/dist/esm/api/types/Project.mjs +0 -4
- package/dist/esm/api/types/ReadyToStartConversationPayload.d.mts +0 -6
- package/dist/esm/api/types/ReadyToStartConversationPayload.mjs +0 -4
- package/dist/esm/api/types/SetExternalIdPayload.d.mts +0 -8
- package/dist/esm/api/types/SetExternalIdPayload.mjs +0 -4
- package/dist/esm/api/types/SetTwilioCallSidPayload.d.mts +0 -8
- package/dist/esm/api/types/SetTwilioCallSidPayload.mjs +0 -4
- package/dist/esm/api/types/Task.d.mts +0 -9
- package/dist/esm/api/types/Task.mjs +0 -4
- package/dist/esm/api/types/Tool.d.mts +0 -51
- package/dist/esm/api/types/Tool.mjs +0 -14
- package/dist/esm/api/types/ToolCallInterruptedPayload.d.mts +0 -12
- package/dist/esm/api/types/ToolCallInterruptedPayload.mjs +0 -4
- package/dist/esm/api/types/ToolCallOutputPayload.d.mts +0 -9
- package/dist/esm/api/types/ToolCallOutputPayload.mjs +0 -4
- package/dist/esm/api/types/ToolCallOutputProcessedPayload.d.mts +0 -35
- package/dist/esm/api/types/ToolCallOutputProcessedPayload.mjs +0 -4
- package/dist/esm/api/types/ToolCallPayload.d.mts +0 -12
- package/dist/esm/api/types/ToolCallPayload.mjs +0 -4
- package/dist/esm/api/types/ToolParameter.d.mts +0 -38
- package/dist/esm/api/types/ToolParameter.mjs +0 -19
- package/dist/esm/api/types/UpdateSystemPromptPayload.d.mts +0 -8
- package/dist/esm/api/types/UpdateSystemPromptPayload.mjs +0 -4
- package/dist/esm/api/types/UserFinishedSpeakingPayload.d.mts +0 -6
- package/dist/esm/api/types/UserFinishedSpeakingPayload.mjs +0 -4
- package/dist/esm/api/types/UserStartedSpeakingPayload.d.mts +0 -6
- package/dist/esm/api/types/UserStartedSpeakingPayload.mjs +0 -4
- package/dist/esm/api/types/ValidationError.d.mts +0 -14
- package/dist/esm/api/types/ValidationError.mjs +0 -4
- package/dist/esm/api/types/Voice.d.mts +0 -11
- package/dist/esm/api/types/Voice.mjs +0 -4
- package/dist/esm/api/types/index.d.mts +0 -44
- package/dist/esm/api/types/index.mjs +0 -44
- package/dist/esm/api/types/overrides.d.mts +0 -50
- package/dist/esm/api/types/overrides.mjs +0 -1
- package/dist/esm/core/auth/BasicAuth.d.mts +0 -8
- package/dist/esm/core/auth/BasicAuth.mjs +0 -23
- package/dist/esm/core/auth/BearerToken.d.mts +0 -5
- package/dist/esm/core/auth/BearerToken.mjs +0 -12
- package/dist/esm/core/auth/index.d.mts +0 -2
- package/dist/esm/core/auth/index.mjs +0 -2
- package/dist/esm/core/base64.d.mts +0 -2
- package/dist/esm/core/base64.mjs +0 -22
- package/dist/esm/core/fetcher/APIResponse.d.mts +0 -20
- package/dist/esm/core/fetcher/APIResponse.mjs +0 -1
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +0 -20
- package/dist/esm/core/fetcher/BinaryResponse.mjs +0 -14
- package/dist/esm/core/fetcher/Fetcher.d.mts +0 -40
- package/dist/esm/core/fetcher/Fetcher.mjs +0 -116
- package/dist/esm/core/fetcher/Headers.d.mts +0 -2
- package/dist/esm/core/fetcher/Headers.mjs +0 -82
- package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +0 -58
- package/dist/esm/core/fetcher/HttpResponsePromise.mjs +0 -99
- package/dist/esm/core/fetcher/RawResponse.d.mts +0 -29
- package/dist/esm/core/fetcher/RawResponse.mjs +0 -40
- package/dist/esm/core/fetcher/ResponseWithBody.d.mts +0 -4
- package/dist/esm/core/fetcher/ResponseWithBody.mjs +0 -3
- package/dist/esm/core/fetcher/Supplier.d.mts +0 -4
- package/dist/esm/core/fetcher/Supplier.mjs +0 -19
- package/dist/esm/core/fetcher/createRequestUrl.d.mts +0 -1
- package/dist/esm/core/fetcher/createRequestUrl.mjs +0 -5
- package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +0 -1
- package/dist/esm/core/fetcher/getErrorResponseBody.mjs +0 -41
- package/dist/esm/core/fetcher/getFetchFn.d.mts +0 -1
- package/dist/esm/core/fetcher/getFetchFn.mjs +0 -14
- package/dist/esm/core/fetcher/getHeader.d.mts +0 -1
- package/dist/esm/core/fetcher/getHeader.mjs +0 -8
- package/dist/esm/core/fetcher/getRequestBody.d.mts +0 -7
- package/dist/esm/core/fetcher/getRequestBody.mjs +0 -20
- package/dist/esm/core/fetcher/getResponseBody.d.mts +0 -1
- package/dist/esm/core/fetcher/getResponseBody.mjs +0 -52
- package/dist/esm/core/fetcher/index.d.mts +0 -9
- package/dist/esm/core/fetcher/index.mjs +0 -5
- package/dist/esm/core/fetcher/makeRequest.d.mts +0 -1
- package/dist/esm/core/fetcher/makeRequest.mjs +0 -38
- package/dist/esm/core/fetcher/requestWithRetries.d.mts +0 -1
- package/dist/esm/core/fetcher/requestWithRetries.mjs +0 -37
- package/dist/esm/core/fetcher/signals.d.mts +0 -11
- package/dist/esm/core/fetcher/signals.mjs +0 -32
- package/dist/esm/core/headers.d.mts +0 -3
- package/dist/esm/core/headers.mjs +0 -25
- package/dist/esm/core/index.d.mts +0 -6
- package/dist/esm/core/index.mjs +0 -6
- package/dist/esm/core/json.d.mts +0 -15
- package/dist/esm/core/json.mjs +0 -19
- package/dist/esm/core/runtime/index.d.mts +0 -1
- package/dist/esm/core/runtime/index.mjs +0 -1
- package/dist/esm/core/runtime/runtime.d.mts +0 -9
- package/dist/esm/core/runtime/runtime.mjs +0 -99
- package/dist/esm/core/url/index.d.mts +0 -2
- package/dist/esm/core/url/index.mjs +0 -2
- package/dist/esm/core/url/join.d.mts +0 -1
- package/dist/esm/core/url/join.mjs +0 -66
- package/dist/esm/core/url/qs.d.mts +0 -6
- package/dist/esm/core/url/qs.mjs +0 -61
- package/dist/esm/core/websocket/events.d.mts +0 -36
- package/dist/esm/core/websocket/events.mjs +0 -21
- package/dist/esm/core/websocket/index.d.mts +0 -1
- package/dist/esm/core/websocket/index.mjs +0 -1
- package/dist/esm/core/websocket/ws.d.mts +0 -147
- package/dist/esm/core/websocket/ws.mjs +0 -423
- package/dist/esm/environments.d.mts +0 -14
- package/dist/esm/environments.mjs +0 -9
- package/dist/esm/errors/PhonicError.d.mts +0 -15
- package/dist/esm/errors/PhonicError.mjs +0 -26
- package/dist/esm/errors/PhonicTimeoutError.d.mts +0 -6
- package/dist/esm/errors/PhonicTimeoutError.mjs +0 -9
- package/dist/esm/errors/index.d.mts +0 -2
- package/dist/esm/errors/index.mjs +0 -2
- package/dist/esm/index.d.mts +0 -4
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/version.d.mts +0 -1
- package/dist/esm/version.mjs +0 -1
package/dist/esm/core/base64.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
function base64ToBytes(base64) {
|
|
2
|
-
const binString = atob(base64);
|
|
3
|
-
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
|
4
|
-
}
|
|
5
|
-
function bytesToBase64(bytes) {
|
|
6
|
-
const binString = String.fromCodePoint(...bytes);
|
|
7
|
-
return btoa(binString);
|
|
8
|
-
}
|
|
9
|
-
export function base64Encode(input) {
|
|
10
|
-
if (typeof Buffer !== "undefined") {
|
|
11
|
-
return Buffer.from(input, "utf8").toString("base64");
|
|
12
|
-
}
|
|
13
|
-
const bytes = new TextEncoder().encode(input);
|
|
14
|
-
return bytesToBase64(bytes);
|
|
15
|
-
}
|
|
16
|
-
export function base64Decode(input) {
|
|
17
|
-
if (typeof Buffer !== "undefined") {
|
|
18
|
-
return Buffer.from(input, "base64").toString("utf8");
|
|
19
|
-
}
|
|
20
|
-
const bytes = base64ToBytes(input);
|
|
21
|
-
return new TextDecoder().decode(bytes);
|
|
22
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { RawResponse } from "./RawResponse.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* The response of an API call.
|
|
4
|
-
* It is a successful response or a failed response.
|
|
5
|
-
*/
|
|
6
|
-
export type APIResponse<Success, Failure> = SuccessfulResponse<Success> | FailedResponse<Failure>;
|
|
7
|
-
export interface SuccessfulResponse<T> {
|
|
8
|
-
ok: true;
|
|
9
|
-
body: T;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Use `rawResponse` instead
|
|
12
|
-
*/
|
|
13
|
-
headers?: Record<string, any>;
|
|
14
|
-
rawResponse: RawResponse;
|
|
15
|
-
}
|
|
16
|
-
export interface FailedResponse<T> {
|
|
17
|
-
ok: false;
|
|
18
|
-
error: T;
|
|
19
|
-
rawResponse: RawResponse;
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ResponseWithBody } from "./ResponseWithBody.mjs";
|
|
2
|
-
export type BinaryResponse = {
|
|
3
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
|
|
4
|
-
bodyUsed: boolean;
|
|
5
|
-
/**
|
|
6
|
-
* Returns a ReadableStream of the response body.
|
|
7
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body)
|
|
8
|
-
*/
|
|
9
|
-
stream: () => ReadableStream<Uint8Array>;
|
|
10
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
|
|
11
|
-
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
12
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
|
|
13
|
-
blob: () => Promise<Blob>;
|
|
14
|
-
/**
|
|
15
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
|
|
16
|
-
* Some versions of the Fetch API may not support this method.
|
|
17
|
-
*/
|
|
18
|
-
bytes?(): Promise<Uint8Array>;
|
|
19
|
-
};
|
|
20
|
-
export declare function getBinaryResponse(response: ResponseWithBody): BinaryResponse;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function getBinaryResponse(response) {
|
|
2
|
-
const binaryResponse = {
|
|
3
|
-
get bodyUsed() {
|
|
4
|
-
return response.bodyUsed;
|
|
5
|
-
},
|
|
6
|
-
stream: () => response.body,
|
|
7
|
-
arrayBuffer: response.arrayBuffer.bind(response),
|
|
8
|
-
blob: response.blob.bind(response),
|
|
9
|
-
};
|
|
10
|
-
if ("bytes" in response && typeof response.bytes === "function") {
|
|
11
|
-
binaryResponse.bytes = response.bytes.bind(response);
|
|
12
|
-
}
|
|
13
|
-
return binaryResponse;
|
|
14
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { APIResponse } from "./APIResponse.mjs";
|
|
2
|
-
import { Supplier } from "./Supplier.mjs";
|
|
3
|
-
export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
|
|
4
|
-
export declare namespace Fetcher {
|
|
5
|
-
interface Args {
|
|
6
|
-
url: string;
|
|
7
|
-
method: string;
|
|
8
|
-
contentType?: string;
|
|
9
|
-
headers?: Record<string, string | Supplier<string | undefined> | undefined>;
|
|
10
|
-
queryParameters?: Record<string, unknown>;
|
|
11
|
-
body?: unknown;
|
|
12
|
-
timeoutMs?: number;
|
|
13
|
-
maxRetries?: number;
|
|
14
|
-
withCredentials?: boolean;
|
|
15
|
-
abortSignal?: AbortSignal;
|
|
16
|
-
requestType?: "json" | "file" | "bytes";
|
|
17
|
-
responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer" | "binary-response";
|
|
18
|
-
duplex?: "half";
|
|
19
|
-
}
|
|
20
|
-
type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
|
|
21
|
-
interface FailedStatusCodeError {
|
|
22
|
-
reason: "status-code";
|
|
23
|
-
statusCode: number;
|
|
24
|
-
body: unknown;
|
|
25
|
-
}
|
|
26
|
-
interface NonJsonError {
|
|
27
|
-
reason: "non-json";
|
|
28
|
-
statusCode: number;
|
|
29
|
-
rawBody: string;
|
|
30
|
-
}
|
|
31
|
-
interface TimeoutError {
|
|
32
|
-
reason: "timeout";
|
|
33
|
-
}
|
|
34
|
-
interface UnknownError {
|
|
35
|
-
reason: "unknown";
|
|
36
|
-
errorMessage: string;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>;
|
|
40
|
-
export declare const fetcher: FetchFunction;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { toJson } from "../json.mjs";
|
|
11
|
-
import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
12
|
-
import { Supplier } from "./Supplier.mjs";
|
|
13
|
-
import { createRequestUrl } from "./createRequestUrl.mjs";
|
|
14
|
-
import { getErrorResponseBody } from "./getErrorResponseBody.mjs";
|
|
15
|
-
import { getFetchFn } from "./getFetchFn.mjs";
|
|
16
|
-
import { getRequestBody } from "./getRequestBody.mjs";
|
|
17
|
-
import { getResponseBody } from "./getResponseBody.mjs";
|
|
18
|
-
import { makeRequest } from "./makeRequest.mjs";
|
|
19
|
-
import { requestWithRetries } from "./requestWithRetries.mjs";
|
|
20
|
-
function getHeaders(args) {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const newHeaders = {};
|
|
23
|
-
if (args.body !== undefined && args.contentType != null) {
|
|
24
|
-
newHeaders["Content-Type"] = args.contentType;
|
|
25
|
-
}
|
|
26
|
-
if (args.headers == null) {
|
|
27
|
-
return newHeaders;
|
|
28
|
-
}
|
|
29
|
-
for (const [key, value] of Object.entries(args.headers)) {
|
|
30
|
-
const result = yield Supplier.get(value);
|
|
31
|
-
if (typeof result === "string") {
|
|
32
|
-
newHeaders[key] = result;
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (result == null) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
newHeaders[key] = `${result}`;
|
|
39
|
-
}
|
|
40
|
-
return newHeaders;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
export function fetcherImpl(args) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const url = createRequestUrl(args.url, args.queryParameters);
|
|
46
|
-
const requestBody = yield getRequestBody({
|
|
47
|
-
body: args.body,
|
|
48
|
-
type: args.requestType === "json" ? "json" : "other",
|
|
49
|
-
});
|
|
50
|
-
const fetchFn = yield getFetchFn();
|
|
51
|
-
try {
|
|
52
|
-
const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
return makeRequest(fetchFn, url, args.method, yield getHeaders(args), requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
|
|
54
|
-
}), args.maxRetries);
|
|
55
|
-
if (response.status >= 200 && response.status < 400) {
|
|
56
|
-
return {
|
|
57
|
-
ok: true,
|
|
58
|
-
body: (yield getResponseBody(response, args.responseType)),
|
|
59
|
-
headers: response.headers,
|
|
60
|
-
rawResponse: toRawResponse(response),
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return {
|
|
65
|
-
ok: false,
|
|
66
|
-
error: {
|
|
67
|
-
reason: "status-code",
|
|
68
|
-
statusCode: response.status,
|
|
69
|
-
body: yield getErrorResponseBody(response),
|
|
70
|
-
},
|
|
71
|
-
rawResponse: toRawResponse(response),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
if (args.abortSignal != null && args.abortSignal.aborted) {
|
|
77
|
-
return {
|
|
78
|
-
ok: false,
|
|
79
|
-
error: {
|
|
80
|
-
reason: "unknown",
|
|
81
|
-
errorMessage: "The user aborted a request",
|
|
82
|
-
},
|
|
83
|
-
rawResponse: abortRawResponse,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
else if (error instanceof Error && error.name === "AbortError") {
|
|
87
|
-
return {
|
|
88
|
-
ok: false,
|
|
89
|
-
error: {
|
|
90
|
-
reason: "timeout",
|
|
91
|
-
},
|
|
92
|
-
rawResponse: abortRawResponse,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
else if (error instanceof Error) {
|
|
96
|
-
return {
|
|
97
|
-
ok: false,
|
|
98
|
-
error: {
|
|
99
|
-
reason: "unknown",
|
|
100
|
-
errorMessage: error.message,
|
|
101
|
-
},
|
|
102
|
-
rawResponse: unknownRawResponse,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
ok: false,
|
|
107
|
-
error: {
|
|
108
|
-
reason: "unknown",
|
|
109
|
-
errorMessage: toJson(error),
|
|
110
|
-
},
|
|
111
|
-
rawResponse: unknownRawResponse,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
export const fetcher = fetcherImpl;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
let Headers;
|
|
2
|
-
if (typeof globalThis.Headers !== "undefined") {
|
|
3
|
-
Headers = globalThis.Headers;
|
|
4
|
-
}
|
|
5
|
-
else {
|
|
6
|
-
Headers = class Headers {
|
|
7
|
-
constructor(init) {
|
|
8
|
-
this.headers = new Map();
|
|
9
|
-
if (init) {
|
|
10
|
-
if (init instanceof Headers) {
|
|
11
|
-
init.forEach((value, key) => this.append(key, value));
|
|
12
|
-
}
|
|
13
|
-
else if (Array.isArray(init)) {
|
|
14
|
-
for (const [key, value] of init) {
|
|
15
|
-
if (typeof key === "string" && typeof value === "string") {
|
|
16
|
-
this.append(key, value);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
throw new TypeError("Each header entry must be a [string, string] tuple");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
for (const [key, value] of Object.entries(init)) {
|
|
25
|
-
if (typeof value === "string") {
|
|
26
|
-
this.append(key, value);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
throw new TypeError("Header values must be strings");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
append(name, value) {
|
|
36
|
-
const key = name.toLowerCase();
|
|
37
|
-
const existing = this.headers.get(key) || [];
|
|
38
|
-
this.headers.set(key, [...existing, value]);
|
|
39
|
-
}
|
|
40
|
-
delete(name) {
|
|
41
|
-
const key = name.toLowerCase();
|
|
42
|
-
this.headers.delete(key);
|
|
43
|
-
}
|
|
44
|
-
get(name) {
|
|
45
|
-
const key = name.toLowerCase();
|
|
46
|
-
const values = this.headers.get(key);
|
|
47
|
-
return values ? values.join(", ") : null;
|
|
48
|
-
}
|
|
49
|
-
has(name) {
|
|
50
|
-
const key = name.toLowerCase();
|
|
51
|
-
return this.headers.has(key);
|
|
52
|
-
}
|
|
53
|
-
set(name, value) {
|
|
54
|
-
const key = name.toLowerCase();
|
|
55
|
-
this.headers.set(key, [value]);
|
|
56
|
-
}
|
|
57
|
-
forEach(callbackfn, thisArg) {
|
|
58
|
-
const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
|
|
59
|
-
this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this));
|
|
60
|
-
}
|
|
61
|
-
getSetCookie() {
|
|
62
|
-
return this.headers.get("set-cookie") || [];
|
|
63
|
-
}
|
|
64
|
-
*entries() {
|
|
65
|
-
for (const [key, values] of this.headers.entries()) {
|
|
66
|
-
yield [key, values.join(", ")];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
*keys() {
|
|
70
|
-
yield* this.headers.keys();
|
|
71
|
-
}
|
|
72
|
-
*values() {
|
|
73
|
-
for (const values of this.headers.values()) {
|
|
74
|
-
yield values.join(", ");
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
[Symbol.iterator]() {
|
|
78
|
-
return this.entries();
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export { Headers };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { WithRawResponse } from "./RawResponse.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* A promise that returns the parsed response and lets you retrieve the raw response too.
|
|
4
|
-
*/
|
|
5
|
-
export declare class HttpResponsePromise<T> extends Promise<T> {
|
|
6
|
-
private innerPromise;
|
|
7
|
-
private unwrappedPromise;
|
|
8
|
-
private constructor();
|
|
9
|
-
/**
|
|
10
|
-
* Creates an `HttpResponsePromise` from a function that returns a promise.
|
|
11
|
-
*
|
|
12
|
-
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
|
|
13
|
-
* @param args - Arguments to pass to the function.
|
|
14
|
-
* @returns An `HttpResponsePromise` instance.
|
|
15
|
-
*/
|
|
16
|
-
static fromFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T>(fn: F, ...args: Parameters<F>): HttpResponsePromise<T>;
|
|
17
|
-
/**
|
|
18
|
-
* Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
|
|
19
|
-
*
|
|
20
|
-
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
|
|
21
|
-
* @returns A function that returns an `HttpResponsePromise` instance.
|
|
22
|
-
*/
|
|
23
|
-
static interceptFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T = Awaited<ReturnType<F>>["data"]>(fn: F): (...args: Parameters<F>) => HttpResponsePromise<T>;
|
|
24
|
-
/**
|
|
25
|
-
* Creates an `HttpResponsePromise` from an existing promise.
|
|
26
|
-
*
|
|
27
|
-
* @param promise - A promise resolving to a `WithRawResponse` object.
|
|
28
|
-
* @returns An `HttpResponsePromise` instance.
|
|
29
|
-
*/
|
|
30
|
-
static fromPromise<T>(promise: Promise<WithRawResponse<T>>): HttpResponsePromise<T>;
|
|
31
|
-
/**
|
|
32
|
-
* Creates an `HttpResponsePromise` from an executor function.
|
|
33
|
-
*
|
|
34
|
-
* @param executor - A function that takes resolve and reject callbacks to create a promise.
|
|
35
|
-
* @returns An `HttpResponsePromise` instance.
|
|
36
|
-
*/
|
|
37
|
-
static fromExecutor<T>(executor: (resolve: (value: WithRawResponse<T>) => void, reject: (reason?: unknown) => void) => void): HttpResponsePromise<T>;
|
|
38
|
-
/**
|
|
39
|
-
* Creates an `HttpResponsePromise` from a resolved result.
|
|
40
|
-
*
|
|
41
|
-
* @param result - A `WithRawResponse` object to resolve immediately.
|
|
42
|
-
* @returns An `HttpResponsePromise` instance.
|
|
43
|
-
*/
|
|
44
|
-
static fromResult<T>(result: WithRawResponse<T>): HttpResponsePromise<T>;
|
|
45
|
-
private unwrap;
|
|
46
|
-
/** @inheritdoc */
|
|
47
|
-
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
48
|
-
/** @inheritdoc */
|
|
49
|
-
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
50
|
-
/** @inheritdoc */
|
|
51
|
-
finally(onfinally?: (() => void) | null): Promise<T>;
|
|
52
|
-
/**
|
|
53
|
-
* Retrieves the data and raw response.
|
|
54
|
-
*
|
|
55
|
-
* @returns A promise resolving to a `WithRawResponse` object.
|
|
56
|
-
*/
|
|
57
|
-
withRawResponse(): Promise<WithRawResponse<T>>;
|
|
58
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* A promise that returns the parsed response and lets you retrieve the raw response too.
|
|
12
|
-
*/
|
|
13
|
-
export class HttpResponsePromise extends Promise {
|
|
14
|
-
constructor(promise) {
|
|
15
|
-
// Initialize with a no-op to avoid premature parsing
|
|
16
|
-
super((resolve) => {
|
|
17
|
-
resolve(undefined);
|
|
18
|
-
});
|
|
19
|
-
this.innerPromise = promise;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Creates an `HttpResponsePromise` from a function that returns a promise.
|
|
23
|
-
*
|
|
24
|
-
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
|
|
25
|
-
* @param args - Arguments to pass to the function.
|
|
26
|
-
* @returns An `HttpResponsePromise` instance.
|
|
27
|
-
*/
|
|
28
|
-
static fromFunction(fn, ...args) {
|
|
29
|
-
return new HttpResponsePromise(fn(...args));
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
|
|
33
|
-
*
|
|
34
|
-
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
|
|
35
|
-
* @returns A function that returns an `HttpResponsePromise` instance.
|
|
36
|
-
*/
|
|
37
|
-
static interceptFunction(fn) {
|
|
38
|
-
return (...args) => {
|
|
39
|
-
return HttpResponsePromise.fromPromise(fn(...args));
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Creates an `HttpResponsePromise` from an existing promise.
|
|
44
|
-
*
|
|
45
|
-
* @param promise - A promise resolving to a `WithRawResponse` object.
|
|
46
|
-
* @returns An `HttpResponsePromise` instance.
|
|
47
|
-
*/
|
|
48
|
-
static fromPromise(promise) {
|
|
49
|
-
return new HttpResponsePromise(promise);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Creates an `HttpResponsePromise` from an executor function.
|
|
53
|
-
*
|
|
54
|
-
* @param executor - A function that takes resolve and reject callbacks to create a promise.
|
|
55
|
-
* @returns An `HttpResponsePromise` instance.
|
|
56
|
-
*/
|
|
57
|
-
static fromExecutor(executor) {
|
|
58
|
-
const promise = new Promise(executor);
|
|
59
|
-
return new HttpResponsePromise(promise);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Creates an `HttpResponsePromise` from a resolved result.
|
|
63
|
-
*
|
|
64
|
-
* @param result - A `WithRawResponse` object to resolve immediately.
|
|
65
|
-
* @returns An `HttpResponsePromise` instance.
|
|
66
|
-
*/
|
|
67
|
-
static fromResult(result) {
|
|
68
|
-
const promise = Promise.resolve(result);
|
|
69
|
-
return new HttpResponsePromise(promise);
|
|
70
|
-
}
|
|
71
|
-
unwrap() {
|
|
72
|
-
if (!this.unwrappedPromise) {
|
|
73
|
-
this.unwrappedPromise = this.innerPromise.then(({ data }) => data);
|
|
74
|
-
}
|
|
75
|
-
return this.unwrappedPromise;
|
|
76
|
-
}
|
|
77
|
-
/** @inheritdoc */
|
|
78
|
-
then(onfulfilled, onrejected) {
|
|
79
|
-
return this.unwrap().then(onfulfilled, onrejected);
|
|
80
|
-
}
|
|
81
|
-
/** @inheritdoc */
|
|
82
|
-
catch(onrejected) {
|
|
83
|
-
return this.unwrap().catch(onrejected);
|
|
84
|
-
}
|
|
85
|
-
/** @inheritdoc */
|
|
86
|
-
finally(onfinally) {
|
|
87
|
-
return this.unwrap().finally(onfinally);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Retrieves the data and raw response.
|
|
91
|
-
*
|
|
92
|
-
* @returns A promise resolving to a `WithRawResponse` object.
|
|
93
|
-
*/
|
|
94
|
-
withRawResponse() {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
return yield this.innerPromise;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The raw response from the fetch call excluding the body.
|
|
3
|
-
*/
|
|
4
|
-
export type RawResponse = Omit<{
|
|
5
|
-
[K in keyof Response as Response[K] extends Function ? never : K]: Response[K];
|
|
6
|
-
}, "ok" | "body" | "bodyUsed">;
|
|
7
|
-
/**
|
|
8
|
-
* A raw response indicating that the request was aborted.
|
|
9
|
-
*/
|
|
10
|
-
export declare const abortRawResponse: RawResponse;
|
|
11
|
-
/**
|
|
12
|
-
* A raw response indicating an unknown error.
|
|
13
|
-
*/
|
|
14
|
-
export declare const unknownRawResponse: RawResponse;
|
|
15
|
-
/**
|
|
16
|
-
* Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
|
|
17
|
-
* excluding the `body` and `bodyUsed` fields.
|
|
18
|
-
*
|
|
19
|
-
* @param response - The `RawResponse` object to convert.
|
|
20
|
-
* @returns A `RawResponse` object containing the extracted properties of the input response.
|
|
21
|
-
*/
|
|
22
|
-
export declare function toRawResponse(response: Response): RawResponse;
|
|
23
|
-
/**
|
|
24
|
-
* Creates a `RawResponse` from a standard `Response` object.
|
|
25
|
-
*/
|
|
26
|
-
export interface WithRawResponse<T> {
|
|
27
|
-
readonly data: T;
|
|
28
|
-
readonly rawResponse: RawResponse;
|
|
29
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Headers } from "./Headers.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* A raw response indicating that the request was aborted.
|
|
4
|
-
*/
|
|
5
|
-
export const abortRawResponse = {
|
|
6
|
-
headers: new Headers(),
|
|
7
|
-
redirected: false,
|
|
8
|
-
status: 499,
|
|
9
|
-
statusText: "Client Closed Request",
|
|
10
|
-
type: "error",
|
|
11
|
-
url: "",
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* A raw response indicating an unknown error.
|
|
15
|
-
*/
|
|
16
|
-
export const unknownRawResponse = {
|
|
17
|
-
headers: new Headers(),
|
|
18
|
-
redirected: false,
|
|
19
|
-
status: 0,
|
|
20
|
-
statusText: "Unknown Error",
|
|
21
|
-
type: "error",
|
|
22
|
-
url: "",
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
|
|
26
|
-
* excluding the `body` and `bodyUsed` fields.
|
|
27
|
-
*
|
|
28
|
-
* @param response - The `RawResponse` object to convert.
|
|
29
|
-
* @returns A `RawResponse` object containing the extracted properties of the input response.
|
|
30
|
-
*/
|
|
31
|
-
export function toRawResponse(response) {
|
|
32
|
-
return {
|
|
33
|
-
headers: response.headers,
|
|
34
|
-
redirected: response.redirected,
|
|
35
|
-
status: response.status,
|
|
36
|
-
statusText: response.statusText,
|
|
37
|
-
type: response.type,
|
|
38
|
-
url: response.url,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export const Supplier = {
|
|
11
|
-
get: (supplier) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
-
if (typeof supplier === "function") {
|
|
13
|
-
return supplier();
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
return supplier;
|
|
17
|
-
}
|
|
18
|
-
}),
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createRequestUrl(baseUrl: string, queryParameters?: Record<string, unknown>): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getErrorResponseBody(response: Response): Promise<unknown>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { fromJson } from "../json.mjs";
|
|
11
|
-
import { getResponseBody } from "./getResponseBody.mjs";
|
|
12
|
-
export function getErrorResponseBody(response) {
|
|
13
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
var _a, _b, _c;
|
|
15
|
-
let contentType = (_a = response.headers.get("Content-Type")) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
16
|
-
if (contentType == null || contentType.length === 0) {
|
|
17
|
-
return getResponseBody(response);
|
|
18
|
-
}
|
|
19
|
-
if (contentType.indexOf(";") !== -1) {
|
|
20
|
-
contentType = (_c = (_b = contentType.split(";")[0]) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : "";
|
|
21
|
-
}
|
|
22
|
-
switch (contentType) {
|
|
23
|
-
case "application/hal+json":
|
|
24
|
-
case "application/json":
|
|
25
|
-
case "application/ld+json":
|
|
26
|
-
case "application/problem+json":
|
|
27
|
-
case "application/vnd.api+json":
|
|
28
|
-
case "text/json":
|
|
29
|
-
const text = yield response.text();
|
|
30
|
-
return text.length > 0 ? fromJson(text) : undefined;
|
|
31
|
-
default:
|
|
32
|
-
if (contentType.startsWith("application/vnd.") && contentType.endsWith("+json")) {
|
|
33
|
-
const text = yield response.text();
|
|
34
|
-
return text.length > 0 ? fromJson(text) : undefined;
|
|
35
|
-
}
|
|
36
|
-
// Fallback to plain text if content type is not recognized
|
|
37
|
-
// Even if no body is present, the response will be an empty string
|
|
38
|
-
return yield response.text();
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getFetchFn(): Promise<typeof fetch>;
|