@nextjscms/plugin-cpanel-dashboard 2.1.22 → 2.1.24

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardPage.d.ts","sourceRoot":"","sources":["../../src/client/DashboardPage.tsx"],"names":[],"mappings":"AAuBA,KAAK,wBAAwB,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,WAAW,wBAAwB,4CA0NtE,CAAA;AAkFD,eAAe,mBAAmB,CAAA"}
1
+ {"version":3,"file":"DashboardPage.d.ts","sourceRoot":"","sources":["../../src/client/DashboardPage.tsx"],"names":[],"mappings":"AA+BA,KAAK,wBAAwB,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,WAAW,wBAAwB,4CAgPtE,CAAA;AAiGD,eAAe,mBAAmB,CAAA"}
@@ -1,19 +1,19 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { humanReadableFileSize } from 'nextjs-cms/utils';
4
- import { trpc as trpcClient } from 'nextjs-cms/api/trpc/client';
4
+ import { usePluginTRPC } from 'nextjs-cms/plugins/client';
5
5
  import { useI18n } from 'nextjs-cms/translations/client';
6
6
  // import { LucideIcon } from 'lucide-react'
7
- import { HardDriveIcon, NetworkIcon, MailIcon, DatabaseIcon, ServerIcon, FolderIcon, HexagonIcon, PackageIcon } from 'lucide-react';
7
+ import { HardDriveIcon, NetworkIcon, MailIcon, DatabaseIcon, ServerIcon, FolderIcon, HexagonIcon, PackageIcon, } from 'lucide-react';
8
8
  export const CpanelDashboardPage = ({ title }) => {
9
9
  const t = useI18n();
10
- const trpc = trpcClient;
10
+ const trpc = usePluginTRPC();
11
11
  const query = trpc?.cpanelDashboard?.getData.useQuery;
12
12
  const { data, isLoading, isError, error } = query ? query() : { isLoading: true, isError: true, error: null };
13
13
  if (!query) {
14
- return (_jsx("div", { className: 'flex min-h-[200px] items-center justify-center p-6', children: _jsx("div", { className: 'rounded-lg border border-destructive/30 bg-destructive/5 px-6 py-4 text-sm text-destructive', children: t('cpanelPluginMisconfigured') }) }));
14
+ return (_jsx("div", { className: 'flex min-h-[200px] items-center justify-center p-6', children: _jsx("div", { className: 'border-destructive/30 bg-destructive/5 text-destructive rounded-lg border px-6 py-4 text-sm', children: t('cpanelPluginMisconfigured') }) }));
15
15
  }
16
- return (_jsxs("div", { className: 'w-full', children: [_jsx("div", { className: 'bg-orange-500 dark:bg-orange-800 p-8 font-extrabold text-foreground', children: _jsx("div", { className: 'relative', children: _jsx("h1", { className: 'text-3xl font-bold tracking-tight text-white', children: title || t('cPanelDashboard') }) }) }), _jsxs("div", { className: 'flex flex-col gap-6 p-6', children: [isLoading && (_jsx("div", { className: 'grid grid-cols-1 gap-4 md-sidebar:grid-cols-2 2xl-sidebar:grid-cols-4', children: [...Array(4)].map((_, i) => (_jsxs("div", { className: 'animate-pulse rounded-xl border bg-card p-5', children: [_jsxs("div", { className: 'mb-4 flex items-center gap-3', children: [_jsx("div", { className: 'size-10 rounded-lg bg-muted' }), _jsx("div", { className: 'h-4 w-24 rounded bg-muted' })] }), _jsx("div", { className: 'mb-2 h-8 w-20 rounded bg-muted' }), _jsx("div", { className: 'h-2 rounded-full bg-muted' })] }, i))) })), isError && !isLoading && (_jsxs("div", { className: 'flex items-center gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-4', children: [_jsx("div", { className: 'flex size-10 shrink-0 items-center justify-center rounded-full bg-destructive/10', children: _jsx("svg", { className: 'size-5 text-destructive', fill: 'none', stroke: 'currentColor', viewBox: '0 0 24 24', children: _jsx("path", { strokeLinecap: 'round', strokeLinejoin: 'round', strokeWidth: 2, d: 'M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z' }) }) }), _jsxs("div", { children: [_jsx("p", { className: 'font-medium text-destructive', children: t('unableToLoadCpanelData') }), error instanceof Error && (_jsx("p", { className: 'mt-0.5 text-sm text-destructive/80', children: error.message }))] })] })), data && (_jsxs(_Fragment, { children: [_jsxs("div", { className: 'grid grid-cols-1 gap-4 md-sidebar:grid-cols-2 2xl-sidebar:grid-cols-4', children: [_jsx(StatCard, { icon: _jsx(HardDriveIcon, { color: 'blue' }), title: t('diskSpace'), used: data.diskSpaceUsage, total: data.diskSpaceLimit, formatFn: humanReadableFileSize }), _jsx(StatCard, { icon: _jsx(NetworkIcon, { color: 'green' }), title: t('thisMothBandwidth'), used: data.bandwidthUsage, total: data.bandwidthLimit, formatFn: humanReadableFileSize }), _jsx(StatCard, { icon: _jsx(MailIcon, { color: 'red' }), title: t('emailAccounts'), used: data.emailsUsage, total: data.emailsLimit }), _jsx(StatCard, { icon: _jsx(DatabaseIcon, { color: 'purple' }), title: t('mysqlDatabases'), used: data.dbsCount, total: data.dbsLimit })] }), _jsxs("div", { className: 'grid grid-cols-1 gap-6 lg-sidebar:grid-cols-2', children: [_jsxs("div", { className: 'overflow-hidden rounded-xl border bg-card shadow-sm', children: [_jsxs("div", { className: 'flex items-center gap-3 border-b bg-gradient-to-r from-cyan-500/10 via-transparent to-transparent px-6 py-5', children: [_jsx("div", { className: 'flex size-10 items-center justify-center rounded-xl bg-cyan-500/15 text-cyan-600 dark:bg-cyan-500/20 dark:text-cyan-400', children: _jsx(ServerIcon, {}) }), _jsx("h2", { className: 'text-lg font-semibold text-card-foreground', children: t('accountInformation') })] }), _jsxs("div", { className: 'divide-y p-2', children: [_jsx(InfoRow, { icon: _jsx(HexagonIcon, {}), iconColor: 'text-green-800', label: t('nodeVersion'), value: data?.nodeVersion ?? 'N/A', valueColor: 'text-green-600 dark:text-green-400' }), _jsx(InfoRow, { icon: _jsx(PackageIcon, {}), iconColor: 'text-red-800', label: t('pnpmVersion'), value: data?.pnpmVersion ?? 'N/A', valueColor: 'text-green-600 dark:text-green-400' }), _jsx(InfoRow, { icon: _jsx(PackageIcon, {}), iconColor: 'text-red-800', label: t('npmVersion'), value: data?.npmVersion ?? 'N/A', valueColor: 'text-green-600 dark:text-green-400' }), _jsx(InfoRow, { icon: _jsx(PackageIcon, {}), iconColor: 'text-red-800', label: t('bunVersion'), value: data?.bunVersion ?? 'N/A', valueColor: 'text-green-600 dark:text-green-400' }), _jsx(InfoRow, { icon: _jsx("span", { className: 'font-mono text-xs font-bold text-indigo-600 dark:text-indigo-400', children: "PHP" }), label: t('phpVersion'), value: data?.phpVersion ?? 'N/A', valueColor: 'text-indigo-600 dark:text-indigo-400' }), _jsx(InfoRow, { icon: _jsx(FolderIcon, {}), iconColor: 'text-amber-500', label: t('documentRoot'), value: data?.documentRoot ?? 'N/A', mono: true })] })] }), _jsxs("div", { className: 'overflow-hidden rounded-xl border bg-card shadow-sm', children: [_jsxs("div", { className: 'flex items-center gap-3 border-b bg-gradient-to-r from-purple-500/10 via-transparent to-transparent px-6 py-5', children: [_jsx("div", { className: 'flex size-10 items-center justify-center rounded-xl bg-purple-500/15 text-purple-600 dark:bg-purple-500/20 dark:text-purple-400', children: _jsx(DatabaseIcon, {}) }), _jsx("h2", { className: 'text-lg font-semibold text-card-foreground', children: t('database') })] }), data?.dbInfo ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: 'divide-y border-b p-2', children: [_jsx(InfoRow, { label: t('version'), value: data.dbInfo.version, valueColor: 'text-purple-600 dark:text-purple-400 font-semibold' }), _jsx(InfoRow, { label: t('remote'), value: _jsx("span", { className: `inline-flex items-center rounded-full px-2.5 py-1 text-xs font-semibold ${data.dbInfo.is_remote ? 'bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-400' : 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400'}`, children: data.dbInfo.is_remote ? t('yes') : t('no') }) })] }), data?.dbsList?.length > 0 && (_jsxs("div", { className: 'p-4', children: [_jsxs("p", { className: 'mb-4 text-xs font-semibold uppercase tracking-wider text-purple-600 dark:text-purple-400', children: [t('databases'), " (", data.dbsList.length, ")"] }), _jsx("div", { className: 'space-y-3', children: data.dbsList.map((db, index) => (_jsxs("div", { className: 'flex items-center justify-between rounded-xl border border-purple-200/50 bg-gradient-to-r from-purple-50 to-transparent p-4 transition-all hover:border-purple-300 hover:shadow-sm dark:border-purple-800/30 dark:from-purple-900/20 dark:hover:border-purple-700', children: [_jsxs("div", { className: 'flex items-center gap-3', children: [_jsx("div", { className: 'flex size-10 items-center justify-center rounded-lg bg-purple-500/15 text-purple-600 dark:bg-purple-500/25 dark:text-purple-400', children: _jsx(DatabaseIcon, {}) }), _jsxs("div", { children: [_jsx("p", { className: 'font-semibold text-card-foreground', children: db.database }), _jsxs("p", { className: 'text-xs text-muted-foreground', children: [db.users?.length ?? 0, " ", t('users')] })] })] }), _jsxs("div", { className: 'text-right', children: [_jsx("p", { className: 'text-sm font-bold text-purple-600 dark:text-purple-400', children: humanReadableFileSize(db.disk_usage) }), _jsx("p", { className: 'text-xs text-muted-foreground', children: t('diskUsage') })] })] }, `${db.name}_${db.database}_${index}`))) })] }))] })) : (_jsx("div", { className: 'flex items-center justify-center py-12 text-sm text-muted-foreground', children: t('mysqlNotInstalled') }))] })] })] }))] })] }));
16
+ return (_jsxs("div", { className: 'w-full', children: [_jsx("div", { className: 'text-foreground bg-orange-500 p-8 font-extrabold dark:bg-orange-800', children: _jsx("div", { className: 'relative', children: _jsx("h1", { className: 'text-3xl font-bold tracking-tight text-white', children: title || t('cPanelDashboard') }) }) }), _jsxs("div", { className: 'flex flex-col gap-6 p-6', children: [isLoading && (_jsx("div", { className: 'md-sidebar:grid-cols-2 2xl-sidebar:grid-cols-4 grid grid-cols-1 gap-4', children: [...Array(4)].map((_, i) => (_jsxs("div", { className: 'bg-card animate-pulse rounded-xl border p-5', children: [_jsxs("div", { className: 'mb-4 flex items-center gap-3', children: [_jsx("div", { className: 'bg-muted size-10 rounded-lg' }), _jsx("div", { className: 'bg-muted h-4 w-24 rounded' })] }), _jsx("div", { className: 'bg-muted mb-2 h-8 w-20 rounded' }), _jsx("div", { className: 'bg-muted h-2 rounded-full' })] }, i))) })), isError && !isLoading && (_jsxs("div", { className: 'border-destructive/30 bg-destructive/5 flex items-center gap-3 rounded-lg border p-4', children: [_jsx("div", { className: 'bg-destructive/10 flex size-10 shrink-0 items-center justify-center rounded-full', children: _jsx("svg", { className: 'text-destructive size-5', fill: 'none', stroke: 'currentColor', viewBox: '0 0 24 24', children: _jsx("path", { strokeLinecap: 'round', strokeLinejoin: 'round', strokeWidth: 2, d: 'M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z' }) }) }), _jsxs("div", { children: [_jsx("p", { className: 'text-destructive font-medium', children: t('unableToLoadCpanelData') }), error instanceof Error && (_jsx("p", { className: 'text-destructive/80 mt-0.5 text-sm', children: error.message }))] })] })), data && (_jsxs(_Fragment, { children: [_jsxs("div", { className: 'md-sidebar:grid-cols-2 2xl-sidebar:grid-cols-4 grid grid-cols-1 gap-4', children: [_jsx(StatCard, { icon: _jsx(HardDriveIcon, { color: 'blue' }), title: t('diskSpace'), used: data.diskSpaceUsage, total: data.diskSpaceLimit, formatFn: humanReadableFileSize }), _jsx(StatCard, { icon: _jsx(NetworkIcon, { color: 'green' }), title: t('thisMothBandwidth'), used: data.bandwidthUsage, total: data.bandwidthLimit, formatFn: humanReadableFileSize }), _jsx(StatCard, { icon: _jsx(MailIcon, { color: 'red' }), title: t('emailAccounts'), used: data.emailsUsage, total: data.emailsLimit }), _jsx(StatCard, { icon: _jsx(DatabaseIcon, { color: 'purple' }), title: t('mysqlDatabases'), used: data.dbsCount, total: data.dbsLimit })] }), _jsxs("div", { className: 'lg-sidebar:grid-cols-2 grid grid-cols-1 gap-6', children: [_jsxs("div", { className: 'bg-card overflow-hidden rounded-xl border shadow-sm', children: [_jsxs("div", { className: 'flex items-center gap-3 border-b bg-gradient-to-r from-cyan-500/10 via-transparent to-transparent px-6 py-5', children: [_jsx("div", { className: 'flex size-10 items-center justify-center rounded-xl bg-cyan-500/15 text-cyan-600 dark:bg-cyan-500/20 dark:text-cyan-400', children: _jsx(ServerIcon, {}) }), _jsx("h2", { className: 'text-card-foreground text-lg font-semibold', children: t('accountInformation') })] }), _jsxs("div", { className: 'divide-y p-2', children: [_jsx(InfoRow, { icon: _jsx(HexagonIcon, {}), iconColor: 'text-green-800', label: t('nodeVersion'), value: data?.nodeVersion ?? 'N/A', valueColor: 'text-green-600 dark:text-green-400' }), _jsx(InfoRow, { icon: _jsx(PackageIcon, {}), iconColor: 'text-red-800', label: t('pnpmVersion'), value: data?.pnpmVersion ?? 'N/A', valueColor: 'text-green-600 dark:text-green-400' }), _jsx(InfoRow, { icon: _jsx(PackageIcon, {}), iconColor: 'text-red-800', label: t('npmVersion'), value: data?.npmVersion ?? 'N/A', valueColor: 'text-green-600 dark:text-green-400' }), _jsx(InfoRow, { icon: _jsx(PackageIcon, {}), iconColor: 'text-red-800', label: t('bunVersion'), value: data?.bunVersion ?? 'N/A', valueColor: 'text-green-600 dark:text-green-400' }), _jsx(InfoRow, { icon: _jsx("span", { className: 'font-mono text-xs font-bold text-indigo-600 dark:text-indigo-400', children: "PHP" }), label: t('phpVersion'), value: data?.phpVersion ?? 'N/A', valueColor: 'text-indigo-600 dark:text-indigo-400' }), _jsx(InfoRow, { icon: _jsx(FolderIcon, {}), iconColor: 'text-amber-500', label: t('documentRoot'), value: data?.documentRoot ?? 'N/A', mono: true })] })] }), _jsxs("div", { className: 'bg-card overflow-hidden rounded-xl border shadow-sm', children: [_jsxs("div", { className: 'flex items-center gap-3 border-b bg-gradient-to-r from-purple-500/10 via-transparent to-transparent px-6 py-5', children: [_jsx("div", { className: 'flex size-10 items-center justify-center rounded-xl bg-purple-500/15 text-purple-600 dark:bg-purple-500/20 dark:text-purple-400', children: _jsx(DatabaseIcon, {}) }), _jsx("h2", { className: 'text-card-foreground text-lg font-semibold', children: t('database') })] }), data?.dbInfo ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: 'divide-y border-b p-2', children: [_jsx(InfoRow, { label: t('version'), value: data.dbInfo.version, valueColor: 'text-purple-600 dark:text-purple-400 font-semibold' }), _jsx(InfoRow, { label: t('remote'), value: _jsx("span", { className: `inline-flex items-center rounded-full px-2.5 py-1 text-xs font-semibold ${data.dbInfo.is_remote ? 'bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-400' : 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400'}`, children: data.dbInfo.is_remote ? t('yes') : t('no') }) })] }), data?.dbsList?.length > 0 && (_jsxs("div", { className: 'p-4', children: [_jsxs("p", { className: 'mb-4 text-xs font-semibold tracking-wider text-purple-600 uppercase dark:text-purple-400', children: [t('databases'), " (", data.dbsList.length, ")"] }), _jsx("div", { className: 'space-y-3', children: data.dbsList.map((db, index) => (_jsxs("div", { className: 'flex items-center justify-between rounded-xl border border-purple-200/50 bg-gradient-to-r from-purple-50 to-transparent p-4 transition-all hover:border-purple-300 hover:shadow-sm dark:border-purple-800/30 dark:from-purple-900/20 dark:hover:border-purple-700', children: [_jsxs("div", { className: 'flex items-center gap-3', children: [_jsx("div", { className: 'flex size-10 items-center justify-center rounded-lg bg-purple-500/15 text-purple-600 dark:bg-purple-500/25 dark:text-purple-400', children: _jsx(DatabaseIcon, {}) }), _jsxs("div", { children: [_jsx("p", { className: 'text-card-foreground font-semibold', children: db.database }), _jsxs("p", { className: 'text-muted-foreground text-xs', children: [db.users?.length ?? 0, " ", t('users')] })] })] }), _jsxs("div", { className: 'text-right', children: [_jsx("p", { className: 'text-sm font-bold text-purple-600 dark:text-purple-400', children: humanReadableFileSize(db.disk_usage) }), _jsx("p", { className: 'text-muted-foreground text-xs', children: t('diskUsage') })] })] }, `${db.name}_${db.database}_${index}`))) })] }))] })) : (_jsx("div", { className: 'text-muted-foreground flex items-center justify-center py-12 text-sm', children: t('mysqlNotInstalled') }))] })] })] }))] })] }));
17
17
  };
