@volter/twin-stripe 2.0.38 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/README.md +82 -207
  2. package/dist/generated/pack-facts.json +94 -0
  3. package/dist/spec/SOURCE.md +14 -0
  4. package/dist/spec/fixtures3.json.gz +0 -0
  5. package/dist/spec/openapi.json.gz +0 -0
  6. package/dist/spec/patches.json +34 -0
  7. package/dist/spec/sources.json +378 -0
  8. package/dist/src/cli.js +12 -30
  9. package/dist/src/engine/after-payment.d.ts +9 -0
  10. package/dist/src/engine/after-payment.js +28 -0
  11. package/dist/src/engine/apps-secrets.d.ts +1 -0
  12. package/dist/src/engine/apps-secrets.js +3 -0
  13. package/dist/src/engine/balance.d.ts +5 -0
  14. package/dist/src/engine/balance.js +15 -0
  15. package/dist/src/engine/billing.d.ts +5 -0
  16. package/dist/src/engine/billing.js +6 -0
  17. package/dist/src/engine/charges.d.ts +6 -0
  18. package/dist/src/engine/charges.js +13 -0
  19. package/dist/src/engine/checkout.d.ts +24 -0
  20. package/dist/src/engine/checkout.js +30 -0
  21. package/dist/src/engine/common.d.ts +19 -0
  22. package/dist/src/engine/common.js +32 -0
  23. package/dist/src/{screens → engine}/connect-settings.d.ts +1 -7
  24. package/dist/src/engine/connect-settings.js +26 -0
  25. package/dist/src/engine/connect.d.ts +66 -0
  26. package/dist/src/engine/connect.js +189 -0
  27. package/dist/src/engine/coupons.d.ts +0 -0
  28. package/dist/src/engine/coupons.js +5 -0
  29. package/dist/src/engine/credit-notes.d.ts +1 -0
  30. package/dist/src/engine/credit-notes.js +5 -0
  31. package/dist/src/engine/customers.d.ts +12 -0
  32. package/dist/src/engine/customers.js +30 -0
  33. package/dist/src/engine/display.d.ts +14 -0
  34. package/dist/src/engine/display.js +16 -0
  35. package/dist/src/engine/disputes.d.ts +0 -0
  36. package/dist/src/engine/disputes.js +9 -0
  37. package/dist/src/engine/entitlements.d.ts +1 -0
  38. package/dist/src/engine/entitlements.js +4 -0
  39. package/dist/src/engine/ephemeral-keys.d.ts +0 -0
  40. package/dist/src/engine/ephemeral-keys.js +4 -0
  41. package/dist/src/engine/files.d.ts +18 -0
  42. package/dist/src/engine/files.js +33 -0
  43. package/dist/src/engine/front.d.ts +5 -0
  44. package/dist/src/engine/front.js +25 -0
  45. package/dist/src/engine/invoices.d.ts +24 -0
  46. package/dist/src/engine/invoices.js +57 -0
  47. package/dist/src/engine/issuing.d.ts +35 -0
  48. package/dist/src/engine/issuing.js +45 -0
  49. package/dist/src/engine/ledger.d.ts +9 -0
  50. package/dist/src/engine/ledger.js +9 -0
  51. package/dist/src/engine/oauth.d.ts +4 -0
  52. package/dist/src/engine/oauth.js +25 -0
  53. package/dist/src/engine/onboarding.d.ts +13 -0
  54. package/dist/src/engine/onboarding.js +42 -0
  55. package/dist/src/{stripe-params.d.ts → engine/params.d.ts} +20 -3
  56. package/dist/src/{stripe-params.js → engine/params.js} +7 -60
  57. package/dist/src/engine/payment-intents.d.ts +10 -0
  58. package/dist/src/engine/payment-intents.js +27 -0
  59. package/dist/src/engine/payment-links.d.ts +1 -0
  60. package/dist/src/engine/payment-links.js +5 -0
  61. package/dist/src/engine/payment-methods.d.ts +16 -0
  62. package/dist/src/engine/payment-methods.js +22 -0
  63. package/dist/src/engine/plans.d.ts +6 -0
  64. package/dist/src/engine/plans.js +26 -0
  65. package/dist/src/engine/platform.d.ts +39 -0
  66. package/dist/src/engine/platform.js +34 -0
  67. package/dist/src/engine/products.d.ts +0 -0
  68. package/dist/src/engine/products.js +4 -0
  69. package/dist/src/engine/radar.d.ts +2 -0
  70. package/dist/src/engine/radar.js +5 -0
  71. package/dist/src/engine/refunds.d.ts +1 -0
  72. package/dist/src/engine/refunds.js +28 -0
  73. package/dist/src/engine/renewals.d.ts +36 -0
  74. package/dist/src/engine/renewals.js +65 -0
  75. package/dist/src/engine/setup-intents.d.ts +1 -0
  76. package/dist/src/engine/setup-intents.js +4 -0
  77. package/dist/src/{stripe-twin.d.ts → engine/stripe.d.ts} +11 -39
  78. package/dist/src/{stripe-twin.js → engine/stripe.js} +25 -310
  79. package/dist/src/engine/subscription-schedules.d.ts +3 -0
  80. package/dist/src/engine/subscription-schedules.js +1 -0
  81. package/dist/src/engine/subscriptions.d.ts +12 -0
  82. package/dist/src/engine/subscriptions.js +31 -0
  83. package/dist/src/engine/tax.d.ts +7 -0
  84. package/dist/src/engine/tax.js +28 -0
  85. package/dist/src/engine/terminal.d.ts +4 -0
  86. package/dist/src/engine/terminal.js +20 -0
  87. package/dist/src/engine/test-clocks.d.ts +5 -0
  88. package/dist/src/engine/test-clocks.js +9 -0
  89. package/dist/src/engine/tokens.d.ts +7 -0
  90. package/dist/src/engine/tokens.js +20 -0
  91. package/dist/src/engine/transfers.d.ts +2 -0
  92. package/dist/src/engine/transfers.js +1 -0
  93. package/dist/src/engine/treasury.d.ts +23 -0
  94. package/dist/src/engine/treasury.js +45 -0
  95. package/dist/src/{stripe-version.js → engine/version.js} +4 -3
  96. package/dist/src/engine/webhook-endpoints.d.ts +1 -0
  97. package/dist/src/engine/webhook-endpoints.js +12 -0
  98. package/dist/src/engine/webhooks.d.ts +31 -0
  99. package/dist/src/engine/webhooks.js +68 -0
  100. package/dist/src/fetch.d.ts +2 -0
  101. package/dist/src/fetch.js +26 -0
  102. package/dist/src/generated/surface.gen.json +1 -1
  103. package/dist/src/generated/ui.gen.json +1 -1
  104. package/dist/src/index.d.ts +5 -14
  105. package/dist/src/index.js +8 -75
  106. package/dist/src/manifest.js +232 -758
  107. package/dist/src/screens/billing-portal.d.ts +3 -0
  108. package/dist/src/screens/{portal.js → billing-portal.js} +28 -54
  109. package/dist/src/screens/checkout.d.ts +2 -31
  110. package/dist/src/screens/checkout.js +32 -121
  111. package/dist/src/screens/connect-oauth.d.ts +3 -27
  112. package/dist/src/screens/connect-oauth.js +51 -132
  113. package/dist/src/screens/connect-onboarding.d.ts +3 -0
  114. package/dist/src/screens/{onboarding.js → connect-onboarding.js} +36 -102
  115. package/dist/src/screens/dashboard.d.ts +3 -0
  116. package/dist/src/screens/dashboard.js +117 -0
  117. package/dist/src/screens/shared.d.ts +27 -0
  118. package/dist/src/screens/shared.js +87 -0
  119. package/dist/src/screens/stripe-js.d.ts +3 -0
  120. package/dist/src/screens/stripe-js.js +135 -0
  121. package/dist/src/semantics/account_links.d.ts +2 -0
  122. package/dist/src/semantics/account_links.js +22 -0
  123. package/dist/src/semantics/accounts.d.ts +4 -0
  124. package/dist/src/semantics/accounts.js +38 -0
  125. package/dist/src/semantics/apps.d.ts +4 -0
  126. package/dist/src/semantics/{apps-secrets.js → apps.js} +14 -26
  127. package/dist/src/semantics/around.d.ts +2 -0
  128. package/dist/src/semantics/around.js +16 -0
  129. package/dist/src/semantics/balance.d.ts +2 -11
  130. package/dist/src/semantics/balance.js +3 -194
  131. package/dist/src/semantics/balance_transactions.d.ts +2 -0
  132. package/dist/src/semantics/balance_transactions.js +15 -0
  133. package/dist/src/semantics/billing_portal.d.ts +5 -0
  134. package/dist/src/semantics/billing_portal.js +42 -0
  135. package/dist/src/semantics/charges.d.ts +3 -28
  136. package/dist/src/semantics/charges.js +5 -202
  137. package/dist/src/semantics/checkout.d.ts +3 -20
  138. package/dist/src/semantics/checkout.js +8 -261
  139. package/dist/src/semantics/clock.d.ts +2 -0
  140. package/dist/src/semantics/clock.js +21 -0
  141. package/dist/src/semantics/coupons.d.ts +2 -6
  142. package/dist/src/semantics/coupons.js +2 -60
  143. package/dist/src/semantics/customers.d.ts +6 -6
  144. package/dist/src/semantics/customers.js +27 -387
  145. package/dist/src/semantics/disputes.d.ts +2 -2
  146. package/dist/src/semantics/disputes.js +3 -49
  147. package/dist/src/semantics/doors.d.ts +23 -0
  148. package/dist/src/semantics/doors.js +73 -0
  149. package/dist/src/semantics/entitlements.d.ts +2 -2
  150. package/dist/src/semantics/entitlements.js +5 -50
  151. package/dist/src/semantics/events.d.ts +12 -0
  152. package/dist/src/semantics/events.js +36 -0
  153. package/dist/src/semantics/index.d.ts +2 -0
  154. package/dist/src/semantics/index.js +107 -0
  155. package/dist/src/semantics/invoice_payments.d.ts +2 -0
  156. package/dist/src/semantics/invoice_payments.js +12 -0
  157. package/dist/src/semantics/invoiceitems.d.ts +3 -0
  158. package/dist/src/semantics/invoiceitems.js +59 -0
  159. package/dist/src/semantics/invoices.d.ts +16 -18
  160. package/dist/src/semantics/invoices.js +118 -444
  161. package/dist/src/semantics/payment_intents.d.ts +4 -0
  162. package/dist/src/semantics/payment_intents.js +79 -0
  163. package/dist/src/semantics/payment_methods.d.ts +5 -0
  164. package/dist/src/semantics/payment_methods.js +39 -0
  165. package/dist/src/semantics/payouts.d.ts +2 -0
  166. package/dist/src/semantics/payouts.js +21 -0
  167. package/dist/src/semantics/prices.d.ts +4 -0
  168. package/dist/src/semantics/prices.js +37 -0
  169. package/dist/src/semantics/products.d.ts +6 -2
  170. package/dist/src/semantics/products.js +15 -130
  171. package/dist/src/semantics/promotion_codes.d.ts +3 -0
  172. package/dist/src/semantics/promotion_codes.js +35 -0
  173. package/dist/src/semantics/radar.d.ts +2 -2
  174. package/dist/src/semantics/radar.js +5 -74
  175. package/dist/src/semantics/refunds.d.ts +3 -9
  176. package/dist/src/semantics/refunds.js +6 -192
  177. package/dist/src/semantics/setup_intents.d.ts +3 -0
  178. package/dist/src/semantics/{setup-intents.js → setup_intents.js} +10 -53
  179. package/dist/src/semantics/shared.d.ts +822 -47
  180. package/dist/src/semantics/shared.js +3044 -78
  181. package/dist/src/semantics/states.d.ts +531 -0
  182. package/dist/src/semantics/states.js +852 -0
  183. package/dist/src/semantics/subscription_items.d.ts +5 -0
  184. package/dist/src/semantics/subscription_items.js +55 -0
  185. package/dist/src/semantics/subscription_schedules.d.ts +4 -0
  186. package/dist/src/semantics/subscription_schedules.js +60 -0
  187. package/dist/src/semantics/subscriptions.d.ts +7 -11
  188. package/dist/src/semantics/subscriptions.js +44 -415
  189. package/dist/src/semantics/test_helpers.d.ts +6 -0
  190. package/dist/src/semantics/{test-clocks.js → test_helpers.js} +14 -40
  191. package/dist/src/semantics/transfers.d.ts +2 -2
  192. package/dist/src/semantics/transfers.js +6 -101
  193. package/dist/src/server.d.ts +7 -0
  194. package/dist/src/server.js +7 -0
  195. package/generated/pack-facts.json +94 -0
  196. package/package.json +10 -20
  197. package/spec/SOURCE.md +14 -0
  198. package/spec/fixtures3.json.gz +0 -0
  199. package/spec/openapi.json.gz +0 -0
  200. package/spec/patches.json +34 -0
  201. package/spec/sources.json +378 -0
  202. package/src/cli.ts +12 -26
  203. package/src/engine/after-payment.ts +31 -0
  204. package/src/engine/apps-secrets.ts +4 -0
  205. package/src/engine/balance.ts +33 -0
  206. package/src/engine/billing.ts +16 -0
  207. package/src/engine/charges.ts +19 -0
  208. package/src/engine/checkout.ts +40 -0
  209. package/src/engine/common.ts +47 -0
  210. package/src/engine/connect-settings.ts +23 -0
  211. package/src/engine/connect.ts +184 -0
  212. package/src/engine/coupons.ts +5 -0
  213. package/src/engine/credit-notes.ts +6 -0
  214. package/src/engine/customers.ts +35 -0
  215. package/src/engine/display.ts +19 -0
  216. package/src/engine/disputes.ts +9 -0
  217. package/src/engine/entitlements.ts +5 -0
  218. package/src/engine/ephemeral-keys.ts +3 -0
  219. package/src/engine/files.ts +41 -0
  220. package/src/engine/front.ts +31 -0
  221. package/src/engine/invoices.ts +71 -0
  222. package/src/engine/issuing.ts +61 -0
  223. package/src/engine/ledger.ts +50 -0
  224. package/src/engine/oauth.ts +19 -0
  225. package/src/engine/onboarding.ts +54 -0
  226. package/src/{stripe-params.ts → engine/params.ts} +8 -56
  227. package/src/engine/payment-intents.ts +33 -0
  228. package/src/engine/payment-links.ts +6 -0
  229. package/src/engine/payment-methods.ts +25 -0
  230. package/src/engine/plans.ts +42 -0
  231. package/src/engine/platform.ts +47 -0
  232. package/src/engine/products.ts +3 -0
  233. package/src/engine/radar.ts +6 -0
  234. package/src/engine/refunds.ts +29 -0
  235. package/src/engine/renewals.ts +73 -0
  236. package/src/engine/setup-intents.ts +5 -0
  237. package/src/{stripe-twin.ts → engine/stripe.ts} +28 -323
  238. package/src/engine/subscription-schedules.ts +10 -0
  239. package/src/engine/subscriptions.ts +40 -0
  240. package/src/engine/tax.ts +39 -0
  241. package/src/engine/terminal.ts +23 -0
  242. package/src/engine/test-clocks.ts +11 -0
  243. package/src/engine/tokens.ts +22 -0
  244. package/src/engine/transfers.ts +23 -0
  245. package/src/engine/treasury.ts +47 -0
  246. package/src/{stripe-version.ts → engine/version.ts} +4 -3
  247. package/src/engine/webhook-endpoints.ts +14 -0
  248. package/src/engine/webhooks.ts +72 -0
  249. package/src/fetch.ts +27 -0
  250. package/src/generated/surface.gen.json +1 -1
  251. package/src/generated/ui.gen.json +1 -1
  252. package/src/index.ts +8 -116
  253. package/src/manifest.ts +234 -786
  254. package/src/screens/{portal.tsx → billing-portal.tsx} +32 -37
  255. package/src/screens/checkout.tsx +33 -95
  256. package/src/screens/connect-oauth.tsx +64 -88
  257. package/src/screens/{onboarding.tsx → connect-onboarding.tsx} +38 -82
  258. package/src/screens/dashboard.tsx +198 -0
  259. package/src/screens/shared.tsx +84 -0
  260. package/src/screens/stripe-js.ts +170 -0
  261. package/src/semantics/account_links.ts +21 -0
  262. package/src/semantics/accounts.ts +43 -0
  263. package/src/semantics/{apps-secrets.ts → apps.ts} +17 -32
  264. package/src/semantics/around.ts +20 -0
  265. package/src/semantics/balance.ts +6 -207
  266. package/src/semantics/balance_transactions.ts +20 -0
  267. package/src/semantics/billing_portal.ts +51 -0
  268. package/src/semantics/charges.ts +12 -211
  269. package/src/semantics/checkout.ts +13 -268
  270. package/src/semantics/clock.ts +26 -0
  271. package/src/semantics/coupons.ts +5 -67
  272. package/src/semantics/customers.ts +29 -392
  273. package/src/semantics/disputes.ts +9 -59
  274. package/src/semantics/doors.ts +80 -0
  275. package/src/semantics/entitlements.ts +9 -56
  276. package/src/semantics/events.ts +44 -0
  277. package/src/semantics/index.ts +111 -0
  278. package/src/semantics/invoice_payments.ts +18 -0
  279. package/src/semantics/invoiceitems.ts +59 -0
  280. package/src/semantics/invoices.ts +109 -443
  281. package/src/semantics/payment_intents.ts +83 -0
  282. package/src/semantics/payment_methods.ts +43 -0
  283. package/src/semantics/payouts.ts +23 -0
  284. package/src/semantics/prices.ts +42 -0
  285. package/src/semantics/products.ts +18 -142
  286. package/src/semantics/promotion_codes.ts +39 -0
  287. package/src/semantics/radar.ts +8 -77
  288. package/src/semantics/refunds.ts +9 -212
  289. package/src/semantics/setup_intents.ts +45 -0
  290. package/src/semantics/shared.ts +3092 -106
  291. package/src/semantics/states.ts +883 -0
  292. package/src/semantics/subscription_items.ts +54 -0
  293. package/src/semantics/subscription_schedules.ts +66 -0
  294. package/src/semantics/subscriptions.ts +49 -432
  295. package/src/semantics/{test-clocks.ts → test_helpers.ts} +23 -47
  296. package/src/semantics/transfers.ts +11 -131
  297. package/src/server.ts +8 -0
  298. package/client/dashboard-api.ts +0 -286
  299. package/client/stripe-mirror.css +0 -277
  300. package/client/stripe-mirror.tsx +0 -1559
  301. package/dist/client/dashboard-api.d.ts +0 -107
  302. package/dist/client/dashboard-api.js +0 -238
  303. package/dist/client/dashboard-api.ts +0 -286
  304. package/dist/client/stripe-mirror.bundle.js +0 -236
  305. package/dist/client/stripe-mirror.css +0 -277
  306. package/dist/client/stripe-mirror.d.ts +0 -134
  307. package/dist/client/stripe-mirror.js +0 -859
  308. package/dist/client/stripe-mirror.tsx +0 -1559
  309. package/dist/src/screens/connect-settings.js +0 -103
  310. package/dist/src/screens/consent-skin.d.ts +0 -4
  311. package/dist/src/screens/consent-skin.js +0 -18
  312. package/dist/src/screens/financial-connections.d.ts +0 -5
  313. package/dist/src/screens/financial-connections.js +0 -90
  314. package/dist/src/screens/identity.d.ts +0 -5
  315. package/dist/src/screens/identity.js +0 -86
  316. package/dist/src/screens/onboarding.d.ts +0 -13
  317. package/dist/src/screens/portal.d.ts +0 -5
  318. package/dist/src/screens/public-details.d.ts +0 -5
  319. package/dist/src/screens/public-details.js +0 -90
  320. package/dist/src/semantics/after-payment.d.ts +0 -22
  321. package/dist/src/semantics/after-payment.js +0 -99
  322. package/dist/src/semantics/apps-secrets.d.ts +0 -2
  323. package/dist/src/semantics/billing.d.ts +0 -2
  324. package/dist/src/semantics/billing.js +0 -220
  325. package/dist/src/semantics/connect.d.ts +0 -5
  326. package/dist/src/semantics/connect.js +0 -493
  327. package/dist/src/semantics/credit-notes.d.ts +0 -2
  328. package/dist/src/semantics/credit-notes.js +0 -172
  329. package/dist/src/semantics/ephemeral-keys.d.ts +0 -2
  330. package/dist/src/semantics/ephemeral-keys.js +0 -34
  331. package/dist/src/semantics/files.d.ts +0 -2
  332. package/dist/src/semantics/files.js +0 -125
  333. package/dist/src/semantics/issuing.d.ts +0 -13
  334. package/dist/src/semantics/issuing.js +0 -575
  335. package/dist/src/semantics/ledger.d.ts +0 -59
  336. package/dist/src/semantics/ledger.js +0 -200
  337. package/dist/src/semantics/payment-intents.d.ts +0 -18
  338. package/dist/src/semantics/payment-intents.js +0 -452
  339. package/dist/src/semantics/payment-links.d.ts +0 -2
  340. package/dist/src/semantics/payment-links.js +0 -133
  341. package/dist/src/semantics/payment-methods.d.ts +0 -20
  342. package/dist/src/semantics/payment-methods.js +0 -140
  343. package/dist/src/semantics/plans.d.ts +0 -5
  344. package/dist/src/semantics/plans.js +0 -121
  345. package/dist/src/semantics/platform.d.ts +0 -9
  346. package/dist/src/semantics/platform.js +0 -206
  347. package/dist/src/semantics/renewals.d.ts +0 -47
  348. package/dist/src/semantics/renewals.js +0 -281
  349. package/dist/src/semantics/setup-intents.d.ts +0 -2
  350. package/dist/src/semantics/subscription-schedules.d.ts +0 -2
  351. package/dist/src/semantics/subscription-schedules.js +0 -119
  352. package/dist/src/semantics/tax.d.ts +0 -2
  353. package/dist/src/semantics/tax.js +0 -197
  354. package/dist/src/semantics/terminal.d.ts +0 -5
  355. package/dist/src/semantics/terminal.js +0 -182
  356. package/dist/src/semantics/test-clocks.d.ts +0 -6
  357. package/dist/src/semantics/tokens.d.ts +0 -4
  358. package/dist/src/semantics/tokens.js +0 -44
  359. package/dist/src/semantics/treasury.d.ts +0 -2
  360. package/dist/src/semantics/treasury.js +0 -377
  361. package/dist/src/semantics/webhook-endpoints.d.ts +0 -3
  362. package/dist/src/semantics/webhook-endpoints.js +0 -85
  363. package/dist/src/stripe-budget.d.ts +0 -55
  364. package/dist/src/stripe-budget.js +0 -155
  365. package/dist/src/stripe-capabilities.d.ts +0 -3
  366. package/dist/src/stripe-capabilities.js +0 -5836
  367. package/dist/src/stripe-conformance.d.ts +0 -43
  368. package/dist/src/stripe-conformance.js +0 -105
  369. package/dist/src/stripe-connector.d.ts +0 -161
  370. package/dist/src/stripe-connector.js +0 -414
  371. package/dist/src/stripe-emit.d.ts +0 -2
  372. package/dist/src/stripe-emit.js +0 -145
  373. package/dist/src/stripe-events.d.ts +0 -93
  374. package/dist/src/stripe-events.js +0 -392
  375. package/dist/src/stripe-js.d.ts +0 -4
  376. package/dist/src/stripe-js.js +0 -70
  377. package/dist/src/stripe-mirror-ui.d.ts +0 -15
  378. package/dist/src/stripe-mirror-ui.js +0 -87
  379. package/dist/src/stripe-perform-harness.d.ts +0 -9
  380. package/dist/src/stripe-perform-harness.js +0 -26
  381. package/dist/src/stripe-server.d.ts +0 -33
  382. package/dist/src/stripe-server.js +0 -429
  383. package/dist/src/stripe-shared.d.ts +0 -109
  384. package/dist/src/stripe-shared.js +0 -276
  385. package/dist/src/stripe-ui-conformance.d.ts +0 -5
  386. package/dist/src/stripe-ui-conformance.js +0 -79
  387. package/dist/src/stripe-ui-structure.d.ts +0 -3
  388. package/dist/src/stripe-ui-structure.js +0 -168
  389. package/dist/test-fixtures/stripe-known-deviations.json +0 -110
  390. package/dist/test-fixtures/stripe-openapi-operations.SOURCE.md +0 -14
  391. package/dist/test-fixtures/stripe-openapi-operations.json +0 -4717
  392. package/dist/test-fixtures/stripe-schemas.SOURCE.md +0 -35
  393. package/dist/test-fixtures/stripe-schemas.json +0 -3813
  394. package/src/screens/connect-settings.tsx +0 -121
  395. package/src/screens/consent-skin.ts +0 -20
  396. package/src/screens/financial-connections.tsx +0 -101
  397. package/src/screens/identity.tsx +0 -96
  398. package/src/screens/public-details.tsx +0 -105
  399. package/src/semantics/after-payment.ts +0 -118
  400. package/src/semantics/billing.ts +0 -216
  401. package/src/semantics/connect.ts +0 -487
  402. package/src/semantics/credit-notes.ts +0 -168
  403. package/src/semantics/ephemeral-keys.ts +0 -34
  404. package/src/semantics/files.ts +0 -143
  405. package/src/semantics/issuing.ts +0 -590
  406. package/src/semantics/ledger.ts +0 -253
  407. package/src/semantics/payment-intents.ts +0 -463
  408. package/src/semantics/payment-links.ts +0 -148
  409. package/src/semantics/payment-methods.ts +0 -145
  410. package/src/semantics/plans.ts +0 -131
  411. package/src/semantics/platform.ts +0 -220
  412. package/src/semantics/renewals.ts +0 -279
  413. package/src/semantics/setup-intents.ts +0 -87
  414. package/src/semantics/subscription-schedules.ts +0 -129
  415. package/src/semantics/tax.ts +0 -220
  416. package/src/semantics/terminal.ts +0 -195
  417. package/src/semantics/tokens.ts +0 -52
  418. package/src/semantics/treasury.ts +0 -383
  419. package/src/semantics/webhook-endpoints.ts +0 -87
  420. package/src/stripe-budget.ts +0 -181
  421. package/src/stripe-capabilities.ts +0 -5651
  422. package/src/stripe-conformance.ts +0 -124
  423. package/src/stripe-connector.ts +0 -462
  424. package/src/stripe-emit.ts +0 -157
  425. package/src/stripe-events.ts +0 -434
  426. package/src/stripe-js.ts +0 -70
  427. package/src/stripe-mirror-ui.ts +0 -90
  428. package/src/stripe-perform-harness.ts +0 -29
  429. package/src/stripe-server.ts +0 -393
  430. package/src/stripe-shared.ts +0 -297
  431. package/src/stripe-ui-conformance.ts +0 -88
  432. package/src/stripe-ui-structure.ts +0 -182
  433. package/test-fixtures/stripe-known-deviations.json +0 -110
  434. package/test-fixtures/stripe-openapi-operations.json +0 -4717
  435. package/test-fixtures/stripe-schemas.json +0 -3813
  436. /package/dist/src/{screens → engine}/industries.d.ts +0 -0
  437. /package/dist/src/{screens → engine}/industries.js +0 -0
  438. /package/dist/src/{semantics → engine}/test-cards.d.ts +0 -0
  439. /package/dist/src/{semantics → engine}/test-cards.js +0 -0
  440. /package/dist/src/{stripe-version.d.ts → engine/version.d.ts} +0 -0
  441. /package/src/{screens → engine}/industries.ts +0 -0
  442. /package/src/{semantics → engine}/test-cards.ts +0 -0
