nextjs-cms 0.0.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +289 -0
- package/dist/api/axios/axiosInstance.d.ts +2 -0
- package/dist/api/axios/axiosInstance.d.ts.map +1 -0
- package/dist/api/axios/axiosInstance.js +8 -0
- package/dist/api/index.d.ts +856 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +12 -0
- package/dist/api/lib/serverActions.d.ts +240 -0
- package/dist/api/lib/serverActions.d.ts.map +1 -0
- package/dist/api/lib/serverActions.js +834 -0
- package/dist/api/root.d.ts +829 -0
- package/dist/api/root.d.ts.map +1 -0
- package/dist/api/root.js +30 -0
- package/dist/api/routers/accountSettings.d.ts +61 -0
- package/dist/api/routers/accountSettings.d.ts.map +1 -0
- package/dist/api/routers/accountSettings.js +108 -0
- package/dist/api/routers/admins.d.ts +106 -0
- package/dist/api/routers/admins.d.ts.map +1 -0
- package/dist/api/routers/admins.js +219 -0
- package/dist/api/routers/auth.d.ts +48 -0
- package/dist/api/routers/auth.d.ts.map +1 -0
- package/dist/api/routers/auth.js +25 -0
- package/dist/api/routers/categorySection.d.ts +104 -0
- package/dist/api/routers/categorySection.d.ts.map +1 -0
- package/dist/api/routers/categorySection.js +38 -0
- package/dist/api/routers/cmsSettings.d.ts +49 -0
- package/dist/api/routers/cmsSettings.d.ts.map +1 -0
- package/dist/api/routers/cmsSettings.js +51 -0
- package/dist/api/routers/cpanel.d.ts +84 -0
- package/dist/api/routers/cpanel.d.ts.map +1 -0
- package/dist/api/routers/cpanel.js +216 -0
- package/dist/api/routers/files.d.ts +48 -0
- package/dist/api/routers/files.d.ts.map +1 -0
- package/dist/api/routers/files.js +23 -0
- package/dist/api/routers/gallery.d.ts +36 -0
- package/dist/api/routers/gallery.d.ts.map +1 -0
- package/dist/api/routers/gallery.js +62 -0
- package/dist/api/routers/googleAnalytics.d.ts +31 -0
- package/dist/api/routers/googleAnalytics.d.ts.map +1 -0
- package/dist/api/routers/googleAnalytics.js +7 -0
- package/dist/api/routers/hasItemsSection.d.ts +140 -0
- package/dist/api/routers/hasItemsSection.d.ts.map +1 -0
- package/dist/api/routers/hasItemsSection.js +34 -0
- package/dist/api/routers/navigation.d.ts +52 -0
- package/dist/api/routers/navigation.d.ts.map +1 -0
- package/dist/api/routers/navigation.js +11 -0
- package/dist/api/routers/simpleSection.d.ts +58 -0
- package/dist/api/routers/simpleSection.d.ts.map +1 -0
- package/dist/api/routers/simpleSection.js +12 -0
- package/dist/api/trpc.d.ts +107 -0
- package/dist/api/trpc.d.ts.map +1 -0
- package/dist/api/trpc.js +72 -0
- package/dist/auth/axios/axiosInstance.d.ts +2 -0
- package/dist/auth/axios/axiosInstance.d.ts.map +1 -0
- package/dist/auth/axios/axiosInstance.js +8 -0
- package/dist/auth/csrf.d.ts +30 -0
- package/dist/auth/csrf.d.ts.map +1 -0
- package/dist/auth/csrf.js +76 -0
- package/dist/auth/hooks/index.d.ts +4 -0
- package/dist/auth/hooks/index.d.ts.map +1 -0
- package/dist/auth/hooks/index.js +3 -0
- package/dist/auth/hooks/useAxiosPrivate.d.ts +5 -0
- package/dist/auth/hooks/useAxiosPrivate.d.ts.map +1 -0
- package/dist/auth/hooks/useAxiosPrivate.js +74 -0
- package/dist/auth/hooks/useRefreshToken.d.ts +7 -0
- package/dist/auth/hooks/useRefreshToken.d.ts.map +1 -0
- package/dist/auth/hooks/useRefreshToken.js +79 -0
- package/dist/auth/index.d.ts +23 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +44 -0
- package/dist/auth/jwt.d.ts +6 -0
- package/dist/auth/jwt.d.ts.map +1 -0
- package/dist/auth/jwt.js +25 -0
- package/dist/auth/lib/actions.d.ts +33 -0
- package/dist/auth/lib/actions.d.ts.map +1 -0
- package/dist/auth/lib/actions.js +209 -0
- package/dist/auth/lib/client.d.ts +4 -0
- package/dist/auth/lib/client.d.ts.map +1 -0
- package/dist/auth/lib/client.js +46 -0
- package/dist/auth/lib/index.d.ts +3 -0
- package/dist/auth/lib/index.d.ts.map +1 -0
- package/dist/auth/lib/index.js +2 -0
- package/dist/auth/react.d.ts +106 -0
- package/dist/auth/react.d.ts.map +1 -0
- package/dist/auth/react.js +347 -0
- package/dist/auth/trpc.d.ts +6 -0
- package/dist/auth/trpc.d.ts.map +1 -0
- package/dist/auth/trpc.js +81 -0
- package/dist/core/config/config-loader.d.ts +92 -0
- package/dist/core/config/config-loader.d.ts.map +1 -0
- package/dist/core/config/config-loader.js +230 -0
- package/dist/core/config/index.d.ts +3 -0
- package/dist/core/config/index.d.ts.map +1 -0
- package/dist/core/config/index.js +1 -0
- package/dist/core/config/loader.d.ts +2 -0
- package/dist/core/config/loader.d.ts.map +1 -0
- package/dist/core/config/loader.js +42 -0
- package/dist/core/db/index.d.ts +2 -0
- package/dist/core/db/index.d.ts.map +1 -0
- package/dist/core/db/index.js +1 -0
- package/dist/core/db/table-checker/DbTable.d.ts +6 -0
- package/dist/core/db/table-checker/DbTable.d.ts.map +1 -0
- package/dist/core/db/table-checker/DbTable.js +5 -0
- package/dist/core/db/table-checker/MysqlTable.d.ts +34 -0
- package/dist/core/db/table-checker/MysqlTable.d.ts.map +1 -0
- package/dist/core/db/table-checker/MysqlTable.js +102 -0
- package/dist/core/db/table-checker/index.d.ts +2 -0
- package/dist/core/db/table-checker/index.d.ts.map +1 -0
- package/dist/core/db/table-checker/index.js +1 -0
- package/dist/core/factories/FieldFactory.d.ts +124 -0
- package/dist/core/factories/FieldFactory.d.ts.map +1 -0
- package/dist/core/factories/FieldFactory.js +411 -0
- package/dist/core/factories/SectionFactory.d.ts +110 -0
- package/dist/core/factories/SectionFactory.d.ts.map +1 -0
- package/dist/core/factories/SectionFactory.js +415 -0
- package/dist/core/factories/index.d.ts +3 -0
- package/dist/core/factories/index.d.ts.map +1 -0
- package/dist/core/factories/index.js +2 -0
- package/dist/core/fields/checkbox.d.ts +63 -0
- package/dist/core/fields/checkbox.d.ts.map +1 -0
- package/dist/core/fields/checkbox.js +62 -0
- package/dist/core/fields/color.d.ts +84 -0
- package/dist/core/fields/color.d.ts.map +1 -0
- package/dist/core/fields/color.js +91 -0
- package/dist/core/fields/date.d.ts +100 -0
- package/dist/core/fields/date.d.ts.map +1 -0
- package/dist/core/fields/date.js +108 -0
- package/dist/core/fields/document.d.ts +180 -0
- package/dist/core/fields/document.d.ts.map +1 -0
- package/dist/core/fields/document.js +277 -0
- package/dist/core/fields/field-group.d.ts +18 -0
- package/dist/core/fields/field-group.d.ts.map +1 -0
- package/dist/core/fields/field-group.js +6 -0
- package/dist/core/fields/field.d.ts +126 -0
- package/dist/core/fields/field.d.ts.map +1 -0
- package/dist/core/fields/field.js +148 -0
- package/dist/core/fields/fileField.d.ts +15 -0
- package/dist/core/fields/fileField.d.ts.map +1 -0
- package/dist/core/fields/fileField.js +5 -0
- package/dist/core/fields/index.d.ts +65 -0
- package/dist/core/fields/index.d.ts.map +1 -0
- package/dist/core/fields/index.js +18 -0
- package/dist/core/fields/map.d.ts +167 -0
- package/dist/core/fields/map.d.ts.map +1 -0
- package/dist/core/fields/map.js +152 -0
- package/dist/core/fields/number.d.ts +186 -0
- package/dist/core/fields/number.d.ts.map +1 -0
- package/dist/core/fields/number.js +241 -0
- package/dist/core/fields/password.d.ts +109 -0
- package/dist/core/fields/password.d.ts.map +1 -0
- package/dist/core/fields/password.js +133 -0
- package/dist/core/fields/photo.d.ts +289 -0
- package/dist/core/fields/photo.d.ts.map +1 -0
- package/dist/core/fields/photo.js +410 -0
- package/dist/core/fields/richText.d.ts +295 -0
- package/dist/core/fields/richText.d.ts.map +1 -0
- package/dist/core/fields/richText.js +338 -0
- package/dist/core/fields/select.d.ts +366 -0
- package/dist/core/fields/select.d.ts.map +1 -0
- package/dist/core/fields/select.js +499 -0
- package/dist/core/fields/selectMultiple.d.ts +236 -0
- package/dist/core/fields/selectMultiple.d.ts.map +1 -0
- package/dist/core/fields/selectMultiple.js +417 -0
- package/dist/core/fields/tags.d.ts +131 -0
- package/dist/core/fields/tags.d.ts.map +1 -0
- package/dist/core/fields/tags.js +105 -0
- package/dist/core/fields/text.d.ts +136 -0
- package/dist/core/fields/text.d.ts.map +1 -0
- package/dist/core/fields/text.js +157 -0
- package/dist/core/fields/textArea.d.ts +107 -0
- package/dist/core/fields/textArea.d.ts.map +1 -0
- package/dist/core/fields/textArea.js +126 -0
- package/dist/core/fields/video.d.ts +148 -0
- package/dist/core/fields/video.d.ts.map +1 -0
- package/dist/core/fields/video.js +248 -0
- package/dist/core/helpers/entity.d.ts +8 -0
- package/dist/core/helpers/entity.d.ts.map +1 -0
- package/dist/core/helpers/entity.js +27 -0
- package/dist/core/helpers/index.d.ts +5 -0
- package/dist/core/helpers/index.d.ts.map +1 -0
- package/dist/core/helpers/index.js +3 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +7 -0
- package/dist/core/sections/category.d.ts +283 -0
- package/dist/core/sections/category.d.ts.map +1 -0
- package/dist/core/sections/category.js +147 -0
- package/dist/core/sections/hasItems.d.ts +632 -0
- package/dist/core/sections/hasItems.d.ts.map +1 -0
- package/dist/core/sections/hasItems.js +144 -0
- package/dist/core/sections/index.d.ts +5 -0
- package/dist/core/sections/index.d.ts.map +1 -0
- package/dist/core/sections/index.js +4 -0
- package/dist/core/sections/section.d.ts +226 -0
- package/dist/core/sections/section.d.ts.map +1 -0
- package/dist/core/sections/section.js +341 -0
- package/dist/core/sections/simple.d.ts +99 -0
- package/dist/core/sections/simple.d.ts.map +1 -0
- package/dist/core/sections/simple.js +95 -0
- package/dist/core/security/dom.d.ts +11 -0
- package/dist/core/security/dom.d.ts.map +1 -0
- package/dist/core/security/dom.js +92 -0
- package/dist/core/submit/ItemEditSubmit.d.ts +76 -0
- package/dist/core/submit/ItemEditSubmit.d.ts.map +1 -0
- package/dist/core/submit/ItemEditSubmit.js +186 -0
- package/dist/core/submit/NewItemSubmit.d.ts +14 -0
- package/dist/core/submit/NewItemSubmit.d.ts.map +1 -0
- package/dist/core/submit/NewItemSubmit.js +93 -0
- package/dist/core/submit/SimpleSectionSubmit.d.ts +13 -0
- package/dist/core/submit/SimpleSectionSubmit.d.ts.map +1 -0
- package/dist/core/submit/SimpleSectionSubmit.js +93 -0
- package/dist/core/submit/index.d.ts +5 -0
- package/dist/core/submit/index.d.ts.map +1 -0
- package/dist/core/submit/index.js +4 -0
- package/dist/core/submit/submit.d.ts +116 -0
- package/dist/core/submit/submit.d.ts.map +1 -0
- package/dist/core/submit/submit.js +479 -0
- package/dist/core/types/index.d.ts +280 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/core/types/index.js +1 -0
- package/dist/db/client.d.ts +9 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +19 -0
- package/dist/db/config.d.ts +6 -0
- package/dist/db/config.d.ts.map +1 -0
- package/dist/db/config.js +22 -0
- package/dist/db/drizzle.config.d.ts +6 -0
- package/dist/db/drizzle.config.d.ts.map +1 -0
- package/dist/db/drizzle.config.js +18 -0
- package/dist/db/index.d.ts +3 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +3 -0
- package/dist/db/schema.d.ts +639 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +73 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/translations/dictionaries/ar.json +279 -0
- package/dist/translations/dictionaries/en.json +279 -0
- package/dist/translations/index.d.ts +3 -0
- package/dist/translations/index.d.ts.map +1 -0
- package/dist/translations/index.js +15 -0
- package/dist/utils/CpanelApi.d.ts +25 -0
- package/dist/utils/CpanelApi.d.ts.map +1 -0
- package/dist/utils/CpanelApi.js +64 -0
- package/dist/utils/constants.d.ts +14 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +61 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/utils.d.ts +60 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +132 -0
- package/dist/validators/checkbox.d.ts +4 -0
- package/dist/validators/checkbox.d.ts.map +1 -0
- package/dist/validators/checkbox.js +12 -0
- package/dist/validators/color.d.ts +4 -0
- package/dist/validators/color.d.ts.map +1 -0
- package/dist/validators/color.js +7 -0
- package/dist/validators/date.d.ts +4 -0
- package/dist/validators/date.d.ts.map +1 -0
- package/dist/validators/date.js +5 -0
- package/dist/validators/document.d.ts +4 -0
- package/dist/validators/document.d.ts.map +1 -0
- package/dist/validators/document.js +57 -0
- package/dist/validators/index.d.ts +15 -0
- package/dist/validators/index.d.ts.map +1 -0
- package/dist/validators/index.js +14 -0
- package/dist/validators/map.d.ts +4 -0
- package/dist/validators/map.d.ts.map +1 -0
- package/dist/validators/map.js +5 -0
- package/dist/validators/number.d.ts +4 -0
- package/dist/validators/number.d.ts.map +1 -0
- package/dist/validators/number.js +20 -0
- package/dist/validators/password.d.ts +4 -0
- package/dist/validators/password.d.ts.map +1 -0
- package/dist/validators/password.js +11 -0
- package/dist/validators/photo.d.ts +4 -0
- package/dist/validators/photo.d.ts.map +1 -0
- package/dist/validators/photo.js +100 -0
- package/dist/validators/richText.d.ts +4 -0
- package/dist/validators/richText.d.ts.map +1 -0
- package/dist/validators/richText.js +8 -0
- package/dist/validators/select-multiple.d.ts +10 -0
- package/dist/validators/select-multiple.d.ts.map +1 -0
- package/dist/validators/select-multiple.js +20 -0
- package/dist/validators/select.d.ts +4 -0
- package/dist/validators/select.d.ts.map +1 -0
- package/dist/validators/select.js +5 -0
- package/dist/validators/text.d.ts +4 -0
- package/dist/validators/text.d.ts.map +1 -0
- package/dist/validators/text.js +7 -0
- package/dist/validators/textarea.d.ts +4 -0
- package/dist/validators/textarea.d.ts.map +1 -0
- package/dist/validators/textarea.js +7 -0
- package/dist/validators/video.d.ts +4 -0
- package/dist/validators/video.d.ts.map +1 -0
- package/dist/validators/video.js +57 -0
- package/package.json +150 -6
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import type { BaseSectionOptions } from './section';
|
|
2
|
+
import type { FieldGroupConfig } from '../fields/field-group';
|
|
3
|
+
import { Section } from './section';
|
|
4
|
+
import type { TextFieldConfig } from '../fields';
|
|
5
|
+
import { entityKind } from '../helpers';
|
|
6
|
+
import type { FieldConfig } from '../fields';
|
|
7
|
+
import * as z from 'zod';
|
|
8
|
+
declare const configSchema: z.ZodObject<{
|
|
9
|
+
headingField: z.ZodCustom<{
|
|
10
|
+
type: "text";
|
|
11
|
+
build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("..").TextField, import("..").TextField>>;
|
|
12
|
+
name: string;
|
|
13
|
+
placeholder?: string | undefined;
|
|
14
|
+
minLength?: number | undefined;
|
|
15
|
+
maxLength?: number | undefined;
|
|
16
|
+
defaultValue?: string | undefined;
|
|
17
|
+
sanitize?: boolean | undefined;
|
|
18
|
+
label?: string | undefined;
|
|
19
|
+
required?: boolean | undefined;
|
|
20
|
+
order?: number | undefined;
|
|
21
|
+
conditionalRules?: import("../types").ConditionalRule[] | undefined;
|
|
22
|
+
adminGenerated?: boolean | "readonly" | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
type: "text";
|
|
25
|
+
build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("..").TextField, import("..").TextField>>;
|
|
26
|
+
name: string;
|
|
27
|
+
placeholder?: string | undefined;
|
|
28
|
+
minLength?: number | undefined;
|
|
29
|
+
maxLength?: number | undefined;
|
|
30
|
+
defaultValue?: string | undefined;
|
|
31
|
+
sanitize?: boolean | undefined;
|
|
32
|
+
label?: string | undefined;
|
|
33
|
+
required?: boolean | undefined;
|
|
34
|
+
order?: number | undefined;
|
|
35
|
+
conditionalRules?: import("../types").ConditionalRule[] | undefined;
|
|
36
|
+
adminGenerated?: boolean | "readonly" | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
title: z.ZodObject<{
|
|
39
|
+
section: z.ZodString;
|
|
40
|
+
singular: z.ZodString;
|
|
41
|
+
plural: z.ZodString;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
/**
|
|
44
|
+
* The depth of the category section is the number of nested levels of categories that can be created.
|
|
45
|
+
* For example, if the depth is 2, each category can have one subcategory.
|
|
46
|
+
* Default value is 1. (No subcategories)
|
|
47
|
+
*/
|
|
48
|
+
depth: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
/**
|
|
50
|
+
* Allow recursive delete of categories children (depth > 1) when deleting the parent category.
|
|
51
|
+
* If true, all children categories will be deleted when the parent category is deleted.
|
|
52
|
+
* For this to take effect, `allowRecursiveDelete` in lz.config.ts must also be set to true.
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
allowRecursiveDelete: z.ZodOptional<z.ZodBoolean>;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
type Config = z.infer<typeof configSchema>;
|
|
58
|
+
export declare class CategorySection extends Section<Config> {
|
|
59
|
+
static readonly [entityKind] = "CategorySection";
|
|
60
|
+
readonly type = "category";
|
|
61
|
+
readonly title: {
|
|
62
|
+
section: string;
|
|
63
|
+
singular: string;
|
|
64
|
+
plural: string;
|
|
65
|
+
};
|
|
66
|
+
readonly headingField: TextFieldConfig;
|
|
67
|
+
readonly depth: number;
|
|
68
|
+
readonly allowRecursiveDelete: boolean;
|
|
69
|
+
constructor(config: BaseSectionOptions<Config>);
|
|
70
|
+
}
|
|
71
|
+
declare const optionsSchema: z.ZodObject<{
|
|
72
|
+
headingField: z.ZodCustom<{
|
|
73
|
+
type: "text";
|
|
74
|
+
build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("..").TextField, import("..").TextField>>;
|
|
75
|
+
name: string;
|
|
76
|
+
placeholder?: string | undefined;
|
|
77
|
+
minLength?: number | undefined;
|
|
78
|
+
maxLength?: number | undefined;
|
|
79
|
+
defaultValue?: string | undefined;
|
|
80
|
+
sanitize?: boolean | undefined;
|
|
81
|
+
label?: string | undefined;
|
|
82
|
+
required?: boolean | undefined;
|
|
83
|
+
order?: number | undefined;
|
|
84
|
+
conditionalRules?: import("../types").ConditionalRule[] | undefined;
|
|
85
|
+
adminGenerated?: boolean | "readonly" | undefined;
|
|
86
|
+
}, {
|
|
87
|
+
type: "text";
|
|
88
|
+
build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("..").TextField, import("..").TextField>>;
|
|
89
|
+
name: string;
|
|
90
|
+
placeholder?: string | undefined;
|
|
91
|
+
minLength?: number | undefined;
|
|
92
|
+
maxLength?: number | undefined;
|
|
93
|
+
defaultValue?: string | undefined;
|
|
94
|
+
sanitize?: boolean | undefined;
|
|
95
|
+
label?: string | undefined;
|
|
96
|
+
required?: boolean | undefined;
|
|
97
|
+
order?: number | undefined;
|
|
98
|
+
conditionalRules?: import("../types").ConditionalRule[] | undefined;
|
|
99
|
+
adminGenerated?: boolean | "readonly" | undefined;
|
|
100
|
+
}>;
|
|
101
|
+
title: z.ZodObject<{
|
|
102
|
+
section: z.ZodString;
|
|
103
|
+
singular: z.ZodString;
|
|
104
|
+
plural: z.ZodString;
|
|
105
|
+
}, z.core.$strict>;
|
|
106
|
+
/**
|
|
107
|
+
* The depth of the category section is the number of nested levels of categories that can be created.
|
|
108
|
+
* For example, if the depth is 2, each category can have one subcategory.
|
|
109
|
+
* Default value is 1. (No subcategories)
|
|
110
|
+
*/
|
|
111
|
+
depth: z.ZodOptional<z.ZodNumber>;
|
|
112
|
+
/**
|
|
113
|
+
* Allow recursive delete of categories children (depth > 1) when deleting the parent category.
|
|
114
|
+
* If true, all children categories will be deleted when the parent category is deleted.
|
|
115
|
+
* For this to take effect, `allowRecursiveDelete` in lz.config.ts must also be set to true.
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
allowRecursiveDelete: z.ZodOptional<z.ZodBoolean>;
|
|
119
|
+
fields: z.ZodUnion<[z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>, z.ZodArray<z.ZodCustom<FieldGroupConfig, FieldGroupConfig>>]>;
|
|
120
|
+
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types").Variant, import("../types").Variant>>>;
|
|
121
|
+
name: z.ZodString;
|
|
122
|
+
order: z.ZodNumber;
|
|
123
|
+
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
124
|
+
db: z.ZodObject<{
|
|
125
|
+
table: z.ZodString;
|
|
126
|
+
identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
127
|
+
orderByField: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
128
|
+
primaryKey: z.ZodOptional<z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>>;
|
|
129
|
+
foreignKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
130
|
+
columns: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
131
|
+
foreignColumns: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
132
|
+
name: z.ZodString;
|
|
133
|
+
}, z.core.$strict>>>;
|
|
134
|
+
index: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
135
|
+
columns: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
136
|
+
name: z.ZodOptional<z.ZodString>;
|
|
137
|
+
}, z.core.$strict>>>;
|
|
138
|
+
unique: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
139
|
+
columns: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
140
|
+
name: z.ZodOptional<z.ZodString>;
|
|
141
|
+
}, z.core.$strict>>>;
|
|
142
|
+
fulltext: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
143
|
+
columns: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
144
|
+
name: z.ZodOptional<z.ZodString>;
|
|
145
|
+
}, z.core.$strict>>>;
|
|
146
|
+
}, z.core.$strict>;
|
|
147
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
148
|
+
gallery: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
db: z.ZodObject<{
|
|
150
|
+
tableName: z.ZodString;
|
|
151
|
+
identifierField: z.ZodOptional<z.ZodString>;
|
|
152
|
+
photoNameField: z.ZodOptional<z.ZodString>;
|
|
153
|
+
metaField: z.ZodOptional<z.ZodString>;
|
|
154
|
+
}, z.core.$strict>;
|
|
155
|
+
watermark: z.ZodOptional<z.ZodBoolean>;
|
|
156
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
157
|
+
width: z.ZodNumber;
|
|
158
|
+
height: z.ZodNumber;
|
|
159
|
+
crop: z.ZodBoolean;
|
|
160
|
+
quality: z.ZodNumber;
|
|
161
|
+
}, z.core.$strict>>;
|
|
162
|
+
}, z.core.$strict>>;
|
|
163
|
+
hooks: z.ZodOptional<z.ZodCustom<import("./section").Hooks, import("./section").Hooks>>;
|
|
164
|
+
}, z.core.$strict>;
|
|
165
|
+
export declare const categorySectionConfigSchema: z.ZodObject<{
|
|
166
|
+
type: z.ZodLiteral<"category">;
|
|
167
|
+
fields: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
168
|
+
build: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodCustom<CategorySection, CategorySection>>;
|
|
169
|
+
fieldGroups: z.ZodOptional<z.ZodArray<z.ZodCustom<FieldGroupConfig, FieldGroupConfig>>>;
|
|
170
|
+
headingField: z.ZodCustom<{
|
|
171
|
+
type: "text";
|
|
172
|
+
build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("..").TextField, import("..").TextField>>;
|
|
173
|
+
name: string;
|
|
174
|
+
placeholder?: string | undefined;
|
|
175
|
+
minLength?: number | undefined;
|
|
176
|
+
maxLength?: number | undefined;
|
|
177
|
+
defaultValue?: string | undefined;
|
|
178
|
+
sanitize?: boolean | undefined;
|
|
179
|
+
label?: string | undefined;
|
|
180
|
+
required?: boolean | undefined;
|
|
181
|
+
order?: number | undefined;
|
|
182
|
+
conditionalRules?: import("../types").ConditionalRule[] | undefined;
|
|
183
|
+
adminGenerated?: boolean | "readonly" | undefined;
|
|
184
|
+
}, {
|
|
185
|
+
type: "text";
|
|
186
|
+
build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("..").TextField, import("..").TextField>>;
|
|
187
|
+
name: string;
|
|
188
|
+
placeholder?: string | undefined;
|
|
189
|
+
minLength?: number | undefined;
|
|
190
|
+
maxLength?: number | undefined;
|
|
191
|
+
defaultValue?: string | undefined;
|
|
192
|
+
sanitize?: boolean | undefined;
|
|
193
|
+
label?: string | undefined;
|
|
194
|
+
required?: boolean | undefined;
|
|
195
|
+
order?: number | undefined;
|
|
196
|
+
conditionalRules?: import("../types").ConditionalRule[] | undefined;
|
|
197
|
+
adminGenerated?: boolean | "readonly" | undefined;
|
|
198
|
+
}>;
|
|
199
|
+
title: z.ZodObject<{
|
|
200
|
+
section: z.ZodString;
|
|
201
|
+
singular: z.ZodString;
|
|
202
|
+
plural: z.ZodString;
|
|
203
|
+
}, z.core.$strict>;
|
|
204
|
+
/**
|
|
205
|
+
* The depth of the category section is the number of nested levels of categories that can be created.
|
|
206
|
+
* For example, if the depth is 2, each category can have one subcategory.
|
|
207
|
+
* Default value is 1. (No subcategories)
|
|
208
|
+
*/
|
|
209
|
+
depth: z.ZodOptional<z.ZodNumber>;
|
|
210
|
+
/**
|
|
211
|
+
* Allow recursive delete of categories children (depth > 1) when deleting the parent category.
|
|
212
|
+
* If true, all children categories will be deleted when the parent category is deleted.
|
|
213
|
+
* For this to take effect, `allowRecursiveDelete` in lz.config.ts must also be set to true.
|
|
214
|
+
* @default false
|
|
215
|
+
*/
|
|
216
|
+
allowRecursiveDelete: z.ZodOptional<z.ZodBoolean>;
|
|
217
|
+
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types").Variant, import("../types").Variant>>>;
|
|
218
|
+
name: z.ZodString;
|
|
219
|
+
order: z.ZodNumber;
|
|
220
|
+
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
221
|
+
db: z.ZodObject<{
|
|
222
|
+
table: z.ZodString;
|
|
223
|
+
identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
224
|
+
orderByField: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
225
|
+
primaryKey: z.ZodOptional<z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>>;
|
|
226
|
+
foreignKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
227
|
+
columns: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
228
|
+
foreignColumns: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
229
|
+
name: z.ZodString;
|
|
230
|
+
}, z.core.$strict>>>;
|
|
231
|
+
index: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
232
|
+
columns: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
233
|
+
name: z.ZodOptional<z.ZodString>;
|
|
234
|
+
}, z.core.$strict>>>;
|
|
235
|
+
unique: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
236
|
+
columns: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
237
|
+
name: z.ZodOptional<z.ZodString>;
|
|
238
|
+
}, z.core.$strict>>>;
|
|
239
|
+
fulltext: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
240
|
+
columns: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
241
|
+
name: z.ZodOptional<z.ZodString>;
|
|
242
|
+
}, z.core.$strict>>>;
|
|
243
|
+
}, z.core.$strict>;
|
|
244
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
245
|
+
gallery: z.ZodOptional<z.ZodObject<{
|
|
246
|
+
db: z.ZodObject<{
|
|
247
|
+
tableName: z.ZodString;
|
|
248
|
+
identifierField: z.ZodOptional<z.ZodString>;
|
|
249
|
+
photoNameField: z.ZodOptional<z.ZodString>;
|
|
250
|
+
metaField: z.ZodOptional<z.ZodString>;
|
|
251
|
+
}, z.core.$strict>;
|
|
252
|
+
watermark: z.ZodOptional<z.ZodBoolean>;
|
|
253
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
254
|
+
width: z.ZodNumber;
|
|
255
|
+
height: z.ZodNumber;
|
|
256
|
+
crop: z.ZodBoolean;
|
|
257
|
+
quality: z.ZodNumber;
|
|
258
|
+
}, z.core.$strict>>;
|
|
259
|
+
}, z.core.$strict>>;
|
|
260
|
+
hooks: z.ZodOptional<z.ZodCustom<import("./section").Hooks, import("./section").Hooks>>;
|
|
261
|
+
}, z.core.$strict>;
|
|
262
|
+
export type CategorySectionOptions = z.infer<typeof optionsSchema>;
|
|
263
|
+
/**
|
|
264
|
+
* Category section configuration
|
|
265
|
+
* This is the output of the categorySection() helper function, it that can be serialized and used anywhere
|
|
266
|
+
* The build() method allows creating a CategorySection instance when needed
|
|
267
|
+
*/
|
|
268
|
+
export type CategorySectionConfig = z.infer<typeof categorySectionConfigSchema>;
|
|
269
|
+
/**
|
|
270
|
+
* Helper function to create a category section configuration
|
|
271
|
+
* Returns a config object with a build() method that can be serialized and used anywhere
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* const sectionConfig = categorySection({ name: 'categories', ... })
|
|
276
|
+
* const sectionInstance = sectionConfig.build()
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
279
|
+
* @param section
|
|
280
|
+
*/
|
|
281
|
+
export declare function categorySection(section: CategorySectionOptions): CategorySectionConfig;
|
|
282
|
+
export {};
|
|
283
|
+
//# sourceMappingURL=category.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category.d.ts","sourceRoot":"","sources":["../../../src/core/sections/category.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAA8E,MAAM,WAAW,CAAA;AAC/G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAWd;;;;OAIG;;IAEH;;;;;OAKG;;kBAGL,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1C,qBAAa,eAAgB,SAAQ,OAAO,CAAC,MAAM,CAAC;IAChD,gBAAyB,CAAC,UAAU,CAAC,qBAAoB;IACzD,SAAkB,IAAI,cAAa;IACnC,SAAkB,KAAK,EAAE;QACrB,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAA;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAI;IAC1B,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAA;gBAE1B,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;CA0CjD;AAED,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA1Ef;;;;OAIG;;IAEH;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAkEL,CAAA;AAOF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IApFpC;;;;OAIG;;IAEH;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAiFL,CAAA;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AAElE;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAE/E;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,qBAAqB,CA6CtF"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Section, baseHelperFunctionOptionsSchema, FieldGroupConfigSchema, fieldConfigSchema } from './section';
|
|
2
|
+
import { entityKind } from '../helpers';
|
|
3
|
+
import { numberField, textField } from '../fields';
|
|
4
|
+
import * as z from 'zod';
|
|
5
|
+
const configSchema = z.strictObject({
|
|
6
|
+
headingField: z
|
|
7
|
+
.custom()
|
|
8
|
+
.describe('Heading field must be a config - will be resolved during instantiation'),
|
|
9
|
+
title: z
|
|
10
|
+
.strictObject({
|
|
11
|
+
section: z.string().describe('The section title'),
|
|
12
|
+
singular: z.string().describe('The singular form of the title'),
|
|
13
|
+
plural: z.string().describe('The plural form of the title'),
|
|
14
|
+
})
|
|
15
|
+
.describe('The title configuration for the category section'),
|
|
16
|
+
/**
|
|
17
|
+
* The depth of the category section is the number of nested levels of categories that can be created.
|
|
18
|
+
* For example, if the depth is 2, each category can have one subcategory.
|
|
19
|
+
* Default value is 1. (No subcategories)
|
|
20
|
+
*/
|
|
21
|
+
depth: z.number().positive().optional().describe('The depth of the category section'),
|
|
22
|
+
/**
|
|
23
|
+
* Allow recursive delete of categories children (depth > 1) when deleting the parent category.
|
|
24
|
+
* If true, all children categories will be deleted when the parent category is deleted.
|
|
25
|
+
* For this to take effect, `allowRecursiveDelete` in lz.config.ts must also be set to true.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
allowRecursiveDelete: z.boolean().optional().describe('Allow recursive delete of categories children'),
|
|
29
|
+
// requirePublishPermission?: boolean
|
|
30
|
+
});
|
|
31
|
+
export class CategorySection extends Section {
|
|
32
|
+
static [entityKind] = 'CategorySection';
|
|
33
|
+
type = 'category';
|
|
34
|
+
title;
|
|
35
|
+
headingField;
|
|
36
|
+
depth = 1;
|
|
37
|
+
allowRecursiveDelete;
|
|
38
|
+
// private requirePublishPermission: boolean
|
|
39
|
+
constructor(config) {
|
|
40
|
+
super(config);
|
|
41
|
+
this.title = config.title;
|
|
42
|
+
this.depth = config.depth ?? 1;
|
|
43
|
+
this.headingField = config.headingField;
|
|
44
|
+
this.allowRecursiveDelete = config.allowRecursiveDelete ?? false;
|
|
45
|
+
// this.requirePublishPermission = config.requirePublishPermission
|
|
46
|
+
/**
|
|
47
|
+
* Add the parentId and level fields to the fields if the depth is greater than 1
|
|
48
|
+
* Make sure to match the identifier field type
|
|
49
|
+
*/
|
|
50
|
+
if (this.depth > 1) {
|
|
51
|
+
const levelConfig = numberField({
|
|
52
|
+
name: 'level',
|
|
53
|
+
label: 'Level',
|
|
54
|
+
required: false,
|
|
55
|
+
order: 0,
|
|
56
|
+
});
|
|
57
|
+
if (this.db.identifier.type === 'number') {
|
|
58
|
+
this._fieldConfigs?.push(numberField({
|
|
59
|
+
name: 'parent_id',
|
|
60
|
+
label: 'Parent ID',
|
|
61
|
+
required: false,
|
|
62
|
+
order: 0,
|
|
63
|
+
}), levelConfig);
|
|
64
|
+
}
|
|
65
|
+
else if (this.db.identifier.type === 'text') {
|
|
66
|
+
this._fieldConfigs?.push(textField({
|
|
67
|
+
name: 'parent_id',
|
|
68
|
+
label: 'Parent ID',
|
|
69
|
+
required: false,
|
|
70
|
+
order: 0,
|
|
71
|
+
}), levelConfig);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const optionsSchema = z.strictObject({
|
|
77
|
+
...baseHelperFunctionOptionsSchema.shape,
|
|
78
|
+
...configSchema.shape,
|
|
79
|
+
});
|
|
80
|
+
const compiledOptionsSchema = z.strictObject({
|
|
81
|
+
...optionsSchema.shape,
|
|
82
|
+
fieldGroups: z.array(FieldGroupConfigSchema).optional().describe('The field groups of the section if provided'),
|
|
83
|
+
});
|
|
84
|
+
export const categorySectionConfigSchema = z.strictObject({
|
|
85
|
+
...compiledOptionsSchema.shape,
|
|
86
|
+
type: z.literal('category').describe('The type of the section'),
|
|
87
|
+
fields: z.array(fieldConfigSchema).describe('The fields of the section'),
|
|
88
|
+
build: z
|
|
89
|
+
.function()
|
|
90
|
+
.output(z.instanceof(CategorySection))
|
|
91
|
+
.describe('Build a CategorySection instance from this config'),
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* Helper function to create a category section configuration
|
|
95
|
+
* Returns a config object with a build() method that can be serialized and used anywhere
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const sectionConfig = categorySection({ name: 'categories', ... })
|
|
100
|
+
* const sectionInstance = sectionConfig.build()
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @param section
|
|
104
|
+
*/
|
|
105
|
+
export function categorySection(section) {
|
|
106
|
+
/**
|
|
107
|
+
* Validate the section config
|
|
108
|
+
*/
|
|
109
|
+
const result = optionsSchema.safeParse(section);
|
|
110
|
+
if (!result.success) {
|
|
111
|
+
throw new Error(`[Section: ${section.name}]: ${z.prettifyError(result.error)}`);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Resolve fields and fieldGroups
|
|
115
|
+
*/
|
|
116
|
+
let fields = [];
|
|
117
|
+
let fieldGroups = [];
|
|
118
|
+
if (section.fields && section.fields.length > 0) {
|
|
119
|
+
const firstInput = section.fields[0];
|
|
120
|
+
/**
|
|
121
|
+
* Check if the first item is a field group.
|
|
122
|
+
* We don't need to check every item,
|
|
123
|
+
* because zod already validated the fields array.
|
|
124
|
+
*/
|
|
125
|
+
if (firstInput && 'fields' in firstInput) {
|
|
126
|
+
fieldGroups = section.fields;
|
|
127
|
+
fields = fieldGroups.flatMap((group) => group.fields);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
fields = section.fields;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const config = {
|
|
134
|
+
...section,
|
|
135
|
+
fields,
|
|
136
|
+
fieldGroups: fieldGroups.length > 0 ? fieldGroups : undefined,
|
|
137
|
+
type: 'category',
|
|
138
|
+
build() {
|
|
139
|
+
return new CategorySection({
|
|
140
|
+
...section,
|
|
141
|
+
fields,
|
|
142
|
+
fieldGroups: fieldGroups.length > 0 ? fieldGroups : undefined,
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
return config;
|
|
147
|
+
}
|