@zonastery/bursar 2.0.1 → 2.0.3
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 +22 -14
- package/dist/billing/auto-recharge-service.d.ts +1 -1
- package/dist/billing/auto-recharge-service.d.ts.map +1 -1
- package/dist/billing/auto-recharge-service.js +9 -6
- package/dist/billing/auto-recharge-service.js.map +1 -1
- package/dist/billing/billing-store.d.ts +4 -1
- package/dist/billing/billing-store.d.ts.map +1 -1
- package/dist/billing/billing-store.js +2 -0
- package/dist/billing/billing-store.js.map +1 -1
- package/dist/billing/contracts.d.ts +2 -1
- package/dist/billing/contracts.d.ts.map +1 -1
- package/dist/billing/contracts.js.map +1 -1
- package/dist/billing/event-handlers.d.ts +2 -3
- package/dist/billing/event-handlers.d.ts.map +1 -1
- package/dist/billing/event-handlers.js +38 -49
- package/dist/billing/event-handlers.js.map +1 -1
- package/dist/billing/event-processor.d.ts.map +1 -1
- package/dist/billing/event-processor.js +22 -10
- package/dist/billing/event-processor.js.map +1 -1
- package/dist/billing/financial-event-handlers.d.ts +2 -2
- package/dist/billing/financial-event-handlers.d.ts.map +1 -1
- package/dist/billing/financial-event-handlers.js +7 -7
- package/dist/billing/financial-event-handlers.js.map +1 -1
- package/dist/billing/postgres/repositories/auto-recharge.js +1 -1
- package/dist/billing/postgres/repositories/auto-recharge.js.map +1 -1
- package/dist/billing/postgres/repositories/event.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/event.js +33 -1
- package/dist/billing/postgres/repositories/event.js.map +1 -1
- package/dist/billing/postgres/repositories/offer.d.ts +1 -1
- package/dist/billing/postgres/repositories/offer.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/offer.js +1 -1
- package/dist/billing/postgres/repositories/offer.js.map +1 -1
- package/dist/billing/postgres/repositories/topup.d.ts +1 -1
- package/dist/billing/postgres/repositories/topup.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/topup.js +1 -1
- package/dist/billing/postgres/repositories/topup.js.map +1 -1
- package/dist/billing/postgres/store.d.ts +6 -2
- package/dist/billing/postgres/store.d.ts.map +1 -1
- package/dist/billing/postgres/store.js +21 -6
- package/dist/billing/postgres/store.js.map +1 -1
- package/dist/billing/service-types.d.ts +2 -15
- package/dist/billing/service-types.d.ts.map +1 -1
- package/dist/billing/service-types.js.map +1 -1
- package/dist/billing/types/auto-recharge.d.ts +1 -1
- package/dist/billing/types/auto-recharge.d.ts.map +1 -1
- package/dist/billing/types/auto-recharge.js.map +1 -1
- package/dist/billing/types/catalog.d.ts +1 -1
- package/dist/billing/types/catalog.d.ts.map +1 -1
- package/dist/billing/types/catalog.js.map +1 -1
- package/dist/billing/types/documents.d.ts +1 -1
- package/dist/billing/types/documents.d.ts.map +1 -1
- package/dist/billing/types/documents.js.map +1 -1
- package/dist/billing/types/events.d.ts +11 -2
- package/dist/billing/types/events.d.ts.map +1 -1
- package/dist/billing/types/events.js +2 -2
- package/dist/billing/types/events.js.map +1 -1
- package/dist/billing/types/subscriptions.d.ts.map +1 -1
- package/dist/billing/types/subscriptions.js.map +1 -1
- package/dist/breakdown.d.ts +1 -1
- package/dist/breakdown.d.ts.map +1 -1
- package/dist/breakdown.js +1 -1
- package/dist/breakdown.js.map +1 -1
- package/dist/bursar.d.ts +21 -11
- package/dist/bursar.d.ts.map +1 -1
- package/dist/bursar.js +40 -4
- package/dist/bursar.js.map +1 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/commerce/index.d.ts +0 -1
- package/dist/commerce/index.d.ts.map +1 -1
- package/dist/commerce/index.js +0 -1
- package/dist/commerce/index.js.map +1 -1
- package/dist/commerce/service.d.ts.map +1 -1
- package/dist/commerce/service.js +154 -106
- package/dist/commerce/service.js.map +1 -1
- package/dist/commerce/types.d.ts +9 -5
- package/dist/commerce/types.d.ts.map +1 -1
- package/dist/commerce/types.js.map +1 -1
- package/dist/config/parse-credits.d.ts.map +1 -1
- package/dist/config/parse-credits.js +0 -6
- package/dist/config/parse-credits.js.map +1 -1
- package/dist/config/parse-utils.d.ts +1 -1
- package/dist/config/parse-utils.d.ts.map +1 -1
- package/dist/config/parse-utils.js +1 -1
- package/dist/config/parse-utils.js.map +1 -1
- package/dist/config/types.d.ts +1 -6
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -1
- package/dist/config.js.map +1 -1
- package/dist/credits/amount.d.ts +8 -0
- package/dist/credits/amount.d.ts.map +1 -0
- package/dist/credits/amount.js +32 -0
- package/dist/credits/amount.js.map +1 -0
- package/dist/credits/catalog-runtime.d.ts +5 -7
- package/dist/credits/catalog-runtime.d.ts.map +1 -1
- package/dist/credits/catalog-runtime.js +4 -13
- package/dist/credits/catalog-runtime.js.map +1 -1
- package/dist/credits/lease-workflow.d.ts +2 -2
- package/dist/credits/lease-workflow.d.ts.map +1 -1
- package/dist/credits/lease-workflow.js +24 -21
- package/dist/credits/lease-workflow.js.map +1 -1
- package/dist/credits/low-balance-monitor.d.ts +1 -1
- package/dist/credits/low-balance-monitor.d.ts.map +1 -1
- package/dist/credits/low-balance-monitor.js +3 -4
- package/dist/credits/low-balance-monitor.js.map +1 -1
- package/dist/credits/postgres/repositories/balance.d.ts.map +1 -1
- package/dist/credits/postgres/repositories/balance.js +1 -1
- package/dist/credits/postgres/repositories/balance.js.map +1 -1
- package/dist/credits/postgres/repositories/bucket.js +1 -1
- package/dist/credits/postgres/repositories/bucket.js.map +1 -1
- package/dist/credits/postgres/repositories/lease.d.ts.map +1 -1
- package/dist/credits/postgres/repositories/lease.js +4 -2
- package/dist/credits/postgres/repositories/lease.js.map +1 -1
- package/dist/credits/postgres/repositories/team.d.ts +2 -1
- package/dist/credits/postgres/repositories/team.d.ts.map +1 -1
- package/dist/credits/postgres/repositories/team.js +19 -5
- package/dist/credits/postgres/repositories/team.js.map +1 -1
- package/dist/credits/postgres/store.d.ts +18 -14
- package/dist/credits/postgres/store.d.ts.map +1 -1
- package/dist/credits/postgres/store.js +30 -18
- package/dist/credits/postgres/store.js.map +1 -1
- package/dist/credits/postgres/value-mappers.d.ts +1 -1
- package/dist/credits/postgres/value-mappers.d.ts.map +1 -1
- package/dist/credits/postgres/value-mappers.js +1 -1
- package/dist/credits/postgres/value-mappers.js.map +1 -1
- package/dist/credits/service-errors.d.ts +1 -1
- package/dist/credits/service-errors.d.ts.map +1 -1
- package/dist/credits/service-errors.js +1 -1
- package/dist/credits/service-errors.js.map +1 -1
- package/dist/credits/service-types.d.ts +21 -16
- package/dist/credits/service-types.d.ts.map +1 -1
- package/dist/credits/service-types.js.map +1 -1
- package/dist/credits/service.d.ts +21 -17
- package/dist/credits/service.d.ts.map +1 -1
- package/dist/credits/service.js +81 -38
- package/dist/credits/service.js.map +1 -1
- package/dist/credits/store.d.ts +26 -23
- package/dist/credits/store.d.ts.map +1 -1
- package/dist/credits/store.js +4 -2
- package/dist/credits/store.js.map +1 -1
- package/dist/credits/types/account.d.ts +1 -1
- package/dist/credits/types/account.d.ts.map +1 -1
- package/dist/credits/types/account.js.map +1 -1
- package/dist/credits/types/grants.d.ts.map +1 -1
- package/dist/credits/types/grants.js.map +1 -1
- package/dist/credits/types/teams.d.ts +1 -0
- package/dist/credits/types/teams.d.ts.map +1 -1
- package/dist/credits/types/teams.js.map +1 -1
- package/dist/engine.js +1 -1
- package/dist/engine.js.map +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +34 -0
- package/dist/errors.js.map +1 -1
- package/dist/expr/ast.d.ts.map +1 -1
- package/dist/expr/ast.js.map +1 -1
- package/dist/expr/evaluator.d.ts +1 -1
- package/dist/expr/evaluator.d.ts.map +1 -1
- package/dist/expr/evaluator.js +1 -1
- package/dist/expr/evaluator.js.map +1 -1
- package/dist/expr/parser.d.ts +1 -0
- package/dist/expr/parser.d.ts.map +1 -1
- package/dist/expr/parser.js +15 -3
- package/dist/expr/parser.js.map +1 -1
- package/dist/expr.d.ts +1 -1
- package/dist/expr.d.ts.map +1 -1
- package/dist/expr.js +1 -1
- package/dist/expr.js.map +1 -1
- package/dist/generated/pricing-config.schema.json +31 -29
- package/dist/generated/pricing-config.types.d.ts +6 -18
- package/dist/generated/pricing-config.types.d.ts.map +1 -1
- package/dist/generated/pricing-config.types.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/load-config-file.d.ts +2 -3
- package/dist/load-config-file.d.ts.map +1 -1
- package/dist/load-config-file.js +14 -29
- package/dist/load-config-file.js.map +1 -1
- package/dist/metrics.d.ts +1 -1
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js.map +1 -1
- package/dist/node.d.ts +6 -3
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +1 -0
- package/dist/node.js.map +1 -1
- package/dist/providers/_shared.d.ts +3 -3
- package/dist/providers/_shared.d.ts.map +1 -1
- package/dist/providers/_shared.js +11 -6
- package/dist/providers/_shared.js.map +1 -1
- package/dist/providers/dodo/client-contract.d.ts +8 -13
- package/dist/providers/dodo/client-contract.d.ts.map +1 -1
- package/dist/providers/dodo/client-contract.js.map +1 -1
- package/dist/providers/dodo/event-mapper.d.ts +1 -1
- package/dist/providers/dodo/event-mapper.d.ts.map +1 -1
- package/dist/providers/dodo/event-mapper.js +23 -15
- package/dist/providers/dodo/event-mapper.js.map +1 -1
- package/dist/providers/dodo/provider.d.ts +4 -6
- package/dist/providers/dodo/provider.d.ts.map +1 -1
- package/dist/providers/dodo/provider.js +44 -82
- package/dist/providers/dodo/provider.js.map +1 -1
- package/dist/providers/dodo/webhook-bridge.d.ts +1 -2
- package/dist/providers/dodo/webhook-bridge.d.ts.map +1 -1
- package/dist/providers/dodo/webhook-bridge.js +0 -1
- package/dist/providers/dodo/webhook-bridge.js.map +1 -1
- package/dist/providers/environment.d.ts +6 -0
- package/dist/providers/environment.d.ts.map +1 -0
- package/dist/providers/environment.js +10 -0
- package/dist/providers/environment.js.map +1 -0
- package/dist/providers/index.d.ts +3 -7
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +1 -5
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/mock/provider.d.ts +6 -8
- package/dist/providers/mock/provider.d.ts.map +1 -1
- package/dist/providers/mock/provider.js +18 -50
- package/dist/providers/mock/provider.js.map +1 -1
- package/dist/providers/stripe/event-mapper.d.ts.map +1 -1
- package/dist/providers/stripe/event-mapper.js +82 -14
- package/dist/providers/stripe/event-mapper.js.map +1 -1
- package/dist/providers/stripe/provider.d.ts +3 -3
- package/dist/providers/stripe/provider.d.ts.map +1 -1
- package/dist/providers/stripe/provider.js +37 -24
- package/dist/providers/stripe/provider.js.map +1 -1
- package/dist/providers/types.d.ts +9 -20
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/providers/types.js.map +1 -1
- package/dist/shared/diagnostics.d.ts +8 -0
- package/dist/shared/diagnostics.d.ts.map +1 -1
- package/dist/shared/diagnostics.js +49 -0
- package/dist/shared/diagnostics.js.map +1 -1
- package/dist/shared/idempotency.d.ts +9 -0
- package/dist/shared/idempotency.d.ts.map +1 -0
- package/dist/shared/idempotency.js +34 -0
- package/dist/shared/idempotency.js.map +1 -0
- package/dist/shared/postgres-client.d.ts +7 -0
- package/dist/shared/postgres-client.d.ts.map +1 -1
- package/dist/shared/postgres-client.js +21 -4
- package/dist/shared/postgres-client.js.map +1 -1
- package/dist/shared/postgres-errors.d.ts.map +1 -1
- package/dist/shared/postgres-errors.js.map +1 -1
- package/dist/storage/adapters/clickhouse.d.ts +9 -2
- package/dist/storage/adapters/clickhouse.d.ts.map +1 -1
- package/dist/storage/adapters/clickhouse.js +142 -36
- package/dist/storage/adapters/clickhouse.js.map +1 -1
- package/dist/storage/adapters/s3.d.ts +44 -6
- package/dist/storage/adapters/s3.d.ts.map +1 -1
- package/dist/storage/adapters/s3.js +59 -21
- package/dist/storage/adapters/s3.js.map +1 -1
- package/dist/storage/diagnostics.d.ts +105 -0
- package/dist/storage/diagnostics.d.ts.map +1 -0
- package/dist/storage/diagnostics.js +227 -0
- package/dist/storage/diagnostics.js.map +1 -0
- package/dist/storage/maintenance.d.ts +88 -0
- package/dist/storage/maintenance.d.ts.map +1 -0
- package/dist/storage/maintenance.js +266 -0
- package/dist/storage/maintenance.js.map +1 -0
- package/dist/storage/outbox-worker.d.ts +20 -0
- package/dist/storage/outbox-worker.d.ts.map +1 -1
- package/dist/storage/outbox-worker.js +172 -42
- package/dist/storage/outbox-worker.js.map +1 -1
- package/dist/storage/ports.d.ts +43 -1
- package/dist/storage/ports.d.ts.map +1 -1
- package/dist/storage/ports.js.map +1 -1
- package/dist/storage/postgres-repository.d.ts +7 -2
- package/dist/storage/postgres-repository.d.ts.map +1 -1
- package/dist/storage/postgres-repository.js +155 -54
- package/dist/storage/postgres-repository.js.map +1 -1
- package/dist/storage/runtime.d.ts +30 -9
- package/dist/storage/runtime.d.ts.map +1 -1
- package/dist/storage/runtime.js +268 -37
- package/dist/storage/runtime.js.map +1 -1
- package/dist/telemetry/index.d.ts +37 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +115 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/opentelemetry.d.ts +25 -0
- package/dist/telemetry/opentelemetry.d.ts.map +1 -0
- package/dist/telemetry/opentelemetry.js +74 -0
- package/dist/telemetry/opentelemetry.js.map +1 -0
- package/package.json +62 -36
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAiBnD,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOpD,OAAO,EACL,yBAAyB,EACzB,8BAA8B,EAC9B,YAAY,EACZ,WAAW,EACX,4BAA4B,EAC5B,2BAA2B,EAC3B,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,0BAA0B,EAC1B,mCAAmC,EACnC,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACb,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAQrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAiBnD,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOpD,OAAO,EACL,yBAAyB,EACzB,8BAA8B,EAC9B,YAAY,EACZ,WAAW,EACX,4BAA4B,EAC5B,2BAA2B,EAC3B,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,0BAA0B,EAC1B,mCAAmC,EACnC,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACb,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAQrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAO9B,0EAA0E;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAYrE,cAAc,qBAAqB,CAAC;AA+FpC,SAAS;AACT,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAKnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,UAAU;AACV,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { PricingEngine } from \"./engine.js\";\nexport type { CostBreakdown } from \"./breakdown.js\";\nexport { makeCostBreakdown } from \"./breakdown.js\";\nexport type { UsageMetrics } from \"./metrics.js\";\nexport type {\n BursarConfigData,\n CatalogRollout,\n ParsedBursarConfig,\n PricingConfig,\n CreditsConfig,\n PlanDefinition,\n PlanEvolution,\n PlanRollout,\n PlanRolloutStrategy,\n CommerceConfig,\n Window,\n Charge,\n FeatureDefinition,\n} from \"./config.js\";\nexport {\n canonicalBursarConfigDict,\n canonicalCatalogRolloutDict,\n loadCatalogRollout,\n loadConfigFromDict,\n validateCatalogRollout,\n} from \"./config.js\";\nexport { projectPublicCatalog } from \"./catalog.js\";\nexport type {\n PublicCatalog,\n PublicCatalogOffer,\n PublicCatalogPlan,\n PublicCatalogWindow,\n} from \"./catalog.js\";\nexport {\n AutoRechargeDisabledError,\n AutoRechargeNotConfiguredError,\n BillingError,\n BursarError,\n CapabilityNotConfiguredError,\n CapabilityNotSupportedError,\n CapReachedError,\n ConcurrencyLimitError,\n CreditError,\n ConfigError,\n ExpressionError,\n FeatureNotEntitledError,\n ImportError,\n InsufficientCreditsError,\n LeaseExpiredError,\n LeaseNotFoundError,\n OperationNotAllowedError,\n PaymentMethodRequiredError,\n ProviderCapabilityNotSupportedError,\n ProviderResponseError,\n CatalogNotLoadedError,\n RefundError,\n QuotaExceededError,\n StoreError,\n StoreClosedError,\n StoreTimeoutError,\n StoreUnavailableError,\n bursarErrorHttpStatus,\n bursarErrorPublicMessage,\n isBursarError,\n isRetryableBursarError,\n} from \"./errors.js\";\nexport type {\n BursarErrorCategory,\n BursarErrorDetails,\n BursarErrorOptions,\n SerializedBursarError,\n StoreErrorOptions,\n} from \"./errors.js\";\nexport { retryBursarOperation } from \"./retry.js\";\nexport type { BursarRetryOptions } from \"./retry.js\";\nexport { validateExpression, evaluateExpression } from \"./expr.js\";\nexport {\n BURSAR_INSTRUMENTATION_SCOPE,\n BURSAR_INSTRUMENTATION_VERSION,\n NOOP_INSTRUMENTATION,\n NoopInstrumentation,\n getDefaultInstrumentation,\n sanitizeTelemetryAttributes,\n setDefaultInstrumentation,\n telemetryErrorAttributes,\n telemetryOperationAttributes,\n} from \"./telemetry/index.js\";\nexport type {\n Instrumentation,\n TelemetryAttributes,\n TelemetryAttributeValue,\n} from \"./telemetry/index.js\";\n\n// Application facade. Credit/billing orchestration is internal to Bursar.\nexport { AccountService, Bursar, CatalogService } from \"./bursar.js\";\nexport type {\n AccountCreatedInput,\n AccountCreatedResult,\n BillingBursarOptions,\n BursarOptions,\n BillingCapability,\n BillingEventSink,\n CommerceOptions,\n CreditsService,\n CreditsOnlyBursarOptions,\n} from \"./bursar.js\";\nexport * from \"./commerce/index.js\";\n\n// Types\nexport type {\n AddCreditsResult,\n AddTeamMemberResult,\n AggregateStats,\n AllowanceResult,\n AvailableResult,\n BalanceResult,\n BillingMode,\n CatalogRevisionSummary,\n CatalogRevision,\n BucketBalance,\n BucketBalancesResult,\n BucketDefinition,\n CanAffordResult,\n CheckFeatureResult,\n CreateTeamResult,\n CreditMetadata,\n DailySpendRow,\n DeductionResult,\n DeductionFailure,\n DeductionSuccess,\n DeductWithAllowanceOptions,\n ExecuteGrantProgramRequest,\n GetUserPlanResult,\n GrantProgramAwardResult,\n GrantProgramTrigger,\n LeaseResult,\n LeaseFailure,\n LeaseSuccess,\n LeasePricingContext,\n ListQuotaEventsOptions,\n PlanAllowancePolicy,\n PlanAdmissionPolicy,\n PlanCreditPolicy,\n PlanMigrationBatchResult,\n PlanMigrationStartResult,\n QuotaEvent,\n QuotaState,\n RefundResult,\n RefundFailure,\n RefundSuccess,\n RevokeCreditsResult,\n ReleaseResult,\n SetUserPlanResult,\n SpendByModelRow,\n SpendByUserRow,\n ListLedgerEntriesOptions,\n ListUsageChargesOptions,\n ListUsageEntriesOptions,\n LedgerCursor,\n LedgerPage,\n LedgerEntry,\n UsageCharge,\n UsageChargeCursor,\n UsageChargePage,\n UsageRecordResult,\n UsageRecordFailure,\n UsageRecordSuccess,\n SweepResult,\n Team,\n TeamBalanceResult,\n TeamDeductionResult,\n TeamDeductionFailure,\n TeamDeductionSuccess,\n TeamMember,\n TopUserRow,\n UsageAnalyticsStore,\n} from \"./credits/types/index.js\";\n\n// Store options\nexport type { CreateLeaseOptions, CreateTeamOptions, SettleLeaseOptions } from \"./credits/store.js\";\nexport type {\n AddCreditsOptions,\n BeginBilledOperationOptions,\n CanAffordOptions,\n CreditsServiceOptions,\n DeductCreditsOptions,\n DeductFlatJobOptions,\n DeductOptions,\n DeductTeamOptions,\n ExactAmount,\n GrantSubscriptionCycleOptions,\n LowBalanceConfig,\n MetricsOrAmount,\n PostDeductionContext,\n RecordUsageOptions,\n RefundCreditsOptions,\n ReserveOptions,\n RunBilledOptions,\n SettleOptions,\n} from \"./credits/service-types.js\";\n\n// Stores\nexport { CreditStore } from \"./credits/store.js\";\nexport { PostgresStore } from \"./credits/postgres/store.js\";\nexport type { PostgresStoreOptions } from \"./credits/postgres/store.js\";\nexport type { PostgresConnectionOptions } from \"./shared/postgres-client.js\";\nexport { PROVIDER_ENVIRONMENTS } from \"./providers/environment.js\";\nexport type { ProviderEnvironment } from \"./providers/environment.js\";\n\n// Events\nexport type { CreditEvent, CreditEventType } from \"./credits/events.js\";\nexport { CreditEventEmitter } from \"./credits/events.js\";\n\n// Billing\nexport { BillingStore, PostgresBillingStore } from \"./billing/index.js\";\nexport { AUTO_RECHARGE_STATES, BillingEventType } from \"./billing/index.js\";\nexport type { BillingServiceOptions } from \"./billing/billing-service.js\";\n\nexport type {\n BillingAutoRechargeAttempt,\n BillingAutoRechargeAttemptState,\n BillingAutoRechargeProfile,\n BillingAutoRechargeStatus,\n BillingProvisioningPort,\n BillingCreditPostingResult,\n BillingCustomerInfo,\n BillingCustomerRecord,\n BillingDisputeInfo,\n BillingEvent,\n BillingEventClaim,\n BillingEventHandler,\n BillingEventResult,\n BillingInvoiceInfo,\n BillingInvoiceRecord,\n BillingOfferInterval,\n BillingPaymentInfo,\n BillingPaymentRecord,\n BillingPreferences,\n PostgresBillingStoreOptions,\n BillingRefundInfo,\n BillingSubscriptionInfo,\n BillingSubscriptionChange,\n BillingSubscriptionChangeInput,\n BillingSubscriptionOfferContext,\n BillingSubscriptionChangeState,\n BillingSubscriptionState,\n BillingSubscriptionStatus,\n EntitlementMode,\n ProviderRef,\n SubscriptionGrant,\n} from \"./billing/index.js\";\n"]}
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* Returns the raw parsed dict (suitable for ``loadConfigFromDict`` or
|
|
5
5
|
* ``PricingEngine.fromDict``).
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* typed message.
|
|
7
|
+
* JSON syntax is validated by the platform parser and mapping keys are also
|
|
8
|
+
* checked by js-yaml so duplicate config fields cannot silently overwrite.
|
|
10
9
|
*/
|
|
11
10
|
export declare function loadConfigFile(filepath: string): Promise<Record<string, unknown>>;
|
|
12
11
|
//# sourceMappingURL=load-config-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config-file.d.ts","sourceRoot":"","sources":["../src/load-config-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-config-file.d.ts","sourceRoot":"","sources":["../src/load-config-file.ts"],"names":[],"mappings":"AAwDA;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA+BvF"}
|
package/dist/load-config-file.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import { readFileSync, statSync } from "fs";
|
|
2
2
|
import { extname } from "path";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return candidate;
|
|
14
|
-
}
|
|
15
|
-
if (candidate.default && typeof candidate.default.load === "function") {
|
|
16
|
-
return candidate.default;
|
|
17
|
-
}
|
|
18
|
-
throw new ImportError("js-yaml is installed but does not export a `load` function");
|
|
3
|
+
import { load as parseYaml } from "js-yaml";
|
|
4
|
+
import { ConfigError } from "./errors.js";
|
|
5
|
+
function parseJsonWithUniqueKeys(content) {
|
|
6
|
+
const parsed = JSON.parse(content);
|
|
7
|
+
// JSON is a strict subset of YAML. js-yaml retains source-level mapping
|
|
8
|
+
// keys and rejects duplicates, including nested and escape-equivalent keys;
|
|
9
|
+
// native JSON.parse above remains the authority for strict JSON syntax and
|
|
10
|
+
// for the returned JavaScript value.
|
|
11
|
+
parseYaml(content, { json: false });
|
|
12
|
+
return parsed;
|
|
19
13
|
}
|
|
20
14
|
/**
|
|
21
15
|
* Read a file's contents, converting missing-file/directory/permission
|
|
@@ -64,9 +58,8 @@ function assertNonEmptyObject(data, filepath) {
|
|
|
64
58
|
* Returns the raw parsed dict (suitable for ``loadConfigFromDict`` or
|
|
65
59
|
* ``PricingEngine.fromDict``).
|
|
66
60
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* typed message.
|
|
61
|
+
* JSON syntax is validated by the platform parser and mapping keys are also
|
|
62
|
+
* checked by js-yaml so duplicate config fields cannot silently overwrite.
|
|
70
63
|
*/
|
|
71
64
|
export async function loadConfigFile(filepath) {
|
|
72
65
|
const extension = extname(filepath).toLowerCase();
|
|
@@ -74,18 +67,10 @@ export async function loadConfigFile(filepath) {
|
|
|
74
67
|
throw new ConfigError(`Unsupported config file format: ${extension || "<none>"}. Expected .json, .yaml, or .yml`);
|
|
75
68
|
}
|
|
76
69
|
if (extension === ".yaml" || extension === ".yml") {
|
|
77
|
-
let mod;
|
|
78
|
-
try {
|
|
79
|
-
mod = await import("js-yaml");
|
|
80
|
-
}
|
|
81
|
-
catch (cause) {
|
|
82
|
-
throw new ImportError("js-yaml required for YAML files: npm install js-yaml", { cause });
|
|
83
|
-
}
|
|
84
|
-
const yaml = asYamlModule(mod);
|
|
85
70
|
const content = readFileClean(filepath);
|
|
86
71
|
let parsed;
|
|
87
72
|
try {
|
|
88
|
-
parsed =
|
|
73
|
+
parsed = parseYaml(content, { json: false });
|
|
89
74
|
}
|
|
90
75
|
catch (cause) {
|
|
91
76
|
throw new ConfigError(`Invalid YAML in ${filepath}: ${cause.message}`, [], {
|
|
@@ -97,7 +82,7 @@ export async function loadConfigFile(filepath) {
|
|
|
97
82
|
const content = readFileClean(filepath);
|
|
98
83
|
let parsed;
|
|
99
84
|
try {
|
|
100
|
-
parsed =
|
|
85
|
+
parsed = parseJsonWithUniqueKeys(content);
|
|
101
86
|
}
|
|
102
87
|
catch (cause) {
|
|
103
88
|
throw new ConfigError(`Invalid JSON in ${filepath}: ${cause.message}`, [], {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config-file.js","sourceRoot":"","sources":["../src/load-config-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"load-config-file.js","sourceRoot":"","sources":["../src/load-config-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,SAAS,uBAAuB,CAAC,OAAe;IAC9C,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5C,wEAAwE;IACxE,4EAA4E;IAC5E,2EAA2E;IAC3E,qCAAqC;IACrC,SAAS,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,QAAgB;IACrC,IAAI,IAA6C,CAAC;IAClD,IAAI,CAAC;QACH,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;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N,CAAC,CAAC;IACL,CAAC;IACD,OAAO,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import { readFileSync, statSync } from \"fs\";\nimport { extname } from \"path\";\nimport { load as parseYaml } from \"js-yaml\";\nimport { ConfigError } from \"./errors.js\";\n\nfunction parseJsonWithUniqueKeys(content: string): unknown {\n const parsed: unknown = JSON.parse(content);\n // JSON is a strict subset of YAML. js-yaml retains source-level mapping\n // keys and rejects duplicates, including nested and escape-equivalent keys;\n // native JSON.parse above remains the authority for strict JSON syntax and\n // for the returned JavaScript value.\n parseYaml(content, { json: false });\n return parsed;\n}\n\n/**\n * Read a file's contents, converting missing-file/directory/permission\n * failures into a clean {@link ConfigError} instead of a raw Node `fs` error\n * (mirrors the Python CLI's `_load_config_file`).\n */\nfunction readFileClean(filepath: string): string {\n let stat: ReturnType<typeof statSync> | undefined;\n try {\n stat = statSync(filepath);\n } catch (cause) {\n const code = (cause as NodeJS.ErrnoException).code;\n if (code === \"ENOENT\") throw new ConfigError(`Config file not found: ${filepath}`);\n if (code === \"EACCES\") throw new ConfigError(`Permission denied: ${filepath}`);\n throw new ConfigError(`Could not read ${filepath}: ${(cause as Error).message}`, [], { cause });\n }\n if (stat.isDirectory()) {\n throw new ConfigError(`Not a file (is a directory): ${filepath}`);\n }\n try {\n return readFileSync(filepath, \"utf-8\");\n } catch (cause) {\n throw new ConfigError(`Could not read ${filepath}: ${(cause as Error).message}`, [], { cause });\n }\n}\n\n/** Guard against an empty file or a non-object parse result (e.g. an empty YAML document). */\nfunction assertNonEmptyObject(data: unknown, filepath: string): Record<string, unknown> {\n if (data == null) {\n throw new ConfigError(`Bursar config is empty: ${filepath}`);\n }\n if (typeof data !== \"object\" || Array.isArray(data)) {\n throw new ConfigError(\n `Bursar config must be a JSON/YAML object, got ${typeof data}: ${filepath}`,\n );\n }\n if (Object.keys(data).length === 0) {\n throw new ConfigError(`Bursar config is empty: ${filepath}`);\n }\n return data as Record<string, unknown>;\n}\n\n/**\n * Read a JSON or YAML Bursar config file from disk.\n *\n * Returns the raw parsed dict (suitable for ``loadConfigFromDict`` or\n * ``PricingEngine.fromDict``).\n *\n * JSON syntax is validated by the platform parser and mapping keys are also\n * checked by js-yaml so duplicate config fields cannot silently overwrite.\n */\nexport async function loadConfigFile(filepath: string): Promise<Record<string, unknown>> {\n const extension = extname(filepath).toLowerCase();\n if (!new Set([\".json\", \".yaml\", \".yml\"]).has(extension)) {\n throw new ConfigError(\n `Unsupported config file format: ${extension || \"<none>\"}. Expected .json, .yaml, or .yml`,\n );\n }\n\n if (extension === \".yaml\" || extension === \".yml\") {\n const content = readFileClean(filepath);\n let parsed: unknown;\n try {\n parsed = parseYaml(content, { json: false });\n } catch (cause) {\n throw new ConfigError(`Invalid YAML in ${filepath}: ${(cause as Error).message}`, [], {\n cause,\n });\n }\n return assertNonEmptyObject(parsed, filepath);\n }\n\n const content = readFileClean(filepath);\n let parsed: unknown;\n try {\n parsed = parseJsonWithUniqueKeys(content);\n } catch (cause) {\n throw new ConfigError(`Invalid JSON in ${filepath}: ${(cause as Error).message}`, [], {\n cause,\n });\n }\n return assertNonEmptyObject(parsed, filepath);\n}\n"]}
|
package/dist/metrics.d.ts
CHANGED
package/dist/metrics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
|
package/dist/metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"","sourcesContent":["import type Decimal from \"decimal.js\";\n\n/** One provider-neutral billable operation. */\nexport interface UsageMetrics {\n operation: string;\n measures?: Record<string, number | string>;\n dimensions?: Record<string, string | number | boolean | Decimal.Value>;\n metadata?: Record<string, unknown>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\n/** One provider-neutral billable operation. */\nexport interface UsageMetrics {\n operation: string;\n measures?: Record<string, number | string>;\n dimensions?: Record<string, string | number | boolean | Decimal.Value>;\n metadata?: Record<string, unknown>;\n}\n"]}
|
package/dist/node.d.ts
CHANGED
|
@@ -12,11 +12,14 @@
|
|
|
12
12
|
export { loadConfigFile } from "./load-config-file.js";
|
|
13
13
|
export { BursarRuntime, createBursarRuntime } from "./storage/runtime.js";
|
|
14
14
|
export type { BursarRuntimeBursarOptions, BursarRuntimeHealth, BursarRuntimeOptions, BursarRuntimeStartOptions, } from "./storage/runtime.js";
|
|
15
|
+
export type { BursarRuntimeDiagnostics, BursarRuntimeState, CatalogDependencyCheck, CheckDependenciesOptions, DependencyCheck, DependencyStatus, OutboxDependencyCheck, OutboxStatusSnapshot, WorkerErrorSnapshot, WorkerLifecycle, WorkerRunSnapshot, WorkerState, } from "./storage/diagnostics.js";
|
|
16
|
+
export { BursarMaintenance, BursarOperatorMaintenance } from "./storage/maintenance.js";
|
|
17
|
+
export type { MaintenanceRunOptions, MaintenanceRunResult, MaintenanceRunStatus, MaintenanceOperations, MaintenanceTaskResult, MaintenanceTaskStatus, OperatorMaintenanceRunOptions, PartitionMaintenanceResult, StorageMaintenanceCounts, StorageMaintenanceResult, StorageMaintenanceStatus, StoragePartition, } from "./storage/maintenance.js";
|
|
15
18
|
export { OutboxWorker } from "./storage/outbox-worker.js";
|
|
16
|
-
export type { OutboxRunResult, OutboxWorkerOptions } from "./storage/outbox-worker.js";
|
|
19
|
+
export type { OutboxClaimLossPhase, OutboxEventOutcome, OutboxEventOutcomeStatus, OutboxRunResult, OutboxWorkerOptions, } from "./storage/outbox-worker.js";
|
|
17
20
|
export { ClickHouseUsageStore } from "./storage/adapters/clickhouse.js";
|
|
18
21
|
export type { ClickHouseClient, ClickHouseQueryResult, ClickHouseUsageStoreOptions, } from "./storage/adapters/clickhouse.js";
|
|
19
22
|
export { S3BillingArchive } from "./storage/adapters/s3.js";
|
|
20
|
-
export type { S3BillingArchiveOptions, S3Credentials } from "./storage/adapters/s3.js";
|
|
21
|
-
export type { BillingEventPayloadExport, BillingPayloadArchive, BillingPayloadArchiveResult, OutboxEvent, OutboxHandler, OutboxStore, UsageChargeExport, UsageEventSink, } from "./storage/ports.js";
|
|
23
|
+
export type { S3ArchiveClient, S3ArchiveClientFactory, S3BillingArchiveOptions, S3Credentials, S3PutObjectOptions, } from "./storage/adapters/s3.js";
|
|
24
|
+
export type { BillingEventPayloadExport, BillingPayloadArchive, BillingPayloadArchiveResult, OutboxClaimRenewalStore, OutboxDeadLetter, OutboxDeadLetterCursor, OutboxDeadLetterListOptions, OutboxDeadLetterPage, OutboxEvent, OutboxHandler, OutboxRecoveryStore, OutboxStats, OutboxStore, UsageChargeExport, UsageEventSink, } from "./storage/ports.js";
|
|
22
25
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;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A4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,YAAY,EACV,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,cAAc,GACf,MAAM,oBAAoB,CAAC"}
|
package/dist/node.js
CHANGED
|
@@ -13,6 +13,7 @@ export { loadConfigFile } from "./load-config-file.js";
|
|
|
13
13
|
// Optional high-volume storage infrastructure. These adapters are Node-only;
|
|
14
14
|
// the main package remains the PostgreSQL-first application API.
|
|
15
15
|
export { BursarRuntime, createBursarRuntime } from "./storage/runtime.js";
|
|
16
|
+
export { BursarMaintenance, BursarOperatorMaintenance } from "./storage/maintenance.js";
|
|
16
17
|
export { OutboxWorker } from "./storage/outbox-worker.js";
|
|
17
18
|
export { ClickHouseUsageStore } from "./storage/adapters/clickhouse.js";
|
|
18
19
|
export { S3BillingArchive } from "./storage/adapters/s3.js";
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,6EAA6E;AAC7E,iEAAiE;AACjE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,6EAA6E;AAC7E,iEAAiE;AACjE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAqB1E,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAexF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAQ1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAMxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["/**\n * Node.js-only bursar exports.\n *\n * These modules depend on Node built-ins (`crypto`, `fs`) and are not\n * compatible with Edge Runtime environments. Import them from the\n * ``@zonastery/bursar/node`` subpath when you need Node-specific behaviour:\n *\n * ```ts\n * import { loadConfigFile } from \"@zonastery/bursar/node\";\n * ```\n */\n\nexport { loadConfigFile } from \"./load-config-file.js\";\n\n// Optional high-volume storage infrastructure. These adapters are Node-only;\n// the main package remains the PostgreSQL-first application API.\nexport { BursarRuntime, createBursarRuntime } from \"./storage/runtime.js\";\nexport type {\n BursarRuntimeBursarOptions,\n BursarRuntimeHealth,\n BursarRuntimeOptions,\n BursarRuntimeStartOptions,\n} from \"./storage/runtime.js\";\nexport type {\n BursarRuntimeDiagnostics,\n BursarRuntimeState,\n CatalogDependencyCheck,\n CheckDependenciesOptions,\n DependencyCheck,\n DependencyStatus,\n OutboxDependencyCheck,\n OutboxStatusSnapshot,\n WorkerErrorSnapshot,\n WorkerLifecycle,\n WorkerRunSnapshot,\n WorkerState,\n} from \"./storage/diagnostics.js\";\nexport { BursarMaintenance, BursarOperatorMaintenance } from \"./storage/maintenance.js\";\nexport type {\n MaintenanceRunOptions,\n MaintenanceRunResult,\n MaintenanceRunStatus,\n MaintenanceOperations,\n MaintenanceTaskResult,\n MaintenanceTaskStatus,\n OperatorMaintenanceRunOptions,\n PartitionMaintenanceResult,\n StorageMaintenanceCounts,\n StorageMaintenanceResult,\n StorageMaintenanceStatus,\n StoragePartition,\n} from \"./storage/maintenance.js\";\nexport { OutboxWorker } from \"./storage/outbox-worker.js\";\nexport type {\n OutboxClaimLossPhase,\n OutboxEventOutcome,\n OutboxEventOutcomeStatus,\n OutboxRunResult,\n OutboxWorkerOptions,\n} from \"./storage/outbox-worker.js\";\nexport { ClickHouseUsageStore } from \"./storage/adapters/clickhouse.js\";\nexport type {\n ClickHouseClient,\n ClickHouseQueryResult,\n ClickHouseUsageStoreOptions,\n} from \"./storage/adapters/clickhouse.js\";\nexport { S3BillingArchive } from \"./storage/adapters/s3.js\";\nexport type {\n S3ArchiveClient,\n S3ArchiveClientFactory,\n S3BillingArchiveOptions,\n S3Credentials,\n S3PutObjectOptions,\n} from \"./storage/adapters/s3.js\";\nexport type {\n BillingEventPayloadExport,\n BillingPayloadArchive,\n BillingPayloadArchiveResult,\n OutboxClaimRenewalStore,\n OutboxDeadLetter,\n OutboxDeadLetterCursor,\n OutboxDeadLetterListOptions,\n OutboxDeadLetterPage,\n OutboxEvent,\n OutboxHandler,\n OutboxRecoveryStore,\n OutboxStats,\n OutboxStore,\n UsageChargeExport,\n UsageEventSink,\n} from \"./storage/ports.js\";\n"]}
|
|
@@ -6,9 +6,9 @@ export declare function optionalProviderBoolean(value: unknown, field: string):
|
|
|
6
6
|
export declare function requireMinorUnits(value: unknown, field: string, positive?: boolean): number;
|
|
7
7
|
export declare function requireCurrency(value: unknown, field: string): string;
|
|
8
8
|
/**
|
|
9
|
-
* Wrapper around the facade event sink that throws on
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Wrapper around the facade event sink that throws on retryable or unexpected
|
|
10
|
+
* failures. Permanent claim outcomes are returned so the provider can
|
|
11
|
+
* acknowledge them without scheduling another delivery.
|
|
12
12
|
*/
|
|
13
13
|
export declare function callBillingEventSink(sink: BillingEventSink, event: BillingEvent): Promise<BillingEventResult>;
|
|
14
14
|
//# sourceMappingURL=_shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_shared.d.ts","sourceRoot":"","sources":["../../src/providers/_shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"_shared.d.ts","sourceRoot":"","sources":["../../src/providers/_shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAerD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK3E;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGxF;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAM1F;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,UAAQ,GAAG,MAAM,CAazF;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAKrE;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAwC7B"}
|
|
@@ -3,6 +3,13 @@ import { BursarError, StoreUnavailableError } from "../errors.js";
|
|
|
3
3
|
class BillingClaimBusyError extends Error {
|
|
4
4
|
name = "BillingClaimBusyError";
|
|
5
5
|
}
|
|
6
|
+
const ACKNOWLEDGED_BILLING_EVENT_ERRORS = new Set([
|
|
7
|
+
"unhandled_event_type",
|
|
8
|
+
"account_not_found",
|
|
9
|
+
"invalid_request",
|
|
10
|
+
"idempotency_conflict",
|
|
11
|
+
"max_retries_exceeded",
|
|
12
|
+
]);
|
|
6
13
|
export function requireProviderString(value, field) {
|
|
7
14
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
8
15
|
throw new TypeError(`${field} must be a non-empty string`);
|
|
@@ -40,9 +47,9 @@ export function requireCurrency(value, field) {
|
|
|
40
47
|
return value.toUpperCase();
|
|
41
48
|
}
|
|
42
49
|
/**
|
|
43
|
-
* Wrapper around the facade event sink that throws on
|
|
44
|
-
*
|
|
45
|
-
*
|
|
50
|
+
* Wrapper around the facade event sink that throws on retryable or unexpected
|
|
51
|
+
* failures. Permanent claim outcomes are returned so the provider can
|
|
52
|
+
* acknowledge them without scheduling another delivery.
|
|
46
53
|
*/
|
|
47
54
|
export async function callBillingEventSink(sink, event) {
|
|
48
55
|
let result;
|
|
@@ -76,9 +83,7 @@ export async function callBillingEventSink(sink, event) {
|
|
|
76
83
|
details: { reason: result.error },
|
|
77
84
|
});
|
|
78
85
|
}
|
|
79
|
-
if (!result.handled &&
|
|
80
|
-
result.error !== "unhandled_event_type" &&
|
|
81
|
-
result.error !== "user_not_found") {
|
|
86
|
+
if (!result.handled && !ACKNOWLEDGED_BILLING_EVENT_ERRORS.has(result.error ?? "")) {
|
|
82
87
|
throw new BursarError("Bursar failed to ingest the billing event", {
|
|
83
88
|
details: { reason: result.error ?? "unknown" },
|
|
84
89
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_shared.js","sourceRoot":"","sources":["../../src/providers/_shared.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAI7B,OAAO,EAAE,WAAW,EAAE,qBAAqB,E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AAE,MAAM,CAAC,KAAK,IAAI,SAAS,EAAE;SAC/C,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import pRetry from \"p-retry\";\n\nimport type { BillingEvent, BillingEventResult } from \"../billing/index.js\";\nimport type { BillingEventSink } from \"../bursar.js\";\nimport { BursarError, StoreUnavailableError } from \"../errors.js\";\n\nclass BillingClaimBusyError extends Error {\n override readonly name = \"BillingClaimBusyError\";\n}\n\nconst ACKNOWLEDGED_BILLING_EVENT_ERRORS = new Set([\n \"unhandled_event_type\",\n \"account_not_found\",\n \"invalid_request\",\n \"idempotency_conflict\",\n \"max_retries_exceeded\",\n]);\n\nexport function requireProviderString(value: unknown, field: string): string {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new TypeError(`${field} must be a non-empty string`);\n }\n return value.trim();\n}\n\nexport function optionalProviderString(value: unknown, field: string): string | undefined {\n if (value === null || value === undefined) return undefined;\n return requireProviderString(value, field);\n}\n\nexport function optionalProviderBoolean(value: unknown, field: string): boolean | undefined {\n if (value === null || value === undefined) return undefined;\n if (typeof value !== \"boolean\") {\n throw new TypeError(`${field} must be a boolean`);\n }\n return value;\n}\n\nexport function requireMinorUnits(value: unknown, field: string, positive = false): number {\n const amount =\n typeof value === \"number\"\n ? value\n : typeof value === \"string\" && /^\\d+$/.test(value)\n ? Number(value)\n : Number.NaN;\n if (!Number.isSafeInteger(amount) || amount < (positive ? 1 : 0)) {\n throw new TypeError(\n `${field} must be a ${positive ? \"positive\" : \"non-negative\"} safe integer`,\n );\n }\n return amount;\n}\n\nexport function requireCurrency(value: unknown, field: string): string {\n if (typeof value !== \"string\" || !/^[A-Za-z]{3}$/.test(value)) {\n throw new TypeError(`${field} must be a three-letter currency code`);\n }\n return value.toUpperCase();\n}\n\n/**\n * Wrapper around the facade event sink that throws on retryable or unexpected\n * failures. Permanent claim outcomes are returned so the provider can\n * acknowledge them without scheduling another delivery.\n */\nexport async function callBillingEventSink(\n sink: BillingEventSink,\n event: BillingEvent,\n): Promise<BillingEventResult> {\n let result: BillingEventResult;\n try {\n result = await pRetry(\n async () => {\n const attempted = await sink.ingestBillingEvent(event);\n if (attempted.error === \"claim_busy\") throw new BillingClaimBusyError();\n return attempted;\n },\n {\n retries: 6,\n minTimeout: 25,\n maxTimeout: 800,\n factor: 2,\n randomize: true,\n maxRetryTime: 5_000,\n shouldRetry: ({ error }) => error instanceof BillingClaimBusyError,\n },\n );\n } catch (cause) {\n if (cause instanceof BillingClaimBusyError) {\n throw new StoreUnavailableError(\"Billing event claim remained busy\", {\n cause,\n details: { reason: \"claim_busy\" },\n });\n }\n throw cause;\n }\n\n if (result.error === \"claim_failed_retry\") {\n throw new StoreUnavailableError(\"Billing event claim could not be acquired\", {\n details: { reason: result.error },\n });\n }\n if (!result.handled && !ACKNOWLEDGED_BILLING_EVENT_ERRORS.has(result.error ?? \"\")) {\n throw new BursarError(\"Bursar failed to ingest the billing event\", {\n details: { reason: result.error ?? \"unknown\" },\n });\n }\n return result;\n}\n"]}
|
|
@@ -10,9 +10,11 @@ type DodoCheckoutSessionStatus = Awaited<ReturnType<DodoPayments["checkoutSessio
|
|
|
10
10
|
type DodoCheckoutPreview = Awaited<ReturnType<DodoPayments["checkoutSessions"]["preview"]>>;
|
|
11
11
|
type DodoPayment = Awaited<ReturnType<DodoPayments["payments"]["retrieve"]>>;
|
|
12
12
|
type DodoPlanChangePreview = Awaited<ReturnType<DodoPayments["subscriptions"]["previewChangePlan"]>>;
|
|
13
|
+
type DodoPaymentMethodUpdate = Awaited<ReturnType<DodoPayments["subscriptions"]["updatePaymentMethod"]>>;
|
|
13
14
|
type DodoCustomer = Awaited<ReturnType<DodoPayments["customers"]["create"]>>;
|
|
14
15
|
type DodoCustomerPortalSession = Awaited<ReturnType<DodoPayments["customers"]["customerPortal"]["create"]>>;
|
|
15
16
|
type DodoPaymentMethods = Awaited<ReturnType<DodoPayments["customers"]["retrievePaymentMethods"]>>;
|
|
17
|
+
type DodoMutationRequestOptions = Pick<NonNullable<Parameters<DodoPayments["checkoutSessions"]["create"]>[1]>, "headers">;
|
|
16
18
|
type DodoSdkWebhookPayload = ReturnType<DodoPayments["webhooks"]["unwrap"]>;
|
|
17
19
|
/**
|
|
18
20
|
* Payload returned by an official Dodo adapter after signature verification.
|
|
@@ -35,14 +37,12 @@ export interface DodoClient {
|
|
|
35
37
|
}): DodoWebhookPayload;
|
|
36
38
|
};
|
|
37
39
|
checkoutSessions: {
|
|
38
|
-
create(body: Parameters<DodoPayments["checkoutSessions"]["create"]>[0], options?:
|
|
39
|
-
idempotencyKey?: string;
|
|
40
|
-
}): Promise<DodoCheckoutSession>;
|
|
40
|
+
create(body: Parameters<DodoPayments["checkoutSessions"]["create"]>[0], options?: DodoMutationRequestOptions): Promise<DodoCheckoutSession>;
|
|
41
41
|
preview(body: Parameters<DodoPayments["checkoutSessions"]["preview"]>[0]): Promise<DodoCheckoutPreview>;
|
|
42
42
|
retrieve(sessionId: Parameters<DodoPayments["checkoutSessions"]["retrieve"]>[0]): Promise<DodoCheckoutSessionStatus>;
|
|
43
43
|
};
|
|
44
44
|
customers: {
|
|
45
|
-
create(body: Parameters<DodoPayments["customers"]["create"]>[0]): Promise<DodoCustomer>;
|
|
45
|
+
create(body: Parameters<DodoPayments["customers"]["create"]>[0], options?: DodoMutationRequestOptions): Promise<DodoCustomer>;
|
|
46
46
|
customerPortal: {
|
|
47
47
|
create(customerId: Parameters<DodoPayments["customers"]["customerPortal"]["create"]>[0], body: Parameters<DodoPayments["customers"]["customerPortal"]["create"]>[1]): Promise<DodoCustomerPortalSession>;
|
|
48
48
|
};
|
|
@@ -52,16 +52,11 @@ export interface DodoClient {
|
|
|
52
52
|
retrieve(paymentId: Parameters<DodoPayments["payments"]["retrieve"]>[0]): Promise<DodoPayment>;
|
|
53
53
|
};
|
|
54
54
|
subscriptions: {
|
|
55
|
-
cancelChangePlan(subscriptionId: Parameters<DodoPayments["subscriptions"]["cancelChangePlan"]>[0], options?:
|
|
56
|
-
|
|
57
|
-
}): Promise<unknown>;
|
|
58
|
-
changePlan(subscriptionId: Parameters<DodoPayments["subscriptions"]["changePlan"]>[0], body: Parameters<DodoPayments["subscriptions"]["changePlan"]>[1], options?: {
|
|
59
|
-
idempotencyKey?: string;
|
|
60
|
-
}): Promise<unknown>;
|
|
55
|
+
cancelChangePlan(subscriptionId: Parameters<DodoPayments["subscriptions"]["cancelChangePlan"]>[0], options?: DodoMutationRequestOptions): Promise<unknown>;
|
|
56
|
+
changePlan(subscriptionId: Parameters<DodoPayments["subscriptions"]["changePlan"]>[0], body: Parameters<DodoPayments["subscriptions"]["changePlan"]>[1], options?: DodoMutationRequestOptions): Promise<unknown>;
|
|
61
57
|
previewChangePlan(subscriptionId: Parameters<DodoPayments["subscriptions"]["previewChangePlan"]>[0], body: Parameters<DodoPayments["subscriptions"]["previewChangePlan"]>[1]): Promise<DodoPlanChangePreview>;
|
|
62
|
-
update(subscriptionId: Parameters<DodoPayments["subscriptions"]["update"]>[0], body: Parameters<DodoPayments["subscriptions"]["update"]>[1], options?:
|
|
63
|
-
|
|
64
|
-
}): Promise<unknown>;
|
|
58
|
+
update(subscriptionId: Parameters<DodoPayments["subscriptions"]["update"]>[0], body: Parameters<DodoPayments["subscriptions"]["update"]>[1], options?: DodoMutationRequestOptions): Promise<unknown>;
|
|
59
|
+
updatePaymentMethod(subscriptionId: Parameters<DodoPayments["subscriptions"]["updatePaymentMethod"]>[0], body: Parameters<DodoPayments["subscriptions"]["updatePaymentMethod"]>[1]): Promise<DodoPaymentMethodUpdate>;
|
|
65
60
|
};
|
|
66
61
|
}
|
|
67
62
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-contract.d.ts","sourceRoot":"","sources":["../../../src/providers/dodo/client-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,cAAc,CAAC;AAE7C;;;;;GAKG;AACH,KAAK,mBAAmB,GAAG,OAAO,CAAC,UAAU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,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EACtE,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAC5D,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,OAAO,CAAC,CAAC;QACpB,mBAAmB,CACjB,cAAc,EAAE,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,EACnF,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,GACxE,OAAO,CAAC,uBAAuB,CAAC,CAAC;KACrC,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-contract.js","sourceRoot":"","sources":["../../../src/providers/dodo/client-contract.ts"],"names":[],"mappings":"","sourcesContent":["import type DodoPayments from \"dodopayments\";\n\n/**\n * The public Dodo SDK surface used by Bursar.\n *\n * This structural boundary prevents compatible Dodo SDK installations from\n * becoming nominally incompatible through private class and APIPromise fields.\n */\ntype DodoCheckoutSession = Awaited<ReturnType<DodoPayments[\"checkoutSessions\"][\"create\"]>>;\ntype DodoCheckoutSessionStatus = Awaited<ReturnType<DodoPayments[\"checkoutSessions\"][\"retrieve\"]>>;\ntype DodoCheckoutPreview = Awaited<ReturnType<DodoPayments[\"checkoutSessions\"][\"preview\"]>>;\ntype DodoPayment = Awaited<ReturnType<DodoPayments[\"payments\"][\"retrieve\"]>>;\ntype DodoPlanChangePreview = Awaited<\n ReturnType<DodoPayments[\"subscriptions\"][\"previewChangePlan\"]>\n>;\ntype DodoCustomer = Awaited<ReturnType<DodoPayments[\"customers\"][\"create\"]>>;\ntype DodoCustomerPortalSession = Awaited<\n ReturnType<DodoPayments[\"customers\"][\"customerPortal\"][\"create\"]>\n>;\ntype DodoPaymentMethods = Awaited<ReturnType<DodoPayments[\"customers\"][\"retrievePaymentMethods\"]>>;\n\ntype DodoSdkWebhookPayload = ReturnType<DodoPayments[\"webhooks\"][\"unwrap\"]>;\n\n/**\n * Payload returned by an official Dodo adapter after signature verification.\n *\n * Dodo's core, Next.js, and Better Auth packages expose equivalent webhook\n * envelopes but can carry incompatible nested SDK types. Keep the envelope\n * SDK-derived and treat only the resource payload as untrusted input; Bursar's\n * mapper validates every field it consumes.\n */\nexport type DodoWebhookPayload = Partial<\n Omit<DodoSdkWebhookPayload, \"data\" | \"timestamp\" | \"type\">\n> & {\n data: unknown;\n timestamp: string | Date;\n type: string;\n};\n\nexport interface DodoClient {\n webhooks: {\n unwrap(\n body: string,\n options: { headers: Record<string, string>; key?: string },\n ): DodoWebhookPayload;\n };\n checkoutSessions: {\n create(\n body: Parameters<DodoPayments[\"checkoutSessions\"][\"create\"]>[0],\n options?:
|
|
1
|
+
{"version":3,"file":"client-contract.js","sourceRoot":"","sources":["../../../src/providers/dodo/client-contract.ts"],"names":[],"mappings":"","sourcesContent":["import type DodoPayments from \"dodopayments\";\n\n/**\n * The public Dodo SDK surface used by Bursar.\n *\n * This structural boundary prevents compatible Dodo SDK installations from\n * becoming nominally incompatible through private class and APIPromise fields.\n */\ntype DodoCheckoutSession = Awaited<ReturnType<DodoPayments[\"checkoutSessions\"][\"create\"]>>;\ntype DodoCheckoutSessionStatus = Awaited<ReturnType<DodoPayments[\"checkoutSessions\"][\"retrieve\"]>>;\ntype DodoCheckoutPreview = Awaited<ReturnType<DodoPayments[\"checkoutSessions\"][\"preview\"]>>;\ntype DodoPayment = Awaited<ReturnType<DodoPayments[\"payments\"][\"retrieve\"]>>;\ntype DodoPlanChangePreview = Awaited<\n ReturnType<DodoPayments[\"subscriptions\"][\"previewChangePlan\"]>\n>;\ntype DodoPaymentMethodUpdate = Awaited<\n ReturnType<DodoPayments[\"subscriptions\"][\"updatePaymentMethod\"]>\n>;\ntype DodoCustomer = Awaited<ReturnType<DodoPayments[\"customers\"][\"create\"]>>;\ntype DodoCustomerPortalSession = Awaited<\n ReturnType<DodoPayments[\"customers\"][\"customerPortal\"][\"create\"]>\n>;\ntype DodoPaymentMethods = Awaited<ReturnType<DodoPayments[\"customers\"][\"retrievePaymentMethods\"]>>;\ntype DodoMutationRequestOptions = Pick<\n NonNullable<Parameters<DodoPayments[\"checkoutSessions\"][\"create\"]>[1]>,\n \"headers\"\n>;\n\ntype DodoSdkWebhookPayload = ReturnType<DodoPayments[\"webhooks\"][\"unwrap\"]>;\n\n/**\n * Payload returned by an official Dodo adapter after signature verification.\n *\n * Dodo's core, Next.js, and Better Auth packages expose equivalent webhook\n * envelopes but can carry incompatible nested SDK types. Keep the envelope\n * SDK-derived and treat only the resource payload as untrusted input; Bursar's\n * mapper validates every field it consumes.\n */\nexport type DodoWebhookPayload = Partial<\n Omit<DodoSdkWebhookPayload, \"data\" | \"timestamp\" | \"type\">\n> & {\n data: unknown;\n timestamp: string | Date;\n type: string;\n};\n\nexport interface DodoClient {\n webhooks: {\n unwrap(\n body: string,\n options: { headers: Record<string, string>; key?: string },\n ): DodoWebhookPayload;\n };\n checkoutSessions: {\n create(\n body: Parameters<DodoPayments[\"checkoutSessions\"][\"create\"]>[0],\n options?: DodoMutationRequestOptions,\n ): Promise<DodoCheckoutSession>;\n preview(\n body: Parameters<DodoPayments[\"checkoutSessions\"][\"preview\"]>[0],\n ): Promise<DodoCheckoutPreview>;\n retrieve(\n sessionId: Parameters<DodoPayments[\"checkoutSessions\"][\"retrieve\"]>[0],\n ): Promise<DodoCheckoutSessionStatus>;\n };\n customers: {\n create(\n body: Parameters<DodoPayments[\"customers\"][\"create\"]>[0],\n options?: DodoMutationRequestOptions,\n ): Promise<DodoCustomer>;\n customerPortal: {\n create(\n customerId: Parameters<DodoPayments[\"customers\"][\"customerPortal\"][\"create\"]>[0],\n body: Parameters<DodoPayments[\"customers\"][\"customerPortal\"][\"create\"]>[1],\n ): Promise<DodoCustomerPortalSession>;\n };\n retrievePaymentMethods(\n customerId: Parameters<DodoPayments[\"customers\"][\"retrievePaymentMethods\"]>[0],\n ): Promise<DodoPaymentMethods>;\n };\n payments: {\n retrieve(paymentId: Parameters<DodoPayments[\"payments\"][\"retrieve\"]>[0]): Promise<DodoPayment>;\n };\n subscriptions: {\n cancelChangePlan(\n subscriptionId: Parameters<DodoPayments[\"subscriptions\"][\"cancelChangePlan\"]>[0],\n options?: DodoMutationRequestOptions,\n ): Promise<unknown>;\n changePlan(\n subscriptionId: Parameters<DodoPayments[\"subscriptions\"][\"changePlan\"]>[0],\n body: Parameters<DodoPayments[\"subscriptions\"][\"changePlan\"]>[1],\n options?: DodoMutationRequestOptions,\n ): Promise<unknown>;\n previewChangePlan(\n subscriptionId: Parameters<DodoPayments[\"subscriptions\"][\"previewChangePlan\"]>[0],\n body: Parameters<DodoPayments[\"subscriptions\"][\"previewChangePlan\"]>[1],\n ): Promise<DodoPlanChangePreview>;\n update(\n subscriptionId: Parameters<DodoPayments[\"subscriptions\"][\"update\"]>[0],\n body: Parameters<DodoPayments[\"subscriptions\"][\"update\"]>[1],\n options?: DodoMutationRequestOptions,\n ): Promise<unknown>;\n updatePaymentMethod(\n subscriptionId: Parameters<DodoPayments[\"subscriptions\"][\"updatePaymentMethod\"]>[0],\n body: Parameters<DodoPayments[\"subscriptions\"][\"updatePaymentMethod\"]>[1],\n ): Promise<DodoPaymentMethodUpdate>;\n };\n}\n"]}
|
|
@@ -4,5 +4,5 @@ import { type ProviderLogger } from "../types.js";
|
|
|
4
4
|
/** Dodo sometimes sends dates in JS toString() format (e.g. "Sat Jul 18 2026 05:15:24 GMT+0000..."). Normalize to ISO 8601. */
|
|
5
5
|
export declare function normalizeDate(raw: unknown): string | null;
|
|
6
6
|
export declare function dodoBillingEventId(payload: DodoWebhookPayload): string;
|
|
7
|
-
export declare function handleDodoBillingEvent(payload: DodoWebhookPayload,
|
|
7
|
+
export declare function handleDodoBillingEvent(payload: DodoWebhookPayload, accountId: string | null, metadata: Record<string, string>, sink: BillingEventSink, logger?: ProviderLogger | null): Promise<void>;
|
|
8
8
|
//# sourceMappingURL=event-mapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-mapper.d.ts","sourceRoot":"","sources":["../../../src/providers/dodo/event-mapper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAMxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,KAAK,cAAc,EAA2B,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"event-mapper.d.ts","sourceRoot":"","sources":["../../../src/providers/dodo/event-mapper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAMxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,KAAK,cAAc,EAA2B,MAAM,aAAa,CAAC;AA8D3E,+HAA+H;AAC/H,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAWzD;AAgBD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAgBtE;AAyGD,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,IAAI,EAAE,gBAAgB,EACtB,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,GAC7B,OAAO,CAAC,IAAI,CAAC,CAwRf"}
|
|
@@ -14,6 +14,7 @@ const DODO_SUBSCRIPTION_STATUS = {
|
|
|
14
14
|
pending: "incomplete",
|
|
15
15
|
trialing: "trialing",
|
|
16
16
|
active: "active",
|
|
17
|
+
paused: "paused",
|
|
17
18
|
on_hold: "past_due",
|
|
18
19
|
cancelled: "canceled",
|
|
19
20
|
failed: "past_due",
|
|
@@ -169,7 +170,7 @@ function subscriptionStatus(value, logger) {
|
|
|
169
170
|
logger.warn("Unsupported Dodo subscription status", { status: raw });
|
|
170
171
|
return status ?? null;
|
|
171
172
|
}
|
|
172
|
-
export async function handleDodoBillingEvent(payload,
|
|
173
|
+
export async function handleDodoBillingEvent(payload, accountId, metadata, sink, logger) {
|
|
173
174
|
const log = normalizeProviderLogger(logger);
|
|
174
175
|
const data = objectValue(payload.data);
|
|
175
176
|
if (!data)
|
|
@@ -181,24 +182,20 @@ export async function handleDodoBillingEvent(payload, userId, metadata, sink, lo
|
|
|
181
182
|
provider: "dodo",
|
|
182
183
|
eventId: dodoBillingEventId(payload),
|
|
183
184
|
occurredAt: requireDate(payload.timestamp, "Dodo webhook timestamp"),
|
|
184
|
-
...(
|
|
185
|
+
...(accountId ? { accountId } : {}),
|
|
185
186
|
...(customerInfo.providerCustomerId ? { customer: customerInfo } : {}),
|
|
186
187
|
...(Object.keys(metadata).length ? { metadata } : {}),
|
|
187
188
|
};
|
|
188
189
|
}
|
|
189
190
|
switch (type) {
|
|
190
191
|
case "subscription.active": {
|
|
191
|
-
if (!userId) {
|
|
192
|
-
log.error("Dodo subscription event: no userId", { event: type });
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
192
|
const subId = subscriptionId(data);
|
|
196
193
|
const refs = subscriptionRefs(data, metadata);
|
|
197
194
|
log.debug("Dodo subscription.active mapped", {
|
|
198
195
|
subscriptionId: subId,
|
|
199
196
|
productId: productId(data),
|
|
200
197
|
planSlug: metadata.plan_slug,
|
|
201
|
-
|
|
198
|
+
hasAccountId: Boolean(accountId),
|
|
202
199
|
refs,
|
|
203
200
|
});
|
|
204
201
|
await callBillingEventSink(sink, {
|
|
@@ -217,10 +214,6 @@ export async function handleDodoBillingEvent(payload, userId, metadata, sink, lo
|
|
|
217
214
|
return;
|
|
218
215
|
}
|
|
219
216
|
case "subscription.renewed": {
|
|
220
|
-
if (!userId) {
|
|
221
|
-
log.error("Dodo subscription event: no userId", { event: type });
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
217
|
const subId = subscriptionId(data);
|
|
225
218
|
await callBillingEventSink(sink, {
|
|
226
219
|
...baseEvent(),
|
|
@@ -291,6 +284,20 @@ export async function handleDodoBillingEvent(payload, userId, metadata, sink, lo
|
|
|
291
284
|
});
|
|
292
285
|
return;
|
|
293
286
|
}
|
|
287
|
+
case "subscription.paused": {
|
|
288
|
+
const subId = subscriptionId(data);
|
|
289
|
+
await callBillingEventSink(sink, {
|
|
290
|
+
...baseEvent(),
|
|
291
|
+
eventType: "subscription.paused",
|
|
292
|
+
subscription: {
|
|
293
|
+
providerSubscriptionId: subId,
|
|
294
|
+
status: "paused",
|
|
295
|
+
...subscriptionFields(data, metadata),
|
|
296
|
+
refs: subscriptionRefs(data, metadata),
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
294
301
|
case "subscription.updated": {
|
|
295
302
|
const subId = subscriptionId(data);
|
|
296
303
|
const periodEnd = optionalDate(data.next_billing_date, "Dodo subscription.next_billing_date");
|
|
@@ -337,7 +344,7 @@ export async function handleDodoBillingEvent(payload, userId, metadata, sink, lo
|
|
|
337
344
|
await callBillingEventSink(sink, {
|
|
338
345
|
...baseEvent(),
|
|
339
346
|
eventType: "payment.succeeded",
|
|
340
|
-
...(
|
|
347
|
+
...(accountId ? { accountId } : {}),
|
|
341
348
|
...(subscriptionId
|
|
342
349
|
? {
|
|
343
350
|
subscription: {
|
|
@@ -354,14 +361,15 @@ export async function handleDodoBillingEvent(payload, userId, metadata, sink, lo
|
|
|
354
361
|
});
|
|
355
362
|
return;
|
|
356
363
|
}
|
|
357
|
-
case "payment.failed":
|
|
364
|
+
case "payment.failed":
|
|
365
|
+
case "payment.cancelled": {
|
|
358
366
|
const subId = optionalProviderString(data.subscription_id, "Dodo payment.subscription_id");
|
|
359
367
|
const paymentId = requireProviderString(data.payment_id, "Dodo payment.payment_id");
|
|
360
368
|
const providerProductId = productId(data);
|
|
361
369
|
await callBillingEventSink(sink, {
|
|
362
370
|
...baseEvent(),
|
|
363
371
|
eventType: "payment.failed",
|
|
364
|
-
...(
|
|
372
|
+
...(accountId ? { accountId } : {}),
|
|
365
373
|
subscription: subId ? { providerSubscriptionId: subId } : undefined,
|
|
366
374
|
payment: {
|
|
367
375
|
providerPaymentId: paymentId,
|
|
@@ -369,7 +377,7 @@ export async function handleDodoBillingEvent(payload, userId, metadata, sink, lo
|
|
|
369
377
|
taxMinor: requireMinorUnits(data.tax ?? 0, "Dodo payment.tax"),
|
|
370
378
|
currency: requireCurrency(data.currency, "Dodo payment.currency"),
|
|
371
379
|
purpose: subId ? "subscription" : "credit_topup",
|
|
372
|
-
status: "failed",
|
|
380
|
+
status: type === "payment.cancelled" ? "canceled" : "failed",
|
|
373
381
|
refs: providerProductId ? { productId: providerProductId } : undefined,
|
|
374
382
|
},
|
|
375
383
|
});
|