@tolt/api 0.7.0 → 1.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.
Files changed (303) hide show
  1. package/dist/BaseClient.js +1 -0
  2. package/dist/Client.d.ts +3 -3
  3. package/dist/Client.js +3 -3
  4. package/dist/api/errors/BadRequestError.d.ts +2 -2
  5. package/dist/api/errors/ConflictError.d.ts +2 -2
  6. package/dist/api/errors/ContentTooLargeError.d.ts +2 -2
  7. package/dist/api/errors/NotFoundError.d.ts +2 -2
  8. package/dist/api/errors/TooManyRequestsError.d.ts +2 -2
  9. package/dist/api/errors/UnauthorizedError.d.ts +2 -2
  10. package/dist/api/resources/clicks/client/Client.d.ts +10 -7
  11. package/dist/api/resources/clicks/client/Client.js +82 -68
  12. package/dist/api/resources/clicks/client/requests/CreateClickRequest.d.ts +28 -0
  13. package/dist/api/resources/clicks/client/requests/{GetClicksRequest.d.ts → GetClickRequest.d.ts} +1 -1
  14. package/dist/api/resources/clicks/client/requests/index.d.ts +2 -1
  15. package/dist/api/resources/clicks/types/{CreateClicksResponse.d.ts → CreateClickResponse.d.ts} +1 -1
  16. package/dist/api/resources/clicks/types/{GetClicksResponse.d.ts → GetClickResponse.d.ts} +1 -1
  17. package/dist/api/resources/clicks/types/index.d.ts +2 -3
  18. package/dist/api/resources/clicks/types/index.js +2 -3
  19. package/dist/api/resources/commissions/client/Client.d.ts +19 -15
  20. package/dist/api/resources/commissions/client/Client.js +94 -76
  21. package/dist/api/resources/commissions/client/requests/{DeleteCommissionsRequest.d.ts → ApproveCommissionRequest.d.ts} +1 -1
  22. package/dist/api/resources/commissions/client/requests/CreateCommissionRequest.d.ts +40 -0
  23. package/dist/api/resources/commissions/client/requests/CreateCommissionRequest.js +9 -0
  24. package/dist/api/resources/commissions/client/requests/{DeclineCommissionsRequest.d.ts → DeclineCommissionRequest.d.ts} +1 -1
  25. package/dist/api/resources/commissions/client/requests/{ApproveCommissionsRequest.d.ts → DeleteCommissionRequest.d.ts} +1 -1
  26. package/dist/api/resources/commissions/client/requests/{GetCommissionsRequest.d.ts → GetCommissionRequest.d.ts} +1 -1
  27. package/dist/api/resources/commissions/client/requests/{UpdateCommissionsRequest.d.ts → UpdateCommissionRequest.d.ts} +3 -3
  28. package/dist/api/resources/commissions/client/requests/UpdateCommissionRequest.js +9 -0
  29. package/dist/api/resources/commissions/client/requests/index.d.ts +6 -5
  30. package/dist/api/resources/commissions/client/requests/index.js +2 -1
  31. package/dist/api/resources/commissions/types/{UpdateCommissionsResponse.d.ts → ApproveCommissionResponse.d.ts} +1 -1
  32. package/dist/api/resources/commissions/types/{DeleteCommissionsResponse.d.ts → CreateCommissionResponse.d.ts} +1 -1
  33. package/dist/api/resources/commissions/types/{CreateCommissionsResponse.d.ts → DeclineCommissionResponse.d.ts} +1 -1
  34. package/dist/api/resources/commissions/types/DeleteCommissionResponse.d.ts +6 -0
  35. package/dist/api/resources/commissions/types/{GetCommissionsResponse.d.ts → GetCommissionResponse.d.ts} +1 -1
  36. package/dist/api/resources/commissions/types/UpdateCommissionResponse.d.ts +6 -0
  37. package/dist/api/resources/commissions/types/index.d.ts +6 -7
  38. package/dist/api/resources/commissions/types/index.js +6 -7
  39. package/dist/api/resources/customers/client/Client.d.ts +9 -10
  40. package/dist/api/resources/customers/client/Client.js +84 -71
  41. package/dist/api/resources/customers/client/requests/{CreateCustomersRequest.d.ts → CreateCustomerRequest.d.ts} +3 -3
  42. package/dist/api/resources/customers/client/requests/{CreateCustomersRequest.js → CreateCustomerRequest.js} +4 -4
  43. package/dist/api/resources/customers/client/requests/{DeleteCustomersRequest.d.ts → DeleteCustomerRequest.d.ts} +1 -1
  44. package/dist/api/resources/customers/client/requests/{GetCustomersRequest.d.ts → GetCustomerRequest.d.ts} +1 -1
  45. package/dist/api/resources/customers/client/requests/{UpdateCustomersRequest.d.ts → UpdateCustomerRequest.d.ts} +3 -3
  46. package/dist/api/resources/customers/client/requests/{UpdateCustomersRequest.js → UpdateCustomerRequest.js} +4 -4
  47. package/dist/api/resources/customers/client/requests/index.d.ts +4 -4
  48. package/dist/api/resources/customers/client/requests/index.js +2 -2
  49. package/dist/api/resources/customers/types/{DeleteCustomersResponse.d.ts → CreateCustomerResponse.d.ts} +1 -1
  50. package/dist/api/resources/customers/types/{UpdateCustomersResponse.d.ts → DeleteCustomerResponse.d.ts} +1 -1
  51. package/dist/api/resources/customers/types/{GetCustomersResponse.d.ts → GetCustomerResponse.d.ts} +1 -1
  52. package/dist/api/resources/customers/types/{CreateCustomersResponse.d.ts → UpdateCustomerResponse.d.ts} +1 -1
  53. package/dist/api/resources/customers/types/index.d.ts +4 -4
  54. package/dist/api/resources/customers/types/index.js +4 -4
  55. package/dist/api/resources/{embed → embedTokens}/client/Client.d.ts +9 -11
  56. package/dist/api/resources/{embed → embedTokens}/client/Client.js +7 -9
  57. package/dist/api/resources/embedTokens/client/index.d.ts +1 -0
  58. package/dist/api/resources/embedTokens/client/index.js +1 -0
  59. package/dist/api/resources/embedTokens/client/requests/CreateEmbedTokenRequest.d.ts +21 -0
  60. package/dist/api/resources/embedTokens/client/requests/index.d.ts +1 -0
  61. package/dist/api/resources/embedTokens/exports.d.ts +2 -0
  62. package/dist/api/resources/{embed → embedTokens}/exports.js +1 -1
  63. package/dist/api/resources/{embed/types/CreateTokenEmbedResponse.d.ts → embedTokens/types/CreateEmbedTokenResponse.d.ts} +1 -1
  64. package/dist/api/resources/embedTokens/types/index.d.ts +1 -0
  65. package/dist/api/resources/embedTokens/types/index.js +1 -0
  66. package/dist/api/resources/flows/client/Client.d.ts +3 -4
  67. package/dist/api/resources/flows/client/Client.js +74 -64
  68. package/dist/api/resources/flows/client/requests/{GetFlowsRequest.d.ts → GetFlowRequest.d.ts} +1 -1
  69. package/dist/api/resources/flows/client/requests/ListFlowsRequest.d.ts +1 -1
  70. package/dist/api/resources/flows/client/requests/index.d.ts +1 -1
  71. package/dist/api/resources/flows/types/{GetFlowsResponse.d.ts → GetFlowResponse.d.ts} +1 -1
  72. package/dist/api/resources/flows/types/index.d.ts +1 -2
  73. package/dist/api/resources/flows/types/index.js +1 -2
  74. package/dist/api/resources/groups/client/Client.d.ts +3 -4
  75. package/dist/api/resources/groups/client/Client.js +71 -61
  76. package/dist/api/resources/groups/client/requests/{GetGroupsRequest.d.ts → GetGroupRequest.d.ts} +1 -1
  77. package/dist/api/resources/groups/client/requests/ListGroupsRequest.d.ts +1 -1
  78. package/dist/api/resources/groups/client/requests/index.d.ts +1 -1
  79. package/dist/api/resources/groups/types/{GetGroupsResponse.d.ts → GetGroupResponse.d.ts} +1 -1
  80. package/dist/api/resources/groups/types/index.d.ts +1 -2
  81. package/dist/api/resources/groups/types/index.js +1 -2
  82. package/dist/api/resources/index.d.ts +3 -2
  83. package/dist/api/resources/index.js +3 -2
  84. package/dist/api/resources/links/client/Client.d.ts +11 -12
  85. package/dist/api/resources/links/client/Client.js +80 -70
  86. package/dist/api/resources/links/client/requests/{CreateLinksRequest.d.ts → CreateLinkRequest.d.ts} +1 -1
  87. package/dist/api/resources/links/client/requests/{DeleteLinksRequest.d.ts → DeleteLinkRequest.d.ts} +1 -1
  88. package/dist/api/resources/links/client/requests/{GetByParamValueLinksRequest.d.ts → GetLinkByParamValueRequest.d.ts} +1 -1
  89. package/dist/api/resources/links/client/requests/{GetLinksRequest.d.ts → GetLinkRequest.d.ts} +1 -1
  90. package/dist/api/resources/links/client/requests/{UpdateLinksRequest.d.ts → UpdateLinkRequest.d.ts} +1 -1
  91. package/dist/api/resources/links/client/requests/index.d.ts +5 -5
  92. package/dist/api/resources/links/types/{DeleteLinksResponse.d.ts → CreateLinkResponse.d.ts} +1 -1
  93. package/dist/api/resources/links/types/{CreateLinksResponse.d.ts → DeleteLinkResponse.d.ts} +1 -1
  94. package/dist/api/resources/links/types/GetLinkByParamValueResponse.d.ts +6 -0
  95. package/dist/api/resources/links/types/{GetLinksResponse.d.ts → GetLinkResponse.d.ts} +1 -1
  96. package/dist/api/resources/links/types/{UpdateLinksResponse.d.ts → UpdateLinkResponse.d.ts} +1 -1
  97. package/dist/api/resources/links/types/index.d.ts +5 -5
  98. package/dist/api/resources/links/types/index.js +5 -5
  99. package/dist/api/resources/partners/client/Client.d.ts +13 -14
  100. package/dist/api/resources/partners/client/Client.js +82 -72
  101. package/dist/api/resources/partners/client/requests/{ApprovePartnersRequest.d.ts → ApprovePartnerRequest.d.ts} +1 -1
  102. package/dist/api/resources/partners/client/requests/{CreatePartnersRequest.d.ts → CreatePartnerRequest.d.ts} +4 -4
  103. package/dist/api/resources/partners/client/requests/{CreatePartnersRequest.js → CreatePartnerRequest.js} +4 -4
  104. package/dist/api/resources/partners/client/requests/{GetPartnersRequest.d.ts → GetPartnerRequest.d.ts} +1 -1
  105. package/dist/api/resources/partners/client/requests/{RejectPartnersRequest.d.ts → RejectPartnerRequest.d.ts} +1 -1
  106. package/dist/api/resources/partners/client/requests/{SuspendPartnersRequest.d.ts → SuspendPartnerRequest.d.ts} +1 -1
  107. package/dist/api/resources/partners/client/requests/{UpdatePartnersRequest.d.ts → UpdatePartnerRequest.d.ts} +1 -1
  108. package/dist/api/resources/partners/client/requests/index.d.ts +6 -6
  109. package/dist/api/resources/partners/client/requests/index.js +1 -1
  110. package/dist/api/resources/partners/types/{RejectPartnersResponse.d.ts → ApprovePartnerResponse.d.ts} +1 -1
  111. package/dist/api/resources/partners/types/{CreatePartnersResponse.d.ts → CreatePartnerResponse.d.ts} +1 -1
  112. package/dist/api/resources/partners/types/{GetPartnersResponse.d.ts → GetPartnerResponse.d.ts} +1 -1
  113. package/dist/api/resources/partners/types/{UpdatePartnersResponse.d.ts → RejectPartnerResponse.d.ts} +1 -1
  114. package/dist/api/resources/partners/types/{ApprovePartnersResponse.d.ts → SuspendPartnerResponse.d.ts} +1 -1
  115. package/dist/api/resources/partners/types/{SuspendPartnersResponse.d.ts → UpdatePartnerResponse.d.ts} +1 -1
  116. package/dist/api/resources/partners/types/index.d.ts +6 -6
  117. package/dist/api/resources/partners/types/index.js +6 -6
  118. package/dist/api/resources/programs/client/Client.d.ts +3 -4
  119. package/dist/api/resources/programs/client/Client.js +69 -59
  120. package/dist/api/resources/programs/client/requests/{GetProgramsRequest.d.ts → GetProgramRequest.d.ts} +1 -1
  121. package/dist/api/resources/programs/client/requests/index.d.ts +1 -1
  122. package/dist/api/resources/programs/types/{GetProgramsResponse.d.ts → GetProgramResponse.d.ts} +1 -1
  123. package/dist/api/resources/programs/types/index.d.ts +1 -1
  124. package/dist/api/resources/programs/types/index.js +1 -1
  125. package/dist/api/resources/promotionCodes/client/Client.d.ts +9 -10
  126. package/dist/api/resources/promotionCodes/client/Client.js +81 -68
  127. package/dist/api/resources/promotionCodes/client/requests/{CreatePromotionCodesRequest.d.ts → CreatePromotionCodeRequest.d.ts} +3 -3
  128. package/dist/api/resources/promotionCodes/client/requests/{CreatePromotionCodesRequest.js → CreatePromotionCodeRequest.js} +4 -4
  129. package/dist/api/resources/promotionCodes/client/requests/{DeletePromotionCodesRequest.d.ts → DeletePromotionCodeRequest.d.ts} +1 -1
  130. package/dist/api/resources/promotionCodes/client/requests/{GetPromotionCodesRequest.d.ts → GetPromotionCodeRequest.d.ts} +1 -1
  131. package/dist/api/resources/promotionCodes/client/requests/{UpdatePromotionCodesRequest.d.ts → UpdatePromotionCodeRequest.d.ts} +3 -3
  132. package/dist/api/resources/promotionCodes/client/requests/{UpdatePromotionCodesRequest.js → UpdatePromotionCodeRequest.js} +4 -4
  133. package/dist/api/resources/promotionCodes/client/requests/index.d.ts +4 -4
  134. package/dist/api/resources/promotionCodes/client/requests/index.js +2 -2
  135. package/dist/api/resources/promotionCodes/types/{CreatePromotionCodesResponse.d.ts → CreatePromotionCodeResponse.d.ts} +1 -1
  136. package/dist/api/resources/promotionCodes/types/{DeletePromotionCodesResponse.d.ts → DeletePromotionCodeResponse.d.ts} +1 -1
  137. package/dist/api/resources/promotionCodes/types/{GetPromotionCodesResponse.d.ts → GetPromotionCodeResponse.d.ts} +1 -1
  138. package/dist/api/resources/promotionCodes/types/{UpdatePromotionCodesResponse.d.ts → UpdatePromotionCodeResponse.d.ts} +1 -1
  139. package/dist/api/resources/promotionCodes/types/index.d.ts +4 -4
  140. package/dist/api/resources/promotionCodes/types/index.js +4 -4
  141. package/dist/api/resources/reports/client/Client.d.ts +12 -14
  142. package/dist/api/resources/reports/client/Client.js +158 -119
  143. package/dist/api/resources/reports/client/requests/{CustomerStatsReportsRequest.d.ts → ReportsCustomersRequest.d.ts} +1 -1
  144. package/dist/api/resources/reports/client/requests/{LinksReportsRequest.d.ts → ReportsLinksRequest.d.ts} +1 -1
  145. package/dist/api/resources/reports/client/requests/{OverviewReportsRequest.d.ts → ReportsOverviewRequest.d.ts} +1 -1
  146. package/dist/api/resources/reports/client/requests/{PartnersReportsRequest.d.ts → ReportsPartnersRequest.d.ts} +1 -1
  147. package/dist/api/resources/reports/client/requests/{TimeseriesReportsRequest.d.ts → ReportsTimeseriesRequest.d.ts} +1 -1
  148. package/dist/api/resources/reports/client/requests/index.d.ts +5 -5
  149. package/dist/api/resources/reports/types/{CustomerStatsReportsResponse.d.ts → ReportsCustomersResponse.d.ts} +1 -1
  150. package/dist/api/resources/reports/types/{LinksReportsResponse.d.ts → ReportsLinksResponse.d.ts} +1 -1
  151. package/dist/api/resources/reports/types/{OverviewReportsResponse.d.ts → ReportsOverviewResponse.d.ts} +1 -1
  152. package/dist/api/resources/reports/types/{PartnersReportsResponse.d.ts → ReportsPartnersResponse.d.ts} +1 -1
  153. package/dist/api/resources/reports/types/{TimeseriesReportsResponse.d.ts → ReportsTimeseriesResponse.d.ts} +1 -1
  154. package/dist/api/resources/reports/types/index.d.ts +5 -5
  155. package/dist/api/resources/reports/types/index.js +5 -5
  156. package/dist/api/resources/transactions/client/Client.d.ts +13 -14
  157. package/dist/api/resources/transactions/client/Client.js +87 -74
  158. package/dist/api/resources/transactions/client/requests/{CreateTransactionsRequest.d.ts → CreateTransactionRequest.d.ts} +1 -1
  159. package/dist/api/resources/transactions/client/requests/{DeleteTransactionsRequest.d.ts → DeleteTransactionRequest.d.ts} +1 -1
  160. package/dist/api/resources/transactions/client/requests/{GetTransactionsRequest.d.ts → GetTransactionRequest.d.ts} +1 -1
  161. package/dist/api/resources/transactions/client/requests/{RefundTransactionsRequest.d.ts → RefundTransactionRequest.d.ts} +1 -1
  162. package/dist/api/resources/transactions/client/requests/{RerunFlowsTransactionsRequest.d.ts → RerunTransactionFlowsRequest.d.ts} +1 -1
  163. package/dist/api/resources/transactions/client/requests/{UpdateTransactionsRequest.d.ts → UpdateTransactionRequest.d.ts} +1 -1
  164. package/dist/api/resources/transactions/client/requests/index.d.ts +6 -6
  165. package/dist/api/resources/transactions/types/{CreateTransactionsResponse.d.ts → CreateTransactionResponse.d.ts} +1 -1
  166. package/dist/api/resources/transactions/types/{DeleteTransactionsResponse.d.ts → DeleteTransactionResponse.d.ts} +1 -1
  167. package/dist/api/resources/transactions/types/{GetTransactionsResponse.d.ts → GetTransactionResponse.d.ts} +1 -1
  168. package/dist/api/resources/transactions/types/{RefundTransactionsResponse.d.ts → RefundTransactionResponse.d.ts} +1 -1
  169. package/dist/api/resources/transactions/types/{RerunFlowsTransactionsResponse.d.ts → RerunTransactionFlowsResponse.d.ts} +1 -1
  170. package/dist/api/resources/transactions/types/UpdateTransactionResponse.d.ts +6 -0
  171. package/dist/api/resources/transactions/types/index.d.ts +6 -6
  172. package/dist/api/resources/transactions/types/index.js +6 -6
  173. package/dist/api/types/{Error_.d.ts → ErrorResponse.d.ts} +4 -4
  174. package/dist/api/types/{Error_.js → ErrorResponse.js} +4 -4
  175. package/dist/api/types/index.d.ts +1 -1
  176. package/dist/api/types/index.js +1 -1
  177. package/dist/core/exports.d.ts +1 -0
  178. package/dist/core/exports.js +1 -0
  179. package/dist/core/fetcher/Fetcher.js +35 -4
  180. package/dist/core/fetcher/getErrorResponseBody.js +21 -8
  181. package/dist/core/fetcher/getResponseBody.d.ts +16 -0
  182. package/dist/core/fetcher/getResponseBody.js +26 -22
  183. package/dist/core/fetcher/makePassthroughRequest.js +18 -2
  184. package/dist/core/fetcher/makeRequest.d.ts +6 -1
  185. package/dist/core/fetcher/makeRequest.js +45 -13
  186. package/dist/core/fetcher/requestWithRetries.d.ts +1 -1
  187. package/dist/core/fetcher/requestWithRetries.js +23 -2
  188. package/dist/core/fetcher/signals.d.ts +1 -0
  189. package/dist/core/fetcher/signals.js +1 -1
  190. package/dist/core/index.d.ts +2 -0
  191. package/dist/core/index.js +2 -0
  192. package/dist/core/pagination/Page.d.ts +33 -0
  193. package/dist/core/pagination/Page.js +49 -0
  194. package/dist/core/pagination/exports.d.ts +1 -0
  195. package/dist/core/pagination/index.d.ts +1 -0
  196. package/dist/core/pagination/index.js +1 -0
  197. package/dist/core/url/encodePathParam.d.ts +3 -1
  198. package/dist/core/url/encodePathParam.js +8 -2
  199. package/dist/core/utils/index.d.ts +1 -0
  200. package/dist/core/utils/index.js +1 -0
  201. package/dist/core/utils/setObjectProperty.d.ts +12 -0
  202. package/dist/core/utils/setObjectProperty.js +45 -0
  203. package/dist/environments.d.ts +1 -1
  204. package/dist/environments.js +1 -1
  205. package/dist/errors/ToltApiError.js +15 -1
  206. package/package.json +7 -2
  207. package/dist/api/resources/clicks/types/CreateClicksRequest.d.ts +0 -1
  208. package/dist/api/resources/commissions/client/requests/UpdateCommissionsRequest.js +0 -9
  209. package/dist/api/resources/commissions/types/ApproveCommissionsResponse.d.ts +0 -6
  210. package/dist/api/resources/commissions/types/CreateCommissionsRequest.d.ts +0 -1
  211. package/dist/api/resources/commissions/types/DeclineCommissionsResponse.d.ts +0 -6
  212. package/dist/api/resources/embed/exports.d.ts +0 -2
  213. package/dist/api/resources/embed/types/CreateTokenEmbedRequest.d.ts +0 -1
  214. package/dist/api/resources/embed/types/index.d.ts +0 -2
  215. package/dist/api/resources/embed/types/index.js +0 -2
  216. package/dist/api/resources/flows/types/ListFlowsRequestActive.d.ts +0 -6
  217. package/dist/api/resources/flows/types/ListFlowsRequestActive.js +0 -6
  218. package/dist/api/resources/groups/types/ListGroupsRequestDefault.d.ts +0 -6
  219. package/dist/api/resources/groups/types/ListGroupsRequestDefault.js +0 -6
  220. package/dist/api/resources/links/types/GetByParamValueLinksResponse.d.ts +0 -6
  221. package/dist/api/resources/transactions/types/UpdateTransactionsResponse.d.ts +0 -6
  222. package/dist/api/resources/transactions/types/UpdateTransactionsResponse.js +0 -2
  223. /package/dist/api/resources/clicks/client/requests/{GetClicksRequest.js → CreateClickRequest.js} +0 -0
  224. /package/dist/api/resources/clicks/{types/CreateClicksRequest.js → client/requests/GetClickRequest.js} +0 -0
  225. /package/dist/api/resources/clicks/types/{CreateClicksResponse.js → CreateClickResponse.js} +0 -0
  226. /package/dist/api/resources/clicks/types/{GetClicksResponse.js → GetClickResponse.js} +0 -0
  227. /package/dist/api/resources/commissions/client/requests/{ApproveCommissionsRequest.js → ApproveCommissionRequest.js} +0 -0
  228. /package/dist/api/resources/commissions/client/requests/{DeclineCommissionsRequest.js → DeclineCommissionRequest.js} +0 -0
  229. /package/dist/api/resources/commissions/client/requests/{DeleteCommissionsRequest.js → DeleteCommissionRequest.js} +0 -0
  230. /package/dist/api/resources/commissions/client/requests/{GetCommissionsRequest.js → GetCommissionRequest.js} +0 -0
  231. /package/dist/api/resources/commissions/types/{ApproveCommissionsResponse.js → ApproveCommissionResponse.js} +0 -0
  232. /package/dist/api/resources/commissions/types/{CreateCommissionsRequest.js → CreateCommissionResponse.js} +0 -0
  233. /package/dist/api/resources/commissions/types/{CreateCommissionsResponse.js → DeclineCommissionResponse.js} +0 -0
  234. /package/dist/api/resources/commissions/types/{DeclineCommissionsResponse.js → DeleteCommissionResponse.js} +0 -0
  235. /package/dist/api/resources/commissions/types/{DeleteCommissionsResponse.js → GetCommissionResponse.js} +0 -0
  236. /package/dist/api/resources/commissions/types/{GetCommissionsResponse.js → UpdateCommissionResponse.js} +0 -0
  237. /package/dist/api/resources/{commissions/types/UpdateCommissionsResponse.js → customers/client/requests/DeleteCustomerRequest.js} +0 -0
  238. /package/dist/api/resources/customers/client/requests/{DeleteCustomersRequest.js → GetCustomerRequest.js} +0 -0
  239. /package/dist/api/resources/customers/{client/requests/GetCustomersRequest.js → types/CreateCustomerResponse.js} +0 -0
  240. /package/dist/api/resources/customers/types/{CreateCustomersResponse.js → DeleteCustomerResponse.js} +0 -0
  241. /package/dist/api/resources/customers/types/{DeleteCustomersResponse.js → GetCustomerResponse.js} +0 -0
  242. /package/dist/api/resources/customers/types/{GetCustomersResponse.js → UpdateCustomerResponse.js} +0 -0
  243. /package/dist/api/resources/{customers/types/UpdateCustomersResponse.js → embedTokens/client/requests/CreateEmbedTokenRequest.js} +0 -0
  244. /package/dist/api/resources/{embed/client → embedTokens/client/requests}/index.js +0 -0
  245. /package/dist/api/resources/{embed → embedTokens}/index.d.ts +0 -0
  246. /package/dist/api/resources/{embed → embedTokens}/index.js +0 -0
  247. /package/dist/api/resources/{embed/types/CreateTokenEmbedRequest.js → embedTokens/types/CreateEmbedTokenResponse.js} +0 -0
  248. /package/dist/api/resources/{embed/types/CreateTokenEmbedResponse.js → flows/client/requests/GetFlowRequest.js} +0 -0
  249. /package/dist/api/resources/flows/{client/requests/GetFlowsRequest.js → types/GetFlowResponse.js} +0 -0
  250. /package/dist/api/resources/{flows/types/GetFlowsResponse.js → groups/client/requests/GetGroupRequest.js} +0 -0
  251. /package/dist/api/resources/groups/{client/requests/GetGroupsRequest.js → types/GetGroupResponse.js} +0 -0
  252. /package/dist/api/resources/{groups/types/GetGroupsResponse.js → links/client/requests/CreateLinkRequest.js} +0 -0
  253. /package/dist/api/resources/links/client/requests/{CreateLinksRequest.js → DeleteLinkRequest.js} +0 -0
  254. /package/dist/api/resources/links/client/requests/{DeleteLinksRequest.js → GetLinkByParamValueRequest.js} +0 -0
  255. /package/dist/api/resources/links/client/requests/{GetByParamValueLinksRequest.js → GetLinkRequest.js} +0 -0
  256. /package/dist/api/resources/links/client/requests/{GetLinksRequest.js → UpdateLinkRequest.js} +0 -0
  257. /package/dist/api/resources/links/{client/requests/UpdateLinksRequest.js → types/CreateLinkResponse.js} +0 -0
  258. /package/dist/api/resources/links/types/{CreateLinksResponse.js → DeleteLinkResponse.js} +0 -0
  259. /package/dist/api/resources/links/types/{DeleteLinksResponse.js → GetLinkByParamValueResponse.js} +0 -0
  260. /package/dist/api/resources/links/types/{GetByParamValueLinksResponse.js → GetLinkResponse.js} +0 -0
  261. /package/dist/api/resources/links/types/{GetLinksResponse.js → UpdateLinkResponse.js} +0 -0
  262. /package/dist/api/resources/{links/types/UpdateLinksResponse.js → partners/client/requests/ApprovePartnerRequest.js} +0 -0
  263. /package/dist/api/resources/partners/client/requests/{ApprovePartnersRequest.js → GetPartnerRequest.js} +0 -0
  264. /package/dist/api/resources/partners/client/requests/{GetPartnersRequest.js → RejectPartnerRequest.js} +0 -0
  265. /package/dist/api/resources/partners/client/requests/{RejectPartnersRequest.js → SuspendPartnerRequest.js} +0 -0
  266. /package/dist/api/resources/partners/client/requests/{SuspendPartnersRequest.js → UpdatePartnerRequest.js} +0 -0
  267. /package/dist/api/resources/partners/{client/requests/UpdatePartnersRequest.js → types/ApprovePartnerResponse.js} +0 -0
  268. /package/dist/api/resources/partners/types/{ApprovePartnersResponse.js → CreatePartnerResponse.js} +0 -0
  269. /package/dist/api/resources/partners/types/{CreatePartnersResponse.js → GetPartnerResponse.js} +0 -0
  270. /package/dist/api/resources/partners/types/{GetPartnersResponse.js → RejectPartnerResponse.js} +0 -0
  271. /package/dist/api/resources/partners/types/{RejectPartnersResponse.js → SuspendPartnerResponse.js} +0 -0
  272. /package/dist/api/resources/partners/types/{SuspendPartnersResponse.js → UpdatePartnerResponse.js} +0 -0
  273. /package/dist/api/resources/{partners/types/UpdatePartnersResponse.js → programs/client/requests/GetProgramRequest.js} +0 -0
  274. /package/dist/api/resources/programs/{client/requests/GetProgramsRequest.js → types/GetProgramResponse.js} +0 -0
  275. /package/dist/api/resources/{programs/types/GetProgramsResponse.js → promotionCodes/client/requests/DeletePromotionCodeRequest.js} +0 -0
  276. /package/dist/api/resources/promotionCodes/client/requests/{DeletePromotionCodesRequest.js → GetPromotionCodeRequest.js} +0 -0
  277. /package/dist/api/resources/promotionCodes/{client/requests/GetPromotionCodesRequest.js → types/CreatePromotionCodeResponse.js} +0 -0
  278. /package/dist/api/resources/promotionCodes/types/{CreatePromotionCodesResponse.js → DeletePromotionCodeResponse.js} +0 -0
  279. /package/dist/api/resources/promotionCodes/types/{DeletePromotionCodesResponse.js → GetPromotionCodeResponse.js} +0 -0
  280. /package/dist/api/resources/promotionCodes/types/{GetPromotionCodesResponse.js → UpdatePromotionCodeResponse.js} +0 -0
  281. /package/dist/api/resources/{promotionCodes/types/UpdatePromotionCodesResponse.js → reports/client/requests/ReportsCustomersRequest.js} +0 -0
  282. /package/dist/api/resources/reports/client/requests/{CustomerStatsReportsRequest.js → ReportsLinksRequest.js} +0 -0
  283. /package/dist/api/resources/reports/client/requests/{LinksReportsRequest.js → ReportsOverviewRequest.js} +0 -0
  284. /package/dist/api/resources/reports/client/requests/{OverviewReportsRequest.js → ReportsPartnersRequest.js} +0 -0
  285. /package/dist/api/resources/reports/client/requests/{PartnersReportsRequest.js → ReportsTimeseriesRequest.js} +0 -0
  286. /package/dist/api/resources/reports/{client/requests/TimeseriesReportsRequest.js → types/ReportsCustomersResponse.js} +0 -0
  287. /package/dist/api/resources/reports/types/{CustomerStatsReportsResponse.js → ReportsLinksResponse.js} +0 -0
  288. /package/dist/api/resources/reports/types/{LinksReportsResponse.js → ReportsOverviewResponse.js} +0 -0
  289. /package/dist/api/resources/reports/types/{OverviewReportsResponse.js → ReportsPartnersResponse.js} +0 -0
  290. /package/dist/api/resources/reports/types/{PartnersReportsResponse.js → ReportsTimeseriesResponse.js} +0 -0
  291. /package/dist/api/resources/{reports/types/TimeseriesReportsResponse.js → transactions/client/requests/CreateTransactionRequest.js} +0 -0
  292. /package/dist/api/resources/transactions/client/requests/{CreateTransactionsRequest.js → DeleteTransactionRequest.js} +0 -0
  293. /package/dist/api/resources/transactions/client/requests/{DeleteTransactionsRequest.js → GetTransactionRequest.js} +0 -0
  294. /package/dist/api/resources/transactions/client/requests/{GetTransactionsRequest.js → RefundTransactionRequest.js} +0 -0
  295. /package/dist/api/resources/transactions/client/requests/{RefundTransactionsRequest.js → RerunTransactionFlowsRequest.js} +0 -0
  296. /package/dist/api/resources/transactions/client/requests/{RerunFlowsTransactionsRequest.js → UpdateTransactionRequest.js} +0 -0
  297. /package/dist/api/resources/transactions/{client/requests/UpdateTransactionsRequest.js → types/CreateTransactionResponse.js} +0 -0
  298. /package/dist/api/resources/transactions/types/{CreateTransactionsResponse.js → DeleteTransactionResponse.js} +0 -0
  299. /package/dist/api/resources/transactions/types/{DeleteTransactionsResponse.js → GetTransactionResponse.js} +0 -0
  300. /package/dist/api/resources/transactions/types/{GetTransactionsResponse.js → RefundTransactionResponse.js} +0 -0
  301. /package/dist/api/resources/transactions/types/{RefundTransactionsResponse.js → RerunTransactionFlowsResponse.js} +0 -0
  302. /package/dist/api/resources/transactions/types/{RerunFlowsTransactionsResponse.js → UpdateTransactionResponse.js} +0 -0
  303. /package/dist/{api/resources/embed/client/index.d.ts → core/pagination/exports.js} +0 -0