18
18
  const StatCard = ({ icon, title, used, total, formatFn }) => {
19
19
  const t = useI18n();
@@ -28,7 +28,11 @@ const StatCard = ({ icon, title, used, total, formatFn }) => {
28
28
  return 'bg-yellow-500';
29
29
  return 'bg-green-500';
30
30
  };
31
- return (_jsx("div", { className: `group relative overflow-hidden rounded-xl border border-l-4 bg-card p-6 shadow-sm transition-all hover:shadow-lg`, children: _jsxs("div", { className: 'flex flex-col relative', children: [_jsxs("div", { className: 'mb-4 flex items-center justify-between', children: [_jsx("span", { className: 'text-sm font-medium text-muted-foreground', children: title }), _jsx("div", { className: `flex size-11 items-center justify-center rounded-xl`, children: icon })] }), _jsxs("div", { className: 'flex items-end gap-2 justify-start content-end mb-4 text-start w-full', children: [_jsx("span", { dir: 'ltr', className: 'text-3xl font-bold tracking-tight text-card-foreground', children: displayUsed }), _jsx("span", { children: "/" }), _jsxs("span", { dir: 'ltr', className: 'text-sm text-muted-foreground', children: [" ", displayTotal] })] }), _jsx("div", { className: 'h-2.5 overflow-hidden rounded-full bg-muted/50', children: _jsx("div", { className: `h-full rounded-full transition-all duration-500 ${getProgressColor()}`, style: { width: `${percentage}%` } }) }), _jsxs("div", { className: 'flex flex-row gap-2 pt-3 text-xs font-medium text-muted-foreground', children: [_jsxs("span", { className: percentage >= 75 ? 'text-amber-600 dark:text-amber-400' : percentage >= 90 ? 'text-red-600 dark:text-red-400' : '', children: [percentage.toFixed(1), "%"] }), _jsx("span", { children: t('usedLabel') })] })] }) }));
31
+ return (_jsx("div", { className: `group bg-card relative overflow-hidden rounded-xl border border-l-4 p-6 shadow-sm transition-all hover:shadow-lg`, children: _jsxs("div", { className: 'relative flex flex-col', children: [_jsxs("div", { className: 'mb-4 flex items-center justify-between', children: [_jsx("span", { className: 'text-muted-foreground text-sm font-medium', children: title }), _jsx("div", { className: `flex size-11 items-center justify-center rounded-xl`, children: icon })] }), _jsxs("div", { className: 'mb-4 flex w-full content-end items-end justify-start gap-2 text-start', children: [_jsx("span", { dir: 'ltr', className: 'text-card-foreground text-3xl font-bold tracking-tight', children: displayUsed }), _jsx("span", { children: "/" }), _jsxs("span", { dir: 'ltr', className: 'text-muted-foreground text-sm', children: [' ', displayTotal] })] }), _jsx("div", { className: 'bg-muted/50 h-2.5 overflow-hidden rounded-full', children: _jsx("div", { className: `h-full rounded-full transition-all duration-500 ${getProgressColor()}`, style: { width: `${percentage}%` } }) }), _jsxs("div", { className: 'text-muted-foreground flex flex-row gap-2 pt-3 text-xs font-medium', children: [_jsxs("span", { className: percentage >= 75
32
+ ? 'text-amber-600 dark:text-amber-400'
33
+ : percentage >= 90
34
+ ? 'text-red-600 dark:text-red-400'
35
+ : '', children: [percentage.toFixed(1), "%"] }), _jsx("span", { children: t('usedLabel') })] })] }) }));
32
36
  };
