@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,50 @@
1
+ import type { CreatedDiscount, DiscountTerms } from "../../data/discount";
2
+ import type { PaymentsLemonSqueezyCredentials } from "../../secret/registry";
3
+ import type { ListedDiscount } from "../contract";
4
+ import { type LemonSqueezyHttpFetch } from "./api";
5
+ /**
6
+ * Minting a discount at Lemon Squeezy, from the normalized terms.
7
+ *
8
+ * One object rather than Stripe's two: a Discount carries the money, the duration, the redemption limit and
9
+ * the expiry together, and the code is a field on it rather than a separate object.
10
+ *
11
+ * ## The two translations that decide whether a customer is charged correctly
12
+ *
13
+ * **Duration.** Lemon Squeezy counts in **billing periods** — `duration_in_months` is its field name, and
14
+ * the name is a trap, because the store applies the number to renewals rather than to months. That happens
15
+ * to be the unit `DiscountDuration` already uses, so the number passes through unchanged. **This is the rail
16
+ * where the value is *not* converted, and Stripe is the one where it is** — which is precisely why neither
17
+ * rail's field name was allowed to become the normalized one. `discounts.test.ts` pins an annual plan on
18
+ * both rails and asserts the two produce the same customer-visible term from different numbers.
19
+ *
20
+ * **Expiry.** `redeemableUntil` means the code can no longer be *claimed*. Lemon Squeezy's `expires_at`
21
+ * stops redemption and leaves an existing subscriber's discount running, which is the same meaning — so it
22
+ * maps directly, and a test pins that a code already redeemed keeps its rate past the date.
23
+ *
24
+ * ## Amount, and the currency that arrives at the customer
25
+ *
26
+ * A fixed amount carries a currency; Lemon Squeezy applies it against a store whose subscriptions have their
27
+ * own. A mismatch is not refused at creation by the store — it fails at *redemption*, in front of whoever
28
+ * typed the code. `createDiscount` on this rail therefore refuses a fixed amount in a currency the store
29
+ * does not use before sending anything, naming both currencies, which is the only moment the adopter is
30
+ * still the one reading the error.
31
+ */
32
+ /** What creating a discount needs: the credentials, the store's currency, and the transport. */
33
+ export interface LemonSqueezyDiscountOptions {
34
+ /** The rail's credentials. `apiKey` creates; `storeId` says which store it belongs to. */
35
+ credentials: PaymentsLemonSqueezyCredentials;
36
+ /**
37
+ * The currency this store prices in, when it is known.
38
+ *
39
+ * Supplied so a fixed amount in another currency is refused here rather than at redemption. Absent means
40
+ * the check cannot be made and the store's own judgment stands — better than inventing a currency.
41
+ */
42
+ storeCurrency?: string;
43
+ /** The HTTP seam. Defaults to the runtime's `fetch`. */
44
+ transport?: LemonSqueezyHttpFetch;
45
+ }
46
+ /** Create a discount and return the code a customer will type. */
47
+ export declare function createLemonSqueezyDiscount(terms: DiscountTerms, options: LemonSqueezyDiscountOptions): Promise<CreatedDiscount>;
48
+ /** The discount codes this store holds. */
49
+ export declare function listLemonSqueezyDiscounts(options: LemonSqueezyDiscountOptions): Promise<readonly ListedDiscount[]>;
50
+ //# sourceMappingURL=discounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discounts.d.ts","sourceRoot":"","sources":["../../../src/rails/lemonSqueezy/discounts.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,KAAK,qBAAqB,EAA2C,MAAM,OAAO,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,gGAAgG;AAChG,MAAM,WAAW,2BAA2B;IAC1C,0FAA0F;IAC1F,WAAW,EAAE,+BAA+B,CAAC;IAC7C;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wDAAwD;IACxD,SAAS,CAAC,EAAE,qBAAqB,CAAC;CACnC;AAcD,kEAAkE;AAClE,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,eAAe,CAAC,CAoD1B;AAuBD,2CAA2C;AAC3C,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAkBpC"}
@@ -0,0 +1,75 @@
1
+ import { PaymentsDiscountInvalidError } from "../../error/errors.js";
2
+ import { lemonSqueezyHttpFetch, lemonSqueezyJson } from "./api.js";
3
+ import { z } from "zod";
4
+ //#region src/rails/lemonSqueezy/discounts.ts
5
+ /** A created discount, narrowed to what an adopter needs back. */
6
+ const LemonSqueezyDiscount = z.object({ data: z.object({
7
+ id: z.string().min(1),
8
+ attributes: z.object({ code: z.string().min(1) }).loose()
9
+ }).loose() }).loose();
10
+ /** Create a discount and return the code a customer will type. */
11
+ async function createLemonSqueezyDiscount(terms, options) {
12
+ if (terms.amount.kind === "fixed" && options.storeCurrency !== void 0 && options.storeCurrency.toLowerCase() !== terms.amount.currency.toLowerCase()) throw new PaymentsDiscountInvalidError({
13
+ message: "That discount is in a currency this store does not sell in.",
14
+ action: `Create it in ${options.storeCurrency.toUpperCase()}, or use a percentage instead.`,
15
+ detail: `A fixed discount of ${terms.amount.amountMinor} ${terms.amount.currency.toUpperCase()} cannot apply to a store selling in ${options.storeCurrency.toUpperCase()}. Lemon Squeezy accepts the object and refuses it at redemption, in front of the customer.`
16
+ });
17
+ const attributes = {
18
+ name: terms.code ?? "Discount",
19
+ amount_type: terms.amount.kind === "percent" ? "percent" : "fixed",
20
+ amount: terms.amount.kind === "percent" ? terms.amount.percent : terms.amount.amountMinor,
21
+ duration: terms.duration.kind,
22
+ is_limited_redemptions: terms.maxRedemptions !== void 0
23
+ };
24
+ if (terms.code !== void 0) attributes.code = terms.code;
25
+ if (terms.duration.kind === "repeating") attributes.duration_in_months = terms.duration.billingPeriods;
26
+ if (terms.maxRedemptions !== void 0) attributes.max_redemptions = terms.maxRedemptions;
27
+ if (terms.redeemableUntil !== void 0) attributes.expires_at = terms.redeemableUntil.toISOString();
28
+ const created = await lemonSqueezyJson(options.transport ?? lemonSqueezyHttpFetch, "/discounts", {
29
+ what: "a discount",
30
+ apiKey: options.credentials.apiKey,
31
+ body: { data: {
32
+ type: "discounts",
33
+ attributes,
34
+ relationships: { store: { data: {
35
+ type: "stores",
36
+ id: options.credentials.storeId
37
+ } } }
38
+ } }
39
+ });
40
+ const parsed = LemonSqueezyDiscount.safeParse(created);
41
+ if (!parsed.success) throw new PaymentsDiscountInvalidError({ detail: "Lemon Squeezy created a discount and returned no code for it." });
42
+ return {
43
+ code: parsed.data.data.attributes.code,
44
+ providerDiscountId: parsed.data.data.id,
45
+ terms
46
+ };
47
+ }
48
+ /** Lemon Squeezy's discount list, narrowed to what a management pane shows. */
49
+ const LemonSqueezyDiscountList = z.object({ data: z.array(z.object({
50
+ id: z.string().min(1),
51
+ attributes: z.object({
52
+ code: z.string().min(1),
53
+ amount: z.number().nullish(),
54
+ amount_type: z.string().nullish(),
55
+ duration: z.string().nullish()
56
+ }).loose()
57
+ }).loose()) }).loose();
58
+ /** The discount codes this store holds. */
59
+ async function listLemonSqueezyDiscounts(options) {
60
+ const found = await lemonSqueezyJson(options.transport ?? lemonSqueezyHttpFetch, "/discounts", {
61
+ what: "the discount codes",
62
+ apiKey: options.credentials.apiKey,
63
+ query: { "filter[store_id]": options.credentials.storeId }
64
+ });
65
+ const parsed = LemonSqueezyDiscountList.safeParse(found);
66
+ if (!parsed.success) return [];
67
+ return parsed.data.data.map((discount) => ({
68
+ code: discount.attributes.code,
69
+ providerDiscountId: discount.id,
70
+ amount: discount.attributes.amount_type === "percent" ? `${discount.attributes.amount ?? 0}%` : `${discount.attributes.amount ?? 0} ${options.storeCurrency ?? ""}`.trim(),
71
+ redemptions: null
72
+ }));
73
+ }
74
+ //#endregion
75
+ export { createLemonSqueezyDiscount, listLemonSqueezyDiscounts };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Lemon Squeezy deliveries, built rather than checked in as JSON.
3
+ *
4
+ * Built because every one of them has to be *signed*, and a signature is over exact bytes: a checked-in
5
+ * JSON file plus a checked-in signature would be a pair that silently stops matching the moment either is
6
+ * reformatted, and the test would still pass by verifying the wrong thing. So a fixture produces the body
7
+ * and the test signs it with the same secret it hands the rail — verification is exercised for real.
8
+ *
9
+ * The shapes are Lemon Squeezy's own, trimmed to the fields this rail reads and the ones that prove it
10
+ * reads the right one. `test_mode: false` throughout, because the projection refuses across environments
11
+ * and every test that is not about that axis wants a production purchase.
12
+ */
13
+ /** The store's ids, fixed so a test can assert on the exact namespaced key a row is written under. */
14
+ export declare const SUBSCRIPTION_ID = "90001";
15
+ export declare const INVOICE_ONE = "8001";
16
+ export declare const INVOICE_TWO = "8002";
17
+ export declare const ORDER_ID = "7001";
18
+ export declare const CUSTOMER_ID = 700;
19
+ export declare const VARIANT_ID = 55555;
20
+ /** The purchaser this deployment stamped into the checkout, echoed back by the store on every delivery. */
21
+ export declare const ACCOUNT_REFERENCE = "user:ada";
22
+ /** What the fences are tested against. */
23
+ export declare const THIS_DEPLOYMENT = "staging";
24
+ /** The signing secret every fixture is minted against, matching what the tests hand the rail. */
25
+ export declare const FIXTURE_WEBHOOK_SECRET = "ls_whsec_test";
26
+ /** A subscription object, as `subscription_*` delivers it. */
27
+ export declare function subscription(overrides?: Record<string, unknown>): Record<string, unknown>;
28
+ /** A subscription-invoice object, as `subscription_payment_*` delivers it. Carries no `variant_id`. */
29
+ export declare function invoice(overrides?: Record<string, unknown>): Record<string, unknown>;
30
+ /** An order object, as `order_*` delivers it. */
31
+ export declare function order(overrides?: Record<string, unknown>): Record<string, unknown>;
32
+ /** A subscription-domain delivery. */
33
+ export declare function subscriptionDelivery(eventName: string, overrides?: Record<string, unknown>, options?: {
34
+ deployment?: string | undefined;
35
+ stamped?: boolean;
36
+ forge?: boolean;
37
+ }): Promise<string>;
38
+ /** An invoice-domain delivery. */
39
+ export declare function invoiceDelivery(eventName: string, id?: string, overrides?: Record<string, unknown>, options?: {
40
+ deployment?: string | undefined;
41
+ stamped?: boolean;
42
+ forge?: boolean;
43
+ }): Promise<string>;
44
+ /** An order-domain delivery. */
45
+ export declare function orderDelivery(eventName: string, overrides?: Record<string, unknown>, options?: {
46
+ deployment?: string | undefined;
47
+ stamped?: boolean;
48
+ forge?: boolean;
49
+ }): Promise<string>;
50
+ /** A delivery of a type this build does not map — a license key, say. */
51
+ export declare function unknownDelivery(): Promise<string>;
52
+ /** The JSON:API answer `GET /v1/subscriptions/{id}` gives, for the transport stub. */
53
+ export declare function subscriptionResponse(overrides?: Record<string, unknown>): string;
54
+ /** The JSON:API answer `GET /v1/orders/{id}` gives. */
55
+ export declare function orderResponse(overrides?: Record<string, unknown>): string;
56
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/rails/lemonSqueezy/fixtures/events.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;GAWG;AAEH,sGAAsG;AACtG,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,UAAU,QAAQ,CAAC;AAEhC,2GAA2G;AAI3G,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAE5C,0CAA0C;AAC1C,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC,iGAAiG;AACjG,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAwCtD,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAa7F;AAED,uGAAuG;AACvG,wBAAgB,OAAO,CAAC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAexF;AAED,iDAAiD;AACjD,wBAAgB,KAAK,CAAC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAetF;AAED,sCAAsC;AACtC,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACvC,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACpF,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,kCAAkC;AAClC,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,EAAE,GAAE,MAAoB,EACxB,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACvC,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACpF,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,gCAAgC;AAChC,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACvC,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACpF,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,yEAAyE;AACzE,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAKvD;AAED,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAIpF;AAED,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAE7E"}
@@ -0,0 +1,144 @@
1
+ import { LEMON_SQUEEZY_CUSTOM_ACCOUNT, LEMON_SQUEEZY_CUSTOM_ENV, LEMON_SQUEEZY_CUSTOM_PROOF, accountReferenceProof } from "../objects.js";
2
+ //#region src/rails/lemonSqueezy/fixtures/events.ts
3
+ /**
4
+ * Lemon Squeezy deliveries, built rather than checked in as JSON.
5
+ *
6
+ * Built because every one of them has to be *signed*, and a signature is over exact bytes: a checked-in
7
+ * JSON file plus a checked-in signature would be a pair that silently stops matching the moment either is
8
+ * reformatted, and the test would still pass by verifying the wrong thing. So a fixture produces the body
9
+ * and the test signs it with the same secret it hands the rail — verification is exercised for real.
10
+ *
11
+ * The shapes are Lemon Squeezy's own, trimmed to the fields this rail reads and the ones that prove it
12
+ * reads the right one. `test_mode: false` throughout, because the projection refuses across environments
13
+ * and every test that is not about that axis wants a production purchase.
14
+ */
15
+ /** The store's ids, fixed so a test can assert on the exact namespaced key a row is written under. */
16
+ const SUBSCRIPTION_ID = "90001";
17
+ const INVOICE_ONE = "8001";
18
+ const INVOICE_TWO = "8002";
19
+ const ORDER_ID = "7001";
20
+ const CUSTOMER_ID = 700;
21
+ const VARIANT_ID = 55555;
22
+ /** The purchaser this deployment stamped into the checkout, echoed back by the store on every delivery. */
23
+ const ACCOUNT_REFERENCE = "user:ada";
24
+ /** What the fences are tested against. */
25
+ const THIS_DEPLOYMENT = "staging";
26
+ /** The signing secret every fixture is minted against, matching what the tests hand the rail. */
27
+ const FIXTURE_WEBHOOK_SECRET = "ls_whsec_test";
28
+ /**
29
+ * The `meta.custom_data` a delivery carries when our own checkout created the purchase — **proof included**.
30
+ *
31
+ * The proof is computed with the real function rather than hard-coded, so a fixture cannot drift from the
32
+ * verifier and quietly stop exercising it. `forge` mints the two public values with no proof, which is
33
+ * exactly what a stranger can build from a storefront buy link.
34
+ */
35
+ async function custom(deployment = THIS_DEPLOYMENT, options = {}) {
36
+ const data = { [LEMON_SQUEEZY_CUSTOM_ACCOUNT]: ACCOUNT_REFERENCE };
37
+ if (deployment !== void 0) {
38
+ data[LEMON_SQUEEZY_CUSTOM_ENV] = deployment;
39
+ if (options.forge !== true) data[LEMON_SQUEEZY_CUSTOM_PROOF] = await accountReferenceProof(ACCOUNT_REFERENCE, deployment, FIXTURE_WEBHOOK_SECRET);
40
+ }
41
+ return data;
42
+ }
43
+ /** One delivery envelope. */
44
+ async function delivery(eventName, id, type, attributes, options = {}) {
45
+ const meta = {
46
+ event_name: eventName,
47
+ test_mode: false
48
+ };
49
+ if (options.stamped !== false) meta.custom_data = await custom(options.deployment, { forge: options.forge });
50
+ return JSON.stringify({
51
+ meta,
52
+ data: {
53
+ type,
54
+ id,
55
+ attributes
56
+ }
57
+ });
58
+ }
59
+ /** A subscription object, as `subscription_*` delivers it. */
60
+ function subscription(overrides = {}) {
61
+ return {
62
+ store_id: 1,
63
+ customer_id: 700,
64
+ variant_id: VARIANT_ID,
65
+ status: "active",
66
+ renews_at: "2026-02-01T10:00:00.000000Z",
67
+ ends_at: null,
68
+ created_at: "2026-01-01T10:00:00.000000Z",
69
+ updated_at: "2026-01-01T10:00:00.000000Z",
70
+ test_mode: false,
71
+ ...overrides
72
+ };
73
+ }
74
+ /** A subscription-invoice object, as `subscription_payment_*` delivers it. Carries no `variant_id`. */
75
+ function invoice(overrides = {}) {
76
+ return {
77
+ store_id: 1,
78
+ subscription_id: Number(SUBSCRIPTION_ID),
79
+ customer_id: 700,
80
+ status: "paid",
81
+ refunded: false,
82
+ refunded_at: null,
83
+ currency: "USD",
84
+ total: 999,
85
+ created_at: "2026-01-01T10:00:05.000000Z",
86
+ updated_at: "2026-01-01T10:00:05.000000Z",
87
+ test_mode: false,
88
+ ...overrides
89
+ };
90
+ }
91
+ /** An order object, as `order_*` delivers it. */
92
+ function order(overrides = {}) {
93
+ return {
94
+ store_id: 1,
95
+ customer_id: 700,
96
+ status: "paid",
97
+ refunded: false,
98
+ refunded_at: null,
99
+ currency: "USD",
100
+ total: 4900,
101
+ first_order_item: { variant_id: VARIANT_ID },
102
+ created_at: "2026-03-01T09:00:00.000000Z",
103
+ updated_at: "2026-03-01T09:00:00.000000Z",
104
+ test_mode: false,
105
+ ...overrides
106
+ };
107
+ }
108
+ /** A subscription-domain delivery. */
109
+ async function subscriptionDelivery(eventName, overrides = {}, options = {}) {
110
+ return await delivery(eventName, SUBSCRIPTION_ID, "subscriptions", subscription(overrides), options);
111
+ }
112
+ /** An invoice-domain delivery. */
113
+ async function invoiceDelivery(eventName, id = INVOICE_ONE, overrides = {}, options = {}) {
114
+ return await delivery(eventName, id, "subscription-invoices", invoice(overrides), options);
115
+ }
116
+ /** An order-domain delivery. */
117
+ async function orderDelivery(eventName, overrides = {}, options = {}) {
118
+ return await delivery(eventName, ORDER_ID, "orders", order(overrides), options);
119
+ }
120
+ /** A delivery of a type this build does not map — a license key, say. */
121
+ async function unknownDelivery() {
122
+ return await delivery("license_key_created", "42", "license-keys", {
123
+ status: "active",
124
+ created_at: "2026-04-01T00:00:00Z"
125
+ });
126
+ }
127
+ /** The JSON:API answer `GET /v1/subscriptions/{id}` gives, for the transport stub. */
128
+ function subscriptionResponse(overrides = {}) {
129
+ return JSON.stringify({ data: {
130
+ type: "subscriptions",
131
+ id: SUBSCRIPTION_ID,
132
+ attributes: subscription(overrides)
133
+ } });
134
+ }
135
+ /** The JSON:API answer `GET /v1/orders/{id}` gives. */
136
+ function orderResponse(overrides = {}) {
137
+ return JSON.stringify({ data: {
138
+ type: "orders",
139
+ id: ORDER_ID,
140
+ attributes: order(overrides)
141
+ } });
142
+ }
143
+ //#endregion
144
+ export { ACCOUNT_REFERENCE, CUSTOMER_ID, FIXTURE_WEBHOOK_SECRET, INVOICE_ONE, INVOICE_TWO, ORDER_ID, SUBSCRIPTION_ID, THIS_DEPLOYMENT, VARIANT_ID, invoice, invoiceDelivery, order, orderDelivery, orderResponse, subscription, subscriptionDelivery, subscriptionResponse, unknownDelivery };
@@ -0,0 +1,229 @@
1
+ import { z } from "zod";
2
+ import type { PurchaseStatus } from "../../data/status";
3
+ import type { UnboundProviderEvent } from "../contract";
4
+ /**
5
+ * Lemon Squeezy's objects, and the mapping from what its webhooks say to what this package stores.
6
+ *
7
+ * ## Identifiers are namespaced, and that is not a style choice
8
+ *
9
+ * Lemon Squeezy numbers **each object type from one**, and renders the number as a JSON:API string. So order
10
+ * `8801` and subscription-invoice `8801` are different objects wearing the same `data.id`. A purchase row's
11
+ * identity is `UNIQUE (rail, providerTransactionId)`, so storing the bare id would silently fuse an order and
12
+ * an invoice into one row — one buyer's refund landing on another buyer's subscription.
13
+ *
14
+ * Stripe never faced this because `pi_`, `in_` and `sub_` are globally distinct, so the Stripe rail stores its
15
+ * ids verbatim. Here the type has to be part of the key, and {@link namespacedId} is the only way an id is
16
+ * allowed to reach the writer. The prefix is stable forever: it is inside the row's identity.
17
+ *
18
+ * ## Two rows per subscription, and why
19
+ *
20
+ * Lemon Squeezy splits money from state at the source. `subscription_payment_*` delivers a **subscription
21
+ * invoice**: an amount, a currency, and nothing about whether the subscription is still live.
22
+ * `subscription_*` delivers a **subscription**: a status and a renewal date, and no charge. Neither names the
23
+ * other's key — an LS subscription has no latest-invoice pointer — so there is no honest way to collapse them
24
+ * onto one row.
25
+ *
26
+ * Collapsing them anyway would mean stamping two different clocks into one monotonic `providerEventAt`: the
27
+ * invoice's `updated_at` lives in the invoice domain and moves when a refund is issued months later, while the
28
+ * subscription's moves on every renewal. That is the defect the CMS learned expensively — an invoice timestamp
29
+ * written into a subscription's watermark drops the `subscription_updated` that follows a renewal.
30
+ *
31
+ * So: a **state row** keyed on the subscription, and a **money row** per invoice, distinguished by
32
+ * `PurchaseRole`. Each row is monotonic on exactly one provider clock, and an invoice event physically cannot
33
+ * address the state row because the keys differ. That is a property of the schema rather than of careful code.
34
+ * Only the money rows fulfill a `grants` clause, which is what makes N renewals credit exactly N times.
35
+ *
36
+ * ## The environment fence
37
+ *
38
+ * A Lemon Squeezy store is **one namespace across every environment** — test mode is a flag on an object, not
39
+ * a separate store — so a `dev` deployment and a `staging` deployment pointed at one store both hear
40
+ * everything the other's buyers do. `createCheckoutSession` stamps this deployment's `ENVIRONMENT` into
41
+ * `checkout_data.custom`, the store echoes it back as `meta.custom_data`, and an event stamped for somebody
42
+ * else projects nothing: no row, no entitlement, no audit warning, and a 200.
43
+ *
44
+ * An event carrying **no** stamp is not fenced. An order placed in the Lemon Squeezy storefront rather than
45
+ * through our checkout carries no `custom_data` at all, and fencing on absence would silently drop real sales.
46
+ *
47
+ * `test_mode` is a separate axis and drives `environment`, which the projection writer refuses across.
48
+ *
49
+ * ## Custom data is snake_case, in both directions
50
+ *
51
+ * Lemon Squeezy normalizes custom keys to snake_case before echoing them back. What checkout sends and what
52
+ * this module reads must therefore both be snake_case, even though the rest of this codebase is camelCase.
53
+ * Sending `pithyEnv` and reading `pithy_env` silently never matches, and the binding never happens — so the
54
+ * two constants below are the single source for both sides and the round-trip is pinned by a test.
55
+ */
56
+ /**
57
+ * The `checkout_data.custom` key carrying the subject reference. snake_case, because LS normalizes to it.
58
+ *
59
+ * **The name is frozen even though its meaning moved.** What travels here is now
60
+ * `encodeSubjectReference`'s output — `user:ada`, `organization:acme` — because a purchase can be held by an
61
+ * organization. This string is a wire contract with Lemon Squeezy rather than an identifier of ours: a
62
+ * checkout stamped today is a hosted page open in somebody's browser and a subscription that renews for
63
+ * months, and the store echoes whatever it was given back on every delivery that purchase ever produces. A
64
+ * renamed key reads nothing on any of them — every in-flight purchase would come back naming nobody,
65
+ * permanently, with a `linkProviderAccount` that never rebinds behind it. Rename it and the loss is silent.
66
+ */
67
+ export declare const LEMON_SQUEEZY_CUSTOM_ACCOUNT = "pithy_account_reference";
68
+ /** The `checkout_data.custom` key carrying this deployment's environment. snake_case, for the same reason. */
69
+ export declare const LEMON_SQUEEZY_CUSTOM_ENV = "pithy_env";
70
+ /**
71
+ * The `checkout_data.custom` key carrying the proof that **this deployment's server** wrote the two above.
72
+ *
73
+ * Without it the other two prove nothing. Lemon Squeezy's public storefront buy links accept
74
+ * `checkout[custom][...]` parameters and the webhook echoes them exactly as an API-created checkout's would,
75
+ * so anyone can set `pithy_account_reference`. The environment stamp does not save it: these key names are
76
+ * exported constants in an open-source package and the value is one of three (`dev`, `staging`, `prod`), so
77
+ * requiring it asks an attacker to guess nothing at all.
78
+ *
79
+ * A MAC is the only thing that distinguishes the two, because it is the only thing a stranger cannot
80
+ * produce. See {@link accountReferenceProof}.
81
+ */
82
+ export declare const LEMON_SQUEEZY_CUSTOM_PROOF = "pithy_ref_proof";
83
+ /**
84
+ * One identifier, prefixed by the object type it came from.
85
+ *
86
+ * The prefix is part of the row's identity forever, so it is never derived from anything that could change
87
+ * spelling. Three values, and they are the only three.
88
+ */
89
+ export declare function namespacedId(type: "subscription" | "subscription_invoice" | "order", id: string): string;
90
+ /** The webhook envelope every delivery arrives in. */
91
+ export declare const LemonSqueezyWebhook: z.ZodObject<{
92
+ meta: z.ZodObject<{
93
+ event_name: z.ZodString;
94
+ test_mode: z.ZodOptional<z.ZodBoolean>;
95
+ custom_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
96
+ }, z.core.$loose>;
97
+ data: z.ZodObject<{
98
+ id: z.ZodString;
99
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnknown>;
100
+ }, z.core.$loose>;
101
+ }, z.core.$loose>;
102
+ export type LemonSqueezyWebhook = z.infer<typeof LemonSqueezyWebhook>;
103
+ /** A subscription's fields, as a `subscription_*` webhook and the API both present them. */
104
+ export declare const LemonSqueezySubscription: z.ZodObject<{
105
+ store_id: z.ZodOptional<z.ZodNumber>;
106
+ customer_id: z.ZodOptional<z.ZodNumber>;
107
+ variant_id: z.ZodOptional<z.ZodNumber>;
108
+ status: z.ZodString;
109
+ renews_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
110
+ ends_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
111
+ pause: z.ZodOptional<z.ZodNullable<z.ZodObject<{
112
+ mode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
113
+ resumes_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
114
+ }, z.core.$loose>>>;
115
+ created_at: z.ZodString;
116
+ updated_at: z.ZodString;
117
+ test_mode: z.ZodOptional<z.ZodBoolean>;
118
+ }, z.core.$loose>;
119
+ export type LemonSqueezySubscription = z.infer<typeof LemonSqueezySubscription>;
120
+ /** A subscription invoice's fields — one billing period's money. */
121
+ export declare const LemonSqueezySubscriptionInvoice: z.ZodObject<{
122
+ store_id: z.ZodOptional<z.ZodNumber>;
123
+ subscription_id: z.ZodNumber;
124
+ customer_id: z.ZodOptional<z.ZodNumber>;
125
+ status: z.ZodString;
126
+ refunded: z.ZodOptional<z.ZodBoolean>;
127
+ refunded_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
128
+ currency: z.ZodOptional<z.ZodString>;
129
+ total: z.ZodOptional<z.ZodNumber>;
130
+ created_at: z.ZodString;
131
+ updated_at: z.ZodString;
132
+ test_mode: z.ZodOptional<z.ZodBoolean>;
133
+ }, z.core.$loose>;
134
+ export type LemonSqueezySubscriptionInvoice = z.infer<typeof LemonSqueezySubscriptionInvoice>;
135
+ /** An order's fields — a one-off purchase. */
136
+ export declare const LemonSqueezyOrder: z.ZodObject<{
137
+ store_id: z.ZodOptional<z.ZodNumber>;
138
+ customer_id: z.ZodOptional<z.ZodNumber>;
139
+ status: z.ZodString;
140
+ refunded: z.ZodOptional<z.ZodBoolean>;
141
+ refunded_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
142
+ currency: z.ZodOptional<z.ZodString>;
143
+ total: z.ZodOptional<z.ZodNumber>;
144
+ first_order_item: z.ZodOptional<z.ZodObject<{
145
+ variant_id: z.ZodOptional<z.ZodNumber>;
146
+ }, z.core.$loose>>;
147
+ created_at: z.ZodString;
148
+ updated_at: z.ZodString;
149
+ test_mode: z.ZodOptional<z.ZodBoolean>;
150
+ }, z.core.$loose>;
151
+ export type LemonSqueezyOrder = z.infer<typeof LemonSqueezyOrder>;
152
+ /**
153
+ * A subscription's status, normalized.
154
+ *
155
+ * `on_trial` grants: a trial is access the store is currently giving, and refusing it would lock a user out
156
+ * of the thing they signed up for. `unpaid` is `on_hold` rather than `expired` — Lemon Squeezy has exhausted
157
+ * its dunning and the money never arrived, so nothing was paid and nothing may be credited. An unknown
158
+ * status refuses rather than guessing, which is the Stripe rail's rule too: a status this package has never
159
+ * seen is a shape change worth failing loudly on.
160
+ */
161
+ export declare function subscriptionStatus(status: string): PurchaseStatus;
162
+ /**
163
+ * A subscription invoice's status, normalized — the money's own story, not the subscription's.
164
+ *
165
+ * A paid invoice is `expired` rather than `active`, and that is deliberate: it records a billing period that
166
+ * was paid for and has closed, and `expired` is the status that credits a `grants` clause without granting
167
+ * access. Access comes from the state row. A `void` or `failed` invoice is `never_paid`, which credits
168
+ * nothing and is never clawed back, because no money ever moved.
169
+ */
170
+ export declare function invoiceStatus(invoice: LemonSqueezySubscriptionInvoice): PurchaseStatus;
171
+ /** An order's status, normalized. An order is money and state at once, so a paid one grants. */
172
+ export declare function orderStatus(order: LemonSqueezyOrder): PurchaseStatus;
173
+ /** The state row a subscription object implies. Carries no amount — a subscription is not a charge. */
174
+ export declare function subscriptionEvent(id: string, subscription: LemonSqueezySubscription): UnboundProviderEvent;
175
+ /** The money row a subscription invoice implies, given the variant its subscription is for. */
176
+ export declare function invoiceEvent(id: string, invoice: LemonSqueezySubscriptionInvoice, variantId: string): UnboundProviderEvent;
177
+ /** The row a one-off order implies. Money and state at once, so one row does both jobs. */
178
+ export declare function orderEvent(id: string, order: LemonSqueezyOrder): UnboundProviderEvent;
179
+ /**
180
+ * The account reference this deployment stamped into the checkout, or null.
181
+ *
182
+ * **Honored only when this deployment's own environment stamp is beside it**, and that condition is the
183
+ * whole security of the field. `accountReference`'s contract says it is "a value this deployment's own
184
+ * server wrote and the store returned unchanged" — the route writes the provider-account link from it, and
185
+ * `linkProviderAccount` never rebinds, so the first pairing is permanent.
186
+ *
187
+ * Lemon Squeezy's public storefront buy links accept `checkout[custom][...]` query parameters, and the
188
+ * resulting webhook echoes them in `meta.custom_data` exactly as an API-created checkout's would. So
189
+ * `custom_data` on its own is **not** evidence our server wrote anything: an unauthenticated stranger can
190
+ * put any string in it and permanently bind their store customer to an account they chose. The env stamp is
191
+ * the discriminator, because it is written only by {@link createLemonSqueezyCheckoutSession}, and a checkout
192
+ * a stranger built through the storefront carries either no stamp or another deployment's.
193
+ *
194
+ * A deployment that does not know its own `ENVIRONMENT` trusts no reference at all. That is the safe
195
+ * direction: the cost is a purchase that lands unbound and is repairable from the trail, where the other way
196
+ * round is an unauthenticated write into the account map that nothing ever undoes.
197
+ *
198
+ * **And the value must be the subject encoding, which the MAC alone does not make it.** A stamp can be
199
+ * authentic and still name nobody: a bare id is what this rail wrote before subjects existed, and reading
200
+ * one as a user would hand a purchase to whoever else holds that id. So the reference is put through
201
+ * `decodeSubjectReference` — the one decoder, never a split written here — and anything that is not exactly
202
+ * the encoding is refused in the same direction as everything else above. The string is returned rather than
203
+ * the pair because a rail reports `accountReference` as a string; the route decodes it again through the same
204
+ * function, and gets the same answer.
205
+ */
206
+ export declare function accountReferenceOf(webhook: LemonSqueezyWebhook, deployment: string | undefined, secret: string): Promise<string | null>;
207
+ /**
208
+ * The proof this deployment stamps beside an account reference, and the only reason the reference is worth
209
+ * anything.
210
+ *
211
+ * An HMAC over the environment and the subject reference, keyed with a secret a stranger does not have. The
212
+ * message is domain-separated by a fixed prefix so this MAC can never be confused with the webhook-body
213
+ * signature that shares its key: the two answer different questions, and a value that satisfied both would be
214
+ * a cross-protocol attack waiting to be found.
215
+ *
216
+ * The key is the webhook signing secret because it is already per-environment, already rotated with the
217
+ * rail, and already known only to this deployment and to Lemon Squeezy — and Lemon Squeezy is not the
218
+ * attacker here. The attacker is anyone who can open a storefront buy link, which is everyone.
219
+ */
220
+ export declare function accountReferenceProof(reference: string, deployment: string, secret: string): Promise<string>;
221
+ /**
222
+ * Whether this delivery belongs to another deployment sharing the same store.
223
+ *
224
+ * True only when both sides named an environment and they differ. An unstamped delivery is ours to consider
225
+ * — a storefront order has no `custom_data` — and a deployment that does not know its own environment
226
+ * fences nothing, which is precisely how the other three rails behave.
227
+ */
228
+ export declare function fencedOut(webhook: LemonSqueezyWebhook, deployment: string | undefined): boolean;
229
+ //# sourceMappingURL=objects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/rails/lemonSqueezy/objects.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B,4BAA4B,CAAC;AAEtE,8GAA8G;AAC9G,eAAO,MAAM,wBAAwB,cAAc,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,oBAAoB,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,sBAAsB,GAAG,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAExG;AAUD,sDAAsD;AACtD,eAAO,MAAM,mBAAmB;;;;;;;;;;iBAqB+B,CAAC;AAChE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,4FAA4F;AAC5F,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;iBAwBkE,CAAC;AACxG,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,oEAAoE;AACpE,eAAO,MAAM,+BAA+B;;;;;;;;;;;;iBAesE,CAAC;AACnH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAE9F,8CAA8C;AAC9C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;iBAmBuE,CAAC;AACtG,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAwBlE;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAoBjE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,+BAA+B,GAAG,cAAc,CAiBtF;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,cAAc,CAiBpE;AAED,uGAAuG;AACvG,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,wBAAwB,GAAG,oBAAoB,CAwB1G;AAED,+FAA+F;AAC/F,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,+BAA+B,EACxC,SAAS,EAAE,MAAM,GAChB,oBAAoB,CAqBtB;AAED,2FAA2F;AAC3F,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,oBAAoB,CAkBrF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,mBAAmB,EAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkBxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWlH;AAyCD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAI/F"}