@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,174 @@
1
+ import { randomBytes } from 'node:crypto';
2
+ import { AuthForbidden } from '@owlmeans/auth';
3
+ import { ConsumerRightsError, DeclarationChannel, } from '@owlmeans/payment';
4
+ import { handlers } from '@owlmeans/server-api';
5
+ import { bind } from '@owlmeans/server-entrypoint';
6
+ import { CONSUMER_RIGHTS_SERVICE, GATEWAY_SERVICE } from '../consts.js';
7
+ import { DEFAULT_PUBLIC_MIN_MS } from './consts.local.js';
8
+ import { paymentAccessOf } from '../access.js';
9
+ import { originHelper } from './origin.js';
10
+ import { consumerRecordsOf } from './records.js';
11
+ const defaultEntity = (req, _ctx) => req.entity?.id ?? null;
12
+ const sleep = async (ms) => await new Promise(resolve => setTimeout(resolve, ms));
13
+ /** Answer no sooner than `minMs` after the start — a matched declaration takes as long as an unmatched one. */
14
+ const padded = async (minMs, run) => {
15
+ const started = Date.now();
16
+ try {
17
+ return await run();
18
+ }
19
+ finally {
20
+ const left = minMs - (Date.now() - started);
21
+ if (left > 0)
22
+ await sleep(left);
23
+ }
24
+ };
25
+ /** The public answer: what was declared and when — never a status, an amount or a match. */
26
+ const publicPart = (receipt) => ({
27
+ declarationId: receipt.declarationId, receivedAt: receipt.receivedAt, content: receipt.content, mailed: receipt.mailed,
28
+ });
29
+ /** A form a bot filled (the honeypot) gets the same shape of answer, and nothing is recorded or sent. */
30
+ const decoyReceipt = (content) => ({
31
+ declarationId: randomBytes(12).toString('hex'), receivedAt: new Date(), content, mailed: false,
32
+ });
33
+ const typed = (fields) => Object.fromEntries(Object.entries(fields).filter((entry) => typeof entry[1] === 'string' && entry[1].trim() !== ''));
34
+ /**
35
+ * Server bindings of `makeConsumerRightsProtocols`' tree over the consumer-rights service. The
36
+ * account routes act for the request's organization (`resolveEntity`, default `req.entity.id`);
37
+ * the money-moving acts (consent, start request, withdrawal, cancellation) pass `guardMoney` first
38
+ * (refuse an API key there). The public routes — the statutory functions without a login — need
39
+ * `throttle` (a wiring error otherwise), drop a filled honeypot silently, and answer every
40
+ * declaration with the same receipt shape after at least `publicMinMs`, matched or not. Every hook
41
+ * gets the request's context as its last argument.
42
+ *
43
+ * @throws SyntaxError when the tree has a public subtree and no `throttle` is given
44
+ */
45
+ export const consumerRightsEntrypoints = (protocols, opts = {}) => {
46
+ if (protocols.public != null && opts.throttle == null) {
47
+ throw new SyntaxError('consumer-rights: the public routes need a throttle');
48
+ }
49
+ const api = handlers();
50
+ const serviceOf = (ctx) => ctx.service(opts.serviceAlias ?? CONSUMER_RIGHTS_SERVICE);
51
+ const apiCtx = (ctx) => ctx;
52
+ const entityOf = (req, ctx) => {
53
+ const entityId = (opts.resolveEntity ?? defaultEntity)(req, apiCtx(ctx));
54
+ if (entityId == null || entityId === '') {
55
+ throw new AuthForbidden('entity');
56
+ }
57
+ return entityId;
58
+ };
59
+ const subjectFor = async (req, ctx) => ({
60
+ ...(await opts.subjectOf?.(req, apiCtx(ctx)) ?? {}),
61
+ entityId: entityOf(req, ctx),
62
+ channel: DeclarationChannel.InApp,
63
+ });
64
+ const metaOf = (req, ctx) => opts.metaOf != null ? opts.metaOf(req, apiCtx(ctx)) : originHelper.requestOriginOf(req);
65
+ const guard = async (req, action, ctx) => {
66
+ await opts.guardMoney?.(req, action, apiCtx(ctx));
67
+ };
68
+ const minMs = opts.publicMinMs ?? DEFAULT_PUBLIC_MIN_MS;
69
+ const bound = [
70
+ bind(protocols.base),
71
+ bind(protocols.profile, api.request(protocols.profile, async (req, ctx) => await serviceOf(ctx).profile(entityOf(req, ctx))
72
+ ?? consumerRecordsOf(apiCtx(ctx))
73
+ .unlockedProfileView(await paymentAccessOf(apiCtx(ctx)).payment().consumerRightsPolicy()))),
74
+ bind(protocols.purchases, api.request(protocols.purchases, async (req, ctx) => ({ purchases: await serviceOf(ctx).purchases(entityOf(req, ctx)) }))),
75
+ bind(protocols.consent, api.request(protocols.consent, async (req, ctx) => await serviceOf(ctx).consentView(entityOf(req, ctx)))),
76
+ bind(protocols.giveConsent, api.body(protocols.giveConsent, async (body, ctx, req) => {
77
+ await guard(req, 'consent', ctx);
78
+ return await serviceOf(ctx).recordConsent(await subjectFor(req, ctx), body, metaOf(req, ctx));
79
+ })),
80
+ bind(protocols.start, api.request(protocols.start, async (req, ctx) => await serviceOf(ctx).startView(entityOf(req, ctx), String(req.query.planSku)))),
81
+ bind(protocols.requestStart, api.body(protocols.requestStart, async (body, ctx, req) => {
82
+ await guard(req, 'start', ctx);
83
+ const plan = await opts.planNameOf?.(body.planSku, body.language, req, apiCtx(ctx));
84
+ return await serviceOf(ctx).recordStartRequest(await subjectFor(req, ctx), body, metaOf(req, ctx), plan != null ? { plan } : {});
85
+ })),
86
+ bind(protocols.withdrawals, api.request(protocols.withdrawals, async (req, ctx) => {
87
+ const subject = await subjectFor(req, ctx);
88
+ return await serviceOf(ctx).withdrawalCandidates(subject.entityId, subject);
89
+ })),
90
+ bind(protocols.withdraw, api.body(protocols.withdraw, async (body, ctx, req) => {
91
+ await guard(req, 'withdraw', ctx);
92
+ return await serviceOf(ctx).withdraw(await subjectFor(req, ctx), body, metaOf(req, ctx));
93
+ })),
94
+ bind(protocols.cancel, api.body(protocols.cancel, async (body, ctx, req) => {
95
+ await guard(req, 'cancel', ctx);
96
+ return await serviceOf(ctx).cancel(await subjectFor(req, ctx), body, metaOf(req, ctx));
97
+ })),
98
+ ];
99
+ const pub = protocols.public;
100
+ if (pub == null) {
101
+ return bound;
102
+ }
103
+ const throttle = opts.throttle;
104
+ return [
105
+ ...bound,
106
+ bind(pub.base),
107
+ bind(pub.policy, api.request(pub.policy, async (_req, ctx) => {
108
+ const policy = await paymentAccessOf(ctx).payment().consumerRightsPolicy();
109
+ if (policy == null) {
110
+ throw new ConsumerRightsError('policy:none');
111
+ }
112
+ const view = {
113
+ mechanisms: { withdrawal: policy.mechanisms.withdrawal, cancellation: policy.mechanisms.cancellation },
114
+ languages: Object.keys(policy.links),
115
+ links: policy.links,
116
+ textVersion: policy.textVersion,
117
+ };
118
+ return view;
119
+ })),
120
+ bind(pub.withdraw, api.body(pub.withdraw, async (body, ctx, req) => {
121
+ const origin = metaOf(req, ctx);
122
+ await throttle(req, { action: 'withdrawal', email: body.email, ...(origin.ip != null ? { ip: origin.ip } : {}) }, apiCtx(ctx));
123
+ return await padded(minMs, async () => {
124
+ const content = typed({ name: body.name, contract: body.contractRef, email: body.email });
125
+ if (body.honeypot != null && body.honeypot !== '') {
126
+ return decoyReceipt(content);
127
+ }
128
+ return publicPart(await serviceOf(ctx).withdraw(null, body, origin));
129
+ });
130
+ })),
131
+ bind(pub.cancel, api.body(pub.cancel, async (body, ctx, req) => {
132
+ const origin = metaOf(req, ctx);
133
+ await throttle(req, { action: 'cancellation', email: body.email, ...(origin.ip != null ? { ip: origin.ip } : {}) }, apiCtx(ctx));
134
+ return await padded(minMs, async () => {
135
+ const content = typed({
136
+ name: body.name, contract: body.contractRef, email: body.email, kind: body.kind, reason: body.reason,
137
+ date: body.effective === 'date' ? body.date : undefined,
138
+ });
139
+ if (body.honeypot != null && body.honeypot !== '') {
140
+ return decoyReceipt(content);
141
+ }
142
+ return publicPart(await serviceOf(ctx).cancel(null, body, origin));
143
+ });
144
+ })),
145
+ ];
146
+ };
147
+ /**
148
+ * Server bindings of `makeCheckoutReadProtocols`' tree: the entity's amount policy as the checkout
149
+ * plugins narrow it now (the same computation the checkout enforces) and the synced plan prices.
150
+ */
151
+ export const checkoutReadEntrypoints = (protocols, opts = {}) => {
152
+ const api = handlers();
153
+ const gatewayOf = (ctx) => ctx.service(opts.gatewayAlias ?? GATEWAY_SERVICE);
154
+ const entityOf = (req, ctx) => {
155
+ const entityId = (opts.resolveEntity ?? defaultEntity)(req, ctx);
156
+ if (entityId == null || entityId === '') {
157
+ throw new AuthForbidden('entity');
158
+ }
159
+ return entityId;
160
+ };
161
+ return [
162
+ bind(protocols.base),
163
+ bind(protocols.amountPolicy, api.request(protocols.amountPolicy, async (req, ctx) => {
164
+ const { productSku, planSku } = req.query;
165
+ return await gatewayOf(ctx).amountPolicy(ctx, entityOf(req, ctx), productSku, planSku ?? undefined);
166
+ })),
167
+ bind(protocols.planPrices, api.request(protocols.planPrices, async (req, ctx) => {
168
+ entityOf(req, ctx);
169
+ const { productSku } = req.query;
170
+ return { prices: await gatewayOf(ctx).planPrices(ctx, productSku) };
171
+ })),
172
+ ];
173
+ };
174
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/consumer/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,EACL,mBAAmB,EAAE,kBAAkB,GAExC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,QAAQ,EAA8B,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAKvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,MAAM,aAAa,GAAG,C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U,EAAE,GAAG,GAAG,CAAC,KAA+B,CAAA;YAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,GAA4B,EAAE,UAAU,CAAC,EAAE,CAAA;QAC9F,CAAC,CAAC,CAAC;KACO,CAAA;AACd,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ export type { ConsumerRightsTree } from './types.js';
2
+ export { appendConsumerRights, makeConsumerRightsService } from './service.js';
3
+ export { consumerRightsEntrypoints, checkoutReadEntrypoints } from './handlers.js';
4
+ export type * from './format/types.js';
5
+ export * from './format.js';
6
+ export type * from './origin/types.js';
7
+ export * from './origin.js';
8
+ export type * from './mail/types.js';
9
+ export * from './mail.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumer/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAClF,mBAAmB,mBAAmB,CAAA;AACtC,cAAc,aAAa,CAAA;AAC3B,mBAAmB,mBAAmB,CAAA;AACtC,cAAc,aAAa,CAAA;AAC3B,mBAAmB,iBAAiB,CAAA;AACpC,cAAc,WAAW,CAAA"}
@@ -0,0 +1,6 @@
1
+ export { appendConsumerRights, makeConsumerRightsService } from './service.js';
2
+ export { consumerRightsEntrypoints, checkoutReadEntrypoints } from './handlers.js';
3
+ export * from './format.js';
4
+ export * from './origin.js';
5
+ export * from './mail.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/consumer/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAElF,cAAc,aAAa,CAAA;AAE3B,cAAc,aAAa,CAAA;AAE3B,cAAc,WAAW,CAAA"}
@@ -0,0 +1,29 @@
1
+ import type { ConsumerRightsPolicy } from '@owlmeans/payment';
2
+ import type { ConsumerMailData, ConsumerMailKind, ConsumerMailPluginConfig, TraderDef } from '../../types.js';
3
+ /** The consumer-rights mails of a context, on a durable medium. */
4
+ export interface ConsumerMailHelper {
5
+ /** The trader as the mails and the withdrawal information name it: legal name, address, e-mail. */
6
+ traderIdentityOf: (trader: TraderDef) => string;
7
+ /** The declared trader; an undeclared one falls back to the service name (no mechanism is on then). */
8
+ traderOf: (mail: ConsumerMailPluginConfig | null) => TraderDef;
9
+ /** A plan's title in a language: its localization, else its catalogue title, else its sku. */
10
+ planTitleOf: (planSku: string | undefined, lng: string) => Promise<string>;
11
+ /**
12
+ * Everything a mail of `kind` about `recordId` is rendered from, read back from the records — the
13
+ * mail repeats exactly what was recorded, and a retry renders the same message. `null` when there
14
+ * is nobody to write to.
15
+ */
16
+ mailDataOf: (policy: ConsumerRightsPolicy, trader: TraderDef, kind: ConsumerMailKind, recordId: string) => Promise<ConsumerMailData | null>;
17
+ /**
18
+ * Send one consumer-rights mail on a durable medium, in the language the consumer was shown, and
19
+ * record the outcome as a `mail` event (step = the mail kind): sent, skipped (a reserved domain
20
+ * such as `.test` / `.example` / `.invalid` / `.localhost`, or a renderer that suppressed it) or
21
+ * failed (a transport error, no mailer registered — retried by `reconcile`). The application's
22
+ * renderer (`useMailRenderer`) may replace the message. Each archive (`bcc`) address gets its own
23
+ * copy. Never throws.
24
+ *
25
+ * @returns whether the consumer's own copy was handed to the mailer
26
+ */
27
+ sendConsumerMail: (policy: ConsumerRightsPolicy, kind: ConsumerMailKind, recordId: string) => Promise<boolean>;
28
+ }
29
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/consumer/mail/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE7G,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,mGAAmG;IACnG,gBAAgB,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,MAAM,CAAA;IAC/C,uGAAuG;IACvG,QAAQ,EAAE,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI,KAAK,SAAS,CAAA;IAC9D,8FAA8F;IAC9F,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC1E;;;;OAIG;IACH,UAAU,EAAE,CACV,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,KACtF,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAA;IACrC;;;;;;;;;OASG;IACH,gBAAgB,EAAE,CAAC,MAAM,EAAE,oBAAoB,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC/G"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/consumer/mail/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { Context as ApiContext } from '@owlmeans/server-api';
2
+ import type { ConsumerMailHelper } from './mail/types.js';
3
+ export declare const makeConsumerMailHelper: (ctx: ApiContext) => ConsumerMailHelper;
4
+ /** The consumer-rights mails of a context — one per context. */
5
+ export declare const consumerMailOf: (target: ApiContext<import("@owlmeans/server-api").Config>) => ConsumerMailHelper;
6
+ //# sourceMappingURL=mail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../src/consumer/mail.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAcjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAsHzD,eAAO,MAAM,sBAAsB,QAAS,UAAU,KAAG,kBAuNxD,CAAA;AAED,gEAAgE;AAChE,eAAO,MAAM,cAAc,mFAA6C,CAAA"}
@@ -0,0 +1,313 @@
1
+ import { MAILER_SERVICE } from '@owlmeans/mailer';
2
+ import { CancellationStatus, PurchaseKind, WithdrawalStatus, consumerCopyHelper, consumerRightsPolicyHelper } from '@owlmeans/payment';
3
+ import { memoHelper } from '@owlmeans/context';
4
+ import { log } from '../log.js';
5
+ import { RECORD_KIND } from './consts.local.js';
6
+ import { paymentAccessOf } from '../access.js';
7
+ import { paymentUtils } from '../utils.js';
8
+ import { catalogueOf } from '../catalogue.js';
9
+ import { consumerFormatHelper } from './format.js';
10
+ import { consumerRecordsOf } from './records.js';
11
+ const text = (lng, path, vars = {}, context) => consumerCopyHelper.consumerText(lng, path, vars, context);
12
+ const textOf = (blocks, lng) => blocks
13
+ .map(block => 'text' in block ? block.text : text(lng, 'email.common.link', { label: block.label, url: block.url }))
14
+ .join('\n\n');
15
+ const htmlOf = (blocks) => blocks.map(block => 'text' in block
16
+ ? `<p>${consumerFormatHelper.escapeHtml(block.text).replace(/\n/g, '<br>')}</p>`
17
+ : `<p>${consumerFormatHelper.escapeHtml(block.label)}: `
18
+ + `<a href="${consumerFormatHelper.escapeHtml(block.url)}">${consumerFormatHelper.escapeHtml(block.url)}</a></p>`).join('\n');
19
+ const linkBlocks = (lng, links, which) => {
20
+ const labels = {
21
+ billingTerms: 'links.billing-terms',
22
+ withdrawalInformation: 'links.withdrawal-information',
23
+ withdrawalForm: 'links.withdrawal-form',
24
+ withdrawalFunction: 'links.withdrawal-function',
25
+ cancellation: 'links.cancellation',
26
+ };
27
+ return which
28
+ .filter(key => links[key] != null && links[key] !== '')
29
+ .map(key => ({ label: text(lng, labels[key]), url: links[key] }));
30
+ };
31
+ /** The trader as the mails and the withdrawal information name it: legal name, address, e-mail. */
32
+ const traderIdentityOf = (trader) => [trader.legalName, trader.address, trader.email].filter(part => part != null && part.trim() !== '').join(', ');
33
+ const renderConsent = (data) => {
34
+ const lng = data.language;
35
+ const consent = data.consent;
36
+ const lines = (data.purchases ?? []).map(purchase => text(lng, 'email.consent.purchase', {
37
+ contractRef: purchase.contractRef,
38
+ date: consumerFormatHelper.formatDate(new Date(purchase.purchasedAt), lng),
39
+ amount: consumerFormatHelper.formatMoney(purchase.amountTotalMinor, purchase.currency, lng),
40
+ deadline: purchase.deadline != null ? consumerFormatHelper.formatDeadline(new Date(purchase.deadline), lng) : '—',
41
+ }));
42
+ return {
43
+ subject: text(lng, 'email.consent.subject'),
44
+ blocks: [
45
+ {
46
+ text: text(lng, 'email.consent.body', {
47
+ date: consumerFormatHelper.formatDateTime(new Date(consent.decidedAt), lng), statement: consent.text.checkbox,
48
+ purchases: lines.join('\n'),
49
+ }),
50
+ },
51
+ { text: text(lng, 'email.consent.unused') },
52
+ ...linkBlocks(lng, data.links, ['billingTerms', 'withdrawalInformation', 'withdrawalFunction']),
53
+ ],
54
+ };
55
+ };
56
+ const renderWithdrawal = (data) => {
57
+ const lng = data.language;
58
+ const declaration = data.declaration;
59
+ const blocks = [{
60
+ text: text(lng, 'email.withdrawal.body', {
61
+ date: consumerFormatHelper.formatDateTime(new Date(declaration.receivedAt), lng), name: declaration.name,
62
+ contract: declaration.contractRef ?? data.purchase?.contractRef ?? '—', email: declaration.email,
63
+ }),
64
+ }];
65
+ const status = declaration.status;
66
+ // `received`: nothing is executed on this declaration (no match, or no statutory right) — the
67
+ // receipt says what happens if it does match, exactly as for an unknown contract.
68
+ if (!declaration.matched || declaration.duplicateOf != null || status === WithdrawalStatus.Received) {
69
+ blocks.push({ text: text(lng, 'email.withdrawal.unmatched') });
70
+ }
71
+ else if (status === WithdrawalStatus.Expired) {
72
+ const deadline = data.purchase?.deadline;
73
+ blocks.push({
74
+ text: text(lng, 'email.withdrawal.expired', {
75
+ deadline: deadline != null ? consumerFormatHelper.formatDeadline(new Date(deadline), lng) : '—',
76
+ }),
77
+ });
78
+ }
79
+ else if ((status === WithdrawalStatus.Processing || status === WithdrawalStatus.Refunded)
80
+ && declaration.refundMinor != null && declaration.currency != null) {
81
+ blocks.push({ text: text(lng, 'email.withdrawal.refund', { amount: consumerFormatHelper.formatMoney(declaration.refundMinor, declaration.currency, lng) }) });
82
+ }
83
+ else {
84
+ blocks.push({ text: text(lng, 'email.withdrawal.review') });
85
+ }
86
+ blocks.push(...linkBlocks(lng, data.links, ['billingTerms', 'withdrawalInformation']));
87
+ return { subject: text(lng, 'email.withdrawal.subject'), blocks };
88
+ };
89
+ const renderCancellation = (data) => {
90
+ const lng = data.language;
91
+ const declaration = data.declaration;
92
+ const requested = declaration.effective === 'date' && declaration.requestedDate != null
93
+ ? consumerFormatHelper.formatDate(new Date(`${declaration.requestedDate}T00:00:00Z`), lng)
94
+ : text(lng, 'cancellation.effective-earliest');
95
+ const blocks = [{
96
+ text: text(lng, 'email.cancellation.body', {
97
+ date: consumerFormatHelper.formatDateTime(new Date(declaration.receivedAt), lng), name: declaration.name,
98
+ contract: declaration.contractRef ?? declaration.subscriptionId ?? '—',
99
+ kind: text(lng, `cancellation.kind-${declaration.cancellationKind ?? 'ordinary'}`),
100
+ requested, email: declaration.email,
101
+ }),
102
+ }];
103
+ if (declaration.status === CancellationStatus.Review) {
104
+ blocks.push({ text: text(lng, 'email.cancellation.review') });
105
+ }
106
+ else if (declaration.matched && declaration.effectiveAt != null) {
107
+ blocks.push({ text: text(lng, 'email.cancellation.effective', { effectiveAt: consumerFormatHelper.formatDate(new Date(declaration.effectiveAt), lng) }) });
108
+ }
109
+ else {
110
+ blocks.push({ text: text(lng, 'email.cancellation.unmatched') });
111
+ }
112
+ blocks.push(...linkBlocks(lng, data.links, ['billingTerms']));
113
+ return { subject: text(lng, 'email.cancellation.subject'), blocks };
114
+ };
115
+ export const makeConsumerMailHelper = (ctx) => {
116
+ const access = paymentAccessOf(ctx);
117
+ const records = consumerRecordsOf(ctx);
118
+ const traderOf = (mail) => mail?.trader ?? { name: ctx.cfg.service, legalName: ctx.cfg.service };
119
+ const planTitleOf = async (planSku, lng) => {
120
+ if (planSku == null) {
121
+ return '';
122
+ }
123
+ const plan = await catalogueOf(ctx).findPlan(planSku);
124
+ const localized = plan != null ? await access.payment().localize(lng, plan).catch(() => null) : null;
125
+ return localized?.title ?? plan?.title ?? planSku;
126
+ };
127
+ const productTitleOf = async (purchase, lng) => {
128
+ const plan = purchase.planSku != null ? await catalogueOf(ctx).findPlan(purchase.planSku) : null;
129
+ const product = await catalogueOf(ctx).findProduct(purchase.productSku);
130
+ const entity = plan ?? product;
131
+ const localized = entity != null ? await access.payment().localize(lng, entity).catch(() => null) : null;
132
+ return localized?.title ?? plan?.title ?? product?.title ?? purchase.productSku;
133
+ };
134
+ const renderPurchase = async (data) => {
135
+ const lng = data.language;
136
+ const purchase = data.purchase;
137
+ const blocks = [{
138
+ text: text(lng, 'email.purchase.body', {
139
+ contractRef: purchase.contractRef,
140
+ date: consumerFormatHelper.formatDateTime(new Date(purchase.purchasedAt), lng),
141
+ product: await productTitleOf(purchase, lng),
142
+ total: consumerFormatHelper.formatMoney(purchase.amountTotalMinor, purchase.currency, lng),
143
+ tax: consumerFormatHelper.formatMoney(purchase.amountTaxMinor, purchase.currency, lng),
144
+ }),
145
+ }];
146
+ if (data.consent != null) {
147
+ blocks.push({ text: text(lng, 'email.purchase.start-request', { statement: data.consent.text.checkbox }) });
148
+ }
149
+ const identity = traderIdentityOf(data.trader);
150
+ blocks.push({
151
+ text: text(lng, 'email.purchase.withdrawal-information', {
152
+ trader: identity,
153
+ withdrawalFunction: data.links.withdrawalFunction ?? data.links.withdrawalInformation ?? data.links.billingTerms,
154
+ }),
155
+ });
156
+ blocks.push({ text: text(lng, 'email.purchase.model-form', { trader: identity }) });
157
+ blocks.push(...linkBlocks(lng, data.links, [
158
+ 'billingTerms', 'withdrawalInformation', 'withdrawalForm', 'withdrawalFunction',
159
+ ...(purchase.kind === PurchaseKind.Subscription ? ['cancellation'] : []),
160
+ ]));
161
+ return { subject: text(lng, 'email.purchase.subject', { contractRef: purchase.contractRef }), blocks };
162
+ };
163
+ const renderStart = async (data) => {
164
+ const lng = data.language;
165
+ const consent = data.consent;
166
+ const title = consent.planName ?? await planTitleOf(consent.planSku, lng);
167
+ return {
168
+ subject: text(lng, 'email.start.subject', { plan: title }),
169
+ blocks: [
170
+ {
171
+ text: text(lng, 'email.start.body', {
172
+ date: consumerFormatHelper.formatDateTime(new Date(consent.decidedAt), lng), plan: title, statement: consent.text.checkbox,
173
+ }),
174
+ },
175
+ // The rule of the variant the statement was recorded in (`_units` for a plan with a units part).
176
+ { text: text(lng, 'email.start.rule', {}, consent.context) },
177
+ ...linkBlocks(lng, data.links, ['billingTerms', 'withdrawalInformation', 'withdrawalFunction']),
178
+ ],
179
+ };
180
+ };
181
+ const mailDataOf = async (policy, trader, kind, recordId) => {
182
+ const base = { kind, recordId, trader };
183
+ switch (kind) {
184
+ case 'purchase': {
185
+ const purchase = await access.purchases().byPurchaseId(recordId);
186
+ if (purchase?.email == null || purchase.email === '')
187
+ return null;
188
+ const consent = purchase.startRequestId != null
189
+ ? await access.consumerConsents().load(purchase.startRequestId).catch(() => null) : null;
190
+ return paymentUtils.compact({
191
+ ...base, entityId: purchase.entityId, language: purchase.language, to: purchase.email,
192
+ name: purchase.name ?? undefined, links: consumerRightsPolicyHelper.linksOf(policy, purchase.language), purchase,
193
+ consent: consent ?? undefined,
194
+ });
195
+ }
196
+ case 'consent':
197
+ case 'start': {
198
+ const consent = await access.consumerConsents().load(recordId);
199
+ if (consent == null)
200
+ return null;
201
+ const to = consent.email ?? await records.contactEmailOf(consent.entityId);
202
+ if (to == null)
203
+ return null;
204
+ const covered = consent.purchaseIds.length > 0
205
+ ? (await access.purchases().list({ purchaseId: consent.purchaseIds }, { size: 0 })).items : [];
206
+ return paymentUtils.compact({
207
+ ...base, entityId: consent.entityId, language: consent.language, to, name: consent.name ?? undefined,
208
+ links: consent.links, consent, purchases: covered,
209
+ });
210
+ }
211
+ default: {
212
+ const declaration = await access.consumerDeclarations().load(recordId);
213
+ if (declaration == null)
214
+ return null;
215
+ const purchase = declaration.purchaseId != null ? await access.purchases().byPurchaseId(declaration.purchaseId) : null;
216
+ return paymentUtils.compact({
217
+ ...base, entityId: declaration.entityId ?? undefined, language: declaration.language, to: declaration.email,
218
+ name: declaration.name, links: consumerRightsPolicyHelper.linksOf(policy, declaration.language), declaration,
219
+ purchase: purchase ?? undefined,
220
+ });
221
+ }
222
+ }
223
+ };
224
+ const render = async (data, mail) => {
225
+ const lng = data.language;
226
+ const body = data.kind === 'purchase' ? await renderPurchase(data)
227
+ : data.kind === 'consent' ? renderConsent(data)
228
+ : data.kind === 'start' ? await renderStart(data)
229
+ : data.kind === 'withdrawal' ? renderWithdrawal(data)
230
+ : renderCancellation(data);
231
+ const blocks = [
232
+ { text: data.name != null && data.name !== '' ? text(lng, 'email.common.greeting-named', { name: data.name }) : text(lng, 'email.common.greeting') },
233
+ ...body.blocks,
234
+ { text: text(lng, 'email.common.trader', { trader: traderIdentityOf(data.trader) }) },
235
+ { text: text(lng, 'email.common.footer') },
236
+ ];
237
+ return paymentUtils.compact({
238
+ to: data.to,
239
+ subject: body.subject,
240
+ text: textOf(blocks, lng),
241
+ html: htmlOf(blocks),
242
+ from: mail?.from,
243
+ replyTo: mail?.replyTo,
244
+ });
245
+ };
246
+ const mailerOf = (alias) => ctx.hasService?.(alias) === true
247
+ ? ctx.service(alias) : null;
248
+ const sendConsumerMail = async (policy, kind, recordId) => {
249
+ const recordKind = RECORD_KIND[kind];
250
+ let entityId;
251
+ try {
252
+ const mail = await access.consumerMailConfig();
253
+ const data = await mailDataOf(policy, traderOf(mail), kind, recordId);
254
+ entityId = data?.entityId;
255
+ if (data == null) {
256
+ await records.recordEvent({
257
+ recordId, recordKind, action: 'mail', step: kind, ok: true, skipped: true, detail: '{"reason":"no-recipient"}',
258
+ });
259
+ return false;
260
+ }
261
+ if (consumerFormatHelper.isReservedAddress(data.to)) {
262
+ await records.recordEvent({
263
+ recordId, recordKind, entityId, action: 'mail', step: kind, ok: true, skipped: true,
264
+ detail: JSON.stringify({ reason: 'reserved-domain', to: data.to }),
265
+ });
266
+ return false;
267
+ }
268
+ const rendered = await render(data, mail);
269
+ const renderer = access.consumerRightsOf()?.mailRenderer() ?? null;
270
+ const replaced = renderer != null ? await renderer(kind, data, rendered) : undefined;
271
+ if (replaced === null) {
272
+ await records.recordEvent({
273
+ recordId, recordKind, entityId, action: 'mail', step: kind, ok: true, skipped: true, detail: '{"reason":"renderer"}',
274
+ });
275
+ return false;
276
+ }
277
+ const message = replaced ?? rendered;
278
+ const mailer = mailerOf(mail?.alias ?? MAILER_SERVICE);
279
+ if (mailer == null) {
280
+ await records.recordEvent({
281
+ recordId, recordKind, entityId, action: 'mail', step: kind, ok: false, error: 'mailer:absent',
282
+ });
283
+ return false;
284
+ }
285
+ await mailer.send(message);
286
+ const archive = [];
287
+ for (const address of mail?.bcc ?? []) {
288
+ try {
289
+ await mailer.send({ ...message, to: address });
290
+ }
291
+ catch (error) {
292
+ archive.push(`${address}: ${paymentUtils.errorText(error)}`);
293
+ }
294
+ }
295
+ await records.recordEvent({
296
+ recordId, recordKind, entityId, action: 'mail', step: kind, ok: true,
297
+ detail: JSON.stringify(paymentUtils.compact({ to: message.to, subject: message.subject, archiveFailures: archive.length > 0 ? archive : undefined })),
298
+ });
299
+ return true;
300
+ }
301
+ catch (error) {
302
+ log.error('Consumer mail failed', { kind, recordId, error });
303
+ await records.recordEvent({
304
+ recordId, recordKind, entityId, action: 'mail', step: kind, ok: false, error: paymentUtils.errorText(error),
305
+ });
306
+ return false;
307
+ }
308
+ };
309
+ return { traderIdentityOf, traderOf, planTitleOf, mailDataOf, sendConsumerMail };
310
+ };
311
+ /** The consumer-rights mails of a context — one per context. */
312
+ export const consumerMailOf = memoHelper.oncePer(makeConsumerMailHelper);
313
+ //# sourceMappingURL=mail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mail.js","sourceRoot":"","sources":["../../src/consumer/mail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAwC,MAAM,kBAAkB,CAAA;AACvF,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAwE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AAE5M,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAK9C,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAGhD,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,IAAY,EAAE,IAAI,GAAe,EAAE,EAAE,OAAgB,EAAU,EAAE,CAC1F,kBAAkB,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AAE3D,MAAM,MAAM,GAAG,CAAC,MAAe,EAAE,GAAW,EAAU,EAAE,CAAC,MAAM;KAC5D,GAAG,CAAC,KAAK,CAAC,EA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