33
- const InfoRow = ({ icon, iconColor, label, value, valueColor, mono }) => (_jsxs("div", { className: 'flex items-center justify-between rounded-lg px-4 py-4 transition-colors hover:bg-muted/30', children: [_jsxs("div", { className: 'flex items-center gap-3 text-sm text-muted-foreground', children: [icon && _jsx("span", { className: iconColor || 'text-muted-foreground/70', children: icon }), _jsx("span", { className: 'font-medium', children: label })] }), _jsx("span", { className: `text-sm ${valueColor || 'text-card-foreground'} ${mono ? 'font-mono text-xs' : 'font-medium'}`, children: value })] }));
37
+ const InfoRow = ({ icon, iconColor, label, value, valueColor, mono }) => (_jsxs("div", { className: 'hover:bg-muted/30 flex items-center justify-between rounded-lg px-4 py-4 transition-colors', children: [_jsxs("div", { className: 'text-muted-foreground flex items-center gap-3 text-sm', children: [icon && _jsx("span", { className: iconColor || 'text-muted-foreground/70', children: icon }), _jsx("span", { className: 'font-medium', children: label })] }), _jsx("span", { className: `text-sm ${valueColor || 'text-card-foreground'} ${mono ? 'font-mono text-xs' : 'font-medium'}`, children: value })] }));
34
38
  export default CpanelDashboardPage;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,68 @@
