gatsby-core-theme 44.3.0 → 44.4.0-beta.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.
Files changed (42) hide show
  1. package/.ci.yml +2 -0
  2. package/CHANGELOG.md +61 -0
  3. package/gatsby-node.mjs +5 -14
  4. package/package.json +2 -1
  5. package/src/components/molecules/module/module.test.js +1 -1
  6. package/src/context/MainProvider.js +12 -4
  7. package/src/helpers/getters.mjs +0 -64
  8. package/src/helpers/getters.test.js +0 -124
  9. package/src/helpers/path.test.js +1 -33
  10. package/src/helpers/schedule.mjs +1 -91
  11. package/src/helpers/server-data.js +2 -4
  12. package/src/resolver/common.mjs +0 -53
  13. package/src/resolver/common.test.js +1 -124
  14. package/src/resolver/index.mjs +3 -604
  15. package/src/resolver/index.test.js +2 -80
  16. package/src/resolver/modules.mjs +14 -653
  17. package/src/services/api.mjs +1 -133
  18. package/tests/factories/modules/card.factory.js +0 -43
  19. package/tests/factories/modules/content.factory.js +0 -13
  20. package/tests/factories/modules/toplist.factory.js +0 -37
  21. package/package.old.json +0 -98
  22. package/src/constants/searchReleationPickKeys.mjs +0 -92
  23. package/src/helpers/schedule.test.js +0 -1685
  24. package/src/helpers/validateData.mjs +0 -17
  25. package/src/helpers/validateData.test.js +0 -39
  26. package/src/resolver/cryptos.mjs +0 -71
  27. package/src/resolver/cryptos.test.js +0 -27
  28. package/src/resolver/games.mjs +0 -100
  29. package/src/resolver/games.test.js +0 -111
  30. package/src/resolver/modules.test.js +0 -329
  31. package/src/resolver/operators.mjs +0 -165
  32. package/src/resolver/operators.test.js +0 -305
  33. package/src/resolver/page.mjs +0 -111
  34. package/src/resolver/page.test.js +0 -305
  35. package/src/resolver/payment.mjs +0 -28
  36. package/src/resolver/providers.mjs +0 -19
  37. package/src/resolver/relations.mjs +0 -148
  38. package/src/resolver/relations.test.js +0 -193
  39. package/src/resolver/sports-relations.mjs +0 -301
  40. package/src/resolver/sports-relations.test.js +0 -208
  41. package/src/services/fetch.mjs +0 -188
  42. package/tests/factories/modules/modules.factory.js +0 -215
package/.ci.yml CHANGED
@@ -50,6 +50,8 @@ Theme Beta Publish:
50
50
  - git config --global http.sslverify false
51
51
  - git config --global user.email "floyd@gig.com"
52
52
  - git config --global user.name "floyd"
53
+ - echo "@gigmedia:registry=https://registry.npmjs.org/" >> ~/.npmrc
54
+ - echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" >> ~/.npmrc
53
55
  script:
54
56
  - export HUSKY=0
55
57
  - yarn config set cache-folder .yarn
