@griddo/ax 11.10.23 → 11.10.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/griddo-config/index.js +1 -0
- package/package.json +2 -2
- package/src/Style/index.tsx +10 -8
- package/src/__tests__/components/ConfigPanel/ConfigPanel.test.tsx +10 -8
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/PageConnectedField.test.tsx +86 -8
- package/src/__tests__/components/SideModal/SideModal.test.tsx +64 -0
- package/src/__tests__/hooks/useSchemas.test.tsx +224 -0
- package/src/__tests__/services/SchemasService.test.ts +135 -0
- package/src/api/schemas.tsx +11 -1
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +11 -17
- package/src/components/Fields/Wysiwyg/helpers.tsx +14 -4
- package/src/components/Loader/components/Dots.js +4 -5
- package/src/components/PageFinder/index.tsx +15 -9
- package/src/components/ResizePanel/index.tsx +13 -3
- package/src/components/ResizePanel/style.tsx +2 -9
- package/src/containers/App/actions.tsx +96 -24
- package/src/containers/App/constants.tsx +7 -0
- package/src/containers/App/interfaces.tsx +26 -8
- package/src/containers/App/reducer.tsx +24 -9
- package/src/containers/Sites/actions.tsx +49 -49
- package/src/forms/editor.tsx +4 -3
- package/src/helpers/index.tsx +76 -94
- package/src/helpers/schemas.tsx +144 -36
- package/src/helpers/structuredData.tsx +36 -7
- package/src/helpers/themes.tsx +26 -8
- package/src/hooks/index.tsx +5 -0
- package/src/hooks/useSchemas.ts +151 -0
- package/src/locales/en-US.ts +1 -0
- package/src/locales/es-ES.ts +1 -0
- package/src/modules/Analytics/GroupPanel/index.tsx +9 -6
- package/src/modules/Analytics/GroupPanel/utils.tsx +12 -28
- package/src/modules/Content/PageItem/index.tsx +33 -36
- package/src/modules/Content/index.tsx +34 -30
- package/src/modules/Content/utils.tsx +16 -12
- package/src/modules/Forms/FormEditor/index.tsx +13 -14
- package/src/modules/FramePreview/index.tsx +8 -8
- package/src/modules/GlobalEditor/index.tsx +57 -42
- package/src/modules/MediaGallery/ImageModal/index.tsx +15 -9
- package/src/modules/MediaGallery/ImageModal/style.tsx +16 -1
- package/src/modules/PublicPreview/index.tsx +4 -3
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +4 -5
- package/src/modules/Settings/Globals/index.tsx +10 -11
- package/src/modules/Sites/index.tsx +13 -5
- package/src/modules/StructuredData/Form/index.tsx +25 -29
- package/src/modules/StructuredData/StructuredDataList/OptionTable/index.tsx +15 -6
- package/src/modules/StructuredData/StructuredDataList/index.tsx +22 -14
- package/src/modules/StructuredData/StructuredDataList/utils.tsx +12 -11
- package/src/schemas/index.tsx +5 -4
- package/src/schemas/pages/Page.ts +308 -0
- package/src/schemas/pages/index.ts +9 -0
- package/src/services/SchemasService.ts +240 -0
- package/src/services/index.ts +9 -0
- package/src/types/index.tsx +48 -39
- package/tsconfig.paths.json +1 -0
- package/src/schemas/pages/Page.tsx +0 -301
- package/src/schemas/pages/index.tsx +0 -5
- /package/src/schemas/pages/{FormPage.tsx → FormPage.ts} +0 -0
- /package/src/schemas/pages/{GlobalPage.tsx → GlobalPage.ts} +0 -0
|
@@ -1,69 +1,69 @@
|
|
|
1
|
+
import { analytics, dataPack, languages, pages, sites, social, structuredData } from "@ax/api";
|
|
2
|
+
import { analyticsActions } from "@ax/containers/Analytics";
|
|
3
|
+
import { appActions } from "@ax/containers/App";
|
|
4
|
+
import { integrationsActions } from "@ax/containers/Integrations";
|
|
5
|
+
import { menuActions, navigationActions } from "@ax/containers/Navigation";
|
|
6
|
+
import { resetPageEditor } from "@ax/containers/PageEditor/actions";
|
|
7
|
+
import { dataPacksActions } from "@ax/containers/Settings/DataPacks";
|
|
8
|
+
import { socialActions } from "@ax/containers/Settings/Social";
|
|
9
|
+
import { structuredDataActions } from "@ax/containers/StructuredData";
|
|
10
|
+
import { usersActions } from "@ax/containers/Users";
|
|
11
|
+
import { getDefaultTheme, getThemeElements, handleRequest, isReqOk, sortBy } from "@ax/helpers";
|
|
12
|
+
import {
|
|
13
|
+
IGetGlobalPagesParams,
|
|
14
|
+
IGetSitePagesParams,
|
|
15
|
+
IGetSitesParams,
|
|
16
|
+
IPage,
|
|
17
|
+
IQueryValue,
|
|
18
|
+
IRootState,
|
|
19
|
+
ISettingsForm,
|
|
20
|
+
ISite,
|
|
21
|
+
ISiteListConfig,
|
|
22
|
+
IThemeElements,
|
|
23
|
+
} from "@ax/types";
|
|
24
|
+
|
|
1
25
|
import { Dispatch } from "redux";
|
|
26
|
+
|
|
2
27
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
28
|
+
DEFAULT_PARAMS,
|
|
29
|
+
SET_ALL_SITE_PAGES,
|
|
30
|
+
SET_CONFIG,
|
|
31
|
+
SET_CONTENT_FILTERS,
|
|
32
|
+
SET_CURRENT_SEARCH,
|
|
33
|
+
SET_CURRENT_SITE_ERROR_PAGES,
|
|
6
34
|
SET_CURRENT_SITE_INFO,
|
|
35
|
+
SET_CURRENT_SITE_LANGUAGES,
|
|
7
36
|
SET_CURRENT_SITE_PAGES,
|
|
8
|
-
SET_ALL_SITE_PAGES,
|
|
9
37
|
SET_FILTER,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
SET_CURRENT_SITE_LANGUAGES,
|
|
38
|
+
SET_IS_SITES_LOADING,
|
|
39
|
+
SET_RECENT_SITES,
|
|
13
40
|
SET_SAVED_SITE_INFO,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
SET_CONFIG,
|
|
18
|
-
SET_CURRENT_SEARCH,
|
|
41
|
+
SET_SITES,
|
|
42
|
+
SET_SITES_BY_LANG,
|
|
43
|
+
SET_SITES_TOTAL_ITEMS,
|
|
19
44
|
SET_THEME_ELEMENTS,
|
|
20
|
-
|
|
45
|
+
SET_TOTAL_ITEMS,
|
|
21
46
|
} from "./constants";
|
|
22
|
-
|
|
23
47
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
48
|
+
ISetAllSitePagesAction,
|
|
49
|
+
ISetConfig,
|
|
50
|
+
ISetContentFilters,
|
|
51
|
+
ISetCurrentSearch,
|
|
52
|
+
ISetCurrentSiteErrorPages,
|
|
27
53
|
ISetCurrentSiteInfoAction,
|
|
54
|
+
ISetCurrentSiteLanguagesAction,
|
|
28
55
|
ISetCurrentSitePagesAction,
|
|
29
|
-
ISetAllSitePagesAction,
|
|
30
56
|
ISetFilter,
|
|
31
|
-
|
|
32
|
-
|
|
57
|
+
ISetIsSitesLoading,
|
|
58
|
+
ISetRecentSitesAction,
|
|
33
59
|
ISetSavedSiteInfoAction,
|
|
34
|
-
|
|
35
|
-
|
|
60
|
+
ISetSitesAction,
|
|
61
|
+
ISetSitesByLangAction,
|
|
36
62
|
ISetSitesTotalItems,
|
|
37
|
-
ISetConfig,
|
|
38
|
-
ISetCurrentSearch,
|
|
39
63
|
ISetThemeElements,
|
|
40
|
-
|
|
64
|
+
ISetTotalItems,
|
|
41
65
|
} from "./interfaces";
|
|
42
66
|
|
|
43
|
-
import {
|
|
44
|
-
ISite,
|
|
45
|
-
IGetSitePagesParams,
|
|
46
|
-
ISettingsForm,
|
|
47
|
-
IGetGlobalPagesParams,
|
|
48
|
-
IPage,
|
|
49
|
-
IGetSitesParams,
|
|
50
|
-
ISiteListConfig,
|
|
51
|
-
IQueryValue,
|
|
52
|
-
IThemeElements,
|
|
53
|
-
IRootState,
|
|
54
|
-
} from "@ax/types";
|
|
55
|
-
import { sites, languages, dataPack, social, structuredData, analytics, pages } from "@ax/api";
|
|
56
|
-
import { appActions } from "@ax/containers/App";
|
|
57
|
-
import { structuredDataActions } from "@ax/containers/StructuredData";
|
|
58
|
-
import { navigationActions, menuActions } from "@ax/containers/Navigation";
|
|
59
|
-
import { resetPageEditor } from "@ax/containers/PageEditor/actions";
|
|
60
|
-
import { analyticsActions } from "@ax/containers/Analytics";
|
|
61
|
-
import { dataPacksActions } from "@ax/containers/Settings/DataPacks";
|
|
62
|
-
import { socialActions } from "@ax/containers/Settings/Social";
|
|
63
|
-
import { integrationsActions } from "@ax/containers/Integrations";
|
|
64
|
-
import { getDefaultTheme, getThemeElements, handleRequest, isReqOk, sortBy } from "@ax/helpers";
|
|
65
|
-
import { usersActions } from "@ax/containers/Users";
|
|
66
|
-
|
|
67
67
|
const { setIsSaving, setLanguage } = appActions;
|
|
68
68
|
const { resetDefaultsValues, getDefaults } = navigationActions;
|
|
69
69
|
const { resetMenuValues } = menuActions;
|
package/src/forms/editor.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { deepClone,
|
|
2
|
-
import {
|
|
1
|
+
import { deepClone, getDisplayName, getSchema, getTemplate } from "@ax/helpers";
|
|
2
|
+
import type { IBreadcrumbItem, IPage } from "@ax/types";
|
|
3
3
|
|
|
4
4
|
const configKeys = ["headerConfig", "footerConfig"];
|
|
5
5
|
|
|
@@ -213,8 +213,9 @@ const evaluateComputedFields = async (page: IPage, operation: "save" | "refresh"
|
|
|
213
213
|
apiUrl: process.env.GRIDDO_API_URL || process.env.REACT_APP_API_ENDPOINT,
|
|
214
214
|
publicApiUrl: process.env.GRIDDO_PUBLIC_API_URL || process.env.REACT_APP_PUBLIC_API_ENDPOINT,
|
|
215
215
|
};
|
|
216
|
-
for (const field of pageSchemaContent) {
|
|
216
|
+
for (const field of pageSchemaContent || []) {
|
|
217
217
|
if (Object.prototype.hasOwnProperty.call(field, "computed")) {
|
|
218
|
+
// biome-ignore lint/security/noGlobalEval: we need to evaluate the computed field
|
|
218
219
|
const computedFunction = eval(`(${field.computed})`);
|
|
219
220
|
updatedPage.template[field.key] = await computedFunction(page, data);
|
|
220
221
|
}
|
package/src/helpers/index.tsx
CHANGED
|
@@ -1,130 +1,112 @@
|
|
|
1
|
+
import { arrayInsert, isEmptyArray, moveArrayElement } from "./arrays";
|
|
1
2
|
import {
|
|
2
|
-
isComponentEmpty,
|
|
3
|
-
setAsContainedComponent,
|
|
4
3
|
areAllComponentsEmpty,
|
|
5
|
-
isEmptyContainer,
|
|
6
4
|
areEqual,
|
|
5
|
+
isComponentEmpty,
|
|
6
|
+
isEmptyContainer,
|
|
7
|
+
setAsContainedComponent,
|
|
7
8
|
} from "./containerEvaluations";
|
|
8
|
-
|
|
9
|
+
import { getMaxColumns, updateColumns } from "./customColumns";
|
|
10
|
+
import { getActivatedDataPacksIds, getDeactivatedModules, isModuleDisabled } from "./dataPacks";
|
|
9
11
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} from "./
|
|
26
|
-
|
|
12
|
+
areEqualDates,
|
|
13
|
+
dateToString,
|
|
14
|
+
getDateRange,
|
|
15
|
+
getDaysAgo,
|
|
16
|
+
getFormattedDateWithTimezone,
|
|
17
|
+
getHumanLastModifiedDate,
|
|
18
|
+
getRange,
|
|
19
|
+
getScheduleFormatDate,
|
|
20
|
+
getStringifyDateRange,
|
|
21
|
+
isValidDate,
|
|
22
|
+
isValidDateRange,
|
|
23
|
+
stringToDate,
|
|
24
|
+
} from "./dates";
|
|
25
|
+
import { isDevelopment } from "./environment";
|
|
26
|
+
import { getFieldByPath } from "./fields";
|
|
27
|
+
import { getFileIcon, getNewBreadcrumb, updatePropertyById } from "./files";
|
|
28
|
+
import { protectFormKeys } from "./forms";
|
|
29
|
+
import { compressImage, imageResizeCropAndCompress } from "./imageResize";
|
|
30
|
+
import { formatBytes, getImageFromHtml, getImageFromIFrame, imageToBase64 } from "./images";
|
|
27
31
|
import {
|
|
28
|
-
|
|
32
|
+
areEquals,
|
|
29
33
|
deepClone,
|
|
30
|
-
|
|
31
|
-
resetMultipleValues,
|
|
34
|
+
encodeData,
|
|
32
35
|
filterDuplicatedValues,
|
|
33
|
-
|
|
34
|
-
removeMenuEditorIds,
|
|
35
|
-
sortBy,
|
|
36
|
+
findObjectValue,
|
|
36
37
|
getNullValue,
|
|
37
|
-
removeEditorIds,
|
|
38
|
-
trimObject,
|
|
39
38
|
hasProps,
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
isEmptyObj,
|
|
40
|
+
isSelectedEditorID,
|
|
42
41
|
removeDuplicatesByProperty,
|
|
42
|
+
removeEditorIds,
|
|
43
|
+
removeMenuEditorIds,
|
|
44
|
+
resetMultipleValues,
|
|
45
|
+
sortBy,
|
|
46
|
+
trimObject,
|
|
43
47
|
} from "./objects";
|
|
44
|
-
|
|
48
|
+
import { parseTheme } from "./parseTheme";
|
|
49
|
+
import { delay, handleRequest, isReqOk } from "./requests";
|
|
45
50
|
import {
|
|
46
|
-
|
|
51
|
+
filterByCategory,
|
|
52
|
+
getDataPackSchema,
|
|
53
|
+
getDefaultFormTemplate,
|
|
54
|
+
getDefaultNavigationModules,
|
|
47
55
|
getDefaultSchema,
|
|
48
|
-
getTemplate,
|
|
49
56
|
getDefaultTemplate,
|
|
50
57
|
getDisplayName,
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
getFormTemplate,
|
|
59
|
+
getFormTemplateCategories,
|
|
60
|
+
getFormTemplates,
|
|
61
|
+
getFormTemplateThumbnails,
|
|
53
62
|
getMenuItems,
|
|
54
|
-
filterByCategory,
|
|
55
|
-
getSchemaType,
|
|
56
63
|
getModuleCategories,
|
|
57
64
|
getModuleStyles,
|
|
58
|
-
|
|
65
|
+
getNavigationModules,
|
|
66
|
+
getSchema,
|
|
67
|
+
getSchemaFormCategories,
|
|
59
68
|
getSchemaThumbnails,
|
|
69
|
+
getSchemaType,
|
|
70
|
+
getTemplate,
|
|
71
|
+
getTemplateDisplayName,
|
|
60
72
|
getTemplateThumbnails,
|
|
61
|
-
|
|
62
|
-
getDefaultNavigationModules,
|
|
73
|
+
getTemplateType,
|
|
63
74
|
isMultipleNavigationModules,
|
|
64
|
-
getFormTemplate,
|
|
65
|
-
getDefaultFormTemplate,
|
|
66
|
-
getFormTemplates,
|
|
67
|
-
getFormTemplateThumbnails,
|
|
68
|
-
getSchemaFormCategories,
|
|
69
|
-
getFormTemplateCategories,
|
|
70
75
|
} from "./schemas";
|
|
71
|
-
|
|
72
76
|
import {
|
|
73
|
-
|
|
77
|
+
camelize,
|
|
78
|
+
capitalize,
|
|
79
|
+
copyTextToClipboard,
|
|
80
|
+
decodeEntities,
|
|
81
|
+
filterImageText,
|
|
82
|
+
getFileExtension,
|
|
83
|
+
getInitials,
|
|
84
|
+
isNumber,
|
|
85
|
+
slugify,
|
|
86
|
+
splitAndJoin,
|
|
87
|
+
splitAndTrim,
|
|
88
|
+
splitCamelCase,
|
|
89
|
+
stripHtml,
|
|
90
|
+
trimText,
|
|
91
|
+
validateEmail,
|
|
92
|
+
} from "./strings";
|
|
93
|
+
import {
|
|
74
94
|
getCurrentPageStructuredData,
|
|
95
|
+
getGlobalPageTypes,
|
|
96
|
+
getStructuredDataFromPage,
|
|
75
97
|
getStructuredDataTitle,
|
|
76
|
-
isStructuredDataFromPage,
|
|
77
98
|
isGlobalStructuredData,
|
|
78
|
-
|
|
99
|
+
isStructuredDataFromPage,
|
|
79
100
|
} from "./structuredData";
|
|
80
|
-
|
|
81
|
-
import { getThumbnailProps, getFormTemplateThumbnailProps } from "./thumbnails";
|
|
82
|
-
|
|
83
|
-
import { getFieldByPath } from "./fields";
|
|
84
|
-
|
|
85
|
-
import { formatBytes, imageToBase64, getImageFromHtml, getImageFromIFrame } from "./images";
|
|
86
|
-
|
|
87
|
-
import { isReqOk, handleRequest, delay } from "./requests";
|
|
88
|
-
|
|
89
101
|
import {
|
|
90
|
-
|
|
91
|
-
stringToDate,
|
|
92
|
-
isValidDate,
|
|
93
|
-
isValidDateRange,
|
|
94
|
-
getDateRange,
|
|
95
|
-
areEqualDates,
|
|
96
|
-
getStringifyDateRange,
|
|
97
|
-
getHumanLastModifiedDate,
|
|
98
|
-
getFormattedDateWithTimezone,
|
|
99
|
-
getDaysAgo,
|
|
100
|
-
getRange,
|
|
101
|
-
getScheduleFormatDate,
|
|
102
|
-
} from "./dates";
|
|
103
|
-
|
|
104
|
-
import { imageResizeCropAndCompress, compressImage } from "./imageResize";
|
|
105
|
-
|
|
106
|
-
import { isEmptyArray, moveArrayElement, arrayInsert } from "./arrays";
|
|
107
|
-
|
|
108
|
-
import { getActivatedDataPacksIds, isModuleDisabled, getDeactivatedModules } from "./dataPacks";
|
|
109
|
-
|
|
110
|
-
import { isDevelopment } from "./environment";
|
|
111
|
-
|
|
112
|
-
import {
|
|
113
|
-
getDefaultTheme,
|
|
114
|
-
getThemeElements,
|
|
102
|
+
filterThemeDatapacks,
|
|
115
103
|
filterThemeModules,
|
|
116
104
|
filterThemeTemplates,
|
|
117
|
-
|
|
105
|
+
getDefaultTheme,
|
|
106
|
+
getThemeElements,
|
|
118
107
|
isTemplateExcludedFromTheme,
|
|
119
108
|
} from "./themes";
|
|
120
|
-
|
|
121
|
-
import { parseTheme } from "./parseTheme";
|
|
122
|
-
|
|
123
|
-
import { getFileIcon, getNewBreadcrumb, updatePropertyById } from "./files";
|
|
124
|
-
|
|
125
|
-
import { getMaxColumns, updateColumns } from "./customColumns";
|
|
126
|
-
|
|
127
|
-
import { protectFormKeys } from "./forms";
|
|
109
|
+
import { getFormTemplateThumbnailProps, getThumbnailProps } from "./thumbnails";
|
|
128
110
|
|
|
129
111
|
export {
|
|
130
112
|
isComponentEmpty,
|
package/src/helpers/schemas.tsx
CHANGED
|
@@ -1,23 +1,87 @@
|
|
|
1
1
|
import { sortBy } from "@ax/helpers";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { getPageSchemas } from "@ax/schemas";
|
|
3
|
+
import { schemasService } from "@ax/services";
|
|
4
|
+
import type { ISchema, ModuleCategoryInfo } from "@ax/types";
|
|
5
|
+
|
|
6
|
+
//////////////////
|
|
7
|
+
const getUISchemas = () => {
|
|
8
|
+
if (!schemasService.isLoaded()) {
|
|
9
|
+
return { modules: {}, components: {}, templates: {} };
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const schemas = schemasService.getSchemas();
|
|
13
|
+
return schemas.ui;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.error(`[helpers/schemas] getUISchemas failed to get schemas:`, e);
|
|
16
|
+
return { modules: {}, components: {}, templates: {} };
|
|
17
|
+
}
|
|
18
|
+
};
|
|
5
19
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
const getSchemasConfig = () => {
|
|
21
|
+
if (!schemasService.isLoaded()) {
|
|
22
|
+
return { menuItems: {}, moduleCategories: [] };
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
return schemasService.getSchemas().config;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.error(`[helpers/schemas] getSchemasConfig failed to get schemas:`, e);
|
|
28
|
+
return { menuItems: {}, moduleCategories: [] };
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const getFormSchemas = () => {
|
|
33
|
+
if (!schemasService.isLoaded()) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
return schemasService.getSchemas().forms;
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.error(`[helpers/schemas] getFormSchemas failed to get schemas:`, e);
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
16
42
|
};
|
|
17
43
|
|
|
18
|
-
const
|
|
44
|
+
const getContentTypesSchemas = () => {
|
|
45
|
+
if (!schemasService.isLoaded()) {
|
|
46
|
+
return { dataPacks: {} };
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
return schemasService.getSchemas().contentTypes;
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.error(`[helpers/schemas] getContentTypesSchemas failed to get schemas:`, e);
|
|
52
|
+
return { dataPacks: {} };
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const getAllSchemas = () => {
|
|
57
|
+
const uiSchemas = getUISchemas();
|
|
58
|
+
const formSchemas = getFormSchemas();
|
|
59
|
+
const pageSchemas = getPageSchemas();
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
...uiSchemas.modules,
|
|
63
|
+
...uiSchemas.components,
|
|
64
|
+
...formSchemas?.fields,
|
|
65
|
+
...pageSchemas,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
//////////////////
|
|
70
|
+
|
|
71
|
+
const getSchema = (name: string): ISchema | undefined => {
|
|
72
|
+
try {
|
|
73
|
+
const allSchemas = getAllSchemas();
|
|
74
|
+
// @ts-expect-error TODO: fix this, before was `any`
|
|
75
|
+
return allSchemas[name];
|
|
76
|
+
} catch (e) {
|
|
77
|
+
console.error(`[helpers/schemas] getSchema(${name}) failed:`, e);
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
19
81
|
|
|
20
82
|
const getDefaultSchema = (name: string) => {
|
|
83
|
+
const allSchemas = getAllSchemas();
|
|
84
|
+
// @ts-expect-error TODO: fix this, before was `any`
|
|
21
85
|
const defaultSchema = allSchemas[name] ? allSchemas[name].default : {};
|
|
22
86
|
|
|
23
87
|
for (const key of Object.keys(defaultSchema)) {
|
|
@@ -28,7 +92,7 @@ const getDefaultSchema = (name: string) => {
|
|
|
28
92
|
) {
|
|
29
93
|
defaultSchema[key] = getDefaultSchema(defaultSchema[key].schema);
|
|
30
94
|
}
|
|
31
|
-
if (defaultSchema[key]
|
|
95
|
+
if (Array.isArray(defaultSchema[key])) {
|
|
32
96
|
for (const i in defaultSchema[key]) {
|
|
33
97
|
if (
|
|
34
98
|
defaultSchema[key][i] &&
|
|
@@ -45,38 +109,71 @@ const getDefaultSchema = (name: string) => {
|
|
|
45
109
|
};
|
|
46
110
|
|
|
47
111
|
const getSchemaThumbnails = (name: string, theme?: string) => {
|
|
48
|
-
|
|
112
|
+
const allSchemas = getAllSchemas();
|
|
113
|
+
// @ts-expect-error TODO: fix this, before was `any`
|
|
114
|
+
if (!allSchemas[name]?.thumbnails) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
49
117
|
|
|
118
|
+
// @ts-expect-error TODO: fix this, before was `any`
|
|
50
119
|
return theme && allSchemas[name].thumbnails[theme] ? allSchemas[name].thumbnails[theme] : allSchemas[name].thumbnails;
|
|
51
120
|
};
|
|
52
121
|
|
|
53
|
-
const getTemplate = (name: string) =>
|
|
122
|
+
const getTemplate = (name: string) => {
|
|
123
|
+
const schemas = getUISchemas();
|
|
124
|
+
return schemas.templates[name];
|
|
125
|
+
};
|
|
54
126
|
|
|
55
|
-
const getDefaultTemplate = (name: string) =>
|
|
127
|
+
const getDefaultTemplate = (name: string) => {
|
|
128
|
+
const schemas = getUISchemas();
|
|
129
|
+
return schemas.templates[name].default;
|
|
130
|
+
};
|
|
56
131
|
|
|
57
|
-
const getFormTemplates = (): Record<string, ISchema> =>
|
|
132
|
+
const getFormTemplates = (): Record<string, ISchema> => {
|
|
133
|
+
const formSchemas = getFormSchemas();
|
|
134
|
+
return formSchemas?.templates || {};
|
|
135
|
+
};
|
|
58
136
|
|
|
59
|
-
const getFormTemplate = (name: string): ISchema | undefined =>
|
|
137
|
+
const getFormTemplate = (name: string): ISchema | undefined => {
|
|
138
|
+
const formSchemas = getFormSchemas();
|
|
139
|
+
return formSchemas?.templates?.[name];
|
|
140
|
+
};
|
|
60
141
|
|
|
61
|
-
const getDefaultFormTemplate = (name: string): Record<string, any> | undefined =>
|
|
142
|
+
const getDefaultFormTemplate = (name: string): Record<string, any> | undefined => {
|
|
143
|
+
const formSchemas = getFormSchemas();
|
|
144
|
+
return formSchemas?.templates?.[name]?.default;
|
|
145
|
+
};
|
|
62
146
|
|
|
63
|
-
|
|
64
|
-
formSchemas
|
|
147
|
+
function getSchemaFormCategories(): { label: string; value: string; featured?: boolean }[] {
|
|
148
|
+
const formSchemas = getFormSchemas();
|
|
149
|
+
return formSchemas?.categories || [];
|
|
150
|
+
}
|
|
65
151
|
|
|
66
|
-
const getFormTemplateCategories = (): { label: string; value: string }[] =>
|
|
152
|
+
const getFormTemplateCategories = (): { label: string; value: string }[] => {
|
|
153
|
+
const formSchemas = getFormSchemas();
|
|
154
|
+
return formSchemas?.templateCategories || [];
|
|
155
|
+
};
|
|
67
156
|
|
|
68
|
-
const getTemplateThumbnails = (name: string, theme?: string) => {
|
|
69
|
-
|
|
157
|
+
const getTemplateThumbnails = (name: string, theme?: string): any => {
|
|
158
|
+
const schemas = getUISchemas();
|
|
159
|
+
if (!schemas.templates?.[name]?.thumbnails) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
70
162
|
|
|
71
|
-
return theme && schemas.templates[name]
|
|
72
|
-
? schemas.templates[name]
|
|
73
|
-
: schemas.templates[name]
|
|
163
|
+
return theme && schemas.templates?.[name]?.thumbnails?.[theme]
|
|
164
|
+
? schemas.templates?.[name]?.thumbnails?.[theme]
|
|
165
|
+
: schemas.templates?.[name]?.thumbnails;
|
|
74
166
|
};
|
|
75
167
|
|
|
76
|
-
const getFormTemplateThumbnails = (name: string): Record<string, string> | null =>
|
|
77
|
-
|
|
168
|
+
const getFormTemplateThumbnails = (name: string): Record<string, string> | null => {
|
|
169
|
+
const formSchemas = getFormSchemas();
|
|
170
|
+
return formSchemas?.templates?.[name]?.thumbnails || null;
|
|
171
|
+
};
|
|
78
172
|
|
|
79
|
-
const getDataPackSchema = (name: string) =>
|
|
173
|
+
const getDataPackSchema = (name: string) => {
|
|
174
|
+
const contentTypesSchemas = getContentTypesSchemas();
|
|
175
|
+
return contentTypesSchemas.dataPacks[name];
|
|
176
|
+
};
|
|
80
177
|
|
|
81
178
|
const getDisplayName = (component: string): string => {
|
|
82
179
|
const schema = getSchema(component);
|
|
@@ -89,7 +186,7 @@ const getSchemaType = (component: string) => {
|
|
|
89
186
|
};
|
|
90
187
|
|
|
91
188
|
const getTemplateType = (template: string) => {
|
|
92
|
-
const { type } = getTemplate(template);
|
|
189
|
+
const { type } = getTemplate(template) || {};
|
|
93
190
|
return type;
|
|
94
191
|
};
|
|
95
192
|
|
|
@@ -98,13 +195,22 @@ const getTemplateDisplayName = (template: string) => {
|
|
|
98
195
|
return schema ? schema.displayName : undefined;
|
|
99
196
|
};
|
|
100
197
|
|
|
101
|
-
const getMenuItems = (type: string): { fields: any[] } | undefined =>
|
|
198
|
+
const getMenuItems = (type: string): { fields: any[] } | undefined => {
|
|
199
|
+
const schemasConfig = getSchemasConfig();
|
|
200
|
+
// @ts-expect-error TODO: fix this, before was `any`
|
|
201
|
+
return schemasConfig.menuItems[type];
|
|
202
|
+
};
|
|
102
203
|
|
|
103
|
-
const filterByCategory = (options: any, category: string) =>
|
|
104
|
-
|
|
204
|
+
const filterByCategory = (options: any, category: string) => {
|
|
205
|
+
const allSchemas = getAllSchemas();
|
|
206
|
+
// @ts-expect-error TODO: fix this, before was `any`
|
|
207
|
+
return options.filter((option: any) => allSchemas[option]?.category === category);
|
|
208
|
+
};
|
|
105
209
|
|
|
106
210
|
const getModuleCategories = (moduleList: string[]): ModuleCategoryInfo[] => {
|
|
107
211
|
const categories: string[] = [];
|
|
212
|
+
const schemasConfig = getSchemasConfig();
|
|
213
|
+
const moduleCategories = schemasConfig.moduleCategories || [];
|
|
108
214
|
|
|
109
215
|
const allCategory: ModuleCategoryInfo = {
|
|
110
216
|
label: "All",
|
|
@@ -118,6 +224,7 @@ const getModuleCategories = (moduleList: string[]): ModuleCategoryInfo[] => {
|
|
|
118
224
|
const foundCategory = moduleCategories.find((category: ModuleCategoryInfo) => category.value === categoryValue);
|
|
119
225
|
|
|
120
226
|
if (foundCategory) {
|
|
227
|
+
// @ts-expect-error TODO: fix this, before was `any`
|
|
121
228
|
categories.push(foundCategory);
|
|
122
229
|
}
|
|
123
230
|
}
|
|
@@ -145,6 +252,7 @@ const getModuleStyles = (module: string): any[] => {
|
|
|
145
252
|
|
|
146
253
|
const getNavigationModules = (): Record<string, any[]> => {
|
|
147
254
|
const navigationModules: Record<string, any[]> = { header: [], footer: [] };
|
|
255
|
+
const schemas = getUISchemas();
|
|
148
256
|
Object.keys(schemas.modules).forEach((key: string) => {
|
|
149
257
|
const moduleType = schemas.modules[key].type;
|
|
150
258
|
if (["header", "footer"].includes(moduleType)) {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const schemas = config.schemas.contentTypes;
|
|
1
|
+
import { schemasService } from "@ax/services";
|
|
4
2
|
|
|
5
3
|
const getStructuredDataFromPage = (site: any) => site.filter((data: any) => data.fromPage);
|
|
6
4
|
|
|
@@ -9,18 +7,49 @@ const getCurrentPageStructuredData = (template: string, structuredDataFromPage:
|
|
|
9
7
|
(data: any) => !!data.schema.templates.find((relatedTemplate: string) => relatedTemplate === template),
|
|
10
8
|
);
|
|
11
9
|
|
|
12
|
-
const getStructuredDataTitle = (name: string): string =>
|
|
10
|
+
const getStructuredDataTitle = (name: string): string => {
|
|
11
|
+
if (!schemasService.isLoaded()) {
|
|
12
|
+
return "";
|
|
13
|
+
}
|
|
14
|
+
const schemas = schemasService.getSchemas().contentTypes;
|
|
15
|
+
// Asumiendo que structuredData está en contentTypes... TODO: fix the type...
|
|
16
|
+
const structuredData = (schemas as any).structuredData;
|
|
17
|
+
return structuredData?.[name]?.title || "";
|
|
18
|
+
};
|
|
13
19
|
|
|
14
|
-
const isStructuredDataFromPage = (name: string): boolean =>
|
|
20
|
+
const isStructuredDataFromPage = (name: string): boolean => {
|
|
21
|
+
if (!schemasService.isLoaded()) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const schemas = schemasService.getSchemas().contentTypes;
|
|
25
|
+
const structuredData = (schemas as any).structuredData;
|
|
26
|
+
return structuredData?.[name]?.fromPage || false;
|
|
27
|
+
};
|
|
15
28
|
|
|
16
|
-
const isGlobalStructuredData = (name: string): boolean =>
|
|
29
|
+
const isGlobalStructuredData = (name: string): boolean => {
|
|
30
|
+
if (!schemasService.isLoaded()) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const schemas = schemasService.getSchemas().contentTypes;
|
|
34
|
+
const structuredData = (schemas as any).structuredData;
|
|
35
|
+
return !structuredData?.[name]?.local;
|
|
36
|
+
};
|
|
17
37
|
|
|
18
38
|
const getGlobalPageTypes = (): Record<string, string>[] => {
|
|
19
|
-
|
|
39
|
+
if (!schemasService.isLoaded()) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const schemas = schemasService.getSchemas().contentTypes;
|
|
44
|
+
const structuredData = (schemas as any).structuredData;
|
|
45
|
+
if (!structuredData) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
20
48
|
const keys = Object.keys(structuredData);
|
|
21
49
|
const globalPageTypes = keys.reduce((arr: Record<string, string>[], type: string) => {
|
|
22
50
|
const title = structuredData[type].title;
|
|
23
51
|
const isGlobalPage = structuredData[type].fromPage && !structuredData[type].local;
|
|
52
|
+
// biome-ignore lint/performance/noAccumulatingSpread: TODO: fix this
|
|
24
53
|
return isGlobalPage ? [...arr, { type, title }] : arr;
|
|
25
54
|
}, []);
|
|
26
55
|
return globalPageTypes;
|