@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,85 @@
|
|
|
1
|
+
import { randomInt } from 'node:crypto'
|
|
2
|
+
import { CONTRACT_REF_ALPHABET, RESERVED_MAIL_TLDS } from '../consts.js'
|
|
3
|
+
import type { ConsumerFormatHelper } from './format/types.js'
|
|
4
|
+
import { withdrawalDeadlineHelper } from '@owlmeans/payment'
|
|
5
|
+
|
|
6
|
+
export const createConsumerFormatHelper = (): ConsumerFormatHelper => {
|
|
7
|
+
const newContractRef = (at: Date = new Date()): string => {
|
|
8
|
+
const date = [at.getUTCFullYear() % 100, at.getUTCMonth() + 1, at.getUTCDate()]
|
|
9
|
+
.map(part => String(part).padStart(2, '0')).join('')
|
|
10
|
+
const suffix = Array.from({ length: 6 }, () => CONTRACT_REF_ALPHABET[randomInt(CONTRACT_REF_ALPHABET.length)])
|
|
11
|
+
.join('')
|
|
12
|
+
|
|
13
|
+
return `CR-${date}-${suffix}`
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const normalizeContractRef = (value: string): string =>
|
|
17
|
+
value.trim().toUpperCase().replace(/[‐-―−\s]+/g, '-')
|
|
18
|
+
|
|
19
|
+
const normalizeEmail = (value: string | null | undefined): string => (value ?? '').trim().toLowerCase()
|
|
20
|
+
|
|
21
|
+
const isReservedAddress = (address: string): boolean => {
|
|
22
|
+
const bare = normalizeEmail(address).replace(/^.*<([^>]*)>.*$/, '$1')
|
|
23
|
+
const domain = (bare.split('@').pop() ?? '').trim().replace(/\.+$/, '')
|
|
24
|
+
const tld = domain.split('.').pop() ?? ''
|
|
25
|
+
|
|
26
|
+
return RESERVED_MAIL_TLDS.includes(tld)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const escapeHtml = (value: string): string => value
|
|
30
|
+
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
31
|
+
.replace(/"/g, '"').replace(/'/g, ''')
|
|
32
|
+
|
|
33
|
+
const fractionDigitsOf = (currency: string): number => {
|
|
34
|
+
try {
|
|
35
|
+
return new Intl.NumberFormat('en', { style: 'currency', currency: currency.toUpperCase() })
|
|
36
|
+
.resolvedOptions().maximumFractionDigits ?? 2
|
|
37
|
+
} catch {
|
|
38
|
+
return 2
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const formatMoney = (amountMinor: number, currency: string, lng: string): string => {
|
|
43
|
+
const digits = fractionDigitsOf(currency)
|
|
44
|
+
const major = amountMinor / 10 ** digits
|
|
45
|
+
try {
|
|
46
|
+
return new Intl.NumberFormat(lng, { style: 'currency', currency: currency.toUpperCase() }).format(major)
|
|
47
|
+
} catch {
|
|
48
|
+
return `${major.toFixed(digits)} ${currency.toUpperCase()}`
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const formatDateTime = (at: Date, lng: string): string => {
|
|
53
|
+
try {
|
|
54
|
+
return new Intl.DateTimeFormat(lng, { dateStyle: 'long', timeStyle: 'short', timeZone: 'UTC' }).format(at)
|
|
55
|
+
} catch {
|
|
56
|
+
return at.toISOString().replace('T', ' ').slice(0, 16)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const formatDate = (at: Date, lng: string): string => {
|
|
61
|
+
try {
|
|
62
|
+
return new Intl.DateTimeFormat(lng, { dateStyle: 'long', timeZone: 'UTC' }).format(at)
|
|
63
|
+
} catch {
|
|
64
|
+
return at.toISOString().slice(0, 10)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const formatDeadline = (deadline: Date, lng: string): string =>
|
|
69
|
+
formatDate(withdrawalDeadlineHelper.lastWithdrawalDayOf(deadline), lng)
|
|
70
|
+
|
|
71
|
+
const countryName = (country: string, lng: string): string => {
|
|
72
|
+
try {
|
|
73
|
+
return new Intl.DisplayNames([lng], { type: 'region' }).of(country.toUpperCase()) ?? country
|
|
74
|
+
} catch {
|
|
75
|
+
return country
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
newContractRef, normalizeContractRef, normalizeEmail, isReservedAddress, escapeHtml, formatMoney, formatDateTime,
|
|
81
|
+
formatDate, formatDeadline, countryName,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const consumerFormatHelper = createConsumerFormatHelper()
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto'
|
|
2
|
+
import { AuthForbidden } from '@owlmeans/auth'
|
|
3
|
+
import type { AbstractRequest } from '@owlmeans/entrypoint'
|
|
4
|
+
import {
|
|
5
|
+
ConsumerRightsError, DeclarationChannel, type CheckoutReadProtocols, type ConsumerRightsPublicView,
|
|
6
|
+
type DeclarationReceipt,
|
|
7
|
+
} from '@owlmeans/payment'
|
|
8
|
+
import { handlers, type Context as ApiContext } from '@owlmeans/server-api'
|
|
9
|
+
import { bind } from '@owlmeans/server-entrypoint'
|
|
10
|
+
import { CONSUMER_RIGHTS_SERVICE, GATEWAY_SERVICE } from '../consts.js'
|
|
11
|
+
import type {
|
|
12
|
+
CheckoutReadHandlerOptions, ConsumerRightsHandlerOptions, ConsumerRightsService, ConsumerSubject, Context,
|
|
13
|
+
GatewayService, RequestOrigin,
|
|
14
|
+
} from '../types.js'
|
|
15
|
+
import { DEFAULT_PUBLIC_MIN_MS } from './consts.local.js'
|
|
16
|
+
import type { Bound, ConsumerRightsTree } from './types.js'
|
|
17
|
+
import { paymentAccessOf } from '../access.js'
|
|
18
|
+
import { originHelper } from './origin.js'
|
|
19
|
+
import { consumerRecordsOf } from './records.js'
|
|
20
|
+
|
|
21
|
+
const defaultEntity = (req: AbstractRequest, _ctx?: ApiContext): string | null => req.entity?.id ?? null
|
|
22
|
+
|
|
23
|
+
const sleep = async (ms: number): Promise<void> => await new Promise(resolve => setTimeout(resolve, ms))
|
|
24
|
+
|
|
25
|
+
/** Answer no sooner than `minMs` after the start — a matched declaration takes as long as an unmatched one. */
|
|
26
|
+
const padded = async <T>(minMs: number, run: () => Promise<T>): Promise<T> => {
|
|
27
|
+
const started = Date.now()
|
|
28
|
+
try {
|
|
29
|
+
return await run()
|
|
30
|
+
} finally {
|
|
31
|
+
const left = minMs - (Date.now() - started)
|
|
32
|
+
if (left > 0) await sleep(left)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The public answer: what was declared and when — never a status, an amount or a match. */
|
|
37
|
+
const publicPart = (receipt: DeclarationReceipt): DeclarationReceipt => ({
|
|
38
|
+
declarationId: receipt.declarationId, receivedAt: receipt.receivedAt, content: receipt.content, mailed: receipt.mailed,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
/** A form a bot filled (the honeypot) gets the same shape of answer, and nothing is recorded or sent. */
|
|
42
|
+
const decoyReceipt = (content: Record<string, string>): DeclarationReceipt => ({
|
|
43
|
+
declarationId: randomBytes(12).toString('hex'), receivedAt: new Date(), content, mailed: false,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const typed = (fields: Record<string, string | undefined>): Record<string, string> =>
|
|
47
|
+
Object.fromEntries(Object.entries(fields).filter((entry): entry is [string, string] =>
|
|
48
|
+
typeof entry[1] === 'string' && entry[1].trim() !== ''))
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Server bindings of `makeConsumerRightsProtocols`' tree over the consumer-rights service. The
|
|
52
|
+
* account routes act for the request's organization (`resolveEntity`, default `req.entity.id`);
|
|
53
|
+
* the money-moving acts (consent, start request, withdrawal, cancellation) pass `guardMoney` first
|
|
54
|
+
* (refuse an API key there). The public routes — the statutory functions without a login — need
|
|
55
|
+
* `throttle` (a wiring error otherwise), drop a filled honeypot silently, and answer every
|
|
56
|
+
* declaration with the same receipt shape after at least `publicMinMs`, matched or not. Every hook
|
|
57
|
+
* gets the request's context as its last argument.
|
|
58
|
+
*
|
|
59
|
+
* @throws SyntaxError when the tree has a public subtree and no `throttle` is given
|
|
60
|
+
*/
|
|
61
|
+
export const consumerRightsEntrypoints = (
|
|
62
|
+
protocols: ConsumerRightsTree, opts: ConsumerRightsHandlerOptions = {},
|
|
63
|
+
): Bound[] => {
|
|
64
|
+
if (protocols.public != null && opts.throttle == null) {
|
|
65
|
+
throw new SyntaxError('consumer-rights: the public routes need a throttle')
|
|
66
|
+
}
|
|
67
|
+
const api = handlers<Context>()
|
|
68
|
+
const serviceOf = (ctx: Context): ConsumerRightsService =>
|
|
69
|
+
ctx.service<ConsumerRightsService>(opts.serviceAlias ?? CONSUMER_RIGHTS_SERVICE)
|
|
70
|
+
const apiCtx = (ctx: Context): ApiContext => ctx as unknown as ApiContext
|
|
71
|
+
const entityOf = (req: AbstractRequest, ctx: Context): string => {
|
|
72
|
+
const entityId = (opts.resolveEntity ?? defaultEntity)(req, apiCtx(ctx))
|
|
73
|
+
if (entityId == null || entityId === '') {
|
|
74
|
+
throw new AuthForbidden('entity')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return entityId
|
|
78
|
+
}
|
|
79
|
+
const subjectFor = async (req: AbstractRequest, ctx: Context): Promise<ConsumerSubject> => ({
|
|
80
|
+
...(await opts.subjectOf?.(req, apiCtx(ctx)) ?? {}),
|
|
81
|
+
entityId: entityOf(req, ctx),
|
|
82
|
+
channel: DeclarationChannel.InApp,
|
|
83
|
+
})
|
|
84
|
+
const metaOf = (req: AbstractRequest, ctx: Context): RequestOrigin =>
|
|
85
|
+
opts.metaOf != null ? opts.metaOf(req, apiCtx(ctx)) : originHelper.requestOriginOf(req)
|
|
86
|
+
const guard = async (req: AbstractRequest, action: string, ctx: Context): Promise<void> => {
|
|
87
|
+
await opts.guardMoney?.(req, action, apiCtx(ctx))
|
|
88
|
+
}
|
|
89
|
+
const minMs = opts.publicMinMs ?? DEFAULT_PUBLIC_MIN_MS
|
|
90
|
+
|
|
91
|
+
const bound: Bound[] = [
|
|
92
|
+
bind(protocols.base),
|
|
93
|
+
bind(protocols.profile, api.request(protocols.profile, async (req, ctx) =>
|
|
94
|
+
await serviceOf(ctx).profile(entityOf(req, ctx))
|
|
95
|
+
?? consumerRecordsOf(apiCtx(ctx))
|
|
96
|
+
.unlockedProfileView(await paymentAccessOf(apiCtx(ctx)).payment().consumerRightsPolicy()))),
|
|
97
|
+
bind(protocols.purchases, api.request(protocols.purchases, async (req, ctx) =>
|
|
98
|
+
({ purchases: await serviceOf(ctx).purchases(entityOf(req, ctx)) }))),
|
|
99
|
+
bind(protocols.consent, api.request(protocols.consent, async (req, ctx) =>
|
|
100
|
+
await serviceOf(ctx).consentView(entityOf(req, ctx)))),
|
|
101
|
+
bind(protocols.giveConsent, api.body(protocols.giveConsent, async (body, ctx, req) => {
|
|
102
|
+
await guard(req, 'consent', ctx)
|
|
103
|
+
return await serviceOf(ctx).recordConsent(await subjectFor(req, ctx), body, metaOf(req, ctx))
|
|
104
|
+
})),
|
|
105
|
+
bind(protocols.start, api.request(protocols.start, async (req, ctx) =>
|
|
106
|
+
await serviceOf(ctx).startView(entityOf(req, ctx), String(req.query.planSku)))),
|
|
107
|
+
bind(protocols.requestStart, api.body(protocols.requestStart, async (body, ctx, req) => {
|
|
108
|
+
await guard(req, 'start', ctx)
|
|
109
|
+
const plan = await opts.planNameOf?.(body.planSku, body.language, req, apiCtx(ctx))
|
|
110
|
+
return await serviceOf(ctx).recordStartRequest(await subjectFor(req, ctx), body, metaOf(req, ctx), plan != null ? { plan } : {})
|
|
111
|
+
})),
|
|
112
|
+
bind(protocols.withdrawals, api.request(protocols.withdrawals, async (req, ctx) => {
|
|
113
|
+
const subject = await subjectFor(req, ctx)
|
|
114
|
+
return await serviceOf(ctx).withdrawalCandidates(subject.entityId, subject)
|
|
115
|
+
})),
|
|
116
|
+
bind(protocols.withdraw, api.body(protocols.withdraw, async (body, ctx, req) => {
|
|
117
|
+
await guard(req, 'withdraw', ctx)
|
|
118
|
+
return await serviceOf(ctx).withdraw(await subjectFor(req, ctx), body, metaOf(req, ctx))
|
|
119
|
+
})),
|
|
120
|
+
bind(protocols.cancel, api.body(protocols.cancel, async (body, ctx, req) => {
|
|
121
|
+
await guard(req, 'cancel', ctx)
|
|
122
|
+
return await serviceOf(ctx).cancel(await subjectFor(req, ctx), body, metaOf(req, ctx))
|
|
123
|
+
})),
|
|
124
|
+
] as Bound[]
|
|
125
|
+
|
|
126
|
+
const pub = protocols.public
|
|
127
|
+
if (pub == null) {
|
|
128
|
+
return bound
|
|
129
|
+
}
|
|
130
|
+
const throttle = opts.throttle as NonNullable<ConsumerRightsHandlerOptions['throttle']>
|
|
131
|
+
|
|
132
|
+
return [
|
|
133
|
+
...bound,
|
|
134
|
+
bind(pub.base),
|
|
135
|
+
bind(pub.policy, api.request(pub.policy, async (_req, ctx) => {
|
|
136
|
+
const policy = await paymentAccessOf(ctx as unknown as ApiContext).payment().consumerRightsPolicy()
|
|
137
|
+
if (policy == null) {
|
|
138
|
+
throw new ConsumerRightsError('policy:none')
|
|
139
|
+
}
|
|
140
|
+
const view: ConsumerRightsPublicView = {
|
|
141
|
+
mechanisms: { withdrawal: policy.mechanisms.withdrawal, cancellation: policy.mechanisms.cancellation },
|
|
142
|
+
languages: Object.keys(policy.links),
|
|
143
|
+
links: policy.links,
|
|
144
|
+
textVersion: policy.textVersion,
|
|
145
|
+
}
|
|
146
|
+
return view
|
|
147
|
+
})),
|
|
148
|
+
bind(pub.withdraw, api.body(pub.withdraw, async (body, ctx, req) => {
|
|
149
|
+
const origin = metaOf(req, ctx)
|
|
150
|
+
await throttle(req, { action: 'withdrawal', email: body.email, ...(origin.ip != null ? { ip: origin.ip } : {}) }, apiCtx(ctx))
|
|
151
|
+
return await padded(minMs, async () => {
|
|
152
|
+
const content = typed({ name: body.name, contract: body.contractRef, email: body.email })
|
|
153
|
+
if (body.honeypot != null && body.honeypot !== '') {
|
|
154
|
+
return decoyReceipt(content)
|
|
155
|
+
}
|
|
156
|
+
return publicPart(await serviceOf(ctx).withdraw(null, body, origin))
|
|
157
|
+
})
|
|
158
|
+
})),
|
|
159
|
+
bind(pub.cancel, api.body(pub.cancel, async (body, ctx, req) => {
|
|
160
|
+
const origin = metaOf(req, ctx)
|
|
161
|
+
await throttle(req, { action: 'cancellation', email: body.email, ...(origin.ip != null ? { ip: origin.ip } : {}) }, apiCtx(ctx))
|
|
162
|
+
return await padded(minMs, async () => {
|
|
163
|
+
const content = typed({
|
|
164
|
+
name: body.name, contract: body.contractRef, email: body.email, kind: body.kind, reason: body.reason,
|
|
165
|
+
date: body.effective === 'date' ? body.date : undefined,
|
|
166
|
+
})
|
|
167
|
+
if (body.honeypot != null && body.honeypot !== '') {
|
|
168
|
+
return decoyReceipt(content)
|
|
169
|
+
}
|
|
170
|
+
return publicPart(await serviceOf(ctx).cancel(null, body, origin))
|
|
171
|
+
})
|
|
172
|
+
})),
|
|
173
|
+
] as Bound[]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Server bindings of `makeCheckoutReadProtocols`' tree: the entity's amount policy as the checkout
|
|
178
|
+
* plugins narrow it now (the same computation the checkout enforces) and the synced plan prices.
|
|
179
|
+
*/
|
|
180
|
+
export const checkoutReadEntrypoints = (protocols: CheckoutReadProtocols, opts: CheckoutReadHandlerOptions = {}): Bound[] => {
|
|
181
|
+
const api = handlers<Context>()
|
|
182
|
+
const gatewayOf = (ctx: Context): GatewayService => ctx.service<GatewayService>(opts.gatewayAlias ?? GATEWAY_SERVICE)
|
|
183
|
+
const entityOf = (req: AbstractRequest, ctx: Context): string => {
|
|
184
|
+
const entityId = (opts.resolveEntity ?? defaultEntity)(req, ctx as unknown as ApiContext)
|
|
185
|
+
if (entityId == null || entityId === '') {
|
|
186
|
+
throw new AuthForbidden('entity')
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return entityId
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return [
|
|
193
|
+
bind(protocols.base),
|
|
194
|
+
bind(protocols.amountPolicy, api.request(protocols.amountPolicy, async (req, ctx) => {
|
|
195
|
+
const { productSku, planSku } = req.query as { productSku: string, planSku?: string }
|
|
196
|
+
return await gatewayOf(ctx).amountPolicy(ctx as unknown as ApiContext, entityOf(req, ctx), productSku, planSku ?? undefined)
|
|
197
|
+
})),
|
|
198
|
+
bind(protocols.planPrices, api.request(protocols.planPrices, async (req, ctx) => {
|
|
199
|
+
entityOf(req, ctx)
|
|
200
|
+
const { productSku } = req.query as { productSku: string }
|
|
201
|
+
return { prices: await gatewayOf(ctx).planPrices(ctx as unknown as ApiContext, productSku) }
|
|
202
|
+
})),
|
|
203
|
+
] as Bound[]
|
|
204
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { ConsumerRightsTree } from './types.js'
|
|
2
|
+
export { appendConsumerRights, makeConsumerRightsService } from './service.js'
|
|
3
|
+
export { consumerRightsEntrypoints, checkoutReadEntrypoints } from './handlers.js'
|
|
4
|
+
export type * from './format/types.js'
|
|
5
|
+
export * from './format.js'
|
|
6
|
+
export type * from './origin/types.js'
|
|
7
|
+
export * from './origin.js'
|
|
8
|
+
export type * from './mail/types.js'
|
|
9
|
+
export * from './mail.js'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ConsumerRightsPolicy } from '@owlmeans/payment'
|
|
2
|
+
import type { ConsumerMailData, ConsumerMailKind, ConsumerMailPluginConfig, TraderDef } from '../../types.js'
|
|
3
|
+
|
|
4
|
+
/** The consumer-rights mails of a context, on a durable medium. */
|
|
5
|
+
export interface ConsumerMailHelper {
|
|
6
|
+
/** The trader as the mails and the withdrawal information name it: legal name, address, e-mail. */
|
|
7
|
+
traderIdentityOf: (trader: TraderDef) => string
|
|
8
|
+
/** The declared trader; an undeclared one falls back to the service name (no mechanism is on then). */
|
|
9
|
+
traderOf: (mail: ConsumerMailPluginConfig | null) => TraderDef
|
|
10
|
+
/** A plan's title in a language: its localization, else its catalogue title, else its sku. */
|
|
11
|
+
planTitleOf: (planSku: string | undefined, lng: string) => Promise<string>
|
|
12
|
+
/**
|
|
13
|
+
* Everything a mail of `kind` about `recordId` is rendered from, read back from the records — the
|
|
14
|
+
* mail repeats exactly what was recorded, and a retry renders the same message. `null` when there
|
|
15
|
+
* is nobody to write to.
|
|
16
|
+
*/
|
|
17
|
+
mailDataOf: (
|
|
18
|
+
policy: ConsumerRightsPolicy, trader: TraderDef, kind: ConsumerMailKind, recordId: string,
|
|
19
|
+
) => Promise<ConsumerMailData | null>
|
|
20
|
+
/**
|
|
21
|
+
* Send one consumer-rights mail on a durable medium, in the language the consumer was shown, and
|
|
22
|
+
* record the outcome as a `mail` event (step = the mail kind): sent, skipped (a reserved domain
|
|
23
|
+
* such as `.test` / `.example` / `.invalid` / `.localhost`, or a renderer that suppressed it) or
|
|
24
|
+
* failed (a transport error, no mailer registered — retried by `reconcile`). The application's
|
|
25
|
+
* renderer (`useMailRenderer`) may replace the message. Each archive (`bcc`) address gets its own
|
|
26
|
+
* copy. Never throws.
|
|
27
|
+
*
|
|
28
|
+
* @returns whether the consumer's own copy was handed to the mailer
|
|
29
|
+
*/
|
|
30
|
+
sendConsumerMail: (policy: ConsumerRightsPolicy, kind: ConsumerMailKind, recordId: string) => Promise<boolean>
|
|
31
|
+
}
|