@owlmeans/server-payment 0.1.18-rc.9 → 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.
- package/README.md +157 -26
- package/agent-meta/manifest.json +30 -4
- package/agent-meta/skills/server-payment/SKILL.md +613 -54
- package/agent-meta/skills/server-payment/parts/reference.md +174 -0
- package/build/access/types.d.ts +46 -0
- package/build/access/types.d.ts.map +1 -0
- package/build/access/types.js +2 -0
- package/build/access/types.js.map +1 -0
- package/build/access.d.ts +6 -0
- package/build/access.d.ts.map +1 -0
- package/build/access.js +45 -0
- package/build/access.js.map +1 -0
- package/build/actions/index.d.ts +1 -0
- package/build/actions/index.d.ts.map +1 -1
- package/build/actions/index.js +1 -0
- package/build/actions/index.js.map +1 -1
- package/build/actions/resync-subscriptions.d.ts +3 -0
- package/build/actions/resync-subscriptions.d.ts.map +1 -0
- package/build/actions/resync-subscriptions.js +7 -0
- package/build/actions/resync-subscriptions.js.map +1 -0
- package/build/actions/resync.d.ts +6 -1
- package/build/actions/resync.d.ts.map +1 -1
- package/build/actions/resync.js +15 -5
- package/build/actions/resync.js.map +1 -1
- package/build/actions/webhook.d.ts +2 -1
- package/build/actions/webhook.d.ts.map +1 -1
- package/build/actions/webhook.js +10 -4
- package/build/actions/webhook.js.map +1 -1
- package/build/bootstrap/types.d.ts +16 -0
- package/build/bootstrap/types.d.ts.map +1 -0
- package/build/bootstrap/types.js +2 -0
- package/build/bootstrap/types.js.map +1 -0
- package/build/bootstrap.d.ts +6 -0
- package/build/bootstrap.d.ts.map +1 -0
- package/build/bootstrap.js +26 -0
- package/build/bootstrap.js.map +1 -0
- package/build/catalogue/types.d.ts +38 -0
- package/build/catalogue/types.d.ts.map +1 -0
- package/build/catalogue/types.js +2 -0
- package/build/catalogue/types.js.map +1 -0
- package/build/catalogue.d.ts +6 -0
- package/build/catalogue.d.ts.map +1 -0
- package/build/catalogue.js +110 -0
- package/build/catalogue.js.map +1 -0
- package/build/commit/types.d.ts +22 -0
- package/build/commit/types.d.ts.map +1 -0
- package/build/commit/types.js +2 -0
- package/build/commit/types.js.map +1 -0
- package/build/commit.d.ts +6 -0
- package/build/commit.d.ts.map +1 -0
- package/build/commit.js +125 -0
- package/build/commit.js.map +1 -0
- package/build/config.d.ts +44 -5
- package/build/config.d.ts.map +1 -1
- package/build/config.js +216 -10
- package/build/config.js.map +1 -1
- package/build/consts.d.ts +74 -16
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +86 -23
- package/build/consts.js.map +1 -1
- package/build/consts.local.d.ts +94 -0
- package/build/consts.local.d.ts.map +1 -0
- package/build/consts.local.js +44 -0
- package/build/consts.local.js.map +1 -0
- package/build/consumer/cancellation/types.d.ts +11 -0
- package/build/consumer/cancellation/types.d.ts.map +1 -0
- package/build/consumer/cancellation/types.js +2 -0
- package/build/consumer/cancellation/types.js.map +1 -0
- package/build/consumer/cancellation.d.ts +6 -0
- package/build/consumer/cancellation.d.ts.map +1 -0
- package/build/consumer/cancellation.js +33 -0
- package/build/consumer/cancellation.js.map +1 -0
- package/build/consumer/capture/types.d.ts +50 -0
- package/build/consumer/capture/types.d.ts.map +1 -0
- package/build/consumer/capture/types.js +2 -0
- package/build/consumer/capture/types.js.map +1 -0
- package/build/consumer/capture.d.ts +6 -0
- package/build/consumer/capture.d.ts.map +1 -0
- package/build/consumer/capture.js +284 -0
- package/build/consumer/capture.js.map +1 -0
- package/build/consumer/consts.local.d.ts +10 -0
- package/build/consumer/consts.local.d.ts.map +1 -0
- package/build/consumer/consts.local.js +11 -0
- package/build/consumer/consts.local.js.map +1 -0
- package/build/consumer/format/types.d.ts +30 -0
- package/build/consumer/format/types.d.ts.map +1 -0
- package/build/consumer/format/types.js +2 -0
- package/build/consumer/format/types.js.map +1 -0
- package/build/consumer/format.d.ts +4 -0
- package/build/consumer/format.d.ts.map +1 -0
- package/build/consumer/format.js +73 -0
- package/build/consumer/format.js.map +1 -0
- package/build/consumer/handlers.d.ts +21 -0
- package/build/consumer/handlers.d.ts.map +1 -0
- package/build/consumer/handlers.js +174 -0
- package/build/consumer/handlers.js.map +1 -0
- package/build/consumer/index.d.ts +10 -0
- package/build/consumer/index.d.ts.map +1 -0
- package/build/consumer/index.js +6 -0
- package/build/consumer/index.js.map +1 -0
- package/build/consumer/mail/types.d.ts +29 -0
- package/build/consumer/mail/types.d.ts.map +1 -0
- package/build/consumer/mail/types.js +2 -0
- package/build/consumer/mail/types.js.map +1 -0
- package/build/consumer/mail.d.ts +6 -0
- package/build/consumer/mail.d.ts.map +1 -0
- package/build/consumer/mail.js +313 -0
- package/build/consumer/mail.js.map +1 -0
- package/build/consumer/observers/types.d.ts +15 -0
- package/build/consumer/observers/types.d.ts.map +1 -0
- package/build/consumer/observers/types.js +2 -0
- package/build/consumer/observers/types.js.map +1 -0
- package/build/consumer/observers.d.ts +6 -0
- package/build/consumer/observers.d.ts.map +1 -0
- package/build/consumer/observers.js +74 -0
- package/build/consumer/observers.js.map +1 -0
- package/build/consumer/origin/types.d.ts +17 -0
- package/build/consumer/origin/types.d.ts.map +1 -0
- package/build/consumer/origin/types.js +2 -0
- package/build/consumer/origin/types.js.map +1 -0
- package/build/consumer/origin.d.ts +8 -0
- package/build/consumer/origin.d.ts.map +1 -0
- package/build/consumer/origin.js +43 -0
- package/build/consumer/origin.js.map +1 -0
- package/build/consumer/reconcile/types.d.ts +13 -0
- package/build/consumer/reconcile/types.d.ts.map +1 -0
- package/build/consumer/reconcile/types.js +2 -0
- package/build/consumer/reconcile/types.js.map +1 -0
- package/build/consumer/reconcile.d.ts +5 -0
- package/build/consumer/reconcile.d.ts.map +1 -0
- package/build/consumer/reconcile.js +320 -0
- package/build/consumer/reconcile.js.map +1 -0
- package/build/consumer/records/types.d.ts +66 -0
- package/build/consumer/records/types.d.ts.map +1 -0
- package/build/consumer/records/types.js +2 -0
- package/build/consumer/records/types.js.map +1 -0
- package/build/consumer/records.d.ts +6 -0
- package/build/consumer/records.d.ts.map +1 -0
- package/build/consumer/records.js +243 -0
- package/build/consumer/records.js.map +1 -0
- package/build/consumer/service.d.ts +28 -0
- package/build/consumer/service.d.ts.map +1 -0
- package/build/consumer/service.js +706 -0
- package/build/consumer/service.js.map +1 -0
- package/build/consumer/types.d.ts +84 -0
- package/build/consumer/types.d.ts.map +1 -0
- package/build/consumer/types.js +2 -0
- package/build/consumer/types.js.map +1 -0
- package/build/consumer/types.local.d.ts +26 -0
- package/build/consumer/types.local.d.ts.map +1 -0
- package/build/consumer/types.local.js +2 -0
- package/build/consumer/types.local.js.map +1 -0
- package/build/consumer/withdrawal/types.d.ts +36 -0
- package/build/consumer/withdrawal/types.d.ts.map +1 -0
- package/build/consumer/withdrawal/types.js +2 -0
- package/build/consumer/withdrawal/types.js.map +1 -0
- package/build/consumer/withdrawal.d.ts +6 -0
- package/build/consumer/withdrawal.d.ts.map +1 -0
- package/build/consumer/withdrawal.js +237 -0
- package/build/consumer/withdrawal.js.map +1 -0
- package/build/entitlement.d.ts +4 -0
- package/build/entitlement.d.ts.map +1 -0
- package/build/entitlement.js +72 -0
- package/build/entitlement.js.map +1 -0
- package/build/entrypoints.d.ts +19 -2
- package/build/entrypoints.d.ts.map +1 -1
- package/build/entrypoints.js +16 -4
- package/build/entrypoints.js.map +1 -1
- package/build/gate/request.d.ts +4 -0
- package/build/gate/request.d.ts.map +1 -0
- package/build/gate/request.js +17 -0
- package/build/gate/request.js.map +1 -0
- package/build/gate/types.d.ts +15 -0
- package/build/gate/types.d.ts.map +1 -0
- package/build/gate/types.js +2 -0
- package/build/gate/types.js.map +1 -0
- package/build/gate.d.ts +13 -9
- package/build/gate.d.ts.map +1 -1
- package/build/gate.js +36 -21
- package/build/gate.js.map +1 -1
- package/build/index.d.ts +50 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +29 -3
- package/build/index.js.map +1 -1
- package/build/limit.d.ts +11 -0
- package/build/limit.d.ts.map +1 -0
- package/build/limit.js +48 -0
- package/build/limit.js.map +1 -0
- package/build/log.d.ts +3 -0
- package/build/log.d.ts.map +1 -0
- package/build/log.js +4 -0
- package/build/log.js.map +1 -0
- package/build/models/declarations/types.d.ts +22 -0
- package/build/models/declarations/types.d.ts.map +1 -0
- package/build/models/declarations/types.js +2 -0
- package/build/models/declarations/types.js.map +1 -0
- package/build/models/declarations.d.ts +4 -0
- package/build/models/declarations.d.ts.map +1 -0
- package/build/models/declarations.js +26 -0
- package/build/models/declarations.js.map +1 -0
- package/build/models/purchase/types.d.ts +13 -0
- package/build/models/purchase/types.d.ts.map +1 -0
- package/build/models/purchase/types.js +2 -0
- package/build/models/purchase/types.js.map +1 -0
- package/build/models/purchase.d.ts +4 -0
- package/build/models/purchase.d.ts.map +1 -0
- package/build/models/purchase.js +37 -0
- package/build/models/purchase.js.map +1 -0
- package/build/observer.d.ts +9 -0
- package/build/observer.d.ts.map +1 -1
- package/build/observer.js +38 -12
- package/build/observer.js.map +1 -1
- package/build/plan/types.d.ts +21 -0
- package/build/plan/types.d.ts.map +1 -0
- package/build/plan/types.js +2 -0
- package/build/plan/types.js.map +1 -0
- package/build/plan.d.ts +7 -0
- package/build/plan.d.ts.map +1 -0
- package/build/plan.js +29 -0
- package/build/plan.js.map +1 -0
- package/build/plugins/checkout-plugins/types.d.ts +25 -0
- package/build/plugins/checkout-plugins/types.d.ts.map +1 -0
- package/build/plugins/checkout-plugins/types.js +2 -0
- package/build/plugins/checkout-plugins/types.js.map +1 -0
- package/build/plugins/checkout-plugins.d.ts +12 -0
- package/build/plugins/checkout-plugins.d.ts.map +1 -0
- package/build/plugins/checkout-plugins.js +72 -0
- package/build/plugins/checkout-plugins.js.map +1 -0
- package/build/plugins/checkout-policy/types.d.ts +18 -0
- package/build/plugins/checkout-policy/types.d.ts.map +1 -0
- package/build/plugins/checkout-policy/types.js +2 -0
- package/build/plugins/checkout-policy/types.js.map +1 -0
- package/build/plugins/checkout-policy.d.ts +4 -0
- package/build/plugins/checkout-policy.d.ts.map +1 -0
- package/build/plugins/checkout-policy.js +26 -0
- package/build/plugins/checkout-policy.js.map +1 -0
- package/build/plugins/checkout-registry/types.d.ts +7 -0
- package/build/plugins/checkout-registry/types.d.ts.map +1 -0
- package/build/plugins/checkout-registry/types.js +2 -0
- package/build/plugins/checkout-registry/types.js.map +1 -0
- package/build/plugins/checkout-registry.d.ts +8 -0
- package/build/plugins/checkout-registry.d.ts.map +1 -0
- package/build/plugins/checkout-registry.js +21 -0
- package/build/plugins/checkout-registry.js.map +1 -0
- package/build/plugins/consts.local.d.ts +13 -0
- package/build/plugins/consts.local.d.ts.map +1 -0
- package/build/plugins/consts.local.js +22 -0
- package/build/plugins/consts.local.js.map +1 -0
- package/build/plugins/customer-lock/types.d.ts +6 -0
- package/build/plugins/customer-lock/types.d.ts.map +1 -0
- package/build/plugins/customer-lock/types.js +2 -0
- package/build/plugins/customer-lock/types.js.map +1 -0
- package/build/plugins/customer-lock.d.ts +5 -0
- package/build/plugins/customer-lock.d.ts.map +1 -0
- package/build/plugins/customer-lock.js +22 -0
- package/build/plugins/customer-lock.js.map +1 -0
- package/build/plugins/estimate/cache.d.ts +4 -0
- package/build/plugins/estimate/cache.d.ts.map +1 -0
- package/build/plugins/estimate/cache.js +7 -0
- package/build/plugins/estimate/cache.js.map +1 -0
- package/build/plugins/estimate/types.d.ts +27 -0
- package/build/plugins/estimate/types.d.ts.map +1 -0
- package/build/plugins/estimate/types.js +2 -0
- package/build/plugins/estimate/types.js.map +1 -0
- package/build/plugins/estimate.d.ts +6 -0
- package/build/plugins/estimate.d.ts.map +1 -0
- package/build/plugins/estimate.js +271 -0
- package/build/plugins/estimate.js.map +1 -0
- package/build/plugins/events/types.d.ts +12 -0
- package/build/plugins/events/types.d.ts.map +1 -0
- package/build/plugins/events/types.js +2 -0
- package/build/plugins/events/types.js.map +1 -0
- package/build/plugins/events.d.ts +6 -13
- package/build/plugins/events.d.ts.map +1 -1
- package/build/plugins/events.js +441 -144
- package/build/plugins/events.js.map +1 -1
- package/build/plugins/fx/types.d.ts +33 -0
- package/build/plugins/fx/types.d.ts.map +1 -0
- package/build/plugins/fx/types.js +2 -0
- package/build/plugins/fx/types.js.map +1 -0
- package/build/plugins/fx.d.ts +6 -0
- package/build/plugins/fx.d.ts.map +1 -0
- package/build/plugins/fx.js +83 -0
- package/build/plugins/fx.js.map +1 -0
- package/build/plugins/portal/types.d.ts +44 -0
- package/build/plugins/portal/types.d.ts.map +1 -0
- package/build/plugins/portal/types.js +2 -0
- package/build/plugins/portal/types.js.map +1 -0
- package/build/plugins/portal.d.ts +6 -0
- package/build/plugins/portal.d.ts.map +1 -0
- package/build/plugins/portal.js +255 -0
- package/build/plugins/portal.js.map +1 -0
- package/build/plugins/refunds/types.d.ts +35 -0
- package/build/plugins/refunds/types.d.ts.map +1 -0
- package/build/plugins/refunds/types.js +2 -0
- package/build/plugins/refunds/types.js.map +1 -0
- package/build/plugins/refunds.d.ts +6 -0
- package/build/plugins/refunds.d.ts.map +1 -0
- package/build/plugins/refunds.js +81 -0
- package/build/plugins/refunds.js.map +1 -0
- package/build/plugins/session/types.d.ts +32 -0
- package/build/plugins/session/types.d.ts.map +1 -0
- package/build/plugins/session/types.js +2 -0
- package/build/plugins/session/types.js.map +1 -0
- package/build/plugins/session.d.ts +4 -0
- package/build/plugins/session.d.ts.map +1 -0
- package/build/plugins/session.js +58 -0
- package/build/plugins/session.js.map +1 -0
- package/build/plugins/status.d.ts +8 -0
- package/build/plugins/status.d.ts.map +1 -0
- package/build/plugins/status.js +21 -0
- package/build/plugins/status.js.map +1 -0
- package/build/plugins/stripe/types.d.ts +20 -0
- package/build/plugins/stripe/types.d.ts.map +1 -0
- package/build/plugins/stripe/types.js +2 -0
- package/build/plugins/stripe/types.js.map +1 -0
- package/build/plugins/stripe.d.ts +5 -13
- package/build/plugins/stripe.d.ts.map +1 -1
- package/build/plugins/stripe.js +481 -129
- package/build/plugins/stripe.js.map +1 -1
- package/build/plugins/subscriptions/types.d.ts +41 -0
- package/build/plugins/subscriptions/types.d.ts.map +1 -0
- package/build/plugins/subscriptions/types.js +2 -0
- package/build/plugins/subscriptions/types.js.map +1 -0
- package/build/plugins/subscriptions.d.ts +6 -0
- package/build/plugins/subscriptions.d.ts.map +1 -0
- package/build/plugins/subscriptions.js +169 -0
- package/build/plugins/subscriptions.js.map +1 -0
- package/build/plugins/types.d.ts +7 -0
- package/build/plugins/types.d.ts.map +1 -0
- package/build/plugins/types.js +2 -0
- package/build/plugins/types.js.map +1 -0
- package/build/plugins/types.local.d.ts +75 -0
- package/build/plugins/types.local.d.ts.map +1 -0
- package/build/plugins/types.local.js +2 -0
- package/build/plugins/types.local.js.map +1 -0
- package/build/plugins/webhook-manager/types.d.ts +62 -0
- package/build/plugins/webhook-manager/types.d.ts.map +1 -0
- package/build/plugins/webhook-manager/types.js +2 -0
- package/build/plugins/webhook-manager/types.js.map +1 -0
- package/build/plugins/webhook-manager.d.ts +8 -0
- package/build/plugins/webhook-manager.d.ts.map +1 -0
- package/build/plugins/webhook-manager.js +245 -0
- package/build/plugins/webhook-manager.js.map +1 -0
- package/build/protocol.d.ts +13 -0
- package/build/protocol.d.ts.map +1 -0
- package/build/protocol.js +17 -0
- package/build/protocol.js.map +1 -0
- package/build/reconcile/types.d.ts +17 -0
- package/build/reconcile/types.d.ts.map +1 -0
- package/build/reconcile/types.js +2 -0
- package/build/reconcile/types.js.map +1 -0
- package/build/reconcile.d.ts +12 -0
- package/build/reconcile.d.ts.map +1 -0
- package/build/reconcile.js +91 -0
- package/build/reconcile.js.map +1 -0
- package/build/resource.d.ts +12 -1
- package/build/resource.d.ts.map +1 -1
- package/build/resource.js +97 -6
- package/build/resource.js.map +1 -1
- package/build/schemas.d.ts +19 -0
- package/build/schemas.d.ts.map +1 -0
- package/build/schemas.js +244 -0
- package/build/schemas.js.map +1 -0
- package/build/service.d.ts +28 -3
- package/build/service.d.ts.map +1 -1
- package/build/service.js +140 -19
- package/build/service.js.map +1 -1
- package/build/subscription/types.d.ts +21 -0
- package/build/subscription/types.d.ts.map +1 -0
- package/build/subscription/types.js +2 -0
- package/build/subscription/types.js.map +1 -0
- package/build/subscription.d.ts +4 -0
- package/build/subscription.d.ts.map +1 -0
- package/build/subscription.js +84 -0
- package/build/subscription.js.map +1 -0
- package/build/sync/types.d.ts +25 -0
- package/build/sync/types.d.ts.map +1 -0
- package/build/sync/types.js +2 -0
- package/build/sync/types.js.map +1 -0
- package/build/sync.d.ts +4 -3
- package/build/sync.d.ts.map +1 -1
- package/build/sync.js +231 -79
- package/build/sync.js.map +1 -1
- package/build/types.d.ts +1258 -36
- package/build/types.d.ts.map +1 -1
- package/build/types.local.d.ts +22 -0
- package/build/types.local.d.ts.map +1 -0
- package/build/types.local.js +2 -0
- package/build/types.local.js.map +1 -0
- package/build/usage/types.d.ts +56 -0
- package/build/usage/types.d.ts.map +1 -0
- package/build/usage/types.js +2 -0
- package/build/usage/types.js.map +1 -0
- package/build/usage.d.ts +6 -0
- package/build/usage.d.ts.map +1 -0
- package/build/usage.js +365 -0
- package/build/usage.js.map +1 -0
- package/build/utils/types.d.ts +31 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/types.js +2 -0
- package/build/utils/types.js.map +1 -0
- package/build/utils.d.ts +21 -7
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +56 -17
- package/build/utils.js.map +1 -1
- package/package.json +22 -17
- package/src/access/types.ts +52 -0
- package/src/access.ts +86 -0
- package/src/actions/index.ts +1 -0
- package/src/actions/resync-subscriptions.ts +10 -0
- package/src/actions/resync.ts +14 -5
- package/src/actions/webhook.ts +9 -4
- package/src/bootstrap/types.ts +16 -0
- package/src/bootstrap.ts +31 -0
- package/src/catalogue/types.ts +32 -0
- package/src/catalogue.ts +135 -0
- package/src/commit/types.ts +27 -0
- package/src/commit.ts +152 -0
- package/src/config.ts +234 -14
- package/src/consts.local.ts +62 -0
- package/src/consts.ts +100 -36
- package/src/consumer/cancellation/types.ts +13 -0
- package/src/consumer/cancellation.ts +43 -0
- package/src/consumer/capture/types.ts +53 -0
- package/src/consumer/capture.ts +321 -0
- package/src/consumer/consts.local.ts +18 -0
- package/src/consumer/format/types.ts +29 -0
- package/src/consumer/format.ts +85 -0
- package/src/consumer/handlers.ts +204 -0
- package/src/consumer/index.ts +9 -0
- package/src/consumer/mail/types.ts +31 -0
- package/src/consumer/mail.ts +353 -0
- package/src/consumer/observers/types.ts +22 -0
- package/src/consumer/observers.ts +97 -0
- package/src/consumer/origin/types.ts +17 -0
- package/src/consumer/origin.ts +61 -0
- package/src/consumer/reconcile/types.ts +13 -0
- package/src/consumer/reconcile.ts +330 -0
- package/src/consumer/records/types.ts +64 -0
- package/src/consumer/records.ts +288 -0
- package/src/consumer/service.ts +768 -0
- package/src/consumer/types.local.ts +22 -0
- package/src/consumer/types.ts +96 -0
- package/src/consumer/withdrawal/types.ts +37 -0
- package/src/consumer/withdrawal.ts +268 -0
- package/src/entitlement.ts +85 -0
- package/src/entrypoints.ts +17 -4
- package/src/gate/request.ts +24 -0
- package/src/gate/types.ts +13 -0
- package/src/gate.ts +47 -30
- package/src/index.ts +55 -3
- package/src/limit.ts +54 -0
- package/src/log.ts +4 -0
- package/src/models/declarations/types.ts +22 -0
- package/src/models/declarations.ts +30 -0
- package/src/models/purchase/types.ts +13 -0
- package/src/models/purchase.ts +43 -0
- package/src/observer.ts +44 -11
- package/src/plan/types.ts +21 -0
- package/src/plan.ts +46 -0
- package/src/plugins/checkout-plugins/types.ts +25 -0
- package/src/plugins/checkout-plugins.ts +90 -0
- package/src/plugins/checkout-policy/types.ts +18 -0
- package/src/plugins/checkout-policy.ts +34 -0
- package/src/plugins/checkout-registry/types.ts +7 -0
- package/src/plugins/checkout-registry.ts +23 -0
- package/src/plugins/consts.local.ts +30 -0
- package/src/plugins/customer-lock/types.ts +5 -0
- package/src/plugins/customer-lock.ts +25 -0
- package/src/plugins/estimate/cache.ts +12 -0
- package/src/plugins/estimate/types.ts +28 -0
- package/src/plugins/estimate.ts +305 -0
- package/src/plugins/events/types.ts +11 -0
- package/src/plugins/events.ts +466 -132
- package/src/plugins/fx/types.ts +40 -0
- package/src/plugins/fx.ts +101 -0
- package/src/plugins/portal/types.ts +45 -0
- package/src/plugins/portal.ts +284 -0
- package/src/plugins/refunds/types.ts +31 -0
- package/src/plugins/refunds.ts +95 -0
- package/src/plugins/session/types.ts +28 -0
- package/src/plugins/session.ts +73 -0
- package/src/plugins/status.ts +22 -0
- package/src/plugins/stripe/types.ts +20 -0
- package/src/plugins/stripe.ts +523 -135
- package/src/plugins/subscriptions/types.ts +39 -0
- package/src/plugins/subscriptions.ts +195 -0
- package/src/plugins/types.local.ts +61 -0
- package/src/plugins/types.ts +7 -0
- package/src/plugins/webhook-manager/types.ts +63 -0
- package/src/plugins/webhook-manager.ts +288 -0
- package/src/protocol.ts +29 -0
- package/src/reconcile/types.ts +17 -0
- package/src/reconcile.ts +110 -0
- package/src/resource.ts +158 -11
- package/src/schemas.ts +271 -0
- package/src/service.ts +161 -19
- package/src/subscription/types.ts +23 -0
- package/src/subscription.ts +104 -0
- package/src/sync/types.ts +25 -0
- package/src/sync.ts +255 -72
- package/src/types.local.ts +18 -0
- package/src/types.ts +1365 -32
- package/src/usage/types.ts +51 -0
- package/src/usage.ts +432 -0
- package/src/utils/types.ts +30 -0
- package/src/utils.ts +94 -29
- package/tests/checkout-consumer.spec.ts +366 -0
- package/tests/checkout-locks.spec.ts +161 -0
- package/tests/checkout-plugins.spec.ts +164 -0
- package/tests/checkout.spec.ts +209 -93
- package/tests/consumer-events.spec.ts +215 -0
- package/tests/consumer-fixtures.ts +134 -0
- package/tests/consumer-ops.spec.ts +350 -0
- package/tests/consumer-rights.integration.spec.ts +147 -0
- package/tests/consumer-rights.spec.ts +572 -0
- package/tests/context.ts +110 -0
- package/tests/entitlement.spec.ts +139 -0
- package/tests/estimate.spec.ts +350 -0
- package/tests/events.spec.ts +357 -0
- package/tests/fake-stripe.ts +981 -0
- package/tests/gate-handlers.spec.ts +120 -0
- package/tests/gate.spec.ts +63 -72
- package/tests/gateway-options.spec.ts +180 -0
- package/tests/limit-gate.spec.ts +66 -0
- package/tests/portal.spec.ts +202 -0
- package/tests/protocol.spec.ts +17 -3
- package/tests/sync.spec.ts +114 -0
- package/tests/usage.integration.spec.ts +133 -0
- package/tests/usage.spec.ts +169 -0
- package/tests/webhook-manager.spec.ts +149 -0
- package/build/model.d.ts +0 -6
- package/build/model.d.ts.map +0 -1
- package/build/model.js +0 -33
- package/build/model.js.map +0 -1
- package/src/model.ts +0 -37
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import type Stripe from 'stripe'
|
|
2
|
+
import { MAILER_SERVICE } from '@owlmeans/mailer'
|
|
3
|
+
import {
|
|
4
|
+
CancellationStatus, DeclarationKind, ENTITLING_STATUSES, PurchaseKind, WithdrawalStatus,
|
|
5
|
+
} from '@owlmeans/payment'
|
|
6
|
+
import type { Context as ApiContext } from '@owlmeans/server-api'
|
|
7
|
+
import { PURCHASE_BACKFILL_DAYS, STRIPE_PAYGATE_ALIAS } from '../consts.js'
|
|
8
|
+
import type { ConsumerRightsInternals, WithdrawalComputation } from './types.js'
|
|
9
|
+
import type {
|
|
10
|
+
ConsumerEventRecord, ConsumerMailKind, ConsumerReconcileOptions, ConsumerReconcileResult, UsageReading,
|
|
11
|
+
} from '../types.js'
|
|
12
|
+
import { log } from '../log.js'
|
|
13
|
+
import { DAY_MS, MAX_ATTEMPTS } from './consts.local.js'
|
|
14
|
+
import { paymentAccessOf } from '../access.js'
|
|
15
|
+
import { paymentUtils } from '../utils.js'
|
|
16
|
+
import { consumerRecordsOf } from './records.js'
|
|
17
|
+
import { captureOf } from './capture.js'
|
|
18
|
+
import { consumerMailOf } from './mail.js'
|
|
19
|
+
import { consumerObserversOf } from './observers.js'
|
|
20
|
+
import { cancellationOf } from './cancellation.js'
|
|
21
|
+
import { withdrawalOf } from './withdrawal.js'
|
|
22
|
+
import type { ConsumerReconcileHelper } from './reconcile/types.js'
|
|
23
|
+
|
|
24
|
+
export const makeConsumerReconcileHelper = (
|
|
25
|
+
ctx: ApiContext, internals: ConsumerRightsInternals,
|
|
26
|
+
): ConsumerReconcileHelper => {
|
|
27
|
+
const access = paymentAccessOf(ctx)
|
|
28
|
+
const records = consumerRecordsOf(ctx)
|
|
29
|
+
|
|
30
|
+
/** What `withdraw` computed for a declaration, read back from its `computed` event. */
|
|
31
|
+
const computedOf = async (
|
|
32
|
+
withdrawalId: string,
|
|
33
|
+
): Promise<Pick<WithdrawalComputation, 'reading' | 'deducted' | 'unitsReturned' | 'netMinor' | 'refundMinor'> | null> => {
|
|
34
|
+
const event = await access.consumerEvents().load({ recordId: withdrawalId, action: 'computed', ok: true })
|
|
35
|
+
if (event == null) {
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
const detail = JSON.parse(event.detail ?? '{}') as {
|
|
39
|
+
reading?: UsageReading, deducted?: number, netMinor?: number, unitsReturned?: number,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
reading: detail.reading ?? { granted: 0, used: 0, usedAfter: 0 },
|
|
44
|
+
deducted: detail.deducted ?? 0,
|
|
45
|
+
unitsReturned: detail.unitsReturned ?? 0,
|
|
46
|
+
netMinor: detail.netMinor ?? 0,
|
|
47
|
+
refundMinor: event.amountMinor ?? 0,
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const failures = async (recordId: string, action: ConsumerEventRecord['action']): Promise<number> =>
|
|
52
|
+
await access.consumerEvents().count({ recordId, action, ok: false })
|
|
53
|
+
|
|
54
|
+
/** Every distinct (record, step) with a failed event since `since` and no success after all. */
|
|
55
|
+
const pendingSteps = async (
|
|
56
|
+
action: ConsumerEventRecord['action'], since: Date, limit: number,
|
|
57
|
+
): Promise<ConsumerEventRecord[]> => {
|
|
58
|
+
const { items } = await access.consumerEvents().list({ action, ok: false, at: { $gte: since } }, {
|
|
59
|
+
size: limit * 4, sort: [{ field: 'at', order: 'desc' }],
|
|
60
|
+
})
|
|
61
|
+
const seen = new Set<string>()
|
|
62
|
+
const pending: ConsumerEventRecord[] = []
|
|
63
|
+
for (const event of items) {
|
|
64
|
+
const key = `${event.recordId}:${event.step ?? ''}`
|
|
65
|
+
if (seen.has(key)) continue
|
|
66
|
+
seen.add(key)
|
|
67
|
+
if (!await records.hasEvent(event.recordId, action, event.step ?? undefined, true)) {
|
|
68
|
+
pending.push(event)
|
|
69
|
+
}
|
|
70
|
+
if (pending.length >= limit) break
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return pending
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const retryWithdrawals = async (
|
|
77
|
+
stripe: Stripe, since: Date, limit: number, result: ConsumerReconcileResult,
|
|
78
|
+
): Promise<void> => {
|
|
79
|
+
const { items } = await access.consumerDeclarations().list({
|
|
80
|
+
kind: DeclarationKind.Withdrawal, status: WithdrawalStatus.Processing, matched: true, receivedAt: { $gte: since },
|
|
81
|
+
}, { size: limit * 2, sort: [{ field: 'receivedAt', order: 'asc' }] })
|
|
82
|
+
let handled = 0
|
|
83
|
+
for (const declaration of items) {
|
|
84
|
+
if (handled >= limit) break
|
|
85
|
+
const id = declaration.id as string
|
|
86
|
+
const purchase = declaration.purchaseId != null ? await access.purchases().byPurchaseId(declaration.purchaseId) : null
|
|
87
|
+
// A declaration that lost the race for its purchase is a duplicate — never executed.
|
|
88
|
+
if (purchase == null || purchase.withdrawalId !== id) continue
|
|
89
|
+
const computed = await computedOf(id)
|
|
90
|
+
const refundDone = (declaration.refundMinor ?? 0) <= 0 || await records.hasEvent(id, 'refund', undefined, true)
|
|
91
|
+
const cancelDone = purchase.kind !== PurchaseKind.Subscription
|
|
92
|
+
|| await records.hasEvent(id, 'subscription-cancel', undefined, true)
|
|
93
|
+
if (refundDone && cancelDone) {
|
|
94
|
+
const refundEvent = await access.consumerEvents().load({ recordId: id, action: 'refund', ok: true })
|
|
95
|
+
const noteFailed = await access.consumerEvents().load({ recordId: id, action: 'credit-note', ok: false, step: null })
|
|
96
|
+
if (refundEvent?.externalId != null && noteFailed != null && computed != null
|
|
97
|
+
&& !await records.hasEvent(id, 'credit-note', undefined, true)) {
|
|
98
|
+
const attempt = await failures(id, 'credit-note')
|
|
99
|
+
if (attempt < MAX_ATTEMPTS) {
|
|
100
|
+
handled++
|
|
101
|
+
result.retried++
|
|
102
|
+
if (!await withdrawalOf(ctx).retryCreditNote(stripe, declaration, purchase, computed.netMinor, refundEvent.externalId, attempt)) {
|
|
103
|
+
result.failed++
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
continue
|
|
108
|
+
}
|
|
109
|
+
const attempt = Math.max(await failures(id, 'refund'), await failures(id, 'subscription-cancel'))
|
|
110
|
+
if (attempt >= MAX_ATTEMPTS) continue
|
|
111
|
+
handled++
|
|
112
|
+
result.retried++
|
|
113
|
+
try {
|
|
114
|
+
const execution = await withdrawalOf(ctx).executeWithdrawal(stripe, declaration, purchase, {
|
|
115
|
+
refundMinor: declaration.refundMinor ?? computed?.refundMinor ?? 0, netMinor: computed?.netMinor ?? 0,
|
|
116
|
+
}, { attempt })
|
|
117
|
+
if (!execution.ok) {
|
|
118
|
+
result.failed++
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
if (!await records.hasEvent(id, 'observers', 'withdrawal')) {
|
|
122
|
+
await consumerObserversOf(ctx).notifyWithdrawal(declaration, purchase, WithdrawalStatus.Refunded, computed, execution)
|
|
123
|
+
}
|
|
124
|
+
} catch (error) {
|
|
125
|
+
result.failed++
|
|
126
|
+
log.error('Reconcile: withdrawal failed', { id, error })
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const retryCancellations = async (
|
|
132
|
+
stripe: Stripe, since: Date, limit: number, result: ConsumerReconcileResult,
|
|
133
|
+
): Promise<void> => {
|
|
134
|
+
const { items } = await access.consumerDeclarations().list({
|
|
135
|
+
kind: DeclarationKind.Cancellation, status: CancellationStatus.Scheduled, matched: true, receivedAt: { $gte: since },
|
|
136
|
+
}, { size: limit * 2, sort: [{ field: 'receivedAt', order: 'asc' }] })
|
|
137
|
+
let handled = 0
|
|
138
|
+
for (const declaration of items) {
|
|
139
|
+
if (handled >= limit) break
|
|
140
|
+
const id = declaration.id as string
|
|
141
|
+
if (declaration.subscriptionId == null
|
|
142
|
+
|| await records.hasEvent(id, 'cancel-scheduled', undefined, true)) continue
|
|
143
|
+
const attempt = await failures(id, 'cancel-scheduled')
|
|
144
|
+
const row = await access.subscriptions().byExternalId(declaration.subscriptionId, STRIPE_PAYGATE_ALIAS)
|
|
145
|
+
if (row == null || attempt >= MAX_ATTEMPTS) continue
|
|
146
|
+
handled++
|
|
147
|
+
result.retried++
|
|
148
|
+
if (!await cancellationOf(ctx).scheduleCancellation(stripe, declaration, row, attempt)) {
|
|
149
|
+
result.failed++
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const retryMails = async (since: Date, limit: number, result: ConsumerReconcileResult): Promise<void> => {
|
|
155
|
+
const policy = await access.payment().consumerRightsPolicy()
|
|
156
|
+
const alias = (await access.consumerMailConfig())?.alias ?? MAILER_SERVICE
|
|
157
|
+
if (policy == null || (ctx as unknown as { hasService?: (alias: string) => boolean }).hasService?.(alias) !== true) {
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
for (const event of await pendingSteps('mail', since, limit)) {
|
|
161
|
+
if (event.step == null) continue
|
|
162
|
+
if (await consumerMailOf(ctx).sendConsumerMail(policy, event.step as ConsumerMailKind, event.recordId)) {
|
|
163
|
+
result.mailed++
|
|
164
|
+
} else if (!await records.hasEvent(event.recordId, 'mail', event.step, true)) {
|
|
165
|
+
result.failed++
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const retryObservers = async (since: Date, limit: number, result: ConsumerReconcileResult): Promise<void> => {
|
|
171
|
+
for (const event of await pendingSteps('observers', since, limit)) {
|
|
172
|
+
let told = false
|
|
173
|
+
try {
|
|
174
|
+
if (event.step === 'consent') {
|
|
175
|
+
const consent = await access.consumerConsents().load(event.recordId)
|
|
176
|
+
told = consent != null && await consumerObserversOf(ctx).notifyConsent(consent)
|
|
177
|
+
} else if (event.step === 'withdrawal') {
|
|
178
|
+
const declaration = await access.consumerDeclarations().load(event.recordId)
|
|
179
|
+
const purchase = declaration?.purchaseId != null ? await access.purchases().byPurchaseId(declaration.purchaseId) : null
|
|
180
|
+
if (declaration != null && purchase != null) {
|
|
181
|
+
const refunded = await records.hasEvent(event.recordId, 'refund', undefined, true)
|
|
182
|
+
|| (declaration.refundMinor ?? 0) <= 0
|
|
183
|
+
const refund = await access.consumerEvents().load({ recordId: event.recordId, action: 'refund', ok: true })
|
|
184
|
+
const note = await access.consumerEvents().load({ recordId: event.recordId, action: 'credit-note', ok: true })
|
|
185
|
+
told = await consumerObserversOf(ctx).notifyWithdrawal(
|
|
186
|
+
declaration, purchase,
|
|
187
|
+
declaration.status === WithdrawalStatus.Processing && refunded ? WithdrawalStatus.Refunded : WithdrawalStatus.Review,
|
|
188
|
+
await computedOf(event.recordId),
|
|
189
|
+
refund != null ? {
|
|
190
|
+
ok: true, refundId: refund.externalId ?? undefined, creditNoteId: note?.externalId ?? undefined,
|
|
191
|
+
refundedMinor: refund.amountMinor ?? 0, needsReview: false,
|
|
192
|
+
subscriptionCanceled: await records.hasEvent(event.recordId, 'subscription-cancel', undefined, true),
|
|
193
|
+
} : null,
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
} else if (event.step === 'cancellation') {
|
|
197
|
+
const declaration = await access.consumerDeclarations().load(event.recordId)
|
|
198
|
+
if (declaration != null) {
|
|
199
|
+
const scheduled = await records.hasEvent(event.recordId, 'cancel-scheduled', undefined, true)
|
|
200
|
+
told = await consumerObserversOf(ctx).notifyCancellation(declaration,
|
|
201
|
+
declaration.status === CancellationStatus.Scheduled && !scheduled
|
|
202
|
+
? CancellationStatus.Received : declaration.status as CancellationStatus)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
} catch (error) {
|
|
206
|
+
log.error('Reconcile: observers failed', { recordId: event.recordId, error })
|
|
207
|
+
}
|
|
208
|
+
if (told) {
|
|
209
|
+
result.observed++
|
|
210
|
+
} else {
|
|
211
|
+
result.failed++
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Completed checkouts of the last days that have no purchase row (records only — no mail). */
|
|
217
|
+
const backfillPurchases = async (stripe: Stripe, limit: number, result: ConsumerReconcileResult): Promise<void> => {
|
|
218
|
+
const from = Math.floor((Date.now() - PURCHASE_BACKFILL_DAYS * DAY_MS) / 1000)
|
|
219
|
+
let startingAfter: string | undefined
|
|
220
|
+
let scanned = 0
|
|
221
|
+
for (;;) {
|
|
222
|
+
const page = await stripe.checkout.sessions.list({
|
|
223
|
+
created: { gte: from }, status: 'complete', limit: 100,
|
|
224
|
+
...(startingAfter != null ? { starting_after: startingAfter } : {}),
|
|
225
|
+
})
|
|
226
|
+
for (const session of page.data) {
|
|
227
|
+
scanned++
|
|
228
|
+
if (result.backfilled >= limit) return
|
|
229
|
+
const metadata = session.metadata ?? {}
|
|
230
|
+
if (metadata.entityId == null || metadata.productSku == null) continue
|
|
231
|
+
try {
|
|
232
|
+
if (session.mode === 'payment' && session.payment_status === 'paid') {
|
|
233
|
+
if (await access.purchases().load({ sessionId: session.id }) != null) continue
|
|
234
|
+
const amount = Number(metadata.amountMinor)
|
|
235
|
+
const captured = await captureOf(ctx).capturePaymentPurchase(stripe, session, {
|
|
236
|
+
...(Number.isSafeInteger(amount) && amount > 0 ? { netAmountMinor: amount } : {}),
|
|
237
|
+
...(metadata.amountCurrency != null ? { amountCurrency: metadata.amountCurrency } : {}),
|
|
238
|
+
at: new Date(session.created * 1000),
|
|
239
|
+
}, { mail: false })
|
|
240
|
+
if (captured?.created === true) result.backfilled++
|
|
241
|
+
} else if (session.mode === 'subscription') {
|
|
242
|
+
const subscriptionId = paymentUtils.idOf(session.subscription)
|
|
243
|
+
if (subscriptionId == null
|
|
244
|
+
|| await access.purchases().byPurchaseId(records.purchaseIdOf(subscriptionId)) != null) continue
|
|
245
|
+
const row = await access.subscriptions().byExternalId(subscriptionId, STRIPE_PAYGATE_ALIAS)
|
|
246
|
+
if (row == null || !ENTITLING_STATUSES.includes(row.status)) continue
|
|
247
|
+
const subscription = await stripe.subscriptions.retrieve(subscriptionId)
|
|
248
|
+
const captured = await captureOf(ctx).captureSubscriptionPurchase(stripe, subscription, row)
|
|
249
|
+
if (captured != null) {
|
|
250
|
+
await captureOf(ctx).completeSubscriptionPurchase(stripe, session, captured.purchase, { mail: false })
|
|
251
|
+
if (captured.created) result.backfilled++
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
} catch (error) {
|
|
255
|
+
result.failed++
|
|
256
|
+
log.error('Reconcile: purchase backfill failed', { sessionId: session.id, error })
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (!page.has_more || page.data.length === 0 || scanned >= limit * 20) return
|
|
260
|
+
startingAfter = page.data[page.data.length - 1].id
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Organizations that paid before countries were locked: locked from their paygate customer's
|
|
266
|
+
* address — never one an operator unlocked (its next completed purchase locks it).
|
|
267
|
+
*/
|
|
268
|
+
const lockLegacy = async (stripe: Stripe, limit: number, result: ConsumerReconcileResult): Promise<void> => {
|
|
269
|
+
const policy = await access.payment().consumerRightsPolicy()
|
|
270
|
+
if (policy?.mechanisms.countryLock !== true) {
|
|
271
|
+
return
|
|
272
|
+
}
|
|
273
|
+
const { items } = await access.paygateCustomers().list({ paygate: STRIPE_PAYGATE_ALIAS, deletedAt: null }, { size: limit * 4 })
|
|
274
|
+
for (const customer of items) {
|
|
275
|
+
if (result.locked >= limit) return
|
|
276
|
+
if (customer.entityId == null || await access.billingProfiles().byEntity(customer.entityId) != null) continue
|
|
277
|
+
if (!await records.hasPaid(customer.entityId) || await records.wasUnlocked(customer.entityId)) continue
|
|
278
|
+
try {
|
|
279
|
+
let country = customer.country
|
|
280
|
+
if (country == null) {
|
|
281
|
+
const retrieved = await stripe.customers.retrieve(customer.externalId)
|
|
282
|
+
country = (retrieved as Stripe.DeletedCustomer).deleted ? undefined : (retrieved as Stripe.Customer).address?.country ?? undefined
|
|
283
|
+
}
|
|
284
|
+
if (country == null) continue
|
|
285
|
+
const { created } = await records.lockProfile(policy, {
|
|
286
|
+
entityId: customer.entityId, country, source: 'customer', customerId: customer.externalId,
|
|
287
|
+
email: customer.email ?? undefined,
|
|
288
|
+
})
|
|
289
|
+
if (created) result.locked++
|
|
290
|
+
} catch (error) {
|
|
291
|
+
result.failed++
|
|
292
|
+
log.error('Reconcile: legacy billing-country lock failed', { entityId: customer.entityId, error })
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const reconcile = async (opts: ConsumerReconcileOptions = {}): Promise<ConsumerReconcileResult> => {
|
|
298
|
+
const result: ConsumerReconcileResult = { retried: 0, mailed: 0, observed: 0, backfilled: 0, locked: 0, failed: 0 }
|
|
299
|
+
if (await access.payment().consumerRightsPolicy() == null) {
|
|
300
|
+
return result
|
|
301
|
+
}
|
|
302
|
+
const limit = Math.max(1, opts.limit ?? 50)
|
|
303
|
+
const since = opts.since ?? new Date(Date.now() - 30 * DAY_MS)
|
|
304
|
+
const stripe = internals.managed ? await internals.stripe(ctx) : null
|
|
305
|
+
const steps: Array<[string, () => Promise<void>]> = [
|
|
306
|
+
...(stripe != null ? [
|
|
307
|
+
['withdrawals', async () => { await retryWithdrawals(stripe, since, limit, result) }],
|
|
308
|
+
['cancellations', async () => { await retryCancellations(stripe, since, limit, result) }],
|
|
309
|
+
] as Array<[string, () => Promise<void>]> : []),
|
|
310
|
+
['mails', async () => { await retryMails(since, limit, result) }],
|
|
311
|
+
['observers', async () => { await retryObservers(since, limit, result) }],
|
|
312
|
+
...(stripe != null ? [
|
|
313
|
+
['backfill', async () => { await backfillPurchases(stripe, limit, result) }],
|
|
314
|
+
['legacy locks', async () => { await lockLegacy(stripe, limit, result) }],
|
|
315
|
+
] as Array<[string, () => Promise<void>]> : []),
|
|
316
|
+
]
|
|
317
|
+
for (const [name, step] of steps) {
|
|
318
|
+
try {
|
|
319
|
+
await step()
|
|
320
|
+
} catch (error) {
|
|
321
|
+
result.failed++
|
|
322
|
+
log.error('Consumer-rights reconcile step failed', { step: name, error })
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return result
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return { reconcile }
|
|
330
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { BillingProfileView, ConsumerRightsPolicy } from '@owlmeans/payment'
|
|
2
|
+
import type {
|
|
3
|
+
BillingProfileRecord, ConsumerEventRecord, PaymentSubscriptionRecord, PurchaseRecord, UnlockOptions,
|
|
4
|
+
} from '../../types.js'
|
|
5
|
+
import type { LockInput, LockResult, PurchaseDraft } from '../types.js'
|
|
6
|
+
|
|
7
|
+
/** One audit step as it is appended — `at` defaults to now. */
|
|
8
|
+
export interface ConsumerEventDraft extends Omit<ConsumerEventRecord, 'at' | 'id'> { at?: Date }
|
|
9
|
+
|
|
10
|
+
/** The consumer-rights records of a context: purchases, billing profiles and the audit trail. */
|
|
11
|
+
export interface ConsumerRecords {
|
|
12
|
+
/** The purchase id of a paygate checkout session or subscription: `stripe:<id>`. */
|
|
13
|
+
purchaseIdOf: (externalId: string) => string
|
|
14
|
+
/** A locked profile as the wire sees it. */
|
|
15
|
+
profileViewOf: (record: BillingProfileRecord, policy: ConsumerRightsPolicy | null) => BillingProfileView
|
|
16
|
+
/** No profile yet: nothing locked, the default legal language, an unknown buyer (protected by default). */
|
|
17
|
+
unlockedProfileView: (policy: ConsumerRightsPolicy | null) => BillingProfileView
|
|
18
|
+
/**
|
|
19
|
+
* Append one audit step. A failure to write it is logged and never fails the act it describes —
|
|
20
|
+
* the act's own record (consent, declaration, purchase) is already written.
|
|
21
|
+
*/
|
|
22
|
+
recordEvent: (event: ConsumerEventDraft) => Promise<void>
|
|
23
|
+
/** Whether a step already succeeded (or a mail was deliberately skipped) for a record. */
|
|
24
|
+
hasEvent: (recordId: string, action: ConsumerEventRecord['action'], step?: string, ok?: boolean) => Promise<boolean>
|
|
25
|
+
/** The entity's highest-ranked entitling Stripe subscription, or `null`. */
|
|
26
|
+
entitlingStripeSubscription: (entityId: string) => Promise<PaymentSubscriptionRecord | null>
|
|
27
|
+
/** Whether the entity ever paid through the paygate (a fulfilled checkout or a propagated subscription). */
|
|
28
|
+
hasPaid: (entityId: string) => Promise<boolean>
|
|
29
|
+
/**
|
|
30
|
+
* Fix an entity's billing country — the FIRST write wins (a unique index on `entityId` settles a
|
|
31
|
+
* race). A later, different country is only a `lock-mismatch` event; only a `manual` lock with
|
|
32
|
+
* `force` replaces the country, audited as `relock`. The charge currency is fixed with it: the
|
|
33
|
+
* currency of an entitling paygate subscription when one exists (a customer's subscriptions share
|
|
34
|
+
* one currency), else the region's (`policy.currencies`), else the given one.
|
|
35
|
+
*/
|
|
36
|
+
lockProfile: (policy: ConsumerRightsPolicy | null, input: LockInput) => Promise<LockResult>
|
|
37
|
+
/**
|
|
38
|
+
* An operator removes an entity's lock: the profile row is deleted (only while it still holds the
|
|
39
|
+
* country read — a concurrent relock survives) and an `unlock` event keeps the whole row, `by` and
|
|
40
|
+
* `reason`. `null` when nothing was locked.
|
|
41
|
+
*/
|
|
42
|
+
unlockProfile: (entityId: string, opts?: UnlockOptions) => Promise<BillingProfileRecord | null>
|
|
43
|
+
/**
|
|
44
|
+
* Whether an operator unlocked the entity — then no lock is taken from its paygate customer's saved
|
|
45
|
+
* address (at checkout or in reconcile): its next completed purchase locks it.
|
|
46
|
+
*/
|
|
47
|
+
wasUnlocked: (entityId: string) => Promise<boolean>
|
|
48
|
+
/** The open, unconsented top-up windows of an entity — what a performance consent covers. */
|
|
49
|
+
unconsentedWindows: (entityId: string, at?: Date) => Promise<PurchaseRecord[]>
|
|
50
|
+
/**
|
|
51
|
+
* Write a purchase once: an existing row for the same purchase (or the same checkout session) is
|
|
52
|
+
* returned as it is. A contract-reference collision retries with a fresh reference.
|
|
53
|
+
*/
|
|
54
|
+
createPurchase: (draft: PurchaseDraft) => Promise<{ record: PurchaseRecord, created: boolean }>
|
|
55
|
+
/** Set fields on a purchase without replacing it (a concurrent conditional write survives). */
|
|
56
|
+
patchPurchase: (purchaseId: string, fields: Partial<PurchaseRecord>) => Promise<void>
|
|
57
|
+
/** The e-mail a consumer-rights mail reaches the organization at when no person named one. */
|
|
58
|
+
contactEmailOf: (entityId: string) => Promise<string | undefined>
|
|
59
|
+
/**
|
|
60
|
+
* Whether an e-mail address belongs to a purchase: its checkout e-mail, the organization's
|
|
61
|
+
* profile e-mail or its paygate customer's — compared case-insensitively.
|
|
62
|
+
*/
|
|
63
|
+
emailMatches: (purchase: PurchaseRecord, email: string) => Promise<boolean>
|
|
64
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { ConsumerRegion, ConsumerRightsError, ENTITLING_STATUSES, PurchaseKind, type BillingProfileView, type ConsumerRightsPolicy, consumerRegionHelper } from '@owlmeans/payment'
|
|
2
|
+
import type { Context as ApiContext } from '@owlmeans/server-api'
|
|
3
|
+
import { memoHelper } from '@owlmeans/context'
|
|
4
|
+
import { PURCHASE_ID_PREFIX, STRIPE_PAYGATE_ALIAS } from '../consts.js'
|
|
5
|
+
import type {
|
|
6
|
+
BillingProfileRecord, ConsumerEventRecord, PaymentSubscriptionRecord, PurchaseRecord, UnlockOptions,
|
|
7
|
+
} from '../types.js'
|
|
8
|
+
import { log } from '../log.js'
|
|
9
|
+
import { CONTRACT_REF_ATTEMPTS } from './consts.local.js'
|
|
10
|
+
import type { LockInput, LockResult, PurchaseDraft } from './types.js'
|
|
11
|
+
import { paymentAccessOf } from '../access.js'
|
|
12
|
+
import { paymentUtils } from '../utils.js'
|
|
13
|
+
import { consumerFormatHelper } from './format.js'
|
|
14
|
+
import type { ConsumerEventDraft, ConsumerRecords } from './records/types.js'
|
|
15
|
+
|
|
16
|
+
export const makeConsumerRecords = (ctx: ApiContext): ConsumerRecords => {
|
|
17
|
+
const access = paymentAccessOf(ctx)
|
|
18
|
+
|
|
19
|
+
const purchaseIdOf = (externalId: string): string => `${PURCHASE_ID_PREFIX}:${externalId}`
|
|
20
|
+
|
|
21
|
+
const profileViewOf = (record: BillingProfileRecord, policy: ConsumerRightsPolicy | null): BillingProfileView => ({
|
|
22
|
+
country: record.country,
|
|
23
|
+
region: record.region,
|
|
24
|
+
currency: record.currency,
|
|
25
|
+
locked: true,
|
|
26
|
+
lockedAt: new Date(record.lockedAt),
|
|
27
|
+
language: record.language,
|
|
28
|
+
inScope: consumerRegionHelper.inScope(record.region, record.country, policy),
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const unlockedProfileView = (policy: ConsumerRightsPolicy | null): BillingProfileView => ({
|
|
32
|
+
country: null,
|
|
33
|
+
region: null,
|
|
34
|
+
currency: null,
|
|
35
|
+
locked: false,
|
|
36
|
+
language: policy?.defaultLanguage ?? 'en',
|
|
37
|
+
inScope: consumerRegionHelper.inScope(null, null, policy),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const recordEvent = async (event: ConsumerEventDraft): Promise<void> => {
|
|
41
|
+
try {
|
|
42
|
+
await access.consumerEvents()
|
|
43
|
+
.create(paymentUtils.compact({ ...event, at: event.at ?? new Date() }) as ConsumerEventRecord)
|
|
44
|
+
} catch (error) {
|
|
45
|
+
log.error('Consumer event not recorded', { action: event.action, recordId: event.recordId, error })
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const hasEvent = async (
|
|
50
|
+
recordId: string, action: ConsumerEventRecord['action'], step?: string, ok?: boolean,
|
|
51
|
+
): Promise<boolean> => await access.consumerEvents().load(paymentUtils.compact({
|
|
52
|
+
recordId, action, ...(step != null ? { step } : {}), ...(ok != null ? { ok } : {}),
|
|
53
|
+
})) != null
|
|
54
|
+
|
|
55
|
+
/** The currency of the entity's entitling Stripe subscription — two of one customer cannot differ. */
|
|
56
|
+
const activeSubscriptionCurrency = async (entityId: string): Promise<string | undefined> => {
|
|
57
|
+
const row = await entitlingStripeSubscription(entityId)
|
|
58
|
+
|
|
59
|
+
return row?.currency ?? undefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const entitlingStripeSubscription = async (
|
|
63
|
+
entityId: string,
|
|
64
|
+
): Promise<PaymentSubscriptionRecord | null> => await access.subscriptions().load(
|
|
65
|
+
{ entityId, paygate: STRIPE_PAYGATE_ALIAS, status: [...ENTITLING_STATUSES] },
|
|
66
|
+
{ sort: [{ field: 'rank', order: 'desc' }, { field: 'createdAt', order: 'desc' }] },
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
const hasPaid = async (entityId: string): Promise<boolean> =>
|
|
70
|
+
await access.fulfillments().load({ entityId, paygate: STRIPE_PAYGATE_ALIAS, fulfilledAt: { $exists: true } }) != null
|
|
71
|
+
|| await access.subscriptions()
|
|
72
|
+
.load({ entityId, paygate: STRIPE_PAYGATE_ALIAS, initialPropagatedAt: { $exists: true } }) != null
|
|
73
|
+
|
|
74
|
+
const lockProfile = async (policy: ConsumerRightsPolicy | null, input: LockInput): Promise<LockResult> => {
|
|
75
|
+
const country = input.country.trim().toUpperCase()
|
|
76
|
+
if (!/^[A-Z]{2}$/.test(country)) {
|
|
77
|
+
throw new ConsumerRightsError(`lock:country:${input.country}`)
|
|
78
|
+
}
|
|
79
|
+
const resource = access.billingProfiles()
|
|
80
|
+
const now = new Date()
|
|
81
|
+
const existing = await resource.byEntity(input.entityId)
|
|
82
|
+
if (existing != null) {
|
|
83
|
+
return await compareLock(policy, existing, input, country, now)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const region = consumerRegionHelper.regionOf(country, policy) ?? ConsumerRegion.Other
|
|
87
|
+
const settlement = (await access.stripePricingConfig())?.settlementCurrency?.toLowerCase()
|
|
88
|
+
const currency = (await activeSubscriptionCurrency(input.entityId))
|
|
89
|
+
?? (policy?.currencies != null && Object.keys(policy.currencies).length > 0
|
|
90
|
+
? consumerRegionHelper.chargeCurrencyOf(region, policy, input.currency ?? settlement ?? 'usd')
|
|
91
|
+
: input.currency ?? settlement ?? 'usd')
|
|
92
|
+
const record = paymentUtils.compact({
|
|
93
|
+
entityId: input.entityId,
|
|
94
|
+
country,
|
|
95
|
+
region,
|
|
96
|
+
currency: currency.toLowerCase(),
|
|
97
|
+
language: input.language ?? consumerRegionHelper.billingLanguageOf(country, policy),
|
|
98
|
+
source: input.source,
|
|
99
|
+
paygate: STRIPE_PAYGATE_ALIAS,
|
|
100
|
+
customerId: input.customerId,
|
|
101
|
+
sessionId: input.sessionId,
|
|
102
|
+
ipCountry: input.ipCountry?.toUpperCase(),
|
|
103
|
+
email: input.email,
|
|
104
|
+
name: input.name,
|
|
105
|
+
business: input.business,
|
|
106
|
+
lockedAt: now,
|
|
107
|
+
createdAt: now,
|
|
108
|
+
}) as BillingProfileRecord
|
|
109
|
+
try {
|
|
110
|
+
const created = await resource.create(record)
|
|
111
|
+
await recordEvent({
|
|
112
|
+
recordId: input.entityId, recordKind: 'profile', entityId: input.entityId, action: 'lock', ok: true,
|
|
113
|
+
detail: JSON.stringify(paymentUtils.compact({
|
|
114
|
+
source: input.source, country, currency: created.currency, sessionId: input.sessionId,
|
|
115
|
+
ipCountry: input.ipCountry?.toUpperCase(),
|
|
116
|
+
ipMismatch: input.ipCountry != null ? input.ipCountry.toUpperCase() !== country : undefined,
|
|
117
|
+
by: input.by, reason: input.reason,
|
|
118
|
+
})),
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
return { record: created, created: true, mismatch: false }
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (!paymentUtils.isDuplicateKey(error)) {
|
|
124
|
+
throw error
|
|
125
|
+
}
|
|
126
|
+
const winner = await resource.byEntity(input.entityId)
|
|
127
|
+
if (winner == null) {
|
|
128
|
+
throw error
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return await compareLock(policy, winner, input, country, now)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const compareLock = async (
|
|
136
|
+
policy: ConsumerRightsPolicy | null, existing: BillingProfileRecord, input: LockInput,
|
|
137
|
+
country: string, now: Date,
|
|
138
|
+
): Promise<LockResult> => {
|
|
139
|
+
if (input.source === 'manual' && input.force === true) {
|
|
140
|
+
const region = consumerRegionHelper.regionOf(country, policy) ?? ConsumerRegion.Other
|
|
141
|
+
const updated = await access.billingProfiles().update(paymentUtils.compact({
|
|
142
|
+
...existing,
|
|
143
|
+
country,
|
|
144
|
+
region,
|
|
145
|
+
currency: (input.currency ?? (country === existing.country ? existing.currency
|
|
146
|
+
: consumerRegionHelper.chargeCurrencyOf(region, policy, existing.currency))).toLowerCase(),
|
|
147
|
+
language: input.language ?? (country === existing.country ? existing.language : consumerRegionHelper.billingLanguageOf(country, policy)),
|
|
148
|
+
source: 'manual' as const,
|
|
149
|
+
updatedAt: now,
|
|
150
|
+
}))
|
|
151
|
+
await recordEvent({
|
|
152
|
+
recordId: existing.entityId, recordKind: 'profile', entityId: existing.entityId, action: 'relock', ok: true,
|
|
153
|
+
detail: JSON.stringify(paymentUtils.compact({
|
|
154
|
+
from: existing.country, to: country, currency: updated.currency, by: input.by, reason: input.reason,
|
|
155
|
+
})),
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
return { record: updated, created: false, mismatch: false }
|
|
159
|
+
}
|
|
160
|
+
const mismatch = existing.country !== country
|
|
161
|
+
if (mismatch) {
|
|
162
|
+
await recordEvent({
|
|
163
|
+
recordId: existing.entityId, recordKind: 'profile', entityId: existing.entityId, action: 'lock-mismatch',
|
|
164
|
+
ok: true,
|
|
165
|
+
detail: JSON.stringify(paymentUtils.compact({
|
|
166
|
+
locked: existing.country, observed: country, source: input.source, sessionId: input.sessionId,
|
|
167
|
+
ipCountry: input.ipCountry,
|
|
168
|
+
})),
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return { record: existing, created: false, mismatch }
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const unlockProfile = async (entityId: string, opts: UnlockOptions = {}): Promise<BillingProfileRecord | null> => {
|
|
176
|
+
const resource = access.billingProfiles()
|
|
177
|
+
const existing = await resource.byEntity(entityId)
|
|
178
|
+
if (existing == null) {
|
|
179
|
+
return null
|
|
180
|
+
}
|
|
181
|
+
if (!await paymentUtils.conditionalDelete(resource, { entityId, country: existing.country })) {
|
|
182
|
+
throw new ConsumerRightsError(`unlock:changed:${entityId}`)
|
|
183
|
+
}
|
|
184
|
+
const { id: _id, ...row } = existing
|
|
185
|
+
await recordEvent({
|
|
186
|
+
recordId: entityId, recordKind: 'profile', entityId, action: 'unlock', ok: true,
|
|
187
|
+
detail: JSON.stringify(paymentUtils.compact({ from: existing.country, by: opts.by, reason: opts.reason, profile: row })),
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
return existing
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const wasUnlocked = async (entityId: string): Promise<boolean> =>
|
|
194
|
+
await hasEvent(entityId, 'unlock')
|
|
195
|
+
|
|
196
|
+
const unconsentedWindows = async (entityId: string, at: Date = new Date()): Promise<PurchaseRecord[]> =>
|
|
197
|
+
(await access.purchases().list({
|
|
198
|
+
entityId, inScope: true, kind: PurchaseKind.TopUp, consentedAt: null, withdrawnAt: null, refundedAt: null,
|
|
199
|
+
deadline: { $gt: at },
|
|
200
|
+
}, { size: 100, sort: [{ field: 'deadline', order: 'desc' }] })).items
|
|
201
|
+
|
|
202
|
+
const createPurchase = async (draft: PurchaseDraft): Promise<{ record: PurchaseRecord, created: boolean }> => {
|
|
203
|
+
const resource = access.purchases()
|
|
204
|
+
const existing = await resource.byPurchaseId(draft.purchaseId)
|
|
205
|
+
?? (draft.sessionId != null ? await resource.load({ sessionId: draft.sessionId }) : null)
|
|
206
|
+
if (existing != null) {
|
|
207
|
+
return { record: existing, created: false }
|
|
208
|
+
}
|
|
209
|
+
let last: unknown = null
|
|
210
|
+
for (let attempt = 0; attempt < CONTRACT_REF_ATTEMPTS; attempt++) {
|
|
211
|
+
try {
|
|
212
|
+
const record = await resource.create(paymentUtils.compact({
|
|
213
|
+
...draft, contractRef: consumerFormatHelper.newContractRef(new Date(draft.purchasedAt)), createdAt: new Date(),
|
|
214
|
+
}) as PurchaseRecord)
|
|
215
|
+
|
|
216
|
+
return { record, created: true }
|
|
217
|
+
} catch (error) {
|
|
218
|
+
if (!paymentUtils.isDuplicateKey(error)) {
|
|
219
|
+
throw error
|
|
220
|
+
}
|
|
221
|
+
last = error
|
|
222
|
+
const winner = await resource.byPurchaseId(draft.purchaseId)
|
|
223
|
+
?? (draft.sessionId != null ? await resource.load({ sessionId: draft.sessionId }) : null)
|
|
224
|
+
if (winner != null) {
|
|
225
|
+
return { record: winner, created: false }
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
log.error('No free contract reference after retries', { purchaseId: draft.purchaseId, error: last })
|
|
230
|
+
throw new ConsumerRightsError('contract-ref')
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const patchPurchase = async (purchaseId: string, fields: Partial<PurchaseRecord>): Promise<void> => {
|
|
234
|
+
const set = Object.fromEntries(Object.entries({ ...fields, updatedAt: new Date() }).filter(([, value]) => value !== undefined))
|
|
235
|
+
const resource = access.purchases()
|
|
236
|
+
const collection = (resource as unknown as { collection?: { updateOne?: unknown } }).collection
|
|
237
|
+
if (collection?.updateOne != null) {
|
|
238
|
+
await (collection.updateOne as (filter: object, update: object) => Promise<unknown>)({ purchaseId }, { $set: set })
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
const current = await resource.byPurchaseId(purchaseId)
|
|
242
|
+
if (current != null) {
|
|
243
|
+
await resource.update({ ...current, ...set })
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const contactEmailOf = async (entityId: string): Promise<string | undefined> => {
|
|
248
|
+
const profile = await access.billingProfiles().byEntity(entityId)
|
|
249
|
+
if (profile?.email != null && profile.email !== '') {
|
|
250
|
+
return profile.email
|
|
251
|
+
}
|
|
252
|
+
const latest = await access.purchases().load({ entityId, email: { $exists: true } }, {
|
|
253
|
+
sort: [{ field: 'purchasedAt', order: 'desc' }],
|
|
254
|
+
})
|
|
255
|
+
if (latest?.email != null && latest.email !== '') {
|
|
256
|
+
return latest.email
|
|
257
|
+
}
|
|
258
|
+
const customer = await access.paygateCustomers().byEntity(entityId, STRIPE_PAYGATE_ALIAS)
|
|
259
|
+
|
|
260
|
+
return customer?.email ?? undefined
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const emailMatches = async (purchase: PurchaseRecord, email: string): Promise<boolean> => {
|
|
264
|
+
const wanted = consumerFormatHelper.normalizeEmail(email)
|
|
265
|
+
if (wanted === '') {
|
|
266
|
+
return false
|
|
267
|
+
}
|
|
268
|
+
if (consumerFormatHelper.normalizeEmail(purchase.email) === wanted) {
|
|
269
|
+
return true
|
|
270
|
+
}
|
|
271
|
+
const profile = await access.billingProfiles().byEntity(purchase.entityId)
|
|
272
|
+
if (consumerFormatHelper.normalizeEmail(profile?.email) === wanted) {
|
|
273
|
+
return true
|
|
274
|
+
}
|
|
275
|
+
const customer = await access.paygateCustomers().byEntity(purchase.entityId, STRIPE_PAYGATE_ALIAS)
|
|
276
|
+
|
|
277
|
+
return consumerFormatHelper.normalizeEmail(customer?.email) === wanted
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return {
|
|
281
|
+
purchaseIdOf, profileViewOf, unlockedProfileView, recordEvent, hasEvent, entitlingStripeSubscription, hasPaid,
|
|
282
|
+
lockProfile, unlockProfile, wasUnlocked, unconsentedWindows, createPurchase, patchPurchase, contactEmailOf,
|
|
283
|
+
emailMatches,
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** The consumer-rights records of a context — one per context. */
|
|
288
|
+
export const consumerRecordsOf = memoHelper.oncePer(makeConsumerRecords)
|