@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,72 @@
1
+ import { createService } from '@owlmeans/context';
2
+ import { INTERNAL_PAYGATE, SubscriptionStatus, entitlementViewHelper, planLimitHelper } from '@owlmeans/payment';
3
+ import { ENTITLEMENT_SERVICE } from './consts.js';
4
+ import { paymentAccessOf } from './access.js';
5
+ import { paymentUtils } from './utils.js';
6
+ import { catalogueOf } from './catalogue.js';
7
+ import { planHelper } from './plan.js';
8
+ import { usageOf } from './usage.js';
9
+ const dateOrUndefined = (value) => value == null ? undefined : new Date(value);
10
+ /** The plan half of an entitlement view. `subscribedAt` is what a grandfathered promo is measured against. */
11
+ const planViewOf = (effective) => {
12
+ const { plan, subscription, fallback } = effective;
13
+ const status = subscription?.status ?? SubscriptionStatus.Active;
14
+ return paymentUtils.compact({
15
+ sku: plan.sku,
16
+ productSku: plan.productSku,
17
+ title: plan.title,
18
+ rank: planHelper.planRank(plan),
19
+ free: plan.free === true,
20
+ status,
21
+ paygate: subscription?.paygate ?? INTERNAL_PAYGATE,
22
+ subscriptionId: subscription?.externalId ?? undefined,
23
+ subscribedAt: dateOrUndefined(subscription?.createdAt),
24
+ periodStart: dateOrUndefined(subscription?.periodStart),
25
+ periodEnd: dateOrUndefined(subscription?.periodEnd),
26
+ cancelAtPeriodEnd: subscription?.cancelAtPeriodEnd ?? undefined,
27
+ trialEnd: dateOrUndefined(subscription?.trialEnd),
28
+ pausedAt: dateOrUndefined(subscription?.pausedAt),
29
+ pastDue: status === SubscriptionStatus.PastDue,
30
+ fallbackSku: plan.free !== true ? fallback?.sku : undefined,
31
+ });
32
+ };
33
+ /** Plan resolution, the entitlement view and the usage ledger — Mongo only, never the paygate. */
34
+ export const makeEntitlementService = (alias = ENTITLEMENT_SERVICE) => {
35
+ // What an entity may do now: its effective plan, every capability and every limit with its usage.
36
+ const entitlementViewFor = async (entityId) => {
37
+ const ctx = ctxOf();
38
+ const at = new Date();
39
+ const effective = await catalogueOf(ctx).resolveEffectivePlan(entityId, at);
40
+ const declared = Object.entries(effective.plan.limits ?? {});
41
+ const windows = new Map(declared.map(([key, declaration]) => [
42
+ key, planLimitHelper.windowKeyOf(declaration.kind, declaration.window, at, effective.subscription?.createdAt),
43
+ ]));
44
+ const usage = [];
45
+ if (declared.length > 0) {
46
+ const { items } = await paymentAccessOf(ctx).usageCounters().list({
47
+ entityId, limitKey: [...windows.keys()], window: [...new Set(windows.values())],
48
+ }, { size: 0 });
49
+ for (const counter of items) {
50
+ if (windows.get(counter.limitKey) === counter.window) {
51
+ usage.push({ key: counter.limitKey, window: counter.window, used: counter.used });
52
+ }
53
+ }
54
+ }
55
+ return entitlementViewHelper.entitlementViewOf(effective.plan, planViewOf(effective), usage, at);
56
+ };
57
+ const service = createService(alias, {
58
+ effectivePlan: async (entityId) => await catalogueOf(ctxOf()).resolveEffectivePlan(entityId),
59
+ entitlements: async (entityId) => await entitlementViewFor(entityId),
60
+ hasCapability: async (entityId, param) => planLimitHelper.capabilityOf(await entitlementViewFor(entityId), param),
61
+ limitState: async (entityId, key) => await usageOf(ctxOf()).limitStateOf(entityId, key),
62
+ consume: async (req) => await usageOf(ctxOf()).consumeLimit(req),
63
+ release: async (req) => await usageOf(ctxOf()).releaseLimit(req),
64
+ reconcileOccupancy: async (entityId, limitKey, actual) => await usageOf(ctxOf()).reconcileOccupancyOf(entityId, limitKey, actual),
65
+ reconcileCounters: async (entityId) => await usageOf(ctxOf()).reconcileLedgerCounters(entityId),
66
+ consumption: async (entityId, limitKey, eventKey) => await usageOf(ctxOf()).consumptionOf(entityId, limitKey, eventKey),
67
+ consumptionByRef: async (entityId, limitKey, ref) => await usageOf(ctxOf()).consumptionByRefOf(entityId, limitKey, ref),
68
+ });
69
+ const ctxOf = () => service.assertCtx();
70
+ return service;
71
+ };
72
+ //# sourceMappingURL=entitlement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entitlement.js","sourceRoot":"","sources":["../src/entitlement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAGhH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,eAAe,GAAG,CAAC,KAA8B,EAAoB,EAAE,CAC3E,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAA;AAE7C,8GAA8G;AAC9G,MAAM,UAAU,GAAG,CAAC,SAAwB,EAAuB,EAAE;IACnE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAA;IAClD,MAAM,MAAM,GAAG,YAAY,EAAE,MAAM,IAAI,kBAAkB,CAAC,MAAM,CAAA;IAEhE,OAAO,YAAY,CAAC,OAAO,CAAsB;QAC/C,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,UAAU,EAAE,IAAI,CAAC,U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E,QAAQ,CAAC;QACpE,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,CAClD,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC;KACrE,CAAC,CAAA;IACF,MAAM,KAAK,GAAG,GAAe,EAAE,CAAC,OAAO,CAAC,SAAS,EAA2B,CAAA;IAE5E,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
@@ -1,5 +1,22 @@
1
+ /**
2
+ * The payment gate's action handlers, for an application that declares the gate itself — its own
3
+ * aliases, a route pinned to its own service: `bind(own.webhook, paymentGateHandlers.webhook)`.
4
+ *
5
+ * A handler reads its context from the entrypoint it is bound to, so the application's own
6
+ * declaration is the one registered, mounted and run. That declaration keeps `paymentGate`'s paths
7
+ * (`webhookUrlOf` registers the webhook at `paymentGate`'s path), contracts and guards. Bind each
8
+ * one with `bind` itself: `bindAll` pairs a handler with the declaration it was made for, by object
9
+ * identity, and leaves another declaration without one.
10
+ */
11
+ export declare const paymentGateHandlers: Readonly<{
12
+ webhook: import("@owlmeans/server-entrypoint").BoundEntrypointHandler<import("@owlmeans/entrypoint").EntrypointProtocol<{
13
+ params: import("./types.js").PaygateParams;
14
+ }, undefined>>;
15
+ resync: import("@owlmeans/server-entrypoint").BoundEntrypointHandler<import("@owlmeans/entrypoint").EntrypointProtocol<{}, import("./types.js").ResyncResult>>;
16
+ resyncSubscriptions: import("@owlmeans/server-entrypoint").BoundEntrypointHandler<import("@owlmeans/entrypoint").EntrypointProtocol<{}, import("./types.js").ResyncSubscriptionsResult>>;
17
+ }>;
1
18
  /** Runtime-local bindings for the shared immutable payment-gateway protocol tree. */