1
1
  export declare const PLUGIN_TITLE = "cPanel Dashboard";
2
- export declare function createPlugin(): import("nextjs-cms/plugins/server").CMSPluginSingleRoute;
2
+ export declare const cpanelDashboardPlugin: {
3
+ readonly package: "@nextjscms/plugin-cpanel-dashboard";
4
+ readonly title: "cPanel Dashboard";
5
+ readonly routes: readonly [{
6
+ readonly path: "/cpanel-dashboard";
7
+ readonly title: "cPanel Dashboard";
8
+ readonly icon: "home";
9
+ readonly prefetch: "cpanelDashboard.getData";
10
+ }];
11
+ };
12
+ export declare function createPlugin(): Promise<{
13
+ router: import("@trpc/server").TRPCBuiltRouter<{
14
+ ctx: {
15
+ headers: Headers;
16
+ db: import("drizzle-orm/mysql2").MySql2Database<typeof import("nextjs-cms/db/schema")> & {
17
+ $client: import("mysql2/promise").Pool;
18
+ };
19
+ session: import("nextjs-cms").Session | null;
20
+ };
21
+ meta: object;
22
+ errorShape: {
23
+ data: {
24
+ zodError: import("zod").ZodFlattenedError<unknown, string> | null;
25
+ code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
26
+ httpStatus: number;
27
+ path?: string;
28
+ stack?: string;
29
+ };
30
+ message: string;
31
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
32
+ };
33
+ transformer: true;
34
+ }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
35
+ getData: import("@trpc/server").TRPCQueryProcedure<{
36
+ input: void;
37
+ output: {
38
+ dbsLimit: number;
39
+ dbsCount: number;
40
+ bandwidthUsage: number;
41
+ bandwidthLimit: number;
42
+ diskSpaceUsage: number;
43
+ diskSpaceLimit: number;
44
+ emailsUsage: number;
45
+ emailsLimit: number;
46
+ dbInfo: any;
47
+ dbsList: any;
48
+ phpVersion: any;
49
+ nodeVersion: string | null;
50
+ pnpmVersion: string | null;
51
+ npmVersion: string | null;
52
+ bunVersion: string | null;
53
+ passengerAppList: never[];
54
+ documentRoot: any;
55
+ };
56
+ meta: object;
57
+ }>;
58
+ }>>;
59
+ package: "@nextjscms/plugin-cpanel-dashboard";
60
+ title: "cPanel Dashboard";
61
+ routes: readonly [{
62
+ readonly path: "/cpanel-dashboard";
63
+ readonly title: "cPanel Dashboard";
64
+ readonly icon: "home";
65
+ readonly prefetch: "cpanelDashboard.getData";
66
+ }];
67
+ }>;
3
68
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,qBAAqB,CAAA;AAC9C,wBAAgB,YAAY,6DAc3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,qBAAqB,CAAA;AAE9C,eAAO,MAAM,qBAAqB;;;;;;;;;CAWhC,CAAA;AAEF,wBAAsB,YAAY;;;;;;;;;;;;;;;oBAQo/C,CAAC;qBAA2B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GADljD"}
package/dist/index.js CHANGED
@@ -1,18 +1,21 @@
1
- import { definePlugin } from 'nextjs-cms/plugins/server';
2
- import { cpanelDashboardRouter } from './router.js';
1
+ import { definePlugin } from 'nextjs-cms/plugins/define';
3
2
  export const PLUGIN_TITLE = 'cPanel Dashboard';
