@volter/twin-stripe 3.0.0 → 3.0.2

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 (253) hide show
  1. package/README.md +75 -21
  2. package/dist/journeys/coverage.json +596 -0
  3. package/dist/journeys/customer-life.json +6108 -0
  4. package/dist/journeys/customer-life.outline.md +371 -0
  5. package/dist/journeys/decisions.json +677 -0
  6. package/dist/journeys/demand.json +706 -0
  7. package/dist/journeys/score.json +853 -0
  8. package/dist/journeys/unreachable.json +102 -0
  9. package/dist/journeys/vendor-examples.json +8010 -0
  10. package/dist/spec/SOURCE.md +5 -1
  11. package/dist/spec/doc-examples.json +445 -0
  12. package/dist/spec/sources.json +135 -207
  13. package/dist/src/cli.d.ts +0 -1
  14. package/dist/src/cli.js +0 -2
  15. package/dist/src/engine/after-payment.d.ts +0 -1
  16. package/dist/src/engine/after-payment.js +0 -1
  17. package/dist/src/engine/common.d.ts +5 -5
  18. package/dist/src/engine/common.js +13 -11
  19. package/dist/src/engine/connect.d.ts +0 -21
  20. package/dist/src/engine/connect.js +1 -82
  21. package/dist/src/engine/customers.d.ts +0 -8
  22. package/dist/src/engine/customers.js +0 -22
  23. package/dist/src/engine/display.d.ts +0 -3
  24. package/dist/src/engine/display.js +0 -3
  25. package/dist/src/engine/files.d.ts +0 -7
  26. package/dist/src/engine/files.js +0 -10
  27. package/dist/src/engine/invoices.d.ts +6 -9
  28. package/dist/src/engine/invoices.js +56 -29
  29. package/dist/src/engine/issuing.d.ts +6 -8
  30. package/dist/src/engine/issuing.js +19 -10
  31. package/dist/src/engine/ledger.d.ts +0 -1
  32. package/dist/src/engine/ledger.js +0 -1
  33. package/dist/src/engine/oauth.js +1 -2
  34. package/dist/src/engine/refunds.js +2 -27
  35. package/dist/src/engine/stripe.d.ts +2 -7
  36. package/dist/src/engine/stripe.js +34 -83
  37. package/dist/src/engine/subscriptions.d.ts +0 -1
  38. package/dist/src/engine/subscriptions.js +0 -1
  39. package/dist/src/engine/version.d.ts +0 -2
  40. package/dist/src/engine/version.js +17 -6
  41. package/dist/src/fetch.js +2 -2
  42. package/dist/src/generated/surface.gen.json +1 -1
  43. package/dist/src/generated/ui.gen.json +1 -1
  44. package/dist/src/index.js +5 -3
  45. package/dist/src/manifest.js +348 -220
  46. package/dist/src/screens/billing-portal.js +5 -5
  47. package/dist/src/screens/{connect-oauth.d.ts → checkout-js.d.ts} +0 -1
  48. package/dist/src/screens/checkout-js.js +84 -0
  49. package/dist/src/screens/connect-onboarding.js +3 -3
  50. package/dist/src/screens/dashboard.d.ts +1 -1
  51. package/dist/src/screens/dashboard.js +56 -53
  52. package/dist/src/screens/stripe-js.js +53 -93
  53. package/dist/src/semantics/account.d.ts +2 -0
  54. package/dist/src/semantics/account.js +8 -0
  55. package/dist/src/semantics/accounts.js +3 -1
  56. package/dist/src/semantics/around.js +3 -6
  57. package/dist/src/semantics/billing_portal.d.ts +0 -1
  58. package/dist/src/semantics/billing_portal.js +1 -7
  59. package/dist/src/semantics/checkout.d.ts +1 -1
  60. package/dist/src/semantics/checkout.js +18 -15
  61. package/dist/src/semantics/clock.js +1 -7
  62. package/dist/src/semantics/customers.d.ts +1 -2
  63. package/dist/src/semantics/customers.js +32 -38
  64. package/dist/src/semantics/entitlements.d.ts +0 -2
  65. package/dist/src/semantics/entitlements.js +4 -50
  66. package/dist/src/semantics/events.d.ts +2 -3
  67. package/dist/src/semantics/events.js +6 -11
  68. package/dist/src/semantics/index.js +16 -38
  69. package/dist/src/semantics/invoices.d.ts +3 -8
  70. package/dist/src/semantics/invoices.js +134 -127
  71. package/dist/src/semantics/issuing.d.ts +6 -0
  72. package/dist/src/semantics/issuing.js +77 -0
  73. package/dist/src/semantics/payment_intents.d.ts +0 -1
  74. package/dist/src/semantics/payment_intents.js +5 -13
  75. package/dist/src/semantics/payment_methods.d.ts +0 -2
  76. package/dist/src/semantics/payment_methods.js +2 -26
  77. package/dist/src/semantics/payouts.d.ts +1 -0
  78. package/dist/src/semantics/payouts.js +8 -1
  79. package/dist/src/semantics/products.d.ts +1 -3
  80. package/dist/src/semantics/products.js +3 -14
  81. package/dist/src/semantics/refunds.d.ts +1 -2
  82. package/dist/src/semantics/refunds.js +1 -5
  83. package/dist/src/semantics/shared.d.ts +64 -336
  84. package/dist/src/semantics/shared.js +326 -1336
  85. package/dist/src/semantics/states.d.ts +20 -89
  86. package/dist/src/semantics/states.js +116 -334
  87. package/dist/src/semantics/subscriptions.d.ts +1 -2
  88. package/dist/src/semantics/subscriptions.js +23 -145
  89. package/dist/src/semantics/test_helpers.d.ts +2 -5
  90. package/dist/src/semantics/test_helpers.js +121 -43
  91. package/dist/src/semantics/webhook_endpoints.d.ts +2 -0
  92. package/dist/src/semantics/webhook_endpoints.js +26 -0
  93. package/generated/pack-facts.json +3 -3
  94. package/journeys/coverage.json +596 -0
  95. package/journeys/customer-life.json +6108 -0
  96. package/journeys/customer-life.outline.md +371 -0
  97. package/journeys/decisions.json +677 -0
  98. package/journeys/demand.json +706 -0
  99. package/journeys/score.json +853 -0
  100. package/journeys/unreachable.json +102 -0
  101. package/journeys/vendor-examples.json +8010 -0
  102. package/package.json +11 -10
  103. package/spec/SOURCE.md +5 -1
  104. package/spec/doc-examples.json +445 -0
  105. package/spec/sources.json +135 -207
  106. package/src/cli.ts +0 -3
  107. package/src/engine/after-payment.ts +0 -2
  108. package/src/engine/balance.ts +0 -1
  109. package/src/engine/checkout.ts +0 -1
  110. package/src/engine/common.ts +19 -17
  111. package/src/engine/connect.ts +1 -79
  112. package/src/engine/customers.ts +0 -25
  113. package/src/engine/display.ts +2 -3
  114. package/src/engine/files.ts +0 -13
  115. package/src/engine/invoices.ts +64 -33
  116. package/src/engine/issuing.ts +16 -11
  117. package/src/engine/ledger.ts +0 -2
  118. package/src/engine/oauth.ts +1 -2
  119. package/src/engine/onboarding.ts +0 -1
  120. package/src/engine/params.ts +0 -1
  121. package/src/engine/payment-intents.ts +0 -1
  122. package/src/engine/payment-methods.ts +0 -1
  123. package/src/engine/refunds.ts +2 -28
  124. package/src/engine/renewals.ts +0 -1
  125. package/src/engine/stripe.ts +35 -83
  126. package/src/engine/subscriptions.ts +0 -3
  127. package/src/engine/transfers.ts +0 -1
  128. package/src/engine/version.ts +15 -7
  129. package/src/engine/webhooks.ts +0 -2
  130. package/src/fetch.ts +2 -2
  131. package/src/generated/surface.gen.json +1 -1
  132. package/src/generated/ui.gen.json +1 -1
  133. package/src/index.ts +6 -4
  134. package/src/manifest.ts +348 -220
  135. package/src/screens/billing-portal.tsx +5 -7
  136. package/src/screens/checkout-js.ts +80 -0
  137. package/src/screens/checkout.tsx +0 -2
  138. package/src/screens/connect-onboarding.tsx +3 -5
  139. package/src/screens/dashboard.tsx +55 -73
  140. package/src/screens/stripe-js.ts +57 -125
  141. package/src/semantics/account.ts +10 -0
  142. package/src/semantics/account_links.ts +0 -1
  143. package/src/semantics/accounts.ts +8 -7
  144. package/src/semantics/apps.ts +1 -2
  145. package/src/semantics/around.ts +3 -6
  146. package/src/semantics/balance.ts +0 -1
  147. package/src/semantics/balance_transactions.ts +1 -3
  148. package/src/semantics/billing_portal.ts +1 -7
  149. package/src/semantics/charges.ts +1 -6
  150. package/src/semantics/checkout.ts +16 -12
  151. package/src/semantics/clock.ts +1 -8
  152. package/src/semantics/coupons.ts +0 -1
  153. package/src/semantics/customers.ts +32 -35
  154. package/src/semantics/doors.ts +2 -3
  155. package/src/semantics/entitlements.ts +1 -45
  156. package/src/semantics/events.ts +7 -14
  157. package/src/semantics/index.ts +16 -38
  158. package/src/semantics/invoice_payments.ts +1 -3
  159. package/src/semantics/invoices.ts +124 -119
  160. package/src/semantics/issuing.ts +74 -0
  161. package/src/semantics/payment_intents.ts +10 -17
  162. package/src/semantics/payment_methods.ts +2 -25
  163. package/src/semantics/payouts.ts +9 -3
  164. package/src/semantics/prices.ts +0 -1
  165. package/src/semantics/products.ts +4 -14
  166. package/src/semantics/promotion_codes.ts +0 -1
  167. package/src/semantics/radar.ts +1 -3
  168. package/src/semantics/refunds.ts +2 -11
  169. package/src/semantics/shared.ts +350 -1382
  170. package/src/semantics/states.ts +109 -330
  171. package/src/semantics/subscriptions.ts +25 -145
  172. package/src/semantics/test_helpers.ts +109 -43
  173. package/src/semantics/transfers.ts +1 -3
  174. package/src/semantics/webhook_endpoints.ts +27 -0
  175. package/src/server.ts +0 -1
  176. package/dist/generated/pack-facts.json +0 -94
  177. package/dist/src/engine/billing.d.ts +0 -5
  178. package/dist/src/engine/billing.js +0 -6
  179. package/dist/src/engine/charges.d.ts +0 -6
  180. package/dist/src/engine/charges.js +0 -13
  181. package/dist/src/engine/connect-settings.d.ts +0 -16
  182. package/dist/src/engine/connect-settings.js +0 -26
  183. package/dist/src/engine/coupons.d.ts +0 -0
  184. package/dist/src/engine/coupons.js +0 -5
  185. package/dist/src/engine/credit-notes.d.ts +0 -1
  186. package/dist/src/engine/credit-notes.js +0 -5
  187. package/dist/src/engine/disputes.d.ts +0 -0
  188. package/dist/src/engine/disputes.js +0 -9
  189. package/dist/src/engine/entitlements.d.ts +0 -1
  190. package/dist/src/engine/entitlements.js +0 -4
  191. package/dist/src/engine/ephemeral-keys.d.ts +0 -0
  192. package/dist/src/engine/ephemeral-keys.js +0 -4
  193. package/dist/src/engine/front.d.ts +0 -5
  194. package/dist/src/engine/front.js +0 -25
  195. package/dist/src/engine/payment-links.d.ts +0 -1
  196. package/dist/src/engine/payment-links.js +0 -5
  197. package/dist/src/engine/plans.d.ts +0 -6
  198. package/dist/src/engine/plans.js +0 -26
  199. package/dist/src/engine/platform.d.ts +0 -39
  200. package/dist/src/engine/platform.js +0 -34
  201. package/dist/src/engine/products.d.ts +0 -0
  202. package/dist/src/engine/products.js +0 -4
  203. package/dist/src/engine/setup-intents.d.ts +0 -1
  204. package/dist/src/engine/setup-intents.js +0 -4
  205. package/dist/src/engine/subscription-schedules.d.ts +0 -3
  206. package/dist/src/engine/subscription-schedules.js +0 -1
  207. package/dist/src/engine/tax.d.ts +0 -7
  208. package/dist/src/engine/tax.js +0 -28
  209. package/dist/src/engine/terminal.d.ts +0 -4
  210. package/dist/src/engine/terminal.js +0 -20
  211. package/dist/src/engine/test-clocks.d.ts +0 -5
  212. package/dist/src/engine/test-clocks.js +0 -9
  213. package/dist/src/engine/tokens.d.ts +0 -7
  214. package/dist/src/engine/tokens.js +0 -20
  215. package/dist/src/engine/treasury.d.ts +0 -23
  216. package/dist/src/engine/treasury.js +0 -45
  217. package/dist/src/screens/connect-oauth.js +0 -333
  218. package/dist/src/semantics/disputes.d.ts +0 -2
  219. package/dist/src/semantics/disputes.js +0 -5
  220. package/dist/src/semantics/invoiceitems.d.ts +0 -3
  221. package/dist/src/semantics/invoiceitems.js +0 -59
  222. package/dist/src/semantics/setup_intents.d.ts +0 -3
  223. package/dist/src/semantics/setup_intents.js +0 -41
  224. package/dist/src/semantics/subscription_items.d.ts +0 -5
  225. package/dist/src/semantics/subscription_items.js +0 -55
  226. package/dist/src/semantics/subscription_schedules.d.ts +0 -4
  227. package/dist/src/semantics/subscription_schedules.js +0 -60
  228. package/src/engine/billing.ts +0 -16
  229. package/src/engine/charges.ts +0 -19
  230. package/src/engine/connect-settings.ts +0 -23
  231. package/src/engine/coupons.ts +0 -5
  232. package/src/engine/credit-notes.ts +0 -6
  233. package/src/engine/disputes.ts +0 -9
  234. package/src/engine/entitlements.ts +0 -5
  235. package/src/engine/ephemeral-keys.ts +0 -3
  236. package/src/engine/front.ts +0 -31
  237. package/src/engine/payment-links.ts +0 -6
  238. package/src/engine/plans.ts +0 -42
  239. package/src/engine/platform.ts +0 -47
  240. package/src/engine/products.ts +0 -3
  241. package/src/engine/setup-intents.ts +0 -5
  242. package/src/engine/subscription-schedules.ts +0 -10
  243. package/src/engine/tax.ts +0 -39
  244. package/src/engine/terminal.ts +0 -23
  245. package/src/engine/test-clocks.ts +0 -11
  246. package/src/engine/tokens.ts +0 -22
  247. package/src/engine/treasury.ts +0 -47
  248. package/src/screens/connect-oauth.tsx +0 -376
  249. package/src/semantics/disputes.ts +0 -12
  250. package/src/semantics/invoiceitems.ts +0 -59
  251. package/src/semantics/setup_intents.ts +0 -45
  252. package/src/semantics/subscription_items.ts +0 -54
  253. package/src/semantics/subscription_schedules.ts +0 -66
