@trycourier/courier 6.3.1 → 6.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (425) hide show
  1. package/Client.d.ts +49 -108
  2. package/Client.js +89 -148
  3. package/README.md +113 -808
  4. package/api/client/requests/SendMessageRequest.d.ts +8 -76
  5. package/api/resources/audiences/client/Client.d.ts +26 -21
  6. package/api/resources/audiences/client/Client.js +97 -90
  7. package/api/resources/audiences/client/requests/AudienceMembersListParams.d.ts +1 -3
  8. package/api/resources/audiences/client/requests/AudienceUpdateParams.d.ts +3 -7
  9. package/api/resources/audiences/client/requests/AudiencesListParams.d.ts +1 -3
  10. package/api/resources/audiences/types/ComparisonOperator.d.ts +1 -1
  11. package/api/resources/audiences/types/Filter.d.ts +1 -1
  12. package/api/resources/audiences/types/FilterConfig.d.ts +1 -1
  13. package/api/resources/audiences/types/LogicalOperator.d.ts +1 -1
  14. package/api/resources/audiences/types/Operator.d.ts +1 -1
  15. package/api/resources/auditEvents/client/Client.d.ts +14 -6
  16. package/api/resources/auditEvents/client/Client.js +48 -38
  17. package/api/resources/auditEvents/client/requests/ListAuditEventsRequest.d.ts +1 -3
  18. package/api/resources/authTokens/client/Client.d.ts +13 -4
  19. package/api/resources/authTokens/client/Client.js +35 -26
  20. package/api/resources/authTokens/client/requests/IssueTokenParams.d.ts +2 -2
  21. package/api/resources/automations/client/Client.d.ts +19 -15
  22. package/api/resources/automations/client/Client.js +52 -50
  23. package/api/resources/automations/types/AutomationAddToBatchMaxItemsType.d.ts +1 -1
  24. package/api/resources/automations/types/AutomationAddToBatchRetainType.d.ts +1 -1
  25. package/api/resources/automations/types/AutomationAddToBatchScope.d.ts +1 -1
  26. package/api/resources/automations/types/AutomationFetchDataWebhookMethod.d.ts +1 -1
  27. package/api/resources/automations/types/AutomationStepOption.d.ts +1 -1
  28. package/api/resources/automations/types/AutomationThrottleScope.d.ts +1 -1
  29. package/api/resources/automations/types/MergeAlgorithm.d.ts +1 -1
  30. package/api/resources/automations/types/Profile.d.ts +1 -1
  31. package/api/resources/brands/client/Client.d.ts +32 -63
  32. package/api/resources/brands/client/Client.js +103 -134
  33. package/api/resources/brands/client/requests/BrandUpdateParameters.d.ts +3 -26
  34. package/api/resources/brands/client/requests/ListBrandsRequest.d.ts +1 -3
  35. package/api/resources/bulk/client/Client.d.ts +40 -126
  36. package/api/resources/bulk/client/Client.js +111 -201
  37. package/api/resources/bulk/client/requests/BulkCreateJobParams.d.ts +6 -86
  38. package/api/resources/bulk/client/requests/BulkGetUsersParams.d.ts +1 -3
  39. package/api/resources/bulk/types/BulkJobStatus.d.ts +1 -1
  40. package/api/resources/bulk/types/BulkJobUserStatus.d.ts +1 -1
  41. package/api/resources/bulk/types/InboundBulkMessageV2.d.ts +3 -5
  42. package/api/resources/commons/errors/AlreadyExistsError.d.ts +2 -1
  43. package/api/resources/commons/errors/AlreadyExistsError.js +19 -8
  44. package/api/resources/commons/errors/BadRequestError.d.ts +2 -1
  45. package/api/resources/commons/errors/BadRequestError.js +19 -8
  46. package/api/resources/commons/errors/ConflictError.d.ts +2 -1
  47. package/api/resources/commons/errors/ConflictError.js +19 -8
  48. package/api/resources/commons/errors/MessageNotFoundError.d.ts +2 -1
  49. package/api/resources/commons/errors/MessageNotFoundError.js +19 -8
  50. package/api/resources/commons/errors/NotFoundError.d.ts +2 -1
  51. package/api/resources/commons/errors/NotFoundError.js +19 -8
  52. package/api/resources/commons/errors/PaymentRequiredError.d.ts +2 -1
  53. package/api/resources/commons/errors/PaymentRequiredError.js +19 -8
  54. package/api/resources/commons/types/ChannelClassification.d.ts +1 -1
  55. package/api/resources/commons/types/NotificationPreferences.d.ts +1 -1
  56. package/api/resources/commons/types/PreferenceStatus.d.ts +1 -1
  57. package/api/resources/inbound/client/Client.d.ts +11 -2
  58. package/api/resources/inbound/client/Client.js +35 -24
  59. package/api/resources/index.js +17 -7
  60. package/api/resources/lists/client/Client.d.ts +51 -44
  61. package/api/resources/lists/client/Client.js +181 -174
  62. package/api/resources/lists/client/requests/AddSubscribersToList.d.ts +5 -5
  63. package/api/resources/lists/client/requests/GetAllListsRequest.d.ts +1 -4
  64. package/api/resources/lists/client/requests/GetSubscriptionForListRequest.d.ts +1 -3
  65. package/api/resources/lists/client/requests/SubscribeUserToListRequest.d.ts +1 -4
  66. package/api/resources/lists/client/requests/SubscribeUsersToListRequest.d.ts +5 -5
  67. package/api/resources/messages/client/Client.d.ts +26 -29
  68. package/api/resources/messages/client/Client.js +111 -114
  69. package/api/resources/messages/client/requests/GetMessageHistoryRequest.d.ts +1 -3
  70. package/api/resources/messages/client/requests/ListMessagesRequest.d.ts +1 -16
  71. package/api/resources/messages/types/MessageDetailsExtended.d.ts +7 -0
  72. package/api/resources/messages/types/MessageDetailsExtended.js +5 -0
  73. package/api/resources/messages/types/MessageStatus.d.ts +25 -5
  74. package/api/resources/messages/types/MessageStatus.js +6 -1
  75. package/api/resources/messages/types/Reason.d.ts +1 -1
  76. package/api/resources/messages/types/index.d.ts +1 -0
  77. package/api/resources/messages/types/index.js +1 -0
  78. package/api/resources/notifications/client/Client.d.ts +32 -17
  79. package/api/resources/notifications/client/Client.js +119 -93
  80. package/api/resources/notifications/client/requests/NotificationListParams.d.ts +1 -4
  81. package/api/resources/notifications/client/requests/SubmissionChecksReplaceParams.d.ts +6 -2
  82. package/api/resources/notifications/types/BlockType.d.ts +1 -1
  83. package/api/resources/notifications/types/CheckStatus.d.ts +1 -1
  84. package/api/resources/notifications/types/MessageRoutingChannel.d.ts +1 -1
  85. package/api/resources/notifications/types/MessageRoutingMethod.d.ts +1 -1
  86. package/api/resources/notifications/types/NotificationContent.d.ts +1 -1
  87. package/api/resources/profiles/client/Client.d.ts +50 -30
  88. package/api/resources/profiles/client/Client.js +160 -139
  89. package/api/resources/profiles/client/requests/GetListSubscriptionsRequest.d.ts +1 -3
  90. package/api/resources/profiles/client/requests/MergeProfileRequest.d.ts +1 -1
  91. package/api/resources/profiles/client/requests/ReplaceProfileRequest.d.ts +1 -1
  92. package/api/resources/profiles/types/DeviceType.d.ts +1 -1
  93. package/api/resources/profiles/types/Discord.d.ts +1 -1
  94. package/api/resources/profiles/types/Expo.d.ts +1 -1
  95. package/api/resources/profiles/types/MsTeams.d.ts +1 -1
  96. package/api/resources/profiles/types/ProfileUpdateRequest.d.ts +8 -0
  97. package/api/resources/profiles/types/ProfileUpdateRequest.js +5 -0
  98. package/api/resources/profiles/types/Slack.d.ts +1 -1
  99. package/api/resources/profiles/types/SnoozeRuleType.d.ts +1 -1
  100. package/api/resources/profiles/types/UserProfileFirebaseToken.d.ts +1 -1
  101. package/api/resources/profiles/types/WebhookAuthMode.d.ts +1 -1
  102. package/api/resources/profiles/types/WebhookMethod.d.ts +1 -1
  103. package/api/resources/profiles/types/WebhookProfileType.d.ts +1 -1
  104. package/api/resources/profiles/types/index.d.ts +1 -0
  105. package/api/resources/profiles/types/index.js +1 -0
  106. package/api/resources/send/types/Attachment.d.ts +1 -1
  107. package/api/resources/send/types/ChannelSource.d.ts +1 -1
  108. package/api/resources/send/types/Content.d.ts +1 -1
  109. package/api/resources/send/types/Criteria.d.ts +1 -1
  110. package/api/resources/send/types/ElementalNode.d.ts +1 -1
  111. package/api/resources/send/types/ExpiresInType.d.ts +1 -1
  112. package/api/resources/send/types/IActionButtonStyle.d.ts +1 -1
  113. package/api/resources/send/types/IAlignment.d.ts +1 -1
  114. package/api/resources/send/types/IPreferences.d.ts +1 -1
  115. package/api/resources/send/types/InAppPlacement.d.ts +1 -1
  116. package/api/resources/send/types/Locales.d.ts +1 -1
  117. package/api/resources/send/types/Message.d.ts +1 -1
  118. package/api/resources/send/types/MessageChannels.d.ts +1 -1
  119. package/api/resources/send/types/MessageData.d.ts +1 -1
  120. package/api/resources/send/types/MessageProviders.d.ts +1 -1
  121. package/api/resources/send/types/MessageRecipient.d.ts +1 -1
  122. package/api/resources/send/types/Recipient.d.ts +1 -1
  123. package/api/resources/send/types/RecipientData.d.ts +1 -1
  124. package/api/resources/send/types/RoutingChannel.d.ts +1 -1
  125. package/api/resources/send/types/RoutingMethod.d.ts +1 -1
  126. package/api/resources/send/types/RuleType.d.ts +1 -1
  127. package/api/resources/send/types/TextAlign.d.ts +1 -1
  128. package/api/resources/send/types/TextStyle.d.ts +1 -1
  129. package/api/resources/templates/client/Client.d.ts +11 -4
  130. package/api/resources/templates/client/Client.js +34 -25
  131. package/api/resources/templates/client/requests/ListTemplatesRequest.d.ts +1 -3
  132. package/api/resources/templates/types/ChannelIdentifier.d.ts +1 -1
  133. package/api/resources/templates/types/RoutingStrategyMethod.d.ts +1 -1
  134. package/api/resources/tenants/client/Client.d.ts +37 -44
  135. package/api/resources/tenants/client/Client.js +130 -135
  136. package/api/resources/tenants/client/requests/ListTenantParams.d.ts +1 -5
  137. package/api/resources/tenants/client/requests/ListUsersForTenantParams.d.ts +1 -4
  138. package/api/resources/tenants/client/requests/TenantCreateOrReplaceParams.d.ts +6 -21
  139. package/api/resources/tenants/types/SubscriptionTopicStatus.d.ts +1 -1
  140. package/api/resources/tenants/types/TemplateProperty.d.ts +1 -1
  141. package/api/resources/translations/client/Client.d.ts +14 -4
  142. package/api/resources/translations/client/Client.js +49 -37
  143. package/api/resources/users/client/Client.d.ts +5 -7
  144. package/api/resources/users/resources/index.js +17 -7
  145. package/api/resources/users/resources/preferences/client/Client.d.ts +19 -12
  146. package/api/resources/users/resources/preferences/client/Client.js +77 -59
  147. package/api/resources/users/resources/preferences/client/requests/UserPreferencesParams.d.ts +1 -3
  148. package/api/resources/users/resources/preferences/client/requests/UserPreferencesTopicParams.d.ts +1 -3
  149. package/api/resources/users/resources/preferences/client/requests/UserPreferencesUpdateParams.d.ts +2 -2
  150. package/api/resources/users/resources/tenants/client/Client.d.ts +33 -26
  151. package/api/resources/users/resources/tenants/client/Client.js +104 -92
  152. package/api/resources/users/resources/tenants/client/requests/AddUserToMultipleTenantsParams.d.ts +9 -8
  153. package/api/resources/users/resources/tenants/client/requests/AddUserToSingleTenantsParams.d.ts +1 -5
  154. package/api/resources/users/resources/tenants/client/requests/ListTenantsForUserParams.d.ts +1 -4
  155. package/api/resources/users/resources/tokens/client/Client.d.ts +39 -35
  156. package/api/resources/users/resources/tokens/client/Client.js +121 -115
  157. package/api/resources/users/resources/tokens/types/ExpiryDate.d.ts +1 -1
  158. package/api/resources/users/resources/tokens/types/GetAllTokensResponse.d.ts +1 -1
  159. package/api/resources/users/resources/tokens/types/PatchOp.d.ts +1 -1
  160. package/api/resources/users/resources/tokens/types/ProviderKey.d.ts +1 -1
  161. package/api/resources/users/resources/tokens/types/TokenStatus.d.ts +1 -1
  162. package/core/auth/BearerToken.d.ts +1 -1
  163. package/core/fetcher/APIResponse.d.ts +11 -1
  164. package/core/fetcher/Fetcher.d.ts +7 -3
  165. package/core/fetcher/Fetcher.js +37 -135
  166. package/core/fetcher/Headers.d.ts +2 -0
  167. package/core/fetcher/Headers.js +84 -0
  168. package/core/fetcher/HttpResponsePromise.d.ts +58 -0
  169. package/core/fetcher/HttpResponsePromise.js +103 -0
  170. package/core/fetcher/RawResponse.d.ts +29 -0
  171. package/core/fetcher/RawResponse.js +44 -0
  172. package/core/fetcher/Supplier.d.ts +1 -1
  173. package/core/fetcher/createRequestUrl.d.ts +1 -0
  174. package/core/fetcher/createRequestUrl.js +12 -0
  175. package/core/fetcher/getFetchFn.d.ts +4 -0
  176. package/core/fetcher/getFetchFn.js +68 -0
  177. package/core/fetcher/getHeader.js +1 -2
  178. package/core/fetcher/getRequestBody.d.ts +7 -0
  179. package/core/fetcher/getRequestBody.js +23 -0
  180. package/core/fetcher/getResponseBody.d.ts +1 -0
  181. package/core/fetcher/getResponseBody.js +54 -0
  182. package/core/fetcher/index.d.ts +3 -0
  183. package/core/fetcher/index.js +7 -1
  184. package/core/fetcher/makeRequest.d.ts +1 -0
  185. package/core/fetcher/makeRequest.js +42 -0
  186. package/core/fetcher/requestWithRetries.d.ts +1 -0
  187. package/core/fetcher/requestWithRetries.js +40 -0
  188. package/core/fetcher/signals.d.ts +11 -0
  189. package/core/fetcher/signals.js +36 -0
  190. package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  191. package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
  192. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
  193. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +126 -0
  194. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
  195. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
  196. package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
  197. package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +59 -0
  198. package/core/index.d.ts +1 -1
  199. package/core/index.js +1 -1
  200. package/core/json.d.ts +15 -0
  201. package/core/json.js +24 -0
  202. package/core/runtime/runtime.d.ts +2 -1
  203. package/core/runtime/runtime.js +57 -36
  204. package/dist/Client.d.ts +49 -108
  205. package/dist/Client.js +89 -148
  206. package/dist/api/client/requests/SendMessageRequest.d.ts +8 -76
  207. package/dist/api/resources/audiences/client/Client.d.ts +26 -21
  208. package/dist/api/resources/audiences/client/Client.js +97 -90
  209. package/dist/api/resources/audiences/client/requests/AudienceMembersListParams.d.ts +1 -3
  210. package/dist/api/resources/audiences/client/requests/AudienceUpdateParams.d.ts +3 -7
  211. package/dist/api/resources/audiences/client/requests/AudiencesListParams.d.ts +1 -3
  212. package/dist/api/resources/audiences/types/ComparisonOperator.d.ts +1 -1
  213. package/dist/api/resources/audiences/types/Filter.d.ts +1 -1
  214. package/dist/api/resources/audiences/types/FilterConfig.d.ts +1 -1
  215. package/dist/api/resources/audiences/types/LogicalOperator.d.ts +1 -1
  216. package/dist/api/resources/audiences/types/Operator.d.ts +1 -1
  217. package/dist/api/resources/auditEvents/client/Client.d.ts +14 -6
  218. package/dist/api/resources/auditEvents/client/Client.js +48 -38
  219. package/dist/api/resources/auditEvents/client/requests/ListAuditEventsRequest.d.ts +1 -3
  220. package/dist/api/resources/authTokens/client/Client.d.ts +13 -4
  221. package/dist/api/resources/authTokens/client/Client.js +35 -26
  222. package/dist/api/resources/authTokens/client/requests/IssueTokenParams.d.ts +2 -2
  223. package/dist/api/resources/automations/client/Client.d.ts +19 -15
  224. package/dist/api/resources/automations/client/Client.js +52 -50
  225. package/dist/api/resources/automations/types/AutomationAddToBatchMaxItemsType.d.ts +1 -1
  226. package/dist/api/resources/automations/types/AutomationAddToBatchRetainType.d.ts +1 -1
  227. package/dist/api/resources/automations/types/AutomationAddToBatchScope.d.ts +1 -1
  228. package/dist/api/resources/automations/types/AutomationFetchDataWebhookMethod.d.ts +1 -1
  229. package/dist/api/resources/automations/types/AutomationStepOption.d.ts +1 -1
  230. package/dist/api/resources/automations/types/AutomationThrottleScope.d.ts +1 -1
  231. package/dist/api/resources/automations/types/MergeAlgorithm.d.ts +1 -1
  232. package/dist/api/resources/automations/types/Profile.d.ts +1 -1
  233. package/dist/api/resources/brands/client/Client.d.ts +32 -63
  234. package/dist/api/resources/brands/client/Client.js +103 -134
  235. package/dist/api/resources/brands/client/requests/BrandUpdateParameters.d.ts +3 -26
  236. package/dist/api/resources/brands/client/requests/ListBrandsRequest.d.ts +1 -3
  237. package/dist/api/resources/bulk/client/Client.d.ts +40 -126
  238. package/dist/api/resources/bulk/client/Client.js +111 -201
  239. package/dist/api/resources/bulk/client/requests/BulkCreateJobParams.d.ts +6 -86
  240. package/dist/api/resources/bulk/client/requests/BulkGetUsersParams.d.ts +1 -3
  241. package/dist/api/resources/bulk/types/BulkJobStatus.d.ts +1 -1
  242. package/dist/api/resources/bulk/types/BulkJobUserStatus.d.ts +1 -1
  243. package/dist/api/resources/bulk/types/InboundBulkMessageV2.d.ts +3 -5
  244. package/dist/api/resources/commons/errors/AlreadyExistsError.d.ts +2 -1
  245. package/dist/api/resources/commons/errors/AlreadyExistsError.js +19 -8
  246. package/dist/api/resources/commons/errors/BadRequestError.d.ts +2 -1
  247. package/dist/api/resources/commons/errors/BadRequestError.js +19 -8
  248. package/dist/api/resources/commons/errors/ConflictError.d.ts +2 -1
  249. package/dist/api/resources/commons/errors/ConflictError.js +19 -8
  250. package/dist/api/resources/commons/errors/MessageNotFoundError.d.ts +2 -1
  251. package/dist/api/resources/commons/errors/MessageNotFoundError.js +19 -8
  252. package/dist/api/resources/commons/errors/NotFoundError.d.ts +2 -1
  253. package/dist/api/resources/commons/errors/NotFoundError.js +19 -8
  254. package/dist/api/resources/commons/errors/PaymentRequiredError.d.ts +2 -1
  255. package/dist/api/resources/commons/errors/PaymentRequiredError.js +19 -8
  256. package/dist/api/resources/commons/types/ChannelClassification.d.ts +1 -1
  257. package/dist/api/resources/commons/types/NotificationPreferences.d.ts +1 -1
  258. package/dist/api/resources/commons/types/PreferenceStatus.d.ts +1 -1
  259. package/dist/api/resources/inbound/client/Client.d.ts +11 -2
  260. package/dist/api/resources/inbound/client/Client.js +35 -24
  261. package/dist/api/resources/index.js +17 -7
  262. package/dist/api/resources/lists/client/Client.d.ts +51 -44
  263. package/dist/api/resources/lists/client/Client.js +181 -174
  264. package/dist/api/resources/lists/client/requests/AddSubscribersToList.d.ts +5 -5
  265. package/dist/api/resources/lists/client/requests/GetAllListsRequest.d.ts +1 -4
  266. package/dist/api/resources/lists/client/requests/GetSubscriptionForListRequest.d.ts +1 -3
  267. package/dist/api/resources/lists/client/requests/SubscribeUserToListRequest.d.ts +1 -4
  268. package/dist/api/resources/lists/client/requests/SubscribeUsersToListRequest.d.ts +5 -5
  269. package/dist/api/resources/messages/client/Client.d.ts +26 -29
  270. package/dist/api/resources/messages/client/Client.js +111 -114
  271. package/dist/api/resources/messages/client/requests/GetMessageHistoryRequest.d.ts +1 -3
  272. package/dist/api/resources/messages/client/requests/ListMessagesRequest.d.ts +1 -16
  273. package/dist/api/resources/messages/types/MessageDetailsExtended.d.ts +7 -0
  274. package/dist/api/resources/messages/types/MessageDetailsExtended.js +5 -0
  275. package/dist/api/resources/messages/types/MessageStatus.d.ts +25 -5
  276. package/dist/api/resources/messages/types/MessageStatus.js +6 -1
  277. package/dist/api/resources/messages/types/Reason.d.ts +1 -1
  278. package/dist/api/resources/messages/types/index.d.ts +1 -0
  279. package/dist/api/resources/messages/types/index.js +1 -0
  280. package/dist/api/resources/notifications/client/Client.d.ts +32 -17
  281. package/dist/api/resources/notifications/client/Client.js +119 -93
  282. package/dist/api/resources/notifications/client/requests/NotificationListParams.d.ts +1 -4
  283. package/dist/api/resources/notifications/client/requests/SubmissionChecksReplaceParams.d.ts +6 -2
  284. package/dist/api/resources/notifications/types/BlockType.d.ts +1 -1
  285. package/dist/api/resources/notifications/types/CheckStatus.d.ts +1 -1
  286. package/dist/api/resources/notifications/types/MessageRoutingChannel.d.ts +1 -1
  287. package/dist/api/resources/notifications/types/MessageRoutingMethod.d.ts +1 -1
  288. package/dist/api/resources/notifications/types/NotificationContent.d.ts +1 -1
  289. package/dist/api/resources/profiles/client/Client.d.ts +50 -30
  290. package/dist/api/resources/profiles/client/Client.js +160 -139
  291. package/dist/api/resources/profiles/client/requests/GetListSubscriptionsRequest.d.ts +1 -3
  292. package/dist/api/resources/profiles/client/requests/MergeProfileRequest.d.ts +1 -1
  293. package/dist/api/resources/profiles/client/requests/ReplaceProfileRequest.d.ts +1 -1
  294. package/dist/api/resources/profiles/types/DeviceType.d.ts +1 -1
  295. package/dist/api/resources/profiles/types/Discord.d.ts +1 -1
  296. package/dist/api/resources/profiles/types/Expo.d.ts +1 -1
  297. package/dist/api/resources/profiles/types/MsTeams.d.ts +1 -1
  298. package/dist/api/resources/profiles/types/ProfileUpdateRequest.d.ts +8 -0
  299. package/dist/api/resources/profiles/types/ProfileUpdateRequest.js +5 -0
  300. package/dist/api/resources/profiles/types/Slack.d.ts +1 -1
  301. package/dist/api/resources/profiles/types/SnoozeRuleType.d.ts +1 -1
  302. package/dist/api/resources/profiles/types/UserProfileFirebaseToken.d.ts +1 -1
  303. package/dist/api/resources/profiles/types/WebhookAuthMode.d.ts +1 -1
  304. package/dist/api/resources/profiles/types/WebhookMethod.d.ts +1 -1
  305. package/dist/api/resources/profiles/types/WebhookProfileType.d.ts +1 -1
  306. package/dist/api/resources/profiles/types/index.d.ts +1 -0
  307. package/dist/api/resources/profiles/types/index.js +1 -0
  308. package/dist/api/resources/send/types/Attachment.d.ts +1 -1
  309. package/dist/api/resources/send/types/ChannelSource.d.ts +1 -1
  310. package/dist/api/resources/send/types/Content.d.ts +1 -1
  311. package/dist/api/resources/send/types/Criteria.d.ts +1 -1
  312. package/dist/api/resources/send/types/ElementalNode.d.ts +1 -1
  313. package/dist/api/resources/send/types/ExpiresInType.d.ts +1 -1
  314. package/dist/api/resources/send/types/IActionButtonStyle.d.ts +1 -1
  315. package/dist/api/resources/send/types/IAlignment.d.ts +1 -1
  316. package/dist/api/resources/send/types/IPreferences.d.ts +1 -1
  317. package/dist/api/resources/send/types/InAppPlacement.d.ts +1 -1
  318. package/dist/api/resources/send/types/Locales.d.ts +1 -1
  319. package/dist/api/resources/send/types/Message.d.ts +1 -1
  320. package/dist/api/resources/send/types/MessageChannels.d.ts +1 -1
  321. package/dist/api/resources/send/types/MessageData.d.ts +1 -1
  322. package/dist/api/resources/send/types/MessageProviders.d.ts +1 -1
  323. package/dist/api/resources/send/types/MessageRecipient.d.ts +1 -1
  324. package/dist/api/resources/send/types/Recipient.d.ts +1 -1
  325. package/dist/api/resources/send/types/RecipientData.d.ts +1 -1
  326. package/dist/api/resources/send/types/RoutingChannel.d.ts +1 -1
  327. package/dist/api/resources/send/types/RoutingMethod.d.ts +1 -1
  328. package/dist/api/resources/send/types/RuleType.d.ts +1 -1
  329. package/dist/api/resources/send/types/TextAlign.d.ts +1 -1
  330. package/dist/api/resources/send/types/TextStyle.d.ts +1 -1
  331. package/dist/api/resources/templates/client/Client.d.ts +11 -4
  332. package/dist/api/resources/templates/client/Client.js +34 -25
  333. package/dist/api/resources/templates/client/requests/ListTemplatesRequest.d.ts +1 -3
  334. package/dist/api/resources/templates/types/ChannelIdentifier.d.ts +1 -1
  335. package/dist/api/resources/templates/types/RoutingStrategyMethod.d.ts +1 -1
  336. package/dist/api/resources/tenants/client/Client.d.ts +37 -44
  337. package/dist/api/resources/tenants/client/Client.js +130 -135
  338. package/dist/api/resources/tenants/client/requests/ListTenantParams.d.ts +1 -5
  339. package/dist/api/resources/tenants/client/requests/ListUsersForTenantParams.d.ts +1 -4
  340. package/dist/api/resources/tenants/client/requests/TenantCreateOrReplaceParams.d.ts +6 -21
  341. package/dist/api/resources/tenants/types/SubscriptionTopicStatus.d.ts +1 -1
  342. package/dist/api/resources/tenants/types/TemplateProperty.d.ts +1 -1
  343. package/dist/api/resources/translations/client/Client.d.ts +14 -4
  344. package/dist/api/resources/translations/client/Client.js +49 -37
  345. package/dist/api/resources/users/client/Client.d.ts +5 -7
  346. package/dist/api/resources/users/resources/index.js +17 -7
  347. package/dist/api/resources/users/resources/preferences/client/Client.d.ts +19 -12
  348. package/dist/api/resources/users/resources/preferences/client/Client.js +77 -59
  349. package/dist/api/resources/users/resources/preferences/client/requests/UserPreferencesParams.d.ts +1 -3
  350. package/dist/api/resources/users/resources/preferences/client/requests/UserPreferencesTopicParams.d.ts +1 -3
  351. package/dist/api/resources/users/resources/preferences/client/requests/UserPreferencesUpdateParams.d.ts +2 -2
  352. package/dist/api/resources/users/resources/tenants/client/Client.d.ts +33 -26
  353. package/dist/api/resources/users/resources/tenants/client/Client.js +104 -92
  354. package/dist/api/resources/users/resources/tenants/client/requests/AddUserToMultipleTenantsParams.d.ts +9 -8
  355. package/dist/api/resources/users/resources/tenants/client/requests/AddUserToSingleTenantsParams.d.ts +1 -5
  356. package/dist/api/resources/users/resources/tenants/client/requests/ListTenantsForUserParams.d.ts +1 -4
  357. package/dist/api/resources/users/resources/tokens/client/Client.d.ts +39 -35
  358. package/dist/api/resources/users/resources/tokens/client/Client.js +121 -115
  359. package/dist/api/resources/users/resources/tokens/types/ExpiryDate.d.ts +1 -1
  360. package/dist/api/resources/users/resources/tokens/types/GetAllTokensResponse.d.ts +1 -1
  361. package/dist/api/resources/users/resources/tokens/types/PatchOp.d.ts +1 -1
  362. package/dist/api/resources/users/resources/tokens/types/ProviderKey.d.ts +1 -1
  363. package/dist/api/resources/users/resources/tokens/types/TokenStatus.d.ts +1 -1
  364. package/dist/core/auth/BearerToken.d.ts +1 -1
  365. package/dist/core/fetcher/APIResponse.d.ts +11 -1
  366. package/dist/core/fetcher/Fetcher.d.ts +7 -3
  367. package/dist/core/fetcher/Fetcher.js +37 -135
  368. package/dist/core/fetcher/Headers.d.ts +2 -0
  369. package/dist/core/fetcher/Headers.js +84 -0
  370. package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
  371. package/dist/core/fetcher/HttpResponsePromise.js +103 -0
  372. package/dist/core/fetcher/RawResponse.d.ts +29 -0
  373. package/dist/core/fetcher/RawResponse.js +44 -0
  374. package/dist/core/fetcher/Supplier.d.ts +1 -1
  375. package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
  376. package/dist/core/fetcher/createRequestUrl.js +12 -0
  377. package/dist/core/fetcher/getFetchFn.d.ts +4 -0
  378. package/dist/core/fetcher/getFetchFn.js +68 -0
  379. package/dist/core/fetcher/getHeader.js +1 -2
  380. package/dist/core/fetcher/getRequestBody.d.ts +7 -0
  381. package/dist/core/fetcher/getRequestBody.js +23 -0
  382. package/dist/core/fetcher/getResponseBody.d.ts +1 -0
  383. package/dist/core/fetcher/getResponseBody.js +54 -0
  384. package/dist/core/fetcher/index.d.ts +3 -0
  385. package/dist/core/fetcher/index.js +7 -1
  386. package/dist/core/fetcher/makeRequest.d.ts +1 -0
  387. package/dist/core/fetcher/makeRequest.js +42 -0
  388. package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
  389. package/dist/core/fetcher/requestWithRetries.js +40 -0
  390. package/dist/core/fetcher/signals.d.ts +11 -0
  391. package/dist/core/fetcher/signals.js +36 -0
  392. package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  393. package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
  394. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
  395. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +126 -0
  396. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
  397. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
  398. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
  399. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +59 -0
  400. package/dist/core/index.d.ts +1 -1
  401. package/dist/core/index.js +1 -1
  402. package/dist/core/json.d.ts +15 -0
  403. package/dist/core/json.js +24 -0
  404. package/dist/core/runtime/runtime.d.ts +2 -1
  405. package/dist/core/runtime/runtime.js +57 -36
  406. package/dist/environments.d.ts +1 -1
  407. package/dist/errors/CourierError.d.ts +4 -1
  408. package/dist/errors/CourierError.js +6 -8
  409. package/dist/errors/CourierTimeoutError.d.ts +1 -1
  410. package/dist/errors/CourierTimeoutError.js +2 -2
  411. package/dist/index.js +17 -7
  412. package/dist/version.d.ts +1 -0
  413. package/dist/version.js +4 -0
  414. package/environments.d.ts +1 -1
  415. package/errors/CourierError.d.ts +4 -1
  416. package/errors/CourierError.js +6 -8
  417. package/errors/CourierTimeoutError.d.ts +1 -1
  418. package/errors/CourierTimeoutError.js +2 -2
  419. package/index.js +17 -7
  420. package/{jest.config.js → jest.config.mjs} +4 -1
  421. package/package.json +25 -15
  422. package/reference.md +5142 -0
  423. package/scripts/rename-to-esm-files.js +115 -0
  424. package/version.d.ts +1 -0
  425. package/version.js +4 -0
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export declare type TokenStatus = "active" | "unknown" | "failed" | "revoked";
4
+ export type TokenStatus = "active" | "unknown" | "failed" | "revoked";
5
5
  export declare const TokenStatus: {
6
6
  readonly Active: "active";
7
7
  readonly Unknown: "unknown";
@@ -1,4 +1,4 @@
1
- export declare type BearerToken = string;
1
+ export type BearerToken = string;
2
2
  export declare const BearerToken: {
3
3
  toAuthorizationHeader: (token: BearerToken | undefined) => string | undefined;
4
4
  fromAuthorizationHeader: (header: string) => BearerToken;
@@ -1,10 +1,20 @@
1
- export declare type APIResponse<Success, Failure> = SuccessfulResponse<Success> | FailedResponse<Failure>;
1
+ import { RawResponse } from "./RawResponse";
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>;
2
7
  export interface SuccessfulResponse<T> {
3
8
  ok: true;
4
9
  body: T;
10
+ /**
11
+ * @deprecated Use `rawResponse` instead
12
+ */
5
13
  headers?: Record<string, any>;
14
+ rawResponse: RawResponse;
6
15
  }
7
16
  export interface FailedResponse<T> {
8
17
  ok: false;
9
18
  error: T;
19
+ rawResponse: RawResponse;
10
20
  }
@@ -1,17 +1,20 @@
1
1
  import { APIResponse } from "./APIResponse";
2
- export declare type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
2
+ export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
3
3
  export declare namespace Fetcher {
4
4
  interface Args {
5
5
  url: string;
6
6
  method: string;
7
7
  contentType?: string;
8
8
  headers?: Record<string, string | undefined>;
9
- queryParameters?: Record<string, string | string[] | object | object[]>;
9
+ queryParameters?: Record<string, string | string[] | object | object[] | null>;
10
10
  body?: unknown;
11
11
  timeoutMs?: number;
12
12
  maxRetries?: number;
13
13
  withCredentials?: boolean;
14
- responseType?: "json" | "blob" | "streaming" | "text";
14
+ abortSignal?: AbortSignal;
15
+ requestType?: "json" | "file" | "bytes";
16
+ responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer";
17
+ duplex?: "half";
15
18
  }
16
19
  type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
17
20
  interface FailedStatusCodeError {
@@ -32,4 +35,5 @@ export declare namespace Fetcher {
32
35
  errorMessage: string;
33
36
  }
34
37
  }
38
+ export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>;
35
39
  export declare const fetcher: FetchFunction;
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,18 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
9
  });
33
10
  };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
