@wopr-network/platform-ui-core 1.19.6 → 1.19.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wopr-network/platform-ui-core",
3
- "version": "1.19.6",
3
+ "version": "1.19.7",
4
4
  "description": "Brand-agnostic AI agent platform UI — deploy as any brand via env vars",
5
5
  "repository": {
6
6
  "type": "git",
@@ -75,8 +75,15 @@ function CreditsContent() {
75
75
 
76
76
  const balance: CreditBalanceData | null = rawBalance
77
77
  ? {
78
- balance: ((rawBalance as { balance_cents?: number }).balance_cents ?? 0) / 100,
79
- dailyBurn: ((rawBalance as { daily_burn_cents?: number }).daily_burn_cents ?? 0) / 100,
78
+ balance:
79
+ ((rawBalance as { balance_credits?: number; balance_cents?: number }).balance_credits ??
80
+ (rawBalance as { balance_cents?: number }).balance_cents ??
81
+ 0) / 100,
82
+ dailyBurn:
83
+ ((rawBalance as { daily_burn_credits?: number; daily_burn_cents?: number })
84
+ .daily_burn_credits ??
85
+ (rawBalance as { daily_burn_cents?: number }).daily_burn_cents ??
86
+ 0) / 100,
80
87
  runway: (rawBalance as { runway_days?: number | null }).runway_days ?? null,
81
88
  }
82
89
  : null;
@@ -19,12 +19,15 @@ export interface OrgMemberUsageRow {
19
19
 
20
20
  // ---- API calls ----
21
21
 
22
- export async function getOrgCreditBalance(orgId: string): Promise<OrgCreditBalance> {
23
- const res = await trpcVanilla.org.orgBillingBalance.query({ orgId });
22
+ export async function getOrgCreditBalance(_orgId: string): Promise<OrgCreditBalance> {
23
+ const res = await trpcVanilla.billing.creditsBalance.query({});
24
24
  return {
25
- balance: (res?.balanceCents ?? 0) / 100,
26
- dailyBurn: (res?.dailyBurnCents ?? 0) / 100,
27
- runway: res?.runwayDays ?? null,
25
+ balance:
26
+ (res?.balance_credits ?? (res as { balance_cents?: number })?.balance_cents ?? 0) / 100,
27
+ dailyBurn:
28
+ (res?.daily_burn_credits ?? (res as { daily_burn_cents?: number })?.daily_burn_cents ?? 0) /
29
+ 100,
30
+ runway: (res as { runway_days?: number | null })?.runway_days ?? null,
28
31
  };
29
32
  }
30
33
 
@@ -33,45 +36,34 @@ export async function getOrgMemberUsage(orgId: string): Promise<{
33
36
  periodStart: string;
34
37
  members: OrgMemberUsageRow[];
35
38
  }> {
36
- const res = await trpcVanilla.org.orgMemberUsage.query({ orgId });
37
- const members = Array.isArray(res?.members) ? res.members : [];
39
+ // org.orgMemberUsage not yet implemented — return empty
38
40
  return {
39
- orgId: res?.orgId ?? orgId,
40
- periodStart: res?.periodStart ?? "",
41
- members: (
42
- members as Array<{
43
- memberId?: string;
44
- name?: string;
45
- email?: string;
46
- creditsConsumedCents?: number;
47
- lastActiveAt?: string | null;
48
- }>
49
- ).map((m) => ({
50
- memberId: m.memberId ?? "",
51
- name: m.name ?? "",
52
- email: m.email ?? "",
53
- creditsConsumed: (m.creditsConsumedCents ?? 0) / 100,
54
- lastActiveAt: m.lastActiveAt ?? null,
55
- })),
41
+ orgId,
42
+ periodStart: new Date().toISOString(),
43
+ members: [],
56
44
  };
57
45
  }
58
46
 
59
- export async function getOrgBillingInfo(orgId: string) {
60
- const res = await trpcVanilla.org.orgBillingInfo.query({ orgId });
61
- return {
62
- paymentMethods: Array.isArray(res?.paymentMethods) ? res.paymentMethods : [],
63
- invoices: Array.isArray(res?.invoices)
64
- ? (res.invoices as Invoice[]).map((inv) => ({
65
- id: inv.id ?? "",
66
- date: inv.date ?? "",
67
- amount: inv.amount ?? 0,
68
- status: inv.status ?? ("paid" as const),
69
- downloadUrl: inv.downloadUrl ?? "",
70
- hostedUrl: inv.hostedUrl ?? "",
71
- hostedLineItems: inv.hostedLineItems,
72
- }))
73
- : ([] as Invoice[]),
74
- };
47
+ export async function getOrgBillingInfo(_orgId: string) {
48
+ try {
49
+ const res = await trpcVanilla.billing.billingInfo.query({});
50
+ return {
51
+ paymentMethods: Array.isArray(res?.paymentMethods) ? res.paymentMethods : [],
52
+ invoices: Array.isArray(res?.invoices)
53
+ ? (res.invoices as Invoice[]).map((inv) => ({
54
+ id: inv.id ?? "",
55
+ date: inv.date ?? "",
56
+ amount: inv.amount ?? 0,
57
+ status: inv.status ?? ("paid" as const),
58
+ downloadUrl: inv.downloadUrl ?? "",
59
+ hostedUrl: inv.hostedUrl ?? "",
60
+ hostedLineItems: inv.hostedLineItems,
61
+ }))
62
+ : ([] as Invoice[]),
63
+ };
64
+ } catch {
65
+ return { paymentMethods: [], invoices: [] as Invoice[] };
66
+ }
75
67
  }
76
68
 
77
69
  export async function createOrgTopupCheckout(