orb-billing 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (413) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +169 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +20 -0
  5. package/dist/internal/utils/contenttype.d.ts +1 -0
  6. package/dist/internal/utils/contenttype.js +33 -0
  7. package/dist/internal/utils/headers.d.ts +4 -0
  8. package/dist/internal/utils/headers.js +92 -0
  9. package/dist/internal/utils/index.d.ts +8 -0
  10. package/dist/internal/utils/index.js +27 -0
  11. package/dist/internal/utils/pathparams.d.ts +2 -0
  12. package/dist/internal/utils/pathparams.js +53 -0
  13. package/dist/internal/utils/queryparams.d.ts +2 -0
  14. package/dist/internal/utils/queryparams.js +178 -0
  15. package/dist/internal/utils/requestbody.d.ts +2 -0
  16. package/dist/internal/utils/requestbody.js +318 -0
  17. package/dist/internal/utils/retries.d.ts +20 -0
  18. package/dist/internal/utils/retries.js +250 -0
  19. package/dist/internal/utils/security.d.ts +2 -0
  20. package/dist/internal/utils/security.js +188 -0
  21. package/dist/internal/utils/utils.d.ts +37 -0
  22. package/dist/internal/utils/utils.js +370 -0
  23. package/dist/sdk/availability.d.ts +19 -0
  24. package/dist/sdk/availability.js +135 -0
  25. package/dist/sdk/coupon.d.ts +53 -0
  26. package/dist/sdk/coupon.js +358 -0
  27. package/dist/sdk/credit.d.ts +142 -0
  28. package/dist/sdk/credit.js +501 -0
  29. package/dist/sdk/creditnote.d.ts +26 -0
  30. package/dist/sdk/creditnote.js +186 -0
  31. package/dist/sdk/customer.d.ts +264 -0
  32. package/dist/sdk/customer.js +958 -0
  33. package/dist/sdk/event.d.ts +258 -0
  34. package/dist/sdk/event.js +732 -0
  35. package/dist/sdk/index.d.ts +1 -0
  36. package/dist/sdk/index.js +20 -0
  37. package/dist/sdk/invoice.d.ts +60 -0
  38. package/dist/sdk/invoice.js +416 -0
  39. package/dist/sdk/models/operations/addledgerentryexternalid.d.ts +16 -0
  40. package/dist/sdk/models/operations/addledgerentryexternalid.js +95 -0
  41. package/dist/sdk/models/operations/amendevent.d.ts +23 -0
  42. package/dist/sdk/models/operations/amendevent.js +99 -0
  43. package/dist/sdk/models/operations/amendusage.d.ts +34 -0
  44. package/dist/sdk/models/operations/amendusage.js +122 -0
  45. package/dist/sdk/models/operations/amendusageexternalcustomerid.d.ts +34 -0
  46. package/dist/sdk/models/operations/amendusageexternalcustomerid.js +122 -0
  47. package/dist/sdk/models/operations/archivecoupon.d.ts +15 -0
  48. package/dist/sdk/models/operations/archivecoupon.js +91 -0
  49. package/dist/sdk/models/operations/cancelsubscription.d.ts +16 -0
  50. package/dist/sdk/models/operations/cancelsubscription.js +95 -0
  51. package/dist/sdk/models/operations/closebackfill.d.ts +15 -0
  52. package/dist/sdk/models/operations/closebackfill.js +91 -0
  53. package/dist/sdk/models/operations/createbackfill.d.ts +12 -0
  54. package/dist/sdk/models/operations/createbackfill.js +79 -0
  55. package/dist/sdk/models/operations/createcoupon.d.ts +12 -0
  56. package/dist/sdk/models/operations/createcoupon.js +79 -0
  57. package/dist/sdk/models/operations/createcustomer.d.ts +12 -0
  58. package/dist/sdk/models/operations/createcustomer.js +79 -0
  59. package/dist/sdk/models/operations/createcustomerbalancetransaction.d.ts +16 -0
  60. package/dist/sdk/models/operations/createcustomerbalancetransaction.js +95 -0
  61. package/dist/sdk/models/operations/createinvoicelineitem.d.ts +12 -0
  62. package/dist/sdk/models/operations/createinvoicelineitem.js +79 -0
  63. package/dist/sdk/models/operations/createledgerentry.d.ts +16 -0
  64. package/dist/sdk/models/operations/createledgerentry.js +95 -0
  65. package/dist/sdk/models/operations/createsubscription.d.ts +12 -0
  66. package/dist/sdk/models/operations/createsubscription.js +79 -0
  67. package/dist/sdk/models/operations/deletecustomer.d.ts +22 -0
  68. package/dist/sdk/models/operations/deletecustomer.js +78 -0
  69. package/dist/sdk/models/operations/deprecateevent.d.ts +22 -0
  70. package/dist/sdk/models/operations/deprecateevent.js +95 -0
  71. package/dist/sdk/models/operations/fetchcoupon.d.ts +15 -0
  72. package/dist/sdk/models/operations/fetchcoupon.js +91 -0
  73. package/dist/sdk/models/operations/fetchcreditnote.d.ts +18 -0
  74. package/dist/sdk/models/operations/fetchcreditnote.js +91 -0
  75. package/dist/sdk/models/operations/fetchcustomer.d.ts +18 -0
  76. package/dist/sdk/models/operations/fetchcustomer.js +91 -0
  77. package/dist/sdk/models/operations/fetchcustomercosts.d.ts +34 -0
  78. package/dist/sdk/models/operations/fetchcustomercosts.js +107 -0
  79. package/dist/sdk/models/operations/fetchcustomercostsexternalid.d.ts +31 -0
  80. package/dist/sdk/models/operations/fetchcustomercostsexternalid.js +107 -0
  81. package/dist/sdk/models/operations/fetchcustomercredits.d.ts +26 -0
  82. package/dist/sdk/models/operations/fetchcustomercredits.js +99 -0
  83. package/dist/sdk/models/operations/fetchcustomercreditsexternalid.d.ts +23 -0
  84. package/dist/sdk/models/operations/fetchcustomercreditsexternalid.js +99 -0
  85. package/dist/sdk/models/operations/fetchcustomercreditsledger.d.ts +35 -0
  86. package/dist/sdk/models/operations/fetchcustomercreditsledger.js +111 -0
  87. package/dist/sdk/models/operations/fetchcustomercreditsledgerexternalid.d.ts +35 -0
  88. package/dist/sdk/models/operations/fetchcustomercreditsledgerexternalid.js +111 -0
  89. package/dist/sdk/models/operations/fetchcustomerexternalid.d.ts +15 -0
  90. package/dist/sdk/models/operations/fetchcustomerexternalid.js +91 -0
  91. package/dist/sdk/models/operations/fetchinvoice.d.ts +15 -0
  92. package/dist/sdk/models/operations/fetchinvoice.js +91 -0
  93. package/dist/sdk/models/operations/fetchplan.d.ts +15 -0
  94. package/dist/sdk/models/operations/fetchplan.js +91 -0
  95. package/dist/sdk/models/operations/fetchplanexternalid.d.ts +15 -0
  96. package/dist/sdk/models/operations/fetchplanexternalid.js +91 -0
  97. package/dist/sdk/models/operations/fetchsubscription.d.ts +15 -0
  98. package/dist/sdk/models/operations/fetchsubscription.js +91 -0
  99. package/dist/sdk/models/operations/fetchsubscriptioncosts.d.ts +31 -0
  100. package/dist/sdk/models/operations/fetchsubscriptioncosts.js +107 -0
  101. package/dist/sdk/models/operations/fetchsubscriptionschedule.d.ts +23 -0
  102. package/dist/sdk/models/operations/fetchsubscriptionschedule.js +99 -0
  103. package/dist/sdk/models/operations/fetchsubscriptionusage.d.ts +39 -0
  104. package/dist/sdk/models/operations/fetchsubscriptionusage.js +115 -0
  105. package/dist/sdk/models/operations/fetchupcominginvoice.d.ts +15 -0
  106. package/dist/sdk/models/operations/fetchupcominginvoice.js +91 -0
  107. package/dist/sdk/models/operations/index.d.ts +55 -0
  108. package/dist/sdk/models/operations/index.js +74 -0
  109. package/dist/sdk/models/operations/ingest.d.ts +30 -0
  110. package/dist/sdk/models/operations/ingest.js +118 -0
  111. package/dist/sdk/models/operations/issueinvoice.d.ts +19 -0
  112. package/dist/sdk/models/operations/issueinvoice.js +95 -0
  113. package/dist/sdk/models/operations/listbackfills.d.ts +22 -0
  114. package/dist/sdk/models/operations/listbackfills.js +95 -0
  115. package/dist/sdk/models/operations/listbalancetransactions.d.ts +23 -0
  116. package/dist/sdk/models/operations/listbalancetransactions.js +99 -0
  117. package/dist/sdk/models/operations/listcoupons.d.ts +30 -0
  118. package/dist/sdk/models/operations/listcoupons.js +103 -0
  119. package/dist/sdk/models/operations/listcouponsubscriptions.d.ts +15 -0
  120. package/dist/sdk/models/operations/listcouponsubscriptions.js +91 -0
  121. package/dist/sdk/models/operations/listcreditnote.d.ts +34 -0
  122. package/dist/sdk/models/operations/listcreditnote.js +107 -0
  123. package/dist/sdk/models/operations/listcustomers.d.ts +22 -0
  124. package/dist/sdk/models/operations/listcustomers.js +95 -0
  125. package/dist/sdk/models/operations/listinvoices.d.ts +38 -0
  126. package/dist/sdk/models/operations/listinvoices.js +111 -0
  127. package/dist/sdk/models/operations/listplans.d.ts +22 -0
  128. package/dist/sdk/models/operations/listplans.js +95 -0
  129. package/dist/sdk/models/operations/listsubscriptions.d.ts +24 -0
  130. package/dist/sdk/models/operations/listsubscriptions.js +103 -0
  131. package/dist/sdk/models/operations/ping.d.ts +12 -0
  132. package/dist/sdk/models/operations/ping.js +79 -0
  133. package/dist/sdk/models/operations/revertbackfill.d.ts +15 -0
  134. package/dist/sdk/models/operations/revertbackfill.js +91 -0
  135. package/dist/sdk/models/operations/scheduleplanchange.d.ts +16 -0
  136. package/dist/sdk/models/operations/scheduleplanchange.js +95 -0
  137. package/dist/sdk/models/operations/searchevents.d.ts +23 -0
  138. package/dist/sdk/models/operations/searchevents.js +99 -0
  139. package/dist/sdk/models/operations/unschedulecancellation.d.ts +15 -0
  140. package/dist/sdk/models/operations/unschedulecancellation.js +91 -0
  141. package/dist/sdk/models/operations/unscheduleplanchange.d.ts +15 -0
  142. package/dist/sdk/models/operations/unscheduleplanchange.js +91 -0
  143. package/dist/sdk/models/operations/updatecustomer.d.ts +19 -0
  144. package/dist/sdk/models/operations/updatecustomer.js +95 -0
  145. package/dist/sdk/models/operations/updatecustomerexternalid.d.ts +16 -0
  146. package/dist/sdk/models/operations/updatecustomerexternalid.js +95 -0
  147. package/dist/sdk/models/operations/updatefixedfeequantity.d.ts +16 -0
  148. package/dist/sdk/models/operations/updatefixedfeequantity.js +95 -0
  149. package/dist/sdk/models/operations/voidinvoice.d.ts +19 -0
  150. package/dist/sdk/models/operations/voidinvoice.js +95 -0
  151. package/dist/sdk/models/shared/action.d.ts +8 -0
  152. package/dist/sdk/models/shared/action.js +15 -0
  153. package/dist/sdk/models/shared/amendedevent.d.ts +28 -0
  154. package/dist/sdk/models/shared/amendedevent.js +81 -0
  155. package/dist/sdk/models/shared/amendedusage.d.ts +16 -0
  156. package/dist/sdk/models/shared/amendedusage.js +62 -0
  157. package/dist/sdk/models/shared/amendeventresult.d.ts +10 -0
  158. package/dist/sdk/models/shared/amendeventresult.js +48 -0
  159. package/dist/sdk/models/shared/autocollection.d.ts +18 -0
  160. package/dist/sdk/models/shared/autocollection.js +66 -0
  161. package/dist/sdk/models/shared/availability.d.ts +7 -0
  162. package/dist/sdk/models/shared/availability.js +48 -0
  163. package/dist/sdk/models/shared/backfill.d.ts +27 -0
  164. package/dist/sdk/models/shared/backfill.js +104 -0
  165. package/dist/sdk/models/shared/backfills.d.ts +10 -0
  166. package/dist/sdk/models/shared/backfills.js +57 -0
  167. package/dist/sdk/models/shared/backfillstatus.d.ts +9 -0
  168. package/dist/sdk/models/shared/backfillstatus.js +16 -0
  169. package/dist/sdk/models/shared/billablemetric.d.ts +4 -0
  170. package/dist/sdk/models/shared/billablemetric.js +45 -0
  171. package/dist/sdk/models/shared/billablemetricminified.d.ts +5 -0
  172. package/dist/sdk/models/shared/billablemetricminified.js +50 -0
  173. package/dist/sdk/models/shared/bpsconfig.d.ts +8 -0
  174. package/dist/sdk/models/shared/bpsconfig.js +53 -0
  175. package/dist/sdk/models/shared/bpspriceoverride.d.ts +24 -0
  176. package/dist/sdk/models/shared/bpspriceoverride.js +74 -0
  177. package/dist/sdk/models/shared/bpstier.d.ts +7 -0
  178. package/dist/sdk/models/shared/bpstier.js +60 -0
  179. package/dist/sdk/models/shared/bulkbpsconfig.d.ts +8 -0
  180. package/dist/sdk/models/shared/bulkbpsconfig.js +50 -0
  181. package/dist/sdk/models/shared/bulkbpspriceoverride.d.ts +24 -0
  182. package/dist/sdk/models/shared/bulkbpspriceoverride.js +74 -0
  183. package/dist/sdk/models/shared/bulkbpstier.d.ts +6 -0
  184. package/dist/sdk/models/shared/bulkbpstier.js +55 -0
  185. package/dist/sdk/models/shared/bulkconfig.d.ts +8 -0
  186. package/dist/sdk/models/shared/bulkconfig.js +50 -0
  187. package/dist/sdk/models/shared/bulkpriceoverride.d.ts +24 -0
  188. package/dist/sdk/models/shared/bulkpriceoverride.js +74 -0
  189. package/dist/sdk/models/shared/bulktier.d.ts +5 -0
  190. package/dist/sdk/models/shared/bulktier.js +50 -0
  191. package/dist/sdk/models/shared/cadence.d.ts +5 -0
  192. package/dist/sdk/models/shared/cadence.js +12 -0
  193. package/dist/sdk/models/shared/canceloption.d.ts +8 -0
  194. package/dist/sdk/models/shared/canceloption.js +15 -0
  195. package/dist/sdk/models/shared/changeoption.d.ts +8 -0
  196. package/dist/sdk/models/shared/changeoption.js +15 -0
  197. package/dist/sdk/models/shared/changeoption1.d.ts +8 -0
  198. package/dist/sdk/models/shared/changeoption1.js +15 -0
  199. package/dist/sdk/models/shared/coupon.d.ts +36 -0
  200. package/dist/sdk/models/shared/coupon.js +88 -0
  201. package/dist/sdk/models/shared/coupons.d.ts +10 -0
  202. package/dist/sdk/models/shared/coupons.js +57 -0
  203. package/dist/sdk/models/shared/credit.d.ts +16 -0
  204. package/dist/sdk/models/shared/credit.js +64 -0
  205. package/dist/sdk/models/shared/creditblock.d.ts +15 -0
  206. package/dist/sdk/models/shared/creditblock.js +58 -0
  207. package/dist/sdk/models/shared/creditledgerentries.d.ts +10 -0
  208. package/dist/sdk/models/shared/creditledgerentries.js +57 -0
  209. package/dist/sdk/models/shared/creditledgerentry.d.ts +58 -0
  210. package/dist/sdk/models/shared/creditledgerentry.js +144 -0
  211. package/dist/sdk/models/shared/creditnote.d.ts +71 -0
  212. package/dist/sdk/models/shared/creditnote.js +134 -0
  213. package/dist/sdk/models/shared/creditnotelineitem.d.ts +38 -0
  214. package/dist/sdk/models/shared/creditnotelineitem.js +86 -0
  215. package/dist/sdk/models/shared/creditnotes.d.ts +10 -0
  216. package/dist/sdk/models/shared/creditnotes.js +57 -0
  217. package/dist/sdk/models/shared/creditnotesummary.d.ts +9 -0
  218. package/dist/sdk/models/shared/creditnotesummary.js +74 -0
  219. package/dist/sdk/models/shared/creditnotetype.d.ts +7 -0
  220. package/dist/sdk/models/shared/creditnotetype.js +14 -0
  221. package/dist/sdk/models/shared/credits.d.ts +10 -0
  222. package/dist/sdk/models/shared/credits.js +57 -0
  223. package/dist/sdk/models/shared/customer.d.ts +227 -0
  224. package/dist/sdk/models/shared/customer.js +364 -0
  225. package/dist/sdk/models/shared/customerbalancetransaction.d.ts +57 -0
  226. package/dist/sdk/models/shared/customerbalancetransaction.js +133 -0
  227. package/dist/sdk/models/shared/customercost.d.ts +15 -0
  228. package/dist/sdk/models/shared/customercost.js +75 -0
  229. package/dist/sdk/models/shared/customercosts.d.ts +8 -0
  230. package/dist/sdk/models/shared/customercosts.js +50 -0
  231. package/dist/sdk/models/shared/customerminified.d.ts +8 -0
  232. package/dist/sdk/models/shared/customerminified.js +53 -0
  233. package/dist/sdk/models/shared/customers.d.ts +10 -0
  234. package/dist/sdk/models/shared/customers.js +57 -0
  235. package/dist/sdk/models/shared/debug.d.ts +8 -0
  236. package/dist/sdk/models/shared/debug.js +53 -0
  237. package/dist/sdk/models/shared/deprecatedeventresult.d.ts +10 -0
  238. package/dist/sdk/models/shared/deprecatedeventresult.js +48 -0
  239. package/dist/sdk/models/shared/discount.d.ts +25 -0
  240. package/dist/sdk/models/shared/discount.js +71 -0
  241. package/dist/sdk/models/shared/discounttype.d.ts +6 -0
  242. package/dist/sdk/models/shared/discounttype.js +13 -0
  243. package/dist/sdk/models/shared/durationunit.d.ts +8 -0
  244. package/dist/sdk/models/shared/durationunit.js +15 -0
  245. package/dist/sdk/models/shared/entrystatus.d.ts +7 -0
  246. package/dist/sdk/models/shared/entrystatus.js +14 -0
  247. package/dist/sdk/models/shared/entrytype.d.ts +9 -0
  248. package/dist/sdk/models/shared/entrytype.js +16 -0
  249. package/dist/sdk/models/shared/event.d.ts +32 -0
  250. package/dist/sdk/models/shared/event.js +82 -0
  251. package/dist/sdk/models/shared/eventsearchcriteria.d.ts +11 -0
  252. package/dist/sdk/models/shared/eventsearchcriteria.js +50 -0
  253. package/dist/sdk/models/shared/eventsearchresults.d.ts +10 -0
  254. package/dist/sdk/models/shared/eventsearchresults.js +57 -0
  255. package/dist/sdk/models/shared/externalmarketplace.d.ts +8 -0
  256. package/dist/sdk/models/shared/externalmarketplace.js +15 -0
  257. package/dist/sdk/models/shared/fixedfeequantitychange.d.ts +18 -0
  258. package/dist/sdk/models/shared/fixedfeequantitychange.js +66 -0
  259. package/dist/sdk/models/shared/fixedfeequantityschedule.d.ts +7 -0
  260. package/dist/sdk/models/shared/fixedfeequantityschedule.js +68 -0
  261. package/dist/sdk/models/shared/granularity.d.ts +6 -0
  262. package/dist/sdk/models/shared/granularity.js +13 -0
  263. package/dist/sdk/models/shared/grouping.d.ts +8 -0
  264. package/dist/sdk/models/shared/grouping.js +53 -0
  265. package/dist/sdk/models/shared/index.d.ts +125 -0
  266. package/dist/sdk/models/shared/index.js +144 -0
  267. package/dist/sdk/models/shared/ingestionresponse.d.ts +13 -0
  268. package/dist/sdk/models/shared/ingestionresponse.js +57 -0
  269. package/dist/sdk/models/shared/invoice.d.ts +274 -0
  270. package/dist/sdk/models/shared/invoice.js +460 -0
  271. package/dist/sdk/models/shared/invoicelineitem.d.ts +207 -0
  272. package/dist/sdk/models/shared/invoicelineitem.js +416 -0
  273. package/dist/sdk/models/shared/invoices.d.ts +10 -0
  274. package/dist/sdk/models/shared/invoices.js +57 -0
  275. package/dist/sdk/models/shared/invoicesettings.d.ts +18 -0
  276. package/dist/sdk/models/shared/invoicesettings.js +58 -0
  277. package/dist/sdk/models/shared/invoicestatus.d.ts +10 -0
  278. package/dist/sdk/models/shared/invoicestatus.js +17 -0
  279. package/dist/sdk/models/shared/lineitem.d.ts +58 -0
  280. package/dist/sdk/models/shared/lineitem.js +147 -0
  281. package/dist/sdk/models/shared/matrixconfig.d.ts +13 -0
  282. package/dist/sdk/models/shared/matrixconfig.js +60 -0
  283. package/dist/sdk/models/shared/matrixconfig1.d.ts +10 -0
  284. package/dist/sdk/models/shared/matrixconfig1.js +48 -0
  285. package/dist/sdk/models/shared/matrixvalue.d.ts +8 -0
  286. package/dist/sdk/models/shared/matrixvalue.js +50 -0
  287. package/dist/sdk/models/shared/modeltype.d.ts +10 -0
  288. package/dist/sdk/models/shared/modeltype.js +17 -0
  289. package/dist/sdk/models/shared/newbackfill.d.ts +27 -0
  290. package/dist/sdk/models/shared/newbackfill.js +82 -0
  291. package/dist/sdk/models/shared/newcoupon.d.ts +24 -0
  292. package/dist/sdk/models/shared/newcoupon.js +69 -0
  293. package/dist/sdk/models/shared/newcreditledgerentry.d.ts +44 -0
  294. package/dist/sdk/models/shared/newcreditledgerentry.js +109 -0
  295. package/dist/sdk/models/shared/newcustomer.d.ts +202 -0
  296. package/dist/sdk/models/shared/newcustomer.js +324 -0
  297. package/dist/sdk/models/shared/newinvoicelineitem.d.ts +28 -0
  298. package/dist/sdk/models/shared/newinvoicelineitem.js +79 -0
  299. package/dist/sdk/models/shared/newsubscription.d.ts +79 -0
  300. package/dist/sdk/models/shared/newsubscription.js +145 -0
  301. package/dist/sdk/models/shared/newtransaction.d.ts +10 -0
  302. package/dist/sdk/models/shared/newtransaction.js +56 -0
  303. package/dist/sdk/models/shared/packageconfig.d.ts +8 -0
  304. package/dist/sdk/models/shared/packageconfig.js +53 -0
  305. package/dist/sdk/models/shared/packagepriceoverride.d.ts +24 -0
  306. package/dist/sdk/models/shared/packagepriceoverride.js +74 -0
  307. package/dist/sdk/models/shared/paginationmetadata.d.ts +5 -0
  308. package/dist/sdk/models/shared/paginationmetadata.js +50 -0
  309. package/dist/sdk/models/shared/perpricecost.d.ts +24 -0
  310. package/dist/sdk/models/shared/perpricecost.js +67 -0
  311. package/dist/sdk/models/shared/phaseoverride.d.ts +40 -0
  312. package/dist/sdk/models/shared/phaseoverride.js +100 -0
  313. package/dist/sdk/models/shared/plan.d.ts +101 -0
  314. package/dist/sdk/models/shared/plan.js +250 -0
  315. package/dist/sdk/models/shared/planminified.d.ts +5 -0
  316. package/dist/sdk/models/shared/planminified.js +50 -0
  317. package/dist/sdk/models/shared/planphase.d.ts +68 -0
  318. package/dist/sdk/models/shared/planphase.js +162 -0
  319. package/dist/sdk/models/shared/plans.d.ts +10 -0
  320. package/dist/sdk/models/shared/plans.js +57 -0
  321. package/dist/sdk/models/shared/price.d.ts +114 -0
  322. package/dist/sdk/models/shared/price.js +245 -0
  323. package/dist/sdk/models/shared/pricegroup.d.ts +17 -0
  324. package/dist/sdk/models/shared/pricegroup.js +65 -0
  325. package/dist/sdk/models/shared/product.d.ts +6 -0
  326. package/dist/sdk/models/shared/product.js +59 -0
  327. package/dist/sdk/models/shared/reason.d.ts +9 -0
  328. package/dist/sdk/models/shared/reason.js +16 -0
  329. package/dist/sdk/models/shared/requestvalidationerror.d.ts +20 -0
  330. package/dist/sdk/models/shared/requestvalidationerror.js +65 -0
  331. package/dist/sdk/models/shared/security.d.ts +4 -0
  332. package/dist/sdk/models/shared/security.js +45 -0
  333. package/dist/sdk/models/shared/sublineitem.d.ts +32 -0
  334. package/dist/sdk/models/shared/sublineitem.js +102 -0
  335. package/dist/sdk/models/shared/sublineitem1.d.ts +24 -0
  336. package/dist/sdk/models/shared/sublineitem1.js +75 -0
  337. package/dist/sdk/models/shared/sublineitem2.d.ts +6 -0
  338. package/dist/sdk/models/shared/sublineitem2.js +55 -0
  339. package/dist/sdk/models/shared/subscription.d.ts +95 -0
  340. package/dist/sdk/models/shared/subscription.js +207 -0
  341. package/dist/sdk/models/shared/subscriptioncancellation.d.ts +12 -0
  342. package/dist/sdk/models/shared/subscriptioncancellation.js +55 -0
  343. package/dist/sdk/models/shared/subscriptioncost.d.ts +15 -0
  344. package/dist/sdk/models/shared/subscriptioncost.js +75 -0
  345. package/dist/sdk/models/shared/subscriptioncosts.d.ts +8 -0
  346. package/dist/sdk/models/shared/subscriptioncosts.js +50 -0
  347. package/dist/sdk/models/shared/subscriptionminified.d.ts +7 -0
  348. package/dist/sdk/models/shared/subscriptionminified.js +48 -0
  349. package/dist/sdk/models/shared/subscriptionplanchange.d.ts +54 -0
  350. package/dist/sdk/models/shared/subscriptionplanchange.js +104 -0
  351. package/dist/sdk/models/shared/subscriptions.d.ts +10 -0
  352. package/dist/sdk/models/shared/subscriptions.js +57 -0
  353. package/dist/sdk/models/shared/subscriptionschedule.d.ts +10 -0
  354. package/dist/sdk/models/shared/subscriptionschedule.js +57 -0
  355. package/dist/sdk/models/shared/subscriptionscheduleitem.d.ts +7 -0
  356. package/dist/sdk/models/shared/subscriptionscheduleitem.js +65 -0
  357. package/dist/sdk/models/shared/subscriptionstatus.d.ts +5 -0
  358. package/dist/sdk/models/shared/subscriptionstatus.js +12 -0
  359. package/dist/sdk/models/shared/subscriptionusage.d.ts +8 -0
  360. package/dist/sdk/models/shared/subscriptionusage.js +50 -0
  361. package/dist/sdk/models/shared/taxamount.d.ts +15 -0
  362. package/dist/sdk/models/shared/taxamount.js +55 -0
  363. package/dist/sdk/models/shared/tier.d.ts +6 -0
  364. package/dist/sdk/models/shared/tier.js +55 -0
  365. package/dist/sdk/models/shared/tier7.d.ts +7 -0
  366. package/dist/sdk/models/shared/tier7.js +60 -0
  367. package/dist/sdk/models/shared/tierconfig.d.ts +9 -0
  368. package/dist/sdk/models/shared/tierconfig.js +58 -0
  369. package/dist/sdk/models/shared/tieredbpsconfig.d.ts +8 -0
  370. package/dist/sdk/models/shared/tieredbpsconfig.js +50 -0
  371. package/dist/sdk/models/shared/tieredbpsconfig1.d.ts +5 -0
  372. package/dist/sdk/models/shared/tieredbpsconfig1.js +47 -0
  373. package/dist/sdk/models/shared/tieredbpspriceoverride.d.ts +21 -0
  374. package/dist/sdk/models/shared/tieredbpspriceoverride.js +74 -0
  375. package/dist/sdk/models/shared/tieredconfig.d.ts +8 -0
  376. package/dist/sdk/models/shared/tieredconfig.js +50 -0
  377. package/dist/sdk/models/shared/tieredpriceoverride.d.ts +27 -0
  378. package/dist/sdk/models/shared/tieredpriceoverride.js +74 -0
  379. package/dist/sdk/models/shared/transactions.d.ts +10 -0
  380. package/dist/sdk/models/shared/transactions.js +57 -0
  381. package/dist/sdk/models/shared/transactiontype.d.ts +4 -0
  382. package/dist/sdk/models/shared/transactiontype.js +11 -0
  383. package/dist/sdk/models/shared/trialconfig.d.ts +8 -0
  384. package/dist/sdk/models/shared/trialconfig.js +54 -0
  385. package/dist/sdk/models/shared/type.d.ts +7 -0
  386. package/dist/sdk/models/shared/type.js +14 -0
  387. package/dist/sdk/models/shared/unitconfig.d.ts +7 -0
  388. package/dist/sdk/models/shared/unitconfig.js +48 -0
  389. package/dist/sdk/models/shared/unitpriceoverride.d.ts +24 -0
  390. package/dist/sdk/models/shared/unitpriceoverride.js +74 -0
  391. package/dist/sdk/models/shared/upcominginvoice.d.ts +95 -0
  392. package/dist/sdk/models/shared/upcominginvoice.js +193 -0
  393. package/dist/sdk/models/shared/updateevent.d.ts +28 -0
  394. package/dist/sdk/models/shared/updateevent.js +77 -0
  395. package/dist/sdk/models/shared/usage.d.ts +13 -0
  396. package/dist/sdk/models/shared/usage.js +69 -0
  397. package/dist/sdk/models/shared/usageitem.d.ts +6 -0
  398. package/dist/sdk/models/shared/usageitem.js +63 -0
  399. package/dist/sdk/models/shared/validationerrors.d.ts +13 -0
  400. package/dist/sdk/models/shared/validationerrors.js +59 -0
  401. package/dist/sdk/models/shared/viewmode.d.ts +7 -0
  402. package/dist/sdk/models/shared/viewmode.js +14 -0
  403. package/dist/sdk/plan.d.ts +222 -0
  404. package/dist/sdk/plan.js +422 -0
  405. package/dist/sdk/sdk.d.ts +298 -0
  406. package/dist/sdk/sdk.js +110 -0
  407. package/dist/sdk/subscription.d.ts +614 -0
  408. package/dist/sdk/subscription.js +1192 -0
  409. package/dist/sdk/types/index.d.ts +1 -0
  410. package/dist/sdk/types/index.js +20 -0
  411. package/dist/sdk/types/rfcdate.d.ts +9 -0
  412. package/dist/sdk/types/rfcdate.js +59 -0
  413. package/package.json +33 -0