package/CHANGELOG.md CHANGED
@@ -1,3 +1,64 @@
1
+ # [44.4.0-beta.1](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.3.1...v44.4.0-beta.1) (2025-07-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * tm-5551 - add back process anchor fn ([734b3d9](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/734b3d96458fceee2592b9d2e5b43cd51bfd9092))
7
+ * tm-5551 - add chore and body length to commitlint ([6319412](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/6319412012619e1cc335806529d175b4efb5d1a5))
8
+ * tm-5551 - add core-js ad direct dependency ([d8b1fdf](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/d8b1fdf355ddef28b0fc11f0d77a503dae40c63c))
9
+ * tm-5551 - add debug logs to ci ([6c22a1e](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/6c22a1e95c3eacc236269b9fefee7da6b40eb239))
10
+ * tm-5551 - add logging before npm view ([6298d7d](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/6298d7db48d5ab7f2fc5ef98dc77f06e6a2e6a85))
11
+ * tm-5551 - add logging to pipeline ([fa8403d](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/fa8403d2e0f963c78a71324450608a1a4ef3e38f))
12
+ * tm-5551 - add logs for commits in ci ([7520b20](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/7520b20cb1cf6517bc77b794cadcf01e45afff69))
13
+ * tm-5551 - cancel stages for testing ([957ddac](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/957ddac0c486ede96060b696a46f4a198082daaf))
14
+ * tm-5551 - comment site_name in gitlab ci ([ddd4bf3](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/ddd4bf3af1c61d748b7cfc7026d01dc111cccdb4))
15
+ * tm-5551 - force remove node_modules ([b1e02c2](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/b1e02c2d3246ac6dcba2d39038d02769e315e0f3))
16
+ * tm-5551 - move publish-beta to first stage for testing ([f5a8bb8](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/f5a8bb80c8b8a76316abe9755504e7fd0d203375))
17
+ * tm-5551 - readd missing data.json for build ([263e0b5](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/263e0b558560e01b51376217adbe5f1f1a68015e))
18
+ * tm-5551 - remove core-js ([d09f70b](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/d09f70b162d75d0c91bb69b565ed381df10496cb))
19
+ * tm-5551 - remove leftover console.log ([c1b8497](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/c1b8497a1d39f79694ea3c067e066ec0d0b65721))
20
+ * tm-5551 - remove logs from ci ([584e753](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/584e753adc6b3e46b38f52a99d92bc9142acac8d))
21
+ * tm-5551 - remove logs from ci ([84d19a2](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/84d19a2e91fa1e20e454e4638ab6b4ab781e6017))
22
+ * tm-5551 - remove logs from ci ([c24ca12](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/c24ca122c47d664e460d2487997e2dce110a5205))
23
+ * tm-5551 - remove migrate test cases ([705ee7c](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/705ee7ca6559033183a00287d10439ce9c1aa48d))
24
+ * tm-5551 - remove site_name from ci ([b88d4ac](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/b88d4ac0611c3ea4c0127d22786597c2d1942653))
25
+ * tm-5551 - revert lock file to master state ([86db873](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/86db8735ccf4f7a80e3d4724e2662fac0e7e482d))
26
+ * tm-5551 - set body length to 200 ([17f3f52](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/17f3f52cf955399e0015e9e93e05bb98dff2f517))
27
+ * tm-5551 - set max body length ([5104b78](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/5104b783c79276a8c5f44a91a5cc9243a7c7bdb0))
28
+ * tm-5551 - set registry and auth token for beta publish ([919f2d6](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/919f2d6b123e88c5dbef401884edf152ce08b692))
29
+ * tm-5551 - update enigma-middleware ([9c85ed4](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/9c85ed4333772acf076bfeba08ac50ec04e058df))
30
+ * tm-5551 - update enigma-middleware to latest version ([d3f3f67](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/d3f3f6733fe4a233c44c750f650de538444cc4a0))
31
+ * tm-5551 - update lock file ([8113ba4](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/8113ba4fa696f1f2eceb0d9a23f1b11a139f8690))
32
+ * tm-5551 - update lock file ([be32446](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/be324464b7e33dbe80e8c33fc7f3f0276a8d0688))
33
+ * tm-5551 - updating lock file as per master ([fda39bd](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/fda39bd6b811f53d6091cd3d1b7cbb07ed46c655))
34
+
35
+
36
+ * Merge branch 'feat/TM-5551-migrate-build-logic-to-enigma-middleware' into 'beta' ([3621f4b](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/3621f4b129fadd7bae382261f79cfa4315945cbd))
37
+ * Merge branch 'master' into feat/TM-5551-migrate-build-logic-to-enigma-middleware ([db69165](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/db69165a5d1e05eff145161ec47e4eeb365a368e))
38
+ * Merge branch 'master' into feat/TM-5551-migrate-build-logic-to-enigma-middleware ([cb80639](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/cb80639bd72ff9afa79e3396753445321dd322e4))
39
+ * Merge branch 'master' into feat/TM-5551-migrate-build-logic-to-enigma-middleware ([864c1fb](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/864c1fbd675b8840efe93a4766de351df652e58e))
40
+
41
+
42
+ ### Features
43
+
44
+ * tm-5551 - migrate build logic to enigma middleware ([21bbdc6](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/21bbdc6f8f422c3cc8f78efbbc08d8440e10f864))
45
+
46
+
47
+ ### Tests
48
+
49
+ * tm-5551 - add logging to debug build ([6e19e76](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/6e19e76688cb6bded06211adebc7f847704caf93))
50
+
51
+ ## [44.3.1](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.3.0...v44.3.1) (2025-06-30)
52
+
53
+
54
+ ### Bug Fixes
55
+
56
+ * flag module as toplist ([b0715ee](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/b0715ee5aa6ad3d2f9ed86d8f5381b7e67e2181f))
57
+ * move filters to page, flag toplist that has filters ([7f40833](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/7f408336481a5f53febc7eb8504364971d3683d0))
58
+
59
+
60
+ * Merge branch 'tm-5525-toplist-filters' into 'master' ([30427fb](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/30427fbdaa89b0abf48243ad80ed81e1af23047f))
61
+
1
62
  # [44.3.0](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.2.20...v44.3.0) (2025-06-25)
