@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 @@
|
|
|
1
|
+
{"version":3,"file":"admission.js","sourceRoot":"","sources":["../../../src/credits/types/admission.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\nimport type { BillingMode } from \"./account.js\";\n\nexport interface LeaseResult {\n leaseId: string;\n userId: string;\n amount: Decimal;\n available: Decimal;\n reservedTotal: Decimal;\n minimumBalance: Decimal;\n billingMode: BillingMode;\n expiresAt: string;\n error?: string | null;\n}\n\n/** Immutable pricing references captured when an operation lease is admitted. */\nexport interface LeasePricingContext {\n catalogVersion: number;\n planId: string | null;\n planKey: string | null;\n rateCard: string | null;\n}\n\nexport interface ReleaseResult {\n leaseId: string;\n userId: string;\n released: boolean;\n reason?: string | null;\n}\n\nexport interface CanAffordResult {\n affordable: boolean;\n spendable: Decimal;\n worstCase: Decimal;\n reason?: string | null;\n}\n\nexport interface AvailableResult {\n userId: string;\n balance: Decimal;\n reserved: Decimal;\n available: Decimal;\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Decimal } from "decimal.js";
|
|
2
|
+
import type { ListUsageChargesOptions, UsageChargePage } from "./ledger.js";
|
|
3
|
+
/** Aggregated spend for a single user in a time window. */
|
|
4
|
+
export interface SpendByUserRow {
|
|
5
|
+
userId: string;
|
|
6
|
+
totalSpend: Decimal;
|
|
7
|
+
entryCount: number;
|
|
8
|
+
}
|
|
9
|
+
/** Aggregated spend for a single model in a time window. */
|
|
10
|
+
export interface SpendByModelRow {
|
|
11
|
+
model: string;
|
|
12
|
+
totalSpend: Decimal;
|
|
13
|
+
entryCount: number;
|
|
14
|
+
}
|
|
15
|
+
/** Top-spending user in a time window. */
|
|
16
|
+
export interface TopUserRow {
|
|
17
|
+
userId: string;
|
|
18
|
+
totalSpend: Decimal;
|
|
19
|
+
}
|
|
20
|
+
/** Daily spend aggregation in a time window. */
|
|
21
|
+
export interface DailySpendRow {
|
|
22
|
+
date: string;
|
|
23
|
+
totalSpend: Decimal;
|
|
24
|
+
entryCount: number;
|
|
25
|
+
}
|
|
26
|
+
/** Aggregate statistics across all users in a time window. */
|
|
27
|
+
export interface AggregateStats {
|
|
28
|
+
totalCreditsConsumed: Decimal;
|
|
29
|
+
activeUsers: number;
|
|
30
|
+
avgDailySpend: Decimal;
|
|
31
|
+
topModel: string;
|
|
32
|
+
topUser: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Read-only usage analytics backend.
|
|
36
|
+
*
|
|
37
|
+
* PostgreSQL implements this contract by default. High-volume deployments can
|
|
38
|
+
* provide a ClickHouse implementation without moving balances or compact
|
|
39
|
+
* accounting receipts out of PostgreSQL.
|
|
40
|
+
*/
|
|
41
|
+
export interface UsageAnalyticsStore {
|
|
42
|
+
spendByUser(start: Date, end: Date): Promise<SpendByUserRow[]>;
|
|
43
|
+
spendByModel(start: Date, end: Date): Promise<SpendByModelRow[]>;
|
|
44
|
+
topUsers(limit: number, start: Date, end: Date): Promise<TopUserRow[]>;
|
|
45
|
+
dailySpend(start: Date, end: Date): Promise<DailySpendRow[]>;
|
|
46
|
+
aggregateStats(start: Date, end: Date): Promise<AggregateStats>;
|
|
47
|
+
}
|
|
48
|
+
/** Read-only usage history backend selected with the analytics backend. */
|
|
49
|
+
export interface UsageChargeStore {
|
|
50
|
+
listUsageCharges(userId: string, options?: ListUsageChargesOptions): Promise<UsageChargePage>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../src/credits/types/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG5E,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,0CAA0C;AAC1C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,8DAA8D;AAC9D,MAAM,WAAW,cAAc;IAC7B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC/D,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACvE,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC7D,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACjE;AAED,2EAA2E;AAC3E,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../src/credits/types/analytics.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\nimport type { ListUsageChargesOptions, UsageChargePage } from \"./ledger.js\";\n\n// ── Usage analytics ─────────────────────────────────────────────────\n/** Aggregated spend for a single user in a time window. */\nexport interface SpendByUserRow {\n userId: string;\n totalSpend: Decimal;\n entryCount: number;\n}\n\n/** Aggregated spend for a single model in a time window. */\nexport interface SpendByModelRow {\n model: string;\n totalSpend: Decimal;\n entryCount: number;\n}\n\n/** Top-spending user in a time window. */\nexport interface TopUserRow {\n userId: string;\n totalSpend: Decimal;\n}\n\n/** Daily spend aggregation in a time window. */\nexport interface DailySpendRow {\n date: string;\n totalSpend: Decimal;\n entryCount: number;\n}\n\n/** Aggregate statistics across all users in a time window. */\nexport interface AggregateStats {\n totalCreditsConsumed: Decimal;\n activeUsers: number;\n avgDailySpend: Decimal;\n topModel: string;\n topUser: string;\n}\n\n/**\n * Read-only usage analytics backend.\n *\n * PostgreSQL implements this contract by default. High-volume deployments can\n * provide a ClickHouse implementation without moving balances or compact\n * accounting receipts out of PostgreSQL.\n */\nexport interface UsageAnalyticsStore {\n spendByUser(start: Date, end: Date): Promise<SpendByUserRow[]>;\n spendByModel(start: Date, end: Date): Promise<SpendByModelRow[]>;\n topUsers(limit: number, start: Date, end: Date): Promise<TopUserRow[]>;\n dailySpend(start: Date, end: Date): Promise<DailySpendRow[]>;\n aggregateStats(start: Date, end: Date): Promise<AggregateStats>;\n}\n\n/** Read-only usage history backend selected with the analytics backend. */\nexport interface UsageChargeStore {\n listUsageCharges(userId: string, options?: ListUsageChargesOptions): Promise<UsageChargePage>;\n}\n"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Decimal } from "decimal.js";
|
|
2
|
+
export interface BursarConfigResult {
|
|
3
|
+
id: string;
|
|
4
|
+
config: Record<string, unknown>;
|
|
5
|
+
version: number;
|
|
6
|
+
}
|
|
7
|
+
export interface BursarConfigHistoryItem {
|
|
8
|
+
id: string;
|
|
9
|
+
version: number;
|
|
10
|
+
label: string | null;
|
|
11
|
+
active: boolean;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
}
|
|
14
|
+
export interface PlanAllowancePolicy {
|
|
15
|
+
amount: Decimal | null;
|
|
16
|
+
/** Shared with bucket priorities; null means legacy allowance-first ordering. */
|
|
17
|
+
priority?: number | null;
|
|
18
|
+
resetUnit: string | null;
|
|
19
|
+
resetCount: number | null;
|
|
20
|
+
resetAnchor: string | null;
|
|
21
|
+
resetTimezone: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface PlanCreditPolicy {
|
|
24
|
+
type: "prepaid" | "credit_line";
|
|
25
|
+
creditLimit: Decimal | null;
|
|
26
|
+
}
|
|
27
|
+
export interface PlanAdmissionPolicy {
|
|
28
|
+
maxInFlight: number | null;
|
|
29
|
+
operations: Record<string, {
|
|
30
|
+
maxInFlight: number | null;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
export interface AllowanceResult {
|
|
34
|
+
planId: string;
|
|
35
|
+
allowanceRemaining: Decimal;
|
|
36
|
+
periodStart: string;
|
|
37
|
+
periodEnd: string;
|
|
38
|
+
}
|
|
39
|
+
export interface GetUserPlanResult {
|
|
40
|
+
userId: string;
|
|
41
|
+
planId: string | null;
|
|
42
|
+
planKey: string | null;
|
|
43
|
+
planLabel: string | null;
|
|
44
|
+
allowance: PlanAllowancePolicy | null;
|
|
45
|
+
entitlements: Record<string, {
|
|
46
|
+
value: unknown;
|
|
47
|
+
}>;
|
|
48
|
+
rateCard?: string | null;
|
|
49
|
+
creditPolicy: PlanCreditPolicy | null;
|
|
50
|
+
admission: PlanAdmissionPolicy | null;
|
|
51
|
+
allowedOperations: string[];
|
|
52
|
+
planAssignedAt?: Date | null;
|
|
53
|
+
assignmentSourceType?: string | null;
|
|
54
|
+
assignmentSourceId?: string | null;
|
|
55
|
+
catalogRevisionPinned: boolean;
|
|
56
|
+
catalogVersion?: number | null;
|
|
57
|
+
}
|
|
58
|
+
export interface SetUserPlanResult {
|
|
59
|
+
userId: string;
|
|
60
|
+
planId: string;
|
|
61
|
+
planAssignedAt?: string | null;
|
|
62
|
+
}
|
|
63
|
+
export interface PlanMigrationStartResult {
|
|
64
|
+
migrationId: string;
|
|
65
|
+
}
|
|
66
|
+
export interface PlanMigrationBatchResult {
|
|
67
|
+
migrated: number;
|
|
68
|
+
done: boolean;
|
|
69
|
+
nextCursor: string | null;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/credits/types/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,GAAG,aAAa,CAAC;IAChC,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACjD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,SAAS,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACtC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,cAAc,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/credits/types/catalog.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\nexport interface BursarConfigResult {\n id: string;\n config: Record<string, unknown>;\n version: number;\n}\n\nexport interface BursarConfigHistoryItem {\n id: string;\n version: number;\n label: string | null;\n active: boolean;\n createdAt: string;\n}\n\nexport interface PlanAllowancePolicy {\n amount: Decimal | null;\n /** Shared with bucket priorities; null means legacy allowance-first ordering. */\n priority?: number | null;\n resetUnit: string | null;\n resetCount: number | null;\n resetAnchor: string | null;\n resetTimezone: string | null;\n}\n\nexport interface PlanCreditPolicy {\n type: \"prepaid\" | \"credit_line\";\n creditLimit: Decimal | null;\n}\n\nexport interface PlanAdmissionPolicy {\n maxInFlight: number | null;\n operations: Record<string, { maxInFlight: number | null }>;\n}\n\nexport interface AllowanceResult {\n planId: string;\n allowanceRemaining: Decimal;\n periodStart: string;\n periodEnd: string;\n}\n\nexport interface GetUserPlanResult {\n userId: string;\n planId: string | null;\n planKey: string | null;\n planLabel: string | null;\n allowance: PlanAllowancePolicy | null;\n entitlements: Record<string, { value: unknown }>;\n rateCard?: string | null;\n creditPolicy: PlanCreditPolicy | null;\n admission: PlanAdmissionPolicy | null;\n allowedOperations: string[];\n planAssignedAt?: Date | null;\n assignmentSourceType?: string | null;\n assignmentSourceId?: string | null;\n catalogRevisionPinned: boolean;\n catalogVersion?: number | null;\n}\n\nexport interface SetUserPlanResult {\n userId: string;\n planId: string;\n planAssignedAt?: string | null;\n}\n\nexport interface PlanMigrationStartResult {\n migrationId: string;\n}\n\nexport interface PlanMigrationBatchResult {\n migrated: number;\n done: boolean;\n nextCursor: string | null;\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Decimal } from "decimal.js";
|
|
2
|
+
import type { CreditMetadata } from "./account.js";
|
|
3
|
+
export type GrantProgramTrigger = "account_created" | "referral_completed" | "promo_code_redeemed" | "manual";
|
|
4
|
+
/** One application event that may award one or more catalog grants. */
|
|
5
|
+
export interface ExecuteGrantProgramRequest {
|
|
6
|
+
trigger: GrantProgramTrigger;
|
|
7
|
+
programKey: string;
|
|
8
|
+
subjectId: string;
|
|
9
|
+
eventKey: string;
|
|
10
|
+
referrerSubjectId?: string | null;
|
|
11
|
+
region?: string | null;
|
|
12
|
+
metadata?: CreditMetadata | null;
|
|
13
|
+
}
|
|
14
|
+
/** One award row produced by a grant-program execution. */
|
|
15
|
+
export interface GrantProgramAwardResult {
|
|
16
|
+
grantEventId: string | null;
|
|
17
|
+
grantAwardId: string | null;
|
|
18
|
+
recipientSubjectId: string | null;
|
|
19
|
+
ledgerEntryId: string | null;
|
|
20
|
+
amount: Decimal;
|
|
21
|
+
replayed: boolean;
|
|
22
|
+
error?: string | null;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../../src/credits/types/grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAC7B,iBAAiB,GAAG,oBAAoB,GAAG,qBAAqB,GAAG,QAAQ,CAAC;AAE9E,uEAAuE;AACvE,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC;AAED,2DAA2D;AAC3D,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../../../src/credits/types/grants.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\nimport type { CreditMetadata } from \"./account.js\";\n\nexport type GrantProgramTrigger =\n \"account_created\" | \"referral_completed\" | \"promo_code_redeemed\" | \"manual\";\n\n/** One application event that may award one or more catalog grants. */\nexport interface ExecuteGrantProgramRequest {\n trigger: GrantProgramTrigger;\n programKey: string;\n subjectId: string;\n eventKey: string;\n referrerSubjectId?: string | null;\n region?: string | null;\n metadata?: CreditMetadata | null;\n}\n\n/** One award row produced by a grant-program execution. */\nexport interface GrantProgramAwardResult {\n grantEventId: string | null;\n grantAwardId: string | null;\n recipientSubjectId: string | null;\n ledgerEntryId: string | null;\n amount: Decimal;\n replayed: boolean;\n error?: string | null;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type * from "./account.js";
|
|
2
|
+
export type * from "./catalog.js";
|
|
3
|
+
export type * from "./admission.js";
|
|
4
|
+
export type * from "./quotas.js";
|
|
5
|
+
export type * from "./ledger.js";
|
|
6
|
+
export type * from "./analytics.js";
|
|
7
|
+
export type * from "./teams.js";
|
|
8
|
+
export type * from "./grants.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/credits/types/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/credits/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export type * from \"./account.js\";\nexport type * from \"./catalog.js\";\nexport type * from \"./admission.js\";\nexport type * from \"./quotas.js\";\nexport type * from \"./ledger.js\";\nexport type * from \"./analytics.js\";\nexport type * from \"./teams.js\";\nexport type * from \"./grants.js\";\n"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Decimal } from "decimal.js";
|
|
2
|
+
/** One immutable monetary entry on a canonical credit account. */
|
|
3
|
+
export interface LedgerEntry {
|
|
4
|
+
entryId: string;
|
|
5
|
+
accountId: string;
|
|
6
|
+
actorUserId: string | null;
|
|
7
|
+
amount: Decimal;
|
|
8
|
+
entryType: string;
|
|
9
|
+
operation: string;
|
|
10
|
+
referenceEntryId: string | null;
|
|
11
|
+
idempotencyKey: string | null;
|
|
12
|
+
metadata: Record<string, unknown> | null;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}
|
|
15
|
+
/** Stable position in an account ledger. */
|
|
16
|
+
export interface LedgerCursor {
|
|
17
|
+
createdAt: string;
|
|
18
|
+
entryId: string;
|
|
19
|
+
}
|
|
20
|
+
/** Cursor-only options for listing account ledger entries. */
|
|
21
|
+
export interface ListLedgerEntriesOptions {
|
|
22
|
+
entryTypes?: string[];
|
|
23
|
+
fromDate?: Date;
|
|
24
|
+
toDate?: Date;
|
|
25
|
+
limit?: number;
|
|
26
|
+
cursor?: LedgerCursor | null;
|
|
27
|
+
}
|
|
28
|
+
/** One stable cursor page. */
|
|
29
|
+
export interface LedgerPage {
|
|
30
|
+
items: LedgerEntry[];
|
|
31
|
+
nextCursor: LedgerCursor | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A metered usage charge from the usage charge journal.
|
|
35
|
+
*
|
|
36
|
+
* Usage charges are deliberately separate from ledger entries: included
|
|
37
|
+
* allowance consumption does not create a monetary ledger debit, but it is
|
|
38
|
+
* still a billable usage event that belongs in the usage history.
|
|
39
|
+
*/
|
|
40
|
+
export interface UsageCharge {
|
|
41
|
+
usageId: string;
|
|
42
|
+
accountId: string;
|
|
43
|
+
operation: string;
|
|
44
|
+
requested: Decimal;
|
|
45
|
+
charged: Decimal;
|
|
46
|
+
allowanceRequested: Decimal;
|
|
47
|
+
allowanceCovered: Decimal;
|
|
48
|
+
billingDisposition: "billable" | "record_only";
|
|
49
|
+
feature: string | null;
|
|
50
|
+
model: string | null;
|
|
51
|
+
region: string | null;
|
|
52
|
+
eventAt: string;
|
|
53
|
+
idempotencyKey: string;
|
|
54
|
+
metadata: Record<string, unknown> | null;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
}
|
|
57
|
+
export interface UsageChargeCursor {
|
|
58
|
+
eventAt: string;
|
|
59
|
+
usageId: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ListUsageChargesOptions {
|
|
62
|
+
fromDate?: Date;
|
|
63
|
+
toDate?: Date;
|
|
64
|
+
limit?: number;
|
|
65
|
+
cursor?: UsageChargeCursor | null;
|
|
66
|
+
includeRecordOnly?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface UsageChargePage {
|
|
69
|
+
items: UsageCharge[];
|
|
70
|
+
nextCursor: UsageChargeCursor | null;
|
|
71
|
+
}
|
|
72
|
+
/** Result of appending a usage event without creating another balance debit. */
|
|
73
|
+
export interface UsageRecordResult {
|
|
74
|
+
usageId: string;
|
|
75
|
+
userId: string;
|
|
76
|
+
requested: Decimal;
|
|
77
|
+
idempotent: boolean;
|
|
78
|
+
error?: string | null;
|
|
79
|
+
}
|
|
80
|
+
/** Cursor-only options for the usage-only ledger view. */
|
|
81
|
+
export interface ListUsageEntriesOptions {
|
|
82
|
+
fromDate?: Date;
|
|
83
|
+
toDate?: Date;
|
|
84
|
+
limit?: number;
|
|
85
|
+
cursor?: LedgerCursor | null;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../src/credits/types/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,kEAAkE;AAClE,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,8DAA8D;AAC9D,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC9B;AAED,8BAA8B;AAC9B,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,UAAU,EAAE,YAAY,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,UAAU,GAAG,aAAa,CAAC;IAC/C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAClC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACtC;AAED,gFAAgF;AAChF,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,0DAA0D;AAC1D,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/credits/types/ledger.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\n// ── Canonical ledger history ─────────────────────────────────────────\n\n/** One immutable monetary entry on a canonical credit account. */\nexport interface LedgerEntry {\n entryId: string;\n accountId: string;\n actorUserId: string | null;\n amount: Decimal;\n entryType: string;\n operation: string;\n referenceEntryId: string | null;\n idempotencyKey: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n}\n\n/** Stable position in an account ledger. */\nexport interface LedgerCursor {\n createdAt: string;\n entryId: string;\n}\n\n/** Cursor-only options for listing account ledger entries. */\nexport interface ListLedgerEntriesOptions {\n entryTypes?: string[];\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n cursor?: LedgerCursor | null;\n}\n\n/** One stable cursor page. */\nexport interface LedgerPage {\n items: LedgerEntry[];\n nextCursor: LedgerCursor | null;\n}\n\n/**\n * A metered usage charge from the usage charge journal.\n *\n * Usage charges are deliberately separate from ledger entries: included\n * allowance consumption does not create a monetary ledger debit, but it is\n * still a billable usage event that belongs in the usage history.\n */\nexport interface UsageCharge {\n usageId: string;\n accountId: string;\n operation: string;\n requested: Decimal;\n charged: Decimal;\n allowanceRequested: Decimal;\n allowanceCovered: Decimal;\n billingDisposition: \"billable\" | \"record_only\";\n feature: string | null;\n model: string | null;\n region: string | null;\n eventAt: string;\n idempotencyKey: string;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n}\n\nexport interface UsageChargeCursor {\n eventAt: string;\n usageId: string;\n}\n\nexport interface ListUsageChargesOptions {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n cursor?: UsageChargeCursor | null;\n includeRecordOnly?: boolean;\n}\n\nexport interface UsageChargePage {\n items: UsageCharge[];\n nextCursor: UsageChargeCursor | null;\n}\n\n/** Result of appending a usage event without creating another balance debit. */\nexport interface UsageRecordResult {\n usageId: string;\n userId: string;\n requested: Decimal;\n idempotent: boolean;\n error?: string | null;\n}\n\n/** Cursor-only options for the usage-only ledger view. */\nexport interface ListUsageEntriesOptions {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n cursor?: LedgerCursor | null;\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Decimal } from "decimal.js";
|
|
2
|
+
export interface CheckFeatureResult {
|
|
3
|
+
userId: string;
|
|
4
|
+
feature: string;
|
|
5
|
+
value: unknown;
|
|
6
|
+
hasFeature: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface QuotaState {
|
|
9
|
+
userId: string;
|
|
10
|
+
quotaKey: string;
|
|
11
|
+
operation: string;
|
|
12
|
+
measure: string;
|
|
13
|
+
limit: Decimal;
|
|
14
|
+
consumed: Decimal;
|
|
15
|
+
reserved: Decimal;
|
|
16
|
+
remaining: Decimal;
|
|
17
|
+
overage: Decimal;
|
|
18
|
+
enforcement: "block" | "allow";
|
|
19
|
+
windowStart: string;
|
|
20
|
+
windowEnd: string;
|
|
21
|
+
emitAtPercent: number[];
|
|
22
|
+
}
|
|
23
|
+
export interface QuotaEvent {
|
|
24
|
+
eventId: string;
|
|
25
|
+
quotaKey: string;
|
|
26
|
+
operation: string;
|
|
27
|
+
measure: string;
|
|
28
|
+
eventType: "threshold" | "blocked";
|
|
29
|
+
thresholdPercent: number | null;
|
|
30
|
+
idempotencyKey: string;
|
|
31
|
+
usageChargeId: string | null;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ListQuotaEventsOptions {
|
|
35
|
+
after?: Date | null;
|
|
36
|
+
afterId?: string | null;
|
|
37
|
+
limit?: number;
|
|
38
|
+
idempotencyKey?: string | null;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=quotas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotas.d.ts","sourceRoot":"","sources":["../../../src/credits/types/quotas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,WAAW,GAAG,SAAS,CAAC;IACnC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotas.js","sourceRoot":"","sources":["../../../src/credits/types/quotas.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\nexport interface CheckFeatureResult {\n userId: string;\n feature: string;\n value: unknown;\n hasFeature: boolean;\n}\n\nexport interface QuotaState {\n userId: string;\n quotaKey: string;\n operation: string;\n measure: string;\n limit: Decimal;\n consumed: Decimal;\n reserved: Decimal;\n remaining: Decimal;\n overage: Decimal;\n enforcement: \"block\" | \"allow\";\n windowStart: string;\n windowEnd: string;\n emitAtPercent: number[];\n}\n\nexport interface QuotaEvent {\n eventId: string;\n quotaKey: string;\n operation: string;\n measure: string;\n eventType: \"threshold\" | \"blocked\";\n thresholdPercent: number | null;\n idempotencyKey: string;\n usageChargeId: string | null;\n createdAt: string;\n}\n\nexport interface ListQuotaEventsOptions {\n after?: Date | null;\n afterId?: string | null;\n limit?: number;\n idempotencyKey?: string | null;\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Decimal } from "decimal.js";
|
|
2
|
+
/** A team with a shared credit balance pool. */
|
|
3
|
+
export interface Team {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
balance: Decimal;
|
|
7
|
+
memberCount: number;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
}
|
|
10
|
+
/** A member of a team, with optional spend cap. */
|
|
11
|
+
export interface TeamMember {
|
|
12
|
+
userId: string;
|
|
13
|
+
role: string;
|
|
14
|
+
spendCap?: Decimal | null;
|
|
15
|
+
totalSpent: Decimal;
|
|
16
|
+
}
|
|
17
|
+
/** Result of fetching team balance. */
|
|
18
|
+
export interface TeamBalanceResult {
|
|
19
|
+
teamId: string;
|
|
20
|
+
name: string;
|
|
21
|
+
balance: Decimal;
|
|
22
|
+
memberCount: number;
|
|
23
|
+
}
|
|
24
|
+
/** Result of creating a team. */
|
|
25
|
+
export interface CreateTeamResult {
|
|
26
|
+
teamId: string;
|
|
27
|
+
name: string;
|
|
28
|
+
}
|
|
29
|
+
/** Result of adding a team member. */
|
|
30
|
+
export interface AddTeamMemberResult {
|
|
31
|
+
teamId: string;
|
|
32
|
+
userId: string;
|
|
33
|
+
role: string;
|
|
34
|
+
}
|
|
35
|
+
/** Result of deducting credits from a team pool. */
|
|
36
|
+
export interface TeamDeductionResult {
|
|
37
|
+
entryId: string;
|
|
38
|
+
teamId: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
amount: Decimal;
|
|
41
|
+
teamBalanceAfter: Decimal;
|
|
42
|
+
error?: string | null;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=teams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams.d.ts","sourceRoot":"","sources":["../../../src/credits/types/teams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,gDAAgD;AAChD,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,mDAAmD;AACnD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,uCAAuC;AACvC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,iCAAiC;AACjC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams.js","sourceRoot":"","sources":["../../../src/credits/types/teams.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\n// ── Team/shared balance pools ─────────────────────────────────────────\n/** A team with a shared credit balance pool. */\nexport interface Team {\n id: string;\n name: string;\n balance: Decimal;\n memberCount: number;\n createdAt: string;\n}\n\n/** A member of a team, with optional spend cap. */\nexport interface TeamMember {\n userId: string;\n role: string;\n spendCap?: Decimal | null;\n totalSpent: Decimal;\n}\n\n/** Result of fetching team balance. */\nexport interface TeamBalanceResult {\n teamId: string;\n name: string;\n balance: Decimal;\n memberCount: number;\n}\n\n/** Result of creating a team. */\nexport interface CreateTeamResult {\n teamId: string;\n name: string;\n}\n\n/** Result of adding a team member. */\nexport interface AddTeamMemberResult {\n teamId: string;\n userId: string;\n role: string;\n}\n\n/** Result of deducting credits from a team pool. */\nexport interface TeamDeductionResult {\n entryId: string;\n teamId: string;\n userId: string;\n amount: Decimal;\n teamBalanceAfter: Decimal;\n error?: string | null;\n}\n"]}
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,44 +1,23 @@
|
|
|
1
|
-
import Decimal from "decimal.js";
|
|
2
|
-
import type { PricingConfig } from "./config.js";
|
|
3
1
|
import type { CostBreakdown } from "./breakdown.js";
|
|
2
|
+
import { type BursarConfigData, type ParsedBursarConfig } from "./config.js";
|
|
4
3
|
import type { UsageMetrics } from "./metrics.js";
|
|
5
|
-
import type { PricingConfigData } from "./types.js";
|
|
6
|
-
/**
|
|
7
|
-
* Credit calculation engine.
|
|
8
|
-
*
|
|
9
|
-
* Evaluates pricing expressions against usage metrics to produce cost
|
|
10
|
-
* breakdowns. All money values are exact `Decimal`s — never binary `number`.
|
|
11
|
-
*/
|
|
12
4
|
export declare class PricingEngine {
|
|
13
|
-
private config;
|
|
14
|
-
constructor(config:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
calculateBatch(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
resolveModel(modelVersion: string): string | null;
|
|
31
|
-
/**
|
|
32
|
-
* Get the fixed credit cost for a named batch job, as a `Decimal`.
|
|
33
|
-
* Returns `null` for an unknown job (L3 parity with Python). The amount is
|
|
34
|
-
* NOT truncated to an integer.
|
|
35
|
-
*/
|
|
36
|
-
getFixedCost(jobName: string): Decimal | null;
|
|
37
|
-
private buildVariables;
|
|
38
|
-
private calcModel;
|
|
39
|
-
private calcTools;
|
|
40
|
-
private calcSearch;
|
|
41
|
-
private calcCache;
|
|
42
|
-
private calcFixed;
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(config: ParsedBursarConfig);
|
|
7
|
+
static fromDict(data: BursarConfigData | Record<string, unknown>): PricingEngine;
|
|
8
|
+
get pricingSchema(): Record<string, unknown>;
|
|
9
|
+
calculate(metrics: UsageMetrics, options?: {
|
|
10
|
+
rateCard?: string;
|
|
11
|
+
} | Record<string, string> | null): CostBreakdown;
|
|
12
|
+
calculateBatch(metrics: UsageMetrics[], options?: {
|
|
13
|
+
rateCard?: string;
|
|
14
|
+
}): CostBreakdown[];
|
|
15
|
+
getRateCardForPlan(planId: string | null | undefined): string | undefined;
|
|
16
|
+
private resolveRateCard;
|
|
17
|
+
private operationPricing;
|
|
18
|
+
private matches;
|
|
19
|
+
private matchesOne;
|
|
20
|
+
private scalarEquals;
|
|
21
|
+
private evaluateCharge;
|
|
43
22
|
}
|
|
44
23
|
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAIL,KAAK,gBAAgB,EAGrB,KAAK,kBAAkB,EAExB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAMjD,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,kBAAkB;IAEvD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;IAIhF,IAAI,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE3C;IAED,SAAS,CACP,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAS,GAClE,aAAa;IAiFhB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,aAAa,EAAE;IAI7F,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS;IAKzE,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,cAAc;CA4CvB"}
|