@@ -0,0 +1,318 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
+ */
5
+ var __read = (this && this.__read) || function (o, n) {
6
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
7
+ if (!m) return o;
8
+ var i = m.call(o), r, ar = [], e;
9
+ try {
10
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
11
+ }
12
+ catch (error) { e = { error: error }; }
13
+ finally {
14
+ try {
15
+ if (r && !r.done && (m = i["return"])) m.call(i);
16
+ }
17
+ finally { if (e) throw e.error; }
18
+ }
19
+ return ar;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.serializeRequestBody = exports.requestMetadataKey = void 0;
26
+ var utils_1 = require("./utils");
27
+ var form_data_1 = __importDefault(require("form-data"));
28
+ var types_1 = require("../../sdk/types");
29
+ var class_transformer_1 = require("class-transformer");
30
+ exports.requestMetadataKey = "request";
31
+ var mpFormMetadataKey = "multipart_form";
32
+ function serializeRequestBody(request, requestFieldName, serializationMethod) {
33
+ if (request !== Object(request) ||
34
+ !request.hasOwnProperty(requestFieldName)) {
35
+ return serializeContentType(utils_1.SerializationMethodToContentType[serializationMethod], request);
36
+ }
37
+ var requestBodyAnn = Reflect.getMetadata(exports.requestMetadataKey, request, requestFieldName);
38
+ if (!requestBodyAnn) {
39
+ throw new Error("invalid request type");
40
+ }
41
+ var requestDecorator = parseRequestDecorator(requestBodyAnn);
42
+ return serializeContentType(requestDecorator.MediaType, request[requestFieldName]);
43
+ }
44
+ exports.serializeRequestBody = serializeRequestBody;
45
+ var serializeContentType = function (contentType, reqBody) {
46
+ var _a, _b, _c;
47
+ var _d = __read([{}, {}], 2), requestHeaders = _d[0], requestBody = _d[1];
48
+ switch (contentType) {
49
+ case "multipart/form-data":
50
+ requestBody = encodeMultipartFormData(reqBody);
51
+ break;
52
+ case "multipart/mixed":
53
+ requestBody = encodeMultipartFormData(reqBody);
54
+ requestHeaders = requestBody.getHeaders();
55
+ break;
56
+ case "application/x-www-form-urlencoded":
57
+ _a = __read([
58
+ { "Content-Type": "".concat(contentType) },
59
+ encodeFormUrlEncodeData(reqBody),
60
+ ], 2), requestHeaders = _a[0], requestBody = _a[1];
61
+ break;
62
+ case "application/json":
63
+ _b = __read([
64
+ { "Content-Type": "".concat(contentType) },
65
+ (0, class_transformer_1.classToPlain)(reqBody, { exposeUnsetFields: false }),
66
+ ], 2), requestHeaders = _b[0], requestBody = _b[1];
67
+ break;
68
+ case "text/json":
69
+ _c = __read([
70
+ { "Content-Type": "".concat(contentType) },
71
+ reqBody,
72
+ ], 2), requestHeaders = _c[0], requestBody = _c[1];
73
+ break;
74
+ default: {
75
+ requestBody = reqBody;
76
+ var requestBodyType = typeof requestBody;
77
+ if (requestBodyType === "string" ||
78
+ requestBody instanceof String ||
79
+ requestBody instanceof Uint8Array)
80
+ requestHeaders = { "Content-Type": "".concat(contentType) };
81
+ else
82
+ throw new Error("invalid request body type ".concat(requestBodyType, " for mediaType ").concat(contentType));
83
+ }
84
+ }
85
+ return [requestHeaders, requestBody];
86
+ };
87
+ var encodeFormUrlEncodeData = function (data) {
88
+ var formData = new form_data_1.default();
89
+ var fieldNames = Object.getOwnPropertyNames(data);
90
+ if ((0, utils_1.isNumberRecord)(data) || (0, utils_1.isBooleanRecord)(data) || (0, utils_1.isStringRecord)(data)) {
91
+ fieldNames.forEach(function (fname) {
92
+ formData.append(fname, String(data[fname]));
93
+ });
94
+ }
95
+ else {
96
+ fieldNames.forEach(function (fname) {
97
+ var _a;
98
+ var formAnn = Reflect.getMetadata("form", data, fname);
99
+ if (formAnn === null) {
100
+ return;
101
+ }
102
+ var formDecorator = parseFormDecorator(formAnn);
103
+ if (formDecorator.JSON) {
104
+ formData.append((_a = formDecorator.Name) !== null && _a !== void 0 ? _a : fname, JSON.stringify(data[fname]));
105
+ return;
106
+ }
107
+ if (formDecorator.Style === "form") {
108
+ var parsed_1;
109
+ if (formDecorator.Explode === true) {
110
+ parsed_1 = formExplode(fname, data[fname]);
111
+ }
112
+ else {
113
+ parsed_1 = formNotExplode(fname, data[fname]);
114
+ }
115
+ Object.keys(parsed_1).forEach(function (key) {
116
+ parsed_1[key].forEach(function (v) { return formData.append(key, v); });
117
+ });
118
+ return;
119
+ }
120
+ });
121
+ }
122
+ return formData;
123
+ };
124
+ var formExplode = function (fname, data) {
125
+ var exploded = {};
126
+ if (Array.isArray(data)) {
127
+ data.forEach(function (value) {
128
+ if (!exploded[fname]) {
129
+ exploded[fname] = [];
130
+ }
131
+ exploded[fname].push(value);
132
+ });
133
+ }
134
+ else if (typeof data === "object") {
135
+ if (data instanceof Date || data instanceof types_1.RFCDate) {
136
+ if (!exploded[fname]) {
137
+ exploded[fname] = [];
138
+ }
139
+ exploded[fname].push((0, utils_1.valToString)(data));
140
+ }
141
+ else {
142
+ Object.keys(data).forEach(function (key) {
143
+ if (!exploded[key]) {
144
+ exploded[key] = [];
145
+ }
146
+ exploded[key].push(data[key]);
147
+ });
148
+ }
149
+ }
150
+ else {
151
+ if (!exploded[fname]) {
152
+ exploded[fname] = [];
153
+ }
154
+ exploded[fname].push((0, utils_1.valToString)(data));
155
+ }
156
+ return exploded;
157
+ };
158
+ var formNotExplode = function (fname, data) {
159
+ var notExploded = {};
160
+ if (Array.isArray(data)) {
161
+ if (!notExploded[fname]) {
162
+ notExploded[fname] = [];
163
+ }
164
+ notExploded[fname].push(data.map(function (item) { return item.toString(); }).join(","));
165
+ }
166
+ else if (typeof data === "object") {
167
+ if (data instanceof Date || data instanceof types_1.RFCDate) {
168
+ if (!notExploded[fname]) {
169
+ notExploded[fname] = [];
170
+ }
171
+ notExploded[fname].push((0, utils_1.valToString)(data));
172
+ }
173
+ else {
174
+ Object.keys(data).forEach(function (key) {
175
+ if (!notExploded[key]) {
176
+ notExploded[key] = [];
177
+ }
178
+ notExploded[fname].push("".concat(key, "=").concat(data[key]));
179
+ });
180
+ }
181
+ }
182
+ else {
183
+ if (!notExploded[fname]) {
184
+ notExploded[fname] = [];
185
+ }
186
+ notExploded[fname].push((0, utils_1.valToString)(data));
187
+ }
188
+ return notExploded;
189
+ };
190
+ function parseFormDecorator(formAnn) {
191
+ var formDecorator = new FormDecorator("", "form", false, false);
192
+ formAnn.split(";").forEach(function (formAnnPart) {
193
+ var _a = __read(formAnnPart.split("="), 2), formKey = _a[0], formVal = _a[1];
194
+ switch (formKey) {
195
+ case "name":
196
+ formDecorator.Name = formVal;
197
+ break;
198
+ case "style":
199
+ formDecorator.Style = formVal;
200
+ break;
201
+ case "explode":
202
+ formDecorator.Explode = formVal === "true";
203
+ break;
204
+ case "json":
205
+ formDecorator.JSON = formVal === "true";
206
+ break;
207
+ }
208
+ });
209
+ return formDecorator;
210
+ }
211
+ var FormDecorator = /** @class */ (function () {
212
+ function FormDecorator(Name, Style, Explode, JSON) {
213
+ this.Name = Name;
214
+ this.Style = Style;
215
+ this.Explode = Explode;
216
+ this.JSON = JSON;
217
+ }
218
+ return FormDecorator;
219
+ }());
220
+ function encodeMultipartFormData(form) {
221
+ var formData = new form_data_1.default();
222
+ var fieldNames = Object.getOwnPropertyNames(form);
223
+ fieldNames.forEach(function (fname) {
224
+ var mpFormAnn = Reflect.getMetadata(mpFormMetadataKey, form, fname);
225
+ if (mpFormAnn == null)
226
+ return;
227
+ var mpFormDecorator = parseMultipartFormDecorator(mpFormAnn);
228
+ if (mpFormDecorator.File)
229
+ return encodeMultipartFormDataFile(formData, form[fname]);
230
+ else if (mpFormDecorator.JSON) {
231
+ formData.append(mpFormDecorator.Name, JSON.stringify(form[fname]));
232
+ }
233
+ else {
234
+ if (Array.isArray(form[fname])) {
235
+ form[fname].forEach(function (val) {
236
+ formData.append(mpFormDecorator.Name + "[]", (0, utils_1.valToString)(val));
237
+ });
238
+ }
239
+ else {
240
+ formData.append(mpFormDecorator.Name, (0, utils_1.valToString)(form[fname]));
241
+ }
242
+ }
243
+ });
244
+ return formData;
245
+ }
246
+ function encodeMultipartFormDataFile(formData, file) {
247
+ if (typeof file !== "object" || Array.isArray(file) || file == null) {
248
+ throw new Error("invalid type for multipart/form-data file");
249
+ }
250
+ var content = null;
251
+ var fileName = "";
252
+ var mpFormDecoratorName = "";
253
+ var fieldNames = Object.getOwnPropertyNames(file);
254
+ fieldNames.forEach(function (fname) {
255
+ var mpFormAnn = Reflect.getMetadata(mpFormMetadataKey, file, fname);
256
+ if (mpFormAnn == null)
257
+ return;
258
+ var mpFormDecorator = parseMultipartFormDecorator(mpFormAnn);
259
+ if (!mpFormDecorator.Content && mpFormDecorator.Name == "")
260
+ return;
261
+ if (mpFormDecorator.Content)
262
+ content = file[fname];
263
+ else {
264
+ mpFormDecoratorName = mpFormDecorator.Name;
265
+ fileName = file[fname];
266
+ }
267
+ });
268
+ if (mpFormDecoratorName === "" || fileName === "" || content == null) {
269
+ throw new Error("invalid multipart/form-data file");
270
+ }
271
+ formData.append("file", Buffer.from(content), fileName);
272
+ return formData;
273
+ }
274
+ function parseMultipartFormDecorator(mpFormAnn) {
275
+ // example "name=file"
276
+ var mpFormDecorator = new MultipartFormDecorator(false, false, false, "");
277
+ mpFormAnn.split(";").forEach(function (mpFormAnnPart) {
278
+ var _a = __read(mpFormAnnPart.split("="), 2), mpFormKey = _a[0], mpFormVal = _a[1];
279
+ switch (mpFormKey) {
280
+ case "file":
281
+ mpFormDecorator.File = mpFormVal == "true";
282
+ break;
283
+ case "content":
284
+ mpFormDecorator.Content = mpFormVal == "true";
285
+ break;
286
+ case "name":
287
+ mpFormDecorator.Name = mpFormVal;
288
+ break;
289
+ case "json":
290
+ mpFormDecorator.JSON = mpFormVal == "true";
291
+ break;
292
+ }
293
+ });
294
+ return mpFormDecorator;
295
+ }
296
+ var MultipartFormDecorator = /** @class */ (function () {
297
+ function MultipartFormDecorator(File, Content, JSON, Name) {
298
+ this.File = File;
299
+ this.Content = Content;
300
+ this.JSON = JSON;
301
+ this.Name = Name;
302
+ }
303
+ return MultipartFormDecorator;
304
+ }());
305
+ function parseRequestDecorator(requestAnn) {
306
+ // example "media_type=multipart/form-data"
307
+ var requestDecorator = new RequestDecorator("application/octet-stream");
308
+ var _a = __read(requestAnn.split("="), 2), mediaTypeKey = _a[0], mediaTypeVal = _a[1];
309
+ if (mediaTypeKey === "media_type")
310
+ requestDecorator.MediaType = mediaTypeVal;
311
+ return requestDecorator;
312
+ }
313
+ var RequestDecorator = /** @class */ (function () {
314
+ function RequestDecorator(MediaType) {
315
+ this.MediaType = MediaType;
316
+ }
317
+ return RequestDecorator;
318
+ }());
@@ -0,0 +1,20 @@
1
+ import { AxiosResponse } from "axios";
2
+ export declare class BackoffStrategy {
3
+ initialInterval: number;
4
+ maxInterval: number;
5
+ exponent: number;
6
+ maxElapsedTime: number;
7
+ constructor(initialInterval: number, maxInterval: number, exponent: number, maxElapsedTime: number);
8
+ }
9
+ export declare class RetryConfig {
10
+ strategy: string;
11
+ backoff?: BackoffStrategy;
12
+ retryConnectionErrors: boolean;
13
+ constructor(strategy: string, backoff?: BackoffStrategy, retryConnectionErrors?: boolean);
14
+ }
15
+ export declare class Retries {
16
+ config: RetryConfig;
17
+ statusCodes: string[];
18
+ constructor(config: RetryConfig, statusCodes: string[]);
19
+ }
20
+ export declare function Retry(fn: () => Promise<AxiosResponse<any, any>>, retries: Retries): Promise<AxiosResponse<any, any>>;
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
+ */
5
+ var __extends = (this && this.__extends) || (function () {
6
+ var extendStatics = function (d, b) {
7
+ extendStatics = Object.setPrototypeOf ||
8
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
10
+ return extendStatics(d, b);
11
+ };
12
+ return function (d, b) {
13
+ if (typeof b !== "function" && b !== null)
14
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
15
+ extendStatics(d, b);
16
+ function __() { this.constructor = d; }
17
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18
+ };
19
+ })();
20
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
21
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
22
+ return new (P || (P = Promise))(function (resolve, reject) {
23
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
25
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
26
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
27
+ });
28
+ };
29
+ var __generator = (this && this.__generator) || function (thisArg, body) {
30
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
31
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
32
+ function verb(n) { return function (v) { return step([n, v]); }; }
33
+ function step(op) {
34
+ if (f) throw new TypeError("Generator is already executing.");
35
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
36
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
37
+ if (y = 0, t) op = [op[0] & 2, t.value];
38
+ switch (op[0]) {
39
+ case 0: case 1: t = op; break;
40
+ case 4: _.label++; return { value: op[1], done: false };
41
+ case 5: _.label++; y = op[1]; op = [0]; continue;
42
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
43
+ default:
44
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
45
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
46
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
47
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
48
+ if (t[2]) _.ops.pop();
49
+ _.trys.pop(); continue;
50
+ }
51
+ op = body.call(thisArg, _);
52
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
53
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
54
+ }
55
+ };
56
+ var __values = (this && this.__values) || function(o) {
57
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
58
+ if (m) return m.call(o);
59
+ if (o && typeof o.length === "number") return {
60
+ next: function () {
61
+ if (o && i >= o.length) o = void 0;
62
+ return { value: o && o[i++], done: !o };
63
+ }
64
+ };
65
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
66
+ };
67
+ Object.defineProperty(exports, "__esModule", { value: true });
68
+ exports.Retry = exports.Retries = exports.RetryConfig = exports.BackoffStrategy = void 0;
69
+ var axios_1 = require("axios");
70
+ var BackoffStrategy = /** @class */ (function () {
71
+ function BackoffStrategy(initialInterval, maxInterval, exponent, maxElapsedTime) {
72
+ this.initialInterval = initialInterval;
73
+ this.maxInterval = maxInterval;
74
+ this.exponent = exponent;
75
+ this.maxElapsedTime = maxElapsedTime;
76
+ }
77
+ return BackoffStrategy;
78
+ }());
79
+ exports.BackoffStrategy = BackoffStrategy;
80
+ var RetryConfig = /** @class */ (function () {
81
+ function RetryConfig(strategy, backoff, retryConnectionErrors) {
82
+ if (retryConnectionErrors === void 0) { retryConnectionErrors = true; }
83
+ this.strategy = strategy;
84
+ this.backoff = backoff;
85
+ this.retryConnectionErrors = retryConnectionErrors;
86
+ }
87
+ return RetryConfig;
88
+ }());
89
+ exports.RetryConfig = RetryConfig;
90
+ var Retries = /** @class */ (function () {
91
+ function Retries(config, statusCodes) {
92
+ this.config = config;
93
+ this.statusCodes = statusCodes;
94
+ }
95
+ return Retries;
96
+ }());
97
+ exports.Retries = Retries;
98
+ var PermanentError = /** @class */ (function (_super) {
99
+ __extends(PermanentError, _super);
100
+ function PermanentError(inner) {
101
+ var _this = _super.call(this, "Permanent error") || this;
102
+ _this.inner = inner;
103
+ Object.setPrototypeOf(_this, PermanentError.prototype);
104
+ return _this;
105
+ }
106
+ return PermanentError;
107
+ }(Error));
108
+ var TemporaryError = /** @class */ (function (_super) {
109
+ __extends(TemporaryError, _super);
110
+ function TemporaryError(res) {
111
+ var _this = _super.call(this, "Temporary error") || this;
112
+ _this.res = res;
113
+ Object.setPrototypeOf(_this, TemporaryError.prototype);
114
+ return _this;
115
+ }
116
+ return TemporaryError;
117
+ }(Error));
118
+ function Retry(fn, retries) {
119
+ var _a, _b, _c, _d, _e, _f, _g, _h;
120
+ return __awaiter(this, void 0, void 0, function () {
121
+ var _j;
122
+ var _this = this;
123
+ return __generator(this, function (_k) {
124
+ switch (_k.label) {
125
+ case 0:
126
+ _j = retries.config.strategy;
127
+ switch (_j) {
128
+ case "backoff": return [3 /*break*/, 1];
129
+ }
130
+ return [3 /*break*/, 2];
131
+ case 1: return [2 /*return*/, retryBackoff(function () { return __awaiter(_this, void 0, void 0, function () {
132
+ var res, err_1;
133
+ return __generator(this, function (_a) {
134
+ switch (_a.label) {
135
+ case 0:
136
+ _a.trys.push([0, 2, , 3]);
137
+ return [4 /*yield*/, fn()];
138
+ case 1:
139
+ res = _a.sent();
140
+ if (isRetryableResponse(res, retries.statusCodes)) {
141
+ throw new TemporaryError(res);
142
+ }
143
+ return [2 /*return*/, res];
144
+ case 2:
145
+ err_1 = _a.sent();
146
+ if (err_1 instanceof axios_1.AxiosError) {
147
+ if (err_1.response) {
148
+ if (isRetryableResponse(err_1.response, retries.statusCodes)) {
149
+ throw err_1;
150
+ }
151
+ throw new PermanentError(err_1);
152
+ }
153
+ else if (err_1.request) {
154
+ throw err_1;
155
+ }
156
+ else {
157
+ throw new PermanentError(err_1);
158
+ }
159
+ }
160
+ else if (err_1 instanceof TemporaryError) {
161
+ throw err_1;
162
+ }
163
+ throw new PermanentError(err_1);
164
+ case 3: return [2 /*return*/];
165
+ }
166
+ });
167
+ }); }, (_b = (_a = retries.config.backoff) === null || _a === void 0 ? void 0 : _a.initialInterval) !== null && _b !== void 0 ? _b : 500, (_d = (_c = retries.config.backoff) === null || _c === void 0 ? void 0 : _c.maxInterval) !== null && _d !== void 0 ? _d : 60000, (_f = (_e = retries.config.backoff) === null || _e === void 0 ? void 0 : _e.exponent) !== null && _f !== void 0 ? _f : 1.5, (_h = (_g = retries.config.backoff) === null || _g === void 0 ? void 0 : _g.maxElapsedTime) !== null && _h !== void 0 ? _h : 3600000)];
168
+ case 2: return [4 /*yield*/, fn()];
169
+ case 3: return [2 /*return*/, _k.sent()];
170
+ }
171
+ });
172
+ });
173
+ }
174
+ exports.Retry = Retry;
175
+ function isRetryableResponse(res, statusCodes) {
176
+ var e_1, _a;
177
+ try {
178
+ for (var statusCodes_1 = __values(statusCodes), statusCodes_1_1 = statusCodes_1.next(); !statusCodes_1_1.done; statusCodes_1_1 = statusCodes_1.next()) {
179
+ var code = statusCodes_1_1.value;
180
+ if (code.toUpperCase().includes("X")) {
181
+ var codeRange = parseInt(code[0]);
182
+ if (isNaN(codeRange)) {
183
+ throw new Error("Invalid status code range");
184
+ }
185
+ var s = res.status / 100;
186
+ if (s >= codeRange && s < codeRange + 1) {
187
+ return true;
188
+ }
189
+ }
190
+ else if (res.status == parseInt(code)) {
191
+ return true;
192
+ }
193
+ }
194
+ }
195
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
196
+ finally {
197
+ try {
198
+ if (statusCodes_1_1 && !statusCodes_1_1.done && (_a = statusCodes_1.return)) _a.call(statusCodes_1);
199
+ }
200
+ finally { if (e_1) throw e_1.error; }
201
+ }
202
+ return false;
203
+ }
204
+ function retryBackoff(fn, initialInterval, maxInterval, exponent, maxElapsedTime) {
205
+ return __awaiter(this, void 0, void 0, function () {
206
+ var start, x, err_2, now, d;
207
+ return __generator(this, function (_a) {
208
+ switch (_a.label) {
209
+ case 0:
210
+ start = Date.now();
211
+ x = 0;
212
+ _a.label = 1;
213
+ case 1:
214
+ if (!true) return [3 /*break*/, 7];
215
+ _a.label = 2;
216
+ case 2:
217
+ _a.trys.push([2, 4, , 6]);
218
+ return [4 /*yield*/, fn()];
219
+ case 3: return [2 /*return*/, _a.sent()];
220
+ case 4:
221
+ err_2 = _a.sent();
222
+ if (err_2 instanceof PermanentError) {
223
+ throw err_2.inner;
224
+ }
225
+ now = Date.now();
226
+ if (now - start > maxElapsedTime) {
227
+ if (err_2 instanceof TemporaryError) {
228
+ return [2 /*return*/, err_2.res];
229
+ }
230
+ throw err_2;
231
+ }
232
+ d = Math.min(initialInterval * Math.pow(x, exponent) + Math.random() * 1000, maxInterval);
233
+ return [4 /*yield*/, delay(d)];
234
+ case 5:
235
+ _a.sent();
236
+ x++;
237
+ return [3 /*break*/, 6];
238
+ case 6: return [3 /*break*/, 1];
239
+ case 7: return [2 /*return*/];
240
+ }
241
+ });
242
+ });
243
+ }
244
+ function delay(delay) {
245
+ return __awaiter(this, void 0, void 0, function () {
246
+ return __generator(this, function (_a) {
247
+ return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, delay); })];
248
+ });
249
+ });
250
+ }
@@ -0,0 +1,2 @@
1
+ import { AxiosInstance } from "axios";
2
+ export declare function createSecurityClient(client: AxiosInstance, security: any): AxiosInstance;