@griddo/cx 1.75.178 → 1.75.180

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.
Files changed (72) hide show
  1. package/README.md +22 -14
  2. package/build/index.js +49 -0
  3. package/gatsby-browser.tsx +140 -0
  4. package/gatsby-config.ts +40 -0
  5. package/gatsby-node.ts +130 -0
  6. package/gatsby-ssr.tsx +63 -0
  7. package/index.js +4 -0
  8. package/package.json +119 -100
  9. package/scripts/build-reset.ts +9 -0
  10. package/scripts/griddo-exporter.ts +302 -0
  11. package/src/components/Head.tsx +207 -0
  12. package/src/components/template.tsx +90 -0
  13. package/src/components/types.ts +35 -0
  14. package/src/components/utils.ts +138 -0
  15. package/src/html.tsx +31 -0
  16. package/src/services/auth.ts +64 -0
  17. package/src/services/distributors.ts +153 -0
  18. package/src/services/domains.ts +27 -0
  19. package/src/services/navigation.ts +169 -0
  20. package/src/services/robots.ts +64 -0
  21. package/src/services/settings.ts +52 -0
  22. package/src/services/sites.ts +199 -0
  23. package/src/services/store-with-for-loop.ts +513 -0
  24. package/src/services/store-with-promise-all.ts +515 -0
  25. package/src/services/store.ts +513 -0
  26. package/src/types/api.ts +155 -0
  27. package/src/types/global.ts +72 -0
  28. package/src/types/navigation.ts +25 -0
  29. package/src/types/pages.ts +145 -0
  30. package/src/types/sites.ts +64 -0
  31. package/src/types/templates.ts +11 -0
  32. package/src/utils/api.ts +326 -0
  33. package/src/utils/cache.ts +114 -0
  34. package/src/utils/domains.ts +32 -0
  35. package/src/utils/folders.ts +147 -0
  36. package/src/utils/instance.ts +71 -0
  37. package/src/utils/pages.ts +534 -0
  38. package/src/utils/searches.ts +102 -0
  39. package/src/utils/shared.ts +131 -0
  40. package/src/utils/sites.ts +280 -0
  41. package/.babelrc +0 -7
  42. package/LICENSE +0 -1
  43. package/gatsby-browser.js +0 -115
  44. package/gatsby-config.js +0 -38
  45. package/gatsby-node.js +0 -273
  46. package/gatsby-ssr.js +0 -43
  47. package/scripts/griddo-exporter.js +0 -133
  48. package/src/api/index.js +0 -172
  49. package/src/components/template.js +0 -261
  50. package/src/html.js +0 -30
  51. package/src/images/readme.md +0 -1
  52. package/src/scripts/build-reset.js +0 -12
  53. package/src/services/auth.js +0 -44
  54. package/src/services/distributors.js +0 -85
  55. package/src/services/domains.js +0 -16
  56. package/src/services/navigation.js +0 -104
  57. package/src/services/robots.js +0 -37
  58. package/src/services/settings.js +0 -25
  59. package/src/services/sites.js +0 -110
  60. package/src/utils/cache.js +0 -70
  61. package/src/utils/component-lib-helpers.js +0 -56
  62. package/src/utils/dataLayer.js +0 -47
  63. package/src/utils/delay.js +0 -5
  64. package/src/utils/domains.js +0 -24
  65. package/src/utils/folders.js +0 -123
  66. package/src/utils/helpers.js +0 -144
  67. package/src/utils/index.js +0 -44
  68. package/src/utils/package.js +0 -20
  69. package/src/utils/pages.js +0 -236
  70. package/src/utils/searches.js +0 -62
  71. package/src/utils/sites.js +0 -207
  72. package/static/griddo-full-logo.png +0 -0
