@soma-vertical-web/multi-lib 0.0.48 → 0.0.49
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/cms/ContentTypes/Redirects/Redirects.d.ts +32 -0
- package/cms/ContentTypes/Search/SearchContent.d.ts +3 -0
- package/cms/ContentTypes/Search/SearchPageContent.d.ts +3 -0
- package/cms/ContentTypes/Search/SearchPageScreening.d.ts +3 -0
- package/cms/server.d.ts +30 -0
- package/index-BJzBUeMp.js +1 -0
- package/index-Ba7fQCkk.js +1 -0
- package/index-Do5eAlCL.mjs +219 -0
- package/index-VkanwPXK.mjs +221 -0
- package/index2.js +1 -1
- package/index2.mjs +322 -268
- package/package.json +1 -1
- package/types/cms/ContentTypes/Redirects/index.d.ts +4 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Redirects } from '../../../types/cms/ContentTypes/Redirects';
|
|
2
|
+
|
|
3
|
+
export declare const getRedirectData: ({ slug, ...props }: Redirects) => Promise<{
|
|
4
|
+
slug: string;
|
|
5
|
+
query: null;
|
|
6
|
+
redirect: boolean;
|
|
7
|
+
collectionId?: undefined;
|
|
8
|
+
filters?: undefined;
|
|
9
|
+
sort?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
slug: string;
|
|
12
|
+
query: null;
|
|
13
|
+
redirect: boolean;
|
|
14
|
+
collectionId: null;
|
|
15
|
+
filters: null;
|
|
16
|
+
sort: null;
|
|
17
|
+
} | {
|
|
18
|
+
slug: string;
|
|
19
|
+
query: string;
|
|
20
|
+
redirect: boolean;
|
|
21
|
+
collectionId: number;
|
|
22
|
+
filters: {
|
|
23
|
+
key: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}[];
|
|
26
|
+
sort: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const getPLPSynteticMetaData: ({ slug, ...props }: Redirects) => Promise<{
|
|
29
|
+
slug: string;
|
|
30
|
+
title: string;
|
|
31
|
+
description: string;
|
|
32
|
+
} | null>;
|
package/cms/server.d.ts
CHANGED
|
@@ -6,5 +6,35 @@ export declare const serverCMS: {
|
|
|
6
6
|
FooterContent: ({ PAYMENT_FLAGS_DICTIONARY, PAYMENT_FLAGS, LEGAL_INFORMATION_TEXT, SectionZone, ICONS, Footer, FooterSupport, ...props }: import('../types/cms/ContentTypes/Footer').FooterContentProps) => Promise<import("react/jsx-runtime").JSX.Element>;
|
|
7
7
|
PLPContent: ({ children, slug, SectionZone, COMMON_PAGE_COLUMN_GAP_PDC, PLPContentProvider, ...props }: import('../types/cms/ContentTypes/PLP').PLPContentProps) => Promise<import("react/jsx-runtime").JSX.Element>;
|
|
8
8
|
PDPContent: ({ children, productId, COMMON_PAGE_COLUMN_GAP, SectionZone, PDPContentProvider, ...props }: import('../types/cms/ContentTypes/PDP').PDPContentProps) => Promise<import("react/jsx-runtime").JSX.Element>;
|
|
9
|
+
getRedirectData: ({ slug, ...props }: import('../types/cms/ContentTypes/Redirects').Redirects) => Promise<{
|
|
10
|
+
slug: string;
|
|
11
|
+
query: null;
|
|
12
|
+
redirect: boolean;
|
|
13
|
+
collectionId?: undefined;
|
|
14
|
+
filters?: undefined;
|
|
15
|
+
sort?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
slug: string;
|
|
18
|
+
query: null;
|
|
19
|
+
redirect: boolean;
|
|
20
|
+
collectionId: null;
|
|
21
|
+
filters: null;
|
|
22
|
+
sort: null;
|
|
23
|
+
} | {
|
|
24
|
+
slug: string;
|
|
25
|
+
query: string;
|
|
26
|
+
redirect: boolean;
|
|
27
|
+
collectionId: number;
|
|
28
|
+
filters: {
|
|
29
|
+
key: string;
|
|
30
|
+
value: string;
|
|
31
|
+
}[];
|
|
32
|
+
sort: string;
|
|
33
|
+
}>;
|
|
34
|
+
getPLPSynteticMetaData: ({ slug, ...props }: import('../types/cms/ContentTypes/Redirects').Redirects) => Promise<{
|
|
35
|
+
slug: string;
|
|
36
|
+
title: string;
|
|
37
|
+
description: string;
|
|
38
|
+
} | null>;
|
|
9
39
|
};
|
|
10
40
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const l=require("react/jsx-runtime"),$=require("@soma-vertical-web/core-components"),h="fuzzy",_="operator",j=e=>({isDepartment:e!=null&&e.length?e[0].key==="category-1":!1}),k=(e,t)=>{const s=decodeURIComponent(t??"").slice(1).split("/");return e.map(o=>{if(o.key==="category-2"&&o.__typename==="FacetBoolean"){const r=o.values;return{...o,values:r.filter(a=>!s.find(n=>n.toLowerCase()===a.value||n.toLowerCase()===a.name.toLowerCase()))}}return o})},b=(e,t)=>t?e==="category-1":!1,x=e=>e.key==="operator"&&(e.value==="and"||e.value==="or"),I=e=>e.type==="TEXT",w=e=>e.key==="fuzzy"&&(e.value==="0"||e.value==="1"||e.value==="auto"),F=e=>{const{key:t,name:s,values:o}=e;return{__typename:"FacetBoolean",key:t,label:s,values:o.slice().sort((r,a)=>r.name.localeCompare(a.name))}},R=({key:e,values:t})=>({__typename:"FacetRange",key:e,values:t}),C=(e,t,s)=>{if(!(e instanceof Object)||!("facets"in e))return[];const{facets:o=[]}=e,r=t!=null&&t.length?t[0].key==="category-1":!1;return o.filter(n=>!s||!b(n.key,r)).map(n=>I(n)?F(n):R(n))},O=(e,t)=>{const s=e.find(({key:r})=>r===h)??null,o=e.find(({key:r})=>r===_)??null;s&&w(s)&&t.append(h,s.value),o&&x(o)&&t.append(_,o.value)},z=e=>e.map(t=>{const[s,o]=t.split("/");return{key:s,value:o}}),B=(e,t)=>{const s=decodeURIComponent(t??"").slice(1).split("/"),o=e.filter(({value:a})=>!s.includes(decodeURIComponent(a))).map(a=>({...a,value:decodeURIComponent(a.value)})),{isDepartment:r}=j(o);return o==null?void 0:o.filter(a=>!b(a.key,r))},T=({pathname:e,searchParams:t},s)=>{const o=t.get("sort")??"",r=t.get("query")??null,a=parseInt(t.get("page")??"1",10);return{sort:o,facets:z(s),term:r,base:r?"":e,page:a}},U=e=>{const t=new URLSearchParams;return Object.entries(e).forEach(([s,o])=>{Array.isArray(o)?o.forEach(r=>t.append(s,r)):o!==void 0&&t.append(s,o)}),t},v={"responsive-mobile-flex":"_responsive-mobile-flex_t5bry_2","responsive-desktop-flex":"_responsive-desktop-flex_t5bry_13","responsive-mobile-block":"_responsive-mobile-block_t5bry_24","responsive-desktop-block":"_responsive-desktop-block_t5bry_35"},S={},D=Object.freeze(Object.defineProperty({__proto__:null,default:S},Symbol.toStringTag,{value:"Module"})),E=({children:e,data:t,SectionZone:s,className:o})=>{var f,u;const r=((f=t==null?void 0:t.filter(i=>{var c,g;return((g=(c=i.config)==null?void 0:c.responsive)==null?void 0:g.deviceType)==="mobile"})[0])==null?void 0:f.sections)||[],a=((u=t==null?void 0:t.filter(i=>{var c,g;return((g=(c=i.config)==null?void 0:c.responsive)==null?void 0:g.deviceType)==="desktop"})[0])==null?void 0:u.sections)||[],n=r.slice(0,1),p=r.slice(1,r.length),d=a.slice(0,1),m=a.slice(1,a.length);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:o,children:[l.jsx("div",{className:v["responsive-mobile-flex"],children:l.jsx(s,{data:n??[]})}),l.jsx("div",{className:v["responsive-desktop-flex"],children:l.jsx(s,{data:d??[]})})]}),e,l.jsx("div",{className:v["responsive-mobile-flex"],children:l.jsx(s,{data:p??[]})}),l.jsx("div",{className:v["responsive-desktop-flex"],children:l.jsx(s,{data:m??[]})}),l.jsx($.Utils.Divider,{})]})};async function M({contentType:e,storeId:t,CMS_PROJECT_NAME:s,NextCookies:o}){const r=await y({contentType:e,storeId:t,CMS_PROJECT_NAME:s,NextCookies:o});if(r.status===200){const a={timestamp:new Date().toISOString(),contentType:e,data:r.data};console.log("Resultado da chamada:",r);const n=`backup-${e}-${Date.now()}.json`;return await S.writeFile(`./backups/${n}`,JSON.stringify(a,null,2),"utf-8"),{success:!0,fileName:n}}return{success:!1,error:r.error||"No data to backup"}}async function N(e){return M(e)}async function L({contentType:e,documentId:t,versionId:s,storeId:o,CMS_PROJECT_NAME:r}){const a=t&&t.length?`/${t}`:"",n=s&&s.length?`?versionId=${s}`:"";return fetch(`https://${o}.myvtex.com/_v/cms/api/${r}/${e}${a}${n}`,{cache:"no-cache"})}async function P({contentType:e,documents:t,NextCookies:s,previewId:o,CMS_PROJECT_NAME:r,storeId:a}){var p;const n=JSON.parse(o??((p=s==null?void 0:s().get("cms_preview_data"))==null?void 0:p.value)??"{}");if(n&&(n==null?void 0:n.contentType)===e){const d=n.documentId&&n.documentId.length?`/${n.documentId}`:"",m=n!=null&&n.versionId&&(n!=null&&n.versionId.length)?`?versionId=${n==null?void 0:n.versionId}`:"",u=await(await fetch(`https://${a}.myvtex.com/_v/cms/api/${r}/${e}${d}${m}`,{cache:"no-store"})).json(),i=t.filter(c=>u.id!==c.documentId);return i.unshift(u),i}return t}async function y({contentType:e,NextCookies:t,CMS_PROJECT_NAME:s,storeId:o,previewId:r}){var f,u;const a=JSON.parse(r??((f=t==null?void 0:t().get("cms_preview_data"))==null?void 0:f.value)??"{}"),n=[];let p=1,d=0,m=!0;try{do{const c=await(await fetch(`https://${o}.myvtex.com/_v/cms/api/${s}/${e}?page=${p}`)).json();p===1&&(d=c.totalItems),(u=c==null?void 0:c.data)!=null&&u.length&&n.push(...c.data),m=c.hasNextPage,p++}while(m&&n.length<d);if(a.previewMode&&n.length){const i=await P({contentType:e,documents:n,NextCookies:t,CMS_PROJECT_NAME:s,storeId:o});return{status:i.length>0?200:404,data:i??[]}}return{status:n.length?200:404,data:n}}catch(i){return{status:"error",data:[],error:i}}}const q=Object.freeze(Object.defineProperty({__proto__:null,cmsBackup:N,getCMSContentType:L,getContentType:y},Symbol.toStringTag,{value:"Module"}));exports.SearchPageScreening=E;exports.__viteBrowserExternal=D;exports.addSearchParamsFacets=O;exports.cms=q;exports.convertSearchParams=U;exports.filterNonCategorySelected=k;exports.filterNonRootFacets=B;exports.formattedFacets=C;exports.getContentType=y;exports.parseSearchState=T;exports.responsive=v;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),x=require("@soma-vertical-web/core-components"),h="fuzzy",_="operator",S=e=>({isDepartment:e!=null&&e.length?e[0].key==="category-1":!1}),$=(e,t)=>{const s=decodeURIComponent(t??"").slice(1).split("/");return e.map(n=>{if(n.key==="category-2"&&n.__typename==="FacetBoolean"){const r=n.values;return{...n,values:r.filter(o=>!s.find(a=>a.toLowerCase()===o.value||a.toLowerCase()===o.name.toLowerCase()))}}return n})},b=(e,t)=>t?e==="category-1":!1,j=e=>e.key==="operator"&&(e.value==="and"||e.value==="or"),C=e=>e.type==="TEXT",I=e=>e.key==="fuzzy"&&(e.value==="0"||e.value==="1"||e.value==="auto"),w=e=>{const{key:t,name:s,values:n}=e;return{__typename:"FacetBoolean",key:t,label:s,values:n.slice().sort((r,o)=>r.name.localeCompare(o.name))}},F=({key:e,values:t})=>({__typename:"FacetRange",key:e,values:t}),N=(e,t,s)=>{if(!(e instanceof Object)||!("facets"in e))return[];const{facets:n=[]}=e,r=t!=null&&t.length?t[0].key==="category-1":!1;return n.filter(a=>!s||!b(a.key,r)).map(a=>C(a)?w(a):F(a))},R=(e,t)=>{const s=e.find(({key:r})=>r===h)??null,n=e.find(({key:r})=>r===_)??null;s&&I(s)&&t.append(h,s.value),n&&j(n)&&t.append(_,n.value)},O=e=>e.map(t=>{const[s,n]=t.split("/");return{key:s,value:n}}),z=(e,t)=>{const s=decodeURIComponent(t??"").slice(1).split("/"),n=e.filter(({value:o})=>!s.includes(decodeURIComponent(o))).map(o=>({...o,value:decodeURIComponent(o.value)})),{isDepartment:r}=S(n);return n==null?void 0:n.filter(o=>!b(o.key,r))},B=({pathname:e,searchParams:t},s)=>{const n=t.get("sort")??"",r=t.get("query")??null,o=parseInt(t.get("page")??"1",10);return{sort:n,facets:O(s),term:r,base:r?"":e,page:o}},T=e=>{const t=new URLSearchParams;return Object.entries(e).forEach(([s,n])=>{Array.isArray(n)?n.forEach(r=>t.append(s,r)):n!==void 0&&t.append(s,n)}),t},v={"responsive-mobile-flex":"_responsive-mobile-flex_t5bry_2","responsive-desktop-flex":"_responsive-desktop-flex_t5bry_13","responsive-mobile-block":"_responsive-mobile-block_t5bry_24","responsive-desktop-block":"_responsive-desktop-block_t5bry_35"},k={},U=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"})),D=({children:e,data:t,SectionZone:s,className:n})=>{var p,l;const r=((p=t==null?void 0:t.filter(c=>{var f,g;return((g=(f=c.config)==null?void 0:f.responsive)==null?void 0:g.deviceType)==="mobile"})[0])==null?void 0:p.sections)||[],o=((l=t==null?void 0:t.filter(c=>{var f,g;return((g=(f=c.config)==null?void 0:f.responsive)==null?void 0:g.deviceType)==="desktop"})[0])==null?void 0:l.sections)||[],a=r.slice(0,1),u=r.slice(1,r.length),d=o.slice(0,1),m=o.slice(1,o.length);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:n,children:[i.jsx("div",{className:v["responsive-mobile-flex"],children:i.jsx(s,{data:a??[]})}),i.jsx("div",{className:v["responsive-desktop-flex"],children:i.jsx(s,{data:d??[]})})]}),e,i.jsx("div",{className:v["responsive-mobile-flex"],children:i.jsx(s,{data:u??[]})}),i.jsx("div",{className:v["responsive-desktop-flex"],children:i.jsx(s,{data:m??[]})}),i.jsx(x.Utils.Divider,{})]})};async function E({contentType:e,storeId:t,CMS_PROJECT_NAME:s,NextCookies:n}){const r=await y({contentType:e,storeId:t,CMS_PROJECT_NAME:s,NextCookies:n});if(r.status===200){const o={timestamp:new Date().toISOString(),contentType:e,data:r.data};console.log("Resultado da chamada:",r);const a=`backup-${e}-${Date.now()}.json`;return await k.writeFile(`./backups/${a}`,JSON.stringify(o,null,2),"utf-8"),{success:!0,fileName:a}}return{success:!1,error:r.error||"No data to backup"}}async function M(e){return E(e)}async function L({contentType:e,documentId:t,versionId:s,storeId:n,CMS_PROJECT_NAME:r}){const o=t&&t.length?`/${t}`:"",a=s&&s.length?`?versionId=${s}`:"";return fetch(`https://${n}.myvtex.com/_v/cms/api/${r}/${e}${o}${a}`,{cache:"no-cache"})}async function P({contentType:e,documents:t,NextCookies:s,CMS_PROJECT_NAME:n,storeId:r}){var a;const o=JSON.parse(((a=s().get("cms_preview_data"))==null?void 0:a.value)??"{}");if(o&&(o==null?void 0:o.contentType)===e){const u=o.documentId&&o.documentId.length?`/${o.documentId}`:"",d=o!=null&&o.versionId&&(o!=null&&o.versionId.length)?`?versionId=${o==null?void 0:o.versionId}`:"",p=await(await fetch(`https://${r}.myvtex.com/_v/cms/api/${n}/${e}${u}${d}`,{cache:"no-store"})).json(),l=t.filter(c=>p.id!==c.documentId);return l.unshift(p),l}return t}async function y({contentType:e,NextCookies:t,CMS_PROJECT_NAME:s,storeId:n}){var m,p;const r=JSON.parse(((m=t().get("cms_preview_data"))==null?void 0:m.value)??"{}"),o=[];let a=1,u=0,d=!0;try{do{const c=await(await fetch(`https://${n}.myvtex.com/_v/cms/api/${s}/${e}?page=${a}`)).json();a===1&&(u=c.totalItems),(p=c==null?void 0:c.data)!=null&&p.length&&o.push(...c.data),d=c.hasNextPage,a++}while(d&&o.length<u);if(r.previewMode&&o.length){const l=await P({contentType:e,documents:o,NextCookies:t,CMS_PROJECT_NAME:s,storeId:n});return{status:l.length>0?200:404,data:l??[]}}return{status:o.length?200:404,data:o}}catch(l){return{status:"error",data:[],error:l}}}const q=Object.freeze(Object.defineProperty({__proto__:null,cmsBackup:M,getCMSContentType:L,getContentType:y},Symbol.toStringTag,{value:"Module"}));exports.SearchPageScreening=D;exports.__viteBrowserExternal=U;exports.addSearchParamsFacets=R;exports.cms=q;exports.convertSearchParams=T;exports.filterNonCategorySelected=$;exports.filterNonRootFacets=z;exports.formattedFacets=N;exports.getContentType=y;exports.parseSearchState=B;exports.responsive=v;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { jsxs as y, Fragment as C, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { Utils as I } from "@soma-vertical-web/core-components";
|
|
3
|
+
const h = "fuzzy", b = "operator", x = (e) => ({
|
|
4
|
+
isDepartment: e != null && e.length ? e[0].key === "category-1" : !1
|
|
5
|
+
}), E = (e, t) => {
|
|
6
|
+
const s = decodeURIComponent(t ?? "").slice(1).split("/");
|
|
7
|
+
return e.map((n) => {
|
|
8
|
+
if (n.key === "category-2" && n.__typename === "FacetBoolean") {
|
|
9
|
+
const r = n.values;
|
|
10
|
+
return {
|
|
11
|
+
...n,
|
|
12
|
+
values: r.filter(
|
|
13
|
+
(o) => !s.find(
|
|
14
|
+
(a) => a.toLowerCase() === o.value || a.toLowerCase() === o.name.toLowerCase()
|
|
15
|
+
)
|
|
16
|
+
)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return n;
|
|
20
|
+
});
|
|
21
|
+
}, _ = (e, t) => t ? e === "category-1" : !1, S = (e) => e.key === "operator" && (e.value === "and" || e.value === "or"), w = (e) => e.type === "TEXT", O = (e) => e.key === "fuzzy" && (e.value === "0" || e.value === "1" || e.value === "auto"), N = (e) => {
|
|
22
|
+
const { key: t, name: s, values: n } = e;
|
|
23
|
+
return {
|
|
24
|
+
__typename: "FacetBoolean",
|
|
25
|
+
key: t,
|
|
26
|
+
label: s,
|
|
27
|
+
values: n.slice().sort((r, o) => r.name.localeCompare(o.name))
|
|
28
|
+
};
|
|
29
|
+
}, R = ({ key: e, values: t }) => ({
|
|
30
|
+
__typename: "FacetRange",
|
|
31
|
+
key: e,
|
|
32
|
+
values: t
|
|
33
|
+
}), M = (e, t, s) => {
|
|
34
|
+
if (!(e instanceof Object) || !("facets" in e))
|
|
35
|
+
return [];
|
|
36
|
+
const { facets: n = [] } = e, r = t != null && t.length ? t[0].key === "category-1" : !1;
|
|
37
|
+
return n.filter(
|
|
38
|
+
(a) => !s || !_(a.key, r)
|
|
39
|
+
).map(
|
|
40
|
+
(a) => w(a) ? N(a) : R(a)
|
|
41
|
+
);
|
|
42
|
+
}, L = (e, t) => {
|
|
43
|
+
const s = e.find(({ key: r }) => r === h) ?? null, n = e.find(({ key: r }) => r === b) ?? null;
|
|
44
|
+
s && O(s) && t.append(h, s.value), n && S(n) && t.append(b, n.value);
|
|
45
|
+
}, j = (e) => e.map((t) => {
|
|
46
|
+
const [s, n] = t.split("/");
|
|
47
|
+
return { key: s, value: n };
|
|
48
|
+
}), Y = (e, t) => {
|
|
49
|
+
const s = decodeURIComponent(t ?? "").slice(1).split("/"), n = e.filter(({ value: o }) => !s.includes(decodeURIComponent(o))).map((o) => ({
|
|
50
|
+
...o,
|
|
51
|
+
value: decodeURIComponent(o.value)
|
|
52
|
+
})), { isDepartment: r } = x(n);
|
|
53
|
+
return n == null ? void 0 : n.filter((o) => !_(o.key, r));
|
|
54
|
+
}, A = ({ pathname: e, searchParams: t }, s) => {
|
|
55
|
+
const n = t.get("sort") ?? "", r = t.get("query") ?? null, o = parseInt(t.get("page") ?? "1", 10);
|
|
56
|
+
return {
|
|
57
|
+
sort: n,
|
|
58
|
+
facets: j(s),
|
|
59
|
+
term: r,
|
|
60
|
+
base: r ? "" : e,
|
|
61
|
+
page: o
|
|
62
|
+
};
|
|
63
|
+
}, J = (e) => {
|
|
64
|
+
const t = new URLSearchParams();
|
|
65
|
+
return Object.entries(e).forEach(([s, n]) => {
|
|
66
|
+
Array.isArray(n) ? n.forEach((r) => t.append(s, r)) : n !== void 0 && t.append(s, n);
|
|
67
|
+
}), t;
|
|
68
|
+
}, v = {
|
|
69
|
+
"responsive-mobile-flex": "_responsive-mobile-flex_t5bry_2",
|
|
70
|
+
"responsive-desktop-flex": "_responsive-desktop-flex_t5bry_13",
|
|
71
|
+
"responsive-mobile-block": "_responsive-mobile-block_t5bry_24",
|
|
72
|
+
"responsive-desktop-block": "_responsive-desktop-block_t5bry_35"
|
|
73
|
+
}, k = {}, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
74
|
+
__proto__: null,
|
|
75
|
+
default: k
|
|
76
|
+
}, Symbol.toStringTag, { value: "Module" })), V = ({
|
|
77
|
+
children: e,
|
|
78
|
+
data: t,
|
|
79
|
+
SectionZone: s,
|
|
80
|
+
className: n
|
|
81
|
+
}) => {
|
|
82
|
+
var p, i;
|
|
83
|
+
const r = ((p = t == null ? void 0 : t.filter((c) => {
|
|
84
|
+
var f, g;
|
|
85
|
+
return ((g = (f = c.config) == null ? void 0 : f.responsive) == null ? void 0 : g.deviceType) === "mobile";
|
|
86
|
+
})[0]) == null ? void 0 : p.sections) || [], o = ((i = t == null ? void 0 : t.filter((c) => {
|
|
87
|
+
var f, g;
|
|
88
|
+
return ((g = (f = c.config) == null ? void 0 : f.responsive) == null ? void 0 : g.deviceType) === "desktop";
|
|
89
|
+
})[0]) == null ? void 0 : i.sections) || [], a = r.slice(0, 1), u = r.slice(1, r.length), d = o.slice(0, 1), m = o.slice(1, o.length);
|
|
90
|
+
return /* @__PURE__ */ y(C, { children: [
|
|
91
|
+
/* @__PURE__ */ y("div", { className: n, children: [
|
|
92
|
+
/* @__PURE__ */ l("div", { className: v["responsive-mobile-flex"], children: /* @__PURE__ */ l(s, { data: a ?? [] }) }),
|
|
93
|
+
/* @__PURE__ */ l("div", { className: v["responsive-desktop-flex"], children: /* @__PURE__ */ l(s, { data: d ?? [] }) })
|
|
94
|
+
] }),
|
|
95
|
+
e,
|
|
96
|
+
/* @__PURE__ */ l("div", { className: v["responsive-mobile-flex"], children: /* @__PURE__ */ l(s, { data: u ?? [] }) }),
|
|
97
|
+
/* @__PURE__ */ l("div", { className: v["responsive-desktop-flex"], children: /* @__PURE__ */ l(s, { data: m ?? [] }) }),
|
|
98
|
+
/* @__PURE__ */ l(I.Divider, {})
|
|
99
|
+
] });
|
|
100
|
+
};
|
|
101
|
+
async function z({ contentType: e, storeId: t, CMS_PROJECT_NAME: s, NextCookies: n }) {
|
|
102
|
+
const r = await $({
|
|
103
|
+
contentType: e,
|
|
104
|
+
storeId: t,
|
|
105
|
+
CMS_PROJECT_NAME: s,
|
|
106
|
+
NextCookies: n
|
|
107
|
+
});
|
|
108
|
+
if (r.status === 200) {
|
|
109
|
+
const o = {
|
|
110
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
111
|
+
contentType: e,
|
|
112
|
+
data: r.data
|
|
113
|
+
};
|
|
114
|
+
console.log("Resultado da chamada:", r);
|
|
115
|
+
const a = `backup-${e}-${Date.now()}.json`;
|
|
116
|
+
return await k.writeFile(
|
|
117
|
+
`./backups/${a}`,
|
|
118
|
+
JSON.stringify(o, null, 2),
|
|
119
|
+
"utf-8"
|
|
120
|
+
), { success: !0, fileName: a };
|
|
121
|
+
}
|
|
122
|
+
return { success: !1, error: r.error || "No data to backup" };
|
|
123
|
+
}
|
|
124
|
+
async function F(e) {
|
|
125
|
+
return z(e);
|
|
126
|
+
}
|
|
127
|
+
async function B({
|
|
128
|
+
contentType: e,
|
|
129
|
+
documentId: t,
|
|
130
|
+
versionId: s,
|
|
131
|
+
storeId: n,
|
|
132
|
+
CMS_PROJECT_NAME: r
|
|
133
|
+
}) {
|
|
134
|
+
const o = t && t.length ? `/${t}` : "", a = s && s.length ? `?versionId=${s}` : "";
|
|
135
|
+
return fetch(
|
|
136
|
+
`https://${n}.myvtex.com/_v/cms/api/${r}/${e}${o}${a}`,
|
|
137
|
+
{ cache: "no-cache" }
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
async function T({
|
|
141
|
+
contentType: e,
|
|
142
|
+
documents: t,
|
|
143
|
+
NextCookies: s,
|
|
144
|
+
CMS_PROJECT_NAME: n,
|
|
145
|
+
storeId: r
|
|
146
|
+
}) {
|
|
147
|
+
var a;
|
|
148
|
+
const o = JSON.parse(
|
|
149
|
+
((a = s().get("cms_preview_data")) == null ? void 0 : a.value) ?? "{}"
|
|
150
|
+
);
|
|
151
|
+
if (o && (o == null ? void 0 : o.contentType) === e) {
|
|
152
|
+
const u = o.documentId && o.documentId.length ? `/${o.documentId}` : "", d = o != null && o.versionId && (o != null && o.versionId.length) ? `?versionId=${o == null ? void 0 : o.versionId}` : "", p = await (await fetch(
|
|
153
|
+
`https://${r}.myvtex.com/_v/cms/api/${n}/${e}${u}${d}`,
|
|
154
|
+
{ cache: "no-store" }
|
|
155
|
+
)).json(), i = t.filter(
|
|
156
|
+
(c) => p.id !== c.documentId
|
|
157
|
+
);
|
|
158
|
+
return i.unshift(p), i;
|
|
159
|
+
}
|
|
160
|
+
return t;
|
|
161
|
+
}
|
|
162
|
+
async function $({
|
|
163
|
+
contentType: e,
|
|
164
|
+
NextCookies: t,
|
|
165
|
+
CMS_PROJECT_NAME: s,
|
|
166
|
+
storeId: n
|
|
167
|
+
}) {
|
|
168
|
+
var m, p;
|
|
169
|
+
const r = JSON.parse(
|
|
170
|
+
((m = t().get("cms_preview_data")) == null ? void 0 : m.value) ?? "{}"
|
|
171
|
+
), o = [];
|
|
172
|
+
let a = 1, u = 0, d = !0;
|
|
173
|
+
try {
|
|
174
|
+
do {
|
|
175
|
+
const c = await (await fetch(
|
|
176
|
+
`https://${n}.myvtex.com/_v/cms/api/${s}/${e}?page=${a}`
|
|
177
|
+
)).json();
|
|
178
|
+
a === 1 && (u = c.totalItems), (p = c == null ? void 0 : c.data) != null && p.length && o.push(...c.data), d = c.hasNextPage, a++;
|
|
179
|
+
} while (d && o.length < u);
|
|
180
|
+
if (r.previewMode && o.length) {
|
|
181
|
+
const i = await T({
|
|
182
|
+
contentType: e,
|
|
183
|
+
documents: o,
|
|
184
|
+
NextCookies: t,
|
|
185
|
+
CMS_PROJECT_NAME: s,
|
|
186
|
+
storeId: n
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
status: i.length > 0 ? 200 : 404,
|
|
190
|
+
data: i ?? []
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
status: o.length ? 200 : 404,
|
|
195
|
+
data: o
|
|
196
|
+
};
|
|
197
|
+
} catch (i) {
|
|
198
|
+
return { status: "error", data: [], error: i };
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
202
|
+
__proto__: null,
|
|
203
|
+
cmsBackup: F,
|
|
204
|
+
getCMSContentType: B,
|
|
205
|
+
getContentType: $
|
|
206
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
207
|
+
export {
|
|
208
|
+
V as S,
|
|
209
|
+
K as _,
|
|
210
|
+
L as a,
|
|
211
|
+
E as b,
|
|
212
|
+
J as c,
|
|
213
|
+
Y as d,
|
|
214
|
+
q as e,
|
|
215
|
+
M as f,
|
|
216
|
+
$ as g,
|
|
217
|
+
A as p,
|
|
218
|
+
v as r
|
|
219
|
+
};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { jsxs as y, Fragment as I, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { Utils as S } from "@soma-vertical-web/core-components";
|
|
3
|
+
const h = "fuzzy", b = "operator", w = (e) => ({
|
|
4
|
+
isDepartment: e != null && e.length ? e[0].key === "category-1" : !1
|
|
5
|
+
}), M = (e, t) => {
|
|
6
|
+
const s = decodeURIComponent(t ?? "").slice(1).split("/");
|
|
7
|
+
return e.map((o) => {
|
|
8
|
+
if (o.key === "category-2" && o.__typename === "FacetBoolean") {
|
|
9
|
+
const r = o.values;
|
|
10
|
+
return {
|
|
11
|
+
...o,
|
|
12
|
+
values: r.filter(
|
|
13
|
+
(a) => !s.find(
|
|
14
|
+
(n) => n.toLowerCase() === a.value || n.toLowerCase() === a.name.toLowerCase()
|
|
15
|
+
)
|
|
16
|
+
)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return o;
|
|
20
|
+
});
|
|
21
|
+
}, _ = (e, t) => t ? e === "category-1" : !1, O = (e) => e.key === "operator" && (e.value === "and" || e.value === "or"), R = (e) => e.type === "TEXT", j = (e) => e.key === "fuzzy" && (e.value === "0" || e.value === "1" || e.value === "auto"), z = (e) => {
|
|
22
|
+
const { key: t, name: s, values: o } = e;
|
|
23
|
+
return {
|
|
24
|
+
__typename: "FacetBoolean",
|
|
25
|
+
key: t,
|
|
26
|
+
label: s,
|
|
27
|
+
values: o.slice().sort((r, a) => r.name.localeCompare(a.name))
|
|
28
|
+
};
|
|
29
|
+
}, F = ({ key: e, values: t }) => ({
|
|
30
|
+
__typename: "FacetRange",
|
|
31
|
+
key: e,
|
|
32
|
+
values: t
|
|
33
|
+
}), L = (e, t, s) => {
|
|
34
|
+
if (!(e instanceof Object) || !("facets" in e))
|
|
35
|
+
return [];
|
|
36
|
+
const { facets: o = [] } = e, r = t != null && t.length ? t[0].key === "category-1" : !1;
|
|
37
|
+
return o.filter(
|
|
38
|
+
(n) => !s || !_(n.key, r)
|
|
39
|
+
).map(
|
|
40
|
+
(n) => R(n) ? z(n) : F(n)
|
|
41
|
+
);
|
|
42
|
+
}, N = (e, t) => {
|
|
43
|
+
const s = e.find(({ key: r }) => r === h) ?? null, o = e.find(({ key: r }) => r === b) ?? null;
|
|
44
|
+
s && j(s) && t.append(h, s.value), o && O(o) && t.append(b, o.value);
|
|
45
|
+
}, C = (e) => e.map((t) => {
|
|
46
|
+
const [s, o] = t.split("/");
|
|
47
|
+
return { key: s, value: o };
|
|
48
|
+
}), Y = (e, t) => {
|
|
49
|
+
const s = decodeURIComponent(t ?? "").slice(1).split("/"), o = e.filter(({ value: a }) => !s.includes(decodeURIComponent(a))).map((a) => ({
|
|
50
|
+
...a,
|
|
51
|
+
value: decodeURIComponent(a.value)
|
|
52
|
+
})), { isDepartment: r } = w(o);
|
|
53
|
+
return o == null ? void 0 : o.filter((a) => !_(a.key, r));
|
|
54
|
+
}, A = ({ pathname: e, searchParams: t }, s) => {
|
|
55
|
+
const o = t.get("sort") ?? "", r = t.get("query") ?? null, a = parseInt(t.get("page") ?? "1", 10);
|
|
56
|
+
return {
|
|
57
|
+
sort: o,
|
|
58
|
+
facets: C(s),
|
|
59
|
+
term: r,
|
|
60
|
+
base: r ? "" : e,
|
|
61
|
+
page: a
|
|
62
|
+
};
|
|
63
|
+
}, J = (e) => {
|
|
64
|
+
const t = new URLSearchParams();
|
|
65
|
+
return Object.entries(e).forEach(([s, o]) => {
|
|
66
|
+
Array.isArray(o) ? o.forEach((r) => t.append(s, r)) : o !== void 0 && t.append(s, o);
|
|
67
|
+
}), t;
|
|
68
|
+
}, v = {
|
|
69
|
+
"responsive-mobile-flex": "_responsive-mobile-flex_t5bry_2",
|
|
70
|
+
"responsive-desktop-flex": "_responsive-desktop-flex_t5bry_13",
|
|
71
|
+
"responsive-mobile-block": "_responsive-mobile-block_t5bry_24",
|
|
72
|
+
"responsive-desktop-block": "_responsive-desktop-block_t5bry_35"
|
|
73
|
+
}, $ = {}, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
74
|
+
__proto__: null,
|
|
75
|
+
default: $
|
|
76
|
+
}, Symbol.toStringTag, { value: "Module" })), V = ({
|
|
77
|
+
children: e,
|
|
78
|
+
data: t,
|
|
79
|
+
SectionZone: s,
|
|
80
|
+
className: o
|
|
81
|
+
}) => {
|
|
82
|
+
var f, u;
|
|
83
|
+
const r = ((f = t == null ? void 0 : t.filter((l) => {
|
|
84
|
+
var c, g;
|
|
85
|
+
return ((g = (c = l.config) == null ? void 0 : c.responsive) == null ? void 0 : g.deviceType) === "mobile";
|
|
86
|
+
})[0]) == null ? void 0 : f.sections) || [], a = ((u = t == null ? void 0 : t.filter((l) => {
|
|
87
|
+
var c, g;
|
|
88
|
+
return ((g = (c = l.config) == null ? void 0 : c.responsive) == null ? void 0 : g.deviceType) === "desktop";
|
|
89
|
+
})[0]) == null ? void 0 : u.sections) || [], n = r.slice(0, 1), p = r.slice(1, r.length), d = a.slice(0, 1), m = a.slice(1, a.length);
|
|
90
|
+
return /* @__PURE__ */ y(I, { children: [
|
|
91
|
+
/* @__PURE__ */ y("div", { className: o, children: [
|
|
92
|
+
/* @__PURE__ */ i("div", { className: v["responsive-mobile-flex"], children: /* @__PURE__ */ i(s, { data: n ?? [] }) }),
|
|
93
|
+
/* @__PURE__ */ i("div", { className: v["responsive-desktop-flex"], children: /* @__PURE__ */ i(s, { data: d ?? [] }) })
|
|
94
|
+
] }),
|
|
95
|
+
e,
|
|
96
|
+
/* @__PURE__ */ i("div", { className: v["responsive-mobile-flex"], children: /* @__PURE__ */ i(s, { data: p ?? [] }) }),
|
|
97
|
+
/* @__PURE__ */ i("div", { className: v["responsive-desktop-flex"], children: /* @__PURE__ */ i(s, { data: m ?? [] }) }),
|
|
98
|
+
/* @__PURE__ */ i(S.Divider, {})
|
|
99
|
+
] });
|
|
100
|
+
};
|
|
101
|
+
async function x({ contentType: e, storeId: t, CMS_PROJECT_NAME: s, NextCookies: o }) {
|
|
102
|
+
const r = await k({
|
|
103
|
+
contentType: e,
|
|
104
|
+
storeId: t,
|
|
105
|
+
CMS_PROJECT_NAME: s,
|
|
106
|
+
NextCookies: o
|
|
107
|
+
});
|
|
108
|
+
if (r.status === 200) {
|
|
109
|
+
const a = {
|
|
110
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
111
|
+
contentType: e,
|
|
112
|
+
data: r.data
|
|
113
|
+
};
|
|
114
|
+
console.log("Resultado da chamada:", r);
|
|
115
|
+
const n = `backup-${e}-${Date.now()}.json`;
|
|
116
|
+
return await $.writeFile(
|
|
117
|
+
`./backups/${n}`,
|
|
118
|
+
JSON.stringify(a, null, 2),
|
|
119
|
+
"utf-8"
|
|
120
|
+
), { success: !0, fileName: n };
|
|
121
|
+
}
|
|
122
|
+
return { success: !1, error: r.error || "No data to backup" };
|
|
123
|
+
}
|
|
124
|
+
async function B(e) {
|
|
125
|
+
return x(e);
|
|
126
|
+
}
|
|
127
|
+
async function T({
|
|
128
|
+
contentType: e,
|
|
129
|
+
documentId: t,
|
|
130
|
+
versionId: s,
|
|
131
|
+
storeId: o,
|
|
132
|
+
CMS_PROJECT_NAME: r
|
|
133
|
+
}) {
|
|
134
|
+
const a = t && t.length ? `/${t}` : "", n = s && s.length ? `?versionId=${s}` : "";
|
|
135
|
+
return fetch(
|
|
136
|
+
`https://${o}.myvtex.com/_v/cms/api/${r}/${e}${a}${n}`,
|
|
137
|
+
{ cache: "no-cache" }
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
async function U({
|
|
141
|
+
contentType: e,
|
|
142
|
+
documents: t,
|
|
143
|
+
NextCookies: s,
|
|
144
|
+
previewId: o,
|
|
145
|
+
CMS_PROJECT_NAME: r,
|
|
146
|
+
storeId: a
|
|
147
|
+
}) {
|
|
148
|
+
var p;
|
|
149
|
+
const n = JSON.parse(
|
|
150
|
+
o ?? ((p = s == null ? void 0 : s().get("cms_preview_data")) == null ? void 0 : p.value) ?? "{}"
|
|
151
|
+
);
|
|
152
|
+
if (n && (n == null ? void 0 : n.contentType) === e) {
|
|
153
|
+
const d = n.documentId && n.documentId.length ? `/${n.documentId}` : "", m = n != null && n.versionId && (n != null && n.versionId.length) ? `?versionId=${n == null ? void 0 : n.versionId}` : "", u = await (await fetch(
|
|
154
|
+
`https://${a}.myvtex.com/_v/cms/api/${r}/${e}${d}${m}`,
|
|
155
|
+
{ cache: "no-store" }
|
|
156
|
+
)).json(), l = t.filter(
|
|
157
|
+
(c) => u.id !== c.documentId
|
|
158
|
+
);
|
|
159
|
+
return l.unshift(u), l;
|
|
160
|
+
}
|
|
161
|
+
return t;
|
|
162
|
+
}
|
|
163
|
+
async function k({
|
|
164
|
+
contentType: e,
|
|
165
|
+
NextCookies: t,
|
|
166
|
+
CMS_PROJECT_NAME: s,
|
|
167
|
+
storeId: o,
|
|
168
|
+
previewId: r
|
|
169
|
+
}) {
|
|
170
|
+
var f, u;
|
|
171
|
+
const a = JSON.parse(
|
|
172
|
+
r ?? ((f = t == null ? void 0 : t().get("cms_preview_data")) == null ? void 0 : f.value) ?? "{}"
|
|
173
|
+
), n = [];
|
|
174
|
+
let p = 1, d = 0, m = !0;
|
|
175
|
+
try {
|
|
176
|
+
do {
|
|
177
|
+
const c = await (await fetch(
|
|
178
|
+
`https://${o}.myvtex.com/_v/cms/api/${s}/${e}?page=${p}`
|
|
179
|
+
)).json();
|
|
180
|
+
p === 1 && (d = c.totalItems), (u = c == null ? void 0 : c.data) != null && u.length && n.push(...c.data), m = c.hasNextPage, p++;
|
|
181
|
+
} while (m && n.length < d);
|
|
182
|
+
if (a.previewMode && n.length) {
|
|
183
|
+
const l = await U({
|
|
184
|
+
contentType: e,
|
|
185
|
+
documents: n,
|
|
186
|
+
NextCookies: t,
|
|
187
|
+
CMS_PROJECT_NAME: s,
|
|
188
|
+
storeId: o
|
|
189
|
+
});
|
|
190
|
+
return {
|
|
191
|
+
status: l.length > 0 ? 200 : 404,
|
|
192
|
+
data: l ?? []
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
status: n.length ? 200 : 404,
|
|
197
|
+
data: n
|
|
198
|
+
};
|
|
199
|
+
} catch (l) {
|
|
200
|
+
return { status: "error", data: [], error: l };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
204
|
+
__proto__: null,
|
|
205
|
+
cmsBackup: B,
|
|
206
|
+
getCMSContentType: T,
|
|
207
|
+
getContentType: k
|
|
208
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
209
|
+
export {
|
|
210
|
+
V as S,
|
|
211
|
+
K as _,
|
|
212
|
+
N as a,
|
|
213
|
+
M as b,
|
|
214
|
+
J as c,
|
|
215
|
+
Y as d,
|
|
216
|
+
q as e,
|
|
217
|
+
L as f,
|
|
218
|
+
k as g,
|
|
219
|
+
A as p,
|
|
220
|
+
v as r
|
|
221
|
+
};
|