@websolutespa/bom-mixer-models 2.0.2 → 3.0.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 (48) hide show
  1. package/CHANGELOG.md +5 -10
  2. package/dist/exports/proxy.d.ts +12 -0
  3. package/dist/exports/proxy.d.ts.map +1 -0
  4. package/dist/exports/proxy.js +172 -0
  5. package/dist/exports/proxy.js.map +1 -0
  6. package/dist/exports/server.d.ts +184 -0
  7. package/dist/exports/server.d.ts.map +1 -0
  8. package/dist/exports/server.js +960 -0
  9. package/dist/exports/server.js.map +1 -0
  10. package/dist/index.d.ts +254 -424
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +41 -1450
  13. package/dist/index.js.map +1 -0
  14. package/dist/lazy-JamSYYoh.d.ts +84 -0
  15. package/dist/lazy-JamSYYoh.d.ts.map +1 -0
  16. package/dist/page-BLbZbnWg.js +12 -0
  17. package/dist/page-BLbZbnWg.js.map +1 -0
  18. package/dist/route-k0W3AKyo.js +53 -0
  19. package/dist/route-k0W3AKyo.js.map +1 -0
  20. package/package.json +75 -27
  21. package/src/app/app.service.ts +1 -1
  22. package/src/captions/captions.handler.ts +1 -1
  23. package/src/category/category.service.ts +3 -3
  24. package/src/consent_preference/consent_preference.service.ts +4 -4
  25. package/src/consent_preference/consent_preference.ts +1 -1
  26. package/src/country/country.service.ts +4 -4
  27. package/src/exports/proxy.ts +2 -0
  28. package/src/exports/server.ts +22 -0
  29. package/src/index.ts +3 -20
  30. package/src/label/label.service.ts +3 -3
  31. package/src/lazy/lazy.service.ts +28 -0
  32. package/src/lazy/lazy.ts +0 -26
  33. package/src/locale/locale.service.ts +3 -13
  34. package/src/locale/locale.ts +9 -0
  35. package/src/market/market.service.ts +3 -3
  36. package/src/menu/menu.service.ts +3 -3
  37. package/src/page/page.service.ts +47 -7
  38. package/src/page/page.ts +9 -0
  39. package/src/province/province.service.ts +4 -4
  40. package/src/redirect/redirect.service.ts +4 -4
  41. package/src/region/region.service.ts +4 -4
  42. package/src/route/route-revalidate.handler.ts +54 -43
  43. package/src/route/route.interceptor.ts +18 -3
  44. package/src/route/route.service.ts +11 -49
  45. package/src/route/route.ts +64 -0
  46. package/src/session/session.service.ts +12 -4
  47. package/src/sitemap/sitemap.service.ts +5 -5
  48. package/dist/index.mjs +0 -1363
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["record: Record<string, any>","category: string","routeLink: IRouteLink | undefined","p: string | undefined","layout: ILayout","props?: {\r\n __NEXT_DATA__?: {\r\n query?: {\r\n locale?: string;\r\n }\r\n }\r\n}","index: number","seoWeight?: SeoWeight","subIndex: number","request: NextApiRequest"],"sources":["../src/gtm/gtm.service.ts","../src/link/link.service.ts","../src/locale/locale.ts","../src/seo/seo.service.ts","../src/utmz/utmz.service.ts"],"sourcesContent":["import { isBrowser } from '@websolutespa/bom-core';\r\n\r\ndeclare global {\r\n interface Window {\r\n dataLayer?: Record<string, any>[];\r\n }\r\n}\r\n\r\nexport function pushDataLayer(record: Record<string, any>) {\r\n if (isBrowser) {\r\n window.dataLayer?.push(record);\r\n }\r\n}\r\n","import { ILayout, IRouteLink } from '@websolutespa/bom-core';\r\n\r\nfunction getLink_(category: string, routeLink: IRouteLink | undefined): string | undefined {\r\n if (routeLink) {\r\n if (routeLink.category === category) {\r\n return routeLink.href;\r\n }\r\n if (routeLink.items) {\r\n return routeLink.items.reduce((p: string | undefined, c) => {\r\n return getLink_(category, c) || p;\r\n }, undefined);\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nexport function getLink(category: string, layout: ILayout) {\r\n return getLink_(category, layout.tree);\r\n}\r\n","export function getLocaleFromProps(props?: {\r\n __NEXT_DATA__?: {\r\n query?: {\r\n locale?: string;\r\n }\r\n }\r\n}): string | undefined {\r\n return props?.__NEXT_DATA__?.query?.locale as string;\r\n}\r\n","\r\nexport type SeoWeight = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\r\n\r\nexport const getSeoWeight = (index: number = 0, seoWeight?: SeoWeight) => {\r\n const getter = (subIndex: number = 0) => {\r\n const i = seoWeight ?\r\n parseInt(seoWeight.replace(/\\D/g, '')) :\r\n (index === 0 ? 1 : 2);\r\n return `h${Math.min(i + subIndex, 6)}` as SeoWeight;\r\n };\r\n return getter;\r\n};\r\n","import { NextApiRequest } from 'next';\r\n\r\nexport function getUtmz(request: NextApiRequest): string {\r\n let utmz = 'N/A';\r\n if (typeof request.cookies.__utmz === 'string') {\r\n utmz = request.cookies.__utmz;\r\n const i = utmz.indexOf('utmcsr');\r\n utmz = utmz.substring(i === -1 ? 0 : i);\r\n }\r\n return utmz;\r\n}\r\n"],"mappings":";;;;;AAQA,SAAgB,cAAcA,QAA6B;AACzD,KAAI,WACF,OAAO,WAAW,KAAK,OAAO;AAEjC;;;;ACVD,SAAS,SAASC,UAAkBC,WAAuD;AACzF,KAAI,WAAW;AACb,MAAI,UAAU,aAAa,SACzB,QAAO,UAAU;AAEnB,MAAI,UAAU,MACZ,QAAO,UAAU,MAAM,OAAO,CAACC,GAAuB,MAAM;AAC1D,UAAO,SAAS,UAAU,EAAE,IAAI;EACjC,GAAE,OAAU;CAEhB;AACD,QAAO;AACR;AAED,SAAgB,QAAQF,UAAkBG,QAAiB;AACzD,QAAO,SAAS,UAAU,OAAO,KAAK;AACvC;;;;AClBD,SAAgB,mBAAmBC,OAMZ;AACrB,QAAO,OAAO,eAAe,OAAO;AACrC;;;;ACLD,MAAa,eAAe,CAACC,QAAgB,GAAGC,cAA0B;CACxE,MAAM,SAAS,CAACC,WAAmB,MAAM;EACvC,MAAM,IAAI,YACR,SAAS,UAAU,QAAQ,OAAO,GAAG,CAAC,GACrC,UAAU,IAAI,IAAI;AACrB,SAAO,CAAC,CAAC,EAAE,KAAK,IAAI,IAAI,UAAU,EAAE,EAAE;CACvC;AACD,QAAO;AACR;;;;ACTD,SAAgB,QAAQC,SAAiC;CACvD,IAAI,OAAO;AACX,KAAI,OAAO,QAAQ,QAAQ,WAAW,UAAU;EAC9C,OAAO,QAAQ,QAAQ;EACvB,MAAM,IAAI,KAAK,QAAQ,SAAS;EAChC,OAAO,KAAK,UAAU,MAAM,KAAK,IAAI,EAAE;CACxC;AACD,QAAO;AACR"}
@@ -0,0 +1,84 @@
1
+ import { IComponent, IEntity, IOption, PageProps } from "@websolutespa/bom-core";
2
+ import { DynamicOptions, Loader } from "next/dynamic";
3
+ import { ComponentType, ReactNode } from "react";
4
+
5
+ //#region src/address/address.d.ts
6
+ type IAddressOptions = {
7
+ countries: IOption[];
8
+ regions: IOption[];
9
+ provinces: IOption[];
10
+ };
11
+ type IAddress = {
12
+ address: string;
13
+ addressLine2?: string;
14
+ city: string;
15
+ companyName?: string;
16
+ country: IOption;
17
+ email?: string;
18
+ firstName?: string;
19
+ lastName?: string;
20
+ phoneNumber?: string;
21
+ faxNumber?: string;
22
+ province?: IOption;
23
+ region?: IOption;
24
+ streetNumber: string;
25
+ title?: string;
26
+ websiteUrl?: string;
27
+ zipCode: string;
28
+ };
29
+ type ICompanyAddress = IAddress & {
30
+ name: string;
31
+ companyName: string;
32
+ email: string;
33
+ websiteUrl?: string;
34
+ };
35
+ //# sourceMappingURL=address.d.ts.map
36
+ //#endregion
37
+ //#region src/consent_preference/consent_preference.d.ts
38
+ type ILegalNotice = IEntity & {
39
+ id: string;
40
+ text: string;
41
+ };
42
+ type IConsentPreference = IEntity & {
43
+ id: string;
44
+ description: string;
45
+ legalNotice: ILegalNotice;
46
+ createdAt?: Date | string;
47
+ updatedAt?: Date | string;
48
+ };
49
+ //# sourceMappingURL=consent_preference.d.ts.map
50
+ //#endregion
51
+ //#region src/lazy/lazy.d.ts
52
+ type ILazyComponent = IComponent;
53
+ type ILazyProps<T> = {
54
+ item: T & ILazyComponent;
55
+ index: number;
56
+ children?: ReactNode;
57
+ };
58
+ type ILazyableProps<T> = {
59
+ item: T & Partial<ILazyComponent>;
60
+ index?: number;
61
+ children?: ReactNode;
62
+ };
63
+ type INullableLazyableProps<T> = {
64
+ item?: T & Partial<ILazyComponent>;
65
+ index?: number;
66
+ children?: ReactNode;
67
+ };
68
+ type ILazyedProps<T> = Omit<ILazyProps<T>, 'children'>;
69
+ type ILazyComponentProps = {
70
+ item: ILazyComponent;
71
+ index: number;
72
+ };
73
+ type ILazyModules = Record<string, ComponentType<ILazyProps<any>>>;
74
+ type ILazyComponentFunc<P = {}> = DynamicOptions<P> | Loader<P>;
75
+ type ILazyFuncProps<T> = PageProps & {
76
+ component: T & ILazyComponent;
77
+ };
78
+ type ILazyStaticPropsFunc<T = any> = (props: ILazyFuncProps<T>) => Promise<T & ILazyComponent>;
79
+ type ILazyStaticProps = Record<string, ILazyStaticPropsFunc>;
80
+ //# sourceMappingURL=lazy.d.ts.map
81
+
82
+ //#endregion
83
+ export { IAddress, IAddressOptions, ICompanyAddress, IConsentPreference, ILazyComponent, ILazyComponentFunc, ILazyComponentProps, ILazyFuncProps, ILazyModules, ILazyProps, ILazyStaticProps, ILazyStaticPropsFunc, ILazyableProps, ILazyedProps, ILegalNotice, INullableLazyableProps };
84
+ //# sourceMappingURL=lazy-JamSYYoh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy-JamSYYoh.d.ts","names":[],"sources":["../src/address/address.ts","../src/consent_preference/consent_preference.ts","../src/lazy/lazy.ts"],"sourcesContent":[],"mappings":";;;;;KAEY,eAAA;aACC;WACF;aACE;AAHb,CAAA;AAA2B,KAMf,QAAA,GANe;EAAA,OACd,EAAA,MAAA;EAAO,YACT,CAAA,EAAA,MAAA;EAAO,IACL,EAAA,MAAA;EAAO,WAAA,CAAA,EAAA,MAAA;EAGR,OAAA,EAKD,OALS;EAAA,KAAA,CAAA,EAAA,MAAA;EAAA,SAKT,CAAA,EAAA,MAAA;EAAO,QAML,CAAA,EAAA,MAAA;EAAO,WACT,CAAA,EAAA,MAAA;EAAO,SAAA,CAAA,EAAA,MAAA;EAON,QAAA,CAAA,EARC,OAQc;WAPhB;;;EClBC,UAAA,C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BE,CAAA,CAAA,CAAA,GCwBkB,SDxBlB,GAAA;EAAI,SACJ,ECuB2C,CDvB3C,GCuB+C,cDvB/C;AAAI,CAAA;KCyBN,wCAAwC,eAAe,OAAO,QAAQ,IAAI;KAE1E,gBAAA,GAAmB,eAAe"}
@@ -0,0 +1,12 @@
1
+ //#region src/page/page.ts
2
+ function getPublicUrl() {
3
+ const publicUrl = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
4
+ return publicUrl;
5
+ }
6
+ function resolveHref(href = "") {
7
+ return href.startsWith("http") ? href : `${getPublicUrl()}${href}`;
8
+ }
9
+
10
+ //#endregion
11
+ export { getPublicUrl, resolveHref };
12
+ //# sourceMappingURL=page-BLbZbnWg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-BLbZbnWg.js","names":["href: string"],"sources":["../src/page/page.ts"],"sourcesContent":["\r\nexport function getPublicUrl() {\r\n const publicUrl = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : '';\r\n return publicUrl;\r\n}\r\n\r\nexport function resolveHref(href: string = '') {\r\n return href.startsWith('http') ? href : `${getPublicUrl()}${href}`;\r\n}\r\n"],"mappings":";AACA,SAAgB,eAAe;CAC7B,MAAM,YAAY,QAAQ,OAAO,QAAQ,IAAI,kBAAkB,QAAQ,IAAI,kBAAkB;AAC7F,QAAO;AACR;AAED,SAAgB,YAAYA,OAAe,IAAI;AAC7C,QAAO,KAAK,WAAW,OAAO,GAAG,OAAO,GAAG,cAAc,GAAG,MAAM;AACnE"}
@@ -0,0 +1,53 @@
1
+ import { asCategoryId, findRouteOfCategory, getRootCategory, localize } from "@websolutespa/bom-core";
2
+
3
+ //#region src/route/route.ts
4
+ function categoryToRouteLink(routes, categories, category, locale) {
5
+ const route = findRouteOfCategory(routes, category.id);
6
+ if (!route) return void 0;
7
+ const rootCategory = getRootCategory(categories);
8
+ const childCategories = categories.filter((x) => {
9
+ const parentId = asCategoryId(x.category);
10
+ return rootCategory && rootCategory.id === category.id ? x.id !== rootCategory.id && (parentId === category.id || !parentId) : parentId === category.id;
11
+ });
12
+ const routeLink = newRouteLink(category, route, locale);
13
+ routeLink.items = childCategories.map((x) => categoryToRouteLink(routes, categories, x, locale)).filter((x) => x !== void 0);
14
+ return routeLink;
15
+ }
16
+ function newRouteLink(category, route, locale) {
17
+ const href = route && route.id ? route.id.toString() : "/";
18
+ const id = route?.page || category.id;
19
+ const media = category.media || route?.media;
20
+ const schema = route?.template || route?.schema || category?.schema || "unknown";
21
+ const title = localize(category.title || route?.title || "untitled", locale);
22
+ const routeLink = {
23
+ category: category.id,
24
+ href,
25
+ id,
26
+ items: [],
27
+ media,
28
+ schema,
29
+ title
30
+ };
31
+ return routeLink;
32
+ }
33
+ function routeToRouteLink(route) {
34
+ const routeLink = {
35
+ category: asCategoryId(route.category),
36
+ href: route.id,
37
+ id: route.page,
38
+ items: [],
39
+ media: route.media,
40
+ schema: route.schema,
41
+ title: route.title
42
+ };
43
+ return routeLink;
44
+ }
45
+ function resolveRoute(route) {
46
+ const routepath = route.template || route.schema;
47
+ const resolvedPathname = `/${route.market}/${route.locale}/${routepath}/${route.page}${route.splat || ""}`;
48
+ return resolvedPathname;
49
+ }
50
+
51
+ //#endregion
52
+ export { categoryToRouteLink, newRouteLink, resolveRoute, routeToRouteLink };
53
+ //# sourceMappingURL=route-k0W3AKyo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-k0W3AKyo.js","names":["routes: IRoute[]","categories: ICategory[]","category: ICategory","locale: string","route: IRoute | undefined","route: IRoute","routeLink: IRouteLink","route: IRoute & { splat?: string }","routepath: string"],"sources":["../src/route/route.ts"],"sourcesContent":["import { asCategoryId, findRouteOfCategory, getRootCategory, ICategory, IRoute, IRouteLink, localize } from '@websolutespa/bom-core';\r\n\r\nexport type StaticPath = { params: { [key: string]: string } };\r\n\r\nexport function categoryToRouteLink(routes: IRoute[], categories: ICategory[], category: ICategory, locale: string): IRouteLink | undefined {\r\n const route = findRouteOfCategory(routes, category.id);\r\n if (!route) {\r\n return undefined;\r\n }\r\n const rootCategory = getRootCategory(categories);\r\n const childCategories = categories.filter(x => {\r\n const parentId = asCategoryId(x.category);\r\n return rootCategory && rootCategory.id === category.id ?\r\n (x.id !== rootCategory.id && (parentId === category.id || !parentId)) :\r\n parentId === category.id;\r\n });\r\n // console.log('childCategories', category.id, childCategories);\r\n const routeLink = newRouteLink(category, route, locale);\r\n // console.log('categoryToRouteLink', href, category.id, route);\r\n routeLink.items = childCategories\r\n .map(x => categoryToRouteLink(routes, categories, x, locale))\r\n .filter(x => x !== undefined) as IRouteLink[];\r\n return routeLink;\r\n}\r\n\r\nexport function newRouteLink(category: ICategory, route: IRoute | undefined, locale: string): IRouteLink {\r\n const href = (route && route.id) ? route.id.toString() : '/';\r\n const id = route?.page || category.id;\r\n const media = category.media || route?.media;\r\n const schema = route?.template || route?.schema || category?.schema || 'unknown';\r\n const title = localize(category.title || route?.title || 'untitled', locale);\r\n const routeLink = {\r\n category: category.id,\r\n href,\r\n id,\r\n items: [],\r\n media,\r\n schema,\r\n title,\r\n };\r\n return routeLink;\r\n}\r\n\r\nexport function routeToRouteLink(route: IRoute): IRouteLink {\r\n const routeLink: IRouteLink = {\r\n category: asCategoryId(route.category),\r\n href: route.id,\r\n id: route.page,\r\n items: [],\r\n media: route.media,\r\n schema: route.schema,\r\n title: route.title,\r\n };\r\n return routeLink;\r\n}\r\n\r\nexport function resolveRoute(route: IRoute & { splat?: string }) {\r\n // console.log('resolveRoute', route);\r\n const routepath: string = route.template || route.schema;\r\n // convert route to next.js pages folder schema\r\n const resolvedPathname = `/${route.market}/${route.locale}/${routepath}/${route.page}${route.splat || ''}`;\r\n // console.log('resolveRoute', route.schema, resolvedPathname);\r\n return resolvedPathname;\r\n}\r\n"],"mappings":";;;AAIA,SAAgB,oBAAoBA,QAAkBC,YAAyBC,UAAqBC,QAAwC;CAC1I,MAAM,QAAQ,oBAAoB,QAAQ,SAAS,G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AAI;AAE1G,QAAO;AACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-models",
3
- "version": "2.0.2",
3
+ "version": "3.0.1",
4
4
  "description": "Mixer Models module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -14,49 +14,97 @@