2
63
 
3
64
 
package/gatsby-node.mjs CHANGED
@@ -10,11 +10,11 @@ import chalk from "chalk";
10
10
  import fs from "fs";
11
11
  import { dirname } from "path";
12
12
  import { fileURLToPath } from "url";
13
+ import middleware from "@gigmedia/enigma-middleware";
13
14
  import keygen from "./src/helpers/keygen.mjs";
14
15
  import { getTranslations } from "./src/services/api.mjs";
15
- import { fetchSiteSettings } from "./src/services/fetch.mjs";
16
16
  import { generateTrackerLink } from "./src/helpers/generators.mjs";
17
- import processor, {
17
+ import {
18
18
  processSitemapPages,
19
19
  } from "./src/resolver/index.mjs";
20
20
  import settings from "./src/constants/settings.mjs";
@@ -27,7 +27,7 @@ import { translate, is404Page } from "./src/helpers/getters.mjs";
27
27
  import { getArchivePages, hasArchiveModule } from "./src/resolver/archive.mjs";
28
28
 
29
29
  const __dirname = dirname(fileURLToPath(import.meta.url));
30
- const { cloneDeep, chunk, pick } = loadash;
30
+ const { cloneDeep } = loadash;
31
31
 
32
32
  let preconnectLinks = null;
33
33
  let pages = null;
@@ -62,9 +62,7 @@ let allMarketPrefixes = [];
62
62
  let allMarketSectionsData = null;
63
63
  let schemaData = null;
64
64
  let templatesData = null;
65
- let defaultLanguage = null;
66
65
  const pagesToCreate = [];
67
- const relations = {};
68
66
 
69
67
  // eslint-disable-next-line import/prefer-default-export
70
68
  export const createPages = async (
@@ -78,7 +76,7 @@ export const createPages = async (
78
76
  console.log(chalk.magenta("info") + chalk.whiteBright(" starting processor"));
79
77
 
80
78
  // add data to modules
81
- const processed = processor.run(
79
+ const processed = middleware.processor.run(
82
80
  {
83
81
  ...siteSettingsData,
84
82
  pages: pagesData,
@@ -377,7 +375,7 @@ export const onPreBootstrap = async () => {
377
375
  cryptoBrokersData,
378
376
  countriesData,
379
377
  licensesData,
380
- } = await fetchSiteSettings(process.env.GATSBY_SITE_NAME));
378
+ } = await middleware.getSiteSettings());
381
379
  };
382
380
 
383
381
  export const sourceNodes = async ({
@@ -390,13 +388,6 @@ export const sourceNodes = async ({
390
388
  .map((key) => `language_codes[]=${key.split("_")[1]}`)
391
389
  .join("&");
392
390
 
393
- let defaultMarket = null;
394
- Object.entries(siteSettingsData.site_markets).forEach(([key, value]) => {
395
- if (value.path_prefix === null || value.path_prefix === "") {
396
- defaultMarket = key;
397
- }
398
- });
399
- defaultLanguage = defaultMarket.split("_")[1];
400
391
  translationsData = await getTranslations(process.env.GATSBY_SITE_NAME, keys);
401
392
 
402
393
  // eslint-disable-next-line array-callback-return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "44.3.0",
3
+ "version": "44.4.0-beta.1",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -18,6 +18,7 @@
18
18
  "build-storybook": "cross-env STORYBOOK_IMAGE_CDN_URL=https://cdn.irishluck.ie STORYBOOK_GATSBY_SITE_NAME=norskespilleautomater.com STORYBOOK_TRACKER_LINK_FORMAT_NON_MAIN=[no],[visit],short_name STORYBOOK_TRACKER_LINK_FORMAT_MAIN=[no],[visit],short_name build-storybook"
19
19
  },
20
20
  "dependencies": {
21
+ "@gigmedia/enigma-middleware": "^1.2.4",
21
22
  "@reach/router": "^1.3.3",
22
23
  "@react-icons/all-files": "^4.1.0",
23
24
  "axios": "^0.21.1",
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-restricted-syntax */
1
2
  import React from 'react';
2
3
  import { render, cleanup, waitFor } from '@testing-library/react';
3
4
  import '@testing-library/jest-dom/extend-expect';
@@ -5,7 +6,6 @@ import '@testing-library/jest-dom/extend-expect';
5
6
  import '~tests/helpers/match-media.mock';
6
7
  import Module from '.';
7
8
  import { getListContentData, contentTableOne } from '~tests/factories/modules/content.factory';
8
- import { objectsHolder } from '~tests/factories/modules/modules.factory';
9
9
 
10
10
  const getAnchorList = (number = 1) => {
11
11
  function anchor(idNumber) {
@@ -1,13 +1,20 @@
1
1
  /* eslint-disable react/prop-types */
2
- import React, { createContext, useState } from 'react';
2
+ import React, { createContext, useState } from "react";
3
3
 
4
4
  export const Context = createContext();
5
5
 
6
6
  export default (props) => {
7
7
  const { value, children } = props;
8
8
 
9
- const [ showTranslationKeys, setShowTranslationKeys ] = useState(false);
10
-
9
+ const [showTranslationKeys, setShowTranslationKeys] = useState(false);
10
+ const [showFilter, setShowFilter] = useState(false);
11
+ const [topListFilters, setTopListFilters] = useState();
12
+ const topListContext = {
13
+ showFilter,
14
+ setShowFilter,
15
+ topListFilters,
16
+ setTopListFilters,
17
+ };
11
18
  return (
12
19
  <Context.Provider
13
20
  value={{
@@ -15,8 +22,9 @@ export default (props) => {
15
22
  preview: value.isPreview,
16
23
  language: value.language,
17
24
  admin: value.admin,
25
+ setShowTranslationKeys,
18
26
  showTranslationKeys,
19
- setShowTranslationKeys
27
+ topListContext,
20
28
  }}
21
29
  >
22
30
  {children}
@@ -408,54 +408,6 @@ export function translate(translations, key, defaultValue = "") {
408
408
  return defaultValue;
409
409
  }
410
410
 
411
- // This part of the code, help us to add operator related to the page as the first item in the comparison table automatically
412
- // example: if we are on the operator review page(Rizk) that should be first in the comparison table
413
- // First, we check if we have that item in the array, if that item is in the array, we check its position
414
- // If the item isn't in the array we will add it automatically
415
- export function shiftFirstOperator(pageId, module, pagesMappedById) {
416
- let index = null;
417
- // check if exist that element in array
418
- const checkIfExistElement = module.items.find((item, i) => {
419
- if (item.id === pageId) {
420
- index = i;
421
- if (index > 0) {
422
- // eslint-disable-next-line no-nested-ternary
423
- module.items.sort((x, y) =>
424
- x.id === pageId ? -1 : y.id === pageId ? 1 : 0
425
- );
426
- }
427
- return true;
428
- }
429
- return false;
430
- });
431
- if (!checkIfExistElement) {
432
- // eslint-disable-next-line no-unused-expressions
433
- if (
434
- pagesMappedById[pageId] &&
435
- pagesMappedById[pageId].relation_type === "operator"
436
- ) {
437
- module.items.unshift(pagesMappedById[pageId]);
438
- }
439
- }
440
- }
441
-
442
- export const getModuleTitle = (module, page) => {
443
- if (page && page.relation && page.relation_type === "operator") {
444
- return (
445
- module.module_title &&
446
- module.module_title.replace("[operator_name]", page.relation.name)
447
- );
448
- }
449
-
450
- return module.module_title;
451
- };
452
-
453
- export const getRoundMinutes = (time) => {
454
- const [minutes, seconds] = time.split(":");
455
- const value = seconds > 30 ? Number(minutes) + 1 : Number(minutes);
456
- return value === 0 ? 1 : value;
457
- };
458
-
459
411
  export function updateArrayTranslations(array, keysArray, translations) {
460
412
  if (array && array.length > 0 && keysArray && keysArray.length > 0) {
461
413
  array.forEach((elm, index) => {
@@ -545,19 +497,3 @@ export function setName(string) {
545
497
  const [name] = string.split(".");
546
498
  return name[0].toUpperCase() + name.slice(1);
547
499
  }
548
- export const trailingSlash = (content) => {
549
- if (!content || process.env.TRAILING_SLASH !== "true") return content;
550
-
551
- const baseUrl = process.env.GATSBY_SITE_URL;
552
- const escapedBaseUrl = baseUrl.replace(/\./g, "\\.");
553
-
554
- return content
555
- .replace(
556
- /(<a[^>]*?\shref=")(\/[^"]*?)(?<!\/)"(?=[^>]*>)/g,
557
- (match, p1, p2) => `${p1}${p2}/"`
558
- )
559
- .replace(
560
- new RegExp(`(<a[^>]*?\\shref=")(${escapedBaseUrl}[^"]*?)(?<!\/)"(?=[^>]*>)`, 'g'),
561
- (match, p1, p2) => `${p1}${p2}/"`
562
- );
563
- };
@@ -1,5 +1,4 @@
1
1
  import * as Getters from './getters';
2
- import pagesMappedById from '../../tests/factories/pagesMappedById';
3
2
  import getPageDataList from '~tests/factories/pages/list.factory';
4
3
 
5
4
  describe('Getters Helper', () => {
@@ -50,15 +49,6 @@ describe('Getters Helper', () => {
50
49
  expect(Object.keys(pagesMappedByMetaTitle).length).toBe(2);
51
50
  });
52
51
 
53
- test('getModuleTitle()', () => {
54
- expect(
55
- Getters.getModuleTitle(
56
- { module_title: 'Test [operator_name] test' },
57
- { relation_type: 'operator', relation: { name: 'test name' } }
58
- )
59
- ).toEqual('Test test name test');
60
- });
61
-
62
52
  test('getSection()', () => {
63
53
  expect(Getters.getSection('short_code', { page: {}, marketSections: {} })).toBeNull();
64
54
  expect(
@@ -279,40 +269,6 @@ describe('Getters Helper', () => {
279
269
  expect(Getters.translate(object, 'foo', 'bar')).toEqual('bar');
280
270
  });
281
271
 
282
- const module = {
283
- items: [
284
- {
285
- id: 12300,
286
- },
287
- {
288
- id: 13212,
289
- },
290
- ],
291
- };
292
-
293
- test('add the operator item', () => {
294
- Getters.shiftFirstOperator(11607, module, pagesMappedById);
295
- expect(module.items[0].id).toBe(11607);
296
- });
297
-
298
- test('move opeartor first postion', () => {
299
- Getters.shiftFirstOperator(13212, module, pagesMappedById);
300
- expect(module.items[0].id).toBe(13212);
301
- });
302
-
303
- test('check when we have the operator in first postion', () => {
304
- Getters.shiftFirstOperator(13212, module, pagesMappedById);
305
- expect(module.items[0].id).toBe(13212);
306
- });
307
-
308
- test('If the reading time is bigger than half, it should return the next number ', () => {
309
- expect(Getters.getRoundMinutes('3:52')).toBe(4);
310
- });
311
-
312
- test('If reading time is less than half, it should return the last number ', () => {
313
- expect(Getters.getRoundMinutes('3:29')).toBe(3);
314
- });
315
-
316
272
  const array = ['apple', 'banana', 'cherry'];
317
273
  const keysArray = ['fruit_apple', 'fruit_banana', 'fruit_cherry'];
318
274
  const translations = {
@@ -394,60 +350,6 @@ describe('Getters Helper', () => {
394
350
  expect(Getters.is404Page([ ], '')).toBe(false);
395
351
  });
396
352
 
397
-
398
-
399
- test('filters out null values, empty arrays, and keeps other data types', () => {
400
- const input = {
401
- a: 1, // Number (should be kept)
402
- b: null, // Null (should be removed)
403
- c: [], // Empty array (should be removed)
404
- d: [1, 2, 3], // Non-empty array (should be kept)
405
- e: "hello", // String (should be kept)
406
- f: undefined, // Undefined (should be removed)
407
- g: {}, // Empty object (should be kept)
408
- h: [null], // Array with null element (should be kept)
409
- i: [undefined, null], // Array with undefined/null (should be kept)
410
- };
411
-
412
- const expectedOutput = {
413
- a: 1,
414
- d: [1, 2, 3],
415
- e: "hello",
416
- g: {},
417
- h: [null],
418
- i: [undefined, null],
419
- };
420
-
421
- expect(Getters.filterNonNullValues(input)).toEqual(expectedOutput);
422
- });
423
-
424
- test('returns an empty object if all values are null or empty arrays', () => {
425
- const input = {
426
- a: null,
427
- b: [],
428
- c: null,
429
- d: [],
430
- };
431
-
432
- expect(Getters.filterNonNullValues(input)).toEqual({});
433
- });
434
-
435
- test('handles an empty input object gracefully', () => {
436
- const input = {};
437
- expect(Getters.filterNonNullValues(input)).toEqual({});
438
- });
439
-
440
- test('handles undefined or null input gracefully', () => {
441
- expect(Getters.filterNonNullValues(null)).toEqual({});
442
- expect(Getters.filterNonNullValues(undefined)).toEqual({});
443
- });
444
-
445
- test('Getters.filterNonNullValues removes null values', () => {
446
- const input = { a: 1, b: null, c: 2, d: undefined };
447
- const expected = { a: 1, c: 2 };
448
- expect(Getters.filterNonNullValues(input)).toEqual(expected);
449
- });
450
-
451
353
  describe('getLanguage', () => {
452
354
  it('returns GATSBY_SITE_LANG if set', () => {
453
355
  process.env.GATSBY_SITE_LANG = 'fr';
@@ -476,32 +378,6 @@ describe('Getters Helper', () => {
476
378
  });
477
379
  });
478
380
 
479
-
480
- test('basic functionality with sample HTML', () => {
481
- process.env.TRAILING_SLASH = 'true';
482
- process.env.GATSBY_SITE_URL = 'https://demo-gatsby-theme.gigmedia.com/';
483
- const input = `<p>Lorem ipsum dolor sit amet.
484
- <a href="/spotlights/icon" data-page-id="241228">Internal page</a>
485
- and <a href="https://demo-gatsby-theme.gigmedia.com/modules/bonus">External</a>
486
- and <a href="https://external.com/page">Ignore me</a></p>`;
487
-
488
- const expected = `<p>Lorem ipsum dolor sit amet.
489
- <a href="/spotlights/icon/" data-page-id="241228">Internal page</a>
490
- and <a href="https://demo-gatsby-theme.gigmedia.com/modules/bonus/">External</a>
491
- and <a href="https://external.com/page">Ignore me</a></p>`;
492
-
493
- expect(Getters.trailingSlash(input)).toBe(expected);
494
- });
495
- test('should not modify content when TRAILING_SLASH is not true', () => {
496
- process.env.TRAILING_SLASH = 'false';
497
- process.env.GATSBY_SITE_URL = 'https://demo-gatsby-theme.gigmedia.com/';
498
- const input = '<a href="/test">Link</a>';
499
- expect(Getters.trailingSlash(input)).toBe(input);
500
- });
501
-
502
- test('should handle null content', () => {
503
- expect(Getters.trailingSlash(null)).toBeNull();
504
- });
505
381
  test("returns null if item is null", () => {
506
382
  expect(Getters.getPromoCode(null, "main")).toBeNull();
507
383
  });
@@ -1,4 +1,4 @@
1
- import { formatPath, stripDomainAndLeadingSlash } from './path';
1
+ import { formatPath } from './path';
2
2
 
3
3
  describe('Path format component', () => {
4
4
  test('path format adding /', () => {
@@ -14,35 +14,3 @@ describe('Path format component', () => {
14
14
  });
15
15
  });
16
16
 
17
- describe('stripDomainAndLeadingSlash', () => {
18
- test('strips domain and leading slash from full URL', () => {
19
- const url = 'https://www.playcasino.co.za/';
20
- const result = stripDomainAndLeadingSlash(url);
21
- expect(result).toBe('');
22
- });
23
-
24
- test('strips domain and leading slash review', () => {
25
- const url = 'https://www.playcasino.co.za/yebo-casino-review';
26
- const result = stripDomainAndLeadingSlash(url);
27
- expect(result).toBe('yebo-casino-review');
28
- });
29
-
30
-
31
- test('strips only leading slashes if no domain', () => {
32
- const url = '/yebo-casino-review';
33
- const result = stripDomainAndLeadingSlash(url);
34
- expect(result).toBe('/yebo-casino-review');
35
- });
36
-
37
- test('returns original input if invalid URL', () => {
38
- const url = 'not a real url';
39
- const result = stripDomainAndLeadingSlash(url);
40
- expect(result).toBe(url);
41
- });
42
-
43
- test('handles URLs with multiple leading slashes', () => {
44
- const url = 'https://example.com///deep/path';
45
- const result = stripDomainAndLeadingSlash(url);
46
- expect(result).toBe('deep/path');
47
- });
48
- });
@@ -1,96 +1,6 @@
1
1
  /* eslint-disable camelcase */
2
2
  /* eslint-disable array-callback-return */
3
- export function reverseDate(date) {
4
- return date.split('-').reverse().join('-');
5
- }
6
-
3
+ // eslint-disable-next-line import/prefer-default-export
7
4
  export function zeroPadding(num, places) {
8
5
  return String(num).padStart(places, '0');
9
6
  }
10
-
11
- export function populateTeamKits( tournaments, events, teams, team_kits ){
12
- const tournamentKits = {}
13
- Object.entries(tournaments || {}).forEach(([, tournament]) =>
14
- tournament?.events && tournament?.events.forEach((eventId) => {
15
- const homeTeam = events?.[eventId]?.home_team;
16
- const awayTeam = events?.[eventId]?.away_team;
17
-
18
- tournamentKits[teams?.[homeTeam]?.livegoals_v2_id] = team_kits?.[teams?.[homeTeam].livegoals_v2_id] && team_kits[teams?.[homeTeam].livegoals_v2_id];
19
- tournamentKits[teams?.[awayTeam]?.livegoals_v2_id] = team_kits?.[teams?.[awayTeam].livegoals_v2_id] && team_kits[teams?.[awayTeam].livegoals_v2_id];
20
- })
21
- );
22
- return tournamentKits;
23
- }
24
-
25
- export function filterScheduleByDate(schedule, tournaments, events, teams, team_kits) {
26
- const today = new Date().setHours(0, 0, 0, 0);
27
- let todayFound = false;
28
- let todayNextIndex = null;
29
- let filteredTeamKits = null;
30
- Object.keys(schedule.soccer).forEach((key, index) => {
31
- if (new Date(key).setHours(0, 0, 0, 0) === today) {
32
- schedule.soccer[key] = { ...schedule.soccer[key], active: true};
33
- todayFound = true;
34
- todayNextIndex = index;
35
- filteredTeamKits = populateTeamKits( schedule.soccer[key].tournaments, events, teams, team_kits );
36
- }
37
- if(tournaments){
38
- schedule.soccer[key].sorting = Object.keys(schedule.soccer[key].tournaments).sort(
39
- (aKey, bKey) => tournaments?.[aKey]?.sort_order - tournaments?.[bKey]?.sort_order);
40
- }
41
- delete schedule.soccer[key].date;
42
- });
43
-
44
- let nextDay = false;
45
- if(!todayFound) {
46
- Object.keys(schedule.soccer).forEach((key, index) => {
47
- if (!nextDay && new Date(key).setHours(0, 0, 0, 0) > today) {
48
- schedule.soccer[key] = { ...schedule.soccer[key], active: true};
49
- nextDay = true;
50
- todayNextIndex = index;
51
- }
52
- if(tournaments){
53
- schedule.soccer[key].tournaments_sorted = Object.keys(schedule.soccer[key].tournaments).sort(
54
- (aKey, bKey) => tournaments?.[aKey]?.sort_order - tournaments?.[bKey]?.sort_order);
55
- }
56
- });
57
- }
58
-
59
- if(!todayFound && !nextDay) {
60
- const keys = Object.keys(schedule.soccer);
61
- const lastKey = keys[keys.length - 1];
62
- if(keys.length > 0) {
63
- schedule.soccer[lastKey] = { ...schedule.soccer[lastKey], active: true};
64
- }
65
- }
66
-
67
- if(todayNextIndex !== null && todayNextIndex - 2 > 0) {
68
- const indexSlice = todayNextIndex - 2;
69
- const entries = Object.entries(schedule.soccer);
70
- const remainingEntries = entries.slice(indexSlice);
71
- schedule.soccer = Object.fromEntries(remainingEntries);
72
- }
73
-
74
- return {schedule, team_kits: filteredTeamKits};
75
- }
76
-
77
- export function filterEvents(tournamentEvents, events) {
78
- const futureEvents = [];
79
- const today = new Date().setHours(0, 0, 0, 0);
80
- tournamentEvents.forEach((eventId) => {
81
- if (events[eventId]) {
82
- const eventDate = new Date(
83
- `${events[eventId].date.year_number}-${zeroPadding(
84
- events[eventId].date.month_number,
85
- 2
86
- )}-${zeroPadding(events[eventId].date.day_number, 2)}`
87
- );
88
-
89
- if (eventDate >= today) {
90
- futureEvents.push(eventId);
91
- }
92
- }
93
- });
94
-
95
- return futureEvents;
96
- }
@@ -3,16 +3,14 @@
3
3
  /* eslint-disable no-nested-ternary */
4
4
  /* eslint-disable import/prefer-default-export */
5
5
  import chalk from "chalk";
6
+ import { getSiteSettings, processor } from "@gigmedia/enigma-middleware";
6
7
  import loadSource from "~helpers/search-source";
7
8
  import { deparam } from "~helpers/strings";
8
9
  import { groupBy } from "~helpers/getters";
9
- import processor from "../resolver/index.mjs";
10
- import { fetchSiteSettings } from "../services/fetch.mjs";
11
10
 
12
11
  export async function getAPIData(page, url, headers, preview) {
13
12
  if (preview) {
14
13
  const start = new Date();
15
- const siteName = process.env.GATSBY_SITE_NAME;
16
14
  const params = deparam(url.split("?")[1]);
17
15
 
18
16
  const {
@@ -27,7 +25,7 @@ export async function getAPIData(page, url, headers, preview) {
27
25
  paymentData,
28
26
  gamesData,
29
27
  providersData,
30
- } = await fetchSiteSettings(siteName, params?.path);
28
+ } = await getSiteSettings(params?.path);
31
29
 
32
30
  const processed = processor.run(
33
31
  {
@@ -79,47 +79,6 @@ export function clonePageForCards(item, style, content, extraFields = true) {
79
79
  return object;
80
80
  }
81
81
 
82
- export function removeDuplicates(list, key) {
83
- if (!list || !key) {
84
- return [];
85
- }
86
-
87
- return list.reduce((filtered, current) => {
88
- const duplicateItem = filtered.find((item) => item[key] === current[key]);
89
- if (!duplicateItem) {
90
- return filtered.concat([current]);
91
- }
92
- return filtered;
93
- }, []);
94
- }
95
-
96
- export function removeTags(str) {
97
- if (str === null || str === '') return '';
98
- return str.toString().replace(/(<([^>]+)>)/gi, '');
99
- }
100
-
101
- export function removeCurrentPage(list, id) {
102
- const index = list.findIndex((el) => el.id === id);
103
- if (index !== -1) {
104
- list.splice(index, 1);
105
- }
106
- return list;
107
- }
108
-
109
- export function updateMenuPrefixPath(menu, prefixPath) {
110
- menu.map((item) => {
111
- if (item.value && item.page_id) {
112
- item.value = item.value === '/' ? prefixPath : `${prefixPath}/${item.value}`;
113
- }
114
-
115
- if (item.children) {
116
- updateMenuPrefixPath(item.children, prefixPath);
117
- }
118
-
119
- return true;
120
- });
121
- }
122
-
123
82
  export function clean(object) {
124
83
  Object
125
84
  .entries(object)
@@ -204,15 +163,3 @@ export function removeUnwantedSections(obj, pageType, ribbonsData) {
204
163
 
205
164
  return filteredObject;
206
165
  }
207
-
208
- export function filterRelation (relation, allowedKeys) {
209
- if (!relation) return undefined;
210
- if (!allowedKeys) return relation;
211
-
212
- return allowedKeys.reduce((acc, key) => {
213
- if (relation[key]) {
214
- acc[key] = relation[key];
215
- }
216
- return acc;
217
- }, {});
218
- };