@owlmeans/server-payment 0.1.18-rc.8 → 0.1.18

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 (537) hide show
  1. package/README.md +157 -26
  2. package/agent-meta/manifest.json +30 -4
  3. package/agent-meta/skills/server-payment/SKILL.md +613 -54
  4. package/agent-meta/skills/server-payment/parts/reference.md +174 -0
  5. package/build/access/types.d.ts +46 -0
  6. package/build/access/types.d.ts.map +1 -0
  7. package/build/access/types.js +2 -0
  8. package/build/access/types.js.map +1 -0
  9. package/build/access.d.ts +6 -0
  10. package/build/access.d.ts.map +1 -0
  11. package/build/access.js +45 -0
  12. package/build/access.js.map +1 -0
  13. package/build/actions/index.d.ts +1 -0
  14. package/build/actions/index.d.ts.map +1 -1
  15. package/build/actions/index.js +1 -0
  16. package/build/actions/index.js.map +1 -1
  17. package/build/actions/resync-subscriptions.d.ts +3 -0
  18. package/build/actions/resync-subscriptions.d.ts.map +1 -0
  19. package/build/actions/resync-subscriptions.js +7 -0
  20. package/build/actions/resync-subscriptions.js.map +1 -0
  21. package/build/actions/resync.d.ts +6 -1
  22. package/build/actions/resync.d.ts.map +1 -1
  23. package/build/actions/resync.js +15 -5
  24. package/build/actions/resync.js.map +1 -1
  25. package/build/actions/webhook.d.ts +2 -1
  26. package/build/actions/webhook.d.ts.map +1 -1
  27. package/build/actions/webhook.js +10 -4
  28. package/build/actions/webhook.js.map +1 -1
  29. package/build/bootstrap/types.d.ts +16 -0
  30. package/build/bootstrap/types.d.ts.map +1 -0
  31. package/build/bootstrap/types.js +2 -0
  32. package/build/bootstrap/types.js.map +1 -0
  33. package/build/bootstrap.d.ts +6 -0
  34. package/build/bootstrap.d.ts.map +1 -0
  35. package/build/bootstrap.js +26 -0
  36. package/build/bootstrap.js.map +1 -0
  37. package/build/catalogue/types.d.ts +38 -0
  38. package/build/catalogue/types.d.ts.map +1 -0
  39. package/build/catalogue/types.js +2 -0
  40. package/build/catalogue/types.js.map +1 -0
  41. package/build/catalogue.d.ts +6 -0
  42. package/build/catalogue.d.ts.map +1 -0
  43. package/build/catalogue.js +110 -0
  44. package/build/catalogue.js.map +1 -0
  45. package/build/commit/types.d.ts +22 -0
  46. package/build/commit/types.d.ts.map +1 -0
  47. package/build/commit/types.js +2 -0
  48. package/build/commit/types.js.map +1 -0
  49. package/build/commit.d.ts +6 -0
  50. package/build/commit.d.ts.map +1 -0
  51. package/build/commit.js +125 -0
  52. package/build/commit.js.map +1 -0
  53. package/build/config.d.ts +44 -5
  54. package/build/config.d.ts.map +1 -1
  55. package/build/config.js +216 -10
  56. package/build/config.js.map +1 -1
  57. package/build/consts.d.ts +74 -16
  58. package/build/consts.d.ts.map +1 -1
  59. package/build/consts.js +86 -23
  60. package/build/consts.js.map +1 -1
  61. package/build/consts.local.d.ts +94 -0
  62. package/build/consts.local.d.ts.map +1 -0
  63. package/build/consts.local.js +44 -0
  64. package/build/consts.local.js.map +1 -0
  65. package/build/consumer/cancellation/types.d.ts +11 -0
  66. package/build/consumer/cancellation/types.d.ts.map +1 -0
  67. package/build/consumer/cancellation/types.js +2 -0
  68. package/build/consumer/cancellation/types.js.map +1 -0
  69. package/build/consumer/cancellation.d.ts +6 -0
  70. package/build/consumer/cancellation.d.ts.map +1 -0
  71. package/build/consumer/cancellation.js +33 -0
  72. package/build/consumer/cancellation.js.map +1 -0
  73. package/build/consumer/capture/types.d.ts +50 -0
  74. package/build/consumer/capture/types.d.ts.map +1 -0
  75. package/build/consumer/capture/types.js +2 -0
  76. package/build/consumer/capture/types.js.map +1 -0
  77. package/build/consumer/capture.d.ts +6 -0
  78. package/build/consumer/capture.d.ts.map +1 -0
  79. package/build/consumer/capture.js +284 -0
  80. package/build/consumer/capture.js.map +1 -0
  81. package/build/consumer/consts.local.d.ts +10 -0
  82. package/build/consumer/consts.local.d.ts.map +1 -0
  83. package/build/consumer/consts.local.js +11 -0
  84. package/build/consumer/consts.local.js.map +1 -0
  85. package/build/consumer/format/types.d.ts +30 -0
  86. package/build/consumer/format/types.d.ts.map +1 -0
  87. package/build/consumer/format/types.js +2 -0
  88. package/build/consumer/format/types.js.map +1 -0
  89. package/build/consumer/format.d.ts +4 -0
  90. package/build/consumer/format.d.ts.map +1 -0
  91. package/build/consumer/format.js +73 -0
  92. package/build/consumer/format.js.map +1 -0
  93. package/build/consumer/handlers.d.ts +21 -0
  94. package/build/consumer/handlers.d.ts.map +1 -0
  95. package/build/consumer/handlers.js +174 -0
  96. package/build/consumer/handlers.js.map +1 -0
  97. package/build/consumer/index.d.ts +10 -0
  98. package/build/consumer/index.d.ts.map +1 -0
  99. package/build/consumer/index.js +6 -0
  100. package/build/consumer/index.js.map +1 -0
  101. package/build/consumer/mail/types.d.ts +29 -0
  102. package/build/consumer/mail/types.d.ts.map +1 -0
  103. package/build/consumer/mail/types.js +2 -0
  104. package/build/consumer/mail/types.js.map +1 -0
  105. package/build/consumer/mail.d.ts +6 -0
  106. package/build/consumer/mail.d.ts.map +1 -0
  107. package/build/consumer/mail.js +313 -0
  108. package/build/consumer/mail.js.map +1 -0
  109. package/build/consumer/observers/types.d.ts +15 -0
  110. package/build/consumer/observers/types.d.ts.map +1 -0
  111. package/build/consumer/observers/types.js +2 -0
  112. package/build/consumer/observers/types.js.map +1 -0
  113. package/build/consumer/observers.d.ts +6 -0
  114. package/build/consumer/observers.d.ts.map +1 -0
  115. package/build/consumer/observers.js +74 -0
  116. package/build/consumer/observers.js.map +1 -0
  117. package/build/consumer/origin/types.d.ts +17 -0
  118. package/build/consumer/origin/types.d.ts.map +1 -0
  119. package/build/consumer/origin/types.js +2 -0
  120. package/build/consumer/origin/types.js.map +1 -0
  121. package/build/consumer/origin.d.ts +8 -0
  122. package/build/consumer/origin.d.ts.map +1 -0
  123. package/build/consumer/origin.js +43 -0
  124. package/build/consumer/origin.js.map +1 -0
  125. package/build/consumer/reconcile/types.d.ts +13 -0
  126. package/build/consumer/reconcile/types.d.ts.map +1 -0
  127. package/build/consumer/reconcile/types.js +2 -0
  128. package/build/consumer/reconcile/types.js.map +1 -0
  129. package/build/consumer/reconcile.d.ts +5 -0
  130. package/build/consumer/reconcile.d.ts.map +1 -0
  131. package/build/consumer/reconcile.js +320 -0
  132. package/build/consumer/reconcile.js.map +1 -0
  133. package/build/consumer/records/types.d.ts +66 -0
  134. package/build/consumer/records/types.d.ts.map +1 -0
  135. package/build/consumer/records/types.js +2 -0
  136. package/build/consumer/records/types.js.map +1 -0
  137. package/build/consumer/records.d.ts +6 -0
  138. package/build/consumer/records.d.ts.map +1 -0
  139. package/build/consumer/records.js +243 -0
  140. package/build/consumer/records.js.map +1 -0
  141. package/build/consumer/service.d.ts +28 -0
  142. package/build/consumer/service.d.ts.map +1 -0
  143. package/build/consumer/service.js +706 -0
  144. package/build/consumer/service.js.map +1 -0
  145. package/build/consumer/types.d.ts +84 -0
  146. package/build/consumer/types.d.ts.map +1 -0
  147. package/build/consumer/types.js +2 -0
  148. package/build/consumer/types.js.map +1 -0
  149. package/build/consumer/types.local.d.ts +26 -0
  150. package/build/consumer/types.local.d.ts.map +1 -0
  151. package/build/consumer/types.local.js +2 -0
  152. package/build/consumer/types.local.js.map +1 -0
  153. package/build/consumer/withdrawal/types.d.ts +36 -0
  154. package/build/consumer/withdrawal/types.d.ts.map +1 -0
  155. package/build/consumer/withdrawal/types.js +2 -0
  156. package/build/consumer/withdrawal/types.js.map +1 -0
  157. package/build/consumer/withdrawal.d.ts +6 -0
  158. package/build/consumer/withdrawal.d.ts.map +1 -0
  159. package/build/consumer/withdrawal.js +237 -0
  160. package/build/consumer/withdrawal.js.map +1 -0
  161. package/build/entitlement.d.ts +4 -0
  162. package/build/entitlement.d.ts.map +1 -0
  163. package/build/entitlement.js +72 -0
  164. package/build/entitlement.js.map +1 -0
  165. package/build/entrypoints.d.ts +19 -2
  166. package/build/entrypoints.d.ts.map +1 -1
  167. package/build/entrypoints.js +16 -4
  168. package/build/entrypoints.js.map +1 -1
  169. package/build/gate/request.d.ts +4 -0
  170. package/build/gate/request.d.ts.map +1 -0
  171. package/build/gate/request.js +17 -0
  172. package/build/gate/request.js.map +1 -0
  173. package/build/gate/types.d.ts +15 -0
  174. package/build/gate/types.d.ts.map +1 -0
  175. package/build/gate/types.js +2 -0
  176. package/build/gate/types.js.map +1 -0
  177. package/build/gate.d.ts +13 -9
  178. package/build/gate.d.ts.map +1 -1
  179. package/build/gate.js +36 -21
  180. package/build/gate.js.map +1 -1
  181. package/build/index.d.ts +50 -3
  182. package/build/index.d.ts.map +1 -1
  183. package/build/index.js +29 -3
  184. package/build/index.js.map +1 -1
  185. package/build/limit.d.ts +11 -0
  186. package/build/limit.d.ts.map +1 -0
  187. package/build/limit.js +48 -0
  188. package/build/limit.js.map +1 -0
  189. package/build/log.d.ts +3 -0
  190. package/build/log.d.ts.map +1 -0
  191. package/build/log.js +4 -0
  192. package/build/log.js.map +1 -0
  193. package/build/models/declarations/types.d.ts +22 -0
  194. package/build/models/declarations/types.d.ts.map +1 -0
  195. package/build/models/declarations/types.js +2 -0
  196. package/build/models/declarations/types.js.map +1 -0
  197. package/build/models/declarations.d.ts +4 -0
  198. package/build/models/declarations.d.ts.map +1 -0
  199. package/build/models/declarations.js +26 -0
  200. package/build/models/declarations.js.map +1 -0
  201. package/build/models/purchase/types.d.ts +13 -0
  202. package/build/models/purchase/types.d.ts.map +1 -0
  203. package/build/models/purchase/types.js +2 -0
  204. package/build/models/purchase/types.js.map +1 -0
  205. package/build/models/purchase.d.ts +4 -0
  206. package/build/models/purchase.d.ts.map +1 -0
  207. package/build/models/purchase.js +37 -0
  208. package/build/models/purchase.js.map +1 -0
  209. package/build/observer.d.ts +9 -0
  210. package/build/observer.d.ts.map +1 -1
  211. package/build/observer.js +38 -12
  212. package/build/observer.js.map +1 -1
  213. package/build/plan/types.d.ts +21 -0
  214. package/build/plan/types.d.ts.map +1 -0
  215. package/build/plan/types.js +2 -0
  216. package/build/plan/types.js.map +1 -0
  217. package/build/plan.d.ts +7 -0
  218. package/build/plan.d.ts.map +1 -0
  219. package/build/plan.js +29 -0
  220. package/build/plan.js.map +1 -0
  221. package/build/plugins/checkout-plugins/types.d.ts +25 -0
  222. package/build/plugins/checkout-plugins/types.d.ts.map +1 -0
  223. package/build/plugins/checkout-plugins/types.js +2 -0
  224. package/build/plugins/checkout-plugins/types.js.map +1 -0
  225. package/build/plugins/checkout-plugins.d.ts +12 -0
  226. package/build/plugins/checkout-plugins.d.ts.map +1 -0
  227. package/build/plugins/checkout-plugins.js +72 -0
  228. package/build/plugins/checkout-plugins.js.map +1 -0
  229. package/build/plugins/checkout-policy/types.d.ts +18 -0
  230. package/build/plugins/checkout-policy/types.d.ts.map +1 -0
  231. package/build/plugins/checkout-policy/types.js +2 -0
  232. package/build/plugins/checkout-policy/types.js.map +1 -0
  233. package/build/plugins/checkout-policy.d.ts +4 -0
  234. package/build/plugins/checkout-policy.d.ts.map +1 -0
  235. package/build/plugins/checkout-policy.js +26 -0
  236. package/build/plugins/checkout-policy.js.map +1 -0
  237. package/build/plugins/checkout-registry/types.d.ts +7 -0
  238. package/build/plugins/checkout-registry/types.d.ts.map +1 -0
  239. package/build/plugins/checkout-registry/types.js +2 -0
  240. package/build/plugins/checkout-registry/types.js.map +1 -0
  241. package/build/plugins/checkout-registry.d.ts +8 -0
  242. package/build/plugins/checkout-registry.d.ts.map +1 -0
  243. package/build/plugins/checkout-registry.js +21 -0
  244. package/build/plugins/checkout-registry.js.map +1 -0
  245. package/build/plugins/consts.local.d.ts +13 -0
  246. package/build/plugins/consts.local.d.ts.map +1 -0
  247. package/build/plugins/consts.local.js +22 -0
  248. package/build/plugins/consts.local.js.map +1 -0
  249. package/build/plugins/customer-lock/types.d.ts +6 -0
  250. package/build/plugins/customer-lock/types.d.ts.map +1 -0
  251. package/build/plugins/customer-lock/types.js +2 -0
  252. package/build/plugins/customer-lock/types.js.map +1 -0
  253. package/build/plugins/customer-lock.d.ts +5 -0
  254. package/build/plugins/customer-lock.d.ts.map +1 -0
  255. package/build/plugins/customer-lock.js +22 -0
  256. package/build/plugins/customer-lock.js.map +1 -0
  257. package/build/plugins/estimate/cache.d.ts +4 -0
  258. package/build/plugins/estimate/cache.d.ts.map +1 -0
  259. package/build/plugins/estimate/cache.js +7 -0
  260. package/build/plugins/estimate/cache.js.map +1 -0
  261. package/build/plugins/estimate/types.d.ts +27 -0
  262. package/build/plugins/estimate/types.d.ts.map +1 -0
  263. package/build/plugins/estimate/types.js +2 -0
  264. package/build/plugins/estimate/types.js.map +1 -0
  265. package/build/plugins/estimate.d.ts +6 -0
  266. package/build/plugins/estimate.d.ts.map +1 -0
  267. package/build/plugins/estimate.js +271 -0
  268. package/build/plugins/estimate.js.map +1 -0
  269. package/build/plugins/events/types.d.ts +12 -0
  270. package/build/plugins/events/types.d.ts.map +1 -0
  271. package/build/plugins/events/types.js +2 -0
  272. package/build/plugins/events/types.js.map +1 -0
  273. package/build/plugins/events.d.ts +6 -13
  274. package/build/plugins/events.d.ts.map +1 -1
  275. package/build/plugins/events.js +441 -144
  276. package/build/plugins/events.js.map +1 -1
  277. package/build/plugins/fx/types.d.ts +33 -0
  278. package/build/plugins/fx/types.d.ts.map +1 -0
  279. package/build/plugins/fx/types.js +2 -0
  280. package/build/plugins/fx/types.js.map +1 -0
  281. package/build/plugins/fx.d.ts +6 -0
  282. package/build/plugins/fx.d.ts.map +1 -0
  283. package/build/plugins/fx.js +83 -0
  284. package/build/plugins/fx.js.map +1 -0
  285. package/build/plugins/portal/types.d.ts +44 -0
  286. package/build/plugins/portal/types.d.ts.map +1 -0
  287. package/build/plugins/portal/types.js +2 -0
  288. package/build/plugins/portal/types.js.map +1 -0
  289. package/build/plugins/portal.d.ts +6 -0
  290. package/build/plugins/portal.d.ts.map +1 -0
  291. package/build/plugins/portal.js +255 -0
  292. package/build/plugins/portal.js.map +1 -0
  293. package/build/plugins/refunds/types.d.ts +35 -0
  294. package/build/plugins/refunds/types.d.ts.map +1 -0
  295. package/build/plugins/refunds/types.js +2 -0
  296. package/build/plugins/refunds/types.js.map +1 -0
  297. package/build/plugins/refunds.d.ts +6 -0
  298. package/build/plugins/refunds.d.ts.map +1 -0
  299. package/build/plugins/refunds.js +81 -0
  300. package/build/plugins/refunds.js.map +1 -0
  301. package/build/plugins/session/types.d.ts +32 -0
  302. package/build/plugins/session/types.d.ts.map +1 -0
  303. package/build/plugins/session/types.js +2 -0
  304. package/build/plugins/session/types.js.map +1 -0
  305. package/build/plugins/session.d.ts +4 -0
  306. package/build/plugins/session.d.ts.map +1 -0
  307. package/build/plugins/session.js +58 -0
  308. package/build/plugins/session.js.map +1 -0
  309. package/build/plugins/status.d.ts +8 -0
  310. package/build/plugins/status.d.ts.map +1 -0
  311. package/build/plugins/status.js +21 -0
  312. package/build/plugins/status.js.map +1 -0
  313. package/build/plugins/stripe/types.d.ts +20 -0
  314. package/build/plugins/stripe/types.d.ts.map +1 -0
  315. package/build/plugins/stripe/types.js +2 -0
  316. package/build/plugins/stripe/types.js.map +1 -0
  317. package/build/plugins/stripe.d.ts +5 -13
  318. package/build/plugins/stripe.d.ts.map +1 -1
  319. package/build/plugins/stripe.js +481 -129
  320. package/build/plugins/stripe.js.map +1 -1
  321. package/build/plugins/subscriptions/types.d.ts +41 -0
  322. package/build/plugins/subscriptions/types.d.ts.map +1 -0
  323. package/build/plugins/subscriptions/types.js +2 -0
  324. package/build/plugins/subscriptions/types.js.map +1 -0
  325. package/build/plugins/subscriptions.d.ts +6 -0
  326. package/build/plugins/subscriptions.d.ts.map +1 -0
  327. package/build/plugins/subscriptions.js +169 -0
  328. package/build/plugins/subscriptions.js.map +1 -0
  329. package/build/plugins/types.d.ts +7 -0
  330. package/build/plugins/types.d.ts.map +1 -0
  331. package/build/plugins/types.js +2 -0
  332. package/build/plugins/types.js.map +1 -0
  333. package/build/plugins/types.local.d.ts +75 -0
  334. package/build/plugins/types.local.d.ts.map +1 -0
  335. package/build/plugins/types.local.js +2 -0
  336. package/build/plugins/types.local.js.map +1 -0
  337. package/build/plugins/webhook-manager/types.d.ts +62 -0
  338. package/build/plugins/webhook-manager/types.d.ts.map +1 -0
  339. package/build/plugins/webhook-manager/types.js +2 -0
  340. package/build/plugins/webhook-manager/types.js.map +1 -0
  341. package/build/plugins/webhook-manager.d.ts +8 -0
  342. package/build/plugins/webhook-manager.d.ts.map +1 -0
  343. package/build/plugins/webhook-manager.js +245 -0
  344. package/build/plugins/webhook-manager.js.map +1 -0
  345. package/build/protocol.d.ts +13 -0
  346. package/build/protocol.d.ts.map +1 -0
  347. package/build/protocol.js +17 -0
  348. package/build/protocol.js.map +1 -0
  349. package/build/reconcile/types.d.ts +17 -0
  350. package/build/reconcile/types.d.ts.map +1 -0
  351. package/build/reconcile/types.js +2 -0
  352. package/build/reconcile/types.js.map +1 -0
  353. package/build/reconcile.d.ts +12 -0
  354. package/build/reconcile.d.ts.map +1 -0
  355. package/build/reconcile.js +91 -0
  356. package/build/reconcile.js.map +1 -0
  357. package/build/resource.d.ts +12 -1
  358. package/build/resource.d.ts.map +1 -1
  359. package/build/resource.js +97 -6
  360. package/build/resource.js.map +1 -1
  361. package/build/schemas.d.ts +19 -0
  362. package/build/schemas.d.ts.map +1 -0
  363. package/build/schemas.js +244 -0
  364. package/build/schemas.js.map +1 -0
  365. package/build/service.d.ts +28 -3
  366. package/build/service.d.ts.map +1 -1
  367. package/build/service.js +140 -19
  368. package/build/service.js.map +1 -1
  369. package/build/subscription/types.d.ts +21 -0
  370. package/build/subscription/types.d.ts.map +1 -0
  371. package/build/subscription/types.js +2 -0
  372. package/build/subscription/types.js.map +1 -0
  373. package/build/subscription.d.ts +4 -0
  374. package/build/subscription.d.ts.map +1 -0
  375. package/build/subscription.js +84 -0
  376. package/build/subscription.js.map +1 -0
  377. package/build/sync/types.d.ts +25 -0
  378. package/build/sync/types.d.ts.map +1 -0
  379. package/build/sync/types.js +2 -0
  380. package/build/sync/types.js.map +1 -0
  381. package/build/sync.d.ts +4 -3
  382. package/build/sync.d.ts.map +1 -1
  383. package/build/sync.js +231 -79
  384. package/build/sync.js.map +1 -1
  385. package/build/types.d.ts +1258 -36
  386. package/build/types.d.ts.map +1 -1
  387. package/build/types.local.d.ts +22 -0
  388. package/build/types.local.d.ts.map +1 -0
  389. package/build/types.local.js +2 -0
  390. package/build/types.local.js.map +1 -0
  391. package/build/usage/types.d.ts +56 -0
  392. package/build/usage/types.d.ts.map +1 -0
  393. package/build/usage/types.js +2 -0
  394. package/build/usage/types.js.map +1 -0
  395. package/build/usage.d.ts +6 -0
  396. package/build/usage.d.ts.map +1 -0
  397. package/build/usage.js +365 -0
  398. package/build/usage.js.map +1 -0
  399. package/build/utils/types.d.ts +31 -0
  400. package/build/utils/types.d.ts.map +1 -0
  401. package/build/utils/types.js +2 -0
  402. package/build/utils/types.js.map +1 -0
  403. package/build/utils.d.ts +21 -7
  404. package/build/utils.d.ts.map +1 -1
  405. package/build/utils.js +56 -17
  406. package/build/utils.js.map +1 -1
  407. package/package.json +22 -17
  408. package/src/access/types.ts +52 -0
  409. package/src/access.ts +86 -0
  410. package/src/actions/index.ts +1 -0
  411. package/src/actions/resync-subscriptions.ts +10 -0
  412. package/src/actions/resync.ts +14 -5
  413. package/src/actions/webhook.ts +9 -4
  414. package/src/bootstrap/types.ts +16 -0
  415. package/src/bootstrap.ts +31 -0
  416. package/src/catalogue/types.ts +32 -0
  417. package/src/catalogue.ts +135 -0
  418. package/src/commit/types.ts +27 -0
  419. package/src/commit.ts +152 -0
  420. package/src/config.ts +234 -14
  421. package/src/consts.local.ts +62 -0
  422. package/src/consts.ts +100 -36
  423. package/src/consumer/cancellation/types.ts +13 -0
  424. package/src/consumer/cancellation.ts +43 -0
  425. package/src/consumer/capture/types.ts +53 -0
  426. package/src/consumer/capture.ts +321 -0
  427. package/src/consumer/consts.local.ts +18 -0
  428. package/src/consumer/format/types.ts +29 -0
  429. package/src/consumer/format.ts +85 -0
  430. package/src/consumer/handlers.ts +204 -0
  431. package/src/consumer/index.ts +9 -0
  432. package/src/consumer/mail/types.ts +31 -0
  433. package/src/consumer/mail.ts +353 -0
  434. package/src/consumer/observers/types.ts +22 -0
  435. package/src/consumer/observers.ts +97 -0
  436. package/src/consumer/origin/types.ts +17 -0
  437. package/src/consumer/origin.ts +61 -0
  438. package/src/consumer/reconcile/types.ts +13 -0
  439. package/src/consumer/reconcile.ts +330 -0
  440. package/src/consumer/records/types.ts +64 -0
  441. package/src/consumer/records.ts +288 -0
  442. package/src/consumer/service.ts +768 -0
  443. package/src/consumer/types.local.ts +22 -0
  444. package/src/consumer/types.ts +96 -0
  445. package/src/consumer/withdrawal/types.ts +37 -0
  446. package/src/consumer/withdrawal.ts +268 -0
  447. package/src/entitlement.ts +85 -0
  448. package/src/entrypoints.ts +17 -4
  449. package/src/gate/request.ts +24 -0
  450. package/src/gate/types.ts +13 -0
  451. package/src/gate.ts +47 -30
  452. package/src/index.ts +55 -3
  453. package/src/limit.ts +54 -0
  454. package/src/log.ts +4 -0
  455. package/src/models/declarations/types.ts +22 -0
  456. package/src/models/declarations.ts +30 -0
  457. package/src/models/purchase/types.ts +13 -0
  458. package/src/models/purchase.ts +43 -0
  459. package/src/observer.ts +44 -11
  460. package/src/plan/types.ts +21 -0
  461. package/src/plan.ts +46 -0
  462. package/src/plugins/checkout-plugins/types.ts +25 -0
  463. package/src/plugins/checkout-plugins.ts +90 -0
  464. package/src/plugins/checkout-policy/types.ts +18 -0
  465. package/src/plugins/checkout-policy.ts +34 -0
  466. package/src/plugins/checkout-registry/types.ts +7 -0
  467. package/src/plugins/checkout-registry.ts +23 -0
  468. package/src/plugins/consts.local.ts +30 -0
  469. package/src/plugins/customer-lock/types.ts +5 -0
  470. package/src/plugins/customer-lock.ts +25 -0
  471. package/src/plugins/estimate/cache.ts +12 -0
  472. package/src/plugins/estimate/types.ts +28 -0
  473. package/src/plugins/estimate.ts +305 -0
  474. package/src/plugins/events/types.ts +11 -0
  475. package/src/plugins/events.ts +466 -132
  476. package/src/plugins/fx/types.ts +40 -0
  477. package/src/plugins/fx.ts +101 -0
  478. package/src/plugins/portal/types.ts +45 -0
  479. package/src/plugins/portal.ts +284 -0
  480. package/src/plugins/refunds/types.ts +31 -0
  481. package/src/plugins/refunds.ts +95 -0
  482. package/src/plugins/session/types.ts +28 -0
  483. package/src/plugins/session.ts +73 -0
  484. package/src/plugins/status.ts +22 -0
  485. package/src/plugins/stripe/types.ts +20 -0
  486. package/src/plugins/stripe.ts +523 -135
  487. package/src/plugins/subscriptions/types.ts +39 -0
  488. package/src/plugins/subscriptions.ts +195 -0
  489. package/src/plugins/types.local.ts +61 -0
  490. package/src/plugins/types.ts +7 -0
  491. package/src/plugins/webhook-manager/types.ts +63 -0
  492. package/src/plugins/webhook-manager.ts +288 -0
  493. package/src/protocol.ts +29 -0
  494. package/src/reconcile/types.ts +17 -0
  495. package/src/reconcile.ts +110 -0
  496. package/src/resource.ts +158 -11
  497. package/src/schemas.ts +271 -0
  498. package/src/service.ts +161 -19
  499. package/src/subscription/types.ts +23 -0
  500. package/src/subscription.ts +104 -0
  501. package/src/sync/types.ts +25 -0
  502. package/src/sync.ts +255 -72
  503. package/src/types.local.ts +18 -0
  504. package/src/types.ts +1365 -32
  505. package/src/usage/types.ts +51 -0
  506. package/src/usage.ts +432 -0
  507. package/src/utils/types.ts +30 -0
  508. package/src/utils.ts +94 -29
  509. package/tests/checkout-consumer.spec.ts +366 -0
  510. package/tests/checkout-locks.spec.ts +161 -0
  511. package/tests/checkout-plugins.spec.ts +164 -0
  512. package/tests/checkout.spec.ts +209 -93
  513. package/tests/consumer-events.spec.ts +215 -0
  514. package/tests/consumer-fixtures.ts +134 -0
  515. package/tests/consumer-ops.spec.ts +350 -0
  516. package/tests/consumer-rights.integration.spec.ts +147 -0
  517. package/tests/consumer-rights.spec.ts +572 -0
  518. package/tests/context.ts +110 -0
  519. package/tests/entitlement.spec.ts +139 -0
  520. package/tests/estimate.spec.ts +350 -0
  521. package/tests/events.spec.ts +357 -0
  522. package/tests/fake-stripe.ts +981 -0
  523. package/tests/gate-handlers.spec.ts +120 -0
  524. package/tests/gate.spec.ts +63 -72
  525. package/tests/gateway-options.spec.ts +180 -0
  526. package/tests/limit-gate.spec.ts +66 -0
  527. package/tests/portal.spec.ts +202 -0
  528. package/tests/protocol.spec.ts +17 -3
  529. package/tests/sync.spec.ts +114 -0
  530. package/tests/usage.integration.spec.ts +133 -0
  531. package/tests/usage.spec.ts +169 -0
  532. package/tests/webhook-manager.spec.ts +149 -0
  533. package/build/model.d.ts +0 -6
  534. package/build/model.d.ts.map +0 -1
  535. package/build/model.js +0 -33
  536. package/build/model.js.map +0 -1
  537. package/src/model.ts +0 -37