14
14
  },
15
15
  "scripts": {
16
16
  "lint": "eslint *.ts*",
17
- "compile": "tsup ./src/index.ts --format esm,cjs --dts",
17
+ "compile": "tsdown",
18
18
  "prepack": "bom prepack",
19
19
  "postpack": "bom postpack",
20
- "release": "npm publish --access public --tag bom2"
20
+ "types": "tsc --noemit"
21
21
  },
22
22
  "dependencies": {},
23
23
  "peerDependencies": {
24
- "@websolutespa/bom-core": "^2.0.0",
25
- "@websolutespa/bom-mixer-store": "^2.0.0",
26
- "iron-session": ">= 8.0.3",
27
- "next": ">= 14.1.4"
24
+ "@websolutespa/bom-core": "*",
25
+ "@websolutespa/bom-mixer-store": "*",
26
+ "iron-session": "8.0.4",
27
+ "next": "16.1.6"
28
28
  },
29
29
  "devDependencies": {
30
- "@types/react": "^18.2.75",
31
- "@types/react-dom": "^18.2.24",
32
- "@websolutespa/bom-cli": "^2.0.0",
33
- "@websolutespa/test": "^2.0.0",
34
- "@websolutespa/tsconfig": "^2.0.0",
35
- "eslint": "^8.56.0",
36
- "eslint-config-websolute": "^2.0.0",
37
- "npm-run-all": "^4.1.5",
38
- "react": "^18.2.0",
39
- "schema-dts": "^1.1.5",
40
- "ts-node": "^10.9.2",
41
- "tsup": "^6.7.0",
42
- "typescript": "^5.4.5"
30
+ "@types/react": "19.2.10",
31
+ "@types/react-dom": "19.2.3",
32
+ "@websolutespa/bom-cli": "*",
33
+ "@websolutespa/test": "*",
34
+ "@websolutespa/tsconfig": "*",
35
+ "eslint": "9.31.0",
36
+ "@websolutespa/eslint-config": "*",
37
+ "npm-run-all": "4.1.5",
38
+ "react": "19.2.3",
39
+ "schema-dts": "1.1.5",
40
+ "typescript": "5.8.3"
43
41
  },
