nextjs-cms 0.9.36 → 0.9.37
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/api/actions/pages.d.ts +3 -3
- package/dist/api/trpc/root.d.ts +3 -3
- package/dist/api/trpc/routers/navigation.d.ts +3 -3
- package/dist/api/trpc/server.d.ts +9 -9
- package/dist/cli/lib/update-sections.d.ts.map +1 -1
- package/dist/cli/lib/update-sections.js +43 -10
- package/dist/core/config/config-loader.d.ts +2 -2
- package/dist/core/fields/date-range.d.ts +4 -4
- package/dist/core/fields/slug.d.ts +55 -3
- package/dist/core/fields/slug.d.ts.map +1 -1
- package/dist/core/fields/slug.js +56 -2
- package/dist/core/sections/category.d.ts +4 -4
- package/dist/core/sections/hasItems.d.ts +4 -4
- package/dist/core/sections/section.d.ts +3 -3
- package/dist/core/sections/simple.d.ts +4 -4
- package/dist/translations/base/en.d.ts +3 -0
- package/dist/translations/base/en.d.ts.map +1 -1
- package/dist/translations/base/en.js +3 -0
- package/dist/translations/client.d.ts +40 -4
- package/dist/translations/client.d.ts.map +1 -1
- package/dist/translations/server.d.ts +40 -4
- package/dist/translations/server.d.ts.map +1 -1
- package/package.json +6 -3
- package/dist/api/axios/axiosInstance.d.ts +0 -2
- package/dist/api/axios/axiosInstance.d.ts.map +0 -1
- package/dist/api/axios/axiosInstance.js +0 -8
- package/dist/api/client.d.ts +0 -30
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.js +0 -82
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -0
- package/dist/api/lib/serverActions.d.ts +0 -338
- package/dist/api/lib/serverActions.d.ts.map +0 -1
- package/dist/api/lib/serverActions.js +0 -1517
- package/dist/api/root.d.ts +0 -19
- package/dist/api/root.d.ts.map +0 -1
- package/dist/api/root.js +0 -50
- package/dist/api/routers/accountSettings.d.ts +0 -66
- package/dist/api/routers/accountSettings.d.ts.map +0 -1
- package/dist/api/routers/accountSettings.js +0 -202
- package/dist/api/routers/admins.d.ts +0 -112
- package/dist/api/routers/admins.d.ts.map +0 -1
- package/dist/api/routers/admins.js +0 -323
- package/dist/api/routers/auth.d.ts +0 -54
- package/dist/api/routers/auth.d.ts.map +0 -1
- package/dist/api/routers/auth.js +0 -50
- package/dist/api/routers/categorySection.d.ts +0 -105
- package/dist/api/routers/categorySection.d.ts.map +0 -1
- package/dist/api/routers/categorySection.js +0 -49
- package/dist/api/routers/config.d.ts +0 -48
- package/dist/api/routers/config.d.ts.map +0 -1
- package/dist/api/routers/config.js +0 -18
- package/dist/api/routers/cpanel.d.ts +0 -82
- package/dist/api/routers/cpanel.d.ts.map +0 -1
- package/dist/api/routers/cpanel.js +0 -216
- package/dist/api/routers/fields.d.ts +0 -35
- package/dist/api/routers/fields.d.ts.map +0 -1
- package/dist/api/routers/fields.js +0 -81
- package/dist/api/routers/files.d.ts +0 -34
- package/dist/api/routers/files.d.ts.map +0 -1
- package/dist/api/routers/files.js +0 -14
- package/dist/api/routers/gallery.d.ts +0 -35
- package/dist/api/routers/gallery.d.ts.map +0 -1
- package/dist/api/routers/gallery.js +0 -92
- package/dist/api/routers/hasItemsSection.d.ts +0 -194
- package/dist/api/routers/hasItemsSection.d.ts.map +0 -1
- package/dist/api/routers/hasItemsSection.js +0 -86
- package/dist/api/routers/logs.d.ts +0 -59
- package/dist/api/routers/logs.d.ts.map +0 -1
- package/dist/api/routers/logs.js +0 -76
- package/dist/api/routers/navigation.d.ts +0 -50
- package/dist/api/routers/navigation.d.ts.map +0 -1
- package/dist/api/routers/navigation.js +0 -11
- package/dist/api/routers/simpleSection.d.ts +0 -93
- package/dist/api/routers/simpleSection.d.ts.map +0 -1
- package/dist/api/routers/simpleSection.js +0 -54
- package/dist/api/server.d.ts +0 -2748
- package/dist/api/server.d.ts.map +0 -1
- package/dist/api/server.js +0 -100
- package/dist/api/trpc/error-logging.d.ts +0 -14
- package/dist/api/trpc/error-logging.d.ts.map +0 -1
- package/dist/api/trpc/error-logging.js +0 -75
- package/dist/api/trpc.d.ts +0 -111
- package/dist/api/trpc.d.ts.map +0 -1
- package/dist/api/trpc.js +0 -99
- package/dist/api/utils/async-caller-proxy.d.ts +0 -2
- package/dist/api/utils/async-caller-proxy.d.ts.map +0 -1
- package/dist/api/utils/async-caller-proxy.js +0 -36
- package/dist/api/utils/lazy-caller-proxy.d.ts +0 -2
- package/dist/api/utils/lazy-caller-proxy.d.ts.map +0 -1
- package/dist/api/utils/lazy-caller-proxy.js +0 -36
- package/dist/api/utils/router-types.d.ts +0 -7
- package/dist/api/utils/router-types.d.ts.map +0 -1
- package/dist/api/utils/router-types.js +0 -0
- package/dist/auth/axios/axiosInstance.d.ts +0 -2
- package/dist/auth/axios/axiosInstance.d.ts.map +0 -1
- package/dist/auth/axios/axiosInstance.js +0 -8
- package/dist/auth/hooks/useAxiosPrivate.d.ts +0 -5
- package/dist/auth/hooks/useAxiosPrivate.d.ts.map +0 -1
- package/dist/auth/hooks/useAxiosPrivate.js +0 -74
- package/dist/auth/trpc.d.ts +0 -6
- package/dist/auth/trpc.d.ts.map +0 -1
- package/dist/auth/trpc.js +0 -81
- package/dist/plugins/manifest.d.ts +0 -28
- package/dist/plugins/manifest.d.ts.map +0 -1
- package/dist/plugins/manifest.js +0 -83
- package/dist/plugins/registry.d.ts +0 -22
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/plugins/registry.js +0 -25
- package/dist/utils/log.d.ts +0 -18
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js +0 -28
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
export declare const cpanelRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
3
|
-
ctx: {
|
|
4
|
-
headers: Headers;
|
|
5
|
-
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../../db/schema.js")> & {
|
|
6
|
-
$client: import("mysql2/promise").Pool;
|
|
7
|
-
};
|
|
8
|
-
session: import("../../index.js").Session | null;
|
|
9
|
-
};
|
|
10
|
-
meta: object;
|
|
11
|
-
errorShape: {
|
|
12
|
-
data: {
|
|
13
|
-
zodError: z.core.$ZodFlattenedError<unknown, string> | null;
|
|
14
|
-
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
15
|
-
httpStatus: number;
|
|
16
|
-
path?: string;
|
|
17
|
-
stack?: string;
|
|
18
|
-
};
|
|
19
|
-
message: string;
|
|
20
|
-
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
21
|
-
};
|
|
22
|
-
transformer: true;
|
|
23
|
-
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
24
|
-
getData: import("@trpc/server").TRPCQueryProcedure<{
|
|
25
|
-
input: void;
|
|
26
|
-
output: {
|
|
27
|
-
dbsLimit: number;
|
|
28
|
-
dbsCount: number;
|
|
29
|
-
bandwidthUsage: number;
|
|
30
|
-
bandwidthLimit: number;
|
|
31
|
-
diskSpaceUsage: number;
|
|
32
|
-
diskSpaceLimit: number;
|
|
33
|
-
emailsUsage: number;
|
|
34
|
-
emailsLimit: number;
|
|
35
|
-
dbInfo: any;
|
|
36
|
-
dbsList: any;
|
|
37
|
-
phpVersion: any;
|
|
38
|
-
passengerAppList: never[];
|
|
39
|
-
documentRoot: any;
|
|
40
|
-
};
|
|
41
|
-
meta: object;
|
|
42
|
-
}>;
|
|
43
|
-
getEmails: import("@trpc/server").TRPCQueryProcedure<{
|
|
44
|
-
input: void;
|
|
45
|
-
output: {
|
|
46
|
-
emails: any;
|
|
47
|
-
};
|
|
48
|
-
meta: object;
|
|
49
|
-
}>;
|
|
50
|
-
createEmail: import("@trpc/server").TRPCMutationProcedure<{
|
|
51
|
-
input: {
|
|
52
|
-
email: string;
|
|
53
|
-
password: string;
|
|
54
|
-
quota: string;
|
|
55
|
-
};
|
|
56
|
-
output: any;
|
|
57
|
-
meta: object;
|
|
58
|
-
}>;
|
|
59
|
-
quotaChange: import("@trpc/server").TRPCMutationProcedure<{
|
|
60
|
-
input: {
|
|
61
|
-
email: string;
|
|
62
|
-
quota: string;
|
|
63
|
-
};
|
|
64
|
-
output: any;
|
|
65
|
-
meta: object;
|
|
66
|
-
}>;
|
|
67
|
-
passwordChange: import("@trpc/server").TRPCMutationProcedure<{
|
|
68
|
-
input: {
|
|
69
|
-
email: string;
|
|
70
|
-
password: string;
|
|
71
|
-
passwordConfirm: string;
|
|
72
|
-
};
|
|
73
|
-
output: any;
|
|
74
|
-
meta: object;
|
|
75
|
-
}>;
|
|
76
|
-
deleteEmail: import("@trpc/server").TRPCMutationProcedure<{
|
|
77
|
-
input: string;
|
|
78
|
-
output: any;
|
|
79
|
-
meta: object;
|
|
80
|
-
}>;
|
|
81
|
-
}>>;
|
|
82
|
-
//# sourceMappingURL=cpanel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cpanel.d.ts","sourceRoot":"","sources":["../../../src/api/routers/cpanel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0QvB,CAAA"}
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { privateProcedure, router } from '../trpc.js';
|
|
2
|
-
import { CpanelAPI } from '../../utils/index.js';
|
|
3
|
-
import * as z from 'zod';
|
|
4
|
-
import { TRPCError } from '@trpc/server';
|
|
5
|
-
import getString from '../../translations/index.js';
|
|
6
|
-
// import '@/envConfig'
|
|
7
|
-
export const cpanelRouter = router({
|
|
8
|
-
getData: privateProcedure.query(async ({ ctx, input }) => {
|
|
9
|
-
if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
|
|
10
|
-
throw new TRPCError({
|
|
11
|
-
code: 'BAD_REQUEST',
|
|
12
|
-
message: getString('cpanelCredentialsNotSet', ctx.session.user.language),
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
|
|
16
|
-
const data = await Promise.all([
|
|
17
|
-
cPanel.callApi('DomainInfo', 'single_domain_data', {
|
|
18
|
-
domain: process.env.CPANEL_DOMAIN,
|
|
19
|
-
}),
|
|
20
|
-
cPanel.callApi('ResourceUsage', 'get_usages'),
|
|
21
|
-
cPanel.callApi('Mysql', 'get_server_information'),
|
|
22
|
-
cPanel.callApi('Mysql', 'list_databases'),
|
|
23
|
-
// cPanel.callApi('PassengerApps', 'list_applications'),
|
|
24
|
-
]);
|
|
25
|
-
// console.log(data)
|
|
26
|
-
if (cPanel.isError) {
|
|
27
|
-
throw new TRPCError({
|
|
28
|
-
code: 'BAD_REQUEST',
|
|
29
|
-
message: cPanel.getError(),
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
const dbInfo = data[2];
|
|
33
|
-
const dbsList = data[3];
|
|
34
|
-
// const passengerAppList = data[4]
|
|
35
|
-
let bandwidthLimit = 0, bandwidthUsage = 0;
|
|
36
|
-
let diskSpaceLimit = 0, usedDiskSpace = 0;
|
|
37
|
-
let emailsLimit = 0, emailsCount = 0;
|
|
38
|
-
let dbsLimit = 0, dbsCount = 0;
|
|
39
|
-
const domainInfoData = data[0].data;
|
|
40
|
-
const cpanelUsagesArray = data[1].data;
|
|
41
|
-
cpanelUsagesArray.forEach((singleItemUsage) => {
|
|
42
|
-
switch (singleItemUsage.id) {
|
|
43
|
-
case 'bandwidth':
|
|
44
|
-
bandwidthLimit = singleItemUsage.maximum || 1000000000000;
|
|
45
|
-
bandwidthUsage = singleItemUsage.usage;
|
|
46
|
-
break;
|
|
47
|
-
case 'disk_usage':
|
|
48
|
-
diskSpaceLimit = singleItemUsage.maximum || 1000000000000;
|
|
49
|
-
usedDiskSpace = singleItemUsage.usage;
|
|
50
|
-
break;
|
|
51
|
-
case 'email_accounts':
|
|
52
|
-
emailsLimit = singleItemUsage.maximum || 1000000000000;
|
|
53
|
-
emailsCount = singleItemUsage.usage;
|
|
54
|
-
break;
|
|
55
|
-
case 'mysql_databases':
|
|
56
|
-
dbsLimit = singleItemUsage.maximum || 1000000000000;
|
|
57
|
-
dbsCount = singleItemUsage.usage;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
/*data[4].data = Object.keys(data[4].data).map((key) => {
|
|
62
|
-
const app = data[4].data[key]
|
|
63
|
-
return {
|
|
64
|
-
name: app.name,
|
|
65
|
-
path: app.path,
|
|
66
|
-
domain: app.domain,
|
|
67
|
-
enabled: app.enabled,
|
|
68
|
-
url: app.base_uri,
|
|
69
|
-
nodejs: app.nodejs,
|
|
70
|
-
deploymentMode: app.deployment_mode,
|
|
71
|
-
}
|
|
72
|
-
})*/
|
|
73
|
-
return {
|
|
74
|
-
dbsLimit,
|
|
75
|
-
dbsCount,
|
|
76
|
-
bandwidthUsage,
|
|
77
|
-
bandwidthLimit,
|
|
78
|
-
diskSpaceUsage: usedDiskSpace,
|
|
79
|
-
diskSpaceLimit,
|
|
80
|
-
emailsUsage: emailsCount,
|
|
81
|
-
emailsLimit,
|
|
82
|
-
dbInfo: dbInfo.data,
|
|
83
|
-
dbsList: dbsList.data,
|
|
84
|
-
phpVersion: domainInfoData?.phpversion,
|
|
85
|
-
passengerAppList: [],
|
|
86
|
-
documentRoot: domainInfoData?.documentroot,
|
|
87
|
-
};
|
|
88
|
-
}),
|
|
89
|
-
getEmails: privateProcedure.query(async ({ ctx, input }) => {
|
|
90
|
-
if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
|
|
91
|
-
throw new TRPCError({
|
|
92
|
-
code: 'BAD_REQUEST',
|
|
93
|
-
message: getString('cpanelCredentialsNotSet', ctx.session.user.language),
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
|
|
97
|
-
const data = await cPanel.callApi('Email', 'list_pops_with_disk', {
|
|
98
|
-
domain: process.env.CPANEL_DOMAIN,
|
|
99
|
-
maxaccounts: 100,
|
|
100
|
-
no_validate: 1,
|
|
101
|
-
infinitylang: 1,
|
|
102
|
-
'api.sort': '1',
|
|
103
|
-
'api.sort_column': 'mtime',
|
|
104
|
-
});
|
|
105
|
-
return {
|
|
106
|
-
emails: data.data,
|
|
107
|
-
};
|
|
108
|
-
}),
|
|
109
|
-
createEmail: privateProcedure
|
|
110
|
-
.input(z.object({
|
|
111
|
-
email: z.string(),
|
|
112
|
-
password: z.string(),
|
|
113
|
-
quota: z.string(),
|
|
114
|
-
}))
|
|
115
|
-
.mutation(async ({ ctx, input }) => {
|
|
116
|
-
if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
|
|
117
|
-
throw new TRPCError({
|
|
118
|
-
code: 'BAD_REQUEST',
|
|
119
|
-
message: getString('cpanelCredentialsNotSet', ctx.session.user.language),
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
|
|
123
|
-
const data = await cPanel.callApi('Email', 'add_pop', {
|
|
124
|
-
domain: process.env.CPANEL_DOMAIN,
|
|
125
|
-
email: input.email,
|
|
126
|
-
password: input.password,
|
|
127
|
-
quota: input.quota,
|
|
128
|
-
});
|
|
129
|
-
if (cPanel.isError) {
|
|
130
|
-
throw new TRPCError({
|
|
131
|
-
code: 'BAD_REQUEST',
|
|
132
|
-
message: cPanel.getError(),
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
return data;
|
|
136
|
-
}),
|
|
137
|
-
quotaChange: privateProcedure
|
|
138
|
-
.input(z.object({
|
|
139
|
-
email: z.string(),
|
|
140
|
-
quota: z.string(),
|
|
141
|
-
}))
|
|
142
|
-
.mutation(async ({ ctx, input }) => {
|
|
143
|
-
if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
|
|
144
|
-
throw new TRPCError({
|
|
145
|
-
code: 'BAD_REQUEST',
|
|
146
|
-
message: getString('cpanelCredentialsNotSet', ctx.session.user.language),
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
|
|
150
|
-
const data = await cPanel.callApi('Email', 'edit_pop_quota', {
|
|
151
|
-
domain: process.env.CPANEL_DOMAIN,
|
|
152
|
-
email: input.email,
|
|
153
|
-
quota: input.quota,
|
|
154
|
-
});
|
|
155
|
-
if (cPanel.isError) {
|
|
156
|
-
throw new TRPCError({
|
|
157
|
-
code: 'BAD_REQUEST',
|
|
158
|
-
message: cPanel.getError(),
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
return data;
|
|
162
|
-
}),
|
|
163
|
-
passwordChange: privateProcedure
|
|
164
|
-
.input(z.object({
|
|
165
|
-
email: z.string(),
|
|
166
|
-
password: z.string(),
|
|
167
|
-
passwordConfirm: z.string(),
|
|
168
|
-
}))
|
|
169
|
-
.mutation(async ({ ctx, input }) => {
|
|
170
|
-
if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
|
|
171
|
-
throw new TRPCError({
|
|
172
|
-
code: 'BAD_REQUEST',
|
|
173
|
-
message: getString('cpanelCredentialsNotSet', ctx.session.user.language),
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
if (input.password !== input.passwordConfirm) {
|
|
177
|
-
throw new TRPCError({
|
|
178
|
-
code: 'BAD_REQUEST',
|
|
179
|
-
message: getString('passwordsDoNotMatch', ctx.session.user.language),
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
|
|
183
|
-
const data = await cPanel.callApi('Email', 'passwd_pop', {
|
|
184
|
-
domain: process.env.CPANEL_DOMAIN,
|
|
185
|
-
email: input.email,
|
|
186
|
-
password: input.password,
|
|
187
|
-
});
|
|
188
|
-
if (cPanel.isError) {
|
|
189
|
-
throw new TRPCError({
|
|
190
|
-
code: 'BAD_REQUEST',
|
|
191
|
-
message: cPanel.getError(),
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
return data;
|
|
195
|
-
}),
|
|
196
|
-
deleteEmail: privateProcedure.input(z.string()).mutation(async ({ ctx, input }) => {
|
|
197
|
-
if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
|
|
198
|
-
throw new TRPCError({
|
|
199
|
-
code: 'BAD_REQUEST',
|
|
200
|
-
message: getString('cpanelCredentialsNotSet', ctx.session.user.language),
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
|
|
204
|
-
const data = await cPanel.callApi('Email', 'delete_pop', {
|
|
205
|
-
domain: process.env.CPANEL_DOMAIN,
|
|
206
|
-
email: input,
|
|
207
|
-
});
|
|
208
|
-
if (cPanel.isError) {
|
|
209
|
-
throw new TRPCError({
|
|
210
|
-
code: 'BAD_REQUEST',
|
|
211
|
-
message: cPanel.getError(),
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
return data;
|
|
215
|
-
}),
|
|
216
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
export declare const fieldsRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
3
|
-
ctx: {
|
|
4
|
-
headers: Headers;
|
|
5
|
-
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../../db/schema.js")> & {
|
|
6
|
-
$client: import("mysql2/promise").Pool;
|
|
7
|
-
};
|
|
8
|
-
session: import("../../index.js").Session | null;
|
|
9
|
-
};
|
|
10
|
-
meta: object;
|
|
11
|
-
errorShape: {
|
|
12
|
-
data: {
|
|
13
|
-
zodError: z.core.$ZodFlattenedError<unknown, string> | null;
|
|
14
|
-
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
15
|
-
httpStatus: number;
|
|
16
|
-
path?: string;
|
|
17
|
-
stack?: string;
|
|
18
|
-
};
|
|
19
|
-
message: string;
|
|
20
|
-
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
21
|
-
};
|
|
22
|
-
transformer: true;
|
|
23
|
-
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
24
|
-
tagsAutoComplete: import("@trpc/server").TRPCQueryProcedure<{
|
|
25
|
-
input: {
|
|
26
|
-
sectionName: string;
|
|
27
|
-
fieldName: string;
|
|
28
|
-
query: string;
|
|
29
|
-
locale?: string | undefined;
|
|
30
|
-
};
|
|
31
|
-
output: string[];
|
|
32
|
-
meta: object;
|
|
33
|
-
}>;
|
|
34
|
-
}>>;
|
|
35
|
-
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/api/routers/fields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAWxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFvB,CAAA"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { privateProcedure, router } from '../trpc.js';
|
|
2
|
-
import * as z from 'zod';
|
|
3
|
-
import { SectionFactory } from '../../core/factories/index.js';
|
|
4
|
-
import { TRPCError } from '@trpc/server';
|
|
5
|
-
import getString from '../../translations/index.js';
|
|
6
|
-
import { db } from '../../db/client.js';
|
|
7
|
-
import { sql } from 'drizzle-orm';
|
|
8
|
-
import { is } from '../../core/helpers/index.js';
|
|
9
|
-
import { TagsField } from '../../core/fields/index.js';
|
|
10
|
-
import { getCMSConfig } from '../../core/config/index.js';
|
|
11
|
-
import { resolveLocale } from '../../core/localization/index.js';
|
|
12
|
-
export const fieldsRouter = router({
|
|
13
|
-
tagsAutoComplete: privateProcedure
|
|
14
|
-
.input(z.object({
|
|
15
|
-
sectionName: z.string(),
|
|
16
|
-
fieldName: z.string(),
|
|
17
|
-
query: z.string().max(100),
|
|
18
|
-
locale: z.string().optional(),
|
|
19
|
-
}))
|
|
20
|
-
.query(async ({ ctx, input }) => {
|
|
21
|
-
const sectionConfig = await SectionFactory.getSectionForAdmin({
|
|
22
|
-
name: input.sectionName,
|
|
23
|
-
admin: {
|
|
24
|
-
id: ctx.session.user.id,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
if (!sectionConfig?.name) {
|
|
28
|
-
throw new TRPCError({
|
|
29
|
-
code: 'NOT_FOUND',
|
|
30
|
-
message: getString('sectionNotFound', ctx.session.user.language),
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
const section = sectionConfig.build();
|
|
34
|
-
section.buildFields();
|
|
35
|
-
const field = section.fields.find((f) => f.name === input.fieldName);
|
|
36
|
-
if (!field || !is(field, TagsField) || !field.autoCompletion || !field.destinationDb) {
|
|
37
|
-
throw new TRPCError({
|
|
38
|
-
code: 'BAD_REQUEST',
|
|
39
|
-
message: `Field "${input.fieldName}" does not support auto-completion`,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
const { table, selectIdentifier } = field.destinationDb;
|
|
43
|
-
const searchPattern = `%${input.query}%`;
|
|
44
|
-
const query = sql `SELECT DISTINCT \`${sql.raw(selectIdentifier)}\` as value
|
|
45
|
-
FROM \`${sql.raw(table)}\`
|
|
46
|
-
WHERE \`${sql.raw(selectIdentifier)}\` LIKE ${searchPattern}`;
|
|
47
|
-
if (field.localized) {
|
|
48
|
-
const cmsConfig = await getCMSConfig();
|
|
49
|
-
const localeResult = resolveLocale({
|
|
50
|
-
localization: cmsConfig.localization,
|
|
51
|
-
locale: input.locale,
|
|
52
|
-
});
|
|
53
|
-
if (input.locale !== undefined && !localeResult.localizationEnabled) {
|
|
54
|
-
throw new TRPCError({
|
|
55
|
-
code: 'BAD_REQUEST',
|
|
56
|
-
message: getString('localizationNotEnabledForSection', ctx.session.user.language),
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (input.locale !== undefined && !localeResult.resolvedLocale) {
|
|
60
|
-
throw new TRPCError({
|
|
61
|
-
code: 'BAD_REQUEST',
|
|
62
|
-
message: getString('invalidLocale', ctx.session.user.language, {
|
|
63
|
-
locale: input.locale,
|
|
64
|
-
locales: localeResult.availableLocales.map((l) => l.code).join(', '),
|
|
65
|
-
}),
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
if (localeResult.localizationEnabled) {
|
|
69
|
-
const localeForQuery = localeResult.isDefault
|
|
70
|
-
? cmsConfig.localization.defaultLocale
|
|
71
|
-
: (localeResult.resolvedLocale?.code ?? undefined);
|
|
72
|
-
if (localeForQuery !== undefined) {
|
|
73
|
-
query.append(sql ` AND \`locale\` = ${localeForQuery}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
query.append(sql ` ORDER BY \`${sql.raw(selectIdentifier)}\` ASC LIMIT 20`);
|
|
78
|
-
const [rows] = await db.execute(query);
|
|
79
|
-
return rows.map((row) => row.value);
|
|
80
|
-
}),
|
|
81
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
export declare const filesRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
3
|
-
ctx: {
|
|
4
|
-
headers: Headers;
|
|
5
|
-
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../../db/schema.js")> & {
|
|
6
|
-
$client: import("mysql2/promise").Pool;
|
|
7
|
-
};
|
|
8
|
-
session: import("../../index.js").Session | null;
|
|
9
|
-
};
|
|
10
|
-
meta: object;
|
|
11
|
-
errorShape: {
|
|
12
|
-
data: {
|
|
13
|
-
zodError: z.core.$ZodFlattenedError<unknown, string> | null;
|
|
14
|
-
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
15
|
-
httpStatus: number;
|
|
16
|
-
path?: string;
|
|
17
|
-
stack?: string;
|
|
18
|
-
};
|
|
19
|
-
message: string;
|
|
20
|
-
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
21
|
-
};
|
|
22
|
-
transformer: true;
|
|
23
|
-
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
24
|
-
getPhoto: import("@trpc/server").TRPCQueryProcedure<{
|
|
25
|
-
input: {
|
|
26
|
-
name: string;
|
|
27
|
-
folder: string;
|
|
28
|
-
isThumb?: boolean | undefined;
|
|
29
|
-
};
|
|
30
|
-
output: string;
|
|
31
|
-
meta: object;
|
|
32
|
-
}>;
|
|
33
|
-
}>>;
|
|
34
|
-
//# sourceMappingURL=files.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/api/routers/files.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAGxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAYtB,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { privateProcedure, router } from '../trpc.js';
|
|
2
|
-
import * as z from 'zod';
|
|
3
|
-
import { getPhoto } from '../lib/serverActions.js';
|
|
4
|
-
export const filesRouter = router({
|
|
5
|
-
getPhoto: privateProcedure
|
|
6
|
-
.input(z.object({
|
|
7
|
-
name: z.string(),
|
|
8
|
-
folder: z.string(),
|
|
9
|
-
isThumb: z.boolean().optional(),
|
|
10
|
-
}))
|
|
11
|
-
.query(async ({ ctx, input }) => {
|
|
12
|
-
return await getPhoto(input);
|
|
13
|
-
}),
|
|
14
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
export declare const galleryRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
3
|
-
ctx: {
|
|
4
|
-
headers: Headers;
|
|
5
|
-
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../../db/schema.js")> & {
|
|
6
|
-
$client: import("mysql2/promise").Pool;
|
|
7
|
-
};
|
|
8
|
-
session: import("../../index.js").Session | null;
|
|
9
|
-
};
|
|
10
|
-
meta: object;
|
|
11
|
-
errorShape: {
|
|
12
|
-
data: {
|
|
13
|
-
zodError: z.core.$ZodFlattenedError<unknown, string> | null;
|
|
14
|
-
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
15
|
-
httpStatus: number;
|
|
16
|
-
path?: string;
|
|
17
|
-
stack?: string;
|
|
18
|
-
};
|
|
19
|
-
message: string;
|
|
20
|
-
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
21
|
-
};
|
|
22
|
-
transformer: true;
|
|
23
|
-
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
24
|
-
deletePhoto: import("@trpc/server").TRPCMutationProcedure<{
|
|
25
|
-
input: {
|
|
26
|
-
sectionName: string;
|
|
27
|
-
photoName: string;
|
|
28
|
-
referenceId: string;
|
|
29
|
-
locale?: string | undefined;
|
|
30
|
-
};
|
|
31
|
-
output: boolean;
|
|
32
|
-
meta: object;
|
|
33
|
-
}>;
|
|
34
|
-
}>>;
|
|
35
|
-
//# sourceMappingURL=gallery.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gallery.d.ts","sourceRoot":"","sources":["../../../src/api/routers/gallery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAUxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FxB,CAAA"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { TRPCError } from '@trpc/server';
|
|
4
|
-
import { sql } from 'drizzle-orm';
|
|
5
|
-
import * as z from 'zod';
|
|
6
|
-
import { getCMSConfig } from '../../core/config/index.js';
|
|
7
|
-
import { MysqlTableChecker } from '../../core/db/index.js';
|
|
8
|
-
import { SectionFactory } from '../../core/factories/index.js';
|
|
9
|
-
import { resolveLocale } from '../../core/localization/index.js';
|
|
10
|
-
import { db } from '../../db/client.js';
|
|
11
|
-
import getString from '../../translations/index.js';
|
|
12
|
-
import { privateProcedure, router } from '../trpc.js';
|
|
13
|
-
export const galleryRouter = router({
|
|
14
|
-
deletePhoto: privateProcedure
|
|
15
|
-
.input(z.object({
|
|
16
|
-
sectionName: z.string(),
|
|
17
|
-
photoName: z.string(),
|
|
18
|
-
referenceId: z.string(),
|
|
19
|
-
locale: z.string().optional(),
|
|
20
|
-
}))
|
|
21
|
-
.mutation(async ({ ctx, input }) => {
|
|
22
|
-
const cmsConfig = await getCMSConfig();
|
|
23
|
-
const uploadsFolder = cmsConfig.media.upload.path;
|
|
24
|
-
/**
|
|
25
|
-
* Get the section information
|
|
26
|
-
*/
|
|
27
|
-
const sectionConfig = await SectionFactory.getSectionForAdmin({
|
|
28
|
-
name: input.sectionName,
|
|
29
|
-
admin: {
|
|
30
|
-
id: ctx.session.user.id,
|
|
31
|
-
requiredRole: 'D',
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
if (sectionConfig?.name !== input.sectionName) {
|
|
35
|
-
throw new TRPCError({
|
|
36
|
-
code: 'BAD_REQUEST',
|
|
37
|
-
message: getString('sectionNotFound', ctx.session.user.language),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
const section = sectionConfig?.build();
|
|
41
|
-
/**
|
|
42
|
-
* Delete the photo from the database
|
|
43
|
-
*/
|
|
44
|
-
const gallery = await section.getGallery();
|
|
45
|
-
if (gallery?.db.tableName) {
|
|
46
|
-
const columns = await MysqlTableChecker.getColumns(gallery.db.tableName);
|
|
47
|
-
if (columns.includes(gallery.db.photoNameField) &&
|
|
48
|
-
columns.includes(gallery.db.referenceIdentifierField)) {
|
|
49
|
-
const galleryIsLocalized = gallery.localized === true && cmsConfig.localization?.enabled === true;
|
|
50
|
-
if (galleryIsLocalized) {
|
|
51
|
-
const localeResult = resolveLocale({
|
|
52
|
-
localization: cmsConfig.localization,
|
|
53
|
-
locale: input.locale,
|
|
54
|
-
});
|
|
55
|
-
if (!input.locale || !localeResult.resolvedLocale) {
|
|
56
|
-
throw new TRPCError({
|
|
57
|
-
code: 'BAD_REQUEST',
|
|
58
|
-
message: getString('invalidLocale', ctx.session.user.language, {
|
|
59
|
-
locale: input.locale ?? '',
|
|
60
|
-
locales: localeResult.availableLocales.map((l) => l.code).join(', '),
|
|
61
|
-
}),
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
if (!columns.includes('locale')) {
|
|
65
|
-
throw new TRPCError({
|
|
66
|
-
code: 'BAD_REQUEST',
|
|
67
|
-
message: getString('galleryTableNotSetUp', ctx.session.user.language),
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
await db.execute(sql `DELETE FROM ${sql.raw(gallery.db.tableName)} WHERE ${sql.raw(gallery.db.photoNameField)} = ${input.photoName} AND ${sql.raw(gallery.db.referenceIdentifierField)} = ${input.referenceId} AND \`locale\` = ${localeResult.resolvedLocale.code}`);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
await db.execute(sql `DELETE FROM ${sql.raw(gallery.db.tableName)} WHERE ${sql.raw(gallery.db.photoNameField)} = ${input.photoName} AND ${sql.raw(gallery.db.referenceIdentifierField)} = ${input.referenceId}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Delete the photo from disk
|
|
79
|
-
*/
|
|
80
|
-
try {
|
|
81
|
-
await fs.promises.unlink(path.join(uploadsFolder, '.photos', section.name, input.photoName));
|
|
82
|
-
/**
|
|
83
|
-
* TODO: Thumbs are not being deleted, it throws an error that they are being used by nodejs. Fix this
|
|
84
|
-
*/
|
|
85
|
-
await fs.promises.unlink(path.join(uploadsFolder, '.thumbs', section.name, input.photoName));
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
console.error(error);
|
|
89
|
-
}
|
|
90
|
-
return true;
|
|
91
|
-
}),
|
|
92
|
-
});
|