@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,94 @@
1
+ import type { PaymentsResult } from "./api";
2
+ import { type PaddleOptions, type PaddlePriceQuery, type PaddleSetup, type PriceSummaryOptions } from "./paddle";
3
+ /**
4
+ * One quote per named plan — the whole of what two Pithy surfaces share.
5
+ *
6
+ * The marketing site at `pithy.sh/pricing` and the dashboard both quote the same plans from the same
7
+ * Paddle account, and each once carried its own copy of the twelve lines that do it. One of those copies
8
+ * was wrong for months: `#416` read `currencyCode` and `details` off the top of `PricePreview()`'s answer
9
+ * when they live under `data`, so the reader refused every real response — and because a refusal is
10
+ * deliberately not an error, the screen rendered an empty price slot that looked deliberate. It was the
11
+ * *reviewed* copy that was wrong. The hand-written one on the marketing site had it right the whole time.
12
+ * Nothing could tell, because there was nothing that both of them ran.
13
+ *
14
+ * This is that thing. It goes through {@link previewPrices}, so it goes through `readPricePreview`, so
15
+ * the `#416` class of defect has exactly one place left it can exist.
16
+ *
17
+ * **What it deliberately does not do** is the reason it can be shared at all. It does not choose the
18
+ * account — the marketing site decides from the hostname at request time and the dashboard decides from
19
+ * `CLOUDFLARE_ENV` at build time, and both are right for their surface. It does not name a price id —
20
+ * the marketing site holds literals per account and the dashboard has a gate saying only one file in the
21
+ * Worker may name one. It does not cache — the dashboard forbids `localStorage` in a client module
22
+ * outright. And it does not paint: marketing writes text nodes, the dashboard renders React from the
23
+ * same answer. Given an account and a set of price ids, hand back a formatted total per plan. Everything
24
+ * above that stays with whoever is rendering.
25
+ */
26
+ /** Plan name to the Paddle price — `pri_…` — that quotes it. */
27
+ export type PaddlePlanPrices = Readonly<Record<string, string>>;
28
+ /**
29
+ * Who the quote is for, and where — every part of a `PricePreview` query but the prices themselves.
30
+ *
31
+ * **A quote must resolve from the same Paddle row the charge will.** Omitted, Paddle resolves location
32
+ * from the browser's IP, which is right for a stranger reading a marketing page and wrong for everybody
33
+ * who has signed in: a customer with an address on file is quoted from whatever network they happen to
34
+ * be on, and `priceSummary` marks the figure `estimated` because no postal code resolved. Pass
35
+ * `customerId` and Paddle prices them from the address `POST /payments/checkout` will bill.
36
+ *
37
+ * Derived from {@link PaddlePriceQuery} rather than restated, so a field Paddle adds arrives here with
38
+ * it. `items` is the one part {@link quotePlans} owns — it is the plans, and there is one source of it.
39
+ */
40
+ export type PaddleQuoteQuery = Omit<PaddlePriceQuery, "items">;
41
+ /** What {@link quotePlans} lets a caller replace, plus who the quote is for. */
42
+ export interface PaddleQuoteOptions extends PaddleOptions, PriceSummaryOptions {
43
+ /** Who to quote for, and where they are. Omitted, Paddle resolves it from the visitor's IP. */
44
+ readonly query?: PaddleQuoteQuery;
45
+ }
46
+ /** What one plan costs this visitor, ready to render. */
47
+ export interface PaddlePlanQuote {
48
+ /** The plan this quotes, as the caller named it. */
49
+ readonly plan: string;
50
+ /** The Paddle price it resolved to. */
51
+ readonly priceId: string;
52
+ /**
53
+ * The figure to show, already formatted by Paddle for this visitor.
54
+ *
55
+ * Per unit, and not the same field in every country: where tax is added on top the listed price is the
56
+ * subtotal, and where it is taken out of an inclusive figure the listed price is the total. See
57
+ * {@link priceSummary}, which is where that decision is made and tested.
58
+ *
59
+ * Paddle's own string, unless the caller passed `wholeUnits` — the one thing that ever changes it, and
60
+ * only by removing a fraction that is entirely zero.
61
+ */
62
+ readonly headline: string;
63
+ /** One sentence about tax, or null where there is nothing true to say. */
64
+ readonly note: string | null;
65
+ /** Whether the tax in this quote may be short of what the buyer is charged. */
66
+ readonly estimated: boolean;
67
+ /**
68
+ * The ISO-4217 currency Paddle answered in — `"USD"`, `"JPY"`.
69
+ *
70
+ * {@link headline} is already formatted, so nothing here needs this to render. A caller that formats
71
+ * the figure itself does, and this is the only place it exists: `PriceSummary` carries no currency, so
72
+ * a caller reading only the quote had `preview.currencyCode` held one layer down and dropped.
73
+ */
74
+ readonly currency: string;
75
+ }
76
+ /**
77
+ * Quote every named plan, or refuse.
78
+ *
79
+ * One `PricePreview` call for the whole set, because it is one round trip and Paddle answers a line per
80
+ * item. A plan Paddle returned no line for is left out rather than quoted from another plan's line — the
81
+ * caller sees a plan missing, which its own markup already has a sentence for, instead of two plans
82
+ * showing one price.
83
+ *
84
+ * **No plans means no network.** An unconfigured page must cost a visitor nothing, and `PricePreview`
85
+ * with an empty `items` is a request Paddle refuses anyway.
86
+ *
87
+ * **One price is asked for once, however many plans name it.** A pricing table with a highlighted row
88
+ * points two plans at one price often enough; asking for it twice is redundant at best, and whether
89
+ * Paddle tolerates a repeated `priceId` is not a thing to find out in production — a refusal there takes
90
+ * the whole table down to its placeholders, not just the duplicated row. Both plans still resolve, off
91
+ * the one line, because a plan is matched to its line by id.
92
+ */
93
+ export declare function quotePlans(setup: PaddleSetup, plans: PaddlePlanPrices, options?: PaddleQuoteOptions): Promise<PaymentsResult<readonly PaddlePlanQuote[]>>;
94
+ //# sourceMappingURL=paddlePrices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paddlePrices.d.ts","sourceRoot":"","sources":["../../src/client/paddlePrices.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EAGzB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAE/D,gFAAgF;AAChF,MAAM,WAAW,kBAAmB,SAAQ,aAAa,EAAE,mBAAmB;IAC5E,+FAA+F;IAC/F,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAED,yDAAyD;AACzD,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,gBAAgB,EACvB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,cAAc,CAAC,SAAS,eAAe,EAAE,CAAC,CAAC,CA8BrD"}
@@ -0,0 +1,55 @@
1
+ import { previewPrices, priceSummary } from "./paddle.js";
2
+ //#region src/client/paddlePrices.ts
3
+ /**
4
+ * Quote every named plan, or refuse.
5
+ *
6
+ * One `PricePreview` call for the whole set, because it is one round trip and Paddle answers a line per
7
+ * item. A plan Paddle returned no line for is left out rather than quoted from another plan's line — the
8
+ * caller sees a plan missing, which its own markup already has a sentence for, instead of two plans
9
+ * showing one price.
10
+ *
11
+ * **No plans means no network.** An unconfigured page must cost a visitor nothing, and `PricePreview`
12
+ * with an empty `items` is a request Paddle refuses anyway.
13
+ *
14
+ * **One price is asked for once, however many plans name it.** A pricing table with a highlighted row
15
+ * points two plans at one price often enough; asking for it twice is redundant at best, and whether
16
+ * Paddle tolerates a repeated `priceId` is not a thing to find out in production — a refusal there takes
17
+ * the whole table down to its placeholders, not just the duplicated row. Both plans still resolve, off
18
+ * the one line, because a plan is matched to its line by id.
19
+ */
20
+ async function quotePlans(setup, plans, options) {
21
+ const named = Object.entries(plans);
22
+ if (named.length === 0) return {
23
+ ok: true,
24
+ value: []
25
+ };
26
+ const asked = [...new Set(named.map(([, priceId]) => priceId))];
27
+ const preview = await previewPrices(setup, {
28
+ ...options?.query,
29
+ items: asked.map((priceId) => ({
30
+ priceId,
31
+ quantity: 1
32
+ }))
33
+ }, options);
34
+ if (!preview.ok) return preview;
35
+ const quotes = [];
36
+ for (const [plan, priceId] of named) {
37
+ const line = preview.value.lines.find((candidate) => candidate.priceId === priceId);
38
+ if (line === void 0) continue;
39
+ const summary = priceSummary(preview.value, line, { wholeUnits: options?.wholeUnits });
40
+ quotes.push({
41
+ plan,
42
+ priceId,
43
+ headline: summary.headline,
44
+ note: summary.note,
45
+ estimated: summary.estimated,
46
+ currency: preview.value.currencyCode
47
+ });
48
+ }
49
+ return {
50
+ ok: true,
51
+ value: quotes
52
+ };
53
+ }
54
+ //#endregion
55
+ export { quotePlans };
@@ -0,0 +1,127 @@
1
+ import type { PaymentsFailure, PaymentsResult } from "./api";
2
+ import type { PaddleSetup } from "./paddle";
3
+ import { type PaddleCacheStore, type PaddleQuoteCache } from "./paddleCache";
4
+ import { type PaddlePlanPrices, type PaddlePlanQuote, type PaddleQuoteOptions, type PaddleQuoteQuery } from "./paddlePrices";
5
+ /**
6
+ * The script tag as configuration, for a site with no build step.
7
+ *
8
+ * A static site loads one classic script and gets prices. It cannot import a module, it has no bundler,
9
+ * and it must not carry a price id in its markup — an id belongs to one Paddle account, so it is
10
+ * environment-specific and a page that names one is a page that quotes the wrong account the day the
11
+ * account changes. So the ids arrive on the tag, where whoever deploys the site puts them, and the page
12
+ * itself names only plans.
13
+ */
14
+ /** The tag names no account, or is still carrying the placeholders it was scaffolded with. */
15
+ export declare const PADDLE_PRICES_NOT_CONFIGURED: PaymentsFailure;
16
+ /** The slice of a script element this reads, declared structurally for the reason `./checkout` gives. */
17
+ export interface PaddlePricesTag {
18
+ /** Every attribute on the tag, so the `data-paddle-price-*` set can be enumerated rather than guessed. */
19
+ getAttributeNames(): readonly string[];
20
+ /** One attribute's value, or null. */
21
+ getAttribute(name: string): string | null;
22
+ }
23
+ /** What a configured tag says. */
24
+ export interface PaddlePricesTagConfig {
25
+ /** Which Paddle account answers, and with which publishable token. */
26
+ readonly setup: PaddleSetup;
27
+ /** Plan name to price id, one entry per `data-paddle-price-*` attribute. */
28
+ readonly plans: PaddlePlanPrices;
29
+ /** Whether to write the totals into the page, or only to hand them to whoever asked. */
30
+ readonly paint: boolean;
31
+ /**
32
+ * Whether the page asked for a zero fraction to be dropped from each figure — `$6.00` as `$6`.
33
+ *
34
+ * False unless the tag said `on`, and false for any other value. A seller who prices in whole numbers
35
+ * is the one who knows it, and a mistyped attribute leaves every figure exactly as Paddle rendered it,
36
+ * which is the safe half of the two. See `./wholeUnits`.
37
+ */
38
+ readonly wholeUnits: boolean;
39
+ /** Who to quote for. Empty unless the tag named a customer, which is a visitor Paddle knows. */
40
+ readonly query: PaddleQuoteQuery;
41
+ /** Where a quote may rest, or null — which is every tag that did not ask for a cache, and every tag
42
+ * that asked for half of one. */
43
+ readonly cache: PaddleQuoteCache | null;
44
+ }
45
+ /**
46
+ * The two stores a script tag can name, injectable so a suite can look inside one.
47
+ *
48
+ * A tag cannot hand over an object, so it names a store rather than passing one — `local` or `session`,
49
+ * the only two a browser has. Everywhere else in this kit the caller passes the store itself, and that
50
+ * stays true: this is the one surface where the caller is HTML.
51
+ */
52
+ export interface PricesCacheStores {
53
+ /** What `data-paddle-cache-store="local"` resolves to. Defaults to `globalThis.localStorage`. */
54
+ readonly local?: PaddleCacheStore | null;
55
+ /** What `data-paddle-cache-store="session"` resolves to. Defaults to `globalThis.sessionStorage`. */
56
+ readonly session?: PaddleCacheStore | null;
57
+ }
58
+ /**
59
+ * Read a tag's configuration, or refuse it.
60
+ *
61
+ * **Refusal is the whole point of this function, and it is why the shapes are checked rather than
62
+ * trusted.** A site is deployed with the placeholders still in it far more often than anyone plans to:
63
+ * the live account is opened weeks after the sandbox one, and the tag ships carrying
64
+ * `REPLACE_WITH_LIVE_CLIENT_TOKEN` in the meantime. Handing that to Paddle produces a refused
65
+ * initialization, a console warning nobody is watching, and — because a page that has already blanked
66
+ * its own sentence has nothing left to fall back to — an empty price slot that looks deliberate. That is
67
+ * `#416` arriving by a second road.
68
+ *
69
+ * So an unconfigured tag is not an error and not a quote. It is null, and a null tag paints nothing, so
70
+ * the sentence the page shipped with is still standing. **All or nothing across the plans**: one plan
71
+ * still on a placeholder refuses the tag rather than quoting the others, because a pricing table with
72
+ * one real figure and one placeholder is the version a reader believes.
73
+ *
74
+ * **The token is checked against the environment beside it, not merely for a prefix.** The half-updated
75
+ * deploy above has a second shape: the environment is switched to `production` and the token below it is
76
+ * still the sandbox one. Paddle refuses that pairing itself, eventually — after the page has fetched
77
+ * Paddle.js and spent a round trip finding out. Refusing it here is what makes "no request" true of
78
+ * every misconfigured tag rather than of most of them.
79
+ */
80
+ export declare function readPaddlePricesTag(tag: PaddlePricesTag | null, stores?: PricesCacheStores): PaddlePricesTagConfig | null;
81
+ /** What {@link mountPrices} lets a caller replace, plus the stores a tag may name. */
82
+ export interface MountPricesOptions extends PaddleQuoteOptions {
83
+ /** What `data-paddle-cache-store` resolves to. Defaults to the browser's own two. */
84
+ readonly stores?: PricesCacheStores;
85
+ }
86
+ /** The slice of a plan slot this writes. */
87
+ export interface PricesPlanNode {
88
+ /** Which plan the slot is for. */
89
+ getAttribute(name: string): string | null;
90
+ /** The sentence in the slot — the page's own until a quote replaces it. */
91
+ textContent: string | null;
92
+ }
93
+ /** The slice of `document` this reaches, as an injectable seam. */
94
+ export interface PricesDocument {
95
+ /** Whether the page is still being parsed, so the slots to paint may not all exist yet. */
96
+ readyState: string;
97
+ /** How the paint waits for the rest of the page. */
98
+ addEventListener(type: string, listener: () => void, options?: {
99
+ once?: boolean;
100
+ }): void;
101
+ /** Every plan slot on the page. */
102
+ querySelectorAll(selectors: string): ArrayLike<PricesPlanNode>;
103
+ }
104
+ /**
105
+ * Write each quote into the slot that named its plan, and the sentence that makes it true beside it.
106
+ *
107
+ * **The headline alone is not the price, and a page that shows only the headline is the defect the quote
108
+ * path exists to avoid.** Where tax is added on top — the United States convention — the headline is the
109
+ * subtotal and the buyer is charged more; where no postal code resolved, Paddle returns 0% tax and the
110
+ * card is charged up to 15% above the figure. `priceSummary` returns a sentence for each of those cases,
111
+ * and this puts it in `[data-price-note="<plan>"]`. A page quoting a tax-added price wants that slot.
112
+ *
113
+ * **A slot no quote names is left exactly as it was**, and so is a note slot for a quote with nothing to
114
+ * say. A pricing page ships a true sentence in every slot — "Priced where you are billed" — precisely so
115
+ * that a plan which cannot be quoted still says something honest. Blanking it, or writing `undefined`
116
+ * into it, replaces a true sentence with a worse one; leaving it is the whole reason it is there.
117
+ */
118
+ export declare function paintPlanQuotes(document: PricesDocument, quotes: readonly PaddlePlanQuote[]): void;
119
+ /**
120
+ * Read the tag, quote its plans, and — unless the page said it paints itself — put the figures on it.
121
+ *
122
+ * The one entry point the browser build calls, and the one place the three halves meet: configuration
123
+ * off the tag, the quote from `./prices`, and the page. It answers with the result rather than swallowing
124
+ * it, so a page that keeps its own cache and its own formatting can have the same answer this painted.
125
+ */
126
+ export declare function mountPrices(document: PricesDocument, tag: PaddlePricesTag | null, options?: MountPricesOptions): Promise<PaymentsResult<readonly PaddlePlanQuote[]>>;
127
+ //# sourceMappingURL=paddlePricesTag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paddlePricesTag.d.ts","sourceRoot":"","sources":["../../src/client/paddlePricesTag.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAkB,MAAM,eAAe,CAAC;AAC7F,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAEtB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;GAQG;AAEH,8FAA8F;AAC9F,eAAO,MAAM,4BAA4B,EAAE,eAK1C,CAAC;AAEF,yGAAyG;AACzG,MAAM,WAAW,eAAe;IAC9B,0GAA0G;IAC1G,iBAAiB,IAAI,SAAS,MAAM,EAAE,CAAC;IACvC,sCAAsC;IACtC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED,kCAAkC;AAClC,MAAM,WAAW,qBAAqB;IACpC,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,wFAAwF;IACxF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,gGAAgG;IAChG,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC;qCACiC;IACjC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACzC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,iGAAiG;IACjG,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACzC,qGAAqG;IACrG,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAC5C;AAmED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,eAAe,GAAG,IAAI,EAC3B,MAAM,CAAC,EAAE,iBAAiB,GACzB,qBAAqB,GAAG,IAAI,CAwC9B;AAED,sFAAsF;AACtF,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,qFAAqF;IACrF,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;CACrC;AAED,4CAA4C;AAC5C,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC1C,2EAA2E;IAC3E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC7B,2FAA2F;IAC3F,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACzF,mCAAmC;IACnC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;CAChE;AAqBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,IAAI,CAalG;AAUD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,cAAc,EACxB,GAAG,EAAE,eAAe,GAAG,IAAI,EAC3B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,cAAc,CAAC,SAAS,eAAe,EAAE,CAAC,CAAC,CA+BrD"}
@@ -0,0 +1,207 @@
1
+ import { readQuoteCache } from "./paddleCache.js";
2
+ import { quotePlans } from "./paddlePrices.js";
3
+ //#region src/client/paddlePricesTag.ts
4
+ /**
5
+ * The script tag as configuration, for a site with no build step.
6
+ *
7
+ * A static site loads one classic script and gets prices. It cannot import a module, it has no bundler,
8
+ * and it must not carry a price id in its markup — an id belongs to one Paddle account, so it is
9
+ * environment-specific and a page that names one is a page that quotes the wrong account the day the
10
+ * account changes. So the ids arrive on the tag, where whoever deploys the site puts them, and the page
11
+ * itself names only plans.
12
+ */
13
+ /** The tag names no account, or is still carrying the placeholders it was scaffolded with. */
14
+ const PADDLE_PRICES_NOT_CONFIGURED = {
15
+ code: "client/paddle_prices_not_configured",
16
+ message: "Prices aren't available right now.",
17
+ action: "Set data-paddle-env, data-paddle-token and every data-paddle-price-<name> id on the paddle-prices script tag."
18
+ };
19
+ /** The prefix that marks an attribute as naming a plan. */
20
+ const PRICE_PREFIX = "data-paddle-price-";
21
+ /** The token prefix each Paddle account issues. Sandbox and live are separate accounts, not a flag. */
22
+ const CLIENT_TOKEN = {
23
+ sandbox: "test_",
24
+ production: "live_"
25
+ };
26
+ /** A real Paddle price. */
27
+ const PRICE_ID = /^pri_/;
28
+ /** A real Paddle customer. */
29
+ const CUSTOMER_ID = /^ctm_/;
30
+ /**
31
+ * One of the browser's own stores, or null where there is not one.
32
+ *
33
+ * Guarded rather than read, because reaching for `localStorage` **throws** where a browser has storage
34
+ * switched off or a sandboxed frame denies it — a page that quotes prices would take that exception on
35
+ * the way to asking Paddle a question it could have asked anyway.
36
+ */
37
+ function browserStore(name) {
38
+ try {
39
+ return globalThis[name] ?? null;
40
+ } catch {
41
+ return null;
42
+ }
43
+ }
44
+ /**
45
+ * The store a tag named, the **name** it gave when nothing resolved, or null when it named nothing.
46
+ *
47
+ * The three are different and used to be two. `data-paddle-cache-store="localStorage"` is the likely
48
+ * typo — the accepted value is `local` — and collapsing it into the same null a bare tag produces made
49
+ * it the one misconfiguration that got no console line, because "did anybody ask for a cache?" had
50
+ * nothing left to see. Handing the name back is what makes an unresolvable store an answer.
51
+ *
52
+ * An injected `null` is honored as an answer too: `PricesCacheStores` says `PaddleCacheStore | null`,
53
+ * so null means *this environment has none* — a suite saying so, or an adopter's SSR-safe wrapper — and
54
+ * quietly resolving the browser's real store instead would exercise the opposite path from the one the
55
+ * caller named.
56
+ */
57
+ function storeNamed(named, stores) {
58
+ if (named === "local") return stores?.local !== void 0 ? stores.local : browserStore("localStorage") ?? named;
59
+ if (named === "session") return stores?.session !== void 0 ? stores.session : browserStore("sessionStorage") ?? named;
60
+ return named;
61
+ }
62
+ /**
63
+ * A lifetime in seconds, as milliseconds.
64
+ *
65
+ * Seconds on the attribute because a tag is HTML and HTML counts a cache in seconds — `max-age`, and
66
+ * every header that copied it. `NaN` rather than null for text that is not a number, so a tag that
67
+ * tried to state a lifetime and failed is a warning rather than a silence.
68
+ */
69
+ function lifetime(value) {
70
+ if (value === null) return null;
71
+ const seconds = Number(value);
72
+ return Number.isFinite(seconds) ? seconds * 1e3 : NaN;
73
+ }
74
+ /**
75
+ * Read a tag's configuration, or refuse it.
76
+ *
77
+ * **Refusal is the whole point of this function, and it is why the shapes are checked rather than
78
+ * trusted.** A site is deployed with the placeholders still in it far more often than anyone plans to:
79
+ * the live account is opened weeks after the sandbox one, and the tag ships carrying
80
+ * `REPLACE_WITH_LIVE_CLIENT_TOKEN` in the meantime. Handing that to Paddle produces a refused
81
+ * initialization, a console warning nobody is watching, and — because a page that has already blanked
82
+ * its own sentence has nothing left to fall back to — an empty price slot that looks deliberate. That is
83
+ * `#416` arriving by a second road.
84
+ *
85
+ * So an unconfigured tag is not an error and not a quote. It is null, and a null tag paints nothing, so
86
+ * the sentence the page shipped with is still standing. **All or nothing across the plans**: one plan
87
+ * still on a placeholder refuses the tag rather than quoting the others, because a pricing table with
88
+ * one real figure and one placeholder is the version a reader believes.
89
+ *
90
+ * **The token is checked against the environment beside it, not merely for a prefix.** The half-updated
91
+ * deploy above has a second shape: the environment is switched to `production` and the token below it is
92
+ * still the sandbox one. Paddle refuses that pairing itself, eventually — after the page has fetched
93
+ * Paddle.js and spent a round trip finding out. Refusing it here is what makes "no request" true of
94
+ * every misconfigured tag rather than of most of them.
95
+ */
96
+ function readPaddlePricesTag(tag, stores) {
97
+ if (tag === null) return null;
98
+ const environment = tag.getAttribute("data-paddle-env");
99
+ if (environment !== "sandbox" && environment !== "production") return null;
100
+ const clientToken = tag.getAttribute("data-paddle-token");
101
+ if (clientToken === null || !clientToken.startsWith(CLIENT_TOKEN[environment])) return null;
102
+ const plans = {};
103
+ for (const name of tag.getAttributeNames()) {
104
+ if (!name.startsWith(PRICE_PREFIX)) continue;
105
+ const priceId = tag.getAttribute(name);
106
+ if (priceId === null || !PRICE_ID.test(priceId)) return null;
107
+ plans[name.slice(18)] = priceId;
108
+ }
109
+ if (Object.keys(plans).length === 0) return null;
110
+ const named = tag.getAttribute("data-paddle-customer")?.trim() ?? "";
111
+ const query = CUSTOMER_ID.test(named) ? { customerId: named } : {};
112
+ const cache = readQuoteCache({
113
+ key: tag.getAttribute("data-paddle-cache"),
114
+ store: storeNamed(tag.getAttribute("data-paddle-cache-store"), stores),
115
+ ttlMs: lifetime(tag.getAttribute("data-paddle-cache-ttl"))
116
+ });
117
+ return {
118
+ setup: {
119
+ clientToken,
120
+ environment
121
+ },
122
+ plans,
123
+ paint: tag.getAttribute("data-paddle-paint") !== "off",
124
+ wholeUnits: tag.getAttribute("data-paddle-whole-units") === "on",
125
+ query,
126
+ cache
127
+ };
128
+ }
129
+ /** The attribute a page marks a plan slot with. */
130
+ const PLAN_SLOT = "data-price-plan";
131
+ /** The attribute a page marks the sentence beside a figure with. */
132
+ const NOTE_SLOT = "data-price-note";
133
+ /**
134
+ * Match a plan named on the tag to a plan named in the markup.
135
+ *
136
+ * Case-insensitively, and that is forced rather than lenient. A plan arrives on the tag as part of an
137
+ * *attribute name* — `data-paddle-price-teamPlus` — and HTML lower-cases those, so the tag can only ever say
138
+ * `teamplus`. In the markup the same plan is an attribute *value*, `data-price-plan="teamPlus"`, which
139
+ * keeps its case. Matching exactly would leave that slot on its placeholder with nothing anywhere saying
140
+ * why.
141
+ */
142
+ function samePlan(named, quoted) {
143
+ return named !== null && named.toLowerCase() === quoted.toLowerCase();
144
+ }
145
+ /**
146
+ * Write each quote into the slot that named its plan, and the sentence that makes it true beside it.
147
+ *
148
+ * **The headline alone is not the price, and a page that shows only the headline is the defect the quote
149
+ * path exists to avoid.** Where tax is added on top — the United States convention — the headline is the
150
+ * subtotal and the buyer is charged more; where no postal code resolved, Paddle returns 0% tax and the
151
+ * card is charged up to 15% above the figure. `priceSummary` returns a sentence for each of those cases,
152
+ * and this puts it in `[data-price-note="<plan>"]`. A page quoting a tax-added price wants that slot.
153
+ *
154
+ * **A slot no quote names is left exactly as it was**, and so is a note slot for a quote with nothing to
155
+ * say. A pricing page ships a true sentence in every slot — "Priced where you are billed" — precisely so
156
+ * that a plan which cannot be quoted still says something honest. Blanking it, or writing `undefined`
157
+ * into it, replaces a true sentence with a worse one; leaving it is the whole reason it is there.
158
+ */
159
+ function paintPlanQuotes(document, quotes) {
160
+ for (const slot of Array.from(document.querySelectorAll(`[${PLAN_SLOT}]`))) {
161
+ const quote = quotes.find((candidate) => samePlan(slot.getAttribute(PLAN_SLOT), candidate.plan));
162
+ if (quote === void 0) continue;
163
+ slot.textContent = quote.headline;
164
+ }
165
+ for (const slot of Array.from(document.querySelectorAll(`[${NOTE_SLOT}]`))) {
166
+ const quote = quotes.find((candidate) => samePlan(slot.getAttribute(NOTE_SLOT), candidate.plan));
167
+ if (quote === void 0 || quote.note === null) continue;
168
+ slot.textContent = quote.note;
169
+ }
170
+ }
171
+ /** Resolve once the page has the slots this paints into. */
172
+ function parsed(document) {
173
+ if (document.readyState !== "loading") return Promise.resolve();
174
+ return new Promise((resolve) => {
175
+ document.addEventListener("DOMContentLoaded", () => resolve(), { once: true });
176
+ });
177
+ }
178
+ /**
179
+ * Read the tag, quote its plans, and — unless the page said it paints itself — put the figures on it.
180
+ *
181
+ * The one entry point the browser build calls, and the one place the three halves meet: configuration
182
+ * off the tag, the quote from `./prices`, and the page. It answers with the result rather than swallowing
183
+ * it, so a page that keeps its own cache and its own formatting can have the same answer this painted.
184
+ */
185
+ async function mountPrices(document, tag, options) {
186
+ const { stores, ...given } = options ?? {};
187
+ const config = readPaddlePricesTag(tag, stores);
188
+ if (config === null) return {
189
+ ok: false,
190
+ failure: PADDLE_PRICES_NOT_CONFIGURED
191
+ };
192
+ const quoted = await quotePlans(config.setup, config.plans, {
193
+ ...given,
194
+ query: {
195
+ ...config.query,
196
+ ...given.query
197
+ },
198
+ cache: given.cache ?? config.cache ?? void 0,
199
+ wholeUnits: given.wholeUnits ?? config.wholeUnits
200
+ });
201
+ if (!quoted.ok || !config.paint) return quoted;
202
+ await parsed(document);
203
+ paintPlanQuotes(document, quoted.value);
204
+ return quoted;
205
+ }
206
+ //#endregion
207
+ export { PADDLE_PRICES_NOT_CONFIGURED, mountPrices, paintPlanQuotes, readPaddlePricesTag };
@@ -0,0 +1,128 @@
1
+ /**
2
+ * One product, browser-safe — an element of {@link PaymentsClientProjection}'s catalog.
3
+ *
4
+ * Declared as its own type because the element type is the half a value-derived shape loses first: a
5
+ * catalog of one product infers one product's shape, and every branch the next product would have taken
6
+ * — an empty `entitlements`, a SKU on a rail the first product does not sell — is simply not in it.
7
+ *
8
+ * **It is annotated on the `.map` callback, not on the array it builds.** Measured, and the difference
9
+ * matters: `const products: PaymentsClientProduct[] = …map(…)` type-checks the *result*, by which point
10
+ * the element literals are no longer fresh, so a product that grew an `apple` SKU passed silently. On the
11
+ * callback's own return type the literal is checked where it is written, and the store-only field is a
12
+ * compile error at the line that added it.
13
+ */
14
+ export type PaymentsClientProduct = {
15
+ /** The logical product id — what `/payments/checkout` is asked for. */
16
+ id: string;
17
+ /** What kind of product it is. */
18
+ type: "consumable" | "non_consumable" | "subscription";
19
+ /** The entitlement keys it grants. Gating code names these, never the product. */
20
+ entitlements: string[];
21
+ /** The display name a paywall renders. */
22
+ name: string;
23
+ /**
24
+ * This product's SKU on each web rail, or null where it is not sold. Keyed by rail rather than one
25
+ * field per rail, so a screen asks `skus[rail]` and a new rail cannot leave a `purchasable()` check
26
+ * silently out of date. Every id here is publishable by design — each is what a checkout names.
27
+ *
28
+ * Apple's and Google's product ids are deliberately absent: a browser cannot open either store.
29
+ */
30
+ skus: {
31
+ /** The Stripe price id. */
32
+ stripe: string | null;
33
+ /** The Lemon Squeezy variant id. */
34
+ lemonSqueezy: string | null;
35
+ /** The Paddle price id. */
36
+ paddle: string | null;
37
+ };
38
+ };
39
+ /**
40
+ * What a browser may know about this project's payments — the shape of `virtual:pithy/payments`.
41
+ *
42
+ * **This declaration is the contract, and the projection is checked against it.** It is written here
43
+ * rather than inferred from the closure that builds it, and that is the whole point: an inferred type
44
+ * follows whatever the producer last happened to say, so a projection that dropped `basePath`, or that
45
+ * widened `type` because `PaymentsConfig` learned a fourth product kind, or that started passing a
46
+ * product's Apple id through, would take the type with it and nothing would go red. Declared, the
47
+ * function is the thing that has to change — every widening of what a browser sees is decided here.
48
+ *
49
+ * Nothing sensitive is in reach of the producer to begin with: Apple's issuer key, Google's service
50
+ * account, and Stripe's secret and signing keys live in the secrets store behind
51
+ * `paymentsSecretsRegistry`, not in the config the closure can see. What this type covers is the rest of
52
+ * the catalog — the `grants` block and the store-only SKUs, which are omissions of judgment rather than
53
+ * of reach, and so are the ones worth writing down.
54
+ *
55
+ * **`billingSubject` is a third omission of judgment, and it is deliberate.** The subject *id* obviously
56
+ * never crosses — it is a fact about one caller, and this projection is inlined into a bundle every caller
57
+ * receives, so there is no request here to be right about. But the mode is not a secret and is left out
58
+ * anyway, on the plainer ground that nothing in a browser can use it. A paywall renders products and buy
59
+ * buttons; who holds what it buys is decided on the server, on the request, by the subject seam, and a
60
+ * screen that branched on the mode would be a second copy of that decision drifting from the first. The
61
+ * shape is also not free: this type is what `@pithy-sh/vite` generates `templates/client-env.d.ts` from, so
62
+ * a key added here is a key added to every adopter's ambient declaration. It goes in the day something in
63
+ * a browser genuinely cannot be written without it, and not before.
64
+ *
65
+ * **This is the only statement of the shape.** `@pithy-sh/ui-react`'s `templates/client-env.d.ts` — the
66
+ * ambient declaration `pithy ui add react` copies into an adopter's Worker — is generated from this type
67
+ * by `@pithy-sh/vite`'s `clientEnvDeclaration.ts` (#398). The unions and the per-field doc comments below
68
+ * are emitted verbatim, so what is written here is what a screen author reads.
69
+ */
70
+ export type PaymentsClientProjection = {
71
+ /**
72
+ * Payments is not composed, or has no catalog this environment can render. Both read the same on
73
+ * purpose: "composed with nothing to sell" is a paywall with nothing on it, exactly like "not
74
+ * composed", and a screen branches on one value rather than guarding.
75
+ */
76
+ enabled: false;
77
+ } | {
78
+ /** Payments is composed AND has a catalog this environment can render. */
79
+ enabled: true;
80
+ /** The environment this bundle was built for. */
81
+ environment: string;
82
+ /**
83
+ * Which rails this project sells through. Apple and Google are display-only on the web — a
84
+ * paywall shows such a product as owned-elsewhere rather than offering a buy button nothing on
85
+ * the web can honor.
86
+ */
87
+ rails: {
88
+ /** Whether the App Store rail is on. Display-only in a browser. */
89
+ apple: boolean;
90
+ /** Whether the Play Store rail is on. Display-only in a browser. */
91
+ google: boolean;
92
+ /** Whether the Stripe rail is on. */
93
+ stripe: boolean;
94
+ /** Whether the Lemon Squeezy rail is on. */
95
+ lemonSqueezy: boolean;
96
+ /** Whether the Paddle rail is on. */
97
+ paddle: boolean;
98
+ };
99
+ /**
100
+ * What Paddle.js needs to initialize, or null when the rail is off. The client token is
101
+ * publishable by design — it is what a browser opens a checkout with — and the API key and the
102
+ * webhook signing secret are neither here nor expressible here.
103
+ */
104
+ paddle: {
105
+ /** The publishable client token Paddle.js initializes with. */
106
+ clientToken: string;
107
+ /** Which Paddle account the token belongs to. */
108
+ environment: "sandbox" | "production";
109
+ /**
110
+ * How checkout is presented: `overlay` opens Paddle.js over your own page, `inline` renders it
111
+ * into a container the screen provides, `hosted` redirects to Paddle's own page.
112
+ *
113
+ * The union is stated, not `string`. A screen switches on this to decide whether to render a
114
+ * container at all, and the exhaustiveness is the point. It was the one field the hand-written
115
+ * `templates/client-env.d.ts` widened, and generating that file from here is what closed it.
116
+ */
117
+ checkout: "overlay" | "inline" | "hosted";
118
+ } | null;
119
+ /** Where the payments routes mount, e.g. `/payments`. */
120
+ basePath: string;
121
+ /**
122
+ * The catalog, browser-safe, in the order the adopter wrote it. A web rail's price id is
123
+ * publishable by design — a checkout names one. Apple's and Google's SKUs, and anything a
124
+ * purchase fulfills beyond its entitlements, stay server-side.
125
+ */
126
+ products: PaymentsClientProduct[];
127
+ };
128
+ //# sourceMappingURL=projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/client/projection.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,EAAE,YAAY,GAAG,gBAAgB,GAAG,cAAc,CAAC;IACvD,kFAAkF;IAClF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,IAAI,EAAE;QACJ,2BAA2B;QAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,oCAAoC;QACpC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,2BAA2B;QAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,CAAC;CACH,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,MAAM,wBAAwB,GAChC;IACE;;;;OAIG;IACH,OAAO,EAAE,KAAK,CAAC;CAChB,GACD;IACE,0EAA0E;IAC1E,OAAO,EAAE,IAAI,CAAC;IACd,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,KAAK,EAAE;QACL,mEAAmE;QACnE,KAAK,EAAE,OAAO,CAAC;QACf,oEAAoE;QACpE,MAAM,EAAE,OAAO,CAAC;QAChB,qCAAqC;QACrC,MAAM,EAAE,OAAO,CAAC;QAChB,4CAA4C;QAC5C,YAAY,EAAE,OAAO,CAAC;QACtB,qCAAqC;QACrC,MAAM,EAAE,OAAO,CAAC;KACjB,CAAC;IACF;;;;OAIG;IACH,MAAM,EAAE;QACN,+DAA+D;QAC/D,WAAW,EAAE,MAAM,CAAC;QACpB,iDAAiD;QACjD,WAAW,EAAE,SAAS,GAAG,YAAY,CAAC;QACtC;;;;;;;WAOG;QACH,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;KAC3C,GAAG,IAAI,CAAC;IACT,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,EAAE,qBAAqB,EAAE,CAAC;CACnC,CAAC"}
File without changes
@@ -0,0 +1,18 @@
1
+ import type { PaddleCacheStore } from "../paddleCache";
2
+ /**
3
+ * A {@link PaddleCacheStore} a test can look inside.
4
+ *
5
+ * `localStorage` is the store an adopter passes and the wrong one to test against: a suite that reached
6
+ * for it would need a DOM, would leak entries between tests, and could not answer "what is in there now"
7
+ * without re-deriving the key the module chose. This is a `Map`, and the `Map` is exposed — so a test can
8
+ * assert an entry was written, corrupt one to see what happens next, or count what a run left behind.
9
+ *
10
+ * It enumerates, because `Storage` does: `length` and `key` are what a sweep walks, and a stand-in
11
+ * missing them would quietly exercise the un-swept path on every test that thought it was testing one.
12
+ */
13
+ export declare function memoryStore(): PaddleCacheStore & {
14
+ entries: Map<string, string>;
15
+ };
16
+ /** A store that refuses everything — Safari in private browsing, and a quota that is full. */
17
+ export declare function refusingStore(): PaddleCacheStore;
18
+ //# sourceMappingURL=cacheStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cacheStore.d.ts","sourceRoot":"","sources":["../../../src/client/test-utils/cacheStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,IAAI,gBAAgB,GAAG;IAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAgBjF;AAED,8FAA8F;AAC9F,wBAAgB,aAAa,IAAI,gBAAgB,CAKhD"}