@nextjscms/plugin-cpanel-emails 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.
- package/dist/client/EmailsPage.d.ts.map +1 -1
- package/dist/client/EmailsPage.js +10 -6
- package/dist/index.d.ts +81 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -15
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +8 -6
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -9
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailsPage.d.ts","sourceRoot":"","sources":["../../src/client/EmailsPage.tsx"],"names":[],"mappings":"AA6CA,KAAK,qBAAqB,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,WAAW,qBAAqB,
|
|
1
|
+
{"version":3,"file":"EmailsPage.d.ts","sourceRoot":"","sources":["../../src/client/EmailsPage.tsx"],"names":[],"mappings":"AA6CA,KAAK,qBAAqB,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,WAAW,qBAAqB,4CAwDhE,CAAA;AAsID,eAAe,gBAAgB,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { usePluginTRPC } from 'nextjs-cms/plugins/client';
|
|
5
5
|
import { useI18n } from 'nextjs-cms/translations/client';
|
|
6
6
|
export const CpanelEmailsPage = ({ title }) => {
|
|
7
7
|
const t = useI18n();
|
|
8
|
-
const trpc =
|
|
8
|
+
const trpc = usePluginTRPC();
|
|
9
9
|
const query = trpc?.cpanelEmails?.getEmails.useQuery;
|
|
10
10
|
const { data, isLoading, isError, error, refetch } = query
|
|
11
11
|
? query()
|
|
@@ -18,25 +18,29 @@ export const CpanelEmailsPage = ({ title }) => {
|
|
|
18
18
|
const quotaMutation = pluginApi.quotaChange.useMutation({ onSuccess: () => refetch() });
|
|
19
19
|
const passwordMutation = pluginApi.passwordChange.useMutation({ onSuccess: () => refetch() });
|
|
20
20
|
const deleteMutation = pluginApi.deleteEmail.useMutation({ onSuccess: () => refetch() });
|
|
21
|
-
return (_jsxs("div", { className: 'bg-white dark:bg-slate-900', children: [_jsx("div", { className: 'bg-linear-to-r from-sky-200 via-emerald-300 to-blue-600 p-8 font-extrabold
|
|
21
|
+
return (_jsxs("div", { className: 'bg-white dark:bg-slate-900', children: [_jsx("div", { className: 'text-foreground bg-linear-to-r from-sky-200 via-emerald-300 to-blue-600 p-8 font-extrabold dark:from-blue-800 dark:via-amber-700 dark:to-rose-900', children: _jsx("h1", { className: 'text-3xl', children: title || t('emailAccounts') }) }), _jsxs("div", { className: 'flex flex-col gap-3 p-4', children: [_jsx(CreateEmailForm, { onSubmit: createEmailMutation.mutateAsync, isSubmitting: !!createEmailMutation.isPending }), isLoading && _jsx("div", { className: 'text-muted-foreground', children: "Loading emails\u2026" }), isError && !isLoading && (_jsx("div", { className: 'border-destructive/50 bg-destructive/10 text-destructive rounded border p-3 text-sm', children: error instanceof Error ? error.message : 'Unable to load emails' })), data?.emails?.length ? (_jsx("div", { className: 'grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3', children: data.emails.map((email) => (_jsx(EmailCard, { email: email, onDelete: () => deleteMutation.mutateAsync(email.user), onQuotaChange: (quota) => quotaMutation.mutateAsync({ email: email.user, quota }), onPasswordChange: (password, confirm) => passwordMutation.mutateAsync({
|
|
22
|
+
email: email.user,
|
|
23
|
+
password,
|
|
24
|
+
passwordConfirm: confirm,
|
|
25
|
+
}) }, email.user))) })) : null] })] }));
|
|
22
26
|
};
|
|
23
27
|
const CreateEmailForm = ({ onSubmit, isSubmitting, }) => {
|
|
24
28
|
const [email, setEmail] = useState('');
|
|
25
29
|
const [password, setPassword] = useState('');
|
|
26
30
|
const [quota, setQuota] = useState('1024');
|
|
27
31
|
const t = useI18n();
|
|
28
|
-
return (_jsxs("form", { className: 'rounded-lg border
|
|
32
|
+
return (_jsxs("form", { className: 'bg-card text-card-foreground rounded-lg border p-4 shadow-sm', onSubmit: async (e) => {
|
|
29
33
|
e.preventDefault();
|
|
30
34
|
await onSubmit({ email, password, quota });
|
|
31
35
|
setEmail('');
|
|
32
36
|
setPassword('');
|
|
33
|
-
}, children: [_jsx("div", { className: 'text-lg font-semibold', children: t('createNewEmailAccount') }), _jsxs("div", { className: 'mt-3 grid grid-cols-1 gap-3 md:grid-cols-3', children: [_jsx("input", { className: 'rounded border px-3 py-2 text-sm', value: email, onChange: (e) => setEmail(e.target.value), placeholder: t('email'), required: true }), _jsx("input", { className: 'rounded border px-3 py-2 text-sm', type: 'password', value: password, onChange: (e) => setPassword(e.target.value), placeholder: t('password'), required: true }), _jsx("input", { className: 'rounded border px-3 py-2 text-sm', value: quota, onChange: (e) => setQuota(e.target.value), placeholder: t('quota'), required: true })] }), _jsx("button", { type: 'submit', disabled: isSubmitting, className: 'mt-3 inline-flex items-center justify-center rounded
|
|
37
|
+
}, children: [_jsx("div", { className: 'text-lg font-semibold', children: t('createNewEmailAccount') }), _jsxs("div", { className: 'mt-3 grid grid-cols-1 gap-3 md:grid-cols-3', children: [_jsx("input", { className: 'rounded border px-3 py-2 text-sm', value: email, onChange: (e) => setEmail(e.target.value), placeholder: t('email'), required: true }), _jsx("input", { className: 'rounded border px-3 py-2 text-sm', type: 'password', value: password, onChange: (e) => setPassword(e.target.value), placeholder: t('password'), required: true }), _jsx("input", { className: 'rounded border px-3 py-2 text-sm', value: quota, onChange: (e) => setQuota(e.target.value), placeholder: t('quota'), required: true })] }), _jsx("button", { type: 'submit', disabled: isSubmitting, className: 'bg-primary text-primary-foreground mt-3 inline-flex items-center justify-center rounded px-4 py-2 text-sm font-semibold shadow-sm hover:opacity-90 disabled:opacity-50', children: isSubmitting ? t('loading') + '…' : t('create') })] }));
|
|
34
38
|
};
|
|
35
39
|
const EmailCard = ({ email, onDelete, onQuotaChange, onPasswordChange, }) => {
|
|
36
40
|
const [quota, setQuota] = useState(email.diskquota);
|
|
37
41
|
const [password, setPassword] = useState('');
|
|
38
42
|
const [confirm, setConfirm] = useState('');
|
|
39
43
|
const t = useI18n();
|
|
40
|
-
return (_jsxs("div", { className: 'rounded-lg border
|
|
44
|
+
return (_jsxs("div", { className: 'bg-card text-card-foreground rounded-lg border p-4 shadow-sm', children: [_jsxs("div", { className: 'flex items-center justify-between', children: [_jsx("div", { className: 'font-semibold', children: email.user }), _jsx("button", { className: 'text-destructive text-sm hover:underline', type: 'button', onClick: () => onDelete(), children: t('delete') })] }), _jsxs("div", { className: 'text-muted-foreground mt-2 text-sm', children: [_jsxs("div", { children: ["Disk Used: ", email.diskusedpercent, " / ", email.diskquota] }), _jsxs("div", { children: ["Login: ", email.user] })] }), _jsxs("div", { className: 'mt-3 space-y-2 text-sm', children: [_jsxs("label", { className: 'block', children: [_jsx("span", { className: 'text-muted-foreground text-xs', children: "Quota" }), _jsx("input", { className: 'mt-1 w-full rounded border px-3 py-2', value: quota, onChange: (e) => setQuota(e.target.value) }), _jsx("button", { type: 'button', className: 'bg-primary text-primary-foreground mt-1 inline-flex items-center justify-center rounded px-3 py-1 text-xs font-semibold hover:opacity-90', onClick: () => onQuotaChange(quota), children: t('update') })] }), _jsxs("label", { className: 'block', children: [_jsx("span", { className: 'text-muted-foreground text-xs', children: "Password" }), _jsx("input", { className: 'mt-1 w-full rounded border px-3 py-2', type: 'password', value: password, onChange: (e) => setPassword(e.target.value) })] }), _jsxs("label", { className: 'block', children: [_jsx("span", { className: 'text-muted-foreground text-xs', children: "Confirm" }), _jsx("input", { className: 'mt-1 w-full rounded border px-3 py-2', type: 'password', value: confirm, onChange: (e) => setConfirm(e.target.value) })] }), _jsx("button", { type: 'button', className: 'bg-primary text-primary-foreground inline-flex items-center justify-center rounded px-3 py-1 text-xs font-semibold hover:opacity-90', onClick: () => onPasswordChange(password, confirm), children: t('changePassword') })] })] }));
|
|
41
45
|
};
|
|
42
46
|
export default CpanelEmailsPage;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,82 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const cpanelEmailsPlugin: {
|
|
2
|
+
readonly package: "@nextjscms/plugin-cpanel-emails";
|
|
3
|
+
readonly title: "cPanel Emails";
|
|
4
|
+
readonly routes: readonly [{
|
|
5
|
+
readonly path: "/cpanel-emails";
|
|
6
|
+
readonly title: "cPanel Emails";
|
|
7
|
+
readonly icon: "mail";
|
|
8
|
+
readonly prefetch: "cpanelEmails.getEmails";
|
|
9
|
+
}];
|
|
10
|
+
};
|
|
11
|
+
export declare function createPlugin(): Promise<{
|
|
12
|
+
router: import("@trpc/server").TRPCBuiltRouter<{
|
|
13
|
+
ctx: {
|
|
14
|
+
headers: Headers;
|
|
15
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("nextjs-cms/db/schema")> & {
|
|
16
|
+
$client: import("mysql2/promise").Pool;
|
|
17
|
+
};
|
|
18
|
+
session: import("nextjs-cms").Session | null;
|
|
19
|
+
};
|
|
20
|
+
meta: object;
|
|
21
|
+
errorShape: {
|
|
22
|
+
data: {
|
|
23
|
+
zodError: import("zod").ZodFlattenedError<unknown, string> | null;
|
|
24
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
25
|
+
httpStatus: number;
|
|
26
|
+
path?: string;
|
|
27
|
+
stack?: string;
|
|
28
|
+
};
|
|
29
|
+
message: string;
|
|
30
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
31
|
+
};
|
|
32
|
+
transformer: true;
|
|
33
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
34
|
+
getEmails: import("@trpc/server").TRPCQueryProcedure<{
|
|
35
|
+
input: void;
|
|
36
|
+
output: {
|
|
37
|
+
emails: any;
|
|
38
|
+
};
|
|
39
|
+
meta: object;
|
|
40
|
+
}>;
|
|
41
|
+
createEmail: import("@trpc/server").TRPCMutationProcedure<{
|
|
42
|
+
input: {
|
|
43
|
+
email: string;
|
|
44
|
+
password: string;
|
|
45
|
+
quota: string;
|
|
46
|
+
};
|
|
47
|
+
output: any;
|
|
48
|
+
meta: object;
|
|
49
|
+
}>;
|
|
50
|
+
quotaChange: import("@trpc/server").TRPCMutationProcedure<{
|
|
51
|
+
input: {
|
|
52
|
+
email: string;
|
|
53
|
+
quota: string;
|
|
54
|
+
};
|
|
55
|
+
output: any;
|
|
56
|
+
meta: object;
|
|
57
|
+
}>;
|
|
58
|
+
passwordChange: import("@trpc/server").TRPCMutationProcedure<{
|
|
59
|
+
input: {
|
|
60
|
+
email: string;
|
|
61
|
+
password: string;
|
|
62
|
+
passwordConfirm: string;
|
|
63
|
+
};
|
|
64
|
+
output: any;
|
|
65
|
+
meta: object;
|
|
66
|
+
}>;
|
|
67
|
+
deleteEmail: import("@trpc/server").TRPCMutationProcedure<{
|
|
68
|
+
input: string;
|
|
69
|
+
output: any;
|
|
70
|
+
meta: object;
|
|
71
|
+
}>;
|
|
72
|
+
}>>;
|
|
73
|
+
package: "@nextjscms/plugin-cpanel-emails";
|
|
74
|
+
title: "cPanel Emails";
|
|
75
|
+
routes: readonly [{
|
|
76
|
+
readonly path: "/cpanel-emails";
|
|
77
|
+
readonly title: "cPanel Emails";
|
|
78
|
+
readonly icon: "mail";
|
|
79
|
+
readonly prefetch: "cpanelEmails.getEmails";
|
|
80
|
+
}];
|
|
81
|
+
}>;
|
|
2
82
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB;;;;;;;;;CAW7B,CAAA;AAEF,wBAAsB,YAAY;;;;;;;;;;;;;;;oBAQijD,CAAC;qBAA2B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAD/mD"}
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { definePlugin } from 'nextjs-cms/plugins/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { definePlugin } from 'nextjs-cms/plugins/define';
|
|
2
|
+
export const cpanelEmailsPlugin = definePlugin({
|
|
3
|
+
package: '@nextjscms/plugin-cpanel-emails',
|
|
4
|
+
title: 'cPanel Emails',
|
|
5
|
+
routes: [
|
|
6
|
+
{
|
|
7
|
+
path: '/cpanel-emails',
|
|
8
|
+
title: 'cPanel Emails',
|
|
9
|
+
icon: 'mail',
|
|
10
|
+
prefetch: 'cpanelEmails.getEmails',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
});
|
|
14
|
+
export async function createPlugin() {
|
|
15
|
+
const { cpanelEmailsRouter } = await import('./router.js');
|
|
16
|
+
return {
|
|
17
|
+
...cpanelEmailsPlugin,
|
|
8
18
|
router: cpanelEmailsRouter,
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
path: '/cpanel-emails',
|
|
12
|
-
title: 'cPanel Emails',
|
|
13
|
-
icon: 'mail',
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
});
|
|
19
|
+
};
|
|
17
20
|
}
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAQxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;gBAgDf,CAAb;iBAA2B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0H7B,CAAA"}
|
package/dist/router.js
CHANGED
|
@@ -2,9 +2,11 @@ import { TRPCError } from '@trpc/server';
|
|
|
2
2
|
import * as z from 'zod';
|
|
3
3
|
import getString from 'nextjs-cms/translations';
|
|
4
4
|
import { CpanelAPI } from 'nextjs-cms/utils';
|
|
5
|
-
import { pluginProcedure, router } from 'nextjs-cms/api/
|
|
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
|
export const cpanelEmailsRouter = router({
|
|
7
|
-
getEmails: pluginProcedure(
|
|
9
|
+
getEmails: pluginProcedure(PLUGIN_NAME).query(async ({ ctx }) => {
|
|
8
10
|
if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
|
|
9
11
|
throw new TRPCError({
|
|
10
12
|
code: 'BAD_REQUEST',
|
|
@@ -24,7 +26,7 @@ export const cpanelEmailsRouter = router({
|
|
|
24
26
|
emails: data.data,
|
|
25
27
|
};
|
|
26
28
|
}),
|
|
27
|
-
createEmail: pluginProcedure(
|
|
29
|
+
createEmail: pluginProcedure(PLUGIN_NAME, 'C')
|
|
28
30
|
.input(z.object({
|
|
29
31
|
email: z.string(),
|
|
30
32
|
password: z.string(),
|
|
@@ -52,7 +54,7 @@ export const cpanelEmailsRouter = router({
|
|
|
52
54
|
}
|
|
53
55
|
return data;
|
|
54
56
|
}),
|
|
55
|
-
quotaChange: pluginProcedure(
|
|
57
|
+
quotaChange: pluginProcedure(PLUGIN_NAME, 'U')
|
|
56
58
|
.input(z.object({
|
|
57
59
|
email: z.string(),
|
|
58
60
|
quota: z.string(),
|
|
@@ -78,7 +80,7 @@ export const cpanelEmailsRouter = router({
|
|
|
78
80
|
}
|
|
79
81
|
return data;
|
|
80
82
|
}),
|
|
81
|
-
passwordChange: pluginProcedure(
|
|
83
|
+
passwordChange: pluginProcedure(PLUGIN_NAME, 'U')
|
|
82
84
|
.input(z.object({
|
|
83
85
|
email: z.string(),
|
|
84
86
|
password: z.string(),
|
|
@@ -111,7 +113,7 @@ export const cpanelEmailsRouter = router({
|
|
|
111
113
|
}
|
|
112
114
|
return data;
|
|
113
115
|
}),
|
|
114
|
-
deleteEmail: pluginProcedure(
|
|
116
|
+
deleteEmail: pluginProcedure(PLUGIN_NAME, 'D')
|
|
115
117
|
.input(z.string())
|
|
116
118
|
.mutation(async ({ input, ctx }) => {
|
|
117
119
|
if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.tsx"],"names":[],"mappings":"AAMA,wBAA8B,kBAAkB,qDAW/C"}
|
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 { CpanelEmailsPage } from './client/EmailsPage.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 CpanelEmailsServer() {
|
|
9
|
-
const helpers = api;
|
|
10
|
-
const prefetch = helpers.cpanelEmails?.getEmails?.prefetch;
|
|
11
|
-
if (!prefetch) {
|
|
12
|
-
throw new Error('[cpanel-emails] Missing cpanelEmails.getEmails 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-emails'),
|
|
18
10
|
auth(),
|
|
@@ -21,5 +13,5 @@ export default async function CpanelEmailsServer() {
|
|
|
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
|
|
16
|
+
return _jsx(CpanelEmailsPage, { title: resolvedTitle });
|
|
25
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextjscms/plugin-cpanel-emails",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": "19.2.3",
|
|
28
28
|
"react-dom": "19.2.3",
|
|
29
|
-
"nextjs-cms": "0.9.
|
|
29
|
+
"nextjs-cms": "0.9.23"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/react": "^19.2.7",
|