@@ -0,0 +1,378 @@
1
+ {
2
+ "https://docs.stripe.com/api/authentication": {
3
+ "status": 200,
4
+ "checked": "2026-09-30",
5
+ "quotes": {
6
+ "API requests without authentication also fail.": true
7
+ }
8
+ },
9
+ "https://docs.stripe.com/api/balance_transactions/object#balance_transaction_object-status": {
10
+ "status": 200,
11
+ "checked": "2026-09-30"
12
+ },
13
+ "https://docs.stripe.com/api/billing/alert/activate": {
14
+ "status": 200,
15
+ "checked": "2026-09-30"
16
+ },
17
+ "https://docs.stripe.com/api/billing/alert/archive": {
18
+ "status": 200,
19
+ "checked": "2026-09-30"
20
+ },
21
+ "https://docs.stripe.com/api/billing/alert/deactivate": {
22
+ "status": 200,
23
+ "checked": "2026-09-30"
24
+ },
25
+ "https://docs.stripe.com/api/billing/meter/deactivate": {
26
+ "status": 200,
27
+ "checked": "2026-09-30"
28
+ },
29
+ "https://docs.stripe.com/api/billing/meter/reactivate": {
30
+ "status": 200,
31
+ "checked": "2026-09-30"
32
+ },
33
+ "https://docs.stripe.com/api/capabilities/update": {
34
+ "status": 200,
35
+ "checked": "2026-09-30"
36
+ },
37
+ "https://docs.stripe.com/api/charges/capture": {
38
+ "status": 200,
39
+ "checked": "2026-09-30"
40
+ },
41
+ "https://docs.stripe.com/api/charges/object#charge_object-refunded": {
42
+ "status": 200,
43
+ "checked": "2026-09-30"
44
+ },
45
+ "https://docs.stripe.com/api/checkout/sessions/expire": {
46
+ "status": 200,
47
+ "checked": "2026-09-30"
48
+ },
49
+ "https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-payment_status": {
50
+ "status": 200,
51
+ "checked": "2026-09-30"
52
+ },
53
+ "https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-status": {
54
+ "status": 200,
55
+ "checked": "2026-09-30"
56
+ },
57
+ "https://docs.stripe.com/api/climate/order/cancel": {
58
+ "status": 200,
59
+ "checked": "2026-09-30"
60
+ },
61
+ "https://docs.stripe.com/api/credit_notes/void": {
62
+ "status": 200,
63
+ "checked": "2026-09-30"
64
+ },
65
+ "https://docs.stripe.com/api/customer_portal/configurations/update": {
66
+ "status": 200,
67
+ "checked": "2026-09-30"
68
+ },
69
+ "https://docs.stripe.com/api/disputes/close": {
70
+ "status": 200,
71
+ "checked": "2026-09-30"
72
+ },
73
+ "https://docs.stripe.com/api/disputes/update#update_dispute-submit": {
74
+ "status": 200,
75
+ "checked": "2026-09-30"
76
+ },
77
+ "https://docs.stripe.com/api/fee_refunds/create": {
78
+ "status": 200,
79
+ "checked": "2026-09-30"
80
+ },
81
+ "https://docs.stripe.com/api/financial_connections/accounts/disconnect": {
82
+ "status": 200,
83
+ "checked": "2026-09-30"
84
+ },
85
+ "https://docs.stripe.com/api/invoices/delete": {
86
+ "status": 200,
87
+ "checked": "2026-10-02"
88
+ },
89
+ "https://docs.stripe.com/api/invoices/finalize": {
90
+ "status": 200,
91
+ "checked": "2026-09-30"
92
+ },
93
+ "https://docs.stripe.com/api/invoices/mark_uncollectible": {
94
+ "status": 200,
95
+ "checked": "2026-09-30"
96
+ },
97
+ "https://docs.stripe.com/api/invoices/pay": {
98
+ "status": 200,
99
+ "checked": "2026-09-30"
100
+ },
101
+ "https://docs.stripe.com/api/invoices/send": {
102
+ "status": 200,
103
+ "checked": "2026-09-30"
104
+ },
105
+ "https://docs.stripe.com/api/invoices/void": {
106
+ "status": 200,
107
+ "checked": "2026-09-30"
108
+ },
109
+ "https://docs.stripe.com/api/issuing/authorizations/decline": {
110
+ "status": 200,
111
+ "checked": "2026-09-30"
112
+ },
113
+ "https://docs.stripe.com/api/issuing/authorizations/test_mode_capture": {
114
+ "status": 200,
115
+ "checked": "2026-09-30"
116
+ },
117
+ "https://docs.stripe.com/api/issuing/cardholders/update": {
118
+ "status": 200,
119
+ "checked": "2026-09-30"
120
+ },
121
+ "https://docs.stripe.com/api/issuing/cards/update": {
122
+ "status": 200,
123
+ "checked": "2026-09-30"
124
+ },
125
+ "https://docs.stripe.com/api/issuing/tokens/update": {
126
+ "status": 200,
127
+ "checked": "2026-09-30"
128
+ },
129
+ "https://docs.stripe.com/api/mandates/object": {
130
+ "status": 200,
131
+ "checked": "2026-09-30"
132
+ },
133
+ "https://docs.stripe.com/api/payment_intents/apply_customer_balance": {
134
+ "status": 200,
135
+ "checked": "2026-09-30"
136
+ },
137
+ "https://docs.stripe.com/api/payment_intents/cancel": {
138
+ "status": 200,
139
+ "checked": "2026-09-30"
140
+ },
141
+ "https://docs.stripe.com/api/payment_intents/capture": {
142
+ "status": 200,
143
+ "checked": "2026-09-30"
144
+ },
145
+ "https://docs.stripe.com/api/payment_intents/confirm": {
146
+ "status": 200,
147
+ "checked": "2026-09-30"
148
+ },
149
+ "https://docs.stripe.com/api/payment_intents/increment_authorization": {
150
+ "status": 200,
151
+ "checked": "2026-09-30"
152
+ },
153
+ "https://docs.stripe.com/api/payment_links/payment_links/update": {
154
+ "status": 200,
155
+ "checked": "2026-09-30"
156
+ },
157
+ "https://docs.stripe.com/api/payouts/cancel": {
158
+ "status": 200,
159
+ "checked": "2026-09-30"
160
+ },
161
+ "https://docs.stripe.com/api/plans/delete": {
162
+ "status": 200,
163
+ "checked": "2026-09-30"
164
+ },
165
+ "https://docs.stripe.com/api/prices/update#update_price-active": {
166
+ "status": 200,
167
+ "checked": "2026-09-30"
168
+ },
169
+ "https://docs.stripe.com/api/products/update#update_product-active": {
170
+ "status": 200,
171
+ "checked": "2026-09-30"
172
+ },
173
+ "https://docs.stripe.com/api/promotion_codes/update": {
174
+ "status": 200,
175
+ "checked": "2026-09-30"
176
+ },
177
+ "https://docs.stripe.com/api/quotes/accept": {
178
+ "status": 200,
179
+ "checked": "2026-09-30"
180
+ },
181
+ "https://docs.stripe.com/api/quotes/cancel": {
182
+ "status": 200,
183
+ "checked": "2026-09-30"
184
+ },
185
+ "https://docs.stripe.com/api/quotes/finalize": {
186
+ "status": 200,
187
+ "checked": "2026-09-30"
188
+ },
189
+ "https://docs.stripe.com/api/radar/reviews/approve": {
190
+ "status": 200,
191
+ "checked": "2026-09-30"
192
+ },
193
+ "https://docs.stripe.com/api/refunds/cancel": {
194
+ "status": 200,
195
+ "checked": "2026-09-30"
196
+ },
197
+ "https://docs.stripe.com/api/refunds/create#create_refund-refund_application_fee": {
198
+ "status": 200,
199
+ "checked": "2026-09-30"
200
+ },
201
+ "https://docs.stripe.com/api/setup_intents/cancel": {
202
+ "status": 200,
203
+ "checked": "2026-09-30"
204
+ },
205
+ "https://docs.stripe.com/api/setup_intents/confirm": {
206
+ "status": 200,
207
+ "checked": "2026-09-30"
208
+ },
209
+ "https://docs.stripe.com/api/setup_intents/verify_microdeposits": {
210
+ "status": 200,
211
+ "checked": "2026-09-30"
212
+ },
213
+ "https://docs.stripe.com/api/subscription_schedules/cancel": {
214
+ "status": 200,
215
+ "checked": "2026-09-30"
216
+ },
217
+ "https://docs.stripe.com/api/subscription_schedules/release": {
218
+ "status": 200,
219
+ "checked": "2026-09-30"
220
+ },
221
+ "https://docs.stripe.com/api/subscriptions/cancel": {
222
+ "status": 200,
223
+ "checked": "2026-09-30"
224
+ },
225
+ "https://docs.stripe.com/api/subscriptions/update#update_subscription-trial_end": {
226
+ "status": 200,
227
+ "checked": "2026-09-30"
228
+ },
229
+ "https://docs.stripe.com/api/tax_rates/update": {
230
+ "status": 200,
231
+ "checked": "2026-09-30"
232
+ },
233
+ "https://docs.stripe.com/api/terminal/readers/present_payment_method": {
234
+ "status": 200,
235
+ "checked": "2026-09-30"
236
+ },
237
+ "https://docs.stripe.com/api/test_clocks/advance": {
238
+ "status": 200,
239
+ "checked": "2026-09-30"
240
+ },
241
+ "https://docs.stripe.com/api/topups/cancel": {
242
+ "status": 200,
243
+ "checked": "2026-09-30"
244
+ },
245
+ "https://docs.stripe.com/api/treasury": {
246
+ "status": 200,
247
+ "checked": "2026-09-30"
248
+ },
249
+ "https://docs.stripe.com/api/treasury/inbound_transfers": {
250
+ "status": 200,
251
+ "checked": "2026-09-30"
252
+ },
253
+ "https://docs.stripe.com/api/treasury/transactions/object": {
254
+ "status": 200,
255
+ "checked": "2026-09-30"
256
+ },
257
+ "https://docs.stripe.com/api/webhook_endpoints/update#update_webhook_endpoint-disabled": {
258
+ "status": 200,
259
+ "checked": "2026-09-30"
260
+ },
261
+ "https://docs.stripe.com/billing/subscriptions/build-subscriptions": {
262
+ "status": 200,
263
+ "checked": "2026-09-30"
264
+ },
265
+ "https://docs.stripe.com/billing/subscriptions/cancel#cancel-at-end-of-cycle": {
266
+ "status": 200,
267
+ "checked": "2026-09-30"
268
+ },
269
+ "https://docs.stripe.com/billing/subscriptions/overview#payment-status": {
270
+ "status": 200,
271
+ "checked": "2026-09-30"
272
+ },
273
+ "https://docs.stripe.com/billing/subscriptions/trials": {
274
+ "status": 200,
275
+ "checked": "2026-09-30"
276
+ },
277
+ "https://docs.stripe.com/billing/subscriptions/trials/free-trials": {
278
+ "status": 200,
279
+ "checked": "2026-09-30"
280
+ },
281
+ "https://docs.stripe.com/billing/subscriptions/trials/free-trials#adding-a-new-trial-to-a-subscription-previously-in-a-trial": {
282
+ "status": 200,
283
+ "checked": "2026-09-30"
284
+ },
285
+ "https://docs.stripe.com/billing/subscriptions/upgrade-downgrade#immediate-payment": {
286
+ "status": 200,
287
+ "checked": "2026-09-30"
288
+ },
289
+ "https://docs.stripe.com/billing/testing/test-clocks/api-advanced-usage": {
290
+ "status": 200,
291
+ "checked": "2026-09-30"
292
+ },
293
+ "https://docs.stripe.com/connect/account-capabilities#capability-status": {
294
+ "status": 200,
295
+ "checked": "2026-09-30"
296
+ },
297
+ "https://docs.stripe.com/connect/top-ups": {
298
+ "status": 200,
299
+ "checked": "2026-09-30"
300
+ },
301
+ "https://docs.stripe.com/customer-management": {
302
+ "status": 200,
303
+ "checked": "2026-09-30"
304
+ },
305
+ "https://docs.stripe.com/identity/how-sessions-work": {
306
+ "status": 200,
307
+ "checked": "2026-09-30"
308
+ },
309
+ "https://docs.stripe.com/invoicing/integration": {
310
+ "status": 200,
311
+ "checked": "2026-09-30"
312
+ },
313
+ "https://docs.stripe.com/invoicing/integration/workflow-transitions#finalized": {
314
+ "status": 200,
315
+ "checked": "2026-09-30"
316
+ },
317
+ "https://docs.stripe.com/issuing/cards/physical/create-design.md?testing-method=with-code": {
318
+ "status": 200,
319
+ "checked": "2026-09-30",
320
+ "quotes": {
321
+ "Use the [Files API](https://docs.stripe.com/api/files/create.md) to upload a .PNG file of your card logo, and specify the purpose as `issuing_logo`.": true
322
+ }
323
+ },
324
+ "https://docs.stripe.com/issuing/controls/real-time-authorizations": {
325
+ "status": 200,
326
+ "checked": "2026-09-30"
327
+ },
328
+ "https://docs.stripe.com/issuing/purchases/authorizations": {
329
+ "status": 200,
330
+ "checked": "2026-09-30"
331
+ },
332
+ "https://docs.stripe.com/keys": {
333
+ "status": 200,
334
+ "checked": "2026-09-30",
335
+ "quotes": {
336
+ "Publishable keys": true
337
+ }
338
+ },
339
+ "https://docs.stripe.com/payments/ach-direct-debit/accept-a-payment?payment-ui=direct-api": {
340
+ "status": 200,
341
+ "checked": "2026-09-30"
342
+ },
343
+ "https://docs.stripe.com/payments/checkout/how-checkout-works": {
344
+ "status": 200,
345
+ "checked": "2026-09-30"
346
+ },
347
+ "https://docs.stripe.com/payments/customer-balance/reconciliation": {
348
+ "status": 200,
349
+ "checked": "2026-09-30"
350
+ },
351
+ "https://docs.stripe.com/payments/paymentintents/lifecycle": {
352
+ "status": 200,
353
+ "checked": "2026-09-30"
354
+ },
355
+ "https://docs.stripe.com/payouts#payout-statuses": {
356
+ "status": 200,
357
+ "checked": "2026-09-30"
358
+ },
359
+ "https://docs.stripe.com/refunds": {
360
+ "status": 200,
361
+ "checked": "2026-09-30"
362
+ },
363
+ "https://docs.stripe.com/reports/api": {
364
+ "status": 200,
365
+ "checked": "2026-09-30"
366
+ },
367
+ "https://docs.stripe.com/testing#evidence": {
368
+ "status": 200,
369
+ "checked": "2026-09-30"
370
+ },
371
+ "https://docs.stripe.com/webhooks": {
372
+ "status": 200,
373
+ "checked": "2026-09-30",
374
+ "quotes": {
375
+ "register a webhook endpoint, Stripe pushes real-time data to it when": true
376
+ }
377
+ }
378
+ }
package/src/cli.ts CHANGED
@@ -1,36 +1,22 @@
1
1
  #!/usr/bin/env node