44
42
  "publishConfig": {
45
43
  "access": "public"
46
44
  },
47
45
  "sideEffects": false,
46
+ "type": "module",
48
47
  "prepack": {
49
48
  "types": "./dist/index.d.ts",
50
- "main": "./dist/index.mjs",
51
- "module": "./dist/index.mjs",
52
- "source": "./src/index.ts"
49
+ "main": "./dist/index.js",
50
+ "source": "./src/index.ts",
51
+ "exports": {
52
+ ".": {
53
+ "import": "./dist/index.js",
54
+ "types": "./dist/index.d.ts",
55
+ "default": "./dist/index.js"
56
+ },
57
+ "./proxy": {
58
+ "import": "./dist/exports/proxy.js",
59
+ "types": "./dist/exports/proxy.d.ts",
60
+ "default": "./dist/exports/proxy.js"
61
+ },
62
+ "./server": {
63
+ "import": "./dist/exports/server.js",
64
+ "types": "./dist/exports/server.d.ts",
65
+ "default": "./dist/exports/server.js"
66
+ }
67
+ }
53
68
  },
54
69
  "postpack": {
55
70
  "types": "./src/index.ts",
56
- "main": "./src/index.ts"
71
+ "main": "./src/index.ts",
72
+ "exports": {
73
+ ".": {
74
+ "import": "./src/index.ts",
75
+ "types": "./src/index.ts",
76
+ "default": "./src/index.ts"
77
+ },
78
+ "./proxy": {
79
+ "import": "./src/exports/proxy.ts",
80
+ "types": "./src/exports/proxy.ts",
81
+ "default": "./src/exports/proxy.ts"
82
+ },
83
+ "./server": {
84
+ "import": "./src/exports/server.ts",
85
+ "types": "./src/exports/server.ts",
86
+ "default": "./src/exports/server.ts"
87
+ }
88
+ }
57
89
  },
