@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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable read/catalog facade over CreditStore.
|
|
3
|
+
*
|
|
4
|
+
* CreditsService adds pricing, eventing, expiry, and charging workflows on top;
|
|
5
|
+
* methods here intentionally contain no additional business behavior.
|
|
6
|
+
*/
|
|
7
|
+
export class CreditQueries {
|
|
8
|
+
store;
|
|
9
|
+
analytics;
|
|
10
|
+
usageStore;
|
|
11
|
+
constructor(store, analytics = store, usageStore = store) {
|
|
12
|
+
this.store = store;
|
|
13
|
+
this.analytics = analytics;
|
|
14
|
+
this.usageStore = usageStore;
|
|
15
|
+
}
|
|
16
|
+
async getActivePricing() {
|
|
17
|
+
return this.store.getActivePricing();
|
|
18
|
+
}
|
|
19
|
+
async getUserPlan(userId) {
|
|
20
|
+
return this.store.getUserPlan(userId);
|
|
21
|
+
}
|
|
22
|
+
async checkFeature(userId, feature) {
|
|
23
|
+
return this.store.checkFeature(userId, feature);
|
|
24
|
+
}
|
|
25
|
+
async getQuotaState(userId, quotaKey) {
|
|
26
|
+
return this.store.getQuotaState(userId, quotaKey);
|
|
27
|
+
}
|
|
28
|
+
async listQuotaEvents(userId, options) {
|
|
29
|
+
return this.store.listQuotaEvents(userId, options);
|
|
30
|
+
}
|
|
31
|
+
async startPlanMigration(fromPlanId, toPlanId) {
|
|
32
|
+
return this.store.startPlanMigration(fromPlanId, toPlanId);
|
|
33
|
+
}
|
|
34
|
+
async migratePlanBatch(migrationId, batchSize) {
|
|
35
|
+
return this.store.migratePlanBatch(migrationId, batchSize);
|
|
36
|
+
}
|
|
37
|
+
async revokeCreditsByEntryType(userId, entryType) {
|
|
38
|
+
return this.store.revokeCreditsByEntryType(userId, entryType);
|
|
39
|
+
}
|
|
40
|
+
async getLedgerEntry(userId, entryId) {
|
|
41
|
+
return this.store.getLedgerEntry(userId, entryId);
|
|
42
|
+
}
|
|
43
|
+
async getAvailable(userId) {
|
|
44
|
+
return this.store.getAvailable(userId);
|
|
45
|
+
}
|
|
46
|
+
async aggregateStats(start, end) {
|
|
47
|
+
return this.analytics.aggregateStats(start, end);
|
|
48
|
+
}
|
|
49
|
+
async spendByUser(start, end) {
|
|
50
|
+
return this.analytics.spendByUser(start, end);
|
|
51
|
+
}
|
|
52
|
+
async spendByModel(start, end) {
|
|
53
|
+
return this.analytics.spendByModel(start, end);
|
|
54
|
+
}
|
|
55
|
+
async listLedgerEntries(userId, options) {
|
|
56
|
+
return this.store.listLedgerEntries(userId, options);
|
|
57
|
+
}
|
|
58
|
+
async listUsageEntries(userId, options) {
|
|
59
|
+
return this.store.listUsageEntries(userId, options);
|
|
60
|
+
}
|
|
61
|
+
async listUsageCharges(userId, options) {
|
|
62
|
+
return this.usageStore.listUsageCharges(userId, options);
|
|
63
|
+
}
|
|
64
|
+
async topUsers(limit, start, end) {
|
|
65
|
+
return this.analytics.topUsers(limit, start, end);
|
|
66
|
+
}
|
|
67
|
+
async dailySpend(start, end) {
|
|
68
|
+
return this.analytics.dailySpend(start, end);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/credits/queries.ts"],"names":[],"mappings":"AA0BA;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAEL;IACA;IACA;IAHnB,YACmB,KAAkB,EAClB,YAAiC,KAAK,EACtC,aAA+B,KAAK;QAFpC,UAAK,GAAL,KAAK,CAAa;QAClB,cAAS,GAAT,SAAS,CAA6B;QACtC,eAAU,GAAV,UAAU,CAA0B;IACpD,CAAC;IAEJ,KAAK,CAAC,gBAAgB;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,WAAW,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EAAE,GAAS;QACzC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAW,EAAE,GAAS;QACtC,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAW,EAAE,GAAS;QACvC,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,MAAc,EAAE,OAAkC;QACxE,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,MAAc,EAAE,OAAiC;QACtE,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,MAAc,EACd,OAAiC;QAEjC,OAAO,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAa,EAAE,KAAW,EAAE,GAAS;QAClD,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAW,EAAE,GAAS;QACrC,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import type { CreditStore } from \"./store.js\";\nimport type {\n AggregateStats,\n AvailableResult,\n BursarConfigResult,\n CheckFeatureResult,\n DailySpendRow,\n GetUserPlanResult,\n LedgerEntry,\n LedgerPage,\n ListLedgerEntriesOptions,\n ListQuotaEventsOptions,\n ListUsageChargesOptions,\n ListUsageEntriesOptions,\n PlanMigrationBatchResult,\n PlanMigrationStartResult,\n QuotaEvent,\n QuotaState,\n SpendByModelRow,\n SpendByUserRow,\n TopUserRow,\n UsageChargePage,\n UsageAnalyticsStore,\n UsageChargeStore,\n} from \"./types/index.js\";\n\n/**\n * Stable read/catalog facade over CreditStore.\n *\n * CreditsService adds pricing, eventing, expiry, and charging workflows on top;\n * methods here intentionally contain no additional business behavior.\n */\nexport class CreditQueries {\n constructor(\n private readonly store: CreditStore,\n private readonly analytics: UsageAnalyticsStore = store,\n private readonly usageStore: UsageChargeStore = store,\n ) {}\n\n async getActivePricing(): Promise<BursarConfigResult | null> {\n return this.store.getActivePricing();\n }\n\n async getUserPlan(userId: string): Promise<GetUserPlanResult> {\n return this.store.getUserPlan(userId);\n }\n\n async checkFeature(userId: string, feature: string): Promise<CheckFeatureResult> {\n return this.store.checkFeature(userId, feature);\n }\n\n async getQuotaState(userId: string, quotaKey?: string | null): Promise<QuotaState[]> {\n return this.store.getQuotaState(userId, quotaKey);\n }\n\n async listQuotaEvents(userId: string, options?: ListQuotaEventsOptions): Promise<QuotaEvent[]> {\n return this.store.listQuotaEvents(userId, options);\n }\n\n async startPlanMigration(\n fromPlanId: string | null,\n toPlanId: string,\n ): Promise<PlanMigrationStartResult> {\n return this.store.startPlanMigration(fromPlanId, toPlanId);\n }\n\n async migratePlanBatch(\n migrationId: string,\n batchSize?: number,\n ): Promise<PlanMigrationBatchResult> {\n return this.store.migratePlanBatch(migrationId, batchSize);\n }\n\n async revokeCreditsByEntryType(\n userId: string,\n entryType: string,\n ): Promise<Record<string, unknown>> {\n return this.store.revokeCreditsByEntryType(userId, entryType);\n }\n\n async getLedgerEntry(userId: string, entryId: string): Promise<LedgerEntry | null> {\n return this.store.getLedgerEntry(userId, entryId);\n }\n\n async getAvailable(userId: string): Promise<AvailableResult> {\n return this.store.getAvailable(userId);\n }\n\n async aggregateStats(start: Date, end: Date): Promise<AggregateStats> {\n return this.analytics.aggregateStats(start, end);\n }\n\n async spendByUser(start: Date, end: Date): Promise<SpendByUserRow[]> {\n return this.analytics.spendByUser(start, end);\n }\n\n async spendByModel(start: Date, end: Date): Promise<SpendByModelRow[]> {\n return this.analytics.spendByModel(start, end);\n }\n\n async listLedgerEntries(userId: string, options?: ListLedgerEntriesOptions): Promise<LedgerPage> {\n return this.store.listLedgerEntries(userId, options);\n }\n\n async listUsageEntries(userId: string, options?: ListUsageEntriesOptions): Promise<LedgerPage> {\n return this.store.listUsageEntries(userId, options);\n }\n\n async listUsageCharges(\n userId: string,\n options?: ListUsageChargesOptions,\n ): Promise<UsageChargePage> {\n return this.usageStore.listUsageCharges(userId, options);\n }\n\n async topUsers(limit: number, start: Date, end: Date): Promise<TopUserRow[]> {\n return this.analytics.topUsers(limit, start, end);\n }\n\n async dailySpend(start: Date, end: Date): Promise<DailySpendRow[]> {\n return this.analytics.dailySpend(start, end);\n }\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
|
+
export declare function raiseLeaseError(error: string, userId: string, amount: Decimal): never;
|
|
3
|
+
export declare function raiseDeductError(error: string, userId: string, cost: Decimal): never;
|
|
4
|
+
//# sourceMappingURL=service-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-errors.d.ts","sourceRoot":"","sources":["../../src/credits/service-errors.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AAcjC,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,KAAK,CAgCrF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK,CAsBpF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
|
+
import { ConcurrencyLimitError, ConfigError, FeatureNotEntitledError, InsufficientCreditsError, LeaseExpiredError, LeaseNotFoundError, OperationNotAllowedError, QuotaExceededError, StoreError, } from "../errors.js";
|
|
3
|
+
export function raiseLeaseError(error, userId, amount) {
|
|
4
|
+
switch (error) {
|
|
5
|
+
case "max_concurrent_reached":
|
|
6
|
+
throw new ConcurrencyLimitError(`Concurrency limit reached. user=${userId}`);
|
|
7
|
+
case "quota_exceeded":
|
|
8
|
+
throw new QuotaExceededError(`Usage quota exceeded. user=${userId}`);
|
|
9
|
+
case "feature_not_entitled":
|
|
10
|
+
throw new FeatureNotEntitledError(`Feature not entitled. user=${userId}`);
|
|
11
|
+
case "operation_not_allowed":
|
|
12
|
+
throw new OperationNotAllowedError(`Operation is not allowed. user=${userId}`);
|
|
13
|
+
case "insufficient_headroom":
|
|
14
|
+
case "insufficient_credits":
|
|
15
|
+
throw new InsufficientCreditsError(`Insufficient credits. user=${userId}, requested=${amount}`);
|
|
16
|
+
case "expired_lease":
|
|
17
|
+
throw new LeaseExpiredError(`Lease expired. user=${userId}`);
|
|
18
|
+
case "missing_lease":
|
|
19
|
+
throw new LeaseNotFoundError(`Lease not found. user=${userId}`);
|
|
20
|
+
case "released_lease":
|
|
21
|
+
case "settled_lease":
|
|
22
|
+
throw new LeaseNotFoundError(`Lease is already finalized. user=${userId}`);
|
|
23
|
+
case "policy_mismatch":
|
|
24
|
+
throw new ConfigError(`Invalid operation policy. user=${userId}`);
|
|
25
|
+
case "missing_quota_measure":
|
|
26
|
+
case "invalid_measure":
|
|
27
|
+
throw new ConfigError(`Invalid quota measures for user ${userId}: ${error}`);
|
|
28
|
+
case "invalid_request":
|
|
29
|
+
throw new RangeError(`Invalid amount: ${amount}`);
|
|
30
|
+
default:
|
|
31
|
+
throw new StoreError(`Lease operation failed: ${error}. user=${userId}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function raiseDeductError(error, userId, cost) {
|
|
35
|
+
switch (error) {
|
|
36
|
+
case "quota_exceeded":
|
|
37
|
+
throw new QuotaExceededError(`Usage quota exceeded. user=${userId}`);
|
|
38
|
+
case "feature_not_entitled":
|
|
39
|
+
throw new FeatureNotEntitledError(`Feature not entitled. user=${userId}`);
|
|
40
|
+
case "operation_not_allowed":
|
|
41
|
+
throw new OperationNotAllowedError(`Operation is not allowed. user=${userId}`);
|
|
42
|
+
case "insufficient_headroom":
|
|
43
|
+
case "insufficient_credits":
|
|
44
|
+
throw new InsufficientCreditsError(`Insufficient credits. user=${userId}, requested=${cost}`);
|
|
45
|
+
case "policy_mismatch":
|
|
46
|
+
throw new ConfigError(`Invalid operation policy. user=${userId}`);
|
|
47
|
+
case "missing_quota_measure":
|
|
48
|
+
case "invalid_measure":
|
|
49
|
+
throw new ConfigError(`Invalid quota measures for user ${userId}: ${error}`);
|
|
50
|
+
case "invalid_amount":
|
|
51
|
+
case "invalid_request":
|
|
52
|
+
throw new RangeError(`Invalid deduction amount: ${cost}`);
|
|
53
|
+
default:
|
|
54
|
+
throw new StoreError(`Credit deduction failed: ${error}. user=${userId}, requested=${cost}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=service-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-errors.js","sourceRoot":"","sources":["../../src/credits/service-errors.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,MAAc,EAAE,MAAe;IAC5E,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,wBAAwB;YAC3B,MAAM,IAAI,qB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,kBAAkB,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAC;QACvE,KAAK,sBAAsB;YACzB,MAAM,IAAI,uBAAuB,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAC;QAC5E,KAAK,uBAAuB;YAC1B,MAAM,IAAI,wBAAwB,CAAC,kCAAkC,MAAM,EAAE,CAAC,CAAC;QACjF,KAAK,uBAAuB,CAAC;QAC7B,KAAK,sBAAsB;YACzB,MAAM,IAAI,wBAAwB,CAAC,8BAA8B,MAAM,eAAe,IAAI,EAAE,CAAC,CAAC;QAChG,KAAK,iBAAiB;YACpB,MAAM,IAAI,WAAW,CAAC,kCAAkC,MAAM,EAAE,CAAC,CAAC;QACpE,KAAK,uBAAuB,CAAC;QAC7B,KAAK,iBAAiB;YACpB,MAAM,IAAI,WAAW,CAAC,mCAAmC,MAAM,KAAK,KAAK,EAAE,CAAC,CAAC;QAC/E,KAAK,gBAAgB,CAAC;QACtB,KAAK,iBAAiB;YACpB,MAAM,IAAI,UAAU,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;QAC5D;YACE,MAAM,IAAI,UAAU,CAAC,4BAA4B,KAAK,UAAU,MAAM,eAAe,IAAI,EAAE,CAAC,CAAC;IACjG,CAAC;AACH,CAAC","sourcesContent":["import Decimal from \"decimal.js\";\n\nimport {\n ConcurrencyLimitError,\n ConfigError,\n FeatureNotEntitledError,\n InsufficientCreditsError,\n LeaseExpiredError,\n LeaseNotFoundError,\n OperationNotAllowedError,\n QuotaExceededError,\n StoreError,\n} from \"../errors.js\";\n\nexport function raiseLeaseError(error: string, userId: string, amount: Decimal): never {\n switch (error) {\n case \"max_concurrent_reached\":\n throw new ConcurrencyLimitError(`Concurrency limit reached. user=${userId}`);\n case \"quota_exceeded\":\n throw new QuotaExceededError(`Usage quota exceeded. user=${userId}`);\n case \"feature_not_entitled\":\n throw new FeatureNotEntitledError(`Feature not entitled. user=${userId}`);\n case \"operation_not_allowed\":\n throw new OperationNotAllowedError(`Operation is not allowed. user=${userId}`);\n case \"insufficient_headroom\":\n case \"insufficient_credits\":\n throw new InsufficientCreditsError(\n `Insufficient credits. user=${userId}, requested=${amount}`,\n );\n case \"expired_lease\":\n throw new LeaseExpiredError(`Lease expired. user=${userId}`);\n case \"missing_lease\":\n throw new LeaseNotFoundError(`Lease not found. user=${userId}`);\n case \"released_lease\":\n case \"settled_lease\":\n throw new LeaseNotFoundError(`Lease is already finalized. user=${userId}`);\n case \"policy_mismatch\":\n throw new ConfigError(`Invalid operation policy. user=${userId}`);\n case \"missing_quota_measure\":\n case \"invalid_measure\":\n throw new ConfigError(`Invalid quota measures for user ${userId}: ${error}`);\n case \"invalid_request\":\n throw new RangeError(`Invalid amount: ${amount}`);\n default:\n throw new StoreError(`Lease operation failed: ${error}. user=${userId}`);\n }\n}\n\nexport function raiseDeductError(error: string, userId: string, cost: Decimal): never {\n switch (error) {\n case \"quota_exceeded\":\n throw new QuotaExceededError(`Usage quota exceeded. user=${userId}`);\n case \"feature_not_entitled\":\n throw new FeatureNotEntitledError(`Feature not entitled. user=${userId}`);\n case \"operation_not_allowed\":\n throw new OperationNotAllowedError(`Operation is not allowed. user=${userId}`);\n case \"insufficient_headroom\":\n case \"insufficient_credits\":\n throw new InsufficientCreditsError(`Insufficient credits. user=${userId}, requested=${cost}`);\n case \"policy_mismatch\":\n throw new ConfigError(`Invalid operation policy. user=${userId}`);\n case \"missing_quota_measure\":\n case \"invalid_measure\":\n throw new ConfigError(`Invalid quota measures for user ${userId}: ${error}`);\n case \"invalid_amount\":\n case \"invalid_request\":\n throw new RangeError(`Invalid deduction amount: ${cost}`);\n default:\n throw new StoreError(`Credit deduction failed: ${error}. user=${userId}, requested=${cost}`);\n }\n}\n"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type Decimal from "decimal.js";
|
|
2
|
+
import type { UsageMetrics } from "../metrics.js";
|
|
3
|
+
import type { Logger } from "../shared/logger.js";
|
|
4
|
+
import type { CreditEvent } from "./events.js";
|
|
5
|
+
import type { BillingMode, CreditMetadata, DeductionResult, UsageAnalyticsStore, UsageChargeStore } from "./types/index.js";
|
|
6
|
+
export type PolicyPreset = "strict_prepaid" | "overdraft";
|
|
7
|
+
export type MetricsOrAmount = UsageMetrics | Decimal | number;
|
|
8
|
+
export interface PostDeductionContext {
|
|
9
|
+
userId: string;
|
|
10
|
+
source: "deduct" | "settle" | "raw";
|
|
11
|
+
deduction: DeductionResult;
|
|
12
|
+
}
|
|
13
|
+
export interface LowBalanceConfig {
|
|
14
|
+
thresholds?: (Decimal | number)[] | null;
|
|
15
|
+
onTrigger?: ((event: CreditEvent) => void | Promise<void>) | null;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum number of subjects whose breached-threshold state is retained in
|
|
18
|
+
* memory. Defaults to 100,000.
|
|
19
|
+
*/
|
|
20
|
+
maxTrackedUsers?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface CreditsServiceOptions {
|
|
23
|
+
logger?: Logger | null;
|
|
24
|
+
/**
|
|
25
|
+
* Optional read-only analytics backend. Defaults to the credit store, which
|
|
26
|
+
* keeps PostgreSQL as the zero-infrastructure behavior.
|
|
27
|
+
*/
|
|
28
|
+
analytics?: UsageAnalyticsStore | null;
|
|
29
|
+
/** Optional usage-history backend. Defaults to the credit store. */
|
|
30
|
+
usageStore?: UsageChargeStore | null;
|
|
31
|
+
/** Fallback credit policy for subjects without a plan assignment. */
|
|
32
|
+
policy?: PolicyPreset;
|
|
33
|
+
/** Planless-subject floor used with the `overdraft` fallback. */
|
|
34
|
+
overdraftFloor?: Decimal | number | null;
|
|
35
|
+
/** Planless-subject admission limit fallback. */
|
|
36
|
+
maxConcurrent?: number | null;
|
|
37
|
+
/**
|
|
38
|
+
* Edge-triggered low-balance thresholds and optional non-blocking handler.
|
|
39
|
+
* Defaults to zero when omitted.
|
|
40
|
+
*/
|
|
41
|
+
lowBalance?: LowBalanceConfig | null;
|
|
42
|
+
/** Default lease TTL in seconds. Defaults to 600. */
|
|
43
|
+
defaultTtlSeconds?: number;
|
|
44
|
+
/** Sweep a subject's expired credits before balance-sensitive operations. */
|
|
45
|
+
lazyExpiry?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Pricing-engine cache TTL in milliseconds. A value of 0 disables automatic
|
|
48
|
+
* reloads. Concurrent reloads are deduplicated.
|
|
49
|
+
*/
|
|
50
|
+
pricingTtl?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Awaited after a committed, non-replayed deduction. Hook failures are
|
|
53
|
+
* isolated from the committed credit charge.
|
|
54
|
+
*/
|
|
55
|
+
postDeduction?: ((context: PostDeductionContext) => void | Promise<void>) | null;
|
|
56
|
+
}
|
|
57
|
+
export interface ReserveOptions {
|
|
58
|
+
/** Replay-safe acquisition key. A random key is generated when omitted. */
|
|
59
|
+
idempotencyKey?: string | null;
|
|
60
|
+
operationType?: string;
|
|
61
|
+
billingMode?: BillingMode | null;
|
|
62
|
+
ttl?: number | null;
|
|
63
|
+
metadata?: CreditMetadata | null;
|
|
64
|
+
feature?: string | null;
|
|
65
|
+
/** Model tag used when reserving a raw amount instead of usage metrics. */
|
|
66
|
+
model?: string | null;
|
|
67
|
+
}
|
|
68
|
+
export interface SettleOptions {
|
|
69
|
+
idempotencyKey?: string | null;
|
|
70
|
+
metadata?: CreditMetadata | null;
|
|
71
|
+
/** Entitlement key supplied at reserve time. */
|
|
72
|
+
feature?: string | null;
|
|
73
|
+
}
|
|
74
|
+
export interface CanAffordOptions {
|
|
75
|
+
feature?: string | null;
|
|
76
|
+
billingMode?: BillingMode | null;
|
|
77
|
+
operationType?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface GrantSubscriptionCycleOptions {
|
|
80
|
+
bucket?: string;
|
|
81
|
+
expiresAt?: Date;
|
|
82
|
+
ttlDays?: number;
|
|
83
|
+
/** Expire the prior cycle balance first. Defaults to true. */
|
|
84
|
+
replacePrior?: boolean;
|
|
85
|
+
planKey?: string;
|
|
86
|
+
idempotencyKey?: string;
|
|
87
|
+
metadata?: CreditMetadata | null;
|
|
88
|
+
}
|
|
89
|
+
export interface RunBilledOptions<T> {
|
|
90
|
+
estimate: MetricsOrAmount;
|
|
91
|
+
doWork: () => Promise<{
|
|
92
|
+
result: T;
|
|
93
|
+
actual: MetricsOrAmount;
|
|
94
|
+
}>;
|
|
95
|
+
operationType?: string;
|
|
96
|
+
billingMode?: BillingMode | null;
|
|
97
|
+
/** Stable key for the complete reserve/work/settle operation. */
|
|
98
|
+
operationKey?: string | null;
|
|
99
|
+
ttl?: number | null;
|
|
100
|
+
feature?: string | null;
|
|
101
|
+
metadata?: CreditMetadata | null;
|
|
102
|
+
/** Settlement attempts for SDK-classified transient failures. Defaults to 3. */
|
|
103
|
+
settlementAttempts?: number;
|
|
104
|
+
}
|
|
105
|
+
export interface BeginBilledOperationOptions {
|
|
106
|
+
estimate: MetricsOrAmount;
|
|
107
|
+
/** Stable key for the complete reserve/settle operation. */
|
|
108
|
+
operationKey: string;
|
|
109
|
+
operationType?: string;
|
|
110
|
+
billingMode?: BillingMode | null;
|
|
111
|
+
ttl?: number | null;
|
|
112
|
+
feature?: string | null;
|
|
113
|
+
metadata?: CreditMetadata | null;
|
|
114
|
+
}
|
|
115
|
+
export interface BilledOperation {
|
|
116
|
+
readonly leaseId: string;
|
|
117
|
+
readonly operationKey: string;
|
|
118
|
+
settle(actual: MetricsOrAmount, metadata?: CreditMetadata | null): Promise<DeductionResult>;
|
|
119
|
+
renew(ttl?: number | null): Promise<void>;
|
|
120
|
+
release(): Promise<void>;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=service-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-types.d.ts","sourceRoot":"","sources":["../../src/credits/service-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qB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IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-types.js","sourceRoot":"","sources":["../../src/credits/service-types.ts"],"names":[],"mappings":"","sourcesContent":["import type Decimal from \"decimal.js\";\n\nimport type { UsageMetrics } from \"../metrics.js\";\nimport type { Logger } from \"../shared/logger.js\";\nimport type { CreditEvent } from \"./events.js\";\nimport type {\n BillingMode,\n CreditMetadata,\n DeductionResult,\n UsageAnalyticsStore,\n UsageChargeStore,\n} from \"./types/index.js\";\n\nexport type PolicyPreset = \"strict_prepaid\" | \"overdraft\";\nexport type MetricsOrAmount = UsageMetrics | Decimal | number;\n\nexport interface PostDeductionContext {\n userId: string;\n source: \"deduct\" | \"settle\" | \"raw\";\n deduction: DeductionResult;\n}\n\nexport interface LowBalanceConfig {\n thresholds?: (Decimal | number)[] | null;\n onTrigger?: ((event: CreditEvent) => void | Promise<void>) | null;\n /**\n * Maximum number of subjects whose breached-threshold state is retained in\n * memory. Defaults to 100,000.\n */\n maxTrackedUsers?: number;\n}\n\nexport interface CreditsServiceOptions {\n logger?: Logger | null;\n /**\n * Optional read-only analytics backend. Defaults to the credit store, which\n * keeps PostgreSQL as the zero-infrastructure behavior.\n */\n analytics?: UsageAnalyticsStore | null;\n /** Optional usage-history backend. Defaults to the credit store. */\n usageStore?: UsageChargeStore | null;\n /** Fallback credit policy for subjects without a plan assignment. */\n policy?: PolicyPreset;\n /** Planless-subject floor used with the `overdraft` fallback. */\n overdraftFloor?: Decimal | number | null;\n /** Planless-subject admission limit fallback. */\n maxConcurrent?: number | null;\n /**\n * Edge-triggered low-balance thresholds and optional non-blocking handler.\n * Defaults to zero when omitted.\n */\n lowBalance?: LowBalanceConfig | null;\n /** Default lease TTL in seconds. Defaults to 600. */\n defaultTtlSeconds?: number;\n /** Sweep a subject's expired credits before balance-sensitive operations. */\n lazyExpiry?: boolean;\n /**\n * Pricing-engine cache TTL in milliseconds. A value of 0 disables automatic\n * reloads. Concurrent reloads are deduplicated.\n */\n pricingTtl?: number;\n /**\n * Awaited after a committed, non-replayed deduction. Hook failures are\n * isolated from the committed credit charge.\n */\n postDeduction?: ((context: PostDeductionContext) => void | Promise<void>) | null;\n}\n\nexport interface ReserveOptions {\n /** Replay-safe acquisition key. A random key is generated when omitted. */\n idempotencyKey?: string | null;\n operationType?: string;\n billingMode?: BillingMode | null;\n ttl?: number | null;\n metadata?: CreditMetadata | null;\n feature?: string | null;\n /** Model tag used when reserving a raw amount instead of usage metrics. */\n model?: string | null;\n}\n\nexport interface SettleOptions {\n idempotencyKey?: string | null;\n metadata?: CreditMetadata | null;\n /** Entitlement key supplied at reserve time. */\n feature?: string | null;\n}\n\nexport interface CanAffordOptions {\n feature?: string | null;\n billingMode?: BillingMode | null;\n operationType?: string;\n}\n\nexport interface GrantSubscriptionCycleOptions {\n bucket?: string;\n expiresAt?: Date;\n ttlDays?: number;\n /** Expire the prior cycle balance first. Defaults to true. */\n replacePrior?: boolean;\n planKey?: string;\n idempotencyKey?: string;\n metadata?: CreditMetadata | null;\n}\n\nexport interface RunBilledOptions<T> {\n estimate: MetricsOrAmount;\n doWork: () => Promise<{ result: T; actual: MetricsOrAmount }>;\n operationType?: string;\n billingMode?: BillingMode | null;\n /** Stable key for the complete reserve/work/settle operation. */\n operationKey?: string | null;\n ttl?: number | null;\n feature?: string | null;\n metadata?: CreditMetadata | null;\n /** Settlement attempts for SDK-classified transient failures. Defaults to 3. */\n settlementAttempts?: number;\n}\n\nexport interface BeginBilledOperationOptions {\n estimate: MetricsOrAmount;\n /** Stable key for the complete reserve/settle operation. */\n operationKey: string;\n operationType?: string;\n billingMode?: BillingMode | null;\n ttl?: number | null;\n feature?: string | null;\n metadata?: CreditMetadata | null;\n}\n\nexport interface BilledOperation {\n readonly leaseId: string;\n readonly operationKey: string;\n settle(actual: MetricsOrAmount, metadata?: CreditMetadata | null): Promise<DeductionResult>;\n renew(ttl?: number | null): Promise<void>;\n release(): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
|
+
import type { PricingEngine } from "../engine.js";
|
|
3
|
+
import type { CatalogRollout } from "../config.js";
|
|
4
|
+
import type { AddCreditsResult, AggregateStats, AllowanceResult, AvailableResult, BalanceResult, BursarConfigResult, BucketBalancesResult, CanAffordResult, CheckFeatureResult, CreditMetadata, DailySpendRow, DeductionResult, ExecuteGrantProgramRequest, GetUserPlanResult, GrantProgramAwardResult, LedgerEntry, LedgerPage, LeaseResult, ListLedgerEntriesOptions, ListQuotaEventsOptions, ListUsageChargesOptions, ListUsageEntriesOptions, PlanMigrationBatchResult, PlanMigrationStartResult, QuotaEvent, QuotaState, RefundResult, ReleaseResult, SpendByModelRow, SpendByUserRow, SweepResult, TeamDeductionResult, TopUserRow, UsageChargePage, UsageRecordResult } from "./types/index.js";
|
|
5
|
+
import type { CreditStore } from "./store.js";
|
|
6
|
+
import type { CreditEventEmitter } from "./events.js";
|
|
7
|
+
import type { UsageMetrics } from "../metrics.js";
|
|
8
|
+
import type { CanAffordOptions, CreditsServiceOptions, GrantSubscriptionCycleOptions, MetricsOrAmount, PostDeductionContext, ReserveOptions, RunBilledOptions, SettleOptions, BeginBilledOperationOptions, BilledOperation } from "./service-types.js";
|
|
9
|
+
export type { CanAffordOptions, CreditsServiceOptions, GrantSubscriptionCycleOptions, LowBalanceConfig, PolicyPreset, ReserveOptions, RunBilledOptions, SettleOptions, PostDeductionContext, BeginBilledOperationOptions, BilledOperation, } from "./service-types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Orchestrates credit operations.
|
|
12
|
+
*
|
|
13
|
+
* The deduction path is a single atomic, idempotency-keyed store call
|
|
14
|
+
* (``deductWithAllowance``) that consumes free allowance, enforces plan policy,
|
|
15
|
+
* and debits the net amount in one transaction
|
|
16
|
+
* (contract §2). The manager is a thin layer that calculates the cost, maps
|
|
17
|
+
* the store's typed ``error`` codes to exceptions, and emits lifecycle events
|
|
18
|
+
* **only after** the operation has succeeded (contract §6).
|
|
19
|
+
*
|
|
20
|
+
* Optionally accepts a ``CreditEventEmitter`` to emit lifecycle events
|
|
21
|
+
* (deducted, deduct_failed, added, refunded, refund_failed, expired,
|
|
22
|
+
* low_balance).
|
|
23
|
+
*/
|
|
24
|
+
export declare class CreditsService {
|
|
25
|
+
private readonly store;
|
|
26
|
+
private readonly queries;
|
|
27
|
+
private readonly pricing;
|
|
28
|
+
private readonly leases;
|
|
29
|
+
private emitter;
|
|
30
|
+
private balanceMonitor;
|
|
31
|
+
private lazyExpiry;
|
|
32
|
+
private logger;
|
|
33
|
+
private readonly postDeductionHooks;
|
|
34
|
+
constructor(store: CreditStore, engine?: PricingEngine | null, emitter?: CreditEventEmitter | null, options?: CreditsServiceOptions | null);
|
|
35
|
+
/**
|
|
36
|
+
* Register an awaited post-commit deduction hook. A failing hook is logged
|
|
37
|
+
* and isolated so it can never roll back an already committed charge.
|
|
38
|
+
*/
|
|
39
|
+
addPostDeductionHook(hook: (context: PostDeductionContext) => void | Promise<void>): () => void;
|
|
40
|
+
private afterDeduction;
|
|
41
|
+
getActivePricing(): Promise<BursarConfigResult | null>;
|
|
42
|
+
getUserPlan(userId: string): Promise<GetUserPlanResult>;
|
|
43
|
+
checkFeature(userId: string, feature: string): Promise<CheckFeatureResult>;
|
|
44
|
+
getQuotaState(userId: string, quotaKey?: string | null): Promise<QuotaState[]>;
|
|
45
|
+
listQuotaEvents(userId: string, options?: ListQuotaEventsOptions): Promise<QuotaEvent[]>;
|
|
46
|
+
startPlanMigration(fromPlanId: string | null, toPlanId: string): Promise<PlanMigrationStartResult>;
|
|
47
|
+
migratePlanBatch(migrationId: string, batchSize?: number): Promise<PlanMigrationBatchResult>;
|
|
48
|
+
revokeCreditsByEntryType(userId: string, entryType: string): Promise<Record<string, unknown>>;
|
|
49
|
+
/** Execute an application-driven catalog grant program. */
|
|
50
|
+
executeGrantProgram(request: ExecuteGrantProgramRequest): Promise<GrantProgramAwardResult[]>;
|
|
51
|
+
getLedgerEntry(userId: string, entryId: string): Promise<LedgerEntry | null>;
|
|
52
|
+
getAvailable(userId: string): Promise<AvailableResult>;
|
|
53
|
+
aggregateStats(start: Date, end: Date): Promise<AggregateStats>;
|
|
54
|
+
spendByUser(start: Date, end: Date): Promise<SpendByUserRow[]>;
|
|
55
|
+
spendByModel(start: Date, end: Date): Promise<SpendByModelRow[]>;
|
|
56
|
+
listLedgerEntries(userId: string, options?: ListLedgerEntriesOptions): Promise<LedgerPage>;
|
|
57
|
+
listUsageEntries(userId: string, options?: ListUsageEntriesOptions): Promise<LedgerPage>;
|
|
58
|
+
listUsageCharges(userId: string, options?: ListUsageChargesOptions): Promise<UsageChargePage>;
|
|
59
|
+
topUsers(limit: number, start: Date, end: Date): Promise<TopUserRow[]>;
|
|
60
|
+
dailySpend(start: Date, end: Date): Promise<DailySpendRow[]>;
|
|
61
|
+
/** Emit a credit lifecycle event. No-op if no emitter is configured. */
|
|
62
|
+
private emit;
|
|
63
|
+
private emitQuotaEvents;
|
|
64
|
+
/** Load pricing from a raw dict and sync it. */
|
|
65
|
+
publishPricingFromDict(data: Record<string, unknown>): Promise<void>;
|
|
66
|
+
/** Load the active pricing config from the store. */
|
|
67
|
+
loadPricingFromStore(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* If the cached PricingEngine is stale (TTL expired), reload it from the
|
|
70
|
+
* store. Concurrent callers are deduplicated via the underlying
|
|
71
|
+
* ``lru-cache.fetch()`` — only one ``loadPricingFromStore`` runs and all
|
|
72
|
+
* callers await the same result.
|
|
73
|
+
*
|
|
74
|
+
* When ``pricingTtl`` is ``0``, this is a no-op (the consumer must call
|
|
75
|
+
* ``loadPricingFromStore`` manually).
|
|
76
|
+
*/
|
|
77
|
+
refreshIfStale(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Invalidate the pricing cache so the next ``refreshIfStale`` call
|
|
80
|
+
* reloads from the store. Useful after a manual ``loadPricingFromStore``
|
|
81
|
+
* that bypasses the cache, or when the consumer knows the remote config
|
|
82
|
+
* has changed.
|
|
83
|
+
*/
|
|
84
|
+
invalidatePricing(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Publish new pricing and update the engine in one call.
|
|
87
|
+
*
|
|
88
|
+
* H10: the store write is now **awaited** (was a fire-and-forget `void`), so
|
|
89
|
+
* a persistence failure surfaces to the caller instead of becoming an
|
|
90
|
+
* unhandled promise rejection.
|
|
91
|
+
*/
|
|
92
|
+
publishPricing(config: Record<string, unknown>, label?: string | null, rollout?: CatalogRollout | Record<string, unknown> | null): Promise<void>;
|
|
93
|
+
/** Publish a validated, inactive catalog draft. */
|
|
94
|
+
publishPricingDraft(config: Record<string, unknown>, label?: string | null): Promise<string>;
|
|
95
|
+
/** Activate an existing catalog version and reload the local engine. */
|
|
96
|
+
activatePricing(version: number, rollout?: CatalogRollout | Record<string, unknown> | null): Promise<string>;
|
|
97
|
+
/** The current PricingEngine, or null if not loaded. */
|
|
98
|
+
get pricingEngine(): PricingEngine | null;
|
|
99
|
+
/**
|
|
100
|
+
* Set a user's subscription plan and emit ``credits.plan_changed``.
|
|
101
|
+
*
|
|
102
|
+
* The store call is awaited so a persistence failure surfaces to the caller.
|
|
103
|
+
* The event is emitted only after the store write succeeds (contract §6).
|
|
104
|
+
*/
|
|
105
|
+
setUserPlan(userId: string, planKey: string, planAssignedAt?: Date | null): Promise<void>;
|
|
106
|
+
/** Unset a user's subscription plan and emit the plan-change event. */
|
|
107
|
+
unsetUserPlan(userId: string): Promise<void>;
|
|
108
|
+
/** Pin or unpin the user's current assignment revision. */
|
|
109
|
+
setPlanRevisionPin(userId: string, pinned: boolean): Promise<boolean>;
|
|
110
|
+
/** Apply one bounded batch of renewal-effective plan changes. */
|
|
111
|
+
applyDuePlanChanges(limit?: number): Promise<number>;
|
|
112
|
+
/** Sweep this user's expired lots when lazy expiry is enabled. */
|
|
113
|
+
private maybeLazyExpire;
|
|
114
|
+
getBalance(userId: string): Promise<BalanceResult>;
|
|
115
|
+
/** Add credits to a user's account. */
|
|
116
|
+
addCredits(userId: string, amount: Decimal | number, options?: {
|
|
117
|
+
type?: string;
|
|
118
|
+
metadata?: CreditMetadata | null;
|
|
119
|
+
expiresAt?: Date | null;
|
|
120
|
+
/** Target credit bucket; omitted resolves to the config's default bucket. */
|
|
121
|
+
bucket?: string | null;
|
|
122
|
+
/** Replay-safe idempotency key (parity with `deduct`/`settle`/`refund`). */
|
|
123
|
+
idempotencyKey?: string | null;
|
|
124
|
+
}): Promise<AddCreditsResult>;
|
|
125
|
+
/**
|
|
126
|
+
* Deduct a raw credit amount from a user's account.
|
|
127
|
+
*
|
|
128
|
+
* Uses the store's `addCredits` with `type='adjustment'` and a negated
|
|
129
|
+
* amount — the existing validation path for negative/zero adjustments.
|
|
130
|
+
* Use this for refund clawbacks and other administrative deductions that
|
|
131
|
+
* bypass the usage-based `deduct()` flow.
|
|
132
|
+
*/
|
|
133
|
+
deductCredits(userId: string, amount: Decimal | number, options?: {
|
|
134
|
+
entryType?: string;
|
|
135
|
+
bucket?: string | null;
|
|
136
|
+
metadata?: CreditMetadata | null;
|
|
137
|
+
}): Promise<AddCreditsResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Grant one billing-cycle's worth of credits — idempotent-safe for a
|
|
140
|
+
* payment-provider webhook handler (Stripe, etc. — bursar stays
|
|
141
|
+
* provider-agnostic) to call even on webhook redelivery.
|
|
142
|
+
*
|
|
143
|
+
* 1. At most one of ``expiresAt``/``ttlDays`` may be given (throws
|
|
144
|
+
* ``ConfigError`` otherwise).
|
|
145
|
+
* 2. When ``ttlDays`` is given, ``expiresAt = now + ttlDays`` days.
|
|
146
|
+
* 3. When ``replacePrior`` (default ``true``), any remaining balance in
|
|
147
|
+
* ``bucket`` is expired immediately via a direct ``store.addCredits``
|
|
148
|
+
* negative adjustment — naturally idempotent (a replay finds the bucket
|
|
149
|
+
* already at zero and skips the call).
|
|
150
|
+
* 4. The new cycle is granted via a direct ``store.addCredits`` call
|
|
151
|
+
* (bypassing {@link addCredits} so only ``credits.cycle_renewed`` fires,
|
|
152
|
+
* not a duplicate ``credits.added``), threading ``idempotencyKey`` so a
|
|
153
|
+
* redelivered webhook replays the prior grant instead of double-crediting.
|
|
154
|
+
* 5. When ``planKey`` is given, assigns it via {@link setUserPlan}.
|
|
155
|
+
* 6. Emits ``credits.cycle_renewed`` and returns the grant result.
|
|
156
|
+
*/
|
|
157
|
+
grantSubscriptionCycle(userId: string, amount: Decimal | number, options?: GrantSubscriptionCycleOptions): Promise<AddCreditsResult>;
|
|
158
|
+
reserve(userId: string, metricsOrAmount: MetricsOrAmount, options?: ReserveOptions): Promise<LeaseResult>;
|
|
159
|
+
settle(userId: string, leaseId: string, metricsOrAmount: MetricsOrAmount, options?: SettleOptions): Promise<DeductionResult>;
|
|
160
|
+
release(userId: string, leaseId: string): Promise<ReleaseResult>;
|
|
161
|
+
renew(userId: string, leaseId: string, ttl?: number | null): Promise<LeaseResult>;
|
|
162
|
+
canAfford(userId: string, metricsOrAmount: MetricsOrAmount, options?: CanAffordOptions): Promise<CanAffordResult>;
|
|
163
|
+
getBucketBalances(userId: string): Promise<BucketBalancesResult>;
|
|
164
|
+
checkAllowance(userId: string): Promise<AllowanceResult>;
|
|
165
|
+
runBilled<T>(userId: string, options: RunBilledOptions<T>): Promise<{
|
|
166
|
+
result: T;
|
|
167
|
+
deduction: DeductionResult;
|
|
168
|
+
}>;
|
|
169
|
+
beginBilledOperation(userId: string, options: BeginBilledOperationOptions): Promise<BilledOperation>;
|
|
170
|
+
/**
|
|
171
|
+
* Full deduction flow as one atomic store call (contract §2).
|
|
172
|
+
*
|
|
173
|
+
* 1. ``breakdown = engine.calculate(metrics)``; ``cost = breakdown.total``
|
|
174
|
+
* (exact `Decimal`, **no truncation**).
|
|
175
|
+
* 2. ``store.deductWithAllowance`` records the usage, enforces policy, consumes
|
|
176
|
+
* allowance, and debits any remainder — idempotency-keyed end-to-end.
|
|
177
|
+
*
|
|
178
|
+
* On a store ``error`` a ``credits.deduct_failed`` event is emitted and a
|
|
179
|
+
* typed exception is thrown. No success event is emitted on error.
|
|
180
|
+
*/
|
|
181
|
+
deduct(userId: string, metrics: UsageMetrics, idempotencyKey?: string | null, metadata?: CreditMetadata | null,
|
|
182
|
+
/** Entitlement feature required for this operation. */
|
|
183
|
+
feature?: string | null): Promise<DeductionResult>;
|
|
184
|
+
/**
|
|
185
|
+
* Record priced usage for a workflow without debiting the account again.
|
|
186
|
+
*
|
|
187
|
+
* This is intended for child work inside a fixed-price operation. The
|
|
188
|
+
* parent operation remains the only customer debit; the returned usage row
|
|
189
|
+
* preserves the child cost and metadata in Bursar's usage journal.
|
|
190
|
+
*/
|
|
191
|
+
recordUsage(userId: string, metrics: UsageMetrics, idempotencyKey?: string | null, metadata?: CreditMetadata | null): Promise<UsageRecordResult>;
|
|
192
|
+
/**
|
|
193
|
+
* Refund a previous credit deduction.
|
|
194
|
+
*
|
|
195
|
+
* Returns the RefundResult. A successful refund
|
|
196
|
+
* emits ``credits.refunded``; a failed/duplicate/over-refund emits
|
|
197
|
+
* ``credits.refund_failed`` (no success event is ever emitted for a failed
|
|
198
|
+
* refund).
|
|
199
|
+
*/
|
|
200
|
+
/** Deduct the configured fixed cost for one named job. */
|
|
201
|
+
deductFlatJob(userId: string, jobName: string, idempotencyKey?: string | null, metadata?: CreditMetadata | null, feature?: string | null): Promise<DeductionResult>;
|
|
202
|
+
refundCredits(entryId: string, amount?: Decimal | number, reason?: string, metadata?: CreditMetadata | null, idempotencyKey?: string | null): Promise<RefundResult>;
|
|
203
|
+
/**
|
|
204
|
+
* Deduct from a team's shared balance pool.
|
|
205
|
+
*
|
|
206
|
+
* Calculates the cost via the pricing engine (exact `Decimal`, no truncation),
|
|
207
|
+
* then debits the team balance. Threads an optional ``idempotencyKey`` through
|
|
208
|
+
* to the store so retried team charges are not double-counted (H12).
|
|
209
|
+
*/
|
|
210
|
+
deductTeam(teamId: string, userId: string, metrics: UsageMetrics, idempotencyKey?: string | null, metadata?: CreditMetadata | null): Promise<TeamDeductionResult>;
|
|
211
|
+
private runSweep;
|
|
212
|
+
/**
|
|
213
|
+
* Sweep expired credits from all users' balances.
|
|
214
|
+
*
|
|
215
|
+
* When ``dryRun`` is true, reports what would expire without mutating
|
|
216
|
+
* balances. Automatic lazy sweeps remain scoped to one subject.
|
|
217
|
+
*/
|
|
218
|
+
sweepExpiredCredits(dryRun?: boolean): Promise<SweepResult>;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/credits/service.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AASjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,eAAe,EAEf,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,WAAW,EACX,UAAU,EACV,WAAW,EACX,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,aAAa,CAAC;AACvE,OAA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