@boltix/sdk 0.0.1
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/dist/BaseClient.d.ts +42 -0
- package/dist/BaseClient.js +43 -0
- package/dist/Client.d.ts +77 -0
- package/dist/Client.js +120 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/resources/audit/client/Client.d.ts +37 -0
- package/dist/api/resources/audit/client/Client.js +115 -0
- package/dist/api/resources/audit/client/index.d.ts +1 -0
- package/dist/api/resources/audit/client/index.js +1 -0
- package/dist/api/resources/audit/client/requests/GetEventAuditRequest.d.ts +10 -0
- package/dist/api/resources/audit/client/requests/GetEventAuditRequest.js +2 -0
- package/dist/api/resources/audit/client/requests/ListEventsAuditRequest.d.ts +18 -0
- package/dist/api/resources/audit/client/requests/ListEventsAuditRequest.js +2 -0
- package/dist/api/resources/audit/client/requests/index.d.ts +2 -0
- package/dist/api/resources/audit/client/requests/index.js +1 -0
- package/dist/api/resources/audit/exports.d.ts +2 -0
- package/dist/api/resources/audit/exports.js +3 -0
- package/dist/api/resources/audit/index.d.ts +1 -0
- package/dist/api/resources/audit/index.js +1 -0
- package/dist/api/resources/auth/client/Client.d.ts +55 -0
- package/dist/api/resources/auth/client/Client.js +148 -0
- package/dist/api/resources/auth/client/index.d.ts +1 -0
- package/dist/api/resources/auth/client/index.js +1 -0
- package/dist/api/resources/auth/client/requests/LoginInputBody.d.ts +13 -0
- package/dist/api/resources/auth/client/requests/LoginInputBody.js +2 -0
- package/dist/api/resources/auth/client/requests/RefreshInputBody.d.ts +10 -0
- package/dist/api/resources/auth/client/requests/RefreshInputBody.js +2 -0
- package/dist/api/resources/auth/client/requests/RegisterInputBody.d.ts +18 -0
- package/dist/api/resources/auth/client/requests/RegisterInputBody.js +2 -0
- package/dist/api/resources/auth/client/requests/index.d.ts +3 -0
- package/dist/api/resources/auth/client/requests/index.js +1 -0
- package/dist/api/resources/auth/exports.d.ts +2 -0
- package/dist/api/resources/auth/exports.js +3 -0
- package/dist/api/resources/auth/index.d.ts +1 -0
- package/dist/api/resources/auth/index.js +1 -0
- package/dist/api/resources/automation/client/Client.d.ts +161 -0
- package/dist/api/resources/automation/client/Client.js +539 -0
- package/dist/api/resources/automation/client/index.d.ts +1 -0
- package/dist/api/resources/automation/client/index.js +1 -0
- package/dist/api/resources/automation/client/requests/CreateTriggerInputBody.d.ts +43 -0
- package/dist/api/resources/automation/client/requests/CreateTriggerInputBody.js +11 -0
- package/dist/api/resources/automation/client/requests/CreateWorkflowInputBody.d.ts +39 -0
- package/dist/api/resources/automation/client/requests/CreateWorkflowInputBody.js +2 -0
- package/dist/api/resources/automation/client/requests/DeleteTriggerAutomationRequest.d.ts +10 -0
- package/dist/api/resources/automation/client/requests/DeleteTriggerAutomationRequest.js +2 -0
- package/dist/api/resources/automation/client/requests/DeleteWorkflowAutomationRequest.d.ts +10 -0
- package/dist/api/resources/automation/client/requests/DeleteWorkflowAutomationRequest.js +2 -0
- package/dist/api/resources/automation/client/requests/GetConfigAutomationRequest.d.ts +8 -0
- package/dist/api/resources/automation/client/requests/GetConfigAutomationRequest.js +2 -0
- package/dist/api/resources/automation/client/requests/GetTriggerAutomationRequest.d.ts +10 -0
- package/dist/api/resources/automation/client/requests/GetTriggerAutomationRequest.js +2 -0
- package/dist/api/resources/automation/client/requests/GetWorkflowAutomationRequest.d.ts +10 -0
- package/dist/api/resources/automation/client/requests/GetWorkflowAutomationRequest.js +2 -0
- package/dist/api/resources/automation/client/requests/UpdateConfigInputBody.d.ts +46 -0
- package/dist/api/resources/automation/client/requests/UpdateConfigInputBody.js +2 -0
- package/dist/api/resources/automation/client/requests/UpdateTriggerInputBody.d.ts +42 -0
- package/dist/api/resources/automation/client/requests/UpdateTriggerInputBody.js +11 -0
- package/dist/api/resources/automation/client/requests/UpdateWorkflowInputBody.d.ts +38 -0
- package/dist/api/resources/automation/client/requests/UpdateWorkflowInputBody.js +2 -0
- package/dist/api/resources/automation/client/requests/index.d.ts +10 -0
- package/dist/api/resources/automation/client/requests/index.js +2 -0
- package/dist/api/resources/automation/exports.d.ts +2 -0
- package/dist/api/resources/automation/exports.js +3 -0
- package/dist/api/resources/automation/index.d.ts +1 -0
- package/dist/api/resources/automation/index.js +1 -0
- package/dist/api/resources/campaigns/client/Client.d.ts +140 -0
- package/dist/api/resources/campaigns/client/Client.js +447 -0
- package/dist/api/resources/campaigns/client/index.d.ts +1 -0
- package/dist/api/resources/campaigns/client/index.js +1 -0
- package/dist/api/resources/campaigns/client/requests/AddRecipientsInputBody.d.ts +13 -0
- package/dist/api/resources/campaigns/client/requests/AddRecipientsInputBody.js +2 -0
- package/dist/api/resources/campaigns/client/requests/CancelCampaignsRequest.d.ts +10 -0
- package/dist/api/resources/campaigns/client/requests/CancelCampaignsRequest.js +2 -0
- package/dist/api/resources/campaigns/client/requests/CreateCampaignInputBody.d.ts +24 -0
- package/dist/api/resources/campaigns/client/requests/CreateCampaignInputBody.js +2 -0
- package/dist/api/resources/campaigns/client/requests/DeleteCampaignsRequest.d.ts +10 -0
- package/dist/api/resources/campaigns/client/requests/DeleteCampaignsRequest.js +2 -0
- package/dist/api/resources/campaigns/client/requests/GetCampaignsRequest.d.ts +10 -0
- package/dist/api/resources/campaigns/client/requests/GetCampaignsRequest.js +2 -0
- package/dist/api/resources/campaigns/client/requests/ListRecipientsCampaignsRequest.d.ts +10 -0
- package/dist/api/resources/campaigns/client/requests/ListRecipientsCampaignsRequest.js +2 -0
- package/dist/api/resources/campaigns/client/requests/PauseCampaignsRequest.d.ts +10 -0
- package/dist/api/resources/campaigns/client/requests/PauseCampaignsRequest.js +2 -0
- package/dist/api/resources/campaigns/client/requests/StartCampaignsRequest.d.ts +10 -0
- package/dist/api/resources/campaigns/client/requests/StartCampaignsRequest.js +2 -0
- package/dist/api/resources/campaigns/client/requests/UpdateCampaignInputBody.d.ts +26 -0
- package/dist/api/resources/campaigns/client/requests/UpdateCampaignInputBody.js +2 -0
- package/dist/api/resources/campaigns/client/requests/index.d.ts +9 -0
- package/dist/api/resources/campaigns/client/requests/index.js +1 -0
- package/dist/api/resources/campaigns/exports.d.ts +2 -0
- package/dist/api/resources/campaigns/exports.js +3 -0
- package/dist/api/resources/campaigns/index.d.ts +1 -0
- package/dist/api/resources/campaigns/index.js +1 -0
- package/dist/api/resources/catalog/client/Client.d.ts +103 -0
- package/dist/api/resources/catalog/client/Client.js +320 -0
- package/dist/api/resources/catalog/client/index.d.ts +1 -0
- package/dist/api/resources/catalog/client/index.js +1 -0
- package/dist/api/resources/catalog/client/requests/CreateProductInputBody.d.ts +30 -0
- package/dist/api/resources/catalog/client/requests/CreateProductInputBody.js +2 -0
- package/dist/api/resources/catalog/client/requests/CreateStoreInputBody.d.ts +16 -0
- package/dist/api/resources/catalog/client/requests/CreateStoreInputBody.js +2 -0
- package/dist/api/resources/catalog/client/requests/DeleteStoreCatalogRequest.d.ts +10 -0
- package/dist/api/resources/catalog/client/requests/DeleteStoreCatalogRequest.js +2 -0
- package/dist/api/resources/catalog/client/requests/GetStoreCatalogRequest.d.ts +10 -0
- package/dist/api/resources/catalog/client/requests/GetStoreCatalogRequest.js +2 -0
- package/dist/api/resources/catalog/client/requests/ListProductsCatalogRequest.d.ts +10 -0
- package/dist/api/resources/catalog/client/requests/ListProductsCatalogRequest.js +2 -0
- package/dist/api/resources/catalog/client/requests/UpdateStoreInputBody.d.ts +18 -0
- package/dist/api/resources/catalog/client/requests/UpdateStoreInputBody.js +2 -0
- package/dist/api/resources/catalog/client/requests/index.d.ts +6 -0
- package/dist/api/resources/catalog/client/requests/index.js +1 -0
- package/dist/api/resources/catalog/exports.d.ts +2 -0
- package/dist/api/resources/catalog/exports.js +3 -0
- package/dist/api/resources/catalog/index.d.ts +1 -0
- package/dist/api/resources/catalog/index.js +1 -0
- package/dist/api/resources/channels/client/Client.d.ts +75 -0
- package/dist/api/resources/channels/client/Client.js +229 -0
- package/dist/api/resources/channels/client/index.d.ts +1 -0
- package/dist/api/resources/channels/client/index.js +1 -0
- package/dist/api/resources/channels/client/requests/CreateChannelInputBody.d.ts +28 -0
- package/dist/api/resources/channels/client/requests/CreateChannelInputBody.js +2 -0
- package/dist/api/resources/channels/client/requests/DeleteChannelsRequest.d.ts +10 -0
- package/dist/api/resources/channels/client/requests/DeleteChannelsRequest.js +2 -0
- package/dist/api/resources/channels/client/requests/GetChannelsRequest.d.ts +10 -0
- package/dist/api/resources/channels/client/requests/GetChannelsRequest.js +2 -0
- package/dist/api/resources/channels/client/requests/UpdateChannelInputBody.d.ts +31 -0
- package/dist/api/resources/channels/client/requests/UpdateChannelInputBody.js +10 -0
- package/dist/api/resources/channels/client/requests/index.d.ts +4 -0
- package/dist/api/resources/channels/client/requests/index.js +1 -0
- package/dist/api/resources/channels/exports.d.ts +2 -0
- package/dist/api/resources/channels/exports.js +3 -0
- package/dist/api/resources/channels/index.d.ts +1 -0
- package/dist/api/resources/channels/index.js +1 -0
- package/dist/api/resources/contacts/client/Client.d.ts +118 -0
- package/dist/api/resources/contacts/client/Client.js +368 -0
- package/dist/api/resources/contacts/client/index.d.ts +1 -0
- package/dist/api/resources/contacts/client/index.js +1 -0
- package/dist/api/resources/contacts/client/requests/AssignInputBody.d.ts +12 -0
- package/dist/api/resources/contacts/client/requests/AssignInputBody.js +2 -0
- package/dist/api/resources/contacts/client/requests/CreateContactInputBody.d.ts +21 -0
- package/dist/api/resources/contacts/client/requests/CreateContactInputBody.js +2 -0
- package/dist/api/resources/contacts/client/requests/DeleteContactsRequest.d.ts +10 -0
- package/dist/api/resources/contacts/client/requests/DeleteContactsRequest.js +2 -0
- package/dist/api/resources/contacts/client/requests/GetContactsRequest.d.ts +10 -0
- package/dist/api/resources/contacts/client/requests/GetContactsRequest.js +2 -0
- package/dist/api/resources/contacts/client/requests/MarkReadContactsRequest.d.ts +10 -0
- package/dist/api/resources/contacts/client/requests/MarkReadContactsRequest.js +2 -0
- package/dist/api/resources/contacts/client/requests/SetTagsInputBody.d.ts +14 -0
- package/dist/api/resources/contacts/client/requests/SetTagsInputBody.js +2 -0
- package/dist/api/resources/contacts/client/requests/UpdateContactInputBody.d.ts +14 -0
- package/dist/api/resources/contacts/client/requests/UpdateContactInputBody.js +2 -0
- package/dist/api/resources/contacts/client/requests/index.d.ts +7 -0
- package/dist/api/resources/contacts/client/requests/index.js +1 -0
- package/dist/api/resources/contacts/exports.d.ts +2 -0
- package/dist/api/resources/contacts/exports.js +3 -0
- package/dist/api/resources/contacts/index.d.ts +1 -0
- package/dist/api/resources/contacts/index.js +1 -0
- package/dist/api/resources/identity/client/Client.d.ts +58 -0
- package/dist/api/resources/identity/client/Client.js +180 -0
- package/dist/api/resources/identity/client/index.d.ts +1 -0
- package/dist/api/resources/identity/client/index.js +1 -0
- package/dist/api/resources/identity/client/requests/CreateAccountInputBody.d.ts +15 -0
- package/dist/api/resources/identity/client/requests/CreateAccountInputBody.js +2 -0
- package/dist/api/resources/identity/client/requests/UpdateProfileInputBody.d.ts +10 -0
- package/dist/api/resources/identity/client/requests/UpdateProfileInputBody.js +2 -0
- package/dist/api/resources/identity/client/requests/index.d.ts +2 -0
- package/dist/api/resources/identity/client/requests/index.js +1 -0
- package/dist/api/resources/identity/exports.d.ts +2 -0
- package/dist/api/resources/identity/exports.js +3 -0
- package/dist/api/resources/identity/index.d.ts +1 -0
- package/dist/api/resources/identity/index.js +1 -0
- package/dist/api/resources/index.d.ts +36 -0
- package/dist/api/resources/index.js +36 -0
- package/dist/api/resources/insights/client/Client.d.ts +90 -0
- package/dist/api/resources/insights/client/Client.js +274 -0
- package/dist/api/resources/insights/client/index.d.ts +1 -0
- package/dist/api/resources/insights/client/index.js +1 -0
- package/dist/api/resources/insights/client/requests/CreatePanelInputBody.d.ts +81 -0
- package/dist/api/resources/insights/client/requests/CreatePanelInputBody.js +30 -0
- package/dist/api/resources/insights/client/requests/DeletePanelInsightsRequest.d.ts +10 -0
- package/dist/api/resources/insights/client/requests/DeletePanelInsightsRequest.js +2 -0
- package/dist/api/resources/insights/client/requests/GetPanelDataInsightsRequest.d.ts +10 -0
- package/dist/api/resources/insights/client/requests/GetPanelDataInsightsRequest.js +2 -0
- package/dist/api/resources/insights/client/requests/GetPanelInsightsRequest.d.ts +10 -0
- package/dist/api/resources/insights/client/requests/GetPanelInsightsRequest.js +2 -0
- package/dist/api/resources/insights/client/requests/UpdatePanelInputBody.d.ts +83 -0
- package/dist/api/resources/insights/client/requests/UpdatePanelInputBody.js +30 -0
- package/dist/api/resources/insights/client/requests/index.d.ts +5 -0
- package/dist/api/resources/insights/client/requests/index.js +2 -0
- package/dist/api/resources/insights/exports.d.ts +2 -0
- package/dist/api/resources/insights/exports.js +3 -0
- package/dist/api/resources/insights/index.d.ts +1 -0
- package/dist/api/resources/insights/index.js +1 -0
- package/dist/api/resources/intelligence/client/Client.d.ts +76 -0
- package/dist/api/resources/intelligence/client/Client.js +239 -0
- package/dist/api/resources/intelligence/client/index.d.ts +1 -0
- package/dist/api/resources/intelligence/client/index.js +1 -0
- package/dist/api/resources/intelligence/client/requests/CreateContextInputBody.d.ts +33 -0
- package/dist/api/resources/intelligence/client/requests/CreateContextInputBody.js +9 -0
- package/dist/api/resources/intelligence/client/requests/DeleteContextIntelligenceRequest.d.ts +10 -0
- package/dist/api/resources/intelligence/client/requests/DeleteContextIntelligenceRequest.js +2 -0
- package/dist/api/resources/intelligence/client/requests/GetContextIntelligenceRequest.d.ts +10 -0
- package/dist/api/resources/intelligence/client/requests/GetContextIntelligenceRequest.js +2 -0
- package/dist/api/resources/intelligence/client/requests/UpdateContextInputBody.d.ts +34 -0
- package/dist/api/resources/intelligence/client/requests/UpdateContextInputBody.js +9 -0
- package/dist/api/resources/intelligence/client/requests/index.d.ts +4 -0
- package/dist/api/resources/intelligence/client/requests/index.js +2 -0
- package/dist/api/resources/intelligence/exports.d.ts +2 -0
- package/dist/api/resources/intelligence/exports.js +3 -0
- package/dist/api/resources/intelligence/index.d.ts +1 -0
- package/dist/api/resources/intelligence/index.js +1 -0
- package/dist/api/resources/media/client/Client.d.ts +40 -0
- package/dist/api/resources/media/client/Client.js +107 -0
- package/dist/api/resources/media/client/index.d.ts +1 -0
- package/dist/api/resources/media/client/index.js +1 -0
- package/dist/api/resources/media/client/requests/CreateDownloadUrlInputBody.d.ts +10 -0
- package/dist/api/resources/media/client/requests/CreateDownloadUrlInputBody.js +2 -0
- package/dist/api/resources/media/client/requests/CreateUploadUrlInputBody.d.ts +13 -0
- package/dist/api/resources/media/client/requests/CreateUploadUrlInputBody.js +2 -0
- package/dist/api/resources/media/client/requests/index.d.ts +2 -0
- package/dist/api/resources/media/client/requests/index.js +1 -0
- package/dist/api/resources/media/exports.d.ts +2 -0
- package/dist/api/resources/media/exports.js +3 -0
- package/dist/api/resources/media/index.d.ts +1 -0
- package/dist/api/resources/media/index.js +1 -0
- package/dist/api/resources/messages/client/Client.d.ts +40 -0
- package/dist/api/resources/messages/client/Client.js +113 -0
- package/dist/api/resources/messages/client/index.d.ts +1 -0
- package/dist/api/resources/messages/client/index.js +1 -0
- package/dist/api/resources/messages/client/requests/ListMessagesRequest.d.ts +14 -0
- package/dist/api/resources/messages/client/requests/ListMessagesRequest.js +2 -0
- package/dist/api/resources/messages/client/requests/SendMessageInputBody.d.ts +29 -0
- package/dist/api/resources/messages/client/requests/SendMessageInputBody.js +2 -0
- package/dist/api/resources/messages/client/requests/index.d.ts +2 -0
- package/dist/api/resources/messages/client/requests/index.js +1 -0
- package/dist/api/resources/messages/exports.d.ts +2 -0
- package/dist/api/resources/messages/exports.js +3 -0
- package/dist/api/resources/messages/index.d.ts +1 -0
- package/dist/api/resources/messages/index.js +1 -0
- package/dist/api/resources/organizations/client/Client.d.ts +47 -0
- package/dist/api/resources/organizations/client/Client.js +140 -0
- package/dist/api/resources/organizations/client/index.d.ts +1 -0
- package/dist/api/resources/organizations/client/index.js +1 -0
- package/dist/api/resources/organizations/client/requests/CreateOrganizationInputBody.d.ts +15 -0
- package/dist/api/resources/organizations/client/requests/CreateOrganizationInputBody.js +2 -0
- package/dist/api/resources/organizations/client/requests/index.d.ts +1 -0
- package/dist/api/resources/organizations/client/requests/index.js +1 -0
- package/dist/api/resources/organizations/exports.d.ts +2 -0
- package/dist/api/resources/organizations/exports.js +3 -0
- package/dist/api/resources/organizations/index.d.ts +1 -0
- package/dist/api/resources/organizations/index.js +1 -0
- package/dist/api/resources/routing/client/Client.d.ts +182 -0
- package/dist/api/resources/routing/client/Client.js +594 -0
- package/dist/api/resources/routing/client/index.d.ts +1 -0
- package/dist/api/resources/routing/client/index.js +1 -0
- package/dist/api/resources/routing/client/requests/AddAgentInputBody.d.ts +23 -0
- package/dist/api/resources/routing/client/requests/AddAgentInputBody.js +9 -0
- package/dist/api/resources/routing/client/requests/AssignHandoffInputBody.d.ts +13 -0
- package/dist/api/resources/routing/client/requests/AssignHandoffInputBody.js +2 -0
- package/dist/api/resources/routing/client/requests/CreateHandoffInputBody.d.ts +32 -0
- package/dist/api/resources/routing/client/requests/CreateHandoffInputBody.js +11 -0
- package/dist/api/resources/routing/client/requests/CreateTeamInputBody.d.ts +27 -0
- package/dist/api/resources/routing/client/requests/CreateTeamInputBody.js +10 -0
- package/dist/api/resources/routing/client/requests/DeleteTeamRoutingRequest.d.ts +10 -0
- package/dist/api/resources/routing/client/requests/DeleteTeamRoutingRequest.js +2 -0
- package/dist/api/resources/routing/client/requests/GetTeamRoutingRequest.d.ts +10 -0
- package/dist/api/resources/routing/client/requests/GetTeamRoutingRequest.js +2 -0
- package/dist/api/resources/routing/client/requests/ListAgentsRoutingRequest.d.ts +10 -0
- package/dist/api/resources/routing/client/requests/ListAgentsRoutingRequest.js +2 -0
- package/dist/api/resources/routing/client/requests/ListHandoffsRoutingRequest.d.ts +8 -0
- package/dist/api/resources/routing/client/requests/ListHandoffsRoutingRequest.js +2 -0
- package/dist/api/resources/routing/client/requests/PickNextHandoffInputBody.d.ts +10 -0
- package/dist/api/resources/routing/client/requests/PickNextHandoffInputBody.js +2 -0
- package/dist/api/resources/routing/client/requests/RemoveAgentRoutingRequest.d.ts +13 -0
- package/dist/api/resources/routing/client/requests/RemoveAgentRoutingRequest.js +2 -0
- package/dist/api/resources/routing/client/requests/ResumeHandoffRoutingRequest.d.ts +10 -0
- package/dist/api/resources/routing/client/requests/ResumeHandoffRoutingRequest.js +2 -0
- package/dist/api/resources/routing/client/requests/UpdateTeamInputBody.d.ts +29 -0
- package/dist/api/resources/routing/client/requests/UpdateTeamInputBody.js +10 -0
- package/dist/api/resources/routing/client/requests/index.d.ts +12 -0
- package/dist/api/resources/routing/client/requests/index.js +4 -0
- package/dist/api/resources/routing/exports.d.ts +2 -0
- package/dist/api/resources/routing/exports.js +3 -0
- package/dist/api/resources/routing/index.d.ts +1 -0
- package/dist/api/resources/routing/index.js +1 -0
- package/dist/api/resources/snippets/client/Client.d.ts +76 -0
- package/dist/api/resources/snippets/client/Client.js +230 -0
- package/dist/api/resources/snippets/client/index.d.ts +1 -0
- package/dist/api/resources/snippets/client/index.js +1 -0
- package/dist/api/resources/snippets/client/requests/CreateSnippetInputBody.d.ts +21 -0
- package/dist/api/resources/snippets/client/requests/CreateSnippetInputBody.js +2 -0
- package/dist/api/resources/snippets/client/requests/DeleteSnippetsRequest.d.ts +10 -0
- package/dist/api/resources/snippets/client/requests/DeleteSnippetsRequest.js +2 -0
- package/dist/api/resources/snippets/client/requests/GetSnippetsRequest.d.ts +10 -0
- package/dist/api/resources/snippets/client/requests/GetSnippetsRequest.js +2 -0
- package/dist/api/resources/snippets/client/requests/UpdateSnippetInputBody.d.ts +22 -0
- package/dist/api/resources/snippets/client/requests/UpdateSnippetInputBody.js +2 -0
- package/dist/api/resources/snippets/client/requests/index.d.ts +4 -0
- package/dist/api/resources/snippets/client/requests/index.js +1 -0
- package/dist/api/resources/snippets/exports.d.ts +2 -0
- package/dist/api/resources/snippets/exports.js +3 -0
- package/dist/api/resources/snippets/index.d.ts +1 -0
- package/dist/api/resources/snippets/index.js +1 -0
- package/dist/api/resources/tags/client/Client.d.ts +62 -0
- package/dist/api/resources/tags/client/Client.js +186 -0
- package/dist/api/resources/tags/client/index.d.ts +1 -0
- package/dist/api/resources/tags/client/index.js +1 -0
- package/dist/api/resources/tags/client/requests/CreateTagInputBody.d.ts +24 -0
- package/dist/api/resources/tags/client/requests/CreateTagInputBody.js +13 -0
- package/dist/api/resources/tags/client/requests/DeleteTagsRequest.d.ts +10 -0
- package/dist/api/resources/tags/client/requests/DeleteTagsRequest.js +2 -0
- package/dist/api/resources/tags/client/requests/UpdateTagInputBody.d.ts +24 -0
- package/dist/api/resources/tags/client/requests/UpdateTagInputBody.js +13 -0
- package/dist/api/resources/tags/client/requests/index.d.ts +3 -0
- package/dist/api/resources/tags/client/requests/index.js +2 -0
- package/dist/api/resources/tags/exports.d.ts +2 -0
- package/dist/api/resources/tags/exports.js +3 -0
- package/dist/api/resources/tags/index.d.ts +1 -0
- package/dist/api/resources/tags/index.js +1 -0
- package/dist/api/resources/templates/client/Client.d.ts +100 -0
- package/dist/api/resources/templates/client/Client.js +313 -0
- package/dist/api/resources/templates/client/index.d.ts +1 -0
- package/dist/api/resources/templates/client/index.js +1 -0
- package/dist/api/resources/templates/client/requests/CreateTemplateInputBody.d.ts +42 -0
- package/dist/api/resources/templates/client/requests/CreateTemplateInputBody.js +2 -0
- package/dist/api/resources/templates/client/requests/DeleteTemplatesRequest.d.ts +10 -0
- package/dist/api/resources/templates/client/requests/DeleteTemplatesRequest.js +2 -0
- package/dist/api/resources/templates/client/requests/GetTemplatesRequest.d.ts +10 -0
- package/dist/api/resources/templates/client/requests/GetTemplatesRequest.js +2 -0
- package/dist/api/resources/templates/client/requests/SubmitTemplatesRequest.d.ts +10 -0
- package/dist/api/resources/templates/client/requests/SubmitTemplatesRequest.js +2 -0
- package/dist/api/resources/templates/client/requests/UpdateTemplateInputBody.d.ts +42 -0
- package/dist/api/resources/templates/client/requests/UpdateTemplateInputBody.js +2 -0
- package/dist/api/resources/templates/client/requests/index.d.ts +5 -0
- package/dist/api/resources/templates/client/requests/index.js +1 -0
- package/dist/api/resources/templates/exports.d.ts +2 -0
- package/dist/api/resources/templates/exports.js +3 -0
- package/dist/api/resources/templates/index.d.ts +1 -0
- package/dist/api/resources/templates/index.js +1 -0
- package/dist/api/resources/webhooks/client/Client.d.ts +152 -0
- package/dist/api/resources/webhooks/client/Client.js +490 -0
- package/dist/api/resources/webhooks/client/index.d.ts +1 -0
- package/dist/api/resources/webhooks/client/index.js +1 -0
- package/dist/api/resources/webhooks/client/requests/CreateActionInputBody.d.ts +21 -0
- package/dist/api/resources/webhooks/client/requests/CreateActionInputBody.js +2 -0
- package/dist/api/resources/webhooks/client/requests/CreateWebhookInputBody.d.ts +21 -0
- package/dist/api/resources/webhooks/client/requests/CreateWebhookInputBody.js +2 -0
- package/dist/api/resources/webhooks/client/requests/DeleteActionWebhooksRequest.d.ts +10 -0
- package/dist/api/resources/webhooks/client/requests/DeleteActionWebhooksRequest.js +2 -0
- package/dist/api/resources/webhooks/client/requests/DeleteWebhooksRequest.d.ts +10 -0
- package/dist/api/resources/webhooks/client/requests/DeleteWebhooksRequest.js +2 -0
- package/dist/api/resources/webhooks/client/requests/GetActionWebhooksRequest.d.ts +10 -0
- package/dist/api/resources/webhooks/client/requests/GetActionWebhooksRequest.js +2 -0
- package/dist/api/resources/webhooks/client/requests/GetWebhooksRequest.d.ts +10 -0
- package/dist/api/resources/webhooks/client/requests/GetWebhooksRequest.js +2 -0
- package/dist/api/resources/webhooks/client/requests/TestWebhooksRequest.d.ts +10 -0
- package/dist/api/resources/webhooks/client/requests/TestWebhooksRequest.js +2 -0
- package/dist/api/resources/webhooks/client/requests/UpdateActionInputBody.d.ts +22 -0
- package/dist/api/resources/webhooks/client/requests/UpdateActionInputBody.js +2 -0
- package/dist/api/resources/webhooks/client/requests/UpdateWebhookInputBody.d.ts +22 -0
- package/dist/api/resources/webhooks/client/requests/UpdateWebhookInputBody.js +2 -0
- package/dist/api/resources/webhooks/client/requests/index.d.ts +9 -0
- package/dist/api/resources/webhooks/client/requests/index.js +1 -0
- package/dist/api/resources/webhooks/exports.d.ts +2 -0
- package/dist/api/resources/webhooks/exports.js +3 -0
- package/dist/api/resources/webhooks/index.d.ts +1 -0
- package/dist/api/resources/webhooks/index.js +1 -0
- package/dist/api/types/ActionResponse.d.ts +23 -0
- package/dist/api/types/ActionResponse.js +2 -0
- package/dist/api/types/AddRecipientsOutputBody.d.ts +7 -0
- package/dist/api/types/AddRecipientsOutputBody.js +2 -0
- package/dist/api/types/AgentResponse.d.ts +18 -0
- package/dist/api/types/AgentResponse.js +2 -0
- package/dist/api/types/AutomationConfigResponse.d.ts +48 -0
- package/dist/api/types/AutomationConfigResponse.js +2 -0
- package/dist/api/types/AutomationTriggerResponse.d.ts +40 -0
- package/dist/api/types/AutomationTriggerResponse.js +2 -0
- package/dist/api/types/AutomationWorkflowResponse.d.ts +46 -0
- package/dist/api/types/AutomationWorkflowResponse.js +2 -0
- package/dist/api/types/CampaignResponse.d.ts +48 -0
- package/dist/api/types/CampaignResponse.js +2 -0
- package/dist/api/types/ChannelResponse.d.ts +43 -0
- package/dist/api/types/ChannelResponse.js +10 -0
- package/dist/api/types/ChartDataPointResponse.d.ts +6 -0
- package/dist/api/types/ChartDataPointResponse.js +2 -0
- package/dist/api/types/ContactResponse.d.ts +34 -0
- package/dist/api/types/ContactResponse.js +2 -0
- package/dist/api/types/CreateDownloadUrlOutputBody.d.ts +8 -0
- package/dist/api/types/CreateDownloadUrlOutputBody.js +2 -0
- package/dist/api/types/CreateUploadUrlOutputBody.d.ts +10 -0
- package/dist/api/types/CreateUploadUrlOutputBody.js +2 -0
- package/dist/api/types/ErrorDetail.d.ts +8 -0
- package/dist/api/types/ErrorDetail.js +2 -0
- package/dist/api/types/ErrorModel.d.ts +17 -0
- package/dist/api/types/ErrorModel.js +2 -0
- package/dist/api/types/EventResponse.d.ts +21 -0
- package/dist/api/types/EventResponse.js +2 -0
- package/dist/api/types/HandoffResponse.d.ts +48 -0
- package/dist/api/types/HandoffResponse.js +2 -0
- package/dist/api/types/IdentityAccountResponse.d.ts +28 -0
- package/dist/api/types/IdentityAccountResponse.js +2 -0
- package/dist/api/types/IntelligenceContextResponse.d.ts +39 -0
- package/dist/api/types/IntelligenceContextResponse.js +9 -0
- package/dist/api/types/ListAccountsOutputBody.d.ts +7 -0
- package/dist/api/types/ListAccountsOutputBody.js +2 -0
- package/dist/api/types/ListActionsOutputBody.d.ts +7 -0
- package/dist/api/types/ListActionsOutputBody.js +2 -0
- package/dist/api/types/ListAgentsOutputBody.d.ts +7 -0
- package/dist/api/types/ListAgentsOutputBody.js +2 -0
- package/dist/api/types/ListCampaignsOutputBody.d.ts +7 -0
- package/dist/api/types/ListCampaignsOutputBody.js +2 -0
- package/dist/api/types/ListChannelsOutputBody.d.ts +7 -0
- package/dist/api/types/ListChannelsOutputBody.js +2 -0
- package/dist/api/types/ListContactsOutputBody.d.ts +7 -0
- package/dist/api/types/ListContactsOutputBody.js +2 -0
- package/dist/api/types/ListContextsOutputBody.d.ts +7 -0
- package/dist/api/types/ListContextsOutputBody.js +2 -0
- package/dist/api/types/ListEventsOutputBody.d.ts +7 -0
- package/dist/api/types/ListEventsOutputBody.js +2 -0
- package/dist/api/types/ListHandoffsOutputBody.d.ts +7 -0
- package/dist/api/types/ListHandoffsOutputBody.js +2 -0
- package/dist/api/types/ListMessagesOutputBody.d.ts +7 -0
- package/dist/api/types/ListMessagesOutputBody.js +2 -0
- package/dist/api/types/ListOrganizationsOutputBody.d.ts +7 -0
- package/dist/api/types/ListOrganizationsOutputBody.js +2 -0
- package/dist/api/types/ListPanelsOutputBody.d.ts +7 -0
- package/dist/api/types/ListPanelsOutputBody.js +2 -0
- package/dist/api/types/ListProductsOutputBody.d.ts +7 -0
- package/dist/api/types/ListProductsOutputBody.js +2 -0
- package/dist/api/types/ListRecipientsOutputBody.d.ts +7 -0
- package/dist/api/types/ListRecipientsOutputBody.js +2 -0
- package/dist/api/types/ListSnippetsOutputBody.d.ts +7 -0
- package/dist/api/types/ListSnippetsOutputBody.js +2 -0
- package/dist/api/types/ListStoresOutputBody.d.ts +7 -0
- package/dist/api/types/ListStoresOutputBody.js +2 -0
- package/dist/api/types/ListTagsOutputBody.d.ts +7 -0
- package/dist/api/types/ListTagsOutputBody.js +2 -0
- package/dist/api/types/ListTeamsOutputBody.d.ts +7 -0
- package/dist/api/types/ListTeamsOutputBody.js +2 -0
- package/dist/api/types/ListTemplatesOutputBody.d.ts +7 -0
- package/dist/api/types/ListTemplatesOutputBody.js +2 -0
- package/dist/api/types/ListTriggersOutputBody.d.ts +7 -0
- package/dist/api/types/ListTriggersOutputBody.js +2 -0
- package/dist/api/types/ListWebhooksOutputBody.d.ts +7 -0
- package/dist/api/types/ListWebhooksOutputBody.js +2 -0
- package/dist/api/types/ListWorkflowsOutputBody.d.ts +7 -0
- package/dist/api/types/ListWorkflowsOutputBody.js +2 -0
- package/dist/api/types/LoginOutputBody.d.ts +13 -0
- package/dist/api/types/LoginOutputBody.js +2 -0
- package/dist/api/types/MessageResponse.d.ts +45 -0
- package/dist/api/types/MessageResponse.js +2 -0
- package/dist/api/types/OrganizationResponse.d.ts +16 -0
- package/dist/api/types/OrganizationResponse.js +2 -0
- package/dist/api/types/PanelDataResponse.d.ts +13 -0
- package/dist/api/types/PanelDataResponse.js +2 -0
- package/dist/api/types/PanelFilterInput.d.ts +21 -0
- package/dist/api/types/PanelFilterInput.js +14 -0
- package/dist/api/types/PanelFilterResponse.d.ts +8 -0
- package/dist/api/types/PanelFilterResponse.js +2 -0
- package/dist/api/types/PanelResponse.d.ts +55 -0
- package/dist/api/types/PanelResponse.js +2 -0
- package/dist/api/types/ProductResponse.d.ts +34 -0
- package/dist/api/types/ProductResponse.js +2 -0
- package/dist/api/types/RecipientInput.d.ts +10 -0
- package/dist/api/types/RecipientInput.js +2 -0
- package/dist/api/types/RecipientResponse.d.ts +30 -0
- package/dist/api/types/RecipientResponse.js +2 -0
- package/dist/api/types/RefreshOutputBody.d.ts +10 -0
- package/dist/api/types/RefreshOutputBody.js +2 -0
- package/dist/api/types/RegisterOutputBody.d.ts +7 -0
- package/dist/api/types/RegisterOutputBody.js +2 -0
- package/dist/api/types/SnippetResponse.d.ts +27 -0
- package/dist/api/types/SnippetResponse.js +2 -0
- package/dist/api/types/StoreResponse.d.ts +22 -0
- package/dist/api/types/StoreResponse.js +2 -0
- package/dist/api/types/TagResponse.d.ts +14 -0
- package/dist/api/types/TagResponse.js +2 -0
- package/dist/api/types/TeamResponse.d.ts +26 -0
- package/dist/api/types/TeamResponse.js +2 -0
- package/dist/api/types/TemplateResponse.d.ts +46 -0
- package/dist/api/types/TemplateResponse.js +2 -0
- package/dist/api/types/WebhookResponse.d.ts +22 -0
- package/dist/api/types/WebhookResponse.js +2 -0
- package/dist/api/types/index.d.ts +58 -0
- package/dist/api/types/index.js +58 -0
- package/dist/auth/BearerAuthProvider.d.ts +20 -0
- package/dist/auth/BearerAuthProvider.js +32 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js +1 -0
- package/dist/core/auth/AuthProvider.d.ts +8 -0
- package/dist/core/auth/AuthProvider.js +6 -0
- package/dist/core/auth/AuthRequest.d.ts +9 -0
- package/dist/core/auth/AuthRequest.js +1 -0
- package/dist/core/auth/BasicAuth.d.ts +8 -0
- package/dist/core/auth/BasicAuth.js +29 -0
- package/dist/core/auth/BearerToken.d.ts +7 -0
- package/dist/core/auth/BearerToken.js +13 -0
- package/dist/core/auth/NoOpAuthProvider.d.ts +5 -0
- package/dist/core/auth/NoOpAuthProvider.js +5 -0
- package/dist/core/auth/index.d.ts +5 -0
- package/dist/core/auth/index.js +4 -0
- package/dist/core/base64.d.ts +2 -0
- package/dist/core/base64.js +22 -0
- package/dist/core/exports.d.ts +1 -0
- package/dist/core/exports.js +1 -0
- package/dist/core/fetcher/APIResponse.d.ts +20 -0
- package/dist/core/fetcher/APIResponse.js +1 -0
- package/dist/core/fetcher/BinaryResponse.d.ts +19 -0
- package/dist/core/fetcher/BinaryResponse.js +14 -0
- package/dist/core/fetcher/EndpointMetadata.d.ts +13 -0
- package/dist/core/fetcher/EndpointMetadata.js +1 -0
- package/dist/core/fetcher/EndpointSupplier.d.ts +12 -0
- package/dist/core/fetcher/EndpointSupplier.js +10 -0
- package/dist/core/fetcher/Fetcher.d.ts +56 -0
- package/dist/core/fetcher/Fetcher.js +306 -0
- package/dist/core/fetcher/Headers.d.ts +2 -0
- package/dist/core/fetcher/Headers.js +83 -0
- package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/core/fetcher/HttpResponsePromise.js +90 -0
- package/dist/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/core/fetcher/RawResponse.js +40 -0
- package/dist/core/fetcher/Supplier.d.ts +4 -0
- package/dist/core/fetcher/Supplier.js +10 -0
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/core/fetcher/createRequestUrl.js +5 -0
- package/dist/core/fetcher/getErrorResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getErrorResponseBody.js +30 -0
- package/dist/core/fetcher/getFetchFn.d.ts +1 -0
- package/dist/core/fetcher/getFetchFn.js +3 -0
- package/dist/core/fetcher/getHeader.d.ts +1 -0
- package/dist/core/fetcher/getHeader.js +8 -0
- package/dist/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/core/fetcher/getRequestBody.js +13 -0
- package/dist/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getResponseBody.js +55 -0
- package/dist/core/fetcher/index.d.ts +13 -0
- package/dist/core/fetcher/index.js +7 -0
- package/dist/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/core/fetcher/makePassthroughRequest.js +119 -0
- package/dist/core/fetcher/makeRequest.d.ts +6 -0
- package/dist/core/fetcher/makeRequest.js +53 -0
- package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/core/fetcher/requestWithRetries.js +56 -0
- package/dist/core/fetcher/signals.d.ts +5 -0
- package/dist/core/fetcher/signals.js +20 -0
- package/dist/core/headers.d.ts +2 -0
- package/dist/core/headers.js +27 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +6 -0
- package/dist/core/json.d.ts +15 -0
- package/dist/core/json.js +19 -0
- package/dist/core/logging/exports.d.ts +18 -0
- package/dist/core/logging/exports.js +9 -0
- package/dist/core/logging/index.d.ts +1 -0
- package/dist/core/logging/index.js +1 -0
- package/dist/core/logging/logger.d.ts +126 -0
- package/dist/core/logging/logger.js +140 -0
- package/dist/core/runtime/index.d.ts +1 -0
- package/dist/core/runtime/index.js +1 -0
- package/dist/core/runtime/runtime.d.ts +9 -0
- package/dist/core/runtime/runtime.js +100 -0
- package/dist/core/url/QueryStringBuilder.d.ts +47 -0
- package/dist/core/url/QueryStringBuilder.js +78 -0
- package/dist/core/url/encodePathParam.d.ts +1 -0
- package/dist/core/url/encodePathParam.js +18 -0
- package/dist/core/url/index.d.ts +4 -0
- package/dist/core/url/index.js +4 -0
- package/dist/core/url/join.d.ts +1 -0
- package/dist/core/url/join.js +65 -0
- package/dist/core/url/qs.d.ts +7 -0
- package/dist/core/url/qs.js +76 -0
- package/dist/environments.d.ts +4 -0
- package/dist/environments.js +4 -0
- package/dist/errors/BoltixApiError.d.ts +14 -0
- package/dist/errors/BoltixApiError.js +35 -0
- package/dist/errors/BoltixApiTimeoutError.d.ts +6 -0
- package/dist/errors/BoltixApiTimeoutError.js +15 -0
- package/dist/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/errors/handleNonStatusCodeError.js +32 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +2 -0
- package/dist/exports.d.ts +1 -0
- package/dist/exports.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/package.json +37 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type LogConfig, type Logger } from "../logging/logger.js";
|
|
2
|
+
import type { APIResponse } from "./APIResponse.js";
|
|
3
|
+
import type { EndpointMetadata } from "./EndpointMetadata.js";
|
|
4
|
+
export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
|
|
5
|
+
export declare namespace Fetcher {
|
|
6
|
+
interface Args {
|
|
7
|
+
url: string;
|
|
8
|
+
method: string;
|
|
9
|
+
contentType?: string;
|
|
10
|
+
headers?: Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Prefer `queryString` (produced by `core.url.queryBuilder()`).
|
|
13
|
+
* Retained for backwards compatibility with custom fetchers and callers that
|
|
14
|
+
* still construct request args with a query-parameter object.
|
|
15
|
+
*/
|
|
16
|
+
queryParameters?: Record<string, unknown>;
|
|
17
|
+
queryString?: string;
|
|
18
|
+
body?: unknown;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
maxRetries?: number;
|
|
21
|
+
withCredentials?: boolean;
|
|
22
|
+
abortSignal?: AbortSignal;
|
|
23
|
+
requestType?: "json" | "file" | "bytes" | "form" | "other";
|
|
24
|
+
responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer" | "binary-response";
|
|
25
|
+
duplex?: "half";
|
|
26
|
+
endpointMetadata?: EndpointMetadata;
|
|
27
|
+
fetchFn?: typeof fetch;
|
|
28
|
+
logging?: LogConfig | Logger;
|
|
29
|
+
}
|
|
30
|
+
type Error = FailedStatusCodeError | NonJsonError | BodyIsNullError | TimeoutError | UnknownError;
|
|
31
|
+
interface FailedStatusCodeError {
|
|
32
|
+
reason: "status-code";
|
|
33
|
+
statusCode: number;
|
|
34
|
+
body: unknown;
|
|
35
|
+
}
|
|
36
|
+
interface NonJsonError {
|
|
37
|
+
reason: "non-json";
|
|
38
|
+
statusCode: number;
|
|
39
|
+
rawBody: string;
|
|
40
|
+
}
|
|
41
|
+
interface BodyIsNullError {
|
|
42
|
+
reason: "body-is-null";
|
|
43
|
+
statusCode: number;
|
|
44
|
+
}
|
|
45
|
+
interface TimeoutError {
|
|
46
|
+
reason: "timeout";
|
|
47
|
+
cause?: unknown;
|
|
48
|
+
}
|
|
49
|
+
interface UnknownError {
|
|
50
|
+
reason: "unknown";
|
|
51
|
+
errorMessage: string;
|
|
52
|
+
cause?: unknown;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>;
|
|
56
|
+
export declare const fetcher: FetchFunction;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { toJson } from "../json.js";
|
|
2
|
+
import { createLogger } from "../logging/logger.js";
|
|
3
|
+
import { createRequestUrl } from "./createRequestUrl.js";
|
|
4
|
+
import { EndpointSupplier } from "./EndpointSupplier.js";
|
|
5
|
+
import { getErrorResponseBody } from "./getErrorResponseBody.js";
|
|
6
|
+
import { getFetchFn } from "./getFetchFn.js";
|
|
7
|
+
import { getRequestBody } from "./getRequestBody.js";
|
|
8
|
+
import { getResponseBody } from "./getResponseBody.js";
|
|
9
|
+
import { Headers } from "./Headers.js";
|
|
10
|
+
import { makeRequest } from "./makeRequest.js";
|
|
11
|
+
import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
|
|
12
|
+
import { requestWithRetries } from "./requestWithRetries.js";
|
|
13
|
+
const SENSITIVE_HEADERS = new Set([
|
|
14
|
+
"authorization",
|
|
15
|
+
"www-authenticate",
|
|
16
|
+
"x-api-key",
|
|
17
|
+
"api-key",
|
|
18
|
+
"apikey",
|
|
19
|
+
"x-api-token",
|
|
20
|
+
"x-auth-token",
|
|
21
|
+
"auth-token",
|
|
22
|
+
"cookie",
|
|
23
|
+
"set-cookie",
|
|
24
|
+
"proxy-authorization",
|
|
25
|
+
"proxy-authenticate",
|
|
26
|
+
"x-csrf-token",
|
|
27
|
+
"x-xsrf-token",
|
|
28
|
+
"x-session-token",
|
|
29
|
+
"x-access-token",
|
|
30
|
+
]);
|
|
31
|
+
function redactHeaders(headers) {
|
|
32
|
+
const filtered = {};
|
|
33
|
+
for (const [key, value] of headers instanceof Headers ? headers.entries() : Object.entries(headers)) {
|
|
34
|
+
if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
|
|
35
|
+
filtered[key] = "[REDACTED]";
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
filtered[key] = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return filtered;
|
|
42
|
+
}
|
|
43
|
+
const SENSITIVE_QUERY_PARAMS = new Set([
|
|
44
|
+
"api_key",
|
|
45
|
+
"api-key",
|
|
46
|
+
"apikey",
|
|
47
|
+
"token",
|
|
48
|
+
"access_token",
|
|
49
|
+
"access-token",
|
|
50
|
+
"auth_token",
|
|
51
|
+
"auth-token",
|
|
52
|
+
"password",
|
|
53
|
+
"passwd",
|
|
54
|
+
"secret",
|
|
55
|
+
"api_secret",
|
|
56
|
+
"api-secret",
|
|
57
|
+
"apisecret",
|
|
58
|
+
"key",
|
|
59
|
+
"session",
|
|
60
|
+
"session_id",
|
|
61
|
+
"session-id",
|
|
62
|
+
]);
|
|
63
|
+
function redactQueryParameters(queryParameters) {
|
|
64
|
+
if (queryParameters == null) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const redacted = {};
|
|
68
|
+
for (const [key, value] of Object.entries(queryParameters)) {
|
|
69
|
+
redacted[key] = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
|
|
70
|
+
}
|
|
71
|
+
return redacted;
|
|
72
|
+
}
|
|
73
|
+
function redactUrl(url) {
|
|
74
|
+
const protocolIndex = url.indexOf("://");
|
|
75
|
+
if (protocolIndex === -1)
|
|
76
|
+
return url;
|
|
77
|
+
const afterProtocol = protocolIndex + 3;
|
|
78
|
+
// Find the first delimiter that marks the end of the authority section
|
|
79
|
+
const pathStart = url.indexOf("/", afterProtocol);
|
|
80
|
+
let queryStart = url.indexOf("?", afterProtocol);
|
|
81
|
+
let fragmentStart = url.indexOf("#", afterProtocol);
|
|
82
|
+
const firstDelimiter = Math.min(pathStart === -1 ? url.length : pathStart, queryStart === -1 ? url.length : queryStart, fragmentStart === -1 ? url.length : fragmentStart);
|
|
83
|
+
// Find the LAST @ before the delimiter (handles multiple @ in credentials)
|
|
84
|
+
let atIndex = -1;
|
|
85
|
+
for (let i = afterProtocol; i < firstDelimiter; i++) {
|
|
86
|
+
if (url[i] === "@") {
|
|
87
|
+
atIndex = i;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (atIndex !== -1) {
|
|
91
|
+
url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`;
|
|
92
|
+
}
|
|
93
|
+
// Recalculate queryStart since url might have changed
|
|
94
|
+
queryStart = url.indexOf("?");
|
|
95
|
+
if (queryStart === -1)
|
|
96
|
+
return url;
|
|
97
|
+
fragmentStart = url.indexOf("#", queryStart);
|
|
98
|
+
const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length;
|
|
99
|
+
const queryString = url.slice(queryStart + 1, queryEnd);
|
|
100
|
+
if (queryString.length === 0)
|
|
101
|
+
return url;
|
|
102
|
+
// FAST PATH: Quick check if any sensitive keywords present
|
|
103
|
+
// Using indexOf is faster than regex for simple substring matching
|
|
104
|
+
const lower = queryString.toLowerCase();
|
|
105
|
+
const hasSensitive = lower.includes("token") ||
|
|
106
|
+
lower.includes("key") ||
|
|
107
|
+
lower.includes("password") ||
|
|
108
|
+
lower.includes("passwd") ||
|
|
109
|
+
lower.includes("secret") ||
|
|
110
|
+
lower.includes("session") ||
|
|
111
|
+
lower.includes("auth");
|
|
112
|
+
if (!hasSensitive) {
|
|
113
|
+
return url;
|
|
114
|
+
}
|
|
115
|
+
// SLOW PATH: Parse and redact
|
|
116
|
+
const redactedParams = [];
|
|
117
|
+
const params = queryString.split("&");
|
|
118
|
+
for (const param of params) {
|
|
119
|
+
const equalIndex = param.indexOf("=");
|
|
120
|
+
if (equalIndex === -1) {
|
|
121
|
+
redactedParams.push(param);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const key = param.slice(0, equalIndex);
|
|
125
|
+
let shouldRedact = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase());
|
|
126
|
+
if (!shouldRedact && key.includes("%")) {
|
|
127
|
+
try {
|
|
128
|
+
const decodedKey = decodeURIComponent(key);
|
|
129
|
+
shouldRedact = SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase());
|
|
130
|
+
}
|
|
131
|
+
catch { }
|
|
132
|
+
}
|
|
133
|
+
redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param);
|
|
134
|
+
}
|
|
135
|
+
return url.slice(0, queryStart + 1) + redactedParams.join("&") + url.slice(queryEnd);
|
|
136
|
+
}
|
|
137
|
+
async function getHeaders(args) {
|
|
138
|
+
const newHeaders = new Headers();
|
|
139
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
140
|
+
? "application/json"
|
|
141
|
+
: args.responseType === "text"
|
|
142
|
+
? "text/plain"
|
|
143
|
+
: args.responseType === "sse"
|
|
144
|
+
? "text/event-stream"
|
|
145
|
+
: "*/*");
|
|
146
|
+
if (args.body !== undefined && args.contentType != null) {
|
|
147
|
+
newHeaders.set("Content-Type", args.contentType);
|
|
148
|
+
}
|
|
149
|
+
if (args.headers == null) {
|
|
150
|
+
return newHeaders;
|
|
151
|
+
}
|
|
152
|
+
for (const [key, value] of Object.entries(args.headers)) {
|
|
153
|
+
const result = await EndpointSupplier.get(value, { endpointMetadata: args.endpointMetadata ?? {} });
|
|
154
|
+
if (typeof result === "string") {
|
|
155
|
+
newHeaders.set(key, result);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (result == null) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
newHeaders.set(key, `${result}`);
|
|
162
|
+
}
|
|
163
|
+
return newHeaders;
|
|
164
|
+
}
|
|
165
|
+
export async function fetcherImpl(args) {
|
|
166
|
+
let url = args.url;
|
|
167
|
+
if (args.queryString != null && args.queryString.length > 0) {
|
|
168
|
+
url = `${url}?${args.queryString}`;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
url = createRequestUrl(args.url, args.queryParameters);
|
|
172
|
+
}
|
|
173
|
+
const requestBody = await getRequestBody({
|
|
174
|
+
body: args.body,
|
|
175
|
+
type: args.requestType ?? "other",
|
|
176
|
+
});
|
|
177
|
+
const fetchFn = args.fetchFn ?? (await getFetchFn());
|
|
178
|
+
const headers = await getHeaders(args);
|
|
179
|
+
const logger = createLogger(args.logging);
|
|
180
|
+
if (logger.isDebug()) {
|
|
181
|
+
const metadata = {
|
|
182
|
+
method: args.method,
|
|
183
|
+
url: redactUrl(url),
|
|
184
|
+
headers: redactHeaders(headers),
|
|
185
|
+
queryParameters: redactQueryParameters(args.queryParameters),
|
|
186
|
+
hasBody: requestBody != null,
|
|
187
|
+
};
|
|
188
|
+
logger.debug("Making HTTP request", metadata);
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
const response = await requestWithRetries(async () => makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse"), args.maxRetries);
|
|
192
|
+
if (response.status >= 200 && response.status < 400) {
|
|
193
|
+
if (logger.isDebug()) {
|
|
194
|
+
const metadata = {
|
|
195
|
+
method: args.method,
|
|
196
|
+
url: redactUrl(url),
|
|
197
|
+
statusCode: response.status,
|
|
198
|
+
responseHeaders: redactHeaders(response.headers),
|
|
199
|
+
};
|
|
200
|
+
logger.debug("HTTP request succeeded", metadata);
|
|
201
|
+
}
|
|
202
|
+
const body = await getResponseBody(response, args.responseType);
|
|
203
|
+
return {
|
|
204
|
+
ok: true,
|
|
205
|
+
body: body,
|
|
206
|
+
headers: response.headers,
|
|
207
|
+
rawResponse: toRawResponse(response),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
if (logger.isError()) {
|
|
212
|
+
const metadata = {
|
|
213
|
+
method: args.method,
|
|
214
|
+
url: redactUrl(url),
|
|
215
|
+
statusCode: response.status,
|
|
216
|
+
responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())),
|
|
217
|
+
};
|
|
218
|
+
logger.error("HTTP request failed with error status", metadata);
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
ok: false,
|
|
222
|
+
error: {
|
|
223
|
+
reason: "status-code",
|
|
224
|
+
statusCode: response.status,
|
|
225
|
+
body: await getErrorResponseBody(response),
|
|
226
|
+
},
|
|
227
|
+
rawResponse: toRawResponse(response),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
if (args.abortSignal?.aborted) {
|
|
233
|
+
if (logger.isError()) {
|
|
234
|
+
const metadata = {
|
|
235
|
+
method: args.method,
|
|
236
|
+
url: redactUrl(url),
|
|
237
|
+
};
|
|
238
|
+
logger.error("HTTP request was aborted", metadata);
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
ok: false,
|
|
242
|
+
error: {
|
|
243
|
+
reason: "unknown",
|
|
244
|
+
errorMessage: "The user aborted a request",
|
|
245
|
+
cause: error,
|
|
246
|
+
},
|
|
247
|
+
rawResponse: abortRawResponse,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
else if (error instanceof Error && error.name === "AbortError") {
|
|
251
|
+
if (logger.isError()) {
|
|
252
|
+
const metadata = {
|
|
253
|
+
method: args.method,
|
|
254
|
+
url: redactUrl(url),
|
|
255
|
+
timeoutMs: args.timeoutMs,
|
|
256
|
+
};
|
|
257
|
+
logger.error("HTTP request timed out", metadata);
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
ok: false,
|
|
261
|
+
error: {
|
|
262
|
+
reason: "timeout",
|
|
263
|
+
cause: error,
|
|
264
|
+
},
|
|
265
|
+
rawResponse: abortRawResponse,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
else if (error instanceof Error) {
|
|
269
|
+
if (logger.isError()) {
|
|
270
|
+
const metadata = {
|
|
271
|
+
method: args.method,
|
|
272
|
+
url: redactUrl(url),
|
|
273
|
+
errorMessage: error.message,
|
|
274
|
+
};
|
|
275
|
+
logger.error("HTTP request failed with error", metadata);
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
ok: false,
|
|
279
|
+
error: {
|
|
280
|
+
reason: "unknown",
|
|
281
|
+
errorMessage: error.message,
|
|
282
|
+
cause: error,
|
|
283
|
+
},
|
|
284
|
+
rawResponse: unknownRawResponse,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
if (logger.isError()) {
|
|
288
|
+
const metadata = {
|
|
289
|
+
method: args.method,
|
|
290
|
+
url: redactUrl(url),
|
|
291
|
+
error: toJson(error),
|
|
292
|
+
};
|
|
293
|
+
logger.error("HTTP request failed with unknown error", metadata);
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
ok: false,
|
|
297
|
+
error: {
|
|
298
|
+
reason: "unknown",
|
|
299
|
+
errorMessage: toJson(error),
|
|
300
|
+
cause: error,
|
|
301
|
+
},
|
|
302
|
+
rawResponse: unknownRawResponse,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
export const fetcher = fetcherImpl;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
let Headers;
|
|
2
|
+
if (typeof globalThis.Headers !== "undefined") {
|
|
3
|
+
Headers = globalThis.Headers;
|
|
4
|
+
}
|
|
5
|
+
else {
|
|
6
|
+
Headers = class Headers {
|
|
7
|
+
headers;
|
|
8
|
+
constructor(init) {
|
|
9
|
+
this.headers = new Map();
|
|
10
|
+
if (init) {
|
|
11
|
+
if (init instanceof Headers) {
|
|
12
|
+
init.forEach((value, key) => this.append(key, value));
|
|
13
|
+
}
|
|
14
|
+
else if (Array.isArray(init)) {
|
|
15
|
+
for (const [key, value] of init) {
|
|
16
|
+
if (typeof key === "string" && typeof value === "string") {
|
|
17
|
+
this.append(key, value);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
throw new TypeError("Each header entry must be a [string, string] tuple");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
for (const [key, value] of Object.entries(init)) {
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
this.append(key, value);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new TypeError("Header values must be strings");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
append(name, value) {
|
|
37
|
+
const key = name.toLowerCase();
|
|
38
|
+
const existing = this.headers.get(key) || [];
|
|
39
|
+
this.headers.set(key, [...existing, value]);
|
|
40
|
+
}
|
|
41
|
+
delete(name) {
|
|
42
|
+
const key = name.toLowerCase();
|
|
43
|
+
this.headers.delete(key);
|
|
44
|
+
}
|
|
45
|
+
get(name) {
|
|
46
|
+
const key = name.toLowerCase();
|
|
47
|
+
const values = this.headers.get(key);
|
|
48
|
+
return values ? values.join(", ") : null;
|
|
49
|
+
}
|
|
50
|
+
has(name) {
|
|
51
|
+
const key = name.toLowerCase();
|
|
52
|
+
return this.headers.has(key);
|
|
53
|
+
}
|
|
54
|
+
set(name, value) {
|
|
55
|
+
const key = name.toLowerCase();
|
|
56
|
+
this.headers.set(key, [value]);
|
|
57
|
+
}
|
|
58
|
+
forEach(callbackfn, thisArg) {
|
|
59
|
+
const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
|
|
60
|
+
this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this));
|
|
61
|
+
}
|
|
62
|
+
getSetCookie() {
|
|
63
|
+
return this.headers.get("set-cookie") || [];
|
|
64
|
+
}
|
|
65
|
+
*entries() {
|
|
66
|
+
for (const [key, values] of this.headers.entries()) {
|
|
67
|
+
yield [key, values.join(", ")];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
*keys() {
|
|
71
|
+
yield* this.headers.keys();
|
|
72
|
+
}
|
|
73
|
+
*values() {
|
|
74
|
+
for (const values of this.headers.values()) {
|
|
75
|
+
yield values.join(", ");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
[Symbol.iterator]() {
|
|
79
|
+
return this.entries();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export { Headers };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { WithRawResponse } from "./RawResponse.js";
|
|
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
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A promise that returns the parsed response and lets you retrieve the raw response too.
|
|
3
|
+
*/
|
|
4
|
+
export class HttpResponsePromise extends Promise {
|
|
5
|
+
innerPromise;
|
|
6
|
+
unwrappedPromise;
|
|
7
|
+
constructor(promise) {
|
|
8
|
+
// Initialize with a no-op to avoid premature parsing
|
|
9
|
+
super((resolve) => {
|
|
10
|
+
resolve(undefined);
|
|
11
|
+
});
|
|
12
|
+
this.innerPromise = promise;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates an `HttpResponsePromise` from a function that returns a promise.
|
|
16
|
+
*
|
|
17
|
+
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
|
|
18
|
+
* @param args - Arguments to pass to the function.
|
|
19
|
+
* @returns An `HttpResponsePromise` instance.
|
|
20
|
+
*/
|
|
21
|
+
static fromFunction(fn, ...args) {
|
|
22
|
+
return new HttpResponsePromise(fn(...args));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
|
|
26
|
+
*
|
|
27
|
+
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
|
|
28
|
+
* @returns A function that returns an `HttpResponsePromise` instance.
|
|
29
|
+
*/
|
|
30
|
+
static interceptFunction(fn) {
|
|
31
|
+
return (...args) => {
|
|
32
|
+
return HttpResponsePromise.fromPromise(fn(...args));
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates an `HttpResponsePromise` from an existing promise.
|
|
37
|
+
*
|
|
38
|
+
* @param promise - A promise resolving to a `WithRawResponse` object.
|
|
39
|
+
* @returns An `HttpResponsePromise` instance.
|
|
40
|
+
*/
|
|
41
|
+
static fromPromise(promise) {
|
|
42
|
+
return new HttpResponsePromise(promise);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates an `HttpResponsePromise` from an executor function.
|
|
46
|
+
*
|
|
47
|
+
* @param executor - A function that takes resolve and reject callbacks to create a promise.
|
|
48
|
+
* @returns An `HttpResponsePromise` instance.
|
|
49
|
+
*/
|
|
50
|
+
static fromExecutor(executor) {
|
|
51
|
+
const promise = new Promise(executor);
|
|
52
|
+
return new HttpResponsePromise(promise);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates an `HttpResponsePromise` from a resolved result.
|
|
56
|
+
*
|
|
57
|
+
* @param result - A `WithRawResponse` object to resolve immediately.
|
|
58
|
+
* @returns An `HttpResponsePromise` instance.
|
|
59
|
+
*/
|
|
60
|
+
static fromResult(result) {
|
|
61
|
+
const promise = Promise.resolve(result);
|
|
62
|
+
return new HttpResponsePromise(promise);
|
|
63
|
+
}
|
|
64
|
+
unwrap() {
|
|
65
|
+
if (!this.unwrappedPromise) {
|
|
66
|
+
this.unwrappedPromise = this.innerPromise.then(({ data }) => data);
|
|
67
|
+
}
|
|
68
|
+
return this.unwrappedPromise;
|
|
69
|
+
}
|
|
70
|
+
/** @inheritdoc */
|
|
71
|
+
then(onfulfilled, onrejected) {
|
|
72
|
+
return this.unwrap().then(onfulfilled, onrejected);
|
|
73
|
+
}
|
|
74
|
+
/** @inheritdoc */
|
|
75
|
+
catch(onrejected) {
|
|
76
|
+
return this.unwrap().catch(onrejected);
|
|
77
|
+
}
|
|
78
|
+
/** @inheritdoc */
|
|
79
|
+
finally(onfinally) {
|
|
80
|
+
return this.unwrap().finally(onfinally);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the data and raw response.
|
|
84
|
+
*
|
|
85
|
+
* @returns A promise resolving to a `WithRawResponse` object.
|
|
86
|
+
*/
|
|
87
|
+
async withRawResponse() {
|
|
88
|
+
return await this.innerPromise;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Headers } from "./Headers.js";
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createRequestUrl(baseUrl: string, queryParameters?: Record<string, unknown>): string;
|