2
19
  export declare const paymentGateEntrypoints: (import("@owlmeans/server-entrypoint").ServerProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<{
3
- params: import("./consts.js").PaygateParams;
4
- }, undefined>> | import("@owlmeans/server-entrypoint").ServerProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<{}, undefined>> | import("@owlmeans/server-entrypoint").ServerProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<{}, import("./consts.js").ResyncResult>>)[];
20
+ params: import("./types.js").PaygateParams;
21
+ }, undefined>> | import("@owlmeans/server-entrypoint").ServerProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<{}, undefined>> | import("@owlmeans/server-entrypoint").ServerProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<{}, import("./types.js").ResyncResult>> | import("@owlmeans/server-entrypoint").ServerProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<{}, import("./types.js").ResyncSubscriptionsResult>>)[];
5
22
  //# sourceMappingURL=entrypoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAIA,qFAAqF;AACrF,eAAO,MAAM,sBAAsB;;gTAIlC,CAAA"}
1
+ {"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB;;;;;;EAA0D,CAAA;AAE1F,qFAAqF;AACrF,eAAO,MAAM,sBAAsB;;udAKlC,CAAA"}
@@ -1,10 +1,22 @@
1
1
  import { bind } from '@owlmeans/server-entrypoint';
2
- import { paymentGate } from './consts.js';
3
- import { resync, webhook } from './actions/index.js';
2
+ import { resync, resyncSubscriptions, webhook } from './actions/index.js';
3
+ import { paymentGate } from './protocol.js';
4
+ /**
5
+ * The payment gate's action handlers, for an application that declares the gate itself — its own
6
+ * aliases, a route pinned to its own service: `bind(own.webhook, paymentGateHandlers.webhook)`.
7
+ *
8
+ * A handler reads its context from the entrypoint it is bound to, so the application's own
9
+ * declaration is the one registered, mounted and run. That declaration keeps `paymentGate`'s paths
10
+ * (`webhookUrlOf` registers the webhook at `paymentGate`'s path), contracts and guards. Bind each
11
+ * one with `bind` itself: `bindAll` pairs a handler with the declaration it was made for, by object
12
+ * identity, and leaves another declaration without one.
13
+ */
14
+ export const paymentGateHandlers = Object.freeze({ webhook, resync, resyncSubscriptions });
4
15
  /** Runtime-local bindings for the shared immutable payment-gateway protocol tree. */