2
- import { keepProcessAlive } from '@volter/world-core/lifecycle';
3
- // world-stripe CLI: serve the Stripe API twin, the mirror UI, or run conformance.
2
+ // world-stripe: serve the stripe twin.
4
3
  import { hasFlag, optionValue } from '@volter/world-core/args';
5
- import { createStripeTwinServer } from './stripe-server.ts';
6
- import { createStripeMirrorServer } from './stripe-mirror-ui.ts';
4
+ import { keepProcessAlive } from '@volter/world-core/lifecycle';
5
+ import { createStripeTwinServer } from './server.ts';
7
6
 
8
7
  const [cmd, ...rest] = process.argv.slice(2);
9
8
  const port = Number(optionValue(rest, '--port', '0')) || undefined;
10
9
  const root = optionValue(rest, '--root') || undefined;
11
- const readOnly = hasFlag(rest, '--read-only'); // a twin accepts writes unless started read-only
10
+ const readOnly = hasFlag(rest, '--read-only');
11
+ // the World's managed Postgres, which the runtime binds a pack declaring managedDatabase to
12
+ const database = optionValue(rest, '--database') || undefined;
13
+ // the World's scenario file, for a model vendor's turns
14
+ const scenarioPath = optionValue(rest, '--scenario') || undefined;
12
15
 
