nextjs-cms 0.5.100 → 0.5.101
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/index.d.ts +42 -4
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/lib/serverActions.d.ts +5 -5
- package/dist/api/lib/serverActions.d.ts.map +1 -1
- package/dist/api/lib/serverActions.js +60 -13
- package/dist/api/root.d.ts +84 -8
- package/dist/api/root.d.ts.map +1 -1
- package/dist/api/root.js +2 -0
- package/dist/api/routers/accountSettings.d.ts +7 -0
- package/dist/api/routers/accountSettings.d.ts.map +1 -1
- package/dist/api/routers/accountSettings.js +32 -0
- package/dist/api/routers/admins.js +2 -2
- package/dist/api/routers/categorySection.d.ts +1 -1
- package/dist/api/routers/config.d.ts +35 -0
- package/dist/api/routers/config.d.ts.map +1 -0
- package/dist/api/routers/config.js +14 -0
- package/dist/api/routers/hasItemsSection.d.ts +2 -2
- package/dist/api/routers/simpleSection.d.ts +1 -1
- package/dist/auth/lib/actions.d.ts +2 -1
- package/dist/auth/lib/actions.d.ts.map +1 -1
- package/dist/auth/lib/actions.js +19 -8
- package/dist/auth/react.d.ts +2 -1
- package/dist/auth/react.d.ts.map +1 -1
- package/dist/auth/react.js +5 -2
- package/dist/core/config/config-loader.d.ts +17 -0
- package/dist/core/config/config-loader.d.ts.map +1 -1
- package/dist/core/config/config-loader.js +54 -0
- package/dist/core/config/index.d.ts +3 -2
- package/dist/core/config/index.d.ts.map +1 -1
- package/dist/core/config/index.js +1 -1
- package/dist/core/factories/FieldFactory.d.ts +10 -3
- package/dist/core/factories/FieldFactory.d.ts.map +1 -1
- package/dist/core/factories/FieldFactory.js +28 -2
- package/dist/core/fields/checkbox.d.ts +3 -3
- package/dist/core/fields/color.d.ts +3 -3
- package/dist/core/fields/date.d.ts +3 -3
- package/dist/core/fields/document.d.ts +3 -3
- package/dist/core/fields/field.d.ts +4 -3
- package/dist/core/fields/field.d.ts.map +1 -1
- package/dist/core/fields/field.js +7 -1
- package/dist/core/fields/map.d.ts +3 -3
- package/dist/core/fields/number.d.ts +5 -5
- package/dist/core/fields/password.d.ts +3 -3
- package/dist/core/fields/photo.d.ts +3 -3
- package/dist/core/fields/richText.d.ts +5 -5
- package/dist/core/fields/select.d.ts +7 -7
- package/dist/core/fields/selectMultiple.d.ts +4 -4
- package/dist/core/fields/tags.d.ts +3 -3
- package/dist/core/fields/text.d.ts +3 -3
- package/dist/core/fields/textArea.d.ts +3 -3
- package/dist/core/fields/video.d.ts +3 -3
- package/dist/core/helpers/i18n.d.ts +2 -0
- package/dist/core/helpers/i18n.d.ts.map +1 -0
- package/dist/core/helpers/i18n.js +3 -0
- package/dist/core/localization.d.ts +40 -0
- package/dist/core/localization.d.ts.map +1 -0
- package/dist/core/localization.js +48 -0
- package/dist/core/sections/category.d.ts +21 -20
- package/dist/core/sections/category.d.ts.map +1 -1
- package/dist/core/sections/category.js +10 -3
- package/dist/core/sections/hasItems.d.ts +39 -38
- package/dist/core/sections/hasItems.d.ts.map +1 -1
- package/dist/core/sections/hasItems.js +10 -3
- package/dist/core/sections/section.d.ts +1 -1
- package/dist/core/sections/simple.d.ts +7 -6
- package/dist/core/sections/simple.d.ts.map +1 -1
- package/dist/core/sections/simple.js +4 -1
- package/dist/translations/client.d.ts +1 -1
- package/dist/translations/client.d.ts.map +1 -1
- package/dist/translations/client.js +1 -1
- package/dist/translations/dict-store.d.ts +12 -0
- package/dist/translations/dict-store.d.ts.map +1 -0
- package/dist/translations/dict-store.js +21 -0
- package/dist/translations/dictionaries/ar.d.ts +2 -0
- package/dist/translations/dictionaries/ar.d.ts.map +1 -1
- package/dist/translations/dictionaries/ar.js +2 -0
- package/dist/translations/dictionaries/en.d.ts +2 -0
- package/dist/translations/dictionaries/en.d.ts.map +1 -1
- package/dist/translations/dictionaries/en.js +2 -0
- package/dist/translations/index.d.ts +10 -1
- package/dist/translations/index.d.ts.map +1 -1
- package/dist/translations/index.js +12 -6
- package/dist/translations/locale-cookie.d.ts +11 -0
- package/dist/translations/locale-cookie.d.ts.map +1 -0
- package/dist/translations/locale-cookie.js +15 -0
- package/dist/translations/locale-utils.d.ts +8 -0
- package/dist/translations/locale-utils.d.ts.map +1 -0
- package/dist/translations/locale-utils.js +11 -0
- package/dist/translations/localization.d.ts +40 -0
- package/dist/translations/localization.d.ts.map +1 -0
- package/dist/translations/localization.js +48 -0
- package/dist/translations/localized-string.d.ts +17 -0
- package/dist/translations/localized-string.d.ts.map +1 -0
- package/dist/translations/localized-string.js +32 -0
- package/dist/translations/types.d.ts +6 -0
- package/dist/translations/types.d.ts.map +1 -0
- package/dist/translations/types.js +0 -0
- package/dist/translations/use-project-translation.d.ts +19 -0
- package/dist/translations/use-project-translation.d.ts.map +1 -0
- package/dist/translations/use-project-translation.js +25 -0
- package/package.json +11 -3
package/dist/api/index.d.ts
CHANGED
|
@@ -192,6 +192,37 @@ declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
192
192
|
meta: object;
|
|
193
193
|
}>;
|
|
194
194
|
}>>;
|
|
195
|
+
config: import("@trpc/server").TRPCBuiltRouter<{
|
|
196
|
+
ctx: {
|
|
197
|
+
headers: Headers;
|
|
198
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
|
|
199
|
+
$client: import("mysql2/promise").Pool;
|
|
200
|
+
};
|
|
201
|
+
session: import("../index.js").Session | null;
|
|
202
|
+
};
|
|
203
|
+
meta: object;
|
|
204
|
+
errorShape: {
|
|
205
|
+
data: {
|
|
206
|
+
zodError: import("zod").ZodFlattenedError<unknown, string> | null;
|
|
207
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
208
|
+
httpStatus: number;
|
|
209
|
+
path?: string;
|
|
210
|
+
stack?: string;
|
|
211
|
+
};
|
|
212
|
+
message: string;
|
|
213
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
214
|
+
};
|
|
215
|
+
transformer: true;
|
|
216
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
217
|
+
getI18n: import("@trpc/server").TRPCQueryProcedure<{
|
|
218
|
+
input: void;
|
|
219
|
+
output: {
|
|
220
|
+
supportedLanguages: readonly string[];
|
|
221
|
+
fallbackLanguage: string;
|
|
222
|
+
};
|
|
223
|
+
meta: object;
|
|
224
|
+
}>;
|
|
225
|
+
}>>;
|
|
195
226
|
hasItemsSections: import("@trpc/server").TRPCBuiltRouter<{
|
|
196
227
|
ctx: {
|
|
197
228
|
headers: Headers;
|
|
@@ -288,7 +319,7 @@ declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
288
319
|
inputs: {
|
|
289
320
|
type: import("../core/types/index.js").FieldType;
|
|
290
321
|
name: string;
|
|
291
|
-
label:
|
|
322
|
+
label: import("../index.js").LocalizedString;
|
|
292
323
|
required: boolean;
|
|
293
324
|
conditionalFields: import("../core/types/index.js").ConditionalField[];
|
|
294
325
|
readonly: boolean;
|
|
@@ -337,7 +368,7 @@ declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
337
368
|
inputs: {
|
|
338
369
|
type: import("../core/types/index.js").FieldType;
|
|
339
370
|
name: string;
|
|
340
|
-
label:
|
|
371
|
+
label: import("../index.js").LocalizedString;
|
|
341
372
|
required: boolean;
|
|
342
373
|
conditionalFields: import("../core/types/index.js").ConditionalField[];
|
|
343
374
|
readonly: boolean;
|
|
@@ -434,7 +465,7 @@ declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
434
465
|
inputs: {
|
|
435
466
|
type: import("../core/types/index.js").FieldType;
|
|
436
467
|
name: string;
|
|
437
|
-
label:
|
|
468
|
+
label: import("../index.js").LocalizedString;
|
|
438
469
|
required: boolean;
|
|
439
470
|
conditionalFields: import("../core/types/index.js").ConditionalField[];
|
|
440
471
|
readonly: boolean;
|
|
@@ -496,7 +527,7 @@ declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
496
527
|
}[] | undefined;
|
|
497
528
|
required: boolean;
|
|
498
529
|
name: string;
|
|
499
|
-
label:
|
|
530
|
+
label: import("../index.js").LocalizedString;
|
|
500
531
|
value: {
|
|
501
532
|
value: string | number;
|
|
502
533
|
label: string;
|
|
@@ -731,6 +762,13 @@ declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
731
762
|
output: boolean;
|
|
732
763
|
meta: object;
|
|
733
764
|
}>;
|
|
765
|
+
updateLocale: import("@trpc/server").TRPCMutationProcedure<{
|
|
766
|
+
input: {
|
|
767
|
+
locale: string;
|
|
768
|
+
};
|
|
769
|
+
output: boolean;
|
|
770
|
+
meta: object;
|
|
771
|
+
}>;
|
|
734
772
|
}>>;
|
|
735
773
|
logs: import("@trpc/server").TRPCBuiltRouter<{
|
|
736
774
|
ctx: {
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC5E,OAAO,EAEH,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,eAAe,EAClB,MAAM,WAAW,CAAA;AAElB;;;;;;GAMG;AACH,QAAA,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,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iB,CAAC,SAAS,CAAC,CAAA;AAEhD;;;;;IAKI;AACJ,KAAK,aAAa,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAA;AAElD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAA;AAC5F,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAA;AACrE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA"}
|
|
@@ -29,7 +29,7 @@ export declare const getVideo: (input: {
|
|
|
29
29
|
fieldName: string;
|
|
30
30
|
}) => Promise<never>;
|
|
31
31
|
export declare const getAdminPrivileges: (adminId: string) => Promise<Set<string>>;
|
|
32
|
-
export declare const getAllPrivileges: () => Promise<{
|
|
32
|
+
export declare const getAllPrivileges: (session: Session) => Promise<{
|
|
33
33
|
title: string;
|
|
34
34
|
order: number;
|
|
35
35
|
sectionType: string;
|
|
@@ -79,7 +79,7 @@ export declare const createSimpleSectionPage: (session: Session, sectionName: st
|
|
|
79
79
|
inputs: {
|
|
80
80
|
type: import("../../core/types/index.js").FieldType;
|
|
81
81
|
name: string;
|
|
82
|
-
label:
|
|
82
|
+
label: import("../../index.js").LocalizedString;
|
|
83
83
|
required: boolean;
|
|
84
84
|
conditionalFields: import("../../core/types/index.js").ConditionalField[];
|
|
85
85
|
readonly: boolean;
|
|
@@ -126,7 +126,7 @@ export declare const createEditPage: (session: Session, sectionName: string, sec
|
|
|
126
126
|
inputs: {
|
|
127
127
|
type: import("../../core/types/index.js").FieldType;
|
|
128
128
|
name: string;
|
|
129
|
-
label:
|
|
129
|
+
label: import("../../index.js").LocalizedString;
|
|
130
130
|
required: boolean;
|
|
131
131
|
conditionalFields: import("../../core/types/index.js").ConditionalField[];
|
|
132
132
|
readonly: boolean;
|
|
@@ -186,7 +186,7 @@ export declare const createNewPage: (session: Session, sectionName: string) => P
|
|
|
186
186
|
inputs: {
|
|
187
187
|
type: import("../../core/types/index.js").FieldType;
|
|
188
188
|
name: string;
|
|
189
|
-
label:
|
|
189
|
+
label: import("../../index.js").LocalizedString;
|
|
190
190
|
required: boolean;
|
|
191
191
|
conditionalFields: import("../../core/types/index.js").ConditionalField[];
|
|
192
192
|
readonly: boolean;
|
|
@@ -245,7 +245,7 @@ export declare const getCategorySection: (session: Session, sectionName: string)
|
|
|
245
245
|
}[] | undefined;
|
|
246
246
|
required: boolean;
|
|
247
247
|
name: string;
|
|
248
|
-
label:
|
|
248
|
+
label: import("../../index.js").LocalizedString;
|
|
249
249
|
value: {
|
|
250
250
|
value: string | number;
|
|
251
251
|
label: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverActions.d.ts","sourceRoot":"","sources":["../../../src/api/lib/serverActions.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAQlD,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"serverActions.d.ts","sourceRoot":"","sources":["../../../src/api/lib/serverActions.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAQlD,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKxE,eAAO,MAAM,eAAe,GAAU,gCAInC;IACC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;CACjB,qBAmBA,CAAA;AACD,eAAO,MAAM,WAAW,GACpB,SAAS,OAAO,EAChB,OAAO;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;;;EA8GlE,C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{ recordLog } from '../../logging/index.js';
|
|
19
19
|
import getString from '../../translations/index.js';
|
|
20
|
+
import { resolveLocalizedString } from '../../translations/localization.js';
|
|
21
|
+
import { resolveLocale } from '../../translations/locale-utils.js';
|
|
20
22
|
export const isAccessAllowed = async ({ sectionName, role, userId, }) => {
|
|
21
23
|
/**
|
|
22
24
|
* Check admin privileges
|
|
@@ -232,14 +234,24 @@ export const getAdminPrivileges = async (adminId) => {
|
|
|
232
234
|
.where(eq(AdminPrivilegesTable.adminId, adminId));
|
|
233
235
|
return new Set(rows.map((row) => row.sectionName));
|
|
234
236
|
};
|
|
235
|
-
export const getAllPrivileges = async () => {
|
|
237
|
+
export const getAllPrivileges = async (session) => {
|
|
236
238
|
const [sections, pluginRoutes] = await Promise.all([SectionFactory.getSections(), getPluginRoutes()]);
|
|
239
|
+
// Get the locale for resolving localized titles
|
|
240
|
+
const cmsConfig = await getCMSConfig();
|
|
241
|
+
const locale = resolveLocale(session.user.locale, cmsConfig.i18n.supportedLanguages, cmsConfig.i18n.fallbackLanguage);
|
|
237
242
|
// First, let's assign the static privileges
|
|
238
243
|
const privilegesList = [];
|
|
239
244
|
// Now, let's add the rest of the privileges to the list
|
|
240
245
|
sections.forEach((section, index) => {
|
|
246
|
+
let title;
|
|
247
|
+
if (typeof section.title === 'string') {
|
|
248
|
+
title = resolveLocalizedString(section.title, locale, cmsConfig.i18n.fallbackLanguage);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
title = resolveLocalizedString(section.title.section, locale, cmsConfig.i18n.fallbackLanguage);
|
|
252
|
+
}
|
|
241
253
|
privilegesList.push({
|
|
242
|
-
title
|
|
254
|
+
title,
|
|
243
255
|
order: section.order || index,
|
|
244
256
|
sectionName: section.name,
|
|
245
257
|
sectionType: section.type,
|
|
@@ -329,14 +341,18 @@ export const createSimpleSectionPage = async (session, sectionName) => {
|
|
|
329
341
|
}*/
|
|
330
342
|
const sectionInfo = fieldsFactory.sectionInfo;
|
|
331
343
|
const gallery = await sectionInfo.getGallery();
|
|
344
|
+
// Get the locale for resolving localized titles
|
|
345
|
+
const cmsConfig = await getCMSConfig();
|
|
346
|
+
const locale = resolveLocale(session.user.locale, cmsConfig.i18n.supportedLanguages, cmsConfig.i18n.fallbackLanguage);
|
|
347
|
+
const resolvedTitle = resolveLocalizedString(sectionInfo.title, locale, cmsConfig.i18n.fallbackLanguage);
|
|
332
348
|
return {
|
|
333
349
|
section: {
|
|
334
350
|
name: sectionInfo.name,
|
|
335
|
-
title:
|
|
351
|
+
title: resolvedTitle,
|
|
336
352
|
gallery: gallery,
|
|
337
353
|
variants: sectionInfo.variants,
|
|
338
354
|
},
|
|
339
|
-
inputGroups: fieldsFactory.getGroupedFields(),
|
|
355
|
+
inputGroups: await fieldsFactory.getGroupedFields(),
|
|
340
356
|
};
|
|
341
357
|
}
|
|
342
358
|
catch (err) {
|
|
@@ -608,14 +624,22 @@ export const createEditPage = async (session, sectionName, sectionItemId) => {
|
|
|
608
624
|
}
|
|
609
625
|
}
|
|
610
626
|
const sectionInfo = fieldsFactory.sectionInfo;
|
|
627
|
+
// Get the locale for resolving localized titles
|
|
628
|
+
const cmsConfig = await getCMSConfig();
|
|
629
|
+
const locale = resolveLocale(session.user.locale, cmsConfig.i18n.supportedLanguages, cmsConfig.i18n.fallbackLanguage);
|
|
630
|
+
const resolvedTitle = {
|
|
631
|
+
section: resolveLocalizedString(sectionInfo.title.section, locale, cmsConfig.i18n.fallbackLanguage),
|
|
632
|
+
singular: resolveLocalizedString(sectionInfo.title.singular, locale, cmsConfig.i18n.fallbackLanguage),
|
|
633
|
+
plural: resolveLocalizedString(sectionInfo.title.plural, locale, cmsConfig.i18n.fallbackLanguage),
|
|
634
|
+
};
|
|
611
635
|
return {
|
|
612
636
|
section: {
|
|
613
637
|
name: sectionInfo.name,
|
|
614
|
-
title:
|
|
638
|
+
title: resolvedTitle,
|
|
615
639
|
gallery: gallery,
|
|
616
640
|
variants: sectionInfo.variants,
|
|
617
641
|
},
|
|
618
|
-
inputGroups: fieldsFactory.getGroupedFields(),
|
|
642
|
+
inputGroups: await fieldsFactory.getGroupedFields(),
|
|
619
643
|
gallery: galleryItems,
|
|
620
644
|
};
|
|
621
645
|
}
|
|
@@ -678,14 +702,22 @@ export const createNewPage = async (session, sectionName) => {
|
|
|
678
702
|
}*/
|
|
679
703
|
const sectionInfo = fieldsFactory.sectionInfo;
|
|
680
704
|
const gallery = await sectionInfo.getGallery();
|
|
705
|
+
// Get the locale for resolving localized titles
|
|
706
|
+
const cmsConfig = await getCMSConfig();
|
|
707
|
+
const locale = resolveLocale(session.user.locale, cmsConfig.i18n.supportedLanguages, cmsConfig.i18n.fallbackLanguage);
|
|
708
|
+
const resolvedTitle = {
|
|
709
|
+
section: resolveLocalizedString(sectionInfo.title.section, locale, cmsConfig.i18n.fallbackLanguage),
|
|
710
|
+
singular: resolveLocalizedString(sectionInfo.title.singular, locale, cmsConfig.i18n.fallbackLanguage),
|
|
711
|
+
plural: resolveLocalizedString(sectionInfo.title.plural, locale, cmsConfig.i18n.fallbackLanguage),
|
|
712
|
+
};
|
|
681
713
|
return {
|
|
682
714
|
section: {
|
|
683
715
|
name: sectionInfo.name,
|
|
684
|
-
title:
|
|
716
|
+
title: resolvedTitle,
|
|
685
717
|
gallery: gallery,
|
|
686
718
|
variants: sectionInfo.variants,
|
|
687
719
|
},
|
|
688
|
-
inputGroups: fieldsFactory.getGroupedFields(),
|
|
720
|
+
inputGroups: await fieldsFactory.getGroupedFields(),
|
|
689
721
|
};
|
|
690
722
|
}
|
|
691
723
|
catch (err) {
|
|
@@ -799,11 +831,19 @@ export const getCategorySection = async (session, sectionName) => {
|
|
|
799
831
|
sectionName: section.name,
|
|
800
832
|
allowRecursiveDelete: section.allowRecursiveDelete,
|
|
801
833
|
};
|
|
834
|
+
// Get the locale for resolving localized titles
|
|
835
|
+
const cmsConfig = await getCMSConfig();
|
|
836
|
+
const locale = resolveLocale(session.user.locale, cmsConfig.i18n.supportedLanguages, cmsConfig.i18n.fallbackLanguage);
|
|
837
|
+
const resolvedTitle = {
|
|
838
|
+
section: resolveLocalizedString(section.title.section, locale, cmsConfig.i18n.fallbackLanguage),
|
|
839
|
+
singular: resolveLocalizedString(section.title.singular, locale, cmsConfig.i18n.fallbackLanguage),
|
|
840
|
+
plural: resolveLocalizedString(section.title.plural, locale, cmsConfig.i18n.fallbackLanguage),
|
|
841
|
+
};
|
|
802
842
|
return {
|
|
803
843
|
section: {
|
|
804
844
|
tableName: tableName,
|
|
805
845
|
sectionName: section.name,
|
|
806
|
-
title:
|
|
846
|
+
title: resolvedTitle,
|
|
807
847
|
},
|
|
808
848
|
data: categorySectionSelect,
|
|
809
849
|
// publisher: privileges.publisher,
|
|
@@ -859,6 +899,10 @@ export const getBrowsePage = async (session, sectionName, page = 1, q) => {
|
|
|
859
899
|
const totalCountResult = await db.execute(totalRowsSql);
|
|
860
900
|
const totalCountRows = totalCountResult[0];
|
|
861
901
|
const rows = sectionItems[0];
|
|
902
|
+
// Get the locale for resolving localized titles
|
|
903
|
+
const cmsConfig = await getCMSConfig();
|
|
904
|
+
const locale = resolveLocale(session.user.locale, cmsConfig.i18n.supportedLanguages, cmsConfig.i18n.fallbackLanguage);
|
|
905
|
+
const resolvedTitle = resolveLocalizedString(section.title.section, locale, cmsConfig.i18n.fallbackLanguage);
|
|
862
906
|
return {
|
|
863
907
|
section: {
|
|
864
908
|
// tableName: tableName,
|
|
@@ -867,7 +911,7 @@ export const getBrowsePage = async (session, sectionName, page = 1, q) => {
|
|
|
867
911
|
// coverPhotoField: section.coverPhotoField?.name,
|
|
868
912
|
hasSearch: sectionSearch,
|
|
869
913
|
name: section.name,
|
|
870
|
-
title:
|
|
914
|
+
title: resolvedTitle,
|
|
871
915
|
},
|
|
872
916
|
items: rows.map((row) => {
|
|
873
917
|
// Custom browse page implementation: if browse.fields is configured,
|
|
@@ -911,24 +955,27 @@ export const getSidebar = async (session) => {
|
|
|
911
955
|
const pluginRoutes = await getPluginRoutes();
|
|
912
956
|
const privilegeSet = await getAdminPrivileges(session.user.id);
|
|
913
957
|
const allowedPluginRoutes = pluginRoutes.filter(({ pluginName }) => privilegeSet.has(pluginName));
|
|
958
|
+
// Get the locale for resolving localized titles
|
|
959
|
+
const cmsConfig = await getCMSConfig();
|
|
960
|
+
const locale = resolveLocale(session.user.locale, cmsConfig.i18n.supportedLanguages, cmsConfig.i18n.fallbackLanguage);
|
|
914
961
|
// Let's loop through the sections and add path, icon and title to each section item
|
|
915
962
|
const simpleSectionItems = simple.map((section) => {
|
|
916
963
|
return {
|
|
917
|
-
title: section.title,
|
|
964
|
+
title: resolveLocalizedString(section.title, locale, cmsConfig.i18n.fallbackLanguage),
|
|
918
965
|
path: `/section/${section.name}`,
|
|
919
966
|
icon: section.icon,
|
|
920
967
|
};
|
|
921
968
|
});
|
|
922
969
|
const hasItemsSectionItems = has_items.map((section) => {
|
|
923
970
|
return {
|
|
924
|
-
title: section.title.section,
|
|
971
|
+
title: resolveLocalizedString(section.title.section, locale, cmsConfig.i18n.fallbackLanguage),
|
|
925
972
|
path: `/${section.name}`,
|
|
926
973
|
icon: section.icon,
|
|
927
974
|
};
|
|
928
975
|
});
|
|
929
976
|
const categorySectionsItems = category.map((section) => {
|
|
930
977
|
return {
|
|
931
|
-
title: section.title.section,
|
|
978
|
+
title: resolveLocalizedString(section.title.section, locale, cmsConfig.i18n.fallbackLanguage),
|
|
932
979
|
path: `/categorized/${section.name}`,
|
|
933
980
|
icon: section.icon,
|
|
934
981
|
};
|
package/dist/api/root.d.ts
CHANGED
|
@@ -183,6 +183,37 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
183
183
|
meta: object;
|
|
184
184
|
}>;
|
|
185
185
|
}>>;
|
|
186
|
+
config: import("@trpc/server").TRPCBuiltRouter<{
|
|
187
|
+
ctx: {
|
|
188
|
+
headers: Headers;
|
|
189
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
|
|
190
|
+
$client: import("mysql2/promise").Pool;
|
|
191
|
+
};
|
|
192
|
+
session: import("../index.js").Session | null;
|
|
193
|
+
};
|
|
194
|
+
meta: object;
|
|
195
|
+
errorShape: {
|
|
196
|
+
data: {
|
|
197
|
+
zodError: z.core.$ZodFlattenedError<unknown, string> | null;
|
|
198
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
199
|
+
httpStatus: number;
|
|
200
|
+
path?: string;
|
|
201
|
+
stack?: string;
|
|
202
|
+
};
|
|
203
|
+
message: string;
|
|
204
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
205
|
+
};
|
|
206
|
+
transformer: true;
|
|
207
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
208
|
+
getI18n: import("@trpc/server").TRPCQueryProcedure<{
|
|
209
|
+
input: void;
|
|
210
|
+
output: {
|
|
211
|
+
supportedLanguages: readonly string[];
|
|
212
|
+
fallbackLanguage: string;
|
|
213
|
+
};
|
|
214
|
+
meta: object;
|
|
215
|
+
}>;
|
|
216
|
+
}>>;
|
|
186
217
|
hasItemsSections: import("@trpc/server").TRPCBuiltRouter<{
|
|
187
218
|
ctx: {
|
|
188
219
|
headers: Headers;
|
|
@@ -279,7 +310,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
279
310
|
inputs: {
|
|
280
311
|
type: import("../core/types/index.js").FieldType;
|
|
281
312
|
name: string;
|
|
282
|
-
label:
|
|
313
|
+
label: import("../index.js").LocalizedString;
|
|
283
314
|
required: boolean;
|
|
284
315
|
conditionalFields: import("../core/types/index.js").ConditionalField[];
|
|
285
316
|
readonly: boolean;
|
|
@@ -328,7 +359,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
328
359
|
inputs: {
|
|
329
360
|
type: import("../core/types/index.js").FieldType;
|
|
330
361
|
name: string;
|
|
331
|
-
label:
|
|
362
|
+
label: import("../index.js").LocalizedString;
|
|
332
363
|
required: boolean;
|
|
333
364
|
conditionalFields: import("../core/types/index.js").ConditionalField[];
|
|
334
365
|
readonly: boolean;
|
|
@@ -425,7 +456,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
425
456
|
inputs: {
|
|
426
457
|
type: import("../core/types/index.js").FieldType;
|
|
427
458
|
name: string;
|
|
428
|
-
label:
|
|
459
|
+
label: import("../index.js").LocalizedString;
|
|
429
460
|
required: boolean;
|
|
430
461
|
conditionalFields: import("../core/types/index.js").ConditionalField[];
|
|
431
462
|
readonly: boolean;
|
|
@@ -487,7 +518,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
487
518
|
}[] | undefined;
|
|
488
519
|
required: boolean;
|
|
489
520
|
name: string;
|
|
490
|
-
label:
|
|
521
|
+
label: import("../index.js").LocalizedString;
|
|
491
522
|
value: {
|
|
492
523
|
value: string | number;
|
|
493
524
|
label: string;
|
|
@@ -722,6 +753,13 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
722
753
|
output: boolean;
|
|
723
754
|
meta: object;
|
|
724
755
|
}>;
|
|
756
|
+
updateLocale: import("@trpc/server").TRPCMutationProcedure<{
|
|
757
|
+
input: {
|
|
758
|
+
locale: string;
|
|
759
|
+
};
|
|
760
|
+
output: boolean;
|
|
761
|
+
meta: object;
|
|
762
|
+
}>;
|
|
725
763
|
}>>;
|
|
726
764
|
logs: import("@trpc/server").TRPCBuiltRouter<{
|
|
727
765
|
ctx: {
|
|
@@ -1018,6 +1056,37 @@ export declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
1018
1056
|
meta: object;
|
|
1019
1057
|
}>;
|
|
1020
1058
|
}>>;
|
|
1059
|
+
config: import("@trpc/server").TRPCBuiltRouter<{
|
|
1060
|
+
ctx: {
|
|
1061
|
+
headers: Headers;
|
|
1062
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
|
|
1063
|
+
$client: import("mysql2/promise").Pool;
|
|
1064
|
+
};
|
|
1065
|
+
session: import("../index.js").Session | null;
|
|
1066
|
+
};
|
|
1067
|
+
meta: object;
|
|
1068
|
+
errorShape: {
|
|
1069
|
+
data: {
|
|
1070
|
+
zodError: z.core.$ZodFlattenedError<unknown, string> | null;
|
|
1071
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
1072
|
+
httpStatus: number;
|
|
1073
|
+
path?: string;
|
|
1074
|
+
stack?: string;
|
|
1075
|
+
};
|
|
1076
|
+
message: string;
|
|
1077
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
1078
|
+
};
|
|
1079
|
+
transformer: true;
|
|
1080
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
1081
|
+
getI18n: import("@trpc/server").TRPCQueryProcedure<{
|
|
1082
|
+
input: void;
|
|
1083
|
+
output: {
|
|
1084
|
+
supportedLanguages: readonly string[];
|
|
1085
|
+
fallbackLanguage: string;
|
|
1086
|
+
};
|
|
1087
|
+
meta: object;
|
|
1088
|
+
}>;
|
|
1089
|
+
}>>;
|
|
1021
1090
|
hasItemsSections: import("@trpc/server").TRPCBuiltRouter<{
|
|
1022
1091
|
ctx: {
|
|
1023
1092
|
headers: Headers;
|
|
@@ -1114,7 +1183,7 @@ export declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
1114
1183
|
inputs: {
|
|
1115
1184
|
type: import("../core/types/index.js").FieldType;
|
|
1116
1185
|
name: string;
|
|
1117
|
-
label:
|
|
1186
|
+
label: import("../index.js").LocalizedString;
|
|
1118
1187
|
required: boolean;
|
|
1119
1188
|
conditionalFields: import("../core/types/index.js").ConditionalField[];
|
|
1120
1189
|
readonly: boolean;
|
|
@@ -1163,7 +1232,7 @@ export declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
1163
1232
|
inputs: {
|
|
1164
1233
|
type: import("../core/types/index.js").FieldType;
|
|
1165
1234
|
name: string;
|
|
1166
|
-
label:
|
|
1235
|
+
label: import("../index.js").LocalizedString;
|
|
1167
1236
|
required: boolean;
|
|
1168
1237
|
conditionalFields: import("../core/types/index.js").ConditionalField[];
|
|
1169
1238
|
readonly: boolean;
|
|
@@ -1260,7 +1329,7 @@ export declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
1260
1329
|
inputs: {
|
|
1261
1330
|
type: import("../core/types/index.js").FieldType;
|
|
1262
1331
|
name: string;
|
|
1263
|
-
label:
|
|
1332
|
+
label: import("../index.js").LocalizedString;
|
|
1264
1333
|
required: boolean;
|
|
1265
1334
|
conditionalFields: import("../core/types/index.js").ConditionalField[];
|
|
1266
1335
|
readonly: boolean;
|
|
@@ -1322,7 +1391,7 @@ export declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
1322
1391
|
}[] | undefined;
|
|
1323
1392
|
required: boolean;
|
|
1324
1393
|
name: string;
|
|
1325
|
-
label:
|
|
1394
|
+
label: import("../index.js").LocalizedString;
|
|
1326
1395
|
value: {
|
|
1327
1396
|
value: string | number;
|
|
1328
1397
|
label: string;
|
|
@@ -1557,6 +1626,13 @@ export declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
1557
1626
|
output: boolean;
|
|
1558
1627
|
meta: object;
|
|
1559
1628
|
}>;
|
|
1629
|
+
updateLocale: import("@trpc/server").TRPCMutationProcedure<{
|
|
1630
|
+
input: {
|
|
1631
|
+
locale: string;
|
|
1632
|
+
};
|
|
1633
|
+
output: boolean;
|
|
1634
|
+
meta: object;
|
|
1635
|
+
}>;
|
|
1560
1636
|
}>>;
|
|
1561
1637
|
logs: import("@trpc/server").TRPCBuiltRouter<{
|
|
1562
1638
|
ctx: {
|
package/dist/api/root.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/api/root.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;
|
|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js
CHANGED
|
@@ -3,6 +3,7 @@ import { adminsRouter } from './routers/admins.js';
|
|
|
3
3
|
import { hasItemsSectionRouter } from './routers/hasItemsSection.js';
|
|
4
4
|
import { filesRouter } from './routers/files.js';
|
|
5
5
|
import { authRouter } from './routers/auth.js';
|
|
6
|
+
import { configRouter } from './routers/config.js';
|
|
6
7
|
import { navRouter } from './routers/navigation.js';
|
|
7
8
|
import { simpleSectionRouter } from './routers/simpleSection.js';
|
|
8
9
|
import { categorySectionRouter } from './routers/categorySection.js';
|
|
@@ -41,6 +42,7 @@ const pluginsRouter = router({
|
|
|
41
42
|
const coreRouters = {
|
|
42
43
|
auth: authRouter,
|
|
43
44
|
admins: adminsRouter,
|
|
45
|
+
config: configRouter,
|
|
44
46
|
hasItemsSections: hasItemsSectionRouter,
|
|
45
47
|
simpleSections: simpleSectionRouter,
|
|
46
48
|
categorySections: categorySectionRouter,
|
|
@@ -55,5 +55,12 @@ export declare const accountSettings: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
55
55
|
output: boolean;
|
|
56
56
|
meta: object;
|
|
57
57
|
}>;
|
|
58
|
+
updateLocale: import("@trpc/server").TRPCMutationProcedure<{
|
|
59
|
+
input: {
|
|
60
|
+
locale: string;
|
|
61
|
+
};
|
|
62
|
+
output: boolean;
|
|
63
|
+
meta: object;
|
|
64
|
+
}>;
|
|
58
65
|
}>>;
|
|
59
66
|
//# sourceMappingURL=accountSettings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountSettings.d.ts","sourceRoot":"","sources":["../../../src/api/routers/accountSettings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"accountSettings.d.ts","sourceRoot":"","sources":["../../../src/api/routers/accountSettings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAOxB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkBxB;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;GAwML,CAAA"}
|
|
@@ -6,6 +6,8 @@ import * as z from 'zod';
|
|
|
6
6
|
import bcrypt from 'bcrypt';
|
|
7
7
|
import { TRPCError } from '@trpc/server';
|
|
8
8
|
import { getRequestMetadataFromHeaders, recordLog } from '../../logging/index.js';
|
|
9
|
+
import { getCMSConfig } from '../../core/config/index.js';
|
|
10
|
+
import getString from '../../translations/index.js';
|
|
9
11
|
export const accountSettings = router({
|
|
10
12
|
get: privateProcedure.query(async ({ ctx }) => {
|
|
11
13
|
const admin = await db
|
|
@@ -167,4 +169,34 @@ export const accountSettings = router({
|
|
|
167
169
|
});
|
|
168
170
|
return true;
|
|
169
171
|
}),
|
|
172
|
+
updateLocale: privateProcedure
|
|
173
|
+
.input(z.object({ locale: z.string() }))
|
|
174
|
+
.mutation(async ({ ctx, input }) => {
|
|
175
|
+
const requestMetadata = getRequestMetadataFromHeaders(ctx.headers);
|
|
176
|
+
const config = await getCMSConfig();
|
|
177
|
+
const supported = new Set(config.i18n.supportedLanguages);
|
|
178
|
+
if (!supported.has(input.locale)) {
|
|
179
|
+
throw new TRPCError({
|
|
180
|
+
code: 'BAD_REQUEST',
|
|
181
|
+
message: getString('localeNotSupported', ctx.session.user.locale),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
await db
|
|
185
|
+
.update(AdminsTable)
|
|
186
|
+
.set({ language: input.locale })
|
|
187
|
+
.where(eq(AdminsTable.id, ctx.session.user.id))
|
|
188
|
+
.execute();
|
|
189
|
+
await recordLog({
|
|
190
|
+
eventType: 'admin.settings.change',
|
|
191
|
+
actorId: ctx.session.user.id,
|
|
192
|
+
actorUsername: ctx.session.user.name ?? null,
|
|
193
|
+
entityType: 'admin',
|
|
194
|
+
entityId: ctx.session.user.id,
|
|
195
|
+
entityLabel: ctx.session.user.name ?? null,
|
|
196
|
+
sectionName: 'settings',
|
|
197
|
+
metadata: { fields: ['locale'], locale: input.locale },
|
|
198
|
+
requestMetadata,
|
|
199
|
+
});
|
|
200
|
+
return true;
|
|
201
|
+
}),
|
|
170
202
|
});
|
|
@@ -25,7 +25,7 @@ export const adminsRouter = router({
|
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
const data = await Promise.all([getAdminsList(), getAllPrivileges()]);
|
|
28
|
+
const data = await Promise.all([getAdminsList(), getAllPrivileges(ctx.session)]);
|
|
29
29
|
const adminList = data[0];
|
|
30
30
|
const privileges = data[1];
|
|
31
31
|
return {
|
|
@@ -60,7 +60,7 @@ export const adminsRouter = router({
|
|
|
60
60
|
})
|
|
61
61
|
.from(AdminPrivilegesTable)
|
|
62
62
|
.where(eq(AdminPrivilegesTable.adminId, opts.input)),
|
|
63
|
-
getAllPrivileges(),
|
|
63
|
+
getAllPrivileges(opts.ctx.session),
|
|
64
64
|
]);
|
|
65
65
|
const adminRows = data[0];
|
|
66
66
|
const adminRoles = data[1];
|
|
@@ -48,7 +48,7 @@ export declare const categorySectionRouter: import("@trpc/server").TRPCBuiltRout
|
|
|
48
48
|
}[] | undefined;
|
|
49
49
|
required: boolean;
|
|
50
50
|
name: string;
|
|
51
|
-
label:
|
|
51
|
+
label: import("../../index.js").LocalizedString;
|
|
52
52
|
value: {
|
|
53
53
|
value: string | number;
|
|
54
54
|
label: string;
|