@soma-vertical-web/multi-lib 0.0.27 → 0.0.28
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/data/api/checkout/address/index.d.ts +21 -0
- package/data/api/checkout/index.d.ts +4 -0
- package/data/api/checkout/order-form/attachments/index.d.ts +17 -0
- package/data/api/checkout/order-form/attachments/marketing-data/index.d.ts +21 -0
- package/data/api/checkout/order-form/attachments/open-text-field/index.d.ts +18 -0
- package/data/api/checkout/order-form/coupon/index.d.ts +15 -0
- package/data/api/checkout/order-form/custom-data/index.d.ts +17 -0
- package/data/api/checkout/order-form/index.d.ts +14 -0
- package/data/api/checkout/order-form/items/remove-all/index.d.ts +13 -0
- package/data/api/checkout/order-form/items/update/index.d.ts +43 -0
- package/data/api/checkout/order-form/messages/remove-all/index.d.ts +13 -0
- package/data/api/checkout/order-form/offerings/index.d.ts +19 -0
- package/data/api/checkout/order-form/orderform/index.d.ts +14 -0
- package/data/api/checkout/order-form/profile/index.d.ts +25 -0
- package/data/api/checkout/order-form/seller-code/index.d.ts +13 -0
- package/data/api/checkout/order-form/shipping/index.d.ts +17 -0
- package/data/api/checkout/order-form/shipping/update/index.d.ts +36 -0
- package/data/api/checkout/region/index.d.ts +33 -0
- package/data/api/checkout/simulation/index.d.ts +20 -7
- package/data/api/fetchVtex.d.ts +2 -10
- package/data/helpers/cart/index.d.ts +4 -4
- package/index.js +17 -17
- package/index.mjs +3846 -3522
- package/index2.js +1 -1
- package/index2.mjs +455 -75
- package/layout/index.d.ts +1 -0
- package/package.json +1 -1
- package/server.d.ts +150 -3
- package/style.css +1 -1
- package/types/constants.d.ts +2 -3
- package/types/contexts/store/cart.d.ts +4 -0
- package/types/data/api/index.d.ts +16 -0
package/index2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("yup");function g(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(n,o,s.get?s:{enumerable:!0,get:()=>t[o]})}}return n.default=t,Object.freeze(n)}const a=g(p),h=a.object({country:a.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:a.string().nullable()}),y=["allowManualPrice","canEditData","checkedInPickupPointId","clientPreferencesData","clientProfileData","commercialConditionData","giftRegistryData","hooksData","ignoreProfileData","invoiceData","isCheckedIn","itemsOrdination","merchantContextData","purchaseAgentsData","ratesAndBenefitsData","selectableGifts","storeId","storePreferencesData","subscriptionData","userProfileId","userType"],b=(t,n)=>(n.forEach(o=>delete t[o]),t),I=async(t,n={})=>{const{method:o="GET",body:s,headers:l={},skipSanitize:e=!1}=n;try{const r=await fetch(t,{method:o,headers:{...l,Accept:"application/json","Content-Type":"application/json"},...s?{body:JSON.stringify(s)}:{}}).then(c=>c.json()).catch(c=>{console.error("[ERROR FETCH VTEX]",c)});return e?r:b(r,y)}catch(r){throw console.error("[ERROR FETCH ORDER]",r),r}},v=a.object({id:a.string().required("ID of SKU is required"),quantity:a.number().integer().required("Quantity of item is required"),seller:a.string()}),O=a.object({items:a.array().of(v),country:h.fields.country,postalCode:h.fields.postalCode,geoCoordinates:a.array().nullable().of(a.number()).length(2)});async function j({apiUrl:t,body:n,options:o}){return await O.validate(n),I(`${t}/api/checkout/pub/orderForms/simulation`,{method:"POST",body:n,...o})}async function S({contentType:t,documents:n,NextCookies:o,CMS_PROJECT_NAME:s,storeId:l}){var r;const e=JSON.parse(((r=o().get("cms_preview_data"))==null?void 0:r.value)??"{}");if(e&&(e==null?void 0:e.contentType)===t){const c=e.documentId&&e.documentId.length?`/${e.documentId}`:"",f=e!=null&&e.versionId&&(e!=null&&e.versionId.length)?`?versionId=${e==null?void 0:e.versionId}`:"",d=await(await fetch(`https://${l}.myvtex.com/_v/cms/api/${s}/${t}${c}${f}`,{cache:"no-store"})).json(),i=n.filter(u=>d.id!==u.documentId);return i.unshift(d),i}return n}async function D({contentType:t,NextCookies:n,CMS_PROJECT_NAME:o,storeId:s}){var m,d;const l=JSON.parse(((m=n().get("cms_preview_data"))==null?void 0:m.value)??"{}"),e=[];let r=1,c=0,f=!0;try{do{const u=await(await fetch(`https://${s}.myvtex.com/_v/cms/api/${o}/${t}?page=${r}`)).json();r===1&&(c=u.totalItems),(d=u==null?void 0:u.data)!=null&&d.length&&e.push(...u.data),f=u.hasNextPage,r++}while(f&&e.length<c);if(l.previewMode&&e.length){const i=await S({contentType:t,documents:e,NextCookies:n,CMS_PROJECT_NAME:o,storeId:s});return{status:i.length>0?200:404,data:i??[]}}return{status:e.length?200:404,data:e}}catch(i){return{status:"error",data:[],error:i}}}const P=Object.freeze(Object.defineProperty({__proto__:null,getContentType:D},Symbol.toStringTag,{value:"Module"})),$={checkout:{freightSimulation:j},cms:P};exports.serverAPIs=$;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("yup");function $(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>r[o]})}}return t.default=r,Object.freeze(t)}const e=$(y),O=["allowManualPrice","canEditData","checkedInPickupPointId","clientPreferencesData","clientProfileData","commercialConditionData","giftRegistryData","hooksData","ignoreProfileData","invoiceData","isCheckedIn","itemsOrdination","merchantContextData","purchaseAgentsData","ratesAndBenefitsData","selectableGifts","storeId","storePreferencesData","subscriptionData","userProfileId","userType"],v=(r,t)=>(t.forEach(o=>delete r[o]),r),c=async(r,t={})=>{const{method:o="GET",body:n,headers:s={},skipSanitize:a=!1}=t;try{const i=await fetch(r,{method:o,headers:{...s,Accept:"application/json","Content-Type":"application/json"},...n?{body:JSON.stringify(n)}:{}}).then(d=>d.json()).catch(d=>{console.error("[ERROR FETCH VTEX]",d)});return a?i:v(i,O)}catch(i){throw console.error("[ERROR FETCH ORDER]",i),i}},b=e.object({country:e.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:e.string().nullable()});async function C({apiUrl:r,body:t,fetchOptions:o}){await b.validate(t);const{country:n,postalCode:s}=t;return await c(`${r}/api/checkout/pub/postal-code/${n}/${s}`,{method:"POST",body:t,...o})}const S=e.object({orderFormId:e.string().nullable(),sellerCode:e.string().nullable(),sellerName:e.string().nullable()});async function f({apiUrl:r,body:t,fetchOptions:o}){await S.validate(t);const{orderFormId:n,sellerCode:s,sellerName:a}=t,i=s?`${s.trim()} - ${a}`:null;return c(`${r}/api/checkout/pub/orderForm/${n}/attachments/openTextField`,{method:"POST",body:{value:i},...o})}const j=e.object({orderFormId:e.string().nullable(),sellerCode:e.string().nullable(),marketingData:e.object()});async function I({apiUrl:r,body:t,fetchOptions:o}){await j.validate(t);const{orderFormId:n,sellerCode:s,marketingData:a}=t,i=s?{utmCampaign:s?s.toUpperCase():"",utmiCampaign:s?"codigodavendedora":"semcodigo"}:{};return c(`${r}/api/checkout/pub/orderForm/${n}/attachments/marketingData`,{method:"POST",body:{...a,...i},...o})}const D=e.object({orderFormId:e.string().nullable(),sellerCode:e.string().nullable(),sellerName:e.string().nullable()});async function q({apiUrl:r,body:t,fetchOptions:o}){const n=await f({apiUrl:r,body:t,fetchOptions:o});return I({apiUrl:r,body:{...t,marketingData:n.marketingData},fetchOptions:o})}const P=e.object({orderFormId:e.string().nullable(),coupon:e.string().nullable()});async function T({apiUrl:r,body:t,fetchOptions:o}){await P.validate(t);const{coupon:n="",orderFormId:s}=t;return c(`${r}/api/checkout/pub/orderForm/${s}/coupons`,{method:"POST",body:{text:n},...o})}const k=e.object({appId:e.string().required("App ID is required"),orderFormId:e.string().nullable(),key:e.array().of(e.string())});async function w({apiUrl:r,body:t,fetchOptions:o}){await k.validate(t);const{appId:n="faststore",orderFormId:s,key:a}=t;return c(`${r}/api/checkout/pub/orderForm/${s}/customData/${n}/${a}`,{method:"PUT",...o})}const A=e.object({orderFormId:e.string().nullable()});async function _({apiUrl:r,body:t,fetchOptions:o}){await A.validate(t);const{orderFormId:n}=t;return c(`${r}/api/checkout/pub/orderForm/${n}/items/removeAll`,{method:"POST",...o})}const x=e.object().shape({name:e.string().required("Attachment name is required"),content:e.object().nullable()});var h;const F=e.object().shape({attachments:(h=e.array().of(x))==null?void 0:h.nullable(),id:e.string().required("ID of SKU is required"),index:e.number().integer().nullable(),quantity:e.number().integer().nullable(),seller:e.string().required("Seller is required"),price:e.number().integer()}),R=e.object({orderFormId:e.string().nullable(),orderItems:e.array().of(F)});async function N({apiUrl:r,body:t,fetchOptions:o}){await R.validate(t);const{orderFormId:n,orderItems:s}=t;return c(`${r}/api/checkout/pub/orderForm/${n}/items/update`,{method:"POST",body:{orderItems:s},...o})}const E=e.object({orderFormId:e.string().nullable()});async function M({apiUrl:r,body:t,fetchOptions:o}){await E.validate(t);const{orderFormId:n}=t;return c(`${r}/api/checkout/pub/orderForm/${n}/messages/clear`,{method:"POST",...o})}const U=e.object({id:e.string().nullable(),itemIndex:e.number().nullable(),orderFormId:e.string().nullable(),remove:e.boolean().nullable()});async function G({apiUrl:r,body:t,fetchOptions:o}){await U.validate(t);const{itemIndex:n,orderFormId:s,id:a,remove:i}=t,d=i?`/${a}/remove`:"",m=`${r}/api/checkout/pub/orderForm/${s}/items/${n}/offerings${d}`;return c(m,{method:"POST",body:{id:a},...o})}const z=e.object({orderFormId:e.string().nullable()});async function V({apiUrl:r,body:t,fetchOptions:o,extraData:n}){var i;await z.validate(t);const s=new URLSearchParams({refreshOutdatedData:"true"}),a=t.orderFormId&&((i=n.orderFormPurchaseId)==null?void 0:i.value)!==t.orderFormId?`${r}/api/checkout/pub/orderForm/${t.orderFormId}?${String(s)}`:`${r}/api/checkout/pub/orderForm`;return c(a,{method:"GET",...o})}const B=e.object({orderFormId:e.string().nullable(),email:e.string().email().required(),firstName:e.string().required(),lastName:e.string().required(),documentType:e.string().required(),document:e.string().required(),phone:e.string().matches(/^\+\d{1,3}\d{10,11}$/)});async function K({apiUrl:r,body:t,fetchOptions:o}){await B.validate(t);const{orderFormId:n,...s}=t;return c(`${r}/api/checkout/pub/orderForm/${n}/attachments/clientProfileData`,{method:"POST",body:{...s},...o})}const H=e.object({sellerCode:e.string().nullable()});async function J({apiUrl:r,body:t,fetchOptions:o}){await H.validate(t);const{sellerCode:n=""}=t;return c(`${r}/api/dataentities/VD/search?_fields=id,cod,name,ativo&cod=${n}`,{method:"GET",headers:{Accept:"application/vnd.vtex.ds.v10+json"},...o})}const L=e.object().shape({country:e.string().length(3,"Country code must be 3 characters long").required("Country is required"),orderFormId:e.string().nullable(),postalCode:e.string().nullable()});async function Q({apiUrl:r,body:t,fetchOptions:o}){await L.validate(t);const{country:n,orderFormId:s,postalCode:a}=t,i=a?{address:{addressType:"residential",postalCode:a,country:n}}:{logisticsInfo:[],clearAddressIfPostalCodeNotFound:!0};return c(`${r}/api/checkout/pub/orderForm/${s}/attachments/shippingData`,{method:"POST",body:i,...o})}const X=e.object().shape({orderFormId:e.string().nullable(),options:e.array().of(e.object().shape({itemIndex:e.number(),selectedDeliveryChannel:e.string(),selectedSla:e.string()})),selectedAddresses:e.array().of(e.object().shape({addressId:e.string().required(),addressType:e.string().required(),city:e.string().nullable(),complement:e.string().nullable(),country:e.string().required().length(3),geoCoordinates:e.array().of(e.number()).required().min(0),isDisposable:e.boolean().required(),neighborhood:e.string().nullable(),number:e.string().nullable(),postalCode:e.string().required(),receiverName:e.string().nullable(),reference:e.string().nullable(),state:e.string().nullable(),street:e.string().nullable()}))});async function W({apiUrl:r,body:t,fetchOptions:o}){await X.validate(t);const{orderFormId:n,options:s,selectedAddresses:a}=t;return c(`${r}/api/checkout/pub/orderForm/${n}/attachments/shippingData`,{method:"POST",body:{selectedAddresses:a,clearAddressIfPostalCodeNotFound:!1,logisticsInfo:s},...o})}const Y=e.object({country:e.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:e.string().nullable(),geoCoordinates:e.object().shape({longitude:e.number().required(),latitude:e.number().required()})});async function Z({apiUrl:r,body:t,fetchOptions:o}){await Y.validate(t);const{country:n="",geoCoordinates:s,postalCode:a=""}=t,i=new URLSearchParams({country:String(n)});return a?i.append("postalCode",a):i.append("geoCoordinates",`${s==null?void 0:s.longitude};${s==null?void 0:s.latitude}`),await c(`${r}/api/checkout/pub/regions/?${i.toString()}`,{method:"GET",...o})}const ee=e.object({id:e.string().required("ID of SKU is required"),quantity:e.number().integer().required("Quantity of item is required"),seller:e.string()}),te=e.object({items:e.array().of(ee),country:e.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:e.string().nullable(),geoCoordinates:e.array().nullable().of(e.number()).length(2)});async function re({apiUrl:r,body:t,fetchOptions:o}){return await te.validate(t),c(`${r}/api/checkout/pub/orderForms/simulation`,{method:"POST",body:t,...o})}const oe=Object.freeze(Object.defineProperty({__proto__:null,getMasterDataSellerCode:J,getOrderForm:V,postOrderFormAddCoupon:T,postOrderFormAttachClientProfileData:K,postOrderFormAttachOrderFormData:q,postOrderFormAttachShippingData:Q,postOrderFormAttachmentsMarketingData:I,postOrderFormAttachmentsOpenTextField:f,postOrderFormClearMessages:M,postOrderFormFreightSimulation:re,postOrderFormRegion:Z,postOrderFormRemoveAllItems:_,postOrderFormUpdateItems:N,postOrderFormUpdateShippingData:W,postOrderformAddress:C,putOrderFormCustomData:w,schemaAddress:b,schemaAttachments:D,schemaItem:F,updateOrderFormOffering:G},Symbol.toStringTag,{value:"Module"}));async function ae({contentType:r,documents:t,NextCookies:o,CMS_PROJECT_NAME:n,storeId:s}){var i;const a=JSON.parse(((i=o().get("cms_preview_data"))==null?void 0:i.value)??"{}");if(a&&(a==null?void 0:a.contentType)===r){const d=a.documentId&&a.documentId.length?`/${a.documentId}`:"",m=a!=null&&a.versionId&&(a!=null&&a.versionId.length)?`?versionId=${a==null?void 0:a.versionId}`:"",p=await(await fetch(`https://${s}.myvtex.com/_v/cms/api/${n}/${r}${d}${m}`,{cache:"no-store"})).json(),l=t.filter(u=>p.id!==u.documentId);return l.unshift(p),l}return t}async function ne({contentType:r,NextCookies:t,CMS_PROJECT_NAME:o,storeId:n}){var g,p;const s=JSON.parse(((g=t().get("cms_preview_data"))==null?void 0:g.value)??"{}"),a=[];let i=1,d=0,m=!0;try{do{const u=await(await fetch(`https://${n}.myvtex.com/_v/cms/api/${o}/${r}?page=${i}`)).json();i===1&&(d=u.totalItems),(p=u==null?void 0:u.data)!=null&&p.length&&a.push(...u.data),m=u.hasNextPage,i++}while(m&&a.length<d);if(s.previewMode&&a.length){const l=await ae({contentType:r,documents:a,NextCookies:t,CMS_PROJECT_NAME:o,storeId:n});return{status:l.length>0?200:404,data:l??[]}}return{status:a.length?200:404,data:a}}catch(l){return{status:"error",data:[],error:l}}}const se=Object.freeze(Object.defineProperty({__proto__:null,getContentType:ne},Symbol.toStringTag,{value:"Module"})),ie={checkout:{...oe},cms:se};exports.serverAPIs=ie;
|
package/index2.mjs
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
const
|
|
3
|
-
country: r.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
4
|
-
postalCode: r.string().nullable()
|
|
5
|
-
}), p = [
|
|
1
|
+
import * as e from "yup";
|
|
2
|
+
const y = [
|
|
6
3
|
"allowManualPrice",
|
|
7
4
|
"canEditData",
|
|
8
5
|
"checkedInPickupPointId",
|
|
@@ -24,115 +21,498 @@ const f = r.object({
|
|
|
24
21
|
"subscriptionData",
|
|
25
22
|
"userProfileId",
|
|
26
23
|
"userType"
|
|
27
|
-
],
|
|
28
|
-
const { method: a = "GET", body:
|
|
24
|
+
], $ = (r, t) => (t.forEach((a) => delete r[a]), r), c = async (r, t = {}) => {
|
|
25
|
+
const { method: a = "GET", body: n, headers: s = {}, skipSanitize: o = !1 } = t;
|
|
29
26
|
try {
|
|
30
|
-
const
|
|
27
|
+
const i = await fetch(r, {
|
|
31
28
|
method: a,
|
|
32
29
|
headers: {
|
|
33
|
-
...
|
|
30
|
+
...s,
|
|
34
31
|
Accept: "application/json",
|
|
35
32
|
"Content-Type": "application/json"
|
|
36
33
|
},
|
|
37
|
-
...
|
|
34
|
+
...n ? { body: JSON.stringify(n) } : {}
|
|
38
35
|
// not body in get
|
|
39
|
-
}).then((
|
|
40
|
-
console.error("[ERROR FETCH VTEX]",
|
|
36
|
+
}).then((d) => d.json()).catch((d) => {
|
|
37
|
+
console.error("[ERROR FETCH VTEX]", d);
|
|
41
38
|
});
|
|
42
|
-
return
|
|
43
|
-
} catch (
|
|
44
|
-
throw console.error("[ERROR FETCH ORDER]",
|
|
39
|
+
return o ? i : $(i, y);
|
|
40
|
+
} catch (i) {
|
|
41
|
+
throw console.error("[ERROR FETCH ORDER]", i), i;
|
|
45
42
|
}
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
country:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
}, b = e.object({
|
|
44
|
+
country: e.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
45
|
+
postalCode: e.string().nullable()
|
|
46
|
+
});
|
|
47
|
+
async function v({ apiUrl: r, body: t, fetchOptions: a }) {
|
|
48
|
+
await b.validate(t);
|
|
49
|
+
const { country: n, postalCode: s } = t;
|
|
50
|
+
return await c(
|
|
51
|
+
`${r}/api/checkout/pub/postal-code/${n}/${s}`,
|
|
52
|
+
{
|
|
53
|
+
method: "POST",
|
|
54
|
+
body: t,
|
|
55
|
+
...a
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const O = e.object({
|
|
60
|
+
orderFormId: e.string().nullable(),
|
|
61
|
+
sellerCode: e.string().nullable(),
|
|
62
|
+
sellerName: e.string().nullable()
|
|
63
|
+
});
|
|
64
|
+
async function f({
|
|
65
|
+
apiUrl: r,
|
|
66
|
+
body: t,
|
|
67
|
+
fetchOptions: a
|
|
68
|
+
}) {
|
|
69
|
+
await O.validate(t);
|
|
70
|
+
const { orderFormId: n, sellerCode: s, sellerName: o } = t, i = s ? `${s.trim()} - ${o}` : null;
|
|
71
|
+
return c(
|
|
72
|
+
`${r}/api/checkout/pub/orderForm/${n}/attachments/openTextField`,
|
|
73
|
+
{
|
|
74
|
+
method: "POST",
|
|
75
|
+
body: {
|
|
76
|
+
value: i
|
|
77
|
+
},
|
|
78
|
+
...a
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
const C = e.object({
|
|
83
|
+
orderFormId: e.string().nullable(),
|
|
84
|
+
sellerCode: e.string().nullable(),
|
|
85
|
+
marketingData: e.object()
|
|
86
|
+
});
|
|
87
|
+
async function I({ apiUrl: r, body: t, fetchOptions: a }) {
|
|
88
|
+
await C.validate(t);
|
|
89
|
+
const { orderFormId: n, sellerCode: s, marketingData: o } = t, i = s ? {
|
|
90
|
+
utmCampaign: s ? s.toUpperCase() : "",
|
|
91
|
+
utmiCampaign: s ? "codigodavendedora" : "semcodigo"
|
|
92
|
+
} : {};
|
|
93
|
+
return c(
|
|
94
|
+
`${r}/api/checkout/pub/orderForm/${n}/attachments/marketingData`,
|
|
95
|
+
{
|
|
96
|
+
method: "POST",
|
|
97
|
+
body: {
|
|
98
|
+
...o,
|
|
99
|
+
...i
|
|
100
|
+
},
|
|
101
|
+
...a
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
const S = e.object({
|
|
106
|
+
orderFormId: e.string().nullable(),
|
|
107
|
+
sellerCode: e.string().nullable(),
|
|
108
|
+
sellerName: e.string().nullable()
|
|
109
|
+
});
|
|
110
|
+
async function q({ apiUrl: r, body: t, fetchOptions: a }) {
|
|
111
|
+
const n = await f({ apiUrl: r, body: t, fetchOptions: a });
|
|
112
|
+
return I({
|
|
113
|
+
apiUrl: r,
|
|
114
|
+
body: {
|
|
115
|
+
...t,
|
|
116
|
+
marketingData: n.marketingData
|
|
117
|
+
},
|
|
118
|
+
fetchOptions: a
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const D = e.object({
|
|
122
|
+
orderFormId: e.string().nullable(),
|
|
123
|
+
coupon: e.string().nullable()
|
|
124
|
+
});
|
|
125
|
+
async function j({
|
|
126
|
+
apiUrl: r,
|
|
127
|
+
body: t,
|
|
128
|
+
fetchOptions: a
|
|
129
|
+
}) {
|
|
130
|
+
await D.validate(t);
|
|
131
|
+
const { coupon: n = "", orderFormId: s } = t;
|
|
132
|
+
return c(
|
|
133
|
+
`${r}/api/checkout/pub/orderForm/${s}/coupons`,
|
|
59
134
|
{
|
|
60
135
|
method: "POST",
|
|
61
|
-
body:
|
|
136
|
+
body: { text: n },
|
|
62
137
|
...a
|
|
63
138
|
}
|
|
64
139
|
);
|
|
65
140
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
141
|
+
const k = e.object({
|
|
142
|
+
appId: e.string().required("App ID is required"),
|
|
143
|
+
orderFormId: e.string().nullable(),
|
|
144
|
+
key: e.array().of(e.string())
|
|
145
|
+
});
|
|
146
|
+
async function T({
|
|
147
|
+
apiUrl: r,
|
|
148
|
+
body: t,
|
|
149
|
+
fetchOptions: a
|
|
150
|
+
}) {
|
|
151
|
+
await k.validate(t);
|
|
152
|
+
const { appId: n = "faststore", orderFormId: s, key: o } = t;
|
|
153
|
+
return c(
|
|
154
|
+
`${r}/api/checkout/pub/orderForm/${s}/customData/${n}/${o}`,
|
|
155
|
+
{
|
|
156
|
+
method: "PUT",
|
|
157
|
+
...a
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
const P = e.object({
|
|
162
|
+
orderFormId: e.string().nullable()
|
|
163
|
+
});
|
|
164
|
+
async function w({
|
|
165
|
+
apiUrl: r,
|
|
166
|
+
body: t,
|
|
167
|
+
fetchOptions: a
|
|
168
|
+
}) {
|
|
169
|
+
await P.validate(t);
|
|
170
|
+
const { orderFormId: n } = t;
|
|
171
|
+
return c(
|
|
172
|
+
`${r}/api/checkout/pub/orderForm/${n}/items/removeAll`,
|
|
173
|
+
{
|
|
174
|
+
method: "POST",
|
|
175
|
+
...a
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
const A = e.object().shape({
|
|
180
|
+
name: e.string().required("Attachment name is required"),
|
|
181
|
+
content: e.object().nullable()
|
|
182
|
+
});
|
|
183
|
+
var g;
|
|
184
|
+
const F = e.object().shape({
|
|
185
|
+
attachments: (g = e.array().of(A)) == null ? void 0 : g.nullable(),
|
|
186
|
+
id: e.string().required("ID of SKU is required"),
|
|
187
|
+
index: e.number().integer().nullable(),
|
|
188
|
+
quantity: e.number().integer().nullable(),
|
|
189
|
+
seller: e.string().required("Seller is required"),
|
|
190
|
+
price: e.number().integer()
|
|
191
|
+
}), x = e.object({
|
|
192
|
+
orderFormId: e.string().nullable(),
|
|
193
|
+
orderItems: e.array().of(F)
|
|
194
|
+
});
|
|
195
|
+
async function R({
|
|
196
|
+
apiUrl: r,
|
|
197
|
+
body: t,
|
|
198
|
+
fetchOptions: a
|
|
199
|
+
}) {
|
|
200
|
+
await x.validate(t);
|
|
201
|
+
const { orderFormId: n, orderItems: s } = t;
|
|
202
|
+
return c(
|
|
203
|
+
`${r}/api/checkout/pub/orderForm/${n}/items/update`,
|
|
204
|
+
{
|
|
205
|
+
method: "POST",
|
|
206
|
+
body: { orderItems: s },
|
|
207
|
+
...a
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
const _ = e.object({
|
|
212
|
+
orderFormId: e.string().nullable()
|
|
213
|
+
});
|
|
214
|
+
async function N({
|
|
215
|
+
apiUrl: r,
|
|
216
|
+
body: t,
|
|
217
|
+
fetchOptions: a
|
|
218
|
+
}) {
|
|
219
|
+
await _.validate(t);
|
|
220
|
+
const { orderFormId: n } = t;
|
|
221
|
+
return c(
|
|
222
|
+
`${r}/api/checkout/pub/orderForm/${n}/messages/clear`,
|
|
223
|
+
{
|
|
224
|
+
method: "POST",
|
|
225
|
+
...a
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
const E = e.object({
|
|
230
|
+
id: e.string().nullable(),
|
|
231
|
+
// id offering
|
|
232
|
+
itemIndex: e.number().nullable(),
|
|
233
|
+
orderFormId: e.string().nullable(),
|
|
234
|
+
remove: e.boolean().nullable()
|
|
235
|
+
});
|
|
236
|
+
async function M({ apiUrl: r, body: t, fetchOptions: a }) {
|
|
237
|
+
await E.validate(t);
|
|
238
|
+
const { itemIndex: n, orderFormId: s, id: o, remove: i } = t, d = i ? `/${o}/remove` : "", m = `${r}/api/checkout/pub/orderForm/${s}/items/${n}/offerings${d}`;
|
|
239
|
+
return c(m, {
|
|
240
|
+
method: "POST",
|
|
241
|
+
body: { id: o },
|
|
242
|
+
...a
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
const U = e.object({
|
|
246
|
+
orderFormId: e.string().nullable()
|
|
247
|
+
});
|
|
248
|
+
async function G({
|
|
249
|
+
apiUrl: r,
|
|
250
|
+
body: t,
|
|
251
|
+
fetchOptions: a,
|
|
252
|
+
extraData: n
|
|
253
|
+
}) {
|
|
254
|
+
var i;
|
|
255
|
+
await U.validate(t);
|
|
256
|
+
const s = new URLSearchParams({
|
|
257
|
+
refreshOutdatedData: "true"
|
|
258
|
+
}), o = t.orderFormId && ((i = n.orderFormPurchaseId) == null ? void 0 : i.value) !== t.orderFormId ? `${r}/api/checkout/pub/orderForm/${t.orderFormId}?${String(s)}` : `${r}/api/checkout/pub/orderForm`;
|
|
259
|
+
return c(o, { method: "GET", ...a });
|
|
260
|
+
}
|
|
261
|
+
const V = e.object({
|
|
262
|
+
orderFormId: e.string().nullable(),
|
|
263
|
+
email: e.string().email().required(),
|
|
264
|
+
firstName: e.string().required(),
|
|
265
|
+
lastName: e.string().required(),
|
|
266
|
+
documentType: e.string().required(),
|
|
267
|
+
document: e.string().required(),
|
|
268
|
+
phone: e.string().matches(/^\+\d{1,3}\d{10,11}$/)
|
|
269
|
+
});
|
|
270
|
+
async function z({
|
|
271
|
+
apiUrl: r,
|
|
272
|
+
body: t,
|
|
273
|
+
fetchOptions: a
|
|
274
|
+
}) {
|
|
275
|
+
await V.validate(t);
|
|
276
|
+
const { orderFormId: n, ...s } = t;
|
|
277
|
+
return c(
|
|
278
|
+
`${r}/api/checkout/pub/orderForm/${n}/attachments/clientProfileData`,
|
|
279
|
+
{
|
|
280
|
+
method: "POST",
|
|
281
|
+
body: { ...s },
|
|
282
|
+
...a
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
const B = e.object({
|
|
287
|
+
sellerCode: e.string().nullable()
|
|
288
|
+
});
|
|
289
|
+
async function K({
|
|
290
|
+
apiUrl: r,
|
|
291
|
+
body: t,
|
|
292
|
+
fetchOptions: a
|
|
293
|
+
}) {
|
|
294
|
+
await B.validate(t);
|
|
295
|
+
const { sellerCode: n = "" } = t;
|
|
296
|
+
return c(
|
|
297
|
+
`${r}/api/dataentities/VD/search?_fields=id,cod,name,ativo&cod=${n}`,
|
|
298
|
+
{
|
|
299
|
+
method: "GET",
|
|
300
|
+
headers: {
|
|
301
|
+
Accept: "application/vnd.vtex.ds.v10+json"
|
|
302
|
+
},
|
|
303
|
+
...a
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
const H = e.object().shape({
|
|
308
|
+
country: e.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
309
|
+
orderFormId: e.string().nullable(),
|
|
310
|
+
postalCode: e.string().nullable()
|
|
311
|
+
});
|
|
312
|
+
async function J({
|
|
313
|
+
apiUrl: r,
|
|
314
|
+
body: t,
|
|
315
|
+
fetchOptions: a
|
|
316
|
+
}) {
|
|
317
|
+
await H.validate(t);
|
|
318
|
+
const { country: n, orderFormId: s, postalCode: o } = t, i = o ? {
|
|
319
|
+
address: {
|
|
320
|
+
addressType: "residential",
|
|
321
|
+
postalCode: o,
|
|
322
|
+
country: n
|
|
323
|
+
}
|
|
324
|
+
} : {
|
|
325
|
+
logisticsInfo: [],
|
|
326
|
+
clearAddressIfPostalCodeNotFound: !0
|
|
327
|
+
};
|
|
328
|
+
return c(
|
|
329
|
+
`${r}/api/checkout/pub/orderForm/${s}/attachments/shippingData`,
|
|
330
|
+
{
|
|
331
|
+
method: "POST",
|
|
332
|
+
body: i,
|
|
333
|
+
...a
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
const L = e.object().shape({
|
|
338
|
+
orderFormId: e.string().nullable(),
|
|
339
|
+
options: e.array().of(
|
|
340
|
+
e.object().shape({
|
|
341
|
+
itemIndex: e.number(),
|
|
342
|
+
selectedDeliveryChannel: e.string(),
|
|
343
|
+
selectedSla: e.string()
|
|
344
|
+
})
|
|
345
|
+
),
|
|
346
|
+
selectedAddresses: e.array().of(
|
|
347
|
+
e.object().shape({
|
|
348
|
+
addressId: e.string().required(),
|
|
349
|
+
addressType: e.string().required(),
|
|
350
|
+
city: e.string().nullable(),
|
|
351
|
+
complement: e.string().nullable(),
|
|
352
|
+
country: e.string().required().length(3),
|
|
353
|
+
geoCoordinates: e.array().of(e.number()).required().min(0),
|
|
354
|
+
isDisposable: e.boolean().required(),
|
|
355
|
+
neighborhood: e.string().nullable(),
|
|
356
|
+
number: e.string().nullable(),
|
|
357
|
+
postalCode: e.string().required(),
|
|
358
|
+
receiverName: e.string().nullable(),
|
|
359
|
+
reference: e.string().nullable(),
|
|
360
|
+
state: e.string().nullable(),
|
|
361
|
+
street: e.string().nullable()
|
|
362
|
+
})
|
|
363
|
+
)
|
|
364
|
+
});
|
|
365
|
+
async function Q({ apiUrl: r, body: t, fetchOptions: a }) {
|
|
366
|
+
await L.validate(t);
|
|
367
|
+
const { orderFormId: n, options: s, selectedAddresses: o } = t;
|
|
368
|
+
return c(
|
|
369
|
+
`${r}/api/checkout/pub/orderForm/${n}/attachments/shippingData`,
|
|
370
|
+
{
|
|
371
|
+
method: "POST",
|
|
372
|
+
body: {
|
|
373
|
+
selectedAddresses: o,
|
|
374
|
+
clearAddressIfPostalCodeNotFound: !1,
|
|
375
|
+
logisticsInfo: s
|
|
376
|
+
},
|
|
377
|
+
...a
|
|
378
|
+
}
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
const X = e.object({
|
|
382
|
+
country: e.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
383
|
+
postalCode: e.string().nullable(),
|
|
384
|
+
geoCoordinates: e.object().shape({
|
|
385
|
+
longitude: e.number().required(),
|
|
386
|
+
latitude: e.number().required()
|
|
387
|
+
})
|
|
388
|
+
});
|
|
389
|
+
async function W({ apiUrl: r, body: t, fetchOptions: a }) {
|
|
390
|
+
await X.validate(t);
|
|
391
|
+
const { country: n = "", geoCoordinates: s, postalCode: o = "" } = t, i = new URLSearchParams({ country: String(n) });
|
|
392
|
+
return o ? i.append("postalCode", o) : i.append(
|
|
393
|
+
"geoCoordinates",
|
|
394
|
+
`${s == null ? void 0 : s.longitude};${s == null ? void 0 : s.latitude}`
|
|
395
|
+
), await c(
|
|
396
|
+
`${r}/api/checkout/pub/regions/?${i.toString()}`,
|
|
397
|
+
{
|
|
398
|
+
method: "GET",
|
|
399
|
+
...a
|
|
400
|
+
}
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
const Y = e.object({
|
|
404
|
+
id: e.string().required("ID of SKU is required"),
|
|
405
|
+
quantity: e.number().integer().required("Quantity of item is required"),
|
|
406
|
+
seller: e.string()
|
|
407
|
+
}), Z = e.object({
|
|
408
|
+
items: e.array().of(Y),
|
|
409
|
+
country: e.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
410
|
+
postalCode: e.string().nullable(),
|
|
411
|
+
geoCoordinates: e.array().nullable().of(e.number()).length(2)
|
|
412
|
+
});
|
|
413
|
+
async function ee({ apiUrl: r, body: t, fetchOptions: a }) {
|
|
414
|
+
return await Z.validate(t), c(
|
|
415
|
+
`${r}/api/checkout/pub/orderForms/simulation`,
|
|
416
|
+
{
|
|
417
|
+
method: "POST",
|
|
418
|
+
body: t,
|
|
419
|
+
...a
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
const te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
424
|
+
__proto__: null,
|
|
425
|
+
getMasterDataSellerCode: K,
|
|
426
|
+
getOrderForm: G,
|
|
427
|
+
postOrderFormAddCoupon: j,
|
|
428
|
+
postOrderFormAttachClientProfileData: z,
|
|
429
|
+
postOrderFormAttachOrderFormData: q,
|
|
430
|
+
postOrderFormAttachShippingData: J,
|
|
431
|
+
postOrderFormAttachmentsMarketingData: I,
|
|
432
|
+
postOrderFormAttachmentsOpenTextField: f,
|
|
433
|
+
postOrderFormClearMessages: N,
|
|
434
|
+
postOrderFormFreightSimulation: ee,
|
|
435
|
+
postOrderFormRegion: W,
|
|
436
|
+
postOrderFormRemoveAllItems: w,
|
|
437
|
+
postOrderFormUpdateItems: R,
|
|
438
|
+
postOrderFormUpdateShippingData: Q,
|
|
439
|
+
postOrderformAddress: v,
|
|
440
|
+
putOrderFormCustomData: T,
|
|
441
|
+
schemaAddress: b,
|
|
442
|
+
schemaAttachments: S,
|
|
443
|
+
schemaItem: F,
|
|
444
|
+
updateOrderFormOffering: M
|
|
445
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
446
|
+
async function re({
|
|
447
|
+
contentType: r,
|
|
448
|
+
documents: t,
|
|
69
449
|
NextCookies: a,
|
|
70
|
-
CMS_PROJECT_NAME:
|
|
71
|
-
storeId:
|
|
450
|
+
CMS_PROJECT_NAME: n,
|
|
451
|
+
storeId: s
|
|
72
452
|
}) {
|
|
73
|
-
var
|
|
74
|
-
const
|
|
75
|
-
((
|
|
453
|
+
var i;
|
|
454
|
+
const o = JSON.parse(
|
|
455
|
+
((i = a().get("cms_preview_data")) == null ? void 0 : i.value) ?? "{}"
|
|
76
456
|
);
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
79
|
-
`https://${
|
|
457
|
+
if (o && (o == null ? void 0 : o.contentType) === r) {
|
|
458
|
+
const d = o.documentId && o.documentId.length ? `/${o.documentId}` : "", m = o != null && o.versionId && (o != null && o.versionId.length) ? `?versionId=${o == null ? void 0 : o.versionId}` : "", p = await (await fetch(
|
|
459
|
+
`https://${s}.myvtex.com/_v/cms/api/${n}/${r}${d}${m}`,
|
|
80
460
|
{ cache: "no-store" }
|
|
81
|
-
)).json(),
|
|
82
|
-
(
|
|
461
|
+
)).json(), l = t.filter(
|
|
462
|
+
(u) => p.id !== u.documentId
|
|
83
463
|
);
|
|
84
|
-
return
|
|
464
|
+
return l.unshift(p), l;
|
|
85
465
|
}
|
|
86
|
-
return
|
|
466
|
+
return t;
|
|
87
467
|
}
|
|
88
|
-
async function
|
|
89
|
-
contentType:
|
|
90
|
-
NextCookies:
|
|
468
|
+
async function oe({
|
|
469
|
+
contentType: r,
|
|
470
|
+
NextCookies: t,
|
|
91
471
|
CMS_PROJECT_NAME: a,
|
|
92
|
-
storeId:
|
|
472
|
+
storeId: n
|
|
93
473
|
}) {
|
|
94
|
-
var
|
|
95
|
-
const
|
|
96
|
-
((
|
|
97
|
-
),
|
|
98
|
-
let
|
|
474
|
+
var h, p;
|
|
475
|
+
const s = JSON.parse(
|
|
476
|
+
((h = t().get("cms_preview_data")) == null ? void 0 : h.value) ?? "{}"
|
|
477
|
+
), o = [];
|
|
478
|
+
let i = 1, d = 0, m = !0;
|
|
99
479
|
try {
|
|
100
480
|
do {
|
|
101
|
-
const
|
|
102
|
-
`https://${
|
|
481
|
+
const u = await (await fetch(
|
|
482
|
+
`https://${n}.myvtex.com/_v/cms/api/${a}/${r}?page=${i}`
|
|
103
483
|
)).json();
|
|
104
|
-
|
|
105
|
-
} while (
|
|
106
|
-
if (
|
|
107
|
-
const
|
|
108
|
-
contentType:
|
|
109
|
-
documents:
|
|
110
|
-
NextCookies:
|
|
484
|
+
i === 1 && (d = u.totalItems), (p = u == null ? void 0 : u.data) != null && p.length && o.push(...u.data), m = u.hasNextPage, i++;
|
|
485
|
+
} while (m && o.length < d);
|
|
486
|
+
if (s.previewMode && o.length) {
|
|
487
|
+
const l = await re({
|
|
488
|
+
contentType: r,
|
|
489
|
+
documents: o,
|
|
490
|
+
NextCookies: t,
|
|
111
491
|
CMS_PROJECT_NAME: a,
|
|
112
|
-
storeId:
|
|
492
|
+
storeId: n
|
|
113
493
|
});
|
|
114
494
|
return {
|
|
115
|
-
status:
|
|
116
|
-
data:
|
|
495
|
+
status: l.length > 0 ? 200 : 404,
|
|
496
|
+
data: l ?? []
|
|
117
497
|
};
|
|
118
498
|
}
|
|
119
499
|
return {
|
|
120
|
-
status:
|
|
121
|
-
data:
|
|
500
|
+
status: o.length ? 200 : 404,
|
|
501
|
+
data: o
|
|
122
502
|
};
|
|
123
|
-
} catch (
|
|
124
|
-
return { status: "error", data: [], error:
|
|
503
|
+
} catch (l) {
|
|
504
|
+
return { status: "error", data: [], error: l };
|
|
125
505
|
}
|
|
126
506
|
}
|
|
127
|
-
const
|
|
507
|
+
const ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
128
508
|
__proto__: null,
|
|
129
|
-
getContentType:
|
|
130
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
509
|
+
getContentType: oe
|
|
510
|
+
}, Symbol.toStringTag, { value: "Module" })), ne = {
|
|
131
511
|
checkout: {
|
|
132
|
-
|
|
512
|
+
...te
|
|
133
513
|
},
|
|
134
|
-
cms:
|
|
514
|
+
cms: ae
|
|
135
515
|
};
|
|
136
516
|
export {
|
|
137
|
-
|
|
517
|
+
ne as serverAPIs
|
|
138
518
|
};
|
package/layout/index.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ export declare const layout: {
|
|
|
75
75
|
displayName: string;
|
|
76
76
|
};
|
|
77
77
|
BackToTop: ({ children, className, adornment, iconPosition, scrollToOptions, style, ...props }: import('../types/layout/team-components/BackToTop').BackToTopProps) => import("react/jsx-runtime").JSX.Element;
|
|
78
|
+
BuyPackage: ({ CONSTANTS, inView, products, innerRef, WishListToggle }: import('../types/layout/team-components/BuyPackage').BuyPackageProps) => import("react/jsx-runtime").JSX.Element;
|
|
78
79
|
};
|
|
79
80
|
template: {
|
|
80
81
|
pdp: typeof pdp;
|