@zonastery/bursar 1.0.1 → 2.0.0
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 +86 -3
- package/dist/billing/auto-recharge-port.d.ts +3 -3
- package/dist/billing/auto-recharge-port.d.ts.map +1 -1
- package/dist/billing/auto-recharge-port.js.map +1 -1
- package/dist/billing/auto-recharge-service.d.ts +5 -4
- package/dist/billing/auto-recharge-service.d.ts.map +1 -1
- package/dist/billing/auto-recharge-service.js +64 -34
- package/dist/billing/auto-recharge-service.js.map +1 -1
- package/dist/billing/billing-service.d.ts +5 -5
- package/dist/billing/billing-service.d.ts.map +1 -1
- package/dist/billing/billing-service.js +2 -2
- package/dist/billing/billing-service.js.map +1 -1
- package/dist/billing/billing-store.d.ts +8 -7
- 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 +31 -31
- package/dist/billing/contracts.d.ts.map +1 -1
- package/dist/billing/contracts.js.map +1 -1
- package/dist/billing/event-handlers.d.ts.map +1 -1
- package/dist/billing/event-handlers.js +31 -9
- 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 +2 -1
- package/dist/billing/event-processor.js.map +1 -1
- package/dist/billing/financial-event-handlers.d.ts.map +1 -1
- package/dist/billing/financial-event-handlers.js +69 -72
- package/dist/billing/financial-event-handlers.js.map +1 -1
- package/dist/billing/index.d.ts +1 -1
- package/dist/billing/index.d.ts.map +1 -1
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/management.d.ts +5 -5
- package/dist/billing/management.d.ts.map +1 -1
- package/dist/billing/management.js +2 -2
- package/dist/billing/management.js.map +1 -1
- package/dist/billing/postgres/repositories/auto-recharge.d.ts +3 -3
- package/dist/billing/postgres/repositories/auto-recharge.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/auto-recharge.js +202 -59
- package/dist/billing/postgres/repositories/auto-recharge.js.map +1 -1
- package/dist/billing/postgres/repositories/customer.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/customer.js +19 -11
- package/dist/billing/postgres/repositories/customer.js.map +1 -1
- package/dist/billing/postgres/repositories/dispute.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/dispute.js +3 -1
- package/dist/billing/postgres/repositories/dispute.js.map +1 -1
- package/dist/billing/postgres/repositories/event.d.ts +12 -5
- package/dist/billing/postgres/repositories/event.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/event.js +18 -15
- package/dist/billing/postgres/repositories/event.js.map +1 -1
- package/dist/billing/postgres/repositories/invoice.d.ts +3 -3
- package/dist/billing/postgres/repositories/invoice.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/invoice.js +53 -11
- package/dist/billing/postgres/repositories/invoice.js.map +1 -1
- package/dist/billing/postgres/repositories/offer.d.ts +20 -17
- package/dist/billing/postgres/repositories/offer.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/offer.js +123 -57
- package/dist/billing/postgres/repositories/offer.js.map +1 -1
- package/dist/billing/postgres/repositories/payment.d.ts +23 -20
- package/dist/billing/postgres/repositories/payment.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/payment.js +43 -37
- package/dist/billing/postgres/repositories/payment.js.map +1 -1
- package/dist/billing/postgres/repositories/preferences.d.ts +3 -9
- package/dist/billing/postgres/repositories/preferences.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/preferences.js +45 -7
- package/dist/billing/postgres/repositories/preferences.js.map +1 -1
- package/dist/billing/postgres/repositories/refund.d.ts +1 -1
- package/dist/billing/postgres/repositories/refund.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/refund.js +13 -9
- package/dist/billing/postgres/repositories/refund.js.map +1 -1
- package/dist/billing/postgres/repositories/subscription-change.d.ts +15 -0
- package/dist/billing/postgres/repositories/subscription-change.d.ts.map +1 -0
- package/dist/billing/postgres/repositories/subscription-change.js +234 -0
- package/dist/billing/postgres/repositories/subscription-change.js.map +1 -0
- package/dist/billing/postgres/repositories/subscription.d.ts +38 -17
- package/dist/billing/postgres/repositories/subscription.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/subscription.js +199 -91
- package/dist/billing/postgres/repositories/subscription.js.map +1 -1
- package/dist/billing/postgres/repositories/topup.d.ts +13 -15
- package/dist/billing/postgres/repositories/topup.d.ts.map +1 -1
- package/dist/billing/postgres/repositories/topup.js +65 -34
- package/dist/billing/postgres/repositories/topup.js.map +1 -1
- package/dist/billing/postgres/store.d.ts +18 -11
- package/dist/billing/postgres/store.d.ts.map +1 -1
- package/dist/billing/postgres/store.js +260 -238
- package/dist/billing/postgres/store.js.map +1 -1
- package/dist/billing/service-types.d.ts +6 -5
- 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 +6 -4
- 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 +18 -35
- package/dist/billing/types/catalog.d.ts.map +1 -1
- package/dist/billing/types/catalog.js.map +1 -1
- package/dist/billing/types/common.d.ts +0 -1
- package/dist/billing/types/common.d.ts.map +1 -1
- package/dist/billing/types/common.js.map +1 -1
- package/dist/billing/types/documents.d.ts +38 -12
- 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 +2 -0
- package/dist/billing/types/events.d.ts.map +1 -1
- package/dist/billing/types/events.js +238 -0
- package/dist/billing/types/events.js.map +1 -1
- package/dist/billing/types/subscriptions.d.ts +8 -8
- package/dist/billing/types/subscriptions.d.ts.map +1 -1
- package/dist/billing/types/subscriptions.js.map +1 -1
- package/dist/bursar.d.ts +27 -9
- package/dist/bursar.d.ts.map +1 -1
- package/dist/bursar.js +48 -20
- package/dist/bursar.js.map +1 -1
- package/dist/catalog.d.ts +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/errors.d.ts +1 -10
- package/dist/commerce/errors.d.ts.map +1 -1
- package/dist/commerce/errors.js +1 -16
- package/dist/commerce/errors.js.map +1 -1
- package/dist/commerce/index.d.ts +1 -0
- package/dist/commerce/index.d.ts.map +1 -1
- package/dist/commerce/index.js.map +1 -1
- package/dist/commerce/provider-registry.d.ts.map +1 -1
- package/dist/commerce/provider-registry.js +27 -2
- package/dist/commerce/provider-registry.js.map +1 -1
- package/dist/commerce/service.d.ts +15 -7
- package/dist/commerce/service.d.ts.map +1 -1
- package/dist/commerce/service.js +85 -67
- package/dist/commerce/service.js.map +1 -1
- package/dist/commerce/types.d.ts +27 -15
- package/dist/commerce/types.d.ts.map +1 -1
- package/dist/commerce/types.js.map +1 -1
- package/dist/config/parse-plans.d.ts.map +1 -1
- package/dist/config/parse-plans.js +16 -15
- package/dist/config/parse-plans.js.map +1 -1
- package/dist/config/parse-pricing.d.ts.map +1 -1
- package/dist/config/parse-pricing.js +16 -5
- package/dist/config/parse-pricing.js.map +1 -1
- package/dist/config/types.d.ts +2 -2
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/credits/{pricing-runtime.d.ts → catalog-runtime.d.ts} +8 -8
- package/dist/credits/catalog-runtime.d.ts.map +1 -0
- package/dist/credits/{pricing-runtime.js → catalog-runtime.js} +58 -38
- package/dist/credits/catalog-runtime.js.map +1 -0
- package/dist/credits/events.d.ts +4 -4
- package/dist/credits/events.d.ts.map +1 -1
- package/dist/credits/events.js +1 -1
- package/dist/credits/events.js.map +1 -1
- package/dist/credits/lease-workflow.d.ts +14 -14
- package/dist/credits/lease-workflow.d.ts.map +1 -1
- package/dist/credits/lease-workflow.js +18 -17
- package/dist/credits/lease-workflow.js.map +1 -1
- package/dist/credits/low-balance-monitor.d.ts +2 -2
- package/dist/credits/low-balance-monitor.d.ts.map +1 -1
- package/dist/credits/low-balance-monitor.js.map +1 -1
- package/dist/credits/postgres/repositories/analytics.d.ts +34 -34
- package/dist/credits/postgres/repositories/analytics.d.ts.map +1 -1
- package/dist/credits/postgres/repositories/analytics.js +52 -52
- package/dist/credits/postgres/repositories/analytics.js.map +1 -1
- package/dist/credits/postgres/repositories/balance.d.ts +28 -30
- package/dist/credits/postgres/repositories/balance.d.ts.map +1 -1
- package/dist/credits/postgres/repositories/balance.js +100 -59
- package/dist/credits/postgres/repositories/balance.js.map +1 -1
- package/dist/credits/postgres/repositories/bucket.d.ts +14 -8
- package/dist/credits/postgres/repositories/bucket.d.ts.map +1 -1
- package/dist/credits/postgres/repositories/bucket.js +22 -21
- package/dist/credits/postgres/repositories/bucket.js.map +1 -1
- package/dist/credits/postgres/repositories/catalog.d.ts +31 -0
- package/dist/credits/postgres/repositories/catalog.d.ts.map +1 -0
- package/dist/credits/postgres/repositories/catalog.js +90 -0
- package/dist/credits/postgres/repositories/catalog.js.map +1 -0
- package/dist/credits/postgres/repositories/deduction.d.ts +28 -26
- package/dist/credits/postgres/repositories/deduction.d.ts.map +1 -1
- package/dist/credits/postgres/repositories/deduction.js +153 -68
- package/dist/credits/postgres/repositories/deduction.js.map +1 -1
- package/dist/credits/postgres/repositories/lease.d.ts +21 -18
- package/dist/credits/postgres/repositories/lease.d.ts.map +1 -1
- package/dist/credits/postgres/repositories/lease.js +157 -65
- package/dist/credits/postgres/repositories/lease.js.map +1 -1
- package/dist/credits/postgres/repositories/plan.d.ts +90 -43
- package/dist/credits/postgres/repositories/plan.d.ts.map +1 -1
- package/dist/credits/postgres/repositories/plan.js +126 -108
- package/dist/credits/postgres/repositories/plan.js.map +1 -1
- package/dist/credits/postgres/repositories/team.d.ts +36 -27
- package/dist/credits/postgres/repositories/team.d.ts.map +1 -1
- package/dist/credits/postgres/repositories/team.js +96 -52
- package/dist/credits/postgres/repositories/team.js.map +1 -1
- package/dist/credits/postgres/store.d.ts +23 -18
- package/dist/credits/postgres/store.d.ts.map +1 -1
- package/dist/credits/postgres/store.js +282 -265
- package/dist/credits/postgres/store.js.map +1 -1
- package/dist/credits/postgres/value-mappers.d.ts +7 -9
- package/dist/credits/postgres/value-mappers.d.ts.map +1 -1
- package/dist/credits/postgres/value-mappers.js +36 -61
- package/dist/credits/postgres/value-mappers.js.map +1 -1
- package/dist/credits/queries.d.ts +5 -5
- package/dist/credits/queries.d.ts.map +1 -1
- package/dist/credits/queries.js +4 -4
- package/dist/credits/queries.js.map +1 -1
- package/dist/credits/service-types.d.ts +42 -7
- 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 +42 -62
- package/dist/credits/service.d.ts.map +1 -1
- package/dist/credits/service.js +140 -121
- package/dist/credits/service.js.map +1 -1
- package/dist/credits/store.d.ts +20 -22
- package/dist/credits/store.d.ts.map +1 -1
- package/dist/credits/store.js +5 -5
- package/dist/credits/store.js.map +1 -1
- package/dist/credits/types/account.d.ts +49 -11
- package/dist/credits/types/account.d.ts.map +1 -1
- package/dist/credits/types/account.js.map +1 -1
- package/dist/credits/types/admission.d.ts +17 -6
- package/dist/credits/types/admission.d.ts.map +1 -1
- package/dist/credits/types/admission.js.map +1 -1
- package/dist/credits/types/analytics.d.ts +2 -2
- package/dist/credits/types/analytics.d.ts.map +1 -1
- package/dist/credits/types/analytics.js.map +1 -1
- package/dist/credits/types/catalog.d.ts +20 -15
- package/dist/credits/types/catalog.d.ts.map +1 -1
- package/dist/credits/types/catalog.js.map +1 -1
- package/dist/credits/types/grants.d.ts +22 -8
- package/dist/credits/types/grants.d.ts.map +1 -1
- package/dist/credits/types/grants.js.map +1 -1
- package/dist/credits/types/ledger.d.ts +12 -3
- package/dist/credits/types/ledger.d.ts.map +1 -1
- package/dist/credits/types/ledger.js.map +1 -1
- package/dist/credits/types/teams.d.ts +18 -6
- package/dist/credits/types/teams.d.ts.map +1 -1
- package/dist/credits/types/teams.js.map +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +24 -10
- package/dist/engine.js.map +1 -1
- package/dist/errors.d.ts +52 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +76 -4
- 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.map +1 -1
- package/dist/expr/evaluator.js +29 -17
- package/dist/expr/evaluator.js.map +1 -1
- package/dist/expr/parser.d.ts.map +1 -1
- package/dist/expr/parser.js +11 -4
- package/dist/expr/parser.js.map +1 -1
- package/dist/expr/tokenizer.d.ts.map +1 -1
- package/dist/expr/tokenizer.js +17 -13
- package/dist/expr/tokenizer.js.map +1 -1
- package/dist/expr.d.ts +2 -2
- package/dist/expr.d.ts.map +1 -1
- package/dist/expr.js +5 -7
- package/dist/expr.js.map +1 -1
- package/dist/generated/pricing-config.schema.json +5 -12
- package/dist/generated/pricing-config.types.d.ts +3 -3
- 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 +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/better-auth.d.ts +23 -0
- package/dist/integrations/better-auth.d.ts.map +1 -0
- package/dist/integrations/better-auth.js +54 -0
- package/dist/integrations/better-auth.js.map +1 -0
- package/dist/{load-pricing-file.d.ts → load-config-file.d.ts} +4 -4
- package/dist/load-config-file.d.ts.map +1 -0
- package/dist/{load-pricing-file.js → load-config-file.js} +15 -10
- package/dist/load-config-file.js.map +1 -0
- package/dist/node.d.ts +3 -3
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +2 -2
- package/dist/node.js.map +1 -1
- package/dist/providers/_shared.d.ts +5 -0
- package/dist/providers/_shared.d.ts.map +1 -1
- package/dist/providers/_shared.js +36 -0
- package/dist/providers/_shared.js.map +1 -1
- package/dist/providers/dodo/better-auth.d.ts +29 -0
- package/dist/providers/dodo/better-auth.d.ts.map +1 -0
- package/dist/providers/dodo/better-auth.js +23 -0
- package/dist/providers/dodo/better-auth.js.map +1 -0
- package/dist/providers/dodo/client-contract.d.ts +32 -70
- 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 +3 -1
- package/dist/providers/dodo/event-mapper.d.ts.map +1 -1
- package/dist/providers/dodo/event-mapper.js +219 -148
- package/dist/providers/dodo/event-mapper.js.map +1 -1
- package/dist/providers/dodo/index.d.ts +5 -2
- package/dist/providers/dodo/index.d.ts.map +1 -1
- package/dist/providers/dodo/index.js +2 -1
- package/dist/providers/dodo/index.js.map +1 -1
- package/dist/providers/dodo/nextjs.d.ts +16 -0
- package/dist/providers/dodo/nextjs.d.ts.map +1 -0
- package/dist/providers/dodo/nextjs.js +16 -0
- package/dist/providers/dodo/nextjs.js.map +1 -0
- package/dist/providers/dodo/provider.d.ts +30 -11
- package/dist/providers/dodo/provider.d.ts.map +1 -1
- package/dist/providers/dodo/provider.js +192 -122
- package/dist/providers/dodo/provider.js.map +1 -1
- package/dist/providers/dodo/react-native.d.ts +56 -0
- package/dist/providers/dodo/react-native.d.ts.map +1 -0
- package/dist/providers/dodo/react-native.js +57 -0
- package/dist/providers/dodo/react-native.js.map +1 -0
- package/dist/providers/dodo/webhook-bridge.d.ts +17 -0
- package/dist/providers/dodo/webhook-bridge.d.ts.map +1 -0
- package/dist/providers/dodo/webhook-bridge.js +21 -0
- package/dist/providers/dodo/webhook-bridge.js.map +1 -0
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/mock/index.d.ts +1 -0
- package/dist/providers/mock/index.d.ts.map +1 -1
- package/dist/providers/mock/index.js.map +1 -1
- package/dist/providers/mock/provider.d.ts +8 -8
- package/dist/providers/mock/provider.d.ts.map +1 -1
- package/dist/providers/mock/provider.js +26 -19
- 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 +214 -173
- package/dist/providers/stripe/event-mapper.js.map +1 -1
- package/dist/providers/stripe/index.d.ts +1 -0
- package/dist/providers/stripe/index.d.ts.map +1 -1
- package/dist/providers/stripe/index.js.map +1 -1
- package/dist/providers/stripe/provider.d.ts +13 -11
- package/dist/providers/stripe/provider.d.ts.map +1 -1
- package/dist/providers/stripe/provider.js +287 -107
- package/dist/providers/stripe/provider.js.map +1 -1
- package/dist/providers/types.d.ts +1 -2
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/providers/types.js.map +1 -1
- package/dist/shared/postgres-client.d.ts +5 -0
- package/dist/shared/postgres-client.d.ts.map +1 -1
- package/dist/shared/postgres-client.js +23 -7
- package/dist/shared/postgres-client.js.map +1 -1
- package/dist/shared/postgres-validation.d.ts +15 -3
- package/dist/shared/postgres-validation.d.ts.map +1 -1
- package/dist/shared/postgres-validation.js +58 -14
- package/dist/shared/postgres-validation.js.map +1 -1
- package/dist/storage/adapters/clickhouse.d.ts.map +1 -1
- package/dist/storage/adapters/clickhouse.js +2 -5
- package/dist/storage/adapters/clickhouse.js.map +1 -1
- package/dist/storage/adapters/s3.d.ts +0 -6
- package/dist/storage/adapters/s3.d.ts.map +1 -1
- package/dist/storage/adapters/s3.js +0 -2
- package/dist/storage/adapters/s3.js.map +1 -1
- package/dist/storage/ports.d.ts +0 -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 +1 -1
- package/dist/storage/postgres-repository.d.ts.map +1 -1
- package/dist/storage/postgres-repository.js +2 -2
- package/dist/storage/postgres-repository.js.map +1 -1
- package/dist/storage/runtime.d.ts +24 -6
- package/dist/storage/runtime.d.ts.map +1 -1
- package/dist/storage/runtime.js +87 -30
- package/dist/storage/runtime.js.map +1 -1
- package/package.json +56 -7
- package/dist/credits/postgres/repositories/pricing.d.ts +0 -28
- package/dist/credits/postgres/repositories/pricing.d.ts.map +0 -1
- package/dist/credits/postgres/repositories/pricing.js +0 -76
- package/dist/credits/postgres/repositories/pricing.js.map +0 -1
- package/dist/credits/pricing-runtime.d.ts.map +0 -1
- package/dist/credits/pricing-runtime.js.map +0 -1
- package/dist/load-pricing-file.d.ts.map +0 -1
- package/dist/load-pricing-file.js.map +0 -1
|
@@ -8,6 +8,9 @@ export interface CreditMetadata {
|
|
|
8
8
|
referenceType?: string | null;
|
|
9
9
|
referenceId?: string | null;
|
|
10
10
|
idempotencyKey?: string | null;
|
|
11
|
+
providerRequestId?: string | null;
|
|
12
|
+
traceId?: string | null;
|
|
13
|
+
spanId?: string | null;
|
|
11
14
|
[key: string]: unknown;
|
|
12
15
|
}
|
|
13
16
|
export interface BucketDefinition {
|
|
@@ -41,19 +44,35 @@ export interface AddCreditsResult {
|
|
|
41
44
|
amount: Decimal;
|
|
42
45
|
newBalance: Decimal;
|
|
43
46
|
lifetimePurchased: Decimal;
|
|
44
|
-
bucket
|
|
47
|
+
/** Destination bucket for grants; `null` when a debit spans one or more lots. */
|
|
48
|
+
bucket: string | null;
|
|
45
49
|
idempotent: boolean;
|
|
46
50
|
}
|
|
47
|
-
|
|
48
|
-
entryId: string;
|
|
51
|
+
interface DeductionResultBase {
|
|
49
52
|
userId: string;
|
|
50
53
|
amount: Decimal;
|
|
51
54
|
allowanceConsumed: Decimal;
|
|
52
|
-
balanceAfter: Decimal;
|
|
53
55
|
idempotent: boolean;
|
|
54
|
-
error?: string | null;
|
|
55
|
-
bucketBreakdown?: Record<string, Decimal> | null;
|
|
56
56
|
}
|
|
57
|
+
/** A committed usage charge. Allowance-only charges legitimately have no ledger entry. */
|
|
58
|
+
export interface DeductionSuccess extends DeductionResultBase {
|
|
59
|
+
error: null;
|
|
60
|
+
entryId: string | null;
|
|
61
|
+
/** Canonical usage receipt, including zero-cost or allowance-only charges. */
|
|
62
|
+
usageChargeId: string | null;
|
|
63
|
+
balanceAfter: Decimal;
|
|
64
|
+
bucketBreakdown: Record<string, Decimal> | null;
|
|
65
|
+
}
|
|
66
|
+
/** An expected database rejection. Nullable fields were not committed and are not fabricated. */
|
|
67
|
+
export interface DeductionFailure extends DeductionResultBase {
|
|
68
|
+
error: string;
|
|
69
|
+
entryId: null;
|
|
70
|
+
usageChargeId: string | null;
|
|
71
|
+
balanceAfter: Decimal | null;
|
|
72
|
+
idempotent: false;
|
|
73
|
+
bucketBreakdown: null;
|
|
74
|
+
}
|
|
75
|
+
export type DeductionResult = DeductionSuccess | DeductionFailure;
|
|
57
76
|
export interface DeductWithAllowanceOptions {
|
|
58
77
|
idempotencyKey?: string | null;
|
|
59
78
|
operation?: string | null;
|
|
@@ -64,19 +83,38 @@ export interface DeductWithAllowanceOptions {
|
|
|
64
83
|
dimensions?: Record<string, unknown> | null;
|
|
65
84
|
metadata?: CreditMetadata | null;
|
|
66
85
|
}
|
|
67
|
-
|
|
68
|
-
refundEntryId: string;
|
|
86
|
+
interface RefundResultBase {
|
|
69
87
|
originalEntryId: string;
|
|
88
|
+
userId: string | null;
|
|
89
|
+
}
|
|
90
|
+
export interface RefundSuccess extends RefundResultBase {
|
|
91
|
+
error: null;
|
|
92
|
+
refundEntryId: string;
|
|
70
93
|
userId: string;
|
|
71
94
|
amount: Decimal;
|
|
72
95
|
newBalance: Decimal;
|
|
73
|
-
|
|
74
|
-
|
|
96
|
+
bucketBreakdown: Record<string, Decimal> | null;
|
|
97
|
+
}
|
|
98
|
+
export interface RefundFailure extends RefundResultBase {
|
|
99
|
+
error: string;
|
|
100
|
+
refundEntryId: null;
|
|
101
|
+
amount: Decimal | null;
|
|
102
|
+
newBalance: Decimal | null;
|
|
103
|
+
bucketBreakdown: null;
|
|
104
|
+
}
|
|
105
|
+
export type RefundResult = RefundSuccess | RefundFailure;
|
|
106
|
+
/** Credits removed from all remaining lots created by one ledger operation. */
|
|
107
|
+
export interface RevokeCreditsResult {
|
|
108
|
+
userId: string;
|
|
109
|
+
entryType: string;
|
|
110
|
+
revoked: Decimal;
|
|
111
|
+
balanceAfter: Decimal;
|
|
75
112
|
}
|
|
76
113
|
export interface SweepResult {
|
|
77
114
|
expiredCount: number;
|
|
78
115
|
expiredAmount: Decimal;
|
|
79
116
|
dryRun: boolean;
|
|
80
|
-
expiredByBucket
|
|
117
|
+
expiredByBucket: Record<string, Decimal>;
|
|
81
118
|
}
|
|
119
|
+
export {};
|
|
82
120
|
//# sourceMappingURL=account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/credits/types/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAC9E,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CA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Q,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC;AAED,UAAU,gBAAgB;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,KAAK,EAAE,IAAI,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,IAAI,CAAC;IACpB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,IAAI,CAAC;CACvB;AAED,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,aAAa,CAAC;AAEzD,+EAA+E;AAC/E,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/credits/types/account.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\nexport type BillingMode = \"strict\" | \"overdraft\";\n\nexport interface CreditMetadata {\n operation?: string | null;\n measures?: Record<string, unknown> | null;\n dimensions?: Record<string, string | number | boolean | Decimal.Value> | null;\n breakdownTotal?: string | null;\n referenceType?: string | null;\n referenceId?: string | null;\n idempotencyKey?: string | null;\n [key: string]: unknown;\n}\n\nexport interface BucketDefinition {\n label: string;\n priority: number;\n expires: boolean;\n ttlDays?: number | null;\n allowOverdraft?: boolean;\n default?: boolean;\n}\n\nexport interface BucketBalance {\n bucketKey: string;\n label: string;\n priority: number;\n expires: boolean;\n balance: Decimal;\n}\n\nexport interface BucketBalancesResult {\n userId: string;\n buckets: BucketBalance[];\n totalBalance: Decimal;\n}\n\nexport interface BalanceResult {\n userId: string;\n balance: Decimal;\n lifetimePurchased: Decimal;\n}\n\nexport interface AddCreditsResult {\n entryId: string;\n userId: string;\n amount: Decimal;\n newBalance: Decimal;\n lifetimePurchased: Decimal;\n bucket: string;\n idempotent: boolean;\n}\n\
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/credits/types/account.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\nexport type BillingMode = \"strict\" | \"overdraft\";\n\nexport interface CreditMetadata {\n operation?: string | null;\n measures?: Record<string, unknown> | null;\n dimensions?: Record<string, string | number | boolean | Decimal.Value> | null;\n breakdownTotal?: string | null;\n referenceType?: string | null;\n referenceId?: string | null;\n idempotencyKey?: string | null;\n providerRequestId?: string | null;\n traceId?: string | null;\n spanId?: string | null;\n [key: string]: unknown;\n}\n\nexport interface BucketDefinition {\n label: string;\n priority: number;\n expires: boolean;\n ttlDays?: number | null;\n allowOverdraft?: boolean;\n default?: boolean;\n}\n\nexport interface BucketBalance {\n bucketKey: string;\n label: string;\n priority: number;\n expires: boolean;\n balance: Decimal;\n}\n\nexport interface BucketBalancesResult {\n userId: string;\n buckets: BucketBalance[];\n totalBalance: Decimal;\n}\n\nexport interface BalanceResult {\n userId: string;\n balance: Decimal;\n lifetimePurchased: Decimal;\n}\n\nexport interface AddCreditsResult {\n entryId: string;\n userId: string;\n amount: Decimal;\n newBalance: Decimal;\n lifetimePurchased: Decimal;\n /** Destination bucket for grants; `null` when a debit spans one or more lots. */\n bucket: string | null;\n idempotent: boolean;\n}\n\ninterface DeductionResultBase {\n userId: string;\n amount: Decimal;\n allowanceConsumed: Decimal;\n idempotent: boolean;\n}\n\n/** A committed usage charge. Allowance-only charges legitimately have no ledger entry. */\nexport interface DeductionSuccess extends DeductionResultBase {\n error: null;\n entryId: string | null;\n /** Canonical usage receipt, including zero-cost or allowance-only charges. */\n usageChargeId: string | null;\n balanceAfter: Decimal;\n bucketBreakdown: Record<string, Decimal> | null;\n}\n\n/** An expected database rejection. Nullable fields were not committed and are not fabricated. */\nexport interface DeductionFailure extends DeductionResultBase {\n error: string;\n entryId: null;\n usageChargeId: string | null;\n balanceAfter: Decimal | null;\n idempotent: false;\n bucketBreakdown: null;\n}\n\nexport type DeductionResult = DeductionSuccess | DeductionFailure;\n\nexport interface DeductWithAllowanceOptions {\n idempotencyKey?: string | null;\n operation?: string | null;\n feature?: string | null;\n model?: string | null;\n region?: string | null;\n measures?: Record<string, unknown> | null;\n dimensions?: Record<string, unknown> | null;\n metadata?: CreditMetadata | null;\n}\n\ninterface RefundResultBase {\n originalEntryId: string;\n userId: string | null;\n}\n\nexport interface RefundSuccess extends RefundResultBase {\n error: null;\n refundEntryId: string;\n userId: string;\n amount: Decimal;\n newBalance: Decimal;\n bucketBreakdown: Record<string, Decimal> | null;\n}\n\nexport interface RefundFailure extends RefundResultBase {\n error: string;\n refundEntryId: null;\n amount: Decimal | null;\n newBalance: Decimal | null;\n bucketBreakdown: null;\n}\n\nexport type RefundResult = RefundSuccess | RefundFailure;\n\n/** Credits removed from all remaining lots created by one ledger operation. */\nexport interface RevokeCreditsResult {\n userId: string;\n entryType: string;\n revoked: Decimal;\n balanceAfter: Decimal;\n}\n\nexport interface SweepResult {\n expiredCount: number;\n expiredAmount: Decimal;\n dryRun: boolean;\n expiredByBucket: Record<string, Decimal>;\n}\n"]}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import type { Decimal } from "decimal.js";
|
|
2
2
|
import type { BillingMode } from "./account.js";
|
|
3
|
-
|
|
4
|
-
leaseId: string;
|
|
3
|
+
interface LeaseResultBase {
|
|
5
4
|
userId: string;
|
|
6
|
-
amount: Decimal;
|
|
7
5
|
available: Decimal;
|
|
8
6
|
reservedTotal: Decimal;
|
|
9
|
-
minimumBalance: Decimal;
|
|
10
7
|
billingMode: BillingMode;
|
|
8
|
+
}
|
|
9
|
+
export interface LeaseSuccess extends LeaseResultBase {
|
|
10
|
+
error: null;
|
|
11
|
+
leaseId: string;
|
|
12
|
+
amount: Decimal;
|
|
13
|
+
minimumBalance: Decimal;
|
|
11
14
|
expiresAt: string;
|
|
12
|
-
error?: string | null;
|
|
13
15
|
}
|
|
16
|
+
export interface LeaseFailure extends LeaseResultBase {
|
|
17
|
+
error: string;
|
|
18
|
+
leaseId: null;
|
|
19
|
+
amount: Decimal | null;
|
|
20
|
+
minimumBalance: Decimal | null;
|
|
21
|
+
expiresAt: null;
|
|
22
|
+
}
|
|
23
|
+
export type LeaseResult = LeaseSuccess | LeaseFailure;
|
|
14
24
|
/** Immutable pricing references captured when an operation lease is admitted. */
|
|
15
25
|
export interface LeasePricingContext {
|
|
16
26
|
catalogVersion: number;
|
|
@@ -22,7 +32,7 @@ export interface ReleaseResult {
|
|
|
22
32
|
leaseId: string;
|
|
23
33
|
userId: string;
|
|
24
34
|
released: boolean;
|
|
25
|
-
reason
|
|
35
|
+
reason: string | null;
|
|
26
36
|
}
|
|
27
37
|
export interface CanAffordResult {
|
|
28
38
|
affordable: boolean;
|
|
@@ -36,4 +46,5 @@ export interface AvailableResult {
|
|
|
36
46
|
reserved: Decimal;
|
|
37
47
|
available: Decimal;
|
|
38
48
|
}
|
|
49
|
+
export {};
|
|
39
50
|
//# sourceMappingURL=admission.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../../src/credits/types/admission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,
|
|
1
|
+
{"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../../src/credits/types/admission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,KAAK,EAAE,IAAI,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,cAAc,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;AAEtD,iFAAiF;AACjF,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admission.js","sourceRoot":"","sources":["../../../src/credits/types/admission.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\nimport type { BillingMode } from \"./account.js\";\n\
|
|
1
|
+
{"version":3,"file":"admission.js","sourceRoot":"","sources":["../../../src/credits/types/admission.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\nimport type { BillingMode } from \"./account.js\";\n\ninterface LeaseResultBase {\n userId: string;\n available: Decimal;\n reservedTotal: Decimal;\n billingMode: BillingMode;\n}\n\nexport interface LeaseSuccess extends LeaseResultBase {\n error: null;\n leaseId: string;\n amount: Decimal;\n minimumBalance: Decimal;\n expiresAt: string;\n}\n\nexport interface LeaseFailure extends LeaseResultBase {\n error: string;\n leaseId: null;\n amount: Decimal | null;\n minimumBalance: Decimal | null;\n expiresAt: null;\n}\n\nexport type LeaseResult = LeaseSuccess | LeaseFailure;\n\n/** Immutable pricing references captured when an operation lease is admitted. */\nexport interface LeasePricingContext {\n catalogVersion: number;\n planId: string | null;\n planKey: string | null;\n rateCard: string | null;\n}\n\nexport interface ReleaseResult {\n leaseId: string;\n userId: string;\n released: boolean;\n reason: string | null;\n}\n\nexport interface CanAffordResult {\n affordable: boolean;\n spendable: Decimal;\n worstCase: Decimal;\n reason?: string | null;\n}\n\nexport interface AvailableResult {\n userId: string;\n balance: Decimal;\n reserved: Decimal;\n available: Decimal;\n}\n"]}
|
|
@@ -28,8 +28,8 @@ export interface AggregateStats {
|
|
|
28
28
|
totalCreditsConsumed: Decimal;
|
|
29
29
|
activeUsers: number;
|
|
30
30
|
avgDailySpend: Decimal;
|
|
31
|
-
topModel: string;
|
|
32
|
-
topUser: string;
|
|
31
|
+
topModel: string | null;
|
|
32
|
+
topUser: string | null;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Read-only usage analytics backend.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../src/credits/types/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG5E,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,0CAA0C;AAC1C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,8DAA8D;AAC9D,MAAM,WAAW,cAAc;IAC7B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,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AE,CAAC,CAAC;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACvE,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC7D,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACjE;AAED,2EAA2E;AAC3E,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../src/credits/types/analytics.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\nimport type { ListUsageChargesOptions, UsageChargePage } from \"./ledger.js\";\n\n// ── Usage analytics ─────────────────────────────────────────────────\n/** Aggregated spend for a single user in a time window. */\nexport interface SpendByUserRow {\n userId: string;\n totalSpend: Decimal;\n entryCount: number;\n}\n\n/** Aggregated spend for a single model in a time window. */\nexport interface SpendByModelRow {\n model: string;\n totalSpend: Decimal;\n entryCount: number;\n}\n\n/** Top-spending user in a time window. */\nexport interface TopUserRow {\n userId: string;\n totalSpend: Decimal;\n}\n\n/** Daily spend aggregation in a time window. */\nexport interface DailySpendRow {\n date: string;\n totalSpend: Decimal;\n entryCount: number;\n}\n\n/** Aggregate statistics across all users in a time window. */\nexport interface AggregateStats {\n totalCreditsConsumed: Decimal;\n activeUsers: number;\n avgDailySpend: Decimal;\n topModel: string;\n topUser: string;\n}\n\n/**\n * Read-only usage analytics backend.\n *\n * PostgreSQL implements this contract by default. High-volume deployments can\n * provide a ClickHouse implementation without moving balances or compact\n * accounting receipts out of PostgreSQL.\n */\nexport interface UsageAnalyticsStore {\n spendByUser(start: Date, end: Date): Promise<SpendByUserRow[]>;\n spendByModel(start: Date, end: Date): Promise<SpendByModelRow[]>;\n topUsers(limit: number, start: Date, end: Date): Promise<TopUserRow[]>;\n dailySpend(start: Date, end: Date): Promise<DailySpendRow[]>;\n aggregateStats(start: Date, end: Date): Promise<AggregateStats>;\n}\n\n/** Read-only usage history backend selected with the analytics backend. */\nexport interface UsageChargeStore {\n listUsageCharges(userId: string, options?: ListUsageChargesOptions): Promise<UsageChargePage>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../src/credits/types/analytics.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\nimport type { ListUsageChargesOptions, UsageChargePage } from \"./ledger.js\";\n\n// ── Usage analytics ─────────────────────────────────────────────────\n/** Aggregated spend for a single user in a time window. */\nexport interface SpendByUserRow {\n userId: string;\n totalSpend: Decimal;\n entryCount: number;\n}\n\n/** Aggregated spend for a single model in a time window. */\nexport interface SpendByModelRow {\n model: string;\n totalSpend: Decimal;\n entryCount: number;\n}\n\n/** Top-spending user in a time window. */\nexport interface TopUserRow {\n userId: string;\n totalSpend: Decimal;\n}\n\n/** Daily spend aggregation in a time window. */\nexport interface DailySpendRow {\n date: string;\n totalSpend: Decimal;\n entryCount: number;\n}\n\n/** Aggregate statistics across all users in a time window. */\nexport interface AggregateStats {\n totalCreditsConsumed: Decimal;\n activeUsers: number;\n avgDailySpend: Decimal;\n topModel: string | null;\n topUser: string | null;\n}\n\n/**\n * Read-only usage analytics backend.\n *\n * PostgreSQL implements this contract by default. High-volume deployments can\n * provide a ClickHouse implementation without moving balances or compact\n * accounting receipts out of PostgreSQL.\n */\nexport interface UsageAnalyticsStore {\n spendByUser(start: Date, end: Date): Promise<SpendByUserRow[]>;\n spendByModel(start: Date, end: Date): Promise<SpendByModelRow[]>;\n topUsers(limit: number, start: Date, end: Date): Promise<TopUserRow[]>;\n dailySpend(start: Date, end: Date): Promise<DailySpendRow[]>;\n aggregateStats(start: Date, end: Date): Promise<AggregateStats>;\n}\n\n/** Read-only usage history backend selected with the analytics backend. */\nexport interface UsageChargeStore {\n listUsageCharges(userId: string, options?: ListUsageChargesOptions): Promise<UsageChargePage>;\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Decimal } from "decimal.js";
|
|
2
|
-
export interface
|
|
2
|
+
export interface CatalogRevision {
|
|
3
3
|
id: string;
|
|
4
4
|
config: Record<string, unknown>;
|
|
5
5
|
version: number;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface CatalogRevisionSummary {
|
|
8
8
|
id: string;
|
|
9
9
|
version: number;
|
|
10
10
|
label: string | null;
|
|
@@ -12,13 +12,12 @@ export interface BursarConfigHistoryItem {
|
|
|
12
12
|
createdAt: string;
|
|
13
13
|
}
|
|
14
14
|
export interface PlanAllowancePolicy {
|
|
15
|
-
amount: Decimal
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
resetTimezone: string | null;
|
|
15
|
+
amount: Decimal;
|
|
16
|
+
priority: number;
|
|
17
|
+
resetUnit: "second" | "minute" | "hour" | "day" | "week" | "month" | "year";
|
|
18
|
+
resetCount: number;
|
|
19
|
+
resetAnchor: "calendar" | "plan_assignment" | "rolling";
|
|
20
|
+
resetTimezone: string;
|
|
22
21
|
}
|
|
23
22
|
export interface PlanCreditPolicy {
|
|
24
23
|
type: "prepaid" | "credit_line";
|
|
@@ -45,20 +44,26 @@ export interface GetUserPlanResult {
|
|
|
45
44
|
entitlements: Record<string, {
|
|
46
45
|
value: unknown;
|
|
47
46
|
}>;
|
|
48
|
-
rateCard
|
|
47
|
+
rateCard: string | null;
|
|
49
48
|
creditPolicy: PlanCreditPolicy | null;
|
|
50
49
|
admission: PlanAdmissionPolicy | null;
|
|
51
50
|
allowedOperations: string[];
|
|
52
|
-
planAssignedAt
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
planAssignedAt: Date | null;
|
|
52
|
+
planAssignmentEndsAt: Date | null;
|
|
53
|
+
assignmentSourceType: "manual" | "subscription" | "migration" | "system" | null;
|
|
54
|
+
assignmentSourceId: string | null;
|
|
55
55
|
catalogRevisionPinned: boolean;
|
|
56
|
-
catalogVersion
|
|
56
|
+
catalogVersion: number | null;
|
|
57
57
|
}
|
|
58
58
|
export interface SetUserPlanResult {
|
|
59
59
|
userId: string;
|
|
60
60
|
planId: string;
|
|
61
|
-
|
|
61
|
+
planKey: string;
|
|
62
|
+
planAssignedAt: Date;
|
|
63
|
+
assignmentState: "applied" | "scheduled";
|
|
64
|
+
}
|
|
65
|
+
export interface UnsetUserPlanResult {
|
|
66
|
+
userId: string;
|
|
62
67
|
}
|
|
63
68
|
export interface PlanMigrationStartResult {
|
|
64
69
|
migrationId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/credits/types/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/credits/types/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC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,EAAE,MAAM,EAAE,CAAC;IAC5B,cAAc,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,oBAAoB,EAAE,IAAI,GAAG,IAAI,CAAC;IAClC,oBAAoB,EAAE,QAAQ,GAAG,cAAc,GAAG,WAAW,GAAG,QAAQ,GAAG,IAAI,CAAC;IAChF,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,IAAI,CAAC;IACrB,eAAe,EAAE,SAAS,GAAG,WAAW,CAAC;CAC1C;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/credits/types/catalog.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\nexport interface
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/credits/types/catalog.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\nexport interface CatalogRevision {\n id: string;\n config: Record<string, unknown>;\n version: number;\n}\n\nexport interface CatalogRevisionSummary {\n id: string;\n version: number;\n label: string | null;\n active: boolean;\n createdAt: string;\n}\n\nexport interface PlanAllowancePolicy {\n amount: Decimal;\n priority: number;\n resetUnit: \"second\" | \"minute\" | \"hour\" | \"day\" | \"week\" | \"month\" | \"year\";\n resetCount: number;\n resetAnchor: \"calendar\" | \"plan_assignment\" | \"rolling\";\n resetTimezone: string;\n}\n\nexport interface PlanCreditPolicy {\n type: \"prepaid\" | \"credit_line\";\n creditLimit: Decimal | null;\n}\n\nexport interface PlanAdmissionPolicy {\n maxInFlight: number | null;\n operations: Record<string, { maxInFlight: number | null }>;\n}\n\nexport interface AllowanceResult {\n planId: string;\n allowanceRemaining: Decimal;\n periodStart: string;\n periodEnd: string;\n}\n\nexport interface GetUserPlanResult {\n userId: string;\n planId: string | null;\n planKey: string | null;\n planLabel: string | null;\n allowance: PlanAllowancePolicy | null;\n entitlements: Record<string, { value: unknown }>;\n rateCard: string | null;\n creditPolicy: PlanCreditPolicy | null;\n admission: PlanAdmissionPolicy | null;\n allowedOperations: string[];\n planAssignedAt: Date | null;\n planAssignmentEndsAt: Date | null;\n assignmentSourceType: \"manual\" | \"subscription\" | \"migration\" | \"system\" | null;\n assignmentSourceId: string | null;\n catalogRevisionPinned: boolean;\n catalogVersion: number | null;\n}\n\nexport interface SetUserPlanResult {\n userId: string;\n planId: string;\n planKey: string;\n planAssignedAt: Date;\n assignmentState: \"applied\" | \"scheduled\";\n}\n\nexport interface UnsetUserPlanResult {\n userId: string;\n}\n\nexport interface PlanMigrationStartResult {\n migrationId: string;\n}\n\nexport interface PlanMigrationBatchResult {\n migrated: number;\n done: boolean;\n nextCursor: string | null;\n}\n"]}
|
|
@@ -11,14 +11,28 @@ export interface ExecuteGrantProgramRequest {
|
|
|
11
11
|
region?: string | null;
|
|
12
12
|
metadata?: CreditMetadata | null;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
export interface GrantProgramAwardResult {
|
|
16
|
-
grantEventId: string | null;
|
|
17
|
-
grantAwardId: string | null;
|
|
18
|
-
recipientSubjectId: string | null;
|
|
19
|
-
ledgerEntryId: string | null;
|
|
20
|
-
amount: Decimal;
|
|
14
|
+
interface GrantProgramAwardBase {
|
|
21
15
|
replayed: boolean;
|
|
22
|
-
error?: string | null;
|
|
23
16
|
}
|
|
17
|
+
/** One committed award produced by a grant-program execution. */
|
|
18
|
+
export interface GrantProgramAwardSuccess extends GrantProgramAwardBase {
|
|
19
|
+
grantEventId: string;
|
|
20
|
+
grantAwardId: string;
|
|
21
|
+
recipientSubjectId: string;
|
|
22
|
+
ledgerEntryId: string;
|
|
23
|
+
amount: Decimal;
|
|
24
|
+
error: null;
|
|
25
|
+
}
|
|
26
|
+
/** A rejected grant-program execution. No financial identifiers are fabricated. */
|
|
27
|
+
export interface GrantProgramAwardFailure extends GrantProgramAwardBase {
|
|
28
|
+
grantEventId: null;
|
|
29
|
+
grantAwardId: null;
|
|
30
|
+
recipientSubjectId: null;
|
|
31
|
+
ledgerEntryId: null;
|
|
32
|
+
amount: null;
|
|
33
|
+
replayed: false;
|
|
34
|
+
error: string;
|
|
35
|
+
}
|
|
36
|
+
export type GrantProgramAwardResult = GrantProgramAwardSuccess | GrantProgramAwardFailure;
|
|
37
|
+
export {};
|
|
24
38
|
//# sourceMappingURL=grants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../../src/credits/types/grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../../src/credits/types/grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAC3B,iBAAiB,GACjB,oBAAoB,GACpB,qBAAqB,GACrB,QAAQ,CAAC;AAEb,uEAAuE;AACvE,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC;AAED,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,iEAAiE;AACjE,MAAM,WAAW,wBAAyB,SAAQ,qBAAqB;IACrE,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;CACb;AAED,mFAAmF;AACnF,MAAM,WAAW,wBAAyB,SAAQ,qBAAqB;IACrE,YAAY,EAAE,IAAI,CAAC;IACnB,YAAY,EAAE,IAAI,CAAC;IACnB,kBAAkB,EAAE,IAAI,CAAC;IACzB,aAAa,EAAE,IAAI,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,uBAAuB,GAAG,wBAAwB,GAAG,wBAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../../../src/credits/types/grants.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\nimport type { CreditMetadata } from \"./account.js\";\n\nexport type GrantProgramTrigger =\n \"account_created\"
|
|
1
|
+
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../../../src/credits/types/grants.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\nimport type { CreditMetadata } from \"./account.js\";\n\nexport type GrantProgramTrigger =\n | \"account_created\"\n | \"referral_completed\"\n | \"promo_code_redeemed\"\n | \"manual\";\n\n/** One application event that may award one or more catalog grants. */\nexport interface ExecuteGrantProgramRequest {\n trigger: GrantProgramTrigger;\n programKey: string;\n subjectId: string;\n eventKey: string;\n referrerSubjectId?: string | null;\n region?: string | null;\n metadata?: CreditMetadata | null;\n}\n\ninterface GrantProgramAwardBase {\n replayed: boolean;\n}\n\n/** One committed award produced by a grant-program execution. */\nexport interface GrantProgramAwardSuccess extends GrantProgramAwardBase {\n grantEventId: string;\n grantAwardId: string;\n recipientSubjectId: string;\n ledgerEntryId: string;\n amount: Decimal;\n error: null;\n}\n\n/** A rejected grant-program execution. No financial identifiers are fabricated. */\nexport interface GrantProgramAwardFailure extends GrantProgramAwardBase {\n grantEventId: null;\n grantAwardId: null;\n recipientSubjectId: null;\n ledgerEntryId: null;\n amount: null;\n replayed: false;\n error: string;\n}\n\nexport type GrantProgramAwardResult = GrantProgramAwardSuccess | GrantProgramAwardFailure;\n"]}
|
|
@@ -70,13 +70,21 @@ export interface UsageChargePage {
|
|
|
70
70
|
nextCursor: UsageChargeCursor | null;
|
|
71
71
|
}
|
|
72
72
|
/** Result of appending a usage event without creating another balance debit. */
|
|
73
|
-
|
|
74
|
-
usageId: string;
|
|
73
|
+
interface UsageRecordResultBase {
|
|
75
74
|
userId: string;
|
|
76
75
|
requested: Decimal;
|
|
77
76
|
idempotent: boolean;
|
|
78
|
-
error?: string | null;
|
|
79
77
|
}
|
|
78
|
+
export interface UsageRecordSuccess extends UsageRecordResultBase {
|
|
79
|
+
error: null;
|
|
80
|
+
usageId: string;
|
|
81
|
+
}
|
|
82
|
+
export interface UsageRecordFailure extends UsageRecordResultBase {
|
|
83
|
+
error: string;
|
|
84
|
+
usageId: null;
|
|
85
|
+
idempotent: false;
|
|
86
|
+
}
|
|
87
|
+
export type UsageRecordResult = UsageRecordSuccess | UsageRecordFailure;
|
|
80
88
|
/** Cursor-only options for the usage-only ledger view. */
|
|
81
89
|
export interface ListUsageEntriesOptions {
|
|
82
90
|
fromDate?: Date;
|
|
@@ -84,4 +92,5 @@ export interface ListUsageEntriesOptions {
|
|
|
84
92
|
limit?: number;
|
|
85
93
|
cursor?: LedgerCursor | null;
|
|
86
94
|
}
|
|
95
|
+
export {};
|
|
87
96
|
//# sourceMappingURL=ledger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../src/credits/types/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,kEAAkE;AAClE,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,8DAA8D;AAC9D,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC9B;AAED,8BAA8B;AAC9B,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M,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/credits/types/ledger.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\n// ── Canonical ledger history ─────────────────────────────────────────\n\n/** One immutable monetary entry on a canonical credit account. */\nexport interface LedgerEntry {\n entryId: string;\n accountId: string;\n actorUserId: string | null;\n amount: Decimal;\n entryType: string;\n operation: string;\n referenceEntryId: string | null;\n idempotencyKey: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n}\n\n/** Stable position in an account ledger. */\nexport interface LedgerCursor {\n createdAt: string;\n entryId: string;\n}\n\n/** Cursor-only options for listing account ledger entries. */\nexport interface ListLedgerEntriesOptions {\n entryTypes?: string[];\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n cursor?: LedgerCursor | null;\n}\n\n/** One stable cursor page. */\nexport interface LedgerPage {\n items: LedgerEntry[];\n nextCursor: LedgerCursor | null;\n}\n\n/**\n * A metered usage charge from the usage charge journal.\n *\n * Usage charges are deliberately separate from ledger entries: included\n * allowance consumption does not create a monetary ledger debit, but it is\n * still a billable usage event that belongs in the usage history.\n */\nexport interface UsageCharge {\n usageId: string;\n accountId: string;\n operation: string;\n requested: Decimal;\n charged: Decimal;\n allowanceRequested: Decimal;\n allowanceCovered: Decimal;\n billingDisposition: \"billable\" | \"record_only\";\n feature: string | null;\n model: string | null;\n region: string | null;\n eventAt: string;\n idempotencyKey: string;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n}\n\nexport interface UsageChargeCursor {\n eventAt: string;\n usageId: string;\n}\n\nexport interface ListUsageChargesOptions {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n cursor?: UsageChargeCursor | null;\n includeRecordOnly?: boolean;\n}\n\nexport interface UsageChargePage {\n items: UsageCharge[];\n nextCursor: UsageChargeCursor | null;\n}\n\n/** Result of appending a usage event without creating another balance debit. */\nexport interface
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/credits/types/ledger.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\n// ── Canonical ledger history ─────────────────────────────────────────\n\n/** One immutable monetary entry on a canonical credit account. */\nexport interface LedgerEntry {\n entryId: string;\n accountId: string;\n actorUserId: string | null;\n amount: Decimal;\n entryType: string;\n operation: string;\n referenceEntryId: string | null;\n idempotencyKey: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n}\n\n/** Stable position in an account ledger. */\nexport interface LedgerCursor {\n createdAt: string;\n entryId: string;\n}\n\n/** Cursor-only options for listing account ledger entries. */\nexport interface ListLedgerEntriesOptions {\n entryTypes?: string[];\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n cursor?: LedgerCursor | null;\n}\n\n/** One stable cursor page. */\nexport interface LedgerPage {\n items: LedgerEntry[];\n nextCursor: LedgerCursor | null;\n}\n\n/**\n * A metered usage charge from the usage charge journal.\n *\n * Usage charges are deliberately separate from ledger entries: included\n * allowance consumption does not create a monetary ledger debit, but it is\n * still a billable usage event that belongs in the usage history.\n */\nexport interface UsageCharge {\n usageId: string;\n accountId: string;\n operation: string;\n requested: Decimal;\n charged: Decimal;\n allowanceRequested: Decimal;\n allowanceCovered: Decimal;\n billingDisposition: \"billable\" | \"record_only\";\n feature: string | null;\n model: string | null;\n region: string | null;\n eventAt: string;\n idempotencyKey: string;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n}\n\nexport interface UsageChargeCursor {\n eventAt: string;\n usageId: string;\n}\n\nexport interface ListUsageChargesOptions {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n cursor?: UsageChargeCursor | null;\n includeRecordOnly?: boolean;\n}\n\nexport interface UsageChargePage {\n items: UsageCharge[];\n nextCursor: UsageChargeCursor | null;\n}\n\n/** Result of appending a usage event without creating another balance debit. */\ninterface UsageRecordResultBase {\n userId: string;\n requested: Decimal;\n idempotent: boolean;\n}\n\nexport interface UsageRecordSuccess extends UsageRecordResultBase {\n error: null;\n usageId: string;\n}\n\nexport interface UsageRecordFailure extends UsageRecordResultBase {\n error: string;\n usageId: null;\n idempotent: false;\n}\n\nexport type UsageRecordResult = UsageRecordSuccess | UsageRecordFailure;\n\n/** Cursor-only options for the usage-only ledger view. */\nexport interface ListUsageEntriesOptions {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n cursor?: LedgerCursor | null;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Decimal } from "decimal.js";
|
|
2
|
+
export type TeamRole = "owner" | "admin" | "member";
|
|
2
3
|
/** A team with a shared credit balance pool. */
|
|
3
4
|
export interface Team {
|
|
4
5
|
id: string;
|
|
@@ -10,8 +11,8 @@ export interface Team {
|
|
|
10
11
|
/** A member of a team, with optional spend cap. */
|
|
11
12
|
export interface TeamMember {
|
|
12
13
|
userId: string;
|
|
13
|
-
role:
|
|
14
|
-
spendCap
|
|
14
|
+
role: TeamRole;
|
|
15
|
+
spendCap: Decimal | null;
|
|
15
16
|
totalSpent: Decimal;
|
|
16
17
|
}
|
|
17
18
|
/** Result of fetching team balance. */
|
|
@@ -30,15 +31,26 @@ export interface CreateTeamResult {
|
|
|
30
31
|
export interface AddTeamMemberResult {
|
|
31
32
|
teamId: string;
|
|
32
33
|
userId: string;
|
|
33
|
-
role:
|
|
34
|
+
role: TeamRole;
|
|
34
35
|
}
|
|
35
36
|
/** Result of deducting credits from a team pool. */
|
|
36
|
-
|
|
37
|
-
entryId: string;
|
|
37
|
+
interface TeamDeductionResultBase {
|
|
38
38
|
teamId: string;
|
|
39
39
|
userId: string;
|
|
40
40
|
amount: Decimal;
|
|
41
|
+
idempotent: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface TeamDeductionSuccess extends TeamDeductionResultBase {
|
|
44
|
+
error: null;
|
|
45
|
+
entryId: string | null;
|
|
41
46
|
teamBalanceAfter: Decimal;
|
|
42
|
-
error?: string | null;
|
|
43
47
|
}
|
|
48
|
+
export interface TeamDeductionFailure extends TeamDeductionResultBase {
|
|
49
|
+
error: string;
|
|
50
|
+
entryId: null;
|
|
51
|
+
teamBalanceAfter: Decimal | null;
|
|
52
|
+
idempotent: false;
|
|
53
|
+
}
|
|
54
|
+
export type TeamDeductionResult = TeamDeductionSuccess | TeamDeductionFailure;
|
|
55
|
+
export {};
|
|
44
56
|
//# sourceMappingURL=teams.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"teams.d.ts","sourceRoot":"","sources":["../../../src/credits/types/teams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"teams.d.ts","sourceRoot":"","sources":["../../../src/credits/types/teams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAGpD,gDAAgD;AAChD,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,mDAAmD;AACnD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,uCAAuC;AACvC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,iCAAiC;AACjC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,oDAAoD;AACpD,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,oBAAqB,SAAQ,uBAAuB;IACnE,KAAK,EAAE,IAAI,CAAC;IACZ,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAqB,SAAQ,uBAAuB;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,IAAI,CAAC;IACd,gBAAgB,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE,KAAK,CAAC;CACnB;AAED,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"teams.js","sourceRoot":"","sources":["../../../src/credits/types/teams.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\n// ── Team/shared balance pools ─────────────────────────────────────────\n/** A team with a shared credit balance pool. */\nexport interface Team {\n id: string;\n name: string;\n balance: Decimal;\n memberCount: number;\n createdAt: string;\n}\n\n/** A member of a team, with optional spend cap. */\nexport interface TeamMember {\n userId: string;\n role:
|
|
1
|
+
{"version":3,"file":"teams.js","sourceRoot":"","sources":["../../../src/credits/types/teams.ts"],"names":[],"mappings":"","sourcesContent":["import type { Decimal } from \"decimal.js\";\n\nexport type TeamRole = \"owner\" | \"admin\" | \"member\";\n\n// ── Team/shared balance pools ─────────────────────────────────────────\n/** A team with a shared credit balance pool. */\nexport interface Team {\n id: string;\n name: string;\n balance: Decimal;\n memberCount: number;\n createdAt: string;\n}\n\n/** A member of a team, with optional spend cap. */\nexport interface TeamMember {\n userId: string;\n role: TeamRole;\n spendCap: Decimal | null;\n totalSpent: Decimal;\n}\n\n/** Result of fetching team balance. */\nexport interface TeamBalanceResult {\n teamId: string;\n name: string;\n balance: Decimal;\n memberCount: number;\n}\n\n/** Result of creating a team. */\nexport interface CreateTeamResult {\n teamId: string;\n name: string;\n}\n\n/** Result of adding a team member. */\nexport interface AddTeamMemberResult {\n teamId: string;\n userId: string;\n role: TeamRole;\n}\n\n/** Result of deducting credits from a team pool. */\ninterface TeamDeductionResultBase {\n teamId: string;\n userId: string;\n amount: Decimal;\n idempotent: boolean;\n}\n\nexport interface TeamDeductionSuccess extends TeamDeductionResultBase {\n error: null;\n entryId: string | null;\n teamBalanceAfter: Decimal;\n}\n\nexport interface TeamDeductionFailure extends TeamDeductionResultBase {\n error: string;\n entryId: null;\n teamBalanceAfter: Decimal | null;\n idempotent: false;\n}\n\nexport type TeamDeductionResult = TeamDeductionSuccess | TeamDeductionFailure;\n"]}
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAIL,KAAK,gBAAgB,EAGrB,KAAK,kBAAkB,EAExB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAIL,KAAK,gBAAgB,EAGrB,KAAK,kBAAkB,EAExB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAcjD,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,kBAAkB;IAEvD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;IAIhF,IAAI,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE3C;IAED,SAAS,CACP,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAS,GAClE,aAAa;IAiFhB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,aAAa,EAAE;IAI7F,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS;IAKzE,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,cAAc;CA6CvB"}
|
package/dist/engine.js
CHANGED
|
@@ -4,6 +4,13 @@ import { canonicalParsedBursarConfigDict, loadConfigFromDict, } from "./config.j
|
|
|
4
4
|
import { ConfigError } from "./errors.js";
|
|
5
5
|
import { evaluateExpression } from "./expr.js";
|
|
6
6
|
const quantize = (value) => value.toDecimalPlaces(6, Decimal.ROUND_HALF_UP);
|
|
7
|
+
function requiredMeasure(measures, name) {
|
|
8
|
+
const measure = measures[name];
|
|
9
|
+
if (measure === undefined) {
|
|
10
|
+
throw new ConfigError(`price charge references missing usage measure '${name}'`);
|
|
11
|
+
}
|
|
12
|
+
return measure;
|
|
13
|
+
}
|
|
7
14
|
export class PricingEngine {
|
|
8
15
|
config;
|
|
9
16
|
constructor(config) {
|
|
@@ -101,14 +108,18 @@ export class PricingEngine {
|
|
|
101
108
|
return requested;
|
|
102
109
|
}
|
|
103
110
|
const keys = Object.keys(cards);
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
const onlyCard = keys[0];
|
|
112
|
+
if (keys.length === 1 && onlyCard !== undefined)
|
|
113
|
+
return onlyCard;
|
|
106
114
|
throw new ConfigError("rateCard is required when more than one rate card is configured");
|
|
107
115
|
}
|
|
108
116
|
operationPricing(cardKey, operation) {
|
|
109
117
|
const card = this.config.pricing.rateCards[cardKey];
|
|
110
|
-
if (card
|
|
111
|
-
|
|
118
|
+
if (!card)
|
|
119
|
+
throw new ConfigError(`unknown rate card '${cardKey}'`);
|
|
120
|
+
const operationPrice = card.operations[operation];
|
|
121
|
+
if (operationPrice)
|
|
122
|
+
return operationPrice;
|
|
112
123
|
if (!card.extends)
|
|
113
124
|
throw new ConfigError(`rate card '${cardKey}' has no price for operation '${operation}'`);
|
|
114
125
|
return this.operationPricing(card.extends, operation);
|
|
@@ -154,9 +165,9 @@ export class PricingEngine {
|
|
|
154
165
|
if (charge.type === "flat")
|
|
155
166
|
return charge.amount;
|
|
156
167
|
if (charge.type === "per_unit")
|
|
157
|
-
return measures
|
|
168
|
+
return requiredMeasure(measures, charge.measure).div(charge.unitSize).mul(charge.rate);
|
|
158
169
|
if (charge.type === "package") {
|
|
159
|
-
const packages = measures
|
|
170
|
+
const packages = requiredMeasure(measures, charge.measure).div(charge.units);
|
|
160
171
|
const rounded = charge.rounding === "ceil"
|
|
161
172
|
? packages.ceil()
|
|
162
173
|
: charge.rounding === "floor"
|
|
@@ -165,7 +176,7 @@ export class PricingEngine {
|
|
|
165
176
|
return rounded.mul(charge.amount);
|
|
166
177
|
}
|
|
167
178
|
if (charge.type === "graduated") {
|
|
168
|
-
let remaining = measures
|
|
179
|
+
let remaining = requiredMeasure(measures, charge.measure);
|
|
169
180
|
let previous = new Decimal(0);
|
|
170
181
|
let total = new Decimal(0);
|
|
171
182
|
for (const tier of charge.tiers) {
|
|
@@ -182,9 +193,12 @@ export class PricingEngine {
|
|
|
182
193
|
return total;
|
|
183
194
|
}
|
|
184
195
|
if (charge.type === "volume") {
|
|
185
|
-
const value = measures
|
|
186
|
-
const tier = charge.tiers.find((candidate) => candidate.upTo == null || value.lte(candidate.upTo))
|
|
187
|
-
|
|
196
|
+
const value = requiredMeasure(measures, charge.measure);
|
|
197
|
+
const tier = charge.tiers.find((candidate) => candidate.upTo == null || value.lte(candidate.upTo)) ??
|
|
198
|
+
charge.tiers.at(-1);
|
|
199
|
+
if (!tier)
|
|
200
|
+
throw new ConfigError("volume charge requires at least one tier");
|
|
201
|
+
return value.mul(tier.rate);
|
|
188
202
|
}
|
|
189
203
|
if (charge.type === "expression")
|
|
190
204
|
return evaluateExpression(charge.formula, measures);
|