@zonastery/bursar 1.0.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { CallProc } from "../../../shared/postgres-types.js";
|
|
3
3
|
declare const SpendByUserRowSchema: z.ZodObject<{
|
|
4
|
-
user_id: z.
|
|
5
|
-
total_spend: z.
|
|
6
|
-
entry_count: z.
|
|
7
|
-
}, z.core.$
|
|
4
|
+
user_id: z.ZodString;
|
|
5
|
+
total_spend: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
6
|
+
entry_count: z.ZodUnion<readonly [z.ZodNumber, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
8
|
declare const SpendByModelRowSchema: z.ZodObject<{
|
|
9
|
-
model: z.
|
|
10
|
-
total_spend: z.
|
|
11
|
-
entry_count: z.
|
|
12
|
-
}, z.core.$
|
|
9
|
+
model: z.ZodString;
|
|
10
|
+
total_spend: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
11
|
+
entry_count: z.ZodUnion<readonly [z.ZodNumber, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
13
|
declare const TopUserRowSchema: z.ZodObject<{
|
|
14
|
-
user_id: z.
|
|
15
|
-
total_spend: z.
|
|
16
|
-
}, z.core.$
|
|
14
|
+
user_id: z.ZodString;
|
|
15
|
+
total_spend: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
17
|
declare const DailySpendRowSchema: z.ZodObject<{
|
|
18
|
-
date: z.
|
|
19
|
-
total_spend: z.
|
|
20
|
-
entry_count: z.
|
|
21
|
-
}, z.core.$
|
|
18
|
+
date: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodDate, z.ZodTransform<string, Date>>]>;
|
|
19
|
+
total_spend: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
20
|
+
entry_count: z.ZodUnion<readonly [z.ZodNumber, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
22
|
declare const AggregateStatsRowSchema: z.ZodObject<{
|
|
23
|
-
total_credits_consumed: z.
|
|
24
|
-
active_users: z.
|
|
25
|
-
avg_daily_spend: z.
|
|
26
|
-
top_model: z.
|
|
27
|
-
top_user: z.
|
|
28
|
-
}, z.core.$
|
|
23
|
+
total_credits_consumed: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
24
|
+
active_users: z.ZodUnion<readonly [z.ZodNumber, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>;
|
|
25
|
+
avg_daily_spend: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
26
|
+
top_model: z.ZodNullable<z.ZodString>;
|
|
27
|
+
top_user: z.ZodNullable<z.ZodString>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
29
|
declare const LedgerEntryRowSchema: z.ZodObject<{
|
|
30
30
|
entry_id: z.ZodString;
|
|
31
31
|
account_id: z.ZodString;
|
|
32
|
-
actor_user_id: z.
|
|
32
|
+
actor_user_id: z.ZodNullable<z.ZodString>;
|
|
33
33
|
amount: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
34
34
|
entry_type: z.ZodString;
|
|
35
35
|
operation: z.ZodString;
|
|
36
|
-
reference_entry_id: z.
|
|
37
|
-
idempotency_key: z.
|
|
38
|
-
metadata: z.
|
|
39
|
-
created_at: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
|
|
40
|
-
}, z.core.$
|
|
36
|
+
reference_entry_id: z.ZodNullable<z.ZodString>;
|
|
37
|
+
idempotency_key: z.ZodNullable<z.ZodString>;
|
|
38
|
+
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
39
|
+
created_at: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodDate, z.ZodTransform<string, Date>>]>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
41
|
declare const UsageChargeRowSchema: z.ZodObject<{
|
|
42
42
|
usage_id: z.ZodString;
|
|
43
43
|
account_id: z.ZodString;
|
|
@@ -50,14 +50,14 @@ declare const UsageChargeRowSchema: z.ZodObject<{
|
|
|
50
50
|
billable: "billable";
|
|
51
51
|
record_only: "record_only";
|
|
52
52
|
}>;
|
|
53
|
-
feature: z.
|
|
54
|
-
model: z.
|
|
55
|
-
region: z.
|
|
56
|
-
event_at: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
|
|
53
|
+
feature: z.ZodNullable<z.ZodString>;
|
|
54
|
+
model: z.ZodNullable<z.ZodString>;
|
|
55
|
+
region: z.ZodNullable<z.ZodString>;
|
|
56
|
+
event_at: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodDate, z.ZodTransform<string, Date>>]>;
|
|
57
57
|
idempotency_key: z.ZodString;
|
|
58
|
-
metadata: z.
|
|
59
|
-
created_at: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
|
|
60
|
-
}, z.core.$
|
|
58
|
+
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
59
|
+
created_at: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodDate, z.ZodTransform<string, Date>>]>;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
61
|
export type SpendByUserRow = z.infer<typeof SpendByUserRowSchema>;
|
|
62
62
|
export type SpendByModelRow = z.infer<typeof SpendByModelRowSchema>;
|
|
63
63
|
export type TopUserRow = z.infer<typeof TopUserRowSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../../src/credits/postgres/repositories/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../../src/credits/postgres/repositories/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAclE,QAAA,MAAM,oBAAoB;;;;kBAMf,CAAC;AAEZ,QAAA,MAAM,qBAAqB;;;;kBAMhB,CAAC;AAEZ,QAAA,MAAM,gBAAgB;;;kBAA0E,CAAC;AAEjG,QAAA,MAAM,mBAAmB;;;;kBAMd,CAAC;AAEZ,QAAA,MAAM,uBAAuB;;;;;;kBAQlB,CAAC;AAEZ,QAAA,MAAM,oBAAoB;;;;;;;;;;;kBAaf,CAAC;AAEZ,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;kBAkBf,CAAC;AAEZ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,M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AE,MAAM,GAAG,IAAI,EAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,iBAAiB,EAAE,OAAO,GACzB,OAAO,CAAC,cAAc,EAAE,CAAC;CAiB7B"}
|
|
@@ -1,53 +1,60 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { safeParse } from "../../../shared/postgres-validation.js";
|
|
3
|
-
const decimal = z.union([z.string(), z.number()]);
|
|
2
|
+
import { optionalRecordRow, requireRow, safeParse } from "../../../shared/postgres-validation.js";
|
|
3
|
+
const decimal = z.union([z.string().min(1), z.number().finite()]);
|
|
4
|
+
const count = z.union([
|
|
5
|
+
z.number().int().nonnegative(),
|
|
6
|
+
z.string().regex(/^\d+$/).transform(Number),
|
|
7
|
+
]);
|
|
8
|
+
const timestamp = z.union([z.string().min(1), z.date().transform((value) => value.toISOString())]);
|
|
9
|
+
const calendarDate = z.union([
|
|
10
|
+
z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
11
|
+
z.date().transform((value) => value.toISOString().slice(0, 10)),
|
|
12
|
+
]);
|
|
4
13
|
const SpendByUserRowSchema = z
|
|
5
14
|
.object({
|
|
6
|
-
user_id: z.string().
|
|
7
|
-
total_spend: decimal
|
|
8
|
-
entry_count:
|
|
15
|
+
user_id: z.string().min(1),
|
|
16
|
+
total_spend: decimal,
|
|
17
|
+
entry_count: count,
|
|
9
18
|
})
|
|
10
|
-
.
|
|
19
|
+
.strict();
|
|
11
20
|
const SpendByModelRowSchema = z
|
|
12
21
|
.object({
|
|
13
|
-
model: z.string().
|
|
14
|
-
total_spend: decimal
|
|
15
|
-
entry_count:
|
|
22
|
+
model: z.string().min(1),
|
|
23
|
+
total_spend: decimal,
|
|
24
|
+
entry_count: count,
|
|
16
25
|
})
|
|
17
|
-
.
|
|
18
|
-
const TopUserRowSchema = z
|
|
19
|
-
.object({ user_id: z.string().optional(), total_spend: decimal.nullable().optional() })
|
|
20
|
-
.passthrough();
|
|
26
|
+
.strict();
|
|
27
|
+
const TopUserRowSchema = z.object({ user_id: z.string().min(1), total_spend: decimal }).strict();
|
|
21
28
|
const DailySpendRowSchema = z
|
|
22
29
|
.object({
|
|
23
|
-
date:
|
|
24
|
-
total_spend: decimal
|
|
25
|
-
entry_count:
|
|
30
|
+
date: calendarDate,
|
|
31
|
+
total_spend: decimal,
|
|
32
|
+
entry_count: count,
|
|
26
33
|
})
|
|
27
|
-
.
|
|
34
|
+
.strict();
|
|
28
35
|
const AggregateStatsRowSchema = z
|
|
29
36
|
.object({
|
|
30
|
-
total_credits_consumed: decimal
|
|
31
|
-
active_users:
|
|
32
|
-
avg_daily_spend: decimal
|
|
33
|
-
top_model: z.string().
|
|
34
|
-
top_user: z.string().
|
|
37
|
+
total_credits_consumed: decimal,
|
|
38
|
+
active_users: count,
|
|
39
|
+
avg_daily_spend: decimal,
|
|
40
|
+
top_model: z.string().min(1).nullable(),
|
|
41
|
+
top_user: z.string().min(1).nullable(),
|
|
35
42
|
})
|
|
36
|
-
.
|
|
43
|
+
.strict();
|
|
37
44
|
const LedgerEntryRowSchema = z
|
|
38
45
|
.object({
|
|
39
46
|
entry_id: z.string(),
|
|
40
47
|
account_id: z.string(),
|
|
41
|
-
actor_user_id: z.string().nullable()
|
|
48
|
+
actor_user_id: z.string().nullable(),
|
|
42
49
|
amount: decimal,
|
|
43
50
|
entry_type: z.string(),
|
|
44
51
|
operation: z.string(),
|
|
45
|
-
reference_entry_id: z.string().nullable()
|
|
46
|
-
idempotency_key: z.string().nullable()
|
|
47
|
-
metadata: z.record(z.string(), z.unknown()).nullable()
|
|
48
|
-
created_at:
|
|
52
|
+
reference_entry_id: z.string().nullable(),
|
|
53
|
+
idempotency_key: z.string().nullable(),
|
|
54
|
+
metadata: z.record(z.string(), z.unknown()).nullable(),
|
|
55
|
+
created_at: timestamp,
|
|
49
56
|
})
|
|
50
|
-
.
|
|
57
|
+
.strict();
|
|
51
58
|
const UsageChargeRowSchema = z
|
|
52
59
|
.object({
|
|
53
60
|
usage_id: z.string(),
|
|
@@ -58,15 +65,15 @@ const UsageChargeRowSchema = z
|
|
|
58
65
|
allowance_requested: decimal,
|
|
59
66
|
allowance_covered: decimal,
|
|
60
67
|
billing_disposition: z.enum(["billable", "record_only"]),
|
|
61
|
-
feature: z.string().nullable()
|
|
62
|
-
model: z.string().nullable()
|
|
63
|
-
region: z.string().nullable()
|
|
64
|
-
event_at:
|
|
68
|
+
feature: z.string().nullable(),
|
|
69
|
+
model: z.string().nullable(),
|
|
70
|
+
region: z.string().nullable(),
|
|
71
|
+
event_at: timestamp,
|
|
65
72
|
idempotency_key: z.string(),
|
|
66
|
-
metadata: z.record(z.string(), z.unknown()).nullable()
|
|
67
|
-
created_at:
|
|
73
|
+
metadata: z.record(z.string(), z.unknown()).nullable(),
|
|
74
|
+
created_at: timestamp,
|
|
68
75
|
})
|
|
69
|
-
.
|
|
76
|
+
.strict();
|
|
70
77
|
export class AnalyticsRepository {
|
|
71
78
|
callproc;
|
|
72
79
|
constructor(callproc) {
|
|
@@ -76,41 +83,33 @@ export class AnalyticsRepository {
|
|
|
76
83
|
const rows = await this.callproc("spend_by_user", [start, end]);
|
|
77
84
|
return (rows ?? []).map((raw) => {
|
|
78
85
|
const row = raw;
|
|
79
|
-
return safeParse(SpendByUserRowSchema, {
|
|
80
|
-
...row,
|
|
81
|
-
user_id: row.subject_id,
|
|
82
|
-
entry_count: row.charge_count,
|
|
83
|
-
}, "AnalyticsRepository.spendByUser");
|
|
86
|
+
return safeParse(SpendByUserRowSchema, { user_id: row.subject_id, total_spend: row.total_spend, entry_count: row.charge_count }, "AnalyticsRepository.spendByUser");
|
|
84
87
|
});
|
|
85
88
|
}
|
|
86
89
|
async spendByModel(start, end) {
|
|
87
90
|
const rows = await this.callproc("spend_by_model", [start, end]);
|
|
88
91
|
return (rows ?? []).map((raw) => {
|
|
89
92
|
const row = raw;
|
|
90
|
-
return safeParse(SpendByModelRowSchema, {
|
|
93
|
+
return safeParse(SpendByModelRowSchema, { model: row.model, total_spend: row.total_spend, entry_count: row.charge_count }, "AnalyticsRepository.spendByModel");
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
96
|
async topUsers(limit, start, end) {
|
|
94
97
|
const rows = await this.callproc("spend_by_user", [start, end]);
|
|
95
98
|
return (rows ?? []).slice(0, limit).map((raw) => {
|
|
96
99
|
const row = raw;
|
|
97
|
-
return safeParse(TopUserRowSchema, {
|
|
100
|
+
return safeParse(TopUserRowSchema, { user_id: row.subject_id, total_spend: row.total_spend }, "AnalyticsRepository.topUsers");
|
|
98
101
|
});
|
|
99
102
|
}
|
|
100
103
|
async dailySpend(start, end) {
|
|
101
104
|
const rows = await this.callproc("daily_spend", [start, end]);
|
|
102
105
|
return (rows ?? []).map((raw) => {
|
|
103
106
|
const row = raw;
|
|
104
|
-
return safeParse(DailySpendRowSchema, {
|
|
105
|
-
...row,
|
|
106
|
-
date: row.day,
|
|
107
|
-
entry_count: row.charge_count,
|
|
108
|
-
}, "AnalyticsRepository.dailySpend");
|
|
107
|
+
return safeParse(DailySpendRowSchema, { date: row.day, total_spend: row.total_spend, entry_count: row.charge_count }, "AnalyticsRepository.dailySpend");
|
|
109
108
|
});
|
|
110
109
|
}
|
|
111
110
|
async aggregateStats(start, end) {
|
|
112
111
|
const rows = await this.callproc("aggregate_usage_stats", [start, end]);
|
|
113
|
-
return safeParse(AggregateStatsRowSchema, rows
|
|
112
|
+
return safeParse(AggregateStatsRowSchema, requireRow(rows, "AnalyticsRepository.aggregateStats"), "AnalyticsRepository.aggregateStats");
|
|
114
113
|
}
|
|
115
114
|
async listLedgerEntries(userId, entryTypes, fromDate, toDate, limit, cursorCreatedAt, cursorEntryId, usageOnly = false) {
|
|
116
115
|
if ((cursorCreatedAt == null) !== (cursorEntryId == null)) {
|
|
@@ -130,9 +129,10 @@ export class AnalyticsRepository {
|
|
|
130
129
|
}
|
|
131
130
|
async getLedgerEntry(userId, entryId) {
|
|
132
131
|
const rows = await this.callproc("get_ledger_entry", [userId, entryId]);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
const row = optionalRecordRow(rows, "AnalyticsRepository.getLedgerEntry");
|
|
133
|
+
return row === null
|
|
134
|
+
? null
|
|
135
|
+
: safeParse(LedgerEntryRowSchema, row, "AnalyticsRepository.getLedgerEntry");
|
|
136
136
|
}
|
|
137
137
|
async listUsageCharges(userId, fromDate, toDate, limit, cursorEventAt, cursorUsageId, includeRecordOnly) {
|
|
138
138
|
if ((cursorEventAt == null) !== (cursorUsageId == null)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../../src/credits/postgres/repositories/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAEnE,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAElD,MAAM,oBAAoB,GAAG,CAAC;KAC3B,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,WAAW,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC1C,WAAW,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC3C,CAAC;KACD,WAAW,EAAE,CAAC;AAEjB,MAAM,qBAAqB,GAAG,CAAC;KAC5B,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,WAAW,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC1C,WAAW,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC3C,CAAC;KACD,WAAW,EAAE,CAAC;AAEjB,MAAM,gBAAgB,GA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,IAAI,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;QAC3E,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,oBAAoB,EAAE;YACrD,MAAM;YACN,aAAa;YACb,aAAa;YACb,KAAK;YACL,QAAQ;YACR,MAAM;YACN,iBAAiB;SAClB,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAC9B,SAAS,CAAC,oBAAoB,EAAE,GAAG,EAAE,sCAAsC,CAAC,CAC7E,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { z } from \"zod\";\nimport type { CallProc } from \"../../../shared/postgres-types.js\";\nimport { safeParse } from \"../../../shared/postgres-validation.js\";\n\nconst decimal = z.union([z.string(), z.number()]);\n\nconst SpendByUserRowSchema = z\n .object({\n user_id: z.string().optional(),\n total_spend: decimal.nullable().optional(),\n entry_count: decimal.nullable().optional(),\n })\n .passthrough();\n\nconst SpendByModelRowSchema = z\n .object({\n model: z.string().optional(),\n total_spend: decimal.nullable().optional(),\n entry_count: decimal.nullable().optional(),\n })\n .passthrough();\n\nconst TopUserRowSchema = z\n .object({ user_id: z.string().optional(), total_spend: decimal.nullable().optional() })\n .passthrough();\n\nconst DailySpendRowSchema = z\n .object({\n date: z.string().optional(),\n total_spend: decimal.nullable().optional(),\n entry_count: decimal.nullable().optional(),\n })\n .passthrough();\n\nconst AggregateStatsRowSchema = z\n .object({\n total_credits_consumed: decimal.nullable().optional(),\n active_users: decimal.nullable().optional(),\n avg_daily_spend: decimal.nullable().optional(),\n top_model: z.string().nullable().optional(),\n top_user: z.string().nullable().optional(),\n })\n .passthrough();\n\nconst LedgerEntryRowSchema = z\n .object({\n entry_id: z.string(),\n account_id: z.string(),\n actor_user_id: z.string().nullable().optional(),\n amount: decimal,\n entry_type: z.string(),\n operation: z.string(),\n reference_entry_id: z.string().nullable().optional(),\n idempotency_key: z.string().nullable().optional(),\n metadata: z.record(z.string(), z.unknown()).nullable().optional(),\n created_at: z.union([z.string(), z.date()]),\n })\n .passthrough();\n\nconst UsageChargeRowSchema = z\n .object({\n usage_id: z.string(),\n account_id: z.string(),\n operation: z.string(),\n requested: decimal,\n charged: decimal,\n allowance_requested: decimal,\n allowance_covered: decimal,\n billing_disposition: z.enum([\"billable\", \"record_only\"]),\n feature: z.string().nullable().optional(),\n model: z.string().nullable().optional(),\n region: z.string().nullable().optional(),\n event_at: z.union([z.string(), z.date()]),\n idempotency_key: z.string(),\n metadata: z.record(z.string(), z.unknown()).nullable().optional(),\n created_at: z.union([z.string(), z.date()]),\n })\n .passthrough();\n\nexport type SpendByUserRow = z.infer<typeof SpendByUserRowSchema>;\nexport type SpendByModelRow = z.infer<typeof SpendByModelRowSchema>;\nexport type TopUserRow = z.infer<typeof TopUserRowSchema>;\nexport type DailySpendRow = z.infer<typeof DailySpendRowSchema>;\nexport type AggregateStatsRow = z.infer<typeof AggregateStatsRowSchema>;\nexport type LedgerEntryRow = z.infer<typeof LedgerEntryRowSchema>;\nexport type UsageChargeRow = z.infer<typeof UsageChargeRowSchema>;\n\nexport class AnalyticsRepository {\n constructor(private readonly callproc: CallProc) {}\n\n async spendByUser(start: string, end: string): Promise<SpendByUserRow[]> {\n const rows = await this.callproc(\"spend_by_user\", [start, end]);\n return (rows ?? []).map((raw) => {\n const row = raw as Record<string, unknown>;\n return safeParse(\n SpendByUserRowSchema,\n {\n ...row,\n user_id: row.subject_id,\n entry_count: row.charge_count,\n },\n \"AnalyticsRepository.spendByUser\",\n );\n });\n }\n\n async spendByModel(start: string, end: string): Promise<SpendByModelRow[]> {\n const rows = await this.callproc(\"spend_by_model\", [start, end]);\n return (rows ?? []).map((raw) => {\n const row = raw as Record<string, unknown>;\n return safeParse(\n SpendByModelRowSchema,\n { ...row, entry_count: row.charge_count },\n \"AnalyticsRepository.spendByModel\",\n );\n });\n }\n\n async topUsers(limit: number, start: string, end: string): Promise<TopUserRow[]> {\n const rows = await this.callproc(\"spend_by_user\", [start, end]);\n return (rows ?? []).slice(0, limit).map((raw) => {\n const row = raw as Record<string, unknown>;\n return safeParse(\n TopUserRowSchema,\n { ...row, user_id: row.subject_id },\n \"AnalyticsRepository.topUsers\",\n );\n });\n }\n\n async dailySpend(start: string, end: string): Promise<DailySpendRow[]> {\n const rows = await this.callproc(\"daily_spend\", [start, end]);\n return (rows ?? []).map((raw) => {\n const row = raw as Record<string, unknown>;\n return safeParse(\n DailySpendRowSchema,\n {\n ...row,\n date: row.day,\n entry_count: row.charge_count,\n },\n \"AnalyticsRepository.dailySpend\",\n );\n });\n }\n\n async aggregateStats(start: string, end: string): Promise<AggregateStatsRow> {\n const rows = await this.callproc(\"aggregate_usage_stats\", [start, end]);\n return safeParse(\n AggregateStatsRowSchema,\n rows?.[0] ?? {},\n \"AnalyticsRepository.aggregateStats\",\n );\n }\n\n async listLedgerEntries(\n userId: string,\n entryTypes: string[] | null,\n fromDate: string | null,\n toDate: string | null,\n limit: number,\n cursorCreatedAt: string | null,\n cursorEntryId: string | null,\n usageOnly = false,\n ): Promise<LedgerEntryRow[]> {\n if ((cursorCreatedAt == null) !== (cursorEntryId == null)) {\n throw new Error(\"ledger cursor requires both createdAt and entryId\");\n }\n const rows = await this.callproc(\"list_ledger\", [\n userId,\n cursorCreatedAt,\n cursorEntryId,\n limit,\n entryTypes,\n fromDate,\n toDate,\n usageOnly,\n ]);\n return (rows ?? []).map((row) =>\n safeParse(LedgerEntryRowSchema, row, \"AnalyticsRepository.listLedgerEntries\"),\n );\n }\n\n async getLedgerEntry(userId: string, entryId: string): Promise<LedgerEntryRow | null> {\n const rows = await this.callproc(\"get_ledger_entry\", [userId, entryId]);\n if (!rows?.length) return null;\n return safeParse(LedgerEntryRowSchema, rows[0], \"AnalyticsRepository.getLedgerEntry\");\n }\n\n async listUsageCharges(\n userId: string,\n fromDate: string | null,\n toDate: string | null,\n limit: number,\n cursorEventAt: string | null,\n cursorUsageId: string | null,\n includeRecordOnly: boolean,\n ): Promise<UsageChargeRow[]> {\n if ((cursorEventAt == null) !== (cursorUsageId == null)) {\n throw new Error(\"usage charge cursor requires both eventAt and usageId\");\n }\n const rows = await this.callproc(\"list_usage_charges\", [\n userId,\n cursorEventAt,\n cursorUsageId,\n limit,\n fromDate,\n toDate,\n includeRecordOnly,\n ]);\n return (rows ?? []).map((row) =>\n safeParse(UsageChargeRowSchema, row, \"AnalyticsRepository.listUsageCharges\"),\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../../src/credits/postgres/repositories/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAElG,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAU,CAAC,CAAC;AAC3E,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IACpB,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IAC9B,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;CAC5C,CAAC,CAAC;AACH,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;AACnG,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC;I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,CACpB,MAAc,EACd,QAAuB,EACvB,MAAqB,EACrB,KAAa,EACb,aAA4B,EAC5B,aAA4B,EAC5B,iBAA0B;QAE1B,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;QAC3E,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,oBAAoB,EAAE;YACrD,MAAM;YACN,aAAa;YACb,aAAa;YACb,KAAK;YACL,QAAQ;YACR,MAAM;YACN,iBAAiB;SAClB,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAC9B,SAAS,CAAC,oBAAoB,EAAE,GAAG,EAAE,sCAAsC,CAAC,CAC7E,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { z } from \"zod\";\nimport type { CallProc } from \"../../../shared/postgres-types.js\";\nimport { optionalRecordRow, requireRow, safeParse } from \"../../../shared/postgres-validation.js\";\n\nconst decimal = z.union([z.string().min(1), z.number().finite()] as const);\nconst count = z.union([\n z.number().int().nonnegative(),\n z.string().regex(/^\\d+$/).transform(Number),\n]);\nconst timestamp = z.union([z.string().min(1), z.date().transform((value) => value.toISOString())]);\nconst calendarDate = z.union([\n z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/),\n z.date().transform((value) => value.toISOString().slice(0, 10)),\n]);\n\nconst SpendByUserRowSchema = z\n .object({\n user_id: z.string().min(1),\n total_spend: decimal,\n entry_count: count,\n })\n .strict();\n\nconst SpendByModelRowSchema = z\n .object({\n model: z.string().min(1),\n total_spend: decimal,\n entry_count: count,\n })\n .strict();\n\nconst TopUserRowSchema = z.object({ user_id: z.string().min(1), total_spend: decimal }).strict();\n\nconst DailySpendRowSchema = z\n .object({\n date: calendarDate,\n total_spend: decimal,\n entry_count: count,\n })\n .strict();\n\nconst AggregateStatsRowSchema = z\n .object({\n total_credits_consumed: decimal,\n active_users: count,\n avg_daily_spend: decimal,\n top_model: z.string().min(1).nullable(),\n top_user: z.string().min(1).nullable(),\n })\n .strict();\n\nconst LedgerEntryRowSchema = z\n .object({\n entry_id: z.string(),\n account_id: z.string(),\n actor_user_id: z.string().nullable(),\n amount: decimal,\n entry_type: z.string(),\n operation: z.string(),\n reference_entry_id: z.string().nullable(),\n idempotency_key: z.string().nullable(),\n metadata: z.record(z.string(), z.unknown()).nullable(),\n created_at: timestamp,\n })\n .strict();\n\nconst UsageChargeRowSchema = z\n .object({\n usage_id: z.string(),\n account_id: z.string(),\n operation: z.string(),\n requested: decimal,\n charged: decimal,\n allowance_requested: decimal,\n allowance_covered: decimal,\n billing_disposition: z.enum([\"billable\", \"record_only\"]),\n feature: z.string().nullable(),\n model: z.string().nullable(),\n region: z.string().nullable(),\n event_at: timestamp,\n idempotency_key: z.string(),\n metadata: z.record(z.string(), z.unknown()).nullable(),\n created_at: timestamp,\n })\n .strict();\n\nexport type SpendByUserRow = z.infer<typeof SpendByUserRowSchema>;\nexport type SpendByModelRow = z.infer<typeof SpendByModelRowSchema>;\nexport type TopUserRow = z.infer<typeof TopUserRowSchema>;\nexport type DailySpendRow = z.infer<typeof DailySpendRowSchema>;\nexport type AggregateStatsRow = z.infer<typeof AggregateStatsRowSchema>;\nexport type LedgerEntryRow = z.infer<typeof LedgerEntryRowSchema>;\nexport type UsageChargeRow = z.infer<typeof UsageChargeRowSchema>;\n\nexport class AnalyticsRepository {\n constructor(private readonly callproc: CallProc) {}\n\n async spendByUser(start: string, end: string): Promise<SpendByUserRow[]> {\n const rows = await this.callproc(\"spend_by_user\", [start, end]);\n return (rows ?? []).map((raw) => {\n const row = raw as Record<string, unknown>;\n return safeParse(\n SpendByUserRowSchema,\n { user_id: row.subject_id, total_spend: row.total_spend, entry_count: row.charge_count },\n \"AnalyticsRepository.spendByUser\",\n );\n });\n }\n\n async spendByModel(start: string, end: string): Promise<SpendByModelRow[]> {\n const rows = await this.callproc(\"spend_by_model\", [start, end]);\n return (rows ?? []).map((raw) => {\n const row = raw as Record<string, unknown>;\n return safeParse(\n SpendByModelRowSchema,\n { model: row.model, total_spend: row.total_spend, entry_count: row.charge_count },\n \"AnalyticsRepository.spendByModel\",\n );\n });\n }\n\n async topUsers(limit: number, start: string, end: string): Promise<TopUserRow[]> {\n const rows = await this.callproc(\"spend_by_user\", [start, end]);\n return (rows ?? []).slice(0, limit).map((raw) => {\n const row = raw as Record<string, unknown>;\n return safeParse(\n TopUserRowSchema,\n { user_id: row.subject_id, total_spend: row.total_spend },\n \"AnalyticsRepository.topUsers\",\n );\n });\n }\n\n async dailySpend(start: string, end: string): Promise<DailySpendRow[]> {\n const rows = await this.callproc(\"daily_spend\", [start, end]);\n return (rows ?? []).map((raw) => {\n const row = raw as Record<string, unknown>;\n return safeParse(\n DailySpendRowSchema,\n { date: row.day, total_spend: row.total_spend, entry_count: row.charge_count },\n \"AnalyticsRepository.dailySpend\",\n );\n });\n }\n\n async aggregateStats(start: string, end: string): Promise<AggregateStatsRow> {\n const rows = await this.callproc(\"aggregate_usage_stats\", [start, end]);\n return safeParse(\n AggregateStatsRowSchema,\n requireRow(rows, \"AnalyticsRepository.aggregateStats\"),\n \"AnalyticsRepository.aggregateStats\",\n );\n }\n\n async listLedgerEntries(\n userId: string,\n entryTypes: string[] | null,\n fromDate: string | null,\n toDate: string | null,\n limit: number,\n cursorCreatedAt: string | null,\n cursorEntryId: string | null,\n usageOnly = false,\n ): Promise<LedgerEntryRow[]> {\n if ((cursorCreatedAt == null) !== (cursorEntryId == null)) {\n throw new Error(\"ledger cursor requires both createdAt and entryId\");\n }\n const rows = await this.callproc(\"list_ledger\", [\n userId,\n cursorCreatedAt,\n cursorEntryId,\n limit,\n entryTypes,\n fromDate,\n toDate,\n usageOnly,\n ]);\n return (rows ?? []).map((row) =>\n safeParse(LedgerEntryRowSchema, row, \"AnalyticsRepository.listLedgerEntries\"),\n );\n }\n\n async getLedgerEntry(userId: string, entryId: string): Promise<LedgerEntryRow | null> {\n const rows = await this.callproc(\"get_ledger_entry\", [userId, entryId]);\n const row = optionalRecordRow(rows, \"AnalyticsRepository.getLedgerEntry\");\n return row === null\n ? null\n : safeParse(LedgerEntryRowSchema, row, \"AnalyticsRepository.getLedgerEntry\");\n }\n\n async listUsageCharges(\n userId: string,\n fromDate: string | null,\n toDate: string | null,\n limit: number,\n cursorEventAt: string | null,\n cursorUsageId: string | null,\n includeRecordOnly: boolean,\n ): Promise<UsageChargeRow[]> {\n if ((cursorEventAt == null) !== (cursorUsageId == null)) {\n throw new Error(\"usage charge cursor requires both eventAt and usageId\");\n }\n const rows = await this.callproc(\"list_usage_charges\", [\n userId,\n cursorEventAt,\n cursorUsageId,\n limit,\n fromDate,\n toDate,\n includeRecordOnly,\n ]);\n return (rows ?? []).map((row) =>\n safeParse(UsageChargeRowSchema, row, \"AnalyticsRepository.listUsageCharges\"),\n );\n }\n}\n"]}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { CallProc } from "../../../shared/postgres-types.js";
|
|
3
3
|
declare const BalanceRowSchema: z.ZodObject<{
|
|
4
|
-
user_id: z.
|
|
5
|
-
balance: z.
|
|
6
|
-
lifetime_purchased: z.
|
|
7
|
-
}, z.core.$
|
|
4
|
+
user_id: z.ZodString;
|
|
5
|
+
balance: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
6
|
+
lifetime_purchased: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
8
|
declare const AddCreditsRowSchema: z.ZodObject<{
|
|
9
|
-
entry_id: z.
|
|
10
|
-
user_id: z.
|
|
11
|
-
amount: z.
|
|
12
|
-
new_balance: z.
|
|
13
|
-
lifetime_purchased: z.
|
|
14
|
-
bucket: z.
|
|
15
|
-
idempotent: z.
|
|
16
|
-
error: z.
|
|
17
|
-
}, z.core.$
|
|
9
|
+
entry_id: z.ZodNullable<z.ZodString>;
|
|
10
|
+
user_id: z.ZodString;
|
|
11
|
+
amount: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
12
|
+
new_balance: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
13
|
+
lifetime_purchased: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
14
|
+
bucket: z.ZodNullable<z.ZodString>;
|
|
15
|
+
idempotent: z.ZodBoolean;
|
|
16
|
+
error: z.ZodNullable<z.ZodString>;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
18
|
declare const AvailableRowSchema: z.ZodObject<{
|
|
19
|
-
balance: z.
|
|
20
|
-
reserved: z.
|
|
21
|
-
available: z.
|
|
22
|
-
}, z.core.$
|
|
19
|
+
balance: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
20
|
+
reserved: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
21
|
+
available: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
23
|
declare const GrantProgramAwardRowSchema: z.ZodObject<{
|
|
24
|
-
grant_event_id: z.
|
|
25
|
-
grant_award_id: z.
|
|
26
|
-
recipient_subject_id: z.
|
|
27
|
-
ledger_entry_id: z.
|
|
28
|
-
amount: z.
|
|
29
|
-
replayed: z.
|
|
30
|
-
error_code: z.
|
|
31
|
-
}, z.core.$
|
|
24
|
+
grant_event_id: z.ZodNullable<z.ZodString>;
|
|
25
|
+
grant_award_id: z.ZodNullable<z.ZodString>;
|
|
26
|
+
recipient_subject_id: z.ZodNullable<z.ZodString>;
|
|
27
|
+
ledger_entry_id: z.ZodNullable<z.ZodString>;
|
|
28
|
+
amount: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
29
|
+
replayed: z.ZodBoolean;
|
|
30
|
+
error_code: z.ZodNullable<z.ZodString>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
32
|
export type BalanceRow = z.infer<typeof BalanceRowSchema>;
|
|
33
33
|
export type AddCreditsRow = z.infer<typeof AddCreditsRowSchema>;
|
|
34
34
|
export type AvailableRow = z.infer<typeof AvailableRowSchema>;
|
|
@@ -37,10 +37,8 @@ export type GrantProgramAwardRow = z.infer<typeof GrantProgramAwardRowSchema>;
|
|
|
37
37
|
*
|
|
38
38
|
* All methods call Postgres RPCs via the callproc function.
|
|
39
39
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* fallback). This inconsistency is intentional: balance queries distinguish
|
|
43
|
-
* "no data" from "zeroed data" whereas mutation reads always produce a result.
|
|
40
|
+
* Reads may return no row for a new account. Mutations require the database's
|
|
41
|
+
* single-row result envelope and fail closed when that contract is violated.
|
|
44
42
|
*/
|
|
45
43
|
export declare class BalanceRepository {
|
|
46
44
|
private callproc;
|
|
@@ -50,7 +48,7 @@ export declare class BalanceRepository {
|
|
|
50
48
|
/** Add credits to a user's account. */
|
|
51
49
|
addCredits(userId: string, amount: string, type: string, metadata: string, expiresAt: string | null, bucket: string | null, idempotencyKey: string | null): Promise<AddCreditsRow>;
|
|
52
50
|
/** Fetch available balance (balance minus reserved holds). */
|
|
53
|
-
getAvailable(userId: string): Promise<AvailableRow>;
|
|
51
|
+
getAvailable(userId: string): Promise<AvailableRow | null>;
|
|
54
52
|
/** Execute a configured grant-program event and return every award row. */
|
|
55
53
|
executeGrantProgram(params: {
|
|
56
54
|
trigger: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../../../src/credits/postgres/repositories/balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../../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