@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
package/dist/engine.js
CHANGED
|
@@ -1,172 +1,196 @@
|
|
|
1
1
|
import Decimal from "decimal.js";
|
|
2
|
-
import { evaluateExpression } from "./expr.js";
|
|
3
|
-
import { loadConfigFromDict } from "./config.js";
|
|
4
2
|
import { makeCostBreakdown } from "./breakdown.js";
|
|
3
|
+
import { canonicalParsedBursarConfigDict, loadConfigFromDict, } from "./config.js";
|
|
5
4
|
import { ConfigError } from "./errors.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* Evaluates pricing expressions against usage metrics to produce cost
|
|
10
|
-
* breakdowns. All money values are exact `Decimal`s — never binary `number`.
|
|
11
|
-
*/
|
|
5
|
+
import { evaluateExpression } from "./expr.js";
|
|
6
|
+
const quantize = (value) => value.toDecimalPlaces(6, Decimal.ROUND_HALF_UP);
|
|
12
7
|
export class PricingEngine {
|
|
13
8
|
config;
|
|
14
9
|
constructor(config) {
|
|
15
10
|
this.config = config;
|
|
16
11
|
}
|
|
17
|
-
/** Load engine from a config dictionary. */
|
|
18
12
|
static fromDict(data) {
|
|
19
13
|
return new PricingEngine(loadConfigFromDict(data));
|
|
20
14
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
get pricingSchema() {
|
|
16
|
+
return canonicalParsedBursarConfigDict(this.config);
|
|
17
|
+
}
|
|
18
|
+
calculate(metrics, options = {}) {
|
|
19
|
+
const pricing = this.config.pricing;
|
|
20
|
+
if (!pricing)
|
|
21
|
+
throw new ConfigError("usage pricing not configured");
|
|
22
|
+
const operation = pricing.operations[metrics.operation];
|
|
23
|
+
if (!operation)
|
|
24
|
+
throw new ConfigError(`unknown usage operation '${metrics.operation}'`);
|
|
25
|
+
const measuresInput = metrics.measures ?? {};
|
|
26
|
+
const dimensionsInput = metrics.dimensions ?? {};
|
|
27
|
+
const unknownMeasures = Object.keys(measuresInput).filter((key) => !operation.measures[key]);
|
|
28
|
+
const unknownDimensions = Object.keys(dimensionsInput).filter((key) => !operation.dimensions[key]);
|
|
29
|
+
if (unknownMeasures.length)
|
|
30
|
+
throw new ConfigError(`operation '${metrics.operation}' received undeclared measures ${unknownMeasures.join(", ")}`);
|
|
31
|
+
if (unknownDimensions.length)
|
|
32
|
+
throw new ConfigError(`operation '${metrics.operation}' received undeclared dimensions ${unknownDimensions.join(", ")}`);
|
|
33
|
+
const dimensions = {};
|
|
34
|
+
for (const [name, definition] of Object.entries(operation.dimensions)) {
|
|
35
|
+
const input = dimensionsInput[name];
|
|
36
|
+
if (input == null) {
|
|
37
|
+
if (definition.required)
|
|
38
|
+
throw new ConfigError(`operation '${metrics.operation}' requires dimension '${name}'`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (definition.type === "string") {
|
|
42
|
+
if (typeof input !== "string")
|
|
43
|
+
throw new ConfigError(`dimension '${name}' must be string`);
|
|
44
|
+
dimensions[name] = input;
|
|
45
|
+
}
|
|
46
|
+
else if (definition.type === "boolean") {
|
|
47
|
+
if (typeof input !== "boolean")
|
|
48
|
+
throw new ConfigError(`dimension '${name}' must be boolean`);
|
|
49
|
+
dimensions[name] = input;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const numeric = new Decimal(input);
|
|
53
|
+
if (!numeric.isFinite())
|
|
54
|
+
throw new ConfigError(`dimension '${name}' must be finite`);
|
|
55
|
+
dimensions[name] = numeric;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const measures = {};
|
|
59
|
+
for (const name of Object.keys(operation.measures)) {
|
|
60
|
+
const value = new Decimal(measuresInput[name] ?? 0);
|
|
61
|
+
if (!value.isFinite() || value.isNegative())
|
|
62
|
+
throw new ConfigError(`usage measure '${name}' must be finite and non-negative`);
|
|
63
|
+
measures[name] = value;
|
|
64
|
+
}
|
|
65
|
+
const requestedRateCard = options != null && "rateCard" in options ? options.rateCard : undefined;
|
|
66
|
+
const cardKey = this.resolveRateCard(requestedRateCard);
|
|
67
|
+
const operationPrice = this.operationPricing(cardKey, metrics.operation);
|
|
68
|
+
const matched = operationPrice.rules.find((rule) => this.matches(rule, dimensions));
|
|
69
|
+
const selected = matched?.charge ??
|
|
70
|
+
(operationPrice.unmatched.action === "charge" ? operationPrice.unmatched.charge : undefined);
|
|
71
|
+
if (!selected)
|
|
72
|
+
throw new ConfigError(`no price rule matched operation '${metrics.operation}' in rate card '${cardKey}'`);
|
|
73
|
+
const value = this.evaluateCharge(selected, measures);
|
|
74
|
+
if (!value.isFinite() || value.isNegative())
|
|
75
|
+
throw new ConfigError(`price charge for '${metrics.operation}' produced a negative or non-finite credit cost`);
|
|
76
|
+
const total = quantize(value);
|
|
31
77
|
return makeCostBreakdown({
|
|
32
|
-
|
|
33
|
-
toolCredits,
|
|
34
|
-
searchCredits,
|
|
35
|
-
cacheSavings,
|
|
36
|
-
fixedCredits,
|
|
78
|
+
operationCredits: total,
|
|
37
79
|
breakdown: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
80
|
+
operation: metrics.operation,
|
|
81
|
+
rateCard: cardKey,
|
|
82
|
+
chargeType: selected.type,
|
|
83
|
+
measures: Object.fromEntries(Object.entries(measures).map(([key, amount]) => [key, amount.toString()])),
|
|
84
|
+
dimensions: dimensionsInput,
|
|
42
85
|
},
|
|
43
86
|
});
|
|
44
87
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return metricsList.map((m) => this.calculate(m));
|
|
48
|
-
}
|
|
49
|
-
/** Return the pricing config as a typed model. */
|
|
50
|
-
pricingSchema() {
|
|
51
|
-
return {
|
|
52
|
-
models: { ...this.config.models },
|
|
53
|
-
tools: Object.keys(this.config.tools).length > 0 ? { ...this.config.tools } : null,
|
|
54
|
-
search: this.config.search ?? null,
|
|
55
|
-
cache: this.config.cache ?? null,
|
|
56
|
-
fixed: Object.keys(this.config.fixed).length > 0 ? { ...this.config.fixed } : null,
|
|
57
|
-
minBalance: this.config.minBalance,
|
|
58
|
-
plans: this.config.plans ? { ...this.config.plans } : null,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
/** Minimum balance users must keep. */
|
|
62
|
-
get minBalance() {
|
|
63
|
-
return this.config.minBalance;
|
|
88
|
+
calculateBatch(metrics, options = {}) {
|
|
89
|
+
return metrics.map((item) => this.calculate(item, options));
|
|
64
90
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/** Check if a model name exists in the pricing config. */
|
|
70
|
-
hasModel(modelName) {
|
|
71
|
-
return Object.prototype.hasOwnProperty.call(this.config.models, modelName);
|
|
72
|
-
}
|
|
73
|
-
/** Resolve a model version string to a pricing config key. */
|
|
74
|
-
resolveModel(modelVersion) {
|
|
75
|
-
if (Object.prototype.hasOwnProperty.call(this.config.models, modelVersion))
|
|
76
|
-
return modelVersion;
|
|
77
|
-
for (const key of Object.keys(this.config.models)) {
|
|
78
|
-
if (key !== "_default" && modelVersion.startsWith(key))
|
|
79
|
-
return key;
|
|
80
|
-
}
|
|
81
|
-
if (Object.prototype.hasOwnProperty.call(this.config.models, "_default"))
|
|
82
|
-
return "_default";
|
|
83
|
-
return null;
|
|
91
|
+
getRateCardForPlan(planId) {
|
|
92
|
+
if (!planId)
|
|
93
|
+
return undefined;
|
|
94
|
+
return this.config.plans[planId]?.rateCard;
|
|
84
95
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (Object.prototype.hasOwnProperty.call(this.config.fixed, jobName)) {
|
|
92
|
-
return this.config.fixed[jobName];
|
|
96
|
+
resolveRateCard(requested) {
|
|
97
|
+
const cards = this.config.pricing.rateCards;
|
|
98
|
+
if (requested) {
|
|
99
|
+
if (!cards[requested])
|
|
100
|
+
throw new ConfigError(`unknown rate card '${requested}'`);
|
|
101
|
+
return requested;
|
|
93
102
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
103
|
+
const keys = Object.keys(cards);
|
|
104
|
+
if (keys.length === 1)
|
|
105
|
+
return keys[0];
|
|
106
|
+
throw new ConfigError("rateCard is required when more than one rate card is configured");
|
|
107
|
+
}
|
|
108
|
+
operationPricing(cardKey, operation) {
|
|
109
|
+
const card = this.config.pricing.rateCards[cardKey];
|
|
110
|
+
if (card.operations[operation])
|
|
111
|
+
return card.operations[operation];
|
|
112
|
+
if (!card.extends)
|
|
113
|
+
throw new ConfigError(`rate card '${cardKey}' has no price for operation '${operation}'`);
|
|
114
|
+
return this.operationPricing(card.extends, operation);
|
|
115
|
+
}
|
|
116
|
+
matches(rule, dimensions) {
|
|
117
|
+
return Object.entries(rule.when).every(([name, matcher]) => this.matchesOne(matcher, dimensions[name]));
|
|
118
|
+
}
|
|
119
|
+
matchesOne(matcher, value) {
|
|
120
|
+
if (value == null)
|
|
121
|
+
return false;
|
|
122
|
+
if (matcher.op === "eq")
|
|
123
|
+
return this.scalarEquals(value, matcher.value);
|
|
124
|
+
if (matcher.op === "in")
|
|
125
|
+
return matcher.values.some((candidate) => this.scalarEquals(value, candidate));
|
|
126
|
+
if (matcher.op === "not_in")
|
|
127
|
+
return !matcher.values.some((candidate) => this.scalarEquals(value, candidate));
|
|
128
|
+
if (matcher.op === "prefix")
|
|
129
|
+
return typeof value === "string" && value.startsWith(matcher.value);
|
|
130
|
+
if (matcher.op !== "range" || !(value instanceof Decimal))
|
|
131
|
+
return false;
|
|
132
|
+
if (matcher.gt && !value.gt(matcher.gt))
|
|
133
|
+
return false;
|
|
134
|
+
if (matcher.gte && !value.gte(matcher.gte))
|
|
135
|
+
return false;
|
|
136
|
+
if (matcher.lt && !value.lt(matcher.lt))
|
|
137
|
+
return false;
|
|
138
|
+
if (matcher.lte && !value.lte(matcher.lte))
|
|
139
|
+
return false;
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
scalarEquals(left, right) {
|
|
143
|
+
if (left instanceof Decimal || right instanceof Decimal) {
|
|
144
|
+
try {
|
|
145
|
+
return new Decimal(left).eq(new Decimal(right));
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return false;
|
|
139
149
|
}
|
|
140
150
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
return left === right;
|
|
152
|
+
}
|
|
153
|
+
evaluateCharge(charge, measures) {
|
|
154
|
+
if (charge.type === "flat")
|
|
155
|
+
return charge.amount;
|
|
156
|
+
if (charge.type === "per_unit")
|
|
157
|
+
return measures[charge.measure].div(charge.unitSize).mul(charge.rate);
|
|
158
|
+
if (charge.type === "package") {
|
|
159
|
+
const packages = measures[charge.measure].div(charge.units);
|
|
160
|
+
const rounded = charge.rounding === "ceil"
|
|
161
|
+
? packages.ceil()
|
|
162
|
+
: charge.rounding === "floor"
|
|
163
|
+
? packages.floor()
|
|
164
|
+
: packages.toDecimalPlaces(0, Decimal.ROUND_HALF_UP);
|
|
165
|
+
return rounded.mul(charge.amount);
|
|
155
166
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
if (charge.type === "graduated") {
|
|
168
|
+
let remaining = measures[charge.measure];
|
|
169
|
+
let previous = new Decimal(0);
|
|
170
|
+
let total = new Decimal(0);
|
|
171
|
+
for (const tier of charge.tiers) {
|
|
172
|
+
const units = tier.upTo == null ? remaining : Decimal.min(remaining, tier.upTo.sub(previous));
|
|
173
|
+
if (units.isPositive()) {
|
|
174
|
+
total = total.add(units.mul(tier.rate));
|
|
175
|
+
remaining = remaining.sub(units);
|
|
176
|
+
}
|
|
177
|
+
if (!remaining.isPositive())
|
|
178
|
+
break;
|
|
179
|
+
if (tier.upTo != null)
|
|
180
|
+
previous = tier.upTo;
|
|
181
|
+
}
|
|
182
|
+
return total;
|
|
161
183
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
Object.prototype.hasOwnProperty.call(this.config.fixed, metrics.fixedJob)) {
|
|
167
|
-
return this.config.fixed[metrics.fixedJob];
|
|
184
|
+
if (charge.type === "volume") {
|
|
185
|
+
const value = measures[charge.measure];
|
|
186
|
+
const tier = charge.tiers.find((candidate) => candidate.upTo == null || value.lte(candidate.upTo));
|
|
187
|
+
return value.mul((tier ?? charge.tiers.at(-1)).rate);
|
|
168
188
|
}
|
|
169
|
-
|
|
189
|
+
if (charge.type === "expression")
|
|
190
|
+
return evaluateExpression(charge.formula, measures);
|
|
191
|
+
if (charge.type === "sum")
|
|
192
|
+
return Decimal.sum(...charge.components.map((component) => this.evaluateCharge(component, measures)));
|
|
193
|
+
throw new ConfigError(`unsupported charge type '${String(charge.type)}'`);
|
|
170
194
|
}
|
|
171
195
|
}
|
|
172
196
|
//# sourceMappingURL=engine.js.map
|
package/dist/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAgB;IAE9B,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,4CAA4C;IAC5C,MAAM,CAAC,QAAQ,CAAC,IAA6B;QAC3C,OAAO,IAAI,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,sDAAsD;IACtD,SAAS,CAAC,OAAqB;QAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE,SAAS,CAAC,CAAC;QACtE,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACvD,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAE7C,0EAA0E;QAC1E,kEAAkE;QAClE,OAAO,iBAAiB,CAAC;YACvB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YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACvC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAC5B,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CACnE,CAAC;YACF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY;YAAE,OAAO,kBAAkB,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACtF,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK;YACvB,OAAO,OAAO,CAAC,GAAG,CAChB,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAClF,CAAC;QACJ,MAAM,IAAI,WAAW,CAAC,4BAA4B,MAAM,CAAE,MAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxF,CAAC;CACF","sourcesContent":["import Decimal from \"decimal.js\";\n\nimport { makeCostBreakdown } from \"./breakdown.js\";\nimport type { CostBreakdown } from \"./breakdown.js\";\nimport {\n canonicalParsedBursarConfigDict,\n loadConfigFromDict,\n type Charge,\n type BursarConfigData,\n type DimensionMatcher,\n type OperationPricing,\n type ParsedBursarConfig,\n type PriceRule,\n} from \"./config.js\";\nimport { ConfigError } from \"./errors.js\";\nimport { evaluateExpression } from \"./expr.js\";\nimport type { UsageMetrics } from \"./metrics.js\";\n\nconst quantize = (value: Decimal): Decimal => value.toDecimalPlaces(6, Decimal.ROUND_HALF_UP);\n\ntype DimensionValue = string | Decimal | boolean;\n\nexport class PricingEngine {\n constructor(private readonly config: ParsedBursarConfig) {}\n\n static fromDict(data: BursarConfigData | Record<string, unknown>): PricingEngine {\n return new PricingEngine(loadConfigFromDict(data));\n }\n\n get pricingSchema(): Record<string, unknown> {\n return canonicalParsedBursarConfigDict(this.config);\n }\n\n calculate(\n metrics: UsageMetrics,\n options: { rateCard?: string } | Record<string, string> | null = {},\n ): CostBreakdown {\n const pricing = this.config.pricing;\n if (!pricing) throw new ConfigError(\"usage pricing not configured\");\n const operation = pricing.operations[metrics.operation];\n if (!operation) throw new ConfigError(`unknown usage operation '${metrics.operation}'`);\n const measuresInput = metrics.measures ?? {};\n const dimensionsInput = metrics.dimensions ?? {};\n const unknownMeasures = Object.keys(measuresInput).filter((key) => !operation.measures[key]);\n const unknownDimensions = Object.keys(dimensionsInput).filter(\n (key) => !operation.dimensions[key],\n );\n if (unknownMeasures.length)\n throw new ConfigError(\n `operation '${metrics.operation}' received undeclared measures ${unknownMeasures.join(\", \")}`,\n );\n if (unknownDimensions.length)\n throw new ConfigError(\n `operation '${metrics.operation}' received undeclared dimensions ${unknownDimensions.join(\", \")}`,\n );\n\n const dimensions: Record<string, DimensionValue> = {};\n for (const [name, definition] of Object.entries(operation.dimensions)) {\n const input = dimensionsInput[name];\n if (input == null) {\n if (definition.required)\n throw new ConfigError(`operation '${metrics.operation}' requires dimension '${name}'`);\n continue;\n }\n if (definition.type === \"string\") {\n if (typeof input !== \"string\") throw new ConfigError(`dimension '${name}' must be string`);\n dimensions[name] = input;\n } else if (definition.type === \"boolean\") {\n if (typeof input !== \"boolean\")\n throw new ConfigError(`dimension '${name}' must be boolean`);\n dimensions[name] = input;\n } else {\n const numeric = new Decimal(input as Decimal.Value);\n if (!numeric.isFinite()) throw new ConfigError(`dimension '${name}' must be finite`);\n dimensions[name] = numeric;\n }\n }\n\n const measures: Record<string, Decimal> = {};\n for (const name of Object.keys(operation.measures)) {\n const value = new Decimal(measuresInput[name] ?? 0);\n if (!value.isFinite() || value.isNegative())\n throw new ConfigError(`usage measure '${name}' must be finite and non-negative`);\n measures[name] = value;\n }\n const requestedRateCard =\n options != null && \"rateCard\" in options ? options.rateCard : undefined;\n const cardKey = this.resolveRateCard(requestedRateCard);\n const operationPrice = this.operationPricing(cardKey, metrics.operation);\n const matched = operationPrice.rules.find((rule) => this.matches(rule, dimensions));\n const selected =\n matched?.charge ??\n (operationPrice.unmatched.action === \"charge\" ? operationPrice.unmatched.charge : undefined);\n if (!selected)\n throw new ConfigError(\n `no price rule matched operation '${metrics.operation}' in rate card '${cardKey}'`,\n );\n const value = this.evaluateCharge(selected, measures);\n if (!value.isFinite() || value.isNegative())\n throw new ConfigError(\n `price charge for '${metrics.operation}' produced a negative or non-finite credit cost`,\n );\n const total = quantize(value);\n return makeCostBreakdown({\n operationCredits: total,\n breakdown: {\n operation: metrics.operation,\n rateCard: cardKey,\n chargeType: selected.type,\n measures: Object.fromEntries(\n Object.entries(measures).map(([key, amount]) => [key, amount.toString()]),\n ),\n dimensions: dimensionsInput,\n },\n });\n }\n\n calculateBatch(metrics: UsageMetrics[], options: { rateCard?: string } = {}): CostBreakdown[] {\n return metrics.map((item) => this.calculate(item, options));\n }\n\n getRateCardForPlan(planId: string | null | undefined): string | undefined {\n if (!planId) return undefined;\n return this.config.plans[planId]?.rateCard;\n }\n\n private resolveRateCard(requested?: string): string {\n const cards = this.config.pricing!.rateCards;\n if (requested) {\n if (!cards[requested]) throw new ConfigError(`unknown rate card '${requested}'`);\n return requested;\n }\n const keys = Object.keys(cards);\n if (keys.length === 1) return keys[0];\n throw new ConfigError(\"rateCard is required when more than one rate card is configured\");\n }\n\n private operationPricing(cardKey: string, operation: string): OperationPricing {\n const card = this.config.pricing!.rateCards[cardKey];\n if (card.operations[operation]) return card.operations[operation];\n if (!card.extends)\n throw new ConfigError(`rate card '${cardKey}' has no price for operation '${operation}'`);\n return this.operationPricing(card.extends, operation);\n }\n\n private matches(rule: PriceRule, dimensions: Record<string, DimensionValue>): boolean {\n return Object.entries(rule.when).every(([name, matcher]) =>\n this.matchesOne(matcher, dimensions[name]),\n );\n }\n\n private matchesOne(matcher: DimensionMatcher, value: DimensionValue | undefined): boolean {\n if (value == null) return false;\n if (matcher.op === \"eq\") return this.scalarEquals(value, matcher.value);\n if (matcher.op === \"in\")\n return matcher.values.some((candidate) => this.scalarEquals(value, candidate));\n if (matcher.op === \"not_in\")\n return !matcher.values.some((candidate) => this.scalarEquals(value, candidate));\n if (matcher.op === \"prefix\")\n return typeof value === \"string\" && value.startsWith(matcher.value);\n if (matcher.op !== \"range\" || !(value instanceof Decimal)) return false;\n if (matcher.gt && !value.gt(matcher.gt)) return false;\n if (matcher.gte && !value.gte(matcher.gte)) return false;\n if (matcher.lt && !value.lt(matcher.lt)) return false;\n if (matcher.lte && !value.lte(matcher.lte)) return false;\n return true;\n }\n\n private scalarEquals(left: DimensionValue, right: string | Decimal | boolean): boolean {\n if (left instanceof Decimal || right instanceof Decimal) {\n try {\n return new Decimal(left as Decimal.Value).eq(new Decimal(right as Decimal.Value));\n } catch {\n return false;\n }\n }\n return left === right;\n }\n\n private evaluateCharge(charge: Charge, measures: Record<string, Decimal>): Decimal {\n if (charge.type === \"flat\") return charge.amount;\n if (charge.type === \"per_unit\")\n return measures[charge.measure].div(charge.unitSize).mul(charge.rate);\n if (charge.type === \"package\") {\n const packages = measures[charge.measure].div(charge.units);\n const rounded =\n charge.rounding === \"ceil\"\n ? packages.ceil()\n : charge.rounding === \"floor\"\n ? packages.floor()\n : packages.toDecimalPlaces(0, Decimal.ROUND_HALF_UP);\n return rounded.mul(charge.amount);\n }\n if (charge.type === \"graduated\") {\n let remaining = measures[charge.measure];\n let previous = new Decimal(0);\n let total = new Decimal(0);\n for (const tier of charge.tiers) {\n const units =\n tier.upTo == null ? remaining : Decimal.min(remaining, tier.upTo.sub(previous));\n if (units.isPositive()) {\n total = total.add(units.mul(tier.rate));\n remaining = remaining.sub(units);\n }\n if (!remaining.isPositive()) break;\n if (tier.upTo != null) previous = tier.upTo;\n }\n return total;\n }\n if (charge.type === \"volume\") {\n const value = measures[charge.measure];\n const tier = charge.tiers.find(\n (candidate) => candidate.upTo == null || value.lte(candidate.upTo),\n );\n return value.mul((tier ?? charge.tiers.at(-1)!).rate);\n }\n if (charge.type === \"expression\") return evaluateExpression(charge.formula, measures);\n if (charge.type === \"sum\")\n return Decimal.sum(\n ...charge.components.map((component) => this.evaluateCharge(component, measures)),\n );\n throw new ConfigError(`unsupported charge type '${String((charge as Charge).type)}'`);\n }\n}\n"]}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,55 +1,163 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Transport-neutral failure categories for SaaS application boundaries.
|
|
3
|
+
*
|
|
4
|
+
* The category is intentionally coarser than `code`: applications can use it
|
|
5
|
+
* for protocol behavior while retaining the stable code for product-specific
|
|
6
|
+
* copy and analytics.
|
|
7
|
+
*/
|
|
8
|
+
export type BursarErrorCategory = "invalid_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "rate_limited" | "unavailable" | "internal";
|
|
9
|
+
/** Structured, non-secret context that is safe to attach to an SDK error. */
|
|
10
|
+
export type BursarErrorDetails = Readonly<Record<string, unknown>>;
|
|
11
|
+
/** Options shared by all Bursar errors. */
|
|
12
|
+
export interface BursarErrorOptions extends ErrorOptions {
|
|
13
|
+
details?: BursarErrorDetails;
|
|
14
|
+
}
|
|
15
|
+
export interface StoreErrorOptions extends BursarErrorOptions {
|
|
16
|
+
indeterminate?: boolean;
|
|
17
|
+
retryable?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface SerializedBursarError {
|
|
20
|
+
name: string;
|
|
21
|
+
message: string;
|
|
22
|
+
code: string;
|
|
23
|
+
category: BursarErrorCategory;
|
|
24
|
+
retryable: boolean;
|
|
25
|
+
details?: BursarErrorDetails;
|
|
26
|
+
indeterminate?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Base error for all Bursar SDK failures. */
|
|
29
|
+
export declare class BursarError extends Error {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly code: string;
|
|
32
|
+
readonly category: BursarErrorCategory;
|
|
33
|
+
readonly retryable: boolean;
|
|
34
|
+
readonly details?: BursarErrorDetails;
|
|
35
|
+
constructor(message: string, options?: BursarErrorOptions);
|
|
36
|
+
/** A predictable representation for logs and protocol adapters. */
|
|
37
|
+
toJSON(): SerializedBursarError;
|
|
38
|
+
}
|
|
39
|
+
/** Base error for credit-domain admission and settlement failures. */
|
|
40
|
+
export declare class CreditError extends BursarError {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly code: string;
|
|
43
|
+
}
|
|
44
|
+
export declare class ConfigError extends BursarError {
|
|
45
|
+
readonly validationErrors: readonly unknown[];
|
|
2
46
|
readonly name = "ConfigError";
|
|
47
|
+
readonly code = "CONFIG_ERROR";
|
|
48
|
+
constructor(message: string, validationErrors?: readonly unknown[], options?: BursarErrorOptions);
|
|
3
49
|
}
|
|
4
|
-
export declare class ExpressionError extends
|
|
50
|
+
export declare class ExpressionError extends BursarError {
|
|
5
51
|
readonly name = "ExpressionError";
|
|
52
|
+
readonly code = "EXPRESSION_ERROR";
|
|
6
53
|
}
|
|
7
|
-
export declare class InsufficientCreditsError extends
|
|
54
|
+
export declare class InsufficientCreditsError extends CreditError {
|
|
8
55
|
readonly name = "InsufficientCreditsError";
|
|
56
|
+
readonly code = "INSUFFICIENT_CREDITS";
|
|
57
|
+
readonly category: "payment_required";
|
|
9
58
|
}
|
|
10
|
-
export declare class PricingNotLoadedError extends
|
|
59
|
+
export declare class PricingNotLoadedError extends CreditError {
|
|
11
60
|
readonly name = "PricingNotLoadedError";
|
|
61
|
+
readonly code = "PRICING_NOT_LOADED";
|
|
62
|
+
readonly category: "unavailable";
|
|
12
63
|
}
|
|
13
|
-
export declare class ImportError extends
|
|
64
|
+
export declare class ImportError extends BursarError {
|
|
14
65
|
readonly name = "ImportError";
|
|
66
|
+
readonly code = "BURSAR_IMPORT_ERROR";
|
|
67
|
+
readonly category: "unavailable";
|
|
15
68
|
}
|
|
16
|
-
export declare class StoreError extends
|
|
17
|
-
readonly name
|
|
69
|
+
export declare class StoreError extends BursarError {
|
|
70
|
+
readonly name: string;
|
|
71
|
+
readonly code: string;
|
|
72
|
+
readonly category: BursarErrorCategory;
|
|
73
|
+
readonly retryable: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Whether the operation may have committed even though no result was
|
|
76
|
+
* observed. Callers must reuse the same idempotency key before retrying an
|
|
77
|
+
* indeterminate mutation.
|
|
78
|
+
*/
|
|
79
|
+
readonly indeterminate: boolean;
|
|
80
|
+
constructor(message: string, options?: StoreErrorOptions);
|
|
81
|
+
toJSON(): SerializedBursarError;
|
|
18
82
|
}
|
|
19
|
-
|
|
20
|
-
|
|
83
|
+
/** A transient store/transport failure for which a bounded retry can help. */
|
|
84
|
+
export declare class StoreUnavailableError extends StoreError {
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly code: string;
|
|
87
|
+
readonly retryable = true;
|
|
21
88
|
}
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
readonly
|
|
89
|
+
/** A store operation exceeded its configured deadline. */
|
|
90
|
+
export declare class StoreTimeoutError extends StoreUnavailableError {
|
|
91
|
+
readonly name = "StoreTimeoutError";
|
|
92
|
+
readonly code = "STORE_TIMEOUT";
|
|
93
|
+
}
|
|
94
|
+
/** The application attempted to use a store after closing it. */
|
|
95
|
+
export declare class StoreClosedError extends StoreError {
|
|
96
|
+
readonly name = "StoreClosedError";
|
|
97
|
+
readonly code = "STORE_CLOSED";
|
|
98
|
+
readonly category: "conflict";
|
|
99
|
+
}
|
|
100
|
+
export declare class CapReachedError extends StoreError {
|
|
101
|
+
readonly name = "CapReachedError";
|
|
102
|
+
readonly code = "CAP_REACHED";
|
|
103
|
+
readonly category: "rate_limited";
|
|
104
|
+
readonly retryable = false;
|
|
31
105
|
}
|
|
32
|
-
export declare class RefundError extends
|
|
106
|
+
export declare class RefundError extends StoreError {
|
|
33
107
|
readonly name = "RefundError";
|
|
108
|
+
readonly code = "REFUND_REJECTED";
|
|
109
|
+
readonly category: "conflict";
|
|
110
|
+
readonly retryable = false;
|
|
34
111
|
}
|
|
35
|
-
export declare class ConcurrencyLimitError extends
|
|
112
|
+
export declare class ConcurrencyLimitError extends CreditError {
|
|
36
113
|
readonly name = "ConcurrencyLimitError";
|
|
114
|
+
readonly code = "CONCURRENCY_LIMIT_REACHED";
|
|
115
|
+
readonly category: "rate_limited";
|
|
37
116
|
}
|
|
38
|
-
export declare class FeatureNotEntitledError extends
|
|
117
|
+
export declare class FeatureNotEntitledError extends CreditError {
|
|
39
118
|
readonly name = "FeatureNotEntitledError";
|
|
119
|
+
readonly code = "FEATURE_NOT_ENTITLED";
|
|
120
|
+
readonly category: "forbidden";
|
|
40
121
|
}
|
|
41
|
-
export declare class
|
|
122
|
+
export declare class OperationNotAllowedError extends CreditError {
|
|
123
|
+
readonly name = "OperationNotAllowedError";
|
|
124
|
+
readonly code = "OPERATION_NOT_ALLOWED";
|
|
125
|
+
readonly category: "forbidden";
|
|
126
|
+
}
|
|
127
|
+
export declare class QuotaExceededError extends CreditError {
|
|
128
|
+
readonly name = "QuotaExceededError";
|
|
129
|
+
readonly code = "QUOTA_EXCEEDED";
|
|
130
|
+
readonly category: "rate_limited";
|
|
131
|
+
}
|
|
132
|
+
export declare class LeaseExpiredError extends CreditError {
|
|
42
133
|
readonly name = "LeaseExpiredError";
|
|
134
|
+
readonly code = "LEASE_EXPIRED";
|
|
135
|
+
readonly category: "conflict";
|
|
43
136
|
}
|
|
44
|
-
export declare class LeaseNotFoundError extends
|
|
137
|
+
export declare class LeaseNotFoundError extends CreditError {
|
|
45
138
|
readonly name = "LeaseNotFoundError";
|
|
139
|
+
readonly code = "LEASE_NOT_FOUND";
|
|
140
|
+
readonly category: "not_found";
|
|
46
141
|
}
|
|
47
142
|
/**
|
|
48
143
|
* Thrown by the default (concrete) implementation of an optional `CreditStore`
|
|
49
|
-
* capability (analytics,
|
|
144
|
+
* capability (analytics, ledger listing, teams — WS8) when a custom store
|
|
50
145
|
* subclass does not override it.
|
|
51
146
|
*/
|
|
52
|
-
export declare class CapabilityNotSupportedError extends
|
|
147
|
+
export declare class CapabilityNotSupportedError extends StoreError {
|
|
53
148
|
readonly name = "CapabilityNotSupportedError";
|
|
149
|
+
readonly code = "CAPABILITY_NOT_SUPPORTED";
|
|
150
|
+
readonly retryable = false;
|
|
54
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Cross-package-copy-safe check for an SDK error. `instanceof` alone fails
|
|
154
|
+
* when an application installs two copies of the package.
|
|
155
|
+
*/
|
|
156
|
+
export declare function isBursarError(error: unknown): error is BursarError;
|
|
157
|
+
/** Return whether retrying the failed Bursar operation can be useful. */
|
|
158
|
+
export declare function isRetryableBursarError(error: unknown): boolean;
|
|
159
|
+
/** Project a Bursar failure category to its conventional HTTP status. */
|
|
160
|
+
export declare function bursarErrorHttpStatus(error: BursarError): number;
|
|
161
|
+
/** Return safe default copy for exposing a Bursar failure to an end user. */
|
|
162
|
+
export declare function bursarErrorPublicMessage(error: BursarError): string;
|
|
55
163
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAkB,IAAI,iBAAiB;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAC3B,iBAAiB,GACjB,kBAA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