@zonastery/bursar 0.0.2 → 1.0.1
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 +118 -333
- package/dist/billing/auto-recharge-port.d.ts +27 -0
- package/dist/billing/auto-recharge-port.d.ts.map +1 -0
- package/dist/billing/auto-recharge-port.js +2 -0
- package/dist/billing/auto-recharge-port.js.map +1 -0
- package/dist/billing/auto-recharge-service.d.ts +43 -0
- package/dist/billing/auto-recharge-service.d.ts.map +1 -0
- package/dist/billing/auto-recharge-service.js +218 -0
- package/dist/billing/auto-recharge-service.js.map +1 -0
- package/dist/billing/billing-service.d.ts +71 -0
- package/dist/billing/billing-service.d.ts.map +1 -0
- package/dist/billing/billing-service.js +172 -0
- package/dist/billing/billing-service.js.map +1 -0
- package/dist/billing/billing-store.d.ts +45 -13
- package/dist/billing/billing-store.d.ts.map +1 -1
- package/dist/billing/billing-store.js.map +1 -1
- package/dist/billing/contracts.d.ts +149 -0
- package/dist/billing/contracts.d.ts.map +1 -0
- package/dist/billing/contracts.js +2 -0
- package/dist/billing/contracts.js.map +1 -0
- package/dist/billing/event-handlers.d.ts +57 -0
- package/dist/billing/event-handlers.d.ts.map +1 -0
- package/dist/billing/event-handlers.js +684 -0
- package/dist/billing/event-handlers.js.map +1 -0
- package/dist/billing/event-processor.d.ts +20 -0
- package/dist/billing/event-processor.d.ts.map +1 -0
- package/dist/billing/event-processor.js +131 -0
- package/dist/billing/event-processor.js.map +1 -0
- package/dist/billing/financial-event-handlers.d.ts +26 -0
- package/dist/billing/financial-event-handlers.d.ts.map +1 -0
- package/dist/billing/financial-event-handlers.js +241 -0
- package/dist/billing/financial-event-handlers.js.map +1 -0
- package/dist/billing/index.d.ts +9 -5
- package/dist/billing/index.d.ts.map +1 -1
- package/dist/billing/index.js +4 -4
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/management.d.ts +59 -0
- package/dist/billing/management.d.ts.map +1 -0
- package/dist/billing/management.js +113 -0
- package/dist/billing/management.js.map +1 -0
- package/dist/billing/policy-window.d.ts +24 -0
- package/dist/billing/policy-window.d.ts.map +1 -0
- package/dist/billing/policy-window.js +88 -0
- package/dist/billing/policy-window.js.map +1 -0
- package/dist/billing/postgres/repositories/auto-recharge.d.ts +32 -0
- package/dist/billing/postgres/repositories/auto-recharge.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/auto-recharge.js +180 -0
- package/dist/billing/postgres/repositories/auto-recharge.js.map +1 -0
- package/dist/billing/postgres/repositories/customer.d.ts +12 -0
- package/dist/billing/postgres/repositories/customer.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/customer.js +33 -0
- package/dist/billing/postgres/repositories/customer.js.map +1 -0
- package/dist/billing/postgres/repositories/dispute.d.ts +7 -0
- package/dist/billing/postgres/repositories/dispute.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/dispute.js +18 -0
- package/dist/billing/postgres/repositories/dispute.js.map +1 -0
- package/dist/billing/postgres/repositories/event.d.ts +21 -0
- package/dist/billing/postgres/repositories/event.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/event.js +45 -0
- package/dist/billing/postgres/repositories/event.js.map +1 -0
- package/dist/billing/postgres/repositories/invoice.d.ts +9 -0
- package/dist/billing/postgres/repositories/invoice.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/invoice.js +36 -0
- package/dist/billing/postgres/repositories/invoice.js.map +1 -0
- package/dist/billing/postgres/repositories/offer.d.ts +26 -0
- package/dist/billing/postgres/repositories/offer.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/offer.js +73 -0
- package/dist/billing/postgres/repositories/offer.js.map +1 -0
- package/dist/billing/postgres/repositories/payment.d.ts +32 -0
- package/dist/billing/postgres/repositories/payment.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/payment.js +78 -0
- package/dist/billing/postgres/repositories/payment.js.map +1 -0
- package/dist/billing/postgres/repositories/preferences.d.ts +15 -0
- package/dist/billing/postgres/repositories/preferences.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/preferences.js +23 -0
- package/dist/billing/postgres/repositories/preferences.js.map +1 -0
- package/dist/billing/postgres/repositories/refund.d.ts +7 -0
- package/dist/billing/postgres/repositories/refund.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/refund.js +32 -0
- package/dist/billing/postgres/repositories/refund.js.map +1 -0
- package/dist/billing/postgres/repositories/subscription.d.ts +46 -0
- package/dist/billing/postgres/repositories/subscription.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/subscription.js +187 -0
- package/dist/billing/postgres/repositories/subscription.js.map +1 -0
- package/dist/billing/postgres/repositories/topup.d.ts +27 -0
- package/dist/billing/postgres/repositories/topup.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/topup.js +51 -0
- package/dist/billing/postgres/repositories/topup.js.map +1 -0
- package/dist/billing/postgres/store.d.ts +89 -0
- package/dist/billing/postgres/store.d.ts.map +1 -0
- package/dist/billing/postgres/store.js +542 -0
- package/dist/billing/postgres/store.js.map +1 -0
- package/dist/billing/service-types.d.ts +37 -0
- package/dist/billing/service-types.d.ts.map +1 -0
- package/dist/billing/service-types.js +2 -0
- package/dist/billing/service-types.js.map +1 -0
- package/dist/billing/types/auto-recharge.d.ts +56 -0
- package/dist/billing/types/auto-recharge.d.ts.map +1 -0
- package/dist/billing/types/auto-recharge.js +2 -0
- package/dist/billing/types/auto-recharge.js.map +1 -0
- package/dist/billing/types/catalog.d.ts +47 -0
- package/dist/billing/types/catalog.d.ts.map +1 -0
- package/dist/billing/types/catalog.js +2 -0
- package/dist/billing/types/catalog.js.map +1 -0
- package/dist/billing/types/common.d.ts +16 -0
- package/dist/billing/types/common.d.ts.map +1 -0
- package/dist/billing/types/common.js +2 -0
- package/dist/billing/types/common.js.map +1 -0
- package/dist/billing/types/documents.d.ts +39 -0
- package/dist/billing/types/documents.d.ts.map +1 -0
- package/dist/billing/types/documents.js +2 -0
- package/dist/billing/types/documents.js.map +1 -0
- package/dist/billing/types/events.d.ts +75 -0
- package/dist/billing/types/events.d.ts.map +1 -0
- package/dist/billing/types/events.js +38 -0
- package/dist/billing/types/events.js.map +1 -0
- package/dist/billing/types/index.d.ts +8 -0
- package/dist/billing/types/index.d.ts.map +1 -0
- package/dist/billing/types/index.js +8 -0
- package/dist/billing/types/index.js.map +1 -0
- package/dist/billing/types/preferences.d.ts +13 -0
- package/dist/billing/types/preferences.d.ts.map +1 -0
- package/dist/billing/types/preferences.js +2 -0
- package/dist/billing/types/preferences.js.map +1 -0
- package/dist/billing/types/subscriptions.d.ts +97 -0
- package/dist/billing/types/subscriptions.d.ts.map +1 -0
- package/dist/billing/types/subscriptions.js +12 -0
- package/dist/billing/types/subscriptions.js.map +1 -0
- package/dist/breakdown.d.ts +3 -1
- package/dist/breakdown.d.ts.map +1 -1
- package/dist/breakdown.js +4 -1
- package/dist/breakdown.js.map +1 -1
- package/dist/browser.d.ts +8 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +7 -0
- package/dist/browser.js.map +1 -0
- package/dist/bursar.d.ts +84 -0
- package/dist/bursar.d.ts.map +1 -0
- package/dist/bursar.js +137 -0
- package/dist/bursar.js.map +1 -0
- package/dist/catalog.d.ts +62 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +96 -0
- package/dist/catalog.js.map +1 -0
- package/dist/commerce/errors.d.ts +68 -0
- package/dist/commerce/errors.d.ts.map +1 -0
- package/dist/commerce/errors.js +105 -0
- package/dist/commerce/errors.js.map +1 -0
- package/dist/commerce/index.d.ts +6 -0
- package/dist/commerce/index.d.ts.map +1 -0
- package/dist/commerce/index.js +6 -0
- package/dist/commerce/index.js.map +1 -0
- package/dist/commerce/plan-change.d.ts +10 -0
- package/dist/commerce/plan-change.d.ts.map +1 -0
- package/dist/commerce/plan-change.js +42 -0
- package/dist/commerce/plan-change.js.map +1 -0
- package/dist/commerce/provider-registry.d.ts +18 -0
- package/dist/commerce/provider-registry.d.ts.map +1 -0
- package/dist/commerce/provider-registry.js +70 -0
- package/dist/commerce/provider-registry.js.map +1 -0
- package/dist/commerce/service.d.ts +73 -0
- package/dist/commerce/service.d.ts.map +1 -0
- package/dist/commerce/service.js +1016 -0
- package/dist/commerce/service.js.map +1 -0
- package/dist/commerce/types.d.ts +225 -0
- package/dist/commerce/types.d.ts.map +1 -0
- package/dist/commerce/types.js.map +1 -0
- package/dist/config/parse-access.d.ts +6 -0
- package/dist/config/parse-access.d.ts.map +1 -0
- package/dist/config/parse-access.js +72 -0
- package/dist/config/parse-access.js.map +1 -0
- package/dist/config/parse-commerce.d.ts +3 -0
- package/dist/config/parse-commerce.d.ts.map +1 -0
- package/dist/config/parse-commerce.js +236 -0
- package/dist/config/parse-commerce.js.map +1 -0
- package/dist/config/parse-credits.d.ts +3 -0
- package/dist/config/parse-credits.d.ts.map +1 -0
- package/dist/config/parse-credits.js +99 -0
- package/dist/config/parse-credits.js.map +1 -0
- package/dist/config/parse-plans.d.ts +5 -0
- package/dist/config/parse-plans.d.ts.map +1 -0
- package/dist/config/parse-plans.js +142 -0
- package/dist/config/parse-plans.js.map +1 -0
- package/dist/config/parse-pricing.d.ts +4 -0
- package/dist/config/parse-pricing.d.ts.map +1 -0
- package/dist/config/parse-pricing.js +252 -0
- package/dist/config/parse-pricing.js.map +1 -0
- package/dist/config/parse-utils.d.ts +18 -0
- package/dist/config/parse-utils.d.ts.map +1 -0
- package/dist/config/parse-utils.js +118 -0
- package/dist/config/parse-utils.js.map +1 -0
- package/dist/config/types.d.ts +340 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config.d.ts +12 -23
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +141 -377
- package/dist/config.js.map +1 -1
- package/dist/{stores → credits}/events.d.ts +6 -6
- package/dist/credits/events.d.ts.map +1 -0
- package/dist/{stores → credits}/events.js +5 -5
- package/dist/credits/events.js.map +1 -0
- package/dist/credits/lease-workflow.d.ts +90 -0
- package/dist/credits/lease-workflow.d.ts.map +1 -0
- package/dist/credits/lease-workflow.js +378 -0
- package/dist/credits/lease-workflow.js.map +1 -0
- package/dist/credits/low-balance-monitor.d.ts +26 -0
- package/dist/credits/low-balance-monitor.d.ts.map +1 -0
- package/dist/credits/low-balance-monitor.js +110 -0
- package/dist/credits/low-balance-monitor.js.map +1 -0
- package/dist/credits/postgres/repositories/analytics.d.ts +81 -0
- package/dist/credits/postgres/repositories/analytics.d.ts.map +1 -0
- package/dist/credits/postgres/repositories/analytics.js +153 -0
- package/dist/credits/postgres/repositories/analytics.js.map +1 -0
- package/dist/credits/postgres/repositories/balance.d.ts +66 -0
- package/dist/credits/postgres/repositories/balance.d.ts.map +1 -0
- package/dist/credits/postgres/repositories/balance.js +139 -0
- package/dist/credits/postgres/repositories/balance.js.map +1 -0
- package/dist/credits/postgres/repositories/bucket.d.ts +25 -0
- package/dist/credits/postgres/repositories/bucket.d.ts.map +1 -0
- package/dist/credits/postgres/repositories/bucket.js +52 -0
- package/dist/credits/postgres/repositories/bucket.js.map +1 -0
- package/dist/credits/postgres/repositories/deduction.d.ts +64 -0
- package/dist/credits/postgres/repositories/deduction.d.ts.map +1 -0
- package/dist/credits/postgres/repositories/deduction.js +154 -0
- package/dist/credits/postgres/repositories/deduction.js.map +1 -0
- package/dist/credits/postgres/repositories/lease.d.ts +69 -0
- package/dist/credits/postgres/repositories/lease.d.ts.map +1 -0
- package/dist/credits/postgres/repositories/lease.js +148 -0
- package/dist/credits/postgres/repositories/lease.js.map +1 -0
- package/dist/credits/postgres/repositories/plan.d.ts +110 -0
- package/dist/credits/postgres/repositories/plan.d.ts.map +1 -0
- package/dist/credits/postgres/repositories/plan.js +194 -0
- package/dist/credits/postgres/repositories/plan.js.map +1 -0
- package/dist/credits/postgres/repositories/pricing.d.ts +28 -0
- package/dist/credits/postgres/repositories/pricing.d.ts.map +1 -0
- package/dist/credits/postgres/repositories/pricing.js +76 -0
- package/dist/credits/postgres/repositories/pricing.js.map +1 -0
- package/dist/credits/postgres/repositories/team.d.ts +63 -0
- package/dist/credits/postgres/repositories/team.d.ts.map +1 -0
- package/dist/credits/postgres/repositories/team.js +120 -0
- package/dist/credits/postgres/repositories/team.js.map +1 -0
- package/dist/credits/postgres/store.d.ts +89 -0
- package/dist/credits/postgres/store.d.ts.map +1 -0
- package/dist/credits/postgres/store.js +838 -0
- package/dist/credits/postgres/store.js.map +1 -0
- package/dist/credits/postgres/value-mappers.d.ts +17 -0
- package/dist/credits/postgres/value-mappers.d.ts.map +1 -0
- package/dist/credits/postgres/value-mappers.js +102 -0
- package/dist/credits/postgres/value-mappers.js.map +1 -0
- package/dist/credits/pricing-runtime.d.ts +35 -0
- package/dist/credits/pricing-runtime.d.ts.map +1 -0
- package/dist/credits/pricing-runtime.js +141 -0
- package/dist/credits/pricing-runtime.js.map +1 -0
- package/dist/credits/queries.d.ts +33 -0
- package/dist/credits/queries.d.ts.map +1 -0
- package/dist/credits/queries.js +71 -0
- package/dist/credits/queries.js.map +1 -0
- package/dist/credits/service-errors.d.ts +4 -0
- package/dist/credits/service-errors.d.ts.map +1 -0
- package/dist/credits/service-errors.js +57 -0
- package/dist/credits/service-errors.js.map +1 -0
- package/dist/credits/service-types.d.ts +122 -0
- package/dist/credits/service-types.d.ts.map +1 -0
- package/dist/credits/service-types.js +2 -0
- package/dist/credits/service-types.js.map +1 -0
- package/dist/credits/service.d.ts +220 -0
- package/dist/credits/service.d.ts.map +1 -0
- package/dist/credits/service.js +640 -0
- package/dist/credits/service.js.map +1 -0
- package/dist/credits/store.d.ts +172 -0
- package/dist/credits/store.d.ts.map +1 -0
- package/dist/{stores/credit-store.js → credits/store.js} +27 -43
- package/dist/credits/store.js.map +1 -0
- package/dist/credits/types/account.d.ts +82 -0
- package/dist/credits/types/account.d.ts.map +1 -0
- package/dist/credits/types/account.js +2 -0
- package/dist/credits/types/account.js.map +1 -0
- package/dist/credits/types/admission.d.ts +39 -0
- package/dist/credits/types/admission.d.ts.map +1 -0
- package/dist/credits/types/admission.js +2 -0
- package/dist/credits/types/admission.js.map +1 -0
- package/dist/credits/types/analytics.d.ts +52 -0
- package/dist/credits/types/analytics.d.ts.map +1 -0
- package/dist/credits/types/analytics.js +2 -0
- package/dist/credits/types/analytics.js.map +1 -0
- package/dist/credits/types/catalog.d.ts +71 -0
- package/dist/credits/types/catalog.d.ts.map +1 -0
- package/dist/credits/types/catalog.js +2 -0
- package/dist/credits/types/catalog.js.map +1 -0
- package/dist/credits/types/grants.d.ts +24 -0
- package/dist/credits/types/grants.d.ts.map +1 -0
- package/dist/credits/types/grants.js +2 -0
- package/dist/credits/types/grants.js.map +1 -0
- package/dist/credits/types/index.d.ts +9 -0
- package/dist/credits/types/index.d.ts.map +1 -0
- package/dist/credits/types/index.js +2 -0
- package/dist/credits/types/index.js.map +1 -0
- package/dist/credits/types/ledger.d.ts +87 -0
- package/dist/credits/types/ledger.d.ts.map +1 -0
- package/dist/credits/types/ledger.js +2 -0
- package/dist/credits/types/ledger.js.map +1 -0
- package/dist/credits/types/quotas.d.ts +40 -0
- package/dist/credits/types/quotas.d.ts.map +1 -0
- package/dist/credits/types/quotas.js +2 -0
- package/dist/credits/types/quotas.js.map +1 -0
- package/dist/credits/types/teams.d.ts +44 -0
- package/dist/credits/types/teams.d.ts.map +1 -0
- package/dist/credits/types/teams.js +2 -0
- package/dist/credits/types/teams.js.map +1 -0
- package/dist/engine.d.ts +18 -39
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +169 -145
- package/dist/engine.js.map +1 -1
- package/dist/errors.d.ts +133 -25
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +173 -24
- package/dist/errors.js.map +1 -1
- package/dist/expr/ast.d.ts +46 -0
- package/dist/expr/ast.d.ts.map +1 -0
- package/dist/expr/ast.js +18 -0
- package/dist/expr/ast.js.map +1 -0
- package/dist/expr/evaluator.d.ts +4 -0
- package/dist/expr/evaluator.d.ts.map +1 -0
- package/dist/expr/evaluator.js +144 -0
- package/dist/expr/evaluator.js.map +1 -0
- package/dist/expr/language.d.ts +5 -0
- package/dist/expr/language.d.ts.map +1 -0
- package/dist/expr/language.js +73 -0
- package/dist/expr/language.js.map +1 -0
- package/dist/expr/parser.d.ts +24 -0
- package/dist/expr/parser.d.ts.map +1 -0
- package/dist/expr/parser.js +175 -0
- package/dist/expr/parser.js.map +1 -0
- package/dist/expr/tokenizer.d.ts +7 -0
- package/dist/expr/tokenizer.d.ts.map +1 -0
- package/dist/expr/tokenizer.js +85 -0
- package/dist/expr/tokenizer.js.map +1 -0
- package/dist/expr.d.ts +7 -58
- package/dist/expr.d.ts.map +1 -1
- package/dist/expr.js +41 -640
- package/dist/expr.js.map +1 -1
- package/dist/generated/pricing-config.schema.json +2792 -0
- package/dist/generated/pricing-config.types.d.ts +685 -0
- package/dist/generated/pricing-config.types.d.ts.map +1 -0
- package/dist/generated/pricing-config.types.js +8 -0
- package/dist/generated/pricing-config.types.js.map +1 -0
- package/dist/index.d.ts +23 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/load-pricing-file.d.ts.map +1 -1
- package/dist/load-pricing-file.js +8 -4
- package/dist/load-pricing-file.js.map +1 -1
- package/dist/metrics.d.ts +6 -16
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js.map +1 -1
- package/dist/node.d.ts +9 -2
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +6 -2
- package/dist/node.js.map +1 -1
- package/dist/providers/_shared.d.ts +9 -0
- package/dist/providers/_shared.d.ts.map +1 -0
- package/dist/providers/_shared.js +52 -0
- package/dist/providers/_shared.js.map +1 -0
- package/dist/providers/dodo/client-contract.d.ts +106 -0
- package/dist/providers/dodo/client-contract.d.ts.map +1 -0
- package/dist/providers/dodo/client-contract.js +2 -0
- package/dist/providers/dodo/client-contract.js.map +1 -0
- package/dist/providers/dodo/event-mapper.d.ts +5 -3
- package/dist/providers/dodo/event-mapper.d.ts.map +1 -1
- package/dist/providers/dodo/event-mapper.js +213 -38
- package/dist/providers/dodo/event-mapper.js.map +1 -1
- package/dist/providers/dodo/index.d.ts +1 -0
- package/dist/providers/dodo/index.d.ts.map +1 -1
- package/dist/providers/dodo/index.js.map +1 -1
- package/dist/providers/dodo/provider.d.ts +24 -14
- package/dist/providers/dodo/provider.d.ts.map +1 -1
- package/dist/providers/dodo/provider.js +249 -31
- package/dist/providers/dodo/provider.js.map +1 -1
- package/dist/providers/index.d.ts +3 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +1 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/mock/index.js.map +1 -1
- package/dist/providers/mock/provider.d.ts +14 -10
- package/dist/providers/mock/provider.d.ts.map +1 -1
- package/dist/providers/mock/provider.js +78 -10
- package/dist/providers/mock/provider.js.map +1 -1
- package/dist/providers/stripe/event-mapper.d.ts +3 -3
- package/dist/providers/stripe/event-mapper.d.ts.map +1 -1
- package/dist/providers/stripe/event-mapper.js +139 -30
- package/dist/providers/stripe/event-mapper.js.map +1 -1
- package/dist/providers/stripe/index.js.map +1 -1
- package/dist/providers/stripe/provider.d.ts +21 -12
- package/dist/providers/stripe/provider.d.ts.map +1 -1
- package/dist/providers/stripe/provider.js +175 -17
- package/dist/providers/stripe/provider.js.map +1 -1
- package/dist/providers/types.d.ts +128 -32
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/providers/types.js +17 -1
- package/dist/providers/types.js.map +1 -1
- package/dist/retry.d.ts +35 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +70 -0
- package/dist/retry.js.map +1 -0
- package/dist/shared/diagnostics.d.ts +7 -0
- package/dist/shared/diagnostics.d.ts.map +1 -0
- package/dist/shared/diagnostics.js +18 -0
- package/dist/shared/diagnostics.js.map +1 -0
- package/dist/shared/logger.d.ts +10 -0
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/logger.js +15 -0
- package/dist/shared/logger.js.map +1 -0
- package/dist/shared/postgres-client.d.ts +84 -0
- package/dist/shared/postgres-client.d.ts.map +1 -0
- package/dist/shared/postgres-client.js +337 -0
- package/dist/shared/postgres-client.js.map +1 -0
- package/dist/shared/postgres-errors.d.ts +11 -0
- package/dist/shared/postgres-errors.d.ts.map +1 -0
- package/dist/shared/postgres-errors.js +105 -0
- package/dist/shared/postgres-errors.js.map +1 -0
- package/dist/shared/postgres-types.d.ts +7 -0
- package/dist/shared/postgres-types.d.ts.map +1 -0
- package/dist/shared/postgres-types.js +2 -0
- package/dist/shared/postgres-types.js.map +1 -0
- package/dist/shared/postgres-validation.d.ts +8 -0
- package/dist/shared/postgres-validation.d.ts.map +1 -0
- package/dist/shared/postgres-validation.js +40 -0
- package/dist/shared/postgres-validation.js.map +1 -0
- package/dist/storage/adapters/clickhouse.d.ts +61 -0
- package/dist/storage/adapters/clickhouse.d.ts.map +1 -0
- package/dist/storage/adapters/clickhouse.js +347 -0
- package/dist/storage/adapters/clickhouse.js.map +1 -0
- package/dist/storage/adapters/s3.d.ts +35 -0
- package/dist/storage/adapters/s3.d.ts.map +1 -0
- package/dist/storage/adapters/s3.js +100 -0
- package/dist/storage/adapters/s3.js.map +1 -0
- package/dist/storage/outbox-worker.d.ts +41 -0
- package/dist/storage/outbox-worker.d.ts.map +1 -0
- package/dist/storage/outbox-worker.js +146 -0
- package/dist/storage/outbox-worker.js.map +1 -0
- package/dist/storage/ports.d.ts +78 -0
- package/dist/storage/ports.d.ts.map +1 -0
- package/dist/storage/ports.js +2 -0
- package/dist/storage/ports.js.map +1 -0
- package/dist/storage/postgres-repository.d.ts +14 -0
- package/dist/storage/postgres-repository.d.ts.map +1 -0
- package/dist/storage/postgres-repository.js +140 -0
- package/dist/storage/postgres-repository.js.map +1 -0
- package/dist/storage/runtime.d.ts +77 -0
- package/dist/storage/runtime.d.ts.map +1 -0
- package/dist/storage/runtime.js +369 -0
- package/dist/storage/runtime.js.map +1 -0
- package/package.json +43 -21
- package/dist/allowance.d.ts +0 -48
- package/dist/allowance.d.ts.map +0 -1
- package/dist/allowance.js +0 -140
- package/dist/allowance.js.map +0 -1
- package/dist/billing/billing-manager.d.ts +0 -66
- package/dist/billing/billing-manager.d.ts.map +0 -1
- package/dist/billing/billing-manager.js +0 -560
- package/dist/billing/billing-manager.js.map +0 -1
- package/dist/billing/billing-types.d.ts +0 -203
- package/dist/billing/billing-types.d.ts.map +0 -1
- package/dist/billing/billing-types.js +0 -6
- package/dist/billing/billing-types.js.map +0 -1
- package/dist/billing/memory-billing-store.d.ts +0 -37
- package/dist/billing/memory-billing-store.d.ts.map +0 -1
- package/dist/billing/memory-billing-store.js +0 -197
- package/dist/billing/memory-billing-store.js.map +0 -1
- package/dist/billing/postgres-billing-store.d.ts +0 -35
- package/dist/billing/postgres-billing-store.d.ts.map +0 -1
- package/dist/billing/postgres-billing-store.js +0 -274
- package/dist/billing/postgres-billing-store.js.map +0 -1
- package/dist/billing/supabase-billing-store.d.ts +0 -29
- package/dist/billing/supabase-billing-store.d.ts.map +0 -1
- package/dist/billing/supabase-billing-store.js +0 -250
- package/dist/billing/supabase-billing-store.js.map +0 -1
- package/dist/manager.d.ts +0 -444
- package/dist/manager.d.ts.map +0 -1
- package/dist/manager.js +0 -1153
- package/dist/manager.js.map +0 -1
- package/dist/stores/credit-store.d.ts +0 -198
- package/dist/stores/credit-store.d.ts.map +0 -1
- package/dist/stores/credit-store.js.map +0 -1
- package/dist/stores/events.d.ts.map +0 -1
- package/dist/stores/events.js.map +0 -1
- package/dist/stores/memory-store.d.ts +0 -187
- package/dist/stores/memory-store.d.ts.map +0 -1
- package/dist/stores/memory-store.js +0 -1890
- package/dist/stores/memory-store.js.map +0 -1
- package/dist/stores/postgres-store.d.ts +0 -100
- package/dist/stores/postgres-store.d.ts.map +0 -1
- package/dist/stores/postgres-store.js +0 -891
- package/dist/stores/postgres-store.js.map +0 -1
- package/dist/stores/supabase-store.d.ts +0 -87
- package/dist/stores/supabase-store.d.ts.map +0 -1
- package/dist/stores/supabase-store.js +0 -948
- package/dist/stores/supabase-store.js.map +0 -1
- package/dist/types.d.ts +0 -463
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- /package/dist/{types.js → commerce/types.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing-store.d.ts","sourceRoot":"","sources":["../../src/billing/billing-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"billing-store.d.ts","sourceRoot":"","sources":["../../src/billing/billing-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,8BAA8B,EAC9B,wBAAwB,EACxB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,iCAAiC,EACjC,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,EAC/B,iCAAiC,EACjC,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAExB;;;;;GAKG;AACH,8BAAsB,YAAY;IAChC,QAAQ,CAAC,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC;IAExF,QAAQ,CAAC,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAEtF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAEzF,QAAQ,CAAC,mBAAmB,CAC1B,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,EACzB,OAAO,CAAC,EAAE,MAA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"file":"billing-store.js","sourceRoot":"","sources":["../../src/billing/billing-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"billing-store.js","sourceRoot":"","sources":["../../src/billing/billing-store.ts"],"names":[],"mappings":"AA6BA;;;;;GAKG;AACH,MAAM,OAAgB,YAAY;CAkKjC","sourcesContent":["import type {\n BillingAutoRechargeAttempt,\n BillingAutoRechargeProfile,\n BillingCustomerRecord,\n BillingEventClaim,\n BillingOfferResult,\n BillingPreferences,\n BillingSubscriptionChange,\n BillingSubscriptionChangeInput,\n BillingSubscriptionState,\n CheckoutIntent,\n BillingTopupResult,\n BillingInvoiceInfo,\n} from \"./types/index.js\";\nimport type {\n AutoRechargeAttemptClaim,\n AutoRechargeAttemptUpdate,\n AutoRechargeProviderPaymentUpdate,\n BillingCreditGrantCreate,\n BillingDisputeUpsert,\n BillingInvoiceUpsert,\n BillingPaymentUpsert,\n BillingRefundUpsert,\n BillingSubscriptionChangeUpdate,\n BillingSubscriptionConflictCreate,\n CheckoutIntentCreate,\n CheckoutIntentUpdate,\n} from \"./contracts.js\";\n\n/**\n * Abstract billing store — provider-agnostic persistence layer for\n * subscription lifecycle state.\n *\n * Mirrors Python bursar/billing/store.py.\n */\nexport abstract class BillingStore {\n abstract createOrGetCheckoutIntent(input: CheckoutIntentCreate): Promise<CheckoutIntent>;\n\n abstract updateCheckoutIntent(id: string, update: CheckoutIntentUpdate): Promise<void>;\n\n abstract getCheckoutIntent(id: string, subjectId: string): Promise<CheckoutIntent | null>;\n\n abstract resolveBillingOffer(\n provider: string,\n productId?: string | null,\n priceId?: string | null,\n ): Promise<BillingOfferResult | null>;\n\n abstract claimBillingEvent(\n provider: string,\n eventId: string,\n eventType: string,\n envelope?: Record<string, unknown>,\n ): Promise<BillingEventClaim>;\n\n abstract completeBillingEvent(\n provider: string,\n eventId: string,\n claimToken: string,\n ): Promise<boolean>;\n\n abstract failBillingEvent(\n provider: string,\n eventId: string,\n claimToken: string,\n error?: string,\n ): Promise<boolean>;\n\n abstract upsertBillingCustomer(\n provider: string,\n providerCustomerId: string,\n userId: string,\n email?: string | null,\n ): Promise<void>;\n\n abstract upsertBillingSubscription(state: BillingSubscriptionState): Promise<void>;\n\n abstract getBillingCustomer(provider: string, providerCustomerId: string): Promise<string | null>;\n\n abstract getBillingSubscription(\n provider: string,\n providerSubscriptionId: string,\n ): Promise<BillingSubscriptionState | null>;\n\n abstract createBillingSubscriptionChange(\n input: BillingSubscriptionChangeInput,\n ): Promise<BillingSubscriptionChange>;\n\n abstract getOpenBillingSubscriptionChange(\n provider: string,\n providerSubscriptionId: string,\n ): Promise<BillingSubscriptionChange | null>;\n\n abstract listExpiredGraceSubscriptions(\n now: string,\n limit?: number,\n ): Promise<BillingSubscriptionState[]>;\n\n abstract markSubscriptionGraceExpired(\n subscriptionId: string,\n expectedGraceEndsAt: string,\n expiredAt?: string,\n ): Promise<boolean>;\n\n abstract updateBillingSubscriptionChange(\n id: string,\n update: BillingSubscriptionChangeUpdate,\n ): Promise<void>;\n\n abstract getUserSubscription(\n userId: string,\n statuses?: string[],\n ): Promise<BillingSubscriptionState | null>;\n\n abstract resolveCreditTopup(\n provider: string,\n productId?: string | null,\n priceId?: string | null,\n ): Promise<BillingTopupResult | null>;\n abstract resolveCreditTopupByLookup(\n provider: string,\n lookupKey: string,\n ): Promise<BillingTopupResult | null>;\n\n abstract resolveBillingOfferByLookup(\n provider: string,\n lookupKey: string,\n ): Promise<BillingOfferResult | null>;\n\n abstract computeTopupCredits(\n amountMinor: number,\n topupConfig: BillingTopupResult,\n ): Promise<number>;\n\n abstract upsertBillingPayment(options: BillingPaymentUpsert): Promise<string>;\n abstract createBillingCreditGrant(input: BillingCreditGrantCreate): Promise<string>;\n abstract grantBillingCredit(\n grantId: string,\n idempotencyKey: string,\n ): Promise<Record<string, unknown>>;\n abstract getBillingCreditGrantByPayment(paymentId: string): Promise<string | null>;\n abstract postBillingRefund(\n refundId: string,\n grantId: string,\n amountMinor: number,\n idempotencyKey: string,\n ): Promise<Record<string, unknown>>;\n\n abstract listBillingInvoices(userId: string): Promise<BillingInvoiceInfo[]>;\n\n abstract upsertBillingRefund(options: BillingRefundUpsert): Promise<string>;\n\n abstract upsertBillingInvoice(options: BillingInvoiceUpsert): Promise<void>;\n\n abstract upsertBillingDispute(options: BillingDisputeUpsert): Promise<void>;\n\n abstract getBillingPayment(\n provider: string,\n providerPaymentId: string,\n ): Promise<Record<string, unknown> | null>;\n\n abstract getActiveBursarConfig(): Promise<Record<string, unknown> | null>;\n\n abstract pseudonymizeFinancialSubject(userId: string): Promise<boolean>;\n\n abstract getUserSubscriptions(userId: string): Promise<BillingSubscriptionState[]>;\n\n abstract recordSubscriptionConflict(input: BillingSubscriptionConflictCreate): Promise<void>;\n\n /** Select a current provider subscription as the subject's entitlement source. */\n abstract selectSubscriptionEntitlementSource(\n userId: string,\n provider: string,\n providerSubscriptionId?: string | null,\n ): Promise<boolean>;\n\n abstract getBillingPreferences(userId: string): Promise<BillingPreferences | null>;\n\n abstract upsertBillingPreferences(prefs: BillingPreferences): Promise<void>;\n abstract getAutoRechargeProfile(userId: string): Promise<BillingAutoRechargeProfile | null>;\n abstract upsertAutoRechargeProfile(\n profile: BillingAutoRechargeProfile,\n options?: { resetCooldown?: boolean },\n ): Promise<void>;\n abstract claimAutoRechargeAttempt(\n input: AutoRechargeAttemptClaim,\n ): Promise<BillingAutoRechargeAttempt | null>;\n abstract updateAutoRechargeAttempt(input: AutoRechargeAttemptUpdate): Promise<void>;\n abstract updateAutoRechargeAttemptByProviderPayment(\n input: AutoRechargeProviderPaymentUpdate,\n ): Promise<void>;\n abstract countAutoRechargeAttempts(userId: string, since: string | Date): Promise<number>;\n\n abstract getBillingCustomerByUserId(\n userId: string,\n provider?: string | null,\n ): Promise<BillingCustomerRecord | null>;\n}\n"]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { AutoRechargeService } from "./auto-recharge-service.js";
|
|
2
|
+
import type { BillingAutoRechargeAttempt, BillingAutoRechargeProfile, BillingCustomerRecord, BillingDisputeInfo, BillingEvent, BillingEventResult, BillingInvoiceInfo, BillingOfferResult, BillingPaymentInfo, BillingPreferences, BillingRefundInfo, BillingSubscriptionChange, BillingSubscriptionChangeInput, BillingSubscriptionState, BillingTopupResult, CheckoutIntent } from "./types/index.js";
|
|
3
|
+
export interface CheckoutIntentCreate {
|
|
4
|
+
subjectId: string;
|
|
5
|
+
provider: string;
|
|
6
|
+
checkoutKind: "subscription" | "credit_topup";
|
|
7
|
+
productKey: string;
|
|
8
|
+
requestDigest: string;
|
|
9
|
+
expiresAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CheckoutIntentUpdate {
|
|
12
|
+
status?: "open" | "completed" | "failed" | "expired";
|
|
13
|
+
providerSessionId?: string | null;
|
|
14
|
+
checkoutUrl?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface BillingSubscriptionChangeUpdate {
|
|
17
|
+
state?: BillingSubscriptionChange["state"];
|
|
18
|
+
providerOperationId?: string | null;
|
|
19
|
+
errorMessage?: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface BillingSubscriptionConflictCreate {
|
|
22
|
+
userId?: string | null;
|
|
23
|
+
provider: string;
|
|
24
|
+
duplicateSubscriptionId: string;
|
|
25
|
+
existingSubscriptionId?: string | null;
|
|
26
|
+
eventId?: string | null;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export interface BillingPaymentUpsert {
|
|
30
|
+
provider: string;
|
|
31
|
+
providerPaymentId: string;
|
|
32
|
+
providerInvoiceId?: string | null;
|
|
33
|
+
userId?: string | null;
|
|
34
|
+
amountMinor?: number;
|
|
35
|
+
taxMinor?: number | null;
|
|
36
|
+
currency?: string | null;
|
|
37
|
+
purpose?: string;
|
|
38
|
+
status?: "pending" | "succeeded" | "failed" | "canceled";
|
|
39
|
+
providerUpdatedAt?: string;
|
|
40
|
+
metadata?: Record<string, unknown> | null;
|
|
41
|
+
}
|
|
42
|
+
export interface BillingCreditGrantCreate {
|
|
43
|
+
paymentId?: string | null;
|
|
44
|
+
subscriptionId?: string | null;
|
|
45
|
+
topupId?: string | null;
|
|
46
|
+
configuredCredits: number;
|
|
47
|
+
quantity?: number;
|
|
48
|
+
billingEventId?: string | null;
|
|
49
|
+
}
|
|
50
|
+
export interface BillingRefundUpsert {
|
|
51
|
+
provider: string;
|
|
52
|
+
providerRefundId: string;
|
|
53
|
+
providerPaymentId?: string | null;
|
|
54
|
+
userId?: string | null;
|
|
55
|
+
amountMinor?: number;
|
|
56
|
+
currency?: string | null;
|
|
57
|
+
reason?: string | null;
|
|
58
|
+
status?: "pending" | "succeeded" | "failed" | "canceled";
|
|
59
|
+
providerUpdatedAt?: string;
|
|
60
|
+
metadata?: Record<string, unknown> | null;
|
|
61
|
+
}
|
|
62
|
+
export interface BillingInvoiceUpsert {
|
|
63
|
+
provider: string;
|
|
64
|
+
providerInvoiceId: string;
|
|
65
|
+
providerSubscriptionId?: string | null;
|
|
66
|
+
userId?: string | null;
|
|
67
|
+
status?: string | null;
|
|
68
|
+
amountPaidMinor?: number | null;
|
|
69
|
+
amountDueMinor?: number | null;
|
|
70
|
+
currency?: string | null;
|
|
71
|
+
periodStart?: string | null;
|
|
72
|
+
periodEnd?: string | null;
|
|
73
|
+
metadata?: Record<string, unknown> | null;
|
|
74
|
+
providerUpdatedAt?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface BillingDisputeUpsert {
|
|
77
|
+
provider: string;
|
|
78
|
+
providerDisputeId: string;
|
|
79
|
+
providerPaymentId?: string | null;
|
|
80
|
+
userId?: string | null;
|
|
81
|
+
status?: string;
|
|
82
|
+
reason?: string | null;
|
|
83
|
+
metadata?: Record<string, unknown> | null;
|
|
84
|
+
providerUpdatedAt?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface AutoRechargeAttemptClaim {
|
|
87
|
+
userId: string;
|
|
88
|
+
idempotencyKey: string;
|
|
89
|
+
}
|
|
90
|
+
export interface AutoRechargeAttemptUpdate {
|
|
91
|
+
id: string;
|
|
92
|
+
state: string;
|
|
93
|
+
providerAttemptId?: string | null;
|
|
94
|
+
failureCode?: string | null;
|
|
95
|
+
failureMessage?: string | null;
|
|
96
|
+
metadata?: Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
export interface AutoRechargeProviderPaymentUpdate {
|
|
99
|
+
provider: string;
|
|
100
|
+
providerPaymentId: string;
|
|
101
|
+
state: string;
|
|
102
|
+
failureCode?: string | null;
|
|
103
|
+
failureMessage?: string | null;
|
|
104
|
+
}
|
|
105
|
+
/** Boundary used by payment providers to submit normalized lifecycle events. */
|
|
106
|
+
export interface BillingEventSink {
|
|
107
|
+
ingestBillingEvent(event: BillingEvent): Promise<BillingEventResult>;
|
|
108
|
+
}
|
|
109
|
+
/** Application-facing billing capability exposed by Bursar. */
|
|
110
|
+
export interface BillingCapability extends BillingEventSink {
|
|
111
|
+
readonly autoRecharge: AutoRechargeService;
|
|
112
|
+
readonly hasProvisioning: boolean;
|
|
113
|
+
createOrGetCheckoutIntent(input: CheckoutIntentCreate): Promise<CheckoutIntent>;
|
|
114
|
+
updateCheckoutIntent(id: string, update: CheckoutIntentUpdate): Promise<void>;
|
|
115
|
+
getCheckoutIntent(id: string, subjectId: string): Promise<CheckoutIntent | null>;
|
|
116
|
+
getUserSubscription(userId: string): Promise<BillingSubscriptionState | null>;
|
|
117
|
+
getActiveSubscription(userId: string): Promise<BillingSubscriptionState | null>;
|
|
118
|
+
getBlockingSubscription(userId: string): Promise<BillingSubscriptionState | null>;
|
|
119
|
+
getUserPreferences(userId: string): Promise<BillingPreferences | null>;
|
|
120
|
+
getActiveBursarConfig(): Promise<Record<string, unknown> | null>;
|
|
121
|
+
listCancellableProviderSubscriptionIds(userId: string): Promise<string[]>;
|
|
122
|
+
listCancellableSubscriptions(userId: string): Promise<BillingSubscriptionState[]>;
|
|
123
|
+
listBillingInvoices(userId: string): Promise<BillingInvoiceInfo[]>;
|
|
124
|
+
createBillingSubscriptionChange(input: BillingSubscriptionChangeInput): Promise<BillingSubscriptionChange>;
|
|
125
|
+
getOpenBillingSubscriptionChange(provider: string, providerSubscriptionId: string): Promise<BillingSubscriptionChange | null>;
|
|
126
|
+
updateBillingSubscriptionChange(id: string, update: BillingSubscriptionChangeUpdate): Promise<void>;
|
|
127
|
+
recordSubscriptionConflict(input: BillingSubscriptionConflictCreate): Promise<void>;
|
|
128
|
+
upsertBillingSubscription(state: BillingSubscriptionState): Promise<void>;
|
|
129
|
+
updateUserPreferences(preferences: BillingPreferences): Promise<void>;
|
|
130
|
+
getAutoRechargeProfile(userId: string): Promise<BillingAutoRechargeProfile | null>;
|
|
131
|
+
upsertAutoRechargeProfile(profile: BillingAutoRechargeProfile, options?: {
|
|
132
|
+
resetCooldown?: boolean;
|
|
133
|
+
}): Promise<void>;
|
|
134
|
+
claimAutoRechargeAttempt(input: AutoRechargeAttemptClaim): Promise<BillingAutoRechargeAttempt | null>;
|
|
135
|
+
updateAutoRechargeAttempt(input: AutoRechargeAttemptUpdate): Promise<void>;
|
|
136
|
+
updateAutoRechargeAttemptByProviderPayment(input: AutoRechargeProviderPaymentUpdate): Promise<void>;
|
|
137
|
+
countAutoRechargeAttempts(userId: string, since: string | Date): Promise<number>;
|
|
138
|
+
expirePastDueGracePeriods(now?: Date): Promise<number>;
|
|
139
|
+
invalidateOfferCache(): void;
|
|
140
|
+
getCustomerByUserId(userId: string, provider?: string | null): Promise<BillingCustomerRecord | null>;
|
|
141
|
+
resolveOffer(provider: string, productId?: string | null, priceId?: string | null): Promise<BillingOfferResult | null>;
|
|
142
|
+
resolveOfferByLookup(provider: string, lookupKey: string): Promise<BillingOfferResult | null>;
|
|
143
|
+
resolveTopup(provider: string, productId?: string | null, priceId?: string | null): Promise<BillingTopupResult | null>;
|
|
144
|
+
resolveTopupByLookup(provider: string, lookupKey: string): Promise<BillingTopupResult | null>;
|
|
145
|
+
upsertCustomer(provider: string, providerCustomerId: string, userId: string, email?: string | null): Promise<void>;
|
|
146
|
+
pseudonymizeFinancialSubject(userId: string): Promise<void>;
|
|
147
|
+
}
|
|
148
|
+
export type { BillingDisputeInfo, BillingInvoiceInfo, BillingPaymentInfo, BillingRefundInfo };
|
|
149
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/billing/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,8BAA8B,EAC9B,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,cAAc,GAAG,cAAc,CAAC;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;IACrD,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,+BAA+B;IAC9C,KAAK,CAAC,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAC3C,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAA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AE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;IAC9F,YAAY,CACV,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,EACzB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;IACtC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;IAC9F,cAAc,CACZ,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAID,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/billing/contracts.ts"],"names":[],"mappings":"","sourcesContent":["import type { AutoRechargeService } from \"./auto-recharge-service.js\";\nimport type {\n BillingAutoRechargeAttempt,\n BillingAutoRechargeProfile,\n BillingCustomerRecord,\n BillingDisputeInfo,\n BillingEvent,\n BillingEventResult,\n BillingInvoiceInfo,\n BillingOfferResult,\n BillingPaymentInfo,\n BillingPreferences,\n BillingRefundInfo,\n BillingSubscriptionChange,\n BillingSubscriptionChangeInput,\n BillingSubscriptionState,\n BillingTopupResult,\n CheckoutIntent,\n} from \"./types/index.js\";\n\nexport interface CheckoutIntentCreate {\n subjectId: string;\n provider: string;\n checkoutKind: \"subscription\" | \"credit_topup\";\n productKey: string;\n requestDigest: string;\n expiresAt: string;\n}\n\nexport interface CheckoutIntentUpdate {\n status?: \"open\" | \"completed\" | \"failed\" | \"expired\";\n providerSessionId?: string | null;\n checkoutUrl?: string | null;\n}\n\nexport interface BillingSubscriptionChangeUpdate {\n state?: BillingSubscriptionChange[\"state\"];\n providerOperationId?: string | null;\n errorMessage?: string | null;\n}\n\nexport interface BillingSubscriptionConflictCreate {\n userId?: string | null;\n provider: string;\n duplicateSubscriptionId: string;\n existingSubscriptionId?: string | null;\n eventId?: string | null;\n metadata?: Record<string, unknown>;\n}\n\nexport interface BillingPaymentUpsert {\n provider: string;\n providerPaymentId: string;\n providerInvoiceId?: string | null;\n userId?: string | null;\n amountMinor?: number;\n taxMinor?: number | null;\n currency?: string | null;\n purpose?: string;\n status?: \"pending\" | \"succeeded\" | \"failed\" | \"canceled\";\n providerUpdatedAt?: string;\n metadata?: Record<string, unknown> | null;\n}\n\nexport interface BillingCreditGrantCreate {\n paymentId?: string | null;\n subscriptionId?: string | null;\n topupId?: string | null;\n configuredCredits: number;\n quantity?: number;\n billingEventId?: string | null;\n}\n\nexport interface BillingRefundUpsert {\n provider: string;\n providerRefundId: string;\n providerPaymentId?: string | null;\n userId?: string | null;\n amountMinor?: number;\n currency?: string | null;\n reason?: string | null;\n status?: \"pending\" | \"succeeded\" | \"failed\" | \"canceled\";\n providerUpdatedAt?: string;\n metadata?: Record<string, unknown> | null;\n}\n\nexport interface BillingInvoiceUpsert {\n provider: string;\n providerInvoiceId: string;\n providerSubscriptionId?: string | null;\n userId?: string | null;\n status?: string | null;\n amountPaidMinor?: number | null;\n amountDueMinor?: number | null;\n currency?: string | null;\n periodStart?: string | null;\n periodEnd?: string | null;\n metadata?: Record<string, unknown> | null;\n providerUpdatedAt?: string;\n}\n\nexport interface BillingDisputeUpsert {\n provider: string;\n providerDisputeId: string;\n providerPaymentId?: string | null;\n userId?: string | null;\n status?: string;\n reason?: string | null;\n metadata?: Record<string, unknown> | null;\n providerUpdatedAt?: string;\n}\n\nexport interface AutoRechargeAttemptClaim {\n userId: string;\n idempotencyKey: string;\n}\n\nexport interface AutoRechargeAttemptUpdate {\n id: string;\n state: string;\n providerAttemptId?: string | null;\n failureCode?: string | null;\n failureMessage?: string | null;\n metadata?: Record<string, unknown>;\n}\n\nexport interface AutoRechargeProviderPaymentUpdate {\n provider: string;\n providerPaymentId: string;\n state: string;\n failureCode?: string | null;\n failureMessage?: string | null;\n}\n\n/** Boundary used by payment providers to submit normalized lifecycle events. */\nexport interface BillingEventSink {\n ingestBillingEvent(event: BillingEvent): Promise<BillingEventResult>;\n}\n\n/** Application-facing billing capability exposed by Bursar. */\nexport interface BillingCapability extends BillingEventSink {\n readonly autoRecharge: AutoRechargeService;\n readonly hasProvisioning: boolean;\n createOrGetCheckoutIntent(input: CheckoutIntentCreate): Promise<CheckoutIntent>;\n updateCheckoutIntent(id: string, update: CheckoutIntentUpdate): Promise<void>;\n getCheckoutIntent(id: string, subjectId: string): Promise<CheckoutIntent | null>;\n getUserSubscription(userId: string): Promise<BillingSubscriptionState | null>;\n getActiveSubscription(userId: string): Promise<BillingSubscriptionState | null>;\n getBlockingSubscription(userId: string): Promise<BillingSubscriptionState | null>;\n getUserPreferences(userId: string): Promise<BillingPreferences | null>;\n getActiveBursarConfig(): Promise<Record<string, unknown> | null>;\n listCancellableProviderSubscriptionIds(userId: string): Promise<string[]>;\n listCancellableSubscriptions(userId: string): Promise<BillingSubscriptionState[]>;\n listBillingInvoices(userId: string): Promise<BillingInvoiceInfo[]>;\n createBillingSubscriptionChange(\n input: BillingSubscriptionChangeInput,\n ): Promise<BillingSubscriptionChange>;\n getOpenBillingSubscriptionChange(\n provider: string,\n providerSubscriptionId: string,\n ): Promise<BillingSubscriptionChange | null>;\n updateBillingSubscriptionChange(\n id: string,\n update: BillingSubscriptionChangeUpdate,\n ): Promise<void>;\n recordSubscriptionConflict(input: BillingSubscriptionConflictCreate): Promise<void>;\n upsertBillingSubscription(state: BillingSubscriptionState): Promise<void>;\n updateUserPreferences(preferences: BillingPreferences): Promise<void>;\n getAutoRechargeProfile(userId: string): Promise<BillingAutoRechargeProfile | null>;\n upsertAutoRechargeProfile(\n profile: BillingAutoRechargeProfile,\n options?: { resetCooldown?: boolean },\n ): Promise<void>;\n claimAutoRechargeAttempt(\n input: AutoRechargeAttemptClaim,\n ): Promise<BillingAutoRechargeAttempt | null>;\n updateAutoRechargeAttempt(input: AutoRechargeAttemptUpdate): Promise<void>;\n updateAutoRechargeAttemptByProviderPayment(\n input: AutoRechargeProviderPaymentUpdate,\n ): Promise<void>;\n countAutoRechargeAttempts(userId: string, since: string | Date): Promise<number>;\n expirePastDueGracePeriods(now?: Date): Promise<number>;\n invalidateOfferCache(): void;\n getCustomerByUserId(\n userId: string,\n provider?: string | null,\n ): Promise<BillingCustomerRecord | null>;\n resolveOffer(\n provider: string,\n productId?: string | null,\n priceId?: string | null,\n ): Promise<BillingOfferResult | null>;\n resolveOfferByLookup(provider: string, lookupKey: string): Promise<BillingOfferResult | null>;\n resolveTopup(\n provider: string,\n productId?: string | null,\n priceId?: string | null,\n ): Promise<BillingTopupResult | null>;\n resolveTopupByLookup(provider: string, lookupKey: string): Promise<BillingTopupResult | null>;\n upsertCustomer(\n provider: string,\n providerCustomerId: string,\n userId: string,\n email?: string | null,\n ): Promise<void>;\n pseudonymizeFinancialSubject(userId: string): Promise<void>;\n}\n\n// Keep document-record types reachable from the contract module for store\n// implementers without forcing them to import the broad billing type barrel.\nexport type { BillingDisputeInfo, BillingInvoiceInfo, BillingPaymentInfo, BillingRefundInfo };\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { BillingStore } from "./billing-store.js";
|
|
2
|
+
import type { BillingEvent, BillingEventResult } from "./types/index.js";
|
|
3
|
+
import { BillingEventType } from "./types/index.js";
|
|
4
|
+
import type { BillingServiceOptions } from "./service-types.js";
|
|
5
|
+
export declare class BillingEventHandlers {
|
|
6
|
+
private readonly store;
|
|
7
|
+
private readonly provisioning;
|
|
8
|
+
private readonly resolveUser;
|
|
9
|
+
private readonly autoSelectEntitlementSource;
|
|
10
|
+
private readonly pastDueGracePeriodMs;
|
|
11
|
+
private readonly terminalPlanKey;
|
|
12
|
+
private readonly logger;
|
|
13
|
+
private readonly offerCache;
|
|
14
|
+
private readonly financial;
|
|
15
|
+
private readonly handlerMap;
|
|
16
|
+
get hasProvisioning(): boolean;
|
|
17
|
+
constructor(store: BillingStore, options?: BillingServiceOptions);
|
|
18
|
+
getHandler(eventType: BillingEventType): ((event: BillingEvent) => Promise<BillingEventResult>) | undefined;
|
|
19
|
+
invalidateOfferCache(): void;
|
|
20
|
+
updateCheckoutIntentFromEvent(event: BillingEvent, status: "completed" | "failed" | "expired"): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve userId from the event, mutating event.userId so that
|
|
23
|
+
* routeEvent's blanket fireEventCallback can read it. Each ingestBillingEvent
|
|
24
|
+
* call creates a fresh event object, so mutation is safe.
|
|
25
|
+
*/
|
|
26
|
+
private resolveUserId;
|
|
27
|
+
private resolveBillingOfferCached;
|
|
28
|
+
private handleCustomerCreated;
|
|
29
|
+
private handleCustomerDeleted;
|
|
30
|
+
private handleCheckoutCompleted;
|
|
31
|
+
private getExistingSubscription;
|
|
32
|
+
private buildSubscriptionState;
|
|
33
|
+
private resolveOfferAndKeys;
|
|
34
|
+
private handleSubscriptionCreated;
|
|
35
|
+
private handleSubscriptionUpdated;
|
|
36
|
+
private handleSubscriptionActivated;
|
|
37
|
+
private handleSubscriptionRenewed;
|
|
38
|
+
private handleSubscriptionPlanChanged;
|
|
39
|
+
private handleCancellationScheduled;
|
|
40
|
+
private handleCancellationUnscheduled;
|
|
41
|
+
private handleSubscriptionCanceled;
|
|
42
|
+
private handleSubscriptionExpired;
|
|
43
|
+
private handleSubscriptionPaused;
|
|
44
|
+
private handleSubscriptionResumed;
|
|
45
|
+
private handleTrialWillEnd;
|
|
46
|
+
private provisionSubscription;
|
|
47
|
+
private grantSubscriptionCycle;
|
|
48
|
+
private revokeSubscription;
|
|
49
|
+
/**
|
|
50
|
+
* Do not revoke access because a stale subscription record ended while a
|
|
51
|
+
* newer subscription for the same user is still active.
|
|
52
|
+
*/
|
|
53
|
+
revokeIfCurrentSubscription(uid: string, subscriptionId: string): Promise<void>;
|
|
54
|
+
private reEvaluateAccess;
|
|
55
|
+
private resolveOfferFromEvent;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=event-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-handlers.d.ts","sourceRoot":"","sources":["../../src/billing/event-handlers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAInB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAEV,qBAAqB,EAEtB,MAAM,oBAAoB,CAAC;AAY5B,qBAAa,oBAAoB;IAgB7B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAfxB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiC;IAC9D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAU;IACtD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgB;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkD;IAC7E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgC;IAC1D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuE;IAElG,IAAI,eAAe,IAAI,OAAO,CAE7B;gBAGkB,KAAK,EAAE,YAAY,EACpC,OAAO,CAAC,EAAE,qBAAqB;IAmEjC,UAAU,CACR,SAAS,EAAE,gBAAgB,GAC1B,CAAC,CAAC,KAAK,EAAE,YAAY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