@fantastic.dev/better-stripe 0.7.0 → 0.8.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 (359) hide show
  1. package/CHANGELOG.md +29 -18
  2. package/README.md +123 -91
  3. package/dist/client/billing/checkout.d.ts +1 -1
  4. package/dist/client/billing/checkout.d.ts.map +1 -1
  5. package/dist/client/billing/checkout.js +7 -2
  6. package/dist/client/billing/checkout.js.map +1 -1
  7. package/dist/client/connect/disputes.d.ts +1 -1
  8. package/dist/client/connect/disputes.d.ts.map +1 -1
  9. package/dist/client/connect/disputes.js +12 -6
  10. package/dist/client/connect/disputes.js.map +1 -1
  11. package/dist/client/connect/paymentMethods.d.ts.map +1 -1
  12. package/dist/client/connect/paymentMethods.js.map +1 -1
  13. package/dist/client/connect/refundActor.d.ts.map +1 -1
  14. package/dist/client/connect/refundActor.js.map +1 -1
  15. package/dist/client/connect/refunds.d.ts.map +1 -1
  16. package/dist/client/connect/refunds.js.map +1 -1
  17. package/dist/client/connect/transfers.d.ts.map +1 -1
  18. package/dist/client/connect/transfers.js +15 -4
  19. package/dist/client/connect/transfers.js.map +1 -1
  20. package/dist/client/core/accountDefaults.d.ts +6 -0
  21. package/dist/client/core/accountDefaults.d.ts.map +1 -0
  22. package/dist/client/core/accountDefaults.js +15 -0
  23. package/dist/client/core/accountDefaults.js.map +1 -0
  24. package/dist/client/core/accounts.d.ts +1 -5
  25. package/dist/client/core/accounts.d.ts.map +1 -1
  26. package/dist/client/core/accounts.js +2 -14
  27. package/dist/client/core/accounts.js.map +1 -1
  28. package/dist/client/core/fees.d.ts.map +1 -1
  29. package/dist/client/core/fees.js +7 -2
  30. package/dist/client/core/fees.js.map +1 -1
  31. package/dist/client/index.d.ts +1 -1
  32. package/dist/client/index.d.ts.map +1 -1
  33. package/dist/client/products/prices.d.ts.map +1 -1
  34. package/dist/client/products/prices.js.map +1 -1
  35. package/dist/client/products/products.d.ts.map +1 -1
  36. package/dist/client/products/products.js +3 -1
  37. package/dist/client/products/products.js.map +1 -1
  38. package/dist/client/utils/owner.d.ts.map +1 -1
  39. package/dist/client/utils/owner.js +3 -1
  40. package/dist/client/utils/owner.js.map +1 -1
  41. package/dist/client/utils/stripeDashboardUrl.d.ts.map +1 -1
  42. package/dist/client/utils/stripeDashboardUrl.js.map +1 -1
  43. package/dist/client/webhooks/helpers.d.ts +10 -0
  44. package/dist/client/webhooks/helpers.d.ts.map +1 -1
  45. package/dist/client/webhooks/helpers.js +18 -0
  46. package/dist/client/webhooks/helpers.js.map +1 -1
  47. package/dist/client/webhooks/processors.d.ts.map +1 -1
  48. package/dist/client/webhooks/processors.js +1 -19
  49. package/dist/client/webhooks/processors.js.map +1 -1
  50. package/dist/component/connect/mutations.d.ts.map +1 -1
  51. package/dist/component/connect/mutations.js +4 -33
  52. package/dist/component/connect/mutations.js.map +1 -1
  53. package/dist/component/connect/schema.d.ts.map +1 -1
  54. package/dist/component/connect/schema.js.map +1 -1
  55. package/dist/component/lib/paymentSeller.d.ts +3 -0
  56. package/dist/component/lib/paymentSeller.d.ts.map +1 -0
  57. package/dist/component/lib/paymentSeller.js +10 -0
  58. package/dist/component/lib/paymentSeller.js.map +1 -0
  59. package/dist/component/lib/reversals.d.ts +10 -0
  60. package/dist/component/lib/reversals.d.ts.map +1 -1
  61. package/dist/component/lib/reversals.js +17 -0
  62. package/dist/component/lib/reversals.js.map +1 -1
  63. package/dist/react/components/ConnectProvider.d.ts +1 -1
  64. package/dist/react/components/ConnectProvider.d.ts.map +1 -1
  65. package/dist/react/components/ConnectProvider.js +18 -4
  66. package/dist/react/components/ConnectProvider.js.map +1 -1
  67. package/dist/react/components/ConnectStatusBadge.d.ts.map +1 -1
  68. package/dist/react/components/ConnectStatusBadge.js.map +1 -1
  69. package/dist/react/components/DisputeDetail.d.ts +4 -1
  70. package/dist/react/components/DisputeDetail.d.ts.map +1 -1
  71. package/dist/react/components/DisputeDetail.js +12 -6
  72. package/dist/react/components/DisputeDetail.js.map +1 -1
  73. package/dist/react/components/DisputesList.d.ts.map +1 -1
  74. package/dist/react/components/DisputesList.js +2 -1
  75. package/dist/react/components/DisputesList.js.map +1 -1
  76. package/dist/react/components/EmbeddedDisputes.d.ts +1 -1
  77. package/dist/react/components/EmbeddedDisputes.d.ts.map +1 -1
  78. package/dist/react/components/EmbeddedDisputes.js +1 -1
  79. package/dist/react/components/EmbeddedDisputes.js.map +1 -1
  80. package/dist/react/components/SplitBreakdown.d.ts.map +1 -1
  81. package/dist/react/components/SplitBreakdown.js +12 -2
  82. package/dist/react/components/SplitBreakdown.js.map +1 -1
  83. package/dist/react/hooks/useCheckoutSession.d.ts.map +1 -1
  84. package/dist/react/hooks/useCheckoutSession.js.map +1 -1
  85. package/dist/react/hooks/useConfirmPayment.d.ts.map +1 -1
  86. package/dist/react/hooks/useConfirmPayment.js.map +1 -1
  87. package/dist/react/index.d.ts +2 -1
  88. package/dist/react/index.d.ts.map +1 -1
  89. package/dist/react/index.js +3 -1
  90. package/dist/react/index.js.map +1 -1
  91. package/dist/react/workflows/Account.d.ts +67 -0
  92. package/dist/react/workflows/Account.d.ts.map +1 -0
  93. package/dist/react/workflows/Account.js +74 -0
  94. package/dist/react/workflows/Account.js.map +1 -0
  95. package/dist/react/workflows/Billing.d.ts +60 -0
  96. package/dist/react/workflows/Billing.d.ts.map +1 -0
  97. package/dist/react/workflows/Billing.js +84 -0
  98. package/dist/react/workflows/Billing.js.map +1 -0
  99. package/dist/react/workflows/BillingPlans.d.ts +45 -0
  100. package/dist/react/workflows/BillingPlans.d.ts.map +1 -0
  101. package/dist/react/workflows/BillingPlans.js +51 -0
  102. package/dist/react/workflows/BillingPlans.js.map +1 -0
  103. package/dist/react/workflows/Checkout.d.ts +46 -0
  104. package/dist/react/workflows/Checkout.d.ts.map +1 -0
  105. package/dist/react/workflows/Checkout.js +61 -0
  106. package/dist/react/workflows/Checkout.js.map +1 -0
  107. package/dist/react/workflows/CheckoutChooser.d.ts +20 -0
  108. package/dist/react/workflows/CheckoutChooser.d.ts.map +1 -0
  109. package/dist/react/workflows/CheckoutChooser.js +24 -0
  110. package/dist/react/workflows/CheckoutChooser.js.map +1 -0
  111. package/dist/react/workflows/CheckoutForms.d.ts +26 -0
  112. package/dist/react/workflows/CheckoutForms.d.ts.map +1 -0
  113. package/dist/react/workflows/CheckoutForms.js +126 -0
  114. package/dist/react/workflows/CheckoutForms.js.map +1 -0
  115. package/dist/react/workflows/ClipboardButton.d.ts +17 -0
  116. package/dist/react/workflows/ClipboardButton.d.ts.map +1 -0
  117. package/dist/react/workflows/ClipboardButton.js +35 -0
  118. package/dist/react/workflows/ClipboardButton.js.map +1 -0
  119. package/dist/react/workflows/Collection.d.ts +30 -0
  120. package/dist/react/workflows/Collection.d.ts.map +1 -0
  121. package/dist/react/workflows/Collection.js +25 -0
  122. package/dist/react/workflows/Collection.js.map +1 -0
  123. package/dist/react/workflows/Collections.d.ts +56 -0
  124. package/dist/react/workflows/Collections.d.ts.map +1 -0
  125. package/dist/react/workflows/Collections.js +111 -0
  126. package/dist/react/workflows/Collections.js.map +1 -0
  127. package/dist/react/workflows/Connect.d.ts +19 -0
  128. package/dist/react/workflows/Connect.d.ts.map +1 -0
  129. package/dist/react/workflows/Connect.js +43 -0
  130. package/dist/react/workflows/Connect.js.map +1 -0
  131. package/dist/react/workflows/Costs.d.ts +48 -0
  132. package/dist/react/workflows/Costs.d.ts.map +1 -0
  133. package/dist/react/workflows/Costs.js +66 -0
  134. package/dist/react/workflows/Costs.js.map +1 -0
  135. package/dist/react/workflows/Disputes.d.ts +36 -0
  136. package/dist/react/workflows/Disputes.d.ts.map +1 -0
  137. package/dist/react/workflows/Disputes.js +74 -0
  138. package/dist/react/workflows/Disputes.js.map +1 -0
  139. package/dist/react/workflows/Earnings.d.ts +42 -0
  140. package/dist/react/workflows/Earnings.d.ts.map +1 -0
  141. package/dist/react/workflows/Earnings.js +38 -0
  142. package/dist/react/workflows/Earnings.js.map +1 -0
  143. package/dist/react/workflows/Financials.d.ts +43 -0
  144. package/dist/react/workflows/Financials.d.ts.map +1 -0
  145. package/dist/react/workflows/Financials.js +57 -0
  146. package/dist/react/workflows/Financials.js.map +1 -0
  147. package/dist/react/workflows/IntegrationSwitch.d.ts +23 -0
  148. package/dist/react/workflows/IntegrationSwitch.d.ts.map +1 -0
  149. package/dist/react/workflows/IntegrationSwitch.js +31 -0
  150. package/dist/react/workflows/IntegrationSwitch.js.map +1 -0
  151. package/dist/react/workflows/Onboarding.d.ts +56 -0
  152. package/dist/react/workflows/Onboarding.d.ts.map +1 -0
  153. package/dist/react/workflows/Onboarding.js +86 -0
  154. package/dist/react/workflows/Onboarding.js.map +1 -0
  155. package/dist/react/workflows/Overview.d.ts +51 -0
  156. package/dist/react/workflows/Overview.d.ts.map +1 -0
  157. package/dist/react/workflows/Overview.js +63 -0
  158. package/dist/react/workflows/Overview.js.map +1 -0
  159. package/dist/react/workflows/PaymentMethods.d.ts +35 -0
  160. package/dist/react/workflows/PaymentMethods.d.ts.map +1 -0
  161. package/dist/react/workflows/PaymentMethods.js +63 -0
  162. package/dist/react/workflows/PaymentMethods.js.map +1 -0
  163. package/dist/react/workflows/PaymentReceipt.d.ts +20 -0
  164. package/dist/react/workflows/PaymentReceipt.d.ts.map +1 -0
  165. package/dist/react/workflows/PaymentReceipt.js +24 -0
  166. package/dist/react/workflows/PaymentReceipt.js.map +1 -0
  167. package/dist/react/workflows/Payouts.d.ts +48 -0
  168. package/dist/react/workflows/Payouts.d.ts.map +1 -0
  169. package/dist/react/workflows/Payouts.js +88 -0
  170. package/dist/react/workflows/Payouts.js.map +1 -0
  171. package/dist/react/workflows/Products.d.ts +92 -0
  172. package/dist/react/workflows/Products.d.ts.map +1 -0
  173. package/dist/react/workflows/Products.js +179 -0
  174. package/dist/react/workflows/Products.js.map +1 -0
  175. package/dist/react/workflows/ReferralLinks.d.ts +26 -0
  176. package/dist/react/workflows/ReferralLinks.d.ts.map +1 -0
  177. package/dist/react/workflows/ReferralLinks.js +30 -0
  178. package/dist/react/workflows/ReferralLinks.js.map +1 -0
  179. package/dist/react/workflows/Refunds.d.ts +72 -0
  180. package/dist/react/workflows/Refunds.d.ts.map +1 -0
  181. package/dist/react/workflows/Refunds.js +95 -0
  182. package/dist/react/workflows/Refunds.js.map +1 -0
  183. package/dist/react/workflows/Setup.d.ts +50 -0
  184. package/dist/react/workflows/Setup.d.ts.map +1 -0
  185. package/dist/react/workflows/Setup.js +59 -0
  186. package/dist/react/workflows/Setup.js.map +1 -0
  187. package/dist/react/workflows/Storefront.d.ts +53 -0
  188. package/dist/react/workflows/Storefront.d.ts.map +1 -0
  189. package/dist/react/workflows/Storefront.js +44 -0
  190. package/dist/react/workflows/Storefront.js.map +1 -0
  191. package/dist/react/workflows/SubscriptionOverview.d.ts +13 -0
  192. package/dist/react/workflows/SubscriptionOverview.d.ts.map +1 -0
  193. package/dist/react/workflows/SubscriptionOverview.js +26 -0
  194. package/dist/react/workflows/SubscriptionOverview.js.map +1 -0
  195. package/dist/react/workflows/Subscriptions.d.ts +92 -0
  196. package/dist/react/workflows/Subscriptions.d.ts.map +1 -0
  197. package/dist/react/workflows/Subscriptions.js +149 -0
  198. package/dist/react/workflows/Subscriptions.js.map +1 -0
  199. package/dist/react/workflows/Tasks.d.ts +40 -0
  200. package/dist/react/workflows/Tasks.d.ts.map +1 -0
  201. package/dist/react/workflows/Tasks.js +113 -0
  202. package/dist/react/workflows/Tasks.js.map +1 -0
  203. package/dist/react/workflows/checkout-options.d.ts +37 -0
  204. package/dist/react/workflows/checkout-options.d.ts.map +1 -0
  205. package/dist/react/workflows/checkout-options.js +43 -0
  206. package/dist/react/workflows/checkout-options.js.map +1 -0
  207. package/dist/react/workflows/current-subscription.d.ts +11 -0
  208. package/dist/react/workflows/current-subscription.d.ts.map +1 -0
  209. package/dist/react/workflows/current-subscription.js +14 -0
  210. package/dist/react/workflows/current-subscription.js.map +1 -0
  211. package/dist/react/workflows/filters.d.ts +17 -0
  212. package/dist/react/workflows/filters.d.ts.map +1 -0
  213. package/dist/react/workflows/filters.js +23 -0
  214. package/dist/react/workflows/filters.js.map +1 -0
  215. package/dist/react/workflows/index.d.ts +70 -0
  216. package/dist/react/workflows/index.d.ts.map +1 -0
  217. package/dist/react/workflows/index.js +38 -0
  218. package/dist/react/workflows/index.js.map +1 -0
  219. package/dist/react/workflows/useWorkflowAction.d.ts +11 -0
  220. package/dist/react/workflows/useWorkflowAction.d.ts.map +1 -0
  221. package/dist/react/workflows/useWorkflowAction.js +68 -0
  222. package/dist/react/workflows/useWorkflowAction.js.map +1 -0
  223. package/dist/react/workflows/useWorkflowResource.d.ts +9 -0
  224. package/dist/react/workflows/useWorkflowResource.d.ts.map +1 -0
  225. package/dist/react/workflows/useWorkflowResource.js +67 -0
  226. package/dist/react/workflows/useWorkflowResource.js.map +1 -0
  227. package/docs/react-workflows-audit.md +88 -0
  228. package/docs/react-workflows.md +234 -0
  229. package/package.json +19 -3
  230. package/src/client/billing/checkout-ui-modes.test.ts +49 -0
  231. package/src/client/billing/checkout.ts +8 -3
  232. package/src/client/billing/invoices.test.ts +12 -6
  233. package/src/client/connect/disputes.test.ts +15 -0
  234. package/src/client/connect/disputes.ts +13 -7
  235. package/src/client/connect/paymentMethods.test.ts +3 -1
  236. package/src/client/connect/paymentMethods.ts +4 -1
  237. package/src/client/connect/refundActor.ts +1 -2
  238. package/src/client/connect/refunds.test.ts +35 -10
  239. package/src/client/connect/refunds.ts +4 -1
  240. package/src/client/connect/transfers.test.ts +66 -12
  241. package/src/client/connect/transfers.ts +32 -8
  242. package/src/client/core/accountDefaults.ts +15 -0
  243. package/src/client/core/accounts.ts +14 -17
  244. package/src/client/core/config.test.ts +2 -1
  245. package/src/client/core/descriptors.test.ts +6 -4
  246. package/src/client/core/fees.test.ts +20 -28
  247. package/src/client/core/fees.ts +9 -2
  248. package/src/client/index.test.ts +22 -22
  249. package/src/client/index.ts +1 -1
  250. package/src/client/products/prices.test.ts +8 -2
  251. package/src/client/products/prices.ts +4 -1
  252. package/src/client/products/products.test.ts +61 -20
  253. package/src/client/products/products.ts +3 -1
  254. package/src/client/utils/data.test.ts +3 -1
  255. package/src/client/utils/owner.test.ts +4 -1
  256. package/src/client/utils/owner.ts +5 -1
  257. package/src/client/utils/stripeDashboardUrl.ts +1 -4
  258. package/src/client/webhooks/handler.test.ts +16 -19
  259. package/src/client/webhooks/helpers.test.ts +26 -13
  260. package/src/client/webhooks/helpers.ts +23 -0
  261. package/src/client/webhooks/hooks.test.ts +1 -2
  262. package/src/client/webhooks/processors.test.ts +18 -34
  263. package/src/client/webhooks/processors.ts +1 -23
  264. package/src/client/webhooks.test.ts +1 -2
  265. package/src/component/_generated/api.ts +2 -0
  266. package/src/component/connect/mutations.ts +5 -46
  267. package/src/component/connect/schema.ts +4 -3
  268. package/src/component/connect.test.ts +1 -5
  269. package/src/component/lib/paymentSeller.ts +15 -0
  270. package/src/component/lib/reversals.ts +30 -2
  271. package/src/component/subscription-scoping.test.ts +5 -1
  272. package/src/component/triggers.test.ts +7 -4
  273. package/src/react/components/BuyerBillingView.render.test.tsx +7 -2
  274. package/src/react/components/ConnectProvider.live.test.tsx +61 -0
  275. package/src/react/components/ConnectProvider.tsx +18 -4
  276. package/src/react/components/ConnectStatusBadge.tsx +1 -4
  277. package/src/react/components/DisputeDetail.render.test.tsx +5 -1
  278. package/src/react/components/DisputeDetail.tsx +14 -5
  279. package/src/react/components/DisputesList.render.test.tsx +21 -0
  280. package/src/react/components/DisputesList.tsx +2 -1
  281. package/src/react/components/EarningsSummary.render.test.tsx +2 -6
  282. package/src/react/components/EmbeddedDisputes.render.test.tsx +7 -5
  283. package/src/react/components/EmbeddedDisputes.tsx +4 -1
  284. package/src/react/components/EvidenceForm.render.test.tsx +3 -10
  285. package/src/react/components/SplitBreakdown.render.test.tsx +28 -5
  286. package/src/react/components/SplitBreakdown.tsx +12 -2
  287. package/src/react/hooks/useCheckoutSession.ts +1 -2
  288. package/src/react/hooks/useConfirmPayment.ts +1 -2
  289. package/src/react/hooks/useEarnings.test.ts +43 -8
  290. package/src/react/hooks/useStripeMode.test.ts +5 -8
  291. package/src/react/index.ts +7 -1
  292. package/src/react/workflows/Account.test.tsx +31 -0
  293. package/src/react/workflows/Account.tsx +183 -0
  294. package/src/react/workflows/Billing.test.tsx +45 -0
  295. package/src/react/workflows/Billing.tsx +213 -0
  296. package/src/react/workflows/BillingPlans.test.tsx +31 -0
  297. package/src/react/workflows/BillingPlans.tsx +130 -0
  298. package/src/react/workflows/Checkout.test.tsx +118 -0
  299. package/src/react/workflows/Checkout.tsx +135 -0
  300. package/src/react/workflows/CheckoutChooser.test.tsx +44 -0
  301. package/src/react/workflows/CheckoutChooser.tsx +77 -0
  302. package/src/react/workflows/CheckoutForm.test.tsx +66 -0
  303. package/src/react/workflows/CheckoutForms.test.tsx +123 -0
  304. package/src/react/workflows/CheckoutForms.tsx +247 -0
  305. package/src/react/workflows/ClipboardButton.test.tsx +34 -0
  306. package/src/react/workflows/ClipboardButton.tsx +67 -0
  307. package/src/react/workflows/Collection.tsx +76 -0
  308. package/src/react/workflows/Collections.test.tsx +86 -0
  309. package/src/react/workflows/Collections.tsx +213 -0
  310. package/src/react/workflows/Connect.test.tsx +50 -0
  311. package/src/react/workflows/Connect.tsx +107 -0
  312. package/src/react/workflows/Costs.test.tsx +41 -0
  313. package/src/react/workflows/Costs.tsx +133 -0
  314. package/src/react/workflows/Disputes.test.tsx +64 -0
  315. package/src/react/workflows/Disputes.tsx +173 -0
  316. package/src/react/workflows/Earnings.test.ts +19 -0
  317. package/src/react/workflows/Earnings.tsx +84 -0
  318. package/src/react/workflows/Financials.test.tsx +35 -0
  319. package/src/react/workflows/Financials.tsx +117 -0
  320. package/src/react/workflows/IntegrationSwitch.test.tsx +36 -0
  321. package/src/react/workflows/IntegrationSwitch.tsx +63 -0
  322. package/src/react/workflows/Onboarding.test.tsx +75 -0
  323. package/src/react/workflows/Onboarding.tsx +171 -0
  324. package/src/react/workflows/Overview.test.tsx +57 -0
  325. package/src/react/workflows/Overview.tsx +123 -0
  326. package/src/react/workflows/PaymentMethods.test.tsx +60 -0
  327. package/src/react/workflows/PaymentMethods.tsx +117 -0
  328. package/src/react/workflows/PaymentReceipt.test.tsx +24 -0
  329. package/src/react/workflows/PaymentReceipt.tsx +46 -0
  330. package/src/react/workflows/Payouts.test.tsx +112 -0
  331. package/src/react/workflows/Payouts.tsx +215 -0
  332. package/src/react/workflows/Products.test.tsx +90 -0
  333. package/src/react/workflows/Products.tsx +377 -0
  334. package/src/react/workflows/ReferralLinks.test.tsx +39 -0
  335. package/src/react/workflows/ReferralLinks.tsx +75 -0
  336. package/src/react/workflows/Refunds.test.tsx +75 -0
  337. package/src/react/workflows/Refunds.tsx +223 -0
  338. package/src/react/workflows/Setup.test.tsx +25 -0
  339. package/src/react/workflows/Setup.tsx +166 -0
  340. package/src/react/workflows/Storefront.test.tsx +82 -0
  341. package/src/react/workflows/Storefront.tsx +138 -0
  342. package/src/react/workflows/SubscriptionOverview.test.tsx +27 -0
  343. package/src/react/workflows/SubscriptionOverview.tsx +48 -0
  344. package/src/react/workflows/Subscriptions.test.tsx +61 -0
  345. package/src/react/workflows/Subscriptions.tsx +282 -0
  346. package/src/react/workflows/Tasks.test.tsx +23 -0
  347. package/src/react/workflows/Tasks.tsx +199 -0
  348. package/src/react/workflows/checkout-options.ts +42 -0
  349. package/src/react/workflows/current-subscription.test.ts +29 -0
  350. package/src/react/workflows/current-subscription.ts +25 -0
  351. package/src/react/workflows/filters.test.ts +12 -0
  352. package/src/react/workflows/filters.ts +22 -0
  353. package/src/react/workflows/index.ts +238 -0
  354. package/src/react/workflows/native-interactions.test.tsx +73 -0
  355. package/src/react/workflows/public-workflows.test.tsx +216 -0
  356. package/src/react/workflows/useWorkflowAction.test.tsx +54 -0
  357. package/src/react/workflows/useWorkflowAction.ts +75 -0
  358. package/src/react/workflows/useWorkflowResource.test.tsx +41 -0
  359. package/src/react/workflows/useWorkflowResource.ts +78 -0
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useWorkflowAction } from "./useWorkflowAction.js";
4
+ import { useWorkflowResource } from "./useWorkflowResource.js";
5
+ export function useWebhookSetup(props) {
6
+ const status = useWorkflowResource(props.load, props.scopeKey);
7
+ const setup = useWorkflowAction(async () => ({ value: await props.setup() }), props.scopeKey);
8
+ return {
9
+ status: status.data,
10
+ isChecking: status.isLoading,
11
+ statusError: status.error,
12
+ checkStatus: status.refresh,
13
+ result: setup.result?.value,
14
+ isPending: setup.isPending,
15
+ error: setup.error,
16
+ configure: async () => {
17
+ if (await setup.run())
18
+ status.refresh();
19
+ },
20
+ };
21
+ }
22
+ export function WebhookSetup(props) {
23
+ const state = useWebhookSetup(props);
24
+ if (props.children)
25
+ return _jsx(_Fragment, { children: props.children(state) });
26
+ return (_jsxs("section", { "data-better-stripe": "webhook-setup", children: [_jsx("h2", { children: "Webhook destinations" }), (state.error || state.statusError) && (_jsx("p", { role: "alert", children: state.error || state.statusError })), state.isChecking ? (_jsx("p", { role: "status", children: "Checking destinations\u2026" })) : state.status !== undefined && props.renderStatus ? (props.renderStatus(state.status)) : (_jsx("p", { children: "Destination status loaded." })), _jsx("button", { type: "button", disabled: state.isPending || state.isChecking, onClick: () => {
27
+ void state.configure();
28
+ }, children: state.isPending ? "Configuring…" : "Configure webhooks" }), _jsx("button", { type: "button", disabled: state.isChecking, onClick: state.checkStatus, children: "Refresh status" })] }));
29
+ }
30
+ export function EnvironmentStatus({ checks, isLoading = checks === undefined, error, children, }) {
31
+ const state = {
32
+ checks: checks ?? [],
33
+ allConfigured: !!checks?.length && checks.every((check) => check.configured),
34
+ isLoading,
35
+ error: error ?? null,
36
+ };
37
+ if (children)
38
+ return _jsx(_Fragment, { children: children(state) });
39
+ return (_jsxs("section", { "data-better-stripe": "environment-status", children: [_jsx("h2", { children: "Environment" }), error ? (_jsx("p", { role: "alert", children: error })) : isLoading ? (_jsx("p", { role: "status", children: "Checking configuration\u2026" })) : !checks?.length ? (_jsx("p", { children: "No environment checks configured." })) : (_jsx("ul", { children: checks.map((check) => (_jsxs("li", { children: [check.label, ": ", check.configured ? "Set" : "Not set"] }, check.id))) }))] }));
40
+ }
41
+ export function FixtureProgress({ state, children, }) {
42
+ if (!state)
43
+ return _jsx("p", { children: "No fixture run yet." });
44
+ const result = {
45
+ ...state,
46
+ progress: state.total > 0
47
+ ? Math.max(0, Math.min(1, state.cursor / state.total))
48
+ : 0,
49
+ message: state.status === "running"
50
+ ? "Fixtures are being created. Stripe events continue to update your data."
51
+ : state.status === "complete"
52
+ ? "Fixtures are populated. Stripe statuses can continue updating through webhooks."
53
+ : "Population stopped. Resume to retry this step.",
54
+ };
55
+ if (children)
56
+ return _jsx(_Fragment, { children: children(result) });
57
+ return (_jsxs("div", { "data-better-stripe": "fixture-progress", children: [_jsx("progress", { "aria-label": "Sandbox fixture progress", value: result.progress, max: 1 }), _jsxs("p", { role: "status", children: [state.cursor, " of ", state.total, " steps complete. ", result.message] }), state.error && _jsx("p", { role: "alert", children: state.error })] }));
58
+ }
59
+ //# sourceMappingURL=Setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Setup.js","sourceRoot":"","sources":["../../../src/react/workflows/Setup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAM/D,MAAM,UAAU,eAAe,CAC7B,KAA0C;IAE1C,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,iBAAiB,CAC7B,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,EAC5C,KAAK,CAAC,QAA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,CACN,CAAC,GACC,CACN,IACO,CACX,CAAC;AACJ,CAAC;AAOD,MAAM,UAAU,eAAe,CAAC,EAC9B,KAAK,EACL,QAAQ,GAMT;IACC,IAAI,CAAC,KAAK;QAAE,OAAO,8CAA0B,CAAC;IAC9C,MAAM,MAAM,GAAG;QACb,GAAG,KAAK;QACR,QAAQ,EACN,KAAK,CAAC,KAAK,GAAG,CAAC;YACb,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YACtD,CAAC,CAAC,CAAC;QACP,OAAO,EACL,KAAK,CAAC,MAAM,KAAK,SAAS;YACxB,CAAC,CAAC,yEAAyE;YAC3E,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,UAAU;gBAC3B,CAAC,CAAC,iFAAiF;gBACnF,CAAC,CAAC,gDAAgD;KACzD,CAAC;IACF,IAAI,QAAQ;QAAE,OAAO,4BAAG,QAAQ,CAAC,MAAM,CAAC,GAAI,CAAC;IAC7C,OAAO,CACL,qCAAwB,kBAAkB,aACxC,iCACa,0BAA0B,EACrC,KAAK,EAAE,MAAM,CAAC,QAAQ,EACtB,GAAG,EAAE,CAAC,GACN,EACF,aAAG,IAAI,EAAC,QAAQ,aACb,KAAK,CAAC,MAAM,UAAM,KAAK,CAAC,KAAK,uBAAmB,MAAM,CAAC,OAAO,IAC7D,EACH,KAAK,CAAC,KAAK,IAAI,YAAG,IAAI,EAAC,OAAO,YAAE,KAAK,CAAC,KAAK,GAAK,IAC7C,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { ReactNode } from "react";
2
+ export type StorefrontPrice = {
3
+ stripePriceId: string;
4
+ unitAmount: number;
5
+ currency: string;
6
+ type: string;
7
+ interval?: string | null;
8
+ intervalCount?: number | null;
9
+ active?: boolean;
10
+ };
11
+ export type StorefrontProduct = {
12
+ stripeProductId: string;
13
+ name: string;
14
+ description?: string | null;
15
+ active?: boolean;
16
+ prices: StorefrontPrice[];
17
+ };
18
+ export type StorefrontStore = {
19
+ accountId: string;
20
+ name: string;
21
+ products: StorefrontProduct[];
22
+ };
23
+ export type StorefrontSelection = {
24
+ store: StorefrontStore;
25
+ product: StorefrontProduct;
26
+ price: StorefrontPrice;
27
+ referralCode?: string;
28
+ };
29
+ export type StorefrontCard = StorefrontSelection & {
30
+ formattedPrice: string;
31
+ purchaseLabel: string;
32
+ accessibilityLabel: string;
33
+ checkoutUrl?: string;
34
+ purchase: () => void;
35
+ };
36
+ export type StorefrontRenderProps = {
37
+ stores: StorefrontStore[];
38
+ cards: StorefrontCard[];
39
+ isLoading: boolean;
40
+ isEmpty: boolean;
41
+ canPurchase: boolean;
42
+ };
43
+ export type StorefrontProps = {
44
+ stores: StorefrontStore[] | undefined;
45
+ storeId?: string;
46
+ referralCode?: string;
47
+ canPurchase?: boolean;
48
+ getCheckoutUrl?: (selection: StorefrontSelection) => string;
49
+ onSelectPrice?: (selection: StorefrontSelection) => void;
50
+ children?: (state: StorefrontRenderProps) => ReactNode;
51
+ };
52
+ export declare function Storefront({ stores, storeId, referralCode, canPurchase, getCheckoutUrl, onSelectPrice, children, }: StorefrontProps): import("react").JSX.Element;
53
+ //# sourceMappingURL=Storefront.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Storefront.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Storefront.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAA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,CAAC,SAAS,EAAE,mBAAmB,KAAK,MAAM,CAAC;IAC5D,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACzD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,SAAS,CAAC;CACxD,CAAC;AACF,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,OAAO,EACP,YAAY,EACZ,WAAkB,EAClB,cAAc,EACd,aAAa,EACb,QAAQ,GACT,EAAE,eAAe,+BA4EjB"}
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { formatPriceWithInterval } from "../lib/price-helpers.js";
4
+ export function Storefront({ stores, storeId, referralCode, canPurchase = true, getCheckoutUrl, onSelectPrice, children, }) {
5
+ const visible = stores?.filter((store) => !storeId || store.accountId === storeId) ?? [];
6
+ const cards = visible.flatMap((store) => store.products
7
+ .filter((product) => product.active !== false)
8
+ .flatMap((product) => product.prices
9
+ .filter((price) => price.active !== false)
10
+ .map((price) => {
11
+ const selection = { store, product, price, referralCode };
12
+ return {
13
+ ...selection,
14
+ formattedPrice: formatPriceWithInterval({
15
+ ...price,
16
+ active: true,
17
+ }),
18
+ purchaseLabel: price.type === "recurring" ? "Subscribe" : "Buy now",
19
+ accessibilityLabel: `${price.type === "recurring" ? "Subscribe to" : "Buy"} ${product.name}`,
20
+ checkoutUrl: getCheckoutUrl?.(selection),
21
+ purchase: () => {
22
+ if (canPurchase)
23
+ onSelectPrice?.(selection);
24
+ },
25
+ };
26
+ })));
27
+ const state = {
28
+ stores: visible,
29
+ cards,
30
+ isLoading: stores === undefined,
31
+ isEmpty: stores !== undefined && !visible.length,
32
+ canPurchase,
33
+ };
34
+ if (children)
35
+ return _jsx(_Fragment, { children: children(state) });
36
+ if (state.isLoading)
37
+ return _jsx("p", { role: "status", children: "Loading stores\u2026" });
38
+ if (state.isEmpty)
39
+ return _jsx("p", { children: "No stores available yet." });
40
+ return (_jsx("div", { "data-better-stripe": "storefront", children: visible.map((store) => (_jsxs("section", { children: [_jsx("h2", { children: store.name }), !cards.some((card) => card.store.accountId === store.accountId) && (_jsx("p", { children: "No products available yet." })), cards
41
+ .filter((card) => card.store.accountId === store.accountId)
42
+ .map((card) => (_jsxs("article", { children: [_jsx("h3", { children: card.product.name }), _jsx("p", { children: card.product.description }), _jsx("p", { children: card.formattedPrice }), card.checkoutUrl && canPurchase ? (_jsx("a", { href: card.checkoutUrl, "aria-label": card.accessibilityLabel, children: card.purchaseLabel })) : (_jsx("button", { type: "button", disabled: !canPurchase || !onSelectPrice, "aria-label": card.accessibilityLabel, onClick: card.purchase, children: card.purchaseLabel }))] }, card.price.stripePriceId)))] }, store.accountId))) }));
43
+ }
44
+ //# sourceMappingURL=Storefront.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Storefront.js","sourceRoot":"","sources":["../../../src/react/workflows/Storefront.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAmDlE,MAAM,UAAU,UAAU,CAAC,EACzB,MAAM,EACN,OAAO,EACP,YAAY,EACZ,WAAW,GAAG,IAAI,EAClB,cAAc,EACd,aAAa,EACb,QAAQ,GACQ;IAChB,MAAM,OAAO,GACX,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC;IAC3E,MAAM,KAAK,GAAqB,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CACxD,KAAK,CAAC,QAAQ;SACX,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC;SAC7C,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CACnB,OAAO,CAAC,MAAM;SACX,MA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CAAC,CACtB,8BACE,uBAAK,KAAK,CAAC,IAAI,GAAM,EACpB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC,IAAI,CAClE,qDAAiC,CAClC,EACA,KAAK;qBACH,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC;qBAC1D,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACb,8BACE,uBAAK,IAAI,CAAC,OAAO,CAAC,IAAI,GAAM,EAC5B,sBAAI,IAAI,CAAC,OAAO,CAAC,WAAW,GAAK,EACjC,sBAAI,IAAI,CAAC,cAAc,GAAK,EAC3B,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,CAAC,CAAC,CACjC,YACE,IAAI,EAAE,IAAI,CAAC,WAAW,gBACV,IAAI,CAAC,kBAAkB,YAElC,IAAI,CAAC,aAAa,GACjB,CACL,CAAC,CAAC,CAAC,CACF,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,WAAW,IAAI,CAAC,aAAa,gBAC5B,IAAI,CAAC,kBAAkB,EACnC,OAAO,EAAE,IAAI,CAAC,QAAQ,YAErB,IAAI,CAAC,aAAa,GACZ,CACV,KApBW,IAAI,CAAC,KAAK,CAAC,aAAa,CAqB5B,CACX,CAAC,KA9BQ,KAAK,CAAC,SAAS,CA+BnB,CACX,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { ReactNode } from "react";
2
+ import type { SubscriptionRow } from "./Subscriptions.js";
3
+ export type SubscriptionOverviewState<Row> = {
4
+ subscription: Row | null;
5
+ isLoading: boolean;
6
+ isEmpty: boolean;
7
+ };
8
+ export type SubscriptionOverviewProps<Row extends SubscriptionRow = SubscriptionRow> = {
9
+ subscriptions: Row[] | undefined;
10
+ children?: (state: SubscriptionOverviewState<Row>) => ReactNode;
11
+ };
12
+ export declare function SubscriptionOverview<Row extends SubscriptionRow>({ subscriptions, children, }: SubscriptionOverviewProps<Row>): import("react").JSX.Element;
13
+ //# sourceMappingURL=SubscriptionOverview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionOverview.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/SubscriptionOverview.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,MAAM,MAAM,yBAAyB,CAAC,GAAG,IAAI;IAC3C,YAAY,EAAE,GAAG,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AACF,MAAM,MAAM,yBAAyB,CACnC,GAAG,SAAS,eAAe,GAAG,eAAe,IAC3C;IACF,aAAa,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;CACjE,CAAC;AACF,wBAAgB,oBAAoB,CAAC,GAAG,SAAS,eAAe,EAAE,EAChE,aAAa,EACb,QAAQ,GACT,EAAE,yBAAyB,CAAC,GAAG,CAAC,+BA4BhC"}
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { currentSubscriptionFrom } from "./current-subscription.js";
4
+ import { SubscriptionCard } from "../components/SubscriptionCard.js";
5
+ export function SubscriptionOverview({ subscriptions, children, }) {
6
+ const subscription = currentSubscriptionFrom((subscriptions ?? []).map((row) => ({
7
+ ...row,
8
+ cancelAtPeriodEnd: row.cancelAtPeriodEnd ?? false,
9
+ })));
10
+ const state = {
11
+ subscription,
12
+ isLoading: subscriptions === undefined,
13
+ isEmpty: subscriptions !== undefined && !subscription,
14
+ };
15
+ if (children)
16
+ return _jsx(_Fragment, { children: children(state) });
17
+ if (state.isLoading)
18
+ return _jsx("p", { role: "status", children: "Loading subscription\u2026" });
19
+ if (!subscription)
20
+ return _jsx("p", { children: "No subscription yet." });
21
+ return (_jsxs("section", { "data-better-stripe": "subscription-overview", children: [_jsx("h2", { children: "Your subscription" }), _jsx("p", { children: subscription.stripeSubscriptionId }), _jsx(SubscriptionCard, { subscription: {
22
+ ...subscription,
23
+ isTrialing: subscription.isTrialing ?? subscription.status === "trialing",
24
+ } })] }));
25
+ }
26
+ //# sourceMappingURL=SubscriptionOverview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionOverview.js","sourceRoot":"","sources":["../../../src/react/workflows/SubscriptionOverview.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAYrE,MAAM,UAAU,oBAAoB,CAA8B,EAChE,aAAa,EACb,QAAQ,GACuB;IAC/B,MAAM,YAAY,GAAG,uBAAuB,CAC1C,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAClC,GAAG,GAAG;QACN,iBAAiB,EAAE,GAAG,CAAC,iBAAiB,IAAI,KAAK;KAClD,CAAC,CAAC,CACJ,CAAC;IACF,MAAM,KAAK,GAAG;QACZ,YAAY;QACZ,SAAS,EAAE,aAAa,KAAK,SAAS;QACtC,OAAO,EAAE,aAAa,KAAK,SAAS,IAAI,CAAC,YAAY;KACtD,CAAC;IACF,IAAI,QAAQ;QAAE,OAAO,4BAAG,QAAQ,CAAC,KAAK,CAAC,GAAI,CAAC;IAC5C,IAAI,KAAK,CAAC,SAAS;QAAE,OAAO,YAAG,IAAI,EAAC,QAAQ,2CAA0B,CAAC;IACvE,IAAI,CAAC,YAAY;QAAE,OAAO,+CAA2B,CAAC;IACtD,OAAO,CACL,yCAA4B,uBAAuB,aACjD,6CAA0B,EAC1B,sBAAI,YAAY,CAAC,oBAAoB,GAAK,EAC1C,KAAC,gBAAgB,IACf,YAAY,EAAE;oBACZ,GAAG,YAAY;oBACf,UAAU,EACR,YAAY,CAAC,UAAU,IAAI,YAAY,CAAC,MAAM,KAAK,UAAU;iBAChE,GACD,IACM,CACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,92 @@
1
+ import { type ReactNode } from "react";
2
+ import { type CollectionProps, type WorkflowColumn } from "./Collection.js";
3
+ export type SubscriptionRow = {
4
+ stripeSubscriptionId: string;
5
+ status: string;
6
+ isTrialing?: boolean;
7
+ cancelAtPeriodEnd?: boolean;
8
+ isCollectionPaused?: boolean;
9
+ currentPeriodEnd?: string | null;
10
+ trialEnd?: string | null;
11
+ quantity?: number;
12
+ userId?: string;
13
+ };
14
+ export type SubscriptionActionType = "pause" | "resume" | "reactivate" | "cancel" | "price" | "quantity" | "trial" | "endTrial";
15
+ export type SubscriptionCommand = {
16
+ type: SubscriptionActionType;
17
+ stripeSubscriptionId: string;
18
+ stripePriceId?: string;
19
+ quantity?: number;
20
+ trialEnd?: string;
21
+ };
22
+ export type SubscriptionManagerOptions = {
23
+ scopeKey: string;
24
+ subscription: SubscriptionRow | null | undefined;
25
+ onAction: (command: SubscriptionCommand) => Promise<unknown>;
26
+ };
27
+ export declare function useSubscriptionManager(props: SubscriptionManagerOptions): {
28
+ scope: string;
29
+ quantity: string;
30
+ selectedPriceId: string;
31
+ trialEnd: string;
32
+ setQuantity: (quantity: string) => void;
33
+ setSelectedPriceId: (selectedPriceId: string) => void;
34
+ setTrialEnd: (trialEnd: string) => void;
35
+ pendingAction: string | null;
36
+ isPending: boolean;
37
+ message: string | null;
38
+ error: string | null;
39
+ canPause: boolean;
40
+ canResume: boolean;
41
+ canReactivate: boolean;
42
+ run: (type: SubscriptionActionType) => Promise<string | undefined>;
43
+ };
44
+ export type SubscriptionManagerProps = SubscriptionManagerOptions & {
45
+ children?: (state: ReturnType<typeof useSubscriptionManager>) => ReactNode;
46
+ };
47
+ export declare function SubscriptionManager(props: SubscriptionManagerProps): import("react").JSX.Element;
48
+ export declare const SUBSCRIPTION_FILTERS: readonly [{
49
+ readonly label: "All";
50
+ readonly value: "all";
51
+ }, {
52
+ readonly label: "Active";
53
+ readonly value: "active";
54
+ }, {
55
+ readonly label: "Trialing";
56
+ readonly value: "trialing";
57
+ }, {
58
+ readonly label: "Past Due";
59
+ readonly value: "past_due";
60
+ }, {
61
+ readonly label: "Canceled";
62
+ readonly value: "canceled";
63
+ }];
64
+ export declare function useSubscriptionFilter<T extends {
65
+ status: string;
66
+ }>(subscriptions: T[] | undefined): {
67
+ filter: string;
68
+ setFilter: import("react").Dispatch<import("react").SetStateAction<string>>;
69
+ filtered: T[];
70
+ countByStatus: (status: string) => number;
71
+ tabs: readonly [{
72
+ readonly label: "All";
73
+ readonly value: "all";
74
+ }, {
75
+ readonly label: "Active";
76
+ readonly value: "active";
77
+ }, {
78
+ readonly label: "Trialing";
79
+ readonly value: "trialing";
80
+ }, {
81
+ readonly label: "Past Due";
82
+ readonly value: "past_due";
83
+ }, {
84
+ readonly label: "Canceled";
85
+ readonly value: "canceled";
86
+ }];
87
+ };
88
+ export type SubscriptionsProps<Row extends SubscriptionRow = SubscriptionRow> = Omit<CollectionProps<Row>, "getKey" | "columns"> & {
89
+ columns?: WorkflowColumn<Row>[];
90
+ };
91
+ export declare function Subscriptions<Row extends SubscriptionRow>(props: SubscriptionsProps<Row>): import("react").JSX.Element;
92
+ //# sourceMappingURL=Subscriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Subscriptions.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Subscriptions.tsx"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAA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E,UAAU,CAAC,OAAO,sBAAsB,CAAC,KAAK,SAAS,CAAC;CAC5E,CAAC;AACF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,+BA6GlE;AACD,eAAO,MAAM,oBAAoB;aAC7B,KAAK,EAAE,KAAK;aAAE,KAAK,EAAE,KAAK;;aAC1B,KAAK,EAAE,QAAQ;aAAE,KAAK,EAAE,QAAQ;;aAChC,KAAK,EAAE,UAAU;aAAE,KAAK,EAAE,UAAU;;aACpC,KAAK,EAAE,UAAU;aAAE,KAAK,EAAE,UAAU;;aACpC,KAAK,EAAE,UAAU;aAAE,KAAK,EAAE,UAAU;EAC9B,CAAC;AACX,wBAAgB,qBAAqB,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EAChE,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS;;;;4BAUJ,MAAM;;wBAjBvB,KAAK;wBAAS,KAAK;;wBACnB,QAAQ;wBAAS,QAAQ;;wBACzB,UAAU;wBAAS,UAAU;;wBAC7B,UAAU;wBAAS,UAAU;;wBAC7B,UAAU;wBAAS,UAAU;;EAiBvC;AACD,MAAM,MAAM,kBAAkB,CAAC,GAAG,SAAS,eAAe,GAAG,eAAe,IAC1E,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC,GAAG;IACjD,OAAO,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;CACjC,CAAC;AACJ,wBAAgB,aAAa,CAAC,GAAG,SAAS,eAAe,EACvD,KAAK,EAAE,kBAAkB,CAAC,GAAG,CAAC,+BAgC/B"}
@@ -0,0 +1,149 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useState } from "react";
4
+ import { useWorkflowAction } from "./useWorkflowAction.js";
5
+ import { Collection, } from "./Collection.js";
6
+ import { SubscriptionCard } from "../components/SubscriptionCard.js";
7
+ const labels = {
8
+ pause: "pause subscription",
9
+ resume: "resume subscription",
10
+ reactivate: "reactivate subscription",
11
+ cancel: "cancel subscription",
12
+ price: "change plan",
13
+ quantity: "update quantity",
14
+ trial: "update trial end",
15
+ endTrial: "end trial now",
16
+ };
17
+ export function useSubscriptionManager(props) {
18
+ const scope = `${props.scopeKey}:${props.subscription?.stripeSubscriptionId ?? ""}`;
19
+ const initial = { scope, quantity: "1", selectedPriceId: "", trialEnd: "" };
20
+ const [fields, setFields] = useState(initial);
21
+ if (fields.scope !== scope)
22
+ setFields(initial);
23
+ const [operation, setOperation] = useState("pause");
24
+ const action = useWorkflowAction(async (type) => {
25
+ setOperation(type);
26
+ if (!props.subscription)
27
+ throw new Error("Select a subscription first.");
28
+ const request = {
29
+ type,
30
+ stripeSubscriptionId: props.subscription.stripeSubscriptionId,
31
+ };
32
+ if (type === "quantity") {
33
+ const quantity = Number(fields.quantity);
34
+ if (!/^\d+$/.test(fields.quantity) ||
35
+ !Number.isSafeInteger(quantity) ||
36
+ quantity < 1)
37
+ throw new Error("Enter a positive integer quantity.");
38
+ request.quantity = quantity;
39
+ }
40
+ if (type === "price") {
41
+ if (!fields.selectedPriceId)
42
+ throw new Error("Choose a price first.");
43
+ request.stripePriceId = fields.selectedPriceId;
44
+ }
45
+ if (type === "trial") {
46
+ if (!fields.trialEnd || Number.isNaN(new Date(fields.trialEnd).getTime()))
47
+ throw new Error("Enter a valid trial end date.");
48
+ request.trialEnd = fields.trialEnd;
49
+ }
50
+ if (type === "endTrial")
51
+ request.trialEnd = "now";
52
+ await props.onAction(request);
53
+ return `${labels[type]} requested. Waiting for Stripe webhook sync.`;
54
+ }, scope);
55
+ const active = props.subscription?.status === "active" ||
56
+ props.subscription?.status === "trialing";
57
+ return {
58
+ ...fields,
59
+ setQuantity: (quantity) => setFields((previous) => ({ ...previous, quantity })),
60
+ setSelectedPriceId: (selectedPriceId) => setFields((previous) => ({ ...previous, selectedPriceId })),
61
+ setTrialEnd: (trialEnd) => setFields((previous) => ({ ...previous, trialEnd })),
62
+ pendingAction: action.isPending ? labels[operation] : null,
63
+ isPending: action.isPending,
64
+ message: action.error ?? action.result ?? null,
65
+ error: action.error,
66
+ canPause: active && !props.subscription?.isCollectionPaused,
67
+ canResume: !!props.subscription?.isCollectionPaused,
68
+ canReactivate: active && !!props.subscription?.cancelAtPeriodEnd,
69
+ run: action.run,
70
+ };
71
+ }
72
+ export function SubscriptionManager(props) {
73
+ const state = useSubscriptionManager(props);
74
+ const id = useId();
75
+ if (props.children)
76
+ return _jsx(_Fragment, { children: props.children(state) });
77
+ if (!props.subscription)
78
+ return _jsx("p", { children: "No subscription selected." });
79
+ return (_jsxs("section", { "data-better-stripe": "subscription-manager", "aria-busy": state.isPending, children: [_jsx(SubscriptionCard, { subscription: {
80
+ ...props.subscription,
81
+ isTrialing: props.subscription.isTrialing ?? false,
82
+ cancelAtPeriodEnd: props.subscription.cancelAtPeriodEnd ?? false,
83
+ } }), state.message && (_jsx("p", { role: state.error ? "alert" : "status", children: state.message })), [
84
+ ["pause", state.canPause],
85
+ ["resume", state.canResume],
86
+ ["reactivate", state.canReactivate],
87
+ [
88
+ "cancel",
89
+ !props.subscription.cancelAtPeriodEnd &&
90
+ props.subscription.status !== "canceled",
91
+ ],
92
+ ].map(([type, enabled]) => (_jsx("button", { type: "button", disabled: !enabled || state.isPending, onClick: () => {
93
+ void state.run(type);
94
+ }, children: state.pendingAction === labels[type] ? "Processing…" : labels[type] }, type))), _jsxs("form", { onSubmit: (event) => {
95
+ event.preventDefault();
96
+ void state.run("price");
97
+ }, children: [_jsx("label", { htmlFor: `${id}-price`, children: "Price ID" }), _jsx("input", { id: `${id}-price`, required: true, value: state.selectedPriceId, onChange: (event) => state.setSelectedPriceId(event.target.value) }), _jsx("button", { type: "submit", disabled: state.isPending, children: "Change plan" })] }), _jsxs("form", { onSubmit: (event) => {
98
+ event.preventDefault();
99
+ void state.run("quantity");
100
+ }, children: [_jsx("label", { htmlFor: `${id}-quantity`, children: "Quantity" }), _jsx("input", { id: `${id}-quantity`, type: "number", min: "1", step: "1", required: true, value: state.quantity, onChange: (event) => state.setQuantity(event.target.value) }), _jsx("button", { type: "submit", disabled: state.isPending, children: "Update quantity" })] }), _jsxs("form", { onSubmit: (event) => {
101
+ event.preventDefault();
102
+ void state.run("trial");
103
+ }, children: [_jsx("label", { htmlFor: `${id}-trial`, children: "Trial end" }), _jsx("input", { id: `${id}-trial`, type: "datetime-local", required: true, value: state.trialEnd, onChange: (event) => state.setTrialEnd(event.target.value) }), _jsx("button", { type: "submit", disabled: state.isPending, children: "Set trial end" })] }), _jsx("button", { type: "button", disabled: state.isPending, onClick: () => {
104
+ void state.run("endTrial");
105
+ }, children: "End trial now" })] }));
106
+ }
107
+ export const SUBSCRIPTION_FILTERS = [
108
+ { label: "All", value: "all" },
109
+ { label: "Active", value: "active" },
110
+ { label: "Trialing", value: "trialing" },
111
+ { label: "Past Due", value: "past_due" },
112
+ { label: "Canceled", value: "canceled" },
113
+ ];
114
+ export function useSubscriptionFilter(subscriptions) {
115
+ const [filter, setFilter] = useState("all");
116
+ return {
117
+ filter,
118
+ setFilter,
119
+ filtered: filter === "all"
120
+ ? (subscriptions ?? [])
121
+ : (subscriptions?.filter((row) => row.status === filter) ?? []),
122
+ countByStatus: (status) => subscriptions?.filter((row) => row.status === status).length ?? 0,
123
+ tabs: SUBSCRIPTION_FILTERS,
124
+ };
125
+ }
126
+ export function Subscriptions(props) {
127
+ const columns = [
128
+ {
129
+ id: "id",
130
+ label: "Subscription",
131
+ cell: (row) => row.stripeSubscriptionId,
132
+ },
133
+ { id: "status", label: "Status", cell: (row) => row.status },
134
+ {
135
+ id: "period",
136
+ label: "Current period end",
137
+ cell: (row) => row.currentPeriodEnd
138
+ ? new Date(row.currentPeriodEnd).toLocaleDateString()
139
+ : "Not supplied",
140
+ },
141
+ {
142
+ id: "trial",
143
+ label: "Trial end",
144
+ cell: (row) => row.trialEnd ? new Date(row.trialEnd).toLocaleDateString() : "None",
145
+ },
146
+ ];
147
+ return (_jsx(Collection, { emptyLabel: "No subscriptions yet.", ...props, columns: props.columns ?? columns, getKey: (row) => row.stripeSubscriptionId }));
148
+ }
149
+ //# sourceMappingURL=Subscriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Subscriptions.js","sourceRoot":"","sources":["../../../src/react/workflows/Subscriptions.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,UAAU,GAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAiCrE,MAAM,MAAM,GAA2C;IACrD,KAAK,EAAE,oBAAoB;IAC3B,MAAM,EAAE,qBAAqB;IAC7B,UAAU,EAAE,yBAAyB;IACrC,MAAM,EAAE,qBAAqB;IAC7B,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,iBAAiB;IAC3B,KAAK,EAAE,kBAAkB;IACzB,QAAQ,EAAE,eAAe;CAC1B,CAAC;AACF,MAAM,UAAU,sBAAsB,CAAC,KAAiC;IACtE,MAAM,KAAK,GAAG,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,YAAY,EAAE,oBAAoB,IAAI,EAAE,EAAE,CAAC;IACpF,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC5E,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK;QAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAA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AAC,QAAQ,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,MAAM;SACtE;KACF,CAAC;IACF,OAAO,CACL,KAAC,UAAU,IACT,UAAU,EAAC,uBAAuB,KAC9B,KAAK,EACT,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,OAAO,EACjC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,oBAAoB,GACzC,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { type ReactNode } from "react";
2
+ export type WorkflowLogEntry = {
3
+ id: number;
4
+ timestamp: string;
5
+ action: string;
6
+ result: string;
7
+ status: "success" | "error";
8
+ };
9
+ export type TaskRunnerOptions = {
10
+ scopeKey?: string;
11
+ maxEntries?: number;
12
+ /** Explicitly select safe fields for display. Default never serializes returned secrets. */ formatResult?: (value: unknown) => string;
13
+ };
14
+ export declare function useTaskRunner({ scopeKey, maxEntries, formatResult, }?: TaskRunnerOptions): {
15
+ log: WorkflowLogEntry[];
16
+ results: Record<string, string>;
17
+ errors: Record<string, string>;
18
+ isPending: boolean;
19
+ pendingOperation: string | null;
20
+ run: <T>(name: string, task: () => Promise<T>) => Promise<T | undefined>;
21
+ appendLog: (action: string, result: string, status?: "success" | "error") => void;
22
+ clearLog: () => void;
23
+ };
24
+ export type WorkflowTask = {
25
+ id: string;
26
+ label: string;
27
+ description?: string;
28
+ run: () => Promise<unknown>;
29
+ requiresConfirmation?: boolean;
30
+ };
31
+ export type WorkflowTasksProps = TaskRunnerOptions & {
32
+ title?: string;
33
+ tasks: WorkflowTask[];
34
+ children?: (state: ReturnType<typeof useTaskRunner>) => ReactNode;
35
+ };
36
+ /** Unstyled administration/sandbox operations. Authorization and test-mode enforcement belong to the server callbacks. */
37
+ export declare function WorkflowTasks(props: WorkflowTasksProps): import("react").JSX.Element;
38
+ export declare function StripeSetup(props: Omit<WorkflowTasksProps, "title">): import("react").JSX.Element;
39
+ export declare function SandboxTesting(props: Omit<WorkflowTasksProps, "title">): import("react").JSX.Element;
40
+ //# sourceMappingURL=Tasks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tasks.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Tasks.tsx"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4FAA4F,CAAC,YAAY,CAAC,EAAE,CAC1G,KAAK,EAAE,OAAO,KACX,MAAM,CAAC;CACb,CAAC;AACF,wBAAgB,aAAa,CAAC,EAC5B,QAAkB,EAClB,UAAgB,EAChB,YAAgC,GACjC,GAAE,iBAAsB;;;;;;UA+BJ,CAAC,QACZ,MAAM,QACN,MAAM,OAAO,CAAC,CAAC,CAAC,KACrB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;wBAyCb,MAAM,UACN,MAAM,WACN,SAAS,GAAG,OAAO;;EAiBhC;AACD,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,QAAQ,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