@pithy-sh/payments 0.1.1 → 0.1.3

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 (402) hide show
  1. package/dist/admin/coverage.d.ts +35 -0
  2. package/dist/admin/coverage.d.ts.map +1 -0
  3. package/dist/admin/coverage.js +56 -0
  4. package/dist/admin/read.d.ts +222 -0
  5. package/dist/admin/read.d.ts.map +1 -0
  6. package/dist/admin/read.js +159 -0
  7. package/dist/audit/actions.d.ts +211 -0
  8. package/dist/audit/actions.d.ts.map +1 -0
  9. package/dist/audit/actions.js +211 -0
  10. package/dist/capability.d.ts +72 -0
  11. package/dist/capability.d.ts.map +1 -0
  12. package/dist/capability.js +228 -0
  13. package/dist/client/api.d.ts +435 -0
  14. package/dist/client/api.d.ts.map +1 -0
  15. package/dist/client/api.js +415 -0
  16. package/dist/client/checkout.d.ts +144 -0
  17. package/dist/client/checkout.d.ts.map +1 -0
  18. package/dist/client/checkout.js +173 -0
  19. package/dist/client/fixtures/price-preview-de.js +89 -0
  20. package/dist/client/fixtures/price-preview-gb.js +89 -0
  21. package/dist/client/fixtures/price-preview-jp-yen.js +89 -0
  22. package/dist/client/fixtures/price-preview-us-country-only.js +89 -0
  23. package/dist/client/fixtures/price-preview-us-new-york.js +89 -0
  24. package/dist/client/fixtures/pricePreview.d.ts +54 -0
  25. package/dist/client/fixtures/pricePreview.d.ts.map +1 -0
  26. package/dist/client/fixtures/pricePreview.js +61 -0
  27. package/dist/client/hooks.d.ts +235 -0
  28. package/dist/client/hooks.d.ts.map +1 -0
  29. package/dist/client/hooks.js +428 -0
  30. package/dist/client/paddle.d.ts +433 -0
  31. package/dist/client/paddle.d.ts.map +1 -0
  32. package/dist/client/paddle.js +391 -0
  33. package/dist/client/paddleCache.d.ts +123 -0
  34. package/dist/client/paddleCache.d.ts.map +1 -0
  35. package/dist/client/paddleCache.js +159 -0
  36. package/dist/client/paddlePrices.d.ts +94 -0
  37. package/dist/client/paddlePrices.d.ts.map +1 -0
  38. package/dist/client/paddlePrices.js +55 -0
  39. package/dist/client/paddlePricesTag.d.ts +127 -0
  40. package/dist/client/paddlePricesTag.d.ts.map +1 -0
  41. package/dist/client/paddlePricesTag.js +207 -0
  42. package/dist/client/projection.d.ts +128 -0
  43. package/dist/client/projection.d.ts.map +1 -0
  44. package/dist/client/projection.js +0 -0
  45. package/dist/client/test-utils/cacheStore.d.ts +18 -0
  46. package/dist/client/test-utils/cacheStore.d.ts.map +1 -0
  47. package/dist/client/test-utils/cacheStore.js +42 -0
  48. package/dist/client/wholeUnits.d.ts +18 -0
  49. package/dist/client/wholeUnits.d.ts.map +1 -0
  50. package/dist/client/wholeUnits.js +120 -0
  51. package/dist/config/config.d.ts +238 -0
  52. package/dist/config/config.d.ts.map +1 -0
  53. package/dist/config/config.js +249 -0
  54. package/dist/data/discount.d.ts +127 -0
  55. package/dist/data/discount.d.ts.map +1 -0
  56. package/dist/data/discount.js +91 -0
  57. package/dist/data/entitlement.d.ts +43 -0
  58. package/dist/data/entitlement.d.ts.map +1 -0
  59. package/dist/data/entitlement.js +43 -0
  60. package/dist/data/money.d.ts +15 -0
  61. package/dist/data/money.d.ts.map +1 -0
  62. package/dist/data/money.js +76 -0
  63. package/dist/data/pause.d.ts +133 -0
  64. package/dist/data/pause.d.ts.map +1 -0
  65. package/dist/data/pause.js +63 -0
  66. package/dist/data/providerAccount.d.ts +40 -0
  67. package/dist/data/providerAccount.d.ts.map +1 -0
  68. package/dist/data/providerAccount.js +34 -0
  69. package/dist/data/purchase.d.ts +107 -0
  70. package/dist/data/purchase.d.ts.map +1 -0
  71. package/dist/data/purchase.js +77 -0
  72. package/dist/data/rail.d.ts +74 -0
  73. package/dist/data/rail.d.ts.map +1 -0
  74. package/dist/data/rail.js +74 -0
  75. package/dist/data/reconcileRun.d.ts +120 -0
  76. package/dist/data/reconcileRun.d.ts.map +1 -0
  77. package/dist/data/reconcileRun.js +120 -0
  78. package/dist/data/renderMoney.d.ts +85 -0
  79. package/dist/data/renderMoney.d.ts.map +1 -0
  80. package/dist/data/renderMoney.js +146 -0
  81. package/dist/data/status.d.ts +58 -0
  82. package/dist/data/status.d.ts.map +1 -0
  83. package/dist/data/status.js +68 -0
  84. package/dist/data/subject.d.ts +111 -0
  85. package/dist/data/subject.d.ts.map +1 -0
  86. package/dist/data/subject.js +125 -0
  87. package/dist/data/subscription.d.ts +624 -0
  88. package/dist/data/subscription.d.ts.map +1 -0
  89. package/dist/data/subscription.js +497 -0
  90. package/dist/data/syncCursor.d.ts +33 -0
  91. package/dist/data/syncCursor.d.ts.map +1 -0
  92. package/dist/data/syncCursor.js +29 -0
  93. package/dist/data/tables.d.ts +37 -0
  94. package/dist/data/tables.d.ts.map +1 -0
  95. package/dist/data/tables.js +44 -0
  96. package/dist/data/webhookEvent.d.ts +134 -0
  97. package/dist/data/webhookEvent.d.ts.map +1 -0
  98. package/dist/data/webhookEvent.js +128 -0
  99. package/dist/entitlement/manual.d.ts +101 -0
  100. package/dist/entitlement/manual.d.ts.map +1 -0
  101. package/dist/entitlement/manual.js +84 -0
  102. package/dist/entitlement/resolver.d.ts +60 -0
  103. package/dist/entitlement/resolver.d.ts.map +1 -0
  104. package/dist/entitlement/resolver.js +101 -0
  105. package/dist/entitlement/subjectSeam.d.ts +102 -0
  106. package/dist/entitlement/subjectSeam.d.ts.map +1 -0
  107. package/dist/entitlement/subjectSeam.js +85 -0
  108. package/dist/error/errors.d.ts +247 -0
  109. package/dist/error/errors.d.ts.map +1 -0
  110. package/dist/error/errors.js +326 -0
  111. package/dist/grants/apply.d.ts +74 -0
  112. package/dist/grants/apply.d.ts.map +1 -0
  113. package/dist/grants/apply.js +148 -0
  114. package/dist/grants/clawback.d.ts +43 -0
  115. package/dist/grants/clawback.d.ts.map +1 -0
  116. package/dist/grants/clawback.js +71 -0
  117. package/dist/grants/ledgerSeam.d.ts +89 -0
  118. package/dist/grants/ledgerSeam.d.ts.map +1 -0
  119. package/dist/grants/ledgerSeam.js +66 -0
  120. package/dist/http/dispatch.d.ts +35 -0
  121. package/dist/http/dispatch.d.ts.map +1 -0
  122. package/dist/http/dispatch.js +40 -0
  123. package/dist/http/guards.d.ts +43 -0
  124. package/dist/http/guards.d.ts.map +1 -0
  125. package/dist/http/guards.js +52 -0
  126. package/dist/http/manifestConfig.d.ts +38 -0
  127. package/dist/http/manifestConfig.d.ts.map +1 -0
  128. package/dist/http/manifestConfig.js +49 -0
  129. package/dist/http/responses.d.ts +1455 -0
  130. package/dist/http/responses.d.ts.map +1 -0
  131. package/dist/http/responses.js +728 -0
  132. package/dist/http/routes.d.ts +315 -0
  133. package/dist/http/routes.d.ts.map +1 -0
  134. package/dist/http/routes.js +1966 -0
  135. package/dist/http/schemas.d.ts +404 -0
  136. package/dist/http/schemas.d.ts.map +1 -0
  137. package/dist/http/schemas.js +359 -0
  138. package/dist/http/scopes.d.ts +160 -0
  139. package/dist/http/scopes.d.ts.map +1 -0
  140. package/dist/http/scopes.js +240 -0
  141. package/dist/http/view.d.ts +96 -0
  142. package/dist/http/view.d.ts.map +1 -0
  143. package/dist/http/view.js +170 -0
  144. package/dist/http/webhookGuard.d.ts +109 -0
  145. package/dist/http/webhookGuard.d.ts.map +1 -0
  146. package/dist/http/webhookGuard.js +206 -0
  147. package/dist/index.d.ts +64 -0
  148. package/dist/index.d.ts.map +1 -0
  149. package/dist/index.js +43 -0
  150. package/dist/migrations/0001_purchases.d.ts +35 -0
  151. package/dist/migrations/0001_purchases.d.ts.map +1 -0
  152. package/dist/migrations/0001_purchases.js +80 -0
  153. package/dist/pricing/location.d.ts +138 -0
  154. package/dist/pricing/location.d.ts.map +1 -0
  155. package/dist/pricing/location.js +81 -0
  156. package/dist/pricing/visitor.d.ts +56 -0
  157. package/dist/pricing/visitor.d.ts.map +1 -0
  158. package/dist/pricing/visitor.js +35 -0
  159. package/dist/projection/event.d.ts +66 -0
  160. package/dist/projection/event.d.ts.map +1 -0
  161. package/dist/projection/event.js +45 -0
  162. package/dist/projection/orphans.d.ts +114 -0
  163. package/dist/projection/orphans.d.ts.map +1 -0
  164. package/dist/projection/orphans.js +162 -0
  165. package/dist/projection/owner.d.ts +121 -0
  166. package/dist/projection/owner.d.ts.map +1 -0
  167. package/dist/projection/owner.js +114 -0
  168. package/dist/projection/resolve.d.ts +30 -0
  169. package/dist/projection/resolve.d.ts.map +1 -0
  170. package/dist/projection/resolve.js +42 -0
  171. package/dist/projection/writer.d.ts +103 -0
  172. package/dist/projection/writer.d.ts.map +1 -0
  173. package/dist/projection/writer.js +280 -0
  174. package/dist/provision/resolvePaymentsConfig.d.ts +48 -0
  175. package/dist/provision/resolvePaymentsConfig.d.ts.map +1 -0
  176. package/dist/provision/resolvePaymentsConfig.js +41 -0
  177. package/dist/rails/apple/certs.d.ts +7 -0
  178. package/dist/rails/apple/certs.d.ts.map +1 -0
  179. package/dist/rails/apple/certs.js +8 -0
  180. package/dist/rails/apple/der.d.ts +107 -0
  181. package/dist/rails/apple/der.d.ts.map +1 -0
  182. package/dist/rails/apple/der.js +217 -0
  183. package/dist/rails/apple/fixtures/chain.d.ts +117 -0
  184. package/dist/rails/apple/fixtures/chain.d.ts.map +1 -0
  185. package/dist/rails/apple/fixtures/chain.js +289 -0
  186. package/dist/rails/apple/http.d.ts +74 -0
  187. package/dist/rails/apple/http.d.ts.map +1 -0
  188. package/dist/rails/apple/http.js +32 -0
  189. package/dist/rails/apple/jws.d.ts +17 -0
  190. package/dist/rails/apple/jws.d.ts.map +1 -0
  191. package/dist/rails/apple/jws.js +75 -0
  192. package/dist/rails/apple/notification.d.ts +116 -0
  193. package/dist/rails/apple/notification.d.ts.map +1 -0
  194. package/dist/rails/apple/notification.js +199 -0
  195. package/dist/rails/apple/rail.d.ts +25 -0
  196. package/dist/rails/apple/rail.d.ts.map +1 -0
  197. package/dist/rails/apple/rail.js +68 -0
  198. package/dist/rails/apple/serverApi.d.ts +120 -0
  199. package/dist/rails/apple/serverApi.d.ts.map +1 -0
  200. package/dist/rails/apple/serverApi.js +244 -0
  201. package/dist/rails/apple/verify.d.ts +36 -0
  202. package/dist/rails/apple/verify.d.ts.map +1 -0
  203. package/dist/rails/apple/verify.js +46 -0
  204. package/dist/rails/apple/x509.d.ts +85 -0
  205. package/dist/rails/apple/x509.d.ts.map +1 -0
  206. package/dist/rails/apple/x509.js +273 -0
  207. package/dist/rails/contract.d.ts +871 -0
  208. package/dist/rails/contract.d.ts.map +1 -0
  209. package/dist/rails/contract.js +60 -0
  210. package/dist/rails/google/fixtures/push.d.ts +71 -0
  211. package/dist/rails/google/fixtures/push.d.ts.map +1 -0
  212. package/dist/rails/google/fixtures/push.js +107 -0
  213. package/dist/rails/google/http.d.ts +77 -0
  214. package/dist/rails/google/http.d.ts.map +1 -0
  215. package/dist/rails/google/http.js +39 -0
  216. package/dist/rails/google/jwt.d.ts +53 -0
  217. package/dist/rails/google/jwt.d.ts.map +1 -0
  218. package/dist/rails/google/jwt.js +94 -0
  219. package/dist/rails/google/oidc.d.ts +112 -0
  220. package/dist/rails/google/oidc.d.ts.map +1 -0
  221. package/dist/rails/google/oidc.js +179 -0
  222. package/dist/rails/google/playApi.d.ts +188 -0
  223. package/dist/rails/google/playApi.d.ts.map +1 -0
  224. package/dist/rails/google/playApi.js +350 -0
  225. package/dist/rails/google/rail.d.ts +57 -0
  226. package/dist/rails/google/rail.d.ts.map +1 -0
  227. package/dist/rails/google/rail.js +70 -0
  228. package/dist/rails/google/rtdn.d.ts +105 -0
  229. package/dist/rails/google/rtdn.d.ts.map +1 -0
  230. package/dist/rails/google/rtdn.js +179 -0
  231. package/dist/rails/google/verify.d.ts +20 -0
  232. package/dist/rails/google/verify.d.ts.map +1 -0
  233. package/dist/rails/google/verify.js +76 -0
  234. package/dist/rails/lemonSqueezy/api.d.ts +92 -0
  235. package/dist/rails/lemonSqueezy/api.d.ts.map +1 -0
  236. package/dist/rails/lemonSqueezy/api.js +121 -0
  237. package/dist/rails/lemonSqueezy/checkout.d.ts +52 -0
  238. package/dist/rails/lemonSqueezy/checkout.d.ts.map +1 -0
  239. package/dist/rails/lemonSqueezy/checkout.js +84 -0
  240. package/dist/rails/lemonSqueezy/discounts.d.ts +50 -0
  241. package/dist/rails/lemonSqueezy/discounts.d.ts.map +1 -0
  242. package/dist/rails/lemonSqueezy/discounts.js +75 -0
  243. package/dist/rails/lemonSqueezy/fixtures/events.d.ts +56 -0
  244. package/dist/rails/lemonSqueezy/fixtures/events.d.ts.map +1 -0
  245. package/dist/rails/lemonSqueezy/fixtures/events.js +144 -0
  246. package/dist/rails/lemonSqueezy/objects.d.ts +229 -0
  247. package/dist/rails/lemonSqueezy/objects.d.ts.map +1 -0
  248. package/dist/rails/lemonSqueezy/objects.js +379 -0
  249. package/dist/rails/lemonSqueezy/portal.d.ts +35 -0
  250. package/dist/rails/lemonSqueezy/portal.d.ts.map +1 -0
  251. package/dist/rails/lemonSqueezy/portal.js +18 -0
  252. package/dist/rails/lemonSqueezy/pricing.d.ts +25 -0
  253. package/dist/rails/lemonSqueezy/pricing.d.ts.map +1 -0
  254. package/dist/rails/lemonSqueezy/pricing.js +54 -0
  255. package/dist/rails/lemonSqueezy/rail.d.ts +41 -0
  256. package/dist/rails/lemonSqueezy/rail.d.ts.map +1 -0
  257. package/dist/rails/lemonSqueezy/rail.js +67 -0
  258. package/dist/rails/lemonSqueezy/read.d.ts +28 -0
  259. package/dist/rails/lemonSqueezy/read.d.ts.map +1 -0
  260. package/dist/rails/lemonSqueezy/read.js +37 -0
  261. package/dist/rails/lemonSqueezy/refresh.d.ts +42 -0
  262. package/dist/rails/lemonSqueezy/refresh.d.ts.map +1 -0
  263. package/dist/rails/lemonSqueezy/refresh.js +40 -0
  264. package/dist/rails/lemonSqueezy/signature.d.ts +56 -0
  265. package/dist/rails/lemonSqueezy/signature.d.ts.map +1 -0
  266. package/dist/rails/lemonSqueezy/signature.js +92 -0
  267. package/dist/rails/lemonSqueezy/verify.d.ts +33 -0
  268. package/dist/rails/lemonSqueezy/verify.d.ts.map +1 -0
  269. package/dist/rails/lemonSqueezy/verify.js +41 -0
  270. package/dist/rails/lemonSqueezy/webhook.d.ts +53 -0
  271. package/dist/rails/lemonSqueezy/webhook.d.ts.map +1 -0
  272. package/dist/rails/lemonSqueezy/webhook.js +179 -0
  273. package/dist/rails/paddle/adjustments.d.ts +60 -0
  274. package/dist/rails/paddle/adjustments.d.ts.map +1 -0
  275. package/dist/rails/paddle/adjustments.js +66 -0
  276. package/dist/rails/paddle/api.d.ts +138 -0
  277. package/dist/rails/paddle/api.d.ts.map +1 -0
  278. package/dist/rails/paddle/api.js +152 -0
  279. package/dist/rails/paddle/checkout.d.ts +69 -0
  280. package/dist/rails/paddle/checkout.d.ts.map +1 -0
  281. package/dist/rails/paddle/checkout.js +100 -0
  282. package/dist/rails/paddle/discounts.d.ts +67 -0
  283. package/dist/rails/paddle/discounts.d.ts.map +1 -0
  284. package/dist/rails/paddle/discounts.js +73 -0
  285. package/dist/rails/paddle/events.d.ts +140 -0
  286. package/dist/rails/paddle/events.d.ts.map +1 -0
  287. package/dist/rails/paddle/events.js +183 -0
  288. package/dist/rails/paddle/fixtures/browserForged.d.ts +42 -0
  289. package/dist/rails/paddle/fixtures/browserForged.d.ts.map +1 -0
  290. package/dist/rails/paddle/fixtures/browserForged.js +52 -0
  291. package/dist/rails/paddle/fixtures/pausedSubscription.d.ts +78 -0
  292. package/dist/rails/paddle/fixtures/pausedSubscription.d.ts.map +1 -0
  293. package/dist/rails/paddle/fixtures/pausedSubscription.js +76 -0
  294. package/dist/rails/paddle/objects.d.ts +519 -0
  295. package/dist/rails/paddle/objects.d.ts.map +1 -0
  296. package/dist/rails/paddle/objects.js +588 -0
  297. package/dist/rails/paddle/portal.d.ts +45 -0
  298. package/dist/rails/paddle/portal.d.ts.map +1 -0
  299. package/dist/rails/paddle/portal.js +42 -0
  300. package/dist/rails/paddle/rail.d.ts +55 -0
  301. package/dist/rails/paddle/rail.d.ts.map +1 -0
  302. package/dist/rails/paddle/rail.js +117 -0
  303. package/dist/rails/paddle/read.d.ts +53 -0
  304. package/dist/rails/paddle/read.d.ts.map +1 -0
  305. package/dist/rails/paddle/read.js +66 -0
  306. package/dist/rails/paddle/recorded.d.ts +49 -0
  307. package/dist/rails/paddle/recorded.d.ts.map +1 -0
  308. package/dist/rails/paddle/recorded.js +79 -0
  309. package/dist/rails/paddle/refresh.d.ts +54 -0
  310. package/dist/rails/paddle/refresh.d.ts.map +1 -0
  311. package/dist/rails/paddle/refresh.js +94 -0
  312. package/dist/rails/paddle/refund.d.ts +82 -0
  313. package/dist/rails/paddle/refund.d.ts.map +1 -0
  314. package/dist/rails/paddle/refund.js +175 -0
  315. package/dist/rails/paddle/signature.d.ts +83 -0
  316. package/dist/rails/paddle/signature.d.ts.map +1 -0
  317. package/dist/rails/paddle/signature.js +163 -0
  318. package/dist/rails/paddle/subscription.d.ts +137 -0
  319. package/dist/rails/paddle/subscription.d.ts.map +1 -0
  320. package/dist/rails/paddle/subscription.js +538 -0
  321. package/dist/rails/paddle/verify.d.ts +46 -0
  322. package/dist/rails/paddle/verify.d.ts.map +1 -0
  323. package/dist/rails/paddle/verify.js +43 -0
  324. package/dist/rails/paddle/webhook.d.ts +98 -0
  325. package/dist/rails/paddle/webhook.d.ts.map +1 -0
  326. package/dist/rails/paddle/webhook.js +181 -0
  327. package/dist/rails/providers.d.ts +73 -0
  328. package/dist/rails/providers.d.ts.map +1 -0
  329. package/dist/rails/providers.js +62 -0
  330. package/dist/rails/stripe/api.d.ts +118 -0
  331. package/dist/rails/stripe/api.d.ts.map +1 -0
  332. package/dist/rails/stripe/api.js +153 -0
  333. package/dist/rails/stripe/checkout.d.ts +60 -0
  334. package/dist/rails/stripe/checkout.d.ts.map +1 -0
  335. package/dist/rails/stripe/checkout.js +86 -0
  336. package/dist/rails/stripe/discounts.d.ts +50 -0
  337. package/dist/rails/stripe/discounts.d.ts.map +1 -0
  338. package/dist/rails/stripe/discounts.js +87 -0
  339. package/dist/rails/stripe/fixtures/events.d.ts +64 -0
  340. package/dist/rails/stripe/fixtures/events.d.ts.map +1 -0
  341. package/dist/rails/stripe/fixtures/events.js +67 -0
  342. package/dist/rails/stripe/objects.d.ts +237 -0
  343. package/dist/rails/stripe/objects.d.ts.map +1 -0
  344. package/dist/rails/stripe/objects.js +389 -0
  345. package/dist/rails/stripe/portal.d.ts +29 -0
  346. package/dist/rails/stripe/portal.d.ts.map +1 -0
  347. package/dist/rails/stripe/portal.js +41 -0
  348. package/dist/rails/stripe/pricing.d.ts +25 -0
  349. package/dist/rails/stripe/pricing.d.ts.map +1 -0
  350. package/dist/rails/stripe/pricing.js +68 -0
  351. package/dist/rails/stripe/rail.d.ts +28 -0
  352. package/dist/rails/stripe/rail.d.ts.map +1 -0
  353. package/dist/rails/stripe/rail.js +81 -0
  354. package/dist/rails/stripe/refresh.d.ts +33 -0
  355. package/dist/rails/stripe/refresh.d.ts.map +1 -0
  356. package/dist/rails/stripe/refresh.js +21 -0
  357. package/dist/rails/stripe/signature.d.ts +71 -0
  358. package/dist/rails/stripe/signature.d.ts.map +1 -0
  359. package/dist/rails/stripe/signature.js +92 -0
  360. package/dist/rails/stripe/verify.d.ts +15 -0
  361. package/dist/rails/stripe/verify.d.ts.map +1 -0
  362. package/dist/rails/stripe/verify.js +63 -0
  363. package/dist/rails/stripe/webhook.d.ts +26 -0
  364. package/dist/rails/stripe/webhook.d.ts.map +1 -0
  365. package/dist/rails/stripe/webhook.js +31 -0
  366. package/dist/secret/registry.d.ts +192 -0
  367. package/dist/secret/registry.d.ts.map +1 -0
  368. package/dist/secret/registry.js +154 -0
  369. package/dist/seeds/example.d.ts +3 -0
  370. package/dist/seeds/example.d.ts.map +1 -0
  371. package/dist/seeds/example.js +171 -0
  372. package/dist/version.generated.d.ts +5 -0
  373. package/dist/version.generated.d.ts.map +1 -0
  374. package/dist/version.generated.js +7 -0
  375. package/dist/workflows/paddleSweep.d.ts +175 -0
  376. package/dist/workflows/paddleSweep.d.ts.map +1 -0
  377. package/dist/workflows/paddleSweep.js +433 -0
  378. package/dist/workflows/railAccess.d.ts +48 -0
  379. package/dist/workflows/railAccess.d.ts.map +1 -0
  380. package/dist/workflows/railAccess.js +36 -0
  381. package/dist/workflows/reconcile.d.ts +161 -0
  382. package/dist/workflows/reconcile.d.ts.map +1 -0
  383. package/dist/workflows/reconcile.js +352 -0
  384. package/dist/workflows/report.d.ts +28 -0
  385. package/dist/workflows/report.d.ts.map +1 -0
  386. package/dist/workflows/report.js +54 -0
  387. package/dist/workflows/retryPolicy.d.ts +29 -0
  388. package/dist/workflows/retryPolicy.d.ts.map +1 -0
  389. package/dist/workflows/retryPolicy.js +37 -0
  390. package/dist/workflows/specs.d.ts +102 -0
  391. package/dist/workflows/specs.d.ts.map +1 -0
  392. package/dist/workflows/specs.js +84 -0
  393. package/dist/workflows/worker.d.ts +62 -0
  394. package/dist/workflows/worker.d.ts.map +1 -0
  395. package/dist/workflows/worker.js +92 -0
  396. package/dist/workflows/workerConfig.d.ts +46 -0
  397. package/dist/workflows/workerConfig.d.ts.map +1 -0
  398. package/dist/workflows/workerConfig.js +38 -0
  399. package/package.json +22 -13
  400. package/pithy.manifest.json +19 -13
  401. package/src/version.generated.ts +1 -1
  402. package/src/client/paddlePrices.iife.ts +0 -43