13
- if (cmd === 'serve') {
14
- const s = await createStripeTwinServer({ readOnly, ...(root ? { root } : {}), ...(port ? { port } : {}) });
15
- process.stdout.write(`stripe twin (spec-correct API)${readOnly ? ' [read-only]' : ''} at http://127.0.0.1:${s.port}\n`);
16
- await keepProcessAlive();
17
- } else if (cmd === 'mirror') {
18
- const s = await createStripeMirrorServer({ ...(root ? { root } : {}), ...(port ? { port } : {}) });
19
- process.stdout.write(`stripe mirror UI (dashboard) at http://127.0.0.1:${s.port}\n`);
16
+ if (cmd === 'serve' || cmd === undefined) {
17
+ const s = await createStripeTwinServer({ readOnly, ...(root ? { root } : {}), ...(port ? { port } : {}), ...(database ? { database } : {}), ...(scenarioPath ? { scenarioPath } : {}) });
18
+ process.stdout.write(`stripe twin${readOnly ? ' [read-only]' : ''} at http://127.0.0.1:${s.port}\n`);
20
19
  await keepProcessAlive();
21
- } else if (cmd === 'emit') {
22
- // DELIVER: fire a signed, vendor-shaped event synthesized from twin state at the app's
23
- // registered webhook endpoint(s). `emit --list` shows what's emittable right now.
24
- const { runEmitCli } = await import('@volter/world-core');
25
- const { stripeEmitter } = await import('./stripe-emit.ts');
26
- process.exit(await runEmitCli(stripeEmitter, rest));
27
- } else if (cmd === 'conformance') {
28
- // dev-only; lazy so the bin runs without @volter/world-tooling
29
- const { checkStripeConformance, loadStripeKnownDeviations, loadStripeSchemas, stripeCoverage } = await import('./stripe-conformance.ts');
30
- const [schemas, known] = await Promise.all([loadStripeSchemas(), loadStripeKnownDeviations()]);
31
- const report = checkStripeConformance(schemas, { ...(root ? { root } : {}), known });
32
- process.stdout.write(`${JSON.stringify({ ...report, coverage: stripeCoverage(schemas, { ...(root ? { root } : {}) }) }, null, 2)}\n`);
33
- if (!report.ok) process.exitCode = 1;
34
20
  } else {
35
- process.stdout.write('Usage: world-stripe serve|mirror|emit|conformance [--port N] [--root DIR] [--read-only]\n world-stripe emit --list [--root DIR] | emit <event.type> <subject-id> [--root DIR] [--endpoint URL|we_id] [--json]\n');
21
+ process.stdout.write('Usage: world-stripe serve [--port N] [--root DIR] [--read-only] [--database URL] [--scenario FILE]\n');
36
22
  }
@@ -0,0 +1,31 @@
1
+ // What Stripe does itself once a payment succeeds, which no API call asks for:
2
+ // - a test card that is disputed opens a dispute on its charge (docs.stripe.com/testing#disputes: 4000000000000259
3
+ // "charge succeeds, then disputed as fraudulent", 4000000000002685 disputed as product not received,
4
+ // 4000000000001976 an inquiry), and Stripe debits the disputed
5
+ // amount and its dispute fee from the balance (docs.stripe.com/disputes/how-disputes-work);
6
+ // - a test card Radar scores as elevated risk opens a review of its charge (docs.stripe.com/testing#fraud-prevention:
7
+ // 4000000000009235, "elevated risk", which Radar places in review; docs.stripe.com/radar/reviews);
8
+ // - a charge a platform makes with `application_fee_amount` earns the platform an application fee, from the connected
9
+ // account it pays (a destination charge's `transfer_data.destination`, or the account a direct charge is made on;
10
+ // docs.stripe.com/connect/destination-charges, docs.stripe.com/connect/direct-charges);
11
+ // - a bank account verified by micro-deposits for a payment or a setup carries a mandate, the customer's acceptance
12
+ // of debits (docs.stripe.com/payments/ach-direct-debit/accept-a-payment, docs.stripe.com/api/mandates).
13
+ //
14
+ // Where the documentation stops and the twin decides: evidence is due seven days after a dispute opens (Stripe's
15
+ // deadline depends on the card network); the dispute fee is 1500 cents in any currency (Stripe's US fee is $15); an
16
+ // elevated-risk review's risk score is 67 (Radar's elevated band); the application is `ca_twin`.
17
+ import { BYPASS_PENDING_CARDS } from './test-cards.ts';
18
+
19
+ export type Outcome = 'dispute' | 'dispute_not_received' | 'inquiry' | 'review' | 'available';
20
+ export const DAY = 86_400;
21
+
22
+ /** The test cards whose success Stripe follows with its own act, by number and by their documented test names. */
23
+ export const AFTER_SUCCESS_CARDS: Record<string, { brand: string; number: string; outcome: Outcome }> = {
24
+ pm_card_createDispute: { brand: 'visa', number: '4000000000000259', outcome: 'dispute' },
25
+ pm_card_createDisputeProductNotReceived: { brand: 'visa', number: '4000000000002685', outcome: 'dispute_not_received' },
26
+ pm_card_createDisputeInquiry: { brand: 'visa', number: '4000000000001976', outcome: 'inquiry' },
27
+ pm_card_riskLevelElevated: { brand: 'visa', number: '4000000000009235', outcome: 'review' },
28
+ // its funds go straight to the available balance (ledger.ts reads it; no act follows here)
29
+ ...Object.fromEntries(Object.entries(BYPASS_PENDING_CARDS).map(([name, c]) => [name, { ...c, outcome: 'available' as const }])),
30
+ };
31
+ export const BY_NUMBER: Record<string, Outcome> = Object.fromEntries(Object.values(AFTER_SUCCESS_CARDS).map((c) => [c.number, c.outcome]));
@@ -0,0 +1,4 @@
1
+ // Apps secret-store semantics: a secret is named within a scope (the account, or one user); setting
2
+ // the same name in the same scope overwrites it. The scope is kept as a bookkeeping key.
3
+
4
+ export const SECRET = 'apps.secret';
@@ -0,0 +1,33 @@
1
+ // Balance and payout semantics. The balance is computed from the balance-transaction ledger (./ledger.ts), never
2
+ // stored: funds past their available_on are available, the rest pending, and Issuing funds their own section. The
3
+ // balance, the payouts and the ledger are the acting account's: the platform's, or a connected account's under the
4
+ // Stripe-Account header. A payout comes out of what that account has available and goes to its bank account, which a
5
+ // connected account must have (docs.stripe.com/connect/payouts-connected-accounts). A pending payout can be canceled,
6
+ // which returns its money; a connected account's paid payout can be reversed, which debits its bank account back
7
+ // into its balance (docs.stripe.com/api/payouts/reverse). The machine in ../manifest.ts says how a payout's status
8
+ // moves.
9
+ //
10
+ // Stripe also pays each account out on its own schedule (settings.payouts.schedule: daily by default, weekly or monthly
11
+ // on an anchor, or manual): an automatic payout takes what has become available since the last one, and the ledger
12
+ // lists the entries it paid (docs.stripe.com/payouts#payout-schedule, docs.stripe.com/connect/manage-payout-schedule).
13
+ // A connected account is paid out once it can be (payouts_enabled, with a bank account).
14
+ //
15
+ // Where the documentation stops and the twin decides: a payout arrives two days after it is made (Stripe's standard
16
+ // US schedule counts business days) and reads paid from then on; an automatic payout is made at midnight UTC on the
17
+ // first scheduled day on or after its funds become available, only when what it would pay is positive.
18
+ import type { Row } from './common.ts';
19
+
20
+ export const DAY = 86_400;
21
+
22
+ export const DAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
23
+ /** The first scheduled payout time on or after `from`: midnight UTC of a day the schedule pays out on. */
24
+ export function payoutDay(from: number, schedule: Row): number {
25
+ const first = Math.ceil(from / DAY) * DAY;
26
+ const pays = (day: number): boolean => {
27
+ const d = new Date(day * 1000);
28
+ if (schedule.interval === 'weekly') return DAYS[d.getUTCDay()] === String(schedule.weekly_anchor ?? 'monday');
29
+ if (schedule.interval === 'monthly') return d.getUTCDate() === Math.min(Number(schedule.monthly_anchor ?? 1), new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 0)).getUTCDate());
30
+ return true;
31
+ };
32
+ return Array.from({ length: 62 }, (_, i) => first + i * DAY).find(pays) ?? first;
33
+ }
@@ -0,0 +1,16 @@
1
+ // Billing semantics: meters (how usage events aggregate), the meter events that report usage and
2
+ // the summaries that aggregate them, prepaid credit grants and the balance they leave, and usage
3
+ // alerts. The machines in ../manifest.ts say how a meter and an alert move. Lists and retrieves
4
+ // with no scoping of their own are the derived core's.
5
+ import type { Row } from './common.ts';
6
+
7
+ export const METER = 'billing.meter';
8
+ export const objectOf = (v: unknown): Row => (v && typeof v === 'object' ? (v as Row) : {});
9
+
10
+ // ── credit grants: a customer's prepaid credit, paid or promotional, in a monetary amount ──
11
+
12
+ export const GRANT = 'billing.credit_grant';
13
+
14
+ // ── alerts: a usage threshold on a meter ──
15
+
16
+ export const ALERT = 'billing.alert';
@@ -0,0 +1,19 @@
1
+ // Charge semantics. The machine in ../manifest.ts says a charge is captured once; these handlers
2
+ // compute the money: a charge's `refunds` sub-list is derived on every read from the refunds that
3
+ // point at it, never a stored snapshot, while the cumulative `amount_refunded` / `refunded` stay
4
+ // stored (a partial capture moves them for a reason that is also a Refund row).
5
+ import type { Row } from './common.ts';
6
+
7
+ // A charge is written as the event Stripe sends for it (docs.stripe.com/api/events/types; Stripe has no
8
+ // `charge.created`): charge.succeeded, "Occurs whenever a charge is successful", for one made or authorized
9
+ // (capture=false: its status is succeeded, captured false), and charge.failed, "Occurs whenever a failed charge attempt
10
+ // occurs", for a declined attempt. The twin makes no pending charge (charge.pending, "Occurs whenever a pending charge is
11
+ // created"): its charges settle when made.
12
+ /** The create's parameters as the charge keeps them: without `card`, the request's card details ("A token, like the ones
13
+ * returned by Stripe.js", or a hash of the number, expiry and CVC). The Charge object has no `card` property (served
14
+ * spec, charge); the card it was made with is its payment_method_details. Kept, it answered the card's full number and
15
+ * CVC back on every read of the charge. */
16
+ export function withoutCard(params: Row): Row {
17
+ const { card: _card, ...rest } = params;
18
+ return rest;
19
+ }
@@ -0,0 +1,40 @@
1
+ // Checkout Session semantics. The machine in ../manifest.ts says an open session expires or
2
+ // completes and nothing else does. Stripe completes a session when the customer pays on its hosted
3
+ // page (src/screens/checkout.tsx, the session's url), which has no API verb; completing links what
4
+ // the payment made: a succeeded PaymentIntent, an active (or
5
+ // trialing) subscription, or a succeeded SetupIntent. List and retrieve are the derived core's.
6
+ import type { Row } from './common.ts';
7
+
8
+ export const CS = 'checkout.session';
9
+
10
+ /** The payment method types a session takes: the list a caller pinned to an earlier version gives as
11
+ * payment_method_types ("A list of the types of payment methods (e.g., `card`) this Checkout Session can accept", the
12
+ * parameter the served version's allowed_payment_method_types is described against: "Unlike `payment_method_types`,
13
+ * this acts as a filter on the dynamically computed set of eligible payment methods", docs.stripe.com/api/checkout/
14
+ * sessions/create), else the allowed_payment_method_types of the served one, else card. Where the documentation stops
15
+ * and the twin decides: an allowed list is answered whole (the twin does not compute eligibility), and without one the
16
+ * session takes card (the account's enabled methods are not modelled). */
17
+ export function sessionMethodTypes(params: Row): string[] {
18
+ const given = Array.isArray(params.payment_method_types) ? params.payment_method_types : params.allowed_payment_method_types;
19
+ return Array.isArray(given) && given.length ? given.map(String) : ['card'];
20
+ }
21
+
22
+ /** Metadata passed on to what a session makes (payment_intent_data[metadata], subscription_data[metadata]) as a
23
+ * create's own is kept: "Individual keys can be unset by posting an empty value to them. All keys can be unset by
24
+ * posting an empty value to `metadata`" (every metadata parameter, docs.stripe.com/api/metadata), so a key posted
25
+ * empty is not set, and metadata posted empty is {} (./front.ts createMetadata, the top-level case). */
26
+ export function nestedMetadata(given: unknown): Row | undefined {
27
+ if (given === '') return {};
28
+ if (!given || typeof given !== 'object' || Array.isArray(given)) return undefined;
29
+ return Object.fromEntries(Object.entries(given as Row).filter(([, v]) => v !== ''));
30
+ }
31
+
32
+ /** The card the customer entered on the page. */
33
+ export type EnteredCard = { number: string; exp_month: number; exp_year: number };
34
+
35
+ /** A line item of a one-time Price: a stored Price, or an inline `price_data`, without `recurring` ("Line items with
36
+ * one-time Prices will be on the initial invoice only", docs.stripe.com/api/checkout/sessions/create). */
37
+ export function isOneTime(item: Row, priceData?: Row | null): boolean {
38
+ if (priceData) return !priceData.recurring;
39
+ return !!item.price && typeof item.price === 'object' && !(item.price as Row).recurring;
40
+ }
@@ -0,0 +1,47 @@
1
+ // Stripe's shared computation over rows already read: the fields each object's spec gives, a row as Stripe answers it,
2
+ // and the list and refund shapes (the handlers' shared behaviour is ../semantics/shared.ts).
3
+ import { view } from './stripe.ts';
4
+
5
+ import surface from '../generated/surface.gen.json' with { type: 'json' };
6
+
7
+ export type Row = Record<string, unknown>;
8
+
9
+
10
+ /** A removed discount as Stripe answers it: the discount, marked deleted (docs.stripe.com/api/discounts/delete). */
11
+ export function deletedDiscount(d: Row, now: unknown): Row {
12
+ const coupon = d.coupon && typeof d.coupon === 'object' ? String((d.coupon as Row).id) : typeof d.coupon === 'string' ? d.coupon : null;
13
+ return {
14
+ id: d.id ?? `di_${coupon ?? 'twin'}`, object: 'discount', deleted: true, checkout_session: d.checkout_session ?? null, customer: d.customer ?? null,
15
+ invoice: d.invoice ?? null, invoice_item: d.invoice_item ?? null, promotion_code: d.promotion_code ?? null, subscription: d.subscription ?? null,
16
+ subscription_item: d.subscription_item ?? null, source: d.source ?? { type: 'coupon', coupon }, start: d.start ?? now,
17
+ };
18
+ }
19
+
20
+ /** Keep the rows whose field equals the request's parameter of the same name, for each name given. */
21
+ /** A list's range filter on a unix time (`created[gte]=…&created[lt]=…`, or one exact time). */
22
+ export function inRange(t: unknown, v: unknown): boolean {
23
+ const at = Number(t);
24
+ const r = (v && typeof v === 'object' ? v : { gte: v, lte: v }) as Row;
25
+ return (r.gt === undefined || at > Number(r.gt)) && (r.gte === undefined || at >= Number(r.gte)) && (r.lt === undefined || at < Number(r.lt)) && (r.lte === undefined || at <= Number(r.lte));
26
+ }
27
+
28
+ export const SPEC_FIELDS = new Map((surface.resources as Array<{ name: string; fields: Array<{ name: string }> }>).map((r) => [r.name, new Set(r.fields.map((f) => f.name))]));
29
+
30
+ /** A stored subject of any stored type, tombstones included, in the pack's view: what the pack's
31
+ * shared helpers look a price, a payment method or a card up by, read from the context's tree. */
32
+ export type Find = (storedType: string, id: string) => Row | undefined;
33
+
34
+ /** A refund's destination_details for a card charge: "If this is a `card` refund, this hash contains the transaction
35
+ * specific details" and its `type` "can be `refund`, `reversal`, or `pending`" — a reversal, where "The original charge
36
+ * will drop off the bank statement altogether", for an authorization released uncaptured, else a refund, "a credit entry
37
+ * on the bank statement" (docs.stripe.com/api/refunds/object). The network's reference number the twin never has. A
38
+ * charge not paid by card answers none. */
39
+ export function refundDestination(charge: Row, type: 'refund' | 'reversal'): Row {
40
+ const pmd = charge.payment_method_details as Row | null | undefined;
41
+ if (pmd && pmd.type !== 'card') return {};
42
+ return { destination_details: { type: 'card', card: { reference: null, reference_status: null, reference_type: null, type } } };
43
+ }
44
+
45
+ /** An account's external_accounts, "External accounts (bank accounts and debit cards) currently attached to this
46
+ * account" (docs.stripe.com/api/accounts/object), as the list its example answers. */
47
+ export const externalList = (account: string, data: Row[]): Row => ({ object: 'list', data, has_more: false, total_count: data.length, url: `/v1/accounts/${account}/external_accounts` });
@@ -0,0 +1,23 @@
1
+ // The platform's Connect OAuth settings (its client_id, whether OAuth is on, its redirect URIs), which the Dashboard's
2
+ // settings page saves (../screens/dashboard.tsx) and connect.stripe.com/oauth/authorize reads (../screens/connect-oauth.tsx).
3
+
4
+ /** The platform's test client_id: the World's one platform (acct_twin_self) is the application it names. */
5
+ export const PLATFORM_CLIENT_ID = 'ca_twin_self';
6
+ export const SETTINGS_URL = 'https://dashboard.stripe.com/settings/connect/onboarding-options/oauth';
7
+ /** The page's addresses: the docs' own, its test-mode link, and Connect's settings root. */
8
+ export const CONNECT_SETTINGS_PATH = /^\/(test\/)?settings\/connect(\/onboarding-options\/oauth)?\/?$/;
9
+ export const SETTINGS = '_connect_oauth_settings';
10
+
11
+ export type ConnectOAuthSettings = { oauth_enabled: boolean; redirect_uris: string[] };
12
+
13
+ /** The redirect URIs a form's field names, or the first one refused and why. */
14
+ export function redirectUris(field: string): { uris: string[] } | { refused: string } {
15
+ const uris = [...new Set(field.split(/[\n,]/).map((s) => s.trim()).filter(Boolean))];
16
+ for (const uri of uris) {
17
+ let url: URL;
18
+ try { url = new URL(uri); } catch { return { refused: `${uri} is not a valid URL.` }; }
19
+ if (url.protocol !== 'https:' && url.protocol !== 'http:') return { refused: `${uri} must use http or https.` };
20
+ if (uri.includes('#')) return { refused: `${uri} must not contain a fragment.` };
21
+ }
22
+ return { uris };
23
+ }