@iblai/iblai-js 1.6.0 → 1.6.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.
|
@@ -191470,9 +191470,14 @@ function CreditBalance({ tenant, username, mainPlatformKey, currentUserEmail, re
|
|
|
191470
191470
|
const billing = billingInfo &&
|
|
191471
191471
|
billingInfo;
|
|
191472
191472
|
const balance = parseInt((billing === null || billing === void 0 ? void 0 : billing.available_credits) || '0', 10);
|
|
191473
|
-
const
|
|
191474
|
-
|
|
191475
|
-
const
|
|
191473
|
+
const isFreePlan = formatPlanLabel(billing === null || billing === void 0 ? void 0 : billing.current_plan) === 'Free' ||
|
|
191474
|
+
(Boolean(billing === null || billing === void 0 ? void 0 : billing.free_trial) && (billing === null || billing === void 0 ? void 0 : billing.platform_key) !== mainPlatformKey);
|
|
191475
|
+
const isTrialPlan = Boolean(billing === null || billing === void 0 ? void 0 : billing.free_trial) && (billing === null || billing === void 0 ? void 0 : billing.platform_key) === mainPlatformKey;
|
|
191476
|
+
const planLabel = isFreePlan
|
|
191477
|
+
? 'Free'
|
|
191478
|
+
: isTrialPlan
|
|
191479
|
+
? 'Trial'
|
|
191480
|
+
: 'Premium';
|
|
191476
191481
|
const status = getCreditStatus(balance);
|
|
191477
191482
|
const palette = STATUS_PALETTE[status];
|
|
191478
191483
|
const hasPaymentMethod = Boolean(billing === null || billing === void 0 ? void 0 : billing.has_payment_method);
|
|
@@ -191487,7 +191492,7 @@ function CreditBalance({ tenant, username, mainPlatformKey, currentUserEmail, re
|
|
|
191487
191492
|
setOpen(false);
|
|
191488
191493
|
setIsAddCreditsModalOpen(true);
|
|
191489
191494
|
};
|
|
191490
|
-
return (jsxs(DropdownMenu, { open: open, onOpenChange: handleOpenChange, children: [jsx(DropdownMenuTrigger, { asChild: true, children: jsxs(Button$1, { variant: "ghost", size: "icon", className: cn('relative', className), "data-testid": "credit-balance-trigger", "aria-label": billing ? `${balance.toLocaleString('en-US')} credits remaining` : 'Credit balance', children: [jsx(CreditCard, { className: "h-5! w-5!" }), billing && status !== 'healthy' && (jsx("span", { className: "absolute -top-1 -right-1 flex h-2.5 w-2.5 rounded-full ring-2 ring-white", style: { backgroundColor: palette.dot }, "aria-hidden": "true" }))] }) }), jsxs(DropdownMenuContent, { align: "end", className: "w-[320px] p-0 z-9999 border border-gray-100", "data-testid": "credit-balance-panel", children: [isFetching && !billing ? (jsx("div", { className: "px-3 py-3 text-sm text-gray-500", children: "Loading credits..." })) : isError || !billing ? (jsx("div", { className: "px-3 py-3 text-sm text-gray-500", children: "Unable to load credit balance." })) : (jsxs(Fragment$1, { children: [jsxs("div", { className: "space-y-3 p-4", children: [jsxs("div", { className: "flex items-center justify-between", children: [jsx("span", { className: "text-sm font-normal text-[#717985]", children: "Remaining" }), jsxs("span", { className: "text-sm font-medium text-[#101828]", children: [balance.toLocaleString('en-US'), " Credits"] })] }), billing.consumed_credits != null && (jsxs("div", { className: "flex items-center justify-between", children: [jsx("span", { className: "text-sm font-normal text-[#717985]", children: "Consumed" }), jsxs("span", { className: "text-sm font-medium text-[#101828]", children: [parseInt(billing.consumed_credits || '0', 10).toLocaleString('en-US'), " Credits"] })] })), billing.credits_reset_date && (jsxs("div", { className: "flex items-center justify-between", children: [jsx("span", { className: "text-sm font-normal text-[#717985]", children: "Resets on" }), jsx("span", { className: "text-sm font-medium text-[#101828]", children: formatResetDate(billing.credits_reset_date) })] }))] }),
|
|
191495
|
+
return (jsxs(DropdownMenu, { open: open, onOpenChange: handleOpenChange, children: [jsx(DropdownMenuTrigger, { asChild: true, children: jsxs(Button$1, { variant: "ghost", size: "icon", className: cn('relative', className), "data-testid": "credit-balance-trigger", "aria-label": billing ? `${balance.toLocaleString('en-US')} credits remaining` : 'Credit balance', children: [jsx(CreditCard, { className: "h-5! w-5!" }), billing && status !== 'healthy' && (jsx("span", { className: "absolute -top-1 -right-1 flex h-2.5 w-2.5 rounded-full ring-2 ring-white", style: { backgroundColor: palette.dot }, "aria-hidden": "true" }))] }) }), jsxs(DropdownMenuContent, { align: "end", className: "w-[320px] p-0 z-9999 border border-gray-100", "data-testid": "credit-balance-panel", children: [isFetching && !billing ? (jsx("div", { className: "px-3 py-3 text-sm text-gray-500", children: "Loading credits..." })) : isError || !billing ? (jsx("div", { className: "px-3 py-3 text-sm text-gray-500", children: "Unable to load credit balance." })) : (jsxs(Fragment$1, { children: [jsxs("div", { className: "space-y-3 p-4", children: [jsxs("div", { className: "flex items-center justify-between", children: [jsx("span", { className: "text-sm font-normal text-[#717985]", children: "Remaining" }), jsxs("span", { className: "text-sm font-medium text-[#101828]", children: [balance.toLocaleString('en-US'), " Credits"] })] }), billing.consumed_credits != null && (jsxs("div", { className: "flex items-center justify-between", children: [jsx("span", { className: "text-sm font-normal text-[#717985]", children: "Consumed" }), jsxs("span", { className: "text-sm font-medium text-[#101828]", children: [parseInt(billing.consumed_credits || '0', 10).toLocaleString('en-US'), " Credits"] })] })), billing.credits_reset_date && (jsxs("div", { className: "flex items-center justify-between", children: [jsx("span", { className: "text-sm font-normal text-[#717985]", children: "Resets on" }), jsx("span", { className: "text-sm font-medium text-[#101828]", children: formatResetDate(billing.credits_reset_date) })] }))] }), !isFreePlan && !isTrialPlan && hasPaymentMethod && (jsxs("div", { className: "border-t border-gray-100 p-4 space-y-3", children: [jsxs("div", { className: "flex items-center justify-between gap-3", children: [jsx("span", { className: "text-sm font-normal text-[#717985]", children: "Auto Recharge" }), jsx("span", { className: "rounded-full px-2 py-0.5 text-xs font-medium", style: {
|
|
191491
191496
|
backgroundColor: isAutoRechargeEnabled ? '#f5f8ff' : '#f3f4f6',
|
|
191492
191497
|
color: isAutoRechargeEnabled ? '#155dfc' : '#6a7282',
|
|
191493
191498
|
border: `1px solid ${isAutoRechargeEnabled ? '#d0e0ff' : '#e5e7eb'}`,
|
|
@@ -191495,7 +191500,7 @@ function CreditBalance({ tenant, username, mainPlatformKey, currentUserEmail, re
|
|
|
191495
191500
|
backgroundColor: '#f5f8ff',
|
|
191496
191501
|
color: '#155dfc',
|
|
191497
191502
|
border: '1px solid #d0e0ff',
|
|
191498
|
-
}, children:
|
|
191503
|
+
}, children: planLabel })] })), billing && (jsx("div", { className: "border-t border-gray-100 p-3 flex gap-2", children: isFreePlan || isTrialPlan ? (jsxs("button", { type: "button", onClick: () => handleUpgrade('premium'), disabled: isUpgrading, className: "flex h-9 w-full items-center justify-center gap-2 text-sm font-medium text-white transition-opacity hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-[#1447e6] focus-visible:ring-offset-1 disabled:opacity-70", style: {
|
|
191499
191504
|
background: 'linear-gradient(to right, rgb(56, 161, 229), rgb(114, 132, 255))',
|
|
191500
191505
|
borderRadius: '6px',
|
|
191501
191506
|
}, children: [isUpgrading ? (jsx(LoaderCircle, { className: "h-4 w-4 animate-spin", "aria-hidden": "true" })) : (jsx(Sparkles, { className: "h-4 w-4", "aria-hidden": "true" })), isUpgrading ? 'Redirecting...' : 'Upgrade Plan'] })) : hasPaymentMethod ? (jsxs(Fragment$1, { children: [jsx("button", { type: "button", onClick: handleOpenAutoRechargeModal, className: "flex h-9 flex-1 items-center justify-center text-sm font-medium text-white transition-opacity hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-[#1447e6] focus-visible:ring-offset-1", style: {
|
|
@@ -163316,8 +163316,14 @@ function BillingTab({ tenant, userActiveApp = null, username, mainPlatformKey, c
|
|
|
163316
163316
|
return (jsx("div", { className: "container max-w-3xl !mt-0", children: jsxs("div", { className: "space-y-4", children: [jsx(SectionSkeleton, {}), jsx(SectionSkeleton, { withBody: true }), jsx(SectionSkeleton, { withBody: true })] }) }));
|
|
163317
163317
|
}
|
|
163318
163318
|
const billing = billingInfo;
|
|
163319
|
-
const
|
|
163320
|
-
|
|
163319
|
+
const isFreePlan = formatPlanLabel(billing === null || billing === void 0 ? void 0 : billing.current_plan) === 'Free' ||
|
|
163320
|
+
(Boolean(billing === null || billing === void 0 ? void 0 : billing.free_trial) && (billing === null || billing === void 0 ? void 0 : billing.platform_key) !== mainPlatformKey);
|
|
163321
|
+
const isTrialPlan = Boolean(billing === null || billing === void 0 ? void 0 : billing.free_trial) && (billing === null || billing === void 0 ? void 0 : billing.platform_key) === mainPlatformKey;
|
|
163322
|
+
const planLabel = isFreePlan
|
|
163323
|
+
? 'Free'
|
|
163324
|
+
: isTrialPlan
|
|
163325
|
+
? 'Trial'
|
|
163326
|
+
: 'Premium';
|
|
163321
163327
|
const availableCredits = (_a = Number(billing === null || billing === void 0 ? void 0 : billing.available_credits)) !== null && _a !== void 0 ? _a : 0;
|
|
163322
163328
|
const consumedCredits = (billing === null || billing === void 0 ? void 0 : billing.consumed_credits) != null ? parseInt(billing.consumed_credits, 10) : null;
|
|
163323
163329
|
const hasPaymentMethod = Boolean(billing === null || billing === void 0 ? void 0 : billing.has_payment_method);
|
|
@@ -163338,11 +163344,11 @@ function BillingTab({ tenant, userActiveApp = null, username, mainPlatformKey, c
|
|
|
163338
163344
|
}
|
|
163339
163345
|
return 'Manage your subscription and billing details';
|
|
163340
163346
|
})();
|
|
163341
|
-
return (jsxs("div", { className: "container mx-auto max-w-3xl !mt-0", children: [jsxs("div", { className: "space-y-4", children: [jsx(Section, { title: "Plan", testId: "billing-plan-section", description: planDescription, action:
|
|
163347
|
+
return (jsxs("div", { className: "container mx-auto max-w-3xl !mt-0", children: [jsxs("div", { className: "space-y-4", children: [jsx(Section, { title: "Plan", testId: "billing-plan-section", description: planDescription, action: isFreePlan || isTrialPlan ? (jsxs(Button$1, { onClick: () => handleUpgrade('premium'), disabled: isUpgrading, className: "h-9 px-4 text-[14px] font-medium text-white bg-gradient-to-r from-[rgb(56,161,229)] to-[rgb(114,132,255)] hover:opacity-90 disabled:opacity-70", children: [isUpgrading ? (jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" })) : (jsx(Sparkles, { className: "h-4 w-4" })), isUpgrading ? 'Redirecting...' : 'Upgrade'] })) : undefined, children: jsxs("div", { className: "flex items-center gap-2", children: [jsx("span", { "data-testid": "billing-plan-label", className: "text-[18px] font-semibold leading-7 text-[#101828] dark:text-gray-100", children: planLabel }), jsx("span", { className: "rounded-full px-2.5 py-0.5 text-[12px] font-medium", style: {
|
|
163342
163348
|
backgroundColor: '#f5f8ff',
|
|
163343
163349
|
color: '#155dfc',
|
|
163344
163350
|
border: '1px solid #d0e0ff',
|
|
163345
|
-
}, children: "Current" })] }) }), jsx(Section, { title: "Credits", testId: "billing-credits-section", description: "Track your available credits and usage.", action: isFreePlan ? undefined : hasPaymentMethod ? (jsx(Button$1, { variant: "outline", onClick: () => setIsAddCreditsModalOpen(true), className: "h-9 px-4 text-[14px] font-medium", children: "Add Credits" })) : (jsxs(Button$1, { onClick: handleSetupPaymentMethod, disabled: isRedirectingToPaymentSettings, className: "h-9 px-4 text-[14px] font-medium bg-gradient-to-r from-[#2563EB] to-[#93C5FD] hover:opacity-90 text-white", children: [isRedirectingToPaymentSettings ? (jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" })) : (jsx(Wallet, { className: "h-4 w-4" })), isRedirectingToPaymentSettings ? 'Redirecting...' : 'Manage Billing'] })), children: jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [jsx(Stat, { label: "Available", value: `${formatCredits(availableCredits)} Credits`, hint: "Credits remaining" }), consumedCredits != null && (jsx(Stat, { label: "Consumed", value: `${formatCredits(consumedCredits)} Credits`, hint: "Used this period" })), (billing === null || billing === void 0 ? void 0 : billing.credits_reset_date) && (jsx(Stat, { label: "Resets on", value: formatRenewalDate(billing.credits_reset_date), hint: "Next reset date" }))] }) }),
|
|
163351
|
+
}, children: "Current" })] }) }), jsx(Section, { title: "Credits", testId: "billing-credits-section", description: "Track your available credits and usage.", action: isFreePlan || isTrialPlan ? undefined : hasPaymentMethod ? (jsx(Button$1, { variant: "outline", onClick: () => setIsAddCreditsModalOpen(true), className: "h-9 px-4 text-[14px] font-medium", children: "Add Credits" })) : (jsxs(Button$1, { onClick: handleSetupPaymentMethod, disabled: isRedirectingToPaymentSettings, className: "h-9 px-4 text-[14px] font-medium bg-gradient-to-r from-[#2563EB] to-[#93C5FD] hover:opacity-90 text-white", children: [isRedirectingToPaymentSettings ? (jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" })) : (jsx(Wallet, { className: "h-4 w-4" })), isRedirectingToPaymentSettings ? 'Redirecting...' : 'Manage Billing'] })), children: jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [jsx(Stat, { label: "Available", value: `${formatCredits(availableCredits)} Credits`, hint: "Credits remaining" }), consumedCredits != null && (jsx(Stat, { label: "Consumed", value: `${formatCredits(consumedCredits)} Credits`, hint: "Used this period" })), (billing === null || billing === void 0 ? void 0 : billing.credits_reset_date) && (jsx(Stat, { label: "Resets on", value: formatRenewalDate(billing.credits_reset_date), hint: "Next reset date" }))] }) }), !isFreePlan && !isTrialPlan && hasPaymentMethod && (jsx(Section, { title: "Auto Recharge", testId: "billing-auto-recharge-section", description: "Top up your balance automatically when credits run low.", action: jsxs("div", { className: "flex items-center gap-3", children: [jsx("span", { "data-testid": "billing-auto-recharge-status", className: "rounded-full px-2.5 py-0.5 text-[12px] font-medium", style: {
|
|
163346
163352
|
backgroundColor: isAutoRechargeEnabled ? '#f5f8ff' : '#f3f4f6',
|
|
163347
163353
|
color: isAutoRechargeEnabled ? '#155dfc' : '#6a7282',
|
|
163348
163354
|
border: `1px solid ${isAutoRechargeEnabled ? '#d0e0ff' : '#e5e7eb'}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iblai/iblai-js",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Unified JavaScript SDK for IBL.ai — re-exports data-layer, web-containers, and web-utils under a single package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"dotenv": "16.6.1",
|
|
63
63
|
"winston": "3.19.0",
|
|
64
64
|
"@iblai/data-layer": "1.4.0",
|
|
65
|
-
"@iblai/
|
|
66
|
-
"@iblai/
|
|
67
|
-
"@iblai/web-
|
|
65
|
+
"@iblai/web-containers": "1.4.1",
|
|
66
|
+
"@iblai/mcp": "1.4.1",
|
|
67
|
+
"@iblai/web-utils": "1.4.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@iblai/iblai-api": "4.166.0-ai",
|