@@ -0,0 +1,26 @@
1
+ import { PLAN_RECORD_TYPE, PlanDuration, PlanRankConflict } from '@owlmeans/payment';
2
+ export const makePlanDeclarationsModel = (record) => {
3
+ const plans = () => (record.records ?? []).filter(entry => entry.recordType === PLAN_RECORD_TYPE);
4
+ const assertPlans = () => {
5
+ const freeRanks = new Set();
6
+ const paidRanks = new Set();
7
+ for (const plan of plans()) {
8
+ const rank = plan.rank ?? 0;
9
+ if (plan.free === true) {
10
+ if (freeRanks.has(rank)) {
11
+ throw new PlanRankConflict(`free:${rank}`);
12
+ }
13
+ freeRanks.add(rank);
14
+ }
15
+ else if (plan.duration !== PlanDuration.Consumable) {
16
+ const key = `${plan.productSku}:${rank}`;
17
+ if (paidRanks.has(key)) {
18
+ throw new PlanRankConflict(key);
19
+ }
20
+ paidRanks.add(key);
21
+ }
22
+ }
23
+ };
24
+ return { record, plans, assertPlans };
25
+ };
26
+ //# sourceMappingURL=declarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.js","sourceRoot":"","sources":["../../src/models/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAIpF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAc,EAAyB,EAAE;IACjF,MAAM,KAAK,GAAG,GAAkB,EAAE,CAChC,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,gBAAgB,CAA6B,CAAA;IAE3G,MAAM,WAAW,GAAG,GAAS,EAAE;QAC7B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAA;QACnC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAA;QACnC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAA;YAC3B,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACvB,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxB,MAAM,IAAI,gBAAgB,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAA;gBAC5C,CAAC;gBACD,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACrB,CAAC;iBAAM,IAAI,IAAI,CAAC,QAAQ,KAAK,YAAY,CAAC,UAAU,EAAE,CAAC;gBACrD,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,EAAE,CAAA;gBACxC,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBACvB,MAAM,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAA;gBACjC,CAAC;gBACD,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACpB,CAAC;QACH,CAAC;IACH,CAAC,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;AACvC,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import type { PurchaseView } from '@owlmeans/payment';
2
+ import type { PurchaseRecord, PurchaseRef } from '../../types.js';
3
+ /** One purchase and its withdrawal window. */
4
+ export interface PurchaseModel {
5
+ readonly record: PurchaseRecord;
6
+ /** Inside its window at `at`: in scope, before the deadline, neither withdrawn from nor refunded. */
7
+ windowOpen: (at?: Date) => boolean;
8
+ /** The purchase as the wire sees it. */
9
+ view: (withdrawable: boolean) => PurchaseView;
10
+ /** What a usage meter is told about the purchase. */
11
+ ref: () => PurchaseRef;
12
+ }
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/models/purchase/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjE,8CAA8C;AAC9C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAC/B,qGAAqG;IACrG,UAAU,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,KAAK,OAAO,CAAA;IAClC,wCAAwC;IACxC,IAAI,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,YAAY,CAAA;IAC7C,qDAAqD;IACrD,GAAG,EAAE,MAAM,WAAW,CAAA;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/models/purchase/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { PurchaseRecord } from '../types.js';
2
+ import type { PurchaseModel } from './purchase/types.js';
3
+ export declare const makePurchaseModel: (record: PurchaseRecord) => PurchaseModel;
4
+ //# sourceMappingURL=purchase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purchase.d.ts","sourceRoot":"","sources":["../../src/models/purchase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,aAAa,CAAA;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,eAAO,MAAM,iBAAiB,WAAY,cAAc,KAAG,aAqC1D,CAAA"}
@@ -0,0 +1,37 @@
1
+ import { withdrawalDeadlineHelper } from '@owlmeans/payment';
2
+ import { paymentUtils } from '../utils.js';
3
+ export const makePurchaseModel = (record) => {
4
+ const windowOpen = (at = new Date()) => record.inScope && withdrawalDeadlineHelper.withdrawalOpen({
5
+ deadline: record.deadline != null ? new Date(record.deadline) : null,
6
+ withdrawnAt: record.withdrawnAt ?? null,
7
+ refundedAt: record.refundedAt ?? null,
8
+ }, at);
9
+ const view = (withdrawable) => paymentUtils.compact({
10
+ purchaseId: record.purchaseId,
11
+ contractRef: record.contractRef,
12
+ kind: record.kind,
13
+ purchasedAt: new Date(record.purchasedAt),
14
+ deadline: record.deadline != null ? new Date(record.deadline) : undefined,
15
+ productSku: record.productSku,
16
+ planSku: record.planSku ?? undefined,
17
+ amountTotalMinor: record.amountTotalMinor,
18
+ currency: record.currency,
19
+ consentedAt: record.consentedAt != null ? new Date(record.consentedAt) : undefined,
20
+ withdrawnAt: record.withdrawnAt != null ? new Date(record.withdrawnAt) : undefined,
21
+ withdrawable,
22
+ });
23
+ const ref = () => paymentUtils.compact({
24
+ purchaseId: record.purchaseId,
25
+ kind: record.kind,
26
+ entityId: record.entityId,
27
+ contractRef: record.contractRef,
28
+ productSku: record.productSku,
29
+ planSku: record.planSku ?? undefined,
30
+ sessionId: record.sessionId ?? undefined,
31
+ subscriptionId: record.subscriptionId ?? undefined,
32
+ invoiceId: record.invoiceId ?? undefined,
33
+ purchasedAt: new Date(record.purchasedAt),
34
+ });
35
+ return { record, windowOpen, view, ref };
36
+ };
37
+ //# sourceMappingURL=purchase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purchase.js","sourceRoot":"","sources":["../../src/models/purchase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,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AW,CAAC,CAAC,CAAC,CAAC,SAAS;QAClF,YAAY;KACb,CAAiB,CAAA;IAElB,MAAM,GAAG,GAAG,GAAgB,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC;QAClD,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,SAAS;QACpC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;QACxC,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,SAAS;QAClD,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;QACxC,WAAW,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;KAC1C,CAAgB,CAAA;IAEjB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;AAC1C,CAAC,CAAA"}
@@ -1,4 +1,13 @@
1
1
  import type { CompletionObserver, Config, Context } from './types.js';
