@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
@@ -1,5 +0,0 @@
1
- // Credit note semantics. A credit note credits part of an invoice: pre_payment while the invoice
2
- // is unpaid (it lowers what is owed), post_payment once paid. The invoice carries the sums of its
3
- // issued credit notes, re-derived on every change so voiding one returns the invoice to where it
4
- // was. The machine in ../manifest.ts says a credit note is voided once. The list is the derived core's.
5
- export const CN = 'credit_note';
File without changes
@@ -1,9 +0,0 @@
1
- "use strict";
2
- // Dispute semantics. A dispute is Stripe's to open, when a charge's cardholder disputes it: the test cards
3
- // that are disputed open one as their charge succeeds (./after-payment.ts). It is then listed, retrieved,
4
- // updated with evidence and closed. Closing concedes it (status → lost), the machine's move in
5
- // ../manifest.ts. Evidence is submitted with the update unless `submit` is false
6
- // (docs.stripe.com/api/disputes/update#update_dispute-submit), and the bank then decides it: in test mode, evidence whose
7
- // uncategorized_text is `winning_evidence` wins it and `losing_evidence` loses it (docs.stripe.com/testing#evidence);
8
- // a won dispute returns the disputed amount. Where the documentation stops and the twin decides: the bank decides at
9
- // once, and any other evidence leaves the dispute under review. List is the derived core's.
@@ -1 +0,0 @@
1
- export declare const FEAT = "entitlements.feature";
@@ -1,4 +0,0 @@
1
- // Entitlements semantics: features (unique by lookup_key) that products grant, and the features a
2
- // customer is entitled to now, derived from its live subscriptions' products. Feature retrieve is
3
- // the derived core's.
4
- export const FEAT = 'entitlements.feature';
File without changes
@@ -1,4 +0,0 @@
1
- "use strict";
2
- // Ephemeral key semantics: the short-lived key the mobile SDKs use, scoped to exactly one object.
3
- // It needs the Stripe-Version header; its secret is answered only by the create; deleting it
4
- // expires it early.
@@ -1,5 +0,0 @@
1
- export declare const PUBLISHABLE_CREATES: Set<string>;
2
- export declare const BY_CLIENT_SECRET: Record<string, {
3
- type: string;
4
- param: string;
5
- }>;
@@ -1,25 +0,0 @@
1
- // ── what a publishable key may call ──
2
- // "Publishable API key pk_... | Safe to expose: Yes | API key for Stripe.js, Elements, and mobile SDKs. It can identify
3
- // your account and create tokens or PaymentMethods from payment details, but it can't perform sensitive operations such
4
- // as creating charges or reading account data" (docs.stripe.com/keys). The served spec names the calls a publishable key
5
- // makes with an object's client secret: "You can retrieve a PaymentIntent client-side using a publishable key when the
6
- // client_secret is provided in the query string" (GET /v1/payment_intents/{intent}), "Client-side retrieval using a
7
- // publishable key is allowed when the client_secret is provided" (GET /v1/setup_intents/{intent}), "Required if a
8
- // publishable key is used to retrieve the source" (GET /v1/sources/{source}), and the confirm and verify_microdeposits
9
- // calls that take "The client secret of the PaymentIntent" (or SetupIntent). Anything else is refused with Stripe's
10
- // code: "secret_key_required | The API key provided is a publishable key, but a secret key is required"
11
- // (docs.stripe.com/error-codes), as 403, "The API key doesn't have permissions to perform the request"
12
- // (docs.stripe.com/api/errors).
13
- // Where the documentation stops and the twin decides: the list above is the whole of what a publishable key may call
14
- // (Stripe publishes no complete list); a client-secret call without the secret answers parameter_missing, and one with a
15
- // secret that is not the object's answers the object's 404, as though the key could not see it.
16
- export const PUBLISHABLE_CREATES = new Set(['PostTokens', 'PostPaymentMethods']);
17
- export const BY_CLIENT_SECRET = {
18
- GetPaymentIntentsIntent: { type: 'payment_intent', param: 'intent' },
19
- PostPaymentIntentsIntentConfirm: { type: 'payment_intent', param: 'intent' },
20
- PostPaymentIntentsIntentVerifyMicrodeposits: { type: 'payment_intent', param: 'intent' },
21
- GetSetupIntentsIntent: { type: 'setup_intent', param: 'intent' },
22
- PostSetupIntentsIntentConfirm: { type: 'setup_intent', param: 'intent' },
23
- PostSetupIntentsIntentVerifyMicrodeposits: { type: 'setup_intent', param: 'intent' },
24
- GetSourcesSource: { type: 'source', param: 'source' },
25
- };
@@ -1 +0,0 @@
1
- export declare const PL = "payment_link";
@@ -1,5 +0,0 @@
1
- // Payment Link and Quote semantics. Both carry line items resolved from existing prices. A payment
2
- // link is a reusable hosted-checkout URL, active until switched off; a quote moves draft → open
3
- // (finalize) → accepted or canceled, the machine in ../manifest.ts. Link retrieve and update
4
- // (`active`, its machine), quote retrieve and the quote list are the derived core's.
5
- export const PL = 'payment_link';
@@ -1,6 +0,0 @@
1
- import type { Row } from './common.js';
2
- export declare const INTERVALS: Set<string>;
3
- /** A recurring price in the plan object's shape (the create page's example response). */
4
- export declare function planOf(price: Row): Row;
5
- /** Metadata after an update: an empty value unsets the key, an empty `metadata` unsets them all. */
6
- export declare function metadataAfter(was: Row, given: unknown): Row;
@@ -1,26 +0,0 @@
1
- export const INTERVALS = new Set(['day', 'week', 'month', 'year']);
2
- /** A recurring price in the plan object's shape (the create page's example response). */
3
- export function planOf(price) {
4
- const r = (price.recurring ?? {});
5
- const amount = typeof price.unit_amount === 'number' ? price.unit_amount : null;
6
- const decimal = typeof price.unit_amount_decimal === 'string' ? price.unit_amount_decimal : amount === null ? null : String(amount);
7
- return {
8
- id: price.id, object: 'plan', active: price.active ?? true, amount, amount_decimal: decimal,
9
- billing_scheme: price.billing_scheme ?? 'per_unit', created: price.created, currency: price.currency, interval: r.interval ?? null,
10
- interval_count: r.interval_count ?? 1, livemode: false, metadata: price.metadata ?? {}, meter: r.meter ?? null, nickname: price.nickname ?? null,
11
- product: price.product, tiers_mode: price.tiers_mode ?? null, transform_usage: price.transform_quantity ?? null,
12
- trial_period_days: r.trial_period_days ?? null, usage_type: r.usage_type ?? 'licensed',
13
- };
14
- }
15
- /** Metadata after an update: an empty value unsets the key, an empty `metadata` unsets them all. */
16
- export function metadataAfter(was, given) {
17
- if (given === '' || given === null || typeof given !== 'object')
18
- return {};
19
- const next = { ...was };
20
- for (const [k, v] of Object.entries(given))
21
- if (v === '' || v === null)
22
- delete next[k];
23
- else
24
- next[k] = v;
25
- return next;
26
- }
@@ -1,39 +0,0 @@
1
- import type { Row } from './common.js';
2
- export declare const CLIMATE_SUPPLIERS: readonly [{
3
- readonly id: "climsup_charm_industrial";
4
- readonly name: "Charm Industrial";
5
- readonly removal_pathway: "biomass_carbon_removal_and_storage";
6
- readonly info_url: "https://frontierclimate.com/portfolio/charm-industrial";
7
- readonly locations: readonly [{
8
- readonly city: "San Francisco";
9
- readonly country: "US";
10
- readonly latitude: 37.7749;
11
- readonly longitude: -122.4194;
12
- readonly region: "CA";
13
- }];
14
- }];
15
- export declare const CLIMATE_PRODUCTS: readonly [{
16
- readonly id: "climsku_frontier_offtake_portfolio_2027";
17
- readonly name: "Frontier's 2027 offtake portfolio";
18
- readonly subtotal: 55000;
19
- readonly fees: 1650;
20
- readonly currency: "usd";
21
- readonly delivery_year: 2027;
22
- readonly metric_tons_available: "18000";
23
- readonly created: 1881439203;
24
- readonly suppliers: readonly ["climsup_charm_industrial"];
25
- }];
26
- export declare const supplierView: (s: (typeof CLIMATE_SUPPLIERS)[number]) => Row;
27
- export declare const productView: (p: (typeof CLIMATE_PRODUCTS)[number]) => Row;
28
- export declare const ORDER = "climate.order";
29
- export declare const FCS = "financial_connections.session";
30
- export declare const FCA = "financial_connections.account";
31
- export declare const FCT = "financial_connections.transaction";
32
- export declare const REPORT_TYPES: Array<{
33
- id: string;
34
- name: string;
35
- }>;
36
- export declare const reportTypeView: (t: {
37
- id: string;
38
- name: string;
39
- }) => Row;
@@ -1,34 +0,0 @@
1
- // ── Climate: Stripe's catalog is managed and account-independent. The twin serves the catalog Stripe's reference
2
- // publishes (docs.stripe.com/api/climate/product/object, /api/climate/supplier/object): Frontier's 2027 offtake
3
- // portfolio at $550 a ton plus Frontier's service fees of $16.50 (3%), 18,000 tons, from Charm Industrial.
4
- // Where the documentation stops and the twin decides: the catalog is that one product and supplier. ──
5
- export const CLIMATE_SUPPLIERS = [
6
- { id: 'climsup_charm_industrial', name: 'Charm Industrial', removal_pathway: 'biomass_carbon_removal_and_storage', info_url: 'https://frontierclimate.com/portfolio/charm-industrial', locations: [{ city: 'San Francisco', country: 'US', latitude: 37.7749, longitude: -122.4194, region: 'CA' }] },
7
- ];
8
- export const CLIMATE_PRODUCTS = [
9
- { id: 'climsku_frontier_offtake_portfolio_2027', name: "Frontier's 2027 offtake portfolio", subtotal: 55000, fees: 1650, currency: 'usd', delivery_year: 2027, metric_tons_available: '18000', created: 1881439203, suppliers: ['climsup_charm_industrial'] },
10
- ];
11
- export const supplierView = (s) => ({ id: s.id, object: 'climate.supplier', name: s.name, removal_pathway: s.removal_pathway, info_url: s.info_url, locations: s.locations, livemode: false });
12
- export const productView = (p) => ({
13
- id: p.id, object: 'climate.product', name: p.name, livemode: false, delivery_year: p.delivery_year,
14
- metric_tons_available: p.metric_tons_available, created: p.created,
15
- current_prices_per_metric_ton: { [p.currency]: { amount_fees: p.fees, amount_subtotal: p.subtotal, amount_total: p.subtotal + p.fees } },
16
- suppliers: p.suppliers.map((id) => supplierView(CLIMATE_SUPPLIERS.find((s) => s.id === id))),
17
- });
18
- export const ORDER = 'climate.order';
19
- // ── Financial Connections: a session is created for an account holder and its permissions; accounts
20
- // are linked in the authentication flow Stripe.js opens (../screens/financial-connections.tsx) ──
21
- export const FCS = 'financial_connections.session';
22
- export const FCA = 'financial_connections.account';
23
- export const FCT = 'financial_connections.transaction';
24
- // ── Reporting: a representative subset of Stripe's report types; a run succeeds at once ──
25
- export const REPORT_TYPES = [
26
- { id: 'balance.summary.1', name: 'Balance summary' },
27
- { id: 'balance_change_from_activity.summary.1', name: 'Balance change from activity (summary)' },
28
- { id: 'payouts.summary.1', name: 'Payouts (summary)' },
29
- { id: 'payout_reconciliation.by_id.itemized.4', name: 'Payout reconciliation (itemized)' },
30
- ];
31
- export const reportTypeView = (t) => ({
32
- id: t.id, object: 'reporting.report_type', name: t.name, version: 1,
33
- data_available_start: 0, data_available_end: 0, default_columns: null, updated: 0, livemode: false,
34
- });
File without changes
@@ -1,4 +0,0 @@
1
- "use strict";
2
- // Product and Price semantics, with the entitlement features granted to a product. Retrieve of a
3
- // product and the product and price updates (archiving and restoring by `active`, the machines in
4
- // ../manifest.ts) are the derived core's.
@@ -1 +0,0 @@
1
- export declare const SI = "setup_intent";
@@ -1,4 +0,0 @@
1
- // SetupIntent semantics. The machine in ../manifest.ts says which moves of `status` are legal and
2
- // what Stripe answers otherwise; these handlers compute what each move does. List, retrieve and
3
- // update are the derived core's.
4
- export const SI = 'setup_intent';
@@ -1,3 +0,0 @@
1
- import { addBillingInterval } from './stripe.js';
2
- export declare const SS = "subscription_schedule";
3
- export type Interval = Parameters<typeof addBillingInterval>[1];
@@ -1 +0,0 @@
1
- export const SS = 'subscription_schedule';
@@ -1,7 +0,0 @@
1
- import type { Row } from './common.js';
2
- export declare const TWIN_TAX_RATE_PCT = 10;
3
- export declare const ADDRESS_LINES: string[];
4
- export declare function settingsBody(stored: Row | undefined): Row;
5
- export declare const TX = "tax.transaction";
6
- export declare const txLine: (id: string, i: number, l: Row, sign: 1 | -1, reversal: Row | null, type: string) => Row;
7
- export declare const linesOf: (holder: Row) => Row[];
@@ -1,28 +0,0 @@
1
- export const TWIN_TAX_RATE_PCT = 10;
2
- // ── settings: active once a head office is set; the answer has no id ──
3
- // the defaults' provider: "The tax calculation provider this account uses. Defaults to `stripe` when not using a
4
- // third-party provider" (the served spec's tax settings defaults); the head office's address answers each line, the
5
- // lines not given null (the served spec's address: each "(string, nullable)"; the settings page's example answers
6
- // line2 null)
7
- export const ADDRESS_LINES = ['city', 'country', 'line1', 'line2', 'postal_code', 'state'];
8
- export function settingsBody(stored) {
9
- const given = (stored?.head_office ?? null);
10
- const address = given && typeof given.address === 'object' && given.address ? given.address : undefined;
11
- const headOffice = given ? { ...given, ...(address ? { address: Object.fromEntries(ADDRESS_LINES.map((k) => [k, address[k] ?? null])) } : {}) } : null;
12
- const active = !!headOffice;
13
- return {
14
- object: 'tax.settings', livemode: false,
15
- defaults: { provider: 'stripe', ...(stored?.defaults ?? { tax_behavior: null, tax_code: null }) }, head_office: headOffice,
16
- status: active ? 'active' : 'pending',
17
- status_details: active ? { active: {} } : { pending: { missing_fields: ['head_office'] } },
18
- };
19
- }
20
- // ── transactions: committing a calculation, or reversing a transaction with negated amounts ──
21
- export const TX = 'tax.transaction';
22
- export const txLine = (id, i, l, sign, reversal, type) => ({
23
- object: 'tax.transaction_line_item', id: `tax_li_${id}_${i + 1}`,
24
- amount: sign === 1 ? l.amount : -(Number(l.amount) || 0), amount_tax: sign === 1 ? l.amount_tax : -(Number(l.amount_tax) || 0),
25
- reference: l.reference ?? null, tax_behavior: l.tax_behavior ?? 'exclusive', tax_code: l.tax_code ?? 'txcd_99999999',
26
- quantity: l.quantity ?? 1, reversal, type, livemode: false, metadata: {},
27
- });
28
- export const linesOf = (holder) => holder.line_items?.data ?? [];
@@ -1,4 +0,0 @@
1
- export declare const LOC = "terminal.location";
2
- export declare const READER = "terminal.reader";
3
- export declare const CONF = "terminal.configuration";
4
- export declare const TOPUP_DAYS = 5;
@@ -1,20 +0,0 @@
1
- // Terminal and top-up semantics: in-person locations, readers (handed a PaymentIntent to process)
2
- // and their configurations, the reader SDK's connection tokens, and top-ups that fund the balance
3
- // (a test top-up succeeds at once; only a pending one cancels, the machine in ../manifest.ts). In test mode a
4
- // simulated reader is presented a card by a test helper: the PaymentIntent the reader is processing is paid with a
5
- // card_present payment method (succeeded, or requires_capture under manual capture) and the reader's action succeeds
6
- // (docs.stripe.com/terminal/references/testing#simulated-test-cards,
7
- // docs.stripe.com/api/terminal/readers/present_payment_method). Where the documentation stops and the twin decides:
8
- // the presented card is the simulated reader's default Visa, and the reader answers at once.
9
- // Lists and retrieves are the derived core's.
10
- export const LOC = 'terminal.location';
11
- export const READER = 'terminal.reader';
12
- export const CONF = 'terminal.configuration';
13
- // ── top-ups ──
14
- // a top-up adds money to the balance it names, through the ledger, once its funds arrive: "USA (USD) ACH Debit Transfer
15
- // 5 days" (docs.stripe.com/connect/top-ups), and to the Issuing balance alike: "Top-ups debit your bank account. Your
16
- // top-ups can take up to 5 business days to become available. While they're pending, they won't be added to your
17
- // Issuing balance" (docs.stripe.com/issuing/funding/balance). It is pending until its expected_availability_date, then
18
- // settled by settleTopups. Where the documentation stops and the twin decides: every top-up takes exactly five days,
19
- // whatever its currency and balance, and succeeds.
20
- export const TOPUP_DAYS = 5;
@@ -1,5 +0,0 @@
1
- export declare const CLOCK = "test_helpers.test_clock";
2
- /** How long an advance takes: "it takes a few seconds to advance to the specified time"
3
- * (docs.stripe.com/billing/testing/test-clocks/api-advanced-usage). Where the documentation stops and the twin decides:
4
- * five seconds of World time from the advance. */
5
- export declare const ADVANCE_SECONDS = 5;
@@ -1,9 +0,0 @@
1
- // Test clock semantics. A test clock is Stripe's own door for a transition no API verb makes: the
2
- // passage of time. Advancing it moves the subscriptions of the clock's customers as a real clock tick does:
3
- // trials that ended end, and periods that ended renew (./renewals.ts advanceBilling). List, retrieve and delete are
4
- // the derived core's.
5
- export const CLOCK = 'test_helpers.test_clock';
6
- /** How long an advance takes: "it takes a few seconds to advance to the specified time"
7
- * (docs.stripe.com/billing/testing/test-clocks/api-advanced-usage). Where the documentation stops and the twin decides:
8
- * five seconds of World time from the advance. */
9
- export const ADVANCE_SECONDS = 5;
@@ -1,7 +0,0 @@
1
- import type { Row } from './common.js';
2
- /** The Card object a card token carries, as the served spec's `card` describes it: its brand as a name ("Card brand.
3
- * Can be `American Express`, ... `MasterCard`, `UnionPay`, `Visa`, or `Unknown`"), the holder's name and address as
4
- * given ("Cardholder name"), and the CVC's check when one was given ("If a CVC was provided, results of the check:
5
- * pass, fail, unavailable, or unchecked"). Where the documentation stops and the twin decides: a test card's CVC passes. */
6
- export declare const BRAND_NAMES: Record<string, string>;
7
- export declare function legacyCard(id: string, card: Row): Row;
@@ -1,20 +0,0 @@
1
- // Token semantics: the older integrations' single-use tokens for a card, a bank account or PII. A
2
- // token carries only the safe fields of its instrument, never the card or account number. Retrieve
3
- // is the derived core's.
4
- import { paymentMethodSubObject } from "./stripe.js";
5
- /** The Card object a card token carries, as the served spec's `card` describes it: its brand as a name ("Card brand.
6
- * Can be `American Express`, ... `MasterCard`, `UnionPay`, `Visa`, or `Unknown`"), the holder's name and address as
7
- * given ("Cardholder name"), and the CVC's check when one was given ("If a CVC was provided, results of the check:
8
- * pass, fail, unavailable, or unchecked"). Where the documentation stops and the twin decides: a test card's CVC passes. */
9
- export const BRAND_NAMES = { amex: 'American Express', cartes_bancaires: 'Cartes Bancaires', diners: 'Diners Club', discover: 'Discover', eftpos_au: 'Eftpos Australia', girocard: 'Girocard', jcb: 'JCB', mastercard: 'MasterCard', unionpay: 'UnionPay', visa: 'Visa' };
10
- export function legacyCard(id, card) {
11
- const pm = paymentMethodSubObject('card', { card }).card;
12
- const given = (k) => (typeof card[k] === 'string' && card[k] !== '' ? card[k] : null);
13
- return {
14
- id, object: 'card', brand: BRAND_NAMES[String(pm.brand)] ?? 'Unknown', last4: pm.last4, exp_month: pm.exp_month, exp_year: pm.exp_year,
15
- funding: pm.funding ?? 'credit', country: pm.country ?? null, fingerprint: pm.fingerprint ?? null, name: given('name'),
16
- address_line1: given('address_line1'), address_line2: given('address_line2'), address_city: given('address_city'), address_state: given('address_state'),
17
- address_zip: given('address_zip'), address_country: given('address_country'), address_line1_check: null, address_zip_check: null,
18
- cvc_check: card.cvc !== undefined && card.cvc !== '' ? 'pass' : null, dynamic_last4: null, tokenization_method: null, metadata: {}, customer: null,
19
- };
20
- }
@@ -1,23 +0,0 @@
1
- import type { Row } from './common.js';
2
- export declare const FA = "treasury.financial_account";
3
- export declare const TX = "treasury.transaction";
4
- export declare const ENTRY = "treasury.transaction_entry";
5
- export declare const ENTRY_TYPES: Set<string>;
6
- /** A financial account's features as the served spec's treasury.financial_account_features gives them: a toggle
7
- * (card_issuing, deposit_insurance, intra_stripe_flows) or a feature per network (financial_addresses.aba,
8
- * inbound_transfers.ach, outbound_payments.ach and .us_domestic_wire, outbound_transfers likewise), each
9
- * { requested, status, status_details }. What a request asks for is laid over what the account had. Where the
10
- * documentation stops and the twin decides: a requested feature is active at once (test mode), and one never requested
11
- * is left out (each is optional in the served spec). Answers the features and the active features' paths. */
12
- export declare const NETWORKS: Record<string, string[]>;
13
- export declare const TOGGLES: string[];
14
- export declare function featuresOf(requested: Row, had?: Row): {
15
- features: Row;
16
- active: string[];
17
- };
18
- export declare const noTransitions: {
19
- canceled_at: null;
20
- failed_at: null;
21
- posted_at: null;
22
- returned_at: null;
23
- };
@@ -1,45 +0,0 @@
1
- export const FA = 'treasury.financial_account';
2
- export const TX = 'treasury.transaction';
3
- export const ENTRY = 'treasury.transaction_entry';
4
- export const ENTRY_TYPES = new Set(['credit_reversal', 'debit_reversal', 'inbound_transfer', 'inbound_transfer_return', 'issuing_authorization_hold', 'issuing_authorization_release', 'outbound_payment', 'outbound_transfer', 'received_credit', 'received_debit']);
5
- /** A financial account's features as the served spec's treasury.financial_account_features gives them: a toggle
6
- * (card_issuing, deposit_insurance, intra_stripe_flows) or a feature per network (financial_addresses.aba,
7
- * inbound_transfers.ach, outbound_payments.ach and .us_domestic_wire, outbound_transfers likewise), each
8
- * { requested, status, status_details }. What a request asks for is laid over what the account had. Where the
9
- * documentation stops and the twin decides: a requested feature is active at once (test mode), and one never requested
10
- * is left out (each is optional in the served spec). Answers the features and the active features' paths. */
11
- export const NETWORKS = { financial_addresses: ['aba'], inbound_transfers: ['ach'], outbound_payments: ['ach', 'us_domestic_wire'], outbound_transfers: ['ach', 'us_domestic_wire'] };
12
- export const TOGGLES = ['card_issuing', 'deposit_insurance', 'intra_stripe_flows'];
13
- export function featuresOf(requested, had = {}) {
14
- const on = (v) => v === true || v === 'true';
15
- const setting = (asked) => ({ requested: asked, status: asked ? 'active' : 'restricted', status_details: [] });
16
- const features = { ...had };
17
- for (const t of TOGGLES) {
18
- const r = requested[t];
19
- if (r && typeof r === 'object' && r.requested !== undefined)
20
- features[t] = setting(on(r.requested));
21
- }
22
- for (const [f, nets] of Object.entries(NETWORKS)) {
23
- const r = requested[f];
24
- if (!r || typeof r !== 'object')
25
- continue;
26
- const current = features[f] ?? {};
27
- const next = { ...current };
28
- for (const n of nets) {
29
- const nr = r[n];
30
- if (nr && typeof nr === 'object' && nr.requested !== undefined)
31
- next[n] = setting(on(nr.requested));
32
- }
33
- features[f] = next;
34
- }
35
- const active = [];
36
- for (const t of TOGGLES)
37
- if (features[t]?.status === 'active')
38
- active.push(t);
39
- for (const [f, nets] of Object.entries(NETWORKS))
40
- for (const n of nets)
41
- if (features[f]?.[n]?.status === 'active')
42
- active.push(`${f}.${n}`);
43
- return { features, active };
44
- }
45
- export const noTransitions = { canceled_at: null, failed_at: null, posted_at: null, returned_at: null };