58
90
  "types": "./dist/index.d.ts",
59
- "main": "./dist/index.mjs",
60
- "module": "./dist/index.mjs",
61
- "source": "./src/index.ts"
91
+ "main": "./dist/index.js",
92
+ "source": "./src/index.ts",
93
+ "exports": {
94
+ ".": {
95
+ "import": "./dist/index.js",
96
+ "types": "./dist/index.d.ts",
97
+ "default": "./dist/index.js"
98
+ },
99
+ "./proxy": {
100
+ "import": "./dist/exports/proxy.js",
101
+ "types": "./dist/exports/proxy.d.ts",
102
+ "default": "./dist/exports/proxy.js"
103
+ },
104
+ "./server": {
105
+ "import": "./dist/exports/server.js",
106
+ "types": "./dist/exports/server.d.ts",
107
+ "default": "./dist/exports/server.js"
108
+ }
109
+ }
62
110
  }
@@ -1,5 +1,5 @@
1
1
  import { IApp, IAppExtended, QueryParams } from '@websolutespa/bom-core';
2
- import { getStore } from '@websolutespa/bom-mixer-store';
2
+ import { getStore } from '@websolutespa/bom-mixer-store/server';
3
3
  import { IModelStore } from '../store/store';
4
4
 
5
5
  export async function getApp<T extends IAppExtended = IAppExtended>(params: QueryParams = {}): Promise<IApp<T> | undefined> {
@@ -1,6 +1,6 @@
1
1
  import { GetServerSideProps } from 'next';
2
2
  // import { ILocale } from '@websolutespa/bom-core';
3
- // import { getLocales } from '@websolutespa/bom-mixer-models';
3
+ // import { getLocales } from '@websolutespa/bom-mixer-models/server';
4
4
 
5
5
  export const getCaptionsVttProps: GetServerSideProps = async (context) => {
6
6
  const { req, res, params, query } = context;
@@ -1,16 +1,16 @@
1
1
  import { ICategorized, ICategory, IEquatable, QueryParams, getCategorySegments } from '@websolutespa/bom-core';
2
- import { getStore } from '@websolutespa/bom-mixer-store';
2
+ import { getStore } from '@websolutespa/bom-mixer-store/server';
3
3
  import { IModelStore } from '../store/store';
4
4
 
5
5
  export async function getCategories(params: QueryParams = {}): Promise<ICategory[]> {
6
6
  const store = await getStore<IModelStore>();
7
- const categories = await store.category.findMany(params);
7
+ const categories = await store.category!.findMany(params);
8
8
  return categories;
9
9
  }
10
10
 
11
11
  export async function getCategory(id: IEquatable, params: QueryParams = {}): Promise<ICategory | undefined> {
12
12
  const store = await getStore<IModelStore>();
13
- const item = await store.category.findOne(id, params);
13
+ const item = await store.category!.findOne(id, params);
14
14
  return item;
15
15
  }
16
16
 
@@ -1,22 +1,22 @@
1
1
  import { IEquatable, IPaginationResult, QueryParams } from '@websolutespa/bom-core';
2
- import { getStore } from '@websolutespa/bom-mixer-store';
2
+ import { getStore } from '@websolutespa/bom-mixer-store/server';
3
3
  import { IModelStore } from '../store/store';
4
4
  import { IConsentPreference } from './consent_preference';
5
5
 
6
6
  export async function getConsentPreference(id: IEquatable, params: QueryParams = {}): Promise<IConsentPreference | undefined> {
7
7
  const store = await getStore<IModelStore>();
8
- const item = await store.consent_preference.findOne<IConsentPreference>(id, params);
8
+ const item = await store.consent_preference!.findOne<IConsentPreference>(id, params);
9
9
  return item;
10
10
  }
11
11
 
12
12
  export async function getConsentPreferences(params: QueryParams = {}): Promise<IConsentPreference[]> {
13
13
  const store = await getStore<IModelStore>();
14
- const items = await store.consent_preference.findMany<IConsentPreference>(params);
14
+ const items = await store.consent_preference!.findMany<IConsentPreference>(params);
15
15
  return items;
16
16
  }
17
17
 
18
18
  export async function getConsentPreferencesPagination(params: QueryParams = {}): Promise<IPaginationResult<IConsentPreference>> {
19
19
  const store = await getStore<IModelStore>();
20
- const pagination = await store.consent_preference.findPaged<IConsentPreference>(params);
20
+ const pagination = await store.consent_preference!.findPaged<IConsentPreference>(params);
21
21
  return pagination;
22
22
  }
@@ -1,4 +1,4 @@
1
- import { IEntity } from '@websolutespa/bom-core';
1
+ import type { IEntity } from '@websolutespa/bom-core';
2
2
 
3
3
  export type ILegalNotice = IEntity & {
4
4
  id: string;
@@ -1,21 +1,21 @@
1
1
  import { IEquatable, INamedEntity, IPaginationResult, QueryParams } from '@websolutespa/bom-core';
2
- import { getStore } from '@websolutespa/bom-mixer-store';
2
+ import { getStore } from '@websolutespa/bom-mixer-store/server';
3
3
  import { IModelStore } from '../store/store';
4
4
 
5
5
  export async function getCountries(locale?: string): Promise<INamedEntity[]> {
6
6
  const store = await getStore<IModelStore>();
7
- const items = await store.i18n_country.findMany({ locale });
7
+ const items = await store.i18n_country!.findMany({ locale });
8
8
  return items;
9
9
  }
10
10
 
11
11
  export async function getCountry(id: IEquatable, params: QueryParams = {}): Promise<INamedEntity | undefined> {
12
12
  const store = await getStore<IModelStore>();
13
- const item = await store.i18n_country.findOne(id, params);
13
+ const item = await store.i18n_country!.findOne(id, params);
14
14
  return item;
15
15
  }
16
16
 
17
17
  export async function getCountriesPagination(params: QueryParams = {}): Promise<IPaginationResult<INamedEntity>> {
18
18
  const store = await getStore<IModelStore>();
19
- const pagination = await store.i18n_country.findPaged<INamedEntity>(params);
19
+ const pagination = await store.i18n_country!.findPaged<INamedEntity>(params);
20
20
  return pagination;
21
21
  }
@@ -0,0 +1,2 @@
1
+ export * from '../route/route.interceptor';
2
+
@@ -0,0 +1,22 @@
1
+ export * from '../address/address.service';
2
+ export * from '../app/app.service';
3
+ export * from '../captions/captions.handler';
4
+ export * from '../category/category.service';
5
+ export * from '../consent_preference/consent_preference.service';
6
+ export * from '../country/country.service';
7
+ export * from '../label/label.service';
8
+ export * from '../layout/layout.service';
9
+ export * from '../lazy/lazy.service';
10
+ export * from '../locale/locale.service';
11
+ export * from '../market/market.service';
12
+ export * from '../menu/menu.service';
13
+ export * from '../page/page.service';
14
+ export * from '../province/province.service';
15
+ export * from '../redirect/redirect.service';
16
+ export * from '../region/region.service';
17
+ export * from '../route/route-revalidate.handler';
18
+ export * from '../route/route.service';
19
+ export * from '../session/session.service';
20
+ export * from '../sitemap/sitemap.handler';
21
+ export * from '../sitemap/sitemap.service';
22
+
package/src/index.ts CHANGED
@@ -1,34 +1,17 @@
1
1
  export * from './address/address';
2
- export * from './address/address.service';
3
2
  export * from './application/application';
4
- export * from './captions/captions.handler';
5
- export * from './category/category.service';
6
3
  export * from './consent_preference/consent_preference';
7
- export * from './consent_preference/consent_preference.service';
8
- export * from './country/country.service';
9
4
  export * from './gtm/gtm.service';
10
- export * from './label/label.service';
11
- export * from './layout/layout.service';
12
5
  export * from './lazy/lazy';
13
6
  export * from './link/link.service';
14
- export * from './locale/locale.service';
15
- export * from './market/market.service';
16
- export * from './menu/menu.service';
7
+ export * from './locale/locale';
17
8
  export * from './meta-data/meta-data';
18
9
  export * from './meta-data/open-graph';
19
10
  export * from './meta-data/structured-data';
20
11
  export * from './meta-data/twitter-card';
21
- export * from './page/page.service';
22
- export * from './province/province.service';
23
- export * from './redirect/redirect.service';
24
- export * from './region/region.service';
25
- export * from './route/route-revalidate.handler';
26
- export * from './route/route.interceptor';
27
- export * from './route/route.service';
12
+ export * from './page/page';
13
+ export * from './route/route';
28
14
  export * from './seo/seo.service';
29
- export * from './session/session.service';
30
- export * from './sitemap/sitemap.handler';
31
- export * from './sitemap/sitemap.service';
32
15
  export * from './store/store';
33
16
  export * from './utmz/utmz.service';
34
17
 
@@ -1,16 +1,16 @@
1
1
  import { IEquatable, ILabel, QueryParams } from '@websolutespa/bom-core';
2
- import { getStore } from '@websolutespa/bom-mixer-store';
2
+ import { getStore } from '@websolutespa/bom-mixer-store/server';
3
3
  import { IModelStore } from '../store/store';
4
4
 
5
5
  export async function getLabels(params: QueryParams = {}): Promise<ILabel[]> {
6
6
  const store = await getStore<IModelStore>();
7
- const items = await store.label.findMany(params);
7
+ const items = await store.label!.findMany(params);
8
8
  return items;
9
9
  }
10
10
 
11
11
  export async function getLabel(id: IEquatable, params: QueryParams = {}): Promise<ILabel | undefined> {
12
12
  const store = await getStore<IModelStore>();
13
- const item = await store.label.findOne(id, params);
13
+ const item = await store.label!.findOne(id, params);
14
14
  return item;
15
15
  }
16
16
 
@@ -0,0 +1,28 @@
1
+ import { IComponent, PageProps } from '@websolutespa/bom-core';
2
+ import { ILazyComponent, ILazyStaticProps, ILazyStaticPropsFunc } from './lazy';
3
+
4
+ export const LAZY_PROPS: ILazyStaticProps = {};
5
+
6
+ export async function withLazyProps<T>(key: string, getComponentProps: ILazyStaticPropsFunc<T>) {
7
+ LAZY_PROPS[key] = getComponentProps;
8
+ }
9
+
10
+ export async function getDecoratedComponents(props: PageProps, extraComponents?: IComponent[]) {
11
+ const page = props.page;
12
+ const components = [
13
+ ...(page.components || []),
14
+ ...(extraComponents || []),
15
+ ];
16
+ const decoratedComponents: ILazyComponent[] = [];
17
+ for (const component of components) {
18
+ const key = (component.blockType || component.schema || 'unkown_type') as keyof typeof LAZY_PROPS;
19
+ const getComponentProps = LAZY_PROPS[key];
20
+ if (typeof getComponentProps === 'function') {
21
+ const decoratedComponent = await getComponentProps({ ...(props as PageProps), component });
22
+ decoratedComponents.push(decoratedComponent);
23
+ } else {
24
+ decoratedComponents.push(component);
25
+ }
26
+ }
27
+ page.components = decoratedComponents;
28
+ }
package/src/lazy/lazy.ts CHANGED
@@ -39,32 +39,6 @@ export type ILazyStaticPropsFunc<T = any> = (props: ILazyFuncProps<T>) => Promis
39
39
 
40
40
  export type ILazyStaticProps = Record<string, ILazyStaticPropsFunc>;
41
41
 
42
- export const LAZY_PROPS: ILazyStaticProps = {};
43
-
44
- export function withLazyProps<T>(key: string, getComponentProps: ILazyStaticPropsFunc<T>) {
45
- LAZY_PROPS[key] = getComponentProps;
46
- }
47
-
48
- export async function getDecoratedComponents(props: PageProps, extraComponents?: IComponent[]) {
49
- const page = props.page;
50
- const components = [
51
- ...(page.components || []),
52
- ...(extraComponents || []),
53
- ];
54
- const decoratedComponents: ILazyComponent[] = [];
55
- for (const component of components) {
56
- const key = (component.blockType || component.schema || 'unkown_type') as keyof typeof LAZY_PROPS;
57
- const getComponentProps = LAZY_PROPS[key];
58
- if (typeof getComponentProps === 'function') {
59
- const decoratedComponent = await getComponentProps({ ...(props as PageProps), component });
60
- decoratedComponents.push(decoratedComponent);
61
- } else {
62
- decoratedComponents.push(component);
63
- }
64
- }
65
- page.components = decoratedComponents;
66
- }
67
-
68
42
  /*
69
43
  export const LAZY_MODULES: ILazyModules = {};
70
44
 
@@ -1,25 +1,15 @@
1
1
  import { IEquatable, ILocale, QueryParams } from '@websolutespa/bom-core';
2
- import { getStore } from '@websolutespa/bom-mixer-store';
2
+ import { getStore } from '@websolutespa/bom-mixer-store/server';
3
3
  import { IModelStore } from '../store/store';
4
4
 
5
5
  export async function getLocales(params: QueryParams = {}): Promise<ILocale[]> {
6
6
  const store = await getStore<IModelStore>();
7
- const items = await store.locale.findMany(params);
7
+ const items = await store.locale!.findMany(params);
8
8
  return items;
9
9
  }
10
10
 
11
11
  export async function getLocale(id: IEquatable, params: QueryParams = {}): Promise<ILocale | undefined> {
12
12
  const store = await getStore<IModelStore>();
13
- const item = await store.locale.findOne(id, params);
13
+ const item = await store.locale!.findOne(id, params);
14
14
  return item;
15
15
  }
16
-
17
- export function getLocaleFromProps(props?: {
18
- __NEXT_DATA__?: {
19
- query?: {
20
- locale?: string;
21
- }
22
- }
23
- }): string | undefined {
24
- return props?.__NEXT_DATA__?.query?.locale as string;
25
- }
@@ -0,0 +1,9 @@
1
+ export function getLocaleFromProps(props?: {
2
+ __NEXT_DATA__?: {
3
+ query?: {
4
+ locale?: string;
5
+ }
6
+ }
7
+ }): string | undefined {
8
+ return props?.__NEXT_DATA__?.query?.locale as string;
9
+ }
@@ -1,15 +1,15 @@
1
1
  import { IEquatable, IMarket, QueryParams } from '@websolutespa/bom-core';
2
- import { getStore } from '@websolutespa/bom-mixer-store';
2
+ import { getStore } from '@websolutespa/bom-mixer-store/server';
3
3
  import { IModelStore } from '../store/store';
4
4
 
5
5
  export async function getMarkets(params: QueryParams = {}): Promise<IMarket[]> {
6
6
  const store = await getStore<IModelStore>();
7
- const items = await store.market.findMany(params);
7
+ const items = await store.market!.findMany(params);
8
8
  return items;
9
9
  }
10
10
 
11
11
  export async function getMarket(id: IEquatable, params: QueryParams = {}): Promise<IMarket | undefined> {
12
12
  const store = await getStore<IModelStore>();
13
- const item = await store.market.findOne(id, params);
13
+ const item = await store.market!.findOne(id, params);
14
14
  return item;
15
15
  }
@@ -1,15 +1,15 @@
1
1
  import { IEquatable, IMenu, QueryParams } from '@websolutespa/bom-core';
2
- import { getStore } from '@websolutespa/bom-mixer-store';
2
+ import { getStore } from '@websolutespa/bom-mixer-store/server';
3
3
  import { IModelStore } from '../store/store';
4
4
 
5
5
  export async function getMenus(params: QueryParams = {}): Promise<IMenu[]> {
6
6
  const store = await getStore<IModelStore>();
7
- const items = await store.menu.findMany(params);
7
+ const items = await store.menu!.findMany(params);
8
8
  return items;
9
9
  }
10
10
 
11
11
  export async function getMenu(id: IEquatable, params: QueryParams = {}): Promise<IMenu | undefined> {
12
12
  const store = await getStore<IModelStore>();
13
- const item = await store.menu.findOne(id, params);
13
+ const item = await store.menu!.findOne(id, params);
14
14
  return item;
15
15
  }