@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/config.js
CHANGED
|
@@ -1,396 +1,160 @@
|
|
|
1
|
+
import Ajv2020, {} from "ajv/dist/2020.js";
|
|
2
|
+
import addFormats from "ajv-formats";
|
|
1
3
|
import Decimal from "decimal.js";
|
|
4
|
+
import schema from "./generated/pricing-config.schema.json" with { type: "json" };
|
|
2
5
|
import { ConfigError } from "./errors.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* exactly. Expressions may only reference these names (or allowed functions).
|
|
22
|
-
* Passed into `validateExpression` so typos like `inputtokens` fail at
|
|
23
|
-
* config-load, not at first runtime use (M5).
|
|
24
|
-
*/
|
|
25
|
-
export const KNOWN_VARIABLES = new Set([
|
|
26
|
-
"input_tokens",
|
|
27
|
-
"output_tokens",
|
|
28
|
-
"cache_read_tokens",
|
|
29
|
-
"cache_write_tokens",
|
|
30
|
-
"tool_calls",
|
|
31
|
-
"search_queries",
|
|
32
|
-
"search_results",
|
|
33
|
-
"web_search_calls",
|
|
34
|
-
"code_exec_calls",
|
|
35
|
-
]);
|
|
36
|
-
/** Known top-level config keys, checked after snake→camel normalisation. */
|
|
37
|
-
const TOP_LEVEL_KEYS = new Set([
|
|
38
|
-
"version",
|
|
39
|
-
"models",
|
|
40
|
-
"tools",
|
|
41
|
-
"search",
|
|
42
|
-
"cache",
|
|
43
|
-
"minBalance",
|
|
44
|
-
"signupBonus",
|
|
45
|
-
"fixed",
|
|
46
|
-
"plans",
|
|
47
|
-
"tiers",
|
|
48
|
-
]);
|
|
49
|
-
/** Known plan-definition keys (`billingMode` is the short-form alias for `defaultBillingMode`). */
|
|
50
|
-
const PLAN_KEYS = new Set([
|
|
51
|
-
"id",
|
|
52
|
-
"name",
|
|
53
|
-
"freeAllowance",
|
|
54
|
-
"rateOverrides",
|
|
55
|
-
"features",
|
|
56
|
-
"featureLimits",
|
|
57
|
-
"defaultBillingMode",
|
|
58
|
-
"billingMode",
|
|
59
|
-
"perOperation",
|
|
60
|
-
"maxConcurrent",
|
|
61
|
-
"overdraftFloor",
|
|
62
|
-
"allowancePeriod",
|
|
63
|
-
]);
|
|
64
|
-
/** Known `FeatureLimit` keys. */
|
|
65
|
-
const FEATURE_LIMIT_KEYS = new Set(["maxCalls", "period", "action"]);
|
|
66
|
-
/** Known `OperationPolicy` keys (entries of a plan's `perOperation` map). */
|
|
67
|
-
const OPERATION_POLICY_KEYS = new Set([
|
|
68
|
-
"billingMode",
|
|
69
|
-
"maxConcurrent",
|
|
70
|
-
"overdraftFloor",
|
|
71
|
-
]);
|
|
72
|
-
/** Known tier-definition keys. */
|
|
73
|
-
const TIER_KEYS = new Set([
|
|
74
|
-
"name",
|
|
75
|
-
"priority",
|
|
76
|
-
"expires",
|
|
77
|
-
"defaultTtlDays",
|
|
78
|
-
"allowOverdraft",
|
|
79
|
-
"isDefault",
|
|
80
|
-
]);
|
|
81
|
-
/** Reject any key not in `known` — catches typos (`min_balnce`) that would otherwise silently fall back to a default. */
|
|
82
|
-
function assertKnownKeys(obj, known, context) {
|
|
83
|
-
for (const key of Object.keys(obj)) {
|
|
84
|
-
if (!known.has(key)) {
|
|
85
|
-
throw new ConfigError(`unknown config key in ${context}: ${key}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
6
|
+
import { parseAdmission, parseEntitlements } from "./config/parse-access.js";
|
|
7
|
+
import { parseCommerce } from "./config/parse-commerce.js";
|
|
8
|
+
import { parseCredits } from "./config/parse-credits.js";
|
|
9
|
+
import { parsePlans } from "./config/parse-plans.js";
|
|
10
|
+
import { parsePricing } from "./config/parse-pricing.js";
|
|
11
|
+
import { asObject, identifier, semanticError } from "./config/parse-utils.js";
|
|
12
|
+
const ajv = new Ajv2020({
|
|
13
|
+
allErrors: true,
|
|
14
|
+
strict: false,
|
|
15
|
+
});
|
|
16
|
+
addFormats(ajv, { mode: "full" });
|
|
17
|
+
const validateStructure = ajv.compile(schema);
|
|
18
|
+
function formatAjvErrors(errors) {
|
|
19
|
+
if (!errors?.length)
|
|
20
|
+
return "configuration does not match the Bursar schema";
|
|
21
|
+
return errors
|
|
22
|
+
.map((error) => `${error.instancePath || "$"} ${error.message ?? error.keyword}`)
|
|
23
|
+
.join("; ");
|
|
88
24
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
catch (e) {
|
|
105
|
-
throw new ConfigError(`invalid expression in tools.${key}: ${e.message}`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (raw.search) {
|
|
109
|
-
try {
|
|
110
|
-
validateExpression(raw.search, KNOWN_VARIABLES);
|
|
111
|
-
}
|
|
112
|
-
catch (e) {
|
|
113
|
-
throw new ConfigError(`invalid expression in search: ${e.message}`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (raw.cache) {
|
|
117
|
-
try {
|
|
118
|
-
validateExpression(raw.cache, KNOWN_VARIABLES);
|
|
119
|
-
}
|
|
120
|
-
catch (e) {
|
|
121
|
-
throw new ConfigError(`invalid expression in cache: ${e.message}`);
|
|
25
|
+
export function loadConfigFromDict(data) {
|
|
26
|
+
if (!validateStructure(data)) {
|
|
27
|
+
throw new ConfigError(formatAjvErrors(validateStructure.errors), validateStructure.errors ?? []);
|
|
28
|
+
}
|
|
29
|
+
const raw = data;
|
|
30
|
+
const pricing = raw.pricing == null ? undefined : parsePricing(raw.pricing);
|
|
31
|
+
const credits = parseCredits(raw.credits);
|
|
32
|
+
const entitlements = parseEntitlements(raw.entitlements);
|
|
33
|
+
const admission = parseAdmission(raw.admission);
|
|
34
|
+
if (pricing != null) {
|
|
35
|
+
for (const [policyKey, policy] of Object.entries(admission.policies)) {
|
|
36
|
+
const unknown = Object.keys(policy.operations).filter((operation) => !pricing.operations[operation]);
|
|
37
|
+
if (unknown.length) {
|
|
38
|
+
semanticError(`admission policy '${policyKey}' references unknown operations ${unknown.join(", ")}`);
|
|
39
|
+
}
|
|
122
40
|
}
|
|
123
41
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
42
|
+
const commerce = parseCommerce(raw.commerce, credits);
|
|
43
|
+
const subscriptionPlans = new Set(Object.values(commerce.offers)
|
|
44
|
+
.filter((offer) => offer.type === "subscription")
|
|
45
|
+
.map((offer) => offer.plan));
|
|
46
|
+
const plans = parsePlans(raw.plans, pricing, credits, entitlements, admission, subscriptionPlans);
|
|
47
|
+
for (const [offerKey, offer] of Object.entries(commerce.offers)) {
|
|
48
|
+
if (offer.type === "subscription" && !plans[offer.plan]) {
|
|
49
|
+
semanticError(`commerce.offers.${offerKey}.plan references unknown plan '${offer.plan}'`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for (const [programKey, program] of Object.entries(credits.grantPrograms)) {
|
|
53
|
+
const unknown = program.eligibility.plans.filter((plan) => !plans[plan]);
|
|
54
|
+
if (unknown.length) {
|
|
55
|
+
semanticError(`grant program '${programKey}' references unknown plans ${unknown.join(", ")}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const catalogRaw = asObject(raw.catalog ?? {});
|
|
59
|
+
const defaultPlan = catalogRaw.default_plan == null ? undefined : String(catalogRaw.default_plan);
|
|
60
|
+
if (defaultPlan != null && !plans[defaultPlan]) {
|
|
61
|
+
semanticError(`catalog.default_plan references unknown plan '${defaultPlan}'`);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
version: 1,
|
|
65
|
+
catalog: {
|
|
66
|
+
...(defaultPlan == null ? {} : { defaultPlan }),
|
|
67
|
+
},
|
|
68
|
+
...(pricing == null ? {} : { pricing }),
|
|
69
|
+
credits,
|
|
70
|
+
entitlements,
|
|
71
|
+
admission,
|
|
72
|
+
plans,
|
|
73
|
+
commerce,
|
|
149
74
|
};
|
|
150
|
-
const out = {};
|
|
151
|
-
for (const [k, v] of Object.entries(data)) {
|
|
152
|
-
const mapped = keyMap[k] ?? k;
|
|
153
|
-
out[mapped] = v;
|
|
154
|
-
}
|
|
155
|
-
return out;
|
|
156
75
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
76
|
+
function toSnakeCase(value) {
|
|
77
|
+
if (value instanceof Decimal)
|
|
78
|
+
return value.toFixed(6);
|
|
79
|
+
if (Array.isArray(value))
|
|
80
|
+
return value.map(toSnakeCase);
|
|
81
|
+
if (typeof value !== "object" || value === null)
|
|
82
|
+
return value;
|
|
83
|
+
return Object.fromEntries(Object.entries(value)
|
|
84
|
+
.filter(([, child]) => child !== undefined)
|
|
85
|
+
.map(([key, child]) => [
|
|
86
|
+
key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`),
|
|
87
|
+
toSnakeCase(child),
|
|
88
|
+
]));
|
|
160
89
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return normaliseKeys(t);
|
|
90
|
+
export function canonicalBursarConfigDict(data) {
|
|
91
|
+
return toSnakeCase(loadConfigFromDict(data));
|
|
164
92
|
}
|
|
165
|
-
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
* handling). Each entry's own keys are snake/camel-normalised (`max_calls`
|
|
169
|
-
* -> `maxCalls`) since, unlike top-level plan fields, these nested objects
|
|
170
|
-
* are not otherwise touched by `normaliseKeys`.
|
|
171
|
-
*/
|
|
172
|
-
function normaliseFeatureLimits(planKey, raw) {
|
|
173
|
-
const out = {};
|
|
174
|
-
for (const [featureKey, rawLimit] of Object.entries(raw)) {
|
|
175
|
-
const limit = normaliseKeys((rawLimit ?? {}));
|
|
176
|
-
assertKnownKeys(limit, FEATURE_LIMIT_KEYS, `plans.${planKey}.featureLimits.${featureKey}`);
|
|
177
|
-
const maxCalls = Number(limit.maxCalls ?? 0);
|
|
178
|
-
const period = limit.period ?? "monthly";
|
|
179
|
-
const action = limit.action ?? "deny";
|
|
180
|
-
if (!Number.isFinite(maxCalls) || maxCalls < 0) {
|
|
181
|
-
throw new ConfigError(`invalid featureLimits in plans.${planKey}.${featureKey}: maxCalls must be >= 0, got ${String(limit.maxCalls)}`);
|
|
182
|
-
}
|
|
183
|
-
if (!FEATURE_LIMIT_PERIODS.has(period)) {
|
|
184
|
-
throw new ConfigError(`invalid featureLimits in plans.${planKey}.${featureKey}: unknown period '${period}' ` +
|
|
185
|
-
`(expected one of ${[...FEATURE_LIMIT_PERIODS].sort().join(", ")})`);
|
|
186
|
-
}
|
|
187
|
-
if (!FEATURE_LIMIT_ACTIONS.has(action)) {
|
|
188
|
-
throw new ConfigError(`invalid featureLimits in plans.${planKey}.${featureKey}: unknown action '${action}' ` +
|
|
189
|
-
`(expected one of ${[...FEATURE_LIMIT_ACTIONS].sort().join(", ")})`);
|
|
190
|
-
}
|
|
191
|
-
out[featureKey] = {
|
|
192
|
-
maxCalls,
|
|
193
|
-
period: period,
|
|
194
|
-
action: action,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
return out;
|
|
93
|
+
/** Serialize an already parsed configuration without re-validating camelCase fields as raw input. */
|
|
94
|
+
export function canonicalParsedBursarConfigDict(data) {
|
|
95
|
+
return toSnakeCase(data);
|
|
198
96
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const out = {};
|
|
208
|
-
for (const [opType, rawPolicy] of Object.entries(raw)) {
|
|
209
|
-
const policy = normaliseKeys((rawPolicy ?? {}));
|
|
210
|
-
assertKnownKeys(policy, OPERATION_POLICY_KEYS, `plans.${planKey}.perOperation.${opType}`);
|
|
211
|
-
const billingMode = policy.billingMode ?? "strict";
|
|
212
|
-
if (billingMode !== "strict" && billingMode !== "overdraft") {
|
|
213
|
-
throw new ConfigError(`invalid billingMode in plans.${planKey}.perOperation.${opType}: '${billingMode}' ` +
|
|
214
|
-
`(expected 'strict' or 'overdraft')`);
|
|
215
|
-
}
|
|
216
|
-
out[opType] = {
|
|
217
|
-
billingMode: billingMode,
|
|
218
|
-
maxConcurrent: policy.maxConcurrent ?? null,
|
|
219
|
-
overdraftFloor: policy.overdraftFloor != null ? new Decimal(policy.overdraftFloor) : null,
|
|
220
|
-
};
|
|
97
|
+
const ROLLOUT_STRATEGIES = new Set([
|
|
98
|
+
"immediate",
|
|
99
|
+
"next_renewal",
|
|
100
|
+
"new_assignments_only",
|
|
101
|
+
]);
|
|
102
|
+
function requirePlainObject(value, path) {
|
|
103
|
+
if (value == null || Array.isArray(value) || typeof value !== "object") {
|
|
104
|
+
throw new ConfigError(`${path} must be an object`);
|
|
221
105
|
}
|
|
222
|
-
return
|
|
106
|
+
return value;
|
|
223
107
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
assertKnownKeys(d, TOP_LEVEL_KEYS, "config");
|
|
229
|
-
// Only `1` is a valid version (mirrors Python's `Literal[1]`); JS previously
|
|
230
|
-
// never inspected this field at all.
|
|
231
|
-
if (d.version !== undefined && d.version !== 1) {
|
|
232
|
-
throw new ConfigError(`version must be 1, got ${JSON.stringify(d.version)}`);
|
|
233
|
-
}
|
|
234
|
-
if (d.models == null)
|
|
235
|
-
throw new ConfigError("missing required section: models");
|
|
236
|
-
if (typeof d.models !== "object" || Object.keys(d.models).length === 0) {
|
|
237
|
-
throw new ConfigError("models must be a non-empty dict");
|
|
238
|
-
}
|
|
239
|
-
// Validate plan rate overrides and duplicate names
|
|
240
|
-
const rawPlans = d.plans;
|
|
241
|
-
// Normalise each plan's keys too (free_allowance etc.)
|
|
242
|
-
const plans = rawPlans
|
|
243
|
-
? Object.fromEntries(Object.entries(rawPlans).map(([k, v]) => [k, normalisePlan(v)]))
|
|
244
|
-
: undefined;
|
|
245
|
-
if (plans) {
|
|
246
|
-
for (const [planKey, plan] of Object.entries(plans)) {
|
|
247
|
-
assertKnownKeys(plan, PLAN_KEYS, `plans.${planKey}`);
|
|
248
|
-
// A plan definition must carry a `name` (mirrors Python's `config.py:62`);
|
|
249
|
-
// JS previously left this unchecked and silently produced `undefined`.
|
|
250
|
-
if (plan.name == null) {
|
|
251
|
-
throw new ConfigError(`plan definition is missing required 'name' field: plans.${planKey}`);
|
|
252
|
-
}
|
|
253
|
-
const overrides = plan.rateOverrides;
|
|
254
|
-
if (overrides) {
|
|
255
|
-
for (const [modelKey, expr] of Object.entries(overrides)) {
|
|
256
|
-
try {
|
|
257
|
-
validateExpression(expr, KNOWN_VARIABLES);
|
|
258
|
-
}
|
|
259
|
-
catch (e) {
|
|
260
|
-
throw new ConfigError(`invalid expression in plans.${planKey}.rateOverrides.${modelKey}: ${e.message}`);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
// WS9b: allowancePeriod must be one of the three valid strings if present.
|
|
265
|
-
if (plan.allowancePeriod != null && !ALLOWANCE_PERIODS.has(plan.allowancePeriod)) {
|
|
266
|
-
throw new ConfigError(`invalid allowancePeriod in plans.${planKey}: ${String(plan.allowancePeriod)} ` +
|
|
267
|
-
`(expected one of ${[...ALLOWANCE_PERIODS].sort().join(", ")})`);
|
|
268
|
-
}
|
|
269
|
-
// Per-feature invocation-count limits: normalise nested keys + validate.
|
|
270
|
-
if (plan.featureLimits != null) {
|
|
271
|
-
if (typeof plan.featureLimits !== "object" || Array.isArray(plan.featureLimits)) {
|
|
272
|
-
throw new ConfigError(`plans.${planKey}.featureLimits must be a dict`);
|
|
273
|
-
}
|
|
274
|
-
plan.featureLimits = normaliseFeatureLimits(planKey, plan.featureLimits);
|
|
275
|
-
}
|
|
276
|
-
// Per-operation financial-safety policy overrides: validate shape here;
|
|
277
|
-
// normalised into `OperationPolicy` objects when `planDefs` is built below.
|
|
278
|
-
if (plan.perOperation != null) {
|
|
279
|
-
if (typeof plan.perOperation !== "object" || Array.isArray(plan.perOperation)) {
|
|
280
|
-
throw new ConfigError(`plans.${planKey}.perOperation must be a dict`);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
const planNames = Object.values(plans).map((p) => p.name);
|
|
285
|
-
if (new Set(planNames).size !== planNames.length) {
|
|
286
|
-
throw new ConfigError("duplicate plan names in pricing config");
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
// Credit tiers (sibling to `plans`): validate + normalise. An explicit empty
|
|
290
|
-
// `tiers: {}` is a config error (ambiguous intent — omit the key entirely
|
|
291
|
-
// for "no tiers"), mirroring the Python `config.py` validator exactly.
|
|
292
|
-
if (d.tiers !== undefined && d.tiers !== null) {
|
|
293
|
-
if (typeof d.tiers !== "object" || Array.isArray(d.tiers)) {
|
|
294
|
-
throw new ConfigError("tiers must be a dict of tier definitions");
|
|
295
|
-
}
|
|
296
|
-
if (Object.keys(d.tiers).length === 0) {
|
|
297
|
-
throw new ConfigError("tiers must not be an empty object; omit the `tiers` key entirely for no tiers");
|
|
298
|
-
}
|
|
108
|
+
function rejectUnknownKeys(value, allowed, path) {
|
|
109
|
+
const unknown = Object.keys(value).filter((key) => !allowed.includes(key));
|
|
110
|
+
if (unknown.length > 0) {
|
|
111
|
+
throw new ConfigError(`${path} contains unknown field '${unknown[0]}'`);
|
|
299
112
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
models: d.models,
|
|
326
|
-
// Only default `tools` when the key is entirely absent (mirrors Python's
|
|
327
|
-
// pydantic `default_factory`); a user-supplied `tools` map — even one
|
|
328
|
-
// without `_default` — is used as-is. `PricingEngine.calcTools` already
|
|
329
|
-
// falls back to `"tool_calls * 0"` at evaluation time when `_default` is
|
|
330
|
-
// missing, so behavior is unaffected either way.
|
|
331
|
-
tools: d.tools ?? { _default: "tool_calls * 0" },
|
|
332
|
-
search: d.search ?? null,
|
|
333
|
-
cache: d.cache ?? null,
|
|
334
|
-
// Money fields: Decimal, never a binary `number` (contract §1).
|
|
335
|
-
minBalance: new Decimal(d.minBalance ?? 0),
|
|
336
|
-
signupBonus: d.signupBonus,
|
|
337
|
-
fixed: Object.fromEntries(Object.entries(d.fixed ?? {}).map(([job, cost]) => [job, new Decimal(cost)])),
|
|
338
|
-
};
|
|
339
|
-
if (config.minBalance.isNegative())
|
|
340
|
-
throw new ConfigError("min_balance must be >= 0");
|
|
341
|
-
if (config.signupBonus != null && config.signupBonus < 0) {
|
|
342
|
-
throw new ConfigError(`signup_bonus must be >= 0, got ${config.signupBonus}`);
|
|
343
|
-
}
|
|
344
|
-
// WS3: fixed job costs may be fractional (Decimal-compatible) — only non-negative
|
|
345
|
-
// is enforced. Was: Number.isInteger check (contradicted docs).
|
|
346
|
-
for (const [job, cost] of Object.entries(config.fixed)) {
|
|
347
|
-
if (cost.isNegative()) {
|
|
348
|
-
throw new ConfigError(`fixed.${job} must be non-negative, got ${cost.toString()}`);
|
|
349
|
-
}
|
|
113
|
+
}
|
|
114
|
+
/** Parse a one-release catalog rollout manifest. */
|
|
115
|
+
export function loadCatalogRollout(data = {}) {
|
|
116
|
+
const raw = requirePlainObject(data, "rollout");
|
|
117
|
+
rejectUnknownKeys(raw, ["plans"], "rollout");
|
|
118
|
+
const plansRaw = raw.plans == null ? {} : requirePlainObject(raw.plans, "rollout.plans");
|
|
119
|
+
const plans = {};
|
|
120
|
+
for (const [planKey, value] of Object.entries(plansRaw)) {
|
|
121
|
+
identifier(planKey, `rollout.plans.${planKey}`);
|
|
122
|
+
const plan = requirePlainObject(value, `rollout.plans.${planKey}`);
|
|
123
|
+
rejectUnknownKeys(plan, ["effective", "include_pinned", "includePinned"], `rollout.plans.${planKey}`);
|
|
124
|
+
if (!ROLLOUT_STRATEGIES.has(plan.effective)) {
|
|
125
|
+
throw new ConfigError(`rollout.plans.${planKey}.effective must be immediate, next_renewal, or new_assignments_only`);
|
|
126
|
+
}
|
|
127
|
+
if (plan.include_pinned != null && plan.includePinned != null) {
|
|
128
|
+
throw new ConfigError(`rollout.plans.${planKey} must not set both include_pinned and includePinned`);
|
|
129
|
+
}
|
|
130
|
+
const includePinned = plan.include_pinned ?? plan.includePinned;
|
|
131
|
+
if (includePinned != null && typeof includePinned !== "boolean") {
|
|
132
|
+
throw new ConfigError(`rollout.plans.${planKey}.include_pinned must be boolean`);
|
|
133
|
+
}
|
|
134
|
+
plans[planKey] = {
|
|
135
|
+
effective: plan.effective,
|
|
136
|
+
includePinned: includePinned === true,
|
|
137
|
+
};
|
|
350
138
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
defaultBillingMode: (p.defaultBillingMode ?? p.billingMode) ?? "strict",
|
|
366
|
-
overdraftFloor: p.overdraftFloor != null ? new Decimal(p.overdraftFloor) : null,
|
|
367
|
-
maxConcurrent: p.maxConcurrent ?? null,
|
|
368
|
-
allowancePeriod: (p.allowancePeriod ?? "calendar_month"),
|
|
369
|
-
// Was silently dropped: `PlanDefinition.perOperation` was declared in
|
|
370
|
-
// types.ts but never populated here, so per-operation billing policy
|
|
371
|
-
// from config was ignored by the JS SDK.
|
|
372
|
-
perOperation: p.perOperation != null
|
|
373
|
-
? normalisePerOperation(key, p.perOperation)
|
|
374
|
-
: undefined,
|
|
375
|
-
};
|
|
139
|
+
return { plans };
|
|
140
|
+
}
|
|
141
|
+
/** Serialize a rollout manifest for the catalog activation RPC. */
|
|
142
|
+
export function canonicalCatalogRolloutDict(data = {}) {
|
|
143
|
+
return toSnakeCase(loadCatalogRollout(data));
|
|
144
|
+
}
|
|
145
|
+
/** Validate rollout references and renewal timing against its target catalog. */
|
|
146
|
+
export function validateCatalogRollout(config, rollout) {
|
|
147
|
+
const subscriptionPlans = new Set(Object.values(config.commerce.offers)
|
|
148
|
+
.filter((offer) => offer.type === "subscription")
|
|
149
|
+
.map((offer) => offer.plan));
|
|
150
|
+
for (const [planKey, policy] of Object.entries(rollout.plans)) {
|
|
151
|
+
if (!config.plans[planKey]) {
|
|
152
|
+
throw new ConfigError(`rollout.plans references unknown plan '${planKey}'`);
|
|
376
153
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
if (tiers) {
|
|
380
|
-
const tierDefs = {};
|
|
381
|
-
for (const [key, t] of Object.entries(tiers)) {
|
|
382
|
-
tierDefs[key] = {
|
|
383
|
-
name: t.name ?? key,
|
|
384
|
-
priority: Number(t.priority ?? 0),
|
|
385
|
-
expires: Boolean(t.expires ?? false),
|
|
386
|
-
defaultTtlDays: t.defaultTtlDays != null ? Number(t.defaultTtlDays) : null,
|
|
387
|
-
allowOverdraft: Boolean(t.allowOverdraft ?? false),
|
|
388
|
-
isDefault: Boolean(t.isDefault ?? false),
|
|
389
|
-
};
|
|
154
|
+
if (policy.effective === "next_renewal" && !subscriptionPlans.has(planKey)) {
|
|
155
|
+
throw new ConfigError(`rollout.plans.${planKey}.effective=next_renewal requires a subscription offer`);
|
|
390
156
|
}
|
|
391
|
-
config.tiers = tierDefs;
|
|
392
157
|
}
|
|
393
|
-
|
|
394
|
-
return config;
|
|
158
|
+
return rollout;
|
|
395
159
|
}
|
|
396
160
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAI/C,6CAA6C;AAC7C,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IACrD,gBAAgB;IAChB,aAAa;IACb,aAAa;CACd,CAAC,CAAC;AAEH,uFAAuF;AACvF,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC;IACzD,OAAO;IACP,QAAQ;IACR,SAAS;IACT,QAAQ;CACT,CAAC,CAAC;AAEH,sEAAsE;AACtE,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEvF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IAC1D,cAAc;IACd,eAAe;IACf,mBAAmB;IACnB,oBAAoB;IACpB,YAAY;IACZ,gBAAgB;IAChB,gBAAgB;IAChB,kBAAkB;IAClB,iBAAiB;CAClB,CAAC,CAAC;AAgBH,4EAA4E;AAC5E,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IAClD,SAAS;IACT,QAAQ;IACR,O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C9E,CAAC;QACD,IAAI,MAAM,CAAC,SAAS,KAAK,cAAc,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3E,MAAM,IAAI,WAAW,CACnB,iBAAiB,OAAO,uDAAuD,CAChF,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import Ajv2020, { type ErrorObject } from \"ajv/dist/2020.js\";\nimport addFormats from \"ajv-formats\";\nimport Decimal from \"decimal.js\";\n\nimport schema from \"./generated/pricing-config.schema.json\" with { type: \"json\" };\nimport { ConfigError } from \"./errors.js\";\nimport { parseAdmission, parseEntitlements } from \"./config/parse-access.js\";\nimport { parseCommerce } from \"./config/parse-commerce.js\";\nimport { parseCredits } from \"./config/parse-credits.js\";\nimport { parsePlans } from \"./config/parse-plans.js\";\nimport { parsePricing } from \"./config/parse-pricing.js\";\nimport { asObject, identifier, semanticError, type JsonObject } from \"./config/parse-utils.js\";\nimport type {\n BursarConfigData,\n CatalogRollout,\n ParsedBursarConfig,\n PlanRolloutStrategy,\n SubscriptionOffer,\n} from \"./config/types.js\";\n\nexport type * from \"./config/types.js\";\n\nconst ajv = new Ajv2020({\n allErrors: true,\n strict: false,\n});\naddFormats(ajv, { mode: \"full\" });\nconst validateStructure = ajv.compile(schema);\n\nfunction formatAjvErrors(errors: ErrorObject[] | null | undefined): string {\n if (!errors?.length) return \"configuration does not match the Bursar schema\";\n return errors\n .map((error) => `${error.instancePath || \"$\"} ${error.message ?? error.keyword}`)\n .join(\"; \");\n}\n\nexport function loadConfigFromDict(\n data: BursarConfigData | Record<string, unknown>,\n): ParsedBursarConfig {\n if (!validateStructure(data)) {\n throw new ConfigError(\n formatAjvErrors(validateStructure.errors),\n validateStructure.errors ?? [],\n );\n }\n\n const raw = data as JsonObject;\n const pricing = raw.pricing == null ? undefined : parsePricing(raw.pricing);\n const credits = parseCredits(raw.credits);\n const entitlements = parseEntitlements(raw.entitlements);\n const admission = parseAdmission(raw.admission);\n\n if (pricing != null) {\n for (const [policyKey, policy] of Object.entries(admission.policies)) {\n const unknown = Object.keys(policy.operations).filter(\n (operation) => !pricing.operations[operation],\n );\n if (unknown.length) {\n semanticError(\n `admission policy '${policyKey}' references unknown operations ${unknown.join(\", \")}`,\n );\n }\n }\n }\n\n const commerce = parseCommerce(raw.commerce, credits);\n const subscriptionPlans = new Set(\n Object.values(commerce.offers)\n .filter((offer): offer is SubscriptionOffer => offer.type === \"subscription\")\n .map((offer) => offer.plan),\n );\n const plans = parsePlans(raw.plans, pricing, credits, entitlements, admission, subscriptionPlans);\n\n for (const [offerKey, offer] of Object.entries(commerce.offers)) {\n if (offer.type === \"subscription\" && !plans[offer.plan]) {\n semanticError(`commerce.offers.${offerKey}.plan references unknown plan '${offer.plan}'`);\n }\n }\n for (const [programKey, program] of Object.entries(credits.grantPrograms)) {\n const unknown = program.eligibility.plans.filter((plan) => !plans[plan]);\n if (unknown.length) {\n semanticError(`grant program '${programKey}' references unknown plans ${unknown.join(\", \")}`);\n }\n }\n\n const catalogRaw = asObject(raw.catalog ?? {});\n const defaultPlan = catalogRaw.default_plan == null ? undefined : String(catalogRaw.default_plan);\n if (defaultPlan != null && !plans[defaultPlan]) {\n semanticError(`catalog.default_plan references unknown plan '${defaultPlan}'`);\n }\n return {\n version: 1,\n catalog: {\n ...(defaultPlan == null ? {} : { defaultPlan }),\n },\n ...(pricing == null ? {} : { pricing }),\n credits,\n entitlements,\n admission,\n plans,\n commerce,\n };\n}\n\nfunction toSnakeCase(value: unknown): unknown {\n if (value instanceof Decimal) return value.toFixed(6);\n if (Array.isArray(value)) return value.map(toSnakeCase);\n if (typeof value !== \"object\" || value === null) return value;\n return Object.fromEntries(\n Object.entries(value as JsonObject)\n .filter(([, child]) => child !== undefined)\n .map(([key, child]) => [\n key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`),\n toSnakeCase(child),\n ]),\n );\n}\n\nexport function canonicalBursarConfigDict(\n data: BursarConfigData | Record<string, unknown>,\n): BursarConfigData & Record<string, unknown> {\n return toSnakeCase(loadConfigFromDict(data)) as BursarConfigData & Record<string, unknown>;\n}\n\n/** Serialize an already parsed configuration without re-validating camelCase fields as raw input. */\nexport function canonicalParsedBursarConfigDict(\n data: ParsedBursarConfig,\n): BursarConfigData & Record<string, unknown> {\n return toSnakeCase(data) as BursarConfigData & Record<string, unknown>;\n}\n\nconst ROLLOUT_STRATEGIES = new Set<PlanRolloutStrategy>([\n \"immediate\",\n \"next_renewal\",\n \"new_assignments_only\",\n]);\n\nfunction requirePlainObject(value: unknown, path: string): JsonObject {\n if (value == null || Array.isArray(value) || typeof value !== \"object\") {\n throw new ConfigError(`${path} must be an object`);\n }\n return value as JsonObject;\n}\n\nfunction rejectUnknownKeys(value: JsonObject, allowed: readonly string[], path: string): void {\n const unknown = Object.keys(value).filter((key) => !allowed.includes(key));\n if (unknown.length > 0) {\n throw new ConfigError(`${path} contains unknown field '${unknown[0]}'`);\n }\n}\n\n/** Parse a one-release catalog rollout manifest. */\nexport function loadCatalogRollout(data: unknown = {}): CatalogRollout {\n const raw = requirePlainObject(data, \"rollout\");\n rejectUnknownKeys(raw, [\"plans\"], \"rollout\");\n const plansRaw = raw.plans == null ? {} : requirePlainObject(raw.plans, \"rollout.plans\");\n const plans: CatalogRollout[\"plans\"] = {};\n\n for (const [planKey, value] of Object.entries(plansRaw)) {\n identifier(planKey, `rollout.plans.${planKey}`);\n const plan = requirePlainObject(value, `rollout.plans.${planKey}`);\n rejectUnknownKeys(\n plan,\n [\"effective\", \"include_pinned\", \"includePinned\"],\n `rollout.plans.${planKey}`,\n );\n if (!ROLLOUT_STRATEGIES.has(plan.effective as PlanRolloutStrategy)) {\n throw new ConfigError(\n `rollout.plans.${planKey}.effective must be immediate, next_renewal, or new_assignments_only`,\n );\n }\n if (plan.include_pinned != null && plan.includePinned != null) {\n throw new ConfigError(\n `rollout.plans.${planKey} must not set both include_pinned and includePinned`,\n );\n }\n const includePinned = plan.include_pinned ?? plan.includePinned;\n if (includePinned != null && typeof includePinned !== \"boolean\") {\n throw new ConfigError(`rollout.plans.${planKey}.include_pinned must be boolean`);\n }\n plans[planKey] = {\n effective: plan.effective as PlanRolloutStrategy,\n includePinned: includePinned === true,\n };\n }\n\n return { plans };\n}\n\n/** Serialize a rollout manifest for the catalog activation RPC. */\nexport function canonicalCatalogRolloutDict(data: unknown = {}): Record<string, unknown> {\n return toSnakeCase(loadCatalogRollout(data)) as Record<string, unknown>;\n}\n\n/** Validate rollout references and renewal timing against its target catalog. */\nexport function validateCatalogRollout(\n config: ParsedBursarConfig,\n rollout: CatalogRollout,\n): CatalogRollout {\n const subscriptionPlans = new Set(\n Object.values(config.commerce.offers)\n .filter((offer): offer is SubscriptionOffer => offer.type === \"subscription\")\n .map((offer) => offer.plan),\n );\n for (const [planKey, policy] of Object.entries(rollout.plans)) {\n if (!config.plans[planKey]) {\n throw new ConfigError(`rollout.plans references unknown plan '${planKey}'`);\n }\n if (policy.effective === \"next_renewal\" && !subscriptionPlans.has(planKey)) {\n throw new ConfigError(\n `rollout.plans.${planKey}.effective=next_renewal requires a subscription offer`,\n );\n }\n }\n return rollout;\n}\n"]}
|