@magpie-community/opencode-kiro-auth 0.1.16 → 0.1.17
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/index.mjs +7 -3
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -414,7 +414,10 @@ function goG(x) {
|
|
|
414
414
|
|
|
415
415
|
// usageOf is the allowance Get-Usage-Limits tells, as magpie's built-in
|
|
416
416
|
// said it: the account's email, the credits of each allowance, the month's and a free trial's
|
|
417
|
-
// while it runs.
|
|
417
|
+
// while it runs. Each window carries its count (amount, limit, unit), so
|
|
418
|
+
// magpie can say what is left of it when the user shows what is left
|
|
419
|
+
// (#408): display alone is the vendor's text, which magpie can't turn
|
|
420
|
+
// round.
|
|
418
421
|
function usageOf(l) {
|
|
419
422
|
const at = (secs) => (secs > 0 ? new Date(Math.trunc(secs) * 1000).toISOString() : undefined)
|
|
420
423
|
const count = (used, limit) => used.toFixed(2).replace(/0+$/, "").replace(/\.$/, "") + " / " + goG(limit)
|
|
@@ -424,13 +427,14 @@ function usageOf(l) {
|
|
|
424
427
|
const t = u?.freeTrialInfo
|
|
425
428
|
if (t && String(t.freeTrialStatus ?? "").toUpperCase() === "ACTIVE" && num(t.usageLimitWithPrecision) > 0) {
|
|
426
429
|
const used = num(t.currentUsageWithPrecision), limit = num(t.usageLimitWithPrecision)
|
|
427
|
-
windows.push({ name: "Free trial", used: (100 * used) / limit, resetsAt: at(num(t.freeTrialExpiry)), display: count(used, limit)
|
|
430
|
+
windows.push({ name: "Free trial", used: (100 * used) / limit, resetsAt: at(num(t.freeTrialExpiry)), display: count(used, limit),
|
|
431
|
+
amount: used, limit, unit: "credits" })
|
|
428
432
|
}
|
|
429
433
|
const used = num(u?.currentUsageWithPrecision), limit = num(u?.usageLimitWithPrecision)
|
|
430
434
|
if (limit <= 0) continue
|
|
431
435
|
const reset = num(u?.nextDateReset) || num(l?.nextDateReset)
|
|
432
436
|
windows.push({ name: u?.displayNamePlural || u?.displayName || "Credits", used: (100 * used) / limit, resetsAt: at(reset),
|
|
433
|
-
display: count(used, limit), span: 30 * 24 * 3600 })
|
|
437
|
+
display: count(used, limit), amount: used, limit, unit: "credits", span: 30 * 24 * 3600 })
|
|
434
438
|
}
|
|
435
439
|
const email = l?.userInfo?.email
|
|
436
440
|
return { plan: planName(l?.subscriptionInfo?.subscriptionTitle), ...(typeof email === "string" && email ? { user: email } : {}), windows }
|