11
  Object.defineProperty(exports, "__esModule", { value: true });
38
12
  exports.fetcher = void 0;
39
- const qs_1 = __importDefault(require("qs"));
40
- const runtime_1 = require("../runtime");
41
- const INITIAL_RETRY_DELAY = 1;
42
- const MAX_RETRY_DELAY = 60;
43
- const DEFAULT_MAX_RETRIES = 2;
13
+ exports.fetcherImpl = fetcherImpl;
14
+ const json_1 = require("../json");
15
+ const RawResponse_1 = require("./RawResponse");
16
+ const createRequestUrl_1 = require("./createRequestUrl");
17
+ const getFetchFn_1 = require("./getFetchFn");
18
+ const getRequestBody_1 = require("./getRequestBody");
19
+ const getResponseBody_1 = require("./getResponseBody");
20
+ const makeRequest_1 = require("./makeRequest");
21
+ const requestWithRetries_1 = require("./requestWithRetries");
44
22
  function fetcherImpl(args) {
45
- var _a, _b;
46
23
  return __awaiter(this, void 0, void 0, function* () {
47
24
  const headers = {};
48
25
  if (args.body !== undefined && args.contentType != null) {
@@ -55,112 +32,23 @@ function fetcherImpl(args) {
55
32
  }
56
33
  }
57
34
  }
58
- const url = Object.keys((_a = args.queryParameters) !== null && _a !== void 0 ? _a : {}).length > 0
59
- ? `${args.url}?${qs_1.default.stringify(args.queryParameters, { arrayFormat: "repeat" })}`
60
- : args.url;
61
- let body = undefined;
62
- const maybeStringifyBody = (body) => {
63
- if (body instanceof Uint8Array) {
64
- return body;
65
- }
66
- else {
67
- return JSON.stringify(body);
68
- }
69
- };
70
- if (runtime_1.RUNTIME.type === "node") {
71
- if (args.body instanceof (yield Promise.resolve().then(() => __importStar(require("formdata-node")))).FormData) {
72
- // @ts-expect-error
73
- body = args.body;
74
- }
75
- else {
76
- body = maybeStringifyBody(args.body);
77
- }
78
- }
79
- else {
80
- if (args.body instanceof (yield Promise.resolve().then(() => __importStar(require("form-data")))).default) {
81
- // @ts-expect-error
82
- body = args.body;
83
- }
84
- else {
85
- body = maybeStringifyBody(args.body);
86
- }
87
- }
88
- // In Node.js environments, the SDK always uses`node-fetch`.
89
- // If not in Node.js the SDK uses global fetch if available,
90
- // and falls back to node-fetch.
91
- const fetchFn = runtime_1.RUNTIME.type === "node"
92
- ? // `.default` is required due to this issue:
93
- // https://github.com/node-fetch/node-fetch/issues/450#issuecomment-387045223
94
- (yield Promise.resolve().then(() => __importStar(require("node-fetch")))).default
95
- : typeof fetch == "function"
96
- ? fetch
97
- : (yield Promise.resolve().then(() => __importStar(require("node-fetch")))).default;
98
- const makeRequest = () => __awaiter(this, void 0, void 0, function* () {
99
- const controller = new AbortController();
100
- let abortId = undefined;
101
- if (args.timeoutMs != null) {
102
- abortId = setTimeout(() => controller.abort(), args.timeoutMs);
103
- }
104
- const response = yield fetchFn(url, {
105
- method: args.method,
106
- headers,
107
- body,
108
- signal: controller.signal,
109
- credentials: args.withCredentials ? "include" : undefined,
110
- });
111
- if (abortId != null) {
112
- clearTimeout(abortId);
113
- }
114
- return response;
35
+ const url = (0, createRequestUrl_1.createRequestUrl)(args.url, args.queryParameters);
36
+ const requestBody = yield (0, getRequestBody_1.getRequestBody)({
37
+ body: args.body,
38
+ type: args.requestType === "json" ? "json" : "other",
115
39
  });
40
+ const fetchFn = yield (0, getFetchFn_1.getFetchFn)();
116
41
  try {
117
- let response = yield makeRequest();
118
- for (let i = 0; i < ((_b = args.maxRetries) !== null && _b !== void 0 ? _b : DEFAULT_MAX_RETRIES); ++i) {
119
- if (response.status === 408 ||
120
- response.status === 409 ||
121
- response.status === 429 ||
122
- response.status >= 500) {
123
- const delay = Math.min(INITIAL_RETRY_DELAY * Math.pow(i, 2), MAX_RETRY_DELAY);
124
- yield new Promise((resolve) => setTimeout(resolve, delay));
125
- response = yield makeRequest();
126
- }
127
- else {
128
- break;
129
- }
130
- }
131
- let body;
132
- if (response.body != null && args.responseType === "blob") {
133
- body = yield response.blob();
134
- }
135
- else if (response.body != null && args.responseType === "streaming") {
136
- body = response.body;
137
- }
138
- else if (response.body != null && args.responseType === "text") {
139
- body = yield response.text();
140
- }
141
- else {
142
- const text = yield response.text();
143
- if (text.length > 0) {
144
- try {
145
- body = JSON.parse(text);
146
- }
147
- catch (err) {
148
- return {
149
- ok: false,
150
- error: {
151
- reason: "non-json",
152
- statusCode: response.status,
153
- rawBody: text,
154
- },
155
- };
156
- }
157
- }
158
- }
42
+ const response = yield (0, requestWithRetries_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
43
+ return (0, makeRequest_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
44
+ }), args.maxRetries);
45
+ const responseBody = yield (0, getResponseBody_1.getResponseBody)(response, args.responseType);
159
46
  if (response.status >= 200 && response.status < 400) {
160
47
  return {
161
48
  ok: true,
162
- body: body,
49
+ body: responseBody,
163
50
  headers: response.headers,
51
+ rawResponse: (0, RawResponse_1.toRawResponse)(response),
164
52
  };
165
53
  }
166
54
  else {
@@ -169,18 +57,30 @@ function fetcherImpl(args) {
169
57
  error: {
170
58
  reason: "status-code",
171
59
  statusCode: response.status,
172
- body,
60
+ body: responseBody,
173
61
  },
62
+ rawResponse: (0, RawResponse_1.toRawResponse)(response),
174
63
  };
175
64
  }
176
65
  }
177
66
  catch (error) {
178
- if (error instanceof Error && error.name === "AbortError") {
67
+ if (args.abortSignal != null && args.abortSignal.aborted) {
68
+ return {
69
+ ok: false,
70
+ error: {
71
+ reason: "unknown",
72
+ errorMessage: "The user aborted a request",
73
+ },
74
+ rawResponse: RawResponse_1.abortRawResponse,
75
+ };
76
+ }
77
+ else if (error instanceof Error && error.name === "AbortError") {
179
78
  return {
180
79
  ok: false,
181
80
  error: {
182
81
  reason: "timeout",
183
82
  },
83
+ rawResponse: RawResponse_1.abortRawResponse,
184
84
  };
185
85
  }
186
86
  else if (error instanceof Error) {
@@ -190,14 +90,16 @@ function fetcherImpl(args) {
190
90
  reason: "unknown",
191
91
  errorMessage: error.message,
192
92
  },
93
+ rawResponse: RawResponse_1.unknownRawResponse,
193
94
  };
194
95
  }
195
96
  return {
196
97
  ok: false,
197
98
  error: {
198
99
  reason: "unknown",
199
- errorMessage: JSON.stringify(error),
100
+ errorMessage: (0, json_1.toJson)(error),
200
101
  },
102
+ rawResponse: RawResponse_1.unknownRawResponse,
201
103
  };
202
104
  }
203
105
  });
@@ -0,0 +1,2 @@
1
+ declare let Headers: typeof globalThis.Headers;
2
+ export { Headers };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Headers = void 0;
4
+ let Headers;
5
+ if (typeof globalThis.Headers !== "undefined") {
6
+ exports.Headers = Headers = globalThis.Headers;
7
+ }
8
+ else {
9
+ exports.Headers = Headers = class Headers {
10
+ constructor(init) {
11
+ this.headers = new Map();
12
+ if (init) {
13
+ if (init instanceof Headers) {
14
+ init.forEach((value, key) => this.append(key, value));
15
+ }
16
+ else if (Array.isArray(init)) {
17
+ for (const [key, value] of init) {
18
+ if (typeof key === "string" && typeof value === "string") {
19
+ this.append(key, value);
20
+ }
21
+ else {
22
+ throw new TypeError("Each header entry must be a [string, string] tuple");
23
+ }
24
+ }
25
+ }
26
+ else {
27
+ for (const [key, value] of Object.entries(init)) {
28
+ if (typeof value === "string") {
29
+ this.append(key, value);
30
+ }
31
+ else {
32
+ throw new TypeError("Header values must be strings");
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+ append(name, value) {
39
+ const key = name.toLowerCase();
40
+ const existing = this.headers.get(key) || [];
41
+ this.headers.set(key, [...existing, value]);
42
+ }
43
+ delete(name) {
44
+ const key = name.toLowerCase();
45
+ this.headers.delete(key);
46
+ }
47
+ get(name) {
48
+ const key = name.toLowerCase();
49
+ const values = this.headers.get(key);
50
+ return values ? values.join(", ") : null;
51
+ }
52
+ has(name) {
53
+ const key = name.toLowerCase();
54
+ return this.headers.has(key);
55
+ }
56
+ set(name, value) {
57
+ const key = name.toLowerCase();
58
+ this.headers.set(key, [value]);
59
+ }
60
+ forEach(callbackfn, thisArg) {
61
+ const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
62
+ this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this));
63
+ }
64
+ getSetCookie() {
65
+ return this.headers.get("set-cookie") || [];
66
+ }
67
+ *entries() {
68
+ for (const [key, values] of this.headers.entries()) {
69
+ yield [key, values.join(", ")];
70
+ }
71
+ }
72
+ *keys() {
73
+ yield* this.headers.keys();
74
+ }
75
+ *values() {
76
+ for (const values of this.headers.values()) {
77
+ yield values.join(", ");
78
+ }
79
+ }
80
+ [Symbol.iterator]() {
81
+ return this.entries();
82
+ }
83
+ };
84
+ }
@@ -0,0 +1,58 @@
1
+ import { WithRawResponse } from "./RawResponse";
2
+ /**
3
+ * A promise that returns the parsed response and lets you retrieve the raw response too.
4
+ */
5
+ export declare class HttpResponsePromise<T> extends Promise<T> {
6
+ private innerPromise;
7
+ private unwrappedPromise;
8
+ private constructor();
9
+ /**
10
+ * Creates an `HttpResponsePromise` from a function that returns a promise.
11
+ *
12
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
13
+ * @param args - Arguments to pass to the function.
14
+ * @returns An `HttpResponsePromise` instance.
15
+ */
16
+ static fromFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T>(fn: F, ...args: Parameters<F>): HttpResponsePromise<T>;
17
+ /**
18
+ * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
19
+ *
20
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
21
+ * @returns A function that returns an `HttpResponsePromise` instance.
22
+ */
23
+ static interceptFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T = Awaited<ReturnType<F>>["data"]>(fn: F): (...args: Parameters<F>) => HttpResponsePromise<T>;
24
+ /**
25
+ * Creates an `HttpResponsePromise` from an existing promise.
26
+ *
27
+ * @param promise - A promise resolving to a `WithRawResponse` object.
28
+ * @returns An `HttpResponsePromise` instance.
29
+ */
30
+ static fromPromise<T>(promise: Promise<WithRawResponse<T>>): HttpResponsePromise<T>;
31
+ /**
32
+ * Creates an `HttpResponsePromise` from an executor function.
33
+ *
34
+ * @param executor - A function that takes resolve and reject callbacks to create a promise.
35
+ * @returns An `HttpResponsePromise` instance.
36
+ */
37
+ static fromExecutor<T>(executor: (resolve: (value: WithRawResponse<T>) => void, reject: (reason?: unknown) => void) => void): HttpResponsePromise<T>;
38
+ /**
39
+ * Creates an `HttpResponsePromise` from a resolved result.
40
+ *
41
+ * @param result - A `WithRawResponse` object to resolve immediately.
42
+ * @returns An `HttpResponsePromise` instance.
43
+ */
44
+ static fromResult<T>(result: WithRawResponse<T>): HttpResponsePromise<T>;
45
+ private unwrap;
46
+ /** @inheritdoc */
47
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
48
+ /** @inheritdoc */
49
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
50
+ /** @inheritdoc */
51
+ finally(onfinally?: (() => void) | null): Promise<T>;
52
+ /**
53
+ * Retrieves the data and raw response.
54
+ *
55
+ * @returns A promise resolving to a `WithRawResponse` object.
56
+ */
57
+ withRawResponse(): Promise<WithRawResponse<T>>;
58
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.HttpResponsePromise = void 0;
13
+ /**
14
+ * A promise that returns the parsed response and lets you retrieve the raw response too.
15
+ */
16
+ class HttpResponsePromise extends Promise {
17
+ constructor(promise) {
18
+ // Initialize with a no-op to avoid premature parsing
19
+ super((resolve) => {
20
+ resolve(undefined);
21
+ });
22
+ this.innerPromise = promise;
23
+ }
24
+ /**
25
+ * Creates an `HttpResponsePromise` from a function that returns a promise.
26
+ *
27
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
28
+ * @param args - Arguments to pass to the function.
29
+ * @returns An `HttpResponsePromise` instance.
30
+ */
31
+ static fromFunction(fn, ...args) {
32
+ return new HttpResponsePromise(fn(...args));
33
+ }
34
+ /**
35
+ * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
36
+ *
37
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
38
+ * @returns A function that returns an `HttpResponsePromise` instance.
39
+ */
40
+ static interceptFunction(fn) {
41
+ return (...args) => {
42
+ return HttpResponsePromise.fromPromise(fn(...args));
43
+ };
44
+ }
45
+ /**
46
+ * Creates an `HttpResponsePromise` from an existing promise.
47
+ *
48
+ * @param promise - A promise resolving to a `WithRawResponse` object.
49
+ * @returns An `HttpResponsePromise` instance.
50
+ */
51
+ static fromPromise(promise) {
52
+ return new HttpResponsePromise(promise);
53
+ }
54
+ /**
55
+ * Creates an `HttpResponsePromise` from an executor function.
56
+ *
57
+ * @param executor - A function that takes resolve and reject callbacks to create a promise.
58
+ * @returns An `HttpResponsePromise` instance.
59
+ */
60
+ static fromExecutor(executor) {
61
+ const promise = new Promise(executor);
62
+ return new HttpResponsePromise(promise);
63
+ }
64
+ /**
65
+ * Creates an `HttpResponsePromise` from a resolved result.
66
+ *
67
+ * @param result - A `WithRawResponse` object to resolve immediately.
68
+ * @returns An `HttpResponsePromise` instance.
69
+ */
70
+ static fromResult(result) {
71
+ const promise = Promise.resolve(result);
72
+ return new HttpResponsePromise(promise);
73
+ }
74
+ unwrap() {
75
+ if (!this.unwrappedPromise) {
76
+ this.unwrappedPromise = this.innerPromise.then(({ data }) => data);
77
+ }
78
+ return this.unwrappedPromise;
79
+ }
80
+ /** @inheritdoc */
81
+ then(onfulfilled, onrejected) {
82
+ return this.unwrap().then(onfulfilled, onrejected);
83
+ }
84
+ /** @inheritdoc */
85
+ catch(onrejected) {
86
+ return this.unwrap().catch(onrejected);
87
+ }
88
+ /** @inheritdoc */
89
+ finally(onfinally) {
90
+ return this.unwrap().finally(onfinally);
91
+ }
92
+ /**
93
+ * Retrieves the data and raw response.
94
+ *
95
+ * @returns A promise resolving to a `WithRawResponse` object.
96
+ */
97
+ withRawResponse() {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ return yield this.innerPromise;
100
+ });
101
+ }
102
+ }
103
+ exports.HttpResponsePromise = HttpResponsePromise;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The raw response from the fetch call excluding the body.
3
+ */
4
+ export type RawResponse = Omit<{
5
+ [K in keyof Response as Response[K] extends Function ? never : K]: Response[K];
6
+ }, "ok" | "body" | "bodyUsed">;
7
+ /**
8
+ * A raw response indicating that the request was aborted.
9
+ */
10
+ export declare const abortRawResponse: RawResponse;
11
+ /**
12
+ * A raw response indicating an unknown error.
13
+ */
14
+ export declare const unknownRawResponse: RawResponse;
15
+ /**
16
+ * Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
17
+ * excluding the `body` and `bodyUsed` fields.
18
+ *
19
+ * @param response - The `RawResponse` object to convert.
20
+ * @returns A `RawResponse` object containing the extracted properties of the input response.
21
+ */
22
+ export declare function toRawResponse(response: Response): RawResponse;
23
+ /**
24
+ * Creates a `RawResponse` from a standard `Response` object.
25
+ */
26
+ export interface WithRawResponse<T> {
27
+ readonly data: T;
28
+ readonly rawResponse: RawResponse;
29
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unknownRawResponse = exports.abortRawResponse = void 0;
4
+ exports.toRawResponse = toRawResponse;
5
+ const Headers_1 = require("./Headers");
6
+ /**
7
+ * A raw response indicating that the request was aborted.
8
+ */
9
+ exports.abortRawResponse = {
10
+ headers: new Headers_1.Headers(),
11
+ redirected: false,
12
+ status: 499,
13
+ statusText: "Client Closed Request",
14
+ type: "error",
15
+ url: "",
16
+ };
17
+ /**
18
+ * A raw response indicating an unknown error.
19
+ */
20
+ exports.unknownRawResponse = {
21
+ headers: new Headers_1.Headers(),
22
+ redirected: false,
23
+ status: 0,
24
+ statusText: "Unknown Error",
25
+ type: "error",
26
+ url: "",
27
+ };
28
+ /**
29
+ * Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
30
+ * excluding the `body` and `bodyUsed` fields.
31
+ *
32
+ * @param response - The `RawResponse` object to convert.
33
+ * @returns A `RawResponse` object containing the extracted properties of the input response.
34
+ */
35
+ function toRawResponse(response) {
36
+ return {
37
+ headers: response.headers,
38
+ redirected: response.redirected,
39
+ status: response.status,
40
+ statusText: response.statusText,
41
+ type: response.type,
42
+ url: response.url,
43
+ };
44
+ }
@@ -1,4 +1,4 @@
1
- export declare type Supplier<T> = T | Promise<T> | (() => T | Promise<T>);
1
+ export type Supplier<T> = T | Promise<T> | (() => T | Promise<T>);
2
2
  export declare const Supplier: {
3
3
  get: <T>(supplier: Supplier<T>) => Promise<T>;
4
4
  };
@@ -0,0 +1 @@
1
+ export declare function createRequestUrl(baseUrl: string, queryParameters?: Record<string, string | string[] | object | object[] | null>): string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createRequestUrl = createRequestUrl;
7
+ const qs_1 = __importDefault(require("qs"));
8
+ function createRequestUrl(baseUrl, queryParameters) {
9
+ return Object.keys(queryParameters !== null && queryParameters !== void 0 ? queryParameters : {}).length > 0
10
+ ? `${baseUrl}?${qs_1.default.stringify(queryParameters, { arrayFormat: "repeat" })}`
11
+ : baseUrl;
12
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns a fetch function based on the runtime
3
+ */
4
+ export declare function getFetchFn(): Promise<any>;