@@ -1,110 +0,0 @@
1
- require('dotenv').config();
2
- const api = require('./../api');
3
-
4
- const baseURL = process.env.API_URL;
5
- const withURI = `${baseURL}/site/`;
6
- const ENDPOINTS = {
7
- GET_ALL: `${baseURL}/sites/all`,
8
- GET_PAGE: [`${baseURL}/page/`, ''],
9
- INFO: [`${withURI}`, '/all'],
10
- LANGUAGES: [`${withURI}`, '/languages'],
11
- BUILD_START: [`${withURI}`, '/build/start'],
12
- BUILD_END: [`${withURI}`, '/build/end'],
13
- GET_DISTRIBUTOR_DATA: [`${withURI}`, '/distributor'],
14
- GET_SITEMAP: [`${withURI}`, '/sitemap'],
15
- SOCIALS: [`${withURI}`, '/socials'],
16
- GET_PAGES: [`${withURI}`, '/pages?pagination=false'],
17
- };
18
-
19
- class SitesService {
20
- static async getAll() {
21
- const { GET_ALL } = ENDPOINTS;
22
- const response = await api.get(GET_ALL);
23
- return response;
24
- }
25
-
26
- static async getPage(id, cache) {
27
- const {
28
- GET_PAGE: [prefix, suffix],
29
- } = ENDPOINTS;
30
- const dynamicURL = `${prefix}${id}${suffix}`;
31
- const response = await api.get(dynamicURL, null, cache);
32
- return response;
33
- }
34
-
35
- static async getInfo(id, cached) {
36
- const {
37
- INFO: [prefix, suffix],
38
- } = ENDPOINTS;
39
- const dynamicURL = `${prefix}${id}${suffix}`;
40
- const response = await api.get(dynamicURL, null, cached);
41
- return response;
42
- }
43
-
44
- static async getLanguages(id, cached) {
45
- const {
46
- LANGUAGES: [prefix, suffix],
47
- } = ENDPOINTS;
48
- const dynamicURL = `${prefix}${id}${suffix}`;
49
- const response = await api.get(dynamicURL, null, cached);
50
- return response;
51
- }
52
-
53
- static async startPageRender(id) {
54
- const {
55
- BUILD_START: [prefix, suffix],
56
- } = ENDPOINTS;
57
- const dynamicURL = `${prefix}${id}${suffix}`;
58
- const response = await api.get(dynamicURL);
59
- return response;
60
- }
61
-
62
- static async endPageRender(id, body) {
63
- const {
64
- BUILD_END: [prefix, suffix],
65
- } = ENDPOINTS;
66
- const dynamicURL = `${prefix}${id}${suffix}`;
67
- const response = await api.post(dynamicURL, body);
68
- return response;
69
- }
70
-
71
- static async getDistributorData(page, body, cached) {
72
- const {
73
- GET_DISTRIBUTOR_DATA: [prefix, suffix],
74
- } = ENDPOINTS;
75
- const { language: lang, site: id } = page;
76
-
77
- const dynamicURL = `${prefix}${id}${suffix}`;
78
- const response = await api.post(dynamicURL, body, { lang }, cached);
79
- return response;
80
- }
81
-
82
- static async getSiteMap(id) {
83
- const {
84
- GET_SITEMAP: [prefix, suffix],
85
- } = ENDPOINTS;
86
- const dynamicURL = `${prefix}${id}${suffix}`;
87
- const response = await api.get(dynamicURL);
88
- return response;
89
- }
90
-
91
- static async getSocials(id, cached) {
92
- const {
93
- SOCIALS: [prefix, suffix],
94
- } = ENDPOINTS;
95
- const dynamicURL = `${prefix}${id}${suffix}`;
96
- const response = await api.get(dynamicURL, null, cached);
97
- return response;
98
- }
99
-
100
- static async getPages(id, cached = false) {
101
- const {
102
- GET_PAGES: [prefix, suffix],
103
- } = ENDPOINTS;
104
- const dynamicURL = `${prefix}${id}${suffix}`;
105
- const response = await api.get(dynamicURL, null, cached);
106
- return response;
107
- }
108
- }
109
-
110
- exports.default = SitesService;
@@ -1,70 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const crypto = require('crypto');
4
-
5
- const apiCacheDirectory = path.resolve(__dirname, './../../apiCache');
6
- const gatsbyCacheDirectory = path.resolve(__dirname, './../../.cache');
7
- const siteHashFilename = `${apiCacheDirectory}/siteHash.json`;
8
-
9
- const initCache = () => {
10
- // TODO: Make a domain-based cache to store and restore
11
- if (fs.existsSync(gatsbyCacheDirectory)) {
12
- fs.rmSync(gatsbyCacheDirectory, {
13
- force: true,
14
- recursive: true,
15
- });
16
- }
17
- if (!fs.existsSync(apiCacheDirectory)) {
18
- fs.mkdirSync(apiCacheDirectory);
19
- }
20
- };
21
-
22
- const generateFilename = petition => {
23
- const hashSum = crypto.createHash('sha256');
24
- hashSum.update(JSON.stringify(petition));
25
- return `${apiCacheDirectory}/${hashSum.digest('hex')}`;
26
- };
27
-
28
- const saveCache = (petition, content = '') => {
29
- const rightContent =
30
- typeof content === 'object' ? JSON.stringify(content) : content;
31
- fs.writeFileSync(generateFilename(petition), rightContent, 'utf8');
32
- };
33
-
34
- const getCache = petition => {
35
- try {
36
- const content = fs.readFileSync(generateFilename(petition));
37
- return JSON.parse(content);
38
- } catch {
39
- return null;
40
- }
41
- };
42
-
43
- const getHashSites = () => {
44
- try {
45
- return JSON.parse(fs.readFileSync(siteHashFilename)) || {};
46
- } catch {
47
- return {};
48
- }
49
- };
50
-
51
- const updatedSiteHash = (siteId, siteHash) => {
52
- const allHash = getHashSites();
53
-
54
- const lastHash = allHash[siteId];
55
- const currentHash = siteHash || lastHash || new Date().valueOf();
56
-
57
- if (currentHash !== lastHash) {
58
- allHash[siteId] = currentHash;
59
- fs.writeFileSync(siteHashFilename, JSON.stringify(allHash), 'utf8');
60
- }
61
-
62
- return currentHash;
63
- };
64
-
65
- module.exports = {
66
- initCache,
67
- saveCache,
68
- getCache,
69
- updatedSiteHash,
70
- };
@@ -1,56 +0,0 @@
1
- // TODO: Unify with AX functions
2
- const path = require('path');
3
- const findUp = require('find-up');
4
-
5
- const pkgDir = require('pkg-dir');
6
-
7
- const isComponentLibraryEnv = __dirname.includes('node_modules');
8
-
9
- const resolveComponentsPath = (customPath = '') =>
10
- isComponentLibraryEnv
11
- ? path.resolve(pkgDir.sync(__dirname), '../../../', customPath)
12
- : path.resolve(pkgDir.sync(__dirname), '../griddo-components', customPath);
13
-
14
- const getComponentsJSConfig = () => {
15
- const jsConfigPath = findUp.sync('jsconfig.json', {
16
- cwd: resolveComponentsPath(),
17
- });
18
- const tsConfigPath = findUp.sync('tsconfig.json', {
19
- cwd: resolveComponentsPath(),
20
- });
21
-
22
- return tsConfigPath || jsConfigPath || false;
23
- };
24
-
25
- const getComponentsLibAliases = () => {
26
- // return { components: `${resolveComponentsPath()}/src/index.js` };
27
-
28
- const xsConfig = require(getComponentsJSConfig());
29
-
30
- return Object.keys(xsConfig?.compilerOptions?.paths).reduce(
31
- (currentAlias, pathKey) => {
32
- const [aliasKey] = pathKey.split('/');
33
- const [pathAtJsConfig] = xsConfig?.compilerOptions?.paths[pathKey];
34
-
35
- const [relativePathToDir] = pathAtJsConfig.split('/*');
36
-
37
- const absolutePath = resolveComponentsPath(relativePathToDir);
38
-
39
- return {
40
- ...currentAlias,
41
- [aliasKey]: absolutePath,
42
- };
43
- },
44
- {
45
- components: `${resolveComponentsPath()}/src/index.js`,
46
- }
47
- );
48
- };
49
-
50
- module.exports = {
51
- isComponentLibraryEnv,
52
- resolveComponentsPath,
53
- getComponentsJSConfig,
54
- getComponentsLibAliases,
55
- projectAliases: getComponentsLibAliases(),
56
- };
@@ -1,47 +0,0 @@
1
- // import parse from 'html-react-parser';
2
-
3
- const composeAnalytics = (page, generateAutomaticDimensions = null) => {
4
- const {
5
- pageContext: {
6
- siteScript: siteScriptBulk,
7
- page: { dimensions },
8
- },
9
- } = page;
10
-
11
- const analyticsScript = siteScriptBulk ? siteScriptBulk.trim() : '';
12
-
13
- //Las dimensiones o DataLayer
14
- const dynamicValuePrefix = '__SCRIPT:';
15
- const dimensionValues = dimensions?.values || {};
16
- const automaticDimensionValues = generateAutomaticDimensions
17
- ? generateAutomaticDimensions(page)
18
- : {};
19
- const allDimensionsValues = {
20
- ...dimensionValues,
21
- ...automaticDimensionValues,
22
- };
23
- const allDimensions = [];
24
- for (const dimension of Object.keys(allDimensionsValues)) {
25
- const dimensionValue = allDimensionsValues[dimension];
26
- allDimensions.push(
27
- `"${dimension}":${
28
- dimensionValue?.startsWith(dynamicValuePrefix)
29
- ? `${dimensionValue.slice(
30
- dynamicValuePrefix.length,
31
- dimensionValue.endsWith(';') ? -1 : dimensionValue.length
32
- )}`
33
- : `"${dimensionValue}"`
34
- }`
35
- );
36
- }
37
-
38
- const analyticsDimensions = allDimensions.length
39
- ? `{${allDimensions.join(',')}}`
40
- : null;
41
- return {
42
- analyticsScript,
43
- analyticsDimensions,
44
- };
45
- };
46
-
47
- export { composeAnalytics };
@@ -1,5 +0,0 @@
1
- const delay = ms => new Promise(res => setTimeout(res, ms));
2
-
3
- module.exports = {
4
- delay,
5
- };
@@ -1,24 +0,0 @@
1
- const AuthService = require('../services/auth').default;
2
- const DomainsService = require('./../services/domains').default;
3
-
4
- const getDomainHostname = url => {
5
- const urlObject = new URL(url);
6
- return urlObject.hostname;
7
- };
8
-
9
- const getDomainSlugs = domains =>
10
- domains
11
- .filter(domain => !!domain.slug)
12
- .map(domain => domain.slug.replace('/',''))
13
- .reduce((acc, item) => acc.indexOf(item) < 0 ? [...acc, item] : acc, []);
14
-
15
- const findDomains = async () => {
16
- await AuthService.login();
17
- const domains = await DomainsService.getAll();
18
-
19
- return getDomainSlugs(domains);
20
- };
21
-
22
- exports.getDomainHostname = getDomainHostname;
23
- exports.getDomainSlugs = getDomainSlugs;
24
- exports.findDomains = findDomains;
@@ -1,123 +0,0 @@
1
- const path = require('path');
2
- const fs = require('fs-extra');
3
- const helpers = require('./helpers');
4
- const { resolveComponentsPath } = require('./component-lib-helpers');
5
-
6
- const deleteSites = async updatedSites => {
7
- for await (const site of updatedSites) {
8
- for (const domain of site.domains) {
9
- const mappedDomain = Object.values(domain)[0];
10
- const dir = path.resolve(__dirname, `../../dist${mappedDomain}`);
11
- const pageDataDir = path.resolve(
12
- __dirname,
13
- `../../assets/page-data${mappedDomain}`
14
- );
15
-
16
- helpers.log('info', 'SITE DIR', dir);
17
- helpers.log('info', 'PAGE DATA DIR', pageDataDir);
18
-
19
- // delete directory recursively
20
- if (!fs.existsSync(dir)) return;
21
-
22
- await fs.rmdir(dir, { recursive: true }, err => {
23
- if (err) {
24
- throw err;
25
- }
26
- helpers.log('success', `${dir} IS DELETED!`);
27
- });
28
-
29
- if (!fs.existsSync(pageDataDir)) return;
30
-
31
- await fs.rmdir(pageDataDir, { recursive: true }, err => {
32
- if (err) {
33
- throw err;
34
- }
35
- helpers.log('success', `${pageDataDir} IS DELETED!`);
36
- });
37
- }
38
- }
39
- };
40
-
41
- const updateDist = async () => {
42
- const isGriddoExporter =
43
- process.env.GRIDDO_EXPORTER && process.env.GRIDDO_EXPORTER === 'on';
44
-
45
- const src = './public';
46
- const dest = './dist';
47
-
48
- const domainDestPath = `${dest}/${process.env.DOMAIN}`;
49
-
50
- const files = fs
51
- .readdirSync(src)
52
- .filter(
53
- fn => fn.endsWith('.js') || fn.endsWith('.json') || fn.endsWith('.css')
54
- );
55
-
56
- const assetsDest = './assets';
57
- const pageDataSrc = `${src}/page-data`;
58
- const pageDataDest = `${assetsDest}/page-data`;
59
-
60
- const projectStaticSrc = './static';
61
- const projectStaticDest = assetsDest;
62
-
63
- const gatsbyStaticSrc = `${dest}/static`;
64
- const gatsbyStaticDest = `${assetsDest}/static`;
65
-
66
- try {
67
- fs.mkdirSync(assetsDest, { recursive: true });
68
- fs.copySync(src, dest);
69
- if (process.env.HAS_ASSET_DOMAIN) {
70
- fs.copySync(pageDataSrc, pageDataDest);
71
- fs.copySync(projectStaticSrc, projectStaticDest, { overwrite: false });
72
- fs.copySync(gatsbyStaticSrc, gatsbyStaticDest,{overwrite: false});
73
- fs.copySync(projectStaticSrc, domainDestPath, { overwrite: false });
74
-
75
- files.map(async file => {
76
- const fileSrc = `${src}/${file}`;
77
- const fileDest = `${assetsDest}/${file}`;
78
- fs.copySync(fileSrc, fileDest);
79
- });
80
- }
81
-
82
- if (isGriddoExporter) fs.rmSync(src, { recursive: true });
83
-
84
- helpers.log('success', 'SUCCESS!');
85
- } catch (err) {
86
- console.error(err);
87
- }
88
- };
89
-
90
- const prepareServe = async () => {
91
- const src = './dist';
92
- const dest = './public';
93
-
94
- try {
95
- await fs.copy(src, dest);
96
- helpers.log('info', 'PUBLIC COPIED');
97
- } catch (err) {
98
- helpers.log('error', err);
99
- }
100
- };
101
-
102
- const prepareStaticFolder = async () => {
103
- const src = resolveComponentsPath('static');
104
- const dest = './static';
105
-
106
- const files = fs.readdirSync(src);
107
-
108
- try {
109
- files.map(async file => {
110
- const fileSrc = `${src}/${file}`;
111
- const fileDest = `${dest}/${file}`;
112
- fs.copySync(fileSrc, fileDest);
113
- });
114
- helpers.log('success', 'Components static files copied!');
115
- } catch (err) {
116
- console.error(err);
117
- }
118
- };
119
-
120
- exports.deleteSites = deleteSites;
121
- exports.updateDist = updateDist;
122
- exports.prepareServe = prepareServe;
123
- exports.prepareStaticFolder = prepareStaticFolder;
@@ -1,144 +0,0 @@
1
- const chalk = require('chalk');
2
- const LOGS = process.env.LOGS && JSON.parse(process.env.LOGS);
3
-
4
- // Terminal Log
5
- const log = (state, message, data) => {
6
- const color = {
7
- error: 'red',
8
- info: 'cyan',
9
- success: 'green',
10
- warning: 'yellow',
11
- };
12
- const msg = {
13
- error: 'ERROR',
14
- info: 'INFO',
15
- success: 'SUCCESS',
16
- warning: '! ',
17
- };
18
-
19
- LOGS !== false &&
20
- state !== 'error' &&
21
- console.log(
22
- `${chalk[color[state]](msg[state])} ${message} ${
23
- data ? JSON.stringify(data, null, 2) : ''
24
- }`
25
- );
26
- };
27
-
28
- // Format image
29
- const formatImage = (image, width, height, format = 'jpg') => {
30
- const url = image?.url || image;
31
- if (!url) return null;
32
- const isCloudinary = url.split('/')[2].includes('cloudinary.com');
33
- return isCloudinary
34
- ? addCloudinaryParams(url, `c_fill,w_${width},h_${height}`)
35
- : addGriddoDamParams(url, `f/${format}/w/${width}/h/${height}`);
36
- };
37
-
38
- // Format Griddo DAM image
39
- const addGriddoDamParams = (image, params) => {
40
- const splittedUrl = image.split('/');
41
- return `${splittedUrl.slice(0, -1).join('/')}/${params}/${
42
- splittedUrl.slice(-1)[0]
43
- }`;
44
- };
45
-
46
- // Take a cloudinary url and add query params
47
- const addCloudinaryParams = (image, params) => {
48
- const plainUrl = image.replace('https://', '');
49
- const head = plainUrl.split('/').slice(0, 4).join('/');
50
- const fullId = plainUrl.replace(head, '');
51
- return `https://${head}/${params}${fullId}`;
52
- };
53
-
54
- const getPageMetaData = params => {
55
- const {
56
- title,
57
- metaTitle,
58
- metaDescription,
59
- canonicalURL,
60
- locale,
61
- url,
62
- isIndexed,
63
- follow,
64
- metasAdvanced,
65
- pageLanguages,
66
- fullUrl,
67
- } = params;
68
-
69
- const metasAdvancedList =
70
- metasAdvanced
71
- ?.split(',')
72
- .filter(item => !!item)
73
- .map(item => item.trim().toLowerCase()) || [];
74
-
75
- return {
76
- title: (metaTitle || title || '').trim(),
77
- description: metaDescription,
78
- canonical:
79
- canonicalURL && canonicalURL.trim() && canonicalURL !== fullUrl
80
- ? canonicalURL.trim()
81
- : isIndexed
82
- ? fullUrl
83
- : null,
84
- locale,
85
- url,
86
- index: isIndexed ? 'index' : 'noindex',
87
- follow: follow ? 'follow' : 'nofollow',
88
- translate: metasAdvancedList.includes('notranslate') ? 'notranslate' : '',
89
- metasAdvanced: metasAdvancedList
90
- .filter(item => item !== 'notranslate')
91
- .join(),
92
- pageLanguages,
93
- };
94
- };
95
-
96
- const getOpenGraph = ({
97
- socialTitle,
98
- socialDescription,
99
- socialImage,
100
- }) => ({
101
- type: 'website',
102
- title: socialTitle,
103
- description: socialDescription,
104
- image: formatImage(socialImage, 1280, 768),
105
- twitterImage: formatImage(socialImage, 1280, 768),
106
- });
107
-
108
- const getMultiPageElements = distributorTemplate =>
109
- new Promise(resolve => {
110
- const getMultiPageComponent = (template, level = 0) => {
111
- if (!template || typeof template !== 'object') return;
112
- for (let key in template) {
113
- const currentComponent = template[key];
114
- if (!currentComponent || typeof currentComponent !== 'object') continue;
115
- if (
116
- !JSON.stringify(currentComponent).includes(
117
- '"hasGriddoMultiPage":true'
118
- )
119
- )
120
- continue;
121
- const { component, hasGriddoMultiPage, elements } = currentComponent;
122
- if (component && hasGriddoMultiPage) {
123
- resolve(elements || []);
124
- }
125
- getMultiPageComponent(currentComponent, level + 1);
126
- }
127
- if (!level) resolve(null);
128
- };
129
- getMultiPageComponent([distributorTemplate]);
130
- });
131
-
132
- const cleanCommaSeparated = x =>
133
- x
134
- .split(',')
135
- .map(item => item.trim())
136
- .filter(item => !!item)
137
- .join(',');
138
-
139
- exports.getOpenGraph = getOpenGraph;
140
- exports.getPageMetaData = getPageMetaData;
141
- exports.log = log;
142
- exports.getMultiPageElements = getMultiPageElements;
143
- exports.cleanCommaSeparated = cleanCommaSeparated;
144
- exports.formatImage = formatImage;
@@ -1,44 +0,0 @@
1
- const DEFAULT_ITEMS_PER_PAGE_FOR_LIST_TEMPLATES = 25;
2
-
3
- const pageUtils = require('./pages.js');
4
-
5
- const getPagePath = (site, fullPath) => `${site}${fullPath}`;
6
-
7
- const getPage = (itemsPerPage, pages, page) =>
8
- pages?.slice(itemsPerPage * (page - 1), itemsPerPage * page);
9
-
10
- const getPageCluster = (itemsPerPage, items) => {
11
- let totalPagesCount = Math.ceil(items?.length / itemsPerPage) || 1;
12
- // pageNumbers returns [1, 2, 3, 4, n]
13
- // TODO: Ver por qué pasa esto...
14
- if (totalPagesCount < 0) {
15
- totalPagesCount = 0;
16
- }
17
- const pageNumbers = Array(totalPagesCount)
18
- .fill(0)
19
- .map((x, idx) => idx + 1);
20
-
21
- const result = pageNumbers?.map(x => getPage(itemsPerPage, items, x));
22
- return result;
23
- };
24
-
25
- const getList = distributorTemplate => {
26
- const allItems = distributorTemplate?.queriedItems;
27
- // get itemsPerPage from templaet info
28
- const itemsPerPage =
29
- distributorTemplate?.itemsPerPage ||
30
- DEFAULT_ITEMS_PER_PAGE_FOR_LIST_TEMPLATES;
31
- // return an array of array pages
32
- // [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]
33
- // each array [1, 2, 3] represent a queriedItems
34
- const pageClusters = getPageCluster(itemsPerPage, allItems);
35
-
36
- return pageClusters;
37
- };
38
-
39
- exports.default = {
40
- getPagePath,
41
- getList,
42
- renderPage: pageUtils.renderPage,
43
- renderListPages: pageUtils.renderListPages,
44
- };
@@ -1,20 +0,0 @@
1
- const packageInfo = require('../../package.json');
2
-
3
- const getComponentsVersion = () => {
4
- const {
5
- dependencies,
6
- version,
7
- } = packageInfo;
8
-
9
- const componentsKey = dependencies.components ? 'components' : Object.keys(dependencies).find(key => key.endsWith('/components'));
10
- const componentsVersion = componentsKey ? dependencies[componentsKey] : '0.0.0';
11
-
12
- return {
13
- componentsVersion: componentsVersion.split('^').join('').split('@').slice(-1)[0],
14
- griddoVersion: version,
15
- };
16
- };
17
-
18
- module.exports = {
19
- getComponentsVersion,
20
- };