@tolt/api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +2 -0
- package/README.md +39 -0
- package/dist/BaseClient.d.ts +54 -0
- package/dist/BaseClient.js +43 -0
- package/dist/Client.d.ts +56 -0
- package/dist/Client.js +73 -0
- package/dist/api/errors/BadRequestError.d.ts +7 -0
- package/dist/api/errors/BadRequestError.js +17 -0
- package/dist/api/errors/ConflictError.d.ts +7 -0
- package/dist/api/errors/ConflictError.js +17 -0
- package/dist/api/errors/NotFoundError.d.ts +7 -0
- package/dist/api/errors/NotFoundError.js +17 -0
- package/dist/api/errors/UnauthorizedError.d.ts +7 -0
- package/dist/api/errors/UnauthorizedError.js +17 -0
- package/dist/api/errors/index.d.ts +4 -0
- package/dist/api/errors/index.js +4 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/resources/clicks/client/Client.d.ts +43 -0
- package/dist/api/resources/clicks/client/Client.js +132 -0
- package/dist/api/resources/clicks/client/index.d.ts +1 -0
- package/dist/api/resources/clicks/client/index.js +1 -0
- package/dist/api/resources/clicks/client/requests/GetClickRequest.d.ts +9 -0
- package/dist/api/resources/clicks/client/requests/GetClickRequest.js +2 -0
- package/dist/api/resources/clicks/client/requests/ListClicksRequest.d.ts +16 -0
- package/dist/api/resources/clicks/client/requests/ListClicksRequest.js +2 -0
- package/dist/api/resources/clicks/client/requests/index.d.ts +2 -0
- package/dist/api/resources/clicks/client/requests/index.js +1 -0
- package/dist/api/resources/clicks/exports.d.ts +2 -0
- package/dist/api/resources/clicks/exports.js +3 -0
- package/dist/api/resources/clicks/index.d.ts +2 -0
- package/dist/api/resources/clicks/index.js +2 -0
- package/dist/api/resources/clicks/types/GetClickResponse.d.ts +6 -0
- package/dist/api/resources/clicks/types/GetClickResponse.js +2 -0
- package/dist/api/resources/clicks/types/ListClicksRequestOrder.d.ts +5 -0
- package/dist/api/resources/clicks/types/ListClicksRequestOrder.js +5 -0
- package/dist/api/resources/clicks/types/ListClicksResponse.d.ts +7 -0
- package/dist/api/resources/clicks/types/ListClicksResponse.js +2 -0
- package/dist/api/resources/clicks/types/index.d.ts +3 -0
- package/dist/api/resources/clicks/types/index.js +3 -0
- package/dist/api/resources/commissions/client/Client.d.ts +132 -0
- package/dist/api/resources/commissions/client/Client.js +431 -0
- package/dist/api/resources/commissions/client/index.d.ts +1 -0
- package/dist/api/resources/commissions/client/index.js +1 -0
- package/dist/api/resources/commissions/client/requests/ApproveCommissionRequest.d.ts +9 -0
- package/dist/api/resources/commissions/client/requests/ApproveCommissionRequest.js +2 -0
- package/dist/api/resources/commissions/client/requests/DeclineCommissionRequest.d.ts +9 -0
- package/dist/api/resources/commissions/client/requests/DeclineCommissionRequest.js +2 -0
- package/dist/api/resources/commissions/client/requests/DeleteCommissionRequest.d.ts +9 -0
- package/dist/api/resources/commissions/client/requests/DeleteCommissionRequest.js +2 -0
- package/dist/api/resources/commissions/client/requests/GetCommissionRequest.d.ts +9 -0
- package/dist/api/resources/commissions/client/requests/GetCommissionRequest.js +2 -0
- package/dist/api/resources/commissions/client/requests/ListCommissionsRequest.d.ts +17 -0
- package/dist/api/resources/commissions/client/requests/ListCommissionsRequest.js +2 -0
- package/dist/api/resources/commissions/client/requests/UpdateCommissionRequest.d.ts +18 -0
- package/dist/api/resources/commissions/client/requests/UpdateCommissionRequest.js +2 -0
- package/dist/api/resources/commissions/client/requests/index.d.ts +6 -0
- package/dist/api/resources/commissions/client/requests/index.js +1 -0
- package/dist/api/resources/commissions/exports.d.ts +2 -0
- package/dist/api/resources/commissions/exports.js +3 -0
- package/dist/api/resources/commissions/index.d.ts +2 -0
- package/dist/api/resources/commissions/index.js +2 -0
- package/dist/api/resources/commissions/types/ApproveCommissionResponse.d.ts +6 -0
- package/dist/api/resources/commissions/types/ApproveCommissionResponse.js +2 -0
- package/dist/api/resources/commissions/types/CreateCommissionRequest.d.ts +1 -0
- package/dist/api/resources/commissions/types/CreateCommissionRequest.js +2 -0
- package/dist/api/resources/commissions/types/CreateCommissionResponse.d.ts +6 -0
- package/dist/api/resources/commissions/types/CreateCommissionResponse.js +2 -0
- package/dist/api/resources/commissions/types/DeclineCommissionResponse.d.ts +6 -0
- package/dist/api/resources/commissions/types/DeclineCommissionResponse.js +2 -0
- package/dist/api/resources/commissions/types/DeleteCommissionResponse.d.ts +6 -0
- package/dist/api/resources/commissions/types/DeleteCommissionResponse.js +2 -0
- package/dist/api/resources/commissions/types/GetCommissionResponse.d.ts +6 -0
- package/dist/api/resources/commissions/types/GetCommissionResponse.js +2 -0
- package/dist/api/resources/commissions/types/ListCommissionsRequestOrder.d.ts +5 -0
- package/dist/api/resources/commissions/types/ListCommissionsRequestOrder.js +5 -0
- package/dist/api/resources/commissions/types/ListCommissionsResponse.d.ts +7 -0
- package/dist/api/resources/commissions/types/ListCommissionsResponse.js +2 -0
- package/dist/api/resources/commissions/types/UpdateCommissionResponse.d.ts +6 -0
- package/dist/api/resources/commissions/types/UpdateCommissionResponse.js +2 -0
- package/dist/api/resources/commissions/types/index.d.ts +9 -0
- package/dist/api/resources/commissions/types/index.js +9 -0
- package/dist/api/resources/customers/client/Client.d.ts +92 -0
- package/dist/api/resources/customers/client/Client.js +299 -0
- package/dist/api/resources/customers/client/index.d.ts +1 -0
- package/dist/api/resources/customers/client/index.js +1 -0
- package/dist/api/resources/customers/client/requests/DeleteCustomerRequest.d.ts +9 -0
- package/dist/api/resources/customers/client/requests/DeleteCustomerRequest.js +2 -0
- package/dist/api/resources/customers/client/requests/GetCustomerRequest.d.ts +9 -0
- package/dist/api/resources/customers/client/requests/GetCustomerRequest.js +2 -0
- package/dist/api/resources/customers/client/requests/ListCustomersRequest.d.ts +15 -0
- package/dist/api/resources/customers/client/requests/ListCustomersRequest.js +2 -0
- package/dist/api/resources/customers/client/requests/UpdateCustomerRequest.d.ts +18 -0
- package/dist/api/resources/customers/client/requests/UpdateCustomerRequest.js +2 -0
- package/dist/api/resources/customers/client/requests/index.d.ts +4 -0
- package/dist/api/resources/customers/client/requests/index.js +1 -0
- package/dist/api/resources/customers/exports.d.ts +2 -0
- package/dist/api/resources/customers/exports.js +3 -0
- package/dist/api/resources/customers/index.d.ts +2 -0
- package/dist/api/resources/customers/index.js +2 -0
- package/dist/api/resources/customers/types/CreateCustomerRequest.d.ts +1 -0
- package/dist/api/resources/customers/types/CreateCustomerRequest.js +2 -0
- package/dist/api/resources/customers/types/CreateCustomerResponse.d.ts +6 -0
- package/dist/api/resources/customers/types/CreateCustomerResponse.js +2 -0
- package/dist/api/resources/customers/types/DeleteCustomerResponse.d.ts +6 -0
- package/dist/api/resources/customers/types/DeleteCustomerResponse.js +2 -0
- package/dist/api/resources/customers/types/GetCustomerResponse.d.ts +6 -0
- package/dist/api/resources/customers/types/GetCustomerResponse.js +2 -0
- package/dist/api/resources/customers/types/ListCustomersRequestOrder.d.ts +5 -0
- package/dist/api/resources/customers/types/ListCustomersRequestOrder.js +5 -0
- package/dist/api/resources/customers/types/ListCustomersResponse.d.ts +7 -0
- package/dist/api/resources/customers/types/ListCustomersResponse.js +2 -0
- package/dist/api/resources/customers/types/UpdateCustomerResponse.d.ts +6 -0
- package/dist/api/resources/customers/types/UpdateCustomerResponse.js +2 -0
- package/dist/api/resources/customers/types/index.d.ts +7 -0
- package/dist/api/resources/customers/types/index.js +7 -0
- package/dist/api/resources/flows/client/Client.d.ts +43 -0
- package/dist/api/resources/flows/client/Client.js +132 -0
- package/dist/api/resources/flows/client/index.d.ts +1 -0
- package/dist/api/resources/flows/client/index.js +1 -0
- package/dist/api/resources/flows/client/requests/GetFlowRequest.d.ts +9 -0
- package/dist/api/resources/flows/client/requests/GetFlowRequest.js +2 -0
- package/dist/api/resources/flows/client/requests/ListFlowsRequest.d.ts +16 -0
- package/dist/api/resources/flows/client/requests/ListFlowsRequest.js +2 -0
- package/dist/api/resources/flows/client/requests/index.d.ts +2 -0
- package/dist/api/resources/flows/client/requests/index.js +1 -0
- package/dist/api/resources/flows/exports.d.ts +2 -0
- package/dist/api/resources/flows/exports.js +3 -0
- package/dist/api/resources/flows/index.d.ts +2 -0
- package/dist/api/resources/flows/index.js +2 -0
- package/dist/api/resources/flows/types/GetFlowResponse.d.ts +6 -0
- package/dist/api/resources/flows/types/GetFlowResponse.js +2 -0
- package/dist/api/resources/flows/types/ListFlowsRequestActive.d.ts +5 -0
- package/dist/api/resources/flows/types/ListFlowsRequestActive.js +5 -0
- package/dist/api/resources/flows/types/ListFlowsRequestOrder.d.ts +5 -0
- package/dist/api/resources/flows/types/ListFlowsRequestOrder.js +5 -0
- package/dist/api/resources/flows/types/ListFlowsResponse.d.ts +7 -0
- package/dist/api/resources/flows/types/ListFlowsResponse.js +2 -0
- package/dist/api/resources/flows/types/index.d.ts +4 -0
- package/dist/api/resources/flows/types/index.js +4 -0
- package/dist/api/resources/groups/client/Client.d.ts +43 -0
- package/dist/api/resources/groups/client/Client.js +129 -0
- package/dist/api/resources/groups/client/index.d.ts +1 -0
- package/dist/api/resources/groups/client/index.js +1 -0
- package/dist/api/resources/groups/client/requests/GetGroupRequest.d.ts +9 -0
- package/dist/api/resources/groups/client/requests/GetGroupRequest.js +2 -0
- package/dist/api/resources/groups/client/requests/ListGroupsRequest.d.ts +13 -0
- package/dist/api/resources/groups/client/requests/ListGroupsRequest.js +2 -0
- package/dist/api/resources/groups/client/requests/index.d.ts +2 -0
- package/dist/api/resources/groups/client/requests/index.js +1 -0
- package/dist/api/resources/groups/exports.d.ts +2 -0
- package/dist/api/resources/groups/exports.js +3 -0
- package/dist/api/resources/groups/index.d.ts +2 -0
- package/dist/api/resources/groups/index.js +2 -0
- package/dist/api/resources/groups/types/GetGroupResponse.d.ts +6 -0
- package/dist/api/resources/groups/types/GetGroupResponse.js +2 -0
- package/dist/api/resources/groups/types/ListGroupsRequestDefault.d.ts +5 -0
- package/dist/api/resources/groups/types/ListGroupsRequestDefault.js +5 -0
- package/dist/api/resources/groups/types/ListGroupsRequestOrder.d.ts +5 -0
- package/dist/api/resources/groups/types/ListGroupsRequestOrder.js +5 -0
- package/dist/api/resources/groups/types/ListGroupsResponse.d.ts +7 -0
- package/dist/api/resources/groups/types/ListGroupsResponse.js +2 -0
- package/dist/api/resources/groups/types/index.d.ts +4 -0
- package/dist/api/resources/groups/types/index.js +4 -0
- package/dist/api/resources/index.d.ts +33 -0
- package/dist/api/resources/index.js +33 -0
- package/dist/api/resources/links/client/Client.d.ts +93 -0
- package/dist/api/resources/links/client/Client.js +298 -0
- package/dist/api/resources/links/client/index.d.ts +1 -0
- package/dist/api/resources/links/client/index.js +1 -0
- package/dist/api/resources/links/client/requests/CreateLinkRequest.d.ts +12 -0
- package/dist/api/resources/links/client/requests/CreateLinkRequest.js +2 -0
- package/dist/api/resources/links/client/requests/DeleteLinkRequest.d.ts +9 -0
- package/dist/api/resources/links/client/requests/DeleteLinkRequest.js +2 -0
- package/dist/api/resources/links/client/requests/GetLinkRequest.d.ts +9 -0
- package/dist/api/resources/links/client/requests/GetLinkRequest.js +2 -0
- package/dist/api/resources/links/client/requests/ListLinksRequest.d.ts +13 -0
- package/dist/api/resources/links/client/requests/ListLinksRequest.js +2 -0
- package/dist/api/resources/links/client/requests/UpdateLinkRequest.d.ts +11 -0
- package/dist/api/resources/links/client/requests/UpdateLinkRequest.js +2 -0
- package/dist/api/resources/links/client/requests/index.d.ts +5 -0
- package/dist/api/resources/links/client/requests/index.js +1 -0
- package/dist/api/resources/links/exports.d.ts +2 -0
- package/dist/api/resources/links/exports.js +3 -0
- package/dist/api/resources/links/index.d.ts +2 -0
- package/dist/api/resources/links/index.js +2 -0
- package/dist/api/resources/links/types/CreateLinkResponse.d.ts +6 -0
- package/dist/api/resources/links/types/CreateLinkResponse.js +2 -0
- package/dist/api/resources/links/types/DeleteLinkResponse.d.ts +6 -0
- package/dist/api/resources/links/types/DeleteLinkResponse.js +2 -0
- package/dist/api/resources/links/types/GetLinkResponse.d.ts +6 -0
- package/dist/api/resources/links/types/GetLinkResponse.js +2 -0
- package/dist/api/resources/links/types/ListLinksRequestOrder.d.ts +5 -0
- package/dist/api/resources/links/types/ListLinksRequestOrder.js +5 -0
- package/dist/api/resources/links/types/ListLinksResponse.d.ts +7 -0
- package/dist/api/resources/links/types/ListLinksResponse.js +2 -0
- package/dist/api/resources/links/types/UpdateLinkResponse.d.ts +6 -0
- package/dist/api/resources/links/types/UpdateLinkResponse.js +2 -0
- package/dist/api/resources/links/types/index.d.ts +6 -0
- package/dist/api/resources/links/types/index.js +6 -0
- package/dist/api/resources/partners/client/Client.d.ts +93 -0
- package/dist/api/resources/partners/client/Client.js +302 -0
- package/dist/api/resources/partners/client/index.d.ts +1 -0
- package/dist/api/resources/partners/client/index.js +1 -0
- package/dist/api/resources/partners/client/requests/ApprovePartnerRequest.d.ts +9 -0
- package/dist/api/resources/partners/client/requests/ApprovePartnerRequest.js +2 -0
- package/dist/api/resources/partners/client/requests/GetPartnerRequest.d.ts +9 -0
- package/dist/api/resources/partners/client/requests/GetPartnerRequest.js +2 -0
- package/dist/api/resources/partners/client/requests/ListPartnersRequest.d.ts +14 -0
- package/dist/api/resources/partners/client/requests/ListPartnersRequest.js +2 -0
- package/dist/api/resources/partners/client/requests/RejectPartnerRequest.d.ts +10 -0
- package/dist/api/resources/partners/client/requests/RejectPartnerRequest.js +2 -0
- package/dist/api/resources/partners/client/requests/SuspendPartnerRequest.d.ts +10 -0
- package/dist/api/resources/partners/client/requests/SuspendPartnerRequest.js +2 -0
- package/dist/api/resources/partners/client/requests/index.d.ts +5 -0
- package/dist/api/resources/partners/client/requests/index.js +1 -0
- package/dist/api/resources/partners/exports.d.ts +2 -0
- package/dist/api/resources/partners/exports.js +3 -0
- package/dist/api/resources/partners/index.d.ts +2 -0
- package/dist/api/resources/partners/index.js +2 -0
- package/dist/api/resources/partners/types/ApprovePartnerResponse.d.ts +6 -0
- package/dist/api/resources/partners/types/ApprovePartnerResponse.js +2 -0
- package/dist/api/resources/partners/types/GetPartnerResponse.d.ts +6 -0
- package/dist/api/resources/partners/types/GetPartnerResponse.js +2 -0
- package/dist/api/resources/partners/types/ListPartnersRequestOrder.d.ts +5 -0
- package/dist/api/resources/partners/types/ListPartnersRequestOrder.js +5 -0
- package/dist/api/resources/partners/types/ListPartnersRequestStatus.d.ts +7 -0
- package/dist/api/resources/partners/types/ListPartnersRequestStatus.js +7 -0
- package/dist/api/resources/partners/types/ListPartnersResponse.d.ts +7 -0
- package/dist/api/resources/partners/types/ListPartnersResponse.js +2 -0
- package/dist/api/resources/partners/types/RejectPartnerResponse.d.ts +6 -0
- package/dist/api/resources/partners/types/RejectPartnerResponse.js +2 -0
- package/dist/api/resources/partners/types/SuspendPartnerResponse.d.ts +6 -0
- package/dist/api/resources/partners/types/SuspendPartnerResponse.js +2 -0
- package/dist/api/resources/partners/types/index.d.ts +7 -0
- package/dist/api/resources/partners/types/index.js +7 -0
- package/dist/api/resources/programs/client/Client.d.ts +43 -0
- package/dist/api/resources/programs/client/Client.js +127 -0
- package/dist/api/resources/programs/client/index.d.ts +1 -0
- package/dist/api/resources/programs/client/index.js +1 -0
- package/dist/api/resources/programs/client/requests/GetProgramRequest.d.ts +9 -0
- package/dist/api/resources/programs/client/requests/GetProgramRequest.js +2 -0
- package/dist/api/resources/programs/client/requests/ListProgramsRequest.d.ts +11 -0
- package/dist/api/resources/programs/client/requests/ListProgramsRequest.js +2 -0
- package/dist/api/resources/programs/client/requests/index.d.ts +2 -0
- package/dist/api/resources/programs/client/requests/index.js +1 -0
- package/dist/api/resources/programs/exports.d.ts +2 -0
- package/dist/api/resources/programs/exports.js +3 -0
- package/dist/api/resources/programs/index.d.ts +2 -0
- package/dist/api/resources/programs/index.js +2 -0
- package/dist/api/resources/programs/types/GetProgramResponse.d.ts +6 -0
- package/dist/api/resources/programs/types/GetProgramResponse.js +2 -0
- package/dist/api/resources/programs/types/ListProgramsRequestOrder.d.ts +5 -0
- package/dist/api/resources/programs/types/ListProgramsRequestOrder.js +5 -0
- package/dist/api/resources/programs/types/ListProgramsResponse.d.ts +7 -0
- package/dist/api/resources/programs/types/ListProgramsResponse.js +2 -0
- package/dist/api/resources/programs/types/index.d.ts +3 -0
- package/dist/api/resources/programs/types/index.js +3 -0
- package/dist/api/resources/promotionCodes/client/Client.d.ts +93 -0
- package/dist/api/resources/promotionCodes/client/Client.js +299 -0
- package/dist/api/resources/promotionCodes/client/index.d.ts +1 -0
- package/dist/api/resources/promotionCodes/client/index.js +1 -0
- package/dist/api/resources/promotionCodes/client/requests/CreatePromotionCodeRequest.d.ts +13 -0
- package/dist/api/resources/promotionCodes/client/requests/CreatePromotionCodeRequest.js +2 -0
- package/dist/api/resources/promotionCodes/client/requests/DeletePromotionCodeRequest.d.ts +9 -0
- package/dist/api/resources/promotionCodes/client/requests/DeletePromotionCodeRequest.js +2 -0
- package/dist/api/resources/promotionCodes/client/requests/GetPromotionCodeRequest.d.ts +9 -0
- package/dist/api/resources/promotionCodes/client/requests/GetPromotionCodeRequest.js +2 -0
- package/dist/api/resources/promotionCodes/client/requests/ListPromotionCodesRequest.d.ts +14 -0
- package/dist/api/resources/promotionCodes/client/requests/ListPromotionCodesRequest.js +2 -0
- package/dist/api/resources/promotionCodes/client/requests/UpdatePromotionCodeRequest.d.ts +12 -0
- package/dist/api/resources/promotionCodes/client/requests/UpdatePromotionCodeRequest.js +2 -0
- package/dist/api/resources/promotionCodes/client/requests/index.d.ts +5 -0
- package/dist/api/resources/promotionCodes/client/requests/index.js +1 -0
- package/dist/api/resources/promotionCodes/exports.d.ts +2 -0
- package/dist/api/resources/promotionCodes/exports.js +3 -0
- package/dist/api/resources/promotionCodes/index.d.ts +2 -0
- package/dist/api/resources/promotionCodes/index.js +2 -0
- package/dist/api/resources/promotionCodes/types/CreatePromotionCodeResponse.d.ts +6 -0
- package/dist/api/resources/promotionCodes/types/CreatePromotionCodeResponse.js +2 -0
- package/dist/api/resources/promotionCodes/types/DeletePromotionCodeResponse.d.ts +6 -0
- package/dist/api/resources/promotionCodes/types/DeletePromotionCodeResponse.js +2 -0
- package/dist/api/resources/promotionCodes/types/GetPromotionCodeResponse.d.ts +6 -0
- package/dist/api/resources/promotionCodes/types/GetPromotionCodeResponse.js +2 -0
- package/dist/api/resources/promotionCodes/types/ListPromotionCodesRequestOrder.d.ts +5 -0
- package/dist/api/resources/promotionCodes/types/ListPromotionCodesRequestOrder.js +5 -0
- package/dist/api/resources/promotionCodes/types/ListPromotionCodesResponse.d.ts +7 -0
- package/dist/api/resources/promotionCodes/types/ListPromotionCodesResponse.js +2 -0
- package/dist/api/resources/promotionCodes/types/UpdatePromotionCodeResponse.d.ts +6 -0
- package/dist/api/resources/promotionCodes/types/UpdatePromotionCodeResponse.js +2 -0
- package/dist/api/resources/promotionCodes/types/index.d.ts +6 -0
- package/dist/api/resources/promotionCodes/types/index.js +6 -0
- package/dist/api/resources/reports/client/Client.d.ts +29 -0
- package/dist/api/resources/reports/client/Client.js +75 -0
- package/dist/api/resources/reports/client/index.d.ts +1 -0
- package/dist/api/resources/reports/client/index.js +1 -0
- package/dist/api/resources/reports/client/requests/ReportsOverviewRequest.d.ts +9 -0
- package/dist/api/resources/reports/client/requests/ReportsOverviewRequest.js +2 -0
- package/dist/api/resources/reports/client/requests/index.d.ts +1 -0
- package/dist/api/resources/reports/client/requests/index.js +1 -0
- package/dist/api/resources/reports/exports.d.ts +2 -0
- package/dist/api/resources/reports/exports.js +3 -0
- package/dist/api/resources/reports/index.d.ts +2 -0
- package/dist/api/resources/reports/index.js +2 -0
- package/dist/api/resources/reports/types/ReportsOverviewResponse.d.ts +6 -0
- package/dist/api/resources/reports/types/ReportsOverviewResponse.js +2 -0
- package/dist/api/resources/reports/types/index.d.ts +1 -0
- package/dist/api/resources/reports/types/index.js +1 -0
- package/dist/api/resources/transactions/client/Client.d.ts +131 -0
- package/dist/api/resources/transactions/client/Client.js +423 -0
- package/dist/api/resources/transactions/client/index.d.ts +1 -0
- package/dist/api/resources/transactions/client/index.js +1 -0
- package/dist/api/resources/transactions/client/requests/CreateTransactionRequest.d.ts +17 -0
- package/dist/api/resources/transactions/client/requests/CreateTransactionRequest.js +2 -0
- package/dist/api/resources/transactions/client/requests/DeleteTransactionRequest.d.ts +9 -0
- package/dist/api/resources/transactions/client/requests/DeleteTransactionRequest.js +2 -0
- package/dist/api/resources/transactions/client/requests/GetTransactionRequest.d.ts +9 -0
- package/dist/api/resources/transactions/client/requests/GetTransactionRequest.js +2 -0
- package/dist/api/resources/transactions/client/requests/ListTransactionsRequest.d.ts +15 -0
- package/dist/api/resources/transactions/client/requests/ListTransactionsRequest.js +2 -0
- package/dist/api/resources/transactions/client/requests/RefundTransactionRequest.d.ts +9 -0
- package/dist/api/resources/transactions/client/requests/RefundTransactionRequest.js +2 -0
- package/dist/api/resources/transactions/client/requests/RerunTransactionFlowsRequest.d.ts +9 -0
- package/dist/api/resources/transactions/client/requests/RerunTransactionFlowsRequest.js +2 -0
- package/dist/api/resources/transactions/client/requests/UpdateTransactionRequest.d.ts +18 -0
- package/dist/api/resources/transactions/client/requests/UpdateTransactionRequest.js +2 -0
- package/dist/api/resources/transactions/client/requests/index.d.ts +7 -0
- package/dist/api/resources/transactions/client/requests/index.js +1 -0
- package/dist/api/resources/transactions/exports.d.ts +2 -0
- package/dist/api/resources/transactions/exports.js +3 -0
- package/dist/api/resources/transactions/index.d.ts +2 -0
- package/dist/api/resources/transactions/index.js +2 -0
- package/dist/api/resources/transactions/types/CreateTransactionResponse.d.ts +6 -0
- package/dist/api/resources/transactions/types/CreateTransactionResponse.js +2 -0
- package/dist/api/resources/transactions/types/DeleteTransactionResponse.d.ts +6 -0
- package/dist/api/resources/transactions/types/DeleteTransactionResponse.js +2 -0
- package/dist/api/resources/transactions/types/GetTransactionResponse.d.ts +6 -0
- package/dist/api/resources/transactions/types/GetTransactionResponse.js +2 -0
- package/dist/api/resources/transactions/types/ListTransactionsRequestOrder.d.ts +5 -0
- package/dist/api/resources/transactions/types/ListTransactionsRequestOrder.js +5 -0
- package/dist/api/resources/transactions/types/ListTransactionsResponse.d.ts +7 -0
- package/dist/api/resources/transactions/types/ListTransactionsResponse.js +2 -0
- package/dist/api/resources/transactions/types/RefundTransactionResponse.d.ts +6 -0
- package/dist/api/resources/transactions/types/RefundTransactionResponse.js +2 -0
- package/dist/api/resources/transactions/types/RerunTransactionFlowsResponse.d.ts +6 -0
- package/dist/api/resources/transactions/types/RerunTransactionFlowsResponse.js +2 -0
- package/dist/api/resources/transactions/types/UpdateTransactionResponse.d.ts +6 -0
- package/dist/api/resources/transactions/types/UpdateTransactionResponse.js +2 -0
- package/dist/api/resources/transactions/types/index.d.ts +8 -0
- package/dist/api/resources/transactions/types/index.js +8 -0
- package/dist/api/types/Click.d.ts +14 -0
- package/dist/api/types/Click.js +2 -0
- package/dist/api/types/Commission.d.ts +24 -0
- package/dist/api/types/Commission.js +2 -0
- package/dist/api/types/Customer.d.ts +19 -0
- package/dist/api/types/Customer.js +2 -0
- package/dist/api/types/Error_.d.ts +4 -0
- package/dist/api/types/Error_.js +2 -0
- package/dist/api/types/Flow.d.ts +18 -0
- package/dist/api/types/Flow.js +2 -0
- package/dist/api/types/Group.d.ts +14 -0
- package/dist/api/types/Group.js +2 -0
- package/dist/api/types/Link.d.ts +11 -0
- package/dist/api/types/Link.js +2 -0
- package/dist/api/types/Partner.d.ts +13 -0
- package/dist/api/types/Partner.js +2 -0
- package/dist/api/types/Program.d.ts +15 -0
- package/dist/api/types/Program.js +2 -0
- package/dist/api/types/PromotionCode.d.ts +16 -0
- package/dist/api/types/PromotionCode.js +2 -0
- package/dist/api/types/ReportsOverview.d.ts +30 -0
- package/dist/api/types/ReportsOverview.js +2 -0
- package/dist/api/types/RerunFlowsResult.d.ts +4 -0
- package/dist/api/types/RerunFlowsResult.js +2 -0
- package/dist/api/types/Transaction.d.ts +32 -0
- package/dist/api/types/Transaction.js +2 -0
- package/dist/api/types/index.d.ts +13 -0
- package/dist/api/types/index.js +13 -0
- package/dist/auth/BearerAuthProvider.d.ts +20 -0
- package/dist/auth/BearerAuthProvider.js +31 -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 +223 -0
- package/dist/core/fetcher/Headers.d.ts +2 -0
- package/dist/core/fetcher/Headers.js +82 -0
- package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/core/fetcher/HttpResponsePromise.js +88 -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 +66 -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 +141 -0
- package/dist/core/fetcher/makeRequest.d.ts +6 -0
- package/dist/core/fetcher/makeRequest.js +53 -0
- package/dist/core/fetcher/redactUrl.d.ts +2 -0
- package/dist/core/fetcher/redactUrl.js +84 -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 +28 -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 +137 -0
- package/dist/core/requestBody.d.ts +12 -0
- package/dist/core/requestBody.js +23 -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 +28 -0
- package/dist/core/runtime/runtime.js +171 -0
- package/dist/core/url/QueryStringBuilder.d.ts +47 -0
- package/dist/core/url/QueryStringBuilder.js +80 -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/ToltApiError.d.ts +15 -0
- package/dist/errors/ToltApiError.js +34 -0
- package/dist/errors/ToltApiTimeoutError.d.ts +6 -0
- package/dist/errors/ToltApiTimeoutError.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 +44 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { base64Decode, base64Encode } from "../base64.js";
|
|
2
|
+
const BASIC_AUTH_HEADER_PREFIX = /^Basic /i;
|
|
3
|
+
export const BasicAuth = {
|
|
4
|
+
toAuthorizationHeader: (basicAuth) => {
|
|
5
|
+
if (basicAuth == null) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
const username = basicAuth.username ?? "";
|
|
9
|
+
const password = basicAuth.password ?? "";
|
|
10
|
+
if (username === "" && password === "") {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const token = base64Encode(`${username}:${password}`);
|
|
14
|
+
return `Basic ${token}`;
|
|
15
|
+
},
|
|
16
|
+
fromAuthorizationHeader: (header) => {
|
|
17
|
+
const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, "");
|
|
18
|
+
const decoded = base64Decode(credentials);
|
|
19
|
+
const [username, ...passwordParts] = decoded.split(":");
|
|
20
|
+
const password = passwordParts.length > 0 ? passwordParts.join(":") : undefined;
|
|
21
|
+
if (username == null || password == null) {
|
|
22
|
+
throw new Error("Invalid basic auth");
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
username,
|
|
26
|
+
password,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type BearerToken = string;
|
|
2
|
+
declare function toAuthorizationHeader(token: string | undefined): string | undefined;
|
|
3
|
+
export declare const BearerToken: {
|
|
4
|
+
toAuthorizationHeader: typeof toAuthorizationHeader;
|
|
5
|
+
fromAuthorizationHeader: (header: string) => BearerToken;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
|
|
2
|
+
function toAuthorizationHeader(token) {
|
|
3
|
+
if (token == null) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
return `Bearer ${token}`;
|
|
7
|
+
}
|
|
8
|
+
export const BearerToken = {
|
|
9
|
+
toAuthorizationHeader: toAuthorizationHeader,
|
|
10
|
+
fromAuthorizationHeader: (header) => {
|
|
11
|
+
return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { type AuthProvider, isAuthProvider } from "./AuthProvider.js";
|
|
2
|
+
export type { AuthRequest } from "./AuthRequest.js";
|
|
3
|
+
export { BasicAuth } from "./BasicAuth.js";
|
|
4
|
+
export { BearerToken } from "./BearerToken.js";
|
|
5
|
+
export { NoOpAuthProvider } from "./NoOpAuthProvider.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./logging/exports.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./logging/exports.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RawResponse } from "./RawResponse.js";
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type BinaryResponse = {
|
|
2
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
|
|
3
|
+
bodyUsed: Response["bodyUsed"];
|
|
4
|
+
/**
|
|
5
|
+
* Returns a ReadableStream of the response body.
|
|
6
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body)
|
|
7
|
+
*/
|
|
8
|
+
stream: () => Response["body"];
|
|
9
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
|
|
10
|
+
arrayBuffer: () => ReturnType<Response["arrayBuffer"]>;
|
|
11
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
|
|
12
|
+
blob: () => ReturnType<Response["blob"]>;
|
|
13
|
+
/**
|
|
14
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
|
|
15
|
+
* Some versions of the Fetch API may not support this method.
|
|
16
|
+
*/
|
|
17
|
+
bytes?(): Promise<Uint8Array>;
|
|
18
|
+
};
|
|
19
|
+
export declare function getBinaryResponse(response: Response): BinaryResponse;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SecuritySchemeKey = string;
|
|
2
|
+
/**
|
|
3
|
+
* A collection of security schemes, where the key is the name of the security scheme and the value is the list of scopes required for that scheme.
|
|
4
|
+
* All schemes in the collection must be satisfied for authentication to be successful.
|
|
5
|
+
*/
|
|
6
|
+
export type SecuritySchemeCollection = Record<SecuritySchemeKey, AuthScope[]>;
|
|
7
|
+
export type AuthScope = string;
|
|
8
|
+
export type EndpointMetadata = {
|
|
9
|
+
/**
|
|
10
|
+
* An array of security scheme collections. Each collection represents an alternative way to authenticate.
|
|
11
|
+
*/
|
|
12
|
+
security?: SecuritySchemeCollection[];
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EndpointMetadata } from "./EndpointMetadata.js";
|
|
2
|
+
import type { Supplier } from "./Supplier.js";
|
|
3
|
+
type EndpointSupplierFn<T> = (arg: {
|
|
4
|
+
endpointMetadata?: EndpointMetadata;
|
|
5
|
+
}) => T | Promise<T>;
|
|
6
|
+
export type EndpointSupplier<T> = Supplier<T> | EndpointSupplierFn<T>;
|
|
7
|
+
export declare const EndpointSupplier: {
|
|
8
|
+
get: <T>(supplier: EndpointSupplier<T>, arg: {
|
|
9
|
+
endpointMetadata?: EndpointMetadata;
|
|
10
|
+
}) => Promise<T>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -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,223 @@
|
|
|
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 { redactUrl, SENSITIVE_QUERY_PARAMS } from "./redactUrl.js";
|
|
13
|
+
import { requestWithRetries } from "./requestWithRetries.js";
|
|
14
|
+
const SENSITIVE_HEADERS = new Set([
|
|
15
|
+
"authorization",
|
|
16
|
+
"www-authenticate",
|
|
17
|
+
"x-api-key",
|
|
18
|
+
"api-key",
|
|
19
|
+
"apikey",
|
|
20
|
+
"x-api-token",
|
|
21
|
+
"x-auth-token",
|
|
22
|
+
"auth-token",
|
|
23
|
+
"cookie",
|
|
24
|
+
"set-cookie",
|
|
25
|
+
"proxy-authorization",
|
|
26
|
+
"proxy-authenticate",
|
|
27
|
+
"x-csrf-token",
|
|
28
|
+
"x-xsrf-token",
|
|
29
|
+
"x-session-token",
|
|
30
|
+
"x-access-token",
|
|
31
|
+
]);
|
|
32
|
+
function redactHeaders(headers) {
|
|
33
|
+
const filtered = {};
|
|
34
|
+
for (const [key, value] of headers instanceof Headers ? headers.entries() : Object.entries(headers)) {
|
|
35
|
+
if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
|
|
36
|
+
filtered[key] = "[REDACTED]";
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
filtered[key] = value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return filtered;
|
|
43
|
+
}
|
|
44
|
+
function redactQueryParameters(queryParameters) {
|
|
45
|
+
if (queryParameters == null) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const redacted = {};
|
|
49
|
+
for (const [key, value] of Object.entries(queryParameters)) {
|
|
50
|
+
redacted[key] = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
|
|
51
|
+
}
|
|
52
|
+
return redacted;
|
|
53
|
+
}
|
|
54
|
+
async function getHeaders(args) {
|
|
55
|
+
const newHeaders = new Headers();
|
|
56
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
57
|
+
? "application/json"
|
|
58
|
+
: args.responseType === "text"
|
|
59
|
+
? "text/plain"
|
|
60
|
+
: args.responseType === "sse"
|
|
61
|
+
? "text/event-stream"
|
|
62
|
+
: "*/*");
|
|
63
|
+
if (args.body !== undefined && args.contentType != null) {
|
|
64
|
+
newHeaders.set("Content-Type", args.contentType);
|
|
65
|
+
}
|
|
66
|
+
if (args.headers == null) {
|
|
67
|
+
return newHeaders;
|
|
68
|
+
}
|
|
69
|
+
for (const [key, value] of Object.entries(args.headers)) {
|
|
70
|
+
const result = await EndpointSupplier.get(value, { endpointMetadata: args.endpointMetadata ?? {} });
|
|
71
|
+
if (typeof result === "string") {
|
|
72
|
+
newHeaders.set(key, result);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (result == null) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
newHeaders.set(key, `${result}`);
|
|
79
|
+
}
|
|
80
|
+
return newHeaders;
|
|
81
|
+
}
|
|
82
|
+
export async function fetcherImpl(args) {
|
|
83
|
+
let url = args.url;
|
|
84
|
+
if (args.queryString != null && args.queryString.length > 0) {
|
|
85
|
+
url = `${url}?${args.queryString}`;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
url = createRequestUrl(args.url, args.queryParameters);
|
|
89
|
+
}
|
|
90
|
+
const requestBody = await getRequestBody({
|
|
91
|
+
body: args.body,
|
|
92
|
+
type: args.requestType ?? "other",
|
|
93
|
+
});
|
|
94
|
+
const fetchFn = args.fetchFn ?? (await getFetchFn());
|
|
95
|
+
const headers = await getHeaders(args);
|
|
96
|
+
const logger = createLogger(args.logging);
|
|
97
|
+
if (logger.isDebug()) {
|
|
98
|
+
const metadata = {
|
|
99
|
+
method: args.method,
|
|
100
|
+
url: redactUrl(url),
|
|
101
|
+
headers: redactHeaders(headers),
|
|
102
|
+
queryParameters: redactQueryParameters(args.queryParameters),
|
|
103
|
+
hasBody: requestBody != null,
|
|
104
|
+
};
|
|
105
|
+
logger.debug("Making HTTP request", metadata);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
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);
|
|
109
|
+
if (response.status >= 200 && response.status < 400) {
|
|
110
|
+
if (logger.isDebug()) {
|
|
111
|
+
const metadata = {
|
|
112
|
+
method: args.method,
|
|
113
|
+
url: redactUrl(url),
|
|
114
|
+
statusCode: response.status,
|
|
115
|
+
responseHeaders: redactHeaders(response.headers),
|
|
116
|
+
};
|
|
117
|
+
logger.debug("HTTP request succeeded", metadata);
|
|
118
|
+
}
|
|
119
|
+
const body = await getResponseBody(response, args.responseType);
|
|
120
|
+
return {
|
|
121
|
+
ok: true,
|
|
122
|
+
body: body,
|
|
123
|
+
headers: response.headers,
|
|
124
|
+
rawResponse: toRawResponse(response),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
if (logger.isError()) {
|
|
129
|
+
const metadata = {
|
|
130
|
+
method: args.method,
|
|
131
|
+
url: redactUrl(url),
|
|
132
|
+
statusCode: response.status,
|
|
133
|
+
responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())),
|
|
134
|
+
};
|
|
135
|
+
logger.error("HTTP request failed with error status", metadata);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
ok: false,
|
|
139
|
+
error: {
|
|
140
|
+
reason: "status-code",
|
|
141
|
+
statusCode: response.status,
|
|
142
|
+
body: await getErrorResponseBody(response),
|
|
143
|
+
},
|
|
144
|
+
rawResponse: toRawResponse(response),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
if (args.abortSignal?.aborted) {
|
|
150
|
+
if (logger.isError()) {
|
|
151
|
+
const metadata = {
|
|
152
|
+
method: args.method,
|
|
153
|
+
url: redactUrl(url),
|
|
154
|
+
};
|
|
155
|
+
logger.error("HTTP request was aborted", metadata);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
ok: false,
|
|
159
|
+
error: {
|
|
160
|
+
reason: "unknown",
|
|
161
|
+
errorMessage: "The user aborted a request",
|
|
162
|
+
cause: error,
|
|
163
|
+
},
|
|
164
|
+
rawResponse: abortRawResponse,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
else if (error instanceof Error && error.name === "AbortError") {
|
|
168
|
+
if (logger.isError()) {
|
|
169
|
+
const metadata = {
|
|
170
|
+
method: args.method,
|
|
171
|
+
url: redactUrl(url),
|
|
172
|
+
timeoutMs: args.timeoutMs,
|
|
173
|
+
};
|
|
174
|
+
logger.error("HTTP request timed out", metadata);
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
ok: false,
|
|
178
|
+
error: {
|
|
179
|
+
reason: "timeout",
|
|
180
|
+
cause: error,
|
|
181
|
+
},
|
|
182
|
+
rawResponse: abortRawResponse,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
else if (error instanceof Error) {
|
|
186
|
+
if (logger.isError()) {
|
|
187
|
+
const metadata = {
|
|
188
|
+
method: args.method,
|
|
189
|
+
url: redactUrl(url),
|
|
190
|
+
errorMessage: error.message,
|
|
191
|
+
};
|
|
192
|
+
logger.error("HTTP request failed with error", metadata);
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
ok: false,
|
|
196
|
+
error: {
|
|
197
|
+
reason: "unknown",
|
|
198
|
+
errorMessage: error.message,
|
|
199
|
+
cause: error,
|
|
200
|
+
},
|
|
201
|
+
rawResponse: unknownRawResponse,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
if (logger.isError()) {
|
|
205
|
+
const metadata = {
|
|
206
|
+
method: args.method,
|
|
207
|
+
url: redactUrl(url),
|
|
208
|
+
error: toJson(error),
|
|
209
|
+
};
|
|
210
|
+
logger.error("HTTP request failed with unknown error", metadata);
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
ok: false,
|
|
214
|
+
error: {
|
|
215
|
+
reason: "unknown",
|
|
216
|
+
errorMessage: toJson(error),
|
|
217
|
+
cause: error,
|
|
218
|
+
},
|
|
219
|
+
rawResponse: unknownRawResponse,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export const fetcher = fetcherImpl;
|
|
@@ -0,0 +1,82 @@
|
|
|
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 };
|
|
@@ -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
|
+
}
|