5
16
  export const paymentGateEntrypoints = [
6
17
  bind(paymentGate.base),
7
- bind(paymentGate.webhook, webhook),
8
- bind(paymentGate.resync, resync),
18
+ bind(paymentGate.webhook, paymentGateHandlers.webhook),
19
+ bind(paymentGate.resync, paymentGateHandlers.resync),
20
+ bind(paymentGate.resyncSubscriptions, paymentGateHandlers.resyncSubscriptions),
9
21
  ];
10
22
  //# sourceMappingURL=entrypoints.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAEpD,qFAAqF;AACrF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACtB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC;IAClC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;CACjC,CAAA"}
1
+ {"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAA;AAE1F,qFAAqF;AACrF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACtB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC;IACtD,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,MAAM,CAAC;IACpD,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,mBAAmB,CAAC;CAC/E,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { AbstractRequest } from '@owlmeans/entrypoint';
2
+ import type { GateRequestScope } from './types.js';
3
+ export declare const makeGateRequestScope: (req: AbstractRequest) => GateRequestScope;
4
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/gate/request.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,OAAO,KAAK,EAAc,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE9D,eAAO,MAAM,oBAAoB,QAAS,eAAe,KAAG,gBAkB3D,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { AuthForbidden, authHelper } from '@owlmeans/auth';
2
+ export const makeGateRequestScope = (req) => {
3
+ const defaultEntity = () => req.entity?.id ?? authHelper.entitySlugOf(req.auth) ?? null;
4
+ const gateEntityOf = (opts) => {
5
+ if (req.auth == null) {
6
+ throw new AuthForbidden('auth');
7
+ }
8
+ const resolve = opts?.resolveEntity;
9
+ const entityId = resolve != null ? resolve(req) : defaultEntity();
10
+ if (entityId == null || entityId === '') {
11
+ throw new AuthForbidden('entity');
12
+ }
13
+ return { auth: req.auth, entityId };
14
+ };
15
+ return { defaultEntity, gateEntityOf };
16
+ };
17
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/gate/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAKrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAoB,EAAoB,EAAE;IAC7E,MAAM,aAAa,GAAG,GAAkB,EAAE,CACxC,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,IAAwB,CAAC,IAAI,IAAI,CAAA;IAEjF,MAAM,YAAY,GAAG,CAAC,IAA2B,EAAc,EAAE;QAC/D,IAAI,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACrB,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,CAAA;QACjC,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,EAAE,aAAa,CAAA;QACnC,MAAM,QAAQ,GAAG,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAA;QACjE,IAAI,QAAQ,IAAI,IAAI,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;YACxC,MAAM,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAA;QACnC,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAA;IACrC,CAAC,CAAA;IAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAA;AACxC,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { Auth } from '@owlmeans/auth';
2
+ import type { EntityResolverOption } from '../types.js';
3
+ /** The authenticated entity a gate asserts for. */
4
+ export interface GateEntity {
5
+ auth: Auth;
6
+ entityId: string;
7
+ }
8
+ /** One request as a payment gate reads it. */
9
+ export interface GateRequestScope {
10
+ /** The entity the request acts for by default: `req.entity.id`, else the token's entity. */
11
+ defaultEntity: () => string | null;
12
+ /** Resolve the authenticated entity a gate asserts for, or refuse. @throws AuthForbidden */
13
+ gateEntityOf: (opts?: EntityResolverOption) => GateEntity;
14
+ }
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/gate/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvD,mDAAmD;AACnD,MAAM,WAAW,UAAU;IAAG,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AAE5D,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC/B,4FAA4F;IAC5F,aAAa,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;IAClC,4FAA4F;IAC5F,YAAY,EAAE,CAAC,IAAI,CAAC,EAAE,oBAAoB,KAAK,UAAU,CAAA;CAC1D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/gate/types.ts"],"names":[],"mappings":""}
package/build/gate.d.ts CHANGED
@@ -1,10 +1,14 @@
1
- import type { AbstractRequest, GateService } from '@owlmeans/entrypoint';
2
- import type { PermissionSet } from '@owlmeans/auth';
3
- import type { Context as ApiContext } from '@owlmeans/server-api';
4
- export interface EntitlementGateOptions {
5
- productSkus?: string[];
6
- resolveEntity?: (req: AbstractRequest) => string | null;
7
- }
8
- export declare const entitlementsOf: (ctx: ApiContext, entityId: string, productSkus?: string[]) => Promise<PermissionSet[]>;
9
- export declare const makeEntitlementGate: (alias?: string, opts?: EntitlementGateOptions) => GateService;
1
+ import type { GateService, AbstractRequest } from '@owlmeans/entrypoint';
2
+ import type { CapabilityGateOptions, EntityResolverOption } from './types.js';
3
+ import type { GateEntity } from './gate/types.js';
4
+ /**
5
+ * The capability gate (`ENTITLEMENT_GATE`): passes when the effective plan grants ANY of the
6
+ * parameters (`[scope:]permission[>=n]`) and the token does not deny it. Fails closed — an unreadable
7
+ * store refuses. Refuses with `CapabilityRequired`, an `AuthForbidden`.
8
+ */
9
+ export declare const makeCapabilityGate: (alias?: string, opts?: CapabilityGateOptions) => GateService;
10
+ /** The capability gate under its historical name. */
11
+ export declare const makeEntitlementGate: typeof makeCapabilityGate;
12
+ /** @deprecated compat:factory-refactor — use `makeGateRequestScope(req).gateEntityOf(…)` */
13
+ export declare const gateEntityOf: (req: AbstractRequest, opts?: EntityResolverOption) => GateEntity;
10
14
  //# sourceMappingURL=gate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAExE,OAAO,KAAK,EAAQ,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEzD,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAIjE,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,MAAM,GAAG,IAAI,CAAA;CACxD;AAED,eAAO,MAAM,cAAc,QACpB,UAAU,YAAY,MAAM,gBAAgB,MAAM,EAAE,KACxD,OAAO,CAAC,aAAa,EAAE,CAKzB,CAAA;AAKD,eAAO,MAAM,mBAAmB,WACvB,MAAM,SAA4B,sBAAsB,KAC9D,WAsBF,CAAA"}
1
+ {"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAKxE,OAAO,KAAK,EAAmB,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAI9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAejD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WACtB,MAAM,SAA4B,qBAAqB,KAC7D,WA4BF,CAAA;AAED,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,2BAAqB,CAAA;AAErD,4FAA4F;AAC5F,eAAO,MAAM,YAAY,QAAS,eAAe,SAAS,oBAAoB,KAAG,UACnC,CAAA"}
package/build/gate.js CHANGED
@@ -1,37 +1,52 @@
1
1
  import { createLazyService } from '@owlmeans/context';
2
- import { AuthForbidden, entitySlugOf } from '@owlmeans/auth';
3
- import { ENTITLEMENT_GATE, hasEntitlement, SubscriptionStatus } from '@owlmeans/payment';
4
- import { subscriptions } from './utils.js';
5
- export const entitlementsOf = async (ctx, entityId, productSkus) => {
6
- const { items } = await subscriptions(ctx).list({
7
- entityId, status: [SubscriptionStatus.Active, SubscriptionStatus.Trial], productSku: productSkus,
8
- }, { size: 0 });
9
- return items.flatMap(record => record.capabilities ?? []);
2
+ import { hasPermission } from '@owlmeans/iam';
3
+ import { CapabilityRequired, ENTITLEMENT_GATE, parseEntitlementParam, capabilityOf } from '@owlmeans/payment';
4
+ import { log } from './log.js';
5
+ import { paymentAccessOf } from './access.js';
6
+ import { makeGateRequestScope } from './gate/request.js';
7
+ /** An explicit `false` for the permission in the token denies, whatever the plan grants. */
8
+ const tokenDenies = (auth, param) => {
9
+ const { scope, permission } = parseEntitlementParam(param);
10
+ return auth.permissions?.some(set => (scope == null || set.scope === scope) && set.permissions?.[permission] === false) ?? false;
10
11
  };
11
- const defaultEntity = (req) => req.entity?.id ?? entitySlugOf(req.auth) ?? null;
12
- export const makeEntitlementGate = (alias = ENTITLEMENT_GATE, opts) => {
12
+ const tokenGrants = (auth, param) => {
13
+ const { scope, permission } = parseEntitlementParam(param);
14
+ return hasPermission(auth, permission, scope != null ? { scope } : undefined);
15
+ };
16
+ /**
17
+ * The capability gate (`ENTITLEMENT_GATE`): passes when the effective plan grants ANY of the
18
+ * parameters (`[scope:]permission[>=n]`) and the token does not deny it. Fails closed — an unreadable
19
+ * store refuses. Refuses with `CapabilityRequired`, an `AuthForbidden`.
20
+ */
21
+ export const makeCapabilityGate = (alias = ENTITLEMENT_GATE, opts) => {
13
22
  const service = createLazyService(alias, {
14
23
  assert: async (req, _, params) => {
15
24
  await service.ready();
16
25
  const ctx = service.assertCtx();
17
- if (req.auth == null)
18
- throw new AuthForbidden('auth');
19
- const entityId = (opts?.resolveEntity ?? defaultEntity)(req);
20
- if (entityId == null || entityId === '')
21
- throw new AuthForbidden('entity');
22
- let capabilities;
26
+ const { auth, entityId } = makeGateRequestScope(req).gateEntityOf(opts);
27
+ const list = (Array.isArray(params) ? params : [params]).filter(param => typeof param === 'string');
28
+ let view;
23
29
  try {
24
- capabilities = await entitlementsOf(ctx, entityId, opts?.productSkus);
30
+ view = await paymentAccessOf(ctx).entitlements().entitlements(entityId);
25
31
  }
26
32
  catch (error) {
27
- console.error(`entitlement gate: cannot read subscriptions for "${entityId}"`, error);
28
- throw new AuthForbidden('entitlement');
33
+ log.error('Capability gate cannot resolve entitlements', { entityId, error });
34
+ throw new CapabilityRequired(list);
35
+ }
36
+ if (opts?.productSkus != null && !opts.productSkus.includes(view.plan.productSku)) {
37
+ throw new CapabilityRequired(list);
29
38
  }
30
- if (!params.some(param => hasEntitlement(capabilities, param))) {
31
- throw new AuthForbidden('entitlement');
39
+ const allowed = list.some(param => capabilityOf(view, param) && !tokenDenies(auth, param)
40
+ && (opts?.requirePermission !== true || tokenGrants(auth, param)));
41
+ if (!allowed) {
42
+ throw new CapabilityRequired(list);
32
43
  }
33
44
  },
34
45
  });
35
46
  return service;
36
47
  };
48
+ /** The capability gate under its historical name. */
49
+ export const makeEntitlementGate = makeCapabilityGate;
50
+ /** @deprecated compat:factory-refactor — use `makeGateRequestScope(req).gateEntityOf(…)` */
51
+ export const gateEntityOf = (req, opts) => makeGateRequestScope(req).gateEntityOf(opts);
37
52
  //# sourceMappingURL=gate.js.map
package/build/gate.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"gate.js","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE5D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAExF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAQ1C,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,GAAe,EAAE,QAAgB,EAAE,WAAsB,EAC/B,EAAE;IAC5B,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QAC9C,QAAQ,EAAE,MAAM,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,WAAW;KACjG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;IACf,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,CAAA;AAC3D,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,CAAC,GAAoB,EAAiB,EAAE,CAC5D,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,YAAY,CAAC,GAAG,CAAC,IAAwB,CAAC,IAAI,IAAI,CAAA;AAEtE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,KAAK,GAAW,gBAAgB,EAAE,IAA6B,EAClD,EAAE;IACf,MAAM,OAAO,GAAG,iBAAiB,CAAc,KAAK,EAAE;QACpD,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE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CAAA;AAChB,CAAC,CAAA;AAED,qDAAqD;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAA;AAErD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAoB,EAAE,IAA2B,EAAc,EAAE,CAC5F,oBAAoB,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA"}
package/build/index.d.ts CHANGED
@@ -1,12 +1,59 @@
1
1
  export type * from './types.js';
2
2
  export * from './consts.js';
3
+ export * from './protocol.js';
3
4
  export * from './config.js';
4
5
  export * from './resource.js';
6
+ export { FingerprintSchema, ConsumerEventSchema } from './schemas.js';
5
7
  export * from './observer.js';
6
8
  export * from './service.js';
7
9
  export * from './gate.js';
10
+ export * from './limit.js';
11
+ export * from './entitlement.js';
8
12
  export * from './entrypoints.js';
9
- export { initialize as syncPaymentProducts, planLookupKey } from './sync.js';
10
- export { amountCheckoutLineItem } from './plugins/stripe.js';
11
- export { payment, gateway, observer, paygateCustomers, subscriptions, fingerprints, activeSubscription, } from './utils.js';
13
+ export type * from './access/types.js';
14
+ export * from './access.js';
15
+ export type * from './plan/types.js';
16
+ export * from './plan.js';
17
+ export type * from './models/declarations/types.js';
18
+ export * from './models/declarations.js';
19
+ export type * from './catalogue/types.js';
20
+ export * from './catalogue.js';
21
+ export type * from './usage/types.js';
22
+ export * from './usage.js';
23
+ export type * from './subscription/types.js';
24
+ export * from './subscription.js';
25
+ export type * from './commit/types.js';
26
+ export * from './commit.js';
27
+ export type * from './sync/types.js';
28
+ export * from './sync.js';
29
+ export type * from './bootstrap/types.js';
30
+ export * from './bootstrap.js';
31
+ export type * from './reconcile/types.js';
32
+ export * from './reconcile.js';
33
+ export type * from './gate/types.js';
34
+ export * from './gate/request.js';
35
+ export type * from './plugins/session/types.js';
36
+ export * from './plugins/session.js';
37
+ export type * from './plugins/stripe/types.js';
38
+ export * from './plugins/stripe.js';
39
+ export type * from './plugins/checkout-registry/types.js';
40
+ export * from './plugins/checkout-registry.js';
41
+ export type * from './plugins/checkout-plugins/types.js';
42
+ export * from './plugins/checkout-plugins.js';
43
+ export type * from './plugins/checkout-policy/types.js';
44
+ export * from './plugins/checkout-policy.js';
45
+ export type * from './plugins/estimate/types.js';
46
+ export * from './plugins/estimate/cache.js';
47
+ export * from './plugins/estimate.js';
48
+ export type * from './plugins/events/types.js';
49
+ export * from './plugins/events.js';
50
+ export * from './plugins/status.js';
51
+ export type * from './plugins/subscriptions/types.js';
52
+ export * from './plugins/subscriptions.js';
53
+ export type * from './plugins/webhook-manager/types.js';
54
+ export * from './plugins/webhook-manager.js';
55
+ export type * from './plugins/portal/types.js';
56
+ export * from './plugins/portal.js';
57
+ export * from './consumer/index.js';
58
+ export { consumerConsents, consumerRightsOf, entitlements, fulfillments, gateway, observer, payment, purchases, stripeClient, subscriptions, } from './utils.js';
12
59
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EACL,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,GAC9F,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;A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,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AACrC,mBAAmB,2BAA2B,CAAA;AAC9C,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,mBAAmB,kCAAkC,CAAA;AACrD,cAAc,4BAA4B,CAAA;AAC1C,mBAAmB,oCAAoC,CAAA;AACvD,cAAc,8BAA8B,CAAA;AAC5C,mBAAmB,2BAA2B,CAAA;AAC9C,cAAc,qBAAqB,CAAA;AAEnC,cAAc,qBAAqB,CAAA;AAEnC,OAAO,EACL,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EACnH,aAAa,GACd,MAAM,YAAY,CAAA"}
package/build/index.js CHANGED
@@ -1,11 +1,37 @@
1
1
  export * from './consts.js';
2
+ export * from './protocol.js';
2
3
  export * from './config.js';
3
4
  export * from './resource.js';
5
+ export { FingerprintSchema, ConsumerEventSchema } from './schemas.js';
4
6
  export * from './observer.js';
5
7
  export * from './service.js';
6
8
  export * from './gate.js';
9
+ export * from './limit.js';
10
+ export * from './entitlement.js';
7
11
  export * from './entrypoints.js';
8
- export { initialize as syncPaymentProducts, planLookupKey } from './sync.js';
9
- export { amountCheckoutLineItem } from './plugins/stripe.js';
10
- export { payment, gateway, observer, paygateCustomers, subscriptions, fingerprints, activeSubscription, } from './utils.js';
12
+ export * from './access.js';
13
+ export * from './plan.js';
14
+ export * from './models/declarations.js';
15
+ export * from './catalogue.js';
16
+ export * from './usage.js';
17
+ export * from './subscription.js';
18
+ export * from './commit.js';
19
+ export * from './sync.js';
20
+ export * from './bootstrap.js';
21
+ export * from './reconcile.js';
22
+ export * from './gate/request.js';
23
+ export * from './plugins/session.js';
24
+ export * from './plugins/stripe.js';
25
+ export * from './plugins/checkout-registry.js';
26
+ export * from './plugins/checkout-plugins.js';
27
+ export * from './plugins/checkout-policy.js';
28
+ export * from './plugins/estimate/cache.js';
29
+ export * from './plugins/estimate.js';
30
+ export * from './plugins/events.js';
31
+ export * from './plugins/status.js';
32
+ export * from './plugins/subscriptions.js';
33
+ export * from './plugins/webhook-manager.js';
34
+ export * from './plugins/portal.js';
35
+ export * from './consumer/index.js';
36
+ export { consumerConsents, consumerRightsOf, entitlements, fulfillments, gateway, observer, payment, purchases, stripeClient, subscriptions, } from './utils.js';
11
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EACL,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,GAC9F,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACrE,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAGhC,cAAc,aAAa,CAAA;AAE3B,cAAc,WAAW,CAAA;AAEzB,cAAc,0BAA0B,CAAA;AAExC,cAAc,gBAAgB,CAAA;AAE9B,cAAc,YAAY,CAAA;AAE1B,cAAc,mBAAmB,CAAA;AAEjC,cAAc,aAAa,CAAA;AAE3B,cAAc,WAAW,CAAA;AAEzB,cAAc,gBAAgB,CAAA;AAE9B,cAAc,gBAAgB,CAAA;AAE9B,cAAc,mBAAmB,CAAA;AAGjC,cAAc,sBAAsB,CAAA;AAEpC,cAAc,qBAAqB,CAAA;AAEnC,cAAc,gCAAgC,CAAA;AAE9C,cAAc,+BAA+B,CAAA;AAE7C,cAAc,8BAA8B,CAAA;AAE5C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AAErC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AAEnC,cAAc,4BAA4B,CAAA;AAE1C,cAAc,8BAA8B,CAAA;AAE5C,cAAc,qBAAqB,CAAA;AAEnC,cAAc,qBAAqB,CAAA;AAEnC,OAAO,EACL,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EACnH,aAAa,GACd,MAAM,YAAY,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { GateService } from '@owlmeans/entrypoint';
2
+ import type { LimitGateOptions } from './types.js';
3
+ /**
4
+ * The limit gate (`LIMIT_GATE`): passes when ANY `limit:<key>[>=n]` parameter has at least `n` left
5
+ * in its current window. It never consumes — checking room and spending it are different moments,
6
+ * and only the handler knows the work started. Malformed parameters and keys the plan does not
7
+ * declare are skipped; a store error refuses. Refuses with `LimitExhausted` naming the first
8
+ * declared key, an `AuthForbidden`.
9
+ */
10
+ export declare const makeLimitGate: (alias?: string, opts?: LimitGateOptions) => GateService;
11
+ //# sourceMappingURL=limit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limit.d.ts","sourceRoot":"","sources":["../src/limit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAIvD,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAInE;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,WAAW,MAAM,SAAsB,gBAAgB,KAAG,WAqCnF,CAAA"}
package/build/limit.js ADDED
@@ -0,0 +1,48 @@
1
+ import { createLazyService } from '@owlmeans/context';
2
+ import { LIMIT_GATE, LimitExhausted, LimitUnknown, planLimitHelper } from '@owlmeans/payment';
3
+ import { makeGateRequestScope } from './gate/request.js';
4
+ import { log } from './log.js';
5
+ import { paymentAccessOf } from './access.js';
6
+ /**
7
+ * The limit gate (`LIMIT_GATE`): passes when ANY `limit:<key>[>=n]` parameter has at least `n` left
8
+ * in its current window. It never consumes — checking room and spending it are different moments,
9
+ * and only the handler knows the work started. Malformed parameters and keys the plan does not
10
+ * declare are skipped; a store error refuses. Refuses with `LimitExhausted` naming the first
11
+ * declared key, an `AuthForbidden`.
12
+ */
13
+ export const makeLimitGate = (alias = LIMIT_GATE, opts) => {
14
+ const service = createLazyService(alias, {
15
+ assert: async (req, _, params) => {
16
+ await service.ready();
17
+ const ctx = service.assertCtx();
18
+ const { entityId } = makeGateRequestScope(req).gateEntityOf(opts);
19
+ const list = (Array.isArray(params) ? params : [params]).filter(param => typeof param === 'string');
20
+ const parsed = list.map(planLimitHelper.parseLimitParam).filter((param) => param != null);
21
+ if (parsed.length === 0) {
22
+ throw new LimitExhausted({ key: list[0] ?? 'unknown', used: 0, limit: 0 });
23
+ }
24
+ let refused = null;
25
+ for (const param of parsed) {
26
+ let state;
27
+ try {
28
+ state = await paymentAccessOf(ctx).entitlements().limitState(entityId, param.key);
29
+ }
30
+ catch (error) {
31
+ if (!(error instanceof LimitUnknown)) {
32
+ log.error('Limit gate cannot read a limit', { key: param.key, entityId, error });
33
+ }
34
+ continue;
35
+ }
36
+ if (state.remaining >= param.atLeast) {
37
+ return;
38
+ }
39
+ refused ??= state;
40
+ }
41
+ throw new LimitExhausted(refused != null
42
+ ? { key: refused.key, used: refused.used, limit: refused.limit, resetsAt: refused.resetsAt }
43
+ : { key: parsed[0].key, used: 0, limit: 0 });
44
+ },
45
+ });
46
+ return service;
47
+ };
48
+ //# sourceMappingURL=limit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limit.js","sourceRoot":"","sources":["../src/limit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAmC,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAE9H,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAK,GAAW,UAAU,EAAE,IAAuB,EAAe,EAAE;IAChG,MAAM,OAAO,GAAG,iBAAiB,CAAc,KAAK,EAAE;QACpD,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;YAC/B,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;YACrB,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,EAA4C,CAAA;YACzE,MAAM,EAAE,QAAQ,EAAE,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;YACjE,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAA;YAEnG,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,eAAe,CAAC,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AC,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;QAChD,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
package/build/log.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** The package's logger: webhook outcomes, paygate anomalies and failed side effects. */
2
+ export declare const log: import("@owlmeans/log").Logger;
3
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAEA,yFAAyF;AACzF,eAAO,MAAM,GAAG,gCAA2B,CAAA"}
package/build/log.js ADDED
@@ -0,0 +1,4 @@
1
+ import { logger } from '@owlmeans/log';
2
+ /** The package's logger: webhook outcomes, paygate anomalies and failed side effects. */
3
+ export const log = logger('server-payment');
4
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,yFAAyF;AACzF,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ import type { Config, PaymentPlan } from '../../types.js';
2
+ /** The plans a configuration declares, and the rules no single declaration can check. */
3
+ export interface PlanDeclarationsModel {
4
+ readonly record: Config;
5
+ /** Every plan declared into the configuration. */
6
+ plans: () => PaymentPlan[];
7
+ /**
8
+ * Cross-plan rules a single declaration cannot see:
9
+ *
10
+ * - at most one free plan per rank;
11
+ * - no two paid plans of one product at the same rank (one-time `consumable` plans are never an
12
+ * entity's plan and are not ranked against each other).
13
+ *
14
+ * A limit key MAY change kind between plans (lifetime on one, a monthly window on another): counters
15
+ * are keyed by `(entity, key, window)` and the window is derived from the kind, so each kind keeps its
16
+ * own counter and a lifetime count still sticks to the entity across plan changes.
17
+ *
18
+ * @throws PlanRankConflict
19
+ */
20
+ assertPlans: () => void;
21
+ }
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/models/declarations/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEzD,yFAAyF;AACzF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,kDAAkD;IAClD,KAAK,EAAE,MAAM,WAAW,EAAE,CAAA;IAC1B;;;;;;;;;;;;OAYG;IACH,WAAW,EAAE,MAAM,IAAI,CAAA;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/models/declarations/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { Config } from '../types.js';
2
+ import type { PlanDeclarationsModel } from './declarations/types.js';
3
+ export declare const makePlanDeclarationsModel: (record: Config) => PlanDeclarationsModel;
4
+ //# sourceMappingURL=declarations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../src/models/declarations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,aAAa,CAAA;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAEpE,eAAO,MAAM,yBAAyB,WAAY,MAAM,KAAG,qBAyB1D,CAAA"}