@ottocode/ai-sdk 0.1.7 → 0.1.8
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 +1 -1
- package/src/balance.ts +70 -1
- package/src/types.ts +27 -0
package/package.json
CHANGED
package/src/balance.ts
CHANGED
|
@@ -45,9 +45,36 @@ export async function fetchBalance(
|
|
|
45
45
|
request_count: number;
|
|
46
46
|
created_at?: string;
|
|
47
47
|
last_request?: string;
|
|
48
|
+
scope?: 'wallet' | 'account';
|
|
49
|
+
payg?: {
|
|
50
|
+
wallet_balance_usd: number;
|
|
51
|
+
account_balance_usd: number;
|
|
52
|
+
raw_pool_usd: number;
|
|
53
|
+
effective_spendable_usd: number;
|
|
54
|
+
};
|
|
55
|
+
limits?: {
|
|
56
|
+
enabled: boolean;
|
|
57
|
+
daily_limit_usd: number | null;
|
|
58
|
+
daily_spent_usd: number;
|
|
59
|
+
daily_remaining_usd: number | null;
|
|
60
|
+
monthly_limit_usd: number | null;
|
|
61
|
+
monthly_spent_usd: number;
|
|
62
|
+
monthly_remaining_usd: number | null;
|
|
63
|
+
cap_remaining_usd: number | null;
|
|
64
|
+
} | null;
|
|
65
|
+
subscription?: {
|
|
66
|
+
active: boolean;
|
|
67
|
+
tier_id?: string;
|
|
68
|
+
tier_name?: string;
|
|
69
|
+
credits_included?: number;
|
|
70
|
+
credits_used?: number;
|
|
71
|
+
credits_remaining?: number;
|
|
72
|
+
period_start?: string;
|
|
73
|
+
period_end?: string;
|
|
74
|
+
} | null;
|
|
48
75
|
};
|
|
49
76
|
|
|
50
|
-
|
|
77
|
+
const result: BalanceResponse = {
|
|
51
78
|
walletAddress: data.wallet_address,
|
|
52
79
|
balance: data.balance_usd,
|
|
53
80
|
totalSpent: data.total_spent,
|
|
@@ -55,7 +82,49 @@ export async function fetchBalance(
|
|
|
55
82
|
requestCount: data.request_count,
|
|
56
83
|
createdAt: data.created_at,
|
|
57
84
|
lastRequest: data.last_request,
|
|
85
|
+
scope: data.scope,
|
|
58
86
|
};
|
|
87
|
+
|
|
88
|
+
if (data.payg) {
|
|
89
|
+
result.payg = {
|
|
90
|
+
walletBalanceUsd: data.payg.wallet_balance_usd,
|
|
91
|
+
accountBalanceUsd: data.payg.account_balance_usd,
|
|
92
|
+
rawPoolUsd: data.payg.raw_pool_usd,
|
|
93
|
+
effectiveSpendableUsd: data.payg.effective_spendable_usd,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (data.limits !== undefined) {
|
|
98
|
+
result.limits = data.limits
|
|
99
|
+
? {
|
|
100
|
+
enabled: data.limits.enabled,
|
|
101
|
+
dailyLimitUsd: data.limits.daily_limit_usd,
|
|
102
|
+
dailySpentUsd: data.limits.daily_spent_usd,
|
|
103
|
+
dailyRemainingUsd: data.limits.daily_remaining_usd,
|
|
104
|
+
monthlyLimitUsd: data.limits.monthly_limit_usd,
|
|
105
|
+
monthlySpentUsd: data.limits.monthly_spent_usd,
|
|
106
|
+
monthlyRemainingUsd: data.limits.monthly_remaining_usd,
|
|
107
|
+
capRemainingUsd: data.limits.cap_remaining_usd,
|
|
108
|
+
}
|
|
109
|
+
: null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (data.subscription !== undefined) {
|
|
113
|
+
result.subscription = data.subscription
|
|
114
|
+
? {
|
|
115
|
+
active: data.subscription.active,
|
|
116
|
+
tierId: data.subscription.tier_id,
|
|
117
|
+
tierName: data.subscription.tier_name,
|
|
118
|
+
creditsIncluded: data.subscription.credits_included,
|
|
119
|
+
creditsUsed: data.subscription.credits_used,
|
|
120
|
+
creditsRemaining: data.subscription.credits_remaining,
|
|
121
|
+
periodStart: data.subscription.period_start,
|
|
122
|
+
periodEnd: data.subscription.period_end,
|
|
123
|
+
}
|
|
124
|
+
: null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return result;
|
|
59
128
|
} catch {
|
|
60
129
|
return null;
|
|
61
130
|
}
|
package/src/types.ts
CHANGED
|
@@ -128,6 +128,33 @@ export interface BalanceResponse {
|
|
|
128
128
|
requestCount: number;
|
|
129
129
|
createdAt?: string;
|
|
130
130
|
lastRequest?: string;
|
|
131
|
+
scope?: 'wallet' | 'account';
|
|
132
|
+
payg?: {
|
|
133
|
+
walletBalanceUsd: number;
|
|
134
|
+
accountBalanceUsd: number;
|
|
135
|
+
rawPoolUsd: number;
|
|
136
|
+
effectiveSpendableUsd: number;
|
|
137
|
+
};
|
|
138
|
+
limits?: {
|
|
139
|
+
enabled: boolean;
|
|
140
|
+
dailyLimitUsd: number | null;
|
|
141
|
+
dailySpentUsd: number;
|
|
142
|
+
dailyRemainingUsd: number | null;
|
|
143
|
+
monthlyLimitUsd: number | null;
|
|
144
|
+
monthlySpentUsd: number;
|
|
145
|
+
monthlyRemainingUsd: number | null;
|
|
146
|
+
capRemainingUsd: number | null;
|
|
147
|
+
} | null;
|
|
148
|
+
subscription?: {
|
|
149
|
+
active: boolean;
|
|
150
|
+
tierId?: string;
|
|
151
|
+
tierName?: string;
|
|
152
|
+
creditsIncluded?: number;
|
|
153
|
+
creditsUsed?: number;
|
|
154
|
+
creditsRemaining?: number;
|
|
155
|
+
periodStart?: string;
|
|
156
|
+
periodEnd?: string;
|
|
157
|
+
} | null;
|
|
131
158
|
}
|
|
132
159
|
|
|
133
160
|
export interface WalletUsdcBalance {
|