@@ -0,0 +1,211 @@
1
+ /**
2
+ * The audit action codes `@pithy-sh/payments` emits, as `domain/reason` strings under the `payments` domain.
3
+ *
4
+ * Payments emits through core's seam (`c.var.emit`) and never imports `@pithy-sh/audit` — audit is optional
5
+ * (principle 4: depend on core seams, not on other capabilities). With audit absent the seam is a no-op; with
6
+ * it composed these land in `pithy_audit_events`. The taxonomy is federated, so this list is owned here and
7
+ * core holds no union of every action.
8
+ *
9
+ * **What is audited, and why these.** Money moving is not itself interesting — the purchases table already
10
+ * records every transaction, in more detail than an audit event could. What an audit trail adds is the
11
+ * *attempts*: a receipt that was refused, a notification that failed its signature check, an entitlement that
12
+ * appeared without a payment. Those are the security-relevant events, and they are the ones a trail is read
13
+ * for after the fact.
14
+ *
15
+ * **Never put a credential, a receipt, a purchase token, or a webhook signature in an event's metadata.** The
16
+ * trail is queryable and long-lived, and a receipt is a bearer artifact — the same rule as `detail` on a
17
+ * `PithyError`, for the same reason.
18
+ */
19
+ export declare const PaymentsAuditActions: {
20
+ /** A client-submitted receipt was verified and projected. `denied` when it belonged to another account. */
21
+ readonly purchaseVerified: "payments/purchase_verified";
22
+ /** A restore re-submitted a store's transaction history against the authenticated caller. */
23
+ readonly purchaseRestored: "payments/purchase_restored";
24
+ /** An authentic provider notification was received. `failure` when it arrived with nobody to project against. */
25
+ readonly webhookReceived: "payments/webhook_received";
26
+ /** A notification failed its authenticity check. Always `denied`, and the reason a forgery is visible at all. */
27
+ readonly webhookUnverified: "payments/webhook_unverified";
28
+ /**
29
+ * A caller submitted a purchase whose store-account identifier is already bound to a different subject.
30
+ *
31
+ * On Apple and Google that identifier is a value the *app* chose, so one store account legitimately
32
+ * reaching two subjects is possible — a shared device, a reinstall against a new account, one person
33
+ * buying for two organizations. It is also exactly what squatting on another holder's identifier looks
34
+ * like, and the two are indistinguishable from one request.
35
+ * So the binding is left alone (the first one stands) and the attempt is recorded at `warning`: one is
36
+ * noise, a pattern of them against different identifiers is somebody enumerating.
37
+ */
38
+ readonly providerAccountContested: "payments/provider_account_contested";
39
+ /**
40
+ * A reconciliation pass found a purchase whose stored state disagreed with the store's, and repaired it.
41
+ *
42
+ * Audited at `warning` rather than `info`, and this is the one audit event that is about **us** rather than
43
+ * about a caller. One drift is a dropped delivery. Repeated drift on the same rail means the webhook path is
44
+ * broken — a rotated signing key, a Pub/Sub subscription pointing at a retired deployment — and the only
45
+ * place that pattern is visible is a trail of these. A pass that finds nothing emits nothing.
46
+ */
47
+ readonly purchaseReconciled: "payments/purchase_reconciled";
48
+ /**
49
+ * A hosted checkout session was created for a caller. Money has not moved — that is the webhook's event — but
50
+ * this is the record of who was sent to pay for what, which is what a disputed charge is reconstructed from.
51
+ */
52
+ readonly checkoutStarted: "payments/checkout_started";
53
+ /**
54
+ * A billing-portal session was opened. Audited because the portal shows and can cancel a customer's whole
55
+ * billing history, so which caller opened one against which store account is a security-relevant fact.
56
+ */
57
+ readonly portalOpened: "payments/portal_opened";
58
+ /**
59
+ * A refund's clawback debit was refused because the balance no longer covered it. Always `failure`, always
60
+ * `critical`.
61
+ *
62
+ * The only fulfillment event that is audited, and the reason is the rule at the top of this file: a
63
+ * successful credit or debit is already a ledger row keyed by a ref that names the purchase, so auditing it
64
+ * would duplicate a better record. A refusal is a row that does **not** exist anywhere — the refund stands,
65
+ * the balance is short, and the difference is a decision only a human can make. This is where it becomes
66
+ * queryable.
67
+ */
68
+ readonly clawbackFailed: "payments/clawback_failed";
69
+ /** A discount code was minted at a store. An administrative act with a cost attached, so it is recorded. */
70
+ readonly discountCreated: "payments/discount_created";
71
+ /**
72
+ * A management client listed the discount codes a store holds.
73
+ *
74
+ * Its own action rather than a flag on the mint event. A read-scoped connection polling a pane would
75
+ * otherwise write thousands of mint-shaped rows into the one record of who decided a customer should pay
76
+ * less — and `payments:discounts:read` is granted precisely to connections that cannot mint anything.
77
+ */
78
+ readonly discountsRead: "payments/discounts_read";
79
+ /**
80
+ * An entitlement was granted by hand through the control plane — a comp, or the repair of a purchase that
81
+ * never projected. Audited because it is one of exactly two ways an entitlement appears without money
82
+ * moving, and because the actor is support tooling rather than the user who benefits.
83
+ */
84
+ readonly entitlementGranted: "payments/entitlement_granted";
85
+ /** An entitlement was revoked by hand through the control plane. The other of the two, for the same reason. */
86
+ readonly entitlementRevoked: "payments/entitlement_revoked";
87
+ /**
88
+ * A management client read the purchase log.
89
+ *
90
+ * **Reads are audited here, and only on this surface.** The rule at the top of this file still holds for
91
+ * the adopter's own users: a buyer reading their own purchases is not a security-relevant event, and
92
+ * auditing it would drown the trail. A *management* read is the opposite case — a credential paging every
93
+ * account's commerce leaves no other trace anywhere, and the whole point of the control plane is that a
94
+ * customer can reconstruct what a dashboard did with the access they granted it.
95
+ *
96
+ * Counts and filters only. Never a row, never an amount, never a provider identifier: copying the
97
+ * purchase log into the audit trail would make a second purchase log with weaker access rules than the
98
+ * first.
99
+ */
100
+ readonly purchasesRead: "payments/purchases_read";
101
+ /**
102
+ * A subscription's plan was changed — a move up or down the ladder.
103
+ *
104
+ * **By the subscriber, on a bearer route** — not through the control plane, unlike the two grant
105
+ * actions above. That distinction is the reason the row matters: an operator acting through the
106
+ * control plane is already accountable to it, while a customer changing their own bill leaves this
107
+ * row and the store's own record and nothing else.
108
+ *
109
+ * Audited even though a purchase row may follow it, and the exception to the rule at the top of this
110
+ * file is the direction of the move. An upgrade settles immediately and does leave a transaction; a
111
+ * downgrade is booked against the next billing period and writes **no** transaction at all (#465), so
112
+ * the purchases table holds nothing until the renewal, and the act that made next month's invoice
113
+ * smaller has no record anywhere else. Auditing only one of the two directions would make the trail
114
+ * agree with the ledger precisely where the ledger is already sufficient, and go silent where it is not.
115
+ *
116
+ * The proration mode is chosen by the rail from the direction of the change and is never a caller's to
117
+ * set. It would belong in the event for exactly that reason — a decision this package made on a
118
+ * customer's behalf — but **the route cannot record it**: the rail returns a `SubscriptionStanding`
119
+ * and no flag saying which mode it picked, so the row carries both plans and both price ids and lets
120
+ * the direction imply the mode. Stated rather than left as a silent omission, because a reader who
121
+ * expects the mode here would otherwise conclude the trail had lost it.
122
+ *
123
+ * Price ids and the direction. Never a quote's totals — a preview is not what was charged, and copying
124
+ * money into the trail would make a second, weaker ledger.
125
+ */
126
+ readonly subscriptionPlanChanged: "payments/subscription_plan_changed";
127
+ /**
128
+ * A subscription was canceled by its subscriber on a bearer route, effective at the end of the
129
+ * period already paid for.
130
+ *
131
+ * The write whose *absence* is the incident. A scheduled cancellation leaves `status` at `active` and
132
+ * blanks `next_billed_at` (recorded against the sandbox, #465), so a subscription that has quietly
133
+ * stopped renewing is indistinguishable, in any projection built from status, from one that has not.
134
+ * When a customer says they never asked to cancel, this row is the whole answer: which actor asked,
135
+ * for which subject, and when.
136
+ */
137
+ readonly subscriptionCanceled: "payments/subscription_canceled";
138
+ /**
139
+ * A scheduled cancellation was withdrawn, and the subscription will renew after all.
140
+ *
141
+ * Its own action rather than an outcome on the cancellation event, because the two are separate acts by
142
+ * possibly separate actors, and the pair is what a dispute is reconstructed from. Folded together, the
143
+ * trail asserts a cancellation and holds nothing that says it was taken back — which reads, to whoever
144
+ * audits later, as a subscription that kept billing after it was canceled.
145
+ */
146
+ readonly subscriptionCancelWithdrawn: "payments/subscription_cancel_withdrawn";
147
+ /**
148
+ * A subscriber asked for a subscription's payments back, on a bearer route.
149
+ *
150
+ * **The one write in this capability that leaves no other record at all.** A refund is a *request*:
151
+ * Paddle holds most live ones awaiting a human, no transaction is created, the purchase rows are
152
+ * untouched, and the entitlement stands. Nothing enters `pithy_payments_purchases` until — and unless —
153
+ * the store approves it weeks later and the webhook arrives. Between the ask and that webhook there is
154
+ * one place recording that somebody asked for money back, for which subject, and which actor asked. This
155
+ * is it, and a rejected refund means that gap is permanent.
156
+ *
157
+ * Its own action rather than an outcome on the cancellation, for the reason the withdrawal has its own:
158
+ * canceling and asking for a refund are separate acts, often minutes apart and sometimes by different
159
+ * actors, and the pair is what a dispute is reconstructed from.
160
+ *
161
+ * **Counts and adjustment ids. Never an amount.** How much a customer is getting back is not decided at
162
+ * this moment by anybody — that is the store's later decision — so a figure here would be a number
163
+ * asserting something nobody has agreed to, in the one table nothing corrects. The adjustment ids are
164
+ * carried because they are the only handle an operator has on money in flight, and they are neither a
165
+ * credential nor a bearer artifact.
166
+ *
167
+ * Emitted **only when an adjustment was actually raised.** A repeat of a request already standing is the
168
+ * no-op, the same as a retried cancel, and a trail claiming two refunds where one was asked for is worse
169
+ * than one claiming none.
170
+ */
171
+ readonly subscriptionRefundRequested: "payments/subscription_refund_requested";
172
+ /** A management client read the subscriptions. The narrower half of the purchase log, recorded separately. */
173
+ readonly subscriptionsRead: "payments/subscriptions_read";
174
+ /**
175
+ * A management client read the entitlement model — the page, or one account's.
176
+ *
177
+ * The read that pairs with `entitlement_granted` and `entitlement_revoked`, so a trail shows what a
178
+ * console looked at as well as what it changed.
179
+ */
180
+ readonly entitlementsRead: "payments/entitlements_read";
181
+ /**
182
+ * A management client read the catalog — what this project sells.
183
+ *
184
+ * Audited like the others, and the reason is the same one: the customer's ability to reconstruct what a
185
+ * dashboard did with the access they granted does not have an exception for the reads that touch no
186
+ * account. This one discloses no person and no transaction, so the event carries a count and nothing
187
+ * else — which is also the only fact about it worth asking after.
188
+ */
189
+ readonly catalogRead: "payments/catalog_read";
190
+ /**
191
+ * A management client read the reconciliation run log.
192
+ *
193
+ * Audited like every other management read, and the rule has no exception for the one that touches no
194
+ * account: the customer's ability to reconstruct what a dashboard did with the access they granted is the
195
+ * point, not the sensitivity of the rows. Counts and filters only — the runs themselves are already a
196
+ * queryable table, and copying them into the trail would make a second one.
197
+ */
198
+ readonly reconcileRunsRead: "payments/reconcile_runs_read";
199
+ /**
200
+ * A management client started a reconciliation pass.
201
+ *
202
+ * **A write, and audited as one** — this is the trail entry that says a human, on a date, caused every repair
203
+ * the run then made. The repairs carry the run's id, so the trail joins: this row names who pressed, and the
204
+ * grant and revoke rows behind it name what moved. Without it a pass triggered from a browser is
205
+ * indistinguishable from the 04:00 cron, which is exactly the question somebody reading the trail is asking.
206
+ */
207
+ readonly reconcileRunStarted: "payments/reconcile_run_started";
208
+ };
209
+ /** One of the payments audit action codes. */
210
+ export type PaymentsAuditAction = (typeof PaymentsAuditActions)[keyof typeof PaymentsAuditActions];
211
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/audit/actions.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,oBAAoB;IAC/B,2GAA2G;aAC3G,gBAAgB,EAAE,4BAA4B;IAC9C,6FAA6F;aAC7F,gBAAgB,EAAE,4BAA4B;IAC9C,iHAAiH;aACjH,eAAe,EAAE,2BAA2B;IAC5C,iHAAiH;aACjH,iBAAiB,EAAE,6BAA6B;IAChD;;;;;;;;;OASG;aACH,wBAAwB,EAAE,qCAAqC;IAC/D;;;;;;;OAOG;aACH,kBAAkB,EAAE,8BAA8B;IAClD;;;OAGG;aACH,eAAe,EAAE,2BAA2B;IAC5C;;;OAGG;aACH,YAAY,EAAE,wBAAwB;IACtC;;;;;;;;;OASG;aACH,cAAc,EAAE,0BAA0B;IAC1C,4GAA4G;aAC5G,eAAe,EAAE,2BAA2B;IAC5C;;;;;;OAMG;aACH,aAAa,EAAE,yBAAyB;IACxC;;;;OAIG;aACH,kBAAkB,EAAE,8BAA8B;IAClD,+GAA+G;aAC/G,kBAAkB,EAAE,8BAA8B;IAClD;;;;;;;;;;;;OAYG;aACH,aAAa,EAAE,yBAAyB;IACxC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;aACH,uBAAuB,EAAE,oCAAoC;IAC7D;;;;;;;;;OASG;aACH,oBAAoB,EAAE,gCAAgC;IACtD;;;;;;;OAOG;aACH,2BAA2B,EAAE,wCAAwC;IACrE;;;;;;;;;;;;;;;;;;;;;;;OAuBG;aACH,2BAA2B,EAAE,wCAAwC;IACrE,8GAA8G;aAC9G,iBAAiB,EAAE,6BAA6B;IAChD;;;;;OAKG;aACH,gBAAgB,EAAE,4BAA4B;IAC9C;;;;;;;OAOG;aACH,WAAW,EAAE,uBAAuB;IACpC;;;;;;;OAOG;aACH,iBAAiB,EAAE,8BAA8B;IACjD;;;;;;;OAOG;aACH,mBAAmB,EAAE,gCAAgC;CAC7C,CAAC;AAEX,8CAA8C;AAC9C,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,211 @@
1
+ //#region src/audit/actions.ts
2
+ /**
3
+ * The audit action codes `@pithy-sh/payments` emits, as `domain/reason` strings under the `payments` domain.
4
+ *
5
+ * Payments emits through core's seam (`c.var.emit`) and never imports `@pithy-sh/audit` — audit is optional
6
+ * (principle 4: depend on core seams, not on other capabilities). With audit absent the seam is a no-op; with
7
+ * it composed these land in `pithy_audit_events`. The taxonomy is federated, so this list is owned here and
8
+ * core holds no union of every action.
9
+ *
10
+ * **What is audited, and why these.** Money moving is not itself interesting — the purchases table already
11
+ * records every transaction, in more detail than an audit event could. What an audit trail adds is the
12
+ * *attempts*: a receipt that was refused, a notification that failed its signature check, an entitlement that
13
+ * appeared without a payment. Those are the security-relevant events, and they are the ones a trail is read
14
+ * for after the fact.
15
+ *
16
+ * **Never put a credential, a receipt, a purchase token, or a webhook signature in an event's metadata.** The
17
+ * trail is queryable and long-lived, and a receipt is a bearer artifact — the same rule as `detail` on a
18
+ * `PithyError`, for the same reason.
19
+ */
20
+ const PaymentsAuditActions = {
21
+ /** A client-submitted receipt was verified and projected. `denied` when it belonged to another account. */
22
+ purchaseVerified: "payments/purchase_verified",
23
+ /** A restore re-submitted a store's transaction history against the authenticated caller. */
24
+ purchaseRestored: "payments/purchase_restored",
25
+ /** An authentic provider notification was received. `failure` when it arrived with nobody to project against. */
26
+ webhookReceived: "payments/webhook_received",
27
+ /** A notification failed its authenticity check. Always `denied`, and the reason a forgery is visible at all. */
28
+ webhookUnverified: "payments/webhook_unverified",
29
+ /**
30
+ * A caller submitted a purchase whose store-account identifier is already bound to a different subject.
31
+ *
32
+ * On Apple and Google that identifier is a value the *app* chose, so one store account legitimately
33
+ * reaching two subjects is possible — a shared device, a reinstall against a new account, one person
34
+ * buying for two organizations. It is also exactly what squatting on another holder's identifier looks
35
+ * like, and the two are indistinguishable from one request.
36
+ * So the binding is left alone (the first one stands) and the attempt is recorded at `warning`: one is
37
+ * noise, a pattern of them against different identifiers is somebody enumerating.
38
+ */
39
+ providerAccountContested: "payments/provider_account_contested",
40
+ /**
41
+ * A reconciliation pass found a purchase whose stored state disagreed with the store's, and repaired it.
42
+ *
43
+ * Audited at `warning` rather than `info`, and this is the one audit event that is about **us** rather than
44
+ * about a caller. One drift is a dropped delivery. Repeated drift on the same rail means the webhook path is
45
+ * broken — a rotated signing key, a Pub/Sub subscription pointing at a retired deployment — and the only
46
+ * place that pattern is visible is a trail of these. A pass that finds nothing emits nothing.
47
+ */
48
+ purchaseReconciled: "payments/purchase_reconciled",
49
+ /**
50
+ * A hosted checkout session was created for a caller. Money has not moved — that is the webhook's event — but
51
+ * this is the record of who was sent to pay for what, which is what a disputed charge is reconstructed from.
52
+ */
53
+ checkoutStarted: "payments/checkout_started",
54
+ /**
55
+ * A billing-portal session was opened. Audited because the portal shows and can cancel a customer's whole
56
+ * billing history, so which caller opened one against which store account is a security-relevant fact.
57
+ */
58
+ portalOpened: "payments/portal_opened",
59
+ /**
60
+ * A refund's clawback debit was refused because the balance no longer covered it. Always `failure`, always
61
+ * `critical`.
62
+ *
63
+ * The only fulfillment event that is audited, and the reason is the rule at the top of this file: a
64
+ * successful credit or debit is already a ledger row keyed by a ref that names the purchase, so auditing it
65
+ * would duplicate a better record. A refusal is a row that does **not** exist anywhere — the refund stands,
66
+ * the balance is short, and the difference is a decision only a human can make. This is where it becomes
67
+ * queryable.
68
+ */
69
+ clawbackFailed: "payments/clawback_failed",
70
+ /** A discount code was minted at a store. An administrative act with a cost attached, so it is recorded. */
71
+ discountCreated: "payments/discount_created",
72
+ /**
73
+ * A management client listed the discount codes a store holds.
74
+ *
75
+ * Its own action rather than a flag on the mint event. A read-scoped connection polling a pane would
76
+ * otherwise write thousands of mint-shaped rows into the one record of who decided a customer should pay
77
+ * less — and `payments:discounts:read` is granted precisely to connections that cannot mint anything.
78
+ */
79
+ discountsRead: "payments/discounts_read",
80
+ /**
81
+ * An entitlement was granted by hand through the control plane — a comp, or the repair of a purchase that
82
+ * never projected. Audited because it is one of exactly two ways an entitlement appears without money
83
+ * moving, and because the actor is support tooling rather than the user who benefits.
84
+ */
85
+ entitlementGranted: "payments/entitlement_granted",
86
+ /** An entitlement was revoked by hand through the control plane. The other of the two, for the same reason. */
87
+ entitlementRevoked: "payments/entitlement_revoked",
88
+ /**
89
+ * A management client read the purchase log.
90
+ *
91
+ * **Reads are audited here, and only on this surface.** The rule at the top of this file still holds for
92
+ * the adopter's own users: a buyer reading their own purchases is not a security-relevant event, and
93
+ * auditing it would drown the trail. A *management* read is the opposite case — a credential paging every
94
+ * account's commerce leaves no other trace anywhere, and the whole point of the control plane is that a
95
+ * customer can reconstruct what a dashboard did with the access they granted it.
96
+ *
97
+ * Counts and filters only. Never a row, never an amount, never a provider identifier: copying the
98
+ * purchase log into the audit trail would make a second purchase log with weaker access rules than the
99
+ * first.
100
+ */
101
+ purchasesRead: "payments/purchases_read",
102
+ /**
103
+ * A subscription's plan was changed — a move up or down the ladder.
104
+ *
105
+ * **By the subscriber, on a bearer route** — not through the control plane, unlike the two grant
106
+ * actions above. That distinction is the reason the row matters: an operator acting through the
107
+ * control plane is already accountable to it, while a customer changing their own bill leaves this
108
+ * row and the store's own record and nothing else.
109
+ *
110
+ * Audited even though a purchase row may follow it, and the exception to the rule at the top of this
111
+ * file is the direction of the move. An upgrade settles immediately and does leave a transaction; a
112
+ * downgrade is booked against the next billing period and writes **no** transaction at all (#465), so
113
+ * the purchases table holds nothing until the renewal, and the act that made next month's invoice
114
+ * smaller has no record anywhere else. Auditing only one of the two directions would make the trail
115
+ * agree with the ledger precisely where the ledger is already sufficient, and go silent where it is not.
116
+ *
117
+ * The proration mode is chosen by the rail from the direction of the change and is never a caller's to
118
+ * set. It would belong in the event for exactly that reason — a decision this package made on a
119
+ * customer's behalf — but **the route cannot record it**: the rail returns a `SubscriptionStanding`
120
+ * and no flag saying which mode it picked, so the row carries both plans and both price ids and lets
121
+ * the direction imply the mode. Stated rather than left as a silent omission, because a reader who
122
+ * expects the mode here would otherwise conclude the trail had lost it.
123
+ *
124
+ * Price ids and the direction. Never a quote's totals — a preview is not what was charged, and copying
125
+ * money into the trail would make a second, weaker ledger.
126
+ */
127
+ subscriptionPlanChanged: "payments/subscription_plan_changed",
128
+ /**
129
+ * A subscription was canceled by its subscriber on a bearer route, effective at the end of the
130
+ * period already paid for.
131
+ *
132
+ * The write whose *absence* is the incident. A scheduled cancellation leaves `status` at `active` and
133
+ * blanks `next_billed_at` (recorded against the sandbox, #465), so a subscription that has quietly
134
+ * stopped renewing is indistinguishable, in any projection built from status, from one that has not.
135
+ * When a customer says they never asked to cancel, this row is the whole answer: which actor asked,
136
+ * for which subject, and when.
137
+ */
138
+ subscriptionCanceled: "payments/subscription_canceled",
139
+ /**
140
+ * A scheduled cancellation was withdrawn, and the subscription will renew after all.
141
+ *
142
+ * Its own action rather than an outcome on the cancellation event, because the two are separate acts by
143
+ * possibly separate actors, and the pair is what a dispute is reconstructed from. Folded together, the
144
+ * trail asserts a cancellation and holds nothing that says it was taken back — which reads, to whoever
145
+ * audits later, as a subscription that kept billing after it was canceled.
146
+ */
147
+ subscriptionCancelWithdrawn: "payments/subscription_cancel_withdrawn",
148
+ /**
149
+ * A subscriber asked for a subscription's payments back, on a bearer route.
150
+ *
151
+ * **The one write in this capability that leaves no other record at all.** A refund is a *request*:
152
+ * Paddle holds most live ones awaiting a human, no transaction is created, the purchase rows are
153
+ * untouched, and the entitlement stands. Nothing enters `pithy_payments_purchases` until — and unless —
154
+ * the store approves it weeks later and the webhook arrives. Between the ask and that webhook there is
155
+ * one place recording that somebody asked for money back, for which subject, and which actor asked. This
156
+ * is it, and a rejected refund means that gap is permanent.
157
+ *
158
+ * Its own action rather than an outcome on the cancellation, for the reason the withdrawal has its own:
159
+ * canceling and asking for a refund are separate acts, often minutes apart and sometimes by different
160
+ * actors, and the pair is what a dispute is reconstructed from.
161
+ *
162
+ * **Counts and adjustment ids. Never an amount.** How much a customer is getting back is not decided at
163
+ * this moment by anybody — that is the store's later decision — so a figure here would be a number
164
+ * asserting something nobody has agreed to, in the one table nothing corrects. The adjustment ids are
165
+ * carried because they are the only handle an operator has on money in flight, and they are neither a
166
+ * credential nor a bearer artifact.
167
+ *
168
+ * Emitted **only when an adjustment was actually raised.** A repeat of a request already standing is the
169
+ * no-op, the same as a retried cancel, and a trail claiming two refunds where one was asked for is worse
170
+ * than one claiming none.
171
+ */
172
+ subscriptionRefundRequested: "payments/subscription_refund_requested",
173
+ /** A management client read the subscriptions. The narrower half of the purchase log, recorded separately. */
174
+ subscriptionsRead: "payments/subscriptions_read",
175
+ /**
176
+ * A management client read the entitlement model — the page, or one account's.
177
+ *
178
+ * The read that pairs with `entitlement_granted` and `entitlement_revoked`, so a trail shows what a
179
+ * console looked at as well as what it changed.
180
+ */
181
+ entitlementsRead: "payments/entitlements_read",
182
+ /**
183
+ * A management client read the catalog — what this project sells.
184
+ *
185
+ * Audited like the others, and the reason is the same one: the customer's ability to reconstruct what a
186
+ * dashboard did with the access they granted does not have an exception for the reads that touch no
187
+ * account. This one discloses no person and no transaction, so the event carries a count and nothing
188
+ * else — which is also the only fact about it worth asking after.
189
+ */
190
+ catalogRead: "payments/catalog_read",
191
+ /**
192
+ * A management client read the reconciliation run log.
193
+ *
194
+ * Audited like every other management read, and the rule has no exception for the one that touches no
195
+ * account: the customer's ability to reconstruct what a dashboard did with the access they granted is the
196
+ * point, not the sensitivity of the rows. Counts and filters only — the runs themselves are already a
197
+ * queryable table, and copying them into the trail would make a second one.
198
+ */
199
+ reconcileRunsRead: "payments/reconcile_runs_read",
200
+ /**
201
+ * A management client started a reconciliation pass.
202
+ *
203
+ * **A write, and audited as one** — this is the trail entry that says a human, on a date, caused every repair
204
+ * the run then made. The repairs carry the run's id, so the trail joins: this row names who pressed, and the
205
+ * grant and revoke rows behind it name what moved. Without it a pass triggered from a browser is
206
+ * indistinguishable from the 04:00 cron, which is exactly the question somebody reading the trail is asking.
207
+ */
208
+ reconcileRunStarted: "payments/reconcile_run_started"
209
+ };
210
+ //#endregion
211
+ export { PaymentsAuditActions };
@@ -0,0 +1,72 @@
1
+ import { type Capability } from "@pithy-sh/core/src/capability/capability";
2
+ import type { DatabaseSpecMap } from "@pithy-sh/core/src/data/databases";
3
+ import type { KvNamespaceSpecMap } from "@pithy-sh/core/src/kv/namespaces";
4
+ import { PaymentsConfig, type PaymentsConfigInput } from "./config/config";
5
+ import type { PaymentsSubjectResolver } from "./entitlement/subjectSeam";
6
+ import { paymentsWorkflows } from "./workflows/specs";
7
+ /**
8
+ * Where payments' migrations sort in the app database. Unique per database; the registry composes keys
9
+ * like `1000_payments_0001_purchases`. Sits after vector (900), and was `NEXT_FREE_ORDER` when it was
10
+ * taken — see `packages/cli/src/migrations/orders.test.ts`, which is the only place an order is allocated.
11
+ */
12
+ export declare const PAYMENTS_MIGRATION_ORDER = 1000;
13
+ /**
14
+ * The options `payments()` takes: the catalog, plus the one thing that cannot live in it.
15
+ *
16
+ * **`resolveSubject` rides here rather than in `PaymentsConfig`, and the split is forced rather than
17
+ * stylistic.** The config is serializable by contract: `provision/resolvePaymentsConfig.ts`
18
+ * `JSON.stringify`s it into the reconcile worker's `PAYMENTS_CONFIG` var, and `workflows/worker.ts` parses
19
+ * it back with `PaymentsConfig.parse` at boot. A function does not survive that round trip — `JSON.stringify`
20
+ * drops it, and the field is simply gone in the one deployment that has no human to ask. So the decision is
21
+ * split along the line the round trip draws: the **serializable** half (`billingSubject`, a two-value enum)
22
+ * is config, diffable in git and carried into the var, and the **callable** half is a composition-time
23
+ * option, handed to the factory alongside it.
24
+ *
25
+ * The consequence is worth stating rather than leaving to be discovered: **the reconcile and paddleSweep
26
+ * Workflows always run with no adopter resolver.** They have no request to hand one, so anything in a
27
+ * Workflow that needs a subject reads it from the rows it is already reconciling — never from the seam.
28
+ *
29
+ * An intersection rather than a field on the config schema for the same reason a Zod object cannot hold it:
30
+ * everything in `PaymentsConfig` is data, and this is not.
31
+ */
32
+ export type PaymentsOptions = PaymentsConfigInput & {
33
+ /**
34
+ * Which subject this caller is acting for. Required in practice under `billingSubject: "organization"`,
35
+ * where the capability has no way to answer on its own — see `entitlement/subjectSeam.ts`. Under `"user"`
36
+ * it is optional and the authenticated caller is the answer.
37
+ */
38
+ resolveSubject?: PaymentsSubjectResolver;
39
+ };
40
+ /** The payments capability, with its resolved catalog attached for other tooling to read. */
41
+ export interface PaymentsCapability extends Capability<DatabaseSpecMap, KvNamespaceSpecMap, "payments", typeof paymentsWorkflows> {
42
+ /** The resolved catalog. */
43
+ paymentsConfig: PaymentsConfig;
44
+ }
45
+ /**
46
+ * Three rails — Apple, Google, Stripe — projecting onto one cross-rail entitlement, in the adopter's own
47
+ * D1. The catalog is config, not rows: a product's entitlement mapping is policy, so it is diffable in
48
+ * git and not mutable at runtime.
49
+ *
50
+ * `providesEntitlements` is what makes payments the seam's provider, and it is read in two places. At
51
+ * runtime the middleware below replaces core's fail-closed `noEntitlementProvider` with the D1-backed
52
+ * resolver. At development time `pithy doctor` and `pithy dev` read the flag to answer a question no
53
+ * amount of runtime care can: a Worker whose routes call `requireEntitlement()` while composing no
54
+ * provider is not broken, it is silently paywalled shut, and the seam's own fail-closed default makes
55
+ * that indistinguishable from a user who has not bought anything.
56
+ *
57
+ * `dependsOn: ["secrets"]` is real. Every rail's credentials are read through the aggregated secret
58
+ * registry, so a project composing payments without `@pithy-sh/secrets` must fail at assembly rather
59
+ * than at the first receipt. Auth is *not* listed — it is a seam: under `billingSubject: "user"` a purchase
60
+ * scopes to the authenticated caller, so with no auth capability composed every route denies, which is the
61
+ * right failure and needs no dependency edge. `@pithy-sh/ledger` is likewise a seam, reached through one
62
+ * guarded dynamic import and only for products whose catalog entry declares `grants`. Both belong in the
63
+ * manifest's `optionalCapabilities`.
64
+ *
65
+ * Under `billingSubject: "organization"` the holder is not the caller and cannot be derived from them, so
66
+ * the adopter supplies `resolveSubject` and a composition without one is refused outright — see
67
+ * {@link requireResolvableSubject}.
68
+ */
69
+ export declare function payments(options: PaymentsOptions): PaymentsCapability;
70
+ /** Whether a capability is the payments capability — carries its resolved catalog. */
71
+ export declare function isPaymentsCapability(capability: Capability): capability is PaymentsCapability;
72
+ //# sourceMappingURL=capability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,UAAU,EAGhB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAI3E,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3E,OAAO,KAAK,EAAE,uBAAuB,EAAuB,MAAM,2BAA2B,CAAC;AAQ9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAK7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG;IAClD;;;;OAIG;IACH,cAAc,CAAC,EAAE,uBAAuB,CAAC;CAC1C,CAAC;AA4LF,6FAA6F;AAC7F,MAAM,WAAW,kBACf,SAAQ,UAAU,CAAC,eAAe,EAAE,kBAAkB,EAAE,UAAU,EAAE,OAAO,iBAAiB,CAAC;IAC7F,4BAA4B;IAC5B,cAAc,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB,CAwFrE;AAED,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,kBAAkB,CAE7F"}