@@ -9,6 +9,19 @@ function retainResponse(target, response) {
9
9
  writable: false,
10
10
  });
11
11
  }
12
+ const responseBodyErrors = new WeakSet();
13
+ function responseBodyError(error) {
14
+ const record = { ok: false, error };
15
+ responseBodyErrors.add(record);
16
+ return record;
17
+ }
18
+ /**
19
+ * Returns true when `value` is a failure record created by `getResponseBody` (for example malformed JSON),
20
+ * as opposed to a parsed JSON body that happens to have the same shape.
21
+ */
22
+ export function isResponseBodyError(value) {
23
+ return typeof value === "object" && value != null && responseBodyErrors.has(value);
24
+ }
12
25
  export async function getResponseBody(response, responseType) {
13
26
  switch (responseType) {
14
27
  case "binary-response":
@@ -19,25 +32,19 @@ export async function getResponseBody(response, responseType) {
19
32
  return await response.arrayBuffer();
20
33
  case "sse":
21
34
  if (response.body == null) {
22
- return {
23
- ok: false,
24
- error: {
25
- reason: "body-is-null",
26
- statusCode: response.status,
27
- },
28
- };
35
+ return responseBodyError({
36
+ reason: "body-is-null",
37
+ statusCode: response.status,
38
+ });
29
39
  }
30
40
  retainResponse(response.body, response);
31
41
  return response.body;
32
42
  case "streaming":
33
43
  if (response.body == null) {
34
- return {
35
- ok: false,
36
- error: {
37
- reason: "body-is-null",
38
- statusCode: response.status,
39
- },
40
- };
44
+ return responseBodyError({
45
+ reason: "body-is-null",
46
+ statusCode: response.status,
47
+ });
41
48
  }
42
49
  retainResponse(response.body, response);
43
50
  return response.body;
@@ -52,14 +59,11 @@ export async function getResponseBody(response, responseType) {
52
59
  return responseBody;
53
60
  }
54
61
  catch (_err) {
55
- return {
56
- ok: false,
57
- error: {
58
- reason: "non-json",
59
- statusCode: response.status,
60
- rawBody: text,
61
- },
62
- };
62
+ return responseBodyError({
63
+ reason: "non-json",
64
+ statusCode: response.status,
65
+ rawBody: text,
66
+ });
63
67
  }
64
68
  }
65
69
  return undefined;
@@ -6,6 +6,7 @@ import { makeRequest } from "./makeRequest.js";
6
6
  import { redactUrl } from "./redactUrl.js";
7
7
  import { requestWithRetries } from "./requestWithRetries.js";
8
8
  import { Supplier } from "./Supplier.js";
9
+ import { TIMEOUT } from "./signals.js";
9
10
  /**
10
11
  * Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
11
12
  * while mimicking the standard `fetch` API.
@@ -109,8 +110,18 @@ export async function makePassthroughRequest(input, init, clientOptions, request
109
110
  hasBody: body != null,
110
111
  });
111
112
  }
112
- const response = await requestWithRetries(async () => makeRequest(fetchFn, fullUrl, method, mergedHeaders, body ?? undefined, timeoutMs, abortSignal, effectiveInit?.credentials === "include", undefined, // duplex
113
- false), maxRetries);
113
+ let response;
114
+ try {
115
+ response = await requestWithRetries(async () => makeRequest(fetchFn, fullUrl, method, mergedHeaders, body ?? undefined, timeoutMs, abortSignal, effectiveInit?.credentials === "include", undefined, // duplex
116
+ false), maxRetries, abortSignal);
117
+ }
118
+ catch (error) {
119
+ // Match `fetch`: a timeout rejects with an Error named "TimeoutError", not the bare abort reason.
120
+ if (error === TIMEOUT) {
121
+ throw createTimeoutError();
122
+ }
123
+ throw error;
124
+ }
114
125
  if (logger.isDebug()) {
115
126
  logger.debug("Passthrough HTTP request completed", {
116
127
  method,
@@ -120,6 +131,11 @@ export async function makePassthroughRequest(input, init, clientOptions, request
120
131
  }
121
132
  return response;
122
133
  }
134
+ function createTimeoutError() {
135
+ const error = new Error("The request timed out.");
136
+ error.name = "TimeoutError";
137
+ return error;
138
+ }
123
139
  /**
124
140
  * Returns true when the resolved request URL points at the same origin as the
125
141
  * configured base URL. Relative paths are always joined onto the base URL, so
@@ -3,4 +3,9 @@ export declare function isCacheNoStoreSupported(): boolean;
3
3
  * Reset the cached result of `isCacheNoStoreSupported`. Exposed for testing only.
4
4
  */
5
5
  export declare function resetCacheNoStoreSupported(): void;
6
- export declare const makeRequest: (fetchFn: (url: string, init: RequestInit) => Promise<Response>, url: string, method: string, headers: Headers | Record<string, string>, requestBody: BodyInit | undefined, timeoutMs?: number, abortSignal?: AbortSignal, withCredentials?: boolean, duplex?: "half", disableCache?: boolean) => Promise<Response>;
6
+ /**
7
+ * Clears the timeout that `makeRequest` kept running (with `keepTimeoutUntilBodyRead`) so that it also
8
+ * covered reading the response body.
9
+ */
10
+ export declare function clearResponseTimeout(response: Response): void;
11
+ export declare const makeRequest: (fetchFn: (url: string, init: RequestInit) => Promise<Response>, url: string, method: string, headers: Headers | Record<string, string>, requestBody: BodyInit | undefined, timeoutMs?: number, abortSignal?: AbortSignal, withCredentials?: boolean, duplex?: "half", disableCache?: boolean, keepTimeoutUntilBodyRead?: boolean) => Promise<Response>;
@@ -1,4 +1,4 @@
1
- import { anySignal, getTimeoutSignal } from "./signals.js";
1
+ import { anySignal, getTimeoutSignal, TIMEOUT } from "./signals.js";
2
2
  /**
3
3
  * Cached result of checking whether the current runtime supports
4
4
  * the `cache` option in `Request`. Some runtimes (e.g. Cloudflare Workers)
@@ -24,30 +24,62 @@ export function isCacheNoStoreSupported() {
24
24
  export function resetCacheNoStoreSupported() {
25
25
  _cacheNoStoreSupported = undefined;
26
26
  }
27
- export const makeRequest = async (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex, disableCache) => {
27
+ const responseTimeouts = new WeakMap();
28
+ /**
29
+ * Clears the timeout that `makeRequest` kept running (with `keepTimeoutUntilBodyRead`) so that it also
30
+ * covered reading the response body.
31
+ */
32
+ export function clearResponseTimeout(response) {
33
+ const timeoutId = responseTimeouts.get(response);
34
+ if (timeoutId != null) {
35
+ clearTimeout(timeoutId);
36
+ responseTimeouts.delete(response);
37
+ }
38
+ }
39
+ export const makeRequest = async (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex, disableCache, keepTimeoutUntilBodyRead) => {
28
40
  const signals = [];
29
41
  let timeoutAbortId;
42
+ let timeoutSignal;
30
43
  if (timeoutMs != null) {
31
44
  const { signal, abortId } = getTimeoutSignal(timeoutMs);
32
45
  timeoutAbortId = abortId;
46
+ timeoutSignal = signal;
33
47
  signals.push(signal);
34
48
  }
35
49
  if (abortSignal != null) {
36
50
  signals.push(abortSignal);
37
51
  }
38
52
  const newSignals = anySignal(signals);
39
- const response = await fetchFn(url, {
40
- method: method,
41
- headers,
42
- body: requestBody,
43
- signal: newSignals,
44
- credentials: withCredentials ? "include" : undefined,
45
- // @ts-ignore
46
- duplex,
47
- ...(disableCache && isCacheNoStoreSupported() ? { cache: "no-store" } : {}),
48
- });
53
+ let response;
54
+ try {
55
+ response = await fetchFn(url, {
56
+ method: method,
57
+ headers,
58
+ body: requestBody,
59
+ signal: newSignals,
60
+ credentials: withCredentials ? "include" : undefined,
61
+ // @ts-ignore
62
+ duplex,
63
+ ...(disableCache && isCacheNoStoreSupported() ? { cache: "no-store" } : {}),
64
+ });
65
+ }
66
+ catch (error) {
67
+ if (timeoutAbortId != null) {
68
+ clearTimeout(timeoutAbortId);
69
+ }
70
+ // Some runtimes (e.g. Node 18) reject with their own error instead of the abort reason.
71
+ if (timeoutSignal?.aborted && !abortSignal?.aborted) {
72
+ throw TIMEOUT;
73
+ }
74
+ throw error;
75
+ }
49
76
  if (timeoutAbortId != null) {
50
- clearTimeout(timeoutAbortId);
77
+ if (keepTimeoutUntilBodyRead) {
78
+ responseTimeouts.set(response, timeoutAbortId);
79
+ }
80
+ else {
81
+ clearTimeout(timeoutAbortId);
82
+ }
51
83
  }
52
84
  return response;
53
85
  };
@@ -1 +1 @@
1
- export declare function requestWithRetries(requestFn: () => Promise<Response>, maxRetries?: number): Promise<Response>;
1
+ export declare function requestWithRetries(requestFn: () => Promise<Response>, maxRetries?: number, abortSignal?: AbortSignal): Promise<Response>;
@@ -40,12 +40,33 @@ function getRetryDelayFromHeaders(response, retryAttempt) {
40
40
  }
41
41
  return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * 2 ** retryAttempt, MAX_RETRY_DELAY));