package/README.md CHANGED
@@ -3,10 +3,34 @@
3
3
  A local Stripe: the REST API the unmodified `stripe` SDK calls (`https://api.stripe.com/v1`), the hosted pages an
4
4
  application sends a person through, and Stripe.js, over one state.
5
5
 
6
- A Protocol 3 pack ([architecture](../../../docs/contributing/architecture.md), "Protocol 3"). Its surface is generated
7
- from Stripe's published OpenAPI document (`spec/`). The derived core serves plain reads, writes and deletes. Handlers
8
- are in `src/semantics/<family>.ts`, the state machines in `src/semantics/states.ts`, and Stripe's own computation
9
- (money and declines, billing, the ledger, the API versions) in `src/engine/`.
6
+ ## Use with an existing app
7
+
8
+ In an app that already uses this vendor, install this exact release and the product CLI:
9
+
10
+ ```console
11
+ npm install --save-dev --save-exact @volter/world@3.0.68 @volter/twin-stripe@3.0.2
12
+ npx volter world init --name my-app --twins stripe --source stripe=@volter/twin-stripe
13
+ ```
14
+
15
+ Review the detected vendor and generated bindings before booting. Read the credential names and limitations below; the World supplies throwaway credentials. Then run your app's own command through the World:
16
+
17
+ ```console
18
+ npx volter world up
19
+ npx volter world run -- npm test
20
+ npx volter world log
21
+ npx volter world down
22
+ ```
23
+
24
+ Here `npm test` is your app's existing command; replace it with your app or test command. `down` retains state.
25
+ A later `up` resumes it; do not reset or initialize again merely to return.
26
+
27
+ Publisher and catalog contribution instructions: [the public publisher guide](https://github.com/volter-ai/twin-catalog-open/blob/main/docs/contributing.md).
28
+
29
+
30
+ A Protocol 3 pack ([publisher guide](https://github.com/volter-ai/twin-catalog-open/blob/main/docs/contributing.md)). Its surface is
31
+ generated from Stripe's published OpenAPI document (`spec/`). The derived core serves plain reads, writes and deletes.
32
+ Handlers are in `src/semantics/<family>.ts`, the state machines in `src/semantics/states.ts`, and Stripe's own
33
+ computation (money and declines, billing, the ledger, the API versions) in `src/engine/`.
10
34
 
11
35
  ```bash
12
36
  world-stripe serve [--port N] [--root DIR] [--read-only]
@@ -14,32 +38,55 @@ world-stripe serve [--port N] [--root DIR] [--read-only]
14
38
 
15
39
  ## What it models
16
40
 
17
- The calls the applications make (`journeys/demand.json`: Dub, Twenty, Inbox Zero, Rallly, cal.com and Ponder, and the
18
- frontends' Stripe.js):
19
-
20
- - **Customers**: created, updated, searched, deleted; their balance, payment methods and entitlements.
21
- - **Catalog**: products (with search) and prices, coupons and promotion codes.
22
- - **Checkout Sessions** and the customer portal (sessions and configurations).
23
- - **Subscriptions**: their items and schedules, previews, updates, searches and cancellations.
24
- - **Invoices**: invoice items, finalize, send, pay, void, delete and lines.
25
- - **Intents**: payment and setup intents (confirmed by Stripe.js with the publishable key and the client secret),
26
- payment methods (attach, detach), refunds, charges, disputes.
27
- - **Test clocks**, billing meters, the Apps secret store.
28
- - **Connect**: Express accounts, account links and login links, external accounts, transfers, payouts, the balance and
29
- its transactions.
41
+ What the demand reaches (`journeys/demand.json`: Open Autonomy, Twin, Volter Harness, and the stripe-node applications
42
+ Cal.com, Dub, Postiz, Rallly and Twenty, with their frontends' Stripe.js), the life (`journeys/customer-life.json`) and a
43
+ vendor-backed World's refresh; each served operation is decided in `journeys/decisions.json`:
44
+
45
+ - **Customers**: created, updated, searched, listed by email, deleted; their balance transactions and payment methods,
46
+ and their active entitlements (read). Balance-transaction writes answer the gap.
47
+ - **Catalog**: products and prices created and listed, prices retrieved, coupons and promotion codes managed. Product search and administrative product/price updates answer the gap.
48
+ - **Checkout Sessions** and the customer portal (sessions and configurations): pay, add a card, pay an open invoice,
49
+ cancel at the period's end or at once.
50
+ - **Subscriptions**: created (charged at once, trialing, `default_incomplete` or `error_if_incomplete`), updated (items,
51
+ discounts, a trial ended early or added), searched, canceled; their items, schedules (made, updated, released),
52
+ renewals on the World clock, and a renewal declined and paid later.
53
+ - **Invoices**: invoice items, drafts, finalize, pay (a draft is finalized on the way), void, delete, lines,
54
+ previews and their payments. Invoice lines are read in the invoice; the standalone lines endpoint answers the gap.
55
+ - **Intents**: payment and setup intents, confirmed on the server or by Stripe.js with the publishable key and the
56
+ client secret, through the testing page's cards (declines, 3-D Secure) and test bank accounts (ACH debits that settle,
57
+ micro-deposit verification asked), a hold confirmed under manual capture and canceled, a bank transfer that waits for
58
+ funds; payment methods attached and detached; refunds (held for want of balance, with a destination charge's
59
+ transfer reversed and its application fee refunded); the charges, disputes and Radar reviews the testing page's cards
60
+ bring.
61
+ - **Apps secret store**; existing Radar value lists and their items (reads and item insertion).
62
+ - **Connect**: Express and Custom accounts, account links (Stripe's hosted onboarding) and login links, transfers (from
63
+ a charge's funds too), payouts, the balance and its transactions, application fees and their refunds, and Connect
64
+ OAuth (cal.com's).
65
+ - **Issuing** (Open Autonomy's card rail): cardholders and cards (a card is `inactive` unless its create names a status;
66
+ its number and CVC drawn from the World and shown only when expanded), activated, frozen and canceled; authorizations
67
+ asked of the real-time endpoint, approved or declined within the window or decided by Stripe when it ends, and
68
+ received from the vendor and closed by its transactions. Their published fixtures are recorded notReplayed because authorization creation and capture test helpers remain outside demand.
69
+ - **Webhook endpoints** made through the API, each with its own signing secret; events listed.
30
70
 
31
71
  **Keys.** The platform's secret and publishable keys, and its webhook secret, are issued by the credential door and
32
72
  held by their SHA-256. A request with no key, or with one Stripe never issued, is refused 401. A connected account's
33
73
  OAuth key acts as that account.
34
74
 
35
- **The gap.** Every other operation answers Stripe's unknown-URL 404: Issuing, Terminal, Treasury, Tax, Quotes, credit
36
- notes, reporting, identity, sources, plans, payment links, and the webhook endpoints and keys APIs.
75
+ **The gap.** Operations outside application demand and the declared refresh reads answer Stripe's unknown-URL 404
76
+ (the manifest's literal `unmodeled` list). This includes administrative catalog updates and deletion, direct
77
+ PaymentMethod creation and attachment, send-invoice, balance-credit writes, test clocks and Issuing test helpers,
78
+ top-ups, Plans, meter and entitlement-feature setup, Radar-list creation, and separate products such as Terminal,
79
+ Treasury, Tax, Climate, Identity and Financial Connections. Reading an already declared resource for vendor-backed
80
+ refresh remains served; declaring an unused product does not establish application demand.
81
+
82
+ **Vendor-backed.** Every stored resource declares its `refresh` (the list that reads it back, under its parent where it
83
+ has one); Stripe's webhooks are ingested by their `Stripe-Signature` (`type`, `data.object`); calls are charged against
84
+ Stripe's documented limit (25 requests a second in a sandbox).
37
85
 
38
86
  ## Events
39
87
 
40
88
  Every write Stripe reports sends its event (`payment_intent.succeeded`, `customer.subscription.created`,
41
- `invoice.paid`, …; a charge sends `charge.succeeded`, `charge.failed` or `charge.captured`, never an invented
42
- `charge.created`), declared as data the kernel renders, stores, signs (`Stripe-Signature: t=…,v1=…`, which the
89
+ `invoice.paid`, …; a charge sends `charge.succeeded` or `charge.failed`, never an invented `charge.created`), declared as data the kernel renders, stores, signs (`Stripe-Signature: t=…,v1=…`, which the
43
90
  SDK's `constructEvent` verifies) and delivers to the account's enabled webhook endpoints whose `enabled_events` take it
44
91
  (`*`, `<family>.*` or the type). Each event is rendered in the writing request's API version.
45
92
 
@@ -86,3 +133,10 @@ The World's hands where Stripe's API has no act (`src/semantics/doors.ts`), refu
86
133
  - `POST /_twin/account {settings?, business_profile?, …}`: the platform's own account settings, as the Dashboard
87
134
  changes them.
88
135
  - `POST /_twin/drain`: time's events, sent when a runner drives them (`payout.paid`, `balance.available`).
136
+
137
+ ## Published examples
138
+
139
+ `journeys/vendor-examples.json` replays Stripe's published examples for the operations the pack serves: the fixtures
140
+ beside its spec (`spec/fixtures3.json.gz`), and the requests and rules its documentation pages publish
141
+ (`spec/doc-examples.json`: the testing page's cards and test bank accounts, the payment lifecycle's states, and each
142
+ reference page's stated rule). Examples whose preconditions require an unserved setup operation are recorded notReplayed naming that operation and its pinned-spec citation. Served preconditions replay through vendor APIs, including customer balance changes and their immutable ledger entries. Coverage remains missing where no application call or published replay reaches it.