2
+ /**
3
+ * The application's side of payment completion. Callbacks run sequentially and are awaited; a
4
+ * throw escapes to the webhook so the paygate delivers the event again — every callback must be
5
+ * idempotent by the `eventKey` (`externalId` for a top-up) it is handed.
6
+ *
7
+ * The consumer-rights callbacks (`onConsent`, `onWithdrawal`, `onCancellation`) run after the
8
+ * records and the paygate steps of their act; a throw is recorded as an `observers` event and
9
+ * retried by the consumer-rights `reconcile()` — they, too, are idempotent by `eventKey`.
10
+ */
2
11
  export declare const makeCompletionObserverService: (alias?: string) => CompletionObserver;
3
12
  export declare const appendCompletionObserver: <C extends Config, T extends Context<C>>(ctx: T, alias?: string) => T;
4
13
  //# sourceMappingURL=observer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"observer.d.ts","sourceRoot":"","sources":["../src/observer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,OAAO,EAAuC,MAAM,YAAY,CAAA;AAE1G,eAAO,MAAM,6BAA6B,WACjC,MAAM,KACZ,kBAaF,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,OACxE,CAAC,UAAS,MAAM,KACpB,CAGF,CAAA"}
1
+ {"version":3,"file":"observer.d.ts","sourceRoot":"","sources":["../src/observer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACY,kBAAkB,EAAE,MAAM,EAAmB,OAAO,EAE3E,MAAM,YAAY,CAAA;AAEnB;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,WACjC,MAAM,KACZ,kBAkCF,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,OACxE,CAAC,UAAS,MAAM,KACpB,CAGF,CAAA"}
package/build/observer.js CHANGED
@@ -1,19 +1,45 @@
1
1
  import { createLazyService } from '@owlmeans/context';
2
2
  import { PAYMENT_OBSERVER } from './consts.js';
3
+ /**
4
+ * The application's side of payment completion. Callbacks run sequentially and are awaited; a
5
+ * throw escapes to the webhook so the paygate delivers the event again — every callback must be
6
+ * idempotent by the `eventKey` (`externalId` for a top-up) it is handed.
7
+ *
8
+ * The consumer-rights callbacks (`onConsent`, `onWithdrawal`, `onCancellation`) run after the
9
+ * records and the paygate steps of their act; a throw is recorded as an `observers` event and
10
+ * retried by the consumer-rights `reconcile()` — they, too, are idempotent by `eventKey`.
11
+ */
3
12
  export const makeCompletionObserverService = (alias = PAYMENT_OBSERVER) => {
4
- const topUpCallbacks = [];
5
- const subscriptionCallbacks = [];
13
+ const topUp = [];
14
+ const subscription = [];
15
+ const refund = [];
16
+ const dispute = [];
17
+ const paymentFailed = [];
18
+ const consent = [];
19
+ const withdrawal = [];
20
+ const cancellation = [];
21
+ const run = async (callbacks, event, ctx) => {
22
+ for (const callback of callbacks) {
23
+ await callback(event, ctx);
24
+ }
25
+ };
6
26
  return createLazyService(alias, {
7
- onTopUp: cb => { topUpCallbacks.push(cb); },
8
- onSubscription: cb => { subscriptionCallbacks.push(cb); },
9
- propagateTopUp: async (completion, ctx) => {
10
- for (const callback of topUpCallbacks)
11
- await callback(completion, ctx);
12
- },
13
- propagateSubscription: async (completion, ctx) => {
14
- for (const callback of subscriptionCallbacks)
15
- await callback(completion, ctx);
16
- },
27
+ onTopUp: cb => { topUp.push(cb); },
28
+ onSubscription: cb => { subscription.push(cb); },
29
+ onRefund: cb => { refund.push(cb); },
30
+ onDispute: cb => { dispute.push(cb); },
31
+ onPaymentFailed: cb => { paymentFailed.push(cb); },
32
+ onConsent: cb => { consent.push(cb); },
33
+ onWithdrawal: cb => { withdrawal.push(cb); },
34
+ onCancellation: cb => { cancellation.push(cb); },
35
+ propagateTopUp: async (completion, ctx) => { await run(topUp, completion, ctx); },
36
+ propagateSubscription: async (event, ctx) => { await run(subscription, event, ctx); },
37
+ propagateRefund: async (event, ctx) => { await run(refund, event, ctx); },
38
+ propagateDispute: async (event, ctx) => { await run(dispute, event, ctx); },
39
+ propagatePaymentFailed: async (event, ctx) => { await run(paymentFailed, event, ctx); },
40
+ propagateConsent: async (event, ctx) => { await run(consent, event, ctx); },
41
+ propagateWithdrawal: async (event, ctx) => { await run(withdrawal, event, ctx); },
42
+ propagateCancellation: async (event, ctx) => { await run(cancellation, event, ctx); },
17
43
  }, service => async () => { service.initialized = true; });
18
44
  };
19
45
  export const appendCompletionObserver = (ctx, alias = PAYMENT_OBSERVER) => {
@@ -1 +1 @@
1
- {"version":3,"file":"observer.js","sourceRoot":"","sources":["../src/observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAG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C;QAChF,qBAAqB,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,MAAM,GAAG,CAAC,YAAY,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA,CAAC,CAAC;KACrF,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAA,CAAC,CAAC,CAAC,CAAA;AAC3D,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,GAAM,EAAE,KAAK,GAAW,gBAAgB,EACrC,EAAE;IACL,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,GAAG,CAAC,eAAe,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC,CAAA;IACrF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
@@ -0,0 +1,21 @@
1
+ import type { ProductPlan } from '@owlmeans/payment';
2
+ import type { PaymentPlan, PaymentProduct, PaymentSubscriptionRecord } from '../types.js';
3
+ /** What a plan declaration says on its own — no context, no store. */
4
+ export interface PlanHelper {
5
+ /** A plan's rank; an absent rank reads as `0`. */
6
+ planRank: (plan: Pick<ProductPlan, 'rank'>) => number;
7
+ /**
8
+ * A plan as ONE subscription holds it: the row's `overrides` replace the static declaration.
9
+ *
10
+ * A limit override sets the ceiling of a key the plan declares and drops that key's promo, so the
11
+ * ceiling holds whatever the promo says; the kind and the window stay the plan's, because the
12
+ * counters are keyed by them. A key the plan does not declare, or a ceiling that is not a safe
13
+ * integer `>= 0`, is ignored. The override belongs to the row: it follows the subscription through
14
+ * a plan change and ends with it.
15
+ */
16
+ overriddenPlan: (plan: PaymentPlan, row: Pick<PaymentSubscriptionRecord, 'overrides'> | null | undefined) => PaymentPlan;
17
+ planLookupKey: (product: PaymentProduct, plan: PaymentPlan) => string;
18
+ /** Whether a plan is sold through a paygate: never a free plan; otherwise its own gateways, else the product's. */
19
+ isSoldThrough: (product: PaymentProduct, plan: PaymentPlan, paygate: string) => boolean;
20
+ }
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plan/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAEzF,sEAAsE;AACtE,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,MAAM,CAAA;IACrD;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,CAAC,yBAAyB,EAAE,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,KAAK,WAAW,CAAA;IACxH,aAAa,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,KAAK,MAAM,CAAA;IACrE,mHAAmH;IACnH,aAAa,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAA;CACxF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plan/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { PaymentPlan, PaymentSubscriptionRecord } from './types.js';
2
+ import type { PlanHelper } from './plan/types.js';
3
+ export declare const createPlanHelper: () => PlanHelper;
4
+ export declare const planHelper: PlanHelper;
5
+ /** @deprecated compat:factory-refactor — use `planHelper.overriddenPlan(…)` */
6
+ export declare const overriddenPlan: (plan: PaymentPlan, row: Pick<PaymentSubscriptionRecord, 'overrides'> | null | undefined) => PaymentPlan;
7
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAkB,yBAAyB,EAAE,MAAM,YAAY,CAAA;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,eAAO,MAAM,gBAAgB,QAAO,UAkCnC,CAAA;AAED,eAAO,MAAM,UAAU,YAAqB,CAAA;AAE5C,+EAA+E;AAC/E,eAAO,MAAM,cAAc,SACnB,WAAW,OAAO,IAAI,CAAC,yBAAyB,EAAE,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,KACtF,WAAmD,CAAA"}
package/build/plan.js ADDED
@@ -0,0 +1,29 @@
1
+ import { ProductType } from '@owlmeans/payment';
2
+ export const createPlanHelper = () => {
3
+ const planRank = (plan) => plan.rank ?? 0;
4
+ const isCeiling = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
5
+ const overriddenPlan = (plan, row) => {
6
+ const limits = Object.entries(row?.overrides?.limits ?? {})
7
+ .filter(([key, override]) => plan.limits?.[key] != null && isCeiling(override?.limit));
8
+ if (limits.length === 0) {
9
+ return plan;
10
+ }
11
+ return {
12
+ ...plan,
13
+ limits: {
14
+ ...plan.limits,
15
+ ...Object.fromEntries(limits.map(([key, override]) => {
16
+ const { promo: _promo, ...declaration } = plan.limits[key];
17
+ return [key, { ...declaration, limit: override.limit }];
18
+ })),
19
+ },
20
+ };
21
+ };
22
+ const planLookupKey = (product, plan) => product.type === ProductType.Consumable ? `${product.sku}-consumable` : plan.sku;
23
+ const isSoldThrough = (product, plan, paygate) => plan.free !== true && (plan.gateways ?? product.gateways ?? []).includes(paygate);
24
+ return { planRank, overriddenPlan, planLookupKey, isSoldThrough };
25
+ };
26
+ export const planHelper = createPlanHelper();
27
+ /** @deprecated compat:factory-refactor — use `planHelper.overriddenPlan(…)` */
28
+ export const overriddenPlan = (plan, row) => planHelper.overriddenPlan(plan, row);
29
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoB,MAAM,mBAAmB,CAAA;AAIjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAe,EAAE;IAC/C,MAAM,QAAQ,GAAG,CAAC,IAA+B,EAAU,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAA;IAE5E,MAAM,SAAS,GAAG,CAAC,KAAc,EAAmB,EAAE,CACpD,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;IAExE,MAAM,cAAc,GAAG,CACrB,IAAiB,EAAE,GAAoE,EAC1E,EAAE;QACf,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,IAAI,EAAE,CAAC;aACxD,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAA;QACxF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO;YACL,GAAG,IAAI;YACP,MAAM,EAAE;gBACN,GAAG,IAAI,CAAC,MAAM;gBACd,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,EAAE;oBACnD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,GAAG,IAAI,CAAC,MAAO,CAAC,GAAG,CAAC,CAAA;oBAC3D,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;gBACzD,CAAC,CAAC,CAAC;aACJ;SACF,CAAA;IACH,CAAC,CAAA;IAED,MAAM,aAAa,GAAG,CAAC,OAAuB,EAAE,IAAiB,EAAU,EAAE,CAC3E,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAA;IAElF,MAAM,aAAa,GAAG,CAAC,OAAuB,EAAE,IAAiB,EAAE,OAAe,EAAW,EAAE,CAC7F,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IAEnF,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,CAAA;AACnE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAA;AAE5C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAiB,EAAE,GAAoE,EAC1E,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ import type { AmountPolicyView } from '@owlmeans/payment';
2
+ import type { CheckoutAttempt, CheckoutNarrowInput, CheckoutPlugin, CheckoutSettled } from '../../types.js';
3
+ import type { Admitted } from '../types.js';
4
+ /** The checkout plugins' hooks, called in a context. */
5
+ export interface CheckoutPluginsHelper {
6
+ /**
7
+ * An entity's amount policy as every plugin narrows it now — the ONE computation both
8
+ * `gateway.amountPolicy` and checkout enforcement use, so a control and a refusal cannot disagree.
9
+ * A plugin's error propagates: a narrowing that cannot be computed fails closed.
10
+ */
11
+ narrowAmountFor: (plugins: readonly CheckoutPlugin[], input: CheckoutNarrowInput) => Promise<AmountPolicyView>;
12
+ /**
13
+ * Tell plugins how a checkout ended. A plugin's error is logged, never raised: a hold carries its
14
+ * own TTL, and the webhook that reports the outcome must not be redelivered for it.
15
+ */
16
+ settleCheckout: (plugins: readonly CheckoutPlugin[], settled: CheckoutSettled) => Promise<void>;
17
+ /** Release what admitted plugins hold for a checkout that never became usable. */
18
+ releaseAdmitted: (admitted: readonly Admitted[], attempt: CheckoutAttempt, sessionId?: string) => Promise<void>;
19
+ /**
20
+ * Ask every plugin to admit the attempt, in order. A veto releases what the earlier plugins
21
+ * admitted and propagates.
22
+ */
23
+ admitCheckout: (plugins: readonly CheckoutPlugin[], attempt: CheckoutAttempt) => Promise<Admitted[]>;
24
+ }
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/checkout-plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC3G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,wDAAwD;AACxD,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,eAAe,EAAE,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,EAAE,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC9G;;;OAGG;IACH,cAAc,EAAE,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,EAAE,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/F,kFAAkF;IAClF,eAAe,EAAE,CAAC,QAAQ,EAAE,SAAS,QAAQ,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/G;;;OAGG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,EAAE,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;CACrG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugins/checkout-plugins/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { type AmountPolicyView } from '@owlmeans/payment';
2
+ import type { Context as ApiContext } from '@owlmeans/server-api';
3
+ import type { CheckoutNarrowInput, CheckoutPlugin } from '../types.js';
4
+ import type { CheckoutPluginsHelper } from './checkout-plugins/types.js';
5
+ export declare const makeCheckoutPluginsHelper: (ctx: ApiContext) => CheckoutPluginsHelper;
6
+ /** The checkout plugin calls of a context — one per context. */
7
+ export declare const checkoutPluginsOf: (target: ApiContext<import("@owlmeans/server-api").Config>) => CheckoutPluginsHelper;
8
+ /** @deprecated compat:factory-refactor — use `checkoutPluginsOf(ctx).narrowAmountFor(…)` */
9
+ export declare const narrowAmountFor: (ctx: ApiContext, plugins: readonly CheckoutPlugin[], input: CheckoutNarrowInput) => Promise<AmountPolicyView>;
10
+ /** @deprecated compat:factory-refactor — use `checkoutPolicyHelper.assertAmountAllowed(…)` */
11
+ export declare const assertAmountAllowed: (view: AmountPolicyView, amountMinor: number) => void;
12
+ //# sourceMappingURL=checkout-plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-plugins.d.ts","sourceRoot":"","sources":["../../src/plugins/checkout-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACnG,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjE,OAAO,KAAK,EAAmB,mBAAmB,EAAE,cAAc,EAAmB,MAAM,aAAa,CAAA;AAGxG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAGxE,eAAO,MAAM,yBAAyB,QAAS,UAAU,KAAG,qBAoE3D,CAAA;AAED,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,sFAAgD,CAAA;AAE9E,4FAA4F;AAC5F,eAAO,MAAM,eAAe,QACrB,UAAU,WAAW,SAAS,cAAc,EAAE,SAAS,mBAAmB,KAC9E,OAAO,CAAC,gBAAgB,CAAiE,CAAA;AAE5F,8FAA8F;AAC9F,eAAO,MAAM,mBAAmB,SAAU,gBAAgB,eAAe,MAAM,KAAG,IACrB,CAAA"}
@@ -0,0 +1,72 @@
1
+ import { narrowAmountPolicy } from '@owlmeans/payment';
2
+ import { memoHelper } from '@owlmeans/context';
3
+ import { log } from '../log.js';
4
+ import { checkoutPolicyHelper } from './checkout-policy.js';
5
+ export const makeCheckoutPluginsHelper = (ctx) => {
6
+ const narrowAmountFor = async (plugins, input) => {
7
+ const narrowings = [];
8
+ for (const plugin of plugins) {
9
+ if (plugin.narrow == null) {
10
+ continue;
11
+ }
12
+ const narrowing = await plugin.narrow(ctx, input);
13
+ if (narrowing != null) {
14
+ narrowings.push(narrowing);
15
+ }
16
+ }
17
+ return narrowAmountPolicy(input.base, narrowings, {
18
+ productSku: input.productSku, ...(input.planSku != null ? { planSku: input.planSku } : {}),
19
+ });
20
+ };
21
+ const settleCheckout = async (plugins, settled) => {
22
+ for (const plugin of plugins) {
23
+ if (plugin.settled == null) {
24
+ continue;
25
+ }
26
+ try {
27
+ await plugin.settled(ctx, settled);
28
+ }
29
+ catch (error) {
30
+ log.error('Checkout plugin failed to settle', { plugin: plugin.alias ?? 'anonymous', error });
31
+ }
32
+ }
33
+ };
34
+ const releaseAdmitted = async (admitted, attempt, sessionId) => {
35
+ for (const { plugin, reservationId } of admitted) {
36
+ await settleCheckout([plugin], {
37
+ entityId: attempt.entityId, productSku: attempt.productSku,
38
+ ...(attempt.planSku != null ? { planSku: attempt.planSku } : {}),
39
+ ...(sessionId != null ? { sessionId } : {}),
40
+ ...(reservationId != null ? { reservationId } : {}),
41
+ ...(attempt.amountMinor != null ? { amountMinor: attempt.amountMinor } : {}),
42
+ outcome: 'failed', at: new Date(),
43
+ });
44
+ }
45
+ };
46
+ const admitCheckout = async (plugins, attempt) => {
47
+ const admitted = [];
48
+ for (const plugin of plugins) {
49
+ if (plugin.admit == null) {
50
+ admitted.push({ plugin });
51
+ continue;
52
+ }
53
+ try {
54
+ const admission = await plugin.admit(ctx, attempt);
55
+ admitted.push({ plugin, ...(admission?.reservationId != null ? { reservationId: admission.reservationId } : {}) });
56
+ }
57
+ catch (error) {
58
+ await releaseAdmitted(admitted.filter(entry => entry.plugin.admit != null), attempt);
59
+ throw error;
60
+ }
61
+ }
62
+ return admitted;
63
+ };
64
+ return { narrowAmountFor, settleCheckout, releaseAdmitted, admitCheckout };
65
+ };
66
+ /** The checkout plugin calls of a context — one per context. */
67
+ export const checkoutPluginsOf = memoHelper.oncePer(makeCheckoutPluginsHelper);
68
+ /** @deprecated compat:factory-refactor — use `checkoutPluginsOf(ctx).narrowAmountFor(…)` */
69
+ export const narrowAmountFor = async (ctx, plugins, input) => await checkoutPluginsOf(ctx).narrowAmountFor(plugins, input);
70
+ /** @deprecated compat:factory-refactor — use `checkoutPolicyHelper.assertAmountAllowed(…)` */
71
+ export const assertAmountAllowed = (view, amountMinor) => checkoutPolicyHelper.assertAmountAllowed(view, amountMinor);
72
+ //# sourceMappingURL=checkout-plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-plugins.js","sourceRoot":"","sources":["../../src/plugins/checkout-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA+C,MAAM,mBAAmB,CAAA;AAEnG,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO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from '@owlmeans/payment';
2
+ import type { CheckoutPlugin } from '../../types.js';
3
+ /** What a narrowed amount policy and the plugins' declarations allow a checkout — pure. */
4
+ export interface CheckoutPolicyHelper {
5
+ /**
6
+ * Refuse an amount the narrowed view does not allow: any amount while `blocked`, else one above
7
+ * the narrowed maximum.
8
+ *
9
+ * @throws CheckoutLimitExceeded (409)
10
+ */
11
+ assertAmountAllowed: (view: AmountPolicyView, amountMinor: number) => void;
12
+ /**
13
+ * The session lifetime: the smallest `sessionTtlSeconds` any plugin declares, clamped to Stripe's
14
+ * 30 minutes – 24 hours; `undefined` when none declares one (Stripe's own default).
15
+ */
16
+ sessionTtlOf: (plugins: readonly CheckoutPlugin[]) => number | undefined;
17
+ }
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/checkout-policy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,2FAA2F;AAC3F,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,mBAAmB,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1E;;;OAGG;IACH,YAAY,EAAE,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,KAAK,MAAM,GAAG,SAAS,CAAA;CACzE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugins/checkout-policy/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { CheckoutPolicyHelper } from './checkout-policy/types.js';
2
+ export declare const createCheckoutPolicyHelper: () => CheckoutPolicyHelper;
3
+ export declare const checkoutPolicyHelper: CheckoutPolicyHelper;
4
+ //# sourceMappingURL=checkout-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-policy.d.ts","sourceRoot":"","sources":["../../src/plugins/checkout-policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEtE,eAAO,MAAM,0BAA0B,QAAO,oBA0B7C,CAAA;AAED,eAAO,MAAM,oBAAoB,sBAA+B,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { CheckoutLimitExceeded } from '@owlmeans/payment';
2
+ import { STRIPE_SESSION_TTL_MAX_SECONDS, STRIPE_SESSION_TTL_MIN_SECONDS } from '../consts.js';
3
+ export const createCheckoutPolicyHelper = () => {
4
+ const assertAmountAllowed = (view, amountMinor) => {
5
+ const limit = view.limit;
6
+ if (limit == null || (!limit.blocked && amountMinor <= limit.maximumMinor)) {
7
+ return;
8
+ }
9
+ throw new CheckoutLimitExceeded({
10
+ reason: limit.reason ?? 'limit', maximumMinor: limit.maximumMinor, currency: limit.currency,
11
+ ...(limit.resetsAt != null ? { resetsAt: limit.resetsAt } : {}),
12
+ });
13
+ };
14
+ const sessionTtlOf = (plugins) => {
15
+ const declared = plugins
16
+ .map(plugin => plugin.sessionTtlSeconds)
17
+ .filter((ttl) => typeof ttl === 'number' && Number.isFinite(ttl));
18
+ if (declared.length === 0) {
19
+ return undefined;
20
+ }
21
+ return Math.min(STRIPE_SESSION_TTL_MAX_SECONDS, Math.max(STRIPE_SESSION_TTL_MIN_SECONDS, Math.floor(Math.min(...declared))));
22
+ };
23
+ return { assertAmountAllowed, sessionTtlOf };
24
+ };
25
+ export const checkoutPolicyHelper = createCheckoutPolicyHelper();
26
+ //# sourceMappingURL=checkout-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-policy.js","sourceRoot":"","sources":["../../src/plugins/checkout-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAyB,MAAM,mBAA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G,QAAQ,CAAC,CAAC,CAAC,CAC5G,CAAA;IACH,CAAC,CAAA;IAED,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,CAAA;AAC9C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,0BAA0B,EAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { CheckoutPlugin } from '../../types.js';
2
+ /** The checkout plugins seated on one gateway instance. */
3
+ export interface CheckoutPluginRegistry {
4
+ use: (plugin: CheckoutPlugin) => void;
5
+ list: () => readonly CheckoutPlugin[];
6
+ }
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/checkout-registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,2DAA2D;AAC3D,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAA;IACrC,IAAI,EAAE,MAAM,SAAS,cAAc,EAAE,CAAA;CACtC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugins/checkout-registry/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type { CheckoutPluginRegistry } from './checkout-registry/types.js';
2
+ /**
3
+ * The gateway's checkout plugins, the way `ExecutionService.use` seats its own: a plugin with an
4
+ * alias already registered replaces it in place (a layer wired twice must not answer twice), one
5
+ * without an alias is appended.
6
+ */
7
+ export declare const makeCheckoutPluginRegistry: () => CheckoutPluginRegistry;
8
+ //# sourceMappingURL=checkout-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-registry.d.ts","sourceRoot":"","sources":["../../src/plugins/checkout-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAE1E;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,QAAO,sBAc7C,CAAA"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The gateway's checkout plugins, the way `ExecutionService.use` seats its own: a plugin with an
3
+ * alias already registered replaces it in place (a layer wired twice must not answer twice), one
4
+ * without an alias is appended.
5
+ */
6
+ export const makeCheckoutPluginRegistry = () => {
7
+ const plugins = [];
8
+ return {
9
+ use: plugin => {
10
+ const at = plugin.alias != null ? plugins.findIndex(entry => entry.alias === plugin.alias) : -1;
11
+ if (at < 0) {
12
+ plugins.push(plugin);
13
+ }
14
+ else {
15
+ plugins[at] = plugin;
16
+ }
17
+ },
18
+ list: () => [...plugins],
19
+ };
20
+ };
21
+ //# sourceMappingURL=checkout-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-registry.js","sourceRoot":"","sources":["../../src/plugins/checkout-registry.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAA2B,EAAE;IACrE,MAAM,OAAO,GAAqB,EAAE,CAAA;IAEpC,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,EAAE;YACZ,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/F,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACtB,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,EAAE,CAAC,GAAG,MAAM,CAAA;YACtB,CAAC;QACH,CAAC;QACD,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC;KACzB,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { TaxType } from '@owlmeans/payment';
2
+ import type { DisputePhase } from '../types.js';
3
+ export declare const NON_SCALABLE_REASONS: Set<string>;
4
+ export declare const TAX_TYPE_MAP: Readonly<Record<string, TaxType>>;
5
+ export declare const RESYNC_PAGE = 200;
6
+ export declare const DISPUTE_PHASES: Record<string, DisputePhase>;
7
+ /** Stripe's limit on every `custom_text` message. */
8
+ export declare const CUSTOM_TEXT_MAX = 1200;
9
+ export declare const EMAIL: RegExp;
10
+ /** Countries where Stripe Tax cannot place a customer from the country alone (docs: tax/customer-locations). */
11
+ export declare const NEEDS_POSTAL_CODE: Set<string>;
12
+ export declare const NEEDS_POSTAL_CODE_OR_STATE: Set<string>;
13
+ //# sourceMappingURL=consts.local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.local.d.ts","sourceRoot":"","sources":["../../src/plugins/consts.local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,eAAO,MAAM,oBAAoB,aAG/B,CAAA;AAEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzD,CAAA;AAEF,eAAO,MAAM,WAAW,MAAM,CAAA;AAE9B,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAKvD,CAAA;AAED,qDAAqD;AACrD,eAAO,MAAM,eAAe,OAAO,CAAA;AAEnC,eAAO,MAAM,KAAK,QAA+B,CAAA;AAEjD,gHAAgH;AAChH,eAAO,MAAM,iBAAiB,aAAkB,CAAA;AAEhD,eAAO,MAAM,0BAA0B,aAAwB,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { TaxType } from '@owlmeans/payment';
2
+ export const NON_SCALABLE_REASONS = new Set([
3
+ 'portion_product_exempt', 'portion_reduced_rated', 'portion_standard_rated', 'taxable_basis_reduced',
4
+ 'proportionally_rated',
5
+ ]);
6
+ export const TAX_TYPE_MAP = Object.freeze({
7
+ vat: TaxType.Vat, gst: TaxType.Gst, sales_tax: TaxType.SalesTax,
8
+ });
9
+ export const RESYNC_PAGE = 200;
10
+ export const DISPUTE_PHASES = {
11
+ 'charge.dispute.created': 'opened',
12
+ 'charge.dispute.funds_withdrawn': 'funds-withdrawn',
13
+ 'charge.dispute.funds_reinstated': 'funds-reinstated',
14
+ 'charge.dispute.closed': 'closed',
15
+ };
16
+ /** Stripe's limit on every `custom_text` message. */
17
+ export const CUSTOM_TEXT_MAX = 1200;
18
+ export const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
19
+ /** Countries where Stripe Tax cannot place a customer from the country alone (docs: tax/customer-locations). */
20
+ export const NEEDS_POSTAL_CODE = new Set(['US']);
21
+ export const NEEDS_POSTAL_CODE_OR_STATE = new Set(['CA', 'IN']);
22
+ //# sourceMappingURL=consts.local.js.map