42
42
  }
43
- export async function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
43
+ /**
44
+ * Waits `ms` milliseconds, or rejects as soon as `abortSignal` aborts. The timer and
45
+ * the abort listener are always removed, so a cancelled wait never keeps the process alive.
46
+ */
47
+ function sleep(ms, abortSignal) {
48
+ return new Promise((resolve, reject) => {
49
+ if (abortSignal?.aborted) {
50
+ reject(abortSignal.reason);
51
+ return;
52
+ }
53
+ const onAbort = () => {
54
+ clearTimeout(timeoutId);
55
+ reject(abortSignal?.reason);
56
+ };
57
+ const timeoutId = setTimeout(() => {
58
+ abortSignal?.removeEventListener("abort", onAbort);
59
+ resolve();
60
+ }, ms);
61
+ abortSignal?.addEventListener("abort", onAbort, { once: true });
62
+ });
63
+ }
64
+ export async function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES, abortSignal) {
44
65
  let response = await requestFn();
45
66
  for (let i = 0; i < maxRetries; ++i) {
46
67
  if (isRetryableStatusCode(response.status)) {
47
68
  const delay = getRetryDelayFromHeaders(response, i);
48
- await new Promise((resolve) => setTimeout(resolve, delay));
69
+ await sleep(delay, abortSignal);
49
70
  response = await requestFn();
50
71
  }
51
72
  else {
@@ -1,3 +1,4 @@
1
+ export declare const TIMEOUT = "timeout";
1
2
  export declare function getTimeoutSignal(timeoutMs: number): {
2
3
  signal: AbortSignal;
3
4
  abortId: ReturnType<typeof setTimeout>;
@@ -1,4 +1,4 @@
1
- const TIMEOUT = "timeout";
1
+ export const TIMEOUT = "timeout";
2
2
  export function getTimeoutSignal(timeoutMs) {
3
3
  const controller = new AbortController();
4
4
  const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
@@ -2,5 +2,7 @@ export * from "./auth/index.js";
2
2
  export * from "./base64.js";
3
3
  export * from "./fetcher/index.js";
4
4
  export * as logging from "./logging/index.js";
5
+ export * from "./pagination/index.js";
5
6
  export * from "./runtime/index.js";
6
7
  export * as url from "./url/index.js";
8
+ export * from "./utils/index.js";
@@ -2,5 +2,7 @@ export * from "./auth/index.js";
2
2
  export * from "./base64.js";
3
3
  export * from "./fetcher/index.js";
4
4
  export * as logging from "./logging/index.js";
5
+ export * from "./pagination/index.js";
5
6
  export * from "./runtime/index.js";
6
7
  export * as url from "./url/index.js";
8
+ export * from "./utils/index.js";
@@ -0,0 +1,33 @@
1
+ import type { HttpResponsePromise, RawResponse } from "../fetcher/index.js";
2
+ /**
3
+ * A page of results from a paginated API.
4
+ *
5
+ * @template T The type of the items in the page.
6
+ * @template R The type of the API response.
7
+ */
8
+ export declare class Page<T, R = unknown> implements AsyncIterable<T> {
9
+ data: T[];
10
+ rawResponse: RawResponse;
11
+ response: R;
12
+ private _hasNextPage;
13
+ private getItems;
14
+ private loadNextPage;
15
+ constructor({ response, rawResponse, hasNextPage, getItems, loadPage, }: {
16
+ response: R;
17
+ rawResponse: RawResponse;
18
+ hasNextPage: (response: R) => boolean;
19
+ getItems: (response: R) => T[];
20
+ loadPage: (response: R) => HttpResponsePromise<R>;
21
+ });
22
+ /**
23
+ * Retrieves the next page
24
+ * @returns this
25
+ */
26
+ getNextPage(): Promise<this>;
27
+ /**
28
+ * @returns whether there is a next page to load
29
+ */
30
+ hasNextPage(): boolean;
31
+ private iterMessages;
32
+ [Symbol.asyncIterator](): AsyncIterator<T, void, unknown>;
33
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * A page of results from a paginated API.
3
+ *
4
+ * @template T The type of the items in the page.
5
+ * @template R The type of the API response.
6
+ */
7
+ export class Page {
8
+ constructor({ response, rawResponse, hasNextPage, getItems, loadPage, }) {
9
+ this.response = response;
10
+ this.rawResponse = rawResponse;
11
+ this.data = getItems(response);
12
+ this._hasNextPage = hasNextPage;
13
+ this.getItems = getItems;
14
+ this.loadNextPage = loadPage;
15
+ }
16
+ /**
17
+ * Retrieves the next page
18
+ * @returns this
19
+ */
20
+ async getNextPage() {
21
+ const { data, rawResponse } = await this.loadNextPage(this.response).withRawResponse();
22
+ this.response = data;
23
+ this.rawResponse = rawResponse;
24
+ this.data = this.getItems(this.response);
25
+ return this;
26
+ }
27
+ /**
28
+ * @returns whether there is a next page to load
29
+ */
30
+ hasNextPage() {
31
+ return this._hasNextPage(this.response);
32
+ }
33
+ async *iterMessages() {
34
+ for (const item of this.data) {
35
+ yield item;
36
+ }
37
+ while (this.hasNextPage()) {
38
+ await this.getNextPage();
39
+ for (const item of this.data) {
40
+ yield item;
41
+ }
42
+ }
43
+ }
44
+ async *[Symbol.asyncIterator]() {
45
+ for await (const message of this.iterMessages()) {
46
+ yield message;
47
+ }
48
+ }
49
+ }
@@ -0,0 +1 @@
1
+ export type { Page } from "./Page.js";
@@ -0,0 +1 @@
1
+ export { Page } from "./Page.js";
@@ -0,0 +1 @@
1
+ export { Page } from "./Page.js";
@@ -1 +1,3 @@
1
- export declare function encodePathParam(param: unknown): string;
1
+ export declare function encodePathParam(param: unknown, InvalidPathParameterError?: new (args: {
2
+ message: string;
3
+ }) => Error): string;
@@ -1,4 +1,4 @@
1
- export function encodePathParam(param) {
1
+ export function encodePathParam(param, InvalidPathParameterError) {
2
2
  if (param === null) {
3
3
  return "null";
4
4
  }
@@ -14,5 +14,11 @@ export function encodePathParam(param) {
14
14
  param = String(param);
15
15
  break;
16
16
  }
17
- return encodeURIComponent(param);
17
+ const encoded = encodeURIComponent(param);
18
+ // "." and ".." are dot segments: URL resolution would remove them and send the request to a different path.
19
+ if (encoded === "." || encoded === "..") {
20
+ const message = `Invalid path parameter "${encoded}": "." and ".." are not allowed because they change the request path.`;
21
+ throw InvalidPathParameterError != null ? new InvalidPathParameterError({ message }) : new Error(message);
22
+ }
23
+ return encoded;
18
24
  }
@@ -0,0 +1 @@
1
+ export { setObjectProperty } from "./setObjectProperty.js";
@@ -0,0 +1 @@
1
+ export { setObjectProperty } from "./setObjectProperty.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns a copy of object with the value at path set. If a portion of path doesn’t exist it’s created.
3
+ * Each object along path is shallow-copied, so the original object (and any nested objects it
4
+ * shares with the copy) is never modified. This is inspired by Lodash's set function, but is
5
+ * simplified to accommodate our use case. For more details, see https://lodash.com/docs/4.17.15#set.
6
+ *
7
+ * @param object The object to copy.
8
+ * @param path The path of the property to set.
9
+ * @param value The value to set.
10
+ * @return Returns the updated copy of object.
11
+ */
12
+ export declare function setObjectProperty<T extends object>(object: T, path: string, value: any): T;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Returns a copy of object with the value at path set. If a portion of path doesn’t exist it’s created.
3
+ * Each object along path is shallow-copied, so the original object (and any nested objects it
4
+ * shares with the copy) is never modified. This is inspired by Lodash's set function, but is
5
+ * simplified to accommodate our use case. For more details, see https://lodash.com/docs/4.17.15#set.
6
+ *
7
+ * @param object The object to copy.
8
+ * @param path The path of the property to set.
9
+ * @param value The value to set.
10
+ * @return Returns the updated copy of object.
11
+ */
12
+ export function setObjectProperty(object, path, value) {
13
+ if (object == null) {
14
+ return object;
15
+ }
16
+ const keys = path.split(".");
17
+ if (keys.length === 0) {
18
+ // Invalid path; do nothing.
19
+ return object;
20
+ }
21
+ const result = { ...object };
22
+ let current = result;
23
+ for (let i = 0; i < keys.length - 1; i++) {
24
+ const key = keys[i];
25
+ if (key == null) {
26
+ // Unreachable.
27
+ continue;
28
+ }
29
+ const next = current[key];
30
+ if (Array.isArray(next)) {
31
+ current[key] = [...next];
32
+ }
33
+ else {
34
+ current[key] = next != null && typeof next === "object" ? { ...next } : {};
35
+ }
36
+ current = current[key];
37
+ }
38
+ const lastKey = keys[keys.length - 1];
39
+ if (lastKey == null) {
40
+ // Unreachable.
41
+ return result;
42
+ }
43
+ current[lastKey] = value;
44
+ return result;
45
+ }
@@ -1,4 +1,4 @@
1
1
  export declare const ToltApiEnvironment: {
2
- readonly Default: "https://platform.tolt.dev";
2
+ readonly Default: "https://platform.tolt.com";
3
3
  };
4
4
  export type ToltApiEnvironment = typeof ToltApiEnvironment.Default;
@@ -1,4 +1,4 @@
1
1
  // This file was auto-generated by Fern from our API Definition.
2
2
  export const ToltApiEnvironment = {
3
- Default: "https://platform.tolt.dev",
3
+ Default: "https://platform.tolt.com",
4
4
  };
@@ -16,7 +16,21 @@ export class ToltApiError extends Error {
16
16
  }
17
17
  }
18
18
  get requestId() {
19
- return this.rawResponse?.headers?.get("x-request-id") ?? undefined;
19
+ const headers = this.rawResponse?.headers;
20
+ if (headers == null) {
21
+ return undefined;
22
+ }
23
+ const requestId = headers.get("X-Request-Id");
24
+ if (requestId != null) {
25
+ return requestId;
26
+ }
27
+ let fallback;
28
+ headers.forEach((value, name) => {
29
+ if (fallback === undefined && /request[-_]?id$/i.test(name)) {
30
+ fallback = value;
31
+ }
32
+ });
33
+ return fallback;
20
34
  }
21
35
  }
22
36
  function buildMessage({ message, statusCode, body, }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolt/api",
3
- "version": "0.7.0",
3
+ "version": "1.1.0",
4
4
  "description": "TypeScript SDK for the Tolt Public API",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -13,6 +13,9 @@
13
13
  },
14
14
  "type": "module",
15
15
  "sideEffects": false,
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
16
19
  "main": "./dist/index.js",
17
20
  "types": "./dist/index.d.ts",
18
21
  "exports": {
@@ -31,11 +34,13 @@
31
34
  },
32
35
  "scripts": {
33
36
  "build": "tsc -p tsconfig.json",
34
- "prepare": "npm run build"
37
+ "prepare": "npm run build",
38
+ "test": "node --test test/client.test.mjs"
35
39
  },
36
40
  "devDependencies": {
37
41
  "@semantic-release/changelog": "^7.0.0",
38
42
  "@semantic-release/commit-analyzer": "^13.0.1",
43
+ "@semantic-release/exec": "^7.1.0",
39
44
  "@semantic-release/git": "^11.0.1",
40
45
  "@semantic-release/github": "^12.0.9",
41
46
  "@semantic-release/npm": "^13.1.5",
@@ -1 +0,0 @@
1
- export type CreateClicksRequest = unknown;
@@ -1,9 +0,0 @@
1
- // This file was auto-generated by Fern from our API Definition.
2
- export var UpdateCommissionsRequest;
3
- (function (UpdateCommissionsRequest) {
4
- UpdateCommissionsRequest.Status = {
5
- Pending: "pending",
6
- Approved: "approved",
7
- Rejected: "rejected",
8
- };
9
- })(UpdateCommissionsRequest || (UpdateCommissionsRequest = {}));
@@ -1,6 +0,0 @@
1
- import type * as ToltApi from "../../../index.js";
2
- export interface ApproveCommissionsResponse {
3
- success: boolean;
4
- message: string;
5
- data: ToltApi.Commission;
6
- }
@@ -1 +0,0 @@
1
- export type CreateCommissionsRequest = unknown;
@@ -1,6 +0,0 @@
1
- import type * as ToltApi from "../../../index.js";
2
- export interface DeclineCommissionsResponse {
3
- success: boolean;
4
- message: string;
5
- data: ToltApi.Commission;
6
- }
@@ -1,2 +0,0 @@
1
- export { EmbedClient } from "./client/Client.js";
2
- export * from "./client/index.js";
@@ -1 +0,0 @@
1
- export type CreateTokenEmbedRequest = unknown;
@@ -1,2 +0,0 @@
1
- export * from "./CreateTokenEmbedRequest.js";
2
- export * from "./CreateTokenEmbedResponse.js";
@@ -1,2 +0,0 @@
1
- export * from "./CreateTokenEmbedRequest.js";
2
- export * from "./CreateTokenEmbedResponse.js";
@@ -1,6 +0,0 @@
1
- /** true lists only active flows, false only paused flows, which do not run. */
2
- export declare const ListFlowsRequestActive: {
3
- readonly True: "true";
4
- readonly False: "false";
5
- };
6
- export type ListFlowsRequestActive = (typeof ListFlowsRequestActive)[keyof typeof ListFlowsRequestActive];
@@ -1,6 +0,0 @@
1
- // This file was auto-generated by Fern from our API Definition.
2
- /** true lists only active flows, false only paused flows, which do not run. */
3
- export const ListFlowsRequestActive = {
4
- True: "true",
5
- False: "false",
6
- };
@@ -1,6 +0,0 @@
1
- /** true lists only default groups, where new partners are placed unless another group is chosen; false lists the others. */
2
- export declare const ListGroupsRequestDefault: {
3
- readonly True: "true";
4
- readonly False: "false";
5
- };
6
- export type ListGroupsRequestDefault = (typeof ListGroupsRequestDefault)[keyof typeof ListGroupsRequestDefault];
@@ -1,6 +0,0 @@
1
- // This file was auto-generated by Fern from our API Definition.
2
- /** true lists only default groups, where new partners are placed unless another group is chosen; false lists the others. */
3
- export const ListGroupsRequestDefault = {
4
- True: "true",
5
- False: "false",
6
- };
@@ -1,6 +0,0 @@
1
- import type * as ToltApi from "../../../index.js";
2
- export interface GetByParamValueLinksResponse {
3
- success: boolean;
4
- message: string;
5
- data: ToltApi.Link;
6
- }
@@ -1,6 +0,0 @@
1
- import type * as ToltApi from "../../../index.js";
2
- export interface UpdateTransactionsResponse {
3
- success: boolean;
4
- message: string;
5
- data: ToltApi.Transaction;
6
- }
@@ -1,2 +0,0 @@
1
- // This file was auto-generated by Fern from our API Definition.
2
- export {};