4
- export function createPlugin() {
5
- return definePlugin({
6
- title: PLUGIN_TITLE,
7
- name: 'plugin_cpanel_dashboard',
8
- registryName: 'cpanel-dashboard',
3
+ export const cpanelDashboardPlugin = definePlugin({
4
+ package: '@nextjscms/plugin-cpanel-dashboard',
5
+ title: PLUGIN_TITLE,
6
+ routes: [
7
+ {
8
+ path: '/cpanel-dashboard',
9
+ title: PLUGIN_TITLE,
10
+ icon: 'home',
11
+ prefetch: 'cpanelDashboard.getData',
12
+ },
13
+ ],
14
+ });
15
+ export async function createPlugin() {
16
+ const { cpanelDashboardRouter } = await import('./router.js');
17
+ return {
18
+ ...cpanelDashboardPlugin,
9
19
  router: cpanelDashboardRouter,
10
- routes: [
11
- {
12
- path: '/cpanel-dashboard',
13
- title: PLUGIN_TITLE,
14
- icon: 'home',
15
- },
16
- ],
17
- });
20
+ };
18
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AA0CA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;gBAsBvB,CAAC;iBACA,CAAH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEP,CAAA"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAuDA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;gBAWU,CAAC;iBAEpC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8ER,CAAA"}
package/dist/router.js CHANGED
@@ -2,7 +2,9 @@ import { TRPCError } from '@trpc/server';
2
2
  import { execSync } from 'child_process';
3
3
  import getString from 'nextjs-cms/translations';
4
4
  import { CpanelAPI } from 'nextjs-cms/utils';
5
- import { pluginProcedure, router } from 'nextjs-cms/api/trpc';
5
+ import { pluginProcedure, router } from 'nextjs-cms/api/plugin';
6
+ import { extractPluginName } from 'nextjs-cms/plugins/derive';
7
+ const PLUGIN_NAME = extractPluginName(import.meta.url);
6
8
  const getNodeVersion = () => {
7
9
  try {
8
10
  const version = execSync('node -v', { encoding: 'utf-8' }).trim();
@@ -21,9 +23,18 @@ const getPnpmVersion = () => {
21
23
  return null;
22
24
  }
23
25
  };
26
+ const cleanNpmEnv = () => {
27
+ const env = { ...process.env };
28
+ for (const key of Object.keys(env)) {
29
+ if (key.startsWith('npm_config_') || key === 'npm_package_json') {
30
+ delete env[key];
31
+ }
32
+ }
33
+ return env;
34
+ };
24
35
  const getNpmVersion = () => {
25
36
  try {
26
- const version = execSync('npm -v', { encoding: 'utf-8' }).trim();
37
+ const version = execSync('npm -v', { encoding: 'utf-8', env: cleanNpmEnv() }).trim();
27
38
  return version; // Returns something like "10.10.0"
28
39
  }
29
40
  catch {
@@ -40,7 +51,7 @@ const getBunVersion = () => {
40
51
  }
41
52
  };
42
53
  export const cpanelDashboardRouter = router({
43
- getData: pluginProcedure('plugin_cpanel_dashboard').query(async ({ ctx }) => {
54
+ getData: pluginProcedure(PLUGIN_NAME).query(async ({ ctx }) => {
44
55
  if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
45
56
  throw new TRPCError({
46
57
  code: 'BAD_REQUEST',
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.tsx"],"names":[],"mappings":"AAOA,wBAA8B,qBAAqB,qDA6BlD"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.tsx"],"names":[],"mappings":"AAMA,wBAA8B,qBAAqB,qDAWlD"}
package/dist/server.js CHANGED
@@ -1,18 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { api, HydrateClient } from 'nextjs-cms/api/trpc/server';
3
2
  import { CpanelDashboardPage } from './client/DashboardPage.js';
4
3
  import { findPluginRouteByPath } from 'nextjs-cms/plugins/server';
5
4
  import { resolveMultilingualString, resolveLanguage } from 'nextjs-cms/translations';
6
5
  import { getCMSConfig } from 'nextjs-cms/core';
7
6
  import auth from 'nextjs-cms/auth';
8
7
  export default async function CpanelDashboardServer() {
9
- const helpers = api;
10
- const prefetch = helpers.cpanelDashboard?.getData?.prefetch;
11
- if (!prefetch) {
12
- throw new Error('[cpanel-dashboard] Missing cpanelDashboard.getData prefetch helper.');
13
- }
14
- await prefetch();
15
- // Resolve the plugin route title
16
8
  const [route, session, config] = await Promise.all([
17
9
  findPluginRouteByPath('/cpanel-dashboard'),
18
10
  auth(),
@@ -21,5 +13,5 @@ export default async function CpanelDashboardServer() {
21
13
  const { supportedLanguages, fallbackLanguage } = config.i18n;
22
14
  const language = resolveLanguage(session?.user?.language, supportedLanguages, fallbackLanguage);
23
15
  const resolvedTitle = route ? resolveMultilingualString(route.title, language, fallbackLanguage) : '';
24
- return (_jsx(HydrateClient, { children: _jsx(CpanelDashboardPage, { title: resolvedTitle }) }));
16
+ return _jsx(CpanelDashboardPage, { title: resolvedTitle });
25
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextjscms/plugin-cpanel-dashboard",
3
- "version": "2.1.22",
3
+ "version": "2.1.24",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "lucide-react": "^0.563.0",
28
28
  "react": "19.2.3",
29
29
  "react-dom": "19.2.3",
30
- "nextjs-cms": "0.9.22"
30
+ "nextjs-cms": "0.9.23"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/react": "^19.2.7",