@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.
- 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,66 @@
|
|
|
1
|
+
import type { BillingProfileView, ConsumerRightsPolicy } from '@owlmeans/payment';
|
|
2
|
+
import type { BillingProfileRecord, ConsumerEventRecord, PaymentSubscriptionRecord, PurchaseRecord, UnlockOptions } from '../../types.js';
|
|
3
|
+
import type { LockInput, LockResult, PurchaseDraft } from '../types.js';
|
|
4
|
+
/** One audit step as it is appended — `at` defaults to now. */
|
|
5
|
+
export interface ConsumerEventDraft extends Omit<ConsumerEventRecord, 'at' | 'id'> {
|
|
6
|
+
at?: Date;
|
|
7
|
+
}
|
|
8
|
+
/** The consumer-rights records of a context: purchases, billing profiles and the audit trail. */
|
|
9
|
+
export interface ConsumerRecords {
|
|
10
|
+
/** The purchase id of a paygate checkout session or subscription: `stripe:<id>`. */
|
|
11
|
+
purchaseIdOf: (externalId: string) => string;
|
|
12
|
+
/** A locked profile as the wire sees it. */
|
|
13
|
+
profileViewOf: (record: BillingProfileRecord, policy: ConsumerRightsPolicy | null) => BillingProfileView;
|
|
14
|
+
/** No profile yet: nothing locked, the default legal language, an unknown buyer (protected by default). */
|
|
15
|
+
unlockedProfileView: (policy: ConsumerRightsPolicy | null) => BillingProfileView;
|
|
16
|
+
/**
|
|
17
|
+
* Append one audit step. A failure to write it is logged and never fails the act it describes —
|
|
18
|
+
* the act's own record (consent, declaration, purchase) is already written.
|
|
19
|
+
*/
|
|
20
|
+
recordEvent: (event: ConsumerEventDraft) => Promise<void>;
|
|
21
|
+
/** Whether a step already succeeded (or a mail was deliberately skipped) for a record. */
|
|
22
|
+
hasEvent: (recordId: string, action: ConsumerEventRecord['action'], step?: string, ok?: boolean) => Promise<boolean>;
|
|
23
|
+
/** The entity's highest-ranked entitling Stripe subscription, or `null`. */
|
|
24
|
+
entitlingStripeSubscription: (entityId: string) => Promise<PaymentSubscriptionRecord | null>;
|
|
25
|
+
/** Whether the entity ever paid through the paygate (a fulfilled checkout or a propagated subscription). */
|
|
26
|
+
hasPaid: (entityId: string) => Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Fix an entity's billing country — the FIRST write wins (a unique index on `entityId` settles a
|
|
29
|
+
* race). A later, different country is only a `lock-mismatch` event; only a `manual` lock with
|
|
30
|
+
* `force` replaces the country, audited as `relock`. The charge currency is fixed with it: the
|
|
31
|
+
* currency of an entitling paygate subscription when one exists (a customer's subscriptions share
|
|
32
|
+
* one currency), else the region's (`policy.currencies`), else the given one.
|
|
33
|
+
*/
|
|
34
|
+
lockProfile: (policy: ConsumerRightsPolicy | null, input: LockInput) => Promise<LockResult>;
|
|
35
|
+
/**
|
|
36
|
+
* An operator removes an entity's lock: the profile row is deleted (only while it still holds the
|
|
37
|
+
* country read — a concurrent relock survives) and an `unlock` event keeps the whole row, `by` and
|
|
38
|
+
* `reason`. `null` when nothing was locked.
|
|
39
|
+
*/
|
|
40
|
+
unlockProfile: (entityId: string, opts?: UnlockOptions) => Promise<BillingProfileRecord | null>;
|
|
41
|
+
/**
|
|
42
|
+
* Whether an operator unlocked the entity — then no lock is taken from its paygate customer's saved
|
|
43
|
+
* address (at checkout or in reconcile): its next completed purchase locks it.
|
|
44
|
+
*/
|
|
45
|
+
wasUnlocked: (entityId: string) => Promise<boolean>;
|
|
46
|
+
/** The open, unconsented top-up windows of an entity — what a performance consent covers. */
|
|
47
|
+
unconsentedWindows: (entityId: string, at?: Date) => Promise<PurchaseRecord[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Write a purchase once: an existing row for the same purchase (or the same checkout session) is
|
|
50
|
+
* returned as it is. A contract-reference collision retries with a fresh reference.
|
|
51
|
+
*/
|
|
52
|
+
createPurchase: (draft: PurchaseDraft) => Promise<{
|
|
53
|
+
record: PurchaseRecord;
|
|
54
|
+
created: boolean;
|
|
55
|
+
}>;
|
|
56
|
+
/** Set fields on a purchase without replacing it (a concurrent conditional write survives). */
|
|
57
|
+
patchPurchase: (purchaseId: string, fields: Partial<PurchaseRecord>) => Promise<void>;
|
|
58
|
+
/** The e-mail a consumer-rights mail reaches the organization at when no person named one. */
|
|
59
|
+
contactEmailOf: (entityId: string) => Promise<string | undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* Whether an e-mail address belongs to a purchase: its checkout e-mail, the organization's
|
|
62
|
+
* profile e-mail or its paygate customer's — compared case-insensitively.
|
|
63
|
+
*/
|
|
64
|
+
emailMatches: (purchase: PurchaseRecord, email: string) => Promise<boolean>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/consumer/records/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EACV,oBAAoB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,cAAc,EAAE,aAAa,EACpG,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEvE,+DAA+D;AAC/D,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC;IAAG,EAAE,CAAC,EAAE,IAAI,CAAA;CAAE;AAEhG,iGAAiG;AACjG,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAA;IAC5C,4CAA4C;IAC5C,aAAa,E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AK,EAAE,aAAa,KAAK,OAAO,CAAC;QAAE,MAAM,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IAC/F,+FAA+F;IAC/F,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrF,8FAA8F;IAC9F,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACjE;;;OAGG;IACH,YAAY,EAAE,CAAC,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/consumer/records/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context as ApiContext } from '@owlmeans/server-api';
|
|
2
|
+
import type { ConsumerRecords } from './records/types.js';
|
|
3
|
+
export declare const makeConsumerRecords: (ctx: ApiContext) => ConsumerRecords;
|
|
4
|
+
/** The consumer-rights records of a context — one per context. */
|
|
5
|
+
export declare const consumerRecordsOf: (target: ApiContext<import("@owlmeans/server-api").Config>) => ConsumerRecords;
|
|
6
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/consumer/records.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAYjE,OAAO,KAAK,EAAsB,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAE7E,eAAO,MAAM,mBAAmB,QAAS,UAAU,KAAG,eA6QrD,CAAA;AAED,kEAAkE;AAClE,eAAO,MAAM,iBAAiB,gFAA0C,CAAA"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { ConsumerRegion, ConsumerRightsError, ENTITLING_STATUSES, PurchaseKind, consumerRegionHelper } from '@owlmeans/payment';
|
|
2
|
+
import { memoHelper } from '@owlmeans/context';
|
|
3
|
+
import { PURCHASE_ID_PREFIX, STRIPE_PAYGATE_ALIAS } from '../consts.js';
|
|
4
|
+
import { log } from '../log.js';
|
|
5
|
+
import { CONTRACT_REF_ATTEMPTS } from './consts.local.js';
|
|
6
|
+
import { paymentAccessOf } from '../access.js';
|
|
7
|
+
import { paymentUtils } from '../utils.js';
|
|
8
|
+
import { consumerFormatHelper } from './format.js';
|
|
9
|
+
export const makeConsumerRecords = (ctx) => {
|
|
10
|
+
const access = paymentAccessOf(ctx);
|
|
11
|
+
const purchaseIdOf = (externalId) => `${PURCHASE_ID_PREFIX}:${externalId}`;
|
|
12
|
+
const profileViewOf = (record, policy) => ({
|
|
13
|
+
country: record.country,
|
|
14
|
+
region: record.region,
|
|
15
|
+
currency: record.currency,
|
|
16
|
+
locked: true,
|
|
17
|
+
lockedAt: new Date(record.lockedAt),
|
|
18
|
+
language: record.language,
|
|
19
|
+
inScope: consumerRegionHelper.inScope(record.region, record.country, policy),
|
|
20
|
+
});
|
|
21
|
+
const unlockedProfileView = (policy) => ({
|
|
22
|
+
country: null,
|
|
23
|
+
region: null,
|
|
24
|
+
currency: null,
|
|
25
|
+
locked: false,
|
|
26
|
+
language: policy?.defaultLanguage ?? 'en',
|
|
27
|
+
inScope: consumerRegionHelper.inScope(null, null, policy),
|
|
28
|
+
});
|
|
29
|
+
const recordEvent = async (event) => {
|
|
30
|
+
try {
|
|
31
|
+
await access.consumerEvents()
|
|
32
|
+
.create(paymentUtils.compact({ ...event, at: event.at ?? new Date() }));
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
log.error('Consumer event not recorded', { action: event.action, recordId: event.recordId, error });
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const hasEvent = async (recordId, action, step, ok) => await access.consumerEvents().load(paymentUtils.compact({
|
|
39
|
+
recordId, action, ...(step != null ? { step } : {}), ...(ok != null ? { ok } : {}),
|
|
40
|
+
})) != null;
|
|
41
|
+
/** The currency of the entity's entitling Stripe subscription — two of one customer cannot differ. */
|
|
42
|
+
const activeSubscriptionCurrency = async (entityId) => {
|
|
43
|
+
const row = await entitlingStripeSubscription(entityId);
|
|
44
|
+
return row?.currency ?? undefined;
|
|
45
|
+
};
|
|
46
|
+
const entitlingStripeSubscription = async (entityId) => await access.subscriptions().load({ entityId, paygate: STRIPE_PAYGATE_ALIAS, status: [...ENTITLING_STATUSES] }, { sort: [{ field: 'rank', order: 'desc' }, { field: 'createdAt', order: 'desc' }] });
|
|
47
|
+
const hasPaid = async (entityId) => await access.fulfillments().load({ entityId, paygate: STRIPE_PAYGATE_ALIAS, fulfilledAt: { $exists: true } }) != null
|
|
48
|
+
|| await access.subscriptions()
|
|
49
|
+
.load({ entityId, paygate: STRIPE_PAYGATE_ALIAS, initialPropagatedAt: { $exists: true } }) != null;
|
|
50
|
+
const lockProfile = async (policy, input) => {
|
|
51
|
+
const country = input.country.trim().toUpperCase();
|
|
52
|
+
if (!/^[A-Z]{2}$/.test(country)) {
|
|
53
|
+
throw new ConsumerRightsError(`lock:country:${input.country}`);
|
|
54
|
+
}
|
|
55
|
+
const resource = access.billingProfiles();
|
|
56
|
+
const now = new Date();
|
|
57
|
+
const existing = await resource.byEntity(input.entityId);
|
|
58
|
+
if (existing != null) {
|
|
59
|
+
return await compareLock(policy, existing, input, country, now);
|
|
60
|
+
}
|
|
61
|
+
const region = consumerRegionHelper.regionOf(country, policy) ?? ConsumerRegion.Other;
|
|
62
|
+
const settlement = (await access.stripePricingConfig())?.settlementCurrency?.toLowerCase();
|
|
63
|
+
const currency = (await activeSubscriptionCurrency(input.entityId))
|
|
64
|
+
?? (policy?.currencies != null && Object.keys(policy.currencies).length > 0
|
|
65
|
+
? consumerRegionHelper.chargeCurrencyOf(region, policy, input.currency ?? settlement ?? 'usd')
|
|
66
|
+
: input.currency ?? settlement ?? 'usd');
|
|
67
|
+
const record = paymentUtils.compact({
|
|
68
|
+
entityId: input.entityId,
|
|
69
|
+
country,
|
|
70
|
+
region,
|
|
71
|
+
currency: currency.toLowerCase(),
|
|
72
|
+
language: input.language ?? consumerRegionHelper.billingLanguageOf(country, policy),
|
|
73
|
+
source: input.source,
|
|
74
|
+
paygate: STRIPE_PAYGATE_ALIAS,
|
|
75
|
+
customerId: input.customerId,
|
|
76
|
+
sessionId: input.sessionId,
|
|
77
|
+
ipCountry: input.ipCountry?.toUpperCase(),
|
|
78
|
+
email: input.email,
|
|
79
|
+
name: input.name,
|
|
80
|
+
business: input.business,
|
|
81
|
+
lockedAt: now,
|
|
82
|
+
createdAt: now,
|
|
83
|
+
});
|
|
84
|
+
try {
|
|
85
|
+
const created = await resource.create(record);
|
|
86
|
+
await recordEvent({
|
|
87
|
+
recordId: input.entityId, recordKind: 'profile', entityId: input.entityId, action: 'lock', ok: true,
|
|
88
|
+
detail: JSON.stringify(paymentUtils.compact({
|
|
89
|
+
source: input.source, country, currency: created.currency, sessionId: input.sessionId,
|
|
90
|
+
ipCountry: input.ipCountry?.toUpperCase(),
|
|
91
|
+
ipMismatch: input.ipCountry != null ? input.ipCountry.toUpperCase() !== country : undefined,
|
|
92
|
+
by: input.by, reason: input.reason,
|
|
93
|
+
})),
|
|
94
|
+
});
|
|
95
|
+
return { record: created, created: true, mismatch: false };
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (!paymentUtils.isDuplicateKey(error)) {
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
const winner = await resource.byEntity(input.entityId);
|
|
102
|
+
if (winner == null) {
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
return await compareLock(policy, winner, input, country, now);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const compareLock = async (policy, existing, input, country, now) => {
|
|
109
|
+
if (input.source === 'manual' && input.force === true) {
|
|
110
|
+
const region = consumerRegionHelper.regionOf(country, policy) ?? ConsumerRegion.Other;
|
|
111
|
+
const updated = await access.billingProfiles().update(paymentUtils.compact({
|
|
112
|
+
...existing,
|
|
113
|
+
country,
|
|
114
|
+
region,
|
|
115
|
+
currency: (input.currency ?? (country === existing.country ? existing.currency
|
|
116
|
+
: consumerRegionHelper.chargeCurrencyOf(region, policy, existing.currency))).toLowerCase(),
|
|
117
|
+
language: input.language ?? (country === existing.country ? existing.language : consumerRegionHelper.billingLanguageOf(country, policy)),
|
|
118
|
+
source: 'manual',
|
|
119
|
+
updatedAt: now,
|
|
120
|
+
}));
|
|
121
|
+
await recordEvent({
|
|
122
|
+
recordId: existing.entityId, recordKind: 'profile', entityId: existing.entityId, action: 'relock', ok: true,
|
|
123
|
+
detail: JSON.stringify(paymentUtils.compact({
|
|
124
|
+
from: existing.country, to: country, currency: updated.currency, by: input.by, reason: input.reason,
|
|
125
|
+
})),
|
|
126
|
+
});
|
|
127
|
+
return { record: updated, created: false, mismatch: false };
|
|
128
|
+
}
|
|
129
|
+
const mismatch = existing.country !== country;
|
|
130
|
+
if (mismatch) {
|
|
131
|
+
await recordEvent({
|
|
132
|
+
recordId: existing.entityId, recordKind: 'profile', entityId: existing.entityId, action: 'lock-mismatch',
|
|
133
|
+
ok: true,
|
|
134
|
+
detail: JSON.stringify(paymentUtils.compact({
|
|
135
|
+
locked: existing.country, observed: country, source: input.source, sessionId: input.sessionId,
|
|
136
|
+
ipCountry: input.ipCountry,
|
|
137
|
+
})),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return { record: existing, created: false, mismatch };
|
|
141
|
+
};
|
|
142
|
+
const unlockProfile = async (entityId, opts = {}) => {
|
|
143
|
+
const resource = access.billingProfiles();
|
|
144
|
+
const existing = await resource.byEntity(entityId);
|
|
145
|
+
if (existing == null) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
if (!await paymentUtils.conditionalDelete(resource, { entityId, country: existing.country })) {
|
|
149
|
+
throw new ConsumerRightsError(`unlock:changed:${entityId}`);
|
|
150
|
+
}
|
|
151
|
+
const { id: _id, ...row } = existing;
|
|
152
|
+
await recordEvent({
|
|
153
|
+
recordId: entityId, recordKind: 'profile', entityId, action: 'unlock', ok: true,
|
|
154
|
+
detail: JSON.stringify(paymentUtils.compact({ from: existing.country, by: opts.by, reason: opts.reason, profile: row })),
|
|
155
|
+
});
|
|
156
|
+
return existing;
|
|
157
|
+
};
|
|
158
|
+
const wasUnlocked = async (entityId) => await hasEvent(entityId, 'unlock');
|
|
159
|
+
const unconsentedWindows = async (entityId, at = new Date()) => (await access.purchases().list({
|
|
160
|
+
entityId, inScope: true, kind: PurchaseKind.TopUp, consentedAt: null, withdrawnAt: null, refundedAt: null,
|
|
161
|
+
deadline: { $gt: at },
|
|
162
|
+
}, { size: 100, sort: [{ field: 'deadline', order: 'desc' }] })).items;
|
|
163
|
+
const createPurchase = async (draft) => {
|
|
164
|
+
const resource = access.purchases();
|
|
165
|
+
const existing = await resource.byPurchaseId(draft.purchaseId)
|
|
166
|
+
?? (draft.sessionId != null ? await resource.load({ sessionId: draft.sessionId }) : null);
|
|
167
|
+
if (existing != null) {
|
|
168
|
+
return { record: existing, created: false };
|
|
169
|
+
}
|
|
170
|
+
let last = null;
|
|
171
|
+
for (let attempt = 0; attempt < CONTRACT_REF_ATTEMPTS; attempt++) {
|
|
172
|
+
try {
|
|
173
|
+
const record = await resource.create(paymentUtils.compact({
|
|
174
|
+
...draft, contractRef: consumerFormatHelper.newContractRef(new Date(draft.purchasedAt)), createdAt: new Date(),
|
|
175
|
+
}));
|
|
176
|
+
return { record, created: true };
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
if (!paymentUtils.isDuplicateKey(error)) {
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
last = error;
|
|
183
|
+
const winner = await resource.byPurchaseId(draft.purchaseId)
|
|
184
|
+
?? (draft.sessionId != null ? await resource.load({ sessionId: draft.sessionId }) : null);
|
|
185
|
+
if (winner != null) {
|
|
186
|
+
return { record: winner, created: false };
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
log.error('No free contract reference after retries', { purchaseId: draft.purchaseId, error: last });
|
|
191
|
+
throw new ConsumerRightsError('contract-ref');
|
|
192
|
+
};
|
|
193
|
+
const patchPurchase = async (purchaseId, fields) => {
|
|
194
|
+
const set = Object.fromEntries(Object.entries({ ...fields, updatedAt: new Date() }).filter(([, value]) => value !== undefined));
|
|
195
|
+
const resource = access.purchases();
|
|
196
|
+
const collection = resource.collection;
|
|
197
|
+
if (collection?.updateOne != null) {
|
|
198
|
+
await collection.updateOne({ purchaseId }, { $set: set });
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const current = await resource.byPurchaseId(purchaseId);
|
|
202
|
+
if (current != null) {
|
|
203
|
+
await resource.update({ ...current, ...set });
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const contactEmailOf = async (entityId) => {
|
|
207
|
+
const profile = await access.billingProfiles().byEntity(entityId);
|
|
208
|
+
if (profile?.email != null && profile.email !== '') {
|
|
209
|
+
return profile.email;
|
|
210
|
+
}
|
|
211
|
+
const latest = await access.purchases().load({ entityId, email: { $exists: true } }, {
|
|
212
|
+
sort: [{ field: 'purchasedAt', order: 'desc' }],
|
|
213
|
+
});
|
|
214
|
+
if (latest?.email != null && latest.email !== '') {
|
|
215
|
+
return latest.email;
|
|
216
|
+
}
|
|
217
|
+
const customer = await access.paygateCustomers().byEntity(entityId, STRIPE_PAYGATE_ALIAS);
|
|
218
|
+
return customer?.email ?? undefined;
|
|
219
|
+
};
|
|
220
|
+
const emailMatches = async (purchase, email) => {
|
|
221
|
+
const wanted = consumerFormatHelper.normalizeEmail(email);
|
|
222
|
+
if (wanted === '') {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
if (consumerFormatHelper.normalizeEmail(purchase.email) === wanted) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
const profile = await access.billingProfiles().byEntity(purchase.entityId);
|
|
229
|
+
if (consumerFormatHelper.normalizeEmail(profile?.email) === wanted) {
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
const customer = await access.paygateCustomers().byEntity(purchase.entityId, STRIPE_PAYGATE_ALIAS);
|
|
233
|
+
return consumerFormatHelper.normalizeEmail(customer?.email) === wanted;
|
|
234
|
+
};
|
|
235
|
+
return {
|
|
236
|
+
purchaseIdOf, profileViewOf, unlockedProfileView, recordEvent, hasEvent, entitlingStripeSubscription, hasPaid,
|
|
237
|
+
lockProfile, unlockProfile, wasUnlocked, unconsentedWindows, createPurchase, patchPurchase, contactEmailOf,
|
|
238
|
+
emailMatches,
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
/** The consumer-rights records of a context — one per context. */
|
|
242
|
+
export const consumerRecordsOf = memoHelper.oncePer(makeConsumerRecords);
|
|
243
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/consumer/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAsD,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAEnL,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAIvE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAG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AAC,KAAK,CAAC,KAAK,MAAM,EAAE,CAAC;YACnE,OAAO,IAAI,CAAA;QACb,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAC1E,IAAI,oBAAoB,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,MAAM,EAAE,CAAC;YACnE,OAAO,IAAI,CAAA;QACb,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAA;QAElG,OAAO,oBAAoB,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,MAAM,CAAA;IACxE,CAAC,CAAA;IAED,OAAO;QACL,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,QAAQ,EAAE,2BAA2B,EAAE,OAAO;QAC7G,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc;QAC1G,YAAY;KACb,CAAA;AACH,CAAC,CAAA;AAED,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ConsumerRightsRegistrar } from './types.js';
|
|
2
|
+
import type { Config, ConsumerRightsOptions, ConsumerRightsService, Context } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The consumer-rights service (`CONSUMER_RIGHTS_SERVICE`): the billing profile and its lock,
|
|
5
|
+
* purchases and their withdrawal windows, performance consent and subscription start requests,
|
|
6
|
+
* the withdrawal and cancellation functions with their paygate steps, the durable-medium mails,
|
|
7
|
+
* and `reconcile`. Unmanaged (`manage: false`) it still reads, records consents and asserts them;
|
|
8
|
+
* withdrawing and cancelling need the paygate.
|
|
9
|
+
*
|
|
10
|
+
* A lazy service, like the completion observer: `useMeter` / `useMailRenderer` work while the
|
|
11
|
+
* application is still being wired, before the context initializes.
|
|
12
|
+
*/
|
|
13
|
+
export declare const makeConsumerRightsService: (alias?: string, opts?: ConsumerRightsOptions) => ConsumerRightsService;
|
|
14
|
+
/**
|
|
15
|
+
* Register the consumer-rights resources and service (each only when absent), or configure the
|
|
16
|
+
* service already registered — `from` says who asks. The order of the application's call and the
|
|
17
|
+
* gateway's is free: `usage` and `stripe` are installed whenever they come, and the application's
|
|
18
|
+
* explicit `manage` wins over the gateway's. The resources keep the first registration's aliases.
|
|
19
|
+
*/
|
|
20
|
+
export declare const registerConsumerRights: <C extends Config, T extends Context<C>>(ctx: T, opts?: ConsumerRightsOptions, from?: ConsumerRightsRegistrar) => T;
|
|
21
|
+
/**
|
|
22
|
+
* Register the consumer-rights resources and service, each only when absent — the gateway
|
|
23
|
+
* registration does too. Called before or after the gateway, it installs `usage` and `stripe` on
|
|
24
|
+
* the service and its explicit `manage` wins over the gateway's; `useMeter` and `useMailRenderer`
|
|
25
|
+
* work on the service at any time.
|
|
26
|
+
*/
|
|
27
|
+
export declare const appendConsumerRights: <C extends Config, T extends Context<C>>(ctx: T, opts?: ConsumerRightsOptions) => T;
|
|
28
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/consumer/service.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAC2D,uBAAuB,EAC7F,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EACV,MAAM,EAA0E,qBAAqB,EACrG,qBAAqB,EAAE,OAAO,EAC/B,MAAM,aAAa,CAAA;AAmDpB;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,WAC7B,MAAM,SAAkC,qBAAqB,KACnE,qBAwoBF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,OACtE,CAAC,SAAQ,qBAAqB,SAAa,uBAAuB,KACtE,CAsBF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,OACpE,CAAC,SAAQ,qBAAqB,KAClC,